From 42f2b7003cae200764dabf6563bf58ab8b6d032a Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Wed, 8 Nov 2023 17:57:52 -0600 Subject: [PATCH] Fixing missing files from repo. --- .gitattributes | 1 + .gitignore | 2 +- INSTALL.txt | 32 - build-all.sh | 13 +- thirdparty/SDL2_image/.gitmodules | 32 - thirdparty/SDL2_image/CMakeLists.txt | 2 - .../SDL2_image/VisualC/SDL_image.vcxproj | 8 +- .../VisualC/external/include/tiff.h | 1380 +- .../VisualC/external/include/tiffconf.h | 57 +- .../VisualC/external/include/tiffio.h | 833 +- .../VisualC/external/include/tiffvers.h | 25 +- .../external/optional/x64/libtiff-5.dll | 3 + .../external/optional/x64/libtiff-6.dll | Bin 403456 -> 0 bytes .../external/optional/x86/libtiff-5.dll | 3 + .../external/optional/x86/libtiff-6.dll | Bin 399360 -> 0 bytes thirdparty/SDL2_image/configure | 43 +- thirdparty/SDL2_image/configure.ac | 43 +- .../SDL2_image/external/Get-GitModules.ps1 | 36 + .../SDL2_image/external/libjxl/.gitmodules | 23 - .../libjxl/third_party/brotli/.gitmodules | 6 - .../libjxl/third_party/skcms/build/android | 18 + .../third_party/skcms/build/android-arm | 18 + .../third_party/skcms/build/android-arm.lsan | 4 + .../skcms/build/android-arm.neon-vfpv4 | 3 + .../skcms/build/android-arm.neon-vfpv4-O3 | 3 + .../skcms/build/android-arm.portable | 3 + .../third_party/skcms/build/android-arm.tiny | 3 + .../third_party/skcms/build/android-arm.vfpv2 | 3 + .../third_party/skcms/build/android.fp16 | 3 + .../third_party/skcms/build/android.lsan | 4 + .../third_party/skcms/build/android.nofp16 | 3 + .../third_party/skcms/build/android.portable | 3 + .../third_party/skcms/build/android.tiny | 3 + .../libjxl/third_party/skcms/build/clang | 7 + .../libjxl/third_party/skcms/build/clang.O0 | 3 + .../third_party/skcms/build/clang.avx512 | 5 + .../libjxl/third_party/skcms/build/clang.lsan | 4 + .../libjxl/third_party/skcms/build/clang.m32 | 6 + .../third_party/skcms/build/clang.m32-O0 | 7 + .../libjxl/third_party/skcms/build/clang.msan | 6 + .../third_party/skcms/build/clang.native | 3 + .../third_party/skcms/build/clang.portable | 3 + .../libjxl/third_party/skcms/build/clang.sse2 | 4 + .../third_party/skcms/build/clang.sse41 | 4 + .../libjxl/third_party/skcms/build/clang.tiny | 3 + .../libjxl/third_party/skcms/build/clang.xsan | 4 + .../skcms/build/clang.xsan-portable | 4 + .../libjxl/third_party/skcms/build/common | 35 + .../libjxl/third_party/skcms/build/emscripten | 19 + .../third_party/skcms/build/emscripten.simd | 5 + .../libjxl/third_party/skcms/build/gcc | 9 + .../libjxl/third_party/skcms/build/gcc.O0 | 3 + .../libjxl/third_party/skcms/build/gcc.m32 | 4 + .../libjxl/third_party/skcms/build/gcc.m32-O0 | 4 + .../third_party/skcms/build/gcc.mips64el | 16 + .../third_party/skcms/build/gcc.mips64el-O3 | 16 + .../libjxl/third_party/skcms/build/gcc.musl | 6 + .../libjxl/third_party/skcms/build/gcc.native | 3 + .../third_party/skcms/build/gcc.portable | 3 + .../libjxl/third_party/skcms/build/gcc.tiny | 3 + .../libjxl/third_party/skcms/build/gcc.xsan | 4 + .../libjxl/third_party/skcms/build/ios | 11 + .../third_party/skcms/build/ios.portable | 3 + .../libjxl/third_party/skcms/build/ios.tiny | 3 + .../libjxl/third_party/skcms/build/ios.xsan | 7 + .../libjxl/third_party/skcms/build/local | 3 + .../libjxl/third_party/skcms/build/msvs | 27 + .../third_party/skcms/build/msvs.analyze | 4 + .../libjxl/third_party/skcms/build/msvs.clang | 5 + .../third_party/skcms/build/msvs.clang-fast | 6 + .../libjxl/third_party/skcms/build/msvs.fast | 3 + .../libjxl/third_party/skcms/build/targets | 30 + .../SDL2_image/external/libtiff/.appveyor.yml | 40 +- .../SDL2_image/external/libtiff/.clang-format | 6 - .../external/libtiff/.git-blame-ignore-revs | 4 - .../SDL2_image/external/libtiff/.gitignore | 7 +- .../external/libtiff/.gitlab-ci.yml | 43 +- .../external/libtiff/.pre-commit-config.yaml | 22 - .../SDL2_image/external/libtiff/.travis.yml | 29 + .../external/libtiff/CMakeLists.txt | 841 +- .../external/libtiff/CONTRIBUTING.md | 19 - .../libtiff/{LICENSE.md => COPYRIGHT} | 6 +- .../SDL2_image/external/libtiff/ChangeLog | 4457 +--- .../SDL2_image/external/libtiff/HOWTO-RELEASE | 25 +- .../SDL2_image/external/libtiff/Makefile.am | 18 +- .../{cmake/SymbolChecks.cmake => Makefile.vc} | 67 +- .../SDL2_image/external/libtiff/RELEASE-DATE | 2 +- .../SDL2_image/external/libtiff/SConstruct | 169 + .../SDL2_image/external/libtiff/VERSION | 2 +- .../external/libtiff/archive/tools/bmp2tiff.c | 1573 +- .../external/libtiff/archive/tools/gif2tiff.c | 629 +- .../external/libtiff/archive/tools/ras2tiff.c | 589 +- .../libtiff/archive/tools/rasterfile.h | 45 +- .../external/libtiff/archive/tools/sgi2tiff.c | 567 +- .../external/libtiff/archive/tools/sgisv.c | 514 +- .../external/libtiff/archive/tools/ycbcr.c | 178 +- .../SDL2_image/external/libtiff/autogen.sh | 23 +- .../CXXLibrary.cmake => build/CMakeLists.txt} | 11 +- .../LERCCodec.cmake => build/Makefile.am} | 36 +- .../SDL2_image/external/libtiff/build/README | 3 + .../external/libtiff/build/gitlab-ci | 82 + .../external/libtiff/build/travis-ci | 109 + .../libtiff/cmake/AutotoolsCompat.cmake | 32 - .../libtiff/cmake/AutotoolsVersion.cmake | 50 - .../libtiff/cmake/CompilerChecks.cmake | 124 - .../external/libtiff/cmake/DeflateCodec.cmake | 45 - .../external/libtiff/cmake/FindCMath.cmake | 72 - .../external/libtiff/cmake/FindDeflate.cmake | 115 - .../external/libtiff/cmake/FindJBIG.cmake | 116 - .../external/libtiff/cmake/FindJPEG.cmake | 142 - .../external/libtiff/cmake/FindLERC.cmake | 100 - .../external/libtiff/cmake/FindWebP.cmake | 91 - .../external/libtiff/cmake/FindZSTD.cmake | 107 - .../external/libtiff/cmake/Findliblzma.cmake | 126 - .../libtiff/cmake/IncludeChecks.cmake | 36 - .../external/libtiff/cmake/JPEGCodec.cmake | 84 - .../libtiff/cmake/LibraryFeatures.cmake | 62 - .../external/libtiff/cmake/OpenGLChecks.cmake | 50 - .../libtiff/cmake/PixarLogCodec.cmake | 33 - .../external/libtiff/cmake/PkgConfig.cmake | 69 - .../external/libtiff/cmake/Release.cmake | 31 - .../external/libtiff/cmake/Sphinx.cmake | 93 - .../cmake/SphinxCheckInternalLinks.cmake | 87 - .../libtiff/cmake/TiffConfig.cmake.in | 6 - .../libtiff/cmake/TypeSizeChecks.cmake | 54 - .../external/libtiff/cmake/ZSTDCodec.cmake | 66 - .../cmake/list-manpage-dependencies.py | 28 - .../external/libtiff/cmake/list-manpages.py | 31 - .../SDL2_image/external/libtiff/configure.ac | 549 +- .../SDL2_image/external/libtiff/configure.com | 1356 ++ .../external/libtiff/contrib/CMakeLists.txt | 8 + .../libtiff/contrib/addtiffo/CMakeLists.txt | 10 +- .../libtiff/contrib/addtiffo/Makefile.am | 3 +- .../libtiff/contrib/addtiffo/Makefile.vc | 28 + .../libtiff/contrib/addtiffo/addtiffo.c | 107 +- .../libtiff/contrib/addtiffo/tif_overview.c | 922 +- .../libtiff/contrib/addtiffo/tif_ovrcache.c | 378 +- .../libtiff/contrib/addtiffo/tif_ovrcache.h | 90 +- .../libtiff/contrib/dbs/CMakeLists.txt | 16 +- .../external/libtiff/contrib/dbs/Makefile.am | 2 - .../external/libtiff/contrib/dbs/tiff-bi.c | 25 +- .../libtiff/contrib/dbs/tiff-grayscale.c | 85 +- .../libtiff/contrib/dbs/tiff-palette.c | 355 +- .../external/libtiff/contrib/dbs/tiff-rgb.c | 219 +- .../dbs/xtiff/CMakeLists.txt} | 15 +- .../libtiff/contrib/dbs/xtiff/Makefile.am | 1 + .../libtiff/contrib/dbs/xtiff/patchlevel.h | 7 + .../libtiff/contrib/dbs/xtiff/xtiff.c | 1277 +- .../libtiff/contrib/dbs/xtiff/xtifficon.h | 29 +- .../libtiff/contrib/iptcutil/CMakeLists.txt | 11 +- .../libtiff/contrib/iptcutil/Makefile.am | 2 - .../libtiff/contrib/iptcutil/iptcutil.c | 1298 +- .../mfs/CMakeLists.txt} | 16 +- .../external/libtiff/contrib/mfs/Makefile.am | 1 + .../external/libtiff/contrib/mfs/mfs_file.c | 165 +- .../libtiff/contrib/oss-fuzz/build.sh | 79 + .../contrib/oss-fuzz/tiff_read_rgba_fuzzer.cc | 164 +- .../libtiff/contrib/pds/CMakeLists.txt | 30 + .../external/libtiff/contrib/pds/Makefile.am | 1 + .../libtiff/contrib/pds/tif_imageiter.c | 675 +- .../libtiff/contrib/pds/tif_imageiter.h | 91 +- .../libtiff/contrib/pds/tif_pdsdirread.c | 1791 +- .../libtiff/contrib/pds/tif_pdsdirwrite.c | 1504 +- .../libtiff/contrib/ras/CMakeLists.txt | 28 + .../external/libtiff/contrib/ras/Makefile.am | 1 + .../external/libtiff/contrib/ras/ras2tif.c | 246 +- .../external/libtiff/contrib/ras/tif2ras.c | 447 +- .../libtiff/contrib/stream/CMakeLists.txt | 28 + .../libtiff/contrib/stream/Makefile.am | 1 + .../libtiff/contrib/stream/tiffstream.cpp | 316 +- .../libtiff/contrib/stream/tiffstream.h | 82 +- .../tags/CMakeLists.txt} | 20 +- .../external/libtiff/contrib/tags/Makefile.am | 1 + .../external/libtiff/contrib/tags/README | 2 +- .../external/libtiff/contrib/tags/listtif.c | 49 +- .../external/libtiff/contrib/tags/maketif.c | 88 +- .../external/libtiff/contrib/tags/xtif_dir.c | 497 +- .../external/libtiff/contrib/tags/xtiffio.h | 31 +- .../external/libtiff/contrib/tags/xtiffiop.h | 53 +- .../libtiff/contrib/win_dib/CMakeLists.txt | 30 + .../libtiff/contrib/win_dib/Makefile.am | 1 + .../libtiff/contrib/win_dib/README.Tiffile | 2 +- .../libtiff/contrib/win_dib/README.tiff2dib | 4 +- .../libtiff/contrib/win_dib/Tiffile.cpp | 399 +- .../libtiff/contrib/win_dib/tiff2dib.c | 480 +- .../external/libtiff/doc/CMakeLists.txt | 146 - .../external/libtiff/doc/Makefile.am | 274 - .../external/libtiff/doc/_static/.gitignore | 0 .../external/libtiff/doc/addingtags.rst | 316 - .../SDL2_image/external/libtiff/doc/conf.py | 177 - .../external/libtiff/doc/contrib.rst | 88 - .../external/libtiff/doc/functions.rst | 66 - .../doc/functions/TIFFAccessTagMethods.rst | 30 - .../libtiff/doc/functions/TIFFClientInfo.rst | 40 - .../libtiff/doc/functions/TIFFClose.rst | 42 - .../doc/functions/TIFFCreateDirectory.rst | 79 - .../doc/functions/TIFFCustomDirectory.rst | 207 - .../doc/functions/TIFFCustomTagList.rst | 47 - .../libtiff/doc/functions/TIFFDataWidth.rst | 47 - .../functions/TIFFDeferStrileArrayWriting.rst | 67 - .../libtiff/doc/functions/TIFFError.rst | 102 - .../doc/functions/TIFFFieldDataType.rst | 32 - .../libtiff/doc/functions/TIFFFieldName.rst | 31 - .../doc/functions/TIFFFieldPassCount.rst | 42 - .../libtiff/doc/functions/TIFFFieldQuery.rst | 78 - .../doc/functions/TIFFFieldReadCount.rst | 43 - .../libtiff/doc/functions/TIFFFieldTag.rst | 34 - .../doc/functions/TIFFFieldWriteCount.rst | 48 - .../libtiff/doc/functions/TIFFFlush.rst | 50 - .../libtiff/doc/functions/TIFFGetField.rst | 490 - .../doc/functions/TIFFMergeFieldInfo.rst | 34 - .../libtiff/doc/functions/TIFFOpen.rst | 330 - .../libtiff/doc/functions/TIFFOpenOptions.rst | 69 - .../doc/functions/TIFFPrintDirectory.rst | 58 - .../doc/functions/TIFFProcFunctions.rst | 57 - .../libtiff/doc/functions/TIFFRGBAImage.rst | 234 - .../doc/functions/TIFFReadDirectory.rst | 146 - .../doc/functions/TIFFReadEncodedStrip.rst | 57 - .../doc/functions/TIFFReadEncodedTile.rst | 57 - .../doc/functions/TIFFReadFromUserBuffer.rst | 46 - .../doc/functions/TIFFReadRGBAImage.rst | 173 - .../doc/functions/TIFFReadRGBAStrip.rst | 139 - .../doc/functions/TIFFReadRGBATile.rst | 141 - .../doc/functions/TIFFReadRawStrip.rst | 43 - .../libtiff/doc/functions/TIFFReadRawTile.rst | 45 - .../doc/functions/TIFFReadScanline.rst | 75 - .../libtiff/doc/functions/TIFFReadTile.rst | 57 - .../doc/functions/TIFFSetDirectory.rst | 71 - .../libtiff/doc/functions/TIFFSetField.rst | 402 - .../doc/functions/TIFFSetTagExtender.rst | 33 - .../libtiff/doc/functions/TIFFStrileQuery.rst | 75 - .../libtiff/doc/functions/TIFFWarning.rst | 101 - .../doc/functions/TIFFWriteDirectory.rst | 140 - .../doc/functions/TIFFWriteEncodedStrip.rst | 80 - .../doc/functions/TIFFWriteEncodedTile.rst | 76 - .../doc/functions/TIFFWriteRawStrip.rst | 75 - .../doc/functions/TIFFWriteRawTile.rst | 67 - .../doc/functions/TIFFWriteScanline.rst | 124 - .../libtiff/doc/functions/TIFFWriteTile.rst | 51 - .../libtiff/doc/functions/TIFFbuffer.rst | 57 - .../libtiff/doc/functions/TIFFcodec.rst | 75 - .../libtiff/doc/functions/TIFFcolor.rst | 211 - .../libtiff/doc/functions/TIFFmemory.rst | 61 - .../libtiff/doc/functions/TIFFquery.rst | 131 - .../libtiff/doc/functions/TIFFsize.rst | 51 - .../libtiff/doc/functions/TIFFstrip.rst | 94 - .../libtiff/doc/functions/TIFFswab.rst | 78 - .../libtiff/doc/functions/TIFFtile.rst | 93 - .../doc/functions/_TIFFRewriteField.rst | 33 - .../libtiff/doc/functions/_TIFFauxiliary.rst | 34 - .../libtiff/doc/functions/libtiff.rst | 843 - .../external/libtiff/doc/images.rst | 22 - .../SDL2_image/external/libtiff/doc/index.rst | 66 - .../external/libtiff/doc/internals.rst | 464 - .../external/libtiff/doc/libtiff.rst | 681 - .../external/libtiff/doc/multi_page.rst | 213 - .../libtiff/doc/project/acknowledgements.rst | 102 - .../external/libtiff/doc/project/bugs.rst | 49 - .../external/libtiff/doc/project/index.rst | 26 - .../external/libtiff/doc/project/license.rst | 24 - .../libtiff/doc/project/mailinglist.rst | 27 - .../libtiff/doc/releases/historical.rst | 48 - .../external/libtiff/doc/releases/index.rst | 28 - .../libtiff/doc/releases/v3.4beta007.rst | 75 - .../libtiff/doc/releases/v3.4beta016.rst | 71 - .../libtiff/doc/releases/v3.4beta018.rst | 50 - .../libtiff/doc/releases/v3.4beta024.rst | 99 - .../libtiff/doc/releases/v3.4beta028.rst | 105 - .../libtiff/doc/releases/v3.4beta029.rst | 52 - .../libtiff/doc/releases/v3.4beta031.rst | 59 - .../libtiff/doc/releases/v3.4beta032.rst | 53 - .../libtiff/doc/releases/v3.4beta033.rst | 45 - .../libtiff/doc/releases/v3.4beta034.rst | 37 - .../libtiff/doc/releases/v3.4beta035.rst | 32 - .../libtiff/doc/releases/v3.4beta036.rst | 86 - .../external/libtiff/doc/releases/v3.5.1.rst | 41 - .../external/libtiff/doc/releases/v3.5.2.rst | 74 - .../external/libtiff/doc/releases/v3.5.3.rst | 97 - .../external/libtiff/doc/releases/v3.5.4.rst | 45 - .../external/libtiff/doc/releases/v3.5.5.rst | 91 - .../libtiff/doc/releases/v3.5.6beta.rst | 135 - .../external/libtiff/doc/releases/v3.5.7.rst | 219 - .../external/libtiff/doc/releases/v3.6.0.rst | 372 - .../external/libtiff/doc/releases/v3.6.1.rst | 135 - .../external/libtiff/doc/releases/v3.7.0.rst | 78 - .../libtiff/doc/releases/v3.7.0alpha.rst | 179 - .../libtiff/doc/releases/v3.7.0beta.rst | 98 - .../libtiff/doc/releases/v3.7.0beta2.rst | 69 - .../external/libtiff/doc/releases/v3.7.1.rst | 160 - .../external/libtiff/doc/releases/v3.7.2.rst | 142 - .../external/libtiff/doc/releases/v3.7.3.rst | 169 - .../external/libtiff/doc/releases/v3.7.4.rst | 84 - .../external/libtiff/doc/releases/v3.8.0.rst | 140 - .../external/libtiff/doc/releases/v3.8.1.rst | 147 - .../external/libtiff/doc/releases/v3.8.2.rst | 76 - .../external/libtiff/doc/releases/v3.9.0.rst | 203 - .../libtiff/doc/releases/v3.9.0beta.rst | 225 - .../external/libtiff/doc/releases/v3.9.1.rst | 63 - .../external/libtiff/doc/releases/v3.9.2.rst | 67 - .../external/libtiff/doc/releases/v3.9.3.rst | 105 - .../external/libtiff/doc/releases/v3.9.4.rst | 69 - .../external/libtiff/doc/releases/v3.9.5.rst | 217 - .../external/libtiff/doc/releases/v4.0.0.rst | 213 - .../external/libtiff/doc/releases/v4.0.1.rst | 60 - .../external/libtiff/doc/releases/v4.0.10.rst | 239 - .../external/libtiff/doc/releases/v4.0.2.rst | 64 - .../external/libtiff/doc/releases/v4.0.3.rst | 68 - .../external/libtiff/doc/releases/v4.0.4.rst | 191 - .../libtiff/doc/releases/v4.0.4beta.rst | 236 - .../external/libtiff/doc/releases/v4.0.5.rst | 85 - .../external/libtiff/doc/releases/v4.0.6.rst | 77 - .../external/libtiff/doc/releases/v4.0.7.rst | 350 - .../external/libtiff/doc/releases/v4.0.8.rst | 390 - .../external/libtiff/doc/releases/v4.0.9.rst | 317 - .../external/libtiff/doc/releases/v4.1.0.rst | 98 - .../external/libtiff/doc/releases/v4.2.0.rst | 103 - .../external/libtiff/doc/releases/v4.3.0.rst | 85 - .../external/libtiff/doc/releases/v4.4.0.rst | 98 - .../external/libtiff/doc/releases/v4.5.0.rst | 142 - .../external/libtiff/doc/releases/v4.5.1.rst | 177 - .../libtiff/doc/specification/bigtiff.rst | 90 - .../doc/specification/coverage-bigtiff.rst | 58 - .../libtiff/doc/specification/coverage.rst | 1690 -- .../libtiff/doc/specification/index.rst | 38 - .../SDL2_image/external/libtiff/doc/terms.rst | 79 - .../SDL2_image/external/libtiff/doc/tools.rst | 155 - .../external/libtiff/doc/tools/fax2ps.rst | 129 - .../external/libtiff/doc/tools/fax2tiff.rst | 246 - .../external/libtiff/doc/tools/pal2rgb.rst | 80 - .../external/libtiff/doc/tools/ppm2tiff.rst | 56 - .../external/libtiff/doc/tools/raw2tiff.rst | 143 - .../external/libtiff/doc/tools/rgb2ycbcr.rst | 63 - .../external/libtiff/doc/tools/thumbnail.rst | 66 - .../external/libtiff/doc/tools/tiff2bw.rst | 60 - .../external/libtiff/doc/tools/tiff2pdf.rst | 211 - .../external/libtiff/doc/tools/tiff2ps.rst | 251 - .../external/libtiff/doc/tools/tiff2rgba.rst | 72 - .../external/libtiff/doc/tools/tiffcmp.rst | 59 - .../external/libtiff/doc/tools/tiffcp.rst | 255 - .../external/libtiff/doc/tools/tiffcrop.rst | 547 - .../external/libtiff/doc/tools/tiffdither.rst | 93 - .../external/libtiff/doc/tools/tiffdump.rst | 52 - .../external/libtiff/doc/tools/tiffgt.rst | 186 - .../external/libtiff/doc/tools/tiffinfo.rst | 65 - .../external/libtiff/doc/tools/tiffmedian.rst | 73 - .../external/libtiff/doc/tools/tiffset.rst | 82 - .../external/libtiff/doc/tools/tiffsplit.rst | 52 - .../libtiff/html/BigTIFFProposal.html | 99 + .../JBIGCodec.cmake => html/CMakeLists.txt} | 82 +- .../external/libtiff/html/Makefile.am | 99 + .../technote2.rst => html/TIFFTechNote2.html} | 449 +- .../external/libtiff/html/addingtags.html | 297 + .../external/libtiff/html/bigtiffdesign.html | 81 + .../external/libtiff/html/bigtiffpr.html | 77 + .../bigtiffpr_images/esri.png | 0 .../bigtiffpr_images/leica.png | 0 .../bigtiffpr_images/safe.png | 0 .../bigtiffpr_images/weogeo.png | 0 .../external/libtiff/html/bugs.html | 67 + .../external/libtiff/html/build.html | 737 + .../external/libtiff/html/contrib.html | 212 + .../external/libtiff/html/document.html | 57 + .../external/libtiff/html/images.html | 46 + .../images/CMakeLists.txt} | 30 +- .../images/Makefile.am} | 51 +- .../libtiff/{doc => html}/images/back.gif | 0 .../libtiff/{doc => html}/images/bali.jpg | 0 .../libtiff/{doc => html}/images/cat.gif | 0 .../libtiff/{doc => html}/images/cover.jpg | 0 .../libtiff/{doc => html}/images/cramps.gif | 0 .../libtiff/{doc => html}/images/dave.gif | 0 .../libtiff/{doc => html}/images/info.gif | 0 .../libtiff/{doc => html}/images/jello.jpg | 0 .../libtiff/{doc => html}/images/jim.gif | 0 .../libtiff/{doc => html}/images/note.gif | 0 .../libtiff/{doc => html}/images/oxford.gif | 0 .../libtiff/{doc => html}/images/quad.jpg | 0 .../libtiff/{doc => html}/images/ring.gif | 0 .../libtiff/{doc => html}/images/smallliz.jpg | 0 .../libtiff/{doc => html}/images/strike.gif | 0 .../libtiff/{doc => html}/images/warning.gif | 0 .../external/libtiff/html/index.html | 120 + .../external/libtiff/html/internals.html | 583 + .../external/libtiff/html/intro.html | 73 + .../external/libtiff/html/libtiff.html | 747 + .../external/libtiff/html/man/CMakeLists.txt | 108 + .../man/HtmlDoc.cmake} | 48 +- .../external/libtiff/html/man/Makefile.am | 122 + .../libtiff/html/man/TIFFClose.3tiff.html | 87 + .../libtiff/html/man/TIFFDataWidth.3tiff.html | 98 + .../libtiff/html/man/TIFFError.3tiff.html | 106 + .../html/man/TIFFFieldDataType.3tiff.html | 89 + .../libtiff/html/man/TIFFFieldName.3tiff.html | 86 + .../html/man/TIFFFieldPassCount.3tiff.html | 98 + .../html/man/TIFFFieldReadCount.3tiff.html | 101 + .../libtiff/html/man/TIFFFieldTag.3tiff.html | 88 + .../html/man/TIFFFieldWriteCount.3tiff.html | 108 + .../libtiff/html/man/TIFFFlush.3tiff.html | 113 + .../libtiff/html/man/TIFFGetField.3tiff.html | 1969 ++ .../libtiff/html/man/TIFFOpen.3tiff.html | 421 + .../html/man/TIFFPrintDirectory.3tiff.html | 225 + .../libtiff/html/man/TIFFRGBAImage.3tiff.html | 319 + .../html/man/TIFFReadDirectory.3tiff.html | 218 + .../html/man/TIFFReadEncodedStrip.3tiff.html | 133 + .../html/man/TIFFReadEncodedTile.3tiff.html | 130 + .../html/man/TIFFReadRGBAImage.3tiff.html | 301 + .../html/man/TIFFReadRGBAStrip.3tiff.html | 208 + .../html/man/TIFFReadRGBATile.3tiff.html | 261 + .../html/man/TIFFReadRawStrip.3tiff.html | 109 + .../html/man/TIFFReadRawTile.3tiff.html | 111 + .../html/man/TIFFReadScanline.3tiff.html | 157 + .../libtiff/html/man/TIFFReadTile.3tiff.html | 133 + .../html/man/TIFFSetDirectory.3tiff.html | 122 + .../libtiff/html/man/TIFFSetField.3tiff.html | 1865 ++ .../libtiff/html/man/TIFFWarning.3tiff.html | 108 + .../html/man/TIFFWriteDirectory.3tiff.html | 176 + .../html/man/TIFFWriteEncodedStrip.3tiff.html | 153 + .../html/man/TIFFWriteEncodedTile.3tiff.html | 147 + .../html/man/TIFFWriteRawStrip.3tiff.html | 144 + .../html/man/TIFFWriteRawTile.3tiff.html | 128 + .../html/man/TIFFWriteScanline.3tiff.html | 206 + .../libtiff/html/man/TIFFWriteTile.3tiff.html | 115 + .../libtiff/html/man/TIFFbuffer.3tiff.html | 116 + .../libtiff/html/man/TIFFcodec.3tiff.html | 116 + .../libtiff/html/man/TIFFcolor.3tiff.html | 975 + .../libtiff/html/man/TIFFmemory.3tiff.html | 110 + .../libtiff/html/man/TIFFquery.3tiff.html | 148 + .../libtiff/html/man/TIFFsize.3tiff.html | 95 + .../libtiff/html/man/TIFFstrip.3tiff.html | 129 + .../libtiff/html/man/TIFFswab.3tiff.html | 110 + .../libtiff/html/man/TIFFtile.3tiff.html | 141 + .../external/libtiff/html/man/fax2ps.1.html | 252 + .../external/libtiff/html/man/fax2tiff.1.html | 607 + .../external/libtiff/html/man/index.html | 64 + .../libtiff/html/man/libtiff.3tiff.html | 1150 + .../external/libtiff/html/man/pal2rgb.1.html | 189 + .../external/libtiff/html/man/ppm2tiff.1.html | 141 + .../external/libtiff/html/man/raw2tiff.1.html | 510 + .../libtiff/html/man/rgb2ycbcr.1.html | 155 + .../libtiff/html/man/thumbnail.1.html | 148 + .../external/libtiff/html/man/tiff2bw.1.html | 161 + .../external/libtiff/html/man/tiff2pdf.1.html | 609 + .../external/libtiff/html/man/tiff2ps.1.html | 639 + .../libtiff/html/man/tiff2rgba.1.html | 162 + .../external/libtiff/html/man/tiffcmp.1.html | 156 + .../external/libtiff/html/man/tiffcp.1.html | 569 + .../external/libtiff/html/man/tiffcrop.1.html | 684 + .../libtiff/html/man/tiffdither.1.html | 196 + .../external/libtiff/html/man/tiffdump.1.html | 145 + .../external/libtiff/html/man/tiffgt.1.html | 551 + .../external/libtiff/html/man/tiffinfo.1.html | 196 + .../libtiff/html/man/tiffmedian.1.html | 183 + .../external/libtiff/html/man/tiffset.1.html | 176 + .../libtiff/html/man/tiffsplit.1.html | 102 + .../external/libtiff/html/misc.html | 121 + .../external/libtiff/html/support.html | 655 + .../external/libtiff/html/tools.html | 142 + .../external/libtiff/html/v3.4beta007.html | 113 + .../external/libtiff/html/v3.4beta016.html | 123 + .../external/libtiff/html/v3.4beta018.html | 85 + .../external/libtiff/html/v3.4beta024.html | 140 + .../external/libtiff/html/v3.4beta028.html | 147 + .../external/libtiff/html/v3.4beta029.html | 87 + .../external/libtiff/html/v3.4beta031.html | 95 + .../external/libtiff/html/v3.4beta032.html | 91 + .../external/libtiff/html/v3.4beta033.html | 83 + .../external/libtiff/html/v3.4beta034.html | 69 + .../external/libtiff/html/v3.4beta035.html | 64 + .../external/libtiff/html/v3.4beta036.html | 118 + .../external/libtiff/html/v3.5.1.html | 76 + .../external/libtiff/html/v3.5.2.html | 109 + .../external/libtiff/html/v3.5.3.html | 133 + .../external/libtiff/html/v3.5.4.html | 89 + .../external/libtiff/html/v3.5.5.html | 156 + .../external/libtiff/html/v3.5.6-beta.html | 186 + .../external/libtiff/html/v3.5.7.html | 260 + .../external/libtiff/html/v3.6.0.html | 435 + .../external/libtiff/html/v3.6.1.html | 200 + .../external/libtiff/html/v3.7.0.html | 145 + .../external/libtiff/html/v3.7.0alpha.html | 250 + .../external/libtiff/html/v3.7.0beta.html | 163 + .../external/libtiff/html/v3.7.0beta2.html | 132 + .../external/libtiff/html/v3.7.1.html | 234 + .../external/libtiff/html/v3.7.2.html | 223 + .../external/libtiff/html/v3.7.3.html | 231 + .../external/libtiff/html/v3.7.4.html | 134 + .../external/libtiff/html/v3.8.0.html | 200 + .../external/libtiff/html/v3.8.1.html | 218 + .../external/libtiff/html/v3.8.2.html | 138 + .../external/libtiff/html/v3.9.0.html | 262 + .../external/libtiff/html/v3.9.0beta.html | 305 + .../external/libtiff/html/v3.9.1.html | 116 + .../external/libtiff/html/v3.9.2.html | 123 + .../external/libtiff/html/v3.9.3.html | 161 + .../external/libtiff/html/v3.9.4.html | 126 + .../external/libtiff/html/v3.9.5.html | 271 + .../external/libtiff/html/v4.0.0.html | 270 + .../external/libtiff/html/v4.0.1.html | 114 + .../external/libtiff/html/v4.0.10.html | 327 + .../external/libtiff/html/v4.0.2.html | 119 + .../external/libtiff/html/v4.0.3.html | 126 + .../external/libtiff/html/v4.0.4.html | 275 + .../external/libtiff/html/v4.0.4beta.html | 292 + .../external/libtiff/html/v4.0.5.html | 149 + .../external/libtiff/html/v4.0.6.html | 140 + .../external/libtiff/html/v4.0.7.html | 412 + .../external/libtiff/html/v4.0.8.html | 446 + .../external/libtiff/html/v4.0.9.html | 374 + .../external/libtiff/html/v4.1.0.html | 205 + .../external/libtiff/html/v4.2.0.html | 205 + .../external/libtiff/libtiff-4.pc.in | 3 +- .../external/libtiff/libtiff/CMakeLists.txt | 290 +- .../external/libtiff/libtiff/Makefile.am | 30 +- .../external/libtiff/libtiff/Makefile.lcc | 128 + .../external/libtiff/libtiff/Makefile.vc | 100 + .../external/libtiff/libtiff/SConstruct | 71 + .../external/libtiff/libtiff/libtiff.def | 16 - .../external/libtiff/libtiff/libtiff.exp | 178 + .../external/libtiff/libtiff/libtiff.map | 102 +- .../libtiff/libtiff/mingw/tif_config.h | 374 + .../external/libtiff/libtiff/mingw/tiffconf.h | 126 + .../external/libtiff/libtiff/mkg3states.c | 504 +- .../external/libtiff/libtiff/mkspans.c | 96 +- .../SDL2_image/external/libtiff/libtiff/t4.h | 464 +- .../external/libtiff/libtiff/tif_aux.c | 633 +- .../external/libtiff/libtiff/tif_close.c | 179 +- .../external/libtiff/libtiff/tif_codec.c | 142 +- .../external/libtiff/libtiff/tif_color.c | 383 +- .../external/libtiff/libtiff/tif_compress.c | 410 +- .../external/libtiff/libtiff/tif_config.h-vms | 46 + .../libtiff/libtiff/tif_config.h.cmake.in | 153 +- .../external/libtiff/libtiff/tif_config.h.in | 182 - .../external/libtiff/libtiff/tif_config.vc.h | 150 + .../libtiff/libtiff/tif_config.wince.h | 69 + .../external/libtiff/libtiff/tif_dir.c | 3618 ++-- .../external/libtiff/libtiff/tif_dir.h | 467 +- .../external/libtiff/libtiff/tif_dirinfo.c | 2299 +- .../external/libtiff/libtiff/tif_dirread.c | 12905 +++++------- .../external/libtiff/libtiff/tif_dirwrite.c | 5918 +++--- .../external/libtiff/libtiff/tif_dumpmode.c | 159 +- .../external/libtiff/libtiff/tif_error.c | 148 +- .../external/libtiff/libtiff/tif_extension.c | 62 +- .../external/libtiff/libtiff/tif_fax3.c | 2743 ++- .../external/libtiff/libtiff/tif_fax3.h | 903 +- .../external/libtiff/libtiff/tif_flush.c | 135 +- .../external/libtiff/libtiff/tif_getimage.c | 4749 ++--- .../external/libtiff/libtiff/tif_hash_set.c | 603 - .../external/libtiff/libtiff/tif_hash_set.h | 100 - .../external/libtiff/libtiff/tif_jbig.c | 304 +- .../external/libtiff/libtiff/tif_jpeg.c | 4093 ++-- .../external/libtiff/libtiff/tif_jpeg_12.c | 88 +- .../external/libtiff/libtiff/tif_lerc.c | 1206 -- .../external/libtiff/libtiff/tif_luv.c | 2654 ++- .../external/libtiff/libtiff/tif_lzma.c | 743 +- .../external/libtiff/libtiff/tif_lzw.c | 2225 +- .../external/libtiff/libtiff/tif_next.c | 301 +- .../external/libtiff/libtiff/tif_ojpeg.c | 4984 +++-- .../external/libtiff/libtiff/tif_open.c | 1228 +- .../external/libtiff/libtiff/tif_packbits.c | 516 +- .../external/libtiff/libtiff/tif_pixarlog.c | 2492 +-- .../external/libtiff/libtiff/tif_predict.c | 1453 +- .../external/libtiff/libtiff/tif_predict.h | 55 +- .../external/libtiff/libtiff/tif_print.c | 1327 +- .../external/libtiff/libtiff/tif_read.c | 2513 +-- .../external/libtiff/libtiff/tif_stream.cxx | 578 +- .../external/libtiff/libtiff/tif_strip.c | 489 +- .../external/libtiff/libtiff/tif_swab.c | 445 +- .../external/libtiff/libtiff/tif_thunder.c | 294 +- .../external/libtiff/libtiff/tif_tile.c | 415 +- .../external/libtiff/libtiff/tif_unix.c | 462 +- .../external/libtiff/libtiff/tif_version.c | 29 +- .../external/libtiff/libtiff/tif_vms.c | 609 + .../external/libtiff/libtiff/tif_warning.c | 122 +- .../external/libtiff/libtiff/tif_webp.c | 1224 +- .../external/libtiff/libtiff/tif_win32.c | 593 +- .../libtiff/libtiff/tif_win32_versioninfo.rc | 51 - .../external/libtiff/libtiff/tif_wince.c | 288 + .../external/libtiff/libtiff/tif_write.c | 1357 +- .../external/libtiff/libtiff/tif_zip.c | 1071 +- .../external/libtiff/libtiff/tif_zstd.c | 680 +- .../external/libtiff/libtiff/tiff.h | 1380 +- .../external/libtiff/libtiff/tiffconf.h-vms | 90 + .../libtiff/libtiff/tiffconf.h.cmake.in | 40 +- .../external/libtiff/libtiff/tiffconf.h.in | 37 +- .../external/libtiff/libtiff/tiffconf.vc.h | 152 + .../external/libtiff/libtiff/tiffconf.wince.h | 110 + .../external/libtiff/libtiff/tiffio.h | 831 +- .../external/libtiff/libtiff/tiffio.hxx | 33 +- .../external/libtiff/libtiff/tiffiop.h | 663 +- .../external/libtiff/libtiff/tiffvers.h | 25 +- .../external/libtiff/libtiff/tiffvers.h.in | 21 - .../external/libtiff/libtiff/uvcode.h | 269 +- .../external/libtiff/man/CMakeLists.txt | 97 + .../external/libtiff/man/Makefile.am | 94 + .../external/libtiff/man/TIFFClose.3tiff | 52 + .../external/libtiff/man/TIFFDataWidth.3tiff | 73 + .../external/libtiff/man/TIFFError.3tiff | 68 + .../libtiff/man/TIFFFieldDataType.3tiff | 52 + .../external/libtiff/man/TIFFFieldName.3tiff | 51 + .../libtiff/man/TIFFFieldPassCount.3tiff | 72 + .../libtiff/man/TIFFFieldReadCount.3tiff | 76 + .../external/libtiff/man/TIFFFieldTag.3tiff | 55 + .../libtiff/man/TIFFFieldWriteCount.3tiff | 87 + .../external/libtiff/man/TIFFFlush.3tiff | 63 + .../external/libtiff/man/TIFFGetField.3tiff | 228 + .../external/libtiff/man/TIFFOpen.3tiff | 293 + .../libtiff/man/TIFFPrintDirectory.3tiff | 69 + .../external/libtiff/man/TIFFRGBAImage.3tiff | 285 + .../libtiff/man/TIFFReadDirectory.3tiff | 163 + .../libtiff/man/TIFFReadEncodedStrip.3tiff | 77 + .../libtiff/man/TIFFReadEncodedTile.3tiff | 75 + .../libtiff/man/TIFFReadRGBAImage.3tiff | 217 + .../libtiff/man/TIFFReadRGBAStrip.3tiff | 169 + .../libtiff/man/TIFFReadRGBATile.3tiff | 170 + .../libtiff/man/TIFFReadRawStrip.3tiff | 63 + .../libtiff/man/TIFFReadRawTile.3tiff | 64 + .../libtiff/man/TIFFReadScanline.3tiff | 93 + .../external/libtiff/man/TIFFReadTile.3tiff | 83 + .../libtiff/man/TIFFSetDirectory.3tiff | 78 + .../external/libtiff/man/TIFFSetField.3tiff | 216 + .../external/libtiff/man/TIFFWarning.3tiff | 69 + .../libtiff/man/TIFFWriteDirectory.3tiff | 137 + .../libtiff/man/TIFFWriteEncodedStrip.3tiff | 101 + .../libtiff/man/TIFFWriteEncodedTile.3tiff | 95 + .../libtiff/man/TIFFWriteRawStrip.3tiff | 95 + .../libtiff/man/TIFFWriteRawTile.3tiff | 83 + .../libtiff/man/TIFFWriteScanline.3tiff | 153 + .../external/libtiff/man/TIFFWriteTile.3tiff | 76 + .../external/libtiff/man/TIFFbuffer.3tiff | 76 + .../external/libtiff/man/TIFFcodec.3tiff | 81 + .../external/libtiff/man/TIFFcolor.3tiff | 267 + .../external/libtiff/man/TIFFmemory.3tiff | 89 + .../external/libtiff/man/TIFFquery.3tiff | 141 + .../external/libtiff/man/TIFFsize.3tiff | 58 + .../external/libtiff/man/TIFFstrip.3tiff | 98 + .../external/libtiff/man/TIFFswab.3tiff | 79 + .../external/libtiff/man/TIFFtile.3tiff | 130 + .../SDL2_image/external/libtiff/man/fax2ps.1 | 158 + .../external/libtiff/man/fax2tiff.1 | 285 + .../external/libtiff/man/libtiff.3tiff | 544 + .../SDL2_image/external/libtiff/man/pal2rgb.1 | 110 + .../external/libtiff/man/ppm2tiff.1 | 104 + .../external/libtiff/man/raw2tiff.1 | 195 + .../external/libtiff/man/rgb2ycbcr.1 | 98 + .../external/libtiff/man/thumbnail.1 | 89 + .../SDL2_image/external/libtiff/man/tiff2bw.1 | 93 + .../external/libtiff/man/tiff2pdf.1 | 256 + .../SDL2_image/external/libtiff/man/tiff2ps.1 | 297 + .../external/libtiff/man/tiff2rgba.1 | 100 + .../SDL2_image/external/libtiff/man/tiffcmp.1 | 86 + .../SDL2_image/external/libtiff/man/tiffcp.1 | 331 + .../external/libtiff/man/tiffcrop.1 | 574 + .../external/libtiff/man/tiffdither.1 | 134 + .../external/libtiff/man/tiffdump.1 | 80 + .../SDL2_image/external/libtiff/man/tiffgt.1 | 244 + .../external/libtiff/man/tiffinfo.1 | 87 + .../external/libtiff/man/tiffmedian.1 | 111 + .../SDL2_image/external/libtiff/man/tiffset.1 | 98 + .../external/libtiff/man/tiffsplit.1 | 68 + .../SDL2_image/external/libtiff/nmake.opt | 220 + .../SDL2_image/external/libtiff/placeholder.h | 6 - .../external/libtiff/port/CMakeLists.txt | 63 +- .../external/libtiff/port/Makefile.am | 5 +- .../InternalCodecs.cmake => port/Makefile.vc} | 89 +- .../external/libtiff/port/_strtol.h | 160 + .../external/libtiff/port/_strtoul.h | 127 + .../SDL2_image/external/libtiff/port/dummy.c | 7 +- .../SDL2_image/external/libtiff/port/getopt.c | 157 +- .../SDL2_image/external/libtiff/port/lfind.c | 60 + .../external/libtiff/port/libport.h | 64 +- .../libtiff/port/libport_config.h.cmake.in | 13 - .../external/libtiff/port/libport_config.h.in | 12 - .../external/libtiff/port/libport_config.vc.h | 10 - .../external/libtiff/port/snprintf.c | 42 + .../external/libtiff/port/strcasecmp.c | 49 + .../SDL2_image/external/libtiff/port/strtol.c | 45 + .../external/libtiff/port/strtoll.c | 44 + .../external/libtiff/port/strtoul.c | 44 + .../external/libtiff/port/strtoull.c | 44 + .../external/libtiff/test/CMakeLists.txt | 471 +- .../external/libtiff/test/Makefile.am | 47 +- .../external/libtiff/test/TiffTest.cmake | 17 +- .../libtiff/test/TiffTestCommon.cmake | 14 - .../external/libtiff/test/ascii_tag.c | 261 +- .../external/libtiff/test/check_tag.c | 102 +- .../external/libtiff/test/common.sh | 1 - .../external/libtiff/test/custom_dir.c | 401 +- .../libtiff/test/custom_dir_EXIF_231.c | 3367 ++- .../libtiff/test/defer_strile_loading.c | 146 +- .../libtiff/test/defer_strile_writing.c | 116 +- .../libtiff/test/images/minisblack-1c-8b.pgm | Bin 23722 -> 130 bytes .../images/test_float64_predictor2_be_lzw.tif | 3 - .../images/test_float64_predictor2_le_lzw.tif | 3 - .../test/images/test_ifd_loop_subifd.tif | 3 - .../test/images/test_ifd_loop_to_first.tif | 3 - .../test/images/test_ifd_loop_to_self.tif | 3 - .../libtiff/test/images/test_two_ifds.tif | 3 - .../libtiff/test/images/testfax3_bug_513.tiff | 3 - .../test/images/tiff_with_subifd_chain.tif | 3 - .../external/libtiff/test/long_tag.c | 227 +- .../libtiff/test/rational_precision2double.c | 2016 +- .../external/libtiff/test/raw_decode.c | 432 +- .../libtiff/test/refs/o-testfax3_bug_513.tiff | 3 - .../external/libtiff/test/rewrite_tag.c | 306 +- .../external/libtiff/test/short_tag.c | 315 +- .../SDL2_image/external/libtiff/test/strip.c | 460 +- .../external/libtiff/test/strip_rw.c | 234 +- .../libtiff/test/test_append_to_strip.c | 113 - .../external/libtiff/test/test_arrays.c | 1466 +- .../external/libtiff/test/test_arrays.h | 20 +- .../external/libtiff/test/test_directory.c | 1184 -- .../libtiff/test/test_ifd_loop_detection.c | 346 - .../external/libtiff/test/test_open_options.c | 238 - .../external/libtiff/test/test_signed_tags.c | 525 - .../test/test_transferfunction_write_read.c | 396 - .../libtiff/test/test_write_read_tags.c | 1852 -- .../external/libtiff/test/testfax3_bug_513.sh | 24 - .../external/libtiff/test/testtypes.c | 38 +- .../external/libtiff/test/tiffinfo.sh | 1 - .../external/libtiff/test/tifftest.h | 23 +- .../external/libtiff/tools/CMakeLists.txt | 132 +- .../external/libtiff/tools/Makefile.am | 8 +- .../external/libtiff/tools/Makefile.lcc | 132 + .../Makefile.vc} | 62 +- .../external/libtiff/tools/fax2ps.c | 654 +- .../external/libtiff/tools/fax2tiff.c | 821 +- .../external/libtiff/tools/pal2rgb.c | 825 +- .../external/libtiff/tools/ppm2tiff.c | 901 +- .../external/libtiff/tools/raw2tiff.c | 1264 +- .../external/libtiff/tools/rgb2ycbcr.c | 638 +- .../external/libtiff/tools/thumbnail.c | 1044 +- .../libtiff/tools/tif_tools_versioninfo.rc | 51 - .../external/libtiff/tools/tiff2bw.c | 919 +- .../external/libtiff/tools/tiff2pdf.c | 10323 +++++---- .../external/libtiff/tools/tiff2ps.c | 5311 +++-- .../external/libtiff/tools/tiff2rgba.c | 623 +- .../external/libtiff/tools/tiffcmp.c | 1120 +- .../external/libtiff/tools/tiffcp.c | 3608 ++-- .../external/libtiff/tools/tiffcrop.c | 17500 ++++++++-------- .../external/libtiff/tools/tiffdither.c | 589 +- .../external/libtiff/tools/tiffdump.c | 1542 +- .../external/libtiff/tools/tiffgt.c | 729 +- .../external/libtiff/tools/tiffinfo.c | 1075 +- .../external/libtiff/tools/tiffinfoce.c | 484 + .../external/libtiff/tools/tiffmedian.c | 1670 +- .../external/libtiff/tools/tiffset.c | 643 +- .../external/libtiff/tools/tiffsplit.c | 662 +- thirdparty/SDL2_image/src/IMG_qoi.c | 2 +- thirdparty/SDL2_image/src/nanosvgrast.h | 7 +- thirdparty/SDL2_image/test/svg-class.bmp | 2 +- thirdparty/SDL2_mixer/.gitmodules | 40 - .../external/tremor/,git-hidden/HEAD | 1 - .../external/tremor/,git-hidden/config | 13 - .../external/tremor/,git-hidden/description | 1 - .../,git-hidden/hooks/applypatch-msg.sample | 15 - .../,git-hidden/hooks/commit-msg.sample | 24 - .../hooks/fsmonitor-watchman.sample | 173 - .../,git-hidden/hooks/post-update.sample | 8 - .../,git-hidden/hooks/pre-applypatch.sample | 14 - .../,git-hidden/hooks/pre-commit.sample | 49 - .../,git-hidden/hooks/pre-merge-commit.sample | 13 - .../tremor/,git-hidden/hooks/pre-push.sample | 53 - .../,git-hidden/hooks/pre-rebase.sample | 169 - .../,git-hidden/hooks/pre-receive.sample | 24 - .../hooks/prepare-commit-msg.sample | 42 - .../,git-hidden/hooks/push-to-checkout.sample | 78 - .../tremor/,git-hidden/hooks/update.sample | 128 - .../external/tremor/,git-hidden/index | Bin 8802 -> 0 bytes .../external/tremor/,git-hidden/info/exclude | 6 - .../external/tremor/,git-hidden/logs/HEAD | 1 - .../,git-hidden/logs/refs/heads/v1.2.1-SDL | 1 - .../,git-hidden/logs/refs/remotes/origin/HEAD | 1 - ...357385f1b065747e10299757d477334a8331aa.idx | Bin 40944 -> 0 bytes ...57385f1b065747e10299757d477334a8331aa.pack | Bin 769432 -> 0 bytes .../external/tremor/,git-hidden/packed-refs | 9 - .../tremor/,git-hidden/refs/heads/v1.2.1-SDL | 1 - .../,git-hidden/refs/remotes/origin/HEAD | 1 - thirdparty/SDL2_ttf/.gitmodules | 8 - .../SDL2_ttf/external/freetype/.gitmodules | 3 - thirdparty/bzip2/.gitmodules | 3 - thirdparty/ffms2/.gitmodules | 4 - 781 files changed, 123374 insertions(+), 118335 deletions(-) delete mode 100644 thirdparty/SDL2_image/.gitmodules create mode 100644 thirdparty/SDL2_image/VisualC/external/optional/x64/libtiff-5.dll delete mode 100644 thirdparty/SDL2_image/VisualC/external/optional/x64/libtiff-6.dll create mode 100644 thirdparty/SDL2_image/VisualC/external/optional/x86/libtiff-5.dll delete mode 100644 thirdparty/SDL2_image/VisualC/external/optional/x86/libtiff-6.dll create mode 100644 thirdparty/SDL2_image/external/Get-GitModules.ps1 delete mode 100644 thirdparty/SDL2_image/external/libjxl/.gitmodules delete mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/brotli/.gitmodules create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.lsan create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.neon-vfpv4 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.neon-vfpv4-O3 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.portable create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.tiny create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.vfpv2 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.fp16 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.lsan create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.nofp16 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.portable create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.tiny create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.O0 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.avx512 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.lsan create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.m32 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.m32-O0 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.msan create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.native create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.portable create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.sse2 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.sse41 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.tiny create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.xsan create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.xsan-portable create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/common create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/emscripten create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/emscripten.simd create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.O0 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.m32 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.m32-O0 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.mips64el create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.mips64el-O3 create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.musl create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.native create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.portable create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.tiny create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.xsan create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.portable create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.tiny create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.xsan create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/local create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.analyze create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.clang create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.clang-fast create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.fast create mode 100644 thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/targets delete mode 100644 thirdparty/SDL2_image/external/libtiff/.clang-format delete mode 100644 thirdparty/SDL2_image/external/libtiff/.git-blame-ignore-revs delete mode 100644 thirdparty/SDL2_image/external/libtiff/.pre-commit-config.yaml create mode 100644 thirdparty/SDL2_image/external/libtiff/.travis.yml delete mode 100644 thirdparty/SDL2_image/external/libtiff/CONTRIBUTING.md rename thirdparty/SDL2_image/external/libtiff/{LICENSE.md => COPYRIGHT} (91%) rename thirdparty/SDL2_image/external/libtiff/{cmake/SymbolChecks.cmake => Makefile.vc} (61%) create mode 100644 thirdparty/SDL2_image/external/libtiff/SConstruct rename thirdparty/SDL2_image/external/libtiff/{cmake/CXXLibrary.cmake => build/CMakeLists.txt} (82%) rename thirdparty/SDL2_image/external/libtiff/{cmake/LERCCodec.cmake => build/Makefile.am} (71%) create mode 100644 thirdparty/SDL2_image/external/libtiff/build/README create mode 100644 thirdparty/SDL2_image/external/libtiff/build/gitlab-ci create mode 100644 thirdparty/SDL2_image/external/libtiff/build/travis-ci delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/AutotoolsCompat.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/AutotoolsVersion.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/CompilerChecks.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/DeflateCodec.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/FindCMath.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/FindDeflate.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/FindJBIG.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/FindJPEG.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/FindLERC.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/FindWebP.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/FindZSTD.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/Findliblzma.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/IncludeChecks.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/JPEGCodec.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/LibraryFeatures.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/OpenGLChecks.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/PixarLogCodec.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/PkgConfig.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/Release.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/Sphinx.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/SphinxCheckInternalLinks.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/TiffConfig.cmake.in delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/TypeSizeChecks.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/ZSTDCodec.cmake delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/list-manpage-dependencies.py delete mode 100644 thirdparty/SDL2_image/external/libtiff/cmake/list-manpages.py create mode 100644 thirdparty/SDL2_image/external/libtiff/configure.com create mode 100755 thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/Makefile.vc rename thirdparty/SDL2_image/external/libtiff/{cmake/LargeFileSupport.cmake => contrib/dbs/xtiff/CMakeLists.txt} (81%) rename thirdparty/SDL2_image/external/libtiff/{cmake/WebPCodec.cmake => contrib/mfs/CMakeLists.txt} (81%) create mode 100755 thirdparty/SDL2_image/external/libtiff/contrib/oss-fuzz/build.sh create mode 100644 thirdparty/SDL2_image/external/libtiff/contrib/pds/CMakeLists.txt create mode 100644 thirdparty/SDL2_image/external/libtiff/contrib/ras/CMakeLists.txt create mode 100644 thirdparty/SDL2_image/external/libtiff/contrib/stream/CMakeLists.txt rename thirdparty/SDL2_image/external/libtiff/{cmake/ProcessorChecks.cmake => contrib/tags/CMakeLists.txt} (81%) create mode 100644 thirdparty/SDL2_image/external/libtiff/contrib/win_dib/CMakeLists.txt delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/CMakeLists.txt delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/Makefile.am delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/_static/.gitignore delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/addingtags.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/conf.py delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/contrib.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFAccessTagMethods.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFClientInfo.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFClose.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCreateDirectory.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCustomDirectory.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCustomTagList.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFDataWidth.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFDeferStrileArrayWriting.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFError.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldDataType.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldName.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldPassCount.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldQuery.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldReadCount.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldTag.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldWriteCount.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFlush.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFGetField.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFMergeFieldInfo.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFOpen.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFOpenOptions.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFPrintDirectory.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFProcFunctions.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFRGBAImage.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadDirectory.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadEncodedStrip.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadEncodedTile.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadFromUserBuffer.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBAImage.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBAStrip.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBATile.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRawStrip.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRawTile.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadScanline.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadTile.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFSetDirectory.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFSetField.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFSetTagExtender.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFStrileQuery.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWarning.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteDirectory.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteEncodedStrip.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteEncodedTile.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteRawStrip.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteRawTile.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteScanline.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteTile.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFbuffer.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFcodec.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFcolor.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFmemory.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFquery.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFsize.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFstrip.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFswab.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFtile.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/_TIFFRewriteField.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/_TIFFauxiliary.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/functions/libtiff.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/images.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/index.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/internals.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/libtiff.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/multi_page.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/project/acknowledgements.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/project/bugs.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/project/index.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/project/license.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/project/mailinglist.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/historical.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/index.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta007.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta016.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta018.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta024.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta028.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta029.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta031.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta032.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta033.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta034.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta035.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta036.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.1.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.2.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.3.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.4.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.5.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.6beta.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.7.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.6.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.6.1.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0alpha.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0beta.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0beta2.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.1.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.2.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.3.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.4.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.1.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.2.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.0beta.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.1.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.2.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.3.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.4.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.5.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.1.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.10.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.2.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.3.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.4.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.4beta.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.5.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.6.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.7.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.8.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.9.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.1.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.2.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.3.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.4.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.5.0.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/releases/v4.5.1.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiff.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/specification/coverage-bigtiff.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/specification/coverage.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/specification/index.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/terms.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/fax2ps.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/fax2tiff.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/pal2rgb.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/ppm2tiff.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/raw2tiff.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/rgb2ycbcr.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/thumbnail.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2bw.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2pdf.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2ps.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2rgba.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcmp.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcp.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcrop.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffdither.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffdump.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffgt.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffinfo.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffmedian.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffset.rst delete mode 100644 thirdparty/SDL2_image/external/libtiff/doc/tools/tiffsplit.rst create mode 100644 thirdparty/SDL2_image/external/libtiff/html/BigTIFFProposal.html rename thirdparty/SDL2_image/external/libtiff/{cmake/JBIGCodec.cmake => html/CMakeLists.txt} (53%) create mode 100644 thirdparty/SDL2_image/external/libtiff/html/Makefile.am rename thirdparty/SDL2_image/external/libtiff/{doc/specification/technote2.rst => html/TIFFTechNote2.html} (61%) create mode 100644 thirdparty/SDL2_image/external/libtiff/html/addingtags.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/bigtiffdesign.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/bigtiffpr.html rename thirdparty/SDL2_image/external/libtiff/{doc/specification => html}/bigtiffpr_images/esri.png (100%) rename thirdparty/SDL2_image/external/libtiff/{doc/specification => html}/bigtiffpr_images/leica.png (100%) rename thirdparty/SDL2_image/external/libtiff/{doc/specification => html}/bigtiffpr_images/safe.png (100%) rename thirdparty/SDL2_image/external/libtiff/{doc/specification => html}/bigtiffpr_images/weogeo.png (100%) create mode 100644 thirdparty/SDL2_image/external/libtiff/html/bugs.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/build.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/contrib.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/document.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/images.html rename thirdparty/SDL2_image/external/libtiff/{cmake/LZMACodec.cmake => html/images/CMakeLists.txt} (78%) rename thirdparty/SDL2_image/external/libtiff/{cmake/ReleaseScript.cmake => html/images/Makefile.am} (66%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/back.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/bali.jpg (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/cat.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/cover.jpg (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/cramps.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/dave.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/info.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/jello.jpg (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/jim.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/note.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/oxford.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/quad.jpg (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/ring.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/smallliz.jpg (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/strike.gif (100%) rename thirdparty/SDL2_image/external/libtiff/{doc => html}/images/warning.gif (100%) create mode 100644 thirdparty/SDL2_image/external/libtiff/html/index.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/internals.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/intro.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/libtiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/CMakeLists.txt rename thirdparty/SDL2_image/external/libtiff/{cmake/LinkerChecks.cmake => html/man/HtmlDoc.cmake} (56%) create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/Makefile.am create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFClose.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFDataWidth.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFError.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldDataType.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldName.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldPassCount.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldReadCount.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldTag.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldWriteCount.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFFlush.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFGetField.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFOpen.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFPrintDirectory.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFRGBAImage.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadDirectory.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadEncodedStrip.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadEncodedTile.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBAImage.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBAStrip.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBATile.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRawStrip.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRawTile.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadScanline.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadTile.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFSetDirectory.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFSetField.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFWarning.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteDirectory.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteEncodedStrip.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteEncodedTile.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteRawStrip.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteRawTile.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteScanline.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteTile.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFbuffer.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFcodec.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFcolor.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFmemory.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFquery.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFsize.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFstrip.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFswab.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/TIFFtile.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/fax2ps.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/fax2tiff.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/index.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/libtiff.3tiff.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/pal2rgb.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/ppm2tiff.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/raw2tiff.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/rgb2ycbcr.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/thumbnail.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiff2bw.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiff2pdf.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiff2ps.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiff2rgba.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffcmp.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffcp.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffcrop.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffdither.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffdump.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffgt.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffinfo.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffmedian.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffset.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/man/tiffsplit.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/misc.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/support.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/tools.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta007.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta016.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta018.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta024.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta028.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta029.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta031.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta032.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta033.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta034.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta035.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.4beta036.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.5.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.5.2.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.5.3.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.5.4.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.5.5.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.5.6-beta.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.5.7.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.6.0.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.6.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.7.0.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.7.0alpha.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.7.0beta.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.7.0beta2.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.7.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.7.2.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.7.3.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.7.4.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.8.0.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.8.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.8.2.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.9.0.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.9.0beta.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.9.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.9.2.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.9.3.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.9.4.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v3.9.5.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.0.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.1.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.10.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.2.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.3.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.4.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.4beta.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.5.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.6.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.7.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.8.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.0.9.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.1.0.html create mode 100644 thirdparty/SDL2_image/external/libtiff/html/v4.2.0.html mode change 100755 => 100644 thirdparty/SDL2_image/external/libtiff/libtiff/CMakeLists.txt create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.lcc create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.vc create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/SConstruct create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.exp create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/mingw/tif_config.h create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/mingw/tiffconf.h create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h-vms delete mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h.in create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.vc.h create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.wince.h delete mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_hash_set.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_hash_set.h delete mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_lerc.c create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_vms.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_win32_versioninfo.rc create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tif_wince.c create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h-vms create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.vc.h create mode 100644 thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.wince.h create mode 100644 thirdparty/SDL2_image/external/libtiff/man/CMakeLists.txt create mode 100644 thirdparty/SDL2_image/external/libtiff/man/Makefile.am create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFClose.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFDataWidth.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFError.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFFieldDataType.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFFieldName.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFFieldPassCount.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFFieldReadCount.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFFieldTag.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFFieldWriteCount.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFFlush.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFGetField.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFOpen.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFPrintDirectory.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFRGBAImage.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadDirectory.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadEncodedStrip.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadEncodedTile.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBAImage.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBAStrip.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBATile.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadRawStrip.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadRawTile.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadScanline.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFReadTile.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFSetDirectory.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFSetField.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFWarning.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFWriteDirectory.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFWriteEncodedStrip.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFWriteEncodedTile.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFWriteRawStrip.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFWriteRawTile.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFWriteScanline.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFWriteTile.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFbuffer.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFcodec.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFcolor.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFmemory.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFquery.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFsize.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFstrip.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFswab.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/TIFFtile.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/fax2ps.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/fax2tiff.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/libtiff.3tiff create mode 100644 thirdparty/SDL2_image/external/libtiff/man/pal2rgb.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/ppm2tiff.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/raw2tiff.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/rgb2ycbcr.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/thumbnail.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiff2bw.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiff2pdf.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiff2ps.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiff2rgba.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffcmp.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffcp.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffcrop.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffdither.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffdump.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffgt.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffinfo.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffmedian.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffset.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/man/tiffsplit.1 create mode 100644 thirdparty/SDL2_image/external/libtiff/nmake.opt delete mode 100644 thirdparty/SDL2_image/external/libtiff/placeholder.h mode change 100755 => 100644 thirdparty/SDL2_image/external/libtiff/port/CMakeLists.txt rename thirdparty/SDL2_image/external/libtiff/{cmake/InternalCodecs.cmake => port/Makefile.vc} (53%) create mode 100644 thirdparty/SDL2_image/external/libtiff/port/_strtol.h create mode 100644 thirdparty/SDL2_image/external/libtiff/port/_strtoul.h create mode 100644 thirdparty/SDL2_image/external/libtiff/port/lfind.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/port/libport_config.h.cmake.in delete mode 100644 thirdparty/SDL2_image/external/libtiff/port/libport_config.h.in delete mode 100644 thirdparty/SDL2_image/external/libtiff/port/libport_config.vc.h create mode 100644 thirdparty/SDL2_image/external/libtiff/port/snprintf.c create mode 100644 thirdparty/SDL2_image/external/libtiff/port/strcasecmp.c create mode 100644 thirdparty/SDL2_image/external/libtiff/port/strtol.c create mode 100644 thirdparty/SDL2_image/external/libtiff/port/strtoll.c create mode 100644 thirdparty/SDL2_image/external/libtiff/port/strtoul.c create mode 100644 thirdparty/SDL2_image/external/libtiff/port/strtoull.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/images/test_float64_predictor2_be_lzw.tif delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/images/test_float64_predictor2_le_lzw.tif delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_subifd.tif delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_to_first.tif delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_to_self.tif delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/images/test_two_ifds.tif delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/images/testfax3_bug_513.tiff delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/images/tiff_with_subifd_chain.tif delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/refs/o-testfax3_bug_513.tiff delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/test_append_to_strip.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/test_directory.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/test_ifd_loop_detection.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/test_open_options.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/test_signed_tags.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/test_transferfunction_write_read.c delete mode 100644 thirdparty/SDL2_image/external/libtiff/test/test_write_read_tags.c delete mode 100755 thirdparty/SDL2_image/external/libtiff/test/testfax3_bug_513.sh mode change 100755 => 100644 thirdparty/SDL2_image/external/libtiff/tools/CMakeLists.txt create mode 100644 thirdparty/SDL2_image/external/libtiff/tools/Makefile.lcc rename thirdparty/SDL2_image/external/libtiff/{cmake/WindowsSupport.cmake => tools/Makefile.vc} (56%) delete mode 100644 thirdparty/SDL2_image/external/libtiff/tools/tif_tools_versioninfo.rc create mode 100644 thirdparty/SDL2_image/external/libtiff/tools/tiffinfoce.c delete mode 100644 thirdparty/SDL2_mixer/.gitmodules delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/HEAD delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/config delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/description delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/applypatch-msg.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/commit-msg.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/fsmonitor-watchman.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/post-update.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-applypatch.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-commit.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-merge-commit.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-push.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-rebase.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-receive.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/prepare-commit-msg.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/push-to-checkout.sample delete mode 100755 thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/update.sample delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/index delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/info/exclude delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/logs/HEAD delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/logs/refs/heads/v1.2.1-SDL delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/logs/refs/remotes/origin/HEAD delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/objects/pack/pack-c6357385f1b065747e10299757d477334a8331aa.idx delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/objects/pack/pack-c6357385f1b065747e10299757d477334a8331aa.pack delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/packed-refs delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/refs/heads/v1.2.1-SDL delete mode 100644 thirdparty/SDL2_mixer/external/tremor/,git-hidden/refs/remotes/origin/HEAD delete mode 100644 thirdparty/SDL2_ttf/.gitmodules delete mode 100644 thirdparty/SDL2_ttf/external/freetype/.gitmodules delete mode 100644 thirdparty/bzip2/.gitmodules delete mode 100644 thirdparty/ffms2/.gitmodules diff --git a/.gitattributes b/.gitattributes index d702c28be..b9247734b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -23,6 +23,7 @@ # Other Binary # *.exe filter=lfs diff=lfs merge=lfs -text +*.dll filter=lfs diff=lfs merge=lfs -text *.dat filter=lfs diff=lfs merge=lfs -text *.ttf filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index dc0460e07..d613e2df4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *~ -**/build/ +**/.builddir/ **/.git-hidden/ **/.github/ cmake-build-debug/ diff --git a/INSTALL.txt b/INSTALL.txt index 316960198..7ce909bae 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -34,38 +34,6 @@ subdirectory that was generated during installation. (You really shouldn't be changing things in there!) Delete the Singe subdirectory and run the new Singe binary with no command line arguments to generate the new files. -Games are available on the Internet Archive: - - Gun Games: - - https://archive.org/details/singe-actionmax - - https://archive.org/details/singe-crime-patrol - - https://archive.org/details/singe-crime-patrol-2 - - https://archive.org/details/singe-last-bounty-hunter - - https://archive.org/details/singe-mad-dog-mccree - - https://archive.org/details/singe-mad-dog-mccree-2 - - https://archive.org/details/singe-platoon - - https://archive.org/details/singe-space-pirates - - https://archive.org/details/singe-who-shot-johnny-rock - - QTE Games: - - https://archive.org/details/singe-cliff-hanger - - https://archive.org/details/singe-conan - - https://archive.org/details/singe-daitarn-3 - - https://archive.org/details/singe-dl-2e - - https://archive.org/details/singe-dl-tv - - https://archive.org/details/singe-dragon-english - - https://archive.org/details/singe-dragon-italian - - https://archive.org/details/singe-fire-and-ice - - https://archive.org/details/singe-jack-english - - https://archive.org/details/singe-jack-italian - - https://archive.org/details/singe-puss-in-boots-english - - https://archive.org/details/singe-puss-in-boots-italian - - https://archive.org/details/singe-time-traveler - - https://archive.org/details/singe-timegal - - https://archive.org/details/singe-titan-ae - -Know of a game we don't have listed? Let us know! - COMMAND LINE ============ diff --git a/build-all.sh b/build-all.sh index 1b406c4b3..ec903ca2d 100755 --- a/build-all.sh +++ b/build-all.sh @@ -21,6 +21,7 @@ G_BUILDROOT=${PWD} +G_BUILDDIR=.builddir G_TARGET= G_GENERATED= @@ -86,7 +87,7 @@ function buildAll() { esac - G_TARGET=${G_BUILDROOT}/build/${OS}/${ARCH} + G_TARGET=${G_BUILDROOT}/${G_BUILDDIR}/${OS}/${ARCH} G_GENERATED=${G_TARGET}/generated TOOLCHAIN=${G_BUILDROOT}/../toolchains/cmake/${TRIPLE}.cmake COMMON="-DCMAKE_INSTALL_PREFIX=${G_TARGET} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" @@ -285,9 +286,9 @@ UNUSED function clearAndEnterBuild() { - [[ -d build ]] && rm -rf build - mkdir -p build - cd build + [[ -d ${G_BUILDDIR} ]] && rm -rf ${G_BUILDDIR} + mkdir -p ${G_BUILDDIR} + cd ${G_BUILDDIR} } @@ -409,8 +410,8 @@ function outputLicense() { #buildAll linux x86 -#buildAll linux x86_64 -buildAll macos aarch64 +buildAll linux x86_64 +#buildAll macos aarch64 #buildAll macos x86 #***TODO*** Needs older SDL2 #buildAll macos x86_64 #***TODO*** Needs older SDL2 #buildAll windows x86 diff --git a/thirdparty/SDL2_image/.gitmodules b/thirdparty/SDL2_image/.gitmodules deleted file mode 100644 index a2bb48a95..000000000 --- a/thirdparty/SDL2_image/.gitmodules +++ /dev/null @@ -1,32 +0,0 @@ -[submodule "external/jpeg"] - path = external/jpeg - url = https://github.com/libsdl-org/jpeg.git - branch = v9e-SDL -[submodule "external/libpng"] - path = external/libpng - url = https://github.com/libsdl-org/libpng.git - branch = v1.6.40-SDL -[submodule "external/libwebp"] - path = external/libwebp - url = https://github.com/libsdl-org/libwebp.git - branch = 1.0.3-SDL -[submodule "external/libtiff"] - path = external/libtiff - url = https://github.com/libsdl-org/libtiff.git - branch = v4.5.1-SDL -[submodule "external/zlib"] - path = external/zlib - url = https://github.com/libsdl-org/zlib.git - branch = v1.3-SDL -[submodule "external/libjxl"] - path = external/libjxl - url = https://github.com/libsdl-org/libjxl.git - branch = v0.6.1-SDL -[submodule "external/libavif"] - path = external/libavif - url = https://github.com/libsdl-org/libavif.git - branch = v1.0.1-SDL -[submodule "external/dav1d"] - path = external/dav1d - url = https://github.com/libsdl-org/dav1d.git - branch = 1.2.1-SDL diff --git a/thirdparty/SDL2_image/CMakeLists.txt b/thirdparty/SDL2_image/CMakeLists.txt index fcfdd437a..705ab0ad0 100644 --- a/thirdparty/SDL2_image/CMakeLists.txt +++ b/thirdparty/SDL2_image/CMakeLists.txt @@ -619,8 +619,6 @@ if(SDL2IMAGE_TIF) target_compile_definitions(SDL2_image PRIVATE LOAD_TIF) if(SDL2IMAGE_TIF_VENDORED) message(STATUS "${PROJECT_NAME}: Using vendored libtiff") - # tiff-tests variable is used by vendored libtiff - set(tiff-tests OFF CACHE BOOL "libtiff: tests" FORCE) # jpeg variable is used by vendored libtiff set(jpeg OFF CACHE BOOL "libtiff: jpeg option" FORCE) # libdeflate variable is used by vendored libtiff diff --git a/thirdparty/SDL2_image/VisualC/SDL_image.vcxproj b/thirdparty/SDL2_image/VisualC/SDL_image.vcxproj index 181a12027..5ed188bfc 100644 --- a/thirdparty/SDL2_image/VisualC/SDL_image.vcxproj +++ b/thirdparty/SDL2_image/VisualC/SDL_image.vcxproj @@ -108,7 +108,7 @@ Disabled $(ProjectDir)\..\include;external\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-6.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions) + DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-5.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions) MultiThreadedDLL Level3 OldStyle @@ -136,7 +136,7 @@ $(ProjectDir)\..\include;external\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-6.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions) + DLL_EXPORT;_DEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-5.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions) MultiThreadedDLL Level3 Disabled @@ -165,7 +165,7 @@ $(ProjectDir)\..\include;external\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-6.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions) + DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-5.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions) MultiThreadedDLL Level3 StreamingSIMDExtensions @@ -191,7 +191,7 @@ $(ProjectDir)\..\include;external\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-6.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions) + DLL_EXPORT;NDEBUG;WIN32;_WINDOWS;USE_STBIMAGE;LOAD_AVIF;LOAD_AVIF_DYNAMIC="libavif-16.dll";LOAD_BMP;LOAD_GIF;LOAD_JPG;LOAD_LBM;LOAD_PCX;LOAD_PNG;LOAD_PNM;LOAD_QOI;LOAD_SVG;LOAD_TGA;LOAD_TIF;LOAD_TIF_DYNAMIC="libtiff-5.dll";LOAD_WEBP;LOAD_WEBP_DYNAMIC="libwebp-7.dll";LOAD_WEBPDEMUX_DYNAMIC="libwebpdemux-2.dll";LOAD_XCF;LOAD_XPM;LOAD_XV;%(PreprocessorDefinitions) MultiThreadedDLL Level3 StreamingSIMDExtensions diff --git a/thirdparty/SDL2_image/VisualC/external/include/tiff.h b/thirdparty/SDL2_image/VisualC/external/include/tiff.h index b2d118668..2d4a47679 100644 --- a/thirdparty/SDL2_image/VisualC/external/include/tiff.h +++ b/thirdparty/SDL2_image/VisualC/external/include/tiff.h @@ -2,28 +2,28 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFF_ -#define _TIFF_ +#define _TIFF_ #include "tiffconf.h" @@ -48,46 +48,32 @@ #define TIFF_VERSION_CLASSIC 42 #define TIFF_VERSION_BIG 43 -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 -#define MDI_LITTLEENDIAN 0x5045 -#define MDI_BIGENDIAN 0x4550 +#define TIFF_BIGENDIAN 0x4d4d +#define TIFF_LITTLEENDIAN 0x4949 +#define MDI_LITTLEENDIAN 0x5045 +#define MDI_BIGENDIAN 0x4550 /* * Intrinsic data types required by the file format: * - * 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 + * 8-bit quantities int8/uint8 + * 16-bit quantities int16/uint16 + * 32-bit quantities int32/uint32 + * 64-bit quantities int64/uint64 * 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 -#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_INT8_T int8; +typedef TIFF_UINT8_T uint8; -typedef TIFF_MSC_DEPRECATED int16_t int16 TIFF_GCC_DEPRECATED; -typedef TIFF_MSC_DEPRECATED uint16_t uint16 TIFF_GCC_DEPRECATED; +typedef TIFF_INT16_T int16; +typedef TIFF_UINT16_T uint16; -typedef TIFF_MSC_DEPRECATED int32_t int32 TIFF_GCC_DEPRECATED; -typedef TIFF_MSC_DEPRECATED uint32_t uint32 TIFF_GCC_DEPRECATED; +typedef TIFF_INT32_T int32; +typedef TIFF_UINT32_T uint32; -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 @@ -102,26 +88,24 @@ typedef int uint16_vap; /* * TIFF header. */ -typedef struct -{ - uint16_t tiff_magic; /* magic number (defines byte order) */ - uint16_t tiff_version; /* TIFF version number */ +typedef struct { + uint16 tiff_magic; /* magic number (defines byte order) */ + uint16 tiff_version; /* TIFF version number */ } TIFFHeaderCommon; -typedef struct -{ - 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 */ +typedef struct { + uint16 tiff_magic; /* magic number (defines byte order) */ + uint16 tiff_version; /* TIFF version number */ + uint32 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; -typedef struct -{ - uint16_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 */ +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 */ } TIFFHeaderBig; + /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, @@ -136,551 +120,464 @@ typedef struct * * Note: RATIONALs are the ratio of two 32-bit integer values. *--: - * Note2: TIFF_IFD8 data type is used in tiffFields[]-tag definition in order to - distinguish the write-handling of those tags between ClassicTIFF and BigTiff: - For ClassicTIFF libtiff writes a 32-bit value and the TIFF_IFD - type-id into the file For BigTIFF libtiff writes a 64-bit value and the - TIFF_IFD8 type-id into the file + * Note2: TIFF_IFD8 data type is used in tiffFields[]-tag definition in order to distinguish the write-handling + of those tags between ClassicTIFF and BigTiff: + For ClassicTIFF libtiff writes a 32-bit value and the TIFF_IFD type-id into the file + For BigTIFF libtiff writes a 64-bit value and the TIFF_IFD8 type-id into the file */ -typedef enum -{ - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ - TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ - TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ - TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ - TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ +typedef enum { + TIFF_NOTYPE = 0, /* placeholder */ + TIFF_BYTE = 1, /* 8-bit unsigned integer */ + TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ + TIFF_SHORT = 3, /* 16-bit unsigned integer */ + TIFF_LONG = 4, /* 32-bit unsigned integer */ + TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ + TIFF_SBYTE = 6, /* !8-bit signed integer */ + TIFF_UNDEFINED = 7, /* !8-bit untyped data */ + TIFF_SSHORT = 8, /* !16-bit signed integer */ + TIFF_SLONG = 9, /* !32-bit signed integer */ + TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ + TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ + TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ + TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ + TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ + TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ + TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ } TIFFDataType; /* * TIFF Tag Definitions. */ -/* clang-format off */ /* for better readability of tag comments */ -#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ -#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ -#define FILETYPE_PAGE 0x2 /* one page of many */ -#define FILETYPE_MASK 0x4 /* transparency mask */ -#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ -#define OFILETYPE_IMAGE 1 /* full resolution image data */ -#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ -#define OFILETYPE_PAGE 3 /* one page of many */ -#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ -#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ -#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ -#define TIFFTAG_COMPRESSION 259 /* data compression technique */ -#define COMPRESSION_NONE 1 /* dump mode */ -#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ -#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ -#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ -#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ -#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ -#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ -#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ -#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ -#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ -#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ -#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ -#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ -#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ -#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ +#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ +#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ +#define FILETYPE_PAGE 0x2 /* one page of many */ +#define FILETYPE_MASK 0x4 /* transparency mask */ +#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ +#define OFILETYPE_IMAGE 1 /* full resolution image data */ +#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ +#define OFILETYPE_PAGE 3 /* one page of many */ +#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ +#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ +#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ +#define TIFFTAG_COMPRESSION 259 /* data compression technique */ +#define COMPRESSION_NONE 1 /* dump mode */ +#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ +#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ +#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ +#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ +#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ +#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ +#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ +#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ +#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ +#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ +#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ +#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ +#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ +#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ /* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ -#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ -#define COMPRESSION_JBIG 34661 /* ISO JBIG */ -#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ -#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ -#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ -#define COMPRESSION_LERC 34887 /* ESRI Lerc codec: https://github.com/Esri/lerc */ +#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ +#define COMPRESSION_JBIG 34661 /* ISO JBIG */ +#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ +#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ +#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ +#define COMPRESSION_LERC 34887 /* ESRI Lerc codec: https://github.com/Esri/lerc */ /* compression codes 34887-34889 are reserved for ESRI */ -#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 */ -#define PHOTOMETRIC_RGB 2 /* RGB color model */ -#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ -#define PHOTOMETRIC_MASK 4 /* $holdout mask */ -#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ -#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ -#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ -#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ -#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ -#define PHOTOMETRIC_CFA 32803 /* color filter array */ -#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ -#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ -#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ -#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ -#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ -#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ -#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ -#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ -#define TIFFTAG_FILLORDER 266 /* data order within a byte */ -#define FILLORDER_MSB2LSB 1 /* most significant -> least */ -#define FILLORDER_LSB2MSB 2 /* least significant -> most */ -#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ -#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ -#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ -#define TIFFTAG_MODEL 272 /* scanner model name/number */ -#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ -#define TIFFTAG_ORIENTATION 274 /* +image orientation */ -#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ -#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ -#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ -#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ -#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ -#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ -#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ -#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ -#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ -#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ -#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ -#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ -#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ -#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ -#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ -#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ -#define PLANARCONFIG_CONTIG 1 /* single image plane */ -#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ -#define TIFFTAG_PAGENAME 285 /* page name image is from */ -#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ -#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ -#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ -#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ -#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ -#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ -#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ -#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ -#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ -#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ -#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ -#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ -#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ -#define RESUNIT_NONE 1 /* no meaningful units */ -#define RESUNIT_INCH 2 /* english */ -#define RESUNIT_CENTIMETER 3 /* metric */ -#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ -#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ -#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ -#define TIFFTAG_SOFTWARE 305 /* name & release */ -#define TIFFTAG_DATETIME 306 /* creation date and time */ -#define TIFFTAG_ARTIST 315 /* creator of image */ -#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ -#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ -#define PREDICTOR_NONE 1 /* no prediction scheme used */ -#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ -#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ -#define TIFFTAG_WHITEPOINT 318 /* image white point */ -#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ -#define TIFFTAG_COLORMAP 320 /* RGB map for palette image */ -#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ -#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ -#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ -#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ -#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ -#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ -#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ -#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ -#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ -#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ -#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ -#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ -#define TIFFTAG_INKSET 332 /* !inks in separated image */ -#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ -#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ -#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ -#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ -#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ -#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ -#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ -#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ -#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ -#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ -#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ -#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ -#define SAMPLEFORMAT_INT 2 /* !signed integer data */ -#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ -#define SAMPLEFORMAT_VOID 4 /* !untyped data */ -#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ -#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ -#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ -#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ -#define TIFFTAG_CLIPPATH 343 /* %ClipPath [Adobe TIFF technote 2] */ -#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits [Adobe TIFF technote 2] */ -#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits [Adobe TIFF technote 2] */ -#define TIFFTAG_INDEXED 346 /* %Indexed [Adobe TIFF Technote 3] */ -#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ -#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ +#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 TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ +#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ +#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ +#define PHOTOMETRIC_RGB 2 /* RGB color model */ +#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ +#define PHOTOMETRIC_MASK 4 /* $holdout mask */ +#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ +#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ +#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ +#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ +#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ +#define PHOTOMETRIC_CFA 32803 /* color filter array */ +#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ +#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ +#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ +#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ +#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ +#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ +#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ +#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ +#define TIFFTAG_FILLORDER 266 /* data order within a byte */ +#define FILLORDER_MSB2LSB 1 /* most significant -> least */ +#define FILLORDER_LSB2MSB 2 /* least significant -> most */ +#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ +#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ +#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ +#define TIFFTAG_MODEL 272 /* scanner model name/number */ +#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ +#define TIFFTAG_ORIENTATION 274 /* +image orientation */ +#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ +#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ +#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ +#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ +#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ +#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ +#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ +#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ +#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ +#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ +#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ +#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ +#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ +#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ +#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ +#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ +#define PLANARCONFIG_CONTIG 1 /* single image plane */ +#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ +#define TIFFTAG_PAGENAME 285 /* page name image is from */ +#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ +#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ +#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ +#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ +#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ +#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ +#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ +#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ +#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ +#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ +#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ +#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ +#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ +#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ +#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ +#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ +#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ +#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ +#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ +#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ +#define RESUNIT_NONE 1 /* no meaningful units */ +#define RESUNIT_INCH 2 /* english */ +#define RESUNIT_CENTIMETER 3 /* metric */ +#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ +#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ +#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ +#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ +#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ +#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ +#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ +#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ +#define TIFFTAG_SOFTWARE 305 /* name & release */ +#define TIFFTAG_DATETIME 306 /* creation date and time */ +#define TIFFTAG_ARTIST 315 /* creator of image */ +#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ +#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ +#define PREDICTOR_NONE 1 /* no prediction scheme used */ +#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ +#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ +#define TIFFTAG_WHITEPOINT 318 /* image white point */ +#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ +#define TIFFTAG_COLORMAP 320 /* RGB map for palette image */ +#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ +#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ +#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ +#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ +#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ +#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ +#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ +#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ +#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ +#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ +#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ +#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ +#define TIFFTAG_INKSET 332 /* !inks in separated image */ +#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ +#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ +#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ +#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ +#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ +#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ +#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ +#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ +#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ +#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ +#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ +#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ +#define SAMPLEFORMAT_INT 2 /* !signed integer data */ +#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ +#define SAMPLEFORMAT_VOID 4 /* !untyped data */ +#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ +#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ +#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ +#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ +#define TIFFTAG_CLIPPATH 343 /* %ClipPath + [Adobe TIFF technote 2] */ +#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits + [Adobe TIFF technote 2] */ +#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits + [Adobe TIFF technote 2] */ +#define TIFFTAG_INDEXED 346 /* %Indexed + [Adobe TIFF Technote 3] */ +#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ +#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ /* Tags 400-435 are from the TIFF/FX spec */ -#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ -#define TIFFTAG_PROFILETYPE 401 /* ! */ -#define PROFILETYPE_UNSPECIFIED 0 /* ! */ -#define PROFILETYPE_G3_FAX 1 /* ! */ -#define TIFFTAG_FAXPROFILE 402 /* ! */ -#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ -#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ -#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ -#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ -#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ -#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ -#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ -#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ -#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ -#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ -#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ -#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ -#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ -#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ -#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ -#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ -#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ -#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ +#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ +#define TIFFTAG_PROFILETYPE 401 /* ! */ +#define PROFILETYPE_UNSPECIFIED 0 /* ! */ +#define PROFILETYPE_G3_FAX 1 /* ! */ +#define TIFFTAG_FAXPROFILE 402 /* ! */ +#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ +#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ +#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ +#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ +#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ +#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ +#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ +#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ +#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ +#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ +#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ +#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ +#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ +#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ +#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ +#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ +#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ +#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. */ -#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ -#define JPEGPROC_BASELINE 1 /* !baseline sequential */ -#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ -#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ -#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ -#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ -#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ -#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ -#define TIFFTAG_JPEGQTABLES 519 /* !Q matrix offsets */ -#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ -#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ -#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ -#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ -#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ -#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ -#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ -#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ -#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ -#define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ -#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID [Adobe TIFF technote] */ -/* For eiStream Annotation Specification, Version 1.00.06 see - * http://web.archive.org/web/20050309141348/http://www.kofile.com/support%20pro/faqs/annospec.htm */ -#define TIFFTAG_TIFFANNOTATIONDATA 32932 +#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ +#define JPEGPROC_BASELINE 1 /* !baseline sequential */ +#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ +#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ +#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ +#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ +#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ +#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ +#define TIFFTAG_JPEGQTABLES 519 /* !Q matrix offsets */ +#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ +#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ +#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ +#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ +#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ +#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ +#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ +#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ +#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ +#define TIFFTAG_XMLPACKET 700 /* %XML packet + [Adobe XMP Specification, + January 2004 */ +#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID + [Adobe TIFF technote] */ +#define TIFFTAG_TIFFANNOTATIONDATA 32932 /* http://web.archive.org/web/20050309141348/http://www.kofile.com/support%20pro/faqs/annospec.htm */ /* tags 32952-32956 are private tags registered to Island Graphics */ -#define TIFFTAG_REFPTS 32953 /* image reference points */ -#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ -#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ -#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ +#define TIFFTAG_REFPTS 32953 /* image reference points */ +#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ +#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ +#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ /* tags 32995-32999 are private tags registered to SGI */ -#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ -#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ -#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ -#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ +#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ +#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ +#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ +#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ /* tags 33300-33309 are private tags registered to Pixar */ /* * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH - * are set when an image has been cropped out of a larger image. + * are set when an image has been cropped out of a larger image. * They reflect the size of the original uncropped image. * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used * to determine the position of the smaller image in the larger one. */ -#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ -#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ -/* Tags 33302-33306 are used to identify special image modes and data - * used by Pixar's texture formats. - */ -#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ -#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ -#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ +#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ +#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ + /* Tags 33302-33306 are used to identify special image modes and data + * used by Pixar's texture formats. + */ +#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ +#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ +#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ #define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 #define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 /* tag 33405 is a private tag registered to Eastman Kodak */ -#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ -#define TIFFTAG_CFAREPEATPATTERNDIM 33421 /* (alias for TIFFTAG_EP_CFAREPEATPATTERNDIM)*/ -#define TIFFTAG_CFAPATTERN 33422 /* (alias for TIFFTAG_EP_CFAPATTERN) */ -#define TIFFTAG_BATTERYLEVEL 33423 /* (alias for TIFFTAG_EP_BATTERYLEVEL) */ +#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ +#define TIFFTAG_CFAREPEATPATTERNDIM 33421 /* dimensions of CFA pattern */ +#define TIFFTAG_CFAPATTERN 33422 /* color filter array pattern */ /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ -#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ -/* Tags 33445-33452 are used for Molecular Dynamics GEL fileformat, - * see http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf - * (2023: the above web site is unavailable but tags are explained briefly at - * https://www.awaresystems.be/imaging/tiff/tifftags/docs/gel.html +#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ +/* Tags 33445-33452 are used for GEL fileformat, see + * http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ -#define TIFFTAG_MD_FILETAG 33445 /* Specifies the pixel data format encoding in the GEL file format. */ -#define TIFFTAG_MD_SCALEPIXEL 33446 /* scale factor */ -#define TIFFTAG_MD_COLORTABLE 33447 /* conversion from 16bit to 8bit */ -#define TIFFTAG_MD_LABNAME 33448 /* name of the lab that scanned this file. */ -#define TIFFTAG_MD_SAMPLEINFO 33449 /* information about the scanned GEL sample */ -#define TIFFTAG_MD_PREPDATE 33450 /* information about the date the sample was prepared YY/MM/DD */ -#define TIFFTAG_MD_PREPTIME 33451 /* information about the time the sample was prepared HH:MM*/ -#define TIFFTAG_MD_FILEUNITS 33452 /* Units for data in this file, as used in the GEL file format. */ +#define TIFFTAG_MD_FILETAG 33445 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_SCALEPIXEL 33446 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_COLORTABLE 33447 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_LABNAME 33448 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_SAMPLEINFO 33449 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_PREPDATE 33450 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_PREPTIME 33451 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_FILEUNITS 33452 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ /* IPTC TAG from RichTIFF specifications */ -#define TIFFTAG_RICHTIFFIPTC 33723 -#define TIFFTAG_INGR_PACKET_DATA_TAG 33918 /* Intergraph Application specific storage. */ -#define TIFFTAG_INGR_FLAG_REGISTERS 33919 /* Intergraph Application specific flags. */ -#define TIFFTAG_IRASB_TRANSORMATION_MATRIX 33920 /* Originally part of Intergraph's GeoTIFF tags, but likely understood by IrasB only. */ -#define TIFFTAG_MODELTIEPOINTTAG 33922 /* GeoTIFF */ +#define TIFFTAG_RICHTIFFIPTC 33723 +#define TIFFTAG_INGR_PACKET_DATA_TAG 33918 /* Intergraph Application specific storage. */ +#define TIFFTAG_INGR_FLAG_REGISTERS 33919 /* Intergraph Application specific flags. */ +#define TIFFTAG_IRASB_TRANSORMATION_MATRIX 33920 /* Originally part of Intergraph's GeoTIFF tags, but likely understood by IrasB only. */ +#define TIFFTAG_MODELTIEPOINTTAG 33922 /* GeoTIFF */ /* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ -#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ +#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ /* tag 34929 is a private tag registered to FedEx */ -#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ -#define TIFFTAG_IMAGESOURCEDATA 37724 /* http://justsolve.archiveteam.org/wiki/PSD, http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ */ -#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to EXIF Interoperability private directory */ -#define TIFFTAG_GDAL_METADATA 42112 /* Used by the GDAL library */ -#define TIFFTAG_GDAL_NODATA 42113 /* Used by the GDAL library */ -#define TIFFTAG_OCE_SCANJOB_DESCRIPTION 50215 /* Used in the Oce scanning process */ -#define TIFFTAG_OCE_APPLICATION_SELECTOR 50216 /* Used in the Oce scanning process. */ -#define TIFFTAG_OCE_IDENTIFICATION_NUMBER 50217 -#define TIFFTAG_OCE_IMAGELOGIC_CHARACTERISTICS 50218 +#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ +#define TIFFTAG_IMAGESOURCEDATA 37724 /* http://justsolve.archiveteam.org/wiki/PSD, http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ */ +#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ +#define TIFFTAG_GDAL_METADATA 42112 /* Used by the GDAL library */ +#define TIFFTAG_GDAL_NODATA 42113 /* Used by the GDAL library */ +#define TIFFTAG_OCE_SCANJOB_DESCRIPTION 50215 /* Used in the Oce scanning process */ +#define TIFFTAG_OCE_APPLICATION_SELECTOR 50216 /* Used in the Oce scanning process. */ +#define TIFFTAG_OCE_IDENTIFICATION_NUMBER 50217 +#define TIFFTAG_OCE_IMAGELOGIC_CHARACTERISTICS 50218 + /* tags 50674 to 50677 are reserved for ESRI */ -#define TIFFTAG_LERC_PARAMETERS 50674 /* Stores LERC version and additional compression method */ - +#define TIFFTAG_LERC_PARAMETERS 50674 /* Stores LERC version and additional compression method */ /* Adobe Digital Negative (DNG) format tags */ -#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ -#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ -#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ -#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model name (UTF-8) */ -#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space mapping */ -#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ -#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ -#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for the BlackLevel tag */ -#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ -#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level differences (columns) */ -#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level differences (rows) */ -#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding level */ -#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ -#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image area */ -#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image area */ -#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space transformation matrix 1 */ -#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space transformation matrix 2 */ -#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ -#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ -#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction matrix 1 */ -#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction matrix 2 */ -#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw values*/ -#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in linear reference space */ -#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in x-y chromaticity coordinates */ -#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero point */ -#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ -#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of sharpening */ -/* TIFFTAG_BAYERGREENSPLIT: &how closely the values of the green pixels in the blue/green rows - * track the values of the green pixels in the red/green rows */ -#define TIFFTAG_BAYERGREENSPLIT 50733 -#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ -#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ -#define TIFFTAG_LENSINFO 50736 /* info about the lens */ -#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ -#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the camera's anti-alias filter */ -#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ -#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ -#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data */ -#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ -#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ -#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ -#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for the raw image data */ -#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original raw file (UTF-8) */ -#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original raw file */ -#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels of the sensor */ -#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates of fully masked pixels */ -#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ -#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space into ICC profile space */ -#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ -#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ +#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ +#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ +#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ +#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model + name */ +#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space + mapping */ +#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ +#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ +#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for + the BlackLevel tag */ +#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ +#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level + differences (columns) */ +#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level + differences (rows) */ +#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding + level */ +#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ +#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image + area */ +#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image + area */ +#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space + transformation matrix 1 */ +#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space + transformation matrix 2 */ +#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ +#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ +#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction + matrix 1 */ +#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction + matrix 2 */ +#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw + values*/ +#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in + linear reference space */ +#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in + x-y chromaticity + coordinates */ +#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero + point */ +#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ +#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of + sharpening */ +#define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of + the green pixels in the + blue/green rows track the + values of the green pixels + in the red/green rows */ +#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ +#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ +#define TIFFTAG_LENSINFO 50736 /* info about the lens */ +#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ +#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the + camera's anti-alias filter */ +#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ +#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ +#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote + tag is safe to preserve + along with the rest of the + EXIF data */ +#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ +#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ +#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ +#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for + the raw image data */ +#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original + raw file */ +#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original + raw file */ +#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels + of the sensor */ +#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates + of fully masked pixels */ +#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ +#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space + into ICC profile space */ +#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ +#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ -/* DNG 1.2.0.0 */ -#define TIFFTAG_COLORIMETRICREFERENCE 50879 /* &colorimetric reference */ -#define TIFFTAG_CAMERACALIBRATIONSIGNATURE 50931 /* &camera calibration signature (UTF-8) */ -#define TIFFTAG_PROFILECALIBRATIONSIGNATURE 50932 /* &profile calibration signature (UTF-8) */ -/* TIFFTAG_EXTRACAMERAPROFILES 50933 &extra camera profiles : is already defined for GeoTIFF DGIWG */ -#define TIFFTAG_ASSHOTPROFILENAME 50934 /* &as shot profile name (UTF-8) */ -#define TIFFTAG_NOISEREDUCTIONAPPLIED 50935 /* &amount of applied noise reduction */ -#define TIFFTAG_PROFILENAME 50936 /* &camera profile name (UTF-8) */ -#define TIFFTAG_PROFILEHUESATMAPDIMS 50937 /* &dimensions of HSV mapping */ -#define TIFFTAG_PROFILEHUESATMAPDATA1 50938 /* &first HSV mapping table */ -#define TIFFTAG_PROFILEHUESATMAPDATA2 50939 /* &second HSV mapping table */ -#define TIFFTAG_PROFILETONECURVE 50940 /* &default tone curve */ -#define TIFFTAG_PROFILEEMBEDPOLICY 50941 /* &profile embedding policy */ -#define TIFFTAG_PROFILECOPYRIGHT 50942 /* &profile copyright information (UTF-8) */ -#define TIFFTAG_FORWARDMATRIX1 50964 /* &matrix for mapping white balanced camera colors to XYZ D50 */ -#define TIFFTAG_FORWARDMATRIX2 50965 /* &matrix for mapping white balanced camera colors to XYZ D50 */ -#define TIFFTAG_PREVIEWAPPLICATIONNAME 50966 /* &name of application that created preview (UTF-8) */ -#define TIFFTAG_PREVIEWAPPLICATIONVERSION 50967 /* &version of application that created preview (UTF-8) */ -#define TIFFTAG_PREVIEWSETTINGSNAME 50968 /* &name of conversion settings (UTF-8) */ -#define TIFFTAG_PREVIEWSETTINGSDIGEST 50969 /* &unique id of conversion settings */ -#define TIFFTAG_PREVIEWCOLORSPACE 50970 /* &preview color space */ -#define TIFFTAG_PREVIEWDATETIME 50971 /* &date/time preview was rendered */ -#define TIFFTAG_RAWIMAGEDIGEST 50972 /* &md5 of raw image data */ -#define TIFFTAG_ORIGINALRAWFILEDIGEST 50973 /* &md5 of the data stored in the OriginalRawFileData tag */ -#define TIFFTAG_SUBTILEBLOCKSIZE 50974 /* &subtile block size */ -#define TIFFTAG_ROWINTERLEAVEFACTOR 50975 /* &number of interleaved fields */ -#define TIFFTAG_PROFILELOOKTABLEDIMS 50981 /* &num of input samples in each dim of default "look" table */ -#define TIFFTAG_PROFILELOOKTABLEDATA 50982 /* &default "look" table for use as starting point */ +#define TIFFTAG_RPCCOEFFICIENT 50844 /* Define by GDAL for geospatial georeferencing through RPC: http://geotiff.maptools.org/rpc_prop.html */ -/* DNG 1.3.0.0 */ -#define TIFFTAG_OPCODELIST1 51008 /* &opcodes that should be applied to raw image after reading */ -#define TIFFTAG_OPCODELIST2 51009 /* &opcodes that should be applied after mapping to linear reference */ -#define TIFFTAG_OPCODELIST3 51022 /* &opcodes that should be applied after demosaicing */ -#define TIFFTAG_NOISEPROFILE 51041 /* &noise profile */ - -/* DNG 1.4.0.0 */ -#define TIFFTAG_DEFAULTUSERCROP 51125 /* &default user crop rectangle in relative coords */ -#define TIFFTAG_DEFAULTBLACKRENDER 51110 /* &black rendering hint */ -#define TIFFTAG_BASELINEEXPOSUREOFFSET 51109 /* &baseline exposure offset */ -#define TIFFTAG_PROFILELOOKTABLEENCODING 51108 /* &3D LookTable indexing conversion */ -#define TIFFTAG_PROFILEHUESATMAPENCODING 51107 /* &3D HueSatMap indexing conversion */ -#define TIFFTAG_ORIGINALDEFAULTFINALSIZE 51089 /* &default final size of larger original file for this proxy */ -#define TIFFTAG_ORIGINALBESTQUALITYFINALSIZE 51090 /* &best quality final size of larger original file for this proxy */ -#define TIFFTAG_ORIGINALDEFAULTCROPSIZE 51091 /* &the default crop size of larger original file for this proxy */ -#define TIFFTAG_NEWRAWIMAGEDIGEST 51111 /* &modified MD5 digest of the raw image data */ -#define TIFFTAG_RAWTOPREVIEWGAIN 51112 /* &The gain between the main raw FD and the preview IFD containing this tag */ - -/* DNG 1.5.0.0 */ -#define TIFFTAG_DEPTHFORMAT 51177 /* &encoding of the depth data in the file */ -#define TIFFTAG_DEPTHNEAR 51178 /* &distance from the camera represented by value 0 in the depth map */ -#define TIFFTAG_DEPTHFAR 51179 /* &distance from the camera represented by the maximum value in the depth map */ -#define TIFFTAG_DEPTHUNITS 51180 /* &measurement units for DepthNear and DepthFar */ -#define TIFFTAG_DEPTHMEASURETYPE 51181 /* &measurement geometry for the depth map */ -#define TIFFTAG_ENHANCEPARAMS 51182 /* &a string that documents how the enhanced image data was processed. */ - -/* DNG 1.6.0.0 */ -#define TIFFTAG_PROFILEGAINTABLEMAP 52525 /* &spatially varying gain tables that can be applied as starting point */ -#define TIFFTAG_SEMANTICNAME 52526 /* &a string that identifies the semantic mask */ -#define TIFFTAG_SEMANTICINSTANCEID 52528 /* &a string that identifies a specific instance in a semantic mask */ -#define TIFFTAG_MASKSUBAREA 52536 /* &the crop rectangle of this IFD's mask, relative to the main image */ -#define TIFFTAG_RGBTABLES 52543 /* &color transforms to apply to masked image regions */ -#define TIFFTAG_CALIBRATIONILLUMINANT3 52529 /* &the illuminant used for the third set of color calibration tags */ -#define TIFFTAG_COLORMATRIX3 52531 /* &matrix to convert XYZ values to reference camera native color space under CalibrationIlluminant3 */ -#define TIFFTAG_CAMERACALIBRATION3 52530 /* &matrix to transform reference camera native space values to individual camera native space values under CalibrationIlluminant3 */ -#define TIFFTAG_REDUCTIONMATRIX3 52538 /* &dimensionality reduction matrix for use in color conversion to XYZ under CalibrationIlluminant3 */ -#define TIFFTAG_PROFILEHUESATMAPDATA3 52537 /* &the data for the third HSV table */ -#define TIFFTAG_FORWARDMATRIX3 52532 /* &matrix to map white balanced camera colors to XYZ D50 */ -#define TIFFTAG_ILLUMINANTDATA1 52533 /* &data for the first calibration illuminant */ -#define TIFFTAG_ILLUMINANTDATA2 52534 /* &data for the second calibration illuminant */ -#define TIFFTAG_ILLUMINANTDATA3 53535 /* &data for the third calibration illuminant */ - -/* TIFF/EP */ -#define TIFFTAG_EP_CFAREPEATPATTERNDIM 33421 /* dimensions of CFA pattern */ -#define TIFFTAG_EP_CFAPATTERN 33422 /* color filter array pattern */ -#define TIFFTAG_EP_BATTERYLEVEL 33423 /* battery level (rational or ASCII) */ -#define TIFFTAG_EP_INTERLACE 34857 /* Number of multi-field images */ -/* TIFFTAG_EP_IPTC_NAA and TIFFTAG_RICHTIFFIPTC share the same tag number (33723) - * LibTIFF type is UNDEFINED or BYTE, but often times incorrectly specified as LONG, - * because TIFF/EP (ISO/DIS 12234-2) specifies type LONG or ASCII. */ -#define TIFFTAG_EP_IPTC_NAA 33723 /* Alias IPTC/NAA Newspaper Association RichTIFF */ -#define TIFFTAG_EP_TIMEZONEOFFSET 34858 /* Time zone offset relative to UTC */ -#define TIFFTAG_EP_SELFTIMERMODE 34859 /* Number of seconds capture was delayed from button press */ -#define TIFFTAG_EP_FLASHENERGY 37387 /* Flash energy, or range if there is uncertainty */ -#define TIFFTAG_EP_SPATIALFREQUENCYRESPONSE 37388 /* Spatial frequency response */ -#define TIFFTAG_EP_NOISE 37389 /* Camera noise measurement values */ -#define TIFFTAG_EP_FOCALPLANEXRESOLUTION 37390 /* Focal plane X resolution */ -#define TIFFTAG_EP_FOCALPLANEYRESOLUTION 37391 /* Focal plane Y resolution */ -#define TIFFTAG_EP_FOCALPLANERESOLUTIONUNIT 37392 /* Focal plane resolution unit */ -#define TIFFTAG_EP_IMAGENUMBER 37393 /* Number of image when several of burst shot stored in same TIFF/EP */ -#define TIFFTAG_EP_SECURITYCLASSIFICATION 37394 /* Security classification */ -#define TIFFTAG_EP_IMAGEHISTORY 37395 /* Record of what has been done to the image */ -#define TIFFTAG_EP_EXPOSUREINDEX 37397 /* Exposure index */ -#define TIFFTAG_EP_STANDARDID 37398 /* TIFF/EP standard version, n.n.n.n */ -#define TIFFTAG_EP_SENSINGMETHOD 37399 /* Type of image sensor */ -/* - * TIFF/EP tags equivalent to EXIF tags - * Note that TIFF-EP and EXIF use nearly the same metadata tag set, but TIFF-EP stores the tags in IFD 0, - * while EXIF store the tags in a separate IFD. Either location is allowed by DNG, but the EXIF location is preferred. - */ -#define TIFFTAG_EP_EXPOSURETIME 33434 /* Exposure time */ -#define TIFFTAG_EP_FNUMBER 33437 /* F number */ -#define TIFFTAG_EP_EXPOSUREPROGRAM 34850 /* Exposure program */ -#define TIFFTAG_EP_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ -#define TIFFTAG_EP_ISOSPEEDRATINGS 34855 /* ISO speed rating */ -#define TIFFTAG_EP_OECF 34856 /* Optoelectric conversion factor */ -#define TIFFTAG_EP_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ -#define TIFFTAG_EP_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ -#define TIFFTAG_EP_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ -#define TIFFTAG_EP_APERTUREVALUE 37378 /* Aperture */ -#define TIFFTAG_EP_BRIGHTNESSVALUE 37379 /* Brightness */ -#define TIFFTAG_EP_EXPOSUREBIASVALUE 37380 /* Exposure bias */ -#define TIFFTAG_EP_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ -#define TIFFTAG_EP_SUBJECTDISTANCE 37382 /* Subject distance */ -#define TIFFTAG_EP_METERINGMODE 37383 /* Metering mode */ -#define TIFFTAG_EP_LIGHTSOURCE 37384 /* Light source */ -#define TIFFTAG_EP_FLASH 37385 /* Flash */ -#define TIFFTAG_EP_FOCALLENGTH 37386 /* Lens focal length */ -#define TIFFTAG_EP_SUBJECTLOCATION 37396 /* Subject location (area) */ - -#define TIFFTAG_RPCCOEFFICIENT 50844 /* Define by GDAL for geospatial georeferencing through RPC: http://geotiff.maptools.org/rpc_prop.html */ -#define TIFFTAG_ALIAS_LAYER_METADATA 50784 /* Alias Sketchbook Pro layer usage description. */ +#define TIFFTAG_ALIAS_LAYER_METADATA 50784 /* Alias Sketchbook Pro layer usage description. */ /* GeoTIFF DGIWG */ -#define TIFFTAG_TIFF_RSID 50908 /* https://www.awaresystems.be/imaging/tiff/tifftags/tiff_rsid.html */ -#define TIFFTAG_GEO_METADATA 50909 /* https://www.awaresystems.be/imaging/tiff/tifftags/geo_metadata.html */ -#define TIFFTAG_EXTRACAMERAPROFILES 50933 /* http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf */ +#define TIFFTAG_TIFF_RSID 50908 /* https://www.awaresystems.be/imaging/tiff/tifftags/tiff_rsid.html */ +#define TIFFTAG_GEO_METADATA 50909 /* https://www.awaresystems.be/imaging/tiff/tifftags/geo_metadata.html */ + +#define TIFFTAG_EXTRACAMERAPROFILES 50933 /* http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf */ /* tag 65535 is an undefined tag used by Eastman Kodak */ -#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ +#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ /* * The following are ``pseudo tags'' that can be used to control @@ -693,206 +590,211 @@ typedef enum * http://www.remotesensing.org/libtiff/bugs.html with the appropriate * C definitions to add. */ -#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ -#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ -#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ -#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ -#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ -#define FAXMODE_WORDALIGN 0x0008 /* word align row */ -#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ -#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ +#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ +#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ +#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ +#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ +#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ +#define FAXMODE_WORDALIGN 0x0008 /* word align row */ +#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ +#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ /* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ -#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ -#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ -#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ -#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ -#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ -#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ +#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ +#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ +#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ +#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ +#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ +#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ -#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ -#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ -#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ -#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ -#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ -#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ -#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ -#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ +#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ +#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ +#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ +#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ +#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ +#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ +#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ +#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ /* 65550-65556 are allocated to Oceana Matrix */ -#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ -#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ -#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ -#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ -#define DCSIMAGERFILTER_IR 0 /* infrared filter */ -#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ -#define DCSIMAGERFILTER_CFA 2 /* color filter array */ -#define DCSIMAGERFILTER_OTHER 3 /* other filter */ -#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ -#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ -#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ -#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ -#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ -#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ -#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ -#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ +#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ +#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ +#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ +#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ +#define DCSIMAGERFILTER_IR 0 /* infrared filter */ +#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ +#define DCSIMAGERFILTER_CFA 2 /* color filter array */ +#define DCSIMAGERFILTER_OTHER 3 /* other filter */ +#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ +#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ +#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ +#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ +#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ +#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ +#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ +#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ /* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ -#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ -#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ +#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ +#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ /* 65559 is allocated to Oceana Matrix */ -#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ -#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ -#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ -#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ -#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ -#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ -#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ -#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ -#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ -#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ -#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ -#define PERSAMPLE_MERGED 0 /* present as a single value */ -#define PERSAMPLE_MULTI 1 /* present as multiple values */ -#define TIFFTAG_ZSTD_LEVEL 65564 /* ZSTD compression level */ -#define TIFFTAG_LERC_VERSION 65565 /* LERC version */ -#define LERC_VERSION_2_4 4 -#define TIFFTAG_LERC_ADD_COMPRESSION 65566 /* LERC additional compression */ -#define LERC_ADD_COMPRESSION_NONE 0 -#define LERC_ADD_COMPRESSION_DEFLATE 1 -#define LERC_ADD_COMPRESSION_ZSTD 2 -#define TIFFTAG_LERC_MAXZERROR 65567 /* LERC maximum error */ -#define TIFFTAG_WEBP_LEVEL 65568 /* WebP compression level */ -#define TIFFTAG_WEBP_LOSSLESS 65569 /* WebP lossless/lossy */ -#define TIFFTAG_DEFLATE_SUBCODEC 65570 /* ZIP codec: to get/set the sub-codec to use. Will default to libdeflate when available */ -#define DEFLATE_SUBCODEC_ZLIB 0 -#define DEFLATE_SUBCODEC_LIBDEFLATE 1 +#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ +#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ +#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ +#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ +#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ +#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ +#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ +#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ +#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ +#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ +#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ +#define PERSAMPLE_MERGED 0 /* present as a single value */ +#define PERSAMPLE_MULTI 1 /* present as multiple values */ +#define TIFFTAG_ZSTD_LEVEL 65564 /* ZSTD compression level */ +#define TIFFTAG_LERC_VERSION 65565 /* LERC version */ +#define LERC_VERSION_2_4 4 +#define TIFFTAG_LERC_ADD_COMPRESSION 65566 /* LERC additional compression */ +#define LERC_ADD_COMPRESSION_NONE 0 +#define LERC_ADD_COMPRESSION_DEFLATE 1 +#define LERC_ADD_COMPRESSION_ZSTD 2 +#define TIFFTAG_LERC_MAXZERROR 65567 /* LERC maximum error */ +#define TIFFTAG_WEBP_LEVEL 65568 /* WebP compression level */ +#define TIFFTAG_WEBP_LOSSLESS 65569 /* WebP lossless/lossy */ +#define TIFFTAG_DEFLATE_SUBCODEC 65570 /* ZIP codec: to get/set the sub-codec to use. Will default to libdeflate when available */ +#define DEFLATE_SUBCODEC_ZLIB 0 +#define DEFLATE_SUBCODEC_LIBDEFLATE 1 /* * EXIF tags */ -#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ -#define EXIFTAG_FNUMBER 33437 /* F number */ -#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ -#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ -/* After EXIF 2.2.1 ISOSpeedRatings is named PhotographicSensitivity. - In addition, while "Count=Any", only 1 count should be used. */ -#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ -#define EXIFTAG_PHOTOGRAPHICSENSITIVITY 34855 /* Photographic Sensitivity (new name for tag 34855) */ -#define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ -#define EXIFTAG_EXIFVERSION 36864 /* Exif version */ -#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ -#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital data generation */ -#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ -#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ -#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ -#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ -#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ -#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ -#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ -#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ -#define EXIFTAG_METERINGMODE 37383 /* Metering mode */ -#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ -#define EXIFTAG_FLASH 37385 /* Flash */ -#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ -#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ -#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ -#define EXIFTAG_USERCOMMENT 37510 /* User comments */ -#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ -#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ -#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ -#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ -#define EXIFTAG_COLORSPACE 40961 /* Color space information */ -#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ -#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ -#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ -#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ -#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ -#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ -#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ -#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ -#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ -#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ -#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ -#define EXIFTAG_FILESOURCE 41728 /* File source */ -#define EXIFTAG_SCENETYPE 41729 /* Scene type */ -#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ -#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ -#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ -#define EXIFTAG_WHITEBALANCE 41987 /* White balance */ -#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ -#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ -#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_CONTRAST 41992 /* Contrast */ -#define EXIFTAG_SATURATION 41993 /* Saturation */ -#define EXIFTAG_SHARPNESS 41994 /* Sharpness */ -#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ -#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ -#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ +#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ +#define EXIFTAG_FNUMBER 33437 /* F number */ +#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ +#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ +#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ +#define EXIFTAG_PHOTOGRAPHICSENSITIVITY 34855 /* Photographic Sensitivity (new name for tag 34855) */ +#define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ +#define EXIFTAG_EXIFVERSION 36864 /* Exif version */ +#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original + data generation */ +#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital + data generation */ +#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ +#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ +#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ +#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ +#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ +#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ +#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ +#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ +#define EXIFTAG_METERINGMODE 37383 /* Metering mode */ +#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ +#define EXIFTAG_FLASH 37385 /* Flash */ +#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ +#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ +#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ +#define EXIFTAG_USERCOMMENT 37510 /* User comments */ +#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ +#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ +#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ +#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ +#define EXIFTAG_COLORSPACE 40961 /* Color space information */ +#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ +#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ +#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ +#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ +#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ +#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ +#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ +#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ +#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ +#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ +#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ +#define EXIFTAG_FILESOURCE 41728 /* File source */ +#define EXIFTAG_SCENETYPE 41729 /* Scene type */ +#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ +#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ +#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ +#define EXIFTAG_WHITEBALANCE 41987 /* White balance */ +#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ +#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ +#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ +#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ +#define EXIFTAG_CONTRAST 41992 /* Contrast */ +#define EXIFTAG_SATURATION 41993 /* Saturation */ +#define EXIFTAG_SHARPNESS 41994 /* Sharpness */ +#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ +#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ +#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ /*--: New for EXIF-Version 2.32, May 2019 ... */ -#define EXIFTAG_SENSITIVITYTYPE 34864 /* The SensitivityType tag indicates which one of the parameters of ISO12232 is the PhotographicSensitivity tag. */ -#define EXIFTAG_STANDARDOUTPUTSENSITIVITY 34865 /* This tag indicates the standard output sensitivity value of a camera or input device defined in ISO 12232. */ -#define EXIFTAG_RECOMMENDEDEXPOSUREINDEX 34866 /* recommended exposure index */ -#define EXIFTAG_ISOSPEED 34867 /* ISO speed value */ -#define EXIFTAG_ISOSPEEDLATITUDEYYY 34868 /* ISO speed latitude yyy */ -#define EXIFTAG_ISOSPEEDLATITUDEZZZ 34869 /* ISO speed latitude zzz */ -#define EXIFTAG_OFFSETTIME 36880 /* offset from UTC of the time of DateTime tag. */ -#define EXIFTAG_OFFSETTIMEORIGINAL 36881 /* offset from UTC of the time of DateTimeOriginal tag. */ -#define EXIFTAG_OFFSETTIMEDIGITIZED 36882 /* offset from UTC of the time of DateTimeDigitized tag. */ -#define EXIFTAG_TEMPERATURE 37888 /* Temperature as the ambient situation at the shot in dergee Celsius */ -#define EXIFTAG_HUMIDITY 37889 /* Humidity as the ambient situation at the shot in percent */ -#define EXIFTAG_PRESSURE 37890 /* Pressure as the ambient situation at the shot hecto-Pascal (hPa) */ -#define EXIFTAG_WATERDEPTH 37891 /* WaterDepth as the ambient situation at the shot in meter (m) */ -#define EXIFTAG_ACCELERATION 37892 /* Acceleration (a scalar regardless of direction) as the ambientsituation at the shot in units of mGal (10-5 m/s^2) */ -/* EXIFTAG_CAMERAELEVATIONANGLE: Elevation/depression. angle of the orientation of the camera(imaging optical axis) - * as the ambient situation at the shot in degree from -180deg to +180deg. */ -#define EXIFTAG_CAMERAELEVATIONANGLE 37893 -#define EXIFTAG_CAMERAOWNERNAME 42032 /* owner of a camera */ -#define EXIFTAG_BODYSERIALNUMBER 42033 /* serial number of the body of the camera */ -/* EXIFTAG_LENSSPECIFICATION: minimum focal length (in mm), maximum focal length (in mm),minimum F number in the minimum focal length, - * and minimum F number in the maximum focal length, */ -#define EXIFTAG_LENSSPECIFICATION 42034 -#define EXIFTAG_LENSMAKE 42035 /* the lens manufacturer */ -#define EXIFTAG_LENSMODEL 42036 /* the lens model name and model number */ -#define EXIFTAG_LENSSERIALNUMBER 42037 /* the serial number of the interchangeable lens */ -#define EXIFTAG_GAMMA 42240 /* value of coefficient gamma */ -#define EXIFTAG_COMPOSITEIMAGE 42080 /* composite image */ -#define EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE 42081 /* source image number of composite image */ -#define EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE 42082 /* source exposure times of composite image */ +#define EXIFTAG_SENSITIVITYTYPE 34864 /* The SensitivityType tag indicates which one of the parameters of ISO12232 is the PhotographicSensitivity tag. */ +#define EXIFTAG_STANDARDOUTPUTSENSITIVITY 34865 /* This tag indicates the standard output sensitivity value of a camera or input device defined in ISO 12232. */ +#define EXIFTAG_RECOMMENDEDEXPOSUREINDEX 34866 /* recommended exposure index */ +#define EXIFTAG_ISOSPEED 34867 /* ISO speed value */ +#define EXIFTAG_ISOSPEEDLATITUDEYYY 34868 /* ISO speed latitude yyy */ +#define EXIFTAG_ISOSPEEDLATITUDEZZZ 34869 /* ISO speed latitude zzz */ +#define EXIFTAG_OFFSETTIME 36880 /* offset from UTC of the time of DateTime tag. */ +#define EXIFTAG_OFFSETTIMEORIGINAL 36881 /* offset from UTC of the time of DateTimeOriginal tag. */ +#define EXIFTAG_OFFSETTIMEDIGITIZED 36882 /* offset from UTC of the time of DateTimeDigitized tag. */ +#define EXIFTAG_TEMPERATURE 37888 /* Temperature as the ambient situation at the shot in dergee Celsius */ +#define EXIFTAG_HUMIDITY 37889 /* Humidity as the ambient situation at the shot in percent */ +#define EXIFTAG_PRESSURE 37890 /* Pressure as the ambient situation at the shot hecto-Pascal (hPa) */ +#define EXIFTAG_WATERDEPTH 37891 /* WaterDepth as the ambient situation at the shot in meter (m) */ +#define EXIFTAG_ACCELERATION 37892 /* Acceleration (a scalar regardless of direction) as the ambient situation at the shot in units of mGal (10-5 m/s^2) */ +#define EXIFTAG_CAMERAELEVATIONANGLE 37893 /* Elevation/depression. angle of the orientation of the camera(imaging optical axis) as the ambient situation at the shot in degree from -180deg to +180deg. */ +#define EXIFTAG_CAMERAOWNERNAME 42032 /* owner of a camera */ +#define EXIFTAG_BODYSERIALNUMBER 42033 /* serial number of the body of the camera */ +#define EXIFTAG_LENSSPECIFICATION 42034 /* minimum focal length (in mm), maximum focal length (in mm), minimum F number in the minimum focal length, and minimum F number in the maximum focal length, */ +#define EXIFTAG_LENSMAKE 42035 /* the lens manufacturer */ +#define EXIFTAG_LENSMODEL 42036 /* the lens model name and model number */ +#define EXIFTAG_LENSSERIALNUMBER 42037 /* the serial number of the interchangeable lens */ +#define EXIFTAG_GAMMA 42240 /* value of coefficient gamma */ +#define EXIFTAG_COMPOSITEIMAGE 42080 /* composite image */ +#define EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE 42081 /* source image number of composite image */ +#define EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE 42082 /* source exposure times of composite image */ /* * EXIF-GPS tags (Version 2.31, July 2016) */ -#define GPSTAG_VERSIONID 0 /* Indicates the version of GPSInfoIFD. */ -#define GPSTAG_LATITUDEREF 1 /* Indicates whether the latitude is north or south latitude. */ -#define GPSTAG_LATITUDE 2 /* Indicates the latitude. */ -#define GPSTAG_LONGITUDEREF 3 /* Indicates whether the longitude is east or west longitude. */ -#define GPSTAG_LONGITUDE 4 /* Indicates the longitude. */ -#define GPSTAG_ALTITUDEREF 5 /* Indicates the altitude used as the reference altitude. */ -#define GPSTAG_ALTITUDE 6 /* Indicates the altitude based on the reference in GPSAltitudeRef. */ -#define GPSTAG_TIMESTAMP 7 /*Indicates the time as UTC (Coordinated Universal Time). */ -#define GPSTAG_SATELLITES 8 /*Indicates the GPS satellites used for measurements. */ -#define GPSTAG_STATUS 9 /* Indicates the status of the GPS receiver when the image is recorded. */ -#define GPSTAG_MEASUREMODE 10 /* Indicates the GPS measurement mode. */ -#define GPSTAG_DOP 11 /* Indicates the GPS DOP (data degree of precision). */ -#define GPSTAG_SPEEDREF 12 /* Indicates the unit used to express the GPS receiver speed of movement. */ -#define GPSTAG_SPEED 13 /* Indicates the speed of GPS receiver movement. */ -#define GPSTAG_TRACKREF 14 /* Indicates the reference for giving the direction of GPS receiver movement. */ -#define GPSTAG_TRACK 15 /* Indicates the direction of GPS receiver movement. */ -#define GPSTAG_IMGDIRECTIONREF 16 /* Indicates the reference for giving the direction of the image when it is captured. */ -#define GPSTAG_IMGDIRECTION 17 /* Indicates the direction of the image when it was captured. */ -#define GPSTAG_MAPDATUM 18 /* Indicates the geodetic survey data used by the GPS receiver. (e.g. WGS-84) */ -#define GPSTAG_DESTLATITUDEREF 19 /* Indicates whether the latitude of the destination point is north or south latitude. */ -#define GPSTAG_DESTLATITUDE 20 /* Indicates the latitude of the destination point. */ -#define GPSTAG_DESTLONGITUDEREF 21 /* Indicates whether the longitude of the destination point is east or west longitude. */ -#define GPSTAG_DESTLONGITUDE 22 /* Indicates the longitude of the destination point. */ -#define GPSTAG_DESTBEARINGREF 23 /* Indicates the reference used for giving the bearing to the destination point. */ -#define GPSTAG_DESTBEARING 24 /* Indicates the bearing to the destination point. */ -#define GPSTAG_DESTDISTANCEREF 25 /* Indicates the unit used to express the distance to the destination point. */ -#define GPSTAG_DESTDISTANCE 26 /* Indicates the distance to the destination point. */ -#define GPSTAG_PROCESSINGMETHOD 27 /* A character string recording the name of the method used for location finding. */ -#define GPSTAG_AREAINFORMATION 28 /* A character string recording the name of the GPS area. */ -#define GPSTAG_DATESTAMP 29 /* A character string recording date and time information relative to UTC (Coordinated Universal Time). */ -#define GPSTAG_DIFFERENTIAL 30 /* Indicates whether differential correction is applied to the GPS receiver. */ -#define GPSTAG_GPSHPOSITIONINGERROR 31 /* Indicates horizontal positioning errors in meters. */ +#define GPSTAG_VERSIONID 0 /* Indicates the version of GPSInfoIFD. */ +#define GPSTAG_LATITUDEREF 1 /* Indicates whether the latitude is north or south latitude. */ +#define GPSTAG_LATITUDE 2 /* Indicates the latitude. */ +#define GPSTAG_LONGITUDEREF 3 /* Indicates whether the longitude is east or west longitude. */ +#define GPSTAG_LONGITUDE 4 /* Indicates the longitude. */ +#define GPSTAG_ALTITUDEREF 5 /* Indicates the altitude used as the reference altitude. */ +#define GPSTAG_ALTITUDE 6 /* Indicates the altitude based on the reference in GPSAltitudeRef. */ +#define GPSTAG_TIMESTAMP 7 /* Indicates the time as UTC (Coordinated Universal Time). */ +#define GPSTAG_SATELLITES 8 /* Indicates the GPS satellites used for measurements. */ +#define GPSTAG_STATUS 9 /* Indicates the status of the GPS receiver when the image is recorded. */ +#define GPSTAG_MEASUREMODE 10 /* Indicates the GPS measurement mode. */ +#define GPSTAG_DOP 11 /* Indicates the GPS DOP (data degree of precision). */ +#define GPSTAG_SPEEDREF 12 /* Indicates the unit used to express the GPS receiver speed of movement. */ +#define GPSTAG_SPEED 13 /* Indicates the speed of GPS receiver movement. */ +#define GPSTAG_TRACKREF 14 /* Indicates the reference for giving the direction of GPS receiver movement. */ +#define GPSTAG_TRACK 15 /* Indicates the direction of GPS receiver movement. */ +#define GPSTAG_IMGDIRECTIONREF 16 /* Indicates the reference for giving the direction of the image when it is captured. */ +#define GPSTAG_IMGDIRECTION 17 /* Indicates the direction of the image when it was captured. */ +#define GPSTAG_MAPDATUM 18 /* Indicates the geodetic survey data used by the GPS receiver. (e.g. WGS-84) */ +#define GPSTAG_DESTLATITUDEREF 19 /* Indicates whether the latitude of the destination point is north or south latitude. */ +#define GPSTAG_DESTLATITUDE 20 /* Indicates the latitude of the destination point. */ +#define GPSTAG_DESTLONGITUDEREF 21 /* Indicates whether the longitude of the destination point is east or west longitude. */ +#define GPSTAG_DESTLONGITUDE 22 /* Indicates the longitude of the destination point. */ +#define GPSTAG_DESTBEARINGREF 23 /* Indicates the reference used for giving the bearing to the destination point. */ +#define GPSTAG_DESTBEARING 24 /* Indicates the bearing to the destination point. */ +#define GPSTAG_DESTDISTANCEREF 25 /* Indicates the unit used to express the distance to the destination point. */ +#define GPSTAG_DESTDISTANCE 26 /* Indicates the distance to the destination point. */ +#define GPSTAG_PROCESSINGMETHOD 27 /* A character string recording the name of the method used for location finding. */ +#define GPSTAG_AREAINFORMATION 28 /* A character string recording the name of the GPS area. */ +#define GPSTAG_DATESTAMP 29 /* A character string recording date and time information relative to UTC (Coordinated Universal Time). */ +#define GPSTAG_DIFFERENTIAL 30 /* Indicates whether differential correction is applied to the GPS receiver. */ +#define GPSTAG_GPSHPOSITIONINGERROR 31 /* Indicates horizontal positioning errors in meters. */ #endif /* _TIFF_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/VisualC/external/include/tiffconf.h b/thirdparty/SDL2_image/VisualC/external/include/tiffconf.h index 1aad690e0..7bd087a34 100644 --- a/thirdparty/SDL2_image/VisualC/external/include/tiffconf.h +++ b/thirdparty/SDL2_image/VisualC/external/include/tiffconf.h @@ -5,68 +5,50 @@ from this file in your programs. */ -/* clang-format off */ -/* clang-format disabled because CMake scripts are very sensitive to the - * formatting of this file. configure_file variables of type "@VAR@" are - * modified by clang-format and won't be substituted. - */ - #ifndef _TIFFCONF_ #define _TIFFCONF_ - -#include -#include -#include - - /* Signed 16-bit type */ -/* #undef TIFF_INT16_T */ +#define TIFF_INT16_T signed short /* Signed 32-bit type */ -/* #undef TIFF_INT32_T */ +#define TIFF_INT32_T signed int /* Signed 64-bit type */ -/* #undef TIFF_INT64_T */ +#define TIFF_INT64_T signed long long /* Signed 8-bit type */ -/* #undef TIFF_INT8_T */ +#define TIFF_INT8_T signed char /* Unsigned 16-bit type */ -/* #undef TIFF_UINT16_T */ +#define TIFF_UINT16_T unsigned short /* Unsigned 32-bit type */ -/* #undef TIFF_UINT32_T */ +#define TIFF_UINT32_T unsigned int /* Unsigned 64-bit type */ -/* #undef TIFF_UINT64_T */ +#define TIFF_UINT64_T unsigned long long /* Unsigned 8-bit type */ -/* #undef TIFF_UINT8_T */ +#define TIFF_UINT8_T unsigned char /* Signed size type */ #if defined _WIN64 -#define TIFF_SSIZE_T int64_t +#define TIFF_SSIZE_T signed long long #else -#define TIFF_SSIZE_T int32_t +#define TIFF_SSIZE_T signed int #endif +/* Pointer difference type */ +#define TIFF_PTRDIFF_T ptrdiff_t + /* Compatibility stuff. */ -/* Define as 0 or 1 according to the floating point format supported by the +/* Define as 0 or 1 according to the floating point format suported by the machine */ #define HAVE_IEEEFP 1 -/* The concept of HOST_FILLORDER is broken. Since libtiff 4.5.1 - * this macro will always be hardcoded to FILLORDER_LSB2MSB on all - * architectures, to reflect past long behavior of doing so on x86 architecture. - * Note however that the default FillOrder used by libtiff is FILLORDER_MSB2LSB, - * as mandated per the TIFF specification. - * The influence of HOST_FILLORDER is only when passing the 'H' mode in - * TIFFOpen(). - * You should NOT rely on this macro to decide the CPU endianness! - * This macro will be removed in libtiff 4.6 - */ +/* 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 @@ -82,9 +64,6 @@ /* Support JBIG compression (requires JBIG-KIT library) */ /* #undef JBIG_SUPPORT */ -/* Support LERC compression */ -/* #undef LERC_SUPPORT */ - /* Support LogLuv high dynamic range encoding */ #define LOGLUV_SUPPORT 1 @@ -114,7 +93,7 @@ /* #undef LIBDEFLATE_SUPPORT */ /* Support strip chopping (whether or not to convert single-strip uncompressed - images to multiple strips of ~8Kb to reduce memory usage) */ + images to mutiple strips of ~8Kb to reduce memory usage) */ #define STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* Enable SubIFD tag (330) support */ @@ -127,7 +106,7 @@ /* Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 +/* #undef CHECK_JPEG_YCBCR_SUBSAMPLING */ /* Support MS MDI magic number files as TIFF */ #define MDI_SUPPORT 1 @@ -145,5 +124,3 @@ #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ - -/* clang-format on */ diff --git a/thirdparty/SDL2_image/VisualC/external/include/tiffio.h b/thirdparty/SDL2_image/VisualC/external/include/tiffio.h index d6bf0cc54..9eac24940 100644 --- a/thirdparty/SDL2_image/VisualC/external/include/tiffio.h +++ b/thirdparty/SDL2_image/VisualC/external/include/tiffio.h @@ -23,7 +23,7 @@ */ #ifndef _TIFFIO_ -#define _TIFFIO_ +#define _TIFFIO_ /* * TIFF I/O Library Definitions. @@ -60,22 +60,20 @@ typedef struct tiff TIFF; */ /* * this is the machine addressing size type, only it's signed, so make it - * int32_t on 32bit machines, int64_t on 64bit machines + * int32 on 32bit machines, int64 on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; -#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1) - -typedef uint64_t toff_t; /* file offset */ +typedef uint64 toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ -typedef uint32_t ttag_t; /* directory tag */ -typedef uint32_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 */ -typedef void *tdata_t; /* image data ref */ +typedef uint32 ttag_t; /* directory tag */ +typedef uint16 tdir_t; /* directory index */ +typedef uint16 tsample_t; /* sample number */ +typedef uint32 tstrile_t; /* strip or tile number */ +typedef tstrile_t tstrip_t; /* strip number */ +typedef tstrile_t ttile_t; /* tile number */ +typedef tmsize_t tsize_t; /* i/o size in bytes */ +typedef void* tdata_t; /* image data ref */ #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) #define __WIN32__ @@ -89,22 +87,21 @@ typedef void *tdata_t; /* image data ref */ */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -#if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && \ - !defined(USE_WIN32_FILEIO) -#define AVOID_WIN32_FILEIO -#endif +# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) +# define AVOID_WIN32_FILEIO +# endif #endif #if defined(USE_WIN32_FILEIO) -#define VC_EXTRALEAN -#include -#ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ +# define VC_EXTRALEAN +# include +# ifdef __WIN32__ +DECLARE_HANDLE(thandle_t); /* Win32 file handle */ +# else +typedef HFILE thandle_t; /* client data handle */ +# endif /* __WIN32__ */ #else -typedef HFILE thandle_t; /* client data handle */ -#endif /* __WIN32__ */ -#else -typedef void *thandle_t; /* client data handle */ +typedef void* thandle_t; /* client data handle */ #endif /* USE_WIN32_FILEIO */ /* @@ -113,15 +110,15 @@ typedef void *thandle_t; /* client data handle */ * very large. Bit-or these flags to enable printing * multiple items. */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ +#define TIFFPRINT_NONE 0x0 /* no extra info */ +#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ +#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ +#define TIFFPRINT_COLORMAP 0x4 /* colormap */ +#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ +#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ +#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ -/* +/* * Colour conversion stuff */ @@ -136,45 +133,42 @@ typedef void *thandle_t; /* client data handle */ /* Structure for holding information about a display device. */ -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ +typedef unsigned char TIFFRGBValue; /* 8-bit samples */ -typedef struct -{ - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCR; /* Light o/p for reference white */ - float d_YCG; - float d_YCB; - uint32_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; - float d_gammaR; /* Gamma values for the three guns */ - float d_gammaG; - float d_gammaB; +typedef struct { + float d_mat[3][3]; /* XYZ -> luminance matrix */ + float d_YCR; /* Light o/p for reference white */ + float d_YCG; + float d_YCB; + uint32 d_Vrwr; /* Pixel values for ref. white */ + uint32 d_Vrwg; + uint32 d_Vrwb; + float d_Y0R; /* Residual light for black pixel */ + float d_Y0G; + float d_Y0B; + float d_gammaR; /* Gamma values for the three guns */ + float d_gammaG; + float d_gammaB; } TIFFDisplay; -typedef struct -{ /* YCbCr->RGB support */ - TIFFRGBValue *clamptab; /* range clamping table */ - int *Cr_r_tab; - int *Cb_b_tab; - int32_t *Cr_g_tab; - int32_t *Cb_g_tab; - int32_t *Y_tab; +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; } TIFFYCbCrToRGB; -typedef struct -{ /* CIE Lab 1976->RGB support */ - int range; /* Size of conversion table */ +typedef struct { /* CIE Lab 1976->RGB support */ + int range; /* Size of conversion table */ #define CIELABTORGB_TABLE_RANGE 1500 - float rstep, gstep, bstep; - float X0, Y0, Z0; /* Reference white point */ - TIFFDisplay display; - float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ - float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ - float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ + float rstep, gstep, bstep; + float X0, Y0, Z0; /* Reference white point */ + TIFFDisplay display; + float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ + float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ + float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ } TIFFCIELabToRGB; /* @@ -184,66 +178,63 @@ typedef struct _TIFFRGBAImage TIFFRGBAImage; /* * The image reading and conversion routines invoke * ``put routines'' to copy/image/whatever tiles of - * raw image data. A default set of routines are + * raw image data. A default set of routines are * provided to convert/copy raw image data to 8-bit * packed ABGR format rasters. Applications can supply * alternate routines that unpack the data into a * different format or, for example, unpack the data * and draw the unpacked raster on the display. */ -typedef void (*tileContigRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t, - uint32_t, uint32_t, uint32_t, int32_t, - int32_t, unsigned char *); -typedef void (*tileSeparateRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t, - uint32_t, uint32_t, uint32_t, int32_t, - int32_t, unsigned char *, unsigned char *, - unsigned char *, unsigned char *); +typedef void (*tileContigRoutine) + (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, + unsigned char*); +typedef void (*tileSeparateRoutine) + (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, + unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ -struct _TIFFRGBAImage -{ - TIFF *tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32_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_t *, uint32_t, uint32_t); - /* put decoded strip/tile */ - union - { - void (*any)(TIFFRGBAImage *); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; - TIFFRGBValue *Map; /* sample mapping array */ - 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 */ +struct _TIFFRGBAImage { + TIFF* tif; /* image handle */ + int stoponerr; /* stop on read error */ + int isContig; /* data is packed/separate */ + int alpha; /* type of alpha data present */ + uint32 width; /* image width */ + uint32 height; /* image height */ + uint16 bitspersample; /* image bits/sample */ + uint16 samplesperpixel; /* image samples/pixel */ + uint16 orientation; /* image orientation */ + uint16 req_orientation; /* requested orientation */ + uint16 photometric; /* image photometric interp */ + uint16* redcmap; /* colormap palette */ + uint16* greencmap; + uint16* bluecmap; + /* get image data routine */ + int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); + /* put decoded strip/tile */ + union { + void (*any)(TIFFRGBAImage*); + tileContigRoutine contig; + tileSeparateRoutine separate; + } put; + TIFFRGBValue* Map; /* sample mapping array */ + uint32** BWmap; /* black&white map */ + uint32** PALmap; /* palette image map */ + TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ + TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - uint8_t *UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ - uint8_t *Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ + uint8* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ + uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ - int row_offset; - int col_offset; + int row_offset; + int col_offset; }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ -#define TIFFGetR(abgr) ((abgr)&0xff) +#define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) @@ -255,399 +246,327 @@ struct _TIFFRGBAImage * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ -typedef int (*TIFFInitMethod)(TIFF *, int); -typedef struct -{ - char *name; - uint16_t scheme; - TIFFInitMethod init; +typedef int (*TIFFInitMethod)(TIFF*, int); +typedef struct { + char* name; + uint16 scheme; + TIFFInitMethod init; } TIFFCodec; -typedef struct -{ - uint32_t uNum; - uint32_t uDenom; -} TIFFRational_t; - -#include #include +#include /* share internal LogLuv conversion routines? */ #ifndef LOGLUV_PUBLIC #define LOGLUV_PUBLIC 1 #endif -#if defined(__GNUC__) || defined(__attribute__) -#define TIFF_ATTRIBUTE(x) __attribute__(x) +#if defined(__GNUC__) || defined(__clang__) || defined(__attribute__) +# define TIFF_ATTRIBUTE(x) __attribute__(x) #else -#define TIFF_ATTRIBUTE(x) /*nothing*/ +# define TIFF_ATTRIBUTE(x) /*nothing*/ #endif #if defined(c_plusplus) || defined(__cplusplus) -extern "C" -{ +extern "C" { #endif - typedef void (*TIFFErrorHandler)(const char *, const char *, va_list); - typedef void (*TIFFErrorHandlerExt)(thandle_t, const char *, const char *, - va_list); - typedef int (*TIFFErrorHandlerExtR)(TIFF *, void *user_data, const char *, - const char *, va_list); - typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t); - typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); - typedef int (*TIFFCloseProc)(thandle_t); - typedef toff_t (*TIFFSizeProc)(thandle_t); - typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size); - typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size); - typedef void (*TIFFExtendProc)(TIFF *); +typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); +typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); +typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); +typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); +typedef int (*TIFFCloseProc)(thandle_t); +typedef toff_t (*TIFFSizeProc)(thandle_t); +typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); +typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); +typedef void (*TIFFExtendProc)(TIFF*); - extern const char *TIFFGetVersion(void); +extern const char* TIFFGetVersion(void); - extern const TIFFCodec *TIFFFindCODEC(uint16_t); - extern TIFFCodec *TIFFRegisterCODEC(uint16_t, const char *, TIFFInitMethod); - extern void TIFFUnRegisterCODEC(TIFFCodec *); - extern int TIFFIsCODECConfigured(uint16_t); - extern TIFFCodec *TIFFGetConfiguredCODECs(void); +extern const TIFFCodec* TIFFFindCODEC(uint16); +extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); +extern void TIFFUnRegisterCODEC(TIFFCodec*); +extern int TIFFIsCODECConfigured(uint16); +extern TIFFCodec* TIFFGetConfiguredCODECs(void); - /* - * Auxiliary functions. - */ +/* + * Auxiliary functions. + */ - extern void *_TIFFmalloc(tmsize_t s); - extern void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz); - extern void *_TIFFrealloc(void *p, tmsize_t s); - extern void _TIFFmemset(void *p, int v, tmsize_t c); - extern void _TIFFmemcpy(void *d, const void *s, tmsize_t c); - extern int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c); - extern void _TIFFfree(void *p); +extern void* _TIFFmalloc(tmsize_t s); +extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz); +extern void* _TIFFrealloc(void* p, tmsize_t s); +extern void _TIFFmemset(void* p, int v, tmsize_t c); +extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); +extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); +extern void _TIFFfree(void* p); - /* - ** Stuff, related to tag handling and creating custom tags. - */ - extern int TIFFGetTagListCount(TIFF *); - extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index); +/* +** Stuff, related to tag handling and creating custom tags. +*/ +extern int TIFFGetTagListCount( TIFF * ); +extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); + +#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ +#define TIFF_VARIABLE -1 /* marker for variable length tags */ +#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ +#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ -#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_t var-length tags */ +#define FIELD_CUSTOM 65 -#define FIELD_CUSTOM 65 +typedef struct _TIFFField TIFFField; +typedef struct _TIFFFieldArray TIFFFieldArray; - typedef struct _TIFFField TIFFField; - typedef struct _TIFFFieldArray TIFFFieldArray; +extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); +extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); +extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); - 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 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*); - 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 *); - extern int - TIFFFieldSetGetSize(const TIFFField *); /* returns internal storage size of - TIFFSetGetFieldType in bytes. */ - extern int TIFFFieldSetGetCountSize( - const TIFFField *); /* returns size of count parameter 0=none, - 2=uint16_t, 4=uint32_t */ - extern int TIFFFieldIsAnonymous(const TIFFField *); +typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); +typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); +typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); - typedef int (*TIFFVSetMethod)(TIFF *, uint32_t, va_list); - typedef int (*TIFFVGetMethod)(TIFF *, uint32_t, va_list); - typedef void (*TIFFPrintMethod)(TIFF *, FILE *, long); +typedef struct { + TIFFVSetMethod vsetfield; /* tag set routine */ + TIFFVGetMethod vgetfield; /* tag get routine */ + TIFFPrintMethod printdir; /* directory print routine */ +} TIFFTagMethods; - typedef struct - { - TIFFVSetMethod vsetfield; /* tag set routine */ - TIFFVGetMethod vgetfield; /* tag get routine */ - TIFFPrintMethod printdir; /* directory print routine */ - } TIFFTagMethods; +extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); +extern void *TIFFGetClientInfo(TIFF *, const char *); +extern void TIFFSetClientInfo(TIFF *, void *, const char *); - extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); - extern void *TIFFGetClientInfo(TIFF *, const char *); - extern void TIFFSetClientInfo(TIFF *, void *, const char *); - - 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_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_t TIFFScanlineSize64(TIFF *tif); - extern tmsize_t TIFFScanlineSize(TIFF *tif); - extern uint64_t TIFFRasterScanlineSize64(TIFF *tif); - extern tmsize_t TIFFRasterScanlineSize(TIFF *tif); - extern uint64_t TIFFStripSize64(TIFF *tif); - extern tmsize_t TIFFStripSize(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_t TIFFTileSize64(TIFF *tif); - extern tmsize_t TIFFTileSize(TIFF *tif); - 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 *); - extern thandle_t TIFFSetClientdata(TIFF *, thandle_t); - extern int TIFFGetMode(TIFF *); - extern int TIFFSetMode(TIFF *, int); - extern int TIFFIsTiled(TIFF *); - extern int TIFFIsByteSwapped(TIFF *); - extern int TIFFIsUpSampled(TIFF *); - extern int TIFFIsMSB2LSB(TIFF *); - extern int TIFFIsBigEndian(TIFF *); - extern int TIFFIsBigTIFF(TIFF *); - extern TIFFReadWriteProc TIFFGetReadProc(TIFF *); - extern TIFFReadWriteProc TIFFGetWriteProc(TIFF *); - extern TIFFSeekProc TIFFGetSeekProc(TIFF *); - extern TIFFCloseProc TIFFGetCloseProc(TIFF *); - extern TIFFSizeProc TIFFGetSizeProc(TIFF *); - extern TIFFMapFileProc TIFFGetMapFileProc(TIFF *); - extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *); - extern uint32_t TIFFCurrentRow(TIFF *); - extern tdir_t TIFFCurrentDirectory(TIFF *); - extern tdir_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 *); - extern int TIFFWriteCheck(TIFF *, int, const char *); - extern void TIFFFreeDirectory(TIFF *); - extern int TIFFCreateDirectory(TIFF *); - extern int TIFFCreateCustomDirectory(TIFF *, const TIFFFieldArray *); - extern int TIFFCreateEXIFDirectory(TIFF *); - extern int TIFFCreateGPSDirectory(TIFF *); - extern int TIFFLastDirectory(TIFF *); - extern int TIFFSetDirectory(TIFF *, tdir_t); - extern int TIFFSetSubDirectory(TIFF *, uint64_t); - extern int TIFFUnlinkDirectory(TIFF *, tdir_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_t *); - extern int TIFFCheckpointDirectory(TIFF *); - extern int TIFFRewriteDirectory(TIFF *); - extern int TIFFDeferStrileArrayWriting(TIFF *); - extern int TIFFForceStrileArrayWriting(TIFF *); +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 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 tmsize_t TIFFScanlineSize(TIFF* tif); +extern uint64 TIFFRasterScanlineSize64(TIFF* tif); +extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); +extern uint64 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 tmsize_t TIFFTileRowSize(TIFF* tif); +extern uint64 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 int TIFFFileno(TIFF*); +extern int TIFFSetFileno(TIFF*, int); +extern thandle_t TIFFClientdata(TIFF*); +extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); +extern int TIFFGetMode(TIFF*); +extern int TIFFSetMode(TIFF*, int); +extern int TIFFIsTiled(TIFF*); +extern int TIFFIsByteSwapped(TIFF*); +extern int TIFFIsUpSampled(TIFF*); +extern int TIFFIsMSB2LSB(TIFF*); +extern int TIFFIsBigEndian(TIFF*); +extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); +extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); +extern TIFFSeekProc TIFFGetSeekProc(TIFF*); +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 int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); +extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); +extern int TIFFSetupStrips(TIFF *); +extern int TIFFWriteCheck(TIFF*, int, const char *); +extern void TIFFFreeDirectory(TIFF*); +extern int TIFFCreateDirectory(TIFF*); +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 TIFFWriteDirectory(TIFF *); +extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); +extern int TIFFCheckpointDirectory(TIFF *); +extern int TIFFRewriteDirectory(TIFF *); +extern int TIFFDeferStrileArrayWriting(TIFF *); +extern int TIFFForceStrileArrayWriting(TIFF* ); #if defined(c_plusplus) || defined(__cplusplus) - extern void TIFFPrintDirectory(TIFF *, FILE *, long = 0); - 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); +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*, + int = ORIENTATION_BOTLEFT, int = 0); #else -extern void TIFFPrintDirectory(TIFF *, FILE *, long); -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); +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); #endif - 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_t *, uint32_t, - uint32_t); - extern void TIFFRGBAImageEnd(TIFFRGBAImage *); +extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); +extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); +extern int TIFFReadRGBAStripExt(TIFF*, uint32, uint32 *, int stop_on_error ); +extern int TIFFReadRGBATileExt(TIFF*, uint32, uint32, uint32 *, int stop_on_error ); +extern int TIFFRGBAImageOK(TIFF*, char [1024]); +extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); +extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); +extern void TIFFRGBAImageEnd(TIFFRGBAImage*); +extern TIFF* TIFFOpen(const char*, const char*); +# ifdef __WIN32__ +extern TIFF* TIFFOpenW(const wchar_t*, const char*); +# endif /* __WIN32__ */ +extern TIFF* TIFFFdOpen(int, const char*, const char*); +extern TIFF* TIFFClientOpen(const char*, const char*, + thandle_t, + TIFFReadWriteProc, TIFFReadWriteProc, + TIFFSeekProc, TIFFCloseProc, + TIFFSizeProc, + TIFFMapFileProc, TIFFUnmapFileProc); +extern const char* TIFFFileName(TIFF*); +extern const char* TIFFSetFileName(TIFF*, const char *); +extern void TIFFError(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3))); +extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4))); +extern void TIFFWarning(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3))); +extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4))); +extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); +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, + 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 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 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 TIFFSwabArrayOfFloat(float* fp, tmsize_t n); +extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); +extern void TIFFReverseBits(uint8* cp, tmsize_t n); +extern const unsigned char* TIFFGetBitRevTable(int); - extern const char *TIFFFileName(TIFF *); - extern const char *TIFFSetFileName(TIFF *, const char *); - extern void TIFFError(const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 2, 3))); - extern void TIFFErrorExt(thandle_t, const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); - extern void TIFFWarning(const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 2, 3))); - extern void TIFFWarningExt(thandle_t, const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); - extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); - extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); - extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); - extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); - - extern void TIFFWarningExtR(TIFF *, const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); - extern void TIFFErrorExtR(TIFF *, const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); - - typedef struct TIFFOpenOptions TIFFOpenOptions; - extern TIFFOpenOptions *TIFFOpenOptionsAlloc(void); - extern void TIFFOpenOptionsFree(TIFFOpenOptions *); - extern void - TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts, - tmsize_t max_single_mem_alloc); - extern void - TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts, - TIFFErrorHandlerExtR handler, - void *errorhandler_user_data); - extern void - TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions *opts, - TIFFErrorHandlerExtR handler, - void *warnhandler_user_data); - - extern TIFF *TIFFOpen(const char *, const char *); - extern TIFF *TIFFOpenExt(const char *, const char *, TIFFOpenOptions *opts); -#ifdef __WIN32__ - extern TIFF *TIFFOpenW(const wchar_t *, const char *); - extern TIFF *TIFFOpenWExt(const wchar_t *, const char *, - TIFFOpenOptions *opts); -#endif /* __WIN32__ */ - extern TIFF *TIFFFdOpen(int, const char *, const char *); - extern TIFF *TIFFFdOpenExt(int, const char *, const char *, - TIFFOpenOptions *opts); - extern TIFF *TIFFClientOpen(const char *, const char *, thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); - extern TIFF *TIFFClientOpenExt(const char *, const char *, thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc, - TIFFOpenOptions *opts); - extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); - 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_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 within TIFF file. */ - extern void TIFFSetWriteOffset(TIFF *tif, toff_t off); - 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_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_t *cp, tmsize_t n); - extern const unsigned char *TIFFGetBitRevTable(int); - - 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); +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); #ifdef LOGLUV_PUBLIC -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. - extern double LogL16toY(int); - extern double LogL10toY(int); - extern void XYZtoRGB24(float *, uint8_t *); - extern int uv_decode(double *, double *, int); - extern void LogLuv24toXYZ(uint32_t, float *); - extern void LogLuv32toXYZ(uint32_t, float *); +#define U_NEU 0.210526316 +#define V_NEU 0.473684211 +#define UVSCALE 410. +extern double LogL16toY(int); +extern double LogL10toY(int); +extern void XYZtoRGB24(float*, uint8*); +extern int uv_decode(double*, double*, int); +extern void LogLuv24toXYZ(uint32, float*); +extern void LogLuv32toXYZ(uint32, 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_t LogLuv24fromXYZ(float *, int = SGILOGENCODE_NODITHER); - extern uint32_t LogLuv32fromXYZ(float *, int = SGILOGENCODE_NODITHER); +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); #else - extern int LogL16fromY(double, int); - extern int LogL10fromY(double, int); - extern int uv_encode(double, double, int); - extern uint32_t LogLuv24fromXYZ(float *, int); - extern uint32_t LogLuv32fromXYZ(float *, int); +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); #endif #endif /* LOGLUV_PUBLIC */ - extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB *, const TIFFDisplay *, - float *); - extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t, - float *, float *, float *); - extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32_t *, - uint32_t *, uint32_t *); +extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); +extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, + float *, float *, float *); +extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, + uint32 *, uint32 *, uint32 *); - extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *, float *, float *); - extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t, - uint32_t *, uint32_t *, uint32_t *); +extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); +extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, + uint32 *, uint32 *, uint32 *); - /**************************************************************************** - * O B S O L E T E D I N T E R F A C E S - * - * Don't use this stuff in your applications, it may be removed in the - *future libtiff versions. - ****************************************************************************/ - typedef struct - { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ - short field_writecount; /* write count/TIFF_VARIABLE */ - TIFFDataType field_type; /* type of associated data */ - unsigned short field_bit; /* bit in fieldsset bit vector */ - unsigned char field_oktochange; /* if true, can change while writing */ - unsigned char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ - } TIFFFieldInfo; - - extern int TIFFMergeFieldInfo(TIFF *, const TIFFFieldInfo[], uint32_t); +/**************************************************************************** + * O B S O L E T E D I N T E R F A C E S + * + * Don't use this stuff in your applications, it may be removed in the future + * libtiff versions. + ****************************************************************************/ +typedef struct { + ttag_t field_tag; /* field's tag */ + short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ + short field_writecount; /* write count/TIFF_VARIABLE */ + TIFFDataType field_type; /* type of associated data */ + unsigned short field_bit; /* bit in fieldsset bit vector */ + unsigned char field_oktochange; /* if true, can change while writing */ + unsigned char field_passcount; /* if true, pass dir count on set */ + char *field_name; /* ASCII name */ +} TIFFFieldInfo; +extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); + #if defined(c_plusplus) || defined(__cplusplus) } #endif #endif /* _TIFFIO_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/VisualC/external/include/tiffvers.h b/thirdparty/SDL2_image/VisualC/external/include/tiffvers.h index ed847760c..0cce798b8 100644 --- a/thirdparty/SDL2_image/VisualC/external/include/tiffvers.h +++ b/thirdparty/SDL2_image/VisualC/external/include/tiffvers.h @@ -1,9 +1,4 @@ -/* clang-format off */ - -/* clang-format disabled because FindTIFF.cmake is very sensitive to the - * formatting of below line being a single line. - */ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.5.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.2.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 @@ -11,20 +6,4 @@ * version checking should be done based on the * string returned by TIFFGetVersion. */ -#define TIFFLIB_VERSION 20230609 - -/* The following defines have been added in 4.5.0 */ -#define TIFFLIB_MAJOR_VERSION 4 -#define TIFFLIB_MINOR_VERSION 5 -#define TIFFLIB_MICRO_VERSION 1 - -/* Macro added in 4.5.0. Returns TRUE if the current libtiff version is - * greater or equal to major.minor.micro - */ -#define TIFFLIB_AT_LEAST(major, minor, micro) \ - (TIFFLIB_MAJOR_VERSION > (major) || \ - (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION > (minor)) || \ - (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION == (minor) && \ - TIFFLIB_MICRO_VERSION >= (micro))) - -/* clang-format on */ +#define TIFFLIB_VERSION 20201219 diff --git a/thirdparty/SDL2_image/VisualC/external/optional/x64/libtiff-5.dll b/thirdparty/SDL2_image/VisualC/external/optional/x64/libtiff-5.dll new file mode 100644 index 000000000..854ba6585 --- /dev/null +++ b/thirdparty/SDL2_image/VisualC/external/optional/x64/libtiff-5.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:217d47ef36418c31b6eb25e3764542c4fae206a2caac5bd310a03f4826474b79 +size 387584 diff --git a/thirdparty/SDL2_image/VisualC/external/optional/x64/libtiff-6.dll b/thirdparty/SDL2_image/VisualC/external/optional/x64/libtiff-6.dll deleted file mode 100644 index a9ba826416d1555101a3fd5329ef576f5ffbfe2d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 403456 zcmdSCd3;nw);HeSAP88^rg1@oMokbgQPf1mNs~^ztsOuG35W`U5qE@cKt~}>cN4DH z)+j1E&gL?XGtM(QkB$M{vH%I7Obm)3sGz9#(mJweWD)azzg72kcLMsG=lOl!KVCkX zdvDdLQ>RXybL!Nor7I`ZxiVZXS0?`N>~y)7;mLoc^6xMIsX_M9C$Bi#^=hwohb&9; zzdK~yjGJfY&YX4UO|z!no;z*o9e3Or$i3ml+*!dpa&NvP*E{B_+}rP*e&g`IeUHks zQI9Qmxu!4b-KC;kuHmQjPEQ}~ngYu5dbnJDT&|Y~0K`qO)|(_S-_sS{{LbPB|J4B= zjk(~b90gYY%BhwF`AOtt@Q%W~~H!TG?mribeRGVEvm z<<9Kk%0EKhZCCbi71|^oA=@=PaO1oHGB#ZYy}5p8vy2z;yYO!-&pDl8p7Pr(&3 z-vu6@gvVz`fV*M#Y+00DnhUri{Ht+IX&8Q^!Y6qS-n)(=U{`oq@68HM_6hpNbrisk zISj60c-fWXh@pyqrXZhu=~jQKtF&Qw;5JF$48ozWB-|<8@qxZsH{N#VG?(h@8sxJt zD2ploK;Nj8&;KW1uhPO_=Pq}pxm@OP6Ea+y-l*x#<}nxG)fja0sw|fl-J-1rGs6K#I9-KW1(sjmv&VGMdy^l%k5 zMBC?&5ARIVjKR;X%yJcV>Vxh@`ddV)8E5@=R1a6Y=W-L6J3r9$eY-UAk8`zXL-1?O zI4_I>Mvw5mbP@R&;LA_OAG71?43{JbRODZC-SyXcCVQ@J4j)Jp(dUtWq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A<7m}Wd}A|8sjMWdnx~H*3pdHpdaUn|{>K~HrpHS+^XRdz0naM)xaqVdRgwqv zOhfDHoBi)9^1Dj?K8GttA_|&$U1)K#al;rjyE0M^%UhEhmvDRI?)+HDbHNhFABK8X z#=nIZIZvKH4RNz<_5w+DxW2m$r!LlGx&LWnoNDJcrn+(b!rOCqlFv<3RJXXJsBM5R|X%i3GK7u4p3IH>YoaWO+rKNw!x zmQ1GPv2a7O6aUdvw5|y*xAtG-Rbo+h@4gBJ??mgv;?mwd{@Oa>84g5Z#io1Xj-)fN4&z9 z<5jD;nXkw7sPW*z)pDOA_^vrNqcc(r9 z$t+LOxXw|DZ+86Crc%3}UJ~A5&F9Zu#)Q8zu3cDv{ldi;%=SK}Ggwc;FI5Nic_> z+#Y0~UP&=WMRT65$wsnpnte2sdNMuRdv^5<_T+mG^*q}%+%wX1xThu;$<^j&<>usK zxp;16t|gbsrE^a6m_Iioz0-SV^+tPRy^DHR_9l8$y^>+? z4vqVP!3TyPi0q2(O6|(-8shKI=;(OA22KNl_iR_K-P3_I@9paDC zXn&$V)1U7j>8~A#53o@a|EXef&k%p3MstZ=CYR5R>=?MUs&?nvy(?8)yL*;BhWzBj#haPRQmNPnz9)t~Jj;!oe`Kw=;> zkRKQssNEOem)A+OY~*>@_i$HwL9ZG(>t@&%JfxIfZAy}!197VT&b3<9QWFCx;KN3gS~m|9PS;#j!0iE_Qv|+*qrK1V|TW1uul@qt0d~_)ZLsc RLdrj`&CaqKl>fWG{{d9Vd$a%m diff --git a/thirdparty/SDL2_image/VisualC/external/optional/x86/libtiff-5.dll b/thirdparty/SDL2_image/VisualC/external/optional/x86/libtiff-5.dll new file mode 100644 index 000000000..0b8192362 --- /dev/null +++ b/thirdparty/SDL2_image/VisualC/external/optional/x86/libtiff-5.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:705c744e2b8efac675d3dda54cc86ad4f8a5175a92d637be2543d832eb248414 +size 380928 diff --git a/thirdparty/SDL2_image/VisualC/external/optional/x86/libtiff-6.dll b/thirdparty/SDL2_image/VisualC/external/optional/x86/libtiff-6.dll deleted file mode 100644 index bd988bcab014d8a7fce441f7be2d6222ec85aa48..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 399360 zcmeFadtemR*+0HX7Fcj)7L6J;YOJdb8Z~LDO(eF_1jwt1Q4p!76)Of*suXqs6*cSZ zCXC}^D%#p=t+u{ZtF2Zo!5icPEO2W}hDyIYo+4F`6<8mCatRFeEItemr9(Xys(k0)^r0Sa;dkbGymdo81%qT)m7yLH z`;NcULRT#eAunp8KSYRqO?N_7n(nEae%g#HLRa9imPzb8`s`^T4KjaKp1QWv=Bk3L zYEa-QUD)0p-pinE(IpyD2bP-&&CH1{+br@H+d15_(nLT9N%)iXS z&vJ5d$d?d)Dr?hM6M0nUQELcFE_V?)bBq%leUml+^=o3SQz_CusNlUk5ubm~cO#ij+C znTH0y!9!|&#isdR8DoOhtlRQDi6JbF=5a?*yen%<3?U(T-#mo0?N2=!7JFzam1<~d z7TVh<_L2yTfTqXrY5dufr1`8iJudjrL)kTV&k^h}n5#o!eQ!?qQEUG6OeaW8 zV*FvIm=?PnXc0zsFWXgtfysXuJbB(e>8pJhJGd7@F#ij>p8DM7#W+2wg2l=UayZMoR^L}`esd~2rF_lrEwI!E&3D@hOJ z|GYD6K&ejzdObA4y3kOgYv%`ZMi^_gCp$%Jpw$v|(&u?9In$^K`ti?8OvvxsFU!htUero^ld)&cB9b5XFy3yS zfzne3!MBR|Rtdgk81e+Q?bV{45(sz|uYeH=-4s&4m!lTY2stZPdMVwK0@bxKt!vPut-FjOMf_!&`)2lww%RF}#)Ny`P+gQS%ywL9)NK3~UPOd=DeVmd7w1jAL#3XD*ax z2>2CYxQPaGt57AMV@^6wbNXrKxpi)zMk*G8im1_|Z!JL;HmbA>SOCxEfbN%uRD-1k zhWkQF)~XVh{gwT>SUOON4%7kpDd@yBG%tvUfcR_Y!D_T=v45jOk(V=LF^9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8e?i@p>6F1}|6Fi`3(z!E7`S zU=G>@lsyVh@PyfFwwdkbX>1qs@o?UsNAO4<#iQXN#sY;$!B1pd%rS@O!z*5m=u#1U$>J{P)`?P`sMLu=oru$Et2>*sXROF#fbn z8hd$h$vNVB#H~u;^OeHlmTQIZ^47zamFOE`bIV{~;*A7jB4RMfurM<_@R&6B^5SCt qH#v&cl3?BFnE2kFKhs}`5~5vyCfR@QgLl(kh;TW-|NB4M1OEZC=AG66 diff --git a/thirdparty/SDL2_image/configure b/thirdparty/SDL2_image/configure index 3ed51f386..b22960bdd 100755 --- a/thirdparty/SDL2_image/configure +++ b/thirdparty/SDL2_image/configure @@ -14503,10 +14503,16 @@ fi case "$host" in *-*-darwin*) - avif_lib=`find_lib libavif.dylib` + avif_lib=`find_lib "libavif.[0-9]*.dylib"` + if test x$avif_lib = x; then + avif_lib=`find_lib "libavif*.dylib"` + fi ;; *-*-cygwin* | *-*-mingw*) - avif_lib=`find_lib "libavif*.dll"` + avif_lib=`find_lib "libavif-[0-9]*.dll"` + if test x$avif_lib = x; then + avif_lib=`find_lib "libavif*.dll"` + fi ;; *) avif_lib=`find_lib "libavif[0-9]*.so.*"` @@ -14726,7 +14732,10 @@ fi case "$host" in *-*-darwin*) - jpg_lib=`find_lib libjpeg.dylib` + jpg_lib=`find_lib "libjpeg.[0-9]*.dylib"` + if test x$jpg_lib = x; then + jpg_lib=`find_lib libjpeg.dylib` + fi ;; *-*-cygwin* | *-*-mingw*) jpg_lib=`find_lib "libjpeg*.dll"` @@ -14938,10 +14947,16 @@ fi case "$host" in *-*-darwin*) - jxl_lib=`find_lib libjxl.dylib` + jxl_lib=`find_lib "libjxl.[0-9]*.dylib"` + if test x$jxl_lib = x; then + jxl_lib=`find_lib libjxl.dylib` + fi ;; *-*-cygwin* | *-*-mingw*) - jxl_lib=`find_lib "libjxl.dll"` + jxl_lib=`find_lib "libjxl-[0-9]*.dll"` + if test x$jxl_lib = x; then + jxl_lib=`find_lib "libjxl.dll"` + fi ;; *) jxl_lib=`find_lib "libjxl[0-9]*.so.*"` @@ -15158,7 +15173,10 @@ fi case "$host" in *-*-darwin*) - png_lib=`find_lib libpng.dylib` + png_lib=`find_lib "libpng[0-9]*.dylib"` + if test x$png_lib = x; then + png_lib=`find_lib libpng.dylib` + fi ;; *-*-cygwin* | *-*-mingw*) png_lib=`find_lib "libpng*.dll"` @@ -15368,7 +15386,10 @@ fi case "$host" in *-*-darwin*) - tif_lib=`find_lib libtiff.dylib` + tif_lib=`find_lib "libtiff.[0-9]*.dylib"` + if test x$tif_lib = x; then + tif_lib=`find_lib libtiff.dylib` + fi ;; *-*-cygwin* | *-*-mingw*) tif_lib=`find_lib "libtiff-*.dll"` @@ -15754,8 +15775,12 @@ fi case "$host" in *-*-darwin*) - webpdemux_lib=`find_lib libwebpdemux.dylib` - webp_lib=`find_lib libwebp.dylib` + webpdemux_lib=`find_lib "libwebpdemux.[0-9]*.dylib"` + webp_lib=`find_lib "libwebp.[0-9]*.dylib"` + if test x$webp_lib = x; then + webpdemux_lib=`find_lib libwebpdemux.dylib` + webp_lib=`find_lib libwebp.dylib` + fi ;; *-*-cygwin* | *-*-mingw*) webpdemux_lib=`find_lib "libwebpdemux-*.dll"` diff --git a/thirdparty/SDL2_image/configure.ac b/thirdparty/SDL2_image/configure.ac index 72b3eee23..d6c909a49 100644 --- a/thirdparty/SDL2_image/configure.ac +++ b/thirdparty/SDL2_image/configure.ac @@ -339,10 +339,16 @@ if test x$enable_avif = xyes; then case "$host" in *-*-darwin*) - avif_lib=[`find_lib libavif.dylib`] + avif_lib=[`find_lib "libavif.[0-9]*.dylib"`] + if test x$avif_lib = x; then + avif_lib=[`find_lib "libavif*.dylib"`] + fi ;; *-*-cygwin* | *-*-mingw*) - avif_lib=[`find_lib "libavif*.dll"`] + avif_lib=[`find_lib "libavif-[0-9]*.dll"`] + if test x$avif_lib = x; then + avif_lib=[`find_lib "libavif*.dll"`] + fi ;; *) avif_lib=[`find_lib "libavif[0-9]*.so.*"`] @@ -391,7 +397,10 @@ if test x$enable_jpg = xyes; then case "$host" in *-*-darwin*) - jpg_lib=[`find_lib libjpeg.dylib`] + jpg_lib=[`find_lib "libjpeg.[0-9]*.dylib"`] + if test x$jpg_lib = x; then + jpg_lib=[`find_lib libjpeg.dylib`] + fi ;; *-*-cygwin* | *-*-mingw*) jpg_lib=[`find_lib "libjpeg*.dll"`] @@ -435,10 +444,16 @@ if test x$enable_jxl = xyes; then case "$host" in *-*-darwin*) - jxl_lib=[`find_lib libjxl.dylib`] + jxl_lib=[`find_lib "libjxl.[0-9]*.dylib"`] + if test x$jxl_lib = x; then + jxl_lib=[`find_lib libjxl.dylib`] + fi ;; *-*-cygwin* | *-*-mingw*) - jxl_lib=[`find_lib "libjxl.dll"`] + jxl_lib=[`find_lib "libjxl-[0-9]*.dll"`] + if test x$jxl_lib = x; then + jxl_lib=[`find_lib "libjxl.dll"`] + fi ;; *) jxl_lib=[`find_lib "libjxl[0-9]*.so.*"`] @@ -484,7 +499,10 @@ if test x$enable_png = xyes; then case "$host" in *-*-darwin*) - png_lib=[`find_lib libpng.dylib`] + png_lib=[`find_lib "libpng[0-9]*.dylib"`] + if test x$png_lib = x; then + png_lib=[`find_lib libpng.dylib`] + fi ;; *-*-cygwin* | *-*-mingw*) png_lib=[`find_lib "libpng*.dll"`] @@ -526,7 +544,10 @@ if test x$enable_tif = xyes -a x$enable_imageio != xyes; then case "$host" in *-*-darwin*) - tif_lib=[`find_lib libtiff.dylib`] + tif_lib=[`find_lib "libtiff.[0-9]*.dylib"`] + if test x$tif_lib = x; then + tif_lib=[`find_lib libtiff.dylib`] + fi ;; *-*-cygwin* | *-*-mingw*) tif_lib=[`find_lib "libtiff-*.dll"`] @@ -580,8 +601,12 @@ if test x$enable_webp = xyes; then case "$host" in *-*-darwin*) - webpdemux_lib=[`find_lib libwebpdemux.dylib`] - webp_lib=[`find_lib libwebp.dylib`] + webpdemux_lib=[`find_lib "libwebpdemux.[0-9]*.dylib"`] + webp_lib=[`find_lib "libwebp.[0-9]*.dylib"`] + if test x$webp_lib = x; then + webpdemux_lib=[`find_lib libwebpdemux.dylib`] + webp_lib=[`find_lib libwebp.dylib`] + fi ;; *-*-cygwin* | *-*-mingw*) webpdemux_lib=[`find_lib "libwebpdemux-*.dll"`] diff --git a/thirdparty/SDL2_image/external/Get-GitModules.ps1 b/thirdparty/SDL2_image/external/Get-GitModules.ps1 new file mode 100644 index 000000000..c43f63756 --- /dev/null +++ b/thirdparty/SDL2_image/external/Get-GitModules.ps1 @@ -0,0 +1,36 @@ +<# + .SYNOPSIS + Downloads the Git modules specified in ../.gitmodules + + .DESCRIPTION + Parses and downloads the Github repositories specified in the .gitmodules file + + .EXAMPLE + PS> .\Get-GitModules.ps1 + < Downloads and parses the repositories in the .gitmodules file. > +#> + +#------- Variables ------------------------------------------------------------- +[String] $PathRegex = "path\s*=\s*(?.*)" +[String] $URLRegex = "url\s*=\s*(?.*)" +[String] $BranchRegex = "branch\s*=\s*(?.*)" + +#------- Script ---------------------------------------------------------------- +foreach ($Line in Get-Content $PSScriptRoot\..\.gitmodules) { + if ($Line -match $PathRegex) { + $Match = Select-String -InputObject $Line -Pattern $PathRegex + $Path = $Match.Matches[0].Groups[1].Value + } + elseif ($Line -match $URLRegex) { + $Match = Select-String -InputObject $Line -Pattern $URLRegex + $URL = $Match.Matches[0].Groups[1].Value + } + elseif ($Line -match $BranchRegex) { + $Match = Select-String -InputObject $Line -Pattern $BranchRegex + $Branch = $Match.Matches[0].Groups[1].Value + + Write-Host "git clone $URL $Path -b $Branch --recursive" ` + -ForegroundColor Blue + git clone $URL $PSScriptRoot/../$Path -b $Branch --recursive + } +} diff --git a/thirdparty/SDL2_image/external/libjxl/.gitmodules b/thirdparty/SDL2_image/external/libjxl/.gitmodules deleted file mode 100644 index 8b6cfcb77..000000000 --- a/thirdparty/SDL2_image/external/libjxl/.gitmodules +++ /dev/null @@ -1,23 +0,0 @@ -[submodule "third_party/lodepng"] - path = third_party/lodepng - url = https://github.com/lvandeve/lodepng -[submodule "third_party/lcms"] - path = third_party/lcms - url = https://github.com/mm2/Little-CMS -[submodule "third_party/googletest"] - path = third_party/googletest - url = https://github.com/google/googletest -[submodule "third_party/sjpeg"] - path = third_party/sjpeg - url = https://github.com/webmproject/sjpeg.git -[submodule "third_party/skcms"] - path = third_party/skcms - url = https://skia.googlesource.com/skcms -[submodule "third_party/brotli"] - path = third_party/brotli - url = https://github.com/libsdl-org/brotli.git - branch = v1.0.9-SDL -[submodule "third_party/highway"] - path = third_party/highway - url = https://github.com/libsdl-org/highway.git - branch = 0.15.0-SDL diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/brotli/.gitmodules b/thirdparty/SDL2_image/external/libjxl/third_party/brotli/.gitmodules deleted file mode 100644 index 3ec8760a5..000000000 --- a/thirdparty/SDL2_image/external/libjxl/third_party/brotli/.gitmodules +++ /dev/null @@ -1,6 +0,0 @@ -[submodule "research/esaxx"] - path = research/esaxx - url = https://github.com/hillbig/esaxx -[submodule "research/libdivsufsort"] - path = research/libdivsufsort - url = https://github.com/y-256/libdivsufsort.git diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android new file mode 100644 index 000000000..634303a47 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android @@ -0,0 +1,18 @@ +ndk = ../ndk +cc = $ndk/toolchains/llvm/prebuilt/*/bin/aarch64-linux-android24-clang +cxx = $ndk/toolchains/llvm/prebuilt/*/bin/aarch64-linux-android24-clang++ + +cflags = -fcolor-diagnostics -Weverything +ldflags = -pie -fuse-ld=lld -static-libstdc++ + +out = out/android$mode + +rule run + command = if which adb >/dev/null && adb get-state >/dev/null 2>/dev/null; $ + then $ + adb push --sync profiles /data/local/tmp >/dev/null; $ + adb push $in /data/local/tmp/$in >/dev/null; $ + adb shell "cd /data/local/tmp; taskset f ./$in" > $out; $ + else touch $out; fi + description = run $in +include build/common diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm new file mode 100644 index 000000000..6446b309b --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm @@ -0,0 +1,18 @@ +ndk = ../ndk +cc = $ndk/toolchains/llvm/prebuilt/*/bin/armv7a-linux-androideabi24-clang +cxx = $ndk/toolchains/llvm/prebuilt/*/bin/armv7a-linux-androideabi24-clang++ + +cflags = -fcolor-diagnostics -Weverything -mthumb +ldflags = -pie -fuse-ld=lld -static-libstdc++ + +out = out/android-arm$mode + +rule run + command = if which adb >/dev/null && adb get-state >/dev/null 2>/dev/null; $ + then $ + adb push --sync profiles /data/local/tmp >/dev/null; $ + adb push $in /data/local/tmp/$in >/dev/null; $ + adb shell "cd /data/local/tmp; taskset f ./$in" > $out; $ + else touch $out; fi + description = run $in +include build/common diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.lsan b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.lsan new file mode 100644 index 000000000..c9a4f2449 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.lsan @@ -0,0 +1,4 @@ +mode = .lsan +extra_cflags = -fsanitize=leak +extra_ldflags = -fsanitize=leak +include build/android-arm diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.neon-vfpv4 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.neon-vfpv4 new file mode 100644 index 000000000..ef3f972d2 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.neon-vfpv4 @@ -0,0 +1,3 @@ +mode = .neon-vfpv4 +extra_cflags = -mfpu=neon-vfpv4 +include build/android-arm diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.neon-vfpv4-O3 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.neon-vfpv4-O3 new file mode 100644 index 000000000..409b566f8 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.neon-vfpv4-O3 @@ -0,0 +1,3 @@ +mode = .neon-vfpv4-O3 +extra_cflags = -mfpu=neon-vfpv4 -O3 +include build/android-arm diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.portable b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.portable new file mode 100644 index 000000000..a07516781 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.portable @@ -0,0 +1,3 @@ +mode = .portable +extra_cflags = -DSKCMS_PORTABLE +include build/android-arm diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.tiny b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.tiny new file mode 100644 index 000000000..167af17a0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.tiny @@ -0,0 +1,3 @@ +mode = .tiny +extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables +include build/android-arm diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.vfpv2 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.vfpv2 new file mode 100644 index 000000000..fd66c5d57 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android-arm.vfpv2 @@ -0,0 +1,3 @@ +mode = .vfpv2 +extra_cflags = -mfpu=vfpv2 +include build/android-arm diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.fp16 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.fp16 new file mode 100644 index 000000000..bec99e7cc --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.fp16 @@ -0,0 +1,3 @@ +mode = .fp16 +extra_cflags = -march=armv8.2a+fp16 -DSKCMS_OPT_INTO_NEON_FP16 +include build/android diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.lsan b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.lsan new file mode 100644 index 000000000..b5c9a73ab --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.lsan @@ -0,0 +1,4 @@ +mode = .lsan +extra_cflags = -fsanitize=leak +extra_ldflags = -fsanitize=leak +include build/android diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.nofp16 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.nofp16 new file mode 100644 index 000000000..2842f4c32 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.nofp16 @@ -0,0 +1,3 @@ +mode = .nofp16 +extra_cflags = -march=armv8.2a+fp16 +include build/android diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.portable b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.portable new file mode 100644 index 000000000..aaa9213c4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.portable @@ -0,0 +1,3 @@ +mode = .portable +extra_cflags = -DSKCMS_PORTABLE +include build/android diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.tiny b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.tiny new file mode 100644 index 000000000..1caaacd7c --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/android.tiny @@ -0,0 +1,3 @@ +mode = .tiny +extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables +include build/android diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang new file mode 100644 index 000000000..27bad60c6 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang @@ -0,0 +1,7 @@ +cc = clang +cxx = clang++ +cflags = -fcolor-diagnostics -Weverything +out = out/clang$mode + +include build/local +include build/common diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.O0 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.O0 new file mode 100644 index 000000000..4aba86094 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.O0 @@ -0,0 +1,3 @@ +mode = .O0 +extra_cflags = -O0 +include build/clang diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.avx512 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.avx512 new file mode 100644 index 000000000..cb1225e83 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.avx512 @@ -0,0 +1,5 @@ +mode = .avx512 +extra_cflags = -march=skylake-avx512 +include build/clang + +disabled = (uname | grep -q Darwin && sysctl machdep.cpu.leaf7_features | grep -qv AVX512F || grep flags /proc/cpuinfo | grep -vq avx512f) diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.lsan b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.lsan new file mode 100644 index 000000000..774a8e732 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.lsan @@ -0,0 +1,4 @@ +mode = .lsan +extra_cflags = -fsanitize=leak +extra_ldflags = -fsanitize=leak +include build/clang diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.m32 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.m32 new file mode 100644 index 000000000..3ffa99456 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.m32 @@ -0,0 +1,6 @@ +mode = .m32 +extra_cflags = -m32 -msse2 +extra_ldflags = -m32 +include build/clang + +disabled = (uname | grep -qv Linux) diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.m32-O0 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.m32-O0 new file mode 100644 index 000000000..64be218d2 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.m32-O0 @@ -0,0 +1,7 @@ +mode = .m32-O0 +extra_cflags = -m32 -msse2 -O0 +extra_ldflags = -m32 +include build/clang + +disabled = (uname | grep -qv Linux) + diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.msan b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.msan new file mode 100644 index 000000000..f1dd0ae7a --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.msan @@ -0,0 +1,6 @@ +mode = .msan +extra_cflags = -fsanitize=memory +extra_ldflags = -fsanitize=memory +include build/clang + +disabled = (uname | grep -qv Linux) diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.native b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.native new file mode 100644 index 000000000..2e080a968 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.native @@ -0,0 +1,3 @@ +mode = .native +extra_cflags = -march=native +include build/clang diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.portable b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.portable new file mode 100644 index 000000000..f7dc4f4b4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.portable @@ -0,0 +1,3 @@ +mode = .portable +extra_cflags = -DSKCMS_PORTABLE +include build/clang diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.sse2 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.sse2 new file mode 100644 index 000000000..f26ec794a --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.sse2 @@ -0,0 +1,4 @@ +mode = .sse2 +extra_cflags = -msse2 -mno-sse3 -mno-ssse3 -mno-sse4.1 -DSKCMS_NO_RUNTIME_CPU_DETECTION +include build/clang + diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.sse41 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.sse41 new file mode 100644 index 000000000..20c4ed64c --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.sse41 @@ -0,0 +1,4 @@ +mode = .sse41 +extra_cflags = -msse4.1 -DSKCMS_NO_RUNTIME_CPU_DETECTION +include build/clang + diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.tiny b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.tiny new file mode 100644 index 000000000..c2d63aeac --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.tiny @@ -0,0 +1,3 @@ +mode = .tiny +extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables +include build/clang diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.xsan b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.xsan new file mode 100644 index 000000000..014fec403 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.xsan @@ -0,0 +1,4 @@ +mode = .xsan +extra_cflags = -fsanitize=address,integer,undefined -fno-sanitize-recover=all +extra_ldflags = -fsanitize=address,integer,undefined +include build/clang diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.xsan-portable b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.xsan-portable new file mode 100644 index 000000000..b825f4167 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/clang.xsan-portable @@ -0,0 +1,4 @@ +mode = .xsan-portable +extra_cflags = -fsanitize=address,integer,undefined -fno-sanitize-recover=all -DSKCMS_PORTABLE +extra_ldflags = -fsanitize=address,integer,undefined +include build/clang diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/common b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/common new file mode 100644 index 000000000..7ed5f5c3d --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/common @@ -0,0 +1,35 @@ +builddir = $out +disabled = false + +# Each compiler has enabled all the warnings it can. +# Here we make them errors, and disable a few we don't want bothering us. +warnings = -Werror $ + -Wno-double-promotion $ + -Wno-float-equal $ + -Wno-padded $ + +warnings_cc = $warnings $ + -Wno-c++98-compat-pedantic $ + -Wno-gnu-anonymous-struct $ + -Wno-old-style-cast $ + + +rule compile_c + command = $disabled && touch $out || $cc -std=c11 -g -Os $warnings $cflags $extra_cflags $ + -MD -MF $out.d -c $in -o $out + depfile = $out.d + deps = gcc + description = compile $out + +rule compile_cc + command = $disabled && touch $out || $cxx -std=c++11 -g -Os $warnings_cc $cflags $extra_cflags $ + -MD -MF $out.d -c $in -o $out + depfile = $out.d + deps = gcc + description = compile $out + +rule link + command = $disabled && touch $out || $cxx $ldflags $extra_ldflags $in -ldl -o $out + description = link $out + +include build/targets diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/emscripten b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/emscripten new file mode 100644 index 000000000..d6dcf2d11 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/emscripten @@ -0,0 +1,19 @@ +cc = emcc +cxx = em++ +cflags = -g3 -s WASM=1 -s ENVIRONMENT=node +ldflags = -g3 -s WASM=1 -s ENVIRONMENT=node --embed-file profiles +exe = .js +out = out/emscripten$mode + +node = 'node' + +rule run + command = if which $node >/dev/null; $ + then $ + $node $in > $out; $ + else touch $out; fi + description = run $in + +include build/common + +disabled = (uname | grep -qv Linux) diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/emscripten.simd b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/emscripten.simd new file mode 100644 index 000000000..f8279fa7b --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/emscripten.simd @@ -0,0 +1,5 @@ +mode = .simd +extra_cflags = -s SIMD=1 +extra_ldflags = -s SIMD=1 + +include build/emscripten diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc new file mode 100644 index 000000000..2823c1f83 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc @@ -0,0 +1,9 @@ +cc = gcc +cxx = g++ +cflags = -fdiagnostics-color -Wall -Wextra -ffp-contract=off -fstack-usage +out = out/gcc$mode + +include build/local +include build/common + +disabled = (uname | grep -qv Linux) diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.O0 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.O0 new file mode 100644 index 000000000..369d5177c --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.O0 @@ -0,0 +1,3 @@ +mode = .O0 +extra_cflags = -O0 +include build/gcc diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.m32 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.m32 new file mode 100644 index 000000000..8f4f41689 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.m32 @@ -0,0 +1,4 @@ +mode = .m32 +extra_cflags = -m32 -msse2 -mfpmath=sse +extra_ldflags = -m32 +include build/gcc diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.m32-O0 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.m32-O0 new file mode 100644 index 000000000..4b6f2a205 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.m32-O0 @@ -0,0 +1,4 @@ +mode = .m32-O0 +extra_cflags = -m32 -msse2 -mfpmath=sse -O0 +extra_ldflags = -m32 +include build/gcc diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.mips64el b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.mips64el new file mode 100644 index 000000000..7c44b0afc --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.mips64el @@ -0,0 +1,16 @@ +mode = .mips64el + +_toolchain = ../mips64el_toolchain_linux +_env = env LD_LIBRARY_PATH=$_toolchain/lib/x86_64-linux-gnu + +out = out/gcc$mode +cflags = -fdiagnostics-color -Wall -Wextra -ffp-contract=off -fstack-usage +cc = $_env $_toolchain/bin/mips64el-linux-gnuabi64-gcc-7 +cxx = $_env $_toolchain/bin/mips64el-linux-gnuabi64-g++-7 + +rule run + command = touch $out + description = skipping $in +include build/common + +disabled = (uname | grep -qv Linux) diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.mips64el-O3 b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.mips64el-O3 new file mode 100644 index 000000000..42b58d305 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.mips64el-O3 @@ -0,0 +1,16 @@ +mode = .mips64el-O3 + +_toolchain = ../mips64el_toolchain_linux +_env = env LD_LIBRARY_PATH=$_toolchain/lib/x86_64-linux-gnu + +out = out/gcc$mode +cflags = -fdiagnostics-color -Wall -Wextra -ffp-contract=off -fstack-usage -O3 +cc = $_env $_toolchain/bin/mips64el-linux-gnuabi64-gcc-7 +cxx = $_env $_toolchain/bin/mips64el-linux-gnuabi64-g++-7 + +rule run + command = touch $out + description = skipping $in +include build/common + +disabled = (uname | grep -qv Linux) diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.musl b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.musl new file mode 100644 index 000000000..5a2f0ebec --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.musl @@ -0,0 +1,6 @@ +mode = .musl +extra_ldflags = -static +include build/gcc + +cc = env REALGCC=gcc musl-gcc +cxx = env REALGCC=g++ musl-gcc diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.native b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.native new file mode 100644 index 000000000..de17b3b22 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.native @@ -0,0 +1,3 @@ +mode = .native +extra_cflags = -march=native +include build/gcc diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.portable b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.portable new file mode 100644 index 000000000..6c1bdd87c --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.portable @@ -0,0 +1,3 @@ +mode = .portable +extra_cflags = -DSKCMS_PORTABLE +include build/gcc diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.tiny b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.tiny new file mode 100644 index 000000000..282f41f60 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.tiny @@ -0,0 +1,3 @@ +mode = .tiny +extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables +include build/gcc diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.xsan b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.xsan new file mode 100644 index 000000000..150ce076f --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/gcc.xsan @@ -0,0 +1,4 @@ +mode = .xsan +extra_cflags = -fsanitize=address,undefined -fno-sanitize-recover=all +extra_ldflags = -fsanitize=address,undefined +include build/gcc diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios new file mode 100644 index 000000000..3667b116d --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios @@ -0,0 +1,11 @@ +cc = clang -arch arm64 -isysroot `xcrun --sdk iphoneos --show-sdk-path` +cxx = clang++ -arch arm64 -isysroot `xcrun --sdk iphoneos --show-sdk-path` +cflags = -fcolor-diagnostics -Weverything +out = out/ios$mode + +rule run + command = touch $out + description = skipping $in +include build/common + +disabled = (uname | grep -qv Darwin) diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.portable b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.portable new file mode 100644 index 000000000..22a1cfad5 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.portable @@ -0,0 +1,3 @@ +mode = .portable +extra_cflags = -DSKCMS_PORTABLE +include build/ios diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.tiny b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.tiny new file mode 100644 index 000000000..71ac73db1 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.tiny @@ -0,0 +1,3 @@ +mode = .tiny +extra_cflags = -g0 -DNDEBUG -fno-unwind-tables -fno-asynchronous-unwind-tables +include build/ios diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.xsan b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.xsan new file mode 100644 index 000000000..633d46089 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/ios.xsan @@ -0,0 +1,7 @@ +mode = .xsan +extra_cflags = -fsanitize=address,integer,undefined -fno-sanitize-recover=all +extra_ldflags = -fsanitize=address,integer,undefined +include build/ios + +cc = /usr/bin/clang +cxx = /usr/bin/clang++ diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/local b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/local new file mode 100644 index 000000000..a24755c49 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/local @@ -0,0 +1,3 @@ +rule run + command = $disabled && touch $out || ./$in > $out + description = run $in diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs new file mode 100644 index 000000000..1c2f64e1e --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs @@ -0,0 +1,27 @@ +cl = cl.exe +cflags = /W4 /wd"4200" /wd"4201" /wd"4204" /wd"4221" +out = out/msvs$mode +exe = .exe +builddir = $out + +rule run + command = cmd /c ""$in" > "$out"" + description = run $in + +rule compile_c + command = $cl /c /showIncludes /nologo /Zi /WX /MT /Fo"$out" /Fd"$out.pdb" $ + $cflags $extra_cflags $in + deps = msvc + description = compile $out + +rule compile_cc + command = $cl /c /showIncludes /nologo /Zi /WX /MT /Fo"$out" /Fd"$out.pdb" $ + $cflags $extra_cflags $in + deps = msvc + description = compile $out + +rule link + command = link.exe /nologo /DEBUG $extra_ldflags $in /OUT:"$out" /PDB:"$out.pdb" + description = link $out + +include build/targets diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.analyze b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.analyze new file mode 100644 index 000000000..537f8245a --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.analyze @@ -0,0 +1,4 @@ +mode = .analyze +extra_cflags = /analyze /RTCcsu /guard:cf +extra_ldflags = /guard:cf +include build/msvs diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.clang b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.clang new file mode 100644 index 000000000..65abd1f34 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.clang @@ -0,0 +1,5 @@ +mode = .clang + +include build/msvs + +cl = "../clang_win/bin/clang-cl.exe" diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.clang-fast b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.clang-fast new file mode 100644 index 000000000..f91c1db93 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.clang-fast @@ -0,0 +1,6 @@ +mode = .clang-fast +extra_cflags = /O2 /Zc:inline + +include build/msvs + +cl = "../clang_win/bin/clang-cl.exe" diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.fast b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.fast new file mode 100644 index 000000000..ba0ffc471 --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/msvs.fast @@ -0,0 +1,3 @@ +mode = .fast +extra_cflags = /O2 /Zc:inline +include build/msvs diff --git a/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/targets b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/targets new file mode 100644 index 000000000..54ff8c98f --- /dev/null +++ b/thirdparty/SDL2_image/external/libjxl/third_party/skcms/build/targets @@ -0,0 +1,30 @@ +build $out/skcms.o: compile_cc skcms.cc + +build $out/test_only.o: compile_c test_only.c + +build $out/tests.o: compile_c tests.c +build $out/tests$exe: link $out/skcms.o $out/tests.o $out/test_only.o +build $out/tests.ok: run $out/tests$exe + +build $out/bench.o: compile_c bench.c +build $out/bench$exe: link $out/skcms.o $out/bench.o + +build $out/iccdump.o: compile_c iccdump.c +build $out/iccdump$exe: link $out/skcms.o $out/iccdump.o $out/test_only.o + +build $out/fuzz/fuzz_main.o: compile_c fuzz/fuzz_main.c + +build $out/fuzz/fuzz_iccprofile_atf.o: compile_c fuzz/fuzz_iccprofile_atf.c +build $out/fuzz_iccprofile_atf$exe: link $out/fuzz/fuzz_iccprofile_atf.o $ + $out/fuzz/fuzz_main.o $ + $out/skcms.o + +build $out/fuzz/fuzz_iccprofile_info.o: compile_c fuzz/fuzz_iccprofile_info.c +build $out/fuzz_iccprofile_info$exe: link $out/fuzz/fuzz_iccprofile_info.o $ + $out/fuzz/fuzz_main.o $ + $out/skcms.o + +build $out/fuzz/fuzz_iccprofile_transform.o: compile_c fuzz/fuzz_iccprofile_transform.c +build $out/fuzz_iccprofile_transform$exe: link $out/fuzz/fuzz_iccprofile_transform.o $ + $out/fuzz/fuzz_main.o $ + $out/skcms.o diff --git a/thirdparty/SDL2_image/external/libtiff/.appveyor.yml b/thirdparty/SDL2_image/external/libtiff/.appveyor.yml index 9a8fa1979..04369ec6b 100644 --- a/thirdparty/SDL2_image/external/libtiff/.appveyor.yml +++ b/thirdparty/SDL2_image/external/libtiff/.appveyor.yml @@ -24,14 +24,14 @@ environment: shared: OFF - compiler: vc14-cmake configuration: Release - arch: x64 generator: Visual Studio 16 2019 shared: ON - compiler: vc14-cmake configuration: Debug - arch: Win32 generator: Visual Studio 16 2019 shared: OFF + - compiler: vc14-nmake + configuration: Release cache: @@ -50,34 +50,51 @@ init: - git config --global core.autocrlf input before_build: - - 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_SOURCE%`) DO SET AV_TIFF_CYG_SOURCE=%%F' - - 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\cygwin64\bin\cygpath -u %AV_TIFF_INSTALL%`) DO SET AV_TIFF_CYG_INSTALL=%%F' - - 'if %compiler%==cygwin-cmake C:\cygwin64\setup-x86_64 -q -R C:\cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -P cmake,libjpeg-devel,zlib-devel' - - 'if %compiler%==cygwin-cmake set "PATH=C:\cygwin64\bin;%PATH%"' + - 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\Cygwin64\bin\cygpath -u %AV_TIFF_SOURCE%`) DO SET AV_TIFF_CYG_SOURCE=%%F' + - 'FOR /F "tokens=* USEBACKQ" %%F IN (`C:\Cygwin64\bin\cygpath -u %AV_TIFF_INSTALL%`) DO SET AV_TIFF_CYG_INSTALL=%%F' + - 'if %compiler%==cygwin-cmake C:\Cygwin64\setup-x86_64 -q -R C:\Cygwin64 -s http://cygwin.mirror.constant.com -l %AV_TIFF_DOWNLOAD%\cygwin -P cmake,libjpeg-devel,zlib-devel' + - 'if %compiler%==cygwin-cmake set "PATH=C:\Cygwin64\bin;%PATH%"' - set + - 'if %compiler%==cygwin-cmake dir C:\Cygwin64\bin' + - 'if %compiler%==cygwin-cmake dir C:\Cygwin64\bin\cmake.exe' + - 'if %compiler%==cygwin-cmake C:\Cygwin64\bin\cmake.exe --version || echo CMake not found' + - 'if %compiler%==cygwin-cmake C:\Cygwin64\bin\cmake --version || echo CMake not found' - 'if %compiler%==cygwin-cmake cygpath --version || echo cygpath not found' - 'if %compiler%==cygwin-cmake cmake --version || echo CMake not found' - set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%" - - 'if %compiler%==cygwin-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"' - - 'if %compiler%==mingw32-cmake set "AV_CMAKE_ARGS=%AV_CMAKE_ARGS% -Dfatal-warnings=ON"' + - set "AV_CMAKE_ARGS=-DBUILD_SHARED_LIBS:BOOL=%shared%" - set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_SOURCE%" - set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_INSTALL%" - 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_SOURCE=%AV_TIFF_CYG_SOURCE%' - 'if %compiler%==cygwin-cmake set "AV_TIFF_CMAKE_INSTALL=%AV_TIFF_CYG_INSTALL%' - 'if %compiler%==mingw-cmake set "PATH=C:\MinGW\bin;%PATH%"' + - 'if %compiler%==vc14-nmake call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" %platform%' - mkdir %AV_TIFF_BUILD% - cd %AV_TIFF_BUILD% - - echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_TIFF_CMAKE_SOURCE% + - if NOT %compiler%==vc14-nmake echo Running cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_TIFF_CMAKE_SOURCE% - 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%"' - 'if %compiler%==mingw-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%' - - 'if %compiler%==vc14-cmake cmake -G "%generator%" -A %arch% -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%' + - 'if %compiler%==vc14-cmake cmake -G "%generator%" -A x64 -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%' build_script: - - cd %AV_TIFF_BUILD% + - if NOT %compiler%==vc14-nmake cd %AV_TIFF_BUILD% + - if %compiler%==vc14-nmake cd %AV_TIFF_SOURCE% - 'if %compiler%==cygwin-cmake bash -c "cmake --build . --config %configuration% --target install"' - 'if %compiler%==mingw-cmake cmake --build . --config %configuration% --target install' - 'if %compiler%==vc14-cmake cmake --build . --config %configuration% --target install' - 'if %compiler%==vc9-cmake cmake --build . --config %configuration% --target install' + - 'if %compiler%==vc14-nmake nmake /f Makefile.vc EXTRAFLAGS=/DHAVE_SNPRINTF=1' + - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%' + - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\bin' + - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\lib' + - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy tools\*.exe %AV_TIFF_INSTALL%\bin' + - 'if %compiler%==vc14-nmake copy port\*.lib %AV_TIFF_INSTALL%\lib' + - 'if %compiler%==vc14-nmake copy libtiff\tiff.h %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy libtiff\tiffio.h %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy libtiff\tiffvers.h %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy libtiff\tiffconf.h %AV_TIFF_INSTALL%\include' + - 'if %compiler%==vc14-nmake copy libtiff\tiffio.hxx %AV_TIFF_INSTALL%\include' # scripts to run after build after_build: @@ -92,6 +109,7 @@ before_test: - 'if %compiler%==mingw-cmake ctest -V -C %configuration%' - 'if %compiler%==vc14-cmake ctest -V -C %configuration%' - 'if %compiler%==vc9-cmake ctest -V -C %configuration%' +# vc14-nmake does not support unit tests # AppVeyor don't yet have a configurable retention policy, so this will # eventually use up all the storage allowance. diff --git a/thirdparty/SDL2_image/external/libtiff/.clang-format b/thirdparty/SDL2_image/external/libtiff/.clang-format deleted file mode 100644 index 732fa91e9..000000000 --- a/thirdparty/SDL2_image/external/libtiff/.clang-format +++ /dev/null @@ -1,6 +0,0 @@ ---- -BasedOnStyle: llvm -IndentWidth: 4 -ColumnLimit: 80 -BreakBeforeBraces: Allman -IndentCaseLabels: true diff --git a/thirdparty/SDL2_image/external/libtiff/.git-blame-ignore-revs b/thirdparty/SDL2_image/external/libtiff/.git-blame-ignore-revs deleted file mode 100644 index a907d5d8c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/.git-blame-ignore-revs +++ /dev/null @@ -1,4 +0,0 @@ -42173d6ace476b5228d866640b5355f74e5a108d -b0ae5d7071890160da67d2e833d84a400e0406d0 -dee020782c17c1388ca5774f9904d318b51b288b -aee0113f5ec1fd39b97458539bd79a1447425ac4 diff --git a/thirdparty/SDL2_image/external/libtiff/.gitignore b/thirdparty/SDL2_image/external/libtiff/.gitignore index 0fe95bba8..ad4d4e3cd 100644 --- a/thirdparty/SDL2_image/external/libtiff/.gitignore +++ b/thirdparty/SDL2_image/external/libtiff/.gitignore @@ -4,8 +4,6 @@ configure Makefile.in config/compile config/config.guess -config/config.h -config/config.h.in config/config.sub config/depcomp config/install-sh @@ -32,6 +30,7 @@ libtiff/mkg3states libtiff/stamp-h1 libtiff/stamp-h2 libtiff/tif_config.h +libtiff/tif_config.h.in libtiff/tiffconf.h libtool m4/libtool.m4 @@ -76,7 +75,3 @@ test/*.log test/*.trs test/o-* *~ -.idea -.vs -cmake-build* -build* diff --git a/thirdparty/SDL2_image/external/libtiff/.gitlab-ci.yml b/thirdparty/SDL2_image/external/libtiff/.gitlab-ci.yml index cf10b2e47..7efe145b3 100644 --- a/thirdparty/SDL2_image/external/libtiff/.gitlab-ci.yml +++ b/thirdparty/SDL2_image/external/libtiff/.gitlab-ci.yml @@ -1,60 +1,33 @@ -image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04:latest +image: ubuntu:20.04 + +before_script: + - apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq autoconf automake build-essential cmake libtool libjpeg8-dev libjbig-dev liblzma-dev ninja-build zlib1g-dev libdeflate-dev zip wget stages: - build - - static-analysis - pages - -autoconf-current: +autoconf: stage: build script: - sh build/gitlab-ci autoconf after_script: - 'cat autoconf-build/test/test-suite.log' - artifacts: - name: distribution - paths: - - distribution -autoconf-old: - stage: build - image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu20.04:latest - script: - - sh build/gitlab-ci autoconf-minimal - after_script: - - 'cat autoconf-build/test/test-suite.log' - -cmake-makefiles-current: +cmake-makefiles: stage: build script: - sh build/gitlab-ci cmake "Unix Makefiles" Release -cmake-ninja-current: +cmake-ninja: stage: build script: - sh build/gitlab-ci cmake "Ninja" Debug -cmake-makefiles-old: - stage: build - image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu20.04:latest - script: - - sh build/gitlab-ci cmake "Unix Makefiles" Release - -coverity: - stage: static-analysis - image: registry.gitlab.com/libtiff/libtiff-ci-ubuntu22.04-coverity:latest - script: - - sh build/gitlab-ci coverity "Ninja" Debug - only: - refs: - - master - pages: stage: pages script: - - sh build/gitlab-ci cmake "Ninja" Debug - - cp -r cmake-install/share/doc/tiff/manual/html public + - cp -r html public artifacts: name: $CI_PROJECT_NAME-$CI_JOB_NAME paths: diff --git a/thirdparty/SDL2_image/external/libtiff/.pre-commit-config.yaml b/thirdparty/SDL2_image/external/libtiff/.pre-commit-config.yaml deleted file mode 100644 index 9b3e0e0cf..000000000 --- a/thirdparty/SDL2_image/external/libtiff/.pre-commit-config.yaml +++ /dev/null @@ -1,22 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: 'v15.0.4' - hooks: - - id: clang-format - # tif_fax3sm.c is a generated file - # tiffvers.h as well, and its formatting is sensitive for - # FindTIFF.cmake to detect the version number - # Furthermore, the .in files are formatting sensitive for - # cmake functions. - exclude: > - (?x)^( - libtiff/tif_fax3sm.c| - libtiff/tiffvers.h| - libtiff/tiffvers.h.in| - libtiff/tif_config.h| - libtiff/tif_config.h.in| - libtiff/tif_config.h.cmake.in| - libtiff/tiffconf.h| - libtiff/tiffconf.h.in| - libtiff/tiffconf.h.cmake.in - ) diff --git a/thirdparty/SDL2_image/external/libtiff/.travis.yml b/thirdparty/SDL2_image/external/libtiff/.travis.yml new file mode 100644 index 000000000..ccb15be6b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/.travis.yml @@ -0,0 +1,29 @@ +language: c + +sudo: false +dist: trusty + +cache: + directories: + - download + +addons: + apt_packages: + - libjpeg8-dev + - libjbig-dev + - liblzma-dev + - zlib1g-dev + - zip + +os: + - linux + - osx + +env: + matrix: + - BUILD=autoconf + - BUILD=cmake TOOL="Unix Makefiles" TYPE=Release + - BUILD=cmake TOOL="Ninja" TYPE=Debug + +script: + - sh ./build/travis-ci "$BUILD" "$TOOL" "$TYPE" diff --git a/thirdparty/SDL2_image/external/libtiff/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/CMakeLists.txt index 8d440f310..73b716f16 100644 --- a/thirdparty/SDL2_image/external/libtiff/CMakeLists.txt +++ b/thirdparty/SDL2_image/external/libtiff/CMakeLists.txt @@ -2,7 +2,6 @@ # Run "cmake" to generate the build files for your platform # # Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh # Written by Roger Leigh # # Permission to use, copy, modify, distribute, and sell this software and @@ -24,158 +23,739 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -cmake_minimum_required(VERSION 3.9.0) +cmake_minimum_required(VERSION 2.8.11) # b/c of use of BUILD_INTERFACE generator expression -# Default policy is from 3.9.0 -cmake_policy(VERSION 3.9.0) - -# Find CMake modules in cmake/ -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +# Default policy is from 2.8.9 +cmake_policy(VERSION 2.8.9) +# Set MacOSX @rpath usage globally. +if (POLICY CMP0020) + cmake_policy(SET CMP0020 NEW) +endif(POLICY CMP0020) +if (POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif(POLICY CMP0042) +# Use new variable expansion policy. +if (POLICY CMP0053) + cmake_policy(SET CMP0053 NEW) +endif(POLICY CMP0053) +if (POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif(POLICY CMP0054) # Read version information from configure.ac. -include(AutotoolsVersion) -message(STATUS "Building tiff version ${LIBTIFF_VERSION_FULL}") -message(STATUS "libtiff library version ${SO_VERSION}") -string(TIMESTAMP BUILD_DATE "%Y%m%d") -message(STATUS "libtiff build date: ${BUILD_DATE}") +FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure REGEX "^LIBTIFF_.*=") +foreach(line ${configure}) + foreach(var LIBTIFF_MAJOR_VERSION LIBTIFF_MINOR_VERSION LIBTIFF_MICRO_VERSION LIBTIFF_ALPHA_VERSION + LIBTIFF_CURRENT LIBTIFF_REVISION LIBTIFF_AGE) + if(NOT ${var} AND line MATCHES "^${var}=(.*)") + set(${var} "${CMAKE_MATCH_1}") + break() + endif() + endforeach() +endforeach() -# Project definition -set(CMAKE_C_STANDARD 99) -project(tiff - VERSION "${LIBTIFF_VERSION}" - LANGUAGES C CXX) +math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}") +set(SO_MINOR "${LIBTIFF_AGE}") +set(SO_REVISION "${LIBTIFF_REVISION}") -if(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) - # libtiff is being included as a subproject of some other project. - set(TIFF_INSTALL_DEFAULT OFF) -else() - set(TIFF_INSTALL_DEFAULT ON) - option(BUILD_SHARED_LIBS "Build shared libraries" ON) -endif() +message(STATUS "Building tiff version ${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}${LIBTIFF_ALPHA_VERSION}") +message(STATUS "libtiff library version ${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}") -option(tiff-tools "build TIFF tools" ON) -option(tiff-tests "build TIFF tests" ON) -option(tiff-contrib "build TIFF contrib" ON) -option(tiff-docs "build TIFF documentation" ON) -option(tiff-deprecated "build TIFF deprecated features" OFF) -option(tiff-install "install TIFF targets" ${TIFF_INSTALL_DEFAULT}) +set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries") -# Disable deprecated features to ensure clean build -if (tiff-deprecated) - add_definitions(-DTIFF_DISABLE_DEPRECATED) -endif() +# Project version +project(tiff C) +set(VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}") +set(tiff_VERSION "${VERSION}") +set(tiff_VERSION_MAJOR "${LIBTIFF_MAJOR_VERSION}") +set(tiff_VERSION_MINOR "${LIBTIFF_MINOR_VERSION}") +set(tiff_VERSION_PATCH "${LIBTIFF_MICRO_VERSION}") -# Autotools compatibility -include(AutotoolsCompat) +# the other tiff_VERSION_* variables are set automatically +set(tiff_VERSION_ALPHA "${LIBTIFF_ALPHA_VERSION}") +# Library version (unlike libtool's baroque scheme, WYSIWYG here) +set(SO_COMPATVERSION "${SO_MAJOR}") +set(SO_VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}") -# Compiler checks (warning flags, etc.) -include(CompilerChecks) +# For autotools header compatibility +set(PACKAGE_NAME "LibTIFF Software") +set(PACKAGE_TARNAME "${PROJECT_NAME}") +set(PACKAGE_VERSION "${PROJECT_VERSION}${tiff_VERSION_ALPHA}") +set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") +set(PACKAGE_BUGREPORT "tiff@lists.maptools.org") -# Linker checks (version script, etc.) -include(LinkerChecks) - -# Processor checks (endianness, fill order, floating point, etc.) -include(ProcessorChecks) - -# Checks for headers -include(IncludeChecks) - -# Checks for functions and other symbols -include(SymbolChecks) - -# Standard installation paths include(GNUInstallDirs) -# Documentation install directory (default to cmake project docdir) -set(LIBTIFF_DOCDIR "${CMAKE_INSTALL_DOCDIR}") - -# CTest testing +include(CheckCCompilerFlag) +include(CheckCSourceCompiles) +include(CheckIncludeFile) +include(CheckLibraryExists) +include(CheckTypeSize) +include(CheckSymbolExists) enable_testing() -# Checks for type presence and size -include(TypeSizeChecks) +macro(current_date var) + if(UNIX) + execute_process(COMMAND "date" +"%Y%m%d" OUTPUT_VARIABLE ${var}) + endif() +endmacro() -# Check for POSIX Large File Support (LFS) -include(LargeFileSupport) +current_date(RELEASE_DATE) -# Options for internal codec support -include(InternalCodecs) +macro(extra_dist) + foreach(file ${ARGV}) + file(RELATIVE_PATH relfile "${PROJECT_SOURCE_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}/${file}") + list(APPEND EXTRA_DIST "${relfile}") + endforeach() + set(EXTRA_DIST "${EXTRA_DIST}" PARENT_SCOPE) +endmacro() -# Check for Deflate codec -include(DeflateCodec) +set(EXTRA_DIST + HOWTO-RELEASE + Makefile.vc + SConstruct + autogen.sh + configure.com + nmake.opt + libtiff-4.pc.in) -# Check for PixarLog codec -include(PixarLogCodec) +# These are annoyingly verbose, produce false positives or don't work +# nicely with all supported compiler versions, so are disabled unless +# explicitly enabled. +option(extra-warnings "Enable extra compiler warnings" OFF) -# Check for JPEG codec -include(JPEGCodec) +# This will cause the compiler to fail when an error occurs. +option(fatal-warnings "Compiler warnings are errors" OFF) -# Check for JBIG codec -include(JBIGCodec) +# Check if the compiler supports each of the following additional +# flags, and enable them if supported. This greatly improves the +# quality of the build by checking for a number of common problems, +# some of which are quite serious. +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR + CMAKE_C_COMPILER_ID MATCHES "Clang") + set(test_flags + -Wall + -Winline + -W + -Wformat-security + -Wpointer-arith + -Wdisabled-optimization + -Wno-unknown-pragmas + -Wdeclaration-after-statement + -fstrict-aliasing) + if(extra-warnings) + list(APPEND test_flags + -Wfloat-equal + -Wmissing-prototypes + -Wunreachable-code) + endif() + if(fatal-warnings) + list(APPEND test_flags + -Werror) + endif() +elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + set(test_flags) + if(extra-warnings) + list(APPEND test_flags + /W4) + else() + list(APPEND test_flags + /W3) + endif() + if (fatal-warnings) + list(APPEND test_flags + /WX) + endif() +endif() -# Check for LERC codec -include(LERCCodec) +foreach(flag ${test_flags}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" flag_var "${flag}") + set(test_c_flag "C_FLAG${flag_var}") + CHECK_C_COMPILER_FLAG(${flag} "${test_c_flag}") + if (${test_c_flag}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + endif (${test_c_flag}) +endforeach(flag ${test_flags}) -# Check for LZMA codec -include(LZMACodec) +if(MSVC) + set(CMAKE_DEBUG_POSTFIX "d") +endif() -# Check for ZSTD codec -include(ZSTDCodec) +option(ld-version-script "Enable linker version script" ON) +# Check if LD supports linker scripts. +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { + global: sym; +}; -# Check for WebP codec -include(WebPCodec) +VERS_2 { + global: sym; +} VERS_1; +") +set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) +set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map") +check_c_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT) +set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) +file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") +if (ld-version-script AND HAVE_LD_VERSION_SCRIPT) + set(HAVE_LD_VERSION_SCRIPT TRUE) +else() + set(HAVE_LD_VERSION_SCRIPT FALSE) +endif() -# Option for C++ libtiffxx library -include(CXXLibrary) +# Find libm, if available +if(NOT WIN32) + find_library(M_LIBRARY m) +endif() -# Checks for OpenGL support -include(OpenGLChecks) +check_include_file(assert.h HAVE_ASSERT_H) +check_include_file(dlfcn.h HAVE_DLFCN_H) +check_include_file(fcntl.h HAVE_FCNTL_H) +check_include_file(inttypes.h HAVE_INTTYPES_H) +check_include_file(io.h HAVE_IO_H) +check_include_file(search.h HAVE_SEARCH_H) +check_include_file(stdint.h HAVE_STDINT_H) +check_include_file(string.h HAVE_STRING_H) +check_include_file(strings.h HAVE_STRINGS_H) +check_include_file(sys/time.h HAVE_SYS_TIME_H) +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(unistd.h HAVE_UNISTD_H) -# Windows support -include(WindowsSupport) +# Inspired from /usr/share/autoconf/autoconf/c.m4 +foreach(inline_keyword "inline" "__inline__" "__inline") + if(NOT DEFINED C_INLINE) + set(CMAKE_REQUIRED_DEFINITIONS_SAVE ${CMAKE_REQUIRED_DEFINITIONS}) + set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + "-Dinline=${inline_keyword}") + check_c_source_compiles(" + typedef int foo_t; + static inline foo_t static_foo() {return 0;} + foo_t foo(){return 0;} + int main(int argc, char *argv[]) {return 0;}" + C_HAS_${inline_keyword}) + set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_SAVE}) + if(C_HAS_${inline_keyword}) + set(C_INLINE TRUE) + set(INLINE_KEYWORD "${inline_keyword}") + endif() + endif() +endforeach() +if(NOT DEFINED C_INLINE) + set(INLINE_KEYWORD) +endif() + +# off_t and size_t checks omitted; not clear they are used at all +# Are off_t and size_t checks strictly necessary? + +# Check if sys/time.h and time.h allow use together +check_c_source_compiles(" +#include +#include +int main(void){return 0;}" + TIME_WITH_SYS_TIME) + +# Check if struct tm is in sys/time.h +check_c_source_compiles(" +#include +#include + +int main(void){ + struct tm tm; + int *p = &tm.tm_sec; + return !p; +}" + TM_IN_SYS_TIME) + +# Check type sizes +# NOTE: Could be replaced with C99 +check_type_size("signed int" SIZEOF_SIGNED_INT) +check_type_size("unsigned int" SIZEOF_UNSIGNED_INT) +check_type_size("signed long" SIZEOF_SIGNED_LONG) +check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG) +check_type_size("signed long long" SIZEOF_SIGNED_LONG_LONG) +check_type_size("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG) +check_type_size("unsigned char *" SIZEOF_UNSIGNED_CHAR_P) + +set(CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES}) +set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "stddef.h") +check_type_size("size_t" SIZEOF_SIZE_T) +check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T) +set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE}) + +macro(report_values) + foreach(val ${ARGV}) + message(STATUS "${val} set to ${${val}}") + endforeach() +endmacro() + +set(TIFF_INT8_T "signed char") +set(TIFF_UINT8_T "unsigned char") + +set(TIFF_INT16_T "signed short") +set(TIFF_UINT16_T "unsigned short") + +if(SIZEOF_SIGNED_INT EQUAL 4) + set(TIFF_INT32_T "signed int") + set(TIFF_INT32_FORMAT "%d") +elseif(SIZEOF_SIGNED_LONG EQUAL 4) + set(TIFF_INT32_T "signed long") + set(TIFF_INT32_FORMAT "%ld") +endif() + +if(SIZEOF_UNSIGNED_INT EQUAL 4) + set(TIFF_UINT32_T "unsigned int") + set(TIFF_UINT32_FORMAT "%u") +elseif(SIZEOF_UNSIGNED_LONG EQUAL 4) + set(TIFF_UINT32_T "unsigned long") + set(TIFF_UINT32_FORMAT "%lu") +endif() + +if(SIZEOF_SIGNED_LONG EQUAL 8) + set(TIFF_INT64_T "signed long") + set(TIFF_INT64_FORMAT "%ld") +elseif(SIZEOF_SIGNED_LONG_LONG EQUAL 8) + set(TIFF_INT64_T "signed long long") + if (WIN32) + set(TIFF_INT64_FORMAT "%I64d") + else() + set(TIFF_INT64_FORMAT "%lld") + endif() +endif() + +if(SIZEOF_UNSIGNED_LONG EQUAL 8) + set(TIFF_UINT64_T "unsigned long") + set(TIFF_UINT64_FORMAT "%lu") +elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL 8) + set(TIFF_UINT64_T "unsigned long long") + if (WIN32) + set(TIFF_UINT64_FORMAT "%I64u") + else() + set(TIFF_UINT64_FORMAT "%llu") + endif() +endif() + +if(SIZEOF_UNSIGNED_INT EQUAL SIZEOF_SIZE_T) + set(TIFF_SIZE_T "unsigned int") + set(TIFF_SIZE_FORMAT "%u") + set(TIFF_SSIZE_T "signed int") + set(TIFF_SSIZE_FORMAT "%d") +elseif(SIZEOF_UNSIGNED_LONG EQUAL SIZEOF_SIZE_T) + set(TIFF_SIZE_T "unsigned long") + set(TIFF_SIZE_FORMAT "%lu") + set(TIFF_SSIZE_T "signed long") + set(TIFF_SSIZE_FORMAT "%ld") +elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL SIZEOF_SIZE_T) + set(TIFF_SIZE_T "unsigned long long") + set(TIFF_SSIZE_T "signed long long") + if (WIN32) + set(TIFF_SIZE_FORMAT "%I64u") + set(TIFF_SSIZE_FORMAT "%I64d") + else() + set(TIFF_SIZE_FORMAT "%llu") + set(TIFF_SSIZE_FORMAT "%lld") + endif() +endif() + +if(NOT SIZEOF_PTRDIFF_T) + set(TIFF_PTRDIFF_T "${TIFF_SSIZE_T}") + set(TIFF_PTRDIFF_FORMAT "${SSIZE_FORMAT}") +else() + set(TIFF_PTRDIFF_T "ptrdiff_t") + set(TIFF_PTRDIFF_FORMAT "%ld") +endif() + +#report_values(TIFF_INT8_T TIFF_INT8_FORMAT +# TIFF_UINT8_T TIFF_UINT8_FORMAT +# TIFF_INT16_T TIFF_INT16_FORMAT +# TIFF_UINT16_T TIFF_UINT16_FORMAT +# TIFF_INT32_T TIFF_INT32_FORMAT +# TIFF_UINT32_T TIFF_UINT32_FORMAT +# TIFF_INT64_T TIFF_INT64_FORMAT +# TIFF_UINT64_T TIFF_UINT64_FORMAT +# TIFF_SSIZE_T TIFF_SSIZE_FORMAT +# TIFF_PTRDIFF_T TIFF_PTRDIFF_FORMAT) + +check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP) +check_symbol_exists(setmode "unistd.h" HAVE_SETMODE) +check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) +check_symbol_exists(strcasecmp "strings.h" HAVE_STRCASECMP) +check_symbol_exists(strtol "stdlib.h" HAVE_STRTOL) +check_symbol_exists(strtoll "stdlib.h" HAVE_STRTOLL) +check_symbol_exists(strtoul "stdlib.h" HAVE_STRTOUL) +check_symbol_exists(strtoull "stdlib.h" HAVE_STRTOULL) +check_symbol_exists(getopt "unistd.h;stdio.h" HAVE_GETOPT) +check_symbol_exists(lfind "search.h" HAVE_LFIND) + +if(NOT HAVE_SNPRINTF) + add_definitions(-DNEED_LIBPORT) +endif() + +# CPU bit order +set(HOST_FILLORDER FILLORDER_MSB2LSB) +if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR + CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR + # AMD64 on Windows + CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64" OR + CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*") + set(HOST_FILLORDER FILLORDER_LSB2MSB) +endif() + +# CPU endianness +include(TestBigEndian) +test_big_endian(HOST_BIG_ENDIAN) +if(HOST_BIG_ENDIAN) + add_definitions(-DWORDS_BIGENDIAN) +endif() + +# IEEE floating point +set(HAVE_IEEEFP 1) + +report_values(CMAKE_HOST_SYSTEM_PROCESSOR HOST_FILLORDER + HOST_BIG_ENDIAN HAVE_IEEEFP) + +# Large file support +if (UNIX OR MINGW) + # This might not catch every possibility catered for by + # AC_SYS_LARGEFILE. + add_definitions(-D_FILE_OFFSET_BITS=64) + set(FILE_OFFSET_BITS 64) +endif() + +# Documentation install directory (default to cmake project docdir) +set(LIBTIFF_DOCDIR "${CMAKE_INSTALL_FULL_DOCDIR}") + +# Options to enable and disable internal codecs + +option(ccitt "support for CCITT Group 3 & 4 algorithms" ON) +set(CCITT_SUPPORT ${ccitt}) + +option(packbits "support for Macintosh PackBits algorithm" ON) +set(PACKBITS_SUPPORT ${packbits}) + +option(lzw "support for LZW algorithm" ON) +set(LZW_SUPPORT ${lzw}) + +option(thunder "support for ThunderScan 4-bit RLE algorithm" ON) +set(THUNDER_SUPPORT ${thunder}) + +option(next "support for NeXT 2-bit RLE algorithm" ON) +set(NEXT_SUPPORT ${next}) + +option(logluv "support for LogLuv high dynamic range algorithm" ON) +set(LOGLUV_SUPPORT ${logluv}) + +# Option for Microsoft Document Imaging +option(mdi "support for Microsoft Document Imaging" ON) +set(MDI_SUPPORT ${mdi}) + +# ZLIB +option(zlib "use zlib (required for Deflate compression)" ON) +if (zlib) + find_package(ZLIB) +endif() +set(ZLIB_SUPPORT 0) +if(ZLIB_FOUND) + set(ZLIB_SUPPORT 1) +endif() +set(ZIP_SUPPORT ${ZLIB_SUPPORT}) + + +# libdeflate +option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ON) +if (libdeflate) + set(DEFLATE_FOUND 0) + find_path(DEFLATE_INCLUDE_DIR libdeflate.h) + set(DEFLATE_NAMES ${DEFLATE_NAMES} deflate) + find_library(DEFLATE_LIBRARY NAMES ${DEFLATE_NAMES}) + if (DEFLATE_INCLUDE_DIR AND DEFLATE_LIBRARY) + set(DEFLATE_FOUND 1) + set(DEFLATE_LIBRARIES ${DEFLATE_LIBRARY}) + endif() +endif() +set(LIBDEFLATE_SUPPORT FALSE) +if(DEFLATE_FOUND) + set(LIBDEFLATE_SUPPORT TRUE) +endif() + +if(LIBDEFLATE_SUPPORT AND NOT ZIP_SUPPORT) + message(WARNING "libdeflate available but zlib is not. libdeflate cannot be used") + set(LIBDEFLATE_SUPPORT FALSE) +endif() + +set(LIBDEFLATE_SUPPORT ${LIBDEFLATE_SUPPORT}) + + +# Option for Pixar log-format algorithm + +# Pixar log format +option(pixarlog "support for Pixar log-format algorithm (requires Zlib)" ON) +set(PIXARLOG_SUPPORT FALSE) +if (ZLIB_SUPPORT) + if(pixarlog) + set(PIXARLOG_SUPPORT TRUE) + endif() +endif() + +# JPEG +option(jpeg "use libjpeg (required for JPEG compression)" ON) +if (jpeg) + find_package(JPEG) +endif() +set(JPEG_SUPPORT FALSE) +if(JPEG_FOUND) + set(JPEG_SUPPORT TRUE) +endif() + +option(old-jpeg "support for Old JPEG compression (read-only)" ON) +set(OJPEG_SUPPORT FALSE) +if (JPEG_SUPPORT) + if (old-jpeg) + set(OJPEG_SUPPORT TRUE) + endif() +endif() + +# JBIG-KIT +option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ON) +if (jbig) + set(JBIG_FOUND 0) + find_path(JBIG_INCLUDE_DIR jbig.h) + set(JBIG_NAMES ${JBIG_NAMES} jbig libjbig) + find_library(JBIG_LIBRARY NAMES ${JBIG_NAMES}) + if (JBIG_INCLUDE_DIR AND JBIG_LIBRARY) + set(JBIG_FOUND 1) + set(JBIG_LIBRARIES ${JBIG_LIBRARY}) + endif() +endif() +set(JBIG_SUPPORT 0) +if(JBIG_FOUND) + set(JBIG_FOUND TRUE) + set(JBIG_SUPPORT 1) +else() + set(JBIG_FOUND FALSE) +endif() + +set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) +set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIR}) +check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) +set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + +# liblzma2 +option(lzma "use liblzma (required for LZMA2 compression)" ON) +if (lzma) + find_package(LibLZMA) +endif() +set(LZMA_SUPPORT 0) +if(LIBLZMA_FOUND) + set(LZMA_SUPPORT 1) +endif() + +# libzstd +option(zstd "use libzstd (required for ZSTD compression)" ON) +if (zstd) + find_path(ZSTD_INCLUDE_DIR zstd.h) + find_library(ZSTD_LIBRARY NAMES zstd) + if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY) + check_library_exists ("${ZSTD_LIBRARY}" ZSTD_decompressStream "" ZSTD_RECENT_ENOUGH) + if (ZSTD_RECENT_ENOUGH) + set(ZSTD_FOUND TRUE) + set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) + message(STATUS "Found ZSTD library: ${ZSTD_LIBRARY}") + else () + message(WARNING "Found ZSTD library, but not recent enough. Use zstd >= 1.0") + endif () + endif () +endif() +set(ZSTD_SUPPORT 0) +if(ZSTD_FOUND) + set(ZSTD_SUPPORT 1) +endif() + +# libwebp +option(webp "use libwebp (required for WEBP compression)" ON) +if (webp) + find_path(WEBP_INCLUDE_DIR /webp/decode.h) + find_library(WEBP_LIBRARY NAMES webp) +endif() +set(WEBP_SUPPORT 0) +set(WEBP_FOUND FALSE) +if (WEBP_INCLUDE_DIR AND WEBP_LIBRARY) + set(WEBP_SUPPORT 1) + set(WEBP_FOUND TRUE) + set(WEBP_LIBRARIES ${WEBP_LIBRARY}) + message(STATUS "Found WEBP library: ${WEBP_LIBRARY}") +endif() + +# 8/12-bit jpeg mode +option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate +12-bit libjpeg build)" ON) +set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg") +set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library") +set(JPEG12_FOUND FALSE) +if (JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY) + set(JPEG12_LIBRARIES ${JPEG12_LIBRARY}) + set(JPEG12_FOUND TRUE) +endif() +if (JPEG12_FOUND) + set(JPEG_DUAL_MODE_8_12 1) + set(LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h") +endif() + +# C++ support +option(cxx "Enable C++ stream API building (requires C++ compiler)" ON) +set(CXX_SUPPORT FALSE) +if (cxx) + enable_language(CXX) + set(CXX_SUPPORT TRUE) +endif() + +# OpenGL and GLUT +find_package(OpenGL) +find_package(GLUT) +set(HAVE_OPENGL FALSE) +if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) + set(HAVE_OPENGL TRUE) +endif() +# Purely to satisfy the generated headers: +check_include_file(GL/gl.h HAVE_GL_GL_H) +check_include_file(GL/glu.h HAVE_GL_GLU_H) +check_include_file(GL/glut.h HAVE_GL_GLUT_H) +check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) +check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) +check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) + +# Win32 IO +set(win32_io FALSE) +if(WIN32) + set(win32_io TRUE) +endif() + +set(USE_WIN32_FILEIO ${win32_io}) # Orthogonal features -include(LibraryFeatures) +# Strip chopping +option(strip-chopping "strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)" ON) +set(TIFF_DEFAULT_STRIP_SIZE 8192 CACHE STRING "default size of the strip in bytes (when strip chopping is enabled)") -# math.h/libm portability -find_package(CMath REQUIRED) +set(STRIPCHOP_DEFAULT) +if(strip-chopping) + set(STRIPCHOP_DEFAULT TRUE) + if(TIFF_DEFAULT_STRIP_SIZE) + set(STRIP_SIZE_DEFAULT "${TIFF_DEFAULT_STRIP_SIZE}") + endif() +endif() -# Release support -include(Release) +# Defer loading of strip/tile offsets +option(defer-strile-load "enable deferred strip/tile offset/size loading (also available at runtime with the 'D' flag of TIFFOpen())" OFF) +set(DEFER_STRILE_LOAD ${defer-strile-load}) + +# CHUNKY_STRIP_READ_SUPPORT +option(chunky-strip-read "enable reading large strips in chunks for TIFFReadScanline() (experimental)" OFF) +set(CHUNKY_STRIP_READ_SUPPORT ${chunky-strip-read}) + +# SUBIFD support +set(SUBIFD_SUPPORT 1) + +# Default handling of ASSOCALPHA support. +option(extrasample-as-alpha "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" ON) +if(extrasample-as-alpha) + set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1) +endif() + +# Default handling of YCbCr subsampling support. +# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details. +option(check-ycbcr-subsampling "enable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag" ON) +if (check-ycbcr-subsampling) + set(CHECK_JPEG_YCBCR_SUBSAMPLING 1) +endif() + +# Generate pkg-config file +set(prefix "${CMAKE_INSTALL_PREFIX}") +set(exec_prefix "${CMAKE_INSTALL_PREFIX}") +set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") +set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc + DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") + +# Includes used by libtiff (and tests) +if(ZLIB_INCLUDE_DIRS) + list(APPEND TIFF_INCLUDES $) +endif() +if(DEFLATE_INCLUDE_DIR) + list(APPEND TIFF_INCLUDES ${DEFLATE_INCLUDE_DIR}) +endif() +if(JPEG_INCLUDE_DIR) + list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR}) +endif() +if(JPEG12_INCLUDE_DIR) + list(APPEND TIFF_INCLUDES ${JPEG12_INCLUDE_DIR}) +endif() +if(JBIG_INCLUDE_DIR) + list(APPEND TIFF_INCLUDES ${JBIG_INCLUDE_DIR}) +endif() +if(LIBLZMA_INCLUDE_DIRS) + list(APPEND TIFF_INCLUDES ${LIBLZMA_INCLUDE_DIRS}) +endif() +if(ZSTD_INCLUDE_DIR) + list(APPEND TIFF_INCLUDES ${ZSTD_INCLUDE_DIR}) +endif() +if(WEBP_INCLUDE_DIR) + list(APPEND TIFF_INCLUDES ${WEBP_INCLUDE_DIR}) +endif() + +# Libraries required by libtiff +set(TIFF_LIBRARY_DEPS) +if(NOT WIN32 AND M_LIBRARY) + list(APPEND TIFF_LIBRARY_DEPS "m") +endif() +if(ZLIB_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES}) +endif() +if(DEFLATE_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${DEFLATE_LIBRARIES}) +endif() +if(JPEG_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES}) +endif() +if(JPEG12_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES}) +endif() +if(JBIG_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${JBIG_LIBRARIES}) +endif() +if(LIBLZMA_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${LIBLZMA_LIBRARIES}) +endif() +if(ZSTD_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${ZSTD_LIBRARIES}) +endif() +if(WEBP_LIBRARIES) + list(APPEND TIFF_LIBRARY_DEPS ${WEBP_LIBRARIES}) +endif() + +#report_values(TIFF_INCLUDES TIFF_LIBRARY_DEPS) # Process subdirectories add_subdirectory(port) add_subdirectory(libtiff) -if(tiff-tools) - add_subdirectory(tools) -endif() -if(tiff-tests) - add_subdirectory(test) -endif() -if(tiff-contrib) - add_subdirectory(contrib) -endif() -add_subdirectory(build) -if(tiff-docs) - add_subdirectory(doc) -endif() +#add_subdirectory(tools) +#add_subdirectory(test) +#add_subdirectory(contrib) +#add_subdirectory(build) +#add_subdirectory(man) +#add_subdirectory(html) -# pkg-config support -include(PkgConfig) +#message(STATUS "EXTRA_DIST: ${EXTRA_DIST}") message(STATUS "") -message(STATUS "Libtiff is now configured for ${CMAKE_SYSTEM}") +message(STATUS "Libtiff is now configured for ${host}") message(STATUS "") message(STATUS " Installation directory: ${prefix}") message(STATUS " Documentation directory: ${LIBTIFF_DOCDIR}") message(STATUS " C compiler: ${CMAKE_C_COMPILER}") message(STATUS " C++ compiler: ${CMAKE_CXX_COMPILER}") message(STATUS " Build shared libraries: ${BUILD_SHARED_LIBS}") -message(STATUS " Build tools: ${tiff-tools}") -message(STATUS " Build tests: ${tiff-tests}") -message(STATUS " Build contrib: ${tiff-contrib}") -message(STATUS " Build docs: ${tiff-docs}") -message(STATUS " Build deprecated features: ${tiff-deprecated}") message(STATUS " Enable linker symbol versioning: ${HAVE_LD_VERSION_SCRIPT}") message(STATUS " Support Microsoft Document Imaging: ${mdi}") message(STATUS " Use win32 IO: ${USE_WIN32_FILEIO}") @@ -189,40 +769,19 @@ message(STATUS " NeXT 2-bit RLE algorithm: ${next}") message(STATUS " LogLuv high dynamic range encoding: ${logluv}") message(STATUS "") message(STATUS " Support for external codecs:") -message(STATUS " ZLIB support: Requested:${zlib} Availability:${ZLIB_FOUND} Support:${ZLIB_SUPPORT}") -if(ZLIB_SUPPORT) - message(STATUS " libdeflate support: Requested:${libdeflate} Availability:${DEFLATE_FOUND} Support:${LIBDEFLATE_SUPPORT}") -else() - message(STATUS " libdeflate support: Requested:${libdeflate} Availability:${DEFLATE_FOUND} Support:${LIBDEFLATE_SUPPORT} (Depends on ZLIB Support)") -endif() -if(ZLIB_SUPPORT) - message(STATUS " Pixar log-format algorithm: Requested:${pixarlog} Availability:${ZLIB_FOUND} Support:${PIXARLOG_SUPPORT}") -else() - message(STATUS " Pixar log-format algorithm: Requested:${pixarlog} Availability:${ZLIB_FOUND} Support:${PIXARLOG_SUPPORT} (Depends on ZLIB Support)") -endif() -message(STATUS " JPEG support: Requested:${jpeg} Availability:${JPEG_FOUND} Support:${JPEG_SUPPORT}") -if(JPEG_SUPPORT) - message(STATUS " Old JPEG support: Requested:${old-jpeg} Availability:${JPEG_SUPPORT} Support:${OJPEG_SUPPORT}") -else() - message(STATUS " Old JPEG support: Requested:${old-jpeg} Availability:${JPEG_SUPPORT} Support:${OJPEG_SUPPORT} (Depends on JPEG Support)") -endif() -if(JPEG_SUPPORT AND HAVE_JPEGTURBO_DUAL_MODE_8_12) - message(STATUS " JPEG 8/12 bit dual mode: Support: yes (libjpeg turbo >= 2.2 dual mode)") -else() - message(STATUS " JPEG 8/12 bit dual mode: Requested:${jpeg12} Availability:${JPEG12_FOUND} Support:${JPEG_DUAL_MODE_8_12}") -endif() -message(STATUS " ISO JBIG support: Requested:${jbig} Availability:${JBIG_FOUND} Support:${JBIG_SUPPORT}") -if(ZLIB_SUPPORT) - message(STATUS " LERC support: Requested:${lerc} Availability:${LERC_FOUND} Support:${LERC_SUPPORT}") -else() - message(STATUS " LERC support: Requested:${lerc} Availability:${LERC_FOUND} Support:${LERC_SUPPORT} (Depends on ZLIB Support)") -endif() -message(STATUS " LZMA2 support: Requested:${lzma} Availability:${liblzma_FOUND} Support:${LZMA_SUPPORT}") -message(STATUS " ZSTD support: Requested:${zstd} Availability:${ZSTD_USABLE} Support:${ZSTD_SUPPORT}") -message(STATUS " WEBP support: Requested:${webp} Availability:${WebP_FOUND} Support:${WEBP_SUPPORT}") +message(STATUS " ZLIB support: ${zlib} (requested) ${ZLIB_FOUND} (availability)") +message(STATUS " libdeflate support: ${libdeflate} (requested) ${LIBDEFLATE_SUPPORT} (availability)") +message(STATUS " Pixar log-format algorithm: ${pixarlog} (requested) ${PIXARLOG_SUPPORT} (availability)") +message(STATUS " JPEG support: ${jpeg} (requested) ${JPEG_FOUND} (availability)") +message(STATUS " Old JPEG support: ${old-jpeg} (requested) ${JPEG_FOUND} (availability)") +message(STATUS " JPEG 8/12 bit dual mode: ${jpeg12} (requested) ${JPEG12_FOUND} (availability)") +message(STATUS " ISO JBIG support: ${jbig} (requested) ${JBIG_FOUND} (availability)") +message(STATUS " LZMA2 support: ${lzma} (requested) ${LIBLZMA_FOUND} (availability)") +message(STATUS " ZSTD support: ${zstd} (requested) ${ZSTD_FOUND} (availability)") +message(STATUS " WEBP support: ${webp} (requested) ${WEBP_FOUND} (availability)") message(STATUS "") message(STATUS " C++ support: ${cxx} (requested) ${CXX_SUPPORT} (availability)") message(STATUS "") # message(STATUS " X Athena Widgets support: ${HAVE_XAW}") -message(STATUS " OpenGL support: Requested:${tiff-opengl} Availability:${HAVE_OPENGL} Support:${OPENGL_SUPPORT}") +message(STATUS " OpenGL support: ${HAVE_OPENGL}") message(STATUS "") diff --git a/thirdparty/SDL2_image/external/libtiff/CONTRIBUTING.md b/thirdparty/SDL2_image/external/libtiff/CONTRIBUTING.md deleted file mode 100644 index 1291d61cf..000000000 --- a/thirdparty/SDL2_image/external/libtiff/CONTRIBUTING.md +++ /dev/null @@ -1,19 +0,0 @@ -Contributing ------------- - -libtiff uses a ``.clang-format`` file to enforce code formatting rules. - -Automatic code reformatting can be done with pre-commit. - -Install (once) pre-commit with ``python -m pip install pre-commit``. - -Install it (once) in the libtiff git repository with ``pre-commit install``. - -Then the rules defined in the ``.pre-commit-config.yaml`` file will be -enforced at ``git commit`` time, with automatic reformatting. - -Due to whole-tree code reformatting done during libtiff 4.5 development, -``git blame`` information might be misleading. To avoid that, you need -to modify your git configuration as following to ignore the revision of -the whole-tree reformatting: -``git config blame.ignoreRevsFile .git-blame-ignore-revs``. diff --git a/thirdparty/SDL2_image/external/libtiff/LICENSE.md b/thirdparty/SDL2_image/external/libtiff/COPYRIGHT similarity index 91% rename from thirdparty/SDL2_image/external/libtiff/LICENSE.md rename to thirdparty/SDL2_image/external/libtiff/COPYRIGHT index 55b65673e..828218615 100644 --- a/thirdparty/SDL2_image/external/libtiff/LICENSE.md +++ b/thirdparty/SDL2_image/external/libtiff/COPYRIGHT @@ -1,7 +1,5 @@ -# LibTIFF license - -Copyright © 1988-1997 Sam Leffler\ -Copyright © 1991-1997 Silicon Graphics, Inc. +Copyright (c) 1988-1997 Sam Leffler +Copyright (c) 1991-1997 Silicon Graphics, Inc. Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided diff --git a/thirdparty/SDL2_image/external/libtiff/ChangeLog b/thirdparty/SDL2_image/external/libtiff/ChangeLog index 212481614..452dcb3a1 100644 --- a/thirdparty/SDL2_image/external/libtiff/ChangeLog +++ b/thirdparty/SDL2_image/external/libtiff/ChangeLog @@ -1,4366 +1,3 @@ -2023-06-09 Even Rouault - - libtiff v4.5.1 released - -2023-06-09 Even Rouault - - Merge remote-tracking branch 'sulaus/Rel_4.5.1_preparation' - -2023-06-09 Even Rouault - - Merge branch 'disable_dng_tags' into 'master' - tif_dirinfo.c: disable DNG 1.2->1.6 tags - - Closes #575 - - See merge request libtiff/libtiff!497 - -2023-06-09 Even Rouault - - Merge branch 'fix_577' into 'master' - CMake related fixes - - Closes #577 - - See merge request libtiff/libtiff!496 - -2023-06-07 Even Rouault - - tif_dirinfo.c: disable DNG 1.2->1.6 tags. - They were added per b90b20d36d7833f54a1f3014c324f6c21b988006 but it has - been found in https://gitlab.com/libtiff/libtiff/-/issues/575 that it - could cause compatibity issues with libtiff users, so this addition - should be defered for a feature release (likely 4.6.0) and not a patch one. - - Fixes #575 - -2023-06-06 Timothy Lyanguzov - - Apply 1 suggestion(s) to 1 file(s) - -2023-06-05 Even Rouault - - CI: add testing of find_package(Tiff CONFIG) - - CMake: export TiffConfig.cmake and TiffConfigVersion.cmake files. - - libtiff/CMakeLists.txt: fix export of INTERFACE_INCLUDE_DIRECTORIES. - - libtiff/CMakeLists.txt: correctly define TIFF::tiff alias (fixes #577) - -2023-06-05 Even Rouault - - Merge branch 'TIFFField_downgrade_errors_to_warnings' into 'master' - TIFFFieldWithName() and TIFFFieldWithTag() downgrade errors to warnings. - - See merge request libtiff/libtiff!495 - -2023-05-28 Su_Laus - - TIFFFieldWithName() and TIFFFieldWithTag() downgrade errors to warnings. see https://gitlab.com/libtiff/libtiff/-/issues/575#note_1407633888 - -2023-05-25 Even Rouault - - Merge branch 'bebuch-master-patch-58347' into 'master' - check if upstream lzma (xz) config was used and bind to it if so - - See merge request libtiff/libtiff!494 - -2023-05-25 Benjamin Buch - - check if upstream lzma (xz) config was used and bind to it if so. - -2023-05-25 Even Rouault - - Merge branch 'upstream-zstd-config' into 'master' - check if upstream zstd config was used and bind to it if so - - See merge request libtiff/libtiff!493 - -2023-05-25 Even Rouault - - Merge branch 'cmake_FindDeflate_bugs_see_526' into 'master' - CMake: FindDeflate several errors fixed (see #526) - - See merge request libtiff/libtiff!491 - -2023-05-24 Su_Laus - - CMake: FindDeflate several errors (see #526) - There are CMake issues if the library is not included in the environment path and only set with CMake -D option. - - For FindDeflate.cmake, FindJBIG.cmake, FindLERC.cmake, FindWebP.cmake, FindZSTD.cmake: - Set IMPORTED_LOCATION (without debug or release) if neither _LIBRARY_RELEASE nor _LIBRARY_DEBUG were set. - - FindDeflate.cmake: Correct code to retrieve library version information from libdeflate.h - - FindLERC.cmake version string return added. - -2023-05-24 Benjamin Buch - - prefer shared over static. - - check if upstream zstd config was used and bind to it if so. - -2023-05-24 Even Rouault - - Merge branch 'master' into 'master' - make WebP component name compatible with upstream ConfigWebP.cmake - - See merge request libtiff/libtiff!492 - -2023-05-24 Benjamin Buch - - CMake: make WebP component name compatible with upstream ConfigWebP.cmake - -2023-05-18 Su_Laus - - Prepare release 4.5.1 - Update till 18.05.23 after fix_559_DNG_1.6_passcount_error - - Prepare release 4.5.1. - -2023-05-18 Even Rouault - - Merge branch 'fix_559_DNG_1.6_passcount_error' into 'master' - Fix #559 DNG 1.6 passcount assertion - - Closes #574 et #559 - - See merge request libtiff/libtiff!489 - -2023-05-18 Even Rouault - - Merge branch 'fix_557_TagExtender_for_CustomDirectories_not_possible' into 'master' - manpage: TIFFSetTagExtender() cannot add tags to custom directories. Closes #557. - - Closes #557 - - See merge request libtiff/libtiff!490 - -2023-05-18 Even Rouault - - Merge branch 'fix_559_DNG_1.6_passcount_error' into 'master' - Fix #559 DNG 1.6 passcount assertion - - Closes #574 et #559 - - See merge request libtiff/libtiff!489 - -2023-05-18 Even Rouault - - Merge branch 'fix_557_TagExtender_for_CustomDirectories_not_possible' into 'master' - manpage: TIFFSetTagExtender() cannot add tags to custom directories. Closes #557. - - Closes #557 - - See merge request libtiff/libtiff!490 - -2023-05-17 Su_Laus - - Documentation update: TIFFSetTagExtender() cannot add tags to custom directories. - Closes #557. - -2023-05-16 Even Rouault - - Merge branch 'fix_558' into 'master' - Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB, and make 'H' flag of TIFFOpen()... - - See merge request libtiff/libtiff!488 - -2023-05-16 Su_Laus - - Fix #559 DNG 1.6 passcount assertion. - Amend DNG tags definition introduced with MR 482: - - DNG 1.6 tags specified as UTF-8 strings are defined as variable TIFF_BYTE with passcount=TRUE. - - For all tags with TIFF_SETGET_C32_UINT8 the readcount and writecount were corrected to -3 (TIFF_VARIABLE2). - - Testprogram to write and read all tags defined within LibTIFF is introduced. - It also checks for valid passcount flag setting for the defined tags but some special tags are excluded from that check. - - Closes #559. - -2023-05-09 Even Rouault - - Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB, and make 'H' flag of TIFFOpen() to warn and an alias of FILLORDER_MSB2LSB - - tif_lerc.c: use WORDS_BIGENDIAN instead of HOST_BIGENDIAN. - -2023-05-07 Even Rouault - - Merge branch 'fix_484_TIFFDirectory_32_64_bit' into 'master' - Fix 484 TIFFDirectory td_fieldsset uses unsigned long which can be 32 or 64 bits. - - Closes #484 - - See merge request libtiff/libtiff!471 - -2023-05-07 Even Rouault - - Merge branch 'DNG_1.6_EP_tags' into 'master' - Add DNG tags up to version 1.6.0.0 and some TIFF/EP tags and update documentation - - See merge request libtiff/libtiff!482 - -2023-05-07 Even Rouault - - Merge branch 'issue547' into 'master' - do not install libtiff-4.pc when tiff-install is reset - - Closes #547 - - See merge request libtiff/libtiff!481 - -2023-05-06 Even Rouault - - Merge branch 'fix_548' into 'master' - LZWDecode(): avoid crash when trying to read again from a strip whith a... - - Closes #548 - - See merge request libtiff/libtiff!484 - -2023-05-06 Even Rouault - - Merge branch 'tiffcrop_fix_553_multi-image-errors' into 'master' - tiffcrop: fix 553 by considering error return of writeSelections() - - Closes #553 - - See merge request libtiff/libtiff!485 - -2023-05-06 Even Rouault - - Merge branch 'tif_ojpeg_fix-554_FPE' into 'master' - tif_ojpeg.c fix 554 by checking for division by zero - - Closes #554 - - See merge request libtiff/libtiff!486 - -2023-05-06 Su Laus - - tif_ojpeg.c fix 554 by checking for division by zero. - -2023-05-05 Su_Laus - - Consider error return of writeSelections(). Fixes #553. - -2023-04-29 Even Rouault - - LZWDecode(): avoid crash when trying to read again from a strip whith a missing end-of-information marker (fixes #548) - -2023-04-25 Su_Laus - - Add DNG tags up to version 1.6.0.0 and some TIFF/EP tags and update documentation - Amend MR !337 'Add support for DNG tags up to version 1.6.0.0 and some TIFF/EP tags' from Sami Liedes: - - Set most tags to OkToChange=1. - - Define BATTERYLEVEL tag as ASCII and convert values of rational variant to ASCII. - - TIFF documentation updated for tags recognized by LibTiff (DNG 1.6 and others). - - TIFF/EP tags added, which are equivalent to EXIF tags. This addresses part of #418 as well. - - Definition of tags reformatted (clang-format off) for better readability of tag comments in tiff.h and tif_dirinfo.c - -2023-04-23 Roman - - do not install libtiff-4.pc when tiff-install is reset. - -2023-04-21 Even Rouault - - Merge branch 'mymaster1' into 'master' - fix runtime error: applying zero offset to null pointer - - See merge request libtiff/libtiff!479 - -2023-04-21 xiaoxiaoafeifei - - countInkNamesString(): fix `UndefinedBehaviorSanitizer`: applying zero offset to null pointer - -2023-03-26 Even Rouault - - Merge branch 'tif_ovrcache_TIFFSetSubDirectory' into 'master' - tif_ovrcache.c: check TIFFSetSubDirectory() return value (CID 1524573) - - See merge request libtiff/libtiff!478 - -2023-03-26 Even Rouault - - tif_ovrcache.c: check TIFFSetSubDirectory() return value (CID 1524573) - -2023-03-26 Even Rouault - - Merge branch 'even_faster_setdirectory_with_IFDlist' into 'master' - Even faster TIFFSetDirectory() using IFD list. - - See merge request libtiff/libtiff!477 - -2023-03-26 Su Laus - - Even faster TIFFSetDirectory() using IFD list. - -2023-03-12 Even Rouault - - Merge branch 'faster-setdirectory_newMR' into 'master' - Optimize relative seeking with TIFFSetDirectory - - See merge request libtiff/libtiff!474 - -2023-03-12 Su Laus - - Optimize relative seeking with TIFFSetDirectory. - -2023-03-11 Even Rouault - - Merge branch 'master' into 'master' - Fix memory leak in tiffcrop.c - - See merge request libtiff/libtiff!475 - -2023-03-08 zhailiangliang - - Fix memory leak in tiffcrop.c. - -2023-02-23 Even Rouault - - Merge branch 'skip-thumbnail-test' into 'master' - test: avoid running tool tests if not built - - Closes #421 - - See merge request libtiff/libtiff!334 - -2023-02-22 Sam James - - test (cmake): skip script tests if tools aren't built. - In Gentoo, we avoid building the tools for multilib (32-bit, x86) builds on - amd64/x86_64 because we only need the library to keep binary applications working. - - This causes a test failure in e.g. tiffcp-thumbnail.sh as the 'thumbnail' - binary isn't built. Skip it if unavailable. - - Fixes: https://gitlab.com/libtiff/libtiff/-/issues/421 - -2023-02-22 Sam James - - test (autotools): skip script tests if tools aren't built. - In Gentoo, we avoid building the tools for multilib (32-bit, x86) builds on - amd64/x86_64 because we only need the library to keep binary applications working. - - This causes a test failure in e.g. tiffcp-thumbnail.sh as the 'thumbnail' - binary isn't built. Skip it if unavailable. - - Fixes: https://gitlab.com/libtiff/libtiff/-/issues/421 - -2023-02-16 Even Rouault - - Merge branch 'fix_Unlink_first_directory_0' into 'master' - Fix TIFFUnlinkDirectory(0) case and unlink of first directory. - - See merge request libtiff/libtiff!460 - -2023-02-16 Even Rouault - - Merge branch 'tif_luv_check_NaN_fix_#530' into 'master' - tif_luv: Check and correct for NaN data in uv_encode(). - - Closes #530 - - See merge request libtiff/libtiff!473 - -2023-02-16 Su_Laus - - tif_luv: Check and correct for NaN data in uv_encode(). - Closes #530 - - See merge request !473 - -2023-02-14 Even Rouault - - Merge branch 'tiffcrop_dont_reuse_input_buffer_fix_527' into 'master' - tiffcrop: Do not reuse input buffer for subsequent images. Fix issue 527 - - Closes #527 - - See merge request libtiff/libtiff!472 - -2023-02-14 Su_Laus - - tiffcrop: Do not reuse input buffer for subsequent images. Fix issue 527 - Reuse of read_buff within loadImage() from previous image is quite unsafe, because other functions (like rotateImage() etc.) reallocate that buffer with different size without updating the local prev_readsize value. - - Closes #527 - -2023-02-08 Su_Laus - - Fix 484 TIFFDirectory td_fieldsset uses unsigned long which can be 32 or 64 bits. - Closes #484 - -2023-02-08 Even Rouault - - Merge branch 'test_ifd_loop_detection_fix_CoverityScan_ln_55' into 'master' - test_ifd_loop_detection: fix Coverity Scan issue CID 1520750: Null pointer... - - See merge request libtiff/libtiff!470 - -2023-02-08 Su_Laus - - test_ifd_loop_detection: fix Coverity Scan issue CID 1520750: Null pointer dereferences (NULL_RETURNS) line 55. - -2023-02-06 Even Rouault - - Merge branch 'tiffcrop_fix_CoverityScan_line_9676' into 'master' - Fix Coverity Scan issue CID 1520761: Integer handling issues... - - See merge request libtiff/libtiff!469 - -2023-02-06 Su_Laus - - Fix Coverity Scan issue CID 1520761: Integer handling issues (OVERFLOW_BEFORE_WIDEN) tiffcrop.c: 9676 in rotateImage() - -2023-02-05 Even Rouault - - Merge branch 'tiffcrop_R270_fix#492' into 'master' - tiffcrop: Amend rotateImage() not to toggle the input (main) image width and... - - Closes #519, #518, #499, #495, #494, #493 et #492 - - See merge request libtiff/libtiff!465 - -2023-02-05 Su_Laus - - tiffcrop: Amend rotateImage() not to toggle the input (main) image width and length parameters when only cropped image sections are rotated. Remove buffptr from region structure because never used. - Closes #492 #493 #494 #495 #499 #518 #519 - -2023-02-05 Even Rouault - - Merge branch 'tiffcrop_correctly_update_buffersize_after_rotate_fix#520' into 'master' - tiffcrop correctly update buffersize after rotateImage() fix#520 - - Closes #520 - - See merge request libtiff/libtiff!467 - -2023-02-05 Even Rouault - - Merge branch 'tiffcrop_composite_image_assumption_test_fix#496' into 'master' - tiffcrop: added check for assumption on composite images (fixes #496) - - Closes #501, #500, #498, #497 et #496 - - See merge request libtiff/libtiff!466 - -2023-02-05 Su Laus - - tiffcrop: added check for assumption on composite images (fixes #496) - tiffcrop: For composite images with more than one region, the combined_length or combined_width always needs to be equal, respectively. Otherwise, even the first section/region copy action might cause buffer overrun. This is now checked before the first copy action. - - Closes #496, #497, #498, #500, #501. - -2023-02-04 Su_Laus - - tiffcrop correctly update buffersize after rotateImage() fix#520 -- enlarge buffsize and check integer overflow within rotateImage(). - -2023-02-04 Even Rouault - - Merge branch 'test_subidf_loop' into 'master' - test_ifd_loop_detection: Added test to check loops in SubIFDs that are chained. - - See merge request libtiff/libtiff!464 - -2023-02-04 Su Laus - - test_ifd_loop_detection: Added test to check loops in SubIFDs that are chained. - -2023-02-04 Su_Laus - - Fix TIFFUnlinkDirectory(0) case and unlink of first directory. - If directory number 0 is unlinked, then the base offset variables within LibTiff are not updated. As a result, a subsequent TIFFSetDirectory() first goes to the unlinked former directory number 0. - - In addition, the error case for dirn=0 is handled. - - This MR fixes that by updating the base offset variables tif->tif_header.classic.tiff_diroff and tif->tif_header.big.tiff_diroff. - -2023-02-03 Even Rouault - - Merge branch 'TiffClose_NULL_ptr_dereferencing_fix_515' into 'master' - TIFFClose() avoid NULL pointer dereferencing. fix#515 - - Closes #515 - - See merge request libtiff/libtiff!468 - -2023-02-03 Su_Laus - - TIFFClose() avoid NULL pointer dereferencing. fix#515. - Closes #515 - - tiffcrop correctly update buffersize after rotateImage() fix#520 rotateImage() set up a new buffer and calculates its size individually. Therefore, seg_buffs[] size needs to be updated accordingly. Before this fix, the seg_buffs buffer size was calculated with a different formula than within rotateImage(). - Closes #520. - -2023-01-25 Even Rouault - - Merge branch 'add_windows_DLL_versioninfo' into 'master' - Add versioninfo resource files for DLL and tools compiled with Windows MSVC and MINGW. - - See merge request libtiff/libtiff!455 - -2023-01-25 Su Laus - - Add versioninfo resource files for DLL and tools compiled with Windows MSVC and MINGW. - -2023-01-22 Even Rouault - - Merge branch 'tif_hash_set_order_include' into 'master' - tif_hash_set.c: include tif_hash_set.h after tif_config.h to let a chance for... - - See merge request libtiff/libtiff!462 - -2023-01-22 Even Rouault - - tif_hash_set.c: include tif_hash_set.h after tif_config.h to let a chance for GDAL symbol renaming trick - -2023-01-22 Even Rouault - - Merge branch 'fix_513' into 'master' - Fax3: fix failure to decode some fax3 images (fixes #513) - - Closes #513 - - See merge request libtiff/libtiff!461 - -2023-01-21 Even Rouault - - Add test for Fax3 decoding issues (refs #513) - -2023-01-21 Even Rouault - - Merge branch 'tiffcrop_fix_#488' into 'master' - tiffcrop: Correct simple copy paste error. Fix #488. - - Closes #488 - - See merge request libtiff/libtiff!459 - -2023-01-21 Su Laus - - tiffcrop: Correct simple copy paste error. Fix #488. - -2023-01-21 Even Rouault - - Fax3: fix failure to decode some fax3 images (fixes #513) - Patch by @jsummers26 - -2023-01-12 Even Rouault - - Merge branch 'tiffmedian_fix_#477' into 'master' - tiffmedian: avoid zero num_colors, fixes #477 - - Closes #477 - - See merge request libtiff/libtiff!458 - -2023-01-12 Even Rouault - - Merge branch 'fax2ps_fixes_#475' into 'master' - fax2ps: fixes #475 buffer overflow in qsort function pcompar. - - Closes #475 - - See merge request libtiff/libtiff!457 - -2023-01-12 Su_Laus - - tiffmedian: avoid zero num_colors, fixes #477. - - fax2ps: fixes #475 buffer overflow in qsort function pcompar. - -2023-01-09 Even Rouault - - Merge branch 'fix_241_tiffset_file_size_limit' into 'master' - tiffset: get filesize to allocate only the required memory. Fixes issue #241 - - Closes #241 - - See merge request libtiff/libtiff!451 - -2023-01-09 Su Laus - - tiffset: get filesize to allocate only the required memory. Fixes issue #241 - -2023-01-09 Even Rouault - - Merge branch '_TIFFCleanupIFDOffsetAndNumberMaps' into 'master' - Add _TIFFCleanupIFDOffsetAndNumberMaps() and call it from TIFFUnlinkDirectory() - - See merge request libtiff/libtiff!454 - -2023-01-06 Even Rouault - - Remove use of tif_dirnumber. - - TIFFSetSubDirectory(): call _TIFFCleanupIFDOffsetAndNumberMaps() - - struct tiff: remove unused tif_dirlistoff. - - TIFFUnlinkDirectory(): reset tif_dirnumber. - - Add _TIFFCleanupIFDOffsetAndNumberMaps() and call it from TIFFUnlinkDirectory() - -2022-12-29 Even Rouault - - Merge branch 'cmake_in_files_formatting_sensitive' into 'master' - Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in... - - See merge request libtiff/libtiff!452 - -2022-12-28 Su_Laus - - Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in because sensitive for CMake scripts. - explanation added - -2022-12-26 Su_Laus - - Disable clang-formatting for tif_config.h.cmake.in and tiffconf.h.cmake.in because sensitive for CMake scripts. - -2022-12-19 Even Rouault - - Merge branch 'manpage_multi-page-TIFF' into 'master' - manpage: Add multi page TIFF and SubIFDs description and read / write example. - - See merge request libtiff/libtiff!450 - -2022-12-19 Su Laus - - manpage: Add multi page TIFF and SubIFDs description and read / write example. - -2022-12-18 Even Rouault - - Merge branch 'TIFFOpen_r+_windows_behaviour' into 'master' - Behavior of TIFFOpen() mode "r+" in the Windows implementation adjusted to that of Linux. - - See merge request libtiff/libtiff!449 - -2022-12-16 Su_Laus - - Behavior of TIFFOpen() mode "r+" in the Windows implementation adjusted to that of Linux. - -2022-12-15 Even Rouault - - Merge branch 'ossfuzz_54343' into 'master' - TIFFSetDirectory: avoid harmless unsigned-integer-overflow - - See merge request libtiff/libtiff!447 - -2022-12-15 Even Rouault - - TIFFSetDirectory: avoid harmless unsigned-integer-overflow. - Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54343 - -2022-12-14 Even Rouault - - Merge branch 'ossfuzz_54311' into 'master' - TIFFWriteDirectorySec(): avoid harmless unsigned-integer-overflow - - See merge request libtiff/libtiff!446 - -2022-12-14 Even Rouault - - TIFFWriteDirectorySec(): avoid harmless unsigned-integer-overflow. - Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=54311 - -2022-12-14 Even Rouault - - libtiff v4.5.0rc2 preparation - -2022-12-14 Su_Laus - - tiffinfo: update curdir from uint16_t to tdir_t for more than 64k IFD handling. - -2022-12-13 Even Rouault - - Merge branch 'fix_502' into 'master' - Make TIFFSetDirectory(tiff, 65534) work again (fixes #502) - - Closes #502 - - See merge request libtiff/libtiff!436 - -2022-12-13 Even Rouault - - Add tests for IFD loop detection. - - Fix IFD loop detection. - - Use UINT_MAX. - - Make TIFF_MAX_DIR_COUNT a autoconf/CMake setting. - -2022-12-13 Even Rouault - - Merge branch 'build-shared-by-default' into 'master' - Restore shared libraries by default - - See merge request libtiff/libtiff!437 - -2022-12-13 shaun walbridge - - CMake: restore shared libraries by default for top-level build. - -2022-12-12 Even Rouault - - Add a TIFF_MAX_DIR_COUNT public #define. - - TIFFCurrentDirectory(), TIFFNumberOfDirectories(), TIFFSetDirectory(), TIFFUnlinkDirectory(): use tdir_t that is now a uint32_t, and raise limit of IFDs to 1048576 - - IFD loop checking: use hashmap to avoid quadratic performance. - - Add a hashset/hashmap implementation (ported from GDAL's CPLHashSet) - - Make TIFFSetDirectory(tiff, 65534) work again (fixes #502) - -2022-12-11 Even Rouault - - Merge branch 'do_not_format_tiffvers_h' into 'master' - Revert formatting of tiffvers.h and add TIFFLIB_MAJOR_VERSION, TIFFLIB_MINOR_VERSION, TIFFLIB_MICRO_VERSION defines - - See merge request libtiff/libtiff!434 - -2022-12-11 Even Rouault - - Merge branch 'tiffcrop_exclude_some_comment_from_clang-format' into 'master' - tiffcrop: Exclude some comments from clang-format - - See merge request libtiff/libtiff!435 - -2022-12-11 Su Laus - - tiffcrop: Exclude some comments from clang-format. - -2022-12-11 Even Rouault - - tiffvers.h.in: add clang-format off/on. - -2022-12-10 Even Rouault - - tiffvers.h: add TIFFLIB_MAJOR_VERSION, TIFFLIB_MINOR_VERSION, TIFFLIB_MICRO_VERSION defines - Also add a TIFFLIB_AT_LEAST() macro - - tiffvers.h: revert formatting. - - Exclude reformatting of tiffvers.h which breaks version detection for FindTIFF.cmake - -2022-12-09 Even Rouault - - Merge branch 'release_4_5_0' into 'master' - Prepare v4.5.0 release - - See merge request libtiff/libtiff!433 - -2022-12-09 Even Rouault - - libtiff v4.5.0rc1 preparation - -2022-12-08 Even Rouault - - Merge branch 'reformat' into 'master' - Whole code-base reformatting - - See merge request libtiff/libtiff!431 - -2022-12-08 Even Rouault - - Add .git-blame-ignore-revs. - - tiffcrop: remove version_id and rev_date. - -2022-12-08 pre-commit run by Even Rouault - - Reformatting in all other directories using 'pre-commit run' - - Reformatting in test/ using 'pre-commit run' - - Reformatting in tools/ using 'pre-commit run' - - Reformatting in libtiff/ using 'pre-commit run' - -2022-12-08 Even Rouault - - Add .clang-format, .pre-commit-config.yaml and CONTRIBUTING.md. - - Remove vim/emacs formatting footers. - -2022-11-29 Even Rouault - - Merge branch 'fix_489' into 'master' - TIFFWriteRawStrip(): restore capabilities to append data in the current strip (fixes #489) - - Closes #489 - - See merge request libtiff/libtiff!430 - -2022-11-29 Even Rouault - - Add test case for scenario of issue #489. - - TIFFWriteRawStrip(): restore capabilities to append data in the current strip (fixes #489) - This fixes a regression of libtiff 4.4.0 - -2022-11-29 Even Rouault - - Merge branch 'manpage_re-entrant_error_handler' into 'master' - manpage update for re-entrant error handler TIFFErrorExtR(), TIFFOpenExt() and... - - See merge request libtiff/libtiff!427 - -2022-11-29 Su Laus - - manpage update for re-entrant error handler TIFFErrorExtR(), TIFFOpenExt() and... - -2022-11-27 Even Rouault - - Merge branch 'tiffcrop_fix_#169' into 'master' - tiffcrop: Add check if (bps != 1) in writeSingleSection() for... - - Closes #169 - - See merge request libtiff/libtiff!429 - -2022-11-27 Su Laus - - tiffcrop: Add check if (bps != 1) in writeSingleSection() for... - -2022-11-26 Even Rouault - - Merge branch 'TIFFErrorExtR_fix_missing_calls' into 'master' - TIFFErrorExt() was not replaced with TIFFErrorExtR() everywhere in libtiff.... - - See merge request libtiff/libtiff!428 - -2022-11-26 Su Laus - - TIFFErrorExt() was not replaced with TIFFErrorExtR() everywhere in libtiff.... - -2022-11-25 Even Rouault - - Merge branch 'tif_jpeg_build_fix' into 'master' - tif_jpeg.c: fix compilation with MSVC (fixes commit 0fd1a81d3547acb8f5be50bbbc3e44bde01c014b) - - See merge request libtiff/libtiff!426 - -2022-11-25 Even Rouault - - tif_jpeg.c: fix compilation with MSVC (fixes commit 0fd1a81d3547acb8f5be50bbbc3e44bde01c014b) - -2022-11-25 Even Rouault - - Merge branch 'fix_0fd1a81d3547acb8f5be50bbbc3e44bde01c014b' into 'master' - JPEGEncode(): fix wrong pointer data type with libjpeg-turbo 2.2dev in 12-bit mode - - See merge request libtiff/libtiff!425 - -2022-11-25 Even Rouault - - JPEGEncode(): fix wrong pointer data type with libjpeg-turbo 2.2dev in 12-bit mode - (fixes commit 0fd1a81d3547acb8f5be50bbbc3e44bde01c014b) - -2022-11-25 Even Rouault - - Merge branch 'libjpegturbo_dual' into 'master' - Add support for libjpeg-turbo 2.2-dev 8/12 bit dual mode - - See merge request libtiff/libtiff!422 - -2022-11-25 Even Rouault - - Add support for libjpeg-turbo 2.2-dev 8/12 bit dual mode. - -2022-11-23 Even Rouault - - Merge branch 'windows-fix' into 'master' - libtiff: Fix TIFFOpen* for the Windows platform in tif_unix.c - - See merge request libtiff/libtiff!424 - -2022-11-23 Francois Bleibel - - libtiff: Fix TIFFOpen* for the Windows platform in tif_unix.c. - I'm not sure where this change was made, but it must have been in a recent update. TIFFOpenWEx is now TIFFOpenWExt, and _TIFFgetMode takes additional arguments. - - Verified: Tested libtiff on a local Windows build. - -2022-11-23 Even Rouault - - Merge branch 'tiffcrop_signed_vs_unsigned' into 'master' - tiffcrop.c: fix warning about signed vs unsigned comparison - - See merge request libtiff/libtiff!423 - -2022-11-23 Even Rouault - - tiffcrop.c: fix warning about signed vs unsigned comparison. - -2022-11-23 Even Rouault - - Merge branch 'TIFFClientOpenExt_warning_fix' into 'master' - TIFFClientOpenExt(): fix warning on 32-bit platforms (master only) - - See merge request libtiff/libtiff!421 - -2022-11-23 Even Rouault - - TIFFClientOpenExt(): fix warning on 32-bit platforms (master only) - -2022-11-23 Even Rouault - - Merge branch 'tiffcp_TIFFOpenOptionsFree_memleak_fix' into 'master' - tiffcp: fix leak of TIFFOpenOptionsAlloc() introduced in latest commit (master only) - - See merge request libtiff/libtiff!420 - -2022-11-23 Even Rouault - - tiffcp: fix leak of TIFFOpenOptionsAlloc() introduced in latest commit (master only) - Fixes Coverity CID 1517032 - -2022-11-23 Even Rouault - - Merge branch 'TIFFOpenOptionsSetMaxSingleMemAlloc' into 'master' - Add TIFFOpenOptionsSetMaxSingleMemAlloc() to define a limit in bytes for a single memory allocation done by libtiff - - See merge request libtiff/libtiff!419 - -2022-11-23 Even Rouault - - Emit explicit error message when tif_max_single_mem_alloc is exceeded. - - test_open_options: test TIFFOpenOptionsSetMaxSingleMemAlloc() - - Rename test_error_handlers to test_open_options. - - tiffinfo, tiffcp, tiffcrop, tiffsplit, tiff2rgba, tiff2ps: use TIFFOpenOptionsSetMaxSingleMemAlloc() - - Convert uses of _TIFFmalloc/realloc/calloc/free to the Ext functions. - -2022-11-22 Even Rouault - - Add TIFFOpenOptionsSetMaxSingleMemAlloc() - to define a limit in bytes for a single memory allocation done by libtiff. - - Also add internal functions used in replacement of the non Ext ones: - void* _TIFFmallocExt(TIFF* tif, tmsize_t s); - void* _TIFFcallocExt(TIFF* tif, tmsize_t nmemb, tmsize_t siz); - void* _TIFFreallocExt(TIFF* tif, void* p, tmsize_t s); - void _TIFFfreeExt(TIFF* tif, void* p); - -2022-11-22 Even Rouault - - Merge branch 'TIFFOpenEx' into 'master' - Add TIFFOpenExt(), TIFFOpenWExt() and TIFFFdOpenExt() with re-entrant error handlers - - See merge request libtiff/libtiff!413 - -2022-11-21 Even Rouault - - Remove TIFFSetErrorHandlerExtR() and TIFFSetWarningHandlerExtR() that were temporarily added in master - - Add a _TIFFErrorEarly() function to be able to use the re-entrant error handler, even before TIFF* is valid - - Rework TIFFOpenExt() and similar to use an opaque TIFFOpenOptions* opts argument, with alloc, free and setters - - Document TIFFOpenExt, TIFFOpenWExt, TIFFFdOpenExt, TIFFClientOpenExt, TIFFSetErrorHandlerExtR, TIFFSetWarningHandlerExtR - -2022-11-21 Even Rouault - - Add TIFFOpenExt(), TIFFOpenWExt() and TIFFFdOpenExt() with re-entrant error handlers - Rename TIFFClientOpenEx() to TIFFClientOpenExt() - - Rework signature of the re-entrant error handlers and of - TIFFSetWarningHandlerExt() and TIFFSetErrorHandlerExt() - - Use structures that can be extended as extra argument. - - Leverages and ammends https://gitlab.com/libtiff/libtiff/-/merge_requests/409 - -2022-11-21 Even Rouault - - Merge branch 'manpage_fix485_file-descriptor_clientdata' into 'master' - manpage: Correct description of file handle/descriptors tif_fd and tif_clientdata. Closes #485. - - Closes #485 - - See merge request libtiff/libtiff!418 - -2022-11-21 Su Laus - - manpage: Correct description of file handle/descriptors tif_fd and tif_clientdata. Closes #485. - -2022-11-20 Even Rouault - - Merge branch 'manpage_fix440_fix28_TIFFOpen_SubIFD_update' into 'master' - manpage: fix28, fix440, update TIFFOpen and SubIFD - - Closes #440 et #28 - - See merge request libtiff/libtiff!417 - -2022-11-20 Su Laus - - manpage: fix28, fix440, update TIFFOpen and SubIFD. - -2022-11-17 Even Rouault - - Merge branch 'cmake_tiff_install_warning' into 'master' - CMakeLists.txt: fix warning with -Wdev - - See merge request libtiff/libtiff!416 - -2022-11-13 Even Rouault - - CMakeLists.txt: fix warning with -Wdev. - ``` - CMake Warning (dev) at CMakeLists.txt:62 (option): - Policy CMP0077 is not set: option() honors normal variables. Run "cmake - --help-policy CMP0077" for policy details. Use the cmake_policy command to - set the policy and suppress this warning. - - For compatibility with older versions of CMake, option is clearing the - normal variable 'tiff-install'. - This warning is for project developers. Use -Wno-dev to suppress it. - ``` - -2022-11-12 Even Rouault - - Merge branch 'fix_479' into 'master' - _TIFFReadEncodedTileAndAllocBuffer(): avoid excessive memory allocation on... - - See merge request libtiff/libtiff!412 - -2022-11-12 Even Rouault - - Merge branch 'typo_fix' into 'master' - tif_dirread.c: fix typo in comment - - See merge request libtiff/libtiff!414 - -2022-11-12 Even Rouault - - tif_dirread.c: fix typo in comment. - -2022-11-11 Even Rouault - - _TIFFReadEncodedTileAndAllocBuffer(): avoid excessive memory allocation on broken files (fixes #479) - -2022-11-10 Even Rouault - - Merge branch 'bugfix/tiff2pdf-stdout' into 'master' - tiff2pdf Don't try to seek into stdout. - - See merge request libtiff/libtiff!367 - -2022-11-10 Claus-Justus Heine - - tiff2pdf: Don't try to seek into stdout. - Fixes #441 - -2022-11-08 Even Rouault - - Merge branch 'fix_coverity_1516759' into 'master' - TIFFErrorExtR(): fix Dereference after null check (CID 1516759) - - See merge request libtiff/libtiff!411 - -2022-11-08 Even Rouault - - Merge branch 'fix_ossfuzz_53137' into 'master' - TIFFReadRGBATileExt(): fix (unsigned) integer overflow on strips/tiles > 2 GB - - See merge request libtiff/libtiff!410 - -2022-11-08 Even Rouault - - TIFFErrorExtR(): fix Dereference after null check (CID 1516759) - -2022-11-08 Even Rouault - - Merge branch 'no_sprintf' into 'master' - Replace sprintf calls with snprintf - - See merge request libtiff/libtiff!408 - -2022-11-08 Mark Mentovai - - Replace sprintf calls with snprintf. - This makes it possible to build libtiff without warnings using the macOS - 13 SDK. Calls to sprintf are replaced with snprintf, passing appropriate - buffer sizes. - - It doesn’t appear that any of the changed uses of sprintf were actually - unsafe, so no behavior change is expected aside from SDK compatibility. - - The macOS 13 SDK deprecates sprintf as it’s difficult to use safely. The - deprecation warning message is visible when building C++, but it is not - normally visible when building plain C code due to a quirk in how - sprintf is declared in the SDK. However, the deprecation message is - visible when building plain C under Address Sanitizer - (-fsanitize=address). This discrepancy was discovered at - https://crbug.com/1381706 and reported to Apple with a copy at - https://openradar.appspot.com/FB11761475. - - The macOS 13 SDK is packaged in Xcode 14.1, released on 2022-11-01. This - also affects the iOS 16 SDK and other 2022-era Apple OS SDKs packaged in - Xcode 14.0, released on 2022-09-12. - - libtiff is visible to the Chromium build via PDFium, and this change is - needed to allow Chromium to move forward to the macOS 13 SDK. - - This change is limited to the libtiff directory. Other uses of sprintf - were found in contrib, test, and tools. - -2022-11-08 Even Rouault - - Merge branch 'reentrant' into 'master' - Add reentrant error functions - - See merge request libtiff/libtiff!409 - -2022-11-08 Even Rouault - - TIFFReadRGBATileExt(): fix (unsigned) integer overflow on strips/tiles > 2 GB - Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53137 - -2022-11-08 Laramie Leavitt - - Add reentrant error functions. - Prior to this change, libtiff relied on global error handlers, - which is problematic when libtiff used by multiple independent - libraries from within the same process, as they may unwittingly - clobber the error handling, introduce race conditions when setting - handlers, or otherwise have unintended side effects. - - This change adds error handlers to the TIFF struct, which are - used preferentially when available. The error handlers are invoked - when the re-entrant error functions are called: - - void TIFFErrorExtR(TIFF*, const char* module, const char* fmt, ...) - void TIFFWarningExtR(TIFF*, const char* module, const char* fmt, ...) - - The handlers have a similar signature to the existing extended - handlers, additionally returning an int: - - int TIFFErrorHandlerExtR(thandle_t, const char*, const char*, va_list) - - thandle_t is the userdata passed to TIFFOpen - When the handler returns 1, the global handlers are not called. - - Custom error/warning handlers may be installed on a per-file - basis by calling the Set functions: - - TIFF* tif = TIFFOpen(...); - TIFFSetErrorHandlerExtR(tif, MyErrorHandler); - TIFFSetWarningHandlerExtR(tif, MyWarningHandler); - - Additionally, the callsites to TIFFErrorExt and TIFFWarningExt - have been updated to call the reentrant versions. - -2022-11-08 Even Rouault - - Merge branch 'tiffcrop_fix_CoverityScan_tmsize_issue' into 'master' - tiffcrop: should fix some Coverity Scan issues OVERFLOW_BEFORE_WIDEN - - See merge request libtiff/libtiff!403 - -2022-11-08 Su Laus - - tiffcrop: should fix some Coverity Scan issues OVERFLOW_BEFORE_WIDEN. - -2022-11-02 Even Rouault - - Merge branch 'typo_fix' into 'master' - tif_dirread.c: fix typo in comment - - See merge request libtiff/libtiff!407 - -2022-11-02 Even Rouault - - tif_dirread.c: fix typo in comment. - -2022-10-23 Even Rouault - - Merge branch 'tiffcrop_formatting_fix' into 'master' - tiffcrop: add casts in TIFFError() to fix compiler warnings - - See merge request libtiff/libtiff!406 - -2022-10-23 Even Rouault - - Merge branch 'fix_482' into 'master' - CMake: correctly set default value of 'lzma' option when liblzma is detected (fixes #482) - - Closes #482 - - See merge request libtiff/libtiff!404 - -2022-10-23 Even Rouault - - tiffcrop: add casts in TIFFError() to fix compiler warnings. - - CMake: correctly set default value of 'lzma' option when liblzma is detected (fixes #482) - -2022-10-20 Even Rouault - - Merge branch 'fix_480' into 'master' - Fix incorrect printf() formatters introduced in recent commits (fixes #480) - - Closes #480 - - See merge request libtiff/libtiff!401 - -2022-10-19 Even Rouault - - Fix incorrect printf() formatters introduced in recent commits (fixes #480) - -2022-10-13 Even Rouault - - Merge branch 'CLIPPATH_tags_corrected' into 'master' - CLIPPATH tags defined twice but differently and also wrongly (#439) - corrected - - Closes #439 - - See merge request libtiff/libtiff!366 - -2022-10-13 Even Rouault - - Merge branch 'FIELD_IGNORE_warning-messages' into 'master' - Warning messages for FIELD_IGNORE tags for writing and for TIFF_SETGET_UNDEFINED for reading added. (#438) - - Closes #438 - - See merge request libtiff/libtiff!365 - -2022-10-13 Su Laus - - Warning messages for FIELD_IGNORE tags for writing and for TIFF_SETGET_UNDEFINED for reading added. (#438) - -2022-10-13 Even Rouault - - Merge branch 'tag-def_COMPRESSION_corrected' into 'master' - tif_dirinfo.c TIFFTAG_COMPRESSION and _BITSPERSAMPLE definition corrected - - See merge request libtiff/libtiff!364 - -2022-10-13 Even Rouault - - Merge branch 'fix_getopt_included_twice' into 'master' - Fix including module getopt.c twice with CMake and HAVE_GETOPT=false - - See merge request libtiff/libtiff!381 - -2022-10-13 Even Rouault - - Merge branch 'tiffcrop_CoverityScan_fix_PRINTF_ARGS' into 'master' - tiffcrop: fix Coverity Scan issues about PRINTF_ARGS. - - See merge request libtiff/libtiff!400 - -2022-10-13 Su_Laus - - tiffcrop fix Coverity Scan issues about PRINTF_ARGS. - -2022-10-13 Even Rouault - - Merge branch 'tiffcrop_fix_#450_too-many-mode-options' into 'master' - tiffcrop: fix #450 too many 'mode' options on command line. - - Closes #470 et #450 - - See merge request libtiff/libtiff!384 - -2022-10-13 Su Laus - - tiffcrop: fix #450 too many 'mode' options on command line. - -2022-10-13 Even Rouault - - Merge branch 'tiffcrop_fix_#435' into 'master' - tiffcrop subroutines require a larger buffer (fixes #271, #381, #386, #388, #389, #435) - - Closes #465, #464, #435, #389, #388, #386, #381 et #271 - - See merge request libtiff/libtiff!382 - -2022-10-13 Su Laus - - tiffcrop subroutines require a larger buffer (fixes #271, #381, #386, #388, #389, #435) - -2022-10-12 Even Rouault - - Merge branch 'InkNames_NumberOfInks_handling_revised' into 'master' - Revised handling of TIFFTAG_INKNAMES and related TIFFTAG_NUMBEROFINKS value (fixes #149, #150, #152, #168, #250, #269, #398 and #456) - - Closes #474, #463, #387, #456, #398, #269, #250, #168, #152, #150 et #149 - - See merge request libtiff/libtiff!385 - -2022-10-12 Even Rouault - - Merge branch 'tiffcrop_fix_#411_#413' into 'master' - tiffcrop: disable incompatibility of -Z, -X, -Y, -z options with any PAGE_MODE_x option (fixes #411, #413 and #426) - - Closes #426, #413 et #411 - - See merge request libtiff/libtiff!383 - -2022-10-10 Even Rouault - - Merge branch 'TIFFAdvanceDirectory_mapped_uio' into 'master' - TIFFAdvanceDirectory(): fix unsigned-integer-overflow in mapped case - - See merge request libtiff/libtiff!398 - -2022-10-10 Even Rouault - - TIFFAdvanceDirectory(): fix unsigned-integer-overflow in mapped case. - Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52309 - -2022-10-08 Even Rouault - - Merge branch 'tiffinfo_parse_SubIFDs' into 'master' - tiffinfo: Updated to parse through SubIFDs and show their tags. - - See merge request libtiff/libtiff!396 - -2022-10-08 Su Laus - - tiffinfo: Updated to parse through SubIFDs and show their tags. - -2022-10-07 Roger Leigh - - Merge branch 'master' into 'master' - Moved linking of CMath::CMath into CMath_LIBRARY check - - See merge request libtiff/libtiff!397 - -2022-10-07 Frei Herr - - Moved linking of CMath::CMath into CMath_LIBRARY check. - -2022-10-06 Even Rouault - - Merge branch 'rational_precision2double_coverity-fix' into 'master' - rational_precision2double.c: Fix issue from Coverity Scan. - - See merge request libtiff/libtiff!395 - -2022-10-06 Su_Laus - - rational_precision2double.c: Fix issue from Coverity Scan. - - Fix including module getopt.c twice with CMake and HAVE_GETOPT=false. - The "make-files" for the tools- and test- programmes include the module getopt.c once directly as additional source and then again by including port.lib. - This can be avoided by including getopt.c as source in port.lib within port\CMakeLists.txt not with PUBLIC but with PRIVATE. - -2022-10-06 Even Rouault - - Merge branch 'fix-455_Improved-IFD-loop-handling' into 'master' - Improved IFD-Loop Handling (fixes #455) - - Closes #455 - - See merge request libtiff/libtiff!386 - -2022-10-06 Su Laus - - Improved IFD-Loop Handling (fixes #455) - IFD infinite looping was not fixed by MR 20 (see #455). - An improved IFD loop handling is proposed. - - Basic approach: - - - The order in the entire chain must be checked, and not only whether an offset has already been read once. - - To do this, pairs of directory number and offset are stored and checked. - - The offset of a directory number can change. - - TIFFAdvanceDirectory() must also perform an IFD loop check. - - TIFFCheckDirOffset() is replaced by _TIFFCheckDirNumberAndOffset(). - - Rules for the check: - - - If an offset is already in the list, it must have the same IFD number. Otherwise it is an IDF loop. - - If the offset is not in the list and the IFD number is greater than there are list entries, a new list entry is added. - - Otherwise, the offset of the IFD number is updated. - - Reference is also made to old bugzilla bug 2772 and MR 20, which did not solve the general issue. - This MR closes #455 - -2022-10-05 Roger Leigh - - Merge branch 'fix-cmake-subproject' into 'master' - Fix CMake build to be compatible with FetchContent - - See merge request libtiff/libtiff!394 - -2022-10-04 Timothy Lyanguzov - - Apply 9 suggestion(s) to 3 file(s) - -2022-10-04 Jeremy Maitin-Shepard - - Fix CMake build to be compatible with FetchContent. - Recent versions of CMake have improved support for including - dependencies, using the FetchContent module, which allows a dependency - to be imported as a subproject and then later found automatically by - calls to `find_package`. - - This change makes libtiff's CMake better behaved when used as a - sub-project: - - - CMake has a single global namespace for all target names in all - sub-projects. This commit renames the following CMake targets: - - - port -> tiff_port - - mkg3states -> tiff_mkg3states - - faxtable -> tiff_faxtable - - release -> tiff_release - - - When building TIFF as a sub-project, it is not normally useful to - create install rules for its targets. This commit adds a - `tiff-install` option that controls whether the install rules are - added and defaults to OFF when libtiff is included as a sub-project. - - - Previously, libtiff set `BUILD_SHARED_LIBS` to ON by default. With - this commit, that default is only set if libtiff is the top-level - project. - - - When using `find_package(TIFF)`, the targets `TIFF::TIFF` and - `TIFF::CXX` are defined. This commit makes libtiff itself define - those targets as aliases, to allow other cmake projects to use - either `find_package` or `FetchContent` interchangeably. - - - Adds ZSTD_HAVE_DECOMPRESS_STREAM variable which may be set to bypass - `check_symbol_exists` call. Fixes - https://gitlab.com/libtiff/libtiff/-/issues/472. - -2022-09-27 Even Rouault - - Merge branch 'getimage_overflow' into 'master' - Update getimage to support reading large raster images - - See merge request libtiff/libtiff!389 - -2022-09-26 Even Rouault - - Merge branch 'MinGW-warnings_ipctutil' into 'master' - Fix #458: MinGW Windows 64: warning because 'long' is a 32 bits type in... - - Closes #458 - - See merge request libtiff/libtiff!391 - -2022-09-26 Su Laus - - Fix #458: MinGW Windows 64: warning because 'long' is a 32 bits type in... - -2022-09-16 Eric Siegel - - Update getimage to support large raster images. - -2022-09-08 Even Rouault - - Merge branch 'typo_fix' into 'master' - tif_lzw.c: fix typo in code comment - - See merge request libtiff/libtiff!387 - -2022-09-08 Even Rouault - - tif_lzw.c: fix typo in code comment. - -2022-08-30 Su_Laus - - Revised handling of TIFFTAG_INKNAMES and related TIFFTAG_NUMBEROFINKS value - In order to solve the buffer overflow issues related to TIFFTAG_INKNAMES and related TIFFTAG_NUMBEROFINKS value, a revised handling of those tags within LibTiff is proposed: - - Behaviour for writing: - `NumberOfInks` MUST fit to the number of inks in the `InkNames` string. - `NumberOfInks` is automatically set when `InkNames` is set. - If `NumberOfInks` is different to the number of inks within `InkNames` string, that will be corrected and a warning is issued. - If `NumberOfInks` is not equal to samplesperpixel only a warning will be issued. - - Behaviour for reading: - When reading `InkNames` from a TIFF file, the `NumberOfInks` will be set automatically to the number of inks in `InkNames` string. - If `NumberOfInks` is different to the number of inks within `InkNames` string, that will be corrected and a warning is issued. - If `NumberOfInks` is not equal to samplesperpixel only a warning will be issued. - - This allows the safe use of the NumberOfInks value to read out the InkNames without buffer overflow - - This MR will close the following issues: #149, #150, #152, #168 (to be checked), #250, #269, #398 and #456. - - It also fixes the old bug at http://bugzilla.maptools.org/show_bug.cgi?id=2599, for which the limitation of `NumberOfInks = SPP` was introduced, which is in my opinion not necessary and does not solve the general issue. - -2022-08-25 Su_Laus - - tiffcrop: disable incompatibility of -Z, -X, -Y, -z options with any PAGE_MODE_x option (fixes #411 and #413) - tiffcrop does not support –Z, -z, -X and –Y options together with any other PAGE_MODE_x options like -H, -V, -P, -J, -K or –S. - - Code analysis: - - With the options –Z, -z, the crop.selections are set to a value > 0. Within main(), this triggers the call of processCropSelections(), which copies the sections from the read_buff into seg_buffs[]. - In the following code in main(), the only supported step, where that seg_buffs are further handled are within an if-clause with if (page.mode == PAGE_MODE_NONE) . - - Execution of the else-clause often leads to buffer-overflows. - - Therefore, the above option combination is not supported and will be disabled to prevent those buffer-overflows. - - The MR solves issues #411 and #413. - -2022-08-21 Even Rouault - - Merge branch 'tiffcrop_S-option_mutually_exclusive' into 'master' - tiffcrop: -S option mutually exclusive (fixes #349, #414, #422, #423, #424) - - Closes #424, #423, #422, #414 et #349 - - See merge request libtiff/libtiff!378 - -2022-08-20 Su_Laus - - tiffcrop -S option: Make decision simpler. - -2022-08-20 Even Rouault - - Merge branch 'remove_death_commented_code' into 'master' - Remove dead code from tif_dirread.c, tif_dirwrite.c and tif_getimage.c - - See merge request libtiff/libtiff!380 - -2022-08-20 Su Laus - - Remove dead code from tif_dirread.c, tif_dirwrite.c and tif_getimage.c. - -2022-08-16 Even Rouault - - Merge branch 'coverity_fixes' into 'master' - Silence Coverity Scan false positive warnings about out-of-bounds access - - See merge request libtiff/libtiff!379 - -2022-08-16 Even Rouault - - tif_zip.c: silence Coverity Scan false positive warnings about out-of-bounds access (CID 1491190, 1491197, 1491201) - - tif_dirread.c: silence Coverity Scan false positive warnings about out-of-bounds access (CID 1491182, 1491186) - -2022-08-16 Even Rouault - - Merge branch 'default_tag_values_extended' into 'master' - Presetting of default tag values extended (e.g. PlanarConfig). (fixes #449) - - Closes #449 - - See merge request libtiff/libtiff!377 - -2022-08-16 Su Laus - - Presetting of default tag values extended (e.g. PlanarConfig). (fixes #449) - -2022-08-15 Su_Laus - - According to Richard Nolde https://gitlab.com/libtiff/libtiff/-/issues/401#note_877637400 the tiffcrop option „-S“ is also mutually exclusive to the other crop options (-X|-Y), -Z and -z. - This is now checked and ends tiffcrop if those arguments are not mutually exclusive. - - This MR will fix the following tiffcrop issues: #349, #414, #422, #423, #424 - -2022-08-09 Even Rouault - - Merge branch 'warning_fix' into 'master' - Fix warning about shadowing - - See merge request libtiff/libtiff!376 - -2022-08-09 Even Rouault - - Fix warning about shadowing. - -2022-08-09 Even Rouault - - Merge branch 'fix_225' into 'master' - Deal with RichTIFFIPTC tag written with LONG type (fixes #225) - - Closes #225 - - See merge request libtiff/libtiff!374 - -2022-08-09 Even Rouault - - Merge branch 'Writing_IFD8_to_ClassicTIFF_bugfix' into 'master' - Correcting defects reported by Coverity Scan for MR !369 - - See merge request libtiff/libtiff!375 - -2022-08-09 Su Laus - - Correcting defects reported by Coverity Scan for MR !369. - -2022-08-09 Even Rouault - - Merge branch 'fix_442_Writing_IFD8_to_ClassicTIFF' into 'master' - TIFFSetValue(): Writing IFD8 & LONG8 tags to ClassicTIFF corrected (fixes #442) - - Closes #442 - - See merge request libtiff/libtiff!369 - -2022-08-09 Su Laus - - TIFFSetValue(): Writing IFD8 & LONG8 tags to ClassicTIFF corrected (fixes #442) - -2022-08-09 Even Rouault - - Deal with RichTIFFIPTC tag written with LONG type (fixes #225) - -2022-08-07 Roger Leigh - - Merge branch 'manpage-functions-added' into 'master' - doc: Missing public functions added to TIFF documentation in Sphinx - - See merge request libtiff/libtiff!372 - -2022-08-07 Su Laus - - doc: Missing public functions added to TIFF documentation in Sphinx. - -2022-07-29 Even Rouault - - Merge branch 'tifjpeg_version_check' into 'master' - tif_jpeg.c: allow to pass -DEXPECTED_JPEG_LIB_VERSION=number to do optional... - - See merge request libtiff/libtiff!373 - -2022-07-29 Even Rouault - - tif_jpeg.c: allow to pass -DEXPECTED_JPEG_LIB_VERSION=number to do optional compile-time version check - -2022-07-21 Even Rouault - - Merge branch 'TIFFReadFromUserBuffer_fix' into 'master' - TIFFReadFromUserBuffer(): fix clearing of TIFF_CODERSETUP flag that could... - - See merge request libtiff/libtiff!371 - -2022-07-21 Even Rouault - - TIFFReadFromUserBuffer(): fix clearing of TIFF_CODERSETUP flag that could cause issues with reading JPEG compressed files - -2022-07-21 Roger Leigh - - Merge branch 'vs2022-fixes' into 'master' - cmake: Correct duplicate definition of _CRT_SECURE_NO_WARNINGS - - Closes #443 - - See merge request libtiff/libtiff!370 - -2022-07-13 Roger Leigh - - cmake: Correct duplicate definition of _CRT_SECURE_NO_WARNINGS. - -2022-07-13 Even Rouault - - Merge branch 'vs2022-fixes' into 'master' - cmake: Fixes for Visual Studio 2022 - - See merge request libtiff/libtiff!368 - -2022-07-13 Roger Leigh - - cmake: Fixes for Visual Studio 2022. - -2022-07-03 Roger Leigh - - Merge branch 'elf-symbol-export' into 'master' - Explicit export of versioned ELF symbols - - Closes #437 - - See merge request libtiff/libtiff!361 - -2022-07-03 Even Rouault - - Merge branch 'fix_433' into 'master' - _TIFFCheckFieldIsValidForCodec(): return FALSE when passed a codec-specific... - - Closes #433 - - See merge request libtiff/libtiff!363 - -2022-07-01 Su_Laus - - CLIPPATH tags defined twice but differently and also wrongly. - In tif_dirinfo.c the tags for clippath are wrongly defined and the tag TIFFTAG_XCLIPPATHUNITS is even different twice. Therefore, those tags cannot be written / read correctly and may even lead to buffer overflow. - E.g.: In the case of TIFFSetField(YCLIPPATHUNITS), a 1 byte storage space is allocated because of TIFF_SETGET_UNDEFINED, in which an int32_t value should be stored because of TIFF_SLONG type definition. Then, an int32_t value is read from that 1 byte storage location. - - The current definition is: - - { TIFFTAG_CLIPPATH, -1, -3, TIFF_BYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL }, - { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL }, - { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SBYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL }, - { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL }, - - Whereas the correct definition according to TIFF Specification Supplement 1 (https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf) should be: - - { TIFFTAG_CLIPPATH, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL }, - { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL }, - { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL }, - - Also the set_get_field of the following tag should be corrected from - - { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL }, - to - { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL }, - - However, if those tags schould not be handled by LibTiff because they are deamed as abandoned or unwanted tags, those tags need to be defined with FIELD_IGNORE instead of FIELD_CUSTOM and keeping set_field_type = TIFF_SETGET_UNDEFINED - -2022-07-01 Su_Laus - - In tif_dirinfo.c the definition for TIFFTAG_COMPRESSION has different settings of field_readcount=TIFF_VARIABLE (-1) and field_writecount=1. The tag is defined with Count=1, thus field_readcount is wrong and should also be 1. Although TIFFTAG_BITSPERSAMPLE is defined with Count:N=SamplesPerPixel, only ONE uint16_t value is passed with TIFFSetField() and TIFFGetField(). However, an array with N=SamplesPerPixel equal values is written into the TIFF file. Shouldn't field_readcount = field_writecount = 1 then? The behaviour of TiffLib does not change, because the handling is coded directly. - -2022-06-27 Even Rouault - - _TIFFCheckFieldIsValidForCodec(): return FALSE when passed a codec-specific tag and the codec is not configured (fixes #433) - This avoids crashes when querying such tags - -2022-06-27 Even Rouault - - Merge branch '16bit_cielab' into 'master' - add basic 16bit-cielab support - - See merge request libtiff/libtiff!336 - -2022-06-27 Caolán McNamara - - Add basic 16bit-cielab support. - just a copy of putcontig8bitCIELab that reads 16bit vals but divide l by - 257, a and b by 256 before passing to TIFFCIELabToXYZ - - motivation: https://bugs.documentfoundation.org/show_bug.cgi?id=131199 - the "clavijo16bitlab.tiff" example where tiffinfo says: - ``` - Image Width: 2601 Image Length: 3503 - Resolution: 96, 96 pixels/inch - Bits/Sample: 16 - Compression Scheme: AdobeDeflate - Photometric Interpretation: CIE L*a*b* - Orientation: row 0 top, col 0 lhs - Samples/Pixel: 3 - Rows/Strip: 1 - Planar Configuration: single image plane - DateTime: 2020:03:07 10:20:42 - ``` - -2022-06-24 Roger Leigh - - Merge branch 'manpage-fixes' into 'master' - Sphinx documentation fixes - - See merge request libtiff/libtiff!362 - -2022-06-24 Roger Leigh - - doc: Correct types and cross-references. - - doc: Correct manual page path. - - build: Make rational2double static only for automake. - This copies the same logic as used by CMake. - - build: Update autoconf version to 4.5.0 and soname to 6.0.0. - - build: Update autoconf ld-version-script default. - - libtiff: Correct version script for changes since v4.4.0. - - libtiff: Update version script documentation. - - libtiff: Add symbol versioning of all exported symbols. - -2022-06-24 Even Rouault - - Merge branch 'webp_mem_improvements' into 'master' - WEBP codec: avoid temporary buffer and memcpy() on whole tile/strip decoding - - See merge request libtiff/libtiff!360 - -2022-06-24 Roger Leigh - - build: Enable symbol versioning by default. - -2022-06-24 Roger Leigh - - Merge branch 'sphinx-manpages' into 'master' - doc: Add Sphinx conversion of all manpages - - Closes #361 - - See merge request libtiff/libtiff!356 - -2022-06-24 Roger Leigh - - Merge branch 'remove-wince' into 'master' - Remove obsolete WinCE source file - - See merge request libtiff/libtiff!357 - -2022-06-23 Even Rouault - - WEBP codec: avoid temporary buffer and memcpy() on whole tile/strip decoding - -2022-06-22 Even Rouault - - Merge branch 'horAcc8_fix' into 'master' - tif_predict.c: make horAcc8() work with icc (ICC) 2021.6.0 20220226 -O2 - - See merge request libtiff/libtiff!359 - -2022-06-22 Even Rouault - - tif_predict.c: make horAcc8() work with icc (ICC) 2021.6.0 20220226 -O2. - For a reason I don't understand, recent ICC generates wrong code in -O2 - mode for the stride = 3 and 4 cases. The modified code is more - straightfoward, so go for it. - -2022-06-19 Roger Leigh - - Merge branch 'ci-restore-old' into 'master' - ci: Restore testing with Ubuntu 20.04 - - See merge request libtiff/libtiff!358 - -2022-06-19 Roger Leigh - - ci: Restore testing with Ubuntu 20.04. - - Remove obsolete WinCE source file. - - doc: Add missing punctuation. - - doc: Remove semicolon from c:function definition. - - doc: Remove remaining HTML entities. - - doc: Improve the build page. - -2022-06-18 Roger Leigh - - doc: Add Sphinx conversion of all manpages. - -2022-06-18 Roger Leigh - - Merge branch 'dist-html' into 'master' - build: Distribute and install HTML documentation - - See merge request libtiff/libtiff!352 - -2022-06-13 Even Rouault - - Merge branch 'pkgconfig' into 'master' - Adding Requires.private generation - - See merge request libtiff/libtiff!355 - -2022-06-13 Yishen Miao - - Adding Requires.private generation. - Adds Requires.private generation so that pkg-config can correctly find - the dependencies of libtiff. - -2022-06-11 Roger Leigh - - Merge branch 'ci-dist' into 'master' - ci: Archive distribution tar and zip files - - See merge request libtiff/libtiff!354 - -2022-06-11 Roger Leigh - - ci: Archive distribution tar and zip files. - -2022-06-11 Even Rouault - - Merge branch 'export_TIFFClampDoubleToUInt32' into 'master' - libtiff.def: export _TIFFClampDoubleToUInt32 - - See merge request libtiff/libtiff!353 - -2022-06-11 Even Rouault - - libtiff.def: export _TIFFClampDoubleToUInt32. - -2022-06-11 Even Rouault - - Merge branch 'issue-415+427+428' into 'master' - fix the FPE in tiffcrop (#415, #427, and #428) - - Closes #428, #427 et #415 - - See merge request libtiff/libtiff!346 - -2022-06-11 4ugustus - - fix the FPE in tiffcrop (#415, #427, and #428) - -2022-06-11 Roger Leigh - - build: Distribute and install HTML documentation. - -2022-06-10 Even Rouault - - Merge branch 'tif_jpeg_warning_fix' into 'master' - tif_jpeg.c: fix error message - - See merge request libtiff/libtiff!351 - -2022-06-10 Even Rouault - - tif_jpeg.c: fix error message. - -2022-06-10 Roger Leigh - - Merge branch 'android_libm' into 'master' - Fix dependency on libm on Android - - See merge request libtiff/libtiff!350 - -2022-06-09 Matthias Kuhn - - Always link to libm if available. - -2022-06-05 Roger Leigh - - Merge branch 'vasyl5-master-patch-97651' into 'master' - libtoolize: command not found on macOS. - - See merge request libtiff/libtiff!289 - -2022-06-05 Roger Leigh - - Merge branch 'rst-docs' into 'master' - Convert HTML documentation to Sphinx RST - - See merge request libtiff/libtiff!349 - -2022-06-05 Roger Leigh - - Merge remote-tracking branch 'origin/master' into rst-docs. - -2022-06-05 Roger Leigh - - Merge branch 'cmake-xc-faxtable' into 'master' - cmake: Do not build faxtable target when cross-compiling - - See merge request libtiff/libtiff!342 - -2022-06-05 Roger Leigh - - Merge branch 'cmake-disable-options' into 'master' - Add options for disabling tools, tests, contrib and docs - - See merge request libtiff/libtiff!343 - -2022-06-05 Roger Leigh - - Merge branch 'cmake-msvc-options' into 'master' - cmake: Add MSVC options when building all libraries and executables - - See merge request libtiff/libtiff!344 - -2022-06-05 Roger Leigh - - Merge branch 'cmake-win32-libtiffxx-static' into 'master' - cmake: libtiffxx is static on win32 - - See merge request libtiff/libtiff!338 - -2022-06-05 Roger Leigh - - Merge branch 'licence-file' into 'master' - Rename COPYRIGHT to LICENSE.md - - See merge request libtiff/libtiff!345 - -2022-06-05 Roger Leigh - - Rename COPYRIGHT to LICENSE.md. - - doc: Fix make distcheck. - - doc: Update automake configuration. - - doc: Do not pass srcdir and builddir to sphinx-build. - - doc: Additional top-level tidying. - - doc: Tidy top-level index. - - doc: Move bugs to project. - - doc: Move misc to project. - - doc: Move all BigTIFF documentation into specification directory. - * Remove the BigTIFF proposal since this has long been completed - * Update the BigTIFF PR to note completion of the work and replace - present with past tense. - - doc: Split release history. - This permits the newer releases to be included in the top-level - toctree without polluting it with dozens of old releases. - - doc: Correct accents. - - doc: BigTIFF design markup improvements. - - Add doc/_static. - - doc: Move TIFF specification and design notes into subdirectory. - - doc: Move releases into subdirectory. - - doc: Mark up TIFF tech note 2. - - doc: Use sphinxdox theme. - The sphix_rtd_theme formats complex tables badly. - - doc: Clean up HTML tags. - -2022-06-04 Roger Leigh - - ci: Install Sphinx manual for use by GitLab pages. - - doc: Use sphinx_rtd_theme. - - Convert HTML documentation to Sphinx RST. - * Add CMake build logic - * Add Autotools build logic - * Move from html/ to doc/ - * Manual pages are still generated HTML for the time being - - git: Ignore common IDE build files. - -2022-06-04 Roger Leigh - - Merge branch 'ci-ubuntu-22.04' into 'master' - ci: Update to use Ubuntu 22.04 CI images - - Closes #429 - - See merge request libtiff/libtiff!348 - -2022-06-04 Roger Leigh - - Merge branch 'opengl-option' into 'master' - cmake: Add tiff-opengl option - - See merge request libtiff/libtiff!340 - -2022-06-04 Roger Leigh - - tiffdump: Avoid overflow warning when reading. - - ci: Update to use Ubuntu 22.04 CI images. - -2022-06-04 Even Rouault - - Merge branch 'master' into 'master' - Include stdlib.h in tif_lzw.c. - - See merge request libtiff/libtiff!347 - -2022-06-04 Brian Ledger - - Merge branch 'master' of https://gitlab.com/libtiff/libtiff. - -2022-06-04 Brian Ledger - - Include stdlib.h in tif_lzw.c. - In `tif_lzw.c`, a call is made to `_byteswap_uint64`. This is declared in `stdlib.h`. `stdlib.h` is not included in `tib_lzw.c`, so a name error may occur. - - This change adds `#include stdlib.h` to `tif_lzw.c`, to prevent a name error from occuring when `stdlib.h` is not included. - -2022-05-29 Roger Leigh - - Add options for disabling tools, tests, contrib and docs. - - cmake: Add MSVC options when building all libraries and executables. - - cmake: Do not build faxtable target when cross-compiling. - - cmake: Use add_compile_definitions and add_compile_options. - It seems that some CMake versions can't export targets using PRIVATE - linking, even though the private target is never used. - - Merge remote-tracking branch 'origin/master' into cmake-msvc-options. - - Merge remote-tracking branch 'origin/master' into cmake-win32-libtiffxx-static - -2022-05-29 Roger Leigh - - Merge branch 'ci-x64' into 'master' - ci: Remove arm64 temporarily - - See merge request libtiff/libtiff!341 - -2022-05-29 Roger Leigh - - ci: Remove arm64 temporarily. - - autoconf: Add --disable-opengl option. - - cmake: Add tiff-opengl option. - - cmake: Add MSVC options when building all libraries and executables. - - cmake: libtiffxx is static on win32. - -2022-05-22 Even Rouault - - html/Makefile.am: add v4.4.0.html to docfiles. - -2022-05-20 Even Rouault - - Update HOWTO-RELEASE with .tar.xz. - - Prepare for release 4.4.0. - -2022-05-16 Even Rouault - - libtiff v4.4.0 released - -2022-05-16 Even Rouault - - Merge branch 'pkgconf_abs_path' into 'master' - Handle absolute paths in pkg-config file - - See merge request libtiff/libtiff!333 - -2022-05-16 MiloÅ¡ KomarÄević - - Handle absolute paths in pkg-config file. - -2022-05-15 Even Rouault - - Merge branch 'fix-tests-with-ro-source-dir' into 'master' - cmake: allow running the tests with a read-only source directory - - See merge request libtiff/libtiff!332 - -2022-05-15 Alex Richardson - - cmake: allow running the tests with a read-only source directory. - Prior to this commit CTest would invoke all simple_tests tests with the - current working directory set to the source directory. However, some of - the tests (e.g. rewrite) will output files to the current working - directory and will therefore fail when run with a read-only source - directory. This can happen e.g. when testing a cross-compiled version of - libtiff where the sources are mounted read-only in the virtual machine. - - Simply changing the working directory to CMAKE_CURRENT_BINARY_DIR allows - all but raw_decode to pass. The raw_decode test looks for files in the - source directory, and uses the `srcdir` environment variable to find, so - we also have to add a set_tests_properties() call to specify that env var. - -2022-05-14 Even Rouault - - Merge branch 'tiffcrop_pipeline_error' into 'master' - tiffcrop: Fixes complain of pipeline "cmake-ninja-arm64" about abs() on... - - See merge request libtiff/libtiff!331 - -2022-05-14 Su Laus - - tiffcrop: Fixes complain of pipeline "cmake-ninja-arm64" about abs() on... - -2022-05-14 Even Rouault - - Merge branch 'TIFFField_SetGetSize_CountSize' into 'master' - Public functions TIFFFieldSetGetSize() and TIFFieldSetGetCountSize() added. - - See merge request libtiff/libtiff!284 - -2022-05-14 Su Laus - - Public functions TIFFFieldSetGetSize() and TIFFieldSetGetCountSize() added. - -2022-05-13 Even Rouault - - Merge branch 'jondo-master-patch-87274' into 'master' - Replace add_compile_definitions for CMake versions before 3.12 (#238) - - See merge request libtiff/libtiff!330 - -2022-05-13 Robert Pollak - - Replace add_compile_definitions for CMake versions before 3.12 (#238) - -2022-05-13 Even Rouault - - Merge branch 'master' into 'master' - Remove incorrect assert. - - See merge request libtiff/libtiff!329 - -2022-05-13 Ben Laurie - - Remove incorrect assert. - -2022-05-10 Even Rouault - - Merge branch 'Fix_Issue#330' into 'master' - tiffcrop: Fix issue #330 and some more from 320 to 349 - - Closes #330 - - See merge request libtiff/libtiff!298 - -2022-05-10 Su Laus - - tiffcrop: Fix issue #330 and some more from 320 to 349. - -2022-05-10 Even Rouault - - test_signed_tags.c: fix CID 1504376. - -2022-05-10 Even Rouault - - Merge branch 'fix_#29_tiffcp_orientationTag' into 'master' - tiffcp: Fix incomprehensible setting of orientation tag (fixes #29) - - Closes #29 - - See merge request libtiff/libtiff!327 - -2022-05-10 Even Rouault - - Merge branch 'palette-8bit' into 'master' - tiff2pdf: handle 8-bit palette colormap - - See merge request libtiff/libtiff!328 - -2022-05-09 Jay Berkenbilt - - tiff2pdf: handle 8-bit palette colormap. - If all the colors in a palette are in the range [0, 255], treat the - palette as an 8-bit colormap. This workaround already exists elsewhere - in the software including in tiff2ps. - -2022-05-08 Even Rouault - - Merge branch 'fix_#40_ReadSignedTags' into 'master' - Reading of signed tags added (fixes #40) - - Closes #40 - - See merge request libtiff/libtiff!326 - -2022-05-08 Su Laus - - Reading of signed tags added (fixes #40) - -2022-05-08 Even Rouault - - Fix typos in comments. - -2022-05-08 Even Rouault - - Merge branch 'fix_400' into 'master' - tiffcp: avoid buffer overflow in "mode" string (fixes #400) - - Closes #400 - - See merge request libtiff/libtiff!323 - -2022-05-08 Even Rouault - - Merge branch 'CheckForBigTiff' into 'master' - TIFFIsBigTiff() function added. - - See merge request libtiff/libtiff!325 - -2022-05-08 Su Laus - - TIFFIsBigTiff() function added. - -2022-05-01 Su_Laus - - tiffcp: Fix incomprehensible setting of orientation tag (fixes #29) - -2022-04-23 Even Rouault - - Merge branch 'fix_#8_FreeAnonTag' into 'master' - extra flag for anonymous (unknown) tags (fixes #8) - - Closes #400 et #8 - - See merge request libtiff/libtiff!324 - -2022-04-22 Even Rouault - - tif_lzw.c: fix potential out-of-bounds error when trying to read in the same tile/strip after an error has occured (fixes #410) - -2022-04-06 Su_Laus - - extra flag for anonymous (unknown) tags (fixes #8) - -2022-04-02 Su_Laus - - tiffcp: avoid buffer overflow in "mode" string (fixes #400) - -2022-03-21 Even Rouault - - avoid hang in TIFFRewriteDirectory() if a classic file > 4 GB is attempted to be created - Fixes https://github.com/OSGeo/gdal/issues/5479 - -2022-03-19 Even Rouault - - Merge branch 'Correct_tag_auto-registration_description' into 'master' - Correct reading description for anonymous tag auto-registration in addingtags.html (closes 353) - - Closes #353 - - See merge request libtiff/libtiff!320 - -2022-03-19 Su Laus - - Correct reading description for anonymous tag auto-registration in addingtags.html (closes 353) - -2022-03-18 Even Rouault - - tif_lzw.c: avoid harmless unsigned-integer-overflow (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45741) - -2022-03-17 Even Rouault - - Merge branch 'fix_396' into 'master' - tiffcp: do not try to fetch compressor-specific tags when not appropriate (fixes #396) - - Closes #396 - - See merge request libtiff/libtiff!316 - -2022-03-17 Even Rouault - - Merge branch 'Fix_cmake_warnings' into 'master' - Fix some CMake warnings - - See merge request libtiff/libtiff!319 - -2022-03-17 Su Laus - - Fix some CMake warnings. - -2022-03-17 Even Rouault - - Merge branch 'lzw_decode_improvements' into 'master' - LZWDecode(): major speed improvements - - See merge request libtiff/libtiff!318 - -2022-03-16 Even Rouault - - LZWDecode(): major speed improvements. - This mostly comes from dealing specifically with codes that expand to - 2, 3 and 4 bytes or more to avoid branches, and dealing with longer - repeated sequences (e.g. lots of bytes to 0). - - With the following bench.c, execution time is 32% faster on a 8000x8000 - 4 bands uint16 predictor=2 image that has a 1.6x compression ratio. with - gcc 9.4.0, on x86_64 - - bench.c: - ``` - #include "tiffio.h" - #include - #include - - int main(int argc, char* argv[]) - { - if( argc != 2 ) - { - fprintf(stderr, "Usage: ./bench my.tif\n"); - exit(1); - } - TIFF* tif = TIFFOpen(argv[1], "r"); - if( tif == NULL ) - { - fprintf(stderr, "Cannot open %s\n", argv[1]); - exit(1); - } - if( !TIFFIsTiled(tif) ) - { - fprintf(stderr, "Only tiled image supported\n"); - exit(1); - } - int tilesize = (int)TIFFTileSize(tif); - char* c = malloc(tilesize); - if( c == NULL ) - { - fprintf(stderr, "Out of memory\n"); - exit(1); - } - const uint32_t numtiles = TIFFNumberOfTiles(tif); - //int numloops = 4 * (int)(1e9 / ((double)tilesize * numtiles)); - //printf("Number of loops: %d\n", numloops); - int numloops = 1; - for(int i =0; i< numloops; i++) - { - for(uint32_t tileindex = 0; tileindex < numtiles; tileindex++ ) - { - TIFFReadEncodedTile(tif, tileindex, c, tilesize); - } - } - free(c); - TIFFClose(tif); - return 0; - } - ``` - -2022-03-16 Even Rouault - - LZWDecode(): modest speed improvement: fetch input data by chunks of the largest natural integer of the architecture - -2022-03-14 Even Rouault - - Merge branch 'kmilos-master-patch-45885' into 'master' - Correct fix for the pkgconf file relative paths - - See merge request libtiff/libtiff!317 - -2022-03-10 Even Rouault - - tif_lzw.c: make LZW_CHECKEOS non-optional. - - tiffsplit.c: fix compiler warning on 32-bit. - -2022-03-10 MiloÅ¡ KomarÄević - - Correct fix for the pkgconf file relative paths. - -2022-03-10 Even Rouault - - Merge branch 'issue-278' into 'master' - fix heap buffer overflow in tiffcp (#278) - - Closes #278 - - See merge request libtiff/libtiff!311 - -2022-03-10 4ugustus - - fix heap buffer overflow in tiffcp (#278) - -2022-03-09 Even Rouault - - tiffcp: do not try to fetch compressor-specific tags when not appropriate (fixes #396) - -2022-03-09 Even Rouault - - Merge branch 'i_am_a_unsympathetic_person' into 'master' - index.html: make it clear that I'm a unsympathetic person - - See merge request libtiff/libtiff!315 - -2022-03-09 Even Rouault - - index.html: make it clear that I'm a unsympathetic person. - -2022-03-08 Even Rouault - - Merge branch 'Fix_Issue#395' into 'master' - tiffcrop: fix issue #395: generation of strange section images. - - Closes #395 - - See merge request libtiff/libtiff!312 - -2022-03-08 Su Laus - - tiffcrop: fix issue #395: generation of strange section images. - -2022-03-08 Even Rouault - - Merge branch 'Fix_Issue#380' into 'master' - tiffcrop: fix issue #380 and #382 heap buffer overflow in extractImageSection - - Closes #382 et #380 - - See merge request libtiff/libtiff!307 - -2022-03-08 Su Laus - - tiffcrop: fix issue #380 and #382 heap buffer overflow in extractImageSection - -2022-03-08 Even Rouault - - Merge branch 'issue-392' into 'master' - add checks for return value of limitMalloc (#392) - - Closes #392 - - See merge request libtiff/libtiff!314 - -2022-03-08 Even Rouault - - Merge branch 'issue-393' into 'master' - fix the FPE in tiffcrop (#393) - - Closes #393 - - See merge request libtiff/libtiff!310 - -2022-03-08 4ugustus - - fix the FPE in tiffcrop (#393) - -2022-03-08 Even Rouault - - Merge branch 'kmilos-master-patch-56785' into 'master' - Fix pkgconf file relative paths - - Closes #394 - - See merge request libtiff/libtiff!309 - -2022-03-07 Augustus - - add checks for return value of limitMalloc (#392) - -2022-03-02 MiloÅ¡ KomarÄević - - Fix pkgconf file relative paths. - -2022-02-25 Even Rouault - - Merge branch 'fix_385' into 'master' - tif_jbig.c: fix crash when reading a file with multiple IFD in memory-mapped... - - Closes #385 - - See merge request libtiff/libtiff!306 - -2022-02-24 Even Rouault - - tif_jbig.c: fix crash when reading a file with multiple IFD in memory-mapped mode and when bit reversal is needed (fixes #385) - -2022-02-24 Even Rouault - - Merge branch 'string_size_limit' into 'master' - _TIFFVSetField(): when passing a string without explicit length, check that... - - See merge request libtiff/libtiff!304 - -2022-02-24 Even Rouault - - Merge branch 'TIFFClientOpen_cleanup' into 'master' - TIFFClientOpen(): remove useless initializations of tif_rawcc and tif_flags... - - See merge request libtiff/libtiff!303 - -2022-02-20 Even Rouault - - Remove extra word in comment. - - TIFFPrintDirectory(): avoid potential multi-threading issue when reading the DotRange tag - The severity of the issue would be low (mix of values displayed) and the - time window where that would occur would be short. - - Constify signature of _TIFFsetXXXXArray() functions, and remove unused _TIFFsetString() - - _TIFFVSetField(): when passing a string without explicit length, check that the length doesn't except the 1 << 31 maximum bytes we support - -2022-02-19 Even Rouault - - tiffsplit.c: fix use after free introduced in master per commit 8ed97f401552a2b4300d3c489b03dcada86a21fd (related to #290) - -2022-02-19 Even Rouault - - Merge branch 'Fix_Issue#284' into 'master' - tiff2ps: In limitMalloc() check for negative size (fixes #284) - - Closes #284 - - See merge request libtiff/libtiff!300 - -2022-02-19 Su Laus - - tiff2ps: In limitMalloc() check for negative size (fixes #284) - -2022-02-19 Even Rouault - - Merge branch 'fix_288' into 'master' - tiffinfo: limit more memory allocations using -M switch (fixes #288) - - Closes #288 - - See merge request libtiff/libtiff!299 - -2022-02-19 Even Rouault - - Merge branch 'Fix_Issue#290' into 'master' - tiffsplit: limitMalloc() and getopt() introduced and more error messages. (fixes #290) - - Closes #290 - - See merge request libtiff/libtiff!301 - -2022-02-19 Su Laus - - tiffsplit: limitMalloc() and getopt() introduced and more error messages. (fixes #290) - -2022-02-19 Even Rouault - - Merge branch 'Fix_Issue#273_#275' into 'master' - tiffcrop: buffsize check formula in loadImage() amended (fixes #273,#275) - - Closes #275 et #273 - - See merge request libtiff/libtiff!302 - -2022-02-19 Su Laus - - tiffcrop: buffsize check formula in loadImage() amended (fixes #273,#275) - -2022-02-19 Even Rouault - - TIFFClientOpen(): remove useless initializations of tif_rawcc and tif_flags after TIFFReadDirectory() - Those initializations date back to the initial commit of libtiff, but I - strongly suspect there are no longer needed those days. - Setting tif_rawcc to (tmsize_t)-1 is weird. AFAICS, nowhere else in the library - -1 is used as a special markeri for that field. Immediately after TIFFReadDirectory() - returns it is set to 0, and this is the value used in tif_read.c/tif_write.c to - reset it. - And setting the TIFF_BUFFERSETUP bit of tif_flags is even more - suspicious as the only place where it is set otherwise is in - TIFFWriteBufferSetup(). I suspect this bogus setting of the flag was the - reason for commit dbf2339a1 where BUFFERCHECK() in addition to checking - the bit also checked the tif_rawdata against nullptr. - - If setting those 2 fields was needed, it would mean that TIFFClientOpen() with the - 'h' hint to disable automatic TIFFReadDirectory() would be broken, - because someone issuing a manual TIFFReadDirectory() couldn't set them, - as being private members. - - The libtiff test suite is happy with that change, and the GDAL one too. - -2022-02-19 Even Rouault - - TIFFFetchNormalTag(): speed optimization when reading a (very large) nul-terminated ASCII tag - - TIFFWriteDirectoryTagData(): turn assertion on data length into a runtime check - For example, the assertion could actually be triggered when writing an - ASCII tag with more than 1 << 31 bytes. - -2022-02-17 Even Rouault - - TIFFFetchNormalTag(): avoid calling memcpy() with a null source pointer and size of zero (fixes #383) - -2022-02-15 Roger Leigh - - Merge branch 'tl/fix-cpack' into 'master' - Fix packaging with CPack - - See merge request libtiff/libtiff!292 - -2022-02-11 Even Rouault - - tiffinfo: limit more memory allocations using -M switch (fixes #288) - - tif_dirwrite.c: take into account COMPRESSION_JXL. - -2022-02-11 Even Rouault - - Merge branch 'predictor_2_64bit' into 'master' - Predictor 2 (horizontal differenciation): support 64-bit - - See merge request libtiff/libtiff!296 - -2022-02-10 Even Rouault - - Merge branch 'Fix_Issue#365' into 'master' - tiff2pdf: Fixes issues #365, #258 and #257 related to initializing 't2p->pdf_compressionquality'. - - Closes #257, #258 et #365 - - See merge request libtiff/libtiff!297 - -2022-02-10 Su Laus - - tiff2pdf: Fixes issues #365, #258 and #257 related to initializing 't2p->pdf_compressionquality'. - -2022-02-09 Even Rouault - - Predictor 2 (horizontal differenciation): support 64-bit. - There's no reason not to support 64-bit. The TIFF 6 specification - doesn't say anything about that (and even mention 4-bit, which we don't - support) - -2022-02-09 Even Rouault - - Merge branch 'Fix_Issue#352' into 'master' - tiffcrop.c: Fix issue #352 heap-buffer-overflow by correcting uint32_t underflow. - - Closes #352 - - See merge request libtiff/libtiff!294 - -2022-02-09 Su Laus - - tiffcrop.c: Fix issue #352 heap-buffer-overflow by correcting uint32_t underflow. - -2022-02-08 Even Rouault - - Merge branch 'custom_dir_EXIF_Coverity_fixes' into 'master' - Fix Coverity Scan report issues for custom_dir_EXIF_231.c and test_directory.c - - See merge request libtiff/libtiff!295 - -2022-02-08 Su Laus - - Fix Coverity Scan report issues for custom_dir_EXIF_231.c and test_directory.c - -2022-02-06 Roger Leigh - - Merge branch 'cmake-test' into 'master' - Correct CMake testing - - Closes #317 - - See merge request libtiff/libtiff!291 - -2022-02-06 Even Rouault - - LogLuvEncode32(): avoid undefined behaviour of left shift on a signed integer - - TIFFFetchStripThing(): avoid calling memcpy() with a null source pointer and size of zero (fixes #362) - -2022-02-05 Even Rouault - - TIFFReadDirectory(): avoid calling memcpy() with a null source pointer and size of zero (fixes #362) - -2022-01-29 Even Rouault - - Merge branch 'Jamaika1-master-patch-68264' into 'master' - Added stdlib.h - - See merge request libtiff/libtiff!293 - -2022-01-29 Jamaika - - tif_win32.c: include stdlib.h. - -2022-01-28 Timothy Lyanguzov - - Fix packaging with CPack. - Replace all CMAKE_INSTALL_FULL_

with CMAKE_INSTALL_ to allow CPack setting CMAKE_INSTALL_PREFIX - -2022-01-25 Even Rouault - - Merge branch 'master' into 'master' - Fix the global-buffer-overflow in tiffset - - See merge request libtiff/libtiff!287 - -2022-01-25 4ugustus - - tiffset: fix global-buffer-overflow for ASCII tags where count is required (fixes #355) - -2022-01-23 Roger Leigh - - Merge branch 'autogen' into 'master' - Fix autogen.sh permissions issues during mv - - See merge request libtiff/libtiff!290 - -2022-01-23 Roger Leigh - - Correct CMake testing. - * Use functions rather than macros to avoid problems with variables in - conditions (since macro arguments are not variables) - * Conditionally add to file lists and test program lists based upon the - configuration options (e.g. JPEG and old-JPEG availability) - * Sync tests, files and option usage with current automake usage - -2022-01-19 Will Cohen - - autogen.sh: mv -f for config.sub and config.guess. - -2022-01-12 Even Rouault - - TIFFYCbCrToRGBInit(): avoid Integer-overflow in gdal_TIFFYCbCrToRGBInit. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=43559 - -2022-01-10 Even Rouault - - Merge branch 'fix_TIFFFillStrip_wrong_check' into 'master' - Fix sanity check in TIFFFillStrip()/TIFFFillStrile() - - See merge request libtiff/libtiff!288 - -2022-01-10 Even Rouault - - TIFFFillStrip()/TIFFFillStrile(): remove useless test. - - Fix sanity check in TIFFFillStrip()/TIFFFillStrile() - A sanity check comparing the compressed vs uncompressed file that was - originally written 'correctly' but relied on undefined behaviour was - changed in 1b5e3b6a23827c33acf19ad50ce5ce78f12b3773 in an incorrect way. - Fix that. Credits to @burn for spotting this in - https://gitlab.com/libtiff/libtiff/-/issues/343#note_806089714 - -2021-12-29 Even Rouault - - Merge branch 'Fix_FieldName_NULL' into 'master' - Fix Issue #354 Segmentation Fault due to field_name=NULL - - See merge request libtiff/libtiff!285 - -2021-12-29 Even Rouault - - Merge branch 'mingw-static' into 'master' - build: Fix static library imports in mingw - - See merge request libtiff/libtiff!286 - -2021-12-29 Biswapriyo Nath - - build: Fix static library imports in mingw. - This defines LERC_STATIC while creating libtiff static library - in Win32 platform in presence of lerc library. Otherwise, the - static library import lerc APIs with dllimport attribute and - thus linked with shared lerc library. - -2021-12-28 Su_Laus - - Fix Issue #354 Segmentation Fault due to field_name=NULL. - -2021-12-17 Even Rouault - - Merge branch 'fix_342' into 'master' - TIFFGetField(TIFFTAG_STRIPBYTECOUNTS/TIFFTAG_STRIPOFFSETS): return error if... - - Closes #342 - - See merge request libtiff/libtiff!283 - -2021-12-16 Even Rouault - - TIFFGetField(TIFFTAG_STRIPBYTECOUNTS/TIFFTAG_STRIPOFFSETS): return error if returned pointer is NULL (fixes #342) - - tiff2pdf: validate TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc) return (fixes #342) - -2021-12-16 Even Rouault - - Merge branch 'master' into 'master' - fix raw2tiff floating point exception(fixes #338) - - Closes #338 - - See merge request libtiff/libtiff!282 - -2021-12-16 t.feng - - raw2tiff: check that band number if not zero to avoid floating point exception(fixes #338) - -2021-12-14 Even Rouault - - Merge branch 'fix_337' into 'master' - OJPEG: avoid assertion when using TIFFReadScanline() (fixes #337) - - Closes #337 - - See merge request libtiff/libtiff!280 - -2021-12-13 Even Rouault - - OJPEG: avoid assertion when using TIFFReadScanline() (fixes #337) - Note: my analyis of the issue would be that the use of the scanline API - is currently propably broken with OJPEG. - -2021-12-10 Even Rouault - - JPEG 12bit: make it easier for GDAL's RENAME_INTERNAL_LIBTIFF_SYMBOLS mode - -2021-12-09 Even Rouault - - tif_lzw.c: other warning fixes. - - tif_lzw.c: fix warnings of previous commit. - -2021-12-09 Even Rouault - - Merge branch 'lzw_2gb_windows' into 'master' - LZW codec: fix support for strips/tiles > 2 GB on Windows - - See merge request libtiff/libtiff!279 - -2021-12-08 Even Rouault - - LZW codec: fix support for strips/tiles > 2 GB on Windows. - -2021-12-07 Even Rouault - - Merge branch 'fix_287' into 'master' - tiffinfo: add a -M switch to define the maximum heap allocation, and default... - - Closes #287 - - See merge request libtiff/libtiff!278 - -2021-12-06 Even Rouault - - Merge branch 'fix_319' into 'master' - TIFFReadDirectory: fix OJPEG hack (fixes #319) - - Closes #319 - - See merge request libtiff/libtiff!277 - -2021-12-06 Even Rouault - - Merge branch 'fix_309' into 'master' - TIFFAppendToStrip(): fix rewrite-in-place logic (fixes #309) - - Closes #309 - - See merge request libtiff/libtiff!276 - -2021-12-05 Even Rouault - - Merge branch 'b1' into 'master' - Fix resource leak on error path - - See merge request libtiff/libtiff!263 - -2021-12-05 bonniegong - - rast2tiff: Fix resource leak on error path. - -2021-12-05 Even Rouault - - Merge branch 'tiffsplit-leak' into 'master' - tiffsplit.c: Fix memleak before exit - - See merge request libtiff/libtiff!270 - -2021-12-05 Even Rouault - - tiffinfo: add a -M switch to define the maximum heap allocation, and default it to 256 MiB (fixes #287) - - tiffinfo: fix read of invalid pointer in TIFFReadRawDataTiled() (fixes #295) - -2021-12-05 Even Rouault - - TIFFReadDirectory: fix OJPEG hack (fixes #319) - to avoid having the size of the strip arrays inconsistent with the - number of strips returned by TIFFNumberOfStrips(), which may cause - out-ouf-bounds array read afterwards. - - One of the OJPEG hack that alters SamplesPerPixel may influence the - number of strips. Hence compute tif_dir.td_nstrips only afterwards. - -2021-12-04 Even Rouault - - TIFFAppendToStrip(): fix rewrite-in-place logic (fixes #309) - Properly reset tif_curoff when writing strips/tiles - -2021-12-03 Even Rouault - - TIFFReInitJPEG_12(): avoid warning about unused variable in -DNDEBUG. - -2021-12-01 Even Rouault - - Merge branch 'fix_316' into 'master' - TIFFReadCustomDirectory(): avoid crash when reading SubjectDistance tag on a non EXIF directory - - Closes #316 - - See merge request libtiff/libtiff!273 - -2021-12-01 Even Rouault - - Merge branch 'VisualStudio_warnings_suppress' into 'master' - Suppress unnecessary warnings in Visual Studio in AppVeyor test. - - See merge request libtiff/libtiff!234 - -2021-11-30 Even Rouault - - TIFFReadCustomDirectory(): avoid crash when reading SubjectDistance tag on a non EXIF directory - Fixes #316 - - The Valgrind trace was - ``` - TIFFReadCustomDirectory: Warning, Unknown field with tag 37382 (0x9206) encountered. - ==3277355== Invalid read of size 1 - ==3277355== at 0x4842B60: memmove (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) - ==3277355== by 0x48BB799: _TIFFmemcpy (tif_unix.c:346) - ==3277355== by 0x485B3CB: _TIFFVSetField (tif_dir.c:647) - ==3277355== by 0x485C125: TIFFVSetField (tif_dir.c:890) - ==3277355== by 0x485BEDC: TIFFSetField (tif_dir.c:834) - ==3277355== by 0x486DA9A: TIFFFetchSubjectDistance (tif_dirread.c:5826) - ==3277355== by 0x4869E35: TIFFReadCustomDirectory (tif_dirread.c:4530) - ==3277355== by 0x4869F0A: TIFFReadGPSDirectory (tif_dirread.c:4564) - ==3277355== by 0x10AA7A: main (tiffinfo.c:171) - ==3277355== Address 0x3fc856aaaaaaaaab is not stack'd, malloc'd or (recently) free'd - ==3277355== - ``` - -2021-11-29 Even Rouault - - Merge branch 'add-null-check' into 'master' - Added missing null check. - - See merge request libtiff/libtiff!274 - -2021-11-28 Dirk Lemstra - - Added missing null check. - -2021-11-26 Even Rouault - - tif_print.c: remove duplicated if() in previous commit. - -2021-11-26 Even Rouault - - Merge branch 'GPS_Print_BugFix' into 'master' - Fix Segmentation fault printing GPS directory if Altitude tag is present (tif_print.c/tiffinfo.c) - - See merge request libtiff/libtiff!272 - -2021-11-26 Su Laus - - Fix Segmentation fault printing GPS directory if Altitude tag is present (tif_print.c/tiffinfo.c) - -2021-11-01 Even Rouault - - Merge branch 'cmake_tiffconf' into 'master' - Fix STRIPCHOP_DEFAULT value in CMake builds - - See merge request libtiff/libtiff!271 - -2021-11-01 Even Rouault - - Fix STRIPCHOP_DEFAULT value in CMake builds. - CMake builds erroneously used value 1 instead of TIFF_STRIPCHOP, which - resulted in strip chopping not being enabled by default. - -2021-10-26 Even Rouault - - tif_jpeg.c: typo fix. - -2021-10-24 Han Han - - tiffsplit.c: Fix memleak before exit. - Details of the memleak: - $ valgrind --leak-check=full tiffsplit id:001763,sync:fuzzer07,src:001641,+cov - - ==2090657== - ==2090657== HEAP SUMMARY: - ==2090657== in use at exit: 13,517 bytes in 17 blocks - ==2090657== total heap usage: 41 allocs, 24 frees, 29,351 bytes allocated - ==2090657== - ==2090657== 2,473 (1,249 direct, 1,224 indirect) bytes in 1 blocks are definitely lost in loss record 10 of 13 - ==2090657== at 0x484086F: malloc (vg_replace_malloc.c:381) - ==2090657== by 0x48BF35C: TIFFClientOpen (tif_open.c:118) - ==2090657== by 0x48CF058: TIFFFdOpen (tif_unix.c:209) - ==2090657== by 0x48CF0C4: TIFFOpen (tif_unix.c:248) - ==2090657== by 0x10954C: main (tiffsplit.c:91) - ==2090657== - ==2090657== 11,044 (1,300 direct, 9,744 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 13 - ==2090657== at 0x484086F: malloc (vg_replace_malloc.c:381) - ==2090657== by 0x48BF35C: TIFFClientOpen (tif_open.c:118) - ==2090657== by 0x48CF058: TIFFFdOpen (tif_unix.c:209) - ==2090657== by 0x48CF0C4: TIFFOpen (tif_unix.c:248) - ==2090657== by 0x1093D9: main (tiffsplit.c:75) - ==2090657== - ==2090657== LEAK SUMMARY: - ==2090657== definitely lost: 2,549 bytes in 2 blocks - ==2090657== indirectly lost: 10,968 bytes in 15 blocks - ==2090657== possibly lost: 0 bytes in 0 blocks - ==2090657== still reachable: 0 bytes in 0 blocks - ==2090657== suppressed: 0 bytes in 0 blocks - ==2090657== - ==2090657== For lists of detected and suppressed errors, rerun with: -s - ==2090657== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0) - -2021-10-20 Even Rouault - - tif_webp.c: add explicit cast to please MSVC verbose warnings. - - tif_webp.c: white space fixing. - -2021-10-04 Even Rouault - - Merge branch 'work/amyspark/psd-blobs' into 'master' - Enable writing Photoshop blobs - - See merge request libtiff/libtiff!269 - -2021-10-04 L. E. Segovia - - Enable writing Photoshop blobs. - -2021-09-29 Even Rouault - - Merge branch 'remove_packbits_hack' into 'master' - PackBitsDecode: remove hack for when char is unsigned. - - See merge request libtiff/libtiff!267 - -2021-09-28 Even Rouault - - PackBitsDecode: remove hack for when char is unsigned. - The function has a hack for platforms where char is unsigned. This is - better replaced by making bp a int8_t* pointer, which is guaranteed to - be signed. - -2021-09-27 Even Rouault - - tiffcrop.c: remove useless 'set but not read' variables. - -2021-09-23 Even Rouault - - Merge branch 'fix_gdal_4538' into 'master' - TIFFAppendToStrip(): fix rewrite-in-place logic - - See merge request libtiff/libtiff!266 - -2021-09-23 Even Rouault - - TIFFAppendToStrip(): fix rewrite-in-place logic. - reproducable in particular with packbits compression. - - Fixes https://github.com/OSGeo/gdal/issues/4538 - -2021-09-17 Even Rouault - - tif_lzw.c: silence compiler warning about set but not used variable with recent clang - -2021-09-07 Even Rouault - - Merge branch 'fix_cygwin' into 'master' - Fix build warnings on cygwin about 'argument 1 of type 'float[3]' with... - - See merge request libtiff/libtiff!265 - -2021-09-06 Even Rouault - - test/rational_precision2double.c: add missing curly braces to fix -Werror=misleading-indentation - -2021-09-05 Even Rouault - - Fix build warnings on cygwin about 'argument 1 of type 'float[3]' with mismatched bound [-Werror=array-parameter=]' - -2021-09-05 Even Rouault - - Merge branch 'rewrite-fix' into 'master' - Fix TIFFRewriteDirectory discarding directories after the rewritten one - - See merge request libtiff/libtiff!264 - -2021-09-05 Facundo Tuesca - - tif_dirwrite.c: Fix TIFFRewriteDirectory discarding directories. - This fixes a bug caused by the `tif_lastdiroff` optimization when - rewriting directories. - - Rewriting the Nth directory temporarily zeroes the pointer to it - (located in the N-1th directory) and relies on `TIFFLinkDirectory` - traversing the whole directory list to find the zeroed pointer and - linking the rewritten directory to it. Since `TIFFLinkDirectory` skips - the traversal when `tif_lastdiroff` is set, this change unsets it - to force the full traversal when rewriting a directory. - - A test to catch this particular issue is also added. - -2021-09-01 Even Rouault - - test_directory.c: fix compiler warnings. - -2021-09-01 Even Rouault - - Merge branch 'multipage-optimization' into 'master' - Keep track of last directory to improve performance for large multi-page files - - See merge request libtiff/libtiff!262 - -2021-08-28 Facundo Tuesca - - Add field to keep track of last written directory. - This adds a new `tif_lastdiroff` field to the TIFF data structure - and uses it to store the offset of the last written directory. - - Appending a new directory required traversing the whole file - to find the last directory. By keeping track of its offset in this - new field, the search is no longer necessary. - - Since this offset is only stored in-memory, the first directory - append after opening a file will have to transverse the whole - directory list. Subsequent calls will have access to the last - offset, avoiding the transversal. - -2021-08-13 Even Rouault - - tif_jpeg.c: fix memory leak on error code path for JPEG 12 bit (CID 1086702) - -2021-07-29 Even Rouault - - Merge branch 'jpeg12' into 'master' - Enable JPEG 12bit support with a libjpeg that has a different ABI than the one for 8bit support - - See merge request libtiff/libtiff!261 - -2021-07-28 Even Rouault - - Reformat tif_jpeg.c and tif_jpeg_12.c with clang-format-10. - -2021-07-27 Even Rouault - - Enable JPEG 12bit support with a libjpeg that has a different ABI than the one for 8bit support - See https://github.com/OSGeo/gdal/pull/4139 for more details - - Note: this hasn't been tested for standalone libtiff builds. - -2021-07-09 Even Rouault - - Merge branch 'wip/export-targets' into 'master' - Export tiff targets - - See merge request libtiff/libtiff!258 - -2021-07-09 Even Rouault - - Merge branch 'pkgconfig' into 'master' - Add version and requirements to pc file - - See merge request libtiff/libtiff!256 - -2021-07-09 Kai Pastor <8989969-dg0yt@users.noreply.gitlab.com> - - Fix version in libtiff-4.pc.in, and CMake build: Add requirements to pc file - -2021-07-09 Even Rouault - - Merge branch 'cmake' into 'master' - Fix build issues with CMake 3.10 - - See merge request libtiff/libtiff!260 - -2021-07-04 Kai Pastor - - Fix reconfiguration with cmake. - - Fix build with CMake 3.10. - -2021-06-28 Milian Wolff - - Export tiff targets. - Fixes build when including libtiff as a cmake subproject into - another project and then installing a target from there which - depends on tiff. For example we could end up with: - - ``` - CMake Error in 3rdParty/diplib/CMakeLists.txt: - export called with target "DIP" which requires target "tiff" that is not in - any export set. - ``` - -2021-06-21 Even Rouault - - Merge branch 'libjpeg9d_support_simplification' into 'master' - tif_jpeg.c: simplify libjpeg 9d support (refs #266) - - See merge request libtiff/libtiff!257 - -2021-06-20 Even Rouault - - tif_jpeg.c: simplify libjpeg 9d support (refs #266) - Credits to Guido Vollbeding for the suggestion - -2021-06-15 Even Rouault - - Merge branch 'jpeg_in_tiff_jpeg_9d' into 'master' - tif_jpeg.c: workaround bug of libjpeg 9d that defers Huffman table creation - - Closes #266 - - See merge request libtiff/libtiff!255 - -2021-06-15 Even Rouault - - Merge branch 'jpeg_disable_progressive_with_mozjpeg' into 'master' - tif_jpeg.c: do not emit progressive scans with mozjpeg and force optimize_coding - - See merge request libtiff/libtiff!254 - -2021-06-12 Even Rouault - - tif_jpeg.c: with mozjpeg, disable emission of Huffman tables in JpegTables tag, and use optimize_coding - -2021-06-10 Even Rouault - - tif_jpeg.c: workaround bug of libjpeg 9d that defers Huffman table creation - Fixes #266 - - libjpeg-9d no longer creates default Huffman tables in - jpeg_set_defaults(), which make their emission in the JpegTables tag no - longer possible. Workaround that by borrowing code from libjpeg to - manually create them when they are not initialized. - -2021-06-10 Even Rouault - - tif_jpeg.c: do not emit progressive scans with mozjpeg. - Relates to #266 - - - On writing, explicitly disable progressive scans, which is normally - not enabled, except with mozjpeg. - - On reading, emit a warning when encountering progressive scans. - -2021-06-10 Even Rouault - - Merge branch 'fix-263' into 'master' - Fix memory leak in tiff2pdf - - See merge request libtiff/libtiff!249 - -2021-06-09 Even Rouault - - Merge branch 'diizzyy-master-patch-20521' into 'master' - html: Add missing pages when using CMake - - See merge request libtiff/libtiff!242 - -2021-06-09 Daniel E - - html: Add missing pages when using CMake. - -2021-06-07 Even Rouault - - Merge branch 'ci-reenable-cygwin' into 'master' - ci: Re-enable cygwin builds - - See merge request libtiff/libtiff!252 - -2021-06-06 Roger Leigh - - ci: Re-enable cygwin builds. - -2021-06-06 Even Rouault - - Merge branch 'ci-arm64' into 'master' - ci: Add arm64 build - - See merge request libtiff/libtiff!251 - -2021-06-06 Roger Leigh - - ci: Add arm64 build. - -2021-06-05 Even Rouault - - _TIFFRewriteField(): fix when writing a IFD with a single tile that is a sparse one, on big endian hosts - -2021-06-02 Timothy Lyanguzov - - Fix memory leak in tiff2pdf. - -2021-06-01 Even Rouault - - Merge branch 'lzw_cleanup' into 'master' - tif_lzw.c: cleanup, no functional change - - See merge request libtiff/libtiff!248 - -2021-05-31 Even Rouault - - tif_lzw.c: cleanup, no functional change. - -2021-05-22 Even Rouault - - Merge branch 'appveyor_disable_cygwin' into 'master' - .appveyor.yml: disable cygwin configs for now as they are broken - - See merge request libtiff/libtiff!247 - -2021-05-22 Even Rouault - - Merge branch 'zstd_reuse_objects' into 'master' - ZSTD codec: reuse compressor/decompressor objects - - See merge request libtiff/libtiff!246 - -2021-05-22 Even Rouault - - .appveyor.yml: disable cygwin configs for now as they are broken. - - ZSTD codec: reuse compressor/decompressor objects. - No need to recreate them each time in the PreEncode/Decode functions. - They can be reused if already existing. - -2021-05-08 Even Rouault - - Merge branch 'adobedeflate-fix' into 'master' - Fix all remaining uses of legacy Deflate compression id and warn on use - - See merge request libtiff/libtiff!245 - -2021-05-08 David Ryskalczyk - - Fix all remaining uses of legacy Deflate compression id and warn on use. - -2021-05-06 Even Rouault - - Merge branch 'improve_tiffinfo_tiffdump_for_gdal_tags' into 'master' - tiffinfo/tiffdump: improve output for GDAL tags - - See merge request libtiff/libtiff!244 - -2021-05-03 Even Rouault - - Merge branch 'issue-252' into 'master' - Prevent adding root directory to include list - - Closes #252 et #218 - - See merge request libtiff/libtiff!243 - -2021-05-03 Even Rouault - - tiffinfo/tiffdump: improve output for GDAL tags. - -2021-04-29 Timothy Lyanguzov - - Prevent adding root directory to include list. - there is a file VERSION in the root directory which clashes with C++20 standard header - "config.h" file is created in "config" subdirectory to prevent adding "-I.." to generated Makefile - - closes #218, #252 - -2021-04-23 Laszlo Boszormenyi (GCS) - - fix TIFFReadRawStrip man and HTML page typo. - From https://github.com/conda-forge/libtiff-feedstock/blob/master/recipe/patches/fix_TIFFReadRawStrip_man_page_typo.patch - -2021-04-20 Even Rouault - - HOWTO-RELEASE: update. - -2021-04-18 Even Rouault - - Merge branch 'lerc_zstd_deflate' into 'master' - Make LERC_SUPPORT conditional on ZLIB_SUPPORT. Make display of lerc options in tiffcp depend on actual zstd support. - - See merge request libtiff/libtiff!239 - -2021-04-18 Miguel Medalha - - Make LERC_SUPPORT conditional on ZLIB_SUPPORT. Make display of lerc options in tiffcp depend on actual zstd support. - -2021-04-17 Even Rouault - - Merge branch 'vtorri_xz' into 'master' - automatic creation of xz archive when running make distcheck - - See merge request libtiff/libtiff!238 - -2021-04-16 Even Rouault - - iptcutil.c: fix bug in EOF comparison, spotted on NetBSD 9 earmv7hf-el. - -2021-04-16 Even Rouault - - libtiff v4.3.0 released - -2021-04-15 Even Rouault - - Merge branch 'libjpeg12_cmake' into 'master' - libtiff/tif_config.h.cmake.in: surround LIBJPEG_12_PATH by double quotes - - See merge request libtiff/libtiff!237 - -2021-04-15 Even Rouault - - libtiff/tif_config.h.cmake.in: surround LIBJPEG_12_PATH by double quotes - -2021-04-14 Even Rouault - - Merge branch 'lerc_api_change' into 'master' - tif_lerc.c: cope with API breakage in liblerc master - - See merge request libtiff/libtiff!236 - -2021-04-14 Even Rouault - - tif_lerc.c: cope with API breakage in liblerc master. - -2021-04-08 Even Rouault - - libtiff: remove remaining #ifdef WIN32 and use PRI formatting. - -2021-03-10 Even Rouault - - Merge branch 'kmilos-master-patch-73187' into 'master' - tiffcp: Remove LZW help text, preset not supported - - See merge request libtiff/libtiff!229 - -2021-03-10 MiloÅ¡ KomarÄević - - tiffcp: Remove LZW help text, preset not supported. - -2021-03-10 Even Rouault - - Merge branch 'feature/lerc' into 'master' - Add LERC Compression Plugin (closes: #213) - - Closes #213 - - See merge request libtiff/libtiff!228 - -2021-03-10 Even Rouault - - Merge branch 'cmake-fixes' into 'master' - CMake fixes - - Closes #246 et #245 - - See merge request libtiff/libtiff!232 - -2021-03-09 Roger Leigh - - cmake: Correct FindCMath. - - cmake: Correct ZSTD_USABLE typo. - -2021-03-07 Roger Leigh - - Merge branch 'cmake-find-lib-prefixes' into 'master' - cmake: Correct find lib prefixes for Deflate and JBIG - - See merge request libtiff/libtiff!231 - -2021-03-07 Roger Leigh - - cmake: FindJBIG uses lib prefix on Windows. - - cmake: FindDeflate uses lib prefix on Windows. - -2021-03-07 Even Rouault - - TWebPDecode(): avoid potential overflow on multiplication (CID 1472928) - - TIFFReadDirEntryArrayWithLimit(): avoid false positive from Coverity Scan regarding out-of-bounds access (CID 1472927) - - tif_dirwrite.c: avoid setting a variable that is not read afterwards. - -2021-03-07 Even Rouault - - Merge branch 'coverity-fixes' into 'master' - Coverity fixes (high impact) - - See merge request libtiff/libtiff!227 - -2021-03-07 Roger Leigh - - Fix high-impact Coverity issues (resource leaks). - The issues are in the tests and tiffcrop, not the core library. Real issues, but not high risk. - - Use to test if Coverity integration is performing properly on merge. - -2021-03-07 Even Rouault - - Merge branch 'fix_tif_fax3_encoder_regression' into 'master' - tif_fax3.c: fix master regression in encoder - - See merge request libtiff/libtiff!230 - -2021-03-07 Even Rouault - - tif_fax3.c: fix master regression in encoder. - Fix issue introduced in 39a74eede0455ec8ee334dcddf71f5354d508d8b - - Spotted by gdal's tiff_write_76 test - -2021-03-07 Antonio Valentino - - Add LERC support in CMake. - -2021-03-07 Antonio Valentino - - Add LERC support in configure.ac and Makefile.am. - -2021-03-07 Antonio Valentino - - Add LERC support to tiffcp. - -2021-03-07 Antonio Valentino - - Add LERC plugin. - The lerc plugin code has been copyed form GDAL. - -2021-03-06 Roger Leigh - - Merge branch 'display_tool_purpose' into 'master' - TIFF tools: insert a line of text summarizing each tool's purpose - - See merge request libtiff/libtiff!214 - -2021-03-06 Even Rouault - - Merge branch 'cmake-update' into 'master' - CMake updates - - See merge request libtiff/libtiff!224 - -2021-03-06 Even Rouault - - tiff.h: typo fix in comment. - -2021-02-15 Roger Leigh - - Merge branch 'remove-travis' into 'master' - ci: Remove unused Travis-CI support - - See merge request libtiff/libtiff!226 - -2021-02-14 Roger Leigh - - ci: Remove unused Travis-CI support. - -2021-02-14 Roger Leigh - - Merge branch 'ci-coverity' into 'master' - Enable Coverity static analysis with CI pipeline - - See merge request libtiff/libtiff!225 - -2021-02-14 Roger Leigh - - ci: Add Coverity static analysis job. - - ci: Use custom libtiff CI image. - -2021-02-13 Roger Leigh - - cmake: Add release target. - - cmake: Remove empty contrib files. - - cmake: Tidy toplevel. - - cmake: Move pkg-config support to PkgConfig.cmake. - - cmake: Move library feature options to CXXLibraryFeatures.cmake. - - cmake: Move C++ support to CXXLibrary.cmake. - - cmake: Add FindCMath to handle libm linking portably. - - cmake: Tidy unused includes. - - cmake: Rename release date to build date. - - cmake: Compute timestamp portably. - - cmake: Remove remaining uses of report_values() - - cmake: Move JPEG12 checks to JPEGCodec.cmake. - - cmake: Move OpenGL checks to OpenGLChecks.cmake. - - cmake: Move OpenGL checks to OpenGLChecks.cmake. - - cmake: Move WebP codec support to WebPCodec.cmake. - - cmake: Use imported targets for WebP. - - cmake: Add FindWebP. - - cmake: Move ZSTD codec support to ZSTDCodec.cmake. - - cmake: Use imported targets for ZSTD. - - cmake: Add FindZSTD. - - cmake: Move LZMA codec support to LZMACodec.cmake. - - cmake: Use imported targets for LibLZMA. - - cmake: Move JBIG codec support to JBIGCodec.cmake. - - cmake: Use imported targets for JBIG. - - cmake: Add FindJBIG. - - cmake: Move PixarLog codec support to PixarLogCodec.cmake. - - cmake: Report system name in configuration report. - - cmake: Move JPEG codec support to JPEGCodec.cmake. - - cmake: Use imported targets for JPEG. - - cmake: Move Deflate codec support to DeflateCodec.cmake. - - cmake: Use imported targets for ZLIB and Deflate. - - cmake: Add FindDeflate. - - cmake: Move symbol checks to SymbolChecks.cmake. - - cmake: Move include checks to IncludeChecks.cmake. - - cmake: Move all autotools logic to separate files. - - cmake: Move internal codec options to InternalCodecs.cmake. - - cmake: Move LFS check to LargeFileSupport.cmake. - - cmake: Move Win32 IO feature to WindowsIOFeature.cmake. - - cmake: Move processor capability checks to ProcessorChecks.cmake. - - cmake: Move type size checks to TypeSizeChecks.cmake. - - cmake: Move linker checks to LinkerChecks.cmake. - - cmake: Move warning options to CompilerChecks. - - cmake: Move version introspection to AutotoolsVersion.cmake. - - cmake: Move compiler checks to CompilerChecks.cmake. - - cmake: Split into helper scripts. - -2021-02-08 Roger Leigh - - cmake: Use target_sources. - - libport: Adjust header and library to only define and link if required. - * Make libport an OBJECT library when in use, otherwise a dummy - INTERFACE library - * libport.h will work if getopt is present or not present. If - present, will fall back to , else will define - symbols - * Add generated libport_config.h to define HAVE_GETOPT and HAVE_UNISTD_H - * dummy.c no longer needed with CMake - * libtiff/libtiffxx no longer link with libport - - cmake: Remove unnecessary extra_dist usage. - Only makes sense in the context of Automake. Was carried over - for reference while porting, but is not needed. - - cmake: Update minimum version and policy version to 3.9. - -2021-02-08 Roger Leigh - - Merge branch 'remove-nmake' into 'master' - Remove NMake build support - - See merge request libtiff/libtiff!223 - -2021-02-08 Roger Leigh - - Remove NMake build support. - The functionality provided by the NMake build is now completely - superseded by the CMake build. - -2021-02-08 Even Rouault - - Merge branch 'warning-fixes' into 'master' - Warning fixes - - See merge request libtiff/libtiff!222 - -2021-02-07 Miguel Medalha - - Update tiffsplit.c. - - Reinsert summary line lost after conflicting merge. - - Merge branch 'master' into 'display_tool_purpose' - # Conflicts: - # tools/tiffsplit.c - -2021-02-06 Roger Leigh - - ci: Enable fatal warnings with -Werror for AppVeyor/GCC. - - ci: Enable fatal warnings with -Werror for GitLab CI. - - tif_zstd.c: Remove unused variable warning. - - custom_dir_EXIF_231: Remove case statement fallthrough. - - custom_dir_EXIF_231: Correct use of strncpy. - - Correct include order. - - Eliminate implict fallthrough usage. - Use simple loops in place of manual loop unrolling. Rely on - the compiler optimiser to unroll loops when appropriate. - - Suppress potential unused variable warning. - - Suppress warnings or avoid case statement fallthrough. - -2021-02-05 Roger Leigh - - Merge branch 'c99-ssize_t-fixes' into 'master' - C99 ssize_t fixes - - Closes #239 - - See merge request libtiff/libtiff!219 - -2021-02-05 Even Rouault - - Merge branch 'tiffsplit-too-many-args' into 'master' - tiffsplit.c: exit with EXIT_FAILURE if there are extra args on the command line - - See merge request libtiff/libtiff!209 - -2021-02-05 Roger Leigh - - Add additional TIFF_SSIZE_FORMAT uses. - -2021-02-04 Roger Leigh - - NMake fixes for size type formatting. - - Add TIFF_SIZE_FORMAT for portable use of %z. - MinGW64 does support %z, but it issues a compiler warning. - - Align Autoconf tif_config.h and CMake tif_config.cmake.in. - - Use TIFF_SSIZE_FORMAT for formatting tmsize_t. - -2021-02-04 Even Rouault - - Merge branch 'remove-lcc' into 'master' - Remove Makefile.lcc - - See merge request libtiff/libtiff!221 - -2021-02-04 Even Rouault - - Merge branch 'remove-scons' into 'master' - Remove SCons build - - See merge request libtiff/libtiff!220 - -2021-02-03 Even Rouault - - Merge branch 'c99-snprintf' into 'master' - Use C99 snprintf - - See merge request libtiff/libtiff!217 - -2021-02-03 Roger Leigh - - Merge branch 'tiff2ps-const' into 'master' - tiff2ps.c: string literals must be const char *, not char * - - See merge request libtiff/libtiff!202 - -2021-02-03 Roger Leigh - - Remove SCons build. - Unmaintained for 16 years. - -2021-02-03 Roger Leigh - - Merge branch 'codec_summary' into 'master' - Modify 'CMakeLists.txt' to produce a meaningful summary of external codecs - - See merge request libtiff/libtiff!192 - -2021-02-03 Roger Leigh - - Remove Makefile.lcc. - Unmaintained for 22 years. - -2021-02-02 Roger Leigh - - Merge branch 'ci-32-bit' into 'master' - ci: Build 32- and 64-bit MSVC variants - - See merge request libtiff/libtiff!218 - -2021-02-01 Roger Leigh - - ci: Build 32- and 64-bit MSVC variants. - - Use C99 snprintf. - -2021-02-01 Even Rouault - - Merge branch 'c99-strtol' into 'master' - Use C99 strtol, strtoul, strtoll and strtoull - - See merge request libtiff/libtiff!216 - -2021-01-31 Even Rouault - - Merge branch 'c99-inline' into 'master' - Use C99 inline - - See merge request libtiff/libtiff!215 - -2021-01-31 Roger Leigh - - Use C99 strtol, strtoul, strtoll and strtoull. - - tif_fax3: Use C99 inline. - - Remove inline feature tests and defines. - Available as a standard feature with C99. - -2021-01-30 Miguel Medalha - - Update raw2tiff.c (remove duplicate description of tool) - -2021-01-30 Roger Leigh - - Merge branch 'c99-format-strings' into 'master' - C99 format strings - - See merge request libtiff/libtiff!211 - -2021-01-29 Miguel Medalha - - Update tiffdither.c (2 tabs caused slight misalignment of lines in usage info output) - -2021-01-28 Miguel Medalha - - Update ppm2tiff.c (slight misalignment of lines in usage info output) - - Update tiffset.c (small misalignment of lines in usage info output) - -2021-01-28 Medalha - - Display tool purpose. - -2021-01-28 Thomas Bernard - - tiff2ps.c: string literals must be const char *, not char * - -2021-01-28 Roger Leigh - - libtiff: Use PRI format flags and remove unnecessary casts. - -2021-01-27 Roger Leigh - - ascii_tag: Use PRI format flags and remove unnecessary casts. - - check_tag: Use PRI format flags and remove unnecessary casts. - - custom_dir_EXIF_231: Use PRI format flags and remove unnecessary casts. - - short_tag: Use PRI format flags and remove unnecessary casts. - - strip_rw: Use PRI format flags and remove unnecessary casts. - - fax2tiff: Use PRI format flags and remove unnecessary casts. - - ppm2tiff: Correct format strings. - - raw2tiff: Use PRI format flags and remove unnecessary casts. - - rgb2ycbcr: Use PRI format flags and remove unnecessary casts. - - tiff2pdf: Use PRI format flags and remove unnecessary casts. - - tiff2ps: Use PRI format flags and remove unnecessary casts. - - tiff2rgba: Use PRI format flags and remove unnecessary casts. - - tiffcmp: Use PRI format flags and remove unnecessary casts. - - tiffcp: Use PRI format flags and remove unnecessary casts. - - tiffcrop: Use PRI format flags and remove unnecessary casts. - - tiffinfo: Use PRI format flags and remove unnecessary casts. - - tiffdump: Use PRI format flags and remove unnecessary casts. - -2021-01-27 Even Rouault - - Merge branch 'c99-require-stdtypes' into 'master' - Use standard C99 integer types - - See merge request libtiff/libtiff!205 - -2021-01-26 Even Rouault - - Merge branch 'reserve_COMPRESSION_JXL' into 'master' - tiff.h: reserve COMPRESSION_JXL=50002 for JPEGXL - - See merge request libtiff/libtiff!210 - -2021-01-22 Even Rouault - - tiff.h: reserve COMPRESSION_JXL=50002 for JPEGXL. - -2021-01-22 Kurt Schwehr - - tiffsplit.c: exit with EXIT_FAILURE if there are extra args on the command line - e.g. tiffsplit in.tif a_prefix_ junk - -2021-01-22 Roger Leigh - - Add and enable TIFF_DISABLE_DEPRECATED for internal use. - - Add typedef deprecations for GCC/Clang and MSVC. - - Use standard C99 integer types. - -2021-01-20 Even Rouault - - Merge branch 'ubuntu-zstd-wepb' into 'master' - gitlab-ci : use libzstd-dev and libwebp-dev ubuntu packages - - See merge request libtiff/libtiff!208 - -2021-01-20 Thomas Bernard - - gitlab-ci : use libzstd-dev and libwebp-dev ubuntu packages. - should replace !206 - -2021-01-20 Even Rouault - - Merge branch 'issue-232' into 'master' - tiff2ps: exit the loop in case of error - - Closes #232 - - See merge request libtiff/libtiff!201 - -2021-01-20 Even Rouault - - Merge branch 'tiffsplit-exit-status' into 'master' - tiffsplit: Exit with EXIT_FAILURE if unable to open the input file. - - See merge request libtiff/libtiff!207 - -2021-01-20 Even Rouault - - Merge branch 'config-cleanup' into 'master' - Remove HAVE_INTTYPES_H, HAVE_LFIND & lfind, HAVE_SEARCH_H & include - - See merge request libtiff/libtiff!203 - -2021-01-19 Kurt Schwehr - - tiffsplit: Exit with EXIT_FAILURE if unable to open the input file. - -2021-01-18 Even Rouault - - Merge branch 'tiffcmp' into 'master' - tiffcmp: fix comparaison with pixels that are fractional number of bytes - - Closes #53 - - See merge request libtiff/libtiff!141 - -2021-01-15 Kurt Schwehr - - CMakeLists.txt: Remove search for lfind. - - Remove HAVE_INTTYPES_H, HAVE_LFIND & lfind, HAVE_SEARCH_H & include - - HAVE_INTTYPES_H is replaced with TIFF_HAVE_INTTYPES_H - - tif_dirinfo.c has a static td_lfind - -2021-01-15 Thomas Bernard - - tiffcmp: fix comparaison with pixels that are fractional number of bytes - For exemple : 4bits per sample + 3 samples per pixel => 1.5 bytes per pixel - - tiff2ps: exit the loop in case of error. - fixes #232 - -2021-01-15 Even Rouault - - Merge branch 'rm-strcasecmp' into 'master' - Remove port/strcasecmp.c as strcasecmp is not currently used in libtiff. - - Closes #235 - - See merge request libtiff/libtiff!199 - -2021-01-15 Even Rouault - - Merge branch 'std-int-types' into 'master' - Use standard C99 integer types - - See merge request libtiff/libtiff!185 - -2021-01-13 Kurt Schwehr - - Remove port/strcasecmp.c as strcasecmp is not currently used in libtiff. - Fixes #235 - -2021-01-10 Miguel Medalha - - Update CMakeLists.txt. Delete unnecessary line from libdeflate codec support section - -2021-01-10 Roger Leigh - - Merge branch 'include_libport' into 'master' - tiff tools and libtiff/mkg3states: include 'libport.h', remove local definition of 'getopt()' - - See merge request libtiff/libtiff!198 - -2021-01-09 Miguel Medalha - - Update CMakeLists.txt. Cleanup of indentation space. Removal of leading '/' from webp include dir. - -2021-01-09 miguel - - cmake: Use target_include_directories correctly. - -2021-01-09 Roger Leigh - - cmake: Use target_include_directories correctly. - - cmake: Drop unnecessary TOOL_INCLUDES. - -2021-01-07 Roger Leigh - - cmake: Use target_include_directories correctly. - -2021-01-07 miguel - - tiff tools and libtiff/mkg3states: include 'libport.h', remove local definition of 'getopt()' - -2021-01-07 Miguel Medalha - - Update CMakeLists.txt. - -2021-01-07 miguel - - tiff tools: include 'libport.h', remove local definition of 'getopt()' - -2021-01-06 Roger Leigh - - Remove conditional use of - - cmake: Drop dlfcn.h check. - - cmake: Remove duplicate line. - - Use stdint.h types when available. - -2021-01-05 Olivier Paquet - - Merge branch 'iptcutil' into 'master' - contrib/iptcutil.c: set '#ifdef _WIN32' (was '#ifdef WIN32', which failed at build time) - - See merge request libtiff/libtiff!197 - -2021-01-05 miguel - - tiff tools: include 'libport.h', remove local definition of 'getopt()' - - contrib/iptcutil.c - set '#ifdef _WIN32' (was '#ifdef WIN32', which failed at build time) - -2021-01-04 Even Rouault - - tools/CMakeLists.txt: add comment about rgb2ycbcr and thumbnail not to be installed - -2021-01-04 Even Rouault - - Merge branch 'revert-5331ed49' into 'master' - Revert "Merge branch 'install_targets' into 'master'" - - See merge request libtiff/libtiff!196 - -2021-01-04 Even Rouault - - Merge branch 'drop-wince' into 'master' - Remove non-functional WinCE support - - See merge request libtiff/libtiff!188 - -2021-01-04 Even Rouault - - Merge branch 'drop-vms' into 'master' - Remove non-functional VMS support - - See merge request libtiff/libtiff!187 - -2021-01-03 Even Rouault - - Revert "Merge branch 'install_targets' into 'master'" - This reverts merge request !193 - -2021-01-03 Even Rouault - - Merge branch 'tiffcp_b_parameter' into 'master' - tiffcp: Remove unnecessary reference to compression from usage info for -b parameter - - See merge request libtiff/libtiff!189 - -2021-01-03 Even Rouault - - Merge branch 'cmake-faxtable' into 'master' - cmake: Add faxtable target - - See merge request libtiff/libtiff!186 - -2021-01-03 Roger Leigh - - Merge branch 'install_targets' into 'master' - Update 'CMakeLists.txt' from 'tools'. - - See merge request libtiff/libtiff!193 - -2021-01-03 Miguel Medalha - - Update 'CMakeLists.txt' from 'tools'. - - Update CMakeLists.txt. - -2021-01-03 Roger Leigh - - Merge branch 'usage_info' into 'master' - thumbnail: Rename constant variable 'stuff' to 'usage_info' - - See merge request libtiff/libtiff!190 - -2021-01-03 Miguel Medalha - - Modified 'CMakeLists.txt' to produce a meaningful summary of external codecs support. - - Removed unnecessary reference to compression from usage info for -b parameter - - Constant variable 'stuff' renamed to 'usage_info' for consistency with the other tools - -2021-01-02 Roger Leigh - - Remove non-functional VMS support. - - Remove non-functional WinCE support. - -2021-01-02 Roger Leigh - - Merge branch 'codespell' into 'master' - Fix spelling mistakes. - - See merge request libtiff/libtiff!183 - -2021-01-02 Kurt Schwehr - - ChangeLog: Remove extraneous character from prior commit - 00fe7828. - -2021-01-02 Roger Leigh - - Merge branch 'codespell-custom_dir_EXIF_231' into 'master' - custom_dir_EXIF_231.c: dos2unix and codespell - - See merge request libtiff/libtiff!184 - -2021-01-01 Roger Leigh - - mkg3states: Sync generator with current generated file content. - - cmake: Add faxtable and mkg3states targets. - -2020-12-31 Kurt Schwehr - - custom_dir_EXIF_231.c: dos2unix and codespell. - additonal, Varable, greather, alwasy - -2020-12-31 Kurt Schwehr - - Fix spelling mistakes. - Found with: - - codespell --version - 1.17.1 - -2020-12-29 Even Rouault - - Merge branch 'remove-some-vms-ifdef' into 'master' - Remove "ifdef VMS" that are no longer necessary. - - See merge request libtiff/libtiff!181 - -2020-12-29 Kurt Schwehr - - Remove "ifdef VMS" that are no longer necessary. - Both sides of the if are now the same. - -2020-12-29 Bob Friesenhahn - - _TIFFBuiltinCODECS should be const. - -2020-12-28 Even Rouault - - Merge branch 'issue-202' into 'master' - tiff2pdf.c: check that tiff_datasize fits in a signed tsize_t - - Closes #202 - - See merge request libtiff/libtiff!166 - -2020-12-28 Even Rouault - - Merge branch 'w_report-when-libdeflate-is-found' into 'master' - CMakeLists.txt: Report when libdeflate is found - - See merge request libtiff/libtiff!175 - -2020-12-28 Bob Friesenhahn - - Declare gpsFields as static const. - -2020-12-28 Bob Friesenhahn - - Merge branch 'tools-reduce-initialized-data' into 'master' - Reduce initialized data by making more data const and simplifying usage() implementation. - - See merge request libtiff/libtiff!180 - -2020-12-28 Bob Friesenhahn - - Reduce initialized data by making more data const and simplifying usage() implementation. - -2020-12-27 Bob Friesenhahn - - Merge branch 'master' into 'master' - tiff tools: display of compression methods is now conditional instead of hard-coded - - See merge request libtiff/libtiff!176 - -2020-12-27 Bob Friesenhahn - - Merge branch 'build' into 'master' - Fix wrong URL for fetching config.guess and config.sub - - See merge request libtiff/libtiff!177 - -2020-12-26 Chocobo1 - - Fix wrong URL for fetching config.guess and config.sub. - -2020-12-25 miguel - - tiff tools: made display of compression methods and their parameters conditional on their actual availability - -2020-12-20 Bob Friesenhahn - - autogen.sh now updates config.guess and config.sub from master gnulib version. - -2020-12-19 Bob Friesenhahn - - Add a https://libtiff.gitlab.io/libtiff/ link. - - Remove stray character in URL area. - - Changes for 4.2.0 release. - - Changes for 4.2.0 release. - 2020-12-19 Bob Friesenhahn * libtiff 4.2.0 released. @@ -4832,7 +469,7 @@ see #17 tiffmedian: shopw usage on stdout when -h is used. - also use EXIT_SUCCESS/EXIT_FAILURE + aslo use EXIT_SUCCESS/EXIT_FAILURE see #17 tiffinfo: print usage on stdout when -h is used. @@ -5037,7 +674,7 @@ 2020-03-27 Thomas Bernard tiff2pdf: fix "raw" copy of Deflate streams. - The Predictor parameter was not copied from the source tiff to the PDF. + The Predictor parametter was not copied from the source tiff to the PDF. fixes #48 / http://bugzilla.maptools.org/show_bug.cgi?id=2442 2020-03-26 Thomas Bernard @@ -5345,7 +982,7 @@ - EXIF_GPS_upgrade rebased onto c8c5309b765ef4ff097d2aaffbdb8f403db8967d (Merge branch 'Rational2DoublePrecision_correction' into 'master') and adapted: - tif_dirinfo.c: All rational tags set to TIFF_SETGET_FLOAT but only the GPSTAG_ tags set to TIFF_SETGET_DOUBLE. - - custom_dir_EXIF_231.c: Editorials amended and gcc warnings fixed. + - custom_dir_EXIF_231.c: Editorials amended and gcc warnigs fixed. - CMakeLists.txt: add_test(NAME "custom_dir_EXIF_231" COMMAND "custom_dir_EXIF_231") added. 2020-03-07 Even Rouault @@ -5369,7 +1006,7 @@ fix #55 http://bugzilla.maptools.org/show_bug.cgi?id=2505 - Patch originally submitted by Ludolf Holzheid + Patch originally submited by Ludolf Holzheid 2020-03-06 Even Rouault @@ -5492,7 +1129,7 @@ 2020-02-29 Su_Laus - tif_dirwrite.c: bugfix DoubleToSrational(), which returns plain signed integer values always as unsigned rationals. Add a test into rational_precision2double.c for "-1.0" and some editorials in tif_dirwrite.c. (code is related to 6df997c786928757caea0dd68d26ea5f098f49df changes). + tif_dirwrite.c: bugfix DoubleToSrational(), which returns plain signed interger values always as unsigned rationals. Add a test into rational_precision2double.c for "-1.0" and some editorials in tif_dirwrite.c. (code is related to 6df997c786928757caea0dd68d26ea5f098f49df changes). 2020-02-29 Even Rouault @@ -5537,7 +1174,7 @@ Rational with Double Precision Upgrade. Unfortunately, custom rational tags (TIFF_RATIONAL with field_bit=FIELD_CUSTOM) are defined as TIFF_SETGET_DOUBLE - but for the reading interface and LibTiff internally they are stored ALWAYS as floating point SINGLE precision. + but for the reading interface and LibTiff internally they are stored ALLWAYS as floating point SINGLE precision. Double precision custom rational tags are not supported by LibTiff. For the GPS tags in WGS84 a higher accuracy / precision is needed. @@ -5632,7 +1269,7 @@ raw2tiff: avoid divide by 0. fixes #151 / http://bugzilla.maptools.org/show_bug.cgi?id=2839 - first memcmp() lines before computing correlation + first memcmp() lines before computing corellation and always avoid divide by 0 anyway 2020-02-09 Even Rouault @@ -5657,7 +1294,7 @@ tiffcrop.c:4027:20: runtime error: left shift of 190 by 24 places cannot be represented in type 'int' C treats (byte << 24) as an int expression. - casting explicitly to unsigned type uint32 avoids the problem. + casting explicitely to unsigned type uint32 avoids the problem. the same issue has been fixed elsewhere with a24213691616e7cd35aa3e2805493de80c7e4fcf @@ -5886,7 +1523,7 @@ 2019-08-25 Even Rouault - JPEG: avoid use of uninitialized memory on corrupted files. + JPEG: avoid use of unintialized memory on corrupted files. Follow-up of cf3ce6fab894414a336546f62adc57f02590a22c Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16602 Credit to OSS Fuzz @@ -5950,7 +1587,7 @@ signed), which was especially easily triggered on 32-bit builds (with recent enough compilers that assume that signed multiplication cannot overflow, since this is undefined behaviour by the C standard). The original issue which lead to - this fix was triggered from tif_fax3.c + this fix was trigged from tif_fax3.c There were also unsafe (implementation defied), and broken in practice on 64bit builds, ways of checking that a uint64 fits of a (signed) tmsize_t by doing @@ -6023,7 +1660,7 @@ - Discussion in https://gitlab.com/libtiff/libtiff/merge_requests/39 - http://bugzilla.maptools.org/show_bug.cgi?id=2540 - Comments and indentation adapted. + Comments and indention adapted. Preparation to rebase onto master @@ -6043,7 +1680,7 @@ [00:02:58] -- CMAKE_HOST_SYSTEM_PROCESSOR set to AMD64 [00:02:58] -- HOST_FILLORDER set to FILLORDER_MSB2LSB - The reason is that we match the "amd64.*" lowercase string whereas + Ther reason is that we match the "amd64.*" lowercase string whereas CMAKE_HOST_SYSTEM_PROCESSOR is set to AMD64 uppercase. 2019-07-09 Even Rouault @@ -6053,13 +1690,13 @@ 2019-07-09 Even Rouault Merge branch 'fix_chromium_925269' into 'master' - OJPEG: avoid use of uninitialized memory on corrupted files + OJPEG: avoid use of unintialized memory on corrupted files See merge request libtiff/libtiff!86 2019-07-05 Even Rouault - OJPEG: avoid use of uninitialized memory on corrupted files. + OJPEG: avoid use of unintialized memory on corrupted files. Fixes https://bugs.chromium.org/p/chromium/issues/detail?id=925269 Patch from Lei Zhang with little adaptations. @@ -6212,12 +1849,12 @@ arrays are only loaded when first accessed. This can speed-up the opening of files stored on the network when just metadata retrieval is needed. This mode has been used for years by the GDAL library when compiled with - its embedded libtiff copy. + its embeded libtiff copy. To avoid potential out-of-tree code (typically codecs) that would use the td_stripbytecount and td_stripoffset array inconditionnaly assuming they have been loaded, those have been suffixed with _p (for protected). The - use of the new functions mentioned below is then recommended. + use of the new functions mentionned below is then recommended. Another addition of this commit is the capability of loading only the values of the offset/bytecount of the strile of interest instead of the @@ -6233,7 +1870,7 @@ if a strile is present or not without decompressing the data, or updating an existing sparse file. They will also be used to enable a future enhancement where client code can entirely - skip bytecount loading in some situations + skip bytecount loading in some situtations A new test/defer_strile_loading.c test has been added to test the above capabilities. @@ -6504,8 +2141,8 @@ Also the values were not properly calculated. It should be 255-x, 15-x, 3-x for bps 8, 4, 2. - But anyway it is easier to invert all bits as 255-x = ~x, etc. - (subtracting from a binary number composed of all 1 is like inverting + But anyway it is easyer to invert all bits as 255-x = ~x, etc. + (substracting from a binary number composed of all 1 is like inverting the bits) 2019-02-11 Thomas Bernard @@ -7033,7 +2670,7 @@ Merge branch 'zstd' - Add warning about COMPRESSION_ZSTD not being officially registered. + Add warning about COMPRESSION_ZSTD not being officialy registered. 2018-02-14 Even Rouault @@ -7263,7 +2900,7 @@ result, we end up writing past the end of the buffer. There are also some related issues that this also fixes. For example, - TIFFGetField can return uninitialized pointer values, and the logic to + TIFFGetField can return uninitalized pointer values, and the logic to detect a N=3 vs N=1 transfer function seemed rather strange. It is also strange that we declare the transfer functions to be of type @@ -7678,7 +3315,7 @@ scans and not interleavedin a single one, needs to allocate memory (or backing store) for the whole strip/tile. See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf - This limitation may be overridden by setting the + This limitation may be overriden by setting the LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, or recompiling libtiff with a custom value of TIFF_LIBJPEG_LARGEST_MEM_ALLOC macro. @@ -7961,7 +3598,7 @@ * libtiff/tif_jpeg.c: only run JPEGFixupTagsSubsampling() if the YCbCrSubsampling tag is not explicitly present. This helps a bit to reduce - the I/O amount when the tag is present (especially on cloud hosted files). + the I/O amount when te tag is present (especially on cloud hosted files). 2017-01-14 Even Rouault @@ -8202,7 +3839,7 @@ 2016-12-03 Even Rouault * libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() to - instantiate compute nstrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip), + instanciate compute ntrips as TIFFhowmany_32(td->td_imagelength, rowsperstrip), instead of a logic based on the total size of data. Which is faulty is the total size of data is not sufficient to fill the whole image, and thus results in reading outside of the StripByCounts/StripOffsets arrays when @@ -8226,7 +3863,7 @@ 2016-12-02 Even Rouault - * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips that + * tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips that can cause various issues, such as buffer overflows in the library. Reported by Agostino Sarubbo. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2598 @@ -8668,7 +4305,7 @@ * libtiff/tif_write.c: TIFFWriteEncodedStrip() and TIFFWriteEncodedTile() should return -1 in case of failure of tif_encodestrip() as documented * libtiff/tif_dumpmode.c: DumpModeEncode() should return 0 in case of - failure so that the above mentioned functions detect the error. + failure so that the above mentionned functions detect the error. 2015-12-06 Even Rouault @@ -8691,7 +4328,7 @@ 2015-11-22 Even Rouault * libtiff/*.c: fix typos in comments (patch by Kurt Schwehr) - + 2015-11-22 Even Rouault * libtiff/*.c: fix MSVC warnings related to cast shortening and @@ -9259,7 +4896,7 @@ 2014-12-27 Even Rouault * libtiff/tif_dir.c: in TIFFDefaultDirectory(), reset any already existing - extended tags installed by user code through the extender mechanism before + extented tags installed by user code through the extender mechaninm before calling the extender callback (GDAL #5054) 2014-12-26 Bob Friesenhahn @@ -9362,14 +4999,14 @@ cpStripToTile() (called from writeBufferToContigTiles). Note that the resulting TIFF file would be scrambled even if tiffcp wouldn't crash, since the output file would contain - RGB data interpreted as subsampled YCbCr values. + RGB data intepreted as subsampled YCbCr values. This patch fixes the problem by forcing RGB space on the output TIF if the input is JPEG-encoded and output is *not* JPEG-encoded. Author: Tomasz Buchert 2014-12-21 Even Rouault - Fix various crash bugs on fuzzed images. + Fix various crasher bugs on fuzzed images. * libtiff/tif_dir.c: TIFFSetField(): refuse to set negative values for TIFFTAG_XRESOLUTION and TIFFTAG_YRESOLUTION that cause asserts when writing the directory @@ -9706,7 +5343,7 @@ * libtiff 4.0.2 released. - * tools/tif2pdf.c, tools/tifdump.c: avoid uninitialized variable + * tools/tif2pdf.c, tools/tifdump.c: avoid unitialized variable warnings with clang. 2012-06-15 Tom Lane @@ -11353,7 +6990,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic Added support for a TIFF_PTRDIFF_T type to use when doing pointer arithmetic. Added support for a TIFF_SSIZE_T in order to return memory sizes but still allow returning -1 for errors. - * libtiff/tiffconf.vc.h: Add porting type definitions for WIN32. + * libtiff/tiffconf.vc.h: Add porting type defintions for WIN32. 2007-06-25 Bob Friesenhahn @@ -11488,7 +7125,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic * libtiff/tif_config.wince.h: Added configuration header for WinCE. * libtiff/tiffconf.wince.h: Ported old configuration header for WinCE. * libtiff/tif_wince.c: Added WinCE-specific implementation of some - functions from tif_win32.c. + functons from tif_win32.c. * libtiff/tif_win32.c: Disabled some functions already reimplemented in tif_wince.c. * libtiff/tiffiop.h, port/lfind.c: Added conditional include of some standard header files for Windows CE build. @@ -11732,7 +7369,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic * libtiff/tif_jpeg.c: strip size related bugfix in encode raw - * libtiff/tif_strip.c: temporarily added two new versions of + * libtiff/tif_strip.c: temporarilly added two new versions of TIFFScanlineSize - TIFFNewScanlineSize: proposed new version, after all related issues and side-effects are sorted out @@ -11792,7 +7429,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2006-03-16 Andrey Kiselev - * libtiff/tiffiop.h: Added declaration for + * libtiff/tiffiop.h: Added decalration for _TIFFSetDefaultCompressionState(). * libtiff/{tif_jpeg.c, tif_fax3.c, tif_zip.c, tif_pixarlog.c, @@ -12122,7 +7759,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic http://bugzilla.remotesensing.org/show_bug.cgi?id=1003 - * libtiff/tif_dirinfo.c: Correctly use bsearch() and lfind() + * libtiff/tif_dirinfo.c: Correctly yse bsearch() and lfind() functions as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1008 @@ -12167,7 +7804,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic http://bugzilla.remotesensing.org/show_bug.cgi?id=977 - * tools/tiffsplit.c: Copy fax related fields over split parts + * tools/tiffsplit.c: Copy fax related fields over splitted parts as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=983 @@ -12349,12 +7986,12 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2005-06-07 Andrey Kiselev * contrib/addtiffo/tif_ovrcache.c: Properly extract tile/strip size; - use pixel sized shift in contiguous case. + use pixel sized shift in contigous case. 2005-06-06 Andrey Kiselev * contrib/addtiffo/{tif_overview.c, tif_ovrcache.c, tif_ovrcache.h}: - Make overviews working for contiguous images. + Make overviews working for contiguos images. 2005-06-03 Andrey Kiselev @@ -12784,7 +8421,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic http://bugzilla.remotesensing.org/show_bug.cgi?id=697 - * libtiff/tif_config.in.vc: Removed unneeded definitions for + * libtiff/tif_config.in.vc: Removed unneded definitions for read/open/close/lseek functions to fix the http://bugzilla.remotesensing.org/show_bug.cgi?id=680 @@ -13643,7 +9280,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic * man/tiff2pdf.1: Few improvements in page layout. * Makefile.in, /man/Makefile.in, /html/man/tiff2pdf.1.html: - Added support for tiff2pdf manual page. + Added support fpr tiff2pdf manual page. 2003-11-26 Ross Finlayson @@ -13652,7 +9289,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2003-11-26 Andrey Kiselev * Makefile.in, /tools/{Makefile.in, makefile.vc}: - Added support for tiff2pdf utility. + Added support fpr tiff2pdf utility. 2003-11-25 Ross Finlayson @@ -13695,7 +9332,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2003-11-17 Andrey Kiselev * contrib/pds/{tif_pdsdirread.c, tif_pdsdirwrite.c}: Use - TIFFDataWidth() function instead of tiffDataWidth array. + TIFFDataWidth() function insted of tiffDataWidth array. 2003-11-16 Andrey Kiselev @@ -14482,7 +10119,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic TIFFDataType sizes instead of working with tiffDataWidth array directly. Should prevent out-of-borders bugs in case of unknown or broken data types. EstimateStripByteCounts routine modified, so it - won't work when tags with unknown sizes founded. + won't work when tags with uknown sizes founded. Closes http://bugzilla.remotesensing.org/show_bug.cgi?id=109 2002-03-13 Andrey Kiselev @@ -14684,7 +10321,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic * libtiff/tif_getimage.c: relax handling of contig case where there are extra samples that are supposed to be ignored. This - should now work for 8bit greyscale or paletted images. + should now work for 8bit greyscale or palletted images. http://bugzilla.remotesensing.org/show_bug.cgi?id=75 @@ -14914,7 +10551,7 @@ btiff/tif_win32.c: Replace custom Win32 memory api with generic 2001-02-16 Frank Warmerdam * libtiff/libtiff.def: Brent Roman submitted new version adding - several missing entry points. + serveral missing entry points. * libtiff/tif_dirinfo.c: don't declare tiffFieldInfo static on VMS. Some sort of weird VMS thing. @@ -15324,7 +10961,7 @@ Tue Nov 30 14:41:43 1999 Frank Warmerdam *** 3.5 Tue Nov 30 14:15:32 EST 1999 Mike Welles - * Added zip creation to release makefile target + * Added zip creation to relase makefile target * Added html for TIFFWriteTile.3t man page. diff --git a/thirdparty/SDL2_image/external/libtiff/HOWTO-RELEASE b/thirdparty/SDL2_image/external/libtiff/HOWTO-RELEASE index 5728d852f..0896ef991 100644 --- a/thirdparty/SDL2_image/external/libtiff/HOWTO-RELEASE +++ b/thirdparty/SDL2_image/external/libtiff/HOWTO-RELEASE @@ -25,11 +25,7 @@ Notes on releasing. 1. Commit any unsaved changes. 2. Use gnulib's gitlog-to-changelog script to add new (since the last - release) entries to the traditional ChangeLog file. - - http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=build-aux/gitlog-to-changelog - - Take note of + release) entries to the traditional ChangeLog file. Take note of the most recent change note time stamp and use that as the starting point. Concatenate the old logs to the new logs. The added logs may be used to help produce the release notes (in next step). For @@ -41,14 +37,13 @@ Notes on releasing. mv ChangeLog.new ChangeLog rm ChangeLog.added -3. Create doc/releases/vX.X.rst and add it to git with 'git add doc/releases/vX.X.rst'. - Update doc/releases/index.rst to point to the new file - Take ChangeLog entries and rst-ify in there. - Easist thing to do is take doc/releases/vX.(X-1).rst and use it as a template. +3. Create html/vX.X.html and add it to git with 'git add html/vX.X.html'. + Take ChangeLog entries and html-ify in there. + Easist thing to do is take html/vX.(X-1).html and use it as a template. -4. Add vX.X.rst file to the list of 'rst_sources' files in the doc/Makefile.am. +4. Add vX.X.html file to the list of 'docfiles' files in the html/Makefile.am. -5. Update "Latest Stable Release" in doc/index.rst. +5. Update html/index.html to refer to this new page as the current release. 6. Increment the release version in configure.ac. Put 'alpha' or 'beta' after the version, if applicable. For example: @@ -134,18 +129,18 @@ Notes on releasing. 16. Sign the release files in the build tree using your private key export GPG_TTY=$(tty) - for file in tiff-*.tar.gz tiff-*.tar.xz tiff-*.zip ; do \ + for file in tiff-*.tar.gz tiff-*.zip ; do \ gpg2 --output ${file}.sig --detach-sig $file ; \ done - for file in tiff-*.tar.gz tiff-*.tar.xz tiff-*.zip ; do \ + for file in tiff-*.tar.gz tiff-*.zip ; do \ gpg2 --verify ${file}.sig $file ; \ done 17. Copy release packages from the build tree to the ftp.remotesensing.org ftp site. - scp tiff-*.tar.gz tiff-*.tar.gz.sig tiff-*.tar.xz tiff-*.tar.xz.sig tiff-*.zip tiff-*.zip.sig \ + scp tiff-*.tar.gz tiff-*.tar.gz.sig tiff-*.zip tiff-*.zip.sig \ bfriesen@upload.osgeo.org:/osgeo/download/libtiff -18. Announce to list: tiff@lists.osgeo.org +18. Announce to list, tiff@lists.maptools.org diff --git a/thirdparty/SDL2_image/external/libtiff/Makefile.am b/thirdparty/SDL2_image/external/libtiff/Makefile.am index 2f07eec70..d19e58ee9 100644 --- a/thirdparty/SDL2_image/external/libtiff/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/Makefile.am @@ -29,30 +29,30 @@ AUTOMAKE_OPTIONS = 1.12 dist-zip foreign ACLOCAL_AMFLAGS = -I m4 docfiles = \ + COPYRIGHT \ ChangeLog \ - LICENSE.md \ README.md \ RELEASE-DATE \ TODO \ VERSION EXTRA_DIST = \ - placeholder.h \ - cmake \ CMakeLists.txt \ HOWTO-RELEASE \ + Makefile.vc \ + SConstruct \ autogen.sh \ - libtiff-4.pc.in + configure.com \ + libtiff-4.pc.in \ + nmake.opt -if TIFF_DOCS dist_doc_DATA = $(docfiles) -endif distcheck-hook: if [ -x "$(CMAKE)" ]; then \ mkdir $(distdir)/_build/cmake \ && cd $(distdir)/_build/cmake \ - && cmake -Dsphinx=OFF ../.. \ + && cmake ../.. \ && $(MAKE) \ && ctest -V \ && $(MAKE) DESTDIR=../../_inst/cmake install ; \ @@ -60,12 +60,12 @@ distcheck-hook: rm -rf $(distdir)/_build/cmake rm -rf $(distdir)/_inst/cmake -SUBDIRS = port libtiff tools build contrib test doc +SUBDIRS = port libtiff tools build contrib test man html release: (rm -f $(top_srcdir)/RELEASE-DATE && echo $(LIBTIFF_RELEASE_DATE) > $(top_srcdir)/RELEASE-DATE) (rm -f $(top_srcdir)/VERSION && echo $(LIBTIFF_VERSION) > $(top_srcdir)/VERSION) - (rm -f $(top_srcdir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),;s,LIBTIFF_MAJOR_VERSION,$(LIBTIFF_MAJOR_VERSION),;s,LIBTIFF_MINOR_VERSION,$(LIBTIFF_MINOR_VERSION),;s,LIBTIFF_MICRO_VERSION,$(LIBTIFF_MICRO_VERSION),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_srcdir)/libtiff/tiffvers.h) + (rm -f $(top_srcdir)/libtiff/tiffvers.h && sed 's,LIBTIFF_VERSION,$(LIBTIFF_VERSION),;s,LIBTIFF_RELEASE_DATE,$(LIBTIFF_RELEASE_DATE),' $(top_srcdir)/libtiff/tiffvers.h.in > $(top_srcdir)/libtiff/tiffvers.h) pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libtiff-4.pc diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/SymbolChecks.cmake b/thirdparty/SDL2_image/external/libtiff/Makefile.vc similarity index 61% rename from thirdparty/SDL2_image/external/libtiff/cmake/SymbolChecks.cmake rename to thirdparty/SDL2_image/external/libtiff/Makefile.vc index 210748ed9..eeb5d04d2 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/SymbolChecks.cmake +++ b/thirdparty/SDL2_image/external/libtiff/Makefile.vc @@ -1,43 +1,60 @@ -# Checks for symbols # -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh +# Copyright (C) 2004, Andrey Kiselev # -# Permission to use, copy, modify, distribute, and sell this software and +# Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +# +# Makefile for MS Visual C and Watcom C compilers. +# Edit nmake.opt file if you want to ajust building options. +# +# To build: +# C:\libtiff> nmake /f makefile.vc +!INCLUDE nmake.opt -include(CheckSymbolExists) +all: port lib tools +port:: + cd libtiff + $(MAKE) /f Makefile.vc tif_config.h + cd.. + cd port + $(MAKE) /f Makefile.vc + cd.. -# Check for getopt -check_symbol_exists(getopt "unistd.h;stdio.h" HAVE_GETOPT) -check_symbol_exists(optarg "getopt.h" HAVE_DECL_OPTARG) -if (HAVE_DECL_OPTARG) - set(HAVE_DECL_OPTARG 1) -else() - set(HAVE_DECL_OPTARG 0) -endif() +lib: port + cd libtiff + $(MAKE) /f Makefile.vc + cd.. -# Check for mmap -check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP) +tools: lib + cd tools + $(MAKE) /f Makefile.vc + cd .. -# Check for setmode -check_symbol_exists(setmode "unistd.h" HAVE_SETMODE) +clean: + cd port + $(MAKE) /f Makefile.vc clean + cd.. + cd libtiff + $(MAKE) /f Makefile.vc clean + cd.. + cd tools + $(MAKE) /f Makefile.vc clean + cd .. diff --git a/thirdparty/SDL2_image/external/libtiff/RELEASE-DATE b/thirdparty/SDL2_image/external/libtiff/RELEASE-DATE index a4ca097fc..1137155e7 100644 --- a/thirdparty/SDL2_image/external/libtiff/RELEASE-DATE +++ b/thirdparty/SDL2_image/external/libtiff/RELEASE-DATE @@ -1 +1 @@ -20230609 +20201219 diff --git a/thirdparty/SDL2_image/external/libtiff/SConstruct b/thirdparty/SDL2_image/external/libtiff/SConstruct new file mode 100644 index 000000000..ee87fedf5 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/SConstruct @@ -0,0 +1,169 @@ +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2005, Andrey Kiselev +# +# 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 os + +env = Environment() + +# Read the user supplied options +opts = Options('libtiff.conf') +opts.Add(PathOption('PREFIX', \ + 'install architecture-independent files in this directory', \ + '/usr/local', PathOption.PathIsDirCreate)) +opts.Add(BoolOption('ccitt', \ + 'enable support for CCITT Group 3 & 4 algorithms', \ + 'yes')) +opts.Add(BoolOption('packbits', \ + 'enable support for Macintosh PackBits algorithm', \ + 'yes')) +opts.Add(BoolOption('lzw', \ + 'enable support for LZW algorithm', \ + 'yes')) +opts.Add(BoolOption('thunder', \ + 'enable support for ThunderScan 4-bit RLE algorithm', \ + 'yes')) +opts.Add(BoolOption('next', \ + 'enable support for NeXT 2-bit RLE algorithm', \ + 'yes')) +opts.Add(BoolOption('logluv', \ + 'enable support for LogLuv high dynamic range encoding', \ + 'yes')) +opts.Add(BoolOption('strip_chopping', \ + 'support for strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of ~8Kb to reduce memory usage)', \ + 'yes')) +opts.Add(BoolOption('extrasample_as_alpha', \ + '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', \ + 'yes')) +opts.Add(BoolOption('check_ycbcr_subsampling', \ + 'disable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag', \ + 'yes')) +opts.Update(env) +opts.Save('libtiff.conf', env) +Help(opts.GenerateHelpText(env)) + +# Here are our installation paths: +idir_prefix = '$PREFIX' +idir_lib = '$PREFIX/lib' +idir_bin = '$PREFIX/bin' +idir_inc = '$PREFIX/include' +idir_doc = '$PREFIX/doc' +Export([ 'env', 'idir_prefix', 'idir_lib', 'idir_bin', 'idir_inc', 'idir_doc' ]) + +# Now proceed to system feature checks +target_cpu, target_vendor, target_kernel, target_os = \ + os.popen("./config/config.guess").readlines()[0].split("-") + +def Define(context, key, have): + import SCons.Conftest + SCons.Conftest._Have(context, key, have) + +def CheckCustomOption(context, name): + context.Message('Checking is the ' + name + ' option set... ') + ret = env[name] + Define(context, name + '_SUPPORT', ret) + context.Result(ret) + return ret + +def CheckFillorderOption(context): + context.Message('Checking for the native cpu bit order... ') + if target_cpu[0] == 'i' and target_cpu[2:] == '86': + Define(context, 'HOST_FILLORDER', 'FILLORDER_LSB2MSB') + context.Result('lsb2msb') + else: + Define(context, 'HOST_FILLORDER', 'FILLORDER_MSB2LSB') + context.Result('msb2lsb') + return 1 + +def CheckIEEEFPOption(context): + context.Message('Checking for the IEEE floating point format... ') + Define(context, 'HAVE_IEEEFP', 1) + context.Result(1) + return 1 + +def CheckOtherOption(context, name): + context.Message('Checking is the ' + name + ' option set... ') + ret = env[name] + Define(context, 'HAVE_' + name, ret) + context.Result(ret) + return ret + +custom_tests = { \ + 'CheckCustomOption' : CheckCustomOption, \ + 'CheckFillorderOption' : CheckFillorderOption, \ + 'CheckIEEEFPOption' : CheckIEEEFPOption, \ + 'CheckOtherOption' : CheckOtherOption \ + } +conf = Configure(env, custom_tests = custom_tests, \ + config_h = 'libtiff/tif_config.h') + +# Check for standard library +conf.CheckLib('c') +if target_os != 'cygwin' \ + and target_os != 'mingw32' \ + and target_os != 'beos' \ + and target_os != 'darwin': + conf.CheckLib('m') + +# Check for system headers +conf.CheckCHeader('assert.h') +conf.CheckCHeader('fcntl.h') +conf.CheckCHeader('io.h') +conf.CheckCHeader('limits.h') +conf.CheckCHeader('malloc.h') +conf.CheckCHeader('search.h') +conf.CheckCHeader('sys/time.h') +conf.CheckCHeader('unistd.h') + +# Check for standard library functions +conf.CheckFunc('floor') +conf.CheckFunc('isascii') +conf.CheckFunc('memmove') +conf.CheckFunc('memset') +conf.CheckFunc('mmap') +conf.CheckFunc('pow') +conf.CheckFunc('setmode') +conf.CheckFunc('sqrt') +conf.CheckFunc('strchr') +conf.CheckFunc('strrchr') +conf.CheckFunc('strstr') +conf.CheckFunc('strtol') + +conf.CheckFillorderOption() +conf.CheckIEEEFPOption() +conf.CheckCustomOption('ccitt') +conf.CheckCustomOption('packbits') +conf.CheckCustomOption('lzw') +conf.CheckCustomOption('thunder') +conf.CheckCustomOption('next') +conf.CheckCustomOption('logluv') +conf.CheckOtherOption('strip_chopping') +conf.CheckOtherOption('extrasample_as_alpha') +conf.CheckOtherOption('check_ycbcr_subsampling') + +env = conf.Finish() + +# Ok, now go to build files in the subdirectories +SConscript(dirs = [ 'libtiff' ], name = 'SConstruct') diff --git a/thirdparty/SDL2_image/external/libtiff/VERSION b/thirdparty/SDL2_image/external/libtiff/VERSION index 4404a17ba..6aba2b245 100644 --- a/thirdparty/SDL2_image/external/libtiff/VERSION +++ b/thirdparty/SDL2_image/external/libtiff/VERSION @@ -1 +1 @@ -4.5.1 +4.2.0 diff --git a/thirdparty/SDL2_image/external/libtiff/archive/tools/bmp2tiff.c b/thirdparty/SDL2_image/external/libtiff/archive/tools/bmp2tiff.c index 5816ea5d2..d541e2037 100644 --- a/thirdparty/SDL2_image/external/libtiff/archive/tools/bmp2tiff.c +++ b/thirdparty/SDL2_image/external/libtiff/archive/tools/bmp2tiff.c @@ -6,69 +6,69 @@ ****************************************************************************** * Copyright (c) 2004, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include "tif_config.h" -#include -#include #include #include #include -#include +#include +#include #include +#include #ifdef HAVE_UNISTD_H -#include +# include #endif #if HAVE_FCNTL_H -#include +# include #endif #if HAVE_SYS_TYPES_H -#include +# include #endif #if HAVE_IO_H -#include +# include #endif #ifdef NEED_LIBPORT -#include "libport.h" +# include "libport.h" #endif -#include "tiffio.h" #include "tiffiop.h" +#include "tiffio.h" #ifndef O_BINARY -#define O_BINARY 0 +# define O_BINARY 0 #endif enum BMPType { - BMPT_WIN4, /* BMP used in Windows 3.0/NT 3.51/95 */ - BMPT_WIN5, /* BMP used in Windows NT 4.0/98/Me/2000/XP */ - BMPT_OS21, /* BMP used in OS/2 PM 1.x */ - BMPT_OS22 /* BMP used in OS/2 PM 2.x */ + BMPT_WIN4, /* BMP used in Windows 3.0/NT 3.51/95 */ + BMPT_WIN5, /* BMP used in Windows NT 4.0/98/Me/2000/XP */ + BMPT_OS21, /* BMP used in OS/2 PM 1.x */ + BMPT_OS22 /* BMP used in OS/2 PM 2.x */ }; /* @@ -76,7 +76,7 @@ enum BMPType * BMPInfoHeader structure. An array of BMPColorEntry structures (also called * a colour table) follows the bitmap information header structure. The colour * table is followed by a second array of indexes into the colour table (the - * actual bitmap data). Data may be compressed, for 4-bpp and 8-bpp used RLE + * actual bitmap data). Data may be comressed, for 4-bpp and 8-bpp used RLE * compression. * * +---------------------+ @@ -94,115 +94,115 @@ enum BMPType enum BMPComprMethod { - BMPC_RGB = 0L, /* Uncompressed */ - BMPC_RLE8 = 1L, /* RLE for 8 bpp images */ - BMPC_RLE4 = 2L, /* RLE for 4 bpp images */ - BMPC_BITFIELDS = 3L, /* Bitmap is not compressed and the colour table - * consists of three DWORD color masks that specify - * the red, green, and blue components of each - * pixel. This is valid when used with - * 16- and 32-bpp bitmaps. */ - BMPC_JPEG = 4L, /* Indicates that the image is a JPEG image. */ - BMPC_PNG = 5L /* Indicates that the image is a PNG image. */ + BMPC_RGB = 0L, /* Uncompressed */ + BMPC_RLE8 = 1L, /* RLE for 8 bpp images */ + BMPC_RLE4 = 2L, /* RLE for 4 bpp images */ + BMPC_BITFIELDS = 3L, /* Bitmap is not compressed and the colour table + * consists of three DWORD color masks that specify + * the red, green, and blue components of each + * pixel. This is valid when used with + * 16- and 32-bpp bitmaps. */ + BMPC_JPEG = 4L, /* Indicates that the image is a JPEG image. */ + BMPC_PNG = 5L /* Indicates that the image is a PNG image. */ }; -enum BMPLCSType /* Type of logical color space. */ +enum BMPLCSType /* Type of logical color space. */ { - BMPLT_CALIBRATED_RGB = 0, /* This value indicates that endpoints and - * gamma values are given in the appropriate - * fields. */ + BMPLT_CALIBRATED_RGB = 0, /* This value indicates that endpoints and + * gamma values are given in the appropriate + * fields. */ BMPLT_DEVICE_RGB = 1, BMPLT_DEVICE_CMYK = 2 }; typedef struct { - int32_t iCIEX; - int32_t iCIEY; - int32_t iCIEZ; + int32 iCIEX; + int32 iCIEY; + int32 iCIEZ; } BMPCIEXYZ; -typedef struct /* This structure contains the x, y, and z */ -{ /* coordinates of the three colors that */ - /* correspond */ - BMPCIEXYZ iCIERed; /* to the red, green, and blue endpoints for */ - BMPCIEXYZ iCIEGreen; /* a specified logical color space. */ - BMPCIEXYZ iCIEBlue; +typedef struct /* This structure contains the x, y, and z */ +{ /* coordinates of the three colors that */ + /* correspond */ + BMPCIEXYZ iCIERed; /* to the red, green, and blue endpoints for */ + BMPCIEXYZ iCIEGreen; /* a specified logical color space. */ + BMPCIEXYZ iCIEBlue; } BMPCIEXYZTriple; typedef struct { - char bType[2]; /* Signature "BM" */ - uint32_t iSize; /* Size in bytes of the bitmap file. Should - * always be ignored while reading because - * of error in Windows 3.0 SDK's description - * of this field */ - uint16_t iReserved1; /* Reserved, set as 0 */ - uint16_t iReserved2; /* Reserved, set as 0 */ - uint32_t iOffBits; /* Offset of the image from file start in bytes */ + char bType[2]; /* Signature "BM" */ + uint32 iSize; /* Size in bytes of the bitmap file. Should + * always be ignored while reading because + * of error in Windows 3.0 SDK's description + * of this field */ + uint16 iReserved1; /* Reserved, set as 0 */ + uint16 iReserved2; /* Reserved, set as 0 */ + uint32 iOffBits; /* Offset of the image from file start in bytes */ } BMPFileHeader; /* File header size in bytes: */ -const int BFH_SIZE = 14; +const int BFH_SIZE = 14; typedef struct { - uint32_t iSize; /* Size of BMPInfoHeader structure in bytes. - * Should be used to determine start of the - * colour table */ - int32_t iWidth; /* Image width */ - int32_t iHeight; /* Image height. If positive, image has bottom - * left origin, if negative --- top left. */ - int16_t iPlanes; /* Number of image planes (must be set to 1) */ - int16_t iBitCount; /* Number of bits per pixel (1, 4, 8, 16, 24 - * or 32). If 0 then the number of bits per - * pixel is specified or is implied by the - * JPEG or PNG format. */ - uint32_t iCompression; /* Compression method */ - uint32_t iSizeImage; /* Size of uncomressed image in bytes. May - * be 0 for BMPC_RGB bitmaps. If iCompression - * is BI_JPEG or BI_PNG, iSizeImage indicates - * the size of the JPEG or PNG image buffer. */ - int32_t iXPelsPerMeter; /* X resolution, pixels per meter (0 if not used) */ - int32_t iYPelsPerMeter; /* Y resolution, pixels per meter (0 if not used) */ - uint32_t iClrUsed; /* Size of colour table. If 0, iBitCount should - * be used to calculate this value - * (1< 0) ? info_hdr.iHeight : -info_hdr.iHeight; - if (width <= 0 || length <= 0) - { - TIFFError(infilename, "Invalid dimensions of BMP file"); - close(fd); - return -1; - } - - switch (info_hdr.iBitCount) - { - case 1: - case 4: - case 8: - nbands = 1; - depth = info_hdr.iBitCount; - photometric = PHOTOMETRIC_PALETTE; - /* Allocate memory for colour table and read it. */ - if (info_hdr.iClrUsed) - clr_tbl_size = ((uint32_t)(1 << depth) < info_hdr.iClrUsed) - ? (uint32_t)(1 << depth) - : info_hdr.iClrUsed; - else - clr_tbl_size = 1 << depth; - clr_tbl = - (unsigned char *)_TIFFmalloc(n_clr_elems * clr_tbl_size); - if (!clr_tbl) - { - TIFFError(infilename, - "Can't allocate space for color table"); - goto bad; - } - - if (_TIFF_lseek_f(fd, BFH_SIZE + info_hdr.iSize, SEEK_SET) == - (_TIFF_off_t)-1) - { - TIFFError(infilename, "Failed to seek to offset"); - goto bad; - } - if (read(fd, clr_tbl, n_clr_elems * clr_tbl_size) != - (long)(n_clr_elems * clr_tbl_size)) - { - TIFFError(infilename, "Failed to read from file (%s)", - strerror(errno)); - goto bad; - } - - red_tbl = (unsigned short *)_TIFFmalloc( - ((tmsize_t)1) << depth * sizeof(unsigned short)); - if (!red_tbl) - { - TIFFError(infilename, - "Can't allocate space for red component table"); - _TIFFfree(clr_tbl); - goto bad1; - } - green_tbl = (unsigned short *)_TIFFmalloc( - ((tmsize_t)1) << depth * sizeof(unsigned short)); - if (!green_tbl) - { - TIFFError(infilename, - "Can't allocate space for green component table"); - _TIFFfree(clr_tbl); - goto bad2; - } - blue_tbl = (unsigned short *)_TIFFmalloc( - ((tmsize_t)1) << depth * sizeof(unsigned short)); - if (!blue_tbl) - { - TIFFError(infilename, - "Can't allocate space for blue component table"); - _TIFFfree(clr_tbl); - goto bad3; - } - - for (clr = 0; clr < clr_tbl_size; clr++) - { - red_tbl[clr] = 257 * clr_tbl[clr * n_clr_elems + 2]; - green_tbl[clr] = 257 * clr_tbl[clr * n_clr_elems + 1]; - blue_tbl[clr] = 257 * clr_tbl[clr * n_clr_elems]; - } - - _TIFFfree(clr_tbl); - break; - case 16: - case 24: - nbands = 3; - depth = info_hdr.iBitCount / nbands; - photometric = PHOTOMETRIC_RGB; - break; - case 32: - nbands = 3; - depth = 8; - photometric = PHOTOMETRIC_RGB; - break; - default: - break; - } - - /* -------------------------------------------------------------------- - */ - /* Create output file. */ - /* -------------------------------------------------------------------- - */ - - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, length); - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, nbands); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, depth); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, - TIFFDefaultStripSize(out, rowsperstrip)); - - if (red_tbl && green_tbl && blue_tbl) - { - TIFFSetField(out, TIFFTAG_COLORMAP, red_tbl, green_tbl, blue_tbl); - } - - if (compression == (uint16_t)-1) - compression = COMPRESSION_PACKBITS; - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - switch (compression) - { - case COMPRESSION_JPEG: - if (photometric == PHOTOMETRIC_RGB && - jpegcolormode == JPEGCOLORMODE_RGB) - photometric = PHOTOMETRIC_YCBCR; - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != 0) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - break; - } - - /* -------------------------------------------------------------------- - */ - /* Read uncompressed image data. */ - /* -------------------------------------------------------------------- - */ - - if (info_hdr.iCompression == BMPC_RGB) - { - uint32_t offset, size; - char *scanbuf; - - /* XXX: Avoid integer overflow. We can calculate size - * in one step using - * - * size = ((width * info_hdr.iBitCount + 31) & ~31) / 8 - * - * formulae, but we should check for overflow - * conditions during calculation. - */ - size = width * info_hdr.iBitCount + 31; - if (!width || !info_hdr.iBitCount || - (size - 31) / info_hdr.iBitCount != width) - { - TIFFError(infilename, "Wrong image parameters; can't " - "allocate space for scanline buffer"); - goto bad3; - } - size = (size & ~31) / 8; - - scanbuf = (char *)_TIFFmalloc(size); - if (!scanbuf) - { - TIFFError(infilename, - "Can't allocate space for scanline buffer"); - goto bad3; - } - - for (row = 0; row < length; row++) - { - if (info_hdr.iHeight > 0) - offset = file_hdr.iOffBits + (length - row - 1) * size; - else - offset = file_hdr.iOffBits + row * size; - if (_TIFF_lseek_f(fd, offset, SEEK_SET) == (_TIFF_off_t)-1) - { - TIFFError(infilename, "scanline %lu: Seek error", - (unsigned long)row); - break; - } - - if (read(fd, scanbuf, size) != (long)size) - { - TIFFError(infilename, "scanline %lu: Read error", - (unsigned long)row); - break; - } - - rearrangePixels(scanbuf, width, info_hdr.iBitCount); - - if (TIFFWriteScanline(out, scanbuf, row, 0) < 0) - { - TIFFError(infilename, "scanline %lu: Write error", - (unsigned long)row); - break; - } - } - - _TIFFfree(scanbuf); - - /* -------------------------------------------------------------------- - */ - /* Read compressed image data. */ - /* -------------------------------------------------------------------- - */ - } - else if (info_hdr.iCompression == BMPC_RLE8 || - info_hdr.iCompression == BMPC_RLE4) - { - uint32_t i, j, k, runlength; - uint32_t compr_size, uncompr_size; - unsigned char *comprbuf; - unsigned char *uncomprbuf; - - compr_size = file_hdr.iSize - file_hdr.iOffBits; - uncompr_size = width * length; - /* Detect int overflow */ - if (uncompr_size / width != length) - { - TIFFError(infilename, "Invalid dimensions of BMP file"); - close(fd); - return -1; - } - if ((compr_size == 0) || (compr_size > ((uint32_t)~0) >> 1) || - (uncompr_size == 0) || (uncompr_size > ((uint32_t)~0) >> 1)) - { - TIFFError(infilename, "Invalid dimensions of BMP file"); - close(fd); - return -1; - } - comprbuf = (unsigned char *)_TIFFmalloc(compr_size); - if (!comprbuf) - { - TIFFError( - infilename, - "Can't allocate space for compressed scanline buffer"); - goto bad3; - } - uncomprbuf = (unsigned char *)_TIFFmalloc(uncompr_size); - if (!uncomprbuf) - { - TIFFError( - infilename, - "Can't allocate space for uncompressed scanline buffer"); - goto bad3; - } - - if (_TIFF_lseek_f(fd, file_hdr.iOffBits, SEEK_SET) == - (_TIFF_off_t)-1) - { - TIFFError(infilename, "Failed to seek to offset"); - goto bad3; - } - if (read(fd, comprbuf, compr_size) != (long)compr_size) - { - TIFFError(infilename, "Failed to read from file (%s)", - strerror(errno)); - goto bad; - } - i = 0; - j = 0; - if (info_hdr.iBitCount == 8) - { /* RLE8 */ - while (j < uncompr_size && i < compr_size) - { - if (comprbuf[i]) - { - runlength = comprbuf[i++]; - while (runlength > 0 && j < uncompr_size && - i < compr_size) + width = info_hdr.iWidth; + length = (info_hdr.iHeight > 0) ? info_hdr.iHeight : -info_hdr.iHeight; + if( width <= 0 || length <= 0 ) { - uncomprbuf[j++] = comprbuf[i]; - runlength--; + TIFFError(infilename, + "Invalid dimensions of BMP file" ); + close(fd); + return -1; } - i++; - } - else - { - i++; - if (comprbuf[i] == 0) /* Next scanline */ - i++; - else if (comprbuf[i] == 1) /* End of image */ - break; - else if (comprbuf[i] == 2) - { /* Move to... */ - i++; - if (i < compr_size - 1) - { - j += comprbuf[i] + comprbuf[i + 1] * width; - i += 2; - } - else - break; - } - else - { /* Absolute mode */ - runlength = comprbuf[i++]; - for (k = 0; k < runlength && j < uncompr_size && - i < compr_size; - k++) - uncomprbuf[j++] = comprbuf[i++]; - if (k & 0x01) - i++; - } - } - } - } - else - { /* RLE4 */ - while (j < uncompr_size && i < compr_size) - { - if (comprbuf[i]) - { - runlength = comprbuf[i++]; - while (runlength > 0 && j < uncompr_size && - i < compr_size) + + switch (info_hdr.iBitCount) { - if (runlength & 0x01) - uncomprbuf[j++] = (comprbuf[i] & 0xF0) >> 4; - else - uncomprbuf[j++] = comprbuf[i] & 0x0F; - runlength--; + case 1: + case 4: + case 8: + nbands = 1; + depth = info_hdr.iBitCount; + photometric = PHOTOMETRIC_PALETTE; + /* Allocate memory for colour table and read it. */ + if (info_hdr.iClrUsed) + clr_tbl_size = + ((uint32)(1< 0) + offset = file_hdr.iOffBits+(length-row-1)*size; + else + offset = file_hdr.iOffBits + row * size; + if (_TIFF_lseek_f(fd, offset, SEEK_SET) == (_TIFF_off_t)-1) { + TIFFError(infilename, + "scanline %lu: Seek error", + (unsigned long) row); + break; + } + + if (read(fd, scanbuf, size) != (long) size) { + TIFFError(infilename, + "scanline %lu: Read error", + (unsigned long) row); + break; + } + + rearrangePixels(scanbuf, width, info_hdr.iBitCount); + + if (TIFFWriteScanline(out, scanbuf, row, 0)<0) { + TIFFError(infilename, + "scanline %lu: Write error", + (unsigned long) row); + break; + } + } + + _TIFFfree(scanbuf); + + /* -------------------------------------------------------------------- */ + /* Read compressed image data. */ + /* -------------------------------------------------------------------- */ + + } else if ( info_hdr.iCompression == BMPC_RLE8 + || info_hdr.iCompression == BMPC_RLE4 ) { + uint32 i, j, k, runlength; + uint32 compr_size, uncompr_size; + unsigned char *comprbuf; + unsigned char *uncomprbuf; + + compr_size = file_hdr.iSize - file_hdr.iOffBits; + uncompr_size = width * length; + /* Detect int overflow */ + if( uncompr_size / width != length ) { + TIFFError(infilename, + "Invalid dimensions of BMP file" ); + close(fd); + return -1; } - else - { /* Absolute mode */ - runlength = comprbuf[i++]; - for (k = 0; k < runlength && j < uncompr_size && - i < compr_size; - k++) - { - if (k & 0x01) - uncomprbuf[j++] = comprbuf[i++] & 0x0F; - else - uncomprbuf[j++] = (comprbuf[i] & 0xF0) >> 4; - } - if (k & 0x01) - i++; + if ( (compr_size == 0) || + (compr_size > ((uint32) ~0) >> 1) || + (uncompr_size == 0) || + (uncompr_size > ((uint32) ~0) >> 1) ) { + TIFFError(infilename, + "Invalid dimensions of BMP file" ); + close(fd); + return -1; } - } - } - } + comprbuf = (unsigned char *) _TIFFmalloc( compr_size ); + if (!comprbuf) { + TIFFError(infilename, + "Can't allocate space for compressed scanline buffer"); + goto bad3; + } + uncomprbuf = (unsigned char *)_TIFFmalloc(uncompr_size); + if (!uncomprbuf) { + TIFFError(infilename, + "Can't allocate space for uncompressed scanline buffer"); + goto bad3; + } - _TIFFfree(comprbuf); + if (_TIFF_lseek_f(fd, file_hdr.iOffBits, SEEK_SET) == (_TIFF_off_t)-1) { + TIFFError(infilename, "Failed to seek to offset"); + goto bad3; + } + if ( read(fd, comprbuf, compr_size) != (long) compr_size ) { + TIFFError(infilename, "Failed to read from file (%s)", + strerror(errno)); + goto bad; + } + i = 0; + j = 0; + if (info_hdr.iBitCount == 8) { /* RLE8 */ + while(j < uncompr_size && i < compr_size) { + if ( comprbuf[i] ) { + runlength = comprbuf[i++]; + while( runlength > 0 + && j < uncompr_size + && i < compr_size ) { + uncomprbuf[j++] = comprbuf[i]; + runlength--; + } + i++; + } else { + i++; + if (comprbuf[i] == 0) /* Next scanline */ + i++; + else if (comprbuf[i] == 1) /* End of image */ + break; + else if (comprbuf[i] == 2) { /* Move to... */ + i++; + if (i < compr_size - 1) { + j+=comprbuf[i]+comprbuf[i+1]*width; + i += 2; + } + else + break; + } else { /* Absolute mode */ + runlength = comprbuf[i++]; + for (k = 0; k < runlength && j < uncompr_size && i < compr_size; k++) + uncomprbuf[j++] = comprbuf[i++]; + if ( k & 0x01 ) + i++; + } + } + } + } + else { /* RLE4 */ + while( j < uncompr_size && i < compr_size ) { + if ( comprbuf[i] ) { + runlength = comprbuf[i++]; + while( runlength > 0 && j < uncompr_size && i < compr_size ) { + if ( runlength & 0x01 ) + uncomprbuf[j++] = (comprbuf[i] & 0xF0) >> 4; + else + uncomprbuf[j++] = comprbuf[i] & 0x0F; + runlength--; + } + i++; + } else { + i++; + if (comprbuf[i] == 0) /* Next scanline */ + i++; + else if (comprbuf[i] == 1) /* End of image */ + break; + else if (comprbuf[i] == 2) { /* Move to... */ + i++; + if (i < compr_size - 1) { + j+=comprbuf[i]+comprbuf[i+1]*width; + i += 2; + } + else + break; + } else { /* Absolute mode */ + runlength = comprbuf[i++]; + for (k = 0; k < runlength && j < uncompr_size && i < compr_size; k++) { + if (k & 0x01) + uncomprbuf[j++] = comprbuf[i++] & 0x0F; + else + uncomprbuf[j++] = (comprbuf[i] & 0xF0) >> 4; + } + if (k & 0x01) + i++; + } + } + } + } - for (row = 0; row < length; row++) - { - if (TIFFWriteScanline(out, - uncomprbuf + (length - row - 1) * width, - row, 0) < 0) - { - TIFFError(infilename, "scanline %lu: Write error.\n", - (unsigned long)row); - } - } + _TIFFfree(comprbuf); - _TIFFfree(uncomprbuf); - } - TIFFWriteDirectory(out); - if (blue_tbl) - { - _TIFFfree(blue_tbl); - blue_tbl = NULL; - } - if (green_tbl) - { - _TIFFfree(green_tbl); - green_tbl = NULL; - } - if (red_tbl) - { - _TIFFfree(red_tbl); - red_tbl = NULL; - } - } + for (row = 0; row < length; row++) { + if (TIFFWriteScanline(out, + uncomprbuf + (length - row - 1) * width, + row, 0) < 0) { + TIFFError(infilename, + "scanline %lu: Write error.\n", + (unsigned long) row); + } + } -bad3: - if (blue_tbl) - _TIFFfree(blue_tbl); -bad2: - if (green_tbl) - _TIFFfree(green_tbl); -bad1: - if (red_tbl) - _TIFFfree(red_tbl); -bad: - close(fd); + _TIFFfree(uncomprbuf); + } + TIFFWriteDirectory(out); + if (blue_tbl) { + _TIFFfree(blue_tbl); + blue_tbl=NULL; + } + if (green_tbl) { + _TIFFfree(green_tbl); + green_tbl=NULL; + } + if (red_tbl) { + _TIFFfree(red_tbl); + red_tbl=NULL; + } + } - if (out) - TIFFClose(out); - return 0; + bad3: + if (blue_tbl) + _TIFFfree(blue_tbl); + bad2: + if (green_tbl) + _TIFFfree(green_tbl); + bad1: + if (red_tbl) + _TIFFfree(red_tbl); + bad: + close(fd); + + if (out) + TIFFClose(out); + return 0; } /* * Image data in BMP file stored in BGR (or ABGR) format. We should rearrange * pixels to RGB (RGBA) format. */ -static void rearrangePixels(char *buf, uint32_t width, uint32_t bit_count) +static void +rearrangePixels(char *buf, uint32 width, uint32 bit_count) { - char tmp; - uint32_t i; + char tmp; + uint32 i; - switch (bit_count) - { - case 16: /* FIXME: need a sample file */ - break; - case 24: - for (i = 0; i < width; i++, buf += 3) - { - tmp = *buf; - *buf = *(buf + 2); - *(buf + 2) = tmp; - } - break; - case 32: - { - char *buf1 = buf; + switch(bit_count) { + case 16: /* FIXME: need a sample file */ + break; + case 24: + for (i = 0; i < width; i++, buf += 3) { + tmp = *buf; + *buf = *(buf + 2); + *(buf + 2) = tmp; + } + break; + case 32: + { + char *buf1 = buf; - for (i = 0; i < width; i++, buf += 4) - { - tmp = *buf; - *buf1++ = *(buf + 2); - *buf1++ = *(buf + 1); - *buf1++ = tmp; - } + for (i = 0; i < width; i++, buf += 4) { + tmp = *buf; + *buf1++ = *(buf + 2); + *buf1++ = *(buf + 1); + *buf1++ = tmp; + } + } + break; + default: + break; } - break; - default: - break; - } } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) { - if (strcmp(opt, "none") == 0) - compression = COMPRESSION_NONE; - else if (strcmp(opt, "packbits") == 0) - compression = COMPRESSION_PACKBITS; - else if (strncmp(opt, "jpeg", 4) == 0) - { - char *cp = strchr(opt, ':'); + if (strcmp(opt, "none") == 0) + compression = COMPRESSION_NONE; + else if (strcmp(opt, "packbits") == 0) + compression = COMPRESSION_PACKBITS; + else if (strncmp(opt, "jpeg", 4) == 0) { + char* cp = strchr(opt, ':'); - compression = COMPRESSION_JPEG; - while (cp) - { - if (isdigit((int)cp[1])) - quality = atoi(cp + 1); - else if (cp[1] == 'r') - jpegcolormode = JPEGCOLORMODE_RAW; - else - usage(); + compression = COMPRESSION_JPEG; + while( cp ) + { + if (isdigit((int)cp[1])) + quality = atoi(cp+1); + else if (cp[1] == 'r' ) + jpegcolormode = JPEGCOLORMODE_RAW; + else + usage(); - cp = strchr(cp + 1, ':'); - } - } - else if (strncmp(opt, "lzw", 3) == 0) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strncmp(opt, "zip", 3) == 0) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + cp = strchr(cp+1,':'); + } + } else if (strncmp(opt, "lzw", 3) == 0) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strncmp(opt, "zip", 3) == 0) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -static char *stuff[] = { - "bmp2tiff --- convert Windows BMP files to TIFF", - "usage: bmp2tiff [options] input.bmp [input2.bmp ...] output.tif", - "where options are:", - " -r # make each strip have no more than # rows", - "", - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", - " -c zip[:opts] compress output with deflate encoding", - " -c jpeg[:opts]compress output with JPEG encoding", - " -c packbits compress output with packbits encoding", - " -c none use no compression algorithm on output", - "", - "JPEG options:", - " # set compression quality level (0-100, default 75)", - " r output color image as RGB rather than YCbCr", - "For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. " - "quality", - "", - "LZW and deflate options:", - " # set predictor value", - "For example, -c lzw:2 to get LZW-encoded data with horizontal " - "differencing", - " -o out.tif write output to out.tif", - " -h this help message", - NULL}; +static char* stuff[] = { +"bmp2tiff --- convert Windows BMP files to TIFF", +"usage: bmp2tiff [options] input.bmp [input2.bmp ...] output.tif", +"where options are:", +" -r # make each strip have no more than # rows", +"", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c jpeg[:opts]compress output with JPEG encoding", +" -c packbits compress output with packbits encoding", +" -c none use no compression algorithm on output", +"", +"JPEG options:", +" # set compression quality level (0-100, default 75)", +" r output color image as RGB rather than YCbCr", +"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", +"", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +" -o out.tif write output to out.tif", +" -h this help message", +NULL +}; -static void usage(void) +static void +usage(void) { - char buf[BUFSIZ]; - int i; + char buf[BUFSIZ]; + int i; - setbuf(stderr, buf); - fprintf(stderr, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(stderr, "%s\n", stuff[i]); - exit(-1); + setbuf(stderr, buf); + fprintf(stderr, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(stderr, "%s\n", stuff[i]); + exit(-1); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/archive/tools/gif2tiff.c b/thirdparty/SDL2_image/external/libtiff/archive/tools/gif2tiff.c index e773d7a51..394d07949 100644 --- a/thirdparty/SDL2_image/external/libtiff/archive/tools/gif2tiff.c +++ b/thirdparty/SDL2_image/external/libtiff/archive/tools/gif2tiff.c @@ -2,30 +2,30 @@ * Copyright (c) 1990-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * convert a GIF file into a TIFF file. * based on Paul Haeberli's fromgif program which in turn is - * based on a GIF file reader by Marcel J.E. Mol March 23 1989 + * based on a GIF file reader by Marcel J.E. Mol March 23 1989 * * if input is 320 by 200 pixel aspect is probably 1.2 * if input is 640 350 pixel aspect is probably 1.37 @@ -33,65 +33,67 @@ */ #include "tif_config.h" -#include -#include #include #include #include +#include +#include #ifdef HAVE_UNISTD_H -#include +# include #endif #ifdef NEED_LIBPORT -#include "libport.h" +# include "libport.h" #endif #include "tiffio.h" -#define GIFGAMMA (1.5) /* smaller makes output img brighter */ -#define IMAX 0xffff /* max intensity value */ -#define EXTRAFUDGE 128 /* some people write BAD .gif files */ +#define GIFGAMMA (1.5) /* smaller makes output img brighter */ +#define IMAX 0xffff /* max intensity value */ +#define EXTRAFUDGE 128 /* some people write BAD .gif files */ -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) unsigned short gamtab[256]; -void makegamtab(float gam) +void +makegamtab(float gam) { int i; - for (i = 0; i < 256; i++) - gamtab[i] = (unsigned short)(IMAX * pow(i / 255.0, gam) + 0.5); + for(i=0; i<256; i++) + gamtab[i] = (unsigned short) (IMAX*pow(i/255.0,gam)+0.5); } -char *stuff[] = { - "usage: gif2tiff [options] input.gif output.tif", - "where options are:", - " -r # make each strip have no more than # rows", - "", - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", - " -c zip[:opts] compress output with deflate encoding", - " -c packbits compress output with packbits encoding", - " -c none use no compression algorithm on output", - "", - "LZW and deflate options:", - " # set predictor value", - "For example, -c lzw:2 to get LZW-encoded data with horizontal " - "differencing", - NULL}; +char* stuff[] = { +"usage: gif2tiff [options] input.gif output.tif", +"where options are:", +" -r # make each strip have no more than # rows", +"", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c packbits compress output with packbits encoding", +" -c none use no compression algorithm on output", +"", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +NULL +}; -static void usage(void) +static void +usage(void) { - char buf[BUFSIZ]; - int i; + char buf[BUFSIZ]; + int i; - setbuf(stderr, buf); - fprintf(stderr, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(stderr, "%s\n", stuff[i]); - exit(-1); + setbuf(stderr, buf); + fprintf(stderr, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(stderr, "%s\n", stuff[i]); + exit(-1); } #define COLSIZE 256 @@ -100,37 +102,38 @@ unsigned char *stackp; unsigned int prefix[4096]; unsigned char suffix[4096]; unsigned char stack[4096]; -int datasize, codesize, codemask; /* Decoder working variables */ -int clear, eoi; /* Special code values */ +int datasize,codesize,codemask; /* Decoder working variables */ +int clear,eoi; /* Special code values */ int avail, oldcode; FILE *infile; -int global; /* Is there a global color map? */ -int globalbits; /* Number of bits of global colors */ -unsigned char globalmap[COLSIZE][3]; /* RGB values for global color map */ -unsigned char *raster; /* Decoded image data */ +int global; /* Is there a global color map? */ +int globalbits; /* Number of bits of global colors */ +unsigned char globalmap[COLSIZE][3];/* RGB values for global color map */ +unsigned char *raster; /* Decoded image data */ unsigned long width, height; unsigned short red[COLSIZE]; unsigned short green[COLSIZE]; unsigned short blue[COLSIZE]; char *filename, *imagename; -static uint16_t compression = COMPRESSION_PACKBITS; -static uint16_t predictor = 0; -static uint32_t rowsperstrip = (uint32_t)-1; -static int processCompressOptions(char *); +static uint16 compression = COMPRESSION_PACKBITS; +static uint16 predictor = 0; +static uint32 rowsperstrip = (uint32) -1; +static int processCompressOptions(char*); -int convert(void); -int checksignature(void); -int readscreen(void); -int readgifimage(char *); -int readextension(void); -int readraster(void); -int process(int, unsigned char **); -void initcolors(unsigned char[COLSIZE][3], int); -void rasterize(int, char *); +int convert(void); +int checksignature(void); +int readscreen(void); +int readgifimage(char*); +int readextension(void); +int readraster(void); +int process(int, unsigned char**); +void initcolors(unsigned char [COLSIZE][3], int); +void rasterize(int, char*); -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { #if !HAVE_DECL_OPTARG extern int optind; @@ -140,119 +143,105 @@ int main(int argc, char *argv[]) int c, status; while ((c = getopt(argc, argv, "c:r:")) != -1) - switch (c) - { - case 'c': /* compression scheme */ - if (!processCompressOptions(optarg)) - usage(); - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case '?': - usage(); - /*NOTREACHED*/ - } + switch (c) { + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(); + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case '?': + usage(); + /*NOTREACHED*/ + } if (argc - optind != 2) - usage(); + usage(); makegamtab(GIFGAMMA); filename = argv[optind]; - imagename = argv[optind + 1]; - if ((infile = fopen(imagename, "rb")) != NULL) - { - int c; - fclose(infile); - printf("overwrite %s? ", imagename); - fflush(stdout); - c = getc(stdin); - if (c != 'y' && c != 'Y') - return (1); + imagename = argv[optind+1]; + if ((infile = fopen(imagename, "rb")) != NULL) { + int c; + fclose(infile); + printf("overwrite %s? ", imagename); fflush(stdout); + c = getc(stdin); + if (c != 'y' && c != 'Y') + return (1); } - if ((infile = fopen(filename, "rb")) == NULL) - { - perror(filename); - return (1); + if ((infile = fopen(filename, "rb")) == NULL) { + perror(filename); + return (1); } status = convert(); fclose(infile); return (status); } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) { - if (streq(opt, "none")) - compression = COMPRESSION_NONE; - else if (streq(opt, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (strneq(opt, "lzw", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + if (streq(opt, "none")) + compression = COMPRESSION_NONE; + else if (streq(opt, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (strneq(opt, "lzw", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strneq(opt, "zip", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -int convert(void) +int +convert(void) { int ch; - char *mode = "w"; + char* mode = "w"; if (!checksignature()) return (-1); if (!readscreen()) return (-1); - while ((ch = getc(infile)) != ';' && ch != EOF) - { - switch (ch) - { - case '\0': - break; /* this kludge for non-standard files */ - case ',': - if (!readgifimage(mode)) - return (-1); - mode = "a"; /* subsequent images append */ - break; - case '!': - if (!readextension()) - return (-1); - break; - default: - fprintf(stderr, "illegal GIF block type\n"); - return (-1); + while ((ch = getc(infile)) != ';' && ch != EOF) { + switch (ch) { + case '\0': break; /* this kludge for non-standard files */ + case ',': if (!readgifimage(mode)) + return (-1); + mode = "a"; /* subsequent images append */ + break; + case '!': if (!readextension()) + return (-1); + break; + default: fprintf(stderr, "illegal GIF block type\n"); + return (-1); } } return (0); } -int checksignature(void) +int +checksignature(void) { char buf[6]; - if (fread(buf, 1, 6, infile) != 6) - { - fprintf(stderr, "short read from file %s (%s)\n", filename, - strerror(errno)); + if (fread(buf,1,6,infile) != 6) { + fprintf(stderr, "short read from file %s (%s)\n", + filename, strerror(errno)); return 0; } - if (strncmp(buf, "GIF", 3)) - { + if (strncmp(buf,"GIF",3)) { fprintf(stderr, "file is not a GIF file\n"); return 0; } - if (strncmp(&buf[3], "87a", 3)) - { + if (strncmp(&buf[3],"87a",3)) { fprintf(stderr, "unknown GIF version number\n"); return 0; } @@ -260,36 +249,35 @@ int checksignature(void) } /* - * readscreen - - * Get information which is global to all the images stored + * readscreen - + * Get information which is global to all the images stored * in the file */ -int readscreen(void) +int +readscreen(void) { unsigned char buf[7]; - if (fread(buf, 1, 7, infile) != 7) - { - fprintf(stderr, "short read from file %s (%s)\n", filename, - strerror(errno)); + if (fread(buf,1,7,infile) != 7) { + fprintf(stderr, "short read from file %s (%s)\n", + filename, strerror(errno)); return 0; } global = buf[4] & 0x80; - if (global) - { + if (global) { globalbits = (buf[4] & 0x07) + 1; - if (fread(globalmap, 3, ((size_t)1) << globalbits, infile) != - ((size_t)1) << globalbits) - { - fprintf(stderr, "short read from file %s (%s)\n", filename, - strerror(errno)); + if (fread(globalmap,3,((size_t)1)< 2000000000UL / height)) - { + if (width == 0UL || height == 0UL || (width > 2000000000UL / height)) { fprintf(stderr, "Invalid value of width or height\n"); - return (0); + return(0); } - if (local == 0 && global == 0) - { + if (local == 0 && global == 0) { fprintf(stderr, "no colormap present for image\n"); return (0); } - raster_size = width * height; - if ((raster_size / width) == height) - { - raster_size += EXTRAFUDGE; /* Add elbow room */ + raster_size=width*height; + if ((raster_size/width) == height) { + raster_size += EXTRAFUDGE; /* Add elbow room */ + } else { + raster_size=0; } - else - { - raster_size = 0; - } - if ((raster = (unsigned char *)_TIFFmalloc(raster_size)) == NULL) - { + if ((raster = (unsigned char*) _TIFFmalloc(raster_size)) == NULL) { fprintf(stderr, "not enough memory for image\n"); return (0); } - if (local) - { + if (local) { localbits = (buf[8] & 0x7) + 1; - fprintf(stderr, " local colors: %d\n", 1 << localbits); + fprintf(stderr, " local colors: %d\n", 1< 12) - return 0; + return 0; clear = 1 << datasize; eoi = clear + 1; avail = clear + 2; oldcode = -1; codesize = datasize + 1; codemask = (1 << codesize) - 1; - for (code = 0; code < clear; code++) - { - prefix[code] = 0; - suffix[code] = code; + for (code = 0; code < clear; code++) { + prefix[code] = 0; + suffix[code] = code; } stackp = stack; - for (count = getc(infile); count > 0 && count <= 255; count = getc(infile)) - { - if (fread(buf, 1, count, infile) != (size_t)count) - { - fprintf(stderr, "short read from file %s (%s)\n", filename, - strerror(errno)); + for (count = getc(infile); count > 0 && count <= 255; count = getc(infile)) { + if (fread(buf,1,count,infile) != (size_t)count) { + fprintf(stderr, "short read from file %s (%s)\n", + filename, strerror(errno)); return 0; } - for (ch = buf; count-- > 0; ch++) - { - datum += (unsigned long)*ch << bits; - bits += 8; - while (bits >= codesize) - { - code = datum & codemask; - datum >>= codesize; - bits -= codesize; - if (code == eoi) - { /* This kludge put in */ - goto exitloop; /* because some GIF files*/ - } /* aren't standard */ - if (!process(code, &fill)) - { - status = 0; - goto exitloop; - } - } - } - if (fill >= raster + width * height) - { - fprintf(stderr, "raster full before eoi code\n"); - break; - } + for (ch=buf; count-- > 0; ch++) { + datum += (unsigned long) *ch << bits; + bits += 8; + while (bits >= codesize) { + code = datum & codemask; + datum >>= codesize; + bits -= codesize; + if (code == eoi) { /* This kludge put in */ + goto exitloop; /* because some GIF files*/ + } /* aren't standard */ + if (!process(code, &fill)) { + status = 0; + goto exitloop; + } + } + } + if (fill >= raster + width*height) { + fprintf(stderr, "raster full before eoi code\n"); + break; + } } exitloop: - if (fill != raster + width * height) - { - fprintf(stderr, "warning: wrong rastersize: %ld bytes\n", - (long)(fill - raster)); - fprintf(stderr, " instead of %ld bytes\n", - (long)width * height); + if (fill != raster + width*height) { + fprintf(stderr, "warning: wrong rastersize: %ld bytes\n", + (long) (fill-raster)); + fprintf(stderr, " instead of %ld bytes\n", + (long) width*height); } return status; } /* - * process - - * Process a compression code. "clear" resets the code table. - * Otherwise make a new code table entry, and output the bytes + * process - + * Process a compression code. "clear" resets the code table. + * Otherwise make a new code table entry, and output the bytes * associated with the code. */ -int process(register int code, unsigned char **fill) +int +process(register int code, unsigned char** fill) { int incode; static unsigned char firstchar; - if (code == clear) - { - codesize = datasize + 1; - codemask = (1 << codesize) - 1; - avail = clear + 2; - oldcode = -1; - return 1; + if (code == clear) { + codesize = datasize + 1; + codemask = (1 << codesize) - 1; + avail = clear + 2; + oldcode = -1; + return 1; } - if (oldcode == -1) - { - if (code >= clear) - { - fprintf(stderr, "bad input: code=%d is larger than clear=%d\n", - code, clear); + if (oldcode == -1) { + if (code >= clear) { + fprintf(stderr, "bad input: code=%d is larger than clear=%d\n",code, clear); return 0; } - if (*fill >= raster + width * height) - { + if (*fill >= raster + width*height) { fprintf(stderr, "raster full before eoi code\n"); return 0; } - *(*fill)++ = suffix[code]; - firstchar = oldcode = code; - return 1; + *(*fill)++ = suffix[code]; + firstchar = oldcode = code; + return 1; } - if (code > avail) - { - fprintf(stderr, "code %d too large for %d\n", code, avail); - return 0; + if (code > avail) { + fprintf(stderr, "code %d too large for %d\n", code, avail); + return 0; } incode = code; - if (code == avail) - { /* the first code is always < avail */ - *stackp++ = firstchar; - code = oldcode; + if (code == avail) { /* the first code is always < avail */ + *stackp++ = firstchar; + code = oldcode; } - while (code > clear) - { - *stackp++ = suffix[code]; - code = prefix[code]; + while (code > clear) { + *stackp++ = suffix[code]; + code = prefix[code]; } *stackp++ = firstchar = suffix[code]; @@ -515,20 +477,17 @@ int process(register int code, unsigned char **fill) suffix[avail] = firstchar; avail++; - if (((avail & codemask) == 0) && (avail < 4096)) - { - codesize++; - codemask += avail; + if (((avail & codemask) == 0) && (avail < 4096)) { + codesize++; + codemask += avail; } oldcode = incode; - do - { - if (*fill >= raster + width * height) - { + do { + if (*fill >= raster + width*height) { fprintf(stderr, "raster full before eoi code\n"); return 0; } - *(*fill)++ = *--stackp; + *(*fill)++ = *--stackp; } while (stackp > stack); return 1; } @@ -536,22 +495,23 @@ int process(register int code, unsigned char **fill) /* * initcolors - * Convert a color map (local or global) to arrays with R, G and B - * values. + * values. * */ -void initcolors(unsigned char colormap[COLSIZE][3], int ncolors) +void +initcolors(unsigned char colormap[COLSIZE][3], int ncolors) { register int i; - for (i = 0; i < ncolors; i++) - { - red[i] = gamtab[colormap[i][0]]; + for (i = 0; i < ncolors; i++) { + red[i] = gamtab[colormap[i][0]]; green[i] = gamtab[colormap[i][1]]; - blue[i] = gamtab[colormap[i][2]]; + blue[i] = gamtab[colormap[i][2]]; } } -void rasterize(int interleaved, char *mode) +void +rasterize(int interleaved, char* mode) { register unsigned long row; unsigned char *newras; @@ -560,73 +520,70 @@ void rasterize(int interleaved, char *mode) tstrip_t strip; tsize_t stripsize; - if ((newras = (unsigned char *)_TIFFmalloc(width * height + EXTRAFUDGE)) == - NULL) - { + if ((newras = (unsigned char*) _TIFFmalloc(width*height+EXTRAFUDGE)) == NULL) { fprintf(stderr, "not enough memory for image\n"); return; } -#define DRAWSEGMENT(offset, step) \ - { \ - for (row = offset; row < height; row += step) \ - { \ - _TIFFmemcpy(newras + row * width, ras, width); \ - ras += width; \ - } \ +#define DRAWSEGMENT(offset, step) { \ + for (row = offset; row < height; row += step) { \ + _TIFFmemcpy(newras + row*width, ras, width);\ + ras += width; \ + } \ } ras = raster; - if (interleaved) - { + if (interleaved) { DRAWSEGMENT(0, 8); DRAWSEGMENT(4, 8); DRAWSEGMENT(2, 4); DRAWSEGMENT(1, 2); - } - else + } else DRAWSEGMENT(0, 1); #undef DRAWSEGMENT tif = TIFFOpen(imagename, mode); - if (!tif) - { - TIFFError(imagename, "Can not open output image"); - exit(-1); + if (!tif) { + TIFFError(imagename,"Can not open output image"); + exit(-1); } - TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32_t)width); - TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32_t)height); + TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) width); + TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32) height); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, - rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip)); + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, + rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip)); TIFFSetField(tif, TIFFTAG_COMPRESSION, compression); - switch (compression) - { - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != 0) - TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor); - break; + switch (compression) { + case COMPRESSION_LZW: + case COMPRESSION_DEFLATE: + if (predictor != 0) + TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor); + break; } TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); strip = 0; stripsize = TIFFStripSize(tif); - for (row = 0; row < height; row += rowsperstrip) - { - if (rowsperstrip > height - row) - { - rowsperstrip = height - row; - stripsize = TIFFVStripSize(tif, rowsperstrip); - } - if (TIFFWriteEncodedStrip(tif, strip, newras + row * width, stripsize) < - 0) - break; - strip++; + for (row=0; row height-row) { + rowsperstrip = height-row; + stripsize = TIFFVStripSize(tif, rowsperstrip); + } + if (TIFFWriteEncodedStrip(tif, strip, newras+row*width, stripsize) < 0) + break; + strip++; } TIFFClose(tif); _TIFFfree(newras); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/archive/tools/ras2tiff.c b/thirdparty/SDL2_image/external/libtiff/archive/tools/ras2tiff.c index e0cec2809..ff116c614 100644 --- a/thirdparty/SDL2_image/external/libtiff/archive/tools/ras2tiff.c +++ b/thirdparty/SDL2_image/external/libtiff/archive/tools/ras2tiff.c @@ -2,366 +2,335 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include "tif_config.h" -#include -#include #include #include #include +#include +#include #ifdef HAVE_UNISTD_H -#include +# include #endif #ifdef NEED_LIBPORT -#include "libport.h" +# include "libport.h" #endif #include "rasterfile.h" #include "tiffio.h" #ifndef howmany -#define howmany(x, y) (((x) + ((y)-1)) / (y)) +#define howmany(x, y) (((x)+((y)-1))/(y)) #endif -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) -static uint16_t compression = (uint16_t)-1; -static int jpegcolormode = JPEGCOLORMODE_RGB; -static int quality = 75; /* JPEG quality */ -static uint16_t predictor = 0; +static uint16 compression = (uint16) -1; +static int jpegcolormode = JPEGCOLORMODE_RGB; +static int quality = 75; /* JPEG quality */ +static uint16 predictor = 0; static void usage(void); -static int processCompressOptions(char *); +static int processCompressOptions(char*); -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - unsigned char *buf; - long row; - tsize_t linebytes, scanline; - TIFF *out; - FILE *in; - struct rasterfile h; - uint16_t photometric; - uint16_t config = PLANARCONFIG_CONTIG; - uint32_t rowsperstrip = (uint32_t)-1; - int c; + unsigned char* buf; + long row; + tsize_t linebytes, scanline; + TIFF *out; + FILE *in; + struct rasterfile h; + uint16 photometric; + uint16 config = PLANARCONFIG_CONTIG; + uint32 rowsperstrip = (uint32) -1; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - while ((c = getopt(argc, argv, "c:r:h")) != -1) - switch (c) - { - case 'c': /* compression scheme */ - if (!processCompressOptions(optarg)) - usage(); - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case 'h': - usage(); - /*NOTREACHED*/ - } - if (argc - optind != 2) - usage(); - in = fopen(argv[optind], "rb"); - if (in == NULL) - { - fprintf(stderr, "%s: Can not open.\n", argv[optind]); - return (-1); - } - if (fread(&h, sizeof(h), 1, in) != 1) - { - fprintf(stderr, "%s: Can not read header.\n", argv[optind]); - fclose(in); - return (-2); - } - if (strcmp(h.ras_magic, RAS_MAGIC) == 0) - { + while ((c = getopt(argc, argv, "c:r:h")) != -1) + switch (c) { + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(); + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case 'h': + usage(); + /*NOTREACHED*/ + } + if (argc - optind != 2) + usage(); + in = fopen(argv[optind], "rb"); + if (in == NULL) { + fprintf(stderr, "%s: Can not open.\n", argv[optind]); + return (-1); + } + if (fread(&h, sizeof (h), 1, in) != 1) { + fprintf(stderr, "%s: Can not read header.\n", argv[optind]); + fclose(in); + return (-2); + } + if (strcmp(h.ras_magic, RAS_MAGIC) == 0) { #ifndef WORDS_BIGENDIAN - TIFFSwabLong((uint32_t *)&h.ras_width); - TIFFSwabLong((uint32_t *)&h.ras_height); - TIFFSwabLong((uint32_t *)&h.ras_depth); - TIFFSwabLong((uint32_t *)&h.ras_length); - TIFFSwabLong((uint32_t *)&h.ras_type); - TIFFSwabLong((uint32_t *)&h.ras_maptype); - TIFFSwabLong((uint32_t *)&h.ras_maplength); + TIFFSwabLong((uint32 *)&h.ras_width); + TIFFSwabLong((uint32 *)&h.ras_height); + TIFFSwabLong((uint32 *)&h.ras_depth); + TIFFSwabLong((uint32 *)&h.ras_length); + TIFFSwabLong((uint32 *)&h.ras_type); + TIFFSwabLong((uint32 *)&h.ras_maptype); + TIFFSwabLong((uint32 *)&h.ras_maplength); #endif - } - else if (strcmp(h.ras_magic, RAS_MAGIC_INV) == 0) - { + } else if (strcmp(h.ras_magic, RAS_MAGIC_INV) == 0) { #ifdef WORDS_BIGENDIAN - TIFFSwabLong((uint32_t *)&h.ras_width); - TIFFSwabLong((uint32_t *)&h.ras_height); - TIFFSwabLong((uint32_t *)&h.ras_depth); - TIFFSwabLong((uint32_t *)&h.ras_length); - TIFFSwabLong((uint32_t *)&h.ras_type); - TIFFSwabLong((uint32_t *)&h.ras_maptype); - TIFFSwabLong((uint32_t *)&h.ras_maplength); + TIFFSwabLong((uint32 *)&h.ras_width); + TIFFSwabLong((uint32 *)&h.ras_height); + TIFFSwabLong((uint32 *)&h.ras_depth); + TIFFSwabLong((uint32 *)&h.ras_length); + TIFFSwabLong((uint32 *)&h.ras_type); + TIFFSwabLong((uint32 *)&h.ras_maptype); + TIFFSwabLong((uint32 *)&h.ras_maplength); #endif - } - else - { - fprintf(stderr, "%s: Not a rasterfile.\n", argv[optind]); - fclose(in); - return (-3); - } - if ((h.ras_width <= 0) || (h.ras_width >= INT_MAX) || (h.ras_height <= 0) || - (h.ras_height >= INT_MAX) || (h.ras_depth <= 0) || - (h.ras_depth >= INT_MAX) || (h.ras_length <= 0) || - (h.ras_length >= INT_MAX) || (h.ras_type <= 0) || - (h.ras_maptype <= 0) || (h.ras_maplength <= 0) || - (h.ras_maplength >= INT_MAX)) - { - fprintf(stderr, "%s: Improper image header.\n", argv[optind]); - fclose(in); - return (-2); - } - if ((h.ras_depth != 1) && (h.ras_depth != 8) && (h.ras_depth != 24)) - { - fprintf(stderr, "%s: Improper image depth (%d).\n", argv[optind], - h.ras_depth); - fclose(in); - return (-2); - } - out = TIFFOpen(argv[optind + 1], "w"); - if (out == NULL) - { - fclose(in); - return (-4); - } - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t)h.ras_width); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t)h.ras_height); - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, h.ras_depth > 8 ? 3 : 1); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, h.ras_depth > 1 ? 8 : 1); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); - if (h.ras_maptype != RMT_NONE) - { - uint16_t *red; - register uint16_t *map; - register int i, j; - int mapsize; + } else { + fprintf(stderr, "%s: Not a rasterfile.\n", argv[optind]); + fclose(in); + return (-3); + } + if ((h.ras_width <= 0) || (h.ras_width >= INT_MAX) || + (h.ras_height <= 0) || (h.ras_height >= INT_MAX) || + (h.ras_depth <= 0) || (h.ras_depth >= INT_MAX) || + (h.ras_length <= 0) || (h.ras_length >= INT_MAX) || + (h.ras_type <= 0) || + (h.ras_maptype <= 0) || + (h.ras_maplength <= 0) || (h.ras_maplength >= INT_MAX)) { + fprintf(stderr, "%s: Improper image header.\n", argv[optind]); + fclose(in); + return (-2); + } + if ((h.ras_depth != 1) && + (h.ras_depth != 8) && + (h.ras_depth != 24)) { + fprintf(stderr, "%s: Improper image depth (%d).\n", + argv[optind], h.ras_depth); + fclose(in); + return (-2); + } + out = TIFFOpen(argv[optind+1], "w"); + if (out == NULL) + { + fclose(in); + return (-4); + } + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) h.ras_width); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) h.ras_height); + TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, h.ras_depth > 8 ? 3 : 1); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, h.ras_depth > 1 ? 8 : 1); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + if (h.ras_maptype != RMT_NONE) { + uint16* red; + register uint16* map; + register int i, j; + int mapsize; - buf = (unsigned char *)_TIFFmalloc(h.ras_maplength); - if (buf == NULL) - { - fprintf(stderr, "No space to read in colormap.\n"); - fclose(in); - (void)TIFFClose(out); - return (-5); - } - if (fread(buf, h.ras_maplength, 1, in) != 1) - { - fprintf(stderr, "%s: Read error on colormap.\n", argv[optind]); - fclose(in); - (void)TIFFClose(out); - return (-6); - } - mapsize = 1 << h.ras_depth; - if (h.ras_maplength > mapsize * 3) - { - fprintf(stderr, "%s: Huh, %d colormap entries, should be %d?\n", - argv[optind], h.ras_maplength, mapsize * 3); - fclose(in); - (void)TIFFClose(out); - return (-7); - } - red = (uint16_t *)_TIFFmalloc(mapsize * 3 * sizeof(uint16_t)); - if (red == NULL) - { - fprintf(stderr, "No space for colormap.\n"); - fclose(in); - (void)TIFFClose(out); - return (-8); - } - map = red; - for (j = 0; j < 3; j++) - { -#define SCALE(x) (((x) * ((1L << 16) - 1)) / 255) - for (i = h.ras_maplength / 3; i-- > 0;) - *map++ = SCALE(*buf++); - if ((i = h.ras_maplength / 3) < mapsize) - { - i = mapsize - i; - _TIFFmemset(map, 0, i * sizeof(uint16_t)); - map += i; - } - } - TIFFSetField(out, TIFFTAG_COLORMAP, red, red + mapsize, - red + 2 * mapsize); - photometric = PHOTOMETRIC_PALETTE; - if (compression == (uint16_t)-1) - compression = COMPRESSION_PACKBITS; - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - } - else - { - /* XXX this is bogus... */ - photometric = - h.ras_depth == 24 ? PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK; - if (compression == (uint16_t)-1) - compression = COMPRESSION_LZW; - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - } - switch (compression) - { - case COMPRESSION_JPEG: - if (photometric == PHOTOMETRIC_RGB && - jpegcolormode == JPEGCOLORMODE_RGB) - photometric = PHOTOMETRIC_YCBCR; - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != 0) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - break; - } - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); - linebytes = ((h.ras_depth * h.ras_width + 15) >> 3) & ~1; - scanline = TIFFScanlineSize(out); - if (scanline > linebytes) - { - buf = (unsigned char *)_TIFFmalloc(scanline); - _TIFFmemset(buf + linebytes, 0, scanline - linebytes); - } - else - buf = (unsigned char *)_TIFFmalloc(linebytes); - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, - TIFFDefaultStripSize(out, rowsperstrip)); - for (row = 0; row < h.ras_height; row++) - { - if (fread(buf, linebytes, 1, in) != 1) - { - fprintf(stderr, "%s: scanline %ld: Read error.\n", argv[optind], - row); - break; - } - if (h.ras_type == RT_STANDARD && h.ras_depth == 24) - { - tsize_t cc = h.ras_width; - unsigned char *cp = buf; -#define SWAP(a, b) \ - { \ - unsigned char t = (a); \ - (a) = (b); \ - (b) = t; \ - } - do - { - SWAP(cp[0], cp[2]); - cp += 3; - } while (--cc); - } - if (TIFFWriteScanline(out, buf, row, 0) < 0) - break; - } - (void)TIFFClose(out); - fclose(in); - return (0); + buf = (unsigned char *)_TIFFmalloc(h.ras_maplength); + if (buf == NULL) { + fprintf(stderr, "No space to read in colormap.\n"); + return (-5); + } + if (fread(buf, h.ras_maplength, 1, in) != 1) { + fprintf(stderr, "%s: Read error on colormap.\n", + argv[optind]); + return (-6); + } + mapsize = 1< mapsize*3) { + fprintf(stderr, + "%s: Huh, %d colormap entries, should be %d?\n", + argv[optind], h.ras_maplength, mapsize*3); + return (-7); + } + red = (uint16*)_TIFFmalloc(mapsize * 3 * sizeof (uint16)); + if (red == NULL) { + fprintf(stderr, "No space for colormap.\n"); + return (-8); + } + map = red; + for (j = 0; j < 3; j++) { +#define SCALE(x) (((x)*((1L<<16)-1))/255) + for (i = h.ras_maplength/3; i-- > 0;) + *map++ = SCALE(*buf++); + if ((i = h.ras_maplength/3) < mapsize) { + i = mapsize - i; + _TIFFmemset(map, 0, i*sizeof (uint16)); + map += i; + } + } + TIFFSetField(out, TIFFTAG_COLORMAP, + red, red + mapsize, red + 2*mapsize); + photometric = PHOTOMETRIC_PALETTE; + if (compression == (uint16) -1) + compression = COMPRESSION_PACKBITS; + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + } else { + /* XXX this is bogus... */ + photometric = h.ras_depth == 24 ? + PHOTOMETRIC_RGB : PHOTOMETRIC_MINISBLACK; + if (compression == (uint16) -1) + compression = COMPRESSION_LZW; + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + } + switch (compression) { + case COMPRESSION_JPEG: + if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB) + photometric = PHOTOMETRIC_YCBCR; + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); + break; + case COMPRESSION_LZW: + case COMPRESSION_DEFLATE: + if (predictor != 0) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + break; + } + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); + linebytes = ((h.ras_depth*h.ras_width+15) >> 3) &~ 1; + scanline = TIFFScanlineSize(out); + if (scanline > linebytes) { + buf = (unsigned char *)_TIFFmalloc(scanline); + _TIFFmemset(buf+linebytes, 0, scanline-linebytes); + } else + buf = (unsigned char *)_TIFFmalloc(linebytes); + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, + TIFFDefaultStripSize(out, rowsperstrip)); + for (row = 0; row < h.ras_height; row++) { + if (fread(buf, linebytes, 1, in) != 1) { + fprintf(stderr, "%s: scanline %ld: Read error.\n", + argv[optind], row); + break; + } + if (h.ras_type == RT_STANDARD && h.ras_depth == 24) { + tsize_t cc = h.ras_width; + unsigned char* cp = buf; +#define SWAP(a,b) { unsigned char t = (a); (a) = (b); (b) = t; } + do { + SWAP(cp[0], cp[2]); + cp += 3; + } while (--cc); + } + if (TIFFWriteScanline(out, buf, row, 0) < 0) + break; + } + (void) TIFFClose(out); + fclose(in); + return (0); } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) { - if (streq(opt, "none")) - compression = COMPRESSION_NONE; - else if (streq(opt, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (strneq(opt, "jpeg", 4)) - { - char *cp = strchr(opt, ':'); + if (streq(opt, "none")) + compression = COMPRESSION_NONE; + else if (streq(opt, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (strneq(opt, "jpeg", 4)) { + char* cp = strchr(opt, ':'); - compression = COMPRESSION_JPEG; - while (cp) - { - if (isdigit((int)cp[1])) - quality = atoi(cp + 1); - else if (cp[1] == 'r') - jpegcolormode = JPEGCOLORMODE_RAW; - else - usage(); + compression = COMPRESSION_JPEG; + while( cp ) + { + if (isdigit((int)cp[1])) + quality = atoi(cp+1); + else if (cp[1] == 'r' ) + jpegcolormode = JPEGCOLORMODE_RAW; + else + usage(); - cp = strchr(cp + 1, ':'); - } - } - else if (strneq(opt, "lzw", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + cp = strchr(cp+1,':'); + } + } else if (strneq(opt, "lzw", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strneq(opt, "zip", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -char *stuff[] = { - "usage: ras2tiff [options] input.ras output.tif", - "where options are:", - " -r # make each strip have no more than # rows", - "", - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", - " -c zip[:opts] compress output with deflate encoding", - " -c jpeg[:opts] compress output with JPEG encoding", - " -c packbits compress output with packbits encoding", - " -c none use no compression algorithm on output", - "", - "JPEG options:", - " # set compression quality level (0-100, default 75)", - " r output color image as RGB rather than YCbCr", - "For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. " - "quality", - "", - "LZW and deflate options:", - " # set predictor value", - "For example, -c lzw:2 to get LZW-encoded data with horizontal " - "differencing", - " -h this help message", - NULL}; +char* stuff[] = { +"usage: ras2tiff [options] input.ras output.tif", +"where options are:", +" -r # make each strip have no more than # rows", +"", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c jpeg[:opts] compress output with JPEG encoding", +" -c packbits compress output with packbits encoding", +" -c none use no compression algorithm on output", +"", +"JPEG options:", +" # set compression quality level (0-100, default 75)", +" r output color image as RGB rather than YCbCr", +"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", +"", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +" -h this help message", +NULL +}; -static void usage(void) +static void +usage(void) { - char buf[BUFSIZ]; - int i; + char buf[BUFSIZ]; + int i; - setbuf(stderr, buf); - fprintf(stderr, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(stderr, "%s\n", stuff[i]); - exit(-1); + setbuf(stderr, buf); + fprintf(stderr, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(stderr, "%s\n", stuff[i]); + exit(-1); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/archive/tools/rasterfile.h b/thirdparty/SDL2_image/external/libtiff/archive/tools/rasterfile.h index d9943d7ea..e7d9680b4 100644 --- a/thirdparty/SDL2_image/external/libtiff/archive/tools/rasterfile.h +++ b/thirdparty/SDL2_image/external/libtiff/archive/tools/rasterfile.h @@ -3,32 +3,31 @@ /* * Description of header for files containing raster images */ -struct rasterfile -{ - char ras_magic[4]; /* magic number */ - int32_t ras_width; /* width (pixels) of image */ - int32_t ras_height; /* height (pixels) of image */ - int32_t ras_depth; /* depth (1, 8, or 24 bits) of pixel */ - int32_t ras_length; /* length (bytes) of image */ - int32_t ras_type; /* type of file; see RT_* below */ - int32_t ras_maptype; /* type of colormap; see RMT_* below */ - int32_t ras_maplength; /* length (bytes) of following map */ - /* color map follows for ras_maplength bytes, followed by image */ +struct rasterfile { + char ras_magic[4]; /* magic number */ + int32 ras_width; /* width (pixels) of image */ + int32 ras_height; /* height (pixels) of image */ + int32 ras_depth; /* depth (1, 8, or 24 bits) of pixel */ + int32 ras_length; /* length (bytes) of image */ + int32 ras_type; /* type of file; see RT_* below */ + int32 ras_maptype; /* type of colormap; see RMT_* below */ + int32 ras_maplength; /* length (bytes) of following map */ + /* color map follows for ras_maplength bytes, followed by image */ }; -#define RAS_MAGIC "\x59\xa6\x6a\x95" -#define RAS_MAGIC_INV "\x95\x6a\xa6\x59" +#define RAS_MAGIC "\x59\xa6\x6a\x95" +#define RAS_MAGIC_INV "\x95\x6a\xa6\x59" -/* Sun supported ras_type's */ -#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */ -#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */ -#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */ -#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */ + /* Sun supported ras_type's */ +#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */ +#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */ +#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */ +#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */ -/* Sun registered ras_maptype's */ -#define RMT_RAW 2 -/* Sun supported ras_maptype's */ -#define RMT_NONE 0 /* ras_maplength is expected to be 0 */ -#define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */ + /* Sun registered ras_maptype's */ +#define RMT_RAW 2 + /* Sun supported ras_maptype's */ +#define RMT_NONE 0 /* ras_maplength is expected to be 0 */ +#define RMT_EQUAL_RGB 1 /* red[ras_maplength/3],green[],blue[] */ /* * NOTES: diff --git a/thirdparty/SDL2_image/external/libtiff/archive/tools/sgi2tiff.c b/thirdparty/SDL2_image/external/libtiff/archive/tools/sgi2tiff.c index 44b30010f..36ee0cf05 100644 --- a/thirdparty/SDL2_image/external/libtiff/archive/tools/sgi2tiff.c +++ b/thirdparty/SDL2_image/external/libtiff/archive/tools/sgi2tiff.c @@ -2,345 +2,334 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include -#include #include #include #include +#include +#include #include "tiffio.h" -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) -static short config = PLANARCONFIG_CONTIG; -static uint16_t compression = COMPRESSION_PACKBITS; -static uint16_t predictor = 0; -static uint16_t fillorder = 0; -static uint32_t rowsperstrip = (uint32_t)-1; -static int jpegcolormode = JPEGCOLORMODE_RGB; -static int quality = 75; /* JPEG quality */ -static uint16_t photometric; +static short config = PLANARCONFIG_CONTIG; +static uint16 compression = COMPRESSION_PACKBITS; +static uint16 predictor = 0; +static uint16 fillorder = 0; +static uint32 rowsperstrip = (uint32) -1; +static int jpegcolormode = JPEGCOLORMODE_RGB; +static int quality = 75; /* JPEG quality */ +static uint16 photometric; -static void usage(void); -static int cpContig(IMAGE *, TIFF *); -static int cpSeparate(IMAGE *, TIFF *); -static int processCompressOptions(char *); +static void usage(void); +static int cpContig(IMAGE*, TIFF*); +static int cpSeparate(IMAGE*, TIFF*); +static int processCompressOptions(char*); /* XXX image library has no prototypes */ -extern IMAGE *iopen(const char *, const char *); -extern void iclose(IMAGE *); -extern void getrow(IMAGE *, short *, int, int); +extern IMAGE* iopen(const char*, const char*); +extern void iclose(IMAGE*); +extern void getrow(IMAGE*, short*, int, int); -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - IMAGE *in; - TIFF *out; - int c; + IMAGE *in; + TIFF *out; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - while ((c = getopt(argc, argv, "c:p:r:")) != -1) - switch (c) - { - case 'c': /* compression scheme */ - if (!processCompressOptions(optarg)) - usage(); - break; - case 'f': /* fill order */ - if (streq(optarg, "lsb2msb")) - fillorder = FILLORDER_LSB2MSB; - else if (streq(optarg, "msb2lsb")) - fillorder = FILLORDER_MSB2LSB; - else - usage(); - break; - case 'p': /* planar configuration */ - if (streq(optarg, "separate")) - config = PLANARCONFIG_SEPARATE; - else if (streq(optarg, "contig")) - config = PLANARCONFIG_CONTIG; - else - usage(); - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case '?': - usage(); - /*NOTREACHED*/ - } - if (argc - optind != 2) - usage(); - in = iopen(argv[optind], "r"); - if (in == NULL) - return (-1); - out = TIFFOpen(argv[optind + 1], "w"); - if (out == NULL) - return (-2); - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t)in->xsize); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t)in->ysize); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - if (in->zsize == 1) - photometric = PHOTOMETRIC_MINISBLACK; - else - photometric = PHOTOMETRIC_RGB; - switch (compression) - { - case COMPRESSION_JPEG: - if (photometric == PHOTOMETRIC_RGB && - jpegcolormode == JPEGCOLORMODE_RGB) - photometric = PHOTOMETRIC_YCBCR; - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != 0) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - break; - } - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); - if (fillorder != 0) - TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, in->zsize); - if (in->zsize > 3) - { - uint16_t v[1]; - v[0] = EXTRASAMPLE_UNASSALPHA; - TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, v); - } - TIFFSetField(out, TIFFTAG_MINSAMPLEVALUE, (uint16_t)in->min); - TIFFSetField(out, TIFFTAG_MAXSAMPLEVALUE, (uint16_t)in->max); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); - if (config != PLANARCONFIG_SEPARATE) - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, - TIFFDefaultStripSize(out, rowsperstrip)); - else /* force 1 row/strip for library limitation */ - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1L); - if (in->name[0] != '\0') - TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, in->name); - if (config == PLANARCONFIG_CONTIG) - cpContig(in, out); - else - cpSeparate(in, out); - (void)iclose(in); - (void)TIFFClose(out); - return (0); + while ((c = getopt(argc, argv, "c:p:r:")) != -1) + switch (c) { + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(); + break; + case 'f': /* fill order */ + if (streq(optarg, "lsb2msb")) + fillorder = FILLORDER_LSB2MSB; + else if (streq(optarg, "msb2lsb")) + fillorder = FILLORDER_MSB2LSB; + else + usage(); + break; + case 'p': /* planar configuration */ + if (streq(optarg, "separate")) + config = PLANARCONFIG_SEPARATE; + else if (streq(optarg, "contig")) + config = PLANARCONFIG_CONTIG; + else + usage(); + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case '?': + usage(); + /*NOTREACHED*/ + } + if (argc - optind != 2) + usage(); + in = iopen(argv[optind], "r"); + if (in == NULL) + return (-1); + out = TIFFOpen(argv[optind+1], "w"); + if (out == NULL) + return (-2); + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) in->xsize); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) in->ysize); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + if (in->zsize == 1) + photometric = PHOTOMETRIC_MINISBLACK; + else + photometric = PHOTOMETRIC_RGB; + switch (compression) { + case COMPRESSION_JPEG: + if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB) + photometric = PHOTOMETRIC_YCBCR; + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); + break; + case COMPRESSION_LZW: + case COMPRESSION_DEFLATE: + if (predictor != 0) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + break; + } + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); + if (fillorder != 0) + TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); + TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, in->zsize); + if (in->zsize > 3) { + uint16 v[1]; + v[0] = EXTRASAMPLE_UNASSALPHA; + TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, v); + } + TIFFSetField(out, TIFFTAG_MINSAMPLEVALUE, (uint16) in->min); + TIFFSetField(out, TIFFTAG_MAXSAMPLEVALUE, (uint16) in->max); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + if (config != PLANARCONFIG_SEPARATE) + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, + TIFFDefaultStripSize(out, rowsperstrip)); + else /* force 1 row/strip for library limitation */ + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, 1L); + if (in->name[0] != '\0') + TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, in->name); + if (config == PLANARCONFIG_CONTIG) + cpContig(in, out); + else + cpSeparate(in, out); + (void) iclose(in); + (void) TIFFClose(out); + return (0); } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) { - if (streq(opt, "none")) - compression = COMPRESSION_NONE; - else if (streq(opt, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (strneq(opt, "jpeg", 4)) - { - char *cp = strchr(opt, ':'); + if (streq(opt, "none")) + compression = COMPRESSION_NONE; + else if (streq(opt, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (strneq(opt, "jpeg", 4)) { + char* cp = strchr(opt, ':'); - defcompression = COMPRESSION_JPEG; - while (cp) - { - if (isdigit((int)cp[1])) - quality = atoi(cp + 1); - else if (cp[1] == 'r') - jpegcolormode = JPEGCOLORMODE_RAW; - else - usage(); + defcompression = COMPRESSION_JPEG; + while( cp ) + { + if (isdigit((int)cp[1])) + quality = atoi(cp+1); + else if (cp[1] == 'r' ) + jpegcolormode = JPEGCOLORMODE_RAW; + else + usage(); - cp = strchr(cp + 1, ':'); - } - } - else if (strneq(opt, "lzw", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + cp = strchr(cp+1,':'); + } + } else if (strneq(opt, "lzw", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strneq(opt, "zip", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -static int cpContig(IMAGE *in, TIFF *out) +static int +cpContig(IMAGE* in, TIFF* out) { - tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out)); - short *r = NULL; - int x, y; + tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out)); + short *r = NULL; + int x, y; - if (in->zsize == 3) - { - short *g, *b; + if (in->zsize == 3) { + short *g, *b; - r = (short *)_TIFFmalloc(3 * in->xsize * sizeof(short)); - g = r + in->xsize; - b = g + in->xsize; - for (y = in->ysize - 1; y >= 0; y--) - { - uint8_t *pp = (uint8_t *)buf; + r = (short *)_TIFFmalloc(3 * in->xsize * sizeof (short)); + g = r + in->xsize; + b = g + in->xsize; + for (y = in->ysize-1; y >= 0; y--) { + uint8* pp = (uint8*) buf; - getrow(in, r, y, 0); - getrow(in, g, y, 1); - getrow(in, b, y, 2); - for (x = 0; x < in->xsize; x++) - { - pp[0] = r[x]; - pp[1] = g[x]; - pp[2] = b[x]; - pp += 3; - } - if (TIFFWriteScanline(out, buf, in->ysize - y - 1, 0) < 0) - goto bad; - } - } - else if (in->zsize == 4) - { - short *g, *b, *a; + getrow(in, r, y, 0); + getrow(in, g, y, 1); + getrow(in, b, y, 2); + for (x = 0; x < in->xsize; x++) { + pp[0] = r[x]; + pp[1] = g[x]; + pp[2] = b[x]; + pp += 3; + } + if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0) + goto bad; + } + } else if (in->zsize == 4) { + short *g, *b, *a; - r = (short *)_TIFFmalloc(4 * in->xsize * sizeof(short)); - g = r + in->xsize; - b = g + in->xsize; - a = b + in->xsize; - for (y = in->ysize - 1; y >= 0; y--) - { - uint8_t *pp = (uint8_t *)buf; + r = (short *)_TIFFmalloc(4 * in->xsize * sizeof (short)); + g = r + in->xsize; + b = g + in->xsize; + a = b + in->xsize; + for (y = in->ysize-1; y >= 0; y--) { + uint8* pp = (uint8*) buf; - getrow(in, r, y, 0); - getrow(in, g, y, 1); - getrow(in, b, y, 2); - getrow(in, a, y, 3); - for (x = 0; x < in->xsize; x++) - { - pp[0] = r[x]; - pp[1] = g[x]; - pp[2] = b[x]; - pp[3] = a[x]; - pp += 4; - } - if (TIFFWriteScanline(out, buf, in->ysize - y - 1, 0) < 0) - goto bad; - } - } - else - { - uint8_t *pp = (uint8_t *)buf; + getrow(in, r, y, 0); + getrow(in, g, y, 1); + getrow(in, b, y, 2); + getrow(in, a, y, 3); + for (x = 0; x < in->xsize; x++) { + pp[0] = r[x]; + pp[1] = g[x]; + pp[2] = b[x]; + pp[3] = a[x]; + pp += 4; + } + if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0) + goto bad; + } + } else { + uint8* pp = (uint8*) buf; - r = (short *)_TIFFmalloc(in->xsize * sizeof(short)); - for (y = in->ysize - 1; y >= 0; y--) - { - getrow(in, r, y, 0); - for (x = in->xsize - 1; x >= 0; x--) - pp[x] = r[x]; - if (TIFFWriteScanline(out, buf, in->ysize - y - 1, 0) < 0) - goto bad; - } - } - if (r) - _TIFFfree(r); - _TIFFfree(buf); - return (1); + r = (short *)_TIFFmalloc(in->xsize * sizeof (short)); + for (y = in->ysize-1; y >= 0; y--) { + getrow(in, r, y, 0); + for (x = in->xsize-1; x >= 0; x--) + pp[x] = r[x]; + if (TIFFWriteScanline(out, buf, in->ysize-y-1, 0) < 0) + goto bad; + } + } + if (r) + _TIFFfree(r); + _TIFFfree(buf); + return (1); bad: - if (r) - _TIFFfree(r); - _TIFFfree(buf); - return (0); + if (r) + _TIFFfree(r); + _TIFFfree(buf); + return (0); } -static int cpSeparate(IMAGE *in, TIFF *out) +static int +cpSeparate(IMAGE* in, TIFF* out) { - tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out)); - short *r = (short *)_TIFFmalloc(in->xsize * sizeof(short)); - uint8_t *pp = (uint8_t *)buf; - int x, y, z; + tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out)); + short *r = (short *)_TIFFmalloc(in->xsize * sizeof (short)); + uint8* pp = (uint8*) buf; + int x, y, z; - for (z = 0; z < in->zsize; z++) - { - for (y = in->ysize - 1; y >= 0; y--) - { - getrow(in, r, y, z); - for (x = 0; x < in->xsize; x++) - pp[x] = r[x]; - if (TIFFWriteScanline(out, buf, in->ysize - y - 1, z) < 0) - goto bad; - } - } - _TIFFfree(r); - _TIFFfree(buf); - return (1); + for (z = 0; z < in->zsize; z++) { + for (y = in->ysize-1; y >= 0; y--) { + getrow(in, r, y, z); + for (x = 0; x < in->xsize; x++) + pp[x] = r[x]; + if (TIFFWriteScanline(out, buf, in->ysize-y-1, z) < 0) + goto bad; + } + } + _TIFFfree(r); + _TIFFfree(buf); + return (1); bad: - _TIFFfree(r); - _TIFFfree(buf); - return (0); + _TIFFfree(r); + _TIFFfree(buf); + return (0); } -char *stuff[] = { - "usage: sgi2tiff [options] input.rgb output.tif", - "where options are:", - " -r # make each strip have no more than # rows", - "", - " -p contig pack samples contiguously (e.g. RGBRGB...)", - " -p separate store samples separately (e.g. RRR...GGG...BBB...)", - "", - " -f lsb2msb force lsb-to-msb FillOrder for output", - " -f msb2lsb force msb-to-lsb FillOrder for output", - "", - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", - " -c zip[:opts] compress output with deflate encoding", - " -c jpeg[:opts]compress output with JPEG encoding", - " -c packbits compress output with packbits encoding", - " -c none use no compression algorithm on output", - "", - "JPEG options:", - " # set compression quality level (0-100, default 75)", - " r output color image as RGB rather than YCbCr", - "", - "LZW and deflate options:", - " # set predictor value", - "For example, -c lzw:2 to get LZW-encoded data with horizontal " - "differencing", - NULL}; +char* stuff[] = { +"usage: sgi2tiff [options] input.rgb output.tif", +"where options are:", +" -r # make each strip have no more than # rows", +"", +" -p contig pack samples contiguously (e.g. RGBRGB...)", +" -p separate store samples separately (e.g. RRR...GGG...BBB...)", +"", +" -f lsb2msb force lsb-to-msb FillOrder for output", +" -f msb2lsb force msb-to-lsb FillOrder for output", +"", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c jpeg[:opts]compress output with JPEG encoding", +" -c packbits compress output with packbits encoding", +" -c none use no compression algorithm on output", +"", +"JPEG options:", +" # set compression quality level (0-100, default 75)", +" r output color image as RGB rather than YCbCr", +"", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +NULL +}; -static void usage(void) +static void +usage(void) { - char buf[BUFSIZ]; - int i; + char buf[BUFSIZ]; + int i; - setbuf(stderr, buf); - for (i = 0; stuff[i] != NULL; i++) - fprintf(stderr, "%s\n", stuff[i]); - exit(-1); + setbuf(stderr, buf); + for (i = 0; stuff[i] != NULL; i++) + fprintf(stderr, "%s\n", stuff[i]); + exit(-1); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/archive/tools/sgisv.c b/thirdparty/SDL2_image/external/libtiff/archive/tools/sgisv.c index 09980bd3d..42818bba2 100644 --- a/thirdparty/SDL2_image/external/libtiff/archive/tools/sgisv.c +++ b/thirdparty/SDL2_image/external/libtiff/archive/tools/sgisv.c @@ -2,23 +2,23 @@ * Copyright (c) 1990-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -26,297 +26,291 @@ #include #include -#include #include +#include #include "tiffio.h" typedef unsigned char unsigned char; -typedef unsigned long uint32_t; +typedef unsigned long uint32; -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) -uint32_t rowsperstrip = (uint32_t)-1; -uint16_t compression = COMPRESSION_PACKBITS; -uint16_t config = PLANARCONFIG_CONTIG; -uint16_t predictor = 0; -int xmaxscreen; -int ymaxscreen; -uint16_t photometric = PHOTOMETRIC_RGB; -int jpegcolormode = JPEGCOLORMODE_RGB; -int quality = 75; /* JPEG quality */ +uint32 rowsperstrip = (uint32) -1; +uint16 compression = COMPRESSION_PACKBITS; +uint16 config = PLANARCONFIG_CONTIG; +uint16 predictor = 0; +int xmaxscreen; +int ymaxscreen; +uint16 photometric = PHOTOMETRIC_RGB; +int jpegcolormode = JPEGCOLORMODE_RGB; +int quality = 75; /* JPEG quality */ -static void usage(void); -static void tiffsv(char *, int, int, int, int); +static void usage(void); +static void tiffsv(char*, int, int, int, int); -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - int c; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - while ((c = getopt(argc, argv, "c:p:r:")) != -1) - switch (c) - { - case 'b': /* save as b&w */ - photometric = PHOTOMETRIC_MINISBLACK; - break; - case 'c': /* compression scheme */ - if (streq(optarg, "none")) - compression = COMPRESSION_NONE; - else if (streq(optarg, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (strneq(optarg, "jpeg", 4)) - { - char *cp = strchr(optarg, ':'); - if (cp && isdigit(cp[1])) - quality = atoi(cp + 1); - if (cp && strchr(cp, 'r')) - jpegcolormode = JPEGCOLORMODE_RAW; - compression = COMPRESSION_JPEG; - } - else if (strneq(optarg, "lzw", 3)) - { - char *cp = strchr(optarg, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else - usage(); - break; - case 'p': /* planar configuration */ - if (streq(optarg, "separate")) - config = PLANARCONFIG_SEPARATE; - else if (streq(optarg, "contig")) - config = PLANARCONFIG_CONTIG; - else - usage(); - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case '?': - usage(); - /*NOTREACHED*/ - } - if (argc - optind != 1 && argc - optind != 5) - usage(); - xmaxscreen = getgdesc(GD_XPMAX) - 1; - ymaxscreen = getgdesc(GD_YPMAX) - 1; - foreground(); - noport(); - winopen("tiffsv"); - if (argc - optind == 5) - tiffsv(argv[optind], atoi(argv[optind + 1]), atoi(argv[optind + 2]), - atoi(argv[optind + 3]), atoi(argv[optind + 4])); - else - tiffsv(argv[optind], 0, xmaxscreen, 0, ymaxscreen); - return (0); + while ((c = getopt(argc, argv, "c:p:r:")) != -1) + switch (c) { + case 'b': /* save as b&w */ + photometric = PHOTOMETRIC_MINISBLACK; + break; + case 'c': /* compression scheme */ + if (streq(optarg, "none")) + compression = COMPRESSION_NONE; + else if (streq(optarg, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (strneq(optarg, "jpeg", 4)) { + char* cp = strchr(optarg, ':'); + if (cp && isdigit(cp[1])) + quality = atoi(cp+1); + if (cp && strchr(cp, 'r')) + jpegcolormode = JPEGCOLORMODE_RAW; + compression = COMPRESSION_JPEG; + } else if (strneq(optarg, "lzw", 3)) { + char* cp = strchr(optarg, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else + usage(); + break; + case 'p': /* planar configuration */ + if (streq(optarg, "separate")) + config = PLANARCONFIG_SEPARATE; + else if (streq(optarg, "contig")) + config = PLANARCONFIG_CONTIG; + else + usage(); + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case '?': + usage(); + /*NOTREACHED*/ + } + if (argc - optind != 1 && argc - optind != 5) + usage(); + xmaxscreen = getgdesc(GD_XPMAX)-1; + ymaxscreen = getgdesc(GD_YPMAX)-1; + foreground(); + noport(); + winopen("tiffsv"); + if (argc - optind == 5) + tiffsv(argv[optind], + atoi(argv[optind+1]), atoi(argv[optind+2]), + atoi(argv[optind+3]), atoi(argv[optind+4])); + else + tiffsv(argv[optind], 0, xmaxscreen, 0, ymaxscreen); + return (0); } -char *stuff[] = { - "usage: tiffsv [options] outimage.tif [x1 x2 y1 y2] [-b]", - "where options are:", - " -p contig pack samples contiguously (e.g. RGBRGB...)", - " -p separate store samples separately (e.g. RRR...GGG...BBB...)", - "", - " -r # make each strip have no more than # rows", - "", - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", - " -c jpeg[:opts]compress output with JPEG encoding", - " -c packbits compress output with packbits encoding", - " -c none use no compression algorithm on output", - "", - "JPEG options:", - " # set compression quality level (0-100, default 75)", - " r output color image as RGB rather than YCbCr", - "", - "LZW options:", - " # set predictor value for Lempel-Ziv & Welch encoding", - "For example, -c lzw:2 to get LZW-encoded data with horizontal " - "differencing", - NULL}; +char* stuff[] = { +"usage: tiffsv [options] outimage.tif [x1 x2 y1 y2] [-b]", +"where options are:", +" -p contig pack samples contiguously (e.g. RGBRGB...)", +" -p separate store samples separately (e.g. RRR...GGG...BBB...)", +"", +" -r # make each strip have no more than # rows", +"", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c jpeg[:opts]compress output with JPEG encoding", +" -c packbits compress output with packbits encoding", +" -c none use no compression algorithm on output", +"", +"JPEG options:", +" # set compression quality level (0-100, default 75)", +" r output color image as RGB rather than YCbCr", +"", +"LZW options:", +" # set predictor value for Lempel-Ziv & Welch encoding", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +NULL +}; -static void usage(void) +static void +usage(void) { - char buf[BUFSIZ]; - int i; + char buf[BUFSIZ]; + int i; - setbuf(stderr, buf); - for (i = 0; stuff[i] != NULL; i++) - fprintf(stderr, "%s\n", stuff[i]); - exit(-1); + setbuf(stderr, buf); + for (i = 0; stuff[i] != NULL; i++) + fprintf(stderr, "%s\n", stuff[i]); + exit(-1); } -static void svRGBSeparate(TIFF *tif, uint32_t *ss, int xsize, int ysize) +static void +svRGBSeparate(TIFF* tif, uint32* ss, int xsize, int ysize) { - tsize_t stripsize = TIFFStripSize(tif); - unsigned char *rbuf = (unsigned char *)_TIFFmalloc(3 * stripsize); - unsigned char *gbuf = rbuf + stripsize; - unsigned char *bbuf = gbuf + stripsize; - register int y; + tsize_t stripsize = TIFFStripSize(tif); + unsigned char *rbuf = (unsigned char *)_TIFFmalloc(3*stripsize); + unsigned char *gbuf = rbuf + stripsize; + unsigned char *bbuf = gbuf + stripsize; + register int y; - for (y = 0; y <= ysize; y += rowsperstrip) - { - unsigned char *rp, *gp, *bp; - register int x; - register uint32_t n; + for (y = 0; y <= ysize; y += rowsperstrip) { + unsigned char *rp, *gp, *bp; + register int x; + register uint32 n; - n = rowsperstrip; - if (n > ysize - y + 1) - n = ysize - y + 1; - rp = rbuf; - gp = gbuf; - bp = bbuf; - do - { - for (x = 0; x <= xsize; x++) - { - uint32_t v = ss[x]; - rp[x] = v; - gp[x] = v >> 8; - bp[x] = v >> 16; - } - rp += xsize + 1, gp += xsize + 1, bp += xsize + 1; - ss += xsize + 1; - } while (--n); - if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 0), rbuf, - stripsize) < 0) - break; - if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 1), gbuf, - stripsize) < 0) - break; - if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 2), bbuf, - stripsize) < 0) - break; - } - _TIFFfree(rbuf); + n = rowsperstrip; + if (n > ysize-y+1) + n = ysize-y+1; + rp = rbuf; gp = gbuf; bp = bbuf; + do { + for (x = 0; x <= xsize; x++) { + uint32 v = ss[x]; + rp[x] = v; + gp[x] = v >> 8; + bp[x] = v >> 16; + } + rp += xsize+1, gp += xsize+1, bp += xsize+1; + ss += xsize+1; + } while (--n); + if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,0), + rbuf, stripsize) < 0) + break; + if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,1), + gbuf, stripsize) < 0) + break; + if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,2), + bbuf, stripsize) < 0) + break; + } + _TIFFfree(rbuf); } -static void svRGBContig(TIFF *tif, uint32_t *ss, int xsize, int ysize) +static void +svRGBContig(TIFF* tif, uint32* ss, int xsize, int ysize) { - register int x, y; - tsize_t stripsize = TIFFStripSize(tif); - unsigned char *strip = (unsigned char *)_TIFFmalloc(stripsize); + register int x, y; + tsize_t stripsize = TIFFStripSize(tif); + unsigned char *strip = (unsigned char *)_TIFFmalloc(stripsize); - for (y = 0; y <= ysize; y += rowsperstrip) - { - register unsigned char *pp = strip; - register uint32_t n; + for (y = 0; y <= ysize; y += rowsperstrip) { + register unsigned char *pp = strip; + register uint32 n; - n = rowsperstrip; - if (n > ysize - y + 1) - n = ysize - y + 1; - do - { - for (x = 0; x <= xsize; x++) - { - uint32_t v = ss[x]; - pp[0] = v; - pp[1] = v >> 8; - pp[2] = v >> 16; - pp += 3; - } - ss += xsize + 1; - } while (--n); - if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif, y, 0), strip, - stripsize) < 0) - break; - } - _TIFFfree(strip); + n = rowsperstrip; + if (n > ysize-y+1) + n = ysize-y+1; + do { + for (x = 0; x <= xsize; x++) { + uint32 v = ss[x]; + pp[0] = v; + pp[1] = v >> 8; + pp[2] = v >> 16; + pp += 3; + } + ss += xsize+1; + } while (--n); + if (TIFFWriteEncodedStrip(tif, TIFFComputeStrip(tif,y,0), + strip, stripsize) < 0) + break; + } + _TIFFfree(strip); } #undef RED #undef GREEN #undef BLUE -#define CVT(x) (((x)*255) / 100) -#define RED CVT(28) /* 28% */ -#define GREEN CVT(59) /* 59% */ -#define BLUE CVT(11) /* 11% */ +#define CVT(x) (((x)*255)/100) +#define RED CVT(28) /* 28% */ +#define GREEN CVT(59) /* 59% */ +#define BLUE CVT(11) /* 11% */ -static void svGrey(TIFF *tif, uint32_t *ss, int xsize, int ysize) +static void +svGrey(TIFF* tif, uint32* ss, int xsize, int ysize) { - register int x, y; - unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif)); + register int x, y; + unsigned char *buf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif)); - for (y = 0; y <= ysize; y++) - { - for (x = 0; x <= xsize; x++) - { - unsigned char *cp = (unsigned char *)&ss[x]; - buf[x] = (RED * cp[3] + GREEN * cp[2] + BLUE * cp[1]) >> 8; - } - if (TIFFWriteScanline(tif, buf, (uint32_t)y, 0) < 0) - break; - ss += xsize + 1; - } - _TIFFfree(buf); + for (y = 0; y <= ysize; y++) { + for (x = 0; x <= xsize; x++) { + unsigned char *cp = (unsigned char *)&ss[x]; + buf[x] = (RED*cp[3] + GREEN*cp[2] + BLUE*cp[1]) >> 8; + } + if (TIFFWriteScanline(tif, buf, (uint32) y, 0) < 0) + break; + ss += xsize+1; + } + _TIFFfree(buf); } -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define ABS(x) ((x) < 0 ? -(x) : (x)) +#define MIN(a,b) ((a)<(b)?(a):(b)) +#define ABS(x) ((x)<0?-(x):(x)) -static void tiffsv(char *name, int x1, int x2, int y1, int y2) +static void +tiffsv(char* name, int x1, int x2, int y1, int y2) { - TIFF *tif; - int xsize, ysize; - int xorg, yorg; - uint32_t *scrbuf; + TIFF *tif; + int xsize, ysize; + int xorg, yorg; + uint32 *scrbuf; - xorg = MIN(x1, x2); - yorg = MIN(y1, y2); - if (xorg < 0) - xorg = 0; - if (yorg < 0) - yorg = 0; - xsize = ABS(x2 - x1); - ysize = ABS(y2 - y1); - if (xorg + xsize > xmaxscreen) - xsize = xmaxscreen - xorg; - if (yorg + ysize > ymaxscreen) - ysize = ymaxscreen - yorg; - tif = TIFFOpen(name, "w"); - TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32_t)(xsize + 1)); - TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32_t)(ysize + 1)); - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, - photometric == PHOTOMETRIC_RGB ? 3 : 1); - TIFFSetField(tif, TIFFTAG_PLANARCONFIG, config); - TIFFSetField(tif, TIFFTAG_COMPRESSION, compression); - switch (compression) - { - case COMPRESSION_JPEG: - if (photometric == PHOTOMETRIC_RGB && - jpegcolormode == JPEGCOLORMODE_RGB) - photometric = PHOTOMETRIC_YCBCR; - TIFFSetField(tif, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_LZW: - if (predictor != 0) - TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor); - break; - } - TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric); - TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT); - rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip); - TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - scrbuf = - (uint32_t *)_TIFFmalloc((xsize + 1) * (ysize + 1) * sizeof(uint32_t)); - readdisplay(xorg, yorg, xorg + xsize, yorg + ysize, scrbuf, RD_FREEZE); - if (photometric == PHOTOMETRIC_RGB) - { - if (config == PLANARCONFIG_SEPARATE) - svRGBSeparate(tif, scrbuf, xsize, ysize); - else - svRGBContig(tif, scrbuf, xsize, ysize); - } - else - svGrey(tif, scrbuf, xsize, ysize); - (void)TIFFClose(tif); - _TIFFfree((char *)scrbuf); + xorg = MIN(x1,x2); + yorg = MIN(y1,y2); + if (xorg<0) + xorg = 0; + if (yorg<0) + yorg = 0; + xsize = ABS(x2-x1); + ysize = ABS(y2-y1); + if (xorg+xsize > xmaxscreen) + xsize = xmaxscreen-xorg; + if (yorg+ysize > ymaxscreen) + ysize = ymaxscreen-yorg; + tif = TIFFOpen(name, "w"); + TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) (xsize+1)); + TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32) (ysize+1)); + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, + photometric == PHOTOMETRIC_RGB ? 3 : 1); + TIFFSetField(tif, TIFFTAG_PLANARCONFIG, config); + TIFFSetField(tif, TIFFTAG_COMPRESSION, compression); + switch (compression) { + case COMPRESSION_JPEG: + if (photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB) + photometric = PHOTOMETRIC_YCBCR; + TIFFSetField(tif, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, jpegcolormode); + break; + case COMPRESSION_LZW: + if (predictor != 0) + TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor); + break; + } + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric); + TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT); + rowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip); + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + scrbuf = (uint32 *)_TIFFmalloc((xsize+1)*(ysize+1)*sizeof (uint32)); + readdisplay(xorg, yorg, xorg+xsize, yorg+ysize, scrbuf, RD_FREEZE); + if (photometric == PHOTOMETRIC_RGB) { + if (config == PLANARCONFIG_SEPARATE) + svRGBSeparate(tif, scrbuf, xsize, ysize); + else + svRGBContig(tif, scrbuf, xsize, ysize); + } else + svGrey(tif, scrbuf, xsize, ysize); + (void) TIFFClose(tif); + _TIFFfree((char *)scrbuf); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/archive/tools/ycbcr.c b/thirdparty/SDL2_image/external/libtiff/archive/tools/ycbcr.c index a05fef240..8f72447d0 100644 --- a/thirdparty/SDL2_image/external/libtiff/archive/tools/ycbcr.c +++ b/thirdparty/SDL2_image/external/libtiff/archive/tools/ycbcr.c @@ -1,17 +1,17 @@ -float ycbcrCoeffs[3] = {.299, .587, .114}; +float ycbcrCoeffs[3] = { .299, .587, .114 }; /* default coding range is CCIR Rec 601-1 with no headroom/footroom */ -unsigned long refBlackWhite[6] = {0, 255, 128, 255, 128, 255}; +unsigned long refBlackWhite[6] = { 0, 255, 128, 255, 128, 255 }; -#define LumaRed ycbcrCoeffs[0] -#define LumaGreen ycbcrCoeffs[1] -#define LumaBlue ycbcrCoeffs[2] +#define LumaRed ycbcrCoeffs[0] +#define LumaGreen ycbcrCoeffs[1] +#define LumaBlue ycbcrCoeffs[2] -long eRtotal = 0; -long eGtotal = 0; -long eBtotal = 0; -long preveRtotal = 0; -long preveGtotal = 0; -long preveBtotal = 0; +long eRtotal = 0; +long eGtotal = 0; +long eBtotal = 0; +long preveRtotal = 0; +long preveGtotal = 0; +long preveBtotal = 0; unsigned long AbseRtotal = 0; unsigned long AbseGtotal = 0; unsigned long AbseBtotal = 0; @@ -20,90 +20,101 @@ unsigned long preveCodes = 0; unsigned long eBits = 0; unsigned long preveBits = 0; -static void setupLumaTables(); +static void setupLumaTables(); static int abs(int v) { return (v < 0 ? -v : v); } -static double pct(int v, double range) { return (v * 100. / range); } +static double pct(int v,double range) { return (v*100. / range); } static void check(int R, int G, int B); -float D1, D2; -float D3, D4; -float D5, D6; +float D1, D2; +float D3, D4; +float D5, D6; -int main(int argc, char **argv) +int +main(int argc, char** argv) { int R, G, B; - if (argc > 1) - { - refBlackWhite[0] = 16; - refBlackWhite[1] = 235; - refBlackWhite[2] = 128; - refBlackWhite[3] = 240; - refBlackWhite[4] = 128; - refBlackWhite[5] = 240; + if (argc > 1) { + refBlackWhite[0] = 16; + refBlackWhite[1] = 235; + refBlackWhite[2] = 128; + refBlackWhite[3] = 240; + refBlackWhite[4] = 128; + refBlackWhite[5] = 240; } - D3 = 2 - 2 * LumaRed; - D4 = 2 - 2 * LumaBlue; + D3 = 2 - 2*LumaRed; + D4 = 2 - 2*LumaBlue; D1 = 1. / D3; D2 = 1. / D4; - D5 = D3 * LumaRed / LumaGreen; - D6 = D4 * LumaBlue / LumaGreen; + D5 = D3*LumaRed / LumaGreen; + D6 = D4*LumaBlue / LumaGreen; setupLumaTables(); - for (R = 0; R < 256; R++) - { - for (G = 0; G < 256; G++) - for (B = 0; B < 256; B++) - check(R, G, B); - printf("[%3u] c %u/%u b %u/%u (R %u/%d/%u G %u/%d/%u B %u/%d/%u)\n", R, - eCodes - preveCodes, eCodes, eBits - preveBits, eBits, - abs(AbseRtotal - preveRtotal), eRtotal, AbseRtotal, - abs(AbseGtotal - preveGtotal), eGtotal, AbseGtotal, - abs(AbseBtotal - preveBtotal), eBtotal, AbseBtotal); - preveRtotal = AbseRtotal; - preveGtotal = AbseGtotal; - preveBtotal = AbseBtotal; - preveCodes = eCodes; - preveBits = eBits; + for (R = 0; R < 256; R++) { + for (G = 0; G < 256; G++) + for (B = 0; B < 256; B++) + check(R, G, B); + printf("[%3u] c %u/%u b %u/%u (R %u/%d/%u G %u/%d/%u B %u/%d/%u)\n" + , R + , eCodes - preveCodes, eCodes + , eBits - preveBits, eBits + , abs(AbseRtotal - preveRtotal), eRtotal , AbseRtotal + , abs(AbseGtotal - preveGtotal), eGtotal , AbseGtotal + , abs(AbseBtotal - preveBtotal), eBtotal , AbseBtotal + ); + preveRtotal = AbseRtotal; + preveGtotal = AbseGtotal; + preveBtotal = AbseBtotal; + preveCodes = eCodes; + preveBits = eBits; } - printf("%u total codes\n", 256 * 256 * 256); - printf("total error: %u codes %u bits (R %d/%u G %d/%u B %d/%u)\n", eCodes, - eBits, eRtotal, AbseRtotal, eGtotal, AbseGtotal, eBtotal, - AbseBtotal); + printf("%u total codes\n", 256*256*256); + printf("total error: %u codes %u bits (R %d/%u G %d/%u B %d/%u)\n" + , eCodes + , eBits + , eRtotal , AbseRtotal + , eGtotal , AbseGtotal + , eBtotal , AbseBtotal + ); return (0); } -float *lumaRed; -float *lumaGreen; -float *lumaBlue; +float *lumaRed; +float *lumaGreen; +float *lumaBlue; -static float *setupLuma(float c) +static float* +setupLuma(float c) { - float *v = (float *)_TIFFmalloc(256 * sizeof(float)); + float *v = (float *)_TIFFmalloc(256 * sizeof (float)); int i; for (i = 0; i < 256; i++) - v[i] = c * i; + v[i] = c * i; return (v); } -static void setupLumaTables(void) +static void +setupLumaTables(void) { lumaRed = setupLuma(LumaRed); lumaGreen = setupLuma(LumaGreen); lumaBlue = setupLuma(LumaBlue); } -static unsigned V2Code(float f, unsigned long RB, unsigned long RW, int CR) +static unsigned +V2Code(float f, unsigned long RB, unsigned long RW, int CR) { - unsigned int c = (unsigned int)((((f) * (RW - RB) / CR) + RB) + .5); + unsigned int c = (unsigned int)((((f)*(RW-RB)/CR)+RB)+.5); return (c > 255 ? 255 : c); } -#define Code2V(c, RB, RW, CR) ((((c) - (int)RB) * (float)CR) / (float)(RW - RB)) +#define Code2V(c, RB, RW, CR) ((((c)-(int)RB)*(float)CR)/(float)(RW-RB)) -#define CLAMP(f, min, max) \ - (int)((f) + .5 < (min) ? (min) : (f) + .5 > (max) ? (max) : (f) + .5) +#define CLAMP(f,min,max) \ + (int)((f)+.5 < (min) ? (min) : (f)+.5 > (max) ? (max) : (f)+.5) -static void check(int R, int G, int B) +static +void +check(int R, int G, int B) { float Y, Cb, Cr; int iY, iCb, iCr; @@ -112,29 +123,31 @@ static void check(int R, int G, int B) int eR, eG, eB; Y = lumaRed[R] + lumaGreen[G] + lumaBlue[B]; - Cb = (B - Y) * D2; - Cr = (R - Y) * D1; + Cb = (B - Y)*D2; + Cr = (R - Y)*D1; iY = V2Code(Y, refBlackWhite[0], refBlackWhite[1], 255); iCb = V2Code(Cb, refBlackWhite[2], refBlackWhite[3], 127); iCr = V2Code(Cr, refBlackWhite[4], refBlackWhite[5], 127); rCb = Code2V(iCb, refBlackWhite[2], refBlackWhite[3], 127); rCr = Code2V(iCr, refBlackWhite[4], refBlackWhite[5], 127); rY = Code2V(iY, refBlackWhite[0], refBlackWhite[1], 255); - rR = rY + rCr * D3; - rB = rY + rCb * D4; - rG = rY - rCb * D6 - rCr * D5; - eR = R - CLAMP(rR, 0, 255); - eG = G - CLAMP(rG, 0, 255); - eB = B - CLAMP(rB, 0, 255); - if (abs(eR) > 1 || abs(eG) > 1 || abs(eB) > 1) - { - printf("R %u G %u B %u", R, G, B); - printf(" Y %g Cb %g Cr %g", Y, Cb, Cr); - printf(" iY %u iCb %u iCr %u", iY, iCb, iCr); - printf("\n -> Y %g Cb %g Cr %g", rY, rCb, rCr); - printf(" R %g (%u) G %g (%u) B %g (%u) E=[%d %d %d])\n", rR, - CLAMP(rR, 0, 255), rG, CLAMP(rG, 0, 255), rB, CLAMP(rB, 0, 255), - eR, eG, eB); + rR = rY + rCr*D3; + rB = rY + rCb*D4; + rG = rY - rCb*D6 - rCr*D5; + eR = R - CLAMP(rR,0,255); + eG = G - CLAMP(rG,0,255); + eB = B - CLAMP(rB,0,255); + if (abs(eR) > 1 || abs(eG) > 1 || abs(eB) > 1) { + printf("R %u G %u B %u", R, G, B); + printf(" Y %g Cb %g Cr %g", Y, Cb, Cr); + printf(" iY %u iCb %u iCr %u", iY, iCb, iCr); + printf("\n -> Y %g Cb %g Cr %g", rY, rCb, rCr); + printf(" R %g (%u) G %g (%u) B %g (%u) E=[%d %d %d])\n" + , rR, CLAMP(rR,0,255) + , rG, CLAMP(rG,0,255) + , rB, CLAMP(rB,0,255) + , eR, eG, eB + ); } eRtotal += eR; eGtotal += eG; @@ -143,6 +156,13 @@ static void check(int R, int G, int B) AbseGtotal += abs(eG); AbseBtotal += abs(eB); if (eR | eG | eB) - eCodes++; + eCodes++; eBits += abs(eR) + abs(eG) + abs(eB); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/autogen.sh b/thirdparty/SDL2_image/external/libtiff/autogen.sh index f63dc11df..563388506 100755 --- a/thirdparty/SDL2_image/external/libtiff/autogen.sh +++ b/thirdparty/SDL2_image/external/libtiff/autogen.sh @@ -1,27 +1,8 @@ #!/bin/sh set -x -case `uname` in - Darwin*) - glibtoolize --force --copy - ;; - *) - libtoolize --force --copy - ;; -esac +libtoolize --force --copy aclocal -I ./m4 autoheader automake --foreign --add-missing --copy autoconf -# Get latest config.guess and config.sub from upstream master since -# these are often out of date. -for file in config.guess config.sub -do - echo "$0: getting $file..." - wget -q --timeout=5 -O config/$file.tmp \ - "https://git.savannah.gnu.org/cgit/config.git/plain/${file}" \ - && mv -f config/$file.tmp config/$file \ - && chmod a+x config/$file - retval=$? - rm -f config/$file.tmp - test $retval -eq 0 || exit $retval -done + diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/CXXLibrary.cmake b/thirdparty/SDL2_image/external/libtiff/build/CMakeLists.txt similarity index 82% rename from thirdparty/SDL2_image/external/libtiff/cmake/CXXLibrary.cmake rename to thirdparty/SDL2_image/external/libtiff/build/CMakeLists.txt index 3fc15a985..d44c6eac0 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/CXXLibrary.cmake +++ b/thirdparty/SDL2_image/external/libtiff/build/CMakeLists.txt @@ -1,7 +1,6 @@ -# C++ library option +# CMake build for libtiff # # Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh # Written by Roger Leigh # # Permission to use, copy, modify, distribute, and sell this software and @@ -23,10 +22,4 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -# C++ support -option(cxx "Enable C++ stream API building (requires C++ compiler)" ON) -set(CXX_SUPPORT FALSE) -if (cxx) - enable_language(CXX) - set(CXX_SUPPORT TRUE) -endif() +extra_dist(README) diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/LERCCodec.cmake b/thirdparty/SDL2_image/external/libtiff/build/Makefile.am similarity index 71% rename from thirdparty/SDL2_image/external/libtiff/cmake/LERCCodec.cmake rename to thirdparty/SDL2_image/external/libtiff/build/Makefile.am index 54504ca1b..c912a422a 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/LERCCodec.cmake +++ b/thirdparty/SDL2_image/external/libtiff/build/Makefile.am @@ -1,32 +1,32 @@ -# Checks for LERC codec support # -# Copyright © 2021 Antonio Valentino -# Written by Antonio Valentino +# Tag Image File Format (TIFF) Software # -# Permission to use, copy, modify, distribute, and sell this software and +# Copyright (C) 2007, Andrey Kiselev +# +# Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +# Process this file with automake to produce Makefile.in. + +EXTRA_DIST = \ + CMakeLists.txt \ + README + +SUBDIRS = -# libLerc -set(LERC_SUPPORT FALSE) -find_package(LERC) -option(lerc "use libLerc (required for LERC compression)" ${LERC_FOUND}) -if (lerc AND LERC_FOUND AND ZIP_SUPPORT) - set(LERC_SUPPORT TRUE) -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/build/README b/thirdparty/SDL2_image/external/libtiff/build/README new file mode 100644 index 000000000..f765efc85 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/build/README @@ -0,0 +1,3 @@ +This directory contains scripts and tools needed to build libtiff library +and its utilities in various environments. + diff --git a/thirdparty/SDL2_image/external/libtiff/build/gitlab-ci b/thirdparty/SDL2_image/external/libtiff/build/gitlab-ci new file mode 100644 index 000000000..213431bf0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/build/gitlab-ci @@ -0,0 +1,82 @@ +#!/bin/sh +# This script is used for testing the build, primarily for use +# with travis, but may be used by hand as well. + +# Library versions to use +ZSTD_VER=1.4.4 +WEBP_VER=1.1.0 + +set -e +set -x + +# Test autoconf build +autoconf_build() +{ + autoreconf -ivf + + mkdir autoconf-build + cd autoconf-build + echo "Running ../configure --prefix=$(pwd)/../autoconf-install) ${opts}" + ../configure --prefix=$(pwd)/../autoconf-install --with-zstd-include-dir=/tmp/include --with-zstd-lib-dir=/tmp/lib --with-webp-include-dir=/tmp/include --with-webp-lib-dir=/tmp/lib ${opts} + make + make install + make check + make distcheck +} + +# Test cmake build +cmake_build() +{ + PATH="$(pwd)/tools/bin:$PATH" + if [ "$(uname -s)" = "Darwin" ]; then + PATH="$(pwd)/tools/CMake.app/Contents/bin:$PATH" + fi + mkdir cmake-build + cd cmake-build + echo "Running cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../autoconf-install -DZSTD_INCLUDE_DIR=/tmp/include -DZSTD_LIBRARY=/tmp/lib/libzstd.so -DWEBP_INCLUDE_DIR=/tmp/include -DZWEBP_LIBRARY=/tmp/lib/libwebp.so ${opts} .." + cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../autoconf-install -DZSTD_INCLUDE_DIR=/tmp/include -DZSTD_LIBRARY=/tmp/lib/libzstd.so -DWEBP_INCLUDE_DIR=/tmp/include -DWEBP_LIBRARY=/tmp/lib/libwebp.so ${opts} .. + cmake --build . + cmake --build . --target install + ctest -V +} + +build=$1 +shift + +# Build zstd +wget https://github.com/facebook/zstd/archive/v${ZSTD_VER}.tar.gz +tar xvzf v${ZSTD_VER}.tar.gz +cd zstd-${ZSTD_VER}/lib +# Faster build +make -j3 PREFIX=/tmp ZSTD_LEGACY_SUPPORT=0 CFLAGS=-O1 +make install PREFIX=/tmp ZSTD_LEGACY_SUPPORT=0 CFLAGS=-O1 +cd ../.. +rm -rf zstd-${ZSTD_VER} + +# Build webp +wget https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${WEBP_VER}.tar.gz +tar xvzf libwebp-${WEBP_VER}.tar.gz +cd libwebp-${WEBP_VER} +./configure --prefix=/tmp +make && make install +cd .. +rm -rf libwebp-${WEBP_VER} + +export LD_LIBRARY_PATH=/tmp/lib + +case $build in + autoconf) + echo "Testing Autoconf build" + autoconf_build "$@" + ;; + cmake) + echo "Testing CMake build" + cmake_build "$@" + ;; + *) + echo "Invalid argument: \"$arg\"" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/thirdparty/SDL2_image/external/libtiff/build/travis-ci b/thirdparty/SDL2_image/external/libtiff/build/travis-ci new file mode 100644 index 000000000..b1919c0a0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/build/travis-ci @@ -0,0 +1,109 @@ +#!/bin/sh +# This script is used for testing the build, primarily for use +# with travis, but may be used by hand as well. + +set -e +set -x + +# Test autoconf build +autoconf_build() +{ + autoreconf -ivf + + mkdir autoconf-build + cd autoconf-build + echo "Running ../configure --prefix=$(pwd)/../autoconf-install) ${opts}" + ../configure --prefix=$(pwd)/../autoconf-install ${opts} + make + make install + make check + make distcheck +} + +# Install needed tools +cmake_deps() +{ + mkdir -p download + mkdir -p tools + + if [ "$(uname -s)" = "Linux" ]; then + cmake_file="cmake-3.8.2-Linux-x86_64.tar.gz" + cmake_hash="574673d3f37b0be6a0813b894a8bce9c4af08c13f1ec25c030a69f42e0e4b349e0192385ef20c8a9271055b7c3b24c5b20fb5009762131a3fba3d17576e641f1" + elif [ "$(uname -s)" = "Darwin" ]; then + cmake_file="cmake-3.8.2-Darwin-x86_64.tar.gz" + cmake_hash="fd1c09dd73fe2b23fdc9ac915a90343d2e27409182dd1f2bf509ddf54ca926f97e1906fc18f119e8ea52797c05d4b919772f43500bffbcf2c3cdc86828d9067e" + fi + cmake_url="https://cmake.org/files/v3.8/${cmake_file}" + + if [ "$(uname -s)" = "Linux" ]; then + ninja_file="ninja-linux.zip" + ninja_hash="2dddc52750c5e6f841acd0d978b894c9a6562f12ddb4ba9e5118a213f54265f065682ffe1bc7bc2ac6146760145d17800a4b7373791cd1fbbaf0836faf050e19" + elif [ "$(uname -s)" = "Darwin" ]; then + ninja_file="ninja-mac.zip" + ninja_hash="e008c9814447bbf356be7f2daf6d212657fb22b67e7de3885bd2f27766cd7c8a2ad61a4aace170674464ccf55813cbe2bf311485bc2058e89867f17b692642b9" + fi + ninja_url="https://github.com/ninja-build/ninja/releases/download/v1.7.2/${ninja_file}" + + ( + cd download + if [ ! -f "$cmake_file" ] || [ "$(shasum -a 512 "$cmake_file")" != "$cmake_hash $cmake_file" ]; then + wget "$cmake_url" + if [ "$(shasum -a 512 "$cmake_file")" != "$cmake_hash $cmake_file" ]; then + echo "Error: cmake download hash mismatch" >&2 + exit 1 + fi + fi + tar xf "$cmake_file" + cp -a ${cmake_file%.tar.gz}/* ../tools + + if [ "$1" = "Ninja" ]; then + if [ ! -f "$ninja_file" ] || [ "$(shasum -a 512 "$ninja_file")" != "$ninja_hash $ninja_file" ]; then + wget "$ninja_url" + if [ "$(shasum -a 512 "$ninja_file")" != "$ninja_hash $ninja_file" ]; then + echo "Error: ninja download hash mismatch" >&2 + exit 1 + fi + fi + unzip "$ninja_file" + mkdir -p ../tools/bin + mv ninja ../tools/bin + fi + ) +} + +# Test autoconf build +cmake_build() +{ + PATH="$(pwd)/tools/bin:$PATH" + if [ "$(uname -s)" = "Darwin" ]; then + PATH="$(pwd)/tools/CMake.app/Contents/bin:$PATH" + fi + mkdir cmake-build + cd cmake-build + echo "Running cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../autoconf-install ${opts} .." + cmake -G "$1" -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../autoconf-install ${opts} .. + cmake --build . + cmake --build . --target install + ctest -V +} + +build=$1 +shift + +case $build in + autoconf) + echo "Testing Autoconf build" + autoconf_build "$@" + ;; + cmake) + echo "Testing CMake build" + cmake_deps "$@" + cmake_build "$@" + ;; + *) + echo "Invalid argument: \"$arg\"" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/AutotoolsCompat.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/AutotoolsCompat.cmake deleted file mode 100644 index f491a8a1d..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/AutotoolsCompat.cmake +++ /dev/null @@ -1,32 +0,0 @@ -# Autotools compatibility -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - - -# For autotools header compatibility -set(PACKAGE_NAME "LibTIFF Software") -set(PACKAGE_TARNAME "${PROJECT_NAME}") -set(PACKAGE_VERSION "${PROJECT_VERSION}${LIBTIFF_ALPHA_VERSION}") -set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") -set(PACKAGE_BUGREPORT "tiff@lists.maptools.org") diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/AutotoolsVersion.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/AutotoolsVersion.cmake deleted file mode 100644 index 0f660878a..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/AutotoolsVersion.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# Read version information from configure.ac. -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - - -# Get version from configure.ac -FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure REGEX "^LIBTIFF_.*=") -foreach(line ${configure}) - foreach(var LIBTIFF_MAJOR_VERSION LIBTIFF_MINOR_VERSION LIBTIFF_MICRO_VERSION LIBTIFF_ALPHA_VERSION - LIBTIFF_CURRENT LIBTIFF_REVISION LIBTIFF_AGE) - if(NOT ${var} AND line MATCHES "^${var}=(.*)") - set(${var} "${CMAKE_MATCH_1}") - break() - endif() - endforeach() -endforeach() - -# Package version -set(LIBTIFF_VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}") -set(LIBTIFF_VERSION_FULL "${LIBTIFF_VERSION}${LIBTIFF_ALPHA_VERSION}") - -# Convert the libtool version variables to proper major and minor versions -math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}") -set(SO_MINOR "${LIBTIFF_AGE}") -set(SO_REVISION "${LIBTIFF_REVISION}") - -# Library version (unlike libtool's baroque scheme, WYSIWYG here) -set(SO_COMPATVERSION "${SO_MAJOR}") -set(SO_VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}") diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/CompilerChecks.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/CompilerChecks.cmake deleted file mode 100644 index 8ac5564bc..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/CompilerChecks.cmake +++ /dev/null @@ -1,124 +0,0 @@ -# Compiler feature checks -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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(CheckCCompilerFlag) - - -# These are annoyingly verbose, produce false positives or don't work -# nicely with all supported compiler versions, so are disabled unless -# explicitly enabled. -option(extra-warnings "Enable extra compiler warnings" OFF) - -# This will cause the compiler to fail when an error occurs. -option(fatal-warnings "Compiler warnings are errors" OFF) - -# Check if the compiler supports each of the following additional -# flags, and enable them if supported. This greatly improves the -# quality of the build by checking for a number of common problems, -# some of which are quite serious. -if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR - CMAKE_C_COMPILER_ID MATCHES "Clang") - set(test_flags - -Wall - -Winline - -Wformat-security - -Wpointer-arith - -Wdisabled-optimization - -Wno-unknown-pragmas - -fstrict-aliasing) - if(extra-warnings) - list(APPEND test_flags - -pedantic - -Wextra - -Wformat - -Wformat-overflow - -Wformat-nonliteral - -Wformat-signedness - -Wformat-truncation - -Wdeclaration-after-statement - -Wconversion - -Wsign-conversion - -Wnull-dereference - -Wdouble-promotion - -Wmisleading-indentation - -Wmissing-include-dirs - -Wswitch-default - -Wswitch-enum - -Wunused-local-typedefs - -Wunused-parameter - -Wuninitialized - -Warith-conversion - -Wbool-operation - -Wduplicated-branches - -Wduplicated-cond - -Wshadow - -Wunused-macros - -Wc99-c11-compat - -Wcast-qual - -Wcast-align - -Wwrite-strings - -Wdangling-else - -Wsizeof-array-div - -Wsizeof-pointer-div - -Wsizeof-pointer-memaccess - -Wlogical-op - -Wlogical-not-parentheses - -Wstrict-prototypes - -Wmissing-declarations - -Wredundant-decls - -Wno-int-to-pointer-cast - -Wfloat-equal - -Wfloat-conversion - -Wmissing-prototypes - -Wunreachable-code) - endif() - if(fatal-warnings) - list(APPEND test_flags - -Werror) - endif() -elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") - set(test_flags) - if(extra-warnings) - list(APPEND test_flags - /W4) - else() - list(APPEND test_flags - /W3) - endif() - if (fatal-warnings) - list(APPEND test_flags - /WX) - endif() -endif() - -foreach(flag ${test_flags}) - string(REGEX REPLACE "[^A-Za-z0-9]" "_" flag_var "${flag}") - set(test_c_flag "C_FLAG${flag_var}") - CHECK_C_COMPILER_FLAG(${flag} "${test_c_flag}") - if (${test_c_flag}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") - endif (${test_c_flag}) -endforeach(flag ${test_flags}) diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/DeflateCodec.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/DeflateCodec.cmake deleted file mode 100644 index 76e5673e2..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/DeflateCodec.cmake +++ /dev/null @@ -1,45 +0,0 @@ -# Checks for deflate codec support -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - - -# ZLIB -set(ZLIB_SUPPORT FALSE) -find_package(ZLIB) -option(zlib "use zlib (required for Deflate compression)" ${ZLIB_FOUND}) -if(zlib AND ZLIB_FOUND) - set(ZLIB_SUPPORT TRUE) -endif() -set(ZIP_SUPPORT ${ZLIB_SUPPORT}) - -# libdeflate -set(LIBDEFLATE_SUPPORT FALSE) -find_package(Deflate) -option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND}) -if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT) - set(LIBDEFLATE_SUPPORT TRUE) -endif() -if(Deflate_FOUND AND NOT ZIP_SUPPORT) - message(WARNING "libdeflate available but zlib is not. libdeflate cannot be used") -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/FindCMath.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/FindCMath.cmake deleted file mode 100644 index ad922180b..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/FindCMath.cmake +++ /dev/null @@ -1,72 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindCMath --------- - -Find the native CMath includes and library. - -IMPORTED Targets -^^^^^^^^^^^^^^^^ - -This module defines :prop_tgt:`IMPORTED` target ``CMath::CMath``, if -CMath has been found. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -:: - - CMath_INCLUDE_DIRS - Where to find math.h - CMath_LIBRARIES - List of libraries when using CMath. - CMath_FOUND - True if CMath found. - -#]=======================================================================] - - -include(CheckSymbolExists) -include(CheckLibraryExists) - -check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW) -find_library(CMath_LIBRARY NAMES m) - -if(NOT CMath_HAVE_LIBC_POW) - set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMath_LIBRARY}) - check_symbol_exists(pow "math.h" CMath_HAVE_LIBM_POW) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) -endif() - -set(CMath_pow FALSE) -if(CMath_HAVE_LIBC_POW OR CMath_HAVE_LIBM_POW) - set(CMath_pow TRUE) -endif() - -set(CMath_INCLUDE_DIRS) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CMath REQUIRED_VARS CMath_pow) - -if(CMath_FOUND) - if(NOT CMath_INCLUDE_DIRS) - set(CMath_INCLUDE_DIRS) - endif() - if(NOT CMath_LIBRARIES) - if (CMath_LIBRARY) - set(CMath_LIBRARIES ${CMath_LIBRARY}) - endif() - endif() - - if(NOT TARGET CMath::CMath) - if(CMath_LIBRARIES) - add_library(CMath::CMath UNKNOWN IMPORTED) - set_target_properties(CMath::CMath PROPERTIES - IMPORTED_LOCATION "${CMath_LIBRARY}") - else() - add_library(CMath::CMath INTERFACE IMPORTED) - endif() - endif() -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/FindDeflate.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/FindDeflate.cmake deleted file mode 100644 index 3d606aa0c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/FindDeflate.cmake +++ /dev/null @@ -1,115 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindDeflate --------- - -Find the native Deflate includes and library. - -IMPORTED Targets -^^^^^^^^^^^^^^^^ - -This module defines :prop_tgt:`IMPORTED` target ``Deflate::Deflate``, if -Deflate has been found. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -:: - - Deflate_INCLUDE_DIRS - where to find deflate.h, etc. - Deflate_LIBRARIES - List of libraries when using deflate. - Deflate_FOUND - True if deflate found. - -:: - - Deflate_VERSION_STRING - The version of deflate found (x.y.z) - Deflate_VERSION_MAJOR - The major version of deflate - Deflate_VERSION_MINOR - The minor version of deflate - - Debug and Release variants are found separately. -#]=======================================================================] - -# Standard names to search for -set(Deflate_NAMES deflate deflatestatic) -set(Deflate_NAMES_DEBUG deflated deflatestaticd) - -find_path(Deflate_INCLUDE_DIR - NAMES libdeflate.h - PATH_SUFFIXES include) - -set(Deflate_OLD_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") -# Library has a "lib" prefix even on Windows. -set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") - -# Allow Deflate_LIBRARY to be set manually, as the location of the deflate library -if(NOT Deflate_LIBRARY) - find_library(Deflate_LIBRARY_RELEASE - NAMES ${Deflate_NAMES} - PATH_SUFFIXES lib) - find_library(Deflate_LIBRARY_DEBUG - NAMES ${Deflate_NAMES_DEBUG} - PATH_SUFFIXES lib) - - include(SelectLibraryConfigurations) - select_library_configurations(Deflate) -endif() - -set(CMAKE_FIND_LIBRARY_PREFIXES "${Deflate_OLD_FIND_LIBRARY_PREFIXES}") - -unset(Deflate_NAMES) -unset(Deflate_NAMES_DEBUG) -unset(Deflate_OLD_FIND_LIBRARY_PREFIXES) - -mark_as_advanced(Deflate_INCLUDE_DIR) - -if(Deflate_INCLUDE_DIR AND EXISTS "${Deflate_INCLUDE_DIR}/libdeflate.h") - file(STRINGS "${Deflate_INCLUDE_DIR}/libdeflate.h" Deflate_H REGEX "^#define[\t ]+LIBDEFLATE_VERSION_STRING[\t ]+.*") - string(REGEX REPLACE "^.*LIBDEFLATE_VERSION_STRING[\t ]+\"([0-9]+).*$" "\\1" Deflate_MAJOR_VERSION "${Deflate_H}") - string(REGEX REPLACE "^.*LIBDEFLATE_VERSION_STRING[\t ]\"[0-9]+\\.([0-9]+).*$" "\\1" Deflate_MINOR_VERSION "${Deflate_H}") - set(Deflate_VERSION_STRING "${Deflate_MAJOR_VERSION}.${Deflate_MINOR_VERSION}") - - set(Deflate_VERSION_MAJOR "${Deflate_MAJOR_VERSION}") - set(Deflate_VERSION_MINOR "${Deflate_MINOR_VERSION}") -endif() - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Deflate - REQUIRED_VARS Deflate_LIBRARY Deflate_INCLUDE_DIR - VERSION_VAR Deflate_VERSION_STRING) - -if(Deflate_FOUND) - set(Deflate_INCLUDE_DIRS ${Deflate_INCLUDE_DIR}) - - if(NOT Deflate_LIBRARIES) - set(Deflate_LIBRARIES ${Deflate_LIBRARY}) - endif() - - if(NOT TARGET Deflate::Deflate) - add_library(Deflate::Deflate UNKNOWN IMPORTED) - set_target_properties(Deflate::Deflate PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Deflate_INCLUDE_DIRS}") - - if(Deflate_LIBRARY_RELEASE) - set_property(TARGET Deflate::Deflate APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(Deflate::Deflate PROPERTIES - IMPORTED_LOCATION_RELEASE "${Deflate_LIBRARY_RELEASE}") - endif() - - if(Deflate_LIBRARY_DEBUG) - set_property(TARGET Deflate::Deflate APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(Deflate::Deflate PROPERTIES - IMPORTED_LOCATION_DEBUG "${Deflate_LIBRARY_DEBUG}") - endif() - - if(NOT Deflate_LIBRARY_RELEASE AND NOT Deflate_LIBRARY_DEBUG) - set_target_properties(Deflate::Deflate PROPERTIES - IMPORTED_LOCATION "${Deflate_LIBRARY}") - endif() - endif() -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/FindJBIG.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/FindJBIG.cmake deleted file mode 100644 index 4d8e106e2..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/FindJBIG.cmake +++ /dev/null @@ -1,116 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindJBIG --------- - -Find the native JBIG includes and library. - -IMPORTED Targets -^^^^^^^^^^^^^^^^ - -This module defines :prop_tgt:`IMPORTED` target ``JBIG::JBIG``, if -JBIG has been found. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -:: - - JBIG_INCLUDE_DIRS - where to find jbig.h, etc. - JBIG_LIBRARIES - List of libraries when using jbig. - JBIG_FOUND - True if jbig found. - -:: - - JBIG_VERSION_STRING - The version of jbig found (x.y.z) - JBIG_VERSION_MAJOR - The major version of jbig - JBIG_VERSION_MINOR - The minor version of jbig - - Debug and Release variants are found separately. -#]=======================================================================] - -# Standard names to search for -set(JBIG_NAMES jbig) -set(JBIG_NAMES_DEBUG jbigd) - -find_path(JBIG_INCLUDE_DIR - NAMES jbig.h - PATH_SUFFIXES include) - -set(JBIG_OLD_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") -# Library has a "lib" prefix even on Windows. -set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") - -# Allow JBIG_LIBRARY to be set manually, as the location of the jbig library -if(NOT JBIG_LIBRARY) - find_library(JBIG_LIBRARY_RELEASE - NAMES ${JBIG_NAMES} - PATH_SUFFIXES lib) - find_library(JBIG_LIBRARY_DEBUG - NAMES ${JBIG_NAMES_DEBUG} - PATH_SUFFIXES lib) - - include(SelectLibraryConfigurations) - select_library_configurations(JBIG) -endif() - -set(CMAKE_FIND_LIBRARY_PREFIXES "${JBIG_OLD_FIND_LIBRARY_PREFIXES}") - -unset(JBIG_NAMES) -unset(JBIG_NAMES_DEBUG) -unset(JBIG_OLD_FIND_LIBRARY_PREFIXES) - -mark_as_advanced(JBIG_INCLUDE_DIR) - -if(JBIG_INCLUDE_DIR AND EXISTS "${JBIG_INCLUDE_DIR}/jbig.h") - file(STRINGS "${JBIG_INCLUDE_DIR}/jbig.h" JBIG_H REGEX "^#define JBG_VERSION *\"[^\"]*\"$") - - string(REGEX REPLACE "^.*JBG_VERSION *\"([0-9]+).*$" "\\1" JBIG_MAJOR_VERSION "${JBIG_H}") - string(REGEX REPLACE "^.*JBG_VERSION *\"[0-9]+\\.([0-9]+).*$" "\\1" JBIG_MINOR_VERSION "${JBIG_H}") - set(JBIG_VERSION_STRING "${JBIG_MAJOR_VERSION}.${JBIG_MINOR_VERSION}") - - set(JBIG_MAJOR_VERSION "${JBIG_VERSION_MAJOR}") - set(JBIG_MINOR_VERSION "${JBIG_VERSION_MINOR}") -endif() - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(JBIG - REQUIRED_VARS JBIG_LIBRARY JBIG_INCLUDE_DIR - VERSION_VAR JBIG_VERSION_STRING) - -if(JBIG_FOUND) - set(JBIG_INCLUDE_DIRS ${JBIG_INCLUDE_DIR}) - - if(NOT JBIG_LIBRARIES) - set(JBIG_LIBRARIES ${JBIG_LIBRARY}) - endif() - - if(NOT TARGET JBIG::JBIG) - add_library(JBIG::JBIG UNKNOWN IMPORTED) - set_target_properties(JBIG::JBIG PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${JBIG_INCLUDE_DIRS}") - - if(JBIG_LIBRARY_RELEASE) - set_property(TARGET JBIG::JBIG APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(JBIG::JBIG PROPERTIES - IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY_RELEASE}") - endif() - - if(JBIG_LIBRARY_DEBUG) - set_property(TARGET JBIG::JBIG APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(JBIG::JBIG PROPERTIES - IMPORTED_LOCATION_DEBUG "${JBIG_LIBRARY_DEBUG}") - endif() - - if(NOT JBIG_LIBRARY_RELEASE AND NOT JBIG_LIBRARY_DEBUG) - set_target_properties(JBIG::JBIG PROPERTIES - IMPORTED_LOCATION "${JBIG_LIBRARY}") - endif() - endif() -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/FindJPEG.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/FindJPEG.cmake deleted file mode 100644 index 12d0844b4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/FindJPEG.cmake +++ /dev/null @@ -1,142 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindJPEG --------- - -Find the Joint Photographic Experts Group (JPEG) library (``libjpeg``) - -Imported targets -^^^^^^^^^^^^^^^^ - -.. versionadded:: 3.12 - -This module defines the following :prop_tgt:`IMPORTED` targets: - -``JPEG::JPEG`` - The JPEG library, if found. - -Result variables -^^^^^^^^^^^^^^^^ - -This module will set the following variables in your project: - -``JPEG_FOUND`` - If false, do not try to use JPEG. -``JPEG_INCLUDE_DIRS`` - where to find jpeglib.h, etc. -``JPEG_LIBRARIES`` - the libraries needed to use JPEG. -``JPEG_VERSION`` - .. versionadded:: 3.12 - the version of the JPEG library found - -Cache variables -^^^^^^^^^^^^^^^ - -The following cache variables may also be set: - -``JPEG_INCLUDE_DIRS`` - where to find jpeglib.h, etc. -``JPEG_LIBRARY_RELEASE`` - where to find the JPEG library (optimized). -``JPEG_LIBRARY_DEBUG`` - where to find the JPEG library (debug). - -.. versionadded:: 3.12 - Debug and Release variand are found separately. - -Obsolete variables -^^^^^^^^^^^^^^^^^^ - -``JPEG_INCLUDE_DIR`` - where to find jpeglib.h, etc. (same as JPEG_INCLUDE_DIRS) -``JPEG_LIBRARY`` - where to find the JPEG library. -#]=======================================================================] - -find_path(JPEG_INCLUDE_DIR jpeglib.h) - -set(jpeg_names ${JPEG_NAMES} jpeg jpeg-static libjpeg libjpeg-static turbojpeg turbojpeg-static) -foreach(name ${jpeg_names}) - list(APPEND jpeg_names_debug "${name}d") -endforeach() - -if(NOT JPEG_LIBRARY) - find_library(JPEG_LIBRARY_RELEASE NAMES ${jpeg_names} NAMES_PER_DIR) - find_library(JPEG_LIBRARY_DEBUG NAMES ${jpeg_names_debug} NAMES_PER_DIR) - include(SelectLibraryConfigurations) - select_library_configurations(JPEG) - mark_as_advanced(JPEG_LIBRARY_RELEASE JPEG_LIBRARY_DEBUG) -endif() -unset(jpeg_names) -unset(jpeg_names_debug) - -if(JPEG_INCLUDE_DIR) - file(GLOB _JPEG_CONFIG_HEADERS_FEDORA "${JPEG_INCLUDE_DIR}/jconfig*.h") - file(GLOB _JPEG_CONFIG_HEADERS_DEBIAN "${JPEG_INCLUDE_DIR}/*/jconfig.h") - set(_JPEG_CONFIG_HEADERS - "${JPEG_INCLUDE_DIR}/jpeglib.h" - ${_JPEG_CONFIG_HEADERS_FEDORA} - ${_JPEG_CONFIG_HEADERS_DEBIAN}) - foreach (_JPEG_CONFIG_HEADER IN LISTS _JPEG_CONFIG_HEADERS) - if (NOT EXISTS "${_JPEG_CONFIG_HEADER}") - continue () - endif () - file(STRINGS "${_JPEG_CONFIG_HEADER}" - jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*") - - if (NOT jpeg_lib_version) - continue () - endif () - - string(REGEX REPLACE "^#define[\t ]+JPEG_LIB_VERSION[\t ]+([0-9]+).*" - "\\1" JPEG_VERSION "${jpeg_lib_version}") - break () - endforeach () - unset(jpeg_lib_version) - unset(_JPEG_CONFIG_HEADER) - unset(_JPEG_CONFIG_HEADERS) - unset(_JPEG_CONFIG_HEADERS_FEDORA) - unset(_JPEG_CONFIG_HEADERS_DEBIAN) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(JPEG - REQUIRED_VARS JPEG_LIBRARY JPEG_INCLUDE_DIR - VERSION_VAR JPEG_VERSION) - -if(JPEG_FOUND) - set(JPEG_LIBRARIES ${JPEG_LIBRARY}) - set(JPEG_INCLUDE_DIRS "${JPEG_INCLUDE_DIR}") - - if(NOT TARGET JPEG::JPEG) - add_library(JPEG::JPEG UNKNOWN IMPORTED) - if(JPEG_INCLUDE_DIRS) - set_target_properties(JPEG::JPEG PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIRS}") - endif() - if(EXISTS "${JPEG_LIBRARY}") - set_target_properties(JPEG::JPEG PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${JPEG_LIBRARY}") - endif() - if(EXISTS "${JPEG_LIBRARY_RELEASE}") - set_property(TARGET JPEG::JPEG APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(JPEG::JPEG PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C" - IMPORTED_LOCATION_RELEASE "${JPEG_LIBRARY_RELEASE}") - endif() - if(EXISTS "${JPEG_LIBRARY_DEBUG}") - set_property(TARGET JPEG::JPEG APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(JPEG::JPEG PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C" - IMPORTED_LOCATION_DEBUG "${JPEG_LIBRARY_DEBUG}") - endif() - endif() -endif() - -mark_as_advanced(JPEG_LIBRARY JPEG_INCLUDE_DIR) diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/FindLERC.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/FindLERC.cmake deleted file mode 100644 index aff7ea66d..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/FindLERC.cmake +++ /dev/null @@ -1,100 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindLerc --------- - -Find the native Lerc includes and library. - -IMPORTED Targets -^^^^^^^^^^^^^^^^ - -This module defines :prop_tgt:`IMPORTED` target ``LERC::LERC``, if -LERC has been found. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -:: - - LERC_INCLUDE_DIRS - where to find Lerc_c_api.h, etc. - LERC_LIBRARIES - List of libraries when using LERC. - LERC_FOUND - True if LERC found. - LERC_VERSION_STRING - version number as a string (ex: "4.0.1") - -#]=======================================================================] - -# Standard names to search for -set(LERC_NAMES LercLib Lerc) - -find_path(LERC_INCLUDE_DIR - NAMES Lerc_c_api.h - PATH_SUFFIXES include) - -# Allow LERC_LIBRARY to be set manually, as the location of the deflate library -if(NOT LERC_LIBRARY) - find_library(LERC_LIBRARY_RELEASE - NAMES ${LERC_NAMES} - PATH_SUFFIXES lib) - - include(SelectLibraryConfigurations) - select_library_configurations(LERC) -endif() - -unset(LERC_NAMES) - -mark_as_advanced(LERC_INCLUDE_DIR) - -if(LERC_INCLUDE_DIR AND EXISTS "${LERC_INCLUDE_DIR}/Lerc_c_api.h") - file(STRINGS "${LERC_INCLUDE_DIR}/Lerc_c_api.h" LERC_H REGEX "^#define[\t ]+LERC_VERSION_[A-Z]+[\t ]+[0-9]+") - string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_MAJOR[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_MAJOR "${LERC_H}") - string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_MINOR[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_MINOR "${LERC_H}") - string(REGEX REPLACE "^.*#define[\t ]+LERC_VERSION_PATCH[\t ]+([0-9]+).*$" "\\1" LERC_VERSION_PATCH "${LERC_H}") - set(LERC_VERSION_STRING "${LERC_VERSION_MAJOR}.${LERC_VERSION_MINOR}.${LERC_VERSION_PATCH}") - unset(LERC_H) - unset(LERC_VERSION_MAJOR) - unset(LERC_VERSION_MINOR) - unset(LERC_VERSION_PATCH) -endif() - - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LERC - REQUIRED_VARS LERC_LIBRARY LERC_INCLUDE_DIR - VERSION_VAR LERC_VERSION_STRING) - -if(LERC_FOUND) - set(LERC_INCLUDE_DIRS ${LERC_INCLUDE_DIR}) - - if(NOT LERC_LIBRARIES) - set(LERC_LIBRARIES ${LERC_LIBRARY}) - endif() - - if(NOT TARGET LERC::LERC) - add_library(LERC::LERC UNKNOWN IMPORTED) - set_target_properties(LERC::LERC PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${LERC_INCLUDE_DIRS}") - - if(LERC_LIBRARY_RELEASE) - set_property(TARGET LERC::LERC APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(LERC::LERC PROPERTIES - IMPORTED_LOCATION_RELEASE "${LERC_LIBRARY_RELEASE}") - endif() - - if(LERC_LIBRARY_DEBUG) - set_property(TARGET LERC::LERC APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(LERC::LERC PROPERTIES - IMPORTED_LOCATION_DEBUG "${LERC_LIBRARY_DEBUG}") - endif() - - if(NOT LERC_LIBRARY_RELEASE AND NOT LERC_LIBRARY_DEBUG) - set_target_properties(LERC::LERC PROPERTIES - IMPORTED_LOCATION "${LERC_LIBRARY}") - endif() - endif() -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/FindWebP.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/FindWebP.cmake deleted file mode 100644 index 675bf8c35..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/FindWebP.cmake +++ /dev/null @@ -1,91 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindWebP --------- - -Find the native WebP includes and library. - -IMPORTED Targets -^^^^^^^^^^^^^^^^ - -This module defines :prop_tgt:`IMPORTED` target ``WebP::webp``, if -WebP has been found. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -:: - - WebP_INCLUDE_DIRS - where to find webp/*.h, etc. - WebP_LIBRARIES - List of libraries when using webp. - WebP_FOUND - True if webp found. - - Debug and Release variants are found separately. -#]=======================================================================] - -# Standard names to search for -set(WebP_NAMES webp) -set(WebP_NAMES_DEBUG webpd) - -find_path(WebP_INCLUDE_DIR - NAMES webp/decode.h - PATH_SUFFIXES include) - -# Allow WebP_LIBRARY to be set manually, as the location of the webp library -if(NOT WebP_LIBRARY) - find_library(WebP_LIBRARY_RELEASE - NAMES ${WebP_NAMES} - PATH_SUFFIXES lib) - find_library(WebP_LIBRARY_DEBUG - NAMES ${WebP_NAMES_DEBUG} - PATH_SUFFIXES lib) - - include(SelectLibraryConfigurations) - select_library_configurations(WebP) -endif() - -unset(WebP_NAMES) -unset(WebP_NAMES_DEBUG) - -mark_as_advanced(WebP_INCLUDE_DIR) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(WebP - REQUIRED_VARS WebP_LIBRARY WebP_INCLUDE_DIR) - -if(WebP_FOUND) - set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR}) - - if(NOT WebP_LIBRARIES) - set(WebP_LIBRARIES ${WebP_LIBRARY}) - endif() - - if(NOT TARGET WebP::webp) - add_library(WebP::webp UNKNOWN IMPORTED) - set_target_properties(WebP::webp PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIRS}") - - if(WebP_LIBRARY_RELEASE) - set_property(TARGET WebP::webp APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(WebP::webp PROPERTIES - IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}") - endif() - - if(WebP_LIBRARY_DEBUG) - set_property(TARGET WebP::webp APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(WebP::webp PROPERTIES - IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}") - endif() - - if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG) - set_target_properties(WebP::webp PROPERTIES - IMPORTED_LOCATION "${WebP_LIBRARY}") - endif() - endif() -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/FindZSTD.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/FindZSTD.cmake deleted file mode 100644 index 2e217f11c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/FindZSTD.cmake +++ /dev/null @@ -1,107 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindZSTD --------- - -Find the native ZSTD includes and library. - -IMPORTED Targets -^^^^^^^^^^^^^^^^ - -This module defines :prop_tgt:`IMPORTED` target ``ZSTD::ZSTD``, if -ZSTD has been found. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -:: - - ZSTD_INCLUDE_DIRS - where to find zstd.h, etc. - ZSTD_LIBRARIES - List of libraries when using zstd. - ZSTD_FOUND - True if zstd found. - -:: - - ZSTD_VERSION_STRING - The version of zstd found (x.y.z) - ZSTD_VERSION_MAJOR - The major version of zstd - ZSTD_VERSION_MINOR - The minor version of zstd - - Debug and Release variants are found separately. -#]=======================================================================] - -# Standard names to search for -set(ZSTD_NAMES zstd zstd_static) -set(ZSTD_NAMES_DEBUG zstdd zstd_staticd) - -find_path(ZSTD_INCLUDE_DIR - NAMES zstd.h - PATH_SUFFIXES include) - -# Allow ZSTD_LIBRARY to be set manually, as the location of the zstd library -if(NOT ZSTD_LIBRARY) - find_library(ZSTD_LIBRARY_RELEASE - NAMES ${ZSTD_NAMES} - PATH_SUFFIXES lib) - find_library(ZSTD_LIBRARY_DEBUG - NAMES ${ZSTD_NAMES_DEBUG} - PATH_SUFFIXES lib) - - include(SelectLibraryConfigurations) - select_library_configurations(ZSTD) -endif() - -unset(ZSTD_NAMES) -unset(ZSTD_NAMES_DEBUG) - -mark_as_advanced(ZSTD_INCLUDE_DIR) - -if(ZSTD_INCLUDE_DIR AND EXISTS "${ZSTD_INCLUDE_DIR}/zstd.h") - file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" ZSTD_H REGEX "^#define ZSTD_VERSION_.*$") - - string(REGEX REPLACE "^.*ZSTD_VERSION_MAJOR *([0-9]+).*$" "\\1" ZSTD_MAJOR_VERSION "${ZSTD_H}") - string(REGEX REPLACE "^.*ZSTD_VERSION_MINOR *([0-9]+).*$" "\\1" ZSTD_MINOR_VERSION "${ZSTD_H}") - string(REGEX REPLACE "^.*ZSTD_VERSION_RELEASE *([0-9]+).*$" "\\1" ZSTD_PATCH_VERSION "${ZSTD_H}") - set(ZSTD_VERSION_STRING "${ZSTD_MAJOR_VERSION}.${ZSTD_MINOR_VERSION}.${ZSTD_PATCH_VERSION}") -endif() - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZSTD - REQUIRED_VARS ZSTD_LIBRARY ZSTD_INCLUDE_DIR - VERSION_VAR ZSTD_VERSION_STRING) - -if(ZSTD_FOUND) - set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR}) - - if(NOT ZSTD_LIBRARIES) - set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) - endif() - - if(NOT TARGET ZSTD::ZSTD) - add_library(ZSTD::ZSTD UNKNOWN IMPORTED) - set_target_properties(ZSTD::ZSTD PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}") - - if(ZSTD_LIBRARY_RELEASE) - set_property(TARGET ZSTD::ZSTD APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(ZSTD::ZSTD PROPERTIES - IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}") - endif() - - if(ZSTD_LIBRARY_DEBUG) - set_property(TARGET ZSTD::ZSTD APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(ZSTD::ZSTD PROPERTIES - IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}") - endif() - - if(NOT ZSTD_LIBRARY_RELEASE AND NOT ZSTD_LIBRARY_DEBUG) - set_target_properties(ZSTD::ZSTD PROPERTIES - IMPORTED_LOCATION "${ZSTD_LIBRARY}") - endif() - endif() -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/Findliblzma.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/Findliblzma.cmake deleted file mode 100644 index 8dd5bc2ea..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/Findliblzma.cmake +++ /dev/null @@ -1,126 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -Findliblzma ------------ - -Find LZMA compression algorithm headers and library. - - -Imported Targets -^^^^^^^^^^^^^^^^ - -.. versionadded:: 3.14 - -This module defines :prop_tgt:`IMPORTED` target ``liblzma::liblzma``, if -liblzma has been found. - -Result variables -^^^^^^^^^^^^^^^^ - -This module will set the following variables in your project: - -``liblzma_FOUND`` - True if liblzma headers and library were found. -``LIBLZMA_INCLUDE_DIRS`` - Directory where liblzma headers are located. -``LIBLZMA_LIBRARIES`` - Lzma libraries to link against. -``LIBLZMA_HAS_AUTO_DECODER`` - True if lzma_auto_decoder() is found (required). -``LIBLZMA_HAS_EASY_ENCODER`` - True if lzma_easy_encoder() is found (required). -``LIBLZMA_HAS_LZMA_PRESET`` - True if lzma_lzma_preset() is found (required). -``LIBLZMA_VERSION_MAJOR`` - The major version of lzma -``LIBLZMA_VERSION_MINOR`` - The minor version of lzma -``LIBLZMA_VERSION_PATCH`` - The patch version of lzma -``LIBLZMA_VERSION_STRING`` - version number as a string (ex: "5.0.3") -#]=======================================================================] - -find_path(LIBLZMA_INCLUDE_DIR lzma.h ) -if(NOT LIBLZMA_LIBRARY) - find_library(LIBLZMA_LIBRARY_RELEASE NAMES lzma liblzma NAMES_PER_DIR PATH_SUFFIXES lib) - find_library(LIBLZMA_LIBRARY_DEBUG NAMES lzmad liblzmad NAMES_PER_DIR PATH_SUFFIXES lib) - include(SelectLibraryConfigurations) - select_library_configurations(LIBLZMA) -else() - file(TO_CMAKE_PATH "${LIBLZMA_LIBRARY}" LIBLZMA_LIBRARY) -endif() - -if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h") - file(STRINGS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h" LIBLZMA_HEADER_CONTENTS REGEX "#define LZMA_VERSION_[A-Z]+ [0-9]+") - - string(REGEX REPLACE ".*#define LZMA_VERSION_MAJOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MAJOR "${LIBLZMA_HEADER_CONTENTS}") - string(REGEX REPLACE ".*#define LZMA_VERSION_MINOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MINOR "${LIBLZMA_HEADER_CONTENTS}") - string(REGEX REPLACE ".*#define LZMA_VERSION_PATCH ([0-9]+).*" "\\1" LIBLZMA_VERSION_PATCH "${LIBLZMA_HEADER_CONTENTS}") - - set(LIBLZMA_VERSION_STRING "${LIBLZMA_VERSION_MAJOR}.${LIBLZMA_VERSION_MINOR}.${LIBLZMA_VERSION_PATCH}") - unset(LIBLZMA_HEADER_CONTENTS) -endif() - -# We're using new code known now as XZ, even library still been called LZMA -# it can be found in http://tukaani.org/xz/ -# Avoid using old codebase -if (LIBLZMA_LIBRARY) - include(CheckLibraryExists) - set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) - set(CMAKE_REQUIRED_QUIET ${liblzma_FIND_QUIETLY}) - if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG) - set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY}) - elseif(LIBLZMA_LIBRARY_RELEASE) - set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_RELEASE}) - elseif(LIBLZMA_LIBRARY_DEBUG) - set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_DEBUG}) - endif() - CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER) - CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER) - CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET) - unset(LIBLZMA_LIBRARY_check) - set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) -endif () - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(liblzma REQUIRED_VARS LIBLZMA_LIBRARY - LIBLZMA_INCLUDE_DIR - LIBLZMA_HAS_AUTO_DECODER - LIBLZMA_HAS_EASY_ENCODER - LIBLZMA_HAS_LZMA_PRESET - VERSION_VAR LIBLZMA_VERSION_STRING - ) -mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY ) - -if (liblzma_FOUND) - set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY}) - set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR}) - if(NOT TARGET liblzma::liblzma) - add_library(liblzma::liblzma UNKNOWN IMPORTED) - set_target_properties(liblzma::liblzma PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR} - IMPORTED_LINK_INTERFACE_LANGUAGES C) - - if(LIBLZMA_LIBRARY_RELEASE) - set_property(TARGET liblzma::liblzma APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(liblzma::liblzma PROPERTIES - IMPORTED_LOCATION_RELEASE "${LIBLZMA_LIBRARY_RELEASE}") - endif() - - if(LIBLZMA_LIBRARY_DEBUG) - set_property(TARGET liblzma::liblzma APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(liblzma::liblzma PROPERTIES - IMPORTED_LOCATION_DEBUG "${LIBLZMA_LIBRARY_DEBUG}") - endif() - - if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG) - set_target_properties(liblzma::liblzma PROPERTIES - IMPORTED_LOCATION "${LIBLZMA_LIBRARY}") - endif() - endif() -endif () diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/IncludeChecks.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/IncludeChecks.cmake deleted file mode 100644 index 08873598d..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/IncludeChecks.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# Checks for headers -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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(CheckIncludeFile) - - -check_include_file(assert.h HAVE_ASSERT_H) -check_include_file(fcntl.h HAVE_FCNTL_H) -check_include_file(io.h HAVE_IO_H) -check_include_file(strings.h HAVE_STRINGS_H) -check_include_file(sys/time.h HAVE_SYS_TIME_H) -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(unistd.h HAVE_UNISTD_H) diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/JPEGCodec.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/JPEGCodec.cmake deleted file mode 100644 index 8455a3ece..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/JPEGCodec.cmake +++ /dev/null @@ -1,84 +0,0 @@ -# Checks for JPEG codec support -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - - -# JPEG -set(JPEG_SUPPORT FALSE) -find_package(JPEG) -option(jpeg "use libjpeg (required for JPEG compression)" ${JPEG_FOUND}) -if (jpeg AND JPEG_FOUND) - set(JPEG_SUPPORT TRUE) -endif() - -# Old-jpeg -set(OJPEG_SUPPORT FALSE) -option(old-jpeg "support for Old JPEG compression (read-only)" ${JPEG_SUPPORT}) -if (old-jpeg AND JPEG_SUPPORT) - set(OJPEG_SUPPORT TRUE) -endif() - -if (JPEG_SUPPORT) - # Check for jpeg12_read_scanlines() which has been added in libjpeg-turbo 2.2 - # for dual 8/12 bit mode. - include(CheckCSourceCompiles) - include(CMakePushCheckState) - cmake_push_check_state(RESET) - set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIRS}") - set(CMAKE_REQUIRED_LIBRARIES "${JPEG_LIBRARIES}") - check_c_source_compiles( - " - #include - #include - #include \"jpeglib.h\" - int main() - { - jpeg_read_scanlines(0,0,0); - jpeg12_read_scanlines(0,0,0); - return 0; - } - " - HAVE_JPEGTURBO_DUAL_MODE_8_12) - cmake_pop_check_state() -endif() - -if (NOT HAVE_JPEGTURBO_DUAL_MODE_8_12) - - # 12-bit jpeg mode in a dedicated libjpeg12 library - set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg") - set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library") - set(JPEG_DUAL_MODE_8_12 FALSE) - if (JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY) - set(JPEG12_LIBRARIES ${JPEG12_LIBRARY}) - set(JPEG12_FOUND TRUE) - else() - set(JPEG12_FOUND FALSE) - endif() - option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate 12-bit libjpeg build)" ${JPEG12_FOUND}) - if (jpeg12 AND JPEG12_FOUND) - set(JPEG_DUAL_MODE_8_12 TRUE) - set(LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h") - endif() - -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/LibraryFeatures.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/LibraryFeatures.cmake deleted file mode 100644 index 89635d64e..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/LibraryFeatures.cmake +++ /dev/null @@ -1,62 +0,0 @@ -# C library features -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - -# Strip chopping -option(strip-chopping "strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)" ON) -set(TIFF_DEFAULT_STRIP_SIZE 8192 CACHE STRING "default size of the strip in bytes (when strip chopping is enabled)") - -set(STRIPCHOP_DEFAULT) -if(strip-chopping) - set(STRIPCHOP_DEFAULT TRUE) - if(TIFF_DEFAULT_STRIP_SIZE) - set(STRIP_SIZE_DEFAULT "${TIFF_DEFAULT_STRIP_SIZE}") - endif() -endif() - -set(TIFF_MAX_DIR_COUNT 1048576 CACHE STRING "Maximum number of TIFF directories that libtiff can browse through") - -# Defer loading of strip/tile offsets -option(defer-strile-load "enable deferred strip/tile offset/size loading (also available at runtime with the 'D' flag of TIFFOpen())" OFF) -set(DEFER_STRILE_LOAD ${defer-strile-load}) - -# CHUNKY_STRIP_READ_SUPPORT -option(chunky-strip-read "enable reading large strips in chunks for TIFFReadScanline() (experimental)" OFF) -set(CHUNKY_STRIP_READ_SUPPORT ${chunky-strip-read}) - -# SUBIFD support -set(SUBIFD_SUPPORT 1) - -# Default handling of ASSOCALPHA support. -option(extrasample-as-alpha "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" ON) -if(extrasample-as-alpha) - set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1) -endif() - -# Default handling of YCbCr subsampling support. -# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details. -option(check-ycbcr-subsampling "enable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag" ON) -if (check-ycbcr-subsampling) - set(CHECK_JPEG_YCBCR_SUBSAMPLING 1) -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/OpenGLChecks.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/OpenGLChecks.cmake deleted file mode 100644 index 4b11d70f5..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/OpenGLChecks.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# Checks for OpenGL and GLUT support -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - -# OpenGL and GLUT -set(OpenGL_GL_PREFERENCE LEGACY) - -find_package(OpenGL COMPONENTS OpenGL) -find_package(GLUT) - -set(OPENGL_SUPPORT FALSE) -set(HAVE_OPENGL FALSE) -if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) - set(HAVE_OPENGL TRUE) -endif() - -# Purely to satisfy the generated headers: -check_include_file(GL/gl.h HAVE_GL_GL_H) -check_include_file(GL/glu.h HAVE_GL_GLU_H) -check_include_file(GL/glut.h HAVE_GL_GLUT_H) -check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) -check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) -check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) - -option(tiff-opengl "use OpenGL (required for tiffgt viewer)" ${HAVE_OPENGL}) - -if (tiff-opengl AND HAVE_OPENGL) - set(OPENGL_SUPPORT TRUE) -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/PixarLogCodec.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/PixarLogCodec.cmake deleted file mode 100644 index db363050d..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/PixarLogCodec.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# Checks for PixarLog codec support -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - - -# Option for Pixar log-format algorithm -# Pixar log format -set(PIXARLOG_SUPPORT FALSE) -option(pixarlog "support for Pixar log-format algorithm (requires Zlib)" ${ZLIB_SUPPORT}) -if(pixarlog AND ZLIB_SUPPORT) - set(PIXARLOG_SUPPORT TRUE) -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/PkgConfig.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/PkgConfig.cmake deleted file mode 100644 index 75dc28e89..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/PkgConfig.cmake +++ /dev/null @@ -1,69 +0,0 @@ -# pkg-config support -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - -# Post-process lib files into linker flags -function(set_libs_private out_var) - set(tiff_libs_private "") - foreach(lib IN LISTS ARGN) - get_filename_component(name "${lib}" NAME) - foreach(prefix IN LISTS CMAKE_FIND_LIBRARY_PREFIXES) - if(NOT("${prefix}" STREQUAL "") AND name MATCHES "^${prefix}") - string(REGEX REPLACE "^${prefix}" "" name "${name}") - break() - endif() - endforeach() - foreach(suffix IN LISTS CMAKE_FIND_LIBRARY_SUFFIXES) - if(NOT("${suffix}" STREQUAL "") AND name MATCHES "${suffix}$") - string(REGEX REPLACE "${suffix}$" "" name "${name}") - break() - endif() - endforeach() - string(APPEND tiff_libs_private " -l${name}") - endforeach() - set(${out_var} "${tiff_libs_private}" PARENT_SCOPE) -endfunction() - -# Generate pkg-config file -set(prefix "${CMAKE_INSTALL_PREFIX}") -set(exec_prefix "\${prefix}") -if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") - set(libdir "${CMAKE_INSTALL_LIBDIR}") -else() - set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") -endif() -if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") - set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") -else() - set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") -endif() -set_libs_private(tiff_libs_private ${tiff_libs_private_list}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in - ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc @ONLY) - -# Install pkg-config file -if (tiff-install) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/Release.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/Release.cmake deleted file mode 100644 index 5deba03da..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/Release.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# Release support -# -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - - -add_custom_target(tiff_release - COMMAND ${CMAKE_COMMAND} - "-DSOURCE_DIR:PATH=${PROJECT_SOURCE_DIR}" - "-DLIBTIFF_VERSION=${PROJECT_VERSION}" - -P "${CMAKE_CURRENT_LIST_DIR}/ReleaseScript.cmake" - COMMENT "Releasing ${PROJECT_NAME} ${PROJECT_VERSION}") diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/Sphinx.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/Sphinx.cmake deleted file mode 100644 index bef3bf553..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/Sphinx.cmake +++ /dev/null @@ -1,93 +0,0 @@ -# #%L -# OME Files C++ libraries (cmake build infrastructure) -# %% -# Copyright © 2015 Open Microscopy Environment: -# - Massachusetts Institute of Technology -# - National Institutes of Health -# - University of Dundee -# - Board of Regents of the University of Wisconsin-Madison -# - Glencoe Software, Inc. -# %% -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of any organization. -# #L% - -find_package(Python3 COMPONENTS Interpreter) - -# Sphinx documentation generator -find_program(SPHINX_BUILD sphinx-build) -if (SPHINX_BUILD) - message(STATUS "Looking for sphinx-build - ${SPHINX_BUILD}") -else() - message(STATUS "Looking for sphinx-build - not found") -endif() - -set(SPHINX_DEFAULT OFF) -if(SPHINX_BUILD) - set(SPHINX_DEFAULT ON) -endif() -option(sphinx "Enable sphinx manual page and HTML documentation" ${SPHINX_DEFAULT}) -option(sphinx-linkcheck "Check sphinx documentation links by default" OFF) - -set(BUILD_SPHINX ${sphinx}) -set(SPHINX_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}) - -function(sphinx_manpages srcdir builddir manvar) - execute_process(COMMAND "${Python3_EXECUTABLE}" -B ${SPHINX_LIST_DIR}/list-manpages.py - "${srcdir}" "${builddir}" - RESULT_VARIABLE sphinx_man_fail - OUTPUT_VARIABLE MAN_PAGES) - if (sphinx_man_fail) - message(WARNING "Failed to get generated sphinx manual pages from ${confdir}") - endif() - string(REPLACE "\n" ";" MAN_PAGES "${MAN_PAGES}") - set(${manvar} "${MAN_PAGES}" PARENT_SCOPE) - - message(STATUS "Sphinx manual pages: ${MAN_PAGES}") -endfunction(sphinx_manpages) - -function(sphinx_manpage_dependencies srcdir depvar) - execute_process(COMMAND "${Python3_EXECUTABLE}" -B ${SPHINX_LIST_DIR}/list-manpage-dependencies.py - "${srcdir}" - RESULT_VARIABLE sphinx_dep_fail - OUTPUT_VARIABLE SPHINX_MAN_DEPENDENCIES) - if (sphinx_dep_fail) - message(WARNING "Failed to get Sphinx dependencies from ${confdir}") - endif() - string(REPLACE "\n" ";" SPHINX_MAN_DEPENDENCIES "${SPHINX_MAN_DEPENDENCIES}") - - set(${depvar} "${SPHINX_MAN_DEPENDENCIES}" PARENT_SCOPE) -endfunction(sphinx_manpage_dependencies) - -function(sphinx_dependencies srcdir depvar) - file(GLOB_RECURSE CRUDE_SPHINX_DEPENDENCIES "${srcdir}/*.rst") - foreach(file ${CRUDE_SPHINX_DEPENDENCIES}) - string(FIND "${file}" "_build" FILE_MATCH) - if(FILE_MATCH EQUAL -1) - list(APPEND SPHINX_DEPENDENCIES "${file}") - endif() - endforeach() - set(${depvar} "${SPHINX_DEPENDENCIES}" PARENT_SCOPE) -endfunction(sphinx_dependencies) diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/SphinxCheckInternalLinks.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/SphinxCheckInternalLinks.cmake deleted file mode 100644 index 32c2566e7..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/SphinxCheckInternalLinks.cmake +++ /dev/null @@ -1,87 +0,0 @@ -# Check "local" sphinx links, using files in the build tree and in the -# install tree (other components) - -message(STATUS "Checking internal links") - -set(failed OFF) - -file(STRINGS "${OUTPUT}" output) -file(REMOVE "${OUTPUT}.new") -foreach(line IN LISTS output) - # Parse the filename, link type, link and anchor from each line - string(REGEX MATCH "^.*: \\[.*\\] .*" line_match "${line}") - string(REGEX MATCH "^.*: \\[.*\\] .*#.*" anchor_match "${line}") - if(line_match) - string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)" "\\1" filename "${line}") - string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)" "\\2" type "${line}") - if(anchor_match) - string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)#(.*)" "\\3" link "${line}") - string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)#(.*)" "\\4" link "${anchor}") - else() - string(REGEX REPLACE "^(.*): \\[(.*)\\] (.*)" "\\3" link "${line}") - unset(anchor) - endif() - - # Only check local links - if(type STREQUAL "local") - # Compute path relative to our install path - file(RELATIVE_PATH relpath "/" "/${SPHINX_INSTALL_PATH}/${link}") - - # Check sphinx link in the install tree - unset(linkfile) - if(EXISTS "${EXTERNAL_REFERENCE}/${relpath}") - set(linkfile "${EXTERNAL_REFERENCE}/${relpath}") - endif() - # Check sphinx link in the build tree - if(EXISTS "${INTERNAL_REFERENCE}/${link}") - set(linkfile "${INTERNAL_REFERENCE}/${link}") - endif() - # Check doxygen link in the install tree - if(EXISTS "${DOXYGEN_REFERENCE}/${link}") - set(linkfile "${DOXYGEN_REFERENCE}/${link}") - endif() - # Check doxygen link in the build tree - if(DOXYGEN_REFERENCE AND DOXYGEN_INSTALL_PATH) - string(REGEX REPLACE "^${DOXYGEN_INSTALL_PATH}/(.*)" "\\1" doxygen_path "${relpath}") - if(EXISTS "${DOXYGEN_REFERENCE}/${doxygen_path}") - set(linkfile "${DOXYGEN_REFERENCE}/${doxygen_path}") - endif() - endif() - # Check link and any anchor. If the link does not exist, or the - # anchor does not exist, set the link type to broken when - # rewriting the output file with our test results. - if(linkfile) - if(anchor) - file(STRINGS "${linkfile}" anchor_matches REGEX " -# Written by Roger Leigh -# -# 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("CheckTypeSize") - -set(CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES}) -set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "stddef.h") -check_type_size("size_t" SIZEOF_SIZE_T) -set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE}) - -# C99 fixed-size integer types -set(TIFF_INT8_T "int8_t") -set(TIFF_UINT8_T "uint8_t") - -set(TIFF_INT16_T "int16_t") -set(TIFF_UINT16_T "uint16_t") - -set(TIFF_INT32_T "int32_t") -set(TIFF_UINT32_T "uint32_t") - -set(TIFF_INT64_T "int64_t") -set(TIFF_UINT64_T "uint64_t") - -# size_t and TIFF signed size-type -if(SIZEOF_SIZE_T EQUAL 4) - set(TIFF_SSIZE_T "int32_t") -elseif(SIZEOF_SIZE_T EQUAL 8) - set(TIFF_SSIZE_T "int64_t") -else() - message(FATAL_ERROR "Unsupported size_t size ${SIZEOF_SIZE_T}; please add support") -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/ZSTDCodec.cmake b/thirdparty/SDL2_image/external/libtiff/cmake/ZSTDCodec.cmake deleted file mode 100644 index f8f90cc76..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/ZSTDCodec.cmake +++ /dev/null @@ -1,66 +0,0 @@ -# Checks for LZMA codec support -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh -# -# 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. - - -# libzstd -set(ZSTD_SUPPORT FALSE) -set(ZSTD_USABLE FALSE) - -find_package(ZSTD) - -if(ZSTD_FOUND) - if(TARGET zstd::libzstd_shared) - add_library(ZSTD::ZSTD INTERFACE IMPORTED) - set_target_properties(ZSTD::ZSTD PROPERTIES INTERFACE_LINK_LIBRARIES "zstd::libzstd_shared") - set(ZSTD_HAVE_DECOMPRESS_STREAM ON) - elseif(TARGET zstd::libzstd_static) - add_library(ZSTD::ZSTD INTERFACE IMPORTED) - set_target_properties(ZSTD::ZSTD PROPRETIES INTERFACE_LINK_LIBRARIES "zstd::libzstd_static") - set(ZSTD_HAVE_DECOMPRESS_STREAM ON) - endif() - - if(NOT DEFINED ZSTD_HAVE_DECOMPRESS_STREAM) - set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS}) - set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES}) - check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_HAVE_DECOMPRESS_STREAM) - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) - endif() - set(ZSTD_RECENT_ENOUGH ${ZSTD_HAVE_DECOMPRESS_STREAM}) - - if (ZSTD_RECENT_ENOUGH) - set(ZSTD_USABLE TRUE) - else() - message(WARNING "Found ZSTD library, but not recent enough. Use zstd >= 1.0") - endif() -endif() - -option(zstd "use libzstd (required for ZSTD compression)" ${ZSTD_USABLE}) - -if (zstd AND ZSTD_USABLE) - set(ZSTD_SUPPORT TRUE) -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/list-manpage-dependencies.py b/thirdparty/SDL2_image/external/libtiff/cmake/list-manpage-dependencies.py deleted file mode 100644 index 67e79ad50..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/list-manpage-dependencies.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python - -# Find manual page dependencies -# argv1 = doc dir containing conf.py - -import importlib.util -import os.path -import pathlib -import sys - -if __name__ == "__main__": - - if len(sys.argv) != 2: - sys.exit("Usage: %s sphinx-srcdir" % (sys.argv[0])) - - conf_dir = os.path.abspath(sys.argv[1]) - conf_path = os.path.join(conf_dir, 'conf.py') - spec = importlib.util.spec_from_file_location('conf', conf_path) - conf = importlib.util.module_from_spec(spec) - spec.loader.exec_module(conf) - - if hasattr(conf, 'man_pages'): - for man in conf.man_pages: - man_path = os.path.join(sys.argv[1], "{}{}".format(man[0], '.rst')) - man_path_posix = pathlib.PureWindowsPath(man_path).as_posix() - print(man_path_posix) - - print(pathlib.PureWindowsPath(conf_path).as_posix()) diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/list-manpages.py b/thirdparty/SDL2_image/external/libtiff/cmake/list-manpages.py deleted file mode 100644 index 42bf0d830..000000000 --- a/thirdparty/SDL2_image/external/libtiff/cmake/list-manpages.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python - -# Find manual pages to be generated -# argv1 = doc dir containing conf.py -# argv2 = manpage directory to contain generated manpages - -import importlib.util -import os.path -import pathlib -import sys - -if __name__ == "__main__": - - if len(sys.argv) != 3: - print("Usage: {} sphinx-srcdir sphinx-builddir".format(sys.argv[0]), file=sys.stderr) - sys.exit(2) - - conf_dir = os.path.abspath(sys.argv[1]) - conf_path = os.path.join(conf_dir, 'conf.py') - spec = importlib.util.spec_from_file_location('conf', conf_path) - conf = importlib.util.module_from_spec(spec) - spec.loader.exec_module(conf) - - if hasattr(conf, 'man_pages'): - for man in conf.man_pages: - man_path = os.path.join(sys.argv[2], "%s.%s" % (man[1], man[4])) - man_path_posix = pathlib.PureWindowsPath(man_path).as_posix() - print(man_path_posix) - else: - print("No man_pages array in {}".format(conf_path), file=sys.stderr) - sys.exit(3) diff --git a/thirdparty/SDL2_image/external/libtiff/configure.ac b/thirdparty/SDL2_image/external/libtiff/configure.ac index c71eaef8c..2cb308ff0 100644 --- a/thirdparty/SDL2_image/external/libtiff/configure.ac +++ b/thirdparty/SDL2_image/external/libtiff/configure.ac @@ -25,7 +25,7 @@ dnl OF THIS SOFTWARE. dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.64) -AC_INIT([LibTIFF Software],[4.5.1],[tiff@lists.maptools.org],[tiff]) +AC_INIT([LibTIFF Software],[4.2.0],[tiff@lists.maptools.org],[tiff]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(m4) AC_LANG(C) @@ -33,15 +33,15 @@ AC_LANG(C) dnl Compute the canonical host (run-time) system type variable AC_CANONICAL_HOST -AM_INIT_AUTOMAKE([dist-xz tar-ustar]) +AM_INIT_AUTOMAKE(tar-ustar) dnl Do not rebuild generated files every time AM_MAINTAINER_MODE dnl Versioning. dnl Don't fill the ALPHA_VERSION field, if not applicable. LIBTIFF_MAJOR_VERSION=4 -LIBTIFF_MINOR_VERSION=5 -LIBTIFF_MICRO_VERSION=1 +LIBTIFF_MINOR_VERSION=2 +LIBTIFF_MICRO_VERSION=0 LIBTIFF_ALPHA_VERSION= LIBTIFF_VERSION=$LIBTIFF_MAJOR_VERSION.$LIBTIFF_MINOR_VERSION.$LIBTIFF_MICRO_VERSION$LIBTIFF_ALPHA_VERSION dnl This will be used with the 'make release' target @@ -76,9 +76,9 @@ dnl 5. If any interfaces have been added since the last public release, then dnl increment age. dnl 6. If any interfaces have been removed since the last public release, dnl then set age to 0. -LIBTIFF_CURRENT=6 -LIBTIFF_REVISION=1 -LIBTIFF_AGE=0 +LIBTIFF_CURRENT=11 +LIBTIFF_REVISION=0 +LIBTIFF_AGE=6 LIBTIFF_VERSION_INFO=$LIBTIFF_CURRENT:$LIBTIFF_REVISION:$LIBTIFF_AGE # This is a special hack for OpenBSD and MirOS systems. The dynamic linker @@ -103,7 +103,7 @@ AC_SUBST(LIBTIFF_VERSION_INFO) AC_SUBST(LIBTIFF_RELEASE_DATE) dnl Checks for programs. -AC_PROG_CC_C99 +AC_PROG_CC AM_PROG_CC_C_O dnl We want warnings. As many warnings as possible. @@ -143,7 +143,16 @@ EOF LDFLAGS="$save_LDFLAGS" AC_MSG_RESULT($have_ld_version_script) fi +case "$host" in + *-*-darwin*) + have_darwin_exports=yes + have_ld_version_script=no + ;; + *) have_darwin_exports=no + ;; +esac AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") +AM_CONDITIONAL(HAVE_DARWIN_EXPORTS, test "$have_darwin_exports" = "yes") dnl Tests for Windows @@ -160,11 +169,6 @@ AM_SILENT_RULES tiff_libs_private= AC_SUBST(tiff_libs_private) -tiff_requires_private= -AC_SUBST(tiff_requires_private) - -AM_CONDITIONAL(BUILD_STATIC, test "$enable_static" = "yes") - dnl We don't need to add math library to all targets case "${host_os}" in cygwin* | mingw32* | beos* | darwin*) @@ -183,6 +187,7 @@ AC_CHECK_HEADERS([assert.h fcntl.h io.h search.h unistd.h]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST +AC_C_INLINE AC_C_BIGENDIAN AC_TYPE_OFF_T AC_TYPE_SIZE_T @@ -196,63 +201,248 @@ AC_FUNC_FSEEKO dnl Check if optarg (and presumably related externs) already declared in headers AC_CHECK_DECLS([optarg]) -dnl --------------------------------------------------------------------------- -dnl Deprecated features and backward compatibilty -dnl --------------------------------------------------------------------------- - -AC_ARG_ENABLE([deprecated], - AS_HELP_STRING([--enable-deprecated], - [enable deprecated features (default is disabled)]), - [enable_deprecated=$enableval], [enable_deprecated=no]) - -if test "$enable_deprecated" = "yes"; then - # Disable deprecated features to ensure clean build - CPPFLAGS="-DTIFF_DISABLE_DEPRECATED $CPPFLAGS" -fi - dnl --------------------------------------------------------------------------- dnl Compute sized types for current CPU and compiler options dnl --------------------------------------------------------------------------- +# Obtain size of an 'signed int' and define as SIZEOF_SIGNED_INT +AC_CHECK_SIZEOF(signed int) + +# Obtain size of an 'unsigned int' and define as SIZEOF_UNSIGNED_INT +AC_CHECK_SIZEOF(unsigned int) + +# Obtain size of a 'signed long' and define as SIZEOF_SIGNED_LONG +AC_CHECK_SIZEOF(signed long) + +# Obtain size of a 'unsigned long' and define as SIZEOF_UNSIGNED_LONG +AC_CHECK_SIZEOF(unsigned long) + +# Obtain size of a 'long long' and define as SIZEOF_SIGNED_LONG_LONG. +# If 'long long' is not supported then the value defined is zero. +AC_CHECK_SIZEOF(signed long long) + +# Obtain size of a 'unsigned long long' and define as +# SIZEOF_UNSIGNED_LONG_LONG. If 'unsigned long long' is not +# supported then the value defined is zero. +AC_CHECK_SIZEOF(unsigned long long) + +# Obtain the size of an 'unsigned char *' and define as +# SIZEOF_UNSIGNED_CHAR_P. Result is available in +# ac_cv_sizeof_unsigned_char_p. +AC_CHECK_SIZEOF(unsigned char *) + # Obtain the size of 'size_t' and define as SIZEOF_SIZE_T. Result is # available in ac_cv_sizeof_size_t AC_CHECK_SIZEOF([size_t]) +AC_MSG_CHECKING(for signed 8-bit type) +INT8_T='signed char' +AC_MSG_RESULT($INT8_T) +AC_DEFINE_UNQUOTED(TIFF_INT8_T,$INT8_T,[Signed 8-bit type]) -# C99 fixed-size integer types -INT8_T='int8_t' -UINT8_T='uint8_t' +AC_MSG_CHECKING(for unsigned 8-bit type) +UINT8_T='unsigned char' +AC_MSG_RESULT($UINT8_T) +AC_DEFINE_UNQUOTED(TIFF_UINT8_T,$UINT8_T,[Unsigned 8-bit type]) -INT16_T='int16_t' -UINT16_T='uint16_t' +AC_MSG_CHECKING(for signed 16-bit type) +INT16_T='signed short' +AC_MSG_RESULT($INT16_T) +AC_DEFINE_UNQUOTED(TIFF_INT16_T,$INT16_T,[Signed 16-bit type]) -INT32_T='int32_t' -UINT32_T='uint32_t' -INT64_T='int64_t' -UINT64_T='uint64_t' +AC_MSG_CHECKING(for unsigned 16-bit type) +UINT16_T='unsigned short' +AC_MSG_RESULT($UINT16_T) +AC_DEFINE_UNQUOTED(TIFF_UINT16_T,$UINT16_T,[Unsigned 16-bit type]) -if test $ac_cv_sizeof_size_t -eq 4 +AC_MSG_CHECKING(for signed 32-bit type) +INT32_T='none' +INT32_FORMAT='none' +if test $ac_cv_sizeof_signed_int -eq 4 then - SSIZE_T='int32_t' -elif test $ac_cv_sizeof_size_t -eq 8 + INT32_T='signed int' + INT32_FORMAT='"%d"' +elif test $ac_cv_sizeof_signed_long -eq 4 then - SSIZE_T='int64_t' -else - AC_MSG_ERROR([Unsupported size_t size ${ac_cv_sizeof_size_t}; please add support]) + INT32_T='signed long' + INT32_FORMAT='"%ld"' +fi +AC_MSG_RESULT($INT32_T) +AC_DEFINE_UNQUOTED(TIFF_INT32_T,$INT32_T,[Signed 32-bit type]) +AC_DEFINE_UNQUOTED(TIFF_INT32_FORMAT,$INT32_FORMAT,[Signed 32-bit type formatter]) + +AC_MSG_CHECKING(for unsigned 32-bit type) +UINT32_T='none' +UINT32_FORMAT='none' +if test $ac_cv_sizeof_unsigned_int -eq 4 +then + UINT32_T='unsigned int' + UINT32_FORMAT='"%u"' +elif test $ac_cv_sizeof_unsigned_long -eq 4 +then + UINT32_T='unsigned long' + UINT32_FORMAT='"%lu"' +fi +AC_MSG_RESULT($UINT32_T) +AC_DEFINE_UNQUOTED(TIFF_UINT32_T,$UINT32_T,[Unsigned 32-bit type]) +AC_DEFINE_UNQUOTED(TIFF_UINT32_FORMAT,$UINT32_FORMAT,[Unsigned 32-bit type formatter]) + +AC_MSG_CHECKING(for signed 64-bit type) +INT64_T='none' +INT64_FORMAT='none' +if test $ac_cv_sizeof_signed_long -eq 8 +then + INT64_T='signed long' + INT64_FORMAT='"%ld"' +elif test $ac_cv_sizeof_signed_long_long -eq 8 +then + INT64_T='signed long long' + case "${host_os}" in + mingw32*) + # MinGW32 understands 'long long', but uses printf from WIN32 CRT + INT64_FORMAT='"%I64d"' + ;; + *) + INT64_FORMAT='"%lld"' + ;; + esac fi +AC_MSG_RESULT($INT64_T) +AC_DEFINE_UNQUOTED(TIFF_INT64_T,$INT64_T,[Signed 64-bit type]) +AC_DEFINE_UNQUOTED(TIFF_INT64_FORMAT,$INT64_FORMAT,[Signed 64-bit type formatter]) + +AC_MSG_CHECKING(for unsigned 64-bit type) +UINT64_T='none' +UINT64_FORMAT='none' +if test $ac_cv_sizeof_unsigned_long -eq 8 +then + UINT64_T='unsigned long' + UINT64_FORMAT='"%lu"' +elif test $ac_cv_sizeof_unsigned_long_long -eq 8 +then + UINT64_T='unsigned long long' + case "${host_os}" in + mingw32*) + # MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT + UINT64_FORMAT='"%I64u"' + ;; + *) + UINT64_FORMAT='"%llu"' + ;; + esac +fi +AC_MSG_RESULT($UINT64_T) +AC_DEFINE_UNQUOTED(TIFF_UINT64_T,$UINT64_T,[Unsigned 64-bit type]) +AC_DEFINE_UNQUOTED(TIFF_UINT64_FORMAT,$UINT64_FORMAT,[Unsigned 64-bit type formatter]) + +# Determine formatting specifier for 'size_t'. While the size should +# be precise, the type determined may not match the system definition. +# A named type is provided to allow casting to the type we determined +# without changing the actual size. +AC_MSG_CHECKING([for 'size_t' format specifier]) +SIZE_T='unknown' +SIZE_FORMAT='unknown' +if test $ac_cv_sizeof_unsigned_int -eq $ac_cv_sizeof_size_t +then + SIZE_T='unsigned int' + SIZE_FORMAT='"%u"' +elif test $ac_cv_sizeof_unsigned_long -eq $ac_cv_sizeof_size_t +then + SIZE_T='unsigned long' + SIZE_FORMAT='"%lu"' +elif test $ac_cv_sizeof_unsigned_long_long -eq $ac_cv_sizeof_size_t +then + SIZE_T='unsigned long long' + case "${host_os}" in + mingw32*) + # MinGW32 understands 'unsigned long long', but uses printf from WIN32 CRT + SIZE_FORMAT='"%I64u"' + ;; + *) + SIZE_FORMAT='"%llu"' + ;; + esac +fi +AC_MSG_RESULT([$SIZE_FORMAT]) +AC_DEFINE_UNQUOTED([TIFF_SIZE_T],[$SIZE_T],[Unsigned size type]) +AC_DEFINE_UNQUOTED([TIFF_SIZE_FORMAT],[$SIZE_FORMAT],[Size type formatter]) + # Determine TIFF equivalent of ssize_t AC_MSG_CHECKING(for signed size type) +SSIZE_T='unknown' +SSIZE_FORMAT='unknown' +if test $ac_cv_sizeof_signed_int -eq $ac_cv_sizeof_size_t +then + SSIZE_T='signed int' + SSIZE_FORMAT='"%d"' +elif test $ac_cv_sizeof_signed_long -eq $ac_cv_sizeof_size_t +then + SSIZE_T='signed long' + SSIZE_FORMAT='"%ld"' +elif test $ac_cv_sizeof_signed_long_long -eq $ac_cv_sizeof_size_t +then + SSIZE_T='signed long long' + case "${host_os}" in + mingw32*) + # MinGW32 understands 'long long', but uses printf from WIN32 CRT + SSIZE_FORMAT='"%I64d"' + ;; + *) + SSIZE_FORMAT='"%lld"' + ;; + esac +fi AC_MSG_RESULT($SSIZE_T) AC_DEFINE_UNQUOTED(TIFF_SSIZE_T,$SSIZE_T,[Signed size type]) +AC_DEFINE_UNQUOTED(TIFF_SSIZE_FORMAT,$SSIZE_FORMAT,[Signed size type formatter]) + +# Determine the type to use for the difference between two pointers. +# We will default to the POSIX ptrdiff_t if it is available, but will +# be prepared for the case when it is not. +PTRDIFF_T='unknown' +PTRDIFF_FORMAT='"%ld"' +AC_CHECK_TYPE(ptrdiff_t,[PTRDIFF_T=ptrdiff_t]) +if test $PTRDIFF_T = unknown +then + PTRDIFF_T=$SSIZE_T + PTRDIFF_FORMAT=$SSIZE_FORMAT +fi +AC_MSG_CHECKING(for pointer difference type) +AC_MSG_RESULT($PTRDIFF_T) +AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_T,$PTRDIFF_T,[Pointer difference type]) +AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_FORMAT,$PTRDIFF_FORMAT,[Pointer difference type formatter]) dnl Checks for library functions. -AC_CHECK_FUNCS([mmap setmode]) +AC_CHECK_FUNCS([mmap setmode snprintf]) dnl Will use local replacements for unavailable functions AC_REPLACE_FUNCS(getopt) +AC_REPLACE_FUNCS(snprintf) +AC_REPLACE_FUNCS(strcasecmp) +AC_REPLACE_FUNCS(strtol) +AC_REPLACE_FUNCS(strtoll) +AC_REPLACE_FUNCS(strtoul) +AC_REPLACE_FUNCS(strtoull) +AC_REPLACE_FUNCS(lfind) + +dnl --------------------------------------------------------------------------- +dnl Check the native cpu bit order. +dnl --------------------------------------------------------------------------- +AC_MSG_CHECKING([native cpu bit order]) +case "$host_cpu" in + i*86*|x86_64*) + HOST_FILLORDER=FILLORDER_LSB2MSB + AC_MSG_RESULT([lsb2msb]) + ;; + *) + HOST_FILLORDER=FILLORDER_MSB2LSB + AC_MSG_RESULT([msb2lsb]) + ;; +esac +AC_DEFINE_UNQUOTED(HOST_FILLORDER, $HOST_FILLORDER, [Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB)]) dnl --------------------------------------------------------------------------- dnl Configure legacy tifconf.h HOST_BIGENDIAN. @@ -275,7 +465,7 @@ dnl Set the floating point format. dnl FIXME: write appropriate test. dnl --------------------------------------------------------------------------- HAVE_IEEEFP=1 -AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format supported by the machine]) +AC_DEFINE_UNQUOTED(HAVE_IEEEFP, $HAVE_IEEEFP, [Define as 0 or 1 according to the floating point format suported by the machine]) dnl --------------------------------------------------------------------------- dnl Enable run-time paths to libraries usage. @@ -308,36 +498,6 @@ fi AC_SUBST(LIBTIFF_DOCDIR) - -dnl --------------------------------------------------------------------------- -dnl Enable or disable parts of the build -dnl --------------------------------------------------------------------------- - -AC_ARG_ENABLE(tools, - AS_HELP_STRING([--disable-tools], - [Disable building of tools]), - [TIFF_TOOLS=$enableval], [TIFF_TOOLS=yes]) -AM_CONDITIONAL(TIFF_TOOLS, test "$TIFF_TOOLS" = "yes") - -AC_ARG_ENABLE(tests, - AS_HELP_STRING([--disable-tests], - [Disable building of tests]), - [TIFF_TESTS=$enableval], [TIFF_TESTS=yes]) -AM_CONDITIONAL(TIFF_TESTS, test "$TIFF_TESTS" = "yes") - -AC_ARG_ENABLE(contrib, - AS_HELP_STRING([--disable-contrib], - [Disable building of contrib]), - [TIFF_CONTRIB=$enableval], [TIFF_CONTRIB=yes]) -AM_CONDITIONAL(TIFF_CONTRIB, test "$TIFF_CONTRIB" = "yes") - -AC_ARG_ENABLE(docs, - AS_HELP_STRING([--disable-docs], - [Disable building of docs]), - [TIFF_DOCS=$enableval], [TIFF_DOCS=yes]) -AM_CONDITIONAL(TIFF_DOCS, test "$TIFF_DOCS" = "yes") - - dnl --------------------------------------------------------------------------- dnl Switch on/off internal codecs. dnl --------------------------------------------------------------------------- @@ -456,7 +616,6 @@ if test "$HAVE_ZLIB" = "yes" ; then AC_DEFINE(ZIP_SUPPORT,1,[Support Deflate compression]) LIBS="-lz $LIBS" tiff_libs_private="-lz ${tiff_libs_private}" - tiff_requires_private="zlib ${tiff_requires_private}" if test "$HAVE_RPATH" = "yes" -a "x$with_zlib_lib_dir" != "x" ; then LIBDIR="-R $with_zlib_lib_dir $LIBDIR" @@ -514,7 +673,6 @@ if test "$HAVE_LIBDEFLATE" = "yes" ; then AC_DEFINE(LIBDEFLATE_SUPPORT,1,[Support libdeflate enhanced compression]) LIBS="-ldeflate $LIBS" tiff_libs_private="-ldeflate ${tiff_libs_private}" - tiff_requires_private="libdeflate ${tiff_requires_private}" if test "$HAVE_RPATH" = "yes" -a "x$with_libdeflate_lib_dir" != "x" ; then LIBDIR="-R $with_libdeflate_lib_dir $LIBDIR" @@ -543,7 +701,6 @@ dnl Check for JPEG. dnl --------------------------------------------------------------------------- HAVE_JPEG=no -HAVE_JPEGTURBO_DUAL_MODE_8_12=no AC_ARG_ENABLE(jpeg, AS_HELP_STRING([--disable-jpeg], @@ -576,9 +733,6 @@ if test "x$enable_jpeg" != "xno" ; then fi if test "$jpeg_lib" = "yes" -a "$jpeg_h" = "yes" ; then - dnl Check for jpeg12_read_scanlines which has been added in libjpeg-turbo 2.2 - dnl for dual 8/12 bit mode. - AC_CHECK_LIB(jpeg, jpeg12_read_scanlines, [HAVE_JPEGTURBO_DUAL_MODE_8_12=yes], [HAVE_JPEGTURBO_DUAL_MODE_8_12=no],) HAVE_JPEG=yes fi @@ -588,19 +742,14 @@ if test "$HAVE_JPEG" = "yes" ; then AC_DEFINE(JPEG_SUPPORT,1,[Support JPEG compression (requires IJG JPEG library)]) LIBS="-ljpeg $LIBS" tiff_libs_private="-ljpeg ${tiff_libs_private}" - tiff_requires_private="libjpeg ${tiff_requires_private}" if test "$HAVE_RPATH" = "yes" -a "x$with_jpeg_lib_dir" != "x" ; then LIBDIR="-R $with_jpeg_lib_dir $LIBDIR" fi - if test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = "yes"; then - AC_DEFINE(HAVE_JPEGTURBO_DUAL_MODE_8_12,1,[libjpeg-turbo >= 2.2 dual mode enabled]) - fi fi AM_CONDITIONAL(HAVE_JPEG, test "$HAVE_JPEG" = 'yes') -AM_CONDITIONAL(HAVE_JPEGTURBO_DUAL_MODE_8_12, test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = 'yes') dnl --------------------------------------------------------------------------- dnl Check for Old JPEG. @@ -676,73 +825,6 @@ fi AM_CONDITIONAL(HAVE_JBIG, test "$HAVE_JBIG" = 'yes') -dnl --------------------------------------------------------------------------- -dnl Check for liblerc. -dnl --------------------------------------------------------------------------- - -HAVE_LERC=no -STATIC_LERC=no - -if test "$enable_static" = "no"; then - static_lerc=no -else - static_lerc=yes -fi -AM_CONDITIONAL([STATIC_LERC], [ test "$static_lerc" = yes ]) - -AC_ARG_ENABLE(lerc, - AS_HELP_STRING([--disable-lerc], - [disable liblerc usage (required for lerc compression, enabled by default)]),,) -AC_ARG_WITH(lerc-include-dir, - AS_HELP_STRING([--with-lerc-include-dir=DIR], - [location of liblerc headers]),,) -AC_ARG_WITH(lerc-lib-dir, - AS_HELP_STRING([--with-lerc-lib-dir=DIR], - [location of liblerc library binary]),,) - -if test "x$enable_lerc" != "xno" ; then - - if test "x$with_lerc_lib_dir" != "x" ; then - LDFLAGS="-L$with_lerc_lib_dir $LDFLAGS" - fi - - lerc_lib_name="LercLib" - AC_CHECK_LIB("$lerc_lib_name", lerc_decode, [lerc_lib=yes], [lerc_lib=no],) - if test "$lerc_lib" = "no" ; then - lerc_lib_name="Lerc" - AC_CHECK_LIB("$lerc_lib_name", lerc_decode, [lerc_lib=yes], [lerc_lib=no],) - fi - if test "$lerc_lib" = "no" -a "x$with_lerc_lib_dir" != "x"; then - AC_MSG_ERROR([lerc library not found at $with_lerc_lib_dir]) - fi - - if test "x$with_lerc_include_dir" != "x" ; then - CPPFLAGS="-I$with_lerc_include_dir $CPPFLAGS" - fi - AC_CHECK_HEADER(Lerc_c_api.h, [lerc_c_api_h=yes], [lerc_c_api_h=no]) - if test "$lerc_c_api_h" = "no" -a "x$with_lerc_include_dir" != "x" ; then - AC_MSG_ERROR([Liblerc headers not found at $with_lerc_include_dir]) - fi - - if test "$lerc_lib" = "yes" -a "$lerc_c_api_h" = "yes" ; then - HAVE_LERC=yes - fi - -fi - -if test "$HAVE_LERC" = "yes" ; then - AC_DEFINE(LERC_SUPPORT,1,[Support lerc compression]) - LIBS="-l${lerc_lib_name} $LIBS" - tiff_libs_private="-l${lerc_lib_name} ${tiff_libs_private}" - - if test "$HAVE_RPATH" = "yes" -a "x$with_lerc_lib_dir" != "x" ; then - LIBDIR="-R $with_lerc_lib_dir $LIBDIR" - fi - -fi - -AM_CONDITIONAL(HAVE_LERC, test "$HAVE_LERC" = 'yes') - dnl --------------------------------------------------------------------------- dnl Check for liblzma2. dnl --------------------------------------------------------------------------- @@ -788,7 +870,6 @@ if test "$HAVE_LZMA" = "yes" ; then AC_DEFINE(LZMA_SUPPORT,1,[Support LZMA2 compression]) LIBS="-llzma $LIBS" tiff_libs_private="-llzma ${tiff_libs_private}" - tiff_requires_private="liblzma ${tiff_requires_private}" if test "$HAVE_RPATH" = "yes" -a "x$with_lzma_lib_dir" != "x" ; then LIBDIR="-R $with_lzma_lib_dir $LIBDIR" @@ -843,7 +924,6 @@ if test "$HAVE_ZSTD" = "yes" ; then AC_DEFINE(ZSTD_SUPPORT,1,[Support zstd compression]) LIBS="-lzstd $LIBS" tiff_libs_private="-lzstd ${tiff_libs_private}" - tiff_requires_private="libzstd ${tiff_requires_private}" if test "$HAVE_RPATH" = "yes" -a "x$with_zstd_lib_dir" != "x" ; then LIBDIR="-R $with_zstd_lib_dir $LIBDIR" @@ -898,7 +978,6 @@ if test "$HAVE_WEBP" = "yes" ; then AC_DEFINE(WEBP_SUPPORT,1,[Support webp compression]) LIBS="-lwebp $LIBS" tiff_libs_private="-lwebp ${tiff_libs_private}" - tiff_requires_private="libwebp ${tiff_requires_private}" if test "$HAVE_RPATH" = "yes" -a "x$with_webp_lib_dir" != "x" ; then LIBDIR="-R $with_webp_lib_dir $LIBDIR" @@ -910,38 +989,35 @@ AM_CONDITIONAL(HAVE_WEBP, test "$HAVE_WEBP" = 'yes') dnl --------------------------------------------------------------------------- dnl Should 8/12 bit jpeg mode be enabled? -dnl This should not be used starting with libjpeg-turbo >= 2.2 that has -dnl built-in support for dual mode. dnl --------------------------------------------------------------------------- -if test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = "no"; then - HAVE_JPEG12=no +HAVE_JPEG12=no - AC_ARG_ENABLE(jpeg12, - AS_HELP_STRING([--enable-jpeg12], - [enable libjpeg 8/12bit dual mode (not to be used with libjpeg-turbo >= 2.2)]),,) - AC_ARG_WITH(jpeg12-include-dir, - AS_HELP_STRING([--with-jpeg12-include-dir=DIR], - [location of libjpeg 12bit headers]),,) - AC_ARG_WITH(jpeg12-lib, - AS_HELP_STRING([--with-jpeg12-lib=LIBRARY], - [path to libjpeg 12bit library]),,) +AC_ARG_ENABLE(jpeg12, + AS_HELP_STRING([--enable-jpeg12], + [enable libjpeg 8/12bit dual mode]),,) +AC_ARG_WITH(jpeg12-include-dir, + AS_HELP_STRING([--with-jpeg12-include-dir=DIR], + [location of libjpeg 12bit headers]),,) +AC_ARG_WITH(jpeg12-lib, + AS_HELP_STRING([--with-jpeg12-lib=LIBRARY], + [path to libjpeg 12bit library]),,) - if test "x$enable_jpeg12" = "xyes" ; then +if test "x$enable_jpeg12" = "xyes" ; then - if test "x$with_jpeg12_lib" != "x" ; then - LIBS="$with_jpeg12_lib $LIBS" - fi - - HAVE_JPEG12=yes + if test "x$with_jpeg12_lib" != "x" ; then + LIBS="$with_jpeg12_lib $LIBS" + fi + + HAVE_JPEG12=yes - AC_DEFINE(JPEG_DUAL_MODE_8_12,1,[8/12 bit libjpeg dual mode enabled]) - if test "x$with_jpeg12_include_dir" != "x" ; then - AC_DEFINE_UNQUOTED(LIBJPEG_12_PATH,"$with_jpeg12_include_dir/jpeglib.h",[12bit libjpeg primary include file with path]) - fi - fi + AC_DEFINE(JPEG_DUAL_MODE_8_12,1,[8/12 bit libjpeg dual mode enabled]) + if test "x$with_jpeg12_include_dir" != "x" ; then + AC_DEFINE_UNQUOTED(LIBJPEG_12_PATH,"$with_jpeg12_include_dir/jpeglib.h",[12bit libjpeg primary include file with path]) + fi fi + dnl --------------------------------------------------------------------------- dnl Check for C++. dnl --------------------------------------------------------------------------- @@ -965,28 +1041,22 @@ dnl --------------------------------------------------------------------------- HAVE_OPENGL=no -AC_ARG_ENABLE(opengl, - AS_HELP_STRING([--disable-opengl], - [disable OpenGL usage (required by tiffgt, enabled by default)]),,) -if test "x$enable_opengl" != "xno" ; then +AC_PATH_XTRA - AC_PATH_XTRA +dnl AX_CHECK_GL sets GL_CFLAGS & GL_LIBS. Also PTHREAD_LIBS, +dnl PTHREAD_CFLAGS, & PTHREAD_CC as a side-effect +AX_CHECK_GL - dnl AX_CHECK_GL sets GL_CFLAGS & GL_LIBS. Also PTHREAD_LIBS, - dnl PTHREAD_CFLAGS, & PTHREAD_CC as a side-effect - AX_CHECK_GL +dnl AX_CHECK_GLU sets GLU_CFLAGS & GLU_LIBS +AX_CHECK_GLU - dnl AX_CHECK_GLU sets GLU_CFLAGS & GLU_LIBS - AX_CHECK_GLU +dnl AX_CHECK_GLUT sets GLUT_CFLAGS & GLUT_LIBS +AX_CHECK_GLUT - dnl AX_CHECK_GLUT sets GLUT_CFLAGS & GLUT_LIBS - AX_CHECK_GLUT - - if test "$no_x" != "yes" -a "$no_gl" != "yes" \ - -a "$no_glu" != "yes" -a "$no_glut" != "yes" ; then - HAVE_OPENGL=yes - fi +if test "$no_x" != "yes" -a "$no_gl" != "yes" \ + -a "$no_glu" != "yes" -a "$no_glut" != "yes" ; then + HAVE_OPENGL=yes fi AM_CONDITIONAL(HAVE_OPENGL, test "$HAVE_OPENGL" = "yes") @@ -1045,7 +1115,7 @@ dnl --------------------------------------------------------------------------- AC_ARG_ENABLE(strip-chopping, AS_HELP_STRING([--disable-strip-chopping], - [disable support for strip chopping (whether or not to convert single-strip uncompressed images to multiple strips of specified size to reduce memory usage)]), + [disable support for strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)]), [HAVE_STRIPCHOP=$enableval], [HAVE_STRIPCHOP=yes]) AC_ARG_WITH(default-strip-size, AS_HELP_STRING([--with-default-strip-size=SIZE], @@ -1053,7 +1123,7 @@ AC_ARG_WITH(default-strip-size, if test "$HAVE_STRIPCHOP" = "yes" \ -a "x$with_default_strip_size" != "xno"; then - AC_DEFINE(STRIPCHOP_DEFAULT,TIFF_STRIPCHOP,[Support strip chopping (whether or not to convert single-strip uncompressed images to multiple strips of specified size to reduce memory usage)]) + AC_DEFINE(STRIPCHOP_DEFAULT,TIFF_STRIPCHOP,[Support strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)]) if test "x$with_default_strip_size" = "x" \ -o "x$with_default_strip_size" = "xyes"; then @@ -1064,20 +1134,6 @@ if test "$HAVE_STRIPCHOP" = "yes" \ fi -dnl --------------------------------------------------------------------------- -dnl Maximum number of TIFF directories that libtiff can browse through -dnl --------------------------------------------------------------------------- - -AC_ARG_WITH(max-dir-count, - AS_HELP_STRING([--with-max-dir-count=SIZE], - [Maximum number of TIFF directories that libtiff can browse through [[default=1048576]]]),,) - -if test "x$with_max_dir_count" = "x" -o "x$with_max_dir_count" = "xyes"; then - with_max_dir_count="1048576" -fi - -AC_DEFINE_UNQUOTED(TIFF_MAX_DIR_COUNT,$with_max_dir_count,[Maximum number of TIFF directories that libtiff can browse through]) - dnl --------------------------------------------------------------------------- dnl Should we try to defer loading of strip/tile offsets and sizes to dnl optimize directory scanning? @@ -1145,53 +1201,11 @@ if test "$CHECK_JPEG_YCBCR_SUBSAMPLING" = "yes" ; then [Pick up YCbCr subsampling info from the JPEG data stream to support files lacking the tag (default enabled).]) fi - -for python in python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python3 python; do - AC_CHECK_PROGS(PYTHON_BIN, [$python]) - if test "x$PYTHON_BIN" != "x"; then - break - fi -done - -AC_ARG_ENABLE(sphinx, - AS_HELP_STRING([--disable-sphinx], - [disable building of the sphinx documentation]), - [BUILD_SPHINX=$enableval], - [BUILD_SPHINX=yes]) - - - -AC_PATH_PROG(SPHINX_BUILD, [sphinx-build], [no]) - -AM_CONDITIONAL([SPHINX], [test "$BUILD_SPHINX" = yes -a "$SPHINX_BUILD" != no -a "x$PYTHON_BIN" != "x"]) - -if test "x$PYTHON_BIN" != "x"; then - AC_MSG_CHECKING([generated manual pages]) - TIFF_MAN1_GEN=$(echo $("$PYTHON_BIN" "${srcdir}/cmake/list-manpages.py" "${srcdir}/doc" man | grep "\.1$")) - TIFF_MAN3_GEN=$(echo $("$PYTHON_BIN" "${srcdir}/cmake/list-manpages.py" "${srcdir}/doc" man | grep "\.3tiff$")) - TIFF_MAN_RULES=$("$PYTHON_BIN" "${srcdir}/cmake/list-manpages.py" "${srcdir}/doc" man | sed -e 's;$;: all-local;') - AC_SUBST([TIFF_MAN1_GEN]) - AC_SUBST([TIFF_MAN3_GEN]) - AC_SUBST([TIFF_MAN_RULES]) - AM_SUBST_NOTMAKE([TIFF_MAN_RULES]) - AC_MSG_RESULT([done]) -fi - -if test -d "${srcdir}/doc/man-prebuilt"; then - AC_MSG_CHECKING([prebuilt manual pages]) - TIFF_MAN1_PREBUILT=$(echo $(cd "${srcdir}/doc" && ls -1 man-prebuilt/*.1)) - TIFF_MAN3_PREBUILT=$(echo $(cd "${srcdir}/doc" && ls -1 man-prebuilt/*.3tiff)) - AC_SUBST([TIFF_MAN1_PREBUILT]) - AC_SUBST([TIFF_MAN3_PREBUILT]) - AC_MSG_RESULT([done]) -fi - dnl --------------------------------------------------------------------------- - AC_SUBST(LIBDIR) -AC_CONFIG_HEADERS([config/config.h libtiff/tif_config.h libtiff/tiffconf.h port/libport_config.h]) +AC_CONFIG_HEADERS([libtiff/tif_config.h libtiff/tiffconf.h]) AC_CONFIG_FILES([Makefile \ build/Makefile \ @@ -1206,12 +1220,15 @@ AC_CONFIG_FILES([Makefile \ contrib/stream/Makefile \ contrib/tags/Makefile \ contrib/win_dib/Makefile \ - doc/Makefile \ - libtiff-4.pc \ - libtiff/Makefile \ + html/Makefile \ + html/images/Makefile \ + html/man/Makefile \ + libtiff-4.pc \ + libtiff/Makefile \ + man/Makefile \ port/Makefile \ test/Makefile \ - tools/Makefile]) + tools/Makefile]) AC_OUTPUT dnl --------------------------------------------------------------------------- @@ -1225,15 +1242,10 @@ LOC_MSG([ Installation directory: ${prefix}]) LOC_MSG([ Documentation directory: ${LIBTIFF_DOCDIR}]) LOC_MSG([ C compiler: ${CC} ${CFLAGS}]) LOC_MSG([ C++ compiler: ${CXX} ${CXXFLAGS}]) -LOC_MSG([ Build tools: ${TIFF_TOOLS}]) -LOC_MSG([ Build tests: ${TIFF_TESTS}]) -LOC_MSG([ Build contrib: ${TIFF_CONTRIB}]) -LOC_MSG([ Build docs: ${TIFF_DOCS}]) -LOC_MSG([ Build deprecated features: ${enable_deprecated}]) LOC_MSG([ Enable runtime linker paths: ${HAVE_RPATH}]) LOC_MSG([ Enable linker symbol versioning: ${have_ld_version_script}]) LOC_MSG([ Support Microsoft Document Imaging: ${HAVE_MDI}]) -LOC_MSG([ Use Win32 IO: ${win32_io_ok}]) +LOC_MSG([ Use win32 IO: ${win32_io_ok}]) LOC_MSG() LOC_MSG([ Support for internal codecs:]) LOC_MSG([ CCITT Group 3 & 4 algorithms: ${HAVE_CCITT}]) @@ -1249,13 +1261,8 @@ LOC_MSG([ libdeflate support: ${HAVE_LIBDEFLATE}]) LOC_MSG([ Pixar log-format algorithm: ${HAVE_PIXARLOG}]) LOC_MSG([ JPEG support: ${HAVE_JPEG}]) LOC_MSG([ Old JPEG support: ${HAVE_OJPEG}]) -if test "$HAVE_JPEGTURBO_DUAL_MODE_8_12" = "yes"; then - LOC_MSG([ JPEG 8/12 bit dual mode: ${HAVE_JPEGTURBO_DUAL_MODE_8_12} (libjpeg turbo >= 2.2 dual mode)]) -else - LOC_MSG([ JPEG 8/12 bit dual mode: ${HAVE_JPEG12}]) -fi +LOC_MSG([ JPEG 8/12 bit dual mode: ${HAVE_JPEG12}]) LOC_MSG([ ISO JBIG support: ${HAVE_JBIG}]) -LOC_MSG([ LERC support: ${HAVE_LERC}]) LOC_MSG([ LZMA2 support: ${HAVE_LZMA}]) LOC_MSG([ ZSTD support: ${HAVE_ZSTD}]) LOC_MSG([ WEBP support: ${HAVE_WEBP}]) diff --git a/thirdparty/SDL2_image/external/libtiff/configure.com b/thirdparty/SDL2_image/external/libtiff/configure.com new file mode 100644 index 000000000..a30644258 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/configure.com @@ -0,0 +1,1356 @@ +$! +$! OpenVMS configure procedure for libtiff +$! (c) Alexey Chupahin 22-NOV-2007 +$! elvis_75@mail.ru +$! +$! 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. +$! +$! +$ SET NOON +$WRITE SYS$OUTPUT " " +$WRITE SYS$OUTPUT "Configuring libTIFF library" +$WRITE SYS$OUTPUT " " +$! Checking architecture +$DECC = F$SEARCH("SYS$SYSTEM:DECC$COMPILER.EXE") .NES. "" +$IF (.NOT. DECC) THEN $WRITE SYS$OUTPUT "BAD compiler" GOTO EXIT +$ IF F$GETSYI("ARCH_TYPE").EQ.1 THEN CPU = "VAX" +$ IF F$GETSYI("ARCH_TYPE").EQ.2 THEN CPU = "Alpha" +$ IF F$GETSYI("ARCH_TYPE").EQ.3 THEN CPU = "I64" +$ OS = F$GETSYI("VERSION") +$WRITE SYS$OUTPUT "Checking architecture ... ", CPU +$WRITE SYS$OUTPUT "Checking OS ... OpenVMS ",OS +$SHARED=0 +$IF ( (CPU.EQS."Alpha").OR.(CPU.EQS."I64") ) +$ THEN +$ SHARED=64 +$ ELSE +$ SHARED=32 +$ENDIF +$MMS = F$SEARCH("SYS$SYSTEM:MMS.EXE") .NES. "" +$MMK = F$TYPE(MMK) +$IF (MMS .OR. MMK.NES."") THEN GOTO TEST_LIBRARIES +$! I cant find any make tool +$GOTO EXIT +$! +$! +$TEST_LIBRARIES: +$! Setting as MAKE utility one of MMS or MMK. I prefer MMS. +$IF (MMK.NES."") THEN MAKE="MMK" +$IF (MMS) THEN MAKE="MMS" +$WRITE SYS$OUTPUT "Checking build utility ... ''MAKE'" +$WRITE SYS$OUTPUT " " +$! +$! +$IF (P1.EQS."STATIC").OR.(P1.EQS."static") THEN SHARED=0 +$! +$! +$!"Checking for strcasecmp " +$ DEFINE SYS$ERROR _NLA0: +$ DEFINE SYS$OUTPUT _NLA0: +$ CC/OBJECT=TEST.OBJ/INCLUDE=(ZLIB) SYS$INPUT + #include + #include + + int main() + { + if (strcasecmp("bla", "Bla")==0) exit(0); + else exit(2); + } +$! +$TMP = $STATUS +$DEASS SYS$ERROR +$DEAS SYS$OUTPUT +$IF (TMP .NE. %X10B90001) +$ THEN +$ HAVE_STRCASECMP=0 +$ GOTO NEXT1 +$ENDIF +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_STRCASECMP=0 +$ GOTO NEXT1 +$ENDIF +$! +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$RUN TEST +$IF ($STATUS .NE. %X00000001) +$ THEN +$ HAVE_STRCASECMP=0 +$ ELSE +$ HAVE_STRCASECMP=1 +$ENDIF +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$NEXT1: +$IF (HAVE_STRCASECMP.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for strcasecmp ... Yes" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for strcasecmp ... No" +$ENDIF +$! +$! + +$!"Checking for lfind " +$ DEFINE SYS$ERROR _NLA0: +$ DEFINE SYS$OUTPUT _NLA0: +$ CC/OBJECT=TEST.OBJ/INCLUDE=(ZLIB) SYS$INPUT + #include + + int main() + { + lfind((const void *)key, (const void *)NULL, (size_t *)NULL, + (size_t) 0, NULL); + } +$! +$TMP = $STATUS +$DEASS SYS$ERROR +$DEAS SYS$OUTPUT +$IF (TMP .NE. %X10B90001) +$ THEN +$ HAVE_LFIND=0 +$ GOTO NEXT2 +$ENDIF +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_LFIND=0 +$ GOTO NEXT2 +$ ELSE +$ HAVE_LFIND=1 +$ENDIF +$! +$NEXT2: +$IF (HAVE_LFIND.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for lfind ... Yes" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for lfind ... No" +$ENDIF +$! +$! +$!"Checking for correct zlib library " +$ DEFINE SYS$ERROR _NLA0: +$ DEFINE SYS$OUTPUT _NLA0: +$ CC/OBJECT=TEST.OBJ/INCLUDE=(ZLIB) SYS$INPUT + #include + #include + #include + int main() + { + printf("checking version zlib: %s\n",zlibVersion()); + } +$TMP = $STATUS +$DEASS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10B90001) +$ THEN +$ HAVE_ZLIB=0 +$ GOTO EXIT +$ENDIF +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST,ZLIB:LIBZ/LIB +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_ZLIB=0 +$ GOTO EXIT +$ ELSE +$ HAVE_ZLIB=1 +$ENDIF +$IF (HAVE_ZLIB.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for correct zlib library ... Yes" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for correct zlib library ... No" +$ WRITE SYS$OUTPUT "This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html" +$ENDIF +$RUN TEST +$! + +$DEL TEST.OBJ;* +$! Checking for JPEG ... +$ DEFINE SYS$ERROR _NLA0: +$ DEFINE SYS$OUTPUT _NLA0: +$ CC/OBJECT=TEST.OBJ/INCLUDE=(JPEG) SYS$INPUT + #include + #include + #include + #include + int main() + { + printf("checking version jpeg: %s\n",JVERSION); + jpeg_quality_scaling(0); + return 0; + } +$TMP = $STATUS +$DEASS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10B90001) +$ THEN +$ WRITE SYS$OUTPUT "Checking for static jpeg library ... No" +$ HAVE_JPEG=0 +$ENDIF +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST,JPEG:LIBJPEG/LIB +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_JPEG=0 +$ ELSE +$ HAVE_JPEG=1 +$ENDIF +$IF (HAVE_JPEG.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for static jpeg library ... Yes" +$ JPEG_LIBRARY_PATH="JPEG:LIBJPEG/LIB" +$ RUN TEST +$ ELSE +$ WRITE SYS$OUTPUT "Checking for static jpeg library ... No" +$ENDIF +$! +$!"Checking for SHARED JPEG library " +$OPEN/WRITE OUT TEST.OPT +$WRITE OUT "SYS$SHARE:LIBJPEG$SHR/SHARE" +$WRITE OUT "ZLIB:LIBZ/LIB" +$CLOSE OUT +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$LINK/EXE=TEST TEST,TEST/OPT +$TMP = $STATUS +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT +$!WRITE SYS$OUTPUT TMP +$IF (TMP .NE. %X10000001) +$ THEN +$ HAVE_JPEG_SHARED=0 +$ ELSE +$ HAVE_JPEG_SHARED=1 +$ENDIF +$IF (HAVE_JPEG_SHARED.EQ.1) +$ THEN +$ WRITE SYS$OUTPUT "Checking for shared jpeg library ... Yes" +$ JPEG_LIBRARY_PATH="SYS$SHARE:LIBJPEG$SHR/SHARE" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for shared jpeg library ... No" +$ENDIF +$! +$ IF ( (HAVE_JPEG_SHARED.EQ.0).AND.(HAVE_JPEG.EQ.0) ) +$ THEN +$ WRITE SYS$OUTPUT "No JPEG library installed. This is fatal. Please download and install good library from fafner.dyndns.org/~alexey/libsdl/public.html" +$ GOTO EXIT +$ ENDIF +$! +$! +$! +$! Checking for X11 ... +$IF F$TRNLNM("DECW$INCLUDE") .NES. "" +$ THEN +$ WRITE SYS$OUTPUT "Checking for X11 ... Yes" +$ ELSE +$ WRITE SYS$OUTPUT "Checking for X11 ... No" +$ WRITE SYS$OUTPUT "This is fatal. Please install X11 software" +$ GOTO EXIT +$ENDIF +$! +$!WRITING BUILD FILES +$OPEN/WRITE OUT BUILD.COM +$ WRITE OUT "$set def [.port]" +$ WRITE OUT "$",MAKE +$ WRITE OUT "$set def [-.libtiff]" +$ WRITE OUT "$",MAKE +$ WRITE OUT "$set def [-.tools]" +$ WRITE OUT "$",MAKE +$ WRITE OUT "$set def [-]" +$ WRITE OUT "$cop [.PORT]LIBPORT.OLB [.LIBTIFF]LIBPORT.OLB" +$ WRITE OUT "$ CURRENT = F$ENVIRONMENT (""DEFAULT"") " +$ WRITE OUT "$TIFF=CURRENT" +$ WRITE OUT "$OPEN/WRITE OUTT LIBTIFF$STARTUP.COM" +$ WRITE OUT "$TIFF[F$LOCATE(""]"",TIFF),9]:="".LIBTIFF]""" +$ WRITE OUT "$WRITE OUTT ""DEFINE TIFF ","'","'","TIFF'"" " +$ WRITE OUT "$TIFF=CURRENT" +$ WRITE OUT "$TIFF[F$LOCATE(""]"",TIFF),7]:="".TOOLS]""" +$ WRITE OUT "$WRITE OUTT ""BMP2TIFF:==$", "'","'","TIFF'BMP2TIFF""" +$ WRITE OUT "$WRITE OUTT ""FAX2PS:==$", "'","'","TIFF'FAX2PS""" +$ WRITE OUT "$WRITE OUTT ""FAX2TIFF:==$", "'","'","TIFF'FAX2TIFF""" +$ WRITE OUT "$WRITE OUTT ""GIF2TIFF:==$", "'","'","TIFF'GIF2TIFF""" +$ WRITE OUT "$WRITE OUTT ""PAL2RGB:==$", "'","'","TIFF'PAL2RGB""" +$ WRITE OUT "$WRITE OUTT ""PPM2TIFF:==$", "'","'","TIFF'PPM2TIFF""" +$ WRITE OUT "$WRITE OUTT ""RAS2TIFF:==$", "'","'","TIFF'RAS2TIFF""" +$ WRITE OUT "$WRITE OUTT ""RAW2TIFF:==$", "'","'","TIFF'RAW2TIFF""" +$ WRITE OUT "$WRITE OUTT ""RGB2YCBCR:==$", "'","'","TIFF'RGB2YCBCR""" +$ WRITE OUT "$WRITE OUTT ""THUMBNAIL:==$", "'","'","TIFF'THUMBNAIL""" +$ WRITE OUT "$WRITE OUTT ""TIFF2BW:==$", "'","'","TIFF'TIFF2BW""" +$ WRITE OUT "$WRITE OUTT ""TIFF2PDF:==$", "'","'","TIFF'TIFF2PDF""" +$ WRITE OUT "$WRITE OUTT ""TIFF2PS:==$", "'","'","TIFF'TIFF2PS""" +$ WRITE OUT "$WRITE OUTT ""TIFF2RGBA:==$", "'","'","TIFF'TIFF2RGBA""" +$ WRITE OUT "$WRITE OUTT ""TIFFCMP:==$", "'","'","TIFF'TIFFCMP""" +$ WRITE OUT "$WRITE OUTT ""TIFFCP:==$", "'","'","TIFF'TIFFCP""" +$ WRITE OUT "$WRITE OUTT ""TIFFDITHER:==$", "'","'","TIFF'TIFFDITHER""" +$ WRITE OUT "$WRITE OUTT ""TIFFDUMP:==$", "'","'","TIFF'TIFFDUMP""" +$ WRITE OUT "$WRITE OUTT ""TIFFINFO:==$", "'","'","TIFF'TIFFINFO""" +$ WRITE OUT "$WRITE OUTT ""TIFFMEDIAN:==$", "'","'","TIFF'TIFFMEDIAN""" +$ WRITE OUT "$WRITE OUTT ""TIFFCROP:==$", "'","'","TIFF'TIFFCROP""" +$ WRITE OUT "$WRITE OUTT ""TIFFSET:==$", "'","'","TIFF'TIFFSET""" +$ WRITE OUT "$CLOSE OUTT" +$ WRITE OUT "$OPEN/WRITE OUTT [.LIBTIFF]LIBTIFF.OPT" +$ WRITE OUT "$WRITE OUTT ""TIFF:TIFF/LIB"" +$ WRITE OUT "$WRITE OUTT ""TIFF:LIBPORT/LIB"" +$ WRITE OUT "$WRITE OUTT ""JPEG:LIBJPEG/LIB"" +$ WRITE OUT "$WRITE OUTT ""ZLIB:LIBZ/LIB"" +$ WRITE OUT "$CLOSE OUTT" +$! +$ WRITE OUT "$WRITE SYS$OUTPUT "" "" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""***************************************************************************** "" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""LIBTIFF$STARTUP.COM has been created. "" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""This file setups all logicals needed. It should be execute before using LibTIFF "" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""Nice place to call it - LOGIN.COM "" " +$ WRITE OUT "$WRITE SYS$OUTPUT """" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""Using the library:"" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""CC/INC=TIFF ASCII_TAG.C"" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""LINK ASCII_TAG,TIFF:LIBTIFF/OPT"" " +$ WRITE OUT "$WRITE SYS$OUTPUT ""***************************************************************************** "" " +$CLOSE OUT +$! +$! DESCRIP.MMS in [.PORT] +$OBJ="dummy.obj" +$IF HAVE_STRCASECMP.NE.1 +$ THEN +$ OBJ=OBJ+",strcasecmp.obj" +$ENDIF +$IF HAVE_LFIND.NE.1 +$ THEN +$ OBJ=OBJ+",lfind.obj" +$ENDIF +$OPEN/WRITE OUT [.PORT]DESCRIP.MMS +$WRITE OUT "OBJ=",OBJ +$WRITE OUT "" +$WRITE OUT "LIBPORT.OLB : $(OBJ)" +$WRITE OUT " LIB/CREA LIBPORT $(OBJ)" +$WRITE OUT "" +$WRITE OUT "" +$WRITE OUT "dummy.obj : dummy.c" +$WRITE OUT " $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)" +$WRITE OUT "" +$WRITE OUT "" +$WRITE OUT "strcasecmp.obj : strcasecmp.c" +$WRITE OUT " $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)" +$WRITE OUT "" +$WRITE OUT "" +$WRITE OUT "lfind.obj : lfind.c" +$WRITE OUT " $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET)" +$WRITE OUT "" +$WRITE OUT "" +$CLOSE OUT +$! +$! +$WRITE SYS$OUTPUT "Creating LIBTIFF$DEF.OPT" +$IF (SHARED.EQ.64) +$ THEN +$ COPY SYS$INPUT TIFF$DEF.OPT +SYMBOL_VECTOR= (- +TIFFOpen=PROCEDURE,- +TIFFGetVersion=PROCEDURE,- +TIFFCleanup=PROCEDURE,- +TIFFClose=PROCEDURE,- +TIFFFlush=PROCEDURE,- +TIFFFlushData=PROCEDURE,- +TIFFGetField=PROCEDURE,- +TIFFVGetField=PROCEDURE,- +TIFFGetFieldDefaulted=PROCEDURE,- +TIFFVGetFieldDefaulted=PROCEDURE,- +TIFFGetTagListEntry=PROCEDURE,- +TIFFGetTagListCount=PROCEDURE,- +TIFFReadDirectory=PROCEDURE,- +TIFFScanlineSize=PROCEDURE,- +TIFFStripSize=PROCEDURE,- +TIFFVStripSize=PROCEDURE,- +TIFFRawStripSize=PROCEDURE,- +TIFFTileRowSize=PROCEDURE,- +TIFFTileSize=PROCEDURE,- +TIFFVTileSize=PROCEDURE,- +TIFFFileno=PROCEDURE,- +TIFFSetFileno=PROCEDURE,- +TIFFGetMode=PROCEDURE,- +TIFFIsTiled=PROCEDURE,- +TIFFIsByteSwapped=PROCEDURE,- +TIFFIsBigEndian=PROCEDURE,- +TIFFIsMSB2LSB=PROCEDURE,- +TIFFIsUpSampled=PROCEDURE,- +TIFFCIELabToRGBInit=PROCEDURE,- +TIFFCIELabToXYZ=PROCEDURE,- +TIFFXYZToRGB=PROCEDURE,- +TIFFYCbCrToRGBInit=PROCEDURE,- +TIFFYCbCrtoRGB=PROCEDURE,- +TIFFCurrentRow=PROCEDURE,- +TIFFCurrentDirectory=PROCEDURE,- +TIFFCurrentStrip=PROCEDURE,- +TIFFCurrentTile=PROCEDURE,- +TIFFDataWidth=PROCEDURE,- +TIFFReadBufferSetup=PROCEDURE,- +TIFFWriteBufferSetup=PROCEDURE,- +TIFFSetupStrips=PROCEDURE,- +TIFFLastDirectory=PROCEDURE,- +TIFFSetDirectory=PROCEDURE,- +TIFFSetSubDirectory=PROCEDURE,- +TIFFUnlinkDirectory=PROCEDURE,- +TIFFSetField=PROCEDURE,- +TIFFVSetField=PROCEDURE,- +TIFFCheckpointDirectory=PROCEDURE,- +TIFFWriteDirectory=PROCEDURE,- +TIFFRewriteDirectory=PROCEDURE,- +TIFFPrintDirectory=PROCEDURE,- +TIFFReadScanline=PROCEDURE,- +TIFFWriteScanline=PROCEDURE,- +TIFFReadRGBAImage=PROCEDURE,- +TIFFReadRGBAImageOriented=PROCEDURE,- +TIFFFdOpen=PROCEDURE,- +TIFFClientOpen=PROCEDURE,- +TIFFFileName=PROCEDURE,- +TIFFError=PROCEDURE,- +TIFFErrorExt=PROCEDURE,- +TIFFWarning=PROCEDURE,- +TIFFWarningExt=PROCEDURE,- +TIFFSetErrorHandler=PROCEDURE,- +TIFFSetErrorHandlerExt=PROCEDURE,- +TIFFSetWarningHandler=PROCEDURE,- +TIFFSetWarningHandlerExt=PROCEDURE,- +TIFFComputeTile=PROCEDURE,- +TIFFCheckTile=PROCEDURE,- +TIFFNumberOfTiles=PROCEDURE,- +TIFFReadTile=PROCEDURE,- +TIFFWriteTile=PROCEDURE,- +TIFFComputeStrip=PROCEDURE,- +TIFFNumberOfStrips=PROCEDURE,- +TIFFRGBAImageBegin=PROCEDURE,- +TIFFRGBAImageGet=PROCEDURE,- +TIFFRGBAImageEnd=PROCEDURE,- +TIFFReadEncodedStrip=PROCEDURE,- +TIFFReadRawStrip=PROCEDURE,- +TIFFReadEncodedTile=PROCEDURE,- +TIFFReadRawTile=PROCEDURE,- +TIFFReadRGBATile=PROCEDURE,- +TIFFReadRGBAStrip=PROCEDURE,- +TIFFWriteEncodedStrip=PROCEDURE,- +TIFFWriteRawStrip=PROCEDURE,- +TIFFWriteEncodedTile=PROCEDURE,- +TIFFWriteRawTile=PROCEDURE,- +TIFFSetWriteOffset=PROCEDURE,- +TIFFSwabDouble=PROCEDURE,- +TIFFSwabShort=PROCEDURE,- +TIFFSwabLong=PROCEDURE,- +TIFFSwabArrayOfShort=PROCEDURE,- +TIFFSwabArrayOfLong=PROCEDURE,- +TIFFSwabArrayOfDouble=PROCEDURE,- +TIFFSwabArrayOfTriples=PROCEDURE,- +TIFFReverseBits=PROCEDURE,- +TIFFGetBitRevTable=PROCEDURE,- +TIFFDefaultStripSize=PROCEDURE,- +TIFFDefaultTileSize=PROCEDURE,- +TIFFRasterScanlineSize=PROCEDURE,- +_TIFFmalloc=PROCEDURE,- +_TIFFrealloc=PROCEDURE,- +_TIFFfree=PROCEDURE,- +_TIFFmemset=PROCEDURE,- +_TIFFmemcpy=PROCEDURE,- +_TIFFmemcmp=PROCEDURE,- +TIFFCreateDirectory=PROCEDURE,- +TIFFSetTagExtender=PROCEDURE,- +TIFFMergeFieldInfo=PROCEDURE,- +TIFFFindFieldInfo=PROCEDURE,- +TIFFFindFieldInfoByName=PROCEDURE,- +TIFFFieldWithName=PROCEDURE,- +TIFFFieldWithTag=PROCEDURE,- +TIFFFieldTag=PROCEDURE,- +TIFFFieldName=PROCEDURE,- +TIFFFieldDataType=PROCEDURE,- +TIFFFieldPassCount=PROCEDURE,- +TIFFFieldReadCount=PROCEDURE,- +TIFFFieldWriteCount=PROCEDURE,- +TIFFCurrentDirOffset=PROCEDURE,- +TIFFWriteCheck=PROCEDURE,- +TIFFRGBAImageOK=PROCEDURE,- +TIFFNumberOfDirectories=PROCEDURE,- +TIFFSetFileName=PROCEDURE,- +TIFFSetClientdata=PROCEDURE,- +TIFFSetMode=PROCEDURE,- +TIFFClientdata=PROCEDURE,- +TIFFGetReadProc=PROCEDURE,- +TIFFGetWriteProc=PROCEDURE,- +TIFFGetSeekProc=PROCEDURE,- +TIFFGetCloseProc=PROCEDURE,- +TIFFGetSizeProc=PROCEDURE,- +TIFFGetMapFileProc=PROCEDURE,- +TIFFGetUnmapFileProc=PROCEDURE,- +TIFFIsCODECConfigured=PROCEDURE,- +TIFFGetConfiguredCODECs=PROCEDURE,- +TIFFFindCODEC=PROCEDURE,- +TIFFRegisterCODEC=PROCEDURE,- +TIFFUnRegisterCODEC=PROCEDURE,- +TIFFFreeDirectory=PROCEDURE,- +TIFFReadCustomDirectory=PROCEDURE,- +TIFFReadEXIFDirectory=PROCEDURE,- +TIFFAccessTagMethods=PROCEDURE,- +TIFFGetClientInfo=PROCEDURE,- +TIFFSetClientInfo=PROCEDURE,- +TIFFReassignTagToIgnore=PROCEDURE- +) + +$ENDIF +$IF (SHARED.EQ.32) +$ THEN +$ COPY SYS$INPUT TIFF$DEF.OPT +UNIVERSAL=TIFFOpen +UNIVERSAL=TIFFGetVersion +UNIVERSAL=TIFFCleanup +UNIVERSAL=TIFFClose +UNIVERSAL=TIFFFlush +UNIVERSAL=TIFFFlushData +UNIVERSAL=TIFFGetField +UNIVERSAL=TIFFVGetField +UNIVERSAL=TIFFGetFieldDefaulted +UNIVERSAL=TIFFVGetFieldDefaulted +UNIVERSAL=TIFFGetTagListEntry +UNIVERSAL=TIFFGetTagListCount +UNIVERSAL=TIFFReadDirectory +UNIVERSAL=TIFFScanlineSize +UNIVERSAL=TIFFStripSize +UNIVERSAL=TIFFVStripSize +UNIVERSAL=TIFFRawStripSize +UNIVERSAL=TIFFTileRowSize +UNIVERSAL=TIFFTileSize +UNIVERSAL=TIFFVTileSize +UNIVERSAL=TIFFFileno +UNIVERSAL=TIFFSetFileno +UNIVERSAL=TIFFGetMode +UNIVERSAL=TIFFIsTiled +UNIVERSAL=TIFFIsByteSwapped +UNIVERSAL=TIFFIsBigEndian +UNIVERSAL=TIFFIsMSB2LSB +UNIVERSAL=TIFFIsUpSampled +UNIVERSAL=TIFFCIELabToRGBInit +UNIVERSAL=TIFFCIELabToXYZ +UNIVERSAL=TIFFXYZToRGB +UNIVERSAL=TIFFYCbCrToRGBInit +UNIVERSAL=TIFFYCbCrtoRGB +UNIVERSAL=TIFFCurrentRow +UNIVERSAL=TIFFCurrentDirectory +UNIVERSAL=TIFFCurrentStrip +UNIVERSAL=TIFFCurrentTile +UNIVERSAL=TIFFDataWidth +UNIVERSAL=TIFFReadBufferSetup +UNIVERSAL=TIFFWriteBufferSetup +UNIVERSAL=TIFFSetupStrips +UNIVERSAL=TIFFLastDirectory +UNIVERSAL=TIFFSetDirectory +UNIVERSAL=TIFFSetSubDirectory +UNIVERSAL=TIFFUnlinkDirectory +UNIVERSAL=TIFFSetField +UNIVERSAL=TIFFVSetField +UNIVERSAL=TIFFCheckpointDirectory +UNIVERSAL=TIFFWriteDirectory +UNIVERSAL=TIFFRewriteDirectory +UNIVERSAL=TIFFPrintDirectory +UNIVERSAL=TIFFReadScanline +UNIVERSAL=TIFFWriteScanline +UNIVERSAL=TIFFReadRGBAImage +UNIVERSAL=TIFFReadRGBAImageOriented +UNIVERSAL=TIFFFdOpen +UNIVERSAL=TIFFClientOpen +UNIVERSAL=TIFFFileName +UNIVERSAL=TIFFError +UNIVERSAL=TIFFErrorExt +UNIVERSAL=TIFFWarning +UNIVERSAL=TIFFWarningExt +UNIVERSAL=TIFFSetErrorHandler +UNIVERSAL=TIFFSetErrorHandlerExt +UNIVERSAL=TIFFSetWarningHandler +UNIVERSAL=TIFFSetWarningHandlerExt +UNIVERSAL=TIFFComputeTile +UNIVERSAL=TIFFCheckTile +UNIVERSAL=TIFFNumberOfTiles +UNIVERSAL=TIFFReadTile +UNIVERSAL=TIFFWriteTile +UNIVERSAL=TIFFComputeStrip +UNIVERSAL=TIFFNumberOfStrips +UNIVERSAL=TIFFRGBAImageBegin +UNIVERSAL=TIFFRGBAImageGet +UNIVERSAL=TIFFRGBAImageEnd +UNIVERSAL=TIFFReadEncodedStrip +UNIVERSAL=TIFFReadRawStrip +UNIVERSAL=TIFFReadEncodedTile +UNIVERSAL=TIFFReadRawTile +UNIVERSAL=TIFFReadRGBATile +UNIVERSAL=TIFFReadRGBAStrip +UNIVERSAL=TIFFWriteEncodedStrip +UNIVERSAL=TIFFWriteRawStrip +UNIVERSAL=TIFFWriteEncodedTile +UNIVERSAL=TIFFWriteRawTile +UNIVERSAL=TIFFSetWriteOffset +UNIVERSAL=TIFFSwabDouble +UNIVERSAL=TIFFSwabShort +UNIVERSAL=TIFFSwabLong +UNIVERSAL=TIFFSwabArrayOfShort +UNIVERSAL=TIFFSwabArrayOfLong +UNIVERSAL=TIFFSwabArrayOfDouble +UNIVERSAL=TIFFSwabArrayOfTriples +UNIVERSAL=TIFFReverseBits +UNIVERSAL=TIFFGetBitRevTable +UNIVERSAL=TIFFDefaultStripSize +UNIVERSAL=TIFFDefaultTileSize +UNIVERSAL=TIFFRasterScanlineSize +UNIVERSAL=_TIFFmalloc +UNIVERSAL=_TIFFrealloc +UNIVERSAL=_TIFFfree +UNIVERSAL=_TIFFmemset +UNIVERSAL=_TIFFmemcpy +UNIVERSAL=_TIFFmemcmp +UNIVERSAL=TIFFCreateDirectory +UNIVERSAL=TIFFSetTagExtender +UNIVERSAL=TIFFMergeFieldInfo +UNIVERSAL=TIFFFindFieldInfo +UNIVERSAL=TIFFFindFieldInfoByName +UNIVERSAL=TIFFFieldWithName +UNIVERSAL=TIFFFieldWithTag +UNIVERSAL=TIFFFieldTag +UNIVERSAL=TIFFFieldName +UNIVERSAL=TIFFFieldDataType +UNIVERSAL=TIFFFieldPassCount +UNIVERSAL=TIFFFieldReadCount +UNIVERSAL=TIFFFieldWriteCount +UNIVERSAL=TIFFCurrentDirOffset +UNIVERSAL=TIFFWriteCheck +UNIVERSAL=TIFFRGBAImageOK +UNIVERSAL=TIFFNumberOfDirectories +UNIVERSAL=TIFFSetFileName +UNIVERSAL=TIFFSetClientdata +UNIVERSAL=TIFFSetMode +UNIVERSAL=TIFFClientdata +UNIVERSAL=TIFFGetReadProc +UNIVERSAL=TIFFGetWriteProc +UNIVERSAL=TIFFGetSeekProc +UNIVERSAL=TIFFGetCloseProc +UNIVERSAL=TIFFGetSizeProc +UNIVERSAL=TIFFGetMapFileProc +UNIVERSAL=TIFFGetUnmapFileProc +UNIVERSAL=TIFFIsCODECConfigured +UNIVERSAL=TIFFGetConfiguredCODECs +UNIVERSAL=TIFFFindCODEC +UNIVERSAL=TIFFRegisterCODEC +UNIVERSAL=TIFFUnRegisterCODEC +UNIVERSAL=TIFFFreeDirectory +UNIVERSAL=TIFFReadCustomDirectory +UNIVERSAL=TIFFReadEXIFDirectory +UNIVERSAL=TIFFAccessTagMethods +UNIVERSAL=TIFFGetClientInfo +UNIVERSAL=TIFFSetClientInfo +UNIVERSAL=TIFFReassignTagToIgnore + +$ENDIF +$! +$! +$! Writing TIFF$SHR.OPT file to build TOOLS +$ IF (SHARED.GT.0) +$ THEN +$ OPEN/WRITE OUT TIFF$SHR.OPT +$ WRITE OUT "[]TIFF/LIB" +$ WRITE OUT "[-.PORT]LIBPORT/LIB" +$ WRITE OUT JPEG_LIBRARY_PATH +$ WRITE OUT "ZLIB:LIBZ/LIB" +$ CLOSE OUT +$ ENDIF +$! +$! +$! Writing OPT.OPT file to build TOOLS +$OPEN/WRITE OUT OPT.OPT +$ IF (SHARED.GT.0) +$ THEN +$ WRITE OUT "[-.LIBTIFF]TIFF$SHR/SHARE" +$ WRITE OUT JPEG_LIBRARY_PATH +$ ELSE +$ WRITE OUT "[-.LIBTIFF]TIFF/LIB" +$ WRITE OUT "[-.PORT]LIBPORT/LIB" +$ WRITE OUT JPEG_LIBRARY_PATH +$ ENDIF +$ WRITE OUT "ZLIB:LIBZ/LIB" +$CLOSE OUT +$! +$! +$COPY SYS$INPUT [.LIBTIFF]DESCRIP.MMS +# (c) Alexey Chupahin 22-NOV-2007 +# OpenVMS 7.3-1, DEC 2000 mod.300 +# OpenVMS 8.3, HP rx1620 +# Makefile for DEC C compilers. +# + +INCL = /INCLUDE=(JPEG,ZLIB,[]) + +CFLAGS = $(INCL) + +OBJ_SYSDEP_MODULE = tif_vms.obj + +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_flush.obj,\ +tif_getimage.obj,\ +tif_jbig.obj,\ +tif_jpeg.obj,\ +tif_luv.obj,\ +tif_lzw.obj,\ +tif_next.obj,\ +tif_ojpeg.obj,\ +tif_open.obj,\ +tif_packbits.obj,\ +tif_pixarlog.obj,\ +tif_predict.obj,\ +tif_print.obj,\ +tif_read.obj,\ +tif_strip.obj,\ +tif_swab.obj,\ +tif_thunder.obj,\ +tif_tile.obj,\ +tif_version.obj,\ +tif_warning.obj,\ +tif_write.obj,\ +tif_zip.obj, $(OBJ_SYSDEP_MODULE) + +$IF (SHARED.GT.0) +$ THEN +$ APP SYS$INPUT [.LIBTIFF]DESCRIP.MMS +ALL : tiff.olb, tiff$shr.exe + $WRITE SYS$OUTPUT "Done" + +tiff$shr.exe : tiff.olb + LINK/SHARE=TIFF$SHR.EXE TIF_AUX,[-]TIFF$DEF/OPT, [-]TIFF$SHR/OPT + COPY TIFF$SHR.EXE SYS$SHARE + PURGE SYS$SHARE:TIFF$SHR.EXE + +$ ELSE +$ APP SYS$INPUT [.LIBTIFF]DESCRIP.MMS +ALL : tiff.olb + $WRITE SYS$OUTPUT "Done" + +$ENDIF +$! +$! +$ APP SYS$INPUT [.LIBTIFF]DESCRIP.MMS + +tiff.olb : $(OBJ) + lib/crea tiff.olb $(OBJ) + +#tif_config.h : tif_config.h-vms +# copy tif_config.h-vms tif_config.h +# +#tiffconf.h : tiffconf.h-vms +# copy tiffconf.h-vms tiffconf.h + +tif_aux.obj : tif_aux.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_close.obj : tif_close.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_codec.obj : tif_codec.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_color.obj : tif_color.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_compress.obj : tif_compress.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dir.obj : tif_dir.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dirinfo.obj : tif_dirinfo.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dirread.obj : tif_dirread.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dirwrite.obj : tif_dirwrite.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_dumpmode.obj : tif_dumpmode.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_error.obj : tif_error.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_extension.obj : tif_extension.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_fax3.obj : tif_fax3.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_fax3sm.obj : tif_fax3sm.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_flush.obj : tif_flush.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_getimage.obj : tif_getimage.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_jbig.obj : tif_jbig.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_jpeg.obj : tif_jpeg.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_luv.obj : tif_luv.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_lzw.obj : tif_lzw.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_next.obj : tif_next.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_ojpeg.obj : tif_ojpeg.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_open.obj : tif_open.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_packbits.obj : tif_packbits.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_pixarlog.obj : tif_pixarlog.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_predict.obj : tif_predict.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_print.obj : tif_print.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_read.obj : tif_read.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_strip.obj : tif_strip.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_swab.obj : tif_swab.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_thunder.obj : tif_thunder.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_tile.obj : tif_tile.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_unix.obj : tif_unix.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_version.obj : tif_version.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_warning.obj : tif_warning.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_write.obj : tif_write.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tif_zip.obj : tif_zip.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + + +clean : + del *.obj;* + del *.olb;* +$! +$! +$! +$COPY SYS$INPUT [.TOOLS]DESCRIP.MMS +# (c) Alexey Chupahin 22-NOV-2007 +# OpenVMS 7.3-1, DEC 2000 mod.300 +# OpenVMS 8.3, HP rx1620 + +INCL = /INCL=([],[-.LIBTIFF]) +CFLAGS = $(INCL) +LIBS = [-]OPT/OPT + +OBJ=\ +bmp2tiff.exe,\ +fax2ps.exe,\ +fax2tiff.exe,\ +gif2tiff.exe,\ +pal2rgb.exe,\ +ppm2tiff.exe,\ +ras2tiff.exe,\ +raw2tiff.exe,\ +rgb2ycbcr.exe,\ +thumbnail.exe,\ +tiff2bw.exe,\ +tiff2pdf.exe,\ +tiff2ps.exe,\ +tiff2rgba.exe,\ +tiffcmp.exe,\ +tiffcp.exe,\ +tiffcrop.exe,\ +tiffdither.exe,\ +tiffdump.exe,\ +tiffinfo.exe,\ +tiffmedian.exe,\ +tiffset.exe,\ +tiffsplit.exe,\ +ycbcr.exe + + +all : $(OBJ) + $! + +bmp2tiff.obj : bmp2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +bmp2tiff.exe : bmp2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +fax2ps.obj : fax2ps.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +fax2ps.exe : fax2ps.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +fax2tiff.obj : fax2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +fax2tiff.exe : fax2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +gif2tiff.obj : gif2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +gif2tiff.exe : gif2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +pal2rgb.obj : pal2rgb.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +pal2rgb.exe : pal2rgb.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +ppm2tiff.obj : ppm2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +ppm2tiff.exe : ppm2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +ras2tiff.obj : ras2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +ras2tiff.exe : ras2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +raw2tiff.obj : raw2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +raw2tiff.exe : raw2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +rgb2ycbcr.obj : rgb2ycbcr.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +rgb2ycbcr.exe : rgb2ycbcr.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +sgi2tiff.obj : sgi2tiff.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +sgi2tiff.exe : sgi2tiff.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +sgisv.obj : sgisv.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +sgisv.exe : sgisv.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +thumbnail.obj : thumbnail.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +thumbnail.exe : thumbnail.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiff2bw.obj : tiff2bw.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiff2bw.exe : tiff2bw.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiff2pdf.obj : tiff2pdf.c + $(CC) $(CFLAGS) /NOWARN $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiff2pdf.exe : tiff2pdf.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiff2ps.obj : tiff2ps.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiff2ps.exe : tiff2ps.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiff2rgba.obj : tiff2rgba.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiff2rgba.exe : tiff2rgba.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffcmp.obj : tiffcmp.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffcmp.exe : tiffcmp.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffcp.obj : tiffcp.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffcp.exe : tiffcp.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffcrop.obj : tiffcrop.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffcrop.exe : tiffcrop.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffdither.obj : tiffdither.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffdither.exe : tiffdither.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffdump.obj : tiffdump.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffdump.exe : tiffdump.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffgt.obj : tiffgt.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffgt.exe : tiffgt.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffinfo.obj : tiffinfo.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffinfo.exe : tiffinfo.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffmedian.obj : tiffmedian.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffmedian.exe : tiffmedian.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffset.obj : tiffset.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffset.exe : tiffset.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +tiffsplit.obj : tiffsplit.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +tiffsplit.exe : tiffsplit.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + +ycbcr.obj : ycbcr.c + $(CC) $(CFLAGS) $(MMS$SOURCE) /OBJ=$(MMS$TARGET) + +ycbcr.exe : ycbcr.obj + LINK/EXE=$(MMS$TARGET) $(MMS$SOURCE), $(LIBS) + + +CLEAN : + DEL ALL.;* + DEL *.OBJ;* + DEL *.EXE;* + +$! +$! +$! +$!copiing and patching TIFF_CONF.H, TIF_CONFIG.H +$! +$CURRENT = F$ENVIRONMENT (""DEFAULT"") +$CURRENT[F$LOCATE("]",CURRENT),9]:=".LIBTIFF]" +$WRITE SYS$OUTPUT "Creating TIFFCONF.H and TIF_CONFIG.H" +$COPY SYS$INPUT 'CURRENT'TIFFCONF.H +/* + Configuration defines for installed libtiff. + This file maintained for backward compatibility. Do not use definitions + from this file in your programs. +*/ + +#ifndef _TIFFCONF_ +#define _TIFFCONF_ + +/* Define to 1 if the system has the type `int16'. */ +//#define HAVE_INT16 + +/* Define to 1 if the system has the type `int32'. */ +//#define HAVE_INT32 + +/* Define to 1 if the system has the type `int8'. */ +//#define HAVE_INT8 + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* Compatibility stuff. */ + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ + +#ifdef __IEEE_FLOAT +#define HAVE_IEEEFP 1 +#endif + +#define HAVE_GETOPT 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 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) */ + +/* Support Macintosh PackBits algorithm */ +#define PACKBITS_SUPPORT 1 + +/* Support Pixar log-format algorithm (requires Zlib) */ +#define PIXARLOG_SUPPORT 1 + +/* 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_ */ + + +$COPY SYS$INPUT 'CURRENT'TIF_CONFIG.H +/* Define to 1 if you have the header file. */ + +#ifndef HAVE_GETOPT +# define HAVE_GETOPT 1 +#endif + +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ + +#ifdef __IEEE_FLOAT +#define HAVE_IEEEFP 1 +#endif + +#define HAVE_UNISTD_H 1 + +#define HAVE_STRING_H 1 +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_IO_H 1 + +/* Define to 1 if you have the 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 +*/ + +/* Support CCITT Group 3 & 4 algorithms */ +#define CCITT_SUPPORT 1 + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 +/* Support C++ stream API (requires C++ compiler) */ +#define CXX_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 + +/* little Endian */ +#define HOST_BIGENDIAN 0 +#define JPEG_SUPPORT 1 +#define LOGLUV_SUPPORT 1 +/* Support LZW algorithm */ +#define LZW_SUPPORT 1 + +/* Support Microsoft Document Imaging format */ +#define MDI_SUPPORT 1 + +/* Support NeXT 2-bit RLE algorithm */ +#define NEXT_SUPPORT 1 +#define OJPEG_SUPPORT 1 + +/* Name of package */ +#define PACKAGE "tiff" + + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "tiff@lists.maptools.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "LibTIFF Software" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "LibTIFF Software 3.9.0beta for VMS" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "tiff" + +$PURGE 'CURRENT'TIFFCONF.H +$PURGE 'CURRENT'TIF_CONFIG.H +$OPEN/APPEND OUT 'CURRENT'TIF_CONFIG.H +$IF HAVE_LFIND.EQ.1 +$ THEN +$ WRITE OUT "#define HAVE_SEARCH_H 1" +$ ELSE +$ WRITE OUT "#undef HAVE_SEARCH_H" +$ENDIF +$CLOSE OUT +$! +$! +$WRITE SYS$OUTPUT " " +$WRITE SYS$OUTPUT " " +$WRITE SYS$OUTPUT "Now you can type @BUILD " +$! +$EXIT: +$DEFINE SYS$ERROR _NLA0: +$DEFINE SYS$OUTPUT _NLA0: +$DEL TEST.OBJ;* +$DEL TEST.C;* +$DEL TEST.EXE;* +$DEAS SYS$ERROR +$DEAS SYS$OUTPUT diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/contrib/CMakeLists.txt index 8c8310b64..6bb124f43 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/CMakeLists.txt +++ b/thirdparty/SDL2_image/external/libtiff/contrib/CMakeLists.txt @@ -25,3 +25,11 @@ add_subdirectory(addtiffo) add_subdirectory(dbs) add_subdirectory(iptcutil) +add_subdirectory(mfs) +add_subdirectory(pds) +add_subdirectory(ras) +add_subdirectory(stream) +add_subdirectory(tags) +add_subdirectory(win_dib) + +extra_dist(README) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/CMakeLists.txt index 7c86e950d..45e733cd2 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/CMakeLists.txt +++ b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/CMakeLists.txt @@ -22,8 +22,16 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +extra_dist( + README + Makefile.vc) + +include_directories(${PROJECT_SOURCE_DIR}/libtiff + ${PROJECT_BINARY_DIR}/libtiff + ${CMAKE_CURRENT_BINARY_DIR}) + add_executable(addtiffo addtiffo.c tif_overview.c tif_ovrcache.c tif_ovrcache.h) -target_link_libraries(addtiffo tiff tiff_port) +target_link_libraries(addtiffo tiff port) if(WEBP_SUPPORT AND EMSCRIPTEN) # Emscripten is pretty finnicky about linker flags. diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/Makefile.am index f8f15fcd9..87342bdee 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/Makefile.am @@ -27,11 +27,10 @@ LIBTIFF = $(top_builddir)/libtiff/libtiff.la EXTRA_DIST = \ CMakeLists.txt \ + Makefile.vc \ README -if TIFF_CONTRIB noinst_PROGRAMS = addtiffo -endif addtiffo_SOURCES = addtiffo.c tif_overview.c tif_ovrcache.c tif_ovrcache.h addtiffo_LDADD = $(LIBTIFF) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/Makefile.vc b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/Makefile.vc new file mode 100755 index 000000000..2777dc2ad --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/Makefile.vc @@ -0,0 +1,28 @@ +# +# If libtiff.a is installed in /usr/lib or /usr/local/lib just point +# LIBTIFF_DIR there. It doesn't need a full libtiff tree. +# +!INCLUDE ..\..\nmake.opt + +LIBTIFF_DIR = ..\..\libtiff +# +INCL = -I..\..\libtiff +LIBS = $(LIBTIFF_DIR)\libtiff.lib + +addtiffo: addtiffo.obj tif_overview.obj tif_ovrcache.obj + $(CC) $(CFLAGS) addtiffo.obj tif_overview.obj tif_ovrcache.obj \ + $(LIBS) /Feaddtiffo.exe + + +addtiffo.obj: addtiffo.c + $(CC) -c $(CFLAGS) addtiffo.c + +tif_overview.obj: tif_overview.c + $(CC) -c $(CFLAGS) tif_overview.c + +tif_ovrcache.obj: tif_ovrcache.c + $(CC) -c $(CFLAGS) tif_ovrcache.c + +clean: + -del *.obj + -del addtiffo.exe diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/addtiffo.c b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/addtiffo.c index a4ff19b38..e1d706230 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/addtiffo.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/addtiffo.c @@ -59,50 +59,49 @@ * New */ -#include "tiffio.h" #include #include #include +#include "tiffio.h" -void TIFFBuildOverviews(TIFF *, int, int *, int, const char *, - int (*)(double, void *), void *); +void TIFFBuildOverviews( TIFF *, int, int *, int, const char *, + int (*)(double,void*), void * ); /************************************************************************/ /* main() */ /************************************************************************/ -int main(int argc, char **argv) +int main( int argc, char ** argv ) { - int anOverviews[100]; /* TODO: un-hardwire array length, flexible allocate - */ - int nOverviewCount = 0; - int bUseSubIFD = 0; - TIFF *hTIFF; - const char *pszResampling = "nearest"; + int anOverviews[100]; /* TODO: un-hardwire array length, flexible allocate */ + int nOverviewCount = 0; + int bUseSubIFD = 0; + TIFF *hTIFF; + const char *pszResampling = "nearest"; - /* -------------------------------------------------------------------- */ - /* Usage: */ - /* -------------------------------------------------------------------- */ - if (argc < 2) +/* -------------------------------------------------------------------- */ +/* Usage: */ +/* -------------------------------------------------------------------- */ + if( argc < 2 ) { - printf("Usage: addtiffo [-r {nearest,average,mode}]\n" - " tiff_filename [resolution_reductions]\n" - "\n" - "Example:\n" - " %% addtiffo abc.tif 2 4 8 16\n"); - return (1); + printf( "Usage: addtiffo [-r {nearest,average,mode}]\n" + " tiff_filename [resolution_reductions]\n" + "\n" + "Example:\n" + " %% addtiffo abc.tif 2 4 8 16\n" ); + return( 1 ); } - while (argv[1][0] == '-') + while( argv[1][0] == '-' ) { - if (strcmp(argv[1], "-subifd") == 0) + if( strcmp(argv[1],"-subifd") == 0 ) { bUseSubIFD = 1; argv++; argc--; } - else if (strcmp(argv[1], "-r") == 0) + else if( strcmp(argv[1],"-r") == 0 ) { argv += 2; argc -= 2; @@ -110,35 +109,34 @@ int main(int argc, char **argv) } else { - fprintf(stderr, "Incorrect parameters\n"); - return (1); + fprintf( stderr, "Incorrect parameters\n" ); + return( 1 ); } } - /* TODO: resampling mode parameter needs to be encoded in an integer from - * this point on */ + /* TODO: resampling mode parameter needs to be encoded in an integer from this point on */ - /* -------------------------------------------------------------------- */ - /* Collect the user requested reduction factors. */ - /* -------------------------------------------------------------------- */ - while (nOverviewCount < argc - 2 && nOverviewCount < 100) +/* -------------------------------------------------------------------- */ +/* Collect the user requested reduction factors. */ +/* -------------------------------------------------------------------- */ + while( nOverviewCount < argc - 2 && nOverviewCount < 100 ) { - anOverviews[nOverviewCount] = atoi(argv[nOverviewCount + 2]); - if ((anOverviews[nOverviewCount] <= 0) || + anOverviews[nOverviewCount] = atoi(argv[nOverviewCount+2]); + if( (anOverviews[nOverviewCount] <= 0) || ((anOverviews[nOverviewCount] > 1024))) { - fprintf(stderr, "Incorrect parameters\n"); - return (1); + fprintf( stderr, "Incorrect parameters\n" ); + return(1); } nOverviewCount++; } - /* -------------------------------------------------------------------- */ - /* Default to four overview levels. It would be nicer if it */ - /* defaulted based on the size of the source image. */ - /* -------------------------------------------------------------------- */ +/* -------------------------------------------------------------------- */ +/* Default to four overview levels. It would be nicer if it */ +/* defaulted based on the size of the source image. */ +/* -------------------------------------------------------------------- */ /* TODO: make it default based on the size of the source image */ - if (nOverviewCount == 0) + if( nOverviewCount == 0 ) { nOverviewCount = 4; @@ -148,20 +146,20 @@ int main(int argc, char **argv) anOverviews[3] = 16; } - /* -------------------------------------------------------------------- */ - /* Build the overview. */ - /* -------------------------------------------------------------------- */ - hTIFF = TIFFOpen(argv[1], "r+"); - if (hTIFF == NULL) +/* -------------------------------------------------------------------- */ +/* Build the overview. */ +/* -------------------------------------------------------------------- */ + hTIFF = TIFFOpen( argv[1], "r+" ); + if( hTIFF == NULL ) { - fprintf(stderr, "TIFFOpen(%s) failed.\n", argv[1]); - return (1); + fprintf( stderr, "TIFFOpen(%s) failed.\n", argv[1] ); + return( 1 ); } - TIFFBuildOverviews(hTIFF, nOverviewCount, anOverviews, bUseSubIFD, - pszResampling, NULL, NULL); + TIFFBuildOverviews( hTIFF, nOverviewCount, anOverviews, bUseSubIFD, + pszResampling, NULL, NULL ); - TIFFClose(hTIFF); + TIFFClose( hTIFF ); /* -------------------------------------------------------------------- */ /* Optionally test for memory leaks. */ @@ -170,5 +168,12 @@ int main(int argc, char **argv) malloc_dump(1); #endif - return (0); + return( 0 ); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_overview.c b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_overview.c index 9a4c34427..03b357334 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_overview.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_overview.c @@ -20,8 +20,8 @@ * o Reduced resolution overviews for multi-sample files will currently * always be generated as PLANARCONFIG_SEPARATE. This could be fixed * reasonable easily if needed to improve compatibility with other - * packages. Many don't properly support PLANARCONFIG_SEPARATE. - * + * packages. Many don't properly support PLANARCONFIG_SEPARATE. + * ****************************************************************************** * Copyright (c) 1999, Frank Warmerdam * @@ -47,28 +47,28 @@ /* TODO: update notes in header above */ -#include #include +#include #include #include -#include "tif_ovrcache.h" #include "tiffio.h" +#include "tif_ovrcache.h" #ifndef FALSE -#define FALSE 0 -#define TRUE 1 +# define FALSE 0 +# define TRUE 1 #endif #ifndef MAX -#define MIN(a, b) ((a < b) ? a : b) -#define MAX(a, b) ((a > b) ? a : b) +# define MIN(a,b) ((ab) ? a : b) #endif -#define TIFF_DIR_MAX 65534 +#define TIFF_DIR_MAX 65534 -void TIFFBuildOverviews(TIFF *, int, int *, int, const char *, - int (*)(double, void *), void *); +void TIFFBuildOverviews( TIFF *, int, int *, int, const char *, + int (*)(double,void*), void * ); /************************************************************************/ /* TIFF_WriteOverview() */ @@ -79,90 +79,91 @@ void TIFFBuildOverviews(TIFF *, int, int *, int, const char *, /* function is called. */ /************************************************************************/ -uint32_t TIFF_WriteOverview(TIFF *hTIFF, uint32_t nXSize, uint32_t nYSize, - int nBitsPerPixel, int nPlanarConfig, int nSamples, - int nBlockXSize, int nBlockYSize, int bTiled, - int nCompressFlag, int nPhotometric, - int nSampleFormat, unsigned short *panRed, - unsigned short *panGreen, unsigned short *panBlue, - int bUseSubIFDs, int nHorSubsampling, - int nVerSubsampling) +uint32 TIFF_WriteOverview( TIFF *hTIFF, uint32 nXSize, uint32 nYSize, + int nBitsPerPixel, int nPlanarConfig, int nSamples, + int nBlockXSize, int nBlockYSize, + int bTiled, int nCompressFlag, int nPhotometric, + int nSampleFormat, + unsigned short *panRed, + unsigned short *panGreen, + unsigned short *panBlue, + int bUseSubIFDs, + int nHorSubsampling, int nVerSubsampling ) { - toff_t nBaseDirOffset; - toff_t nOffset; - tdir_t iNumDir; + toff_t nBaseDirOffset; + toff_t nOffset; + tdir_t iNumDir; - (void)bUseSubIFDs; + (void) bUseSubIFDs; - nBaseDirOffset = TIFFCurrentDirOffset(hTIFF); + nBaseDirOffset = TIFFCurrentDirOffset( hTIFF ); - TIFFCreateDirectory(hTIFF); + TIFFCreateDirectory( hTIFF ); - /* -------------------------------------------------------------------- */ - /* Setup TIFF fields. */ - /* -------------------------------------------------------------------- */ - TIFFSetField(hTIFF, TIFFTAG_IMAGEWIDTH, nXSize); - TIFFSetField(hTIFF, TIFFTAG_IMAGELENGTH, nYSize); - if (nSamples == 1) - TIFFSetField(hTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); +/* -------------------------------------------------------------------- */ +/* Setup TIFF fields. */ +/* -------------------------------------------------------------------- */ + TIFFSetField( hTIFF, TIFFTAG_IMAGEWIDTH, nXSize ); + TIFFSetField( hTIFF, TIFFTAG_IMAGELENGTH, nYSize ); + if( nSamples == 1 ) + TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG ); else - TIFFSetField(hTIFF, TIFFTAG_PLANARCONFIG, nPlanarConfig); + TIFFSetField( hTIFF, TIFFTAG_PLANARCONFIG, nPlanarConfig ); - TIFFSetField(hTIFF, TIFFTAG_BITSPERSAMPLE, nBitsPerPixel); - TIFFSetField(hTIFF, TIFFTAG_SAMPLESPERPIXEL, nSamples); - TIFFSetField(hTIFF, TIFFTAG_COMPRESSION, nCompressFlag); - TIFFSetField(hTIFF, TIFFTAG_PHOTOMETRIC, nPhotometric); - TIFFSetField(hTIFF, TIFFTAG_SAMPLEFORMAT, nSampleFormat); + TIFFSetField( hTIFF, TIFFTAG_BITSPERSAMPLE, nBitsPerPixel ); + TIFFSetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, nSamples ); + TIFFSetField( hTIFF, TIFFTAG_COMPRESSION, nCompressFlag ); + TIFFSetField( hTIFF, TIFFTAG_PHOTOMETRIC, nPhotometric ); + TIFFSetField( hTIFF, TIFFTAG_SAMPLEFORMAT, nSampleFormat ); - if (bTiled) + if( bTiled ) { - TIFFSetField(hTIFF, TIFFTAG_TILEWIDTH, nBlockXSize); - TIFFSetField(hTIFF, TIFFTAG_TILELENGTH, nBlockYSize); + TIFFSetField( hTIFF, TIFFTAG_TILEWIDTH, nBlockXSize ); + TIFFSetField( hTIFF, TIFFTAG_TILELENGTH, nBlockYSize ); } else - TIFFSetField(hTIFF, TIFFTAG_ROWSPERSTRIP, nBlockYSize); + TIFFSetField( hTIFF, TIFFTAG_ROWSPERSTRIP, nBlockYSize ); - TIFFSetField(hTIFF, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE); + TIFFSetField( hTIFF, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE ); - if (nPhotometric == PHOTOMETRIC_YCBCR || nPhotometric == PHOTOMETRIC_ITULAB) + if( nPhotometric == PHOTOMETRIC_YCBCR || nPhotometric == PHOTOMETRIC_ITULAB ) { - TIFFSetField(hTIFF, TIFFTAG_YCBCRSUBSAMPLING, nHorSubsampling, - nVerSubsampling); - /* TODO: also write YCbCrPositioning and YCbCrCoefficients tag identical - * to source IFD */ + TIFFSetField( hTIFF, TIFFTAG_YCBCRSUBSAMPLING, nHorSubsampling, nVerSubsampling); + /* TODO: also write YCbCrPositioning and YCbCrCoefficients tag identical to source IFD */ } /* TODO: add command-line parameter for selecting jpeg compression quality * that gets ignored when compression isn't jpeg */ - /* -------------------------------------------------------------------- */ - /* Write color table if one is present. */ - /* -------------------------------------------------------------------- */ - if (panRed != NULL) +/* -------------------------------------------------------------------- */ +/* Write color table if one is present. */ +/* -------------------------------------------------------------------- */ + if( panRed != NULL ) { - TIFFSetField(hTIFF, TIFFTAG_COLORMAP, panRed, panGreen, panBlue); + TIFFSetField( hTIFF, TIFFTAG_COLORMAP, panRed, panGreen, panBlue ); } - /* -------------------------------------------------------------------- */ - /* Write directory, and return byte offset. */ - /* -------------------------------------------------------------------- */ - if (TIFFWriteCheck(hTIFF, bTiled, "TIFFBuildOverviews") == 0) +/* -------------------------------------------------------------------- */ +/* Write directory, and return byte offset. */ +/* -------------------------------------------------------------------- */ + if( TIFFWriteCheck( hTIFF, bTiled, "TIFFBuildOverviews" ) == 0 ) return 0; - TIFFWriteDirectory(hTIFF); + TIFFWriteDirectory( hTIFF ); iNumDir = TIFFNumberOfDirectories(hTIFF); - if (iNumDir > TIFF_DIR_MAX) + if( iNumDir > TIFF_DIR_MAX ) { - TIFFErrorExt(TIFFClientdata(hTIFF), "TIFF_WriteOverview", - "File `%s' has too many directories.\n", - TIFFFileName(hTIFF)); + TIFFErrorExt( TIFFClientdata(hTIFF), + "TIFF_WriteOverview", + "File `%s' has too many directories.\n", + TIFFFileName(hTIFF) ); exit(-1); } - TIFFSetDirectory(hTIFF, (tdir_t)(iNumDir - 1)); + TIFFSetDirectory( hTIFF, (tdir_t) (iNumDir - 1) ); - nOffset = TIFFCurrentDirOffset(hTIFF); + nOffset = TIFFCurrentDirOffset( hTIFF ); - TIFFSetSubDirectory(hTIFF, nBaseDirOffset); + TIFFSetSubDirectory( hTIFF, nBaseDirOffset ); return nOffset; } @@ -171,89 +172,91 @@ uint32_t TIFF_WriteOverview(TIFF *hTIFF, uint32_t nXSize, uint32_t nYSize, /* TIFF_GetSourceSamples() */ /************************************************************************/ -static void TIFF_GetSourceSamples(double *padfSamples, unsigned char *pabySrc, - int nPixelBytes, int nSampleFormat, - uint32_t nXSize, uint32_t nYSize, - int nPixelOffset, int nLineOffset) +static void +TIFF_GetSourceSamples( double * padfSamples, unsigned char *pabySrc, + int nPixelBytes, int nSampleFormat, + uint32 nXSize, uint32 nYSize, + int nPixelOffset, int nLineOffset ) { - uint32_t iXOff, iYOff; - int iSample; + uint32 iXOff, iYOff; + int iSample; iSample = 0; - for (iYOff = 0; iYOff < nYSize; iYOff++) + for( iYOff = 0; iYOff < nYSize; iYOff++ ) { - for (iXOff = 0; iXOff < nXSize; iXOff++) + for( iXOff = 0; iXOff < nXSize; iXOff++ ) { unsigned char *pabyData; pabyData = pabySrc + iYOff * nLineOffset + iXOff * nPixelOffset; - if (nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 1) + if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 1 ) { padfSamples[iSample++] = *pabyData; } - else if (nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 2) + else if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 2 ) { - padfSamples[iSample++] = ((uint16_t *)pabyData)[0]; + padfSamples[iSample++] = ((uint16 *) pabyData)[0]; } - else if (nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 4) + else if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 4 ) { - padfSamples[iSample++] = ((uint32_t *)pabyData)[0]; + padfSamples[iSample++] = ((uint32 *) pabyData)[0]; } - else if (nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 2) + else if( nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 2 ) { - padfSamples[iSample++] = ((int16_t *)pabyData)[0]; + padfSamples[iSample++] = ((int16 *) pabyData)[0]; } - else if (nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 32) + else if( nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 32 ) { - padfSamples[iSample++] = ((int32_t *)pabyData)[0]; + padfSamples[iSample++] = ((int32 *) pabyData)[0]; } - else if (nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 4) + else if( nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 4 ) { - padfSamples[iSample++] = ((float *)pabyData)[0]; + padfSamples[iSample++] = ((float *) pabyData)[0]; } - else if (nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 8) + else if( nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 8 ) { - padfSamples[iSample++] = ((double *)pabyData)[0]; + padfSamples[iSample++] = ((double *) pabyData)[0]; } } } -} +} /************************************************************************/ /* TIFF_SetSample() */ /************************************************************************/ -static void TIFF_SetSample(unsigned char *pabyData, int nPixelBytes, - int nSampleFormat, double dfValue) +static void +TIFF_SetSample( unsigned char * pabyData, int nPixelBytes, int nSampleFormat, + double dfValue ) { - if (nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 1) + if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 1 ) { - *pabyData = (unsigned char)MAX(0, MIN(255, dfValue)); + *pabyData = (unsigned char) MAX(0,MIN(255,dfValue)); } - else if (nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 2) + else if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 2 ) { - *((uint16_t *)pabyData) = (uint16_t)MAX(0, MIN(65535, dfValue)); + *((uint16 *)pabyData) = (uint16) MAX(0,MIN(65535,dfValue)); } - else if (nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 4) + else if( nSampleFormat == SAMPLEFORMAT_UINT && nPixelBytes == 4 ) { - *((uint32_t *)pabyData) = (uint32_t)dfValue; + *((uint32 *)pabyData) = (uint32) dfValue; } - else if (nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 2) + else if( nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 2 ) { - *((int16_t *)pabyData) = (int16_t)MAX(-32768, MIN(32767, dfValue)); + *((int16 *)pabyData) = (int16) MAX(-32768,MIN(32767,dfValue)); } - else if (nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 32) + else if( nSampleFormat == SAMPLEFORMAT_INT && nPixelBytes == 32 ) { - *((int32_t *)pabyData) = (int32_t)dfValue; + *((int32 *)pabyData) = (int32) dfValue; } - else if (nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 4) + else if( nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 4 ) { - *((float *)pabyData) = (float)dfValue; + *((float *)pabyData) = (float) dfValue; } - else if (nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 8) + else if( nSampleFormat == SAMPLEFORMAT_IEEEFP && nPixelBytes == 8 ) { *((double *)pabyData) = dfValue; } @@ -266,79 +269,75 @@ static void TIFF_SetSample(unsigned char *pabyData, int nPixelBytes, /* of downsampled data. */ /************************************************************************/ -static void TIFF_DownSample(unsigned char *pabySrcTile, uint32_t nBlockXSize, - uint32_t nBlockYSize, int nPixelSkewBits, - int nBitsPerPixel, unsigned char *pabyOTile, - uint32_t nOBlockXSize, uint32_t nOBlockYSize, - uint32_t nTXOff, uint32_t nTYOff, int nOMult, - int nSampleFormat, const char *pszResampling) +static +void TIFF_DownSample( unsigned char *pabySrcTile, + uint32 nBlockXSize, uint32 nBlockYSize, + int nPixelSkewBits, int nBitsPerPixel, + unsigned char * pabyOTile, + uint32 nOBlockXSize, uint32 nOBlockYSize, + uint32 nTXOff, uint32 nTYOff, int nOMult, + int nSampleFormat, const char * pszResampling ) { - uint32_t i, j; - int k, nPixelBytes = (nBitsPerPixel) / 8; - int nPixelGroupBytes = (nBitsPerPixel + nPixelSkewBits) / 8; + uint32 i, j; + int k, nPixelBytes = (nBitsPerPixel) / 8; + int nPixelGroupBytes = (nBitsPerPixel+nPixelSkewBits)/8; unsigned char *pabySrc, *pabyDst; - double *padfSamples; - size_t tpadfSamples_size, padfSamples_size; + double *padfSamples; + size_t tpadfSamples_size, padfSamples_size; - assert(nBitsPerPixel >= 8); + assert( nBitsPerPixel >= 8 ); /* sizeof(double) * nOMult * nOMult */ - tpadfSamples_size = nOMult * nOMult; - if ((nOMult != 0) && (tpadfSamples_size / nOMult == (size_t)nOMult)) - { - padfSamples_size = tpadfSamples_size; - tpadfSamples_size = padfSamples_size * sizeof(double); + tpadfSamples_size=nOMult*nOMult; + if ((nOMult != 0) && (tpadfSamples_size/nOMult == (size_t) nOMult)) { + padfSamples_size=tpadfSamples_size; + tpadfSamples_size=padfSamples_size*sizeof(double); if ((tpadfSamples_size / padfSamples_size) == sizeof(double)) - padfSamples_size = tpadfSamples_size; + padfSamples_size=tpadfSamples_size; else - padfSamples_size = 0; + padfSamples_size=0; + } else { + padfSamples_size=0; } - else - { - padfSamples_size = 0; - } - if (padfSamples_size == 0) - { + if (padfSamples_size == 0) { /* TODO: This is an error condition */ return; } - padfSamples = (double *)malloc(padfSamples_size); + padfSamples = (double *) malloc(padfSamples_size); - /* ==================================================================== */ - /* Loop over scanline chunks to process, establishing where the */ - /* data is going. */ - /* ==================================================================== */ - for (j = 0; j * nOMult < nBlockYSize; j++) +/* ==================================================================== */ +/* Loop over scanline chunks to process, establishing where the */ +/* data is going. */ +/* ==================================================================== */ + for( j = 0; j*nOMult < nBlockYSize; j++ ) { - if (j + nTYOff >= nOBlockYSize) + if( j + nTYOff >= nOBlockYSize ) break; - pabyDst = pabyOTile + ((j + nTYOff) * nOBlockXSize + nTXOff) * - nPixelBytes * nPixelGroupBytes; + pabyDst = pabyOTile + ((j+nTYOff)*nOBlockXSize + nTXOff) + * nPixelBytes * nPixelGroupBytes; - /* -------------------------------------------------------------------- - */ - /* Handler nearest resampling ... we don't even care about the */ - /* data type, we just do a bytewise copy. */ - /* -------------------------------------------------------------------- - */ - if (strncmp(pszResampling, "nearest", 4) == 0 || - strncmp(pszResampling, "NEAR", 4) == 0) +/* -------------------------------------------------------------------- */ +/* Handler nearest resampling ... we don't even care about the */ +/* data type, we just do a bytewise copy. */ +/* -------------------------------------------------------------------- */ + if( strncmp(pszResampling,"nearest",4) == 0 + || strncmp(pszResampling,"NEAR",4) == 0 ) { - pabySrc = pabySrcTile + j * nOMult * nBlockXSize * nPixelGroupBytes; + pabySrc = pabySrcTile + j*nOMult*nBlockXSize * nPixelGroupBytes; - for (i = 0; i * nOMult < nBlockXSize; i++) + for( i = 0; i*nOMult < nBlockXSize; i++ ) { - if (i + nTXOff >= nOBlockXSize) + if( i + nTXOff >= nOBlockXSize ) break; - + /* * For now use simple subsampling, from the top left corner * of the source block of pixels. */ - for (k = 0; k < nPixelBytes; k++) + for( k = 0; k < nPixelBytes; k++ ) pabyDst[k] = pabySrc[k]; pabyDst += nPixelBytes * nPixelGroupBytes; @@ -346,40 +345,40 @@ static void TIFF_DownSample(unsigned char *pabySrcTile, uint32_t nBlockXSize, } } - /* -------------------------------------------------------------------- - */ - /* Handle the case of averaging. For this we also have to */ - /* handle each sample format we are concerned with. */ - /* -------------------------------------------------------------------- - */ - else if (strncmp(pszResampling, "averag", 6) == 0 || - strncmp(pszResampling, "AVERAG", 6) == 0) +/* -------------------------------------------------------------------- */ +/* Handle the case of averaging. For this we also have to */ +/* handle each sample format we are concerned with. */ +/* -------------------------------------------------------------------- */ + else if( strncmp(pszResampling,"averag",6) == 0 + || strncmp(pszResampling,"AVERAG",6) == 0 ) { - pabySrc = pabySrcTile + j * nOMult * nBlockXSize * nPixelGroupBytes; + pabySrc = pabySrcTile + j*nOMult*nBlockXSize * nPixelGroupBytes; - for (i = 0; i * nOMult < nBlockXSize; i++) + for( i = 0; i*nOMult < nBlockXSize; i++ ) { - double dfTotal; - uint32_t nXSize, nYSize, iSample; + double dfTotal; + uint32 nXSize, nYSize, iSample; - if (i + nTXOff >= nOBlockXSize) + if( i + nTXOff >= nOBlockXSize ) break; - nXSize = MIN((uint32_t)nOMult, nBlockXSize - i); - nYSize = MIN((uint32_t)nOMult, nBlockYSize - j); + nXSize = MIN((uint32)nOMult,nBlockXSize-i); + nYSize = MIN((uint32)nOMult,nBlockYSize-j); - TIFF_GetSourceSamples( - padfSamples, pabySrc, nPixelBytes, nSampleFormat, nXSize, - nYSize, nPixelGroupBytes, nPixelGroupBytes * nBlockXSize); + TIFF_GetSourceSamples( padfSamples, pabySrc, + nPixelBytes, nSampleFormat, + nXSize, nYSize, + nPixelGroupBytes, + nPixelGroupBytes * nBlockXSize ); dfTotal = 0; - for (iSample = 0; iSample < nXSize * nYSize; iSample++) + for( iSample = 0; iSample < nXSize*nYSize; iSample++ ) { dfTotal += padfSamples[iSample]; } - TIFF_SetSample(pabyDst, nPixelBytes, nSampleFormat, - dfTotal / (nXSize * nYSize)); + TIFF_SetSample( pabyDst, nPixelBytes, nSampleFormat, + dfTotal / (nXSize*nYSize) ); pabySrc += nOMult * nPixelGroupBytes; pabyDst += nPixelBytes; @@ -387,192 +386,173 @@ static void TIFF_DownSample(unsigned char *pabySrcTile, uint32_t nBlockXSize, } } - free(padfSamples); + free( padfSamples ); } /************************************************************************/ /* TIFF_DownSample_Subsampled() */ /************************************************************************/ -static void TIFF_DownSample_Subsampled( - unsigned char *pabySrcTile, int nSample, uint32_t nBlockXSize, - uint32_t nBlockYSize, unsigned char *pabyOTile, uint32_t nOBlockXSize, - uint32_t nOBlockYSize, uint32_t nTXOff, uint32_t nTYOff, int nOMult, - const char *pszResampling, int nHorSubsampling, int nVerSubsampling) +static +void TIFF_DownSample_Subsampled( unsigned char *pabySrcTile, int nSample, + uint32 nBlockXSize, uint32 nBlockYSize, + unsigned char * pabyOTile, + uint32 nOBlockXSize, uint32 nOBlockYSize, + uint32 nTXOff, uint32 nTYOff, int nOMult, + const char *pszResampling, + int nHorSubsampling, int nVerSubsampling ) { - /* TODO: test with variety of subsampling values, and incovinient tile/strip - * sizes */ + /* TODO: test with variety of subsampling values, and incovinient tile/strip sizes */ int nSampleBlockSize; int nSourceSampleRowSize; int nDestSampleRowSize; - uint32_t nSourceX, nSourceY; - uint32_t nSourceXSec, nSourceYSec; - uint32_t nSourceXSecEnd, nSourceYSecEnd; - uint32_t nDestX, nDestY; + uint32 nSourceX, nSourceY; + uint32 nSourceXSec, nSourceYSec; + uint32 nSourceXSecEnd, nSourceYSecEnd; + uint32 nDestX, nDestY; int nSampleOffsetInSampleBlock; unsigned int nCummulator; unsigned int nCummulatorCount; nSampleBlockSize = nHorSubsampling * nVerSubsampling + 2; - nSourceSampleRowSize = - ((nBlockXSize + nHorSubsampling - 1) / nHorSubsampling) * - nSampleBlockSize; - nDestSampleRowSize = - ((nOBlockXSize + nHorSubsampling - 1) / nHorSubsampling) * - nSampleBlockSize; + nSourceSampleRowSize = + ( ( nBlockXSize + nHorSubsampling - 1 ) / nHorSubsampling ) * nSampleBlockSize; + nDestSampleRowSize = + ( ( nOBlockXSize + nHorSubsampling - 1 ) / nHorSubsampling ) * nSampleBlockSize; - if (strncmp(pszResampling, "nearest", 4) == 0 || - strncmp(pszResampling, "NEAR", 4) == 0) + if( strncmp(pszResampling,"nearest",4) == 0 + || strncmp(pszResampling,"NEAR",4) == 0 ) { - if (nSample == 0) + if( nSample == 0 ) { - for (nSourceY = 0, nDestY = nTYOff; nSourceY < nBlockYSize; - nSourceY += nOMult, nDestY++) + for( nSourceY = 0, nDestY = nTYOff; + nSourceY < nBlockYSize; + nSourceY += nOMult, nDestY ++) { - if (nDestY >= nOBlockYSize) + if( nDestY >= nOBlockYSize ) break; - for (nSourceX = 0, nDestX = nTXOff; nSourceX < nBlockXSize; - nSourceX += nOMult, nDestX++) + for( nSourceX = 0, nDestX = nTXOff; + nSourceX < nBlockXSize; + nSourceX += nOMult, nDestX ++) { - if (nDestX >= nOBlockXSize) + if( nDestX >= nOBlockXSize ) break; - *(pabyOTile + - (nDestY / nVerSubsampling) * nDestSampleRowSize + - (nDestY % nVerSubsampling) * nHorSubsampling + - (nDestX / nHorSubsampling) * nSampleBlockSize + - (nDestX % nHorSubsampling)) = - *(pabySrcTile + - (nSourceY / nVerSubsampling) * nSourceSampleRowSize + - (nSourceY % nVerSubsampling) * nHorSubsampling + - (nSourceX / nHorSubsampling) * nSampleBlockSize + - (nSourceX % nHorSubsampling)); + * ( pabyOTile + ( nDestY / nVerSubsampling ) * nDestSampleRowSize + + ( nDestY % nVerSubsampling ) * nHorSubsampling + + ( nDestX / nHorSubsampling ) * nSampleBlockSize + + ( nDestX % nHorSubsampling ) ) = + * ( pabySrcTile + ( nSourceY / nVerSubsampling ) * nSourceSampleRowSize + + ( nSourceY % nVerSubsampling ) * nHorSubsampling + + ( nSourceX / nHorSubsampling ) * nSampleBlockSize + + ( nSourceX % nHorSubsampling ) ); } } } else { - nSampleOffsetInSampleBlock = - nHorSubsampling * nVerSubsampling + nSample - 1; - for (nSourceY = 0, nDestY = (nTYOff / nVerSubsampling); - nSourceY < (nBlockYSize / nVerSubsampling); - nSourceY += nOMult, nDestY++) + nSampleOffsetInSampleBlock = nHorSubsampling * nVerSubsampling + nSample - 1; + for( nSourceY = 0, nDestY = ( nTYOff / nVerSubsampling ); + nSourceY < ( nBlockYSize / nVerSubsampling ); + nSourceY += nOMult, nDestY ++) { - if (nDestY * nVerSubsampling >= nOBlockYSize) + if( nDestY*nVerSubsampling >= nOBlockYSize ) break; - for (nSourceX = 0, nDestX = (nTXOff / nHorSubsampling); - nSourceX < (nBlockXSize / nHorSubsampling); - nSourceX += nOMult, nDestX++) + for( nSourceX = 0, nDestX = ( nTXOff / nHorSubsampling ); + nSourceX < ( nBlockXSize / nHorSubsampling ); + nSourceX += nOMult, nDestX ++) { - if (nDestX * nHorSubsampling >= nOBlockXSize) + if( nDestX*nHorSubsampling >= nOBlockXSize ) break; - *(pabyOTile + nDestY * nDestSampleRowSize + - nDestX * nSampleBlockSize + nSampleOffsetInSampleBlock) = - *(pabySrcTile + nSourceY * nSourceSampleRowSize + - nSourceX * nSampleBlockSize + - nSampleOffsetInSampleBlock); + * ( pabyOTile + nDestY * nDestSampleRowSize + + nDestX * nSampleBlockSize + + nSampleOffsetInSampleBlock ) = + * ( pabySrcTile + nSourceY * nSourceSampleRowSize + + nSourceX * nSampleBlockSize + + nSampleOffsetInSampleBlock ); } } } } - else if (strncmp(pszResampling, "averag", 6) == 0 || - strncmp(pszResampling, "AVERAG", 6) == 0) + else if( strncmp(pszResampling,"averag",6) == 0 + || strncmp(pszResampling,"AVERAG",6) == 0 ) { - if (nSample == 0) + if( nSample == 0 ) { - for (nSourceY = 0, nDestY = nTYOff; nSourceY < nBlockYSize; - nSourceY += nOMult, nDestY++) + for( nSourceY = 0, nDestY = nTYOff; nSourceY < nBlockYSize; nSourceY += nOMult, nDestY ++) { - if (nDestY >= nOBlockYSize) + if( nDestY >= nOBlockYSize ) break; - for (nSourceX = 0, nDestX = nTXOff; nSourceX < nBlockXSize; - nSourceX += nOMult, nDestX++) + for( nSourceX = 0, nDestX = nTXOff; nSourceX < nBlockXSize; nSourceX += nOMult, nDestX ++) { - if (nDestX >= nOBlockXSize) + if( nDestX >= nOBlockXSize ) break; nSourceXSecEnd = nSourceX + nOMult; - if (nSourceXSecEnd > nBlockXSize) + if( nSourceXSecEnd > nBlockXSize ) nSourceXSecEnd = nBlockXSize; nSourceYSecEnd = nSourceY + nOMult; - if (nSourceYSecEnd > nBlockYSize) + if( nSourceYSecEnd > nBlockYSize ) nSourceYSecEnd = nBlockYSize; nCummulator = 0; - for (nSourceYSec = nSourceY; nSourceYSec < nSourceYSecEnd; - nSourceYSec++) + for( nSourceYSec = nSourceY; nSourceYSec < nSourceYSecEnd; nSourceYSec ++) { - for (nSourceXSec = nSourceX; - nSourceXSec < nSourceXSecEnd; nSourceXSec++) + for( nSourceXSec = nSourceX; nSourceXSec < nSourceXSecEnd; nSourceXSec ++) { - nCummulator += *(pabySrcTile + - (nSourceYSec / nVerSubsampling) * - nSourceSampleRowSize + - (nSourceYSec % nVerSubsampling) * - nHorSubsampling + - (nSourceXSec / nHorSubsampling) * - nSampleBlockSize + - (nSourceXSec % nHorSubsampling)); + nCummulator += * ( pabySrcTile + ( nSourceYSec / nVerSubsampling ) * nSourceSampleRowSize + + ( nSourceYSec % nVerSubsampling ) * nHorSubsampling + + ( nSourceXSec / nHorSubsampling ) * nSampleBlockSize + + ( nSourceXSec % nHorSubsampling ) ); } } - nCummulatorCount = (nSourceXSecEnd - nSourceX) * - (nSourceYSecEnd - nSourceY); - *(pabyOTile + - (nDestY / nVerSubsampling) * nDestSampleRowSize + - (nDestY % nVerSubsampling) * nHorSubsampling + - (nDestX / nHorSubsampling) * nSampleBlockSize + - (nDestX % nHorSubsampling)) = - ((nCummulator + (nCummulatorCount >> 1)) / - nCummulatorCount); + nCummulatorCount = ( nSourceXSecEnd - nSourceX ) * ( nSourceYSecEnd - nSourceY ); + * ( pabyOTile + ( nDestY / nVerSubsampling ) * nDestSampleRowSize + + ( nDestY % nVerSubsampling ) * nHorSubsampling + + ( nDestX / nHorSubsampling ) * nSampleBlockSize + + ( nDestX % nHorSubsampling ) ) = + ( ( nCummulator + ( nCummulatorCount >> 1 ) ) / nCummulatorCount ); } } } else { - nSampleOffsetInSampleBlock = - nHorSubsampling * nVerSubsampling + nSample - 1; - for (nSourceY = 0, nDestY = (nTYOff / nVerSubsampling); - nSourceY < (nBlockYSize / nVerSubsampling); - nSourceY += nOMult, nDestY++) + nSampleOffsetInSampleBlock = nHorSubsampling * nVerSubsampling + nSample - 1; + for( nSourceY = 0, nDestY = ( nTYOff / nVerSubsampling ); nSourceY < ( nBlockYSize / nVerSubsampling ); + nSourceY += nOMult, nDestY ++) { - if (nDestY * nVerSubsampling >= nOBlockYSize) + if( nDestY*nVerSubsampling >= nOBlockYSize ) break; - for (nSourceX = 0, nDestX = (nTXOff / nHorSubsampling); - nSourceX < (nBlockXSize / nHorSubsampling); - nSourceX += nOMult, nDestX++) + for( nSourceX = 0, nDestX = ( nTXOff / nHorSubsampling ); nSourceX < ( nBlockXSize / nHorSubsampling ); + nSourceX += nOMult, nDestX ++) { - if (nDestX * nHorSubsampling >= nOBlockXSize) + if( nDestX*nHorSubsampling >= nOBlockXSize ) break; nSourceXSecEnd = nSourceX + nOMult; - if (nSourceXSecEnd > (nBlockXSize / nHorSubsampling)) - nSourceXSecEnd = (nBlockXSize / nHorSubsampling); + if( nSourceXSecEnd > ( nBlockXSize / nHorSubsampling ) ) + nSourceXSecEnd = ( nBlockXSize / nHorSubsampling ); nSourceYSecEnd = nSourceY + nOMult; - if (nSourceYSecEnd > (nBlockYSize / nVerSubsampling)) - nSourceYSecEnd = (nBlockYSize / nVerSubsampling); + if( nSourceYSecEnd > ( nBlockYSize / nVerSubsampling ) ) + nSourceYSecEnd = ( nBlockYSize / nVerSubsampling ); nCummulator = 0; - for (nSourceYSec = nSourceY; nSourceYSec < nSourceYSecEnd; - nSourceYSec++) + for( nSourceYSec = nSourceY; nSourceYSec < nSourceYSecEnd; nSourceYSec ++) { - for (nSourceXSec = nSourceX; - nSourceXSec < nSourceXSecEnd; nSourceXSec++) + for( nSourceXSec = nSourceX; nSourceXSec < nSourceXSecEnd; nSourceXSec ++) { - nCummulator += - *(pabySrcTile + - nSourceYSec * nSourceSampleRowSize + - nSourceXSec * nSampleBlockSize + - nSampleOffsetInSampleBlock); + nCummulator += * ( pabySrcTile + nSourceYSec * nSourceSampleRowSize + + nSourceXSec * nSampleBlockSize + + nSampleOffsetInSampleBlock ); } } - nCummulatorCount = (nSourceXSecEnd - nSourceX) * - (nSourceYSecEnd - nSourceY); - *(pabyOTile + nDestY * nDestSampleRowSize + - nDestX * nSampleBlockSize + nSampleOffsetInSampleBlock) = - ((nCummulator + (nCummulatorCount >> 1)) / - nCummulatorCount); + nCummulatorCount = ( nSourceXSecEnd - nSourceX ) * ( nSourceYSecEnd - nSourceY ); + * ( pabyOTile + nDestY * nDestSampleRowSize + + nDestX * nSampleBlockSize + + nSampleOffsetInSampleBlock ) = + ( ( nCummulator + ( nCummulatorCount >> 1 ) ) / nCummulatorCount ); } } } @@ -586,124 +566,135 @@ static void TIFF_DownSample_Subsampled( /* of the overviews. */ /************************************************************************/ -void TIFF_ProcessFullResBlock(TIFF *hTIFF, int nPlanarConfig, int bSubsampled, - int nHorSubsampling, int nVerSubsampling, - int nOverviews, int *panOvList, int nBitsPerPixel, - int nSamples, TIFFOvrCache **papoRawBIs, - uint32_t nSXOff, uint32_t nSYOff, - unsigned char *pabySrcTile, uint32_t nBlockXSize, - uint32_t nBlockYSize, int nSampleFormat, - const char *pszResampling) - +void TIFF_ProcessFullResBlock( TIFF *hTIFF, int nPlanarConfig, + int bSubsampled, + int nHorSubsampling, int nVerSubsampling, + int nOverviews, int * panOvList, + int nBitsPerPixel, + int nSamples, TIFFOvrCache ** papoRawBIs, + uint32 nSXOff, uint32 nSYOff, + unsigned char *pabySrcTile, + uint32 nBlockXSize, uint32 nBlockYSize, + int nSampleFormat, const char * pszResampling ) + { - int iOverview, iSample; + int iOverview, iSample; - for (iSample = 0; iSample < nSamples; iSample++) + for( iSample = 0; iSample < nSamples; iSample++ ) { /* * We have to read a tile/strip for each sample for * PLANARCONFIG_SEPARATE. Otherwise, we just read all the samples * at once when handling the first sample. */ - if (nPlanarConfig == PLANARCONFIG_SEPARATE || iSample == 0) + if( nPlanarConfig == PLANARCONFIG_SEPARATE || iSample == 0 ) { - if (TIFFIsTiled(hTIFF)) + if( TIFFIsTiled(hTIFF) ) { - TIFFReadEncodedTile(hTIFF, - TIFFComputeTile(hTIFF, nSXOff, nSYOff, 0, - (tsample_t)iSample), - pabySrcTile, TIFFTileSize(hTIFF)); + TIFFReadEncodedTile( hTIFF, + TIFFComputeTile(hTIFF, nSXOff, nSYOff, + 0, (tsample_t)iSample ), + pabySrcTile, + TIFFTileSize(hTIFF)); } else { - TIFFReadEncodedStrip( - hTIFF, TIFFComputeStrip(hTIFF, nSYOff, (tsample_t)iSample), - pabySrcTile, TIFFStripSize(hTIFF)); + TIFFReadEncodedStrip( hTIFF, + TIFFComputeStrip(hTIFF, nSYOff, + (tsample_t) iSample), + pabySrcTile, + TIFFStripSize(hTIFF) ); } } - /* + /* * Loop over destination overview layers */ - for (iOverview = 0; iOverview < nOverviews; iOverview++) + for( iOverview = 0; iOverview < nOverviews; iOverview++ ) { TIFFOvrCache *poRBI = papoRawBIs[iOverview]; unsigned char *pabyOTile; - uint32_t nTXOff, nTYOff, nOXOff, nOYOff, nOMult; - uint32_t nOBlockXSize = poRBI->nBlockXSize; - uint32_t nOBlockYSize = poRBI->nBlockYSize; - int nSkewBits, nSampleByteOffset; + uint32 nTXOff, nTYOff, nOXOff, nOYOff, nOMult; + uint32 nOBlockXSize = poRBI->nBlockXSize; + uint32 nOBlockYSize = poRBI->nBlockYSize; + int nSkewBits, nSampleByteOffset; /* * Fetch the destination overview tile */ nOMult = panOvList[iOverview]; - nOXOff = (nSXOff / nOMult) / nOBlockXSize; - nOYOff = (nSYOff / nOMult) / nOBlockYSize; + nOXOff = (nSXOff/nOMult) / nOBlockXSize; + nOYOff = (nSYOff/nOMult) / nOBlockYSize; - if (bSubsampled) + if( bSubsampled ) { - pabyOTile = TIFFGetOvrBlock_Subsampled(poRBI, nOXOff, nOYOff); + pabyOTile = TIFFGetOvrBlock_Subsampled( poRBI, nOXOff, nOYOff ); /* * Establish the offset into this tile at which we should * start placing data. */ - nTXOff = (nSXOff - nOXOff * nOMult * nOBlockXSize) / nOMult; - nTYOff = (nSYOff - nOYOff * nOMult * nOBlockYSize) / nOMult; + nTXOff = (nSXOff - nOXOff*nOMult*nOBlockXSize) / nOMult; + nTYOff = (nSYOff - nOYOff*nOMult*nOBlockYSize) / nOMult; + #ifdef DBMALLOC - malloc_chain_check(1); + malloc_chain_check( 1 ); #endif - TIFF_DownSample_Subsampled( - pabySrcTile, iSample, nBlockXSize, nBlockYSize, pabyOTile, - poRBI->nBlockXSize, poRBI->nBlockYSize, nTXOff, nTYOff, - nOMult, pszResampling, nHorSubsampling, nVerSubsampling); + TIFF_DownSample_Subsampled( pabySrcTile, iSample, + nBlockXSize, nBlockYSize, + pabyOTile, + poRBI->nBlockXSize, poRBI->nBlockYSize, + nTXOff, nTYOff, + nOMult, pszResampling, + nHorSubsampling, nVerSubsampling ); #ifdef DBMALLOC - malloc_chain_check(1); + malloc_chain_check( 1 ); #endif + } else { - pabyOTile = TIFFGetOvrBlock(poRBI, nOXOff, nOYOff, iSample); + pabyOTile = TIFFGetOvrBlock( poRBI, nOXOff, nOYOff, iSample ); /* * Establish the offset into this tile at which we should * start placing data. */ - nTXOff = (nSXOff - nOXOff * nOMult * nOBlockXSize) / nOMult; - nTYOff = (nSYOff - nOYOff * nOMult * nOBlockYSize) / nOMult; + nTXOff = (nSXOff - nOXOff*nOMult*nOBlockXSize) / nOMult; + nTYOff = (nSYOff - nOYOff*nOMult*nOBlockYSize) / nOMult; /* * Figure out the skew (extra space between ``our samples'') and * the byte offset to the first sample. */ - assert((nBitsPerPixel % 8) == 0); - if (nPlanarConfig == PLANARCONFIG_SEPARATE) + assert( (nBitsPerPixel % 8) == 0 ); + if( nPlanarConfig == PLANARCONFIG_SEPARATE ) { nSkewBits = 0; nSampleByteOffset = 0; } else { - nSkewBits = nBitsPerPixel * (nSamples - 1); - nSampleByteOffset = (nBitsPerPixel / 8) * iSample; + nSkewBits = nBitsPerPixel * (nSamples-1); + nSampleByteOffset = (nBitsPerPixel/8) * iSample; } /* * Perform the downsampling. */ #ifdef DBMALLOC - malloc_chain_check(1); + malloc_chain_check( 1 ); #endif - TIFF_DownSample(pabySrcTile + nSampleByteOffset, nBlockXSize, - nBlockYSize, nSkewBits, nBitsPerPixel, - pabyOTile, poRBI->nBlockXSize, - poRBI->nBlockYSize, nTXOff, nTYOff, nOMult, - nSampleFormat, pszResampling); + TIFF_DownSample( pabySrcTile + nSampleByteOffset, + nBlockXSize, nBlockYSize, + nSkewBits, nBitsPerPixel, pabyOTile, + poRBI->nBlockXSize, poRBI->nBlockYSize, + nTXOff, nTYOff, + nOMult, nSampleFormat, pszResampling ); #ifdef DBMALLOC - malloc_chain_check(1); + malloc_chain_check( 1 ); #endif } } @@ -720,76 +711,69 @@ void TIFF_ProcessFullResBlock(TIFF *hTIFF, int nPlanarConfig, int bSubsampled, /* overviews. */ /************************************************************************/ -void TIFFBuildOverviews(TIFF *hTIFF, int nOverviews, int *panOvList, - int bUseSubIFDs, const char *pszResampleMethod, - int (*pfnProgress)(double, void *), void *pProgressData) +void TIFFBuildOverviews( TIFF *hTIFF, int nOverviews, int * panOvList, + int bUseSubIFDs, const char *pszResampleMethod, + int (*pfnProgress)( double, void * ), + void * pProgressData ) { - TIFFOvrCache **papoRawBIs; - uint32_t nXSize, nYSize, nBlockXSize, nBlockYSize; - uint16_t nBitsPerPixel, nPhotometric, nCompressFlag, nSamples, + TIFFOvrCache **papoRawBIs; + uint32 nXSize, nYSize, nBlockXSize, nBlockYSize; + uint16 nBitsPerPixel, nPhotometric, nCompressFlag, nSamples, nPlanarConfig, nSampleFormat; - int bSubsampled; - uint16_t nHorSubsampling, nVerSubsampling; - int bTiled, nSXOff, nSYOff, i; - unsigned char *pabySrcTile; - uint16_t *panRedMap, *panGreenMap, *panBlueMap; - TIFFErrorHandler pfnWarning; + int bSubsampled; + uint16 nHorSubsampling, nVerSubsampling; + int bTiled, nSXOff, nSYOff, i; + unsigned char *pabySrcTile; + uint16 *panRedMap, *panGreenMap, *panBlueMap; + TIFFErrorHandler pfnWarning; - (void)pfnProgress; - (void)pProgressData; + (void) pfnProgress; + (void) pProgressData; - /* -------------------------------------------------------------------- */ - /* Get the base raster size. */ - /* -------------------------------------------------------------------- */ - TIFFGetField(hTIFF, TIFFTAG_IMAGEWIDTH, &nXSize); - TIFFGetField(hTIFF, TIFFTAG_IMAGELENGTH, &nYSize); +/* -------------------------------------------------------------------- */ +/* Get the base raster size. */ +/* -------------------------------------------------------------------- */ + TIFFGetField( hTIFF, TIFFTAG_IMAGEWIDTH, &nXSize ); + TIFFGetField( hTIFF, TIFFTAG_IMAGELENGTH, &nYSize ); - TIFFGetField(hTIFF, TIFFTAG_BITSPERSAMPLE, &nBitsPerPixel); - /* TODO: nBitsPerPixel seems misnomer and may need renaming to - * nBitsPerSample */ - TIFFGetField(hTIFF, TIFFTAG_SAMPLESPERPIXEL, &nSamples); - TIFFGetFieldDefaulted(hTIFF, TIFFTAG_PLANARCONFIG, &nPlanarConfig); + TIFFGetField( hTIFF, TIFFTAG_BITSPERSAMPLE, &nBitsPerPixel ); + /* TODO: nBitsPerPixel seems misnomer and may need renaming to nBitsPerSample */ + TIFFGetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, &nSamples ); + TIFFGetFieldDefaulted( hTIFF, TIFFTAG_PLANARCONFIG, &nPlanarConfig ); - TIFFGetFieldDefaulted(hTIFF, TIFFTAG_PHOTOMETRIC, &nPhotometric); - TIFFGetFieldDefaulted(hTIFF, TIFFTAG_COMPRESSION, &nCompressFlag); - TIFFGetFieldDefaulted(hTIFF, TIFFTAG_SAMPLEFORMAT, &nSampleFormat); + TIFFGetFieldDefaulted( hTIFF, TIFFTAG_PHOTOMETRIC, &nPhotometric ); + TIFFGetFieldDefaulted( hTIFF, TIFFTAG_COMPRESSION, &nCompressFlag ); + TIFFGetFieldDefaulted( hTIFF, TIFFTAG_SAMPLEFORMAT, &nSampleFormat ); - if (nPhotometric == PHOTOMETRIC_YCBCR || nPhotometric == PHOTOMETRIC_ITULAB) + if( nPhotometric == PHOTOMETRIC_YCBCR || nPhotometric == PHOTOMETRIC_ITULAB ) { - if (nBitsPerPixel != 8 || nSamples != 3 || - nPlanarConfig != PLANARCONFIG_CONTIG || + if( nBitsPerPixel != 8 || nSamples != 3 || nPlanarConfig != PLANARCONFIG_CONTIG || nSampleFormat != SAMPLEFORMAT_UINT) { - /* TODO: use of TIFFError is inconsistent with use of fprintf in - * addtiffo.c, sort out */ - TIFFErrorExt( - TIFFClientdata(hTIFF), "TIFFBuildOverviews", - "File `%s' has an unsupported subsampling configuration.\n", - TIFFFileName(hTIFF)); - /* If you need support for this particular flavor, please contact - * either Frank Warmerdam warmerdam@pobox.com Joris Van Damme - * info@awaresystems.be + /* TODO: use of TIFFError is inconsistent with use of fprintf in addtiffo.c, sort out */ + TIFFErrorExt( TIFFClientdata(hTIFF), "TIFFBuildOverviews", + "File `%s' has an unsupported subsampling configuration.\n", + TIFFFileName(hTIFF) ); + /* If you need support for this particular flavor, please contact either + * Frank Warmerdam warmerdam@pobox.com + * Joris Van Damme info@awaresystems.be */ return; } bSubsampled = 1; - TIFFGetField(hTIFF, TIFFTAG_YCBCRSUBSAMPLING, &nHorSubsampling, - &nVerSubsampling); - /* TODO: find out if maybe TIFFGetFieldDefaulted is better choice for - * YCbCrSubsampling tag */ + TIFFGetField( hTIFF, TIFFTAG_YCBCRSUBSAMPLING, &nHorSubsampling, &nVerSubsampling ); + /* TODO: find out if maybe TIFFGetFieldDefaulted is better choice for YCbCrSubsampling tag */ } else { - if (nBitsPerPixel < 8) + if( nBitsPerPixel < 8 ) { - /* TODO: use of TIFFError is inconsistent with use of fprintf in - * addtiffo.c, sort out */ - TIFFErrorExt( - TIFFClientdata(hTIFF), "TIFFBuildOverviews", - "File `%s' has samples of %d bits per sample. Sample\n" - "sizes of less than 8 bits per sample are not supported.\n", - TIFFFileName(hTIFF), nBitsPerPixel); + /* TODO: use of TIFFError is inconsistent with use of fprintf in addtiffo.c, sort out */ + TIFFErrorExt( TIFFClientdata(hTIFF), "TIFFBuildOverviews", + "File `%s' has samples of %d bits per sample. Sample\n" + "sizes of less than 8 bits per sample are not supported.\n", + TIFFFileName(hTIFF), nBitsPerPixel ); return; } bSubsampled = 0; @@ -797,43 +781,43 @@ void TIFFBuildOverviews(TIFF *hTIFF, int nOverviews, int *panOvList, nVerSubsampling = 1; } - /* -------------------------------------------------------------------- */ - /* Turn off warnings to avoid a lot of repeated warnings while */ - /* rereading directories. */ - /* -------------------------------------------------------------------- */ - pfnWarning = TIFFSetWarningHandler(NULL); +/* -------------------------------------------------------------------- */ +/* Turn off warnings to avoid alot of repeated warnings while */ +/* rereading directories. */ +/* -------------------------------------------------------------------- */ + pfnWarning = TIFFSetWarningHandler( NULL ); - /* -------------------------------------------------------------------- */ - /* Get the base raster block size. */ - /* -------------------------------------------------------------------- */ - if (TIFFGetField(hTIFF, TIFFTAG_ROWSPERSTRIP, &(nBlockYSize))) +/* -------------------------------------------------------------------- */ +/* Get the base raster block size. */ +/* -------------------------------------------------------------------- */ + if( TIFFGetField( hTIFF, TIFFTAG_ROWSPERSTRIP, &(nBlockYSize) ) ) { nBlockXSize = nXSize; bTiled = FALSE; } else { - TIFFGetField(hTIFF, TIFFTAG_TILEWIDTH, &nBlockXSize); - TIFFGetField(hTIFF, TIFFTAG_TILELENGTH, &nBlockYSize); + TIFFGetField( hTIFF, TIFFTAG_TILEWIDTH, &nBlockXSize ); + TIFFGetField( hTIFF, TIFFTAG_TILELENGTH, &nBlockYSize ); bTiled = TRUE; } - /* -------------------------------------------------------------------- */ - /* Capture the palette if there is one. */ - /* -------------------------------------------------------------------- */ - if (TIFFGetField(hTIFF, TIFFTAG_COLORMAP, &panRedMap, &panGreenMap, - &panBlueMap)) +/* -------------------------------------------------------------------- */ +/* Capture the pallette if there is one. */ +/* -------------------------------------------------------------------- */ + if( TIFFGetField( hTIFF, TIFFTAG_COLORMAP, + &panRedMap, &panGreenMap, &panBlueMap ) ) { - uint16_t *panRed2, *panGreen2, *panBlue2; - int nColorCount = 1 << nBitsPerPixel; + uint16 *panRed2, *panGreen2, *panBlue2; + int nColorCount = 1 << nBitsPerPixel; - panRed2 = (uint16_t *)_TIFFmalloc(2 * nColorCount); - panGreen2 = (uint16_t *)_TIFFmalloc(2 * nColorCount); - panBlue2 = (uint16_t *)_TIFFmalloc(2 * nColorCount); + panRed2 = (uint16 *) _TIFFmalloc(2*nColorCount); + panGreen2 = (uint16 *) _TIFFmalloc(2*nColorCount); + panBlue2 = (uint16 *) _TIFFmalloc(2*nColorCount); - memcpy(panRed2, panRedMap, 2 * nColorCount); - memcpy(panGreen2, panGreenMap, 2 * nColorCount); - memcpy(panBlue2, panBlueMap, 2 * nColorCount); + memcpy( panRed2, panRedMap, 2 * nColorCount ); + memcpy( panGreen2, panGreenMap, 2 * nColorCount ); + memcpy( panBlue2, panBlueMap, 2 * nColorCount ); panRedMap = panRed2; panGreenMap = panGreen2; @@ -844,87 +828,101 @@ void TIFFBuildOverviews(TIFF *hTIFF, int nOverviews, int *panOvList, panRedMap = panGreenMap = panBlueMap = NULL; } - /* -------------------------------------------------------------------- */ - /* Initialize overviews. */ - /* -------------------------------------------------------------------- */ - papoRawBIs = (TIFFOvrCache **)_TIFFmalloc(nOverviews * sizeof(void *)); +/* -------------------------------------------------------------------- */ +/* Initialize overviews. */ +/* -------------------------------------------------------------------- */ + papoRawBIs = (TIFFOvrCache **) _TIFFmalloc(nOverviews*sizeof(void*)); - for (i = 0; i < nOverviews; i++) + for( i = 0; i < nOverviews; i++ ) { - uint32_t nOXSize, nOYSize, nOBlockXSize, nOBlockYSize; - toff_t nDirOffset; + uint32 nOXSize, nOYSize, nOBlockXSize, nOBlockYSize; + toff_t nDirOffset; nOXSize = (nXSize + panOvList[i] - 1) / panOvList[i]; nOYSize = (nYSize + panOvList[i] - 1) / panOvList[i]; - nOBlockXSize = MIN(nBlockXSize, nOXSize); - nOBlockYSize = MIN(nBlockYSize, nOYSize); + nOBlockXSize = MIN(nBlockXSize,nOXSize); + nOBlockYSize = MIN(nBlockYSize,nOYSize); - if (bTiled) + if( bTiled ) { - if ((nOBlockXSize % 16) != 0) + if( (nOBlockXSize % 16) != 0 ) nOBlockXSize = nOBlockXSize + 16 - (nOBlockXSize % 16); - if ((nOBlockYSize % 16) != 0) + if( (nOBlockYSize % 16) != 0 ) nOBlockYSize = nOBlockYSize + 16 - (nOBlockYSize % 16); } - nDirOffset = TIFF_WriteOverview( - hTIFF, nOXSize, nOYSize, nBitsPerPixel, nPlanarConfig, nSamples, - nOBlockXSize, nOBlockYSize, bTiled, nCompressFlag, nPhotometric, - nSampleFormat, panRedMap, panGreenMap, panBlueMap, bUseSubIFDs, - nHorSubsampling, nVerSubsampling); - - papoRawBIs[i] = TIFFCreateOvrCache(hTIFF, nDirOffset); + nDirOffset = TIFF_WriteOverview( hTIFF, nOXSize, nOYSize, + nBitsPerPixel, nPlanarConfig, + nSamples, nOBlockXSize, nOBlockYSize, + bTiled, nCompressFlag, nPhotometric, + nSampleFormat, + panRedMap, panGreenMap, panBlueMap, + bUseSubIFDs, + nHorSubsampling, nVerSubsampling ); + + papoRawBIs[i] = TIFFCreateOvrCache( hTIFF, nDirOffset ); } - if (panRedMap != NULL) + if( panRedMap != NULL ) { - _TIFFfree(panRedMap); - _TIFFfree(panGreenMap); - _TIFFfree(panBlueMap); + _TIFFfree( panRedMap ); + _TIFFfree( panGreenMap ); + _TIFFfree( panBlueMap ); } - - /* -------------------------------------------------------------------- */ - /* Allocate a buffer to hold a source block. */ - /* -------------------------------------------------------------------- */ - if (bTiled) - pabySrcTile = (unsigned char *)_TIFFmalloc(TIFFTileSize(hTIFF)); + +/* -------------------------------------------------------------------- */ +/* Allocate a buffer to hold a source block. */ +/* -------------------------------------------------------------------- */ + if( bTiled ) + pabySrcTile = (unsigned char *) _TIFFmalloc(TIFFTileSize(hTIFF)); else - pabySrcTile = (unsigned char *)_TIFFmalloc(TIFFStripSize(hTIFF)); - - /* -------------------------------------------------------------------- */ - /* Loop over the source raster, applying data to the */ - /* destination raster. */ - /* -------------------------------------------------------------------- */ - for (nSYOff = 0; nSYOff < (int)nYSize; nSYOff += nBlockYSize) + pabySrcTile = (unsigned char *) _TIFFmalloc(TIFFStripSize(hTIFF)); + +/* -------------------------------------------------------------------- */ +/* Loop over the source raster, applying data to the */ +/* destination raster. */ +/* -------------------------------------------------------------------- */ + for( nSYOff = 0; nSYOff < (int) nYSize; nSYOff += nBlockYSize ) { - for (nSXOff = 0; nSXOff < (int)nXSize; nSXOff += nBlockXSize) + for( nSXOff = 0; nSXOff < (int) nXSize; nSXOff += nBlockXSize ) { /* * Read and resample into the various overview images. */ - - TIFF_ProcessFullResBlock( - hTIFF, nPlanarConfig, bSubsampled, nHorSubsampling, - nVerSubsampling, nOverviews, panOvList, nBitsPerPixel, nSamples, - papoRawBIs, nSXOff, nSYOff, pabySrcTile, nBlockXSize, - nBlockYSize, nSampleFormat, pszResampleMethod); + + TIFF_ProcessFullResBlock( hTIFF, nPlanarConfig, + bSubsampled,nHorSubsampling,nVerSubsampling, + nOverviews, panOvList, + nBitsPerPixel, nSamples, papoRawBIs, + nSXOff, nSYOff, pabySrcTile, + nBlockXSize, nBlockYSize, + nSampleFormat, pszResampleMethod ); } } - _TIFFfree(pabySrcTile); + _TIFFfree( pabySrcTile ); - /* -------------------------------------------------------------------- */ - /* Cleanup the rawblockedimage files. */ - /* -------------------------------------------------------------------- */ - for (i = 0; i < nOverviews; i++) +/* -------------------------------------------------------------------- */ +/* Cleanup the rawblockedimage files. */ +/* -------------------------------------------------------------------- */ + for( i = 0; i < nOverviews; i++ ) { - TIFFDestroyOvrCache(papoRawBIs[i]); + TIFFDestroyOvrCache( papoRawBIs[i] ); } - if (papoRawBIs != NULL) - _TIFFfree(papoRawBIs); + if( papoRawBIs != NULL ) + _TIFFfree( papoRawBIs ); - TIFFSetWarningHandler(pfnWarning); + TIFFSetWarningHandler( pfnWarning ); } + + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_ovrcache.c b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_ovrcache.c index 9cbf09d1b..ac500ab4e 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_ovrcache.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_ovrcache.c @@ -1,7 +1,7 @@ /****************************************************************************** * Project: TIFF Overview Builder * Purpose: Library functions to maintain two rows of tiles or two strips - * of data for output overviews as an output cache. + * of data for output overviews as an output cache. * Author: Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** @@ -27,8 +27,8 @@ ****************************************************************************** */ -#include "tif_ovrcache.h" #include "tiffiop.h" +#include "tif_ovrcache.h" #include /************************************************************************/ @@ -38,95 +38,89 @@ /* existing TIFF directory. */ /************************************************************************/ -TIFFOvrCache *TIFFCreateOvrCache(TIFF *hTIFF, toff_t nDirOffset) +TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, toff_t nDirOffset ) { - TIFFOvrCache *psCache; - toff_t nBaseDirOffset; - int nRet; + TIFFOvrCache *psCache; + toff_t nBaseDirOffset; - psCache = (TIFFOvrCache *)_TIFFmalloc(sizeof(TIFFOvrCache)); + psCache = (TIFFOvrCache *) _TIFFmalloc(sizeof(TIFFOvrCache)); psCache->nDirOffset = nDirOffset; psCache->hTIFF = hTIFF; + +/* -------------------------------------------------------------------- */ +/* Get definition of this raster from the TIFF file itself. */ +/* -------------------------------------------------------------------- */ + nBaseDirOffset = TIFFCurrentDirOffset( psCache->hTIFF ); + TIFFSetSubDirectory( hTIFF, nDirOffset ); + + TIFFGetField( hTIFF, TIFFTAG_IMAGEWIDTH, &(psCache->nXSize) ); + TIFFGetField( hTIFF, TIFFTAG_IMAGELENGTH, &(psCache->nYSize) ); - /* -------------------------------------------------------------------- */ - /* Get definition of this raster from the TIFF file itself. */ - /* -------------------------------------------------------------------- */ - nBaseDirOffset = TIFFCurrentDirOffset(psCache->hTIFF); - nRet = TIFFSetSubDirectory(hTIFF, nDirOffset); - (void)nRet; - assert(nRet == 1); + TIFFGetField( hTIFF, TIFFTAG_BITSPERSAMPLE, &(psCache->nBitsPerPixel) ); + TIFFGetField( hTIFF, TIFFTAG_SAMPLESPERPIXEL, &(psCache->nSamples) ); + TIFFGetField( hTIFF, TIFFTAG_PLANARCONFIG, &(psCache->nPlanarConfig) ); - TIFFGetField(hTIFF, TIFFTAG_IMAGEWIDTH, &(psCache->nXSize)); - TIFFGetField(hTIFF, TIFFTAG_IMAGELENGTH, &(psCache->nYSize)); - - TIFFGetField(hTIFF, TIFFTAG_BITSPERSAMPLE, &(psCache->nBitsPerPixel)); - TIFFGetField(hTIFF, TIFFTAG_SAMPLESPERPIXEL, &(psCache->nSamples)); - TIFFGetField(hTIFF, TIFFTAG_PLANARCONFIG, &(psCache->nPlanarConfig)); - - if (!TIFFIsTiled(hTIFF)) + if( !TIFFIsTiled( hTIFF ) ) { - TIFFGetField(hTIFF, TIFFTAG_ROWSPERSTRIP, &(psCache->nBlockYSize)); + TIFFGetField( hTIFF, TIFFTAG_ROWSPERSTRIP, &(psCache->nBlockYSize) ); psCache->nBlockXSize = psCache->nXSize; psCache->nBytesPerBlock = TIFFStripSize(hTIFF); psCache->bTiled = FALSE; } else { - TIFFGetField(hTIFF, TIFFTAG_TILEWIDTH, &(psCache->nBlockXSize)); - TIFFGetField(hTIFF, TIFFTAG_TILELENGTH, &(psCache->nBlockYSize)); + TIFFGetField( hTIFF, TIFFTAG_TILEWIDTH, &(psCache->nBlockXSize) ); + TIFFGetField( hTIFF, TIFFTAG_TILELENGTH, &(psCache->nBlockYSize) ); psCache->nBytesPerBlock = TIFFTileSize(hTIFF); psCache->bTiled = TRUE; } - /* -------------------------------------------------------------------- */ - /* Compute some values from this. */ - /* -------------------------------------------------------------------- */ +/* -------------------------------------------------------------------- */ +/* Compute some values from this. */ +/* -------------------------------------------------------------------- */ - psCache->nBlocksPerRow = - (psCache->nXSize + psCache->nBlockXSize - 1) / psCache->nBlockXSize; - psCache->nBlocksPerColumn = - (psCache->nYSize + psCache->nBlockYSize - 1) / psCache->nBlockYSize; + psCache->nBlocksPerRow = (psCache->nXSize + psCache->nBlockXSize - 1) + / psCache->nBlockXSize; + psCache->nBlocksPerColumn = (psCache->nYSize + psCache->nBlockYSize - 1) + / psCache->nBlockYSize; if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) - psCache->nBytesPerRow = psCache->nBytesPerBlock * - psCache->nBlocksPerRow * psCache->nSamples; + psCache->nBytesPerRow = psCache->nBytesPerBlock + * psCache->nBlocksPerRow * psCache->nSamples; else psCache->nBytesPerRow = psCache->nBytesPerBlock * psCache->nBlocksPerRow; - /* -------------------------------------------------------------------- */ - /* Allocate and initialize the data buffers. */ - /* -------------------------------------------------------------------- */ + +/* -------------------------------------------------------------------- */ +/* Allocate and initialize the data buffers. */ +/* -------------------------------------------------------------------- */ psCache->pabyRow1Blocks = - (unsigned char *)_TIFFmalloc(psCache->nBytesPerRow); + (unsigned char *) _TIFFmalloc(psCache->nBytesPerRow); psCache->pabyRow2Blocks = - (unsigned char *)_TIFFmalloc(psCache->nBytesPerRow); + (unsigned char *) _TIFFmalloc(psCache->nBytesPerRow); - if (psCache->pabyRow1Blocks == NULL || psCache->pabyRow2Blocks == NULL) + if ( psCache->pabyRow1Blocks == NULL + || psCache->pabyRow2Blocks == NULL ) { - TIFFErrorExt(hTIFF->tif_clientdata, hTIFF->tif_name, - "Can't allocate memory for overview cache."); - /* TODO: use of TIFFError is inconsistent with use of fprintf in - * addtiffo.c, sort out */ - if (psCache->pabyRow1Blocks) - _TIFFfree(psCache->pabyRow1Blocks); - if (psCache->pabyRow2Blocks) - _TIFFfree(psCache->pabyRow2Blocks); - _TIFFfree(psCache); + TIFFErrorExt( hTIFF->tif_clientdata, hTIFF->tif_name, + "Can't allocate memory for overview cache." ); + /* TODO: use of TIFFError is inconsistent with use of fprintf in addtiffo.c, sort out */ + if (psCache->pabyRow1Blocks) _TIFFfree(psCache->pabyRow1Blocks); + if (psCache->pabyRow2Blocks) _TIFFfree(psCache->pabyRow2Blocks); + _TIFFfree( psCache ); return NULL; } - _TIFFmemset(psCache->pabyRow1Blocks, 0, psCache->nBytesPerRow); - _TIFFmemset(psCache->pabyRow2Blocks, 0, psCache->nBytesPerRow); + _TIFFmemset( psCache->pabyRow1Blocks, 0, psCache->nBytesPerRow ); + _TIFFmemset( psCache->pabyRow2Blocks, 0, psCache->nBytesPerRow ); psCache->nBlockOffset = 0; - nRet = TIFFSetSubDirectory(psCache->hTIFF, nBaseDirOffset); - (void)nRet; - assert(nRet == 1); - + TIFFSetSubDirectory( psCache->hTIFF, nBaseDirOffset ); + return psCache; } @@ -138,130 +132,130 @@ TIFFOvrCache *TIFFCreateOvrCache(TIFF *hTIFF, toff_t nDirOffset) /* down by one block. */ /************************************************************************/ -static void TIFFWriteOvrRow(TIFFOvrCache *psCache) +static void TIFFWriteOvrRow( TIFFOvrCache * psCache ) { - int nRet, iTileX, iTileY = psCache->nBlockOffset; + int nRet, iTileX, iTileY = psCache->nBlockOffset; unsigned char *pabyData; - toff_t nBaseDirOffset; - uint32_t RowsInStrip; + toff_t nBaseDirOffset; + uint32 RowsInStrip; - /* -------------------------------------------------------------------- */ - /* If the output cache is multi-byte per sample, and the file */ - /* being written to is of a different byte order than the current */ - /* platform, we will need to byte swap the data. */ - /* -------------------------------------------------------------------- */ - if (TIFFIsByteSwapped(psCache->hTIFF)) +/* -------------------------------------------------------------------- */ +/* If the output cache is multi-byte per sample, and the file */ +/* being written to is of a different byte order than the current */ +/* platform, we will need to byte swap the data. */ +/* -------------------------------------------------------------------- */ + if( TIFFIsByteSwapped(psCache->hTIFF) ) { - if (psCache->nBitsPerPixel == 16) - TIFFSwabArrayOfShort((uint16_t *)psCache->pabyRow1Blocks, - (psCache->nBytesPerBlock * psCache->nSamples) / - 2); + if( psCache->nBitsPerPixel == 16 ) + TIFFSwabArrayOfShort( (uint16 *) psCache->pabyRow1Blocks, + (psCache->nBytesPerBlock * psCache->nSamples) / 2 ); - else if (psCache->nBitsPerPixel == 32) - TIFFSwabArrayOfLong((uint32_t *)psCache->pabyRow1Blocks, - (psCache->nBytesPerBlock * psCache->nSamples) / - 4); + else if( psCache->nBitsPerPixel == 32 ) + TIFFSwabArrayOfLong( (uint32 *) psCache->pabyRow1Blocks, + (psCache->nBytesPerBlock * psCache->nSamples) / 4 ); - else if (psCache->nBitsPerPixel == 64) - TIFFSwabArrayOfDouble( - (double *)psCache->pabyRow1Blocks, - (psCache->nBytesPerBlock * psCache->nSamples) / 8); + else if( psCache->nBitsPerPixel == 64 ) + TIFFSwabArrayOfDouble( (double *) psCache->pabyRow1Blocks, + (psCache->nBytesPerBlock * psCache->nSamples) / 8 ); } - /* -------------------------------------------------------------------- */ - /* Record original directory position, so we can restore it at */ - /* end. */ - /* -------------------------------------------------------------------- */ - nBaseDirOffset = TIFFCurrentDirOffset(psCache->hTIFF); - nRet = TIFFSetSubDirectory(psCache->hTIFF, psCache->nDirOffset); - (void)nRet; - assert(nRet == 1); +/* -------------------------------------------------------------------- */ +/* Record original directory position, so we can restore it at */ +/* end. */ +/* -------------------------------------------------------------------- */ + nBaseDirOffset = TIFFCurrentDirOffset( psCache->hTIFF ); + nRet = TIFFSetSubDirectory( psCache->hTIFF, psCache->nDirOffset ); + (void) nRet; + assert( nRet == 1 ); - /* -------------------------------------------------------------------- */ - /* Write blocks to TIFF file. */ - /* -------------------------------------------------------------------- */ - for (iTileX = 0; iTileX < psCache->nBlocksPerRow; iTileX++) - { - int nTileID; +/* -------------------------------------------------------------------- */ +/* Write blocks to TIFF file. */ +/* -------------------------------------------------------------------- */ + for( iTileX = 0; iTileX < psCache->nBlocksPerRow; iTileX++ ) + { + int nTileID; - if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) - { - int iSample; + if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) + { + int iSample; - for (iSample = 0; iSample < psCache->nSamples; iSample++) - { - pabyData = TIFFGetOvrBlock(psCache, iTileX, iTileY, iSample); + for( iSample = 0; iSample < psCache->nSamples; iSample++ ) + { + pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, iSample ); - if (psCache->bTiled) - { - nTileID = TIFFComputeTile( - psCache->hTIFF, iTileX * psCache->nBlockXSize, - iTileY * psCache->nBlockYSize, 0, (tsample_t)iSample); - TIFFWriteEncodedTile(psCache->hTIFF, nTileID, pabyData, - TIFFTileSize(psCache->hTIFF)); - } - else - { - nTileID = TIFFComputeStrip(psCache->hTIFF, - iTileY * psCache->nBlockYSize, - (tsample_t)iSample); - RowsInStrip = psCache->nBlockYSize; - if ((iTileY + 1) * psCache->nBlockYSize > psCache->nYSize) - RowsInStrip = - psCache->nYSize - iTileY * psCache->nBlockYSize; - TIFFWriteEncodedStrip( - psCache->hTIFF, nTileID, pabyData, - TIFFVStripSize(psCache->hTIFF, RowsInStrip)); - } - } - } - else - { - pabyData = TIFFGetOvrBlock(psCache, iTileX, iTileY, 0); + if( psCache->bTiled ) + { + nTileID = TIFFComputeTile( psCache->hTIFF, + iTileX * psCache->nBlockXSize, + iTileY * psCache->nBlockYSize, + 0, (tsample_t) iSample ); + TIFFWriteEncodedTile( psCache->hTIFF, nTileID, + pabyData, + TIFFTileSize(psCache->hTIFF) ); + } + else + { + nTileID = TIFFComputeStrip( psCache->hTIFF, + iTileY * psCache->nBlockYSize, + (tsample_t) iSample ); + RowsInStrip=psCache->nBlockYSize; + if ((iTileY+1)*psCache->nBlockYSize>psCache->nYSize) + RowsInStrip=psCache->nYSize-iTileY*psCache->nBlockYSize; + TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, + pabyData, + TIFFVStripSize(psCache->hTIFF,RowsInStrip) ); + } + } - if (psCache->bTiled) - { - nTileID = TIFFComputeTile(psCache->hTIFF, - iTileX * psCache->nBlockXSize, - iTileY * psCache->nBlockYSize, 0, 0); - TIFFWriteEncodedTile(psCache->hTIFF, nTileID, pabyData, - TIFFTileSize(psCache->hTIFF)); - } - else - { - nTileID = TIFFComputeStrip(psCache->hTIFF, - iTileY * psCache->nBlockYSize, 0); - RowsInStrip = psCache->nBlockYSize; - if ((iTileY + 1) * psCache->nBlockYSize > psCache->nYSize) - RowsInStrip = - psCache->nYSize - iTileY * psCache->nBlockYSize; - TIFFWriteEncodedStrip( - psCache->hTIFF, nTileID, pabyData, - TIFFVStripSize(psCache->hTIFF, RowsInStrip)); - } - } - } - /* TODO: add checks on error status return of TIFFWriteEncodedTile and - * TIFFWriteEncodedStrip */ + } + else + { + pabyData = TIFFGetOvrBlock( psCache, iTileX, iTileY, 0 ); - /* -------------------------------------------------------------------- */ - /* Rotate buffers. */ - /* -------------------------------------------------------------------- */ + if( psCache->bTiled ) + { + nTileID = TIFFComputeTile( psCache->hTIFF, + iTileX * psCache->nBlockXSize, + iTileY * psCache->nBlockYSize, + 0, 0 ); + TIFFWriteEncodedTile( psCache->hTIFF, nTileID, + pabyData, + TIFFTileSize(psCache->hTIFF) ); + } + else + { + nTileID = TIFFComputeStrip( psCache->hTIFF, + iTileY * psCache->nBlockYSize, + 0 ); + RowsInStrip=psCache->nBlockYSize; + if ((iTileY+1)*psCache->nBlockYSize>psCache->nYSize) + RowsInStrip=psCache->nYSize-iTileY*psCache->nBlockYSize; + TIFFWriteEncodedStrip( psCache->hTIFF, nTileID, + pabyData, + TIFFVStripSize(psCache->hTIFF,RowsInStrip) ); + } + } + } + /* TODO: add checks on error status return of TIFFWriteEncodedTile and TIFFWriteEncodedStrip */ + +/* -------------------------------------------------------------------- */ +/* Rotate buffers. */ +/* -------------------------------------------------------------------- */ pabyData = psCache->pabyRow1Blocks; psCache->pabyRow1Blocks = psCache->pabyRow2Blocks; psCache->pabyRow2Blocks = pabyData; - _TIFFmemset(pabyData, 0, psCache->nBytesPerRow); + _TIFFmemset( pabyData, 0, psCache->nBytesPerRow ); psCache->nBlockOffset++; - /* -------------------------------------------------------------------- */ - /* Restore access to original directory. */ - /* -------------------------------------------------------------------- */ - TIFFFlush(psCache->hTIFF); +/* -------------------------------------------------------------------- */ +/* Restore access to original directory. */ +/* -------------------------------------------------------------------- */ + TIFFFlush( psCache->hTIFF ); /* TODO: add checks on error status return of TIFFFlush */ - TIFFSetSubDirectory(psCache->hTIFF, nBaseDirOffset); + TIFFSetSubDirectory( psCache->hTIFF, nBaseDirOffset ); /* TODO: add checks on error status return of TIFFSetSubDirectory */ } @@ -270,31 +264,30 @@ static void TIFFWriteOvrRow(TIFFOvrCache *psCache) /************************************************************************/ /* TODO: make TIFF_Downsample handle iSample offset, so that we can - * do with a single TIFFGetOvrBlock and no longer need - * TIFFGetOvrBlock_Subsampled */ -unsigned char *TIFFGetOvrBlock(TIFFOvrCache *psCache, int iTileX, int iTileY, - int iSample) + * do with a single TIFFGetOvrBlock and no longer need TIFFGetOvrBlock_Subsampled */ +unsigned char *TIFFGetOvrBlock( TIFFOvrCache *psCache, int iTileX, int iTileY, + int iSample ) { - long nRowOffset; + long nRowOffset; - if (iTileY > psCache->nBlockOffset + 1) - TIFFWriteOvrRow(psCache); + if ( iTileY > psCache->nBlockOffset + 1 ) + TIFFWriteOvrRow( psCache ); - assert(iTileX >= 0 && iTileX < psCache->nBlocksPerRow); - assert(iTileY >= 0 && iTileY < psCache->nBlocksPerColumn); - assert(iTileY >= psCache->nBlockOffset && - iTileY < psCache->nBlockOffset + 2); - assert(iSample >= 0 && iSample < psCache->nSamples); + assert( iTileX >= 0 && iTileX < psCache->nBlocksPerRow ); + assert( iTileY >= 0 && iTileY < psCache->nBlocksPerColumn ); + assert( iTileY >= psCache->nBlockOffset + && iTileY < psCache->nBlockOffset+2 ); + assert( iSample >= 0 && iSample < psCache->nSamples ); if (psCache->nPlanarConfig == PLANARCONFIG_SEPARATE) - nRowOffset = ((((toff_t)iTileX * psCache->nSamples) + iSample) * - psCache->nBytesPerBlock); + nRowOffset = ((((toff_t) iTileX * psCache->nSamples) + iSample) + * psCache->nBytesPerBlock); else nRowOffset = iTileX * psCache->nBytesPerBlock + - (psCache->nBitsPerPixel + 7) / 8 * iSample; + (psCache->nBitsPerPixel + 7) / 8 * iSample; - if (iTileY == psCache->nBlockOffset) + if ( iTileY == psCache->nBlockOffset ) return psCache->pabyRow1Blocks + nRowOffset; else return psCache->pabyRow2Blocks + nRowOffset; @@ -304,24 +297,24 @@ unsigned char *TIFFGetOvrBlock(TIFFOvrCache *psCache, int iTileX, int iTileY, /* TIFFGetOvrBlock_Subsampled() */ /************************************************************************/ -unsigned char *TIFFGetOvrBlock_Subsampled(TIFFOvrCache *psCache, int iTileX, - int iTileY) +unsigned char *TIFFGetOvrBlock_Subsampled( TIFFOvrCache *psCache, + int iTileX, int iTileY ) { - int nRowOffset; + int nRowOffset; - if (iTileY > psCache->nBlockOffset + 1) - TIFFWriteOvrRow(psCache); + if( iTileY > psCache->nBlockOffset + 1 ) + TIFFWriteOvrRow( psCache ); - assert(iTileX >= 0 && iTileX < psCache->nBlocksPerRow); - assert(iTileY >= 0 && iTileY < psCache->nBlocksPerColumn); - assert(iTileY >= psCache->nBlockOffset && - iTileY < psCache->nBlockOffset + 2); - assert(psCache->nPlanarConfig != PLANARCONFIG_SEPARATE); + assert( iTileX >= 0 && iTileX < psCache->nBlocksPerRow ); + assert( iTileY >= 0 && iTileY < psCache->nBlocksPerColumn ); + assert( iTileY >= psCache->nBlockOffset + && iTileY < psCache->nBlockOffset+2 ); + assert( psCache->nPlanarConfig != PLANARCONFIG_SEPARATE ); nRowOffset = iTileX * psCache->nBytesPerBlock; - if (iTileY == psCache->nBlockOffset) + if( iTileY == psCache->nBlockOffset ) return psCache->pabyRow1Blocks + nRowOffset; else return psCache->pabyRow2Blocks + nRowOffset; @@ -331,13 +324,20 @@ unsigned char *TIFFGetOvrBlock_Subsampled(TIFFOvrCache *psCache, int iTileX, /* TIFFDestroyOvrCache() */ /************************************************************************/ -void TIFFDestroyOvrCache(TIFFOvrCache *psCache) +void TIFFDestroyOvrCache( TIFFOvrCache * psCache ) { - while (psCache->nBlockOffset < psCache->nBlocksPerColumn) - TIFFWriteOvrRow(psCache); + while( psCache->nBlockOffset < psCache->nBlocksPerColumn ) + TIFFWriteOvrRow( psCache ); - _TIFFfree(psCache->pabyRow1Blocks); - _TIFFfree(psCache->pabyRow2Blocks); - _TIFFfree(psCache); + _TIFFfree( psCache->pabyRow1Blocks ); + _TIFFfree( psCache->pabyRow2Blocks ); + _TIFFfree( psCache ); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_ovrcache.h b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_ovrcache.h index 90d198a4a..0ad10829d 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_ovrcache.h +++ b/thirdparty/SDL2_image/external/libtiff/contrib/addtiffo/tif_ovrcache.h @@ -3,11 +3,11 @@ * * Project: TIFF Overview Builder * Purpose: Library functions to maintain two rows of tiles or two strips - * of data for output overviews as an output cache. + * of data for output overviews as an output cache. * Author: Frank Warmerdam, warmerdam@pobox.com * * This code could potentially be used by other applications wanting to - * manage a once-through write cache. + * manage a once-through write cache. * ****************************************************************************** * Copyright (c) 2000, Frank Warmerdam @@ -38,58 +38,66 @@ #include "tiffio.h" #if defined(__cplusplus) -extern "C" -{ +extern "C" { #endif + +typedef struct +{ + uint32 nXSize; + uint32 nYSize; - typedef struct - { - uint32_t nXSize; - uint32_t nYSize; + uint16 nBitsPerPixel; + uint16 nSamples; + uint16 nPlanarConfig; + uint32 nBlockXSize; + uint32 nBlockYSize; + toff_t nBytesPerBlock; + toff_t nBytesPerRow; - uint16_t nBitsPerPixel; - uint16_t nSamples; - uint16_t nPlanarConfig; - uint32_t nBlockXSize; - uint32_t nBlockYSize; - toff_t nBytesPerBlock; - toff_t nBytesPerRow; + int nBlocksPerRow; + int nBlocksPerColumn; - int nBlocksPerRow; - int nBlocksPerColumn; + int nBlockOffset; /* what block is the first in papabyBlocks? */ + unsigned char *pabyRow1Blocks; + unsigned char *pabyRow2Blocks; - int nBlockOffset; /* what block is the first in papabyBlocks? */ - unsigned char *pabyRow1Blocks; - unsigned char *pabyRow2Blocks; + toff_t nDirOffset; + TIFF *hTIFF; + int bTiled; + +} TIFFOvrCache; - toff_t nDirOffset; - TIFF *hTIFF; - int bTiled; +TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, toff_t nDirOffset ); +unsigned char *TIFFGetOvrBlock( TIFFOvrCache *psCache, int iTileX, int iTileY, + int iSample ); +unsigned char *TIFFGetOvrBlock_Subsampled( TIFFOvrCache *psCache, int iTileX, int iTileY ); +void TIFFDestroyOvrCache( TIFFOvrCache * ); - } TIFFOvrCache; +void TIFFBuildOverviews( TIFF *, int, int *, int, const char *, + int (*)(double,void*), void * ); - TIFFOvrCache *TIFFCreateOvrCache(TIFF *hTIFF, toff_t nDirOffset); - unsigned char *TIFFGetOvrBlock(TIFFOvrCache *psCache, int iTileX, - int iTileY, int iSample); - unsigned char *TIFFGetOvrBlock_Subsampled(TIFFOvrCache *psCache, int iTileX, - int iTileY); - void TIFFDestroyOvrCache(TIFFOvrCache *); +void TIFF_ProcessFullResBlock( TIFF *, int, int, int, int, int, int *, int, + int, TIFFOvrCache **, uint32, uint32, + unsigned char *, uint32, uint32, + int, const char * ); - void TIFFBuildOverviews(TIFF *, int, int *, int, const char *, - int (*)(double, void *), void *); +uint32 TIFF_WriteOverview( TIFF *, uint32, uint32, int, int, int, int, int, + int, int, int, int, unsigned short *, + unsigned short *, unsigned short *, int, + int, int); - void TIFF_ProcessFullResBlock(TIFF *, int, int, int, int, int, int *, int, - int, TIFFOvrCache **, uint32_t, uint32_t, - unsigned char *, uint32_t, uint32_t, int, - const char *); - uint32_t TIFF_WriteOverview(TIFF *, uint32_t, uint32_t, int, int, int, int, - int, int, int, int, int, unsigned short *, - unsigned short *, unsigned short *, int, int, - int); #if defined(__cplusplus) } #endif - + #endif /* ndef TIF_OVRCACHE_H_INCLUDED */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/CMakeLists.txt index 74b2a02a0..ff3ce20c1 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/CMakeLists.txt +++ b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/CMakeLists.txt @@ -22,17 +22,25 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +include_directories(${PROJECT_SOURCE_DIR}/libtiff + ${PROJECT_BINARY_DIR}/libtiff + ${CMAKE_CURRENT_BINARY_DIR}) + add_executable(tiff-bi tiff-bi.c) -target_link_libraries(tiff-bi tiff tiff_port) +target_link_libraries(tiff-bi tiff port) add_executable(tiff-grayscale tiff-grayscale.c) -target_link_libraries(tiff-grayscale tiff tiff_port CMath::CMath) +target_link_libraries(tiff-grayscale tiff port) add_executable(tiff-palette tiff-palette.c) -target_link_libraries(tiff-palette tiff tiff_port) +target_link_libraries(tiff-palette tiff port) add_executable(tiff-rgb tiff-rgb.c) -target_link_libraries(tiff-rgb tiff tiff_port CMath::CMath) +target_link_libraries(tiff-rgb tiff port) + +add_subdirectory(xtiff) + +extra_dist(README) if(WEBP_SUPPORT AND EMSCRIPTEN) # Emscripten is pretty finnicky about linker flags. diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/Makefile.am index 191d93467..90697eeda 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/Makefile.am @@ -31,9 +31,7 @@ EXTRA_DIST = \ CMakeLists.txt \ README -if TIFF_CONTRIB noinst_PROGRAMS = tiff-bi tiff-grayscale tiff-palette tiff-rgb -endif tiff_bi_SOURCES = tiff-bi.c tiff_bi_LDADD = $(LIBTIFF) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/tiff-bi.c b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/tiff-bi.c index 7de756366..db0e8c89d 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/tiff-bi.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/tiff-bi.c @@ -27,23 +27,21 @@ #include "tiffio.h" -#define WIDTH 512 -#define HEIGHT WIDTH +#define WIDTH 512 +#define HEIGHT WIDTH int main(int argc, char **argv) { - int i; - unsigned char *scan_line; - TIFF *tif; + int i; + unsigned char * scan_line; + TIFF * tif; - if (argc != 2) - { + if (argc != 2) { fprintf(stderr, "Usage: %s tiff-image\n", argv[0]); return 0; } - if ((tif = TIFFOpen(argv[1], "w")) == NULL) - { + if ((tif = TIFFOpen(argv[1], "w")) == NULL) { fprintf(stderr, "can't open %s as a TIFF file\n", argv[1]); return 0; } @@ -58,7 +56,7 @@ int main(int argc, char **argv) TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE); - scan_line = (unsigned char *)malloc(WIDTH / 8); + scan_line = (unsigned char *) malloc(WIDTH / 8); for (i = 0; i < (WIDTH / 8) / 2; i++) scan_line[i] = 0; @@ -82,3 +80,10 @@ int main(int argc, char **argv) TIFFClose(tif); return 0; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/tiff-grayscale.c b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/tiff-grayscale.c index c3dc48f90..92c7b9045 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/tiff-grayscale.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/tiff-grayscale.c @@ -30,20 +30,20 @@ #include "tiffio.h" -#define WIDTH 512 -#define HEIGHT WIDTH +#define WIDTH 512 +#define HEIGHT WIDTH -char *programName; -void Usage(); +char * programName; +void Usage(); int main(int argc, char **argv) { - int bits_per_pixel = 8, cmsize, i, j, k, gray_index, chunk_size = 32, - nchunks = 16; - unsigned char *scan_line; - uint16_t *gray; - float refblackwhite[2 * 1]; - TIFF *tif; + int bits_per_pixel = 8, cmsize, i, j, k, + gray_index, chunk_size = 32, nchunks = 16; + unsigned char * scan_line; + uint16 * gray; + float refblackwhite[2*1]; + TIFF * tif; programName = argv[0]; @@ -51,12 +51,11 @@ int main(int argc, char **argv) Usage(); if (!strcmp(argv[1], "-depth")) - bits_per_pixel = atoi(argv[2]); + bits_per_pixel = atoi(argv[2]); else - Usage(); + Usage(); - switch (bits_per_pixel) - { + switch (bits_per_pixel) { case 8: nchunks = 16; chunk_size = 32; @@ -74,19 +73,18 @@ int main(int argc, char **argv) } cmsize = nchunks * nchunks; - gray = (uint16_t *)malloc(cmsize * sizeof(uint16_t)); + gray = (uint16 *) malloc(cmsize * sizeof(uint16)); gray[0] = 3000; for (i = 1; i < cmsize; i++) - gray[i] = (uint16_t)(-log10((double)i / (cmsize - 1)) * 1000); + gray[i] = (uint16) (-log10((double) i / (cmsize - 1)) * 1000); refblackwhite[0] = 0.0; - refblackwhite[1] = (float)((1L << bits_per_pixel) - 1); + refblackwhite[1] = (float)((1L< # Written by Roger Leigh # # Permission to use, copy, modify, distribute, and sell this software and @@ -23,10 +22,8 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. - -if (UNIX OR MINGW) - # This might not catch every possibility catered for by - # Autoconf AC_SYS_LARGEFILE. - add_definitions(-D_FILE_OFFSET_BITS=64) - set(FILE_OFFSET_BITS 64) -endif() +extra_dist( + README + patchlevel.h + xtiff.c + xtifficon.h) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/Makefile.am index cd8104723..a138c90a7 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/Makefile.am @@ -27,6 +27,7 @@ #LIBTIFF = $(top_builddir)/libtiff/libtiff.la EXTRA_DIST = \ + CMakeLists.txt \ README \ patchlevel.h \ xtiff.c \ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/patchlevel.h b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/patchlevel.h index 935ec354b..538b6d975 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/patchlevel.h +++ b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/patchlevel.h @@ -1 +1,8 @@ #define PATCHLEVEL 0 +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/xtiff.c b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/xtiff.c index bd549a000..bc10b670a 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/xtiff.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/xtiff.c @@ -52,42 +52,37 @@ * * Only TIFFTAG_BITSPERSAMPLE values that are 1, 2, 4 or 8 are supported. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #define XK_MISCELLANY -#include "xtifficon.h" #include +#include "xtifficon.h" -#define TIFF_GAMMA "2.2" /* default gamma from the TIFF 5.0 spec */ -#define ROUND(x) (uint16_t)((x) + 0.5) -#define SCALE(x, s) (((x)*65535L) / (s)) -#define MCHECK(m) \ - if (!m) \ - { \ - fprintf(stderr, "malloc failed\n"); \ - exit(0); \ - } -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define VIEWPORT_WIDTH 700 +#define TIFF_GAMMA "2.2" /* default gamma from the TIFF 5.0 spec */ +#define ROUND(x) (uint16) ((x) + 0.5) +#define SCALE(x, s) (((x) * 65535L) / (s)) +#define MCHECK(m) if (!m) { fprintf(stderr, "malloc failed\n"); exit(0); } +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define VIEWPORT_WIDTH 700 #define VIEWPORT_HEIGHT 500 -#define KEY_TRANSLATE 20 +#define KEY_TRANSLATE 20 #ifdef __STDC__ -#define PP(args) args +#define PP(args) args #else -#define PP(args) () +#define PP(args) () #endif int main PP((int argc, char **argv)); @@ -97,8 +92,8 @@ void SetNameLabel PP((void)); void CheckAndCorrectColormap PP((void)); void SimpleGammaCorrection PP((void)); void GetVisual PP((void)); -Boolean SearchVisualList PP((int image_depth, int visual_class, - Visual **visual)); +Boolean SearchVisualList PP((int image_depth, + int visual_class, Visual **visual)); void GetTIFFImage PP((void)); void CreateXImage PP((void)); XtCallbackProc SelectProc PP((Widget w, caddr_t unused_1, caddr_t unused_2)); @@ -108,41 +103,36 @@ void PreviousProc PP((void)); void PageProc PP((int direction)); void EventProc PP((Widget widget, caddr_t unused, XEvent *event)); void ResizeProc PP((void)); -int XTiffErrorHandler PP((Display * display, XErrorEvent *error_event)); +int XTiffErrorHandler PP((Display *display, XErrorEvent *error_event)); void Usage PP((void)); -int xtVersion = XtSpecificationRelease; /* xtiff depends on R4 or higher */ +int xtVersion = XtSpecificationRelease; /* xtiff depends on R4 or higher */ /* * Xt data structures */ Widget shellWidget, formWidget, listWidget, labelWidget, imageWidget; -enum -{ - ButtonQuit = 0, - ButtonPreviousPage = 1, - ButtonNextPage = 2 -}; +enum { ButtonQuit = 0, ButtonPreviousPage = 1, ButtonNextPage = 2 }; -String buttonStrings[] = {"Quit", "Previous", "Next"}; +String buttonStrings[] = { "Quit", "Previous", "Next" }; static XrmOptionDescRec shellOptions[] = { - {"-help", "*help", XrmoptionNoArg, (caddr_t) "True"}, - {"-gamma", "*gamma", XrmoptionSepArg, NULL}, - {"-usePixmap", "*usePixmap", XrmoptionSepArg, NULL}, - {"-viewportWidth", "*viewportWidth", XrmoptionSepArg, NULL}, - {"-viewportHeight", "*viewportHeight", XrmoptionSepArg, NULL}, - {"-translate", "*translate", XrmoptionSepArg, NULL}, - {"-verbose", "*verbose", XrmoptionSepArg, NULL}}; + { "-help", "*help", XrmoptionNoArg, (caddr_t) "True" }, + { "-gamma", "*gamma", XrmoptionSepArg, NULL }, + { "-usePixmap", "*usePixmap", XrmoptionSepArg, NULL }, + { "-viewportWidth", "*viewportWidth", XrmoptionSepArg, NULL }, + { "-viewportHeight", "*viewportHeight", XrmoptionSepArg, NULL }, + { "-translate", "*translate", XrmoptionSepArg, NULL }, + { "-verbose", "*verbose", XrmoptionSepArg, NULL } +}; -typedef struct -{ +typedef struct { Boolean help; float gamma; Boolean usePixmap; - uint32_t viewportWidth; - uint32_t viewportHeight; + uint32 viewportWidth; + uint32 viewportHeight; int translate; Boolean verbose; } AppData, *AppDataPtr; @@ -150,45 +140,75 @@ typedef struct AppData appData; XtResource clientResources[] = { - {"help", XtCBoolean, XtRBoolean, sizeof(Boolean), - XtOffset(AppDataPtr, help), XtRImmediate, (XtPointer)False}, - {"gamma", "Gamma", XtRFloat, sizeof(float), XtOffset(AppDataPtr, gamma), - XtRString, (XtPointer)TIFF_GAMMA}, - {"usePixmap", "UsePixmap", XtRBoolean, sizeof(Boolean), - XtOffset(AppDataPtr, usePixmap), XtRImmediate, (XtPointer)True}, - {"viewportWidth", "ViewportWidth", XtRInt, sizeof(int), - XtOffset(AppDataPtr, viewportWidth), XtRImmediate, - (XtPointer)VIEWPORT_WIDTH}, - {"viewportHeight", "ViewportHeight", XtRInt, sizeof(int), - XtOffset(AppDataPtr, viewportHeight), XtRImmediate, - (XtPointer)VIEWPORT_HEIGHT}, - {"translate", "Translate", XtRInt, sizeof(int), - XtOffset(AppDataPtr, translate), XtRImmediate, (XtPointer)KEY_TRANSLATE}, - {"verbose", "Verbose", XtRBoolean, sizeof(Boolean), - XtOffset(AppDataPtr, verbose), XtRImmediate, (XtPointer)True}}; + { + "help", XtCBoolean, XtRBoolean, sizeof(Boolean), + XtOffset(AppDataPtr, help), XtRImmediate, (XtPointer) False + }, { + "gamma", "Gamma", XtRFloat, sizeof(float), + XtOffset(AppDataPtr, gamma), XtRString, (XtPointer) TIFF_GAMMA + }, { + "usePixmap", "UsePixmap", XtRBoolean, sizeof(Boolean), + XtOffset(AppDataPtr, usePixmap), XtRImmediate, (XtPointer) True + }, { + "viewportWidth", "ViewportWidth", XtRInt, sizeof(int), + XtOffset(AppDataPtr, viewportWidth), XtRImmediate, + (XtPointer) VIEWPORT_WIDTH + }, { + "viewportHeight", "ViewportHeight", XtRInt, sizeof(int), + XtOffset(AppDataPtr, viewportHeight), XtRImmediate, + (XtPointer) VIEWPORT_HEIGHT + }, { + "translate", "Translate", XtRInt, sizeof(int), + XtOffset(AppDataPtr, translate), XtRImmediate, (XtPointer) KEY_TRANSLATE + }, { + "verbose", "Verbose", XtRBoolean, sizeof(Boolean), + XtOffset(AppDataPtr, verbose), XtRImmediate, (XtPointer) True + } +}; -Arg formArgs[] = {{XtNresizable, True}}; +Arg formArgs[] = { + { XtNresizable, True } +}; Arg listArgs[] = { - {XtNresizable, False}, {XtNborderWidth, 0}, - {XtNdefaultColumns, 3}, {XtNforceColumns, True}, - {XtNlist, (int)buttonStrings}, {XtNnumberStrings, XtNumber(buttonStrings)}, - {XtNtop, XtChainTop}, {XtNleft, XtChainLeft}, - {XtNbottom, XtChainTop}, {XtNright, XtChainLeft}}; + { XtNresizable, False }, + { XtNborderWidth, 0 }, + { XtNdefaultColumns, 3 }, + { XtNforceColumns, True }, + { XtNlist, (int) buttonStrings }, + { XtNnumberStrings, XtNumber(buttonStrings) }, + { XtNtop, XtChainTop }, + { XtNleft, XtChainLeft }, + { XtNbottom, XtChainTop }, + { XtNright, XtChainLeft } +}; -Arg labelArgs[] = {{XtNresizable, False}, {XtNwidth, 200}, - {XtNborderWidth, 0}, {XtNjustify, XtJustifyLeft}, - {XtNtop, XtChainTop}, {XtNleft, XtChainLeft}, - {XtNbottom, XtChainTop}, {XtNright, XtChainLeft}}; +Arg labelArgs[] = { + { XtNresizable, False }, + { XtNwidth, 200 }, + { XtNborderWidth, 0 }, + { XtNjustify, XtJustifyLeft }, + { XtNtop, XtChainTop }, + { XtNleft, XtChainLeft }, + { XtNbottom, XtChainTop }, + { XtNright, XtChainLeft } +}; -Arg imageArgs[] = {{XtNresizable, True}, {XtNborderWidth, 0}, - {XtNtop, XtChainTop}, {XtNleft, XtChainLeft}, - {XtNbottom, XtChainTop}, {XtNright, XtChainLeft}}; +Arg imageArgs[] = { + { XtNresizable, True }, + { XtNborderWidth, 0 }, + { XtNtop, XtChainTop }, + { XtNleft, XtChainLeft }, + { XtNbottom, XtChainTop }, + { XtNright, XtChainLeft } +}; -XtActionsRec actionsTable[] = {{"quit", QuitProc}, - {"next", NextProc}, - {"previous", PreviousProc}, - {"notifyresize", ResizeProc}}; +XtActionsRec actionsTable[] = { + { "quit", QuitProc }, + { "next", NextProc }, + { "previous", PreviousProc }, + { "notifyresize", ResizeProc } +}; char translationsTable[] = "q: quit() \n \ Q: quit() \n \ @@ -202,64 +222,64 @@ char translationsTable[] = "q: quit() \n \ /* * X data structures */ -Colormap xColormap; -Display *xDisplay; -Pixmap xImagePixmap; -Visual *xVisual; -XImage *xImage; -GC xWinGc; -int xImageDepth, xScreen, xRedMask, xGreenMask, xBlueMask, - xOffset = 0, yOffset = 0, grabX = -1, grabY = -1; -unsigned char basePixel = 0; +Colormap xColormap; +Display * xDisplay; +Pixmap xImagePixmap; +Visual * xVisual; +XImage * xImage; +GC xWinGc; +int xImageDepth, xScreen, xRedMask, xGreenMask, xBlueMask, + xOffset = 0, yOffset = 0, grabX = -1, grabY = -1; +unsigned char basePixel = 0; /* * TIFF data structures */ -TIFF *tfFile = NULL; -uint32_t tfImageWidth, tfImageHeight; -uint16_t tfBitsPerSample, tfSamplesPerPixel, tfPlanarConfiguration, - tfPhotometricInterpretation, tfGrayResponseUnit, tfImageDepth, - tfBytesPerRow; -int tfDirectory = 0, tfMultiPage = False; -double tfUnitMap, - tfGrayResponseUnitMap[] = {-1, -10, -100, -1000, -10000, -100000}; +TIFF * tfFile = NULL; +uint32 tfImageWidth, tfImageHeight; +uint16 tfBitsPerSample, tfSamplesPerPixel, tfPlanarConfiguration, + tfPhotometricInterpretation, tfGrayResponseUnit, + tfImageDepth, tfBytesPerRow; +int tfDirectory = 0, tfMultiPage = False; +double tfUnitMap, tfGrayResponseUnitMap[] = { + -1, -10, -100, -1000, -10000, -100000 + }; /* * display data structures */ -double *dRed, *dGreen, *dBlue; +double *dRed, *dGreen, *dBlue; /* * shared data structures */ -uint16_t *redMap = NULL, *greenMap = NULL, *blueMap = NULL, *grayMap = NULL, - colormapSize; -char *imageMemory; -char *fileName; +uint16 * redMap = NULL, *greenMap = NULL, *blueMap = NULL, + *grayMap = NULL, colormapSize; +char * imageMemory; +char * fileName; -int main(int argc, char **argv) +int +main(int argc, char **argv) { XSetWindowAttributes window_attributes; Widget widget_list[3]; Arg args[5]; - setbuf(stdout, NULL); - setbuf(stderr, NULL); + setbuf(stdout, NULL); setbuf(stderr, NULL); shellWidget = XtInitialize(argv[0], "XTiff", shellOptions, - XtNumber(shellOptions), &argc, argv); + XtNumber(shellOptions), &argc, argv); XSetErrorHandler(XTiffErrorHandler); - XtGetApplicationResources( - shellWidget, &appData, (XtResourceList)clientResources, - (Cardinal)XtNumber(clientResources), (ArgList)NULL, (Cardinal)0); + XtGetApplicationResources(shellWidget, &appData, + (XtResourceList) clientResources, (Cardinal) XtNumber(clientResources), + (ArgList) NULL, (Cardinal) 0); if ((argc <= 1) || (argc > 2) || appData.help) Usage(); - if (appData.verbose == False) - { + if (appData.verbose == False) { TIFFSetErrorHandler(0); TIFFSetWarningHandler(0); } @@ -282,41 +302,38 @@ int main(int argc, char **argv) XtSetArg(args[0], XtNvisual, xVisual); XtSetArg(args[1], XtNcolormap, xColormap); XtSetArg(args[2], XtNdepth, - xImageDepth == 1 ? DefaultDepth(xDisplay, xScreen) : xImageDepth); + xImageDepth == 1 ? DefaultDepth(xDisplay, xScreen) : xImageDepth); XtSetArg(args[3], XtNiconPixmap, - XCreateBitmapFromData(xDisplay, RootWindow(xDisplay, xScreen), - xtifficon_bits, xtifficon_width, - xtifficon_height)); + XCreateBitmapFromData(xDisplay, RootWindow(xDisplay, xScreen), + xtifficon_bits, xtifficon_width, xtifficon_height)); XtSetArg(args[4], XtNallowShellResize, True); XtSetValues(shellWidget, args, 5); /* * widget instance hierarchy */ - formWidget = XtCreateManagedWidget("form", formWidgetClass, shellWidget, - formArgs, XtNumber(formArgs)); + formWidget = XtCreateManagedWidget("form", formWidgetClass, + shellWidget, formArgs, XtNumber(formArgs)); - widget_list[0] = listWidget = XtCreateWidget( - "list", listWidgetClass, formWidget, listArgs, XtNumber(listArgs)); + widget_list[0] = listWidget = XtCreateWidget("list", + listWidgetClass, formWidget, listArgs, XtNumber(listArgs)); - widget_list[1] = labelWidget = XtCreateWidget( - "label", labelWidgetClass, formWidget, labelArgs, XtNumber(labelArgs)); + widget_list[1] = labelWidget = XtCreateWidget("label", + labelWidgetClass, formWidget, labelArgs, XtNumber(labelArgs)); - widget_list[2] = imageWidget = XtCreateWidget( - "image", widgetClass, formWidget, imageArgs, XtNumber(imageArgs)); + widget_list[2] = imageWidget = XtCreateWidget("image", + widgetClass, formWidget, imageArgs, XtNumber(imageArgs)); XtManageChildren(widget_list, XtNumber(widget_list)); /* * initial widget sizes - for small images let xtiff size itself */ - if (tfImageWidth >= appData.viewportWidth) - { + if (tfImageWidth >= appData.viewportWidth) { XtSetArg(args[0], XtNwidth, appData.viewportWidth); XtSetValues(shellWidget, args, 1); } - if (tfImageHeight >= appData.viewportHeight) - { + if (tfImageHeight >= appData.viewportHeight) { XtSetArg(args[0], XtNheight, appData.viewportHeight); XtSetValues(shellWidget, args, 1); } @@ -335,12 +352,12 @@ int main(int argc, char **argv) SetNameLabel(); - XtAddCallback(listWidget, XtNcallback, (XtCallbackProc)SelectProc, - (XtPointer)NULL); + XtAddCallback(listWidget, XtNcallback, (XtCallbackProc) SelectProc, + (XtPointer) NULL); XtAddActions(actionsTable, XtNumber(actionsTable)); XtSetArg(args[0], XtNtranslations, - XtParseTranslationTable(translationsTable)); + XtParseTranslationTable(translationsTable)); XtSetValues(formWidget, &args[0], 1); XtSetValues(imageWidget, &args[0], 1); @@ -348,16 +365,15 @@ int main(int argc, char **argv) * This is intended to be a little faster than going through * the translation manager. */ - XtAddEventHandler(imageWidget, - ExposureMask | ButtonPressMask | ButtonReleaseMask | - Button1MotionMask | KeyPressMask, - False, EventProc, NULL); + XtAddEventHandler(imageWidget, ExposureMask | ButtonPressMask + | ButtonReleaseMask | Button1MotionMask | KeyPressMask, + False, EventProc, NULL); XtRealizeWidget(shellWidget); window_attributes.cursor = XCreateFontCursor(xDisplay, XC_fleur); - XChangeWindowAttributes(xDisplay, XtWindow(imageWidget), CWCursor, - &window_attributes); + XChangeWindowAttributes(xDisplay, XtWindow(imageWidget), + CWCursor, &window_attributes); CreateXImage(); @@ -366,29 +382,29 @@ int main(int argc, char **argv) return 0; } -void OpenTIFFFile() +void +OpenTIFFFile() { if (tfFile != NULL) TIFFClose(tfFile); - if ((tfFile = TIFFOpen(fileName, "r")) == NULL) - { - fprintf(appData.verbose ? stderr : stdout, - "xtiff: can't open %s as a TIFF file\n", fileName); + if ((tfFile = TIFFOpen(fileName, "r")) == NULL) { + fprintf(appData.verbose ? stderr : stdout, + "xtiff: can't open %s as a TIFF file\n", fileName); exit(0); } tfMultiPage = (TIFFLastDirectory(tfFile) ? False : True); } -void GetTIFFHeader() +void +GetTIFFHeader() { register int i; - if (!TIFFSetDirectory(tfFile, tfDirectory)) - { + if (!TIFFSetDirectory(tfFile, tfDirectory)) { fprintf(stderr, "xtiff: can't seek to directory %d in %s\n", - tfDirectory, fileName); + tfDirectory, fileName); exit(0); } @@ -401,113 +417,94 @@ void GetTIFFHeader() TIFFGetFieldDefaulted(tfFile, TIFFTAG_BITSPERSAMPLE, &tfBitsPerSample); TIFFGetFieldDefaulted(tfFile, TIFFTAG_SAMPLESPERPIXEL, &tfSamplesPerPixel); TIFFGetFieldDefaulted(tfFile, TIFFTAG_PLANARCONFIG, &tfPlanarConfiguration); - TIFFGetFieldDefaulted(tfFile, TIFFTAG_GRAYRESPONSEUNIT, - &tfGrayResponseUnit); + TIFFGetFieldDefaulted(tfFile, TIFFTAG_GRAYRESPONSEUNIT, &tfGrayResponseUnit); tfUnitMap = tfGrayResponseUnitMap[tfGrayResponseUnit]; colormapSize = 1 << tfBitsPerSample; tfImageDepth = tfBitsPerSample * tfSamplesPerPixel; - dRed = (double *)malloc(colormapSize * sizeof(double)); - dGreen = (double *)malloc(colormapSize * sizeof(double)); - dBlue = (double *)malloc(colormapSize * sizeof(double)); - MCHECK(dRed); - MCHECK(dGreen); - MCHECK(dBlue); + dRed = (double *) malloc(colormapSize * sizeof(double)); + dGreen = (double *) malloc(colormapSize * sizeof(double)); + dBlue = (double *) malloc(colormapSize * sizeof(double)); + MCHECK(dRed); MCHECK(dGreen); MCHECK(dBlue); /* * If TIFFTAG_PHOTOMETRIC is not present then assign a reasonable default. * The TIFF 5.0 specification doesn't give a default. */ if (!TIFFGetField(tfFile, TIFFTAG_PHOTOMETRIC, - &tfPhotometricInterpretation)) - { + &tfPhotometricInterpretation)) { if (tfSamplesPerPixel != 1) tfPhotometricInterpretation = PHOTOMETRIC_RGB; else if (tfBitsPerSample == 1) tfPhotometricInterpretation = PHOTOMETRIC_MINISBLACK; - else if (TIFFGetField(tfFile, TIFFTAG_COLORMAP, &redMap, &greenMap, - &blueMap)) - { + else if (TIFFGetField(tfFile, TIFFTAG_COLORMAP, + &redMap, &greenMap, &blueMap)) { tfPhotometricInterpretation = PHOTOMETRIC_PALETTE; redMap = greenMap = blueMap = NULL; - } - else + } else tfPhotometricInterpretation = PHOTOMETRIC_MINISBLACK; } /* * Given TIFFTAG_PHOTOMETRIC extract or create the response curves. */ - switch (tfPhotometricInterpretation) - { - case PHOTOMETRIC_RGB: - redMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - greenMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - blueMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - MCHECK(redMap); - MCHECK(greenMap); - MCHECK(blueMap); + switch (tfPhotometricInterpretation) { + case PHOTOMETRIC_RGB: + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); + for (i = 0; i < colormapSize; i++) + dRed[i] = dGreen[i] = dBlue[i] + = (double) SCALE(i, colormapSize - 1); + break; + case PHOTOMETRIC_PALETTE: + if (!TIFFGetField(tfFile, TIFFTAG_COLORMAP, + &redMap, &greenMap, &blueMap)) { + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); for (i = 0; i < colormapSize; i++) - dRed[i] = dGreen[i] = dBlue[i] = - (double)SCALE(i, colormapSize - 1); - break; - case PHOTOMETRIC_PALETTE: - if (!TIFFGetField(tfFile, TIFFTAG_COLORMAP, &redMap, &greenMap, - &blueMap)) - { - redMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - greenMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - blueMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - MCHECK(redMap); - MCHECK(greenMap); - MCHECK(blueMap); - for (i = 0; i < colormapSize; i++) - dRed[i] = dGreen[i] = dBlue[i] = - (double)SCALE(i, colormapSize - 1); + dRed[i] = dGreen[i] = dBlue[i] + = (double) SCALE(i, colormapSize - 1); + } else { + CheckAndCorrectColormap(); + for (i = 0; i < colormapSize; i++) { + dRed[i] = (double) redMap[i]; + dGreen[i] = (double) greenMap[i]; + dBlue[i] = (double) blueMap[i]; } - else - { - CheckAndCorrectColormap(); - for (i = 0; i < colormapSize; i++) - { - dRed[i] = (double)redMap[i]; - dGreen[i] = (double)greenMap[i]; - dBlue[i] = (double)blueMap[i]; - } - } - break; - case PHOTOMETRIC_MINISWHITE: - redMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - greenMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - blueMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - MCHECK(redMap); - MCHECK(greenMap); - MCHECK(blueMap); - for (i = 0; i < colormapSize; i++) - dRed[i] = dGreen[i] = dBlue[i] = - (double)SCALE(colormapSize - 1 - i, colormapSize - 1); - break; - case PHOTOMETRIC_MINISBLACK: - redMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - greenMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - blueMap = (uint16_t *)malloc(colormapSize * sizeof(uint16_t)); - MCHECK(redMap); - MCHECK(greenMap); - MCHECK(blueMap); - for (i = 0; i < colormapSize; i++) - dRed[i] = dGreen[i] = dBlue[i] = - (double)SCALE(i, colormapSize - 1); - break; - default: - fprintf(stderr, - "xtiff: can't display photometric interpretation type %d\n", - tfPhotometricInterpretation); - exit(0); + } + break; + case PHOTOMETRIC_MINISWHITE: + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); + for (i = 0; i < colormapSize; i++) + dRed[i] = dGreen[i] = dBlue[i] = (double) + SCALE(colormapSize-1-i, colormapSize-1); + break; + case PHOTOMETRIC_MINISBLACK: + redMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + greenMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + blueMap = (uint16 *) malloc(colormapSize * sizeof(uint16)); + MCHECK(redMap); MCHECK(greenMap); MCHECK(blueMap); + for (i = 0; i < colormapSize; i++) + dRed[i] = dGreen[i] = dBlue[i] = (double) SCALE(i, colormapSize-1); + break; + default: + fprintf(stderr, + "xtiff: can't display photometric interpretation type %d\n", + tfPhotometricInterpretation); + exit(0); } } -void SetNameLabel() +void +SetNameLabel() { char buffer[BUFSIZ]; Arg args[1]; @@ -524,7 +521,8 @@ void SetNameLabel() * Many programs get TIFF colormaps wrong. They use 8-bit colormaps instead of * 16-bit colormaps. This function is a heuristic to detect and correct this. */ -void CheckAndCorrectColormap() +void +CheckAndCorrectColormap() { register int i; @@ -532,8 +530,7 @@ void CheckAndCorrectColormap() if ((redMap[i] > 255) || (greenMap[i] > 255) || (blueMap[i] > 255)) return; - for (i = 0; i < colormapSize; i++) - { + for (i = 0; i < colormapSize; i++) { redMap[i] = SCALE(redMap[i], 255); greenMap[i] = SCALE(greenMap[i], 255); blueMap[i] = SCALE(blueMap[i], 255); @@ -541,153 +538,144 @@ void CheckAndCorrectColormap() TIFFWarning(fileName, "Assuming 8-bit colormap"); } -void SimpleGammaCorrection() +void +SimpleGammaCorrection() { register int i; register double i_gamma = 1.0 / appData.gamma; - for (i = 0; i < colormapSize; i++) - { - if (((tfPhotometricInterpretation == PHOTOMETRIC_MINISWHITE) && - (i == colormapSize - 1)) || - ((tfPhotometricInterpretation == PHOTOMETRIC_MINISBLACK) && - (i == 0))) + for (i = 0; i < colormapSize; i++) { + if (((tfPhotometricInterpretation == PHOTOMETRIC_MINISWHITE) + && (i == colormapSize - 1)) + || ((tfPhotometricInterpretation == PHOTOMETRIC_MINISBLACK) + && (i == 0))) redMap[i] = greenMap[i] = blueMap[i] = 0; - else - { + else { redMap[i] = ROUND((pow(dRed[i] / 65535.0, i_gamma) * 65535.0)); greenMap[i] = ROUND((pow(dGreen[i] / 65535.0, i_gamma) * 65535.0)); blueMap[i] = ROUND((pow(dBlue[i] / 65535.0, i_gamma) * 65535.0)); } } - free(dRed); - free(dGreen); - free(dBlue); + free(dRed); free(dGreen); free(dBlue); } -static char *classNames[] = {"StaticGray", "GrayScale", "StaticColor", - "PseudoColor", "TrueColor", "DirectColor"}; +static char* classNames[] = { + "StaticGray", + "GrayScale", + "StaticColor", + "PseudoColor", + "TrueColor", + "DirectColor" +}; /* * Current limitation: the visual is set initially by the first file. * It cannot be changed. */ -void GetVisual() +void +GetVisual() { XColor *colors = NULL; unsigned long *pixels = NULL; unsigned long i; - switch (tfImageDepth) - { - /* - * X really wants a 32-bit image with the fourth channel unused, - * but the visual structure thinks it's 24-bit. bitmap_unit is 32. - */ - case 32: - case 24: - if (SearchVisualList(24, DirectColor, &xVisual) == False) - { - fprintf(stderr, - "xtiff: 24-bit DirectColor visual not available\n"); - exit(0); - } - - colors = (XColor *)malloc(3 * colormapSize * sizeof(XColor)); - MCHECK(colors); - - for (i = 0; i < colormapSize; i++) - { - colors[i].pixel = (i << 16) + (i << 8) + i; - colors[i].red = redMap[i]; - colors[i].green = greenMap[i]; - colors[i].blue = blueMap[i]; - colors[i].flags = DoRed | DoGreen | DoBlue; - } - - xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), - xVisual, AllocAll); - XStoreColors(xDisplay, xColormap, colors, colormapSize); - break; - case 8: - case 4: - case 2: - /* - * We assume that systems with 24-bit visuals also have 8-bit - * visuals. We don't promote from 8-bit PseudoColor to 24/32 bit - * DirectColor. - */ - switch (tfPhotometricInterpretation) - { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - if (SearchVisualList((int)tfImageDepth, GrayScale, - &xVisual) == True) - break; - case PHOTOMETRIC_PALETTE: - if (SearchVisualList((int)tfImageDepth, PseudoColor, - &xVisual) == True) - break; - default: - fprintf(stderr, - "xtiff: Unsupported TIFF/X configuration\n"); - exit(0); - } - - colors = (XColor *)malloc(colormapSize * sizeof(XColor)); - MCHECK(colors); - - for (i = 0; i < colormapSize; i++) - { - colors[i].pixel = i; - colors[i].red = redMap[i]; - colors[i].green = greenMap[i]; - colors[i].blue = blueMap[i]; - colors[i].flags = DoRed | DoGreen | DoBlue; - } - - /* - * xtiff's colormap allocation is private. It does not attempt - * to detect whether any existing colormap entries are suitable - * for its use. This will cause colormap flashing. Furthermore, - * background and foreground are taken from the environment. - * For example, the foreground color may be red when the visual - * is GrayScale. If the colormap is completely populated, - * Xt will not be able to allocate fg and bg. - */ - if (tfImageDepth == 8) - xColormap = XCreateColormap( - xDisplay, RootWindow(xDisplay, xScreen), xVisual, AllocAll); - else - { - xColormap = - XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), - xVisual, AllocNone); - pixels = (unsigned long *)malloc(colormapSize * - sizeof(unsigned long)); - MCHECK(pixels); - (void)XAllocColorCells(xDisplay, xColormap, True, NULL, 0, - pixels, colormapSize); - basePixel = (unsigned char)pixels[0]; - free(pixels); - } - XStoreColors(xDisplay, xColormap, colors, colormapSize); - break; - case 1: - xImageDepth = 1; - xVisual = DefaultVisual(xDisplay, xScreen); - xColormap = DefaultColormap(xDisplay, xScreen); - break; - default: - fprintf(stderr, "xtiff: unsupported image depth %d\n", - tfImageDepth); + switch (tfImageDepth) { + /* + * X really wants a 32-bit image with the fourth channel unused, + * but the visual structure thinks it's 24-bit. bitmap_unit is 32. + */ + case 32: + case 24: + if (SearchVisualList(24, DirectColor, &xVisual) == False) { + fprintf(stderr, "xtiff: 24-bit DirectColor visual not available\n"); exit(0); + } + + colors = (XColor *) malloc(3 * colormapSize * sizeof(XColor)); + MCHECK(colors); + + for (i = 0; i < colormapSize; i++) { + colors[i].pixel = (i << 16) + (i << 8) + i; + colors[i].red = redMap[i]; + colors[i].green = greenMap[i]; + colors[i].blue = blueMap[i]; + colors[i].flags = DoRed | DoGreen | DoBlue; + } + + xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), + xVisual, AllocAll); + XStoreColors(xDisplay, xColormap, colors, colormapSize); + break; + case 8: + case 4: + case 2: + /* + * We assume that systems with 24-bit visuals also have 8-bit visuals. + * We don't promote from 8-bit PseudoColor to 24/32 bit DirectColor. + */ + switch (tfPhotometricInterpretation) { + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + if (SearchVisualList((int) tfImageDepth, GrayScale, &xVisual) == True) + break; + case PHOTOMETRIC_PALETTE: + if (SearchVisualList((int) tfImageDepth, PseudoColor, &xVisual) == True) + break; + default: + fprintf(stderr, "xtiff: Unsupported TIFF/X configuration\n"); + exit(0); + } + + colors = (XColor *) malloc(colormapSize * sizeof(XColor)); + MCHECK(colors); + + for (i = 0; i < colormapSize; i++) { + colors[i].pixel = i; + colors[i].red = redMap[i]; + colors[i].green = greenMap[i]; + colors[i].blue = blueMap[i]; + colors[i].flags = DoRed | DoGreen | DoBlue; + } + + /* + * xtiff's colormap allocation is private. It does not attempt + * to detect whether any existing colormap entries are suitable + * for its use. This will cause colormap flashing. Furthermore, + * background and foreground are taken from the environment. + * For example, the foreground color may be red when the visual + * is GrayScale. If the colormap is completely populated, + * Xt will not be able to allocate fg and bg. + */ + if (tfImageDepth == 8) + xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), + xVisual, AllocAll); + else { + xColormap = XCreateColormap(xDisplay, RootWindow(xDisplay, xScreen), + xVisual, AllocNone); + pixels = (unsigned long *) + malloc(colormapSize * sizeof(unsigned long)); + MCHECK(pixels); + (void) XAllocColorCells(xDisplay, xColormap, True, + NULL, 0, pixels, colormapSize); + basePixel = (unsigned char) pixels[0]; + free(pixels); + } + XStoreColors(xDisplay, xColormap, colors, colormapSize); + break; + case 1: + xImageDepth = 1; + xVisual = DefaultVisual(xDisplay, xScreen); + xColormap = DefaultColormap(xDisplay, xScreen); + break; + default: + fprintf(stderr, "xtiff: unsupported image depth %d\n", tfImageDepth); + exit(0); } if (appData.verbose == True) - fprintf(stderr, "%s: Using %d-bit %s visual.\n", fileName, xImageDepth, - classNames[xVisual->class]); + fprintf(stderr, "%s: Using %d-bit %s visual.\n", + fileName, xImageDepth, classNames[xVisual->class]); if (colors != NULL) free(colors); @@ -700,8 +688,7 @@ void GetVisual() if (blueMap != NULL) free(blueMap); - colors = NULL; - grayMap = redMap = greenMap = blueMap = NULL; + colors = NULL; grayMap = redMap = greenMap = blueMap = NULL; } /* @@ -710,104 +697,80 @@ void GetVisual() * basePixel was determined when XAllocColorCells() contiguously * allocated enough entries. basePixel is used below in GetTIFFImage. */ -Boolean SearchVisualList(image_depth, visual_class, visual) -int image_depth, visual_class; -Visual **visual; +Boolean +SearchVisualList(image_depth, visual_class, visual) + int image_depth, visual_class; + Visual **visual; { XVisualInfo template_visual, *visual_list, *vl; int i, n_visuals; template_visual.screen = xScreen; vl = visual_list = XGetVisualInfo(xDisplay, VisualScreenMask, - &template_visual, &n_visuals); + &template_visual, &n_visuals); - if (n_visuals == 0) - { + if (n_visuals == 0) { fprintf(stderr, "xtiff: visual list not available\n"); exit(0); } - for (i = 0; i < n_visuals; vl++, i++) - { - if ((vl->class == visual_class) && (vl->depth >= image_depth) && - (vl->visual->map_entries >= (1 << vl->depth))) - { + for (i = 0; i < n_visuals; vl++, i++) { + if ((vl->class == visual_class) && (vl->depth >= image_depth) + && (vl->visual->map_entries >= (1 << vl->depth))) { *visual = vl->visual; xImageDepth = vl->depth; xRedMask = vl->red_mask; xGreenMask = vl->green_mask; xBlueMask = vl->blue_mask; - XFree((char *)visual_list); + XFree((char *) visual_list); return True; } } - XFree((char *)visual_list); + XFree((char *) visual_list); return False; } -void GetTIFFImage() +void +GetTIFFImage() { int pixel_map[3], red_shift, green_shift, blue_shift; char *scan_line, *output_p, *input_p; - uint32_t i, j; - uint16_t s; + uint32 i, j; + uint16 s; - scan_line = (char *)malloc(tfBytesPerRow = TIFFScanlineSize(tfFile)); + scan_line = (char *) malloc(tfBytesPerRow = TIFFScanlineSize(tfFile)); MCHECK(scan_line); - if ((tfImageDepth == 32) || (tfImageDepth == 24)) - { - output_p = imageMemory = - (char *)malloc(tfImageWidth * tfImageHeight * 4); + if ((tfImageDepth == 32) || (tfImageDepth == 24)) { + output_p = imageMemory = (char *) + malloc(tfImageWidth * tfImageHeight * 4); MCHECK(imageMemory); /* * Handle different color masks for different frame buffers. */ - if (ImageByteOrder(xDisplay) == LSBFirst) - { /* DECstation 5000 */ - red_shift = pixel_map[0] = - xRedMask == 0xFF000000 - ? 3 - : (xRedMask == 0xFF0000 ? 2 : (xRedMask == 0xFF00 ? 1 : 0)); - green_shift = pixel_map[1] = - xGreenMask == 0xFF000000 - ? 3 - : (xGreenMask == 0xFF0000 ? 2 - : (xGreenMask == 0xFF00 ? 1 : 0)); - blue_shift = pixel_map[2] = - xBlueMask == 0xFF000000 - ? 3 - : (xBlueMask == 0xFF0000 ? 2 - : (xBlueMask == 0xFF00 ? 1 : 0)); - } - else - { /* Ardent */ - red_shift = pixel_map[0] = - xRedMask == 0xFF000000 - ? 0 - : (xRedMask == 0xFF0000 ? 1 : (xRedMask == 0xFF00 ? 2 : 3)); - green_shift = pixel_map[0] = - xGreenMask == 0xFF000000 - ? 0 - : (xGreenMask == 0xFF0000 ? 1 - : (xGreenMask == 0xFF00 ? 2 : 3)); - blue_shift = pixel_map[0] = - xBlueMask == 0xFF000000 - ? 0 - : (xBlueMask == 0xFF0000 ? 1 - : (xBlueMask == 0xFF00 ? 2 : 3)); + if (ImageByteOrder(xDisplay) == LSBFirst) { /* DECstation 5000 */ + red_shift = pixel_map[0] = xRedMask == 0xFF000000 ? 3 + : (xRedMask == 0xFF0000 ? 2 : (xRedMask == 0xFF00 ? 1 : 0)); + green_shift = pixel_map[1] = xGreenMask == 0xFF000000 ? 3 + : (xGreenMask == 0xFF0000 ? 2 : (xGreenMask == 0xFF00 ? 1 : 0)); + blue_shift = pixel_map[2] = xBlueMask == 0xFF000000 ? 3 + : (xBlueMask == 0xFF0000 ? 2 : (xBlueMask == 0xFF00 ? 1 : 0)); + } else { /* Ardent */ + red_shift = pixel_map[0] = xRedMask == 0xFF000000 ? 0 + : (xRedMask == 0xFF0000 ? 1 : (xRedMask == 0xFF00 ? 2 : 3)); + green_shift = pixel_map[0] = xGreenMask == 0xFF000000 ? 0 + : (xGreenMask == 0xFF0000 ? 1 : (xGreenMask == 0xFF00 ? 2 : 3)); + blue_shift = pixel_map[0] = xBlueMask == 0xFF000000 ? 0 + : (xBlueMask == 0xFF0000 ? 1 : (xBlueMask == 0xFF00 ? 2 : 3)); } - if (tfPlanarConfiguration == PLANARCONFIG_CONTIG) - { - for (i = 0; i < tfImageHeight; i++) - { + if (tfPlanarConfiguration == PLANARCONFIG_CONTIG) { + for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) break; - for (input_p = scan_line, j = 0; j < tfImageWidth; j++) - { + for (input_p = scan_line, j = 0; j < tfImageWidth; j++) { *(output_p + red_shift) = *input_p++; *(output_p + green_shift) = *input_p++; *(output_p + blue_shift) = *input_p++; @@ -816,42 +779,32 @@ void GetTIFFImage() input_p++; } } - } - else - { - for (s = 0; s < tfSamplesPerPixel; s++) - { - if (s == 3) /* skip the fourth channel */ + } else { + for (s = 0; s < tfSamplesPerPixel; s++) { + if (s == 3) /* skip the fourth channel */ continue; - for (i = 0; i < tfImageHeight; i++) - { + for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, s) < 0) break; input_p = scan_line; - output_p = - imageMemory + (i * tfImageWidth * 4) + pixel_map[s]; + output_p = imageMemory + (i*tfImageWidth*4) + pixel_map[s]; for (j = 0; j < tfImageWidth; j++, output_p += 4) *output_p = *input_p++; } } } - } - else - { - if (xImageDepth == tfImageDepth) - { - output_p = imageMemory = - (char *)malloc(tfBytesPerRow * tfImageHeight); + } else { + if (xImageDepth == tfImageDepth) { + output_p = imageMemory = (char *) + malloc(tfBytesPerRow * tfImageHeight); MCHECK(imageMemory); for (i = 0; i < tfImageHeight; i++, output_p += tfBytesPerRow) if (TIFFReadScanline(tfFile, output_p, i, 0) < 0) break; - } - else if ((xImageDepth == 8) && (tfImageDepth == 4)) - { - output_p = imageMemory = - (char *)malloc(tfBytesPerRow * 2 * tfImageHeight + 2); + } else if ((xImageDepth == 8) && (tfImageDepth == 4)) { + output_p = imageMemory = (char *) + malloc(tfBytesPerRow * 2 * tfImageHeight + 2); MCHECK(imageMemory); /* @@ -859,67 +812,52 @@ void GetTIFFImage() * This is handled very simply by recalculating the start point at * each scanline and padding imageMemory a little at the end. */ - for (i = 0; i < tfImageHeight; i++) - { + for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) break; output_p = &imageMemory[i * tfImageWidth]; input_p = scan_line; - for (j = 0; j < tfImageWidth; j += 2, input_p++) - { + for (j = 0; j < tfImageWidth; j += 2, input_p++) { *output_p++ = (*input_p >> 4) + basePixel; *output_p++ = (*input_p & 0xf) + basePixel; } } - } - else if ((xImageDepth == 8) && (tfImageDepth == 2)) - { - output_p = imageMemory = - (char *)malloc(tfBytesPerRow * 4 * tfImageHeight + 4); + } else if ((xImageDepth == 8) && (tfImageDepth == 2)) { + output_p = imageMemory = (char *) + malloc(tfBytesPerRow * 4 * tfImageHeight + 4); MCHECK(imageMemory); - for (i = 0; i < tfImageHeight; i++) - { + for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) break; output_p = &imageMemory[i * tfImageWidth]; input_p = scan_line; - for (j = 0; j < tfImageWidth; j += 4, input_p++) - { + for (j = 0; j < tfImageWidth; j += 4, input_p++) { *output_p++ = (*input_p >> 6) + basePixel; *output_p++ = ((*input_p >> 4) & 3) + basePixel; *output_p++ = ((*input_p >> 2) & 3) + basePixel; *output_p++ = (*input_p & 3) + basePixel; } } - } - else if ((xImageDepth == 4) && (tfImageDepth == 2)) - { - output_p = imageMemory = - (char *)malloc(tfBytesPerRow * 2 * tfImageHeight + 2); + } else if ((xImageDepth == 4) && (tfImageDepth == 2)) { + output_p = imageMemory = (char *) + malloc(tfBytesPerRow * 2 * tfImageHeight + 2); MCHECK(imageMemory); - for (i = 0; i < tfImageHeight; i++) - { + for (i = 0; i < tfImageHeight; i++) { if (TIFFReadScanline(tfFile, scan_line, i, 0) < 0) break; output_p = &imageMemory[i * tfBytesPerRow * 2]; input_p = scan_line; - for (j = 0; j < tfImageWidth; j += 4, input_p++) - { - *output_p++ = - (((*input_p >> 6) << 4) | ((*input_p >> 4) & 3)) + - basePixel; - *output_p++ = - ((((*input_p >> 2) & 3) << 4) | (*input_p & 3)) + - basePixel; + for (j = 0; j < tfImageWidth; j += 4, input_p++) { + *output_p++ = (((*input_p>>6) << 4) + | ((*input_p >> 4) & 3)) + basePixel; + *output_p++ = ((((*input_p>>2) & 3) << 4) + | (*input_p & 3)) + basePixel; } } - } - else - { - fprintf( - stderr, + } else { + fprintf(stderr, "xtiff: can't handle %d-bit TIFF file on an %d-bit display\n", tfImageDepth, xImageDepth); exit(0); @@ -929,7 +867,8 @@ void GetTIFFImage() free(scan_line); } -void CreateXImage() +void +CreateXImage() { XGCValues gc_values; GC bitmap_gc; @@ -938,9 +877,9 @@ void CreateXImage() grabX = grabY = -1; xImage = XCreateImage(xDisplay, xVisual, xImageDepth, - xImageDepth == 1 ? XYBitmap : ZPixmap, /* offset */ 0, - (char *)imageMemory, tfImageWidth, tfImageHeight, - /* bitmap_pad */ 8, /* bytes_per_line */ 0); + xImageDepth == 1 ? XYBitmap : ZPixmap, /* offset */ 0, + (char *) imageMemory, tfImageWidth, tfImageHeight, + /* bitmap_pad */ 8, /* bytes_per_line */ 0); /* * libtiff converts LSB data into MSB but doesn't change the FillOrder tag. @@ -955,28 +894,22 @@ void CreateXImage() */ gc_values.function = GXcopy; gc_values.plane_mask = AllPlanes; - if (tfPhotometricInterpretation == PHOTOMETRIC_MINISBLACK) - { + if (tfPhotometricInterpretation == PHOTOMETRIC_MINISBLACK) { gc_values.foreground = XWhitePixel(xDisplay, xScreen); gc_values.background = XBlackPixel(xDisplay, xScreen); - } - else - { + } else { gc_values.foreground = XBlackPixel(xDisplay, xScreen); gc_values.background = XWhitePixel(xDisplay, xScreen); } xWinGc = XCreateGC(xDisplay, XtWindow(shellWidget), - GCFunction | GCPlaneMask | GCForeground | GCBackground, - &gc_values); + GCFunction | GCPlaneMask | GCForeground | GCBackground, &gc_values); /* * create the pixmap and load the image */ - if (appData.usePixmap == True) - { - xImagePixmap = - XCreatePixmap(xDisplay, RootWindow(xDisplay, xScreen), - xImage->width, xImage->height, xImageDepth); + if (appData.usePixmap == True) { + xImagePixmap = XCreatePixmap(xDisplay, RootWindow(xDisplay, xScreen), + xImage->width, xImage->height, xImageDepth); /* * According to the O'Reilly X Protocol Reference Manual, page 53, @@ -984,78 +917,89 @@ void CreateXImage() * of depth one might not be supported." Therefore we create a pixmap * of depth one and use XCopyPlane(). This is idiomatic. */ - if (xImageDepth == 1) - { /* just pass the bits through */ - gc_values.foreground = 1; /* foreground describes set bits */ - gc_values.background = 0; /* background describes clear bits */ + if (xImageDepth == 1) { /* just pass the bits through */ + gc_values.foreground = 1; /* foreground describes set bits */ + gc_values.background = 0; /* background describes clear bits */ bitmap_gc = XCreateGC(xDisplay, xImagePixmap, - GCForeground | GCBackground, &gc_values); - XPutImage(xDisplay, xImagePixmap, bitmap_gc, xImage, 0, 0, 0, 0, - xImage->width, xImage->height); - } - else - XPutImage(xDisplay, xImagePixmap, xWinGc, xImage, 0, 0, 0, 0, - xImage->width, xImage->height); + GCForeground | GCBackground, &gc_values); + XPutImage(xDisplay, xImagePixmap, bitmap_gc, xImage, + 0, 0, 0, 0, xImage->width, xImage->height); + } else + XPutImage(xDisplay, xImagePixmap, xWinGc, xImage, + 0, 0, 0, 0, xImage->width, xImage->height); XDestroyImage(xImage); free(imageMemory); } } -XtCallbackProc SelectProc(w, unused_1, unused_2) -Widget w; -caddr_t unused_1; -caddr_t unused_2; +XtCallbackProc +SelectProc(w, unused_1, unused_2) + Widget w; + caddr_t unused_1; + caddr_t unused_2; { XawListReturnStruct *list_return; list_return = XawListShowCurrent(w); - switch (list_return->list_index) - { - case ButtonQuit: - QuitProc(); - break; - case ButtonPreviousPage: - PreviousProc(); - break; - case ButtonNextPage: - NextProc(); - break; - default: - fprintf(stderr, "error in SelectProc\n"); - exit(0); + switch (list_return->list_index) { + case ButtonQuit: + QuitProc(); + break; + case ButtonPreviousPage: + PreviousProc(); + break; + case ButtonNextPage: + NextProc(); + break; + default: + fprintf(stderr, "error in SelectProc\n"); + exit(0); } XawListUnhighlight(w); } -void QuitProc(void) { exit(0); } +void +QuitProc(void) +{ + exit(0); +} -void NextProc() { PageProc(ButtonNextPage); } +void +NextProc() +{ + PageProc(ButtonNextPage); +} -void PreviousProc() { PageProc(ButtonPreviousPage); } +void +PreviousProc() +{ + PageProc(ButtonPreviousPage); +} -void PageProc(direction) int direction; +void +PageProc(direction) + int direction; { XEvent fake_event; Arg args[4]; - switch (direction) - { - case ButtonPreviousPage: - if (tfDirectory > 0) - TIFFSetDirectory(tfFile, --tfDirectory); - else - return; - break; - case ButtonNextPage: - if (TIFFReadDirectory(tfFile) == True) - tfDirectory++; - else - return; - break; - default: - fprintf(stderr, "error in PageProc\n"); - exit(0); + switch (direction) { + case ButtonPreviousPage: + if (tfDirectory > 0) + TIFFSetDirectory(tfFile, --tfDirectory); + else + return; + break; + case ButtonNextPage: + if (TIFFReadDirectory(tfFile) == True) + tfDirectory++; + else + return; + break; + default: + fprintf(stderr, "error in PageProc\n"); + exit(0); } xOffset = yOffset = 0; @@ -1092,23 +1036,24 @@ void PageProc(direction) int direction; fake_event.type = Expose; fake_event.xexpose.x = fake_event.xexpose.y = 0; - fake_event.xexpose.width = tfImageWidth; /* the window will clip */ + fake_event.xexpose.width = tfImageWidth; /* the window will clip */ fake_event.xexpose.height = tfImageHeight; EventProc(imageWidget, NULL, &fake_event); } -void EventProc(widget, unused, event) Widget widget; -caddr_t unused; -XEvent *event; +void +EventProc(widget, unused, event) + Widget widget; + caddr_t unused; + XEvent *event; { int ih, iw, ww, wh, sx, sy, w, h, dx, dy; Dimension w_width, w_height; XEvent next_event; Arg args[2]; - if (event->type == MappingNotify) - { - XRefreshKeyboardMapping((XMappingEvent *)event); + if (event->type == MappingNotify) { + XRefreshKeyboardMapping((XMappingEvent *) event); return; } @@ -1119,15 +1064,14 @@ XEvent *event; if (event->xbutton.button != Button1) return; - iw = tfImageWidth; /* avoid sign problems */ + iw = tfImageWidth; /* avoid sign problems */ ih = tfImageHeight; /* * The grabX and grabY variables record where the user grabbed the image. * They also record whether the mouse button is down or not. */ - if (event->type == ButtonPress) - { + if (event->type == ButtonPress) { grabX = event->xbutton.x; grabY = event->xbutton.y; return; @@ -1145,131 +1089,121 @@ XEvent *event; XtGetValues(listWidget, args, 2); wh -= w_height; - switch (event->type) - { - case Expose: - dx = event->xexpose.x; - dy = event->xexpose.y; - sx = dx + xOffset; - sy = dy + yOffset; - w = MIN(event->xexpose.width, iw); - h = MIN(event->xexpose.height, ih); - break; - case KeyPress: - if ((grabX >= 0) || (grabY >= 0)) /* Mouse button is still down */ + switch (event->type) { + case Expose: + dx = event->xexpose.x; + dy = event->xexpose.y; + sx = dx + xOffset; + sy = dy + yOffset; + w = MIN(event->xexpose.width, iw); + h = MIN(event->xexpose.height, ih); + break; + case KeyPress: + if ((grabX >= 0) || (grabY >= 0)) /* Mouse button is still down */ + return; + switch (XLookupKeysym((XKeyEvent *) event, /* KeySyms index */ 0)) { + case XK_Up: + if (ih < wh) /* Don't scroll if the window fits the image. */ return; - switch (XLookupKeysym((XKeyEvent *)event, /* KeySyms index */ 0)) - { - case XK_Up: - if (ih < - wh) /* Don't scroll if the window fits the image. */ - return; - sy = yOffset + appData.translate; - sy = MIN(ih - wh, sy); - if (sy == - yOffset) /* Filter redundant stationary refreshes. */ - return; - yOffset = sy; - sx = xOffset; - dx = dy = 0; - w = ww; - h = wh; - break; - case XK_Down: - if (ih < wh) - return; - sy = yOffset - appData.translate; - sy = MAX(sy, 0); - if (sy == yOffset) - return; - yOffset = sy; - sx = xOffset; - dx = dy = 0; - w = ww; - h = wh; - break; - case XK_Left: - if (iw < ww) - return; - sx = xOffset + appData.translate; - sx = MIN(iw - ww, sx); - if (sx == xOffset) - return; - xOffset = sx; - sy = yOffset; - dx = dy = 0; - w = ww; - h = wh; - break; - case XK_Right: - if (iw < ww) - return; - sx = xOffset - appData.translate; - sx = MAX(sx, 0); - if (sx == xOffset) - return; - xOffset = sx; - sy = yOffset; - dx = dy = 0; - w = ww; - h = wh; - break; - default: - return; - } - break; - case MotionNotify: - /* - * MotionEvent compression. Ignore multiple motion events. - * Ignore motion events if the mouse button is up. - */ - if (XPending(xDisplay)) /* Xlib doesn't flush the output buffer */ - if (XtPeekEvent(&next_event)) - if (next_event.type == MotionNotify) - return; - if ((grabX < 0) || (grabY < 0)) - return; - sx = xOffset + grabX - (int)event->xmotion.x; - if (sx >= (iw - ww)) /* clamp x motion but allow y motion */ - sx = iw - ww; - sx = MAX(sx, 0); - sy = yOffset + grabY - (int)event->xmotion.y; - if (sy >= (ih - wh)) /* clamp y motion but allow x motion */ - sy = ih - wh; - sy = MAX(sy, 0); - if ((sx == xOffset) && (sy == yOffset)) + sy = yOffset + appData.translate; + sy = MIN(ih - wh, sy); + if (sy == yOffset) /* Filter redundant stationary refreshes. */ return; + yOffset = sy; + sx = xOffset; dx = dy = 0; - w = ww; - h = wh; + w = ww; h = wh; + break; + case XK_Down: + if (ih < wh) + return; + sy = yOffset - appData.translate; + sy = MAX(sy, 0); + if (sy == yOffset) + return; + yOffset = sy; + sx = xOffset; + dx = dy = 0; + w = ww; h = wh; + break; + case XK_Left: + if (iw < ww) + return; + sx = xOffset + appData.translate; + sx = MIN(iw - ww, sx); + if (sx == xOffset) + return; + xOffset = sx; + sy = yOffset; + dx = dy = 0; + w = ww; h = wh; + break; + case XK_Right: + if (iw < ww) + return; + sx = xOffset - appData.translate; + sx = MAX(sx, 0); + if (sx == xOffset) + return; + xOffset = sx; + sy = yOffset; + dx = dy = 0; + w = ww; h = wh; break; - case ButtonRelease: - xOffset = xOffset + grabX - (int)event->xbutton.x; - xOffset = MIN(iw - ww, xOffset); - xOffset = MAX(xOffset, 0); - yOffset = yOffset + grabY - (int)event->xbutton.y; - yOffset = MIN(ih - wh, yOffset); - yOffset = MAX(yOffset, 0); - grabX = grabY = -1; default: return; + } + break; + case MotionNotify: + /* + * MotionEvent compression. Ignore multiple motion events. + * Ignore motion events if the mouse button is up. + */ + if (XPending(xDisplay)) /* Xlib doesn't flush the output buffer */ + if (XtPeekEvent(&next_event)) + if (next_event.type == MotionNotify) + return; + if ((grabX < 0) || (grabY < 0)) + return; + sx = xOffset + grabX - (int) event->xmotion.x; + if (sx >= (iw - ww)) /* clamp x motion but allow y motion */ + sx = iw - ww; + sx = MAX(sx, 0); + sy = yOffset + grabY - (int) event->xmotion.y; + if (sy >= (ih - wh)) /* clamp y motion but allow x motion */ + sy = ih - wh; + sy = MAX(sy, 0); + if ((sx == xOffset) && (sy == yOffset)) + return; + dx = dy = 0; + w = ww; h = wh; + break; + case ButtonRelease: + xOffset = xOffset + grabX - (int) event->xbutton.x; + xOffset = MIN(iw - ww, xOffset); + xOffset = MAX(xOffset, 0); + yOffset = yOffset + grabY - (int) event->xbutton.y; + yOffset = MIN(ih - wh, yOffset); + yOffset = MAX(yOffset, 0); + grabX = grabY = -1; + default: + return; } - if (appData.usePixmap == True) - { + if (appData.usePixmap == True) { if (xImageDepth == 1) - XCopyPlane(xDisplay, xImagePixmap, XtWindow(widget), xWinGc, sx, sy, - w, h, dx, dy, 1); + XCopyPlane(xDisplay, xImagePixmap, XtWindow(widget), + xWinGc, sx, sy, w, h, dx, dy, 1); else - XCopyArea(xDisplay, xImagePixmap, XtWindow(widget), xWinGc, sx, sy, - w, h, dx, dy); - } - else - XPutImage(xDisplay, XtWindow(widget), xWinGc, xImage, sx, sy, dx, dy, w, - h); + XCopyArea(xDisplay, xImagePixmap, XtWindow(widget), + xWinGc, sx, sy, w, h, dx, dy); + } else + XPutImage(xDisplay, XtWindow(widget), xWinGc, xImage, + sx, sy, dx, dy, w, h); } -void ResizeProc() +void +ResizeProc() { Dimension w_width, w_height; int xo, yo, ww, wh; @@ -1287,20 +1221,18 @@ void ResizeProc() XtGetValues(listWidget, args, 2); wh -= w_height; - xo = xOffset; - yo = yOffset; + xo = xOffset; yo = yOffset; if ((xOffset + ww) >= tfImageWidth) - xOffset = MAX((int)tfImageWidth - ww, 0); + xOffset = MAX((int) tfImageWidth - ww, 0); if ((yOffset + wh) >= tfImageHeight) - yOffset = MAX((int)tfImageHeight - wh, 0); + yOffset = MAX((int) tfImageHeight - wh, 0); /* * Send an ExposeEvent if the origin changed. * We have to do this because of the use and semantics of bit gravity. */ - if ((xo != xOffset) || (yo != yOffset)) - { + if ((xo != xOffset) || (yo != yOffset)) { fake_event.type = Expose; fake_event.xexpose.x = fake_event.xexpose.y = 0; fake_event.xexpose.width = tfImageWidth; @@ -1309,20 +1241,20 @@ void ResizeProc() } } -int XTiffErrorHandler(display, error_event) -Display *display; -XErrorEvent *error_event; +int +XTiffErrorHandler(display, error_event) + Display *display; + XErrorEvent *error_event; { char message[80]; /* * Some X servers limit the size of pixmaps. */ - if ((error_event->error_code == BadAlloc) && - (error_event->request_code == X_CreatePixmap)) + if ((error_event->error_code == BadAlloc) + && (error_event->request_code == X_CreatePixmap)) fprintf(stderr, "xtiff: requested pixmap too big for display\n"); - else - { + else { XGetErrorText(display, error_event->error_code, message, 80); fprintf(stderr, "xtiff: error code %s\n", message); } @@ -1330,7 +1262,8 @@ XErrorEvent *error_event; exit(0); } -void Usage() +void +Usage() { fprintf(stderr, "Usage xtiff: [options] tiff-file\n"); fprintf(stderr, "\tstandard Xt options\n"); @@ -1343,3 +1276,13 @@ void Usage() fprintf(stderr, "\t[-verbose (True | False)]\n"); exit(0); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/xtifficon.h b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/xtifficon.h index 0ce5e99f7..3eac48efc 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/xtifficon.h +++ b/thirdparty/SDL2_image/external/libtiff/contrib/dbs/xtiff/xtifficon.h @@ -1,14 +1,21 @@ #define xtifficon_width 32 #define xtifficon_height 32 static char xtifficon_bits[] = { - 0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x7e, 0xc0, 0xfc, 0x03, 0x7e, 0x60, - 0xf8, 0x07, 0x06, 0x30, 0xf8, 0x07, 0x1e, 0x18, 0xf0, 0x0f, 0x1e, 0x0c, - 0xe0, 0x1f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x03, - 0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00, - 0x00, 0xfe, 0x31, 0x7e, 0x7e, 0xfc, 0x33, 0x7e, 0x7e, 0xf8, 0x1b, 0x06, - 0x18, 0xf0, 0x0d, 0x1e, 0x18, 0xf0, 0x0e, 0x1e, 0x18, 0x60, 0x1f, 0x06, - 0x18, 0xb0, 0x3f, 0x06, 0x18, 0x98, 0x7f, 0x06, 0x18, 0x98, 0x7f, 0x00, - 0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x63, 0xfc, 0x03, - 0x80, 0x61, 0xfc, 0x03, 0xc0, 0x60, 0xf8, 0x07, 0xc0, 0x60, 0xf0, 0x0f, - 0x60, 0x60, 0xe0, 0x1f, 0x30, 0x60, 0xe0, 0x1f, 0x18, 0x60, 0xc0, 0x3f, - 0x0c, 0x60, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff}; + 0xff, 0x00, 0x00, 0xc0, 0xfe, 0x01, 0x7e, 0xc0, 0xfc, 0x03, 0x7e, 0x60, + 0xf8, 0x07, 0x06, 0x30, 0xf8, 0x07, 0x1e, 0x18, 0xf0, 0x0f, 0x1e, 0x0c, + 0xe0, 0x1f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x06, 0xc0, 0x3f, 0x06, 0x03, + 0x80, 0x7f, 0x80, 0x01, 0x00, 0xff, 0xc0, 0x00, 0x00, 0xfe, 0x61, 0x00, + 0x00, 0xfe, 0x31, 0x7e, 0x7e, 0xfc, 0x33, 0x7e, 0x7e, 0xf8, 0x1b, 0x06, + 0x18, 0xf0, 0x0d, 0x1e, 0x18, 0xf0, 0x0e, 0x1e, 0x18, 0x60, 0x1f, 0x06, + 0x18, 0xb0, 0x3f, 0x06, 0x18, 0x98, 0x7f, 0x06, 0x18, 0x98, 0x7f, 0x00, + 0x00, 0x0c, 0xff, 0x00, 0x00, 0x06, 0xfe, 0x01, 0x00, 0x63, 0xfc, 0x03, + 0x80, 0x61, 0xfc, 0x03, 0xc0, 0x60, 0xf8, 0x07, 0xc0, 0x60, 0xf0, 0x0f, + 0x60, 0x60, 0xe0, 0x1f, 0x30, 0x60, 0xe0, 0x1f, 0x18, 0x60, 0xc0, 0x3f, + 0x0c, 0x60, 0x80, 0x7f, 0x06, 0x00, 0x00, 0xff}; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/CMakeLists.txt index d13319c6a..35cc26126 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/CMakeLists.txt +++ b/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/CMakeLists.txt @@ -22,5 +22,14 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +extra_dist( + README + test.iptc + test.txt) + +include_directories(${PROJECT_SOURCE_DIR}/libtiff + ${PROJECT_BINARY_DIR}/libtiff + ${CMAKE_CURRENT_BINARY_DIR}) + add_executable(iptcutil iptcutil.c) -target_link_libraries(iptcutil tiff tiff_port) +target_link_libraries(iptcutil tiff port) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/Makefile.am index ca79306ad..4aabe2e9c 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/Makefile.am @@ -31,9 +31,7 @@ EXTRA_DIST = \ test.iptc \ test.txt -if TIFF_CONTRIB noinst_PROGRAMS = iptcutil -endif iptcutil_SOURCES = iptcutil.c iptcutil_LDADD = $(LIBTIFF) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/iptcutil.c b/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/iptcutil.c index 49d4fcd5b..920064997 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/iptcutil.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/iptcutil/iptcutil.c @@ -1,23 +1,23 @@ #include "tif_config.h" -#include #include #include #include +#include #ifdef HAVE_STRINGS_H -#include +# include #endif #ifdef HAVE_IO_H -#include +# include #endif #ifdef HAVE_FCNTL_H -#include +# include #endif -#ifdef _WIN32 +#ifdef WIN32 #define STRNICMP strnicmp #else #define STRNICMP strncasecmp @@ -25,63 +25,67 @@ typedef struct _tag_spec { - short id; + short + id; - char *name; + char + *name; } tag_spec; -static tag_spec tags[] = {{5, "Image Name"}, - {7, "Edit Status"}, - {10, "Priority"}, - {15, "Category"}, - {20, "Supplemental Category"}, - {22, "Fixture Identifier"}, - {25, "Keyword"}, - {30, "Release Date"}, - {35, "Release Time"}, - {40, "Special Instructions"}, - {45, "Reference Service"}, - {47, "Reference Date"}, - {50, "Reference Number"}, - {55, "Created Date"}, - {60, "Created Time"}, - {65, "Originating Program"}, - {70, "Program Version"}, - {75, "Object Cycle"}, - {80, "Byline"}, - {85, "Byline Title"}, - {90, "City"}, - {95, "Province State"}, - {100, "Country Code"}, - {101, "Country"}, - {103, "Original Transmission Reference"}, - {105, "Headline"}, - {110, "Credit"}, - {115, "Source"}, - {116, "Copyright String"}, - {120, "Caption"}, - {121, "Local Caption"}, - {122, "Caption Writer"}, - {200, "Custom Field 1"}, - {201, "Custom Field 2"}, - {202, "Custom Field 3"}, - {203, "Custom Field 4"}, - {204, "Custom Field 5"}, - {205, "Custom Field 6"}, - {206, "Custom Field 7"}, - {207, "Custom Field 8"}, - {208, "Custom Field 9"}, - {209, "Custom Field 10"}, - {210, "Custom Field 11"}, - {211, "Custom Field 12"}, - {212, "Custom Field 13"}, - {213, "Custom Field 14"}, - {214, "Custom Field 15"}, - {215, "Custom Field 16"}, - {216, "Custom Field 17"}, - {217, "Custom Field 18"}, - {218, "Custom Field 19"}, - {219, "Custom Field 20"}}; +static tag_spec tags[] = { + { 5,"Image Name" }, + { 7,"Edit Status" }, + { 10,"Priority" }, + { 15,"Category" }, + { 20,"Supplemental Category" }, + { 22,"Fixture Identifier" }, + { 25,"Keyword" }, + { 30,"Release Date" }, + { 35,"Release Time" }, + { 40,"Special Instructions" }, + { 45,"Reference Service" }, + { 47,"Reference Date" }, + { 50,"Reference Number" }, + { 55,"Created Date" }, + { 60,"Created Time" }, + { 65,"Originating Program" }, + { 70,"Program Version" }, + { 75,"Object Cycle" }, + { 80,"Byline" }, + { 85,"Byline Title" }, + { 90,"City" }, + { 95,"Province State" }, + { 100,"Country Code" }, + { 101,"Country" }, + { 103,"Original Transmission Reference" }, + { 105,"Headline" }, + { 110,"Credit" }, + { 115,"Source" }, + { 116,"Copyright String" }, + { 120,"Caption" }, + { 121,"Local Caption" }, + { 122,"Caption Writer" }, + { 200,"Custom Field 1" }, + { 201,"Custom Field 2" }, + { 202,"Custom Field 3" }, + { 203,"Custom Field 4" }, + { 204,"Custom Field 5" }, + { 205,"Custom Field 6" }, + { 206,"Custom Field 7" }, + { 207,"Custom Field 8" }, + { 208,"Custom Field 9" }, + { 209,"Custom Field 10" }, + { 210,"Custom Field 11" }, + { 211,"Custom Field 12" }, + { 212,"Custom Field 13" }, + { 213,"Custom Field 14" }, + { 214,"Custom Field 15" }, + { 215,"Custom Field 16" }, + { 216,"Custom Field 17" }, + { 217,"Custom Field 18" }, + { 218,"Custom Field 19" }, + { 219,"Custom Field 20" } +}; /* * We format the output using HTML conventions @@ -89,50 +93,52 @@ static tag_spec tags[] = {{5, "Image Name"}, */ void formatString(FILE *ofile, const char *s, int len) { - putc('"', ofile); - for (; len > 0; --len, ++s) - { - int c = *s; - switch (c) - { - case '&': - fputs("&", ofile); - break; + putc('"', ofile); + for (; len > 0; --len, ++s) { + int c = *s; + switch (c) { + case '&': + fputs("&", ofile); + break; #ifdef HANDLE_GT_LT - case '<': - fputs("<", ofile); - break; - case '>': - fputs(">", ofile); - break; + case '<': + fputs("<", ofile); + break; + case '>': + fputs(">", ofile); + break; #endif - case '"': - fputs(""", ofile); - break; - default: - if (iscntrl(c)) - fprintf(ofile, "&#%d;", c); - else - putc(*s, ofile); - break; - } + case '"': + fputs(""", ofile); + break; + default: + if (iscntrl(c)) + fprintf(ofile, "&#%d;", c); + else + putc(*s, ofile); + break; } - fputs("\"\n", ofile); + } + fputs("\"\n", ofile); } typedef struct _html_code { - short len; - const char *code, val; + short + len; + const char + *code, + val; } html_code; static html_code html_codes[] = { #ifdef HANDLE_GT_LT - {4, "<", '<'}, - {4, ">", '>'}, + { 4,"<",'<' }, + { 4,">",'>' }, #endif - {5, "&", '&'}, - {6, """, '"'}}; + { 5,"&",'&' }, + { 6,""",'"' } +}; /* * This routine converts HTML escape sequence @@ -141,577 +147,620 @@ static html_code html_codes[] = { */ int convertHTMLcodes(char *s, int len) { - if (len <= 0 || s == (char *)NULL || *s == '\0') - return 0; - - if (s[1] == '#') - { - int val, o; - - if (sscanf(s, "&#%d;", &val) == 1) - { - o = 3; - while (s[o] != ';') - { - o++; - if (o > 5) - break; - } - if (o < 5) - strcpy(s + 1, s + 1 + o); - *s = val; - return o; - } - } - else - { - int i, codes = sizeof(html_codes) / sizeof(html_code); - - for (i = 0; i < codes; i++) - { - if (html_codes[i].len <= len) - if (STRNICMP(s, html_codes[i].code, html_codes[i].len) == 0) - { - strcpy(s + 1, s + html_codes[i].len); - *s = html_codes[i].val; - return html_codes[i].len - 1; - } - } - } - + if (len <=0 || s==(char*)NULL || *s=='\0') return 0; + + if (s[1] == '#') + { + int val, o; + + if (sscanf(s,"&#%d;",&val) == 1) + { + o = 3; + while (s[o] != ';') + { + o++; + if (o > 5) + break; + } + if (o < 5) + strcpy(s+1, s+1+o); + *s = val; + return o; + } + } + else + { + int + i, + codes = sizeof(html_codes) / sizeof(html_code); + + for (i=0; i < codes; i++) + { + if (html_codes[i].len <= len) + if (STRNICMP(s, html_codes[i].code, html_codes[i].len) == 0) + { + strcpy(s+1, s+html_codes[i].len); + *s = html_codes[i].val; + return html_codes[i].len-1; + } + } + } + + return 0; } int formatIPTC(FILE *ifile, FILE *ofile) { - unsigned int foundiptc, tagsfound; + unsigned int + foundiptc, + tagsfound; - char *readable, *str; + char + *readable, + *str; - long tagindx, taglen; + long + tagindx, + taglen; - int i, tagcount = sizeof(tags) / sizeof(tag_spec); + int + i, + tagcount = sizeof(tags) / sizeof(tag_spec); - int c, dataset, recnum; + int + c, + dataset, + recnum; - foundiptc = 0; /* found the IPTC-Header */ - tagsfound = 0; /* number of tags found */ + foundiptc = 0; /* found the IPTC-Header */ + tagsfound = 0; /* number of tags found */ - c = getc(ifile); - while (c != EOF) + c = getc(ifile); + while (c != EOF) { - if (c == 0x1c) - foundiptc = 1; - else + if (c == 0x1c) + foundiptc = 1; + else { - if (foundiptc) + if (foundiptc) { + return -1; + } + else + { + c = getc(ifile); + continue; + } + } + + /* we found the 0x1c tag and now grab the dataset and record number tags */ + dataset = getc(ifile); + if ((char) dataset == EOF) + return -1; + recnum = getc(ifile); + if ((char) recnum == EOF) + return -1; + /* try to match this record to one of the ones in our named table */ + for (i=0; i< tagcount; i++) + { + if (tags[i].id == recnum) + break; + } + if (i < tagcount) + readable = tags[i].name; + else + readable = ""; + + /* then we decode the length of the block that follows - long or short fmt */ + c = getc(ifile); + if (c == EOF) + return 0; + if (c & (unsigned char) 0x80) + { + unsigned char + buffer[4]; + + for (i=0; i<4; i++) + { + c = getc(ifile); + if (c == EOF) return -1; + buffer[i] = c; } - else - { - c = getc(ifile); - continue; - } + taglen = (((long) buffer[ 0 ]) << 24) | + (((long) buffer[ 1 ]) << 16) | + (((long) buffer[ 2 ]) << 8) | + (((long) buffer[ 3 ])); } + else + { + int + x = c; - /* we found the 0x1c tag and now grab the dataset and record number tags - */ - dataset = getc(ifile); - if (dataset == EOF) + taglen = x << 8; + x = getc(ifile); + if (x == EOF) return -1; - recnum = getc(ifile); - if (recnum == EOF) - return -1; - /* try to match this record to one of the ones in our named table */ - for (i = 0; i < tagcount; i++) - { - if (tags[i].id == recnum) - break; + taglen |= (long) x; } - if (i < tagcount) - readable = tags[i].name; - else - readable = ""; - - /* then we decode the length of the block that follows - long or short - * fmt */ - c = getc(ifile); - if (c == EOF) - return 0; - if (c & (unsigned char)0x80) + /* Place limits on tag length */ + if ((taglen <= 0) || (taglen > 1048576)) { - unsigned char buffer[4]; - - for (i = 0; i < 4; i++) + printf("Inappropriate IPTC tag length %ld\n",taglen); + return -1; + } + /* make a buffer to hold the tag data and snag it from the input stream */ + str = (char *) malloc((unsigned int) (taglen+1)); + if (str == (char *) NULL) + { + printf("Memory allocation failed"); + return 0; + } + for (tagindx=0; tagindx 1048576)) - { - printf("Inappropriate IPTC tag length %ld\n", taglen); - return -1; - } - /* make a buffer to hold the tag data and snag it from the input stream - */ - str = (char *)malloc((unsigned int)(taglen + 1)); - if (str == (char *)NULL) - { - printf("Memory allocation failed"); - return 0; - } - for (tagindx = 0; tagindx < taglen; tagindx++) - { - c = getc(ifile); - if (c == EOF) - { - free(str); - return -1; - } - str[tagindx] = c; - } - str[taglen] = 0; + /* now finish up by formatting this binary data into ASCII equivalent */ + if (strlen(readable) > 0) + fprintf(ofile, "%d#%d#%s=",(unsigned int)dataset, (unsigned int) recnum, readable); + else + fprintf(ofile, "%d#%d=",(unsigned int)dataset, (unsigned int) recnum); + formatString( ofile, str, taglen ); + free(str); - /* now finish up by formatting this binary data into ASCII equivalent */ - if (strlen(readable) > 0) - fprintf(ofile, "%d#%d#%s=", (unsigned int)dataset, - (unsigned int)recnum, readable); - else - fprintf(ofile, "%d#%d=", (unsigned int)dataset, - (unsigned int)recnum); - formatString(ofile, str, taglen); - free(str); + tagsfound++; - tagsfound++; - - c = getc(ifile); + c = getc(ifile); } - return tagsfound; + return tagsfound; } -int tokenizer(unsigned inflag, char *token, int tokmax, char *line, char *white, - char *brkchar, char *quote, char eschar, char *brkused, int *next, - char *quoted); +int tokenizer(unsigned inflag,char *token,int tokmax,char *line, +char *white,char *brkchar,char *quote,char eschar,char *brkused, +int *next,char *quoted); char *super_fgets(char *b, int *blen, FILE *file) { - int c, len; + int + c, + len; - char *q; + char + *q; - len = *blen; - for (q = b;; q++) + len=*blen; + for (q=b; ; q++) { - c = fgetc(file); - if (c == EOF || c == '\n') - break; - if ((int)(q - b + 1) >= len) + c=fgetc(file); + if (c == EOF || c == '\n') + break; + if ((int)(q - b + 1) >= len) { - long tlen; + long + tlen; - tlen = (int)(q - b); - len <<= 1; - b = (char *)realloc((char *)b, (len + 2)); - if ((char *)b == (char *)NULL) - break; - q = b + tlen; + tlen=(int)(q - b); + len<<=1; + b=(char *) realloc((char *) b,(len+2)); + if ((char *) b == (char *) NULL) + break; + q=b+tlen; } - *q = (unsigned char)c; + *q=(unsigned char) c; } - *blen = 0; - if ((unsigned char *)b != (unsigned char *)NULL) + *blen=0; + if ((unsigned char *)b != (unsigned char *) NULL) { - int tlen; + int + tlen; - tlen = (int)(q - b); - if (tlen == 0) - return (char *)NULL; - b[tlen] = '\0'; - *blen = ++tlen; + tlen=(int)(q - b); + if (tlen == 0) + return (char *) NULL; + b[tlen] = '\0'; + *blen=++tlen; } - return b; + return b; } #define BUFFER_SZ 4096 int main(int argc, char *argv[]) -{ - /* unsigned int */ - /* length; */ +{ + /* unsigned int */ + /* length; */ - /*unsigned char - *buffer;*/ + /*unsigned char + *buffer;*/ - int i, mode; /* iptc binary, or iptc text */ + int + i, + mode; /* iptc binary, or iptc text */ - FILE *ifile = stdin, *ofile = stdout; + FILE + *ifile = stdin, + *ofile = stdout; - char c, - *usage = "usage: iptcutil -t | -b [-i file] [-o file] output"; + char + c, + *usage = "usage: iptcutil -t | -b [-i file] [-o file] output"; - if (argc < 2) + if( argc < 2 ) { - puts(usage); - return 1; + puts(usage); + return 1; } - mode = 0; - /* length = -1; */ - /* buffer = (unsigned char *)NULL; */ + mode = 0; + /* length = -1; */ + /* buffer = (unsigned char *)NULL; */ - for (i = 1; i < argc; i++) + for (i=1; i 0) - { - char *s = &token[next - 1]; + { + char + *s = &token[next-1]; len -= convertHTMLcodes(s, (int)strlen(s)); - } - } + } + } fputc(0x1c, ofile); fputc(dataset, ofile); fputc(recnum, ofile); if (len < 0x10000) - { + { fputc((len >> 8) & 255, ofile); fputc(len & 255, ofile); - } + } else - { + { fputc(((len >> 24) & 255) | 0x80, ofile); fputc((len >> 16) & 255, ofile); fputc((len >> 8) & 255, ofile); fputc(len & 255, ofile); - } - next = 0; + } + next=0; while (len--) - fputc(token[next++], ofile); - } - state++; + fputc(token[next++], ofile); + } + state++; } - free(token); - token = (char *)NULL; - free(newstr); - newstr = (char *)NULL; + free(token); + token = (char *)NULL; + free(newstr); + newstr = (char *)NULL; } - free(line); + free(line); - fclose(ifile); - fclose(ofile); + fclose( ifile ); + fclose( ofile ); } - return 0; + return 0; } /* - This routine is a generalized, finite state token parser. It allows + This routine is a generalized, finite state token parser. It allows you extract tokens one at a time from a string of characters. The characters used for white space, for break characters, and for quotes can be specified. Also, characters in the string can be preceded by a specifiable escape character which removes any special meaning the character may have. - There are a lot of formal parameters in this subroutine call, but - once you get familiar with them, this routine is fairly easy to use. - "#define" macros can be used to generate simpler looking calls for - commonly used applications of this routine. + There are a lot of formal parameters in this subroutine call, but + once you get familiar with them, this routine is fairly easy to use. + "#define" macros can be used to generate simpler looking calls for + commonly used applications of this routine. - First, some terminology: + First, some terminology: - token: used here, a single unit of information in - the form of a group of characters. + token: used here, a single unit of information in + the form of a group of characters. - white space: space that gets ignored (except within quotes - or when escaped), like blanks and tabs. in - addition, white space terminates a non-quoted - token. + white space: space that gets ignored (except within quotes + or when escaped), like blanks and tabs. in + addition, white space terminates a non-quoted + token. - break character: a character that separates non-quoted tokens. - commas are a common break character. the - usage of break characters to signal the end - of a token is the same as that of white space, - except multiple break characters with nothing - or only white space between generate a null - token for each two break characters together. + break character: a character that separates non-quoted tokens. + commas are a common break character. the + usage of break characters to signal the end + of a token is the same as that of white space, + except multiple break characters with nothing + or only white space between generate a null + token for each two break characters together. - for example, if blank is set to be the white - space and comma is set to be the break - character, the line ... + for example, if blank is set to be the white + space and comma is set to be the break + character, the line ... - A, B, C , , DEF + A, B, C , , DEF - ... consists of 5 tokens: + ... consists of 5 tokens: - 1) "A" - 2) "B" - 3) "C" - 4) "" (the null string) - 5) "DEF" + 1) "A" + 2) "B" + 3) "C" + 4) "" (the null string) + 5) "DEF" - quote character: a character that, when surrounding a group - of other characters, causes the group of - characters to be treated as a single token, - no matter how many white spaces or break - characters exist in the group. also, a - token always terminates after the closing - quote. for example, if ' is the quote - character, blank is white space, and comma - is the break character, the following - string ... + quote character: a character that, when surrounding a group + of other characters, causes the group of + characters to be treated as a single token, + no matter how many white spaces or break + characters exist in the group. also, a + token always terminates after the closing + quote. for example, if ' is the quote + character, blank is white space, and comma + is the break character, the following + string ... - A, ' B, CD'EF GHI + A, ' B, CD'EF GHI - ... consists of 4 tokens: + ... consists of 4 tokens: - 1) "A" - 2) " B, CD" (note the blanks & comma) - 3) "EF" - 4) "GHI" + 1) "A" + 2) " B, CD" (note the blanks & comma) + 3) "EF" + 4) "GHI" - the quote characters themselves do - not appear in the resultant tokens. the - double quotes are delimiters i use here for - documentation purposes only. + the quote characters themselves do + not appear in the resultant tokens. the + double quotes are delimiters i use here for + documentation purposes only. - escape character: a character which itself is ignored but - which causes the next character to be - used as is. ^ and \ are often used as - escape characters. an escape in the last - position of the string gets treated as a - "normal" (i.e., non-quote, non-white, - non-break, and non-escape) character. - for example, assume white space, break - character, and quote are the same as in the - above examples, and further, assume that - ^ is the escape character. then, in the - string ... + escape character: a character which itself is ignored but + which causes the next character to be + used as is. ^ and \ are often used as + escape characters. an escape in the last + position of the string gets treated as a + "normal" (i.e., non-quote, non-white, + non-break, and non-escape) character. + for example, assume white space, break + character, and quote are the same as in the + above examples, and further, assume that + ^ is the escape character. then, in the + string ... - ABC, ' DEF ^' GH' I ^ J K^ L ^ + ABC, ' DEF ^' GH' I ^ J K^ L ^ - ... there are 7 tokens: + ... there are 7 tokens: - 1) "ABC" - 2) " DEF ' GH" - 3) "I" - 4) " " (a lone blank) - 5) "J" - 6) "K L" - 7) "^" (passed as is at end of line) + 1) "ABC" + 2) " DEF ' GH" + 3) "I" + 4) " " (a lone blank) + 5) "J" + 6) "K L" + 7) "^" (passed as is at end of line) - OK, now that you have this background, here's how to call "tokenizer": + OK, now that you have this background, here's how to call "tokenizer": - result=tokenizer(flag,token,maxtok,string,white,break,quote,escape, - brkused,next,quoted) + result=tokenizer(flag,token,maxtok,string,white,break,quote,escape, + brkused,next,quoted) - result: 0 if we haven't reached EOS (end of string), and - 1 if we have (this is an "int"). + result: 0 if we haven't reached EOS (end of string), and + 1 if we have (this is an "int"). - flag: right now, only the low order 3 bits are used. - 1 => convert non-quoted tokens to upper case - 2 => convert non-quoted tokens to lower case - 0 => do not convert non-quoted tokens - (this is a "char"). + flag: right now, only the low order 3 bits are used. + 1 => convert non-quoted tokens to upper case + 2 => convert non-quoted tokens to lower case + 0 => do not convert non-quoted tokens + (this is a "char"). - token: a character string containing the returned next token - (this is a "char[]"). + token: a character string containing the returned next token + (this is a "char[]"). - maxtok: the maximum size of "token". characters beyond - "maxtok" are truncated (this is an "int"). + maxtok: the maximum size of "token". characters beyond + "maxtok" are truncated (this is an "int"). - string: the string to be parsed (this is a "char[]"). + string: the string to be parsed (this is a "char[]"). - white: a string of the valid white spaces. example: + white: a string of the valid white spaces. example: - char whitesp[]={" \t"}; + char whitesp[]={" \t"}; - blank and tab will be valid white space (this is - a "char[]"). + blank and tab will be valid white space (this is + a "char[]"). - break: a string of the valid break characters. example: + break: a string of the valid break characters. example: - char breakch[]={";,"}; + char breakch[]={";,"}; - semicolon and comma will be valid break characters - (this is a "char[]"). + semicolon and comma will be valid break characters + (this is a "char[]"). - IMPORTANT: do not use the name "break" as a C - variable, as this is a reserved word in C. + IMPORTANT: do not use the name "break" as a C + variable, as this is a reserved word in C. - quote: a string of the valid quote characters. an example - would be + quote: a string of the valid quote characters. an example + would be - char whitesp[]={"'\""); + char whitesp[]={"'\""); - (this causes single and double quotes to be valid) - note that a token starting with one of these characters - needs the same quote character to terminate it. + (this causes single and double quotes to be valid) + note that a token starting with one of these characters + needs the same quote character to terminate it. - for example, + for example, - "ABC ' + "ABC ' - is unterminated, but + is unterminated, but - "DEF" and 'GHI' + "DEF" and 'GHI' - are properly terminated. note that different quote - characters can appear on the same line; only for - a given token do the quote characters have to be - the same (this is a "char[]"). + are properly terminated. note that different quote + characters can appear on the same line; only for + a given token do the quote characters have to be + the same (this is a "char[]"). - escape: the escape character (NOT a string ... only one - allowed). use zero if none is desired (this is - a "char"). + escape: the escape character (NOT a string ... only one + allowed). use zero if none is desired (this is + a "char"). - brkused: the break character used to terminate the current - token. if the token was quoted, this will be the - quote used. if the token is the last one on the - line, this will be zero (this is a pointer to a - "char"). + brkused: the break character used to terminate the current + token. if the token was quoted, this will be the + quote used. if the token is the last one on the + line, this will be zero (this is a pointer to a + "char"). - next: this variable points to the first character of the - next token. it gets reset by "tokenizer" as it steps - through the string. set it to 0 upon initialization, - and leave it alone after that. you can change it - if you want to jump around in the string or re-parse - from the beginning, but be careful (this is a - pointer to an "int"). + next: this variable points to the first character of the + next token. it gets reset by "tokenizer" as it steps + through the string. set it to 0 upon initialization, + and leave it alone after that. you can change it + if you want to jump around in the string or re-parse + from the beginning, but be careful (this is a + pointer to an "int"). - quoted: set to 1 (true) if the token was quoted and 0 (false) - if not. you may need this information (for example: - in C, a string with quotes around it is a character - string, while one without is an identifier). + quoted: set to 1 (true) if the token was quoted and 0 (false) + if not. you may need this information (for example: + in C, a string with quotes around it is a character + string, while one without is an identifier). - (this is a pointer to a "char"). + (this is a pointer to a "char"). */ /* states */ @@ -721,179 +770,184 @@ int main(int argc, char *argv[]) #define IN_QUOTE 2 #define IN_OZONE 3 -int _p_state; /* current state */ -unsigned _p_flag; /* option flag */ -char _p_curquote; /* current quote char */ -int _p_tokpos; /* current token pos */ +int _p_state; /* current state */ +unsigned _p_flag; /* option flag */ +char _p_curquote; /* current quote char */ +int _p_tokpos; /* current token pos */ /* routine to find character in string ... used only by "tokenizer" */ -int sindex(char ch, char *string) +int sindex(char ch,char *string) { - char *cp; - for (cp = string; *cp; ++cp) - if (ch == *cp) - return (int)(cp - string); /* return position of character */ - return -1; /* eol ... no match found */ + char *cp; + for(cp=string;*cp;++cp) + if(ch==*cp) + return (int)(cp-string); /* return position of character */ + return -1; /* eol ... no match found */ } /* routine to store a character in a string ... used only by "tokenizer" */ -void chstore(char *string, int max, char ch) +void chstore(char *string,int max,char ch) { - char c; - if (_p_tokpos >= 0 && _p_tokpos < max - 1) + char c; + if(_p_tokpos>=0&&_p_tokpos= 0) /* break */ + if((qp=sindex(c,brkchar))>=0) /* break */ { - switch (_p_state) + switch(_p_state) { - case IN_WHITE: /* these are the same here ... */ - case IN_TOKEN: /* ... just get out */ - case IN_OZONE: /* ditto */ - ++(*next); - *brkused = brkchar[qp]; - goto byebye; + case IN_WHITE: /* these are the same here ... */ + case IN_TOKEN: /* ... just get out */ + case IN_OZONE: /* ditto */ + ++(*next); + *brkused=brkchar[qp]; + goto byebye; - case IN_QUOTE: /* just keep going */ - chstore(token, tokmax, c); - break; + case IN_QUOTE: /* just keep going */ + chstore(token,tokmax,c); + break; } } - else if ((qp = sindex(c, quote)) >= 0) /* quote */ + else if((qp=sindex(c,quote))>=0) /* quote */ { - switch (_p_state) + switch(_p_state) { - case IN_WHITE: /* these are identical, */ - _p_state = IN_QUOTE; /* change states */ - _p_curquote = quote[qp]; /* save quote char */ - *quoted = - 1; /* set to true as long as something is in quotes */ - break; + case IN_WHITE: /* these are identical, */ + _p_state=IN_QUOTE; /* change states */ + _p_curquote=quote[qp]; /* save quote char */ + *quoted=1; /* set to true as long as something is in quotes */ + break; - case IN_QUOTE: - if (quote[qp] == - _p_curquote) /* same as the beginning quote? */ - { - _p_state = IN_OZONE; - _p_curquote = 0; - } - else - chstore(token, tokmax, c); /* treat as regular char */ - break; + case IN_QUOTE: + if(quote[qp]==_p_curquote) /* same as the beginning quote? */ + { + _p_state=IN_OZONE; + _p_curquote=0; + } + else + chstore(token,tokmax,c); /* treat as regular char */ + break; - case IN_TOKEN: - case IN_OZONE: - *brkused = c; /* uses quote as break char */ - goto byebye; + case IN_TOKEN: + case IN_OZONE: + *brkused=c; /* uses quote as break char */ + goto byebye; } } - else if ((qp = sindex(c, white)) >= 0) /* white */ + else if((qp=sindex(c,white))>=0) /* white */ { - switch (_p_state) + switch(_p_state) { - case IN_WHITE: - case IN_OZONE: - break; /* keep going */ + case IN_WHITE: + case IN_OZONE: + break; /* keep going */ - case IN_TOKEN: - _p_state = IN_OZONE; - break; + case IN_TOKEN: + _p_state=IN_OZONE; + break; - case IN_QUOTE: - chstore(token, tokmax, c); /* it's valid here */ - break; + case IN_QUOTE: + chstore(token,tokmax,c); /* it's valid here */ + break; } } - else if (c == eschar) /* escape */ + else if(c==eschar) /* escape */ { - nc = line[(*next) + 1]; - if (nc == 0) /* end of line */ + nc=line[(*next)+1]; + if(nc==0) /* end of line */ { - *brkused = 0; - chstore(token, tokmax, c); - ++(*next); - goto byebye; + *brkused=0; + chstore(token,tokmax,c); + ++(*next); + goto byebye; } - switch (_p_state) + switch(_p_state) { - case IN_WHITE: - --(*next); - _p_state = IN_TOKEN; - break; + case IN_WHITE: + --(*next); + _p_state=IN_TOKEN; + break; - case IN_TOKEN: - case IN_QUOTE: - ++(*next); - chstore(token, tokmax, nc); - break; + case IN_TOKEN: + case IN_QUOTE: + ++(*next); + chstore(token,tokmax,nc); + break; - case IN_OZONE: - goto byebye; + case IN_OZONE: + goto byebye; } } - else /* anything else is just a real character */ + else /* anything else is just a real character */ { - switch (_p_state) + switch(_p_state) { - case IN_WHITE: - _p_state = IN_TOKEN; /* switch states */ - /* Fall through */ + case IN_WHITE: + _p_state=IN_TOKEN; /* switch states */ + /* Fall through */ - case IN_TOKEN: /* these 2 are */ - case IN_QUOTE: /* identical here */ - chstore(token, tokmax, c); - break; + case IN_TOKEN: /* these 2 are */ + case IN_QUOTE: /* identical here */ + chstore(token,tokmax,c); + break; - case IN_OZONE: - goto byebye; + case IN_OZONE: + goto byebye; } } - } /* end of main loop */ + } /* end of main loop */ -byebye: - token[_p_tokpos] = 0; /* make sure token ends with EOS */ + byebye: + token[_p_tokpos]=0; /* make sure token ends with EOS */ - return 0; + return 0; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 2 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/WebPCodec.cmake b/thirdparty/SDL2_image/external/libtiff/contrib/mfs/CMakeLists.txt similarity index 81% rename from thirdparty/SDL2_image/external/libtiff/cmake/WebPCodec.cmake rename to thirdparty/SDL2_image/external/libtiff/contrib/mfs/CMakeLists.txt index 1d676a78a..3f4f3a906 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/WebPCodec.cmake +++ b/thirdparty/SDL2_image/external/libtiff/contrib/mfs/CMakeLists.txt @@ -1,7 +1,6 @@ -# Checks for WebP codec support +# CMake build for libtiff # # Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh # Written by Roger Leigh # # Permission to use, copy, modify, distribute, and sell this software and @@ -23,13 +22,6 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -# libwebp -set(WEBP_SUPPORT FALSE) - -find_package(WebP) - -option(webp "use libwebp (required for WEBP compression)" ${WebP_FOUND}) - -if (webp AND WebP_FOUND) - set(WEBP_SUPPORT TRUE) -endif() +extra_dist( + README + mfs_file.c) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/mfs/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/mfs/Makefile.am index 62ae5d57d..b0bad60a9 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/mfs/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/mfs/Makefile.am @@ -24,5 +24,6 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ + CMakeLists.txt \ README \ mfs_file.c diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/mfs/mfs_file.c b/thirdparty/SDL2_image/external/libtiff/contrib/mfs/mfs_file.c index 68fc2227f..6675e2a38 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/mfs/mfs_file.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/mfs/mfs_file.c @@ -5,11 +5,11 @@ - as if it were a file. - mfs_ stands for memory file system. - Author : Mike Johnson - Banctec AB 03/07/96 -- +- -------------------------------------------------------------------------------- */ -/* +/* Copyright (c) 1996 Mike Johnson Copyright (c) 1996 BancTec AB @@ -21,28 +21,29 @@ all copies of the software and related documentation, and (ii) the names of Mike Johnson and BancTec may not be used in any advertising or publicity relating to the software. -THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MIKE JOHNSON OR BANCTEC BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + /* -------------------------------------------------------------------------------- - Includes -------------------------------------------------------------------------------- */ -#include -#include -#include +#include +#include +#include /* -------------------------------------------------------------------------------- @@ -50,9 +51,9 @@ OF THIS SOFTWARE. -------------------------------------------------------------------------------- */ -#define MAX_BUFFS 20 -#define FALSE 0 -#define TRUE 1 +#define MAX_BUFFS 20 +#define FALSE 0 +#define TRUE 1 /* -------------------------------------------------------------------------------- @@ -60,30 +61,31 @@ OF THIS SOFTWARE. -------------------------------------------------------------------------------- */ -static char *buf[MAX_BUFFS]; /* Memory for each open buf */ -static long buf_off[MAX_BUFFS]; /* File pointer for each buf */ -static long buf_size[MAX_BUFFS]; /* Count of bytes allocated for each buf */ -static long fds[MAX_BUFFS]; /* File descriptor status */ -static int buf_mode[MAX_BUFFS]; /* Mode of buffer (r, w, a) */ +static char *buf[MAX_BUFFS]; /* Memory for each open buf */ +static long buf_off[MAX_BUFFS]; /* File pointer for each buf */ +static long buf_size[MAX_BUFFS]; /* Count of bytes allocated for each buf */ +static long fds[MAX_BUFFS]; /* File descriptor status */ +static int buf_mode[MAX_BUFFS]; /* Mode of buffer (r, w, a) */ static int library_init_done = FALSE; + /* -------------------------------------------------------------------------------- - Function prototypes -------------------------------------------------------------------------------- */ -int mfs_open(void *ptr, int size, char *mode); -int mfs_lseek(int fd, int offset, int whence); -int mfs_read(int fd, void *buf, int size); -int mfs_write(int fd, void *buf, int size); -int mfs_size(int fd); -int mfs_map(int fd, char **addr, size_t *len); -int mfs_unmap(int fd); -int mfs_close(int fd); -static int extend_mem_file(int fd, int size); -static void mem_init(); +int mfs_open (void *ptr, int size, char *mode); +int mfs_lseek (int fd, int offset, int whence); +int mfs_read (int fd, void *buf, int size); +int mfs_write (int fd, void *buf, int size); +int mfs_size (int fd); +int mfs_map (int fd, char **addr, size_t *len); +int mfs_unmap (int fd); +int mfs_close (int fd); +static int extend_mem_file (int fd, int size); +static void mem_init (); /* -------------------------------------------------------------------------------- @@ -95,7 +97,7 @@ static void mem_init(); -------------------------------------------------------------------------------- - Function : mfs_open () - -- Arguments : Pointer to allocated buffer, initial size of buffer, +- Arguments : Pointer to allocated buffer, initial size of buffer, - mode spec (r, w, a) - - Returns : File descriptor or -1 if error. @@ -106,22 +108,22 @@ static void mem_init(); - back to TIFFClientOpen and used as if it was a disk - based fd. - If the call is for mode 'w' then pass (void *)NULL as -- the buffer and zero size and the library will +- the buffer and zero size and the library will - allocate memory for you. - If the mode is append then pass (void *)NULL and size - zero or with a valid address. -- +- -------------------------------------------------------------------------------- */ -int mfs_open(void *buffer, int size, char *mode) +int mfs_open (void *buffer, int size, char *mode) { int ret, i; void *tmp; if (library_init_done == FALSE) { - mem_init(); + mem_init (); library_init_done = TRUE; } @@ -138,7 +140,7 @@ int mfs_open(void *buffer, int size, char *mode) } } - if (i == MAX_BUFFS) /* No more free descriptors */ + if (i == MAX_BUFFS) /* No more free descriptors */ { ret = -1; errno = EMFILE; @@ -169,7 +171,7 @@ int mfs_open(void *buffer, int size, char *mode) else { - tmp = malloc(0); /* Get a pointer */ + tmp = malloc (0); /* Get a pointer */ if (tmp == (void *)NULL) { ret = -1; @@ -185,9 +187,9 @@ int mfs_open(void *buffer, int size, char *mode) } else if (ret >= 0 && *mode == 'a') { - if (buffer == (void *)NULL) /* Create space for client */ + if (buffer == (void *) NULL) /* Create space for client */ { - tmp = malloc(0); /* Get a pointer */ + tmp = malloc (0); /* Get a pointer */ if (tmp == (void *)NULL) { ret = -1; @@ -200,14 +202,14 @@ int mfs_open(void *buffer, int size, char *mode) buf_off[ret] = 0; } } - else /* Client has file read in already */ + else /* Client has file read in already */ { buf[ret] = (char *)buffer; buf_size[ret] = size; buf_off[ret] = 0; } } - else /* Some other invalid combination of parameters */ + else /* Some other invalid combination of parameters */ { ret = -1; errno = EINVAL; @@ -233,16 +235,16 @@ int mfs_open(void *buffer, int size, char *mode) - Description : Does the same as lseek (2) except on a memory based file. - Note: the memory area will be extended if the caller - attempts to seek past the current end of file (memory). -- +- -------------------------------------------------------------------------------- */ -int mfs_lseek(int fd, int offset, int whence) +int mfs_lseek (int fd, int offset, int whence) { int ret; long test_off; - if (fds[fd] == -1) /* Not open */ + if (fds[fd] == -1) /* Not open */ { ret = -1; errno = EBADF; @@ -258,7 +260,7 @@ int mfs_lseek(int fd, int offset, int whence) { case SEEK_SET: if (offset > buf_size[fd]) - extend_mem_file(fd, offset); + extend_mem_file (fd, offset); buf_off[fd] = offset; ret = offset; break; @@ -274,7 +276,7 @@ int mfs_lseek(int fd, int offset, int whence) else { if (test_off > buf_size[fd]) - extend_mem_file(fd, test_off); + extend_mem_file (fd, test_off); buf_off[fd] = test_off; ret = test_off; } @@ -291,7 +293,7 @@ int mfs_lseek(int fd, int offset, int whence) else { if (test_off > buf_size[fd]) - extend_mem_file(fd, test_off); + extend_mem_file (fd, test_off); buf_off[fd] = test_off; ret = test_off; } @@ -305,7 +307,7 @@ int mfs_lseek(int fd, int offset, int whence) } return (ret); -} +} /* -------------------------------------------------------------------------------- @@ -318,11 +320,11 @@ int mfs_lseek(int fd, int offset, int whence) - Description : Does the same as read (2) except on a memory based file. - Note: An attempt to read past the end of memory currently - allocated to the file will return 0 (End Of File) -- +- -------------------------------------------------------------------------------- */ -int mfs_read(int fd, void *clnt_buf, int size) +int mfs_read (int fd, void *clnt_buf, int size) { int ret; @@ -335,11 +337,11 @@ int mfs_read(int fd, void *clnt_buf, int size) } else if (buf_off[fd] + size > buf_size[fd]) { - ret = 0; /* EOF */ + ret = 0; /* EOF */ } else { - memcpy(clnt_buf, (void *)(buf[fd] + buf_off[fd]), size); + memcpy (clnt_buf, (void *) (buf[fd] + buf_off[fd]), size); buf_off[fd] = buf_off[fd] + size; ret = size; } @@ -358,11 +360,11 @@ int mfs_read(int fd, void *clnt_buf, int size) - Description : Does the same as write (2) except on a memory based file. - Note: the memory area will be extended if the caller - attempts to write past the current end of file (memory). -- +- -------------------------------------------------------------------------------- */ -int mfs_write(int fd, void *clnt_buf, int size) +int mfs_write (int fd, void *clnt_buf, int size) { int ret; @@ -378,12 +380,12 @@ int mfs_write(int fd, void *clnt_buf, int size) /* Write */ if (buf_off[fd] + size > buf_size[fd]) - { - extend_mem_file(fd, buf_off[fd] + size); + { + extend_mem_file (fd, buf_off[fd] + size); buf_size[fd] = (buf_off[fd] + size); } - memcpy((buf[fd] + buf_off[fd]), clnt_buf, size); + memcpy ((buf[fd] + buf_off[fd]), clnt_buf, size); buf_off[fd] = buf_off[fd] + size; ret = size; @@ -395,10 +397,10 @@ int mfs_write(int fd, void *clnt_buf, int size) if (buf_off[fd] != buf_size[fd]) buf_off[fd] = buf_size[fd]; - extend_mem_file(fd, buf_off[fd] + size); + extend_mem_file (fd, buf_off[fd] + size); buf_size[fd] += size; - memcpy((buf[fd] + buf_off[fd]), clnt_buf, size); + memcpy ((buf[fd] + buf_off[fd]), clnt_buf, size); buf_off[fd] = buf_off[fd] + size; ret = size; @@ -416,15 +418,15 @@ int mfs_write(int fd, void *clnt_buf, int size) - Returns : integer file size - - Description : This function returns the current size of the file in bytes. -- +- -------------------------------------------------------------------------------- */ -int mfs_size(int fd) +int mfs_size (int fd) { int ret; - if (fds[fd] == -1) /* Not open */ + if (fds[fd] == -1) /* Not open */ { ret = -1; errno = EBADF; @@ -447,15 +449,15 @@ int mfs_size(int fd) - in memory and what size the mapped area is. It is provided - to satisfy the MapProc function in libtiff. It pretends - that the file has been mmap (2)ped. -- +- -------------------------------------------------------------------------------- */ -int mfs_map(int fd, char **addr, size_t *len) +int mfs_map (int fd, char **addr, size_t *len) { - int ret; + int ret; - if (fds[fd] == -1) /* Not open */ + if (fds[fd] == -1) /* Not open */ { ret = -1; errno = EBADF; @@ -480,11 +482,14 @@ int mfs_map(int fd, char **addr, size_t *len) - - Description : This function does nothing as the file is always - in memory. -- +- -------------------------------------------------------------------------------- */ -int mfs_unmap(int fd) { return (0); } +int mfs_unmap (int fd) +{ + return (0); +} /* -------------------------------------------------------------------------------- @@ -495,15 +500,15 @@ int mfs_unmap(int fd) { return (0); } - Returns : close status (succeeded or otherwise) - - Description : Close the open memory file. (Make fd available again.) -- +- -------------------------------------------------------------------------------- */ -int mfs_close(int fd) +int mfs_close (int fd) { - int ret; + int ret; - if (fds[fd] == -1) /* Not open */ + if (fds[fd] == -1) /* Not open */ { ret = -1; errno = EBADF; @@ -526,20 +531,20 @@ int mfs_close(int fd) - Returns : 0 - All OK, -1 - realloc () failed. - - Description : Increase the amount of memory allocated to a file. -- +- -------------------------------------------------------------------------------- */ -static int extend_mem_file(int fd, int size) +static int extend_mem_file (int fd, int size) { void *new_mem; int ret; - if ((new_mem = realloc(buf[fd], size)) == (void *)NULL) + if ((new_mem = realloc (buf[fd], size)) == (void *) NULL) ret = -1; else { - buf[fd] = (char *)new_mem; + buf[fd] = (char *) new_mem; ret = 0; } @@ -555,11 +560,11 @@ static int extend_mem_file(int fd, int size) - Returns : void - - Description : Initialise the library. -- +- -------------------------------------------------------------------------------- */ -static void mem_init() +static void mem_init () { int i; @@ -571,3 +576,11 @@ static void mem_init() buf_off[i] = 0; } } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/oss-fuzz/build.sh b/thirdparty/SDL2_image/external/libtiff/contrib/oss-fuzz/build.sh new file mode 100755 index 000000000..ab824398e --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/contrib/oss-fuzz/build.sh @@ -0,0 +1,79 @@ +#!/bin/bash -eu +# Copyright (c) 1988-1997 Sam Leffler +# Copyright (c) 1991-1997 Silicon Graphics, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Sam Leffler and Silicon Graphics. +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# +# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# OF THIS SOFTWARE. + +# build zlib +pushd "$SRC/zlib" +./configure --static --prefix="$WORK" +make -j$(nproc) CFLAGS="$CFLAGS -fPIC" +make install +popd + +# Build libjpeg-turbo +pushd "$SRC/libjpeg-turbo" +cmake . -DCMAKE_INSTALL_PREFIX=$WORK -DENABLE_STATIC=on -DENABLE_SHARED=off +make -j$(nproc) +make install +popd + +# Build libjbig +pushd "$SRC/jbigkit" +if [ "$ARCHITECTURE" = "i386" ]; then + echo "#!/bin/bash" > gcc + echo "clang -m32 \$*" >> gcc + chmod +x gcc + PATH=$PWD:$PATH make lib +else + make lib +fi + +mv "$SRC"/jbigkit/libjbig/*.a "$WORK/lib/" +mv "$SRC"/jbigkit/libjbig/*.h "$WORK/include/" +popd + +if [ "$ARCHITECTURE" != "i386" ]; then + apt-get install -y liblzma-dev +fi + +cmake . -DCMAKE_INSTALL_PREFIX=$WORK -DBUILD_SHARED_LIBS=off +make -j$(nproc) +make install + +if [ "$ARCHITECTURE" = "i386" ]; then + $CXX $CXXFLAGS -std=c++11 -I$WORK/include \ + $SRC/libtiff/contrib/oss-fuzz/tiff_read_rgba_fuzzer.cc -o $OUT/tiff_read_rgba_fuzzer \ + $LIB_FUZZING_ENGINE $WORK/lib/libtiffxx.a $WORK/lib/libtiff.a $WORK/lib/libz.a $WORK/lib/libjpeg.a \ + $WORK/lib/libjbig.a $WORK/lib/libjbig85.a +else + $CXX $CXXFLAGS -std=c++11 -I$WORK/include \ + $SRC/libtiff/contrib/oss-fuzz/tiff_read_rgba_fuzzer.cc -o $OUT/tiff_read_rgba_fuzzer \ + $LIB_FUZZING_ENGINE $WORK/lib/libtiffxx.a $WORK/lib/libtiff.a $WORK/lib/libz.a $WORK/lib/libjpeg.a \ + $WORK/lib/libjbig.a $WORK/lib/libjbig85.a -Wl,-Bstatic -llzma -Wl,-Bdynamic +fi + +mkdir afl_testcases +(cd afl_testcases; tar xf "$SRC/afl_testcases.tgz") +mkdir tif +find afl_testcases -type f -name '*.tif' -exec mv -n {} tif/ \; +zip -rj tif.zip tif/ +cp tif.zip "$OUT/tiff_read_rgba_fuzzer_seed_corpus.zip" +cp "$SRC/tiff.dict" "$OUT/tiff_read_rgba_fuzzer.dict" diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/oss-fuzz/tiff_read_rgba_fuzzer.cc b/thirdparty/SDL2_image/external/libtiff/contrib/oss-fuzz/tiff_read_rgba_fuzzer.cc index d90c53ab5..dd17b5d8a 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/oss-fuzz/tiff_read_rgba_fuzzer.cc +++ b/thirdparty/SDL2_image/external/libtiff/contrib/oss-fuzz/tiff_read_rgba_fuzzer.cc @@ -28,126 +28,112 @@ #include #include -/* stolen from tiffiop.h, which is a private header so we can't just include it - */ + +/* stolen from tiffiop.h, which is a private header so we can't just include it */ /* safe multiply returns either the multiplied value or 0 if it overflowed */ -#define __TIFFSafeMultiply(t, v, m) \ - ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v))) \ - ? (t)((v) * (m)) \ - : (t)0) +#define __TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0) -const uint64_t MAX_SIZE = 500000000; +const uint64 MAX_SIZE = 500000000; -extern "C" void handle_error(const char *unused, const char *unused2, - va_list unused3) -{ +extern "C" void handle_error(const char *unused, const char *unused2, va_list unused3) { return; } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) -{ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { #ifndef STANDALONE - TIFFSetErrorHandler(handle_error); - TIFFSetWarningHandler(handle_error); + TIFFSetErrorHandler(handle_error); + TIFFSetWarningHandler(handle_error); #endif #if defined(__has_feature) -#if __has_feature(memory_sanitizer) - // libjpeg-turbo has issues with MSAN and SIMD code - // See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7547 - // and https://github.com/libjpeg-turbo/libjpeg-turbo/pull/365 - setenv("JSIMD_FORCENONE", "1", 1); +# if __has_feature(memory_sanitizer) + // libjpeg-turbo has issues with MSAN and SIMD code + // See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=7547 + // and https://github.com/libjpeg-turbo/libjpeg-turbo/pull/365 + setenv("JSIMD_FORCENONE" ,"1", 1); +# endif #endif -#endif - std::istringstream s(std::string(Data, Data + Size)); - TIFF *tif = TIFFStreamOpen("MemTIFF", &s); - if (!tif) - { - return 0; - } - uint32_t w, h; - uint32_t *raster; + std::istringstream s(std::string(Data,Data+Size)); + TIFF* tif = TIFFStreamOpen("MemTIFF", &s); + if (!tif) { + return 0; + } + uint32 w, h; + uint32* raster; - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - /* don't continue if file size is ludicrous */ - if (TIFFTileSize64(tif) > MAX_SIZE) - { - TIFFClose(tif); - return 0; - } - uint64_t bufsize = TIFFTileSize64(tif); - /* don't continue if the buffer size greater than the max allowed by the - * fuzzer */ - if (bufsize > MAX_SIZE || bufsize == 0) - { - TIFFClose(tif); - return 0; - } - /* another hack to work around an OOM in tif_fax3.c */ - uint32_t tilewidth = 0; - uint32_t imagewidth = 0; - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tilewidth); - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth); - tilewidth = __TIFFSafeMultiply(uint32_t, tilewidth, 2); - imagewidth = __TIFFSafeMultiply(uint32_t, imagewidth, 2); - if (tilewidth * 2 > MAX_SIZE || imagewidth * 2 > MAX_SIZE || - tilewidth == 0 || imagewidth == 0) - { - TIFFClose(tif); - return 0; - } - uint32_t size = __TIFFSafeMultiply(uint32_t, w, h); - if (size > MAX_SIZE || size == 0) - { - TIFFClose(tif); - return 0; - } - raster = (uint32_t *)_TIFFmalloc(size * sizeof(uint32_t)); - if (raster != NULL) - { - TIFFReadRGBAImage(tif, w, h, raster, 0); - _TIFFfree(raster); - } - TIFFClose(tif); + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + /* don't continue if file size is ludicrous */ + if (TIFFTileSize64(tif) > MAX_SIZE) { + TIFFClose(tif); + return 0; + } + uint64 bufsize = TIFFTileSize64(tif); + /* don't continue if the buffer size greater than the max allowed by the fuzzer */ + if (bufsize > MAX_SIZE || bufsize == 0) { + TIFFClose(tif); + return 0; + } + /* another hack to work around an OOM in tif_fax3.c */ + uint32 tilewidth = 0; + uint32 imagewidth = 0; + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tilewidth); + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imagewidth); + tilewidth = __TIFFSafeMultiply(uint32, tilewidth, 2); + imagewidth = __TIFFSafeMultiply(uint32, imagewidth, 2); + if (tilewidth * 2 > MAX_SIZE || imagewidth * 2 > MAX_SIZE || tilewidth == 0 || imagewidth == 0) { + TIFFClose(tif); + return 0; + } + uint32 size = __TIFFSafeMultiply(uint32, w, h); + if (size > MAX_SIZE || size == 0) { + TIFFClose(tif); + return 0; + } + raster = (uint32*) _TIFFmalloc(size * sizeof (uint32)); + if (raster != NULL) { + TIFFReadRGBAImage(tif, w, h, raster, 0); + _TIFFfree(raster); + } + TIFFClose(tif); - return 0; + return 0; } #ifdef STANDALONE -template static void CPL_IGNORE_RET_VAL(T) {} +template static void CPL_IGNORE_RET_VAL(T) {} -static void Usage(int, char *argv[]) +static void Usage(int, char* argv[]) { fprintf(stderr, "%s [--help] [-repeat N] filename.\n", argv[0]); exit(1); } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { int nRet = 0; - void *buf = NULL; + void* buf = NULL; int nLen = 0; int nLoops = 1; - const char *pszFilename = NULL; + const char* pszFilename = NULL; - for (int i = 1; i < argc; i++) + for(int i = 1; i < argc; i++ ) { - if (i + 1 < argc && strcmp(argv[i], "-repeat") == 0) + if( i + 1 < argc && strcmp(argv[i], "-repeat") == 0 ) { - nLoops = atoi(argv[i + 1]); + nLoops = atoi(argv[i+1]); i++; } - else if (strcmp(argv[i], "-dummy") == 0) + else if( strcmp(argv[i], "-dummy") == 0 ) { uint8_t dummy = ' '; return LLVMFuzzerTestOneInput(&dummy, 1); } - else if (strcmp(argv[i], "--help") == 0) + else if( strcmp(argv[i], "--help") == 0 ) { Usage(argc, argv); } - else if (argv[i][0] == '-') + else if( argv[i][0] == '-' ) { fprintf(stderr, "Unrecognized option: %s", argv[i]); Usage(argc, argv); @@ -157,13 +143,13 @@ int main(int argc, char *argv[]) pszFilename = argv[i]; } } - if (pszFilename == nullptr) + if( pszFilename == nullptr ) { fprintf(stderr, "No filename specified\n"); Usage(argc, argv); } - FILE *f = fopen(pszFilename, "rb"); - if (!f) + FILE* f = fopen(pszFilename, "rb"); + if( !f ) { fprintf(stderr, "%s does not exist.\n", pszFilename); exit(1); @@ -172,7 +158,7 @@ int main(int argc, char *argv[]) nLen = (int)ftell(f); fseek(f, 0, SEEK_SET); buf = malloc(nLen); - if (!buf) + if( !buf ) { fprintf(stderr, "malloc failed.\n"); fclose(f); @@ -180,10 +166,10 @@ int main(int argc, char *argv[]) } CPL_IGNORE_RET_VAL(fread(buf, nLen, 1, f)); fclose(f); - for (int i = 0; i < nLoops; i++) + for( int i = 0; i < nLoops; i++ ) { - nRet = LLVMFuzzerTestOneInput(static_cast(buf), nLen); - if (nRet != 0) + nRet = LLVMFuzzerTestOneInput(static_cast(buf), nLen); + if( nRet != 0 ) break; } free(buf); diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/pds/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/contrib/pds/CMakeLists.txt new file mode 100644 index 000000000..53a0e0568 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/contrib/pds/CMakeLists.txt @@ -0,0 +1,30 @@ +# CMake build for libtiff +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Written by Roger Leigh +# +# 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. + +extra_dist( + README + tif_imageiter.c + tif_imageiter.h + tif_pdsdirread.c + tif_pdsdirwrite.c) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/pds/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/pds/Makefile.am index c4e6bafe1..435e2b33d 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/pds/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/pds/Makefile.am @@ -24,6 +24,7 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ + CMakeLists.txt \ README \ tif_imageiter.c \ tif_imageiter.h \ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_imageiter.c b/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_imageiter.c index 921b02315..243cfd658 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_imageiter.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_imageiter.c @@ -2,23 +2,23 @@ * Copyright (c) 1991-1996 Sam Leffler * Copyright (c) 1991-1996 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -34,43 +34,45 @@ * ignore those details. The calling program does, however, need to be * conscious of the type of the pixel data that it is receiving. * - * For reasons of efficiency, the callback function actually gets called for + * For reasons of efficiency, the callback function actually gets called for * "blocks" of pixels rather than for individual pixels. The format of the * callback arguments is given below. * - * This code was taken from TIFFReadRGBAImage() in tif_getimage.c of the - * original TIFF distribution, and simplified and generalized to provide this - * general iteration capability. Those routines could certainly be - * re-implemented in terms of a TIFFImageIter if desired. + * This code was taken from TIFFReadRGBAImage() in tif_getimage.c of the original + * TIFF distribution, and simplified and generalized to provide this general + * iteration capability. Those routines could certainly be re-implemented in terms + * of a TIFFImageIter if desired. * */ -#include "tif_imageiter.h" #include "tiffiop.h" +#include "tif_imageiter.h" #include #include -static int gtTileContig(TIFFImageIter *, void *udata, uint32_t, uint32_t); -static int gtTileSeparate(TIFFImageIter *, void *udata, uint32_t, uint32_t); -static int gtStripContig(TIFFImageIter *, void *udata, uint32_t, uint32_t); -static int gtStripSeparate(TIFFImageIter *, void *udata, uint32_t, uint32_t); +static int gtTileContig(TIFFImageIter*, void *udata, uint32, uint32); +static int gtTileSeparate(TIFFImageIter*, void *udata, uint32, uint32); +static int gtStripContig(TIFFImageIter*, void *udata, uint32, uint32); +static int gtStripSeparate(TIFFImageIter*, void *udata, uint32, uint32); -static const char photoTag[] = "PhotometricInterpretation"; +static const char photoTag[] = "PhotometricInterpretation"; -static int isCCITTCompression(TIFF *tif) +static int +isCCITTCompression(TIFF* tif) { - uint16_t compress; + uint16 compress; TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); return (compress == COMPRESSION_CCITTFAX3 || - compress == COMPRESSION_CCITTFAX4 || - compress == COMPRESSION_CCITTRLE || - compress == COMPRESSION_CCITTRLEW); + compress == COMPRESSION_CCITTFAX4 || + compress == COMPRESSION_CCITTRLE || + compress == COMPRESSION_CCITTRLEW); } -int TIFFImageIterBegin(TIFFImageIter *img, TIFF *tif, int stop, char emsg[1024]) +int +TIFFImageIterBegin(TIFFImageIter* img, TIFF* tif, int stop, char emsg[1024]) { - uint16_t *sampleinfo; - uint16_t extrasamples; - uint16_t planarconfig; + uint16* sampleinfo; + uint16 extrasamples; + uint16 planarconfig; int colorchannels; img->tif = tif; @@ -78,244 +80,217 @@ int TIFFImageIterBegin(TIFFImageIter *img, TIFF *tif, int stop, char emsg[1024]) TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample); img->alpha = 0; TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel); - TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples, - &sampleinfo); + TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, + &extrasamples, &sampleinfo); if (extrasamples == 1) - switch (sampleinfo[0]) - { - case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */ - case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */ - img->alpha = sampleinfo[0]; - break; - } + switch (sampleinfo[0]) { + case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */ + case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */ + img->alpha = sampleinfo[0]; + break; + } colorchannels = img->samplesperpixel - extrasamples; TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig); - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) - { - switch (colorchannels) - { - case 1: - if (isCCITTCompression(tif)) - img->photometric = PHOTOMETRIC_MINISWHITE; - else - img->photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - img->photometric = PHOTOMETRIC_RGB; - break; - default: - sprintf(emsg, "Missing needed %s tag", photoTag); - return (0); - } + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) { + switch (colorchannels) { + case 1: + if (isCCITTCompression(tif)) + img->photometric = PHOTOMETRIC_MINISWHITE; + else + img->photometric = PHOTOMETRIC_MINISBLACK; + break; + case 3: + img->photometric = PHOTOMETRIC_RGB; + break; + default: + sprintf(emsg, "Missing needed %s tag", photoTag); + return (0); + } } - switch (img->photometric) - { - case PHOTOMETRIC_PALETTE: - if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &img->redcmap, - &img->greencmap, &img->bluecmap)) - { - TIFFErrorExtR(tif, TIFFFileName(tif), - "Missing required \"Colormap\" tag"); - return (0); - } - /* fall through... */ - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - /* This should work now so skip the check - BSR - if (planarconfig == PLANARCONFIG_CONTIG && - img->samplesperpixel != 1) { sprintf(emsg, "Sorry, can not handle - contiguous data with %s=%d, and %s=%d", photoTag, - img->photometric, "Samples/pixel", img->samplesperpixel); return - (0); - } - */ - break; - case PHOTOMETRIC_YCBCR: - if (planarconfig != PLANARCONFIG_CONTIG) - { - sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d", - "Planarconfiguration", planarconfig); - return (0); - } - /* It would probably be nice to have a reality check here. */ - { - uint16_t compress; - TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); - if (compress == COMPRESSION_JPEG && - planarconfig == PLANARCONFIG_CONTIG) - { - /* can rely on libjpeg to convert to RGB */ - /* XXX should restore current state on exit */ - TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - img->photometric = PHOTOMETRIC_RGB; - } - } - break; - case PHOTOMETRIC_RGB: - if (colorchannels < 3) - { - sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", - "Color channels", colorchannels); - return (0); - } - break; - case PHOTOMETRIC_SEPARATED: - { - uint16_t inkset; - TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); - if (inkset != INKSET_CMYK) - { - sprintf(emsg, - "Sorry, can not handle separated image with %s=%d", - "InkSet", inkset); - return (0); - } - if (img->samplesperpixel != 4) - { - sprintf(emsg, - "Sorry, can not handle separated image with %s=%d", - "Samples/pixel", img->samplesperpixel); - return (0); - } - break; - } - default: - sprintf(emsg, "Sorry, can not handle image with %s=%d", photoTag, - img->photometric); - return (0); + switch (img->photometric) { + case PHOTOMETRIC_PALETTE: + if (!TIFFGetField(tif, TIFFTAG_COLORMAP, + &img->redcmap, &img->greencmap, &img->bluecmap)) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Missing required \"Colormap\" tag"); + return (0); + } + /* fall through... */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: +/* This should work now so skip the check - BSR + if (planarconfig == PLANARCONFIG_CONTIG && img->samplesperpixel != 1) { + sprintf(emsg, + "Sorry, can not handle contiguous data with %s=%d, and %s=%d", + photoTag, img->photometric, + "Samples/pixel", img->samplesperpixel); + return (0); + } + */ + break; + case PHOTOMETRIC_YCBCR: + if (planarconfig != PLANARCONFIG_CONTIG) { + sprintf(emsg, "Sorry, can not handle YCbCr images with %s=%d", + "Planarconfiguration", planarconfig); + return (0); + } + /* It would probably be nice to have a reality check here. */ + { uint16 compress; + TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); + if (compress == COMPRESSION_JPEG && planarconfig == PLANARCONFIG_CONTIG) { + /* can rely on libjpeg to convert to RGB */ + /* XXX should restore current state on exit */ + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + img->photometric = PHOTOMETRIC_RGB; + } + } + break; + case PHOTOMETRIC_RGB: + if (colorchannels < 3) { + sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", + "Color channels", colorchannels); + return (0); + } + break; + case PHOTOMETRIC_SEPARATED: { + uint16 inkset; + TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); + if (inkset != INKSET_CMYK) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "InkSet", inkset); + return (0); + } + if (img->samplesperpixel != 4) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "Samples/pixel", img->samplesperpixel); + return (0); + } + break; + } + default: + sprintf(emsg, "Sorry, can not handle image with %s=%d", + photoTag, img->photometric); + return (0); } TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height); TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation); - switch (img->orientation) - { - case ORIENTATION_BOTRIGHT: - case ORIENTATION_RIGHTBOT: /* XXX */ - case ORIENTATION_LEFTBOT: /* XXX */ - TIFFWarning(TIFFFileName(tif), "using bottom-left orientation"); - img->orientation = ORIENTATION_BOTLEFT; - /* fall through... */ - case ORIENTATION_BOTLEFT: - break; - case ORIENTATION_TOPRIGHT: - case ORIENTATION_RIGHTTOP: /* XXX */ - case ORIENTATION_LEFTTOP: /* XXX */ - default: - TIFFWarning(TIFFFileName(tif), "using top-left orientation"); - img->orientation = ORIENTATION_TOPLEFT; - /* fall through... */ - case ORIENTATION_TOPLEFT: - break; + switch (img->orientation) { + case ORIENTATION_BOTRIGHT: + case ORIENTATION_RIGHTBOT: /* XXX */ + case ORIENTATION_LEFTBOT: /* XXX */ + TIFFWarning(TIFFFileName(tif), "using bottom-left orientation"); + img->orientation = ORIENTATION_BOTLEFT; + /* fall through... */ + case ORIENTATION_BOTLEFT: + break; + case ORIENTATION_TOPRIGHT: + case ORIENTATION_RIGHTTOP: /* XXX */ + case ORIENTATION_LEFTTOP: /* XXX */ + default: + TIFFWarning(TIFFFileName(tif), "using top-left orientation"); + img->orientation = ORIENTATION_TOPLEFT; + /* fall through... */ + case ORIENTATION_TOPLEFT: + break; } img->isContig = - !(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1); - if (img->isContig) - { - img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig; - } - else - { - img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate; + !(planarconfig == PLANARCONFIG_SEPARATE && colorchannels > 1); + if (img->isContig) { + img->get = TIFFIsTiled(tif) ? gtTileContig : gtStripContig; + } else { + img->get = TIFFIsTiled(tif) ? gtTileSeparate : gtStripSeparate; } return (1); } -int TIFFImageIterGet(TIFFImageIter *img, void *udata, uint32_t w, uint32_t h) +int +TIFFImageIterGet(TIFFImageIter* img, void *udata, uint32 w, uint32 h) { - if (img->get == NULL) - { - TIFFErrorExtR(img->tif, TIFFFileName(img->tif), - "No \"get\" routine setup"); - return (0); + if (img->get == NULL) { + TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No \"get\" routine setup"); + return (0); } - if (img->callback.any == NULL) - { - TIFFErrorExtR( - img->tif, TIFFFileName(img->tif), - "No \"put\" routine setupl; probably can not handle image format"); - return (0); + if (img->callback.any == NULL) { + TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), + "No \"put\" routine setupl; probably can not handle image format"); + return (0); } return (*img->get)(img, udata, w, h); } -TIFFImageIterEnd(TIFFImageIter *img) -{ /* Nothing to free... ? */ +TIFFImageIterEnd(TIFFImageIter* img) +{ + /* Nothing to free... ? */ } /* * Read the specified image into an ABGR-format raster. */ -int TIFFReadImageIter(TIFF *tif, uint32_t rwidth, uint32_t rheight, - uint8_t *raster, int stop) +int +TIFFReadImageIter(TIFF* tif, + uint32 rwidth, uint32 rheight, uint8* raster, int stop) { char emsg[1024]; TIFFImageIter img; int ok; - if (TIFFImageIterBegin(&img, tif, stop, emsg)) - { - /* XXX verify rwidth and rheight against width and height */ - ok = TIFFImageIterGet(&img, raster, rwidth, img.height); - TIFFImageIterEnd(&img); - } - else - { - TIFFErrorExtR(tif, TIFFFileName(tif), emsg); - ok = 0; + if (TIFFImageIterBegin(&img, tif, stop, emsg)) { + /* XXX verify rwidth and rheight against width and height */ + ok = TIFFImageIterGet(&img, raster, rwidth, img.height); + TIFFImageIterEnd(&img); + } else { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg); + ok = 0; } return (ok); } + /* * Get an tile-organized image that has * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 - */ -static int gtTileContig(TIFFImageIter *img, void *udata, uint32_t w, uint32_t h) + */ +static int +gtTileContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h) { - TIFF *tif = img->tif; + TIFF* tif = img->tif; ImageIterTileContigRoutine callback = img->callback.contig; - uint16_t orientation; - uint32_t col, row; - uint32_t tw, th; - u_char *buf; - int32_t fromskew; - uint32_t nrow; + uint16 orientation; + uint32 col, row; + uint32 tw, th; + u_char* buf; + int32 fromskew; + uint32 nrow; - buf = (u_char *)_TIFFmalloc(TIFFTileSize(tif)); - if (buf == 0) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer"); - return (0); + buf = (u_char*) _TIFFmalloc(TIFFTileSize(tif)); + if (buf == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); + return (0); } TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); orientation = img->orientation; - for (row = 0; row < h; row += th) - { - nrow = (row + th > h ? h - row : th); - for (col = 0; col < w; col += tw) - { - if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0 && img->stoponerr) - break; - if (col + tw > w) - { - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - uint32_t npix = w - col; - fromskew = tw - npix; - (*callback)(img, udata, col, row, npix, nrow, fromskew, buf); - } - else - { - (*callback)(img, udata, col, row, tw, nrow, 0, buf); - } - } + for (row = 0; row < h; row += th) { + nrow = (row + th > h ? h - row : th); + for (col = 0; col < w; col += tw) { + if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0 && img->stoponerr) + break; + if (col + tw > w) { + /* + * Tile is clipped horizontally. Calculate + * visible portion and skewing factors. + */ + uint32 npix = w - col; + fromskew = tw - npix; + (*callback)(img, udata, col, row, npix, nrow, fromskew, buf); + } else { + (*callback)(img, udata, col, row, tw, nrow, 0, buf); + } + } } _TIFFfree(buf); return (1); @@ -326,71 +301,63 @@ static int gtTileContig(TIFFImageIter *img, void *udata, uint32_t w, uint32_t h) * SamplesPerPixel > 1 * PlanarConfiguration separated * We assume that all such images are RGB. - */ -static int gtTileSeparate(TIFFImageIter *img, void *udata, uint32_t w, - uint32_t h) + */ +static int +gtTileSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h) { - TIFF *tif = img->tif; + TIFF* tif = img->tif; ImageIterTileSeparateRoutine callback = img->callback.separate; - uint16_t orientation; - uint32_t col, row; - uint32_t tw, th; - u_char *buf; - u_char *r; - u_char *g; - u_char *b; - u_char *a; + uint16 orientation; + uint32 col, row; + uint32 tw, th; + u_char* buf; + u_char* r; + u_char* g; + u_char* b; + u_char* a; tsize_t tilesize; - int32_t fromskew; + int32 fromskew; int alpha = img->alpha; - uint32_t nrow; + uint32 nrow; tilesize = TIFFTileSize(tif); - buf = (u_char *)_TIFFmalloc(4 * tilesize); - if (buf == 0) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer"); - return (0); + buf = (u_char*) _TIFFmalloc(4*tilesize); + if (buf == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); + return (0); } r = buf; g = r + tilesize; b = g + tilesize; a = b + tilesize; if (!alpha) - memset(a, 0xff, tilesize); + memset(a, 0xff, tilesize); TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); orientation = img->orientation; - for (row = 0; row < h; row += th) - { - nrow = (row + th > h ? h - row : th); - for (col = 0; col < w; col += tw) - { - if (TIFFReadTile(tif, r, col, row, 0, 0) < 0 && img->stoponerr) - break; - if (TIFFReadTile(tif, g, col, row, 0, 1) < 0 && img->stoponerr) - break; - if (TIFFReadTile(tif, b, col, row, 0, 2) < 0 && img->stoponerr) - break; - if (alpha && TIFFReadTile(tif, a, col, row, 0, 3) < 0 && - img->stoponerr) - break; - if (col + tw > w) - { - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - uint32_t npix = w - col; - fromskew = tw - npix; - (*callback)(img, udata, col, row, npix, nrow, fromskew, r, g, b, - a); - } - else - { - (*callback)(img, udata, col, row, tw, nrow, 0, r, g, b, a); - } - } + for (row = 0; row < h; row += th) { + nrow = (row + th > h ? h - row : th); + for (col = 0; col < w; col += tw) { + if (TIFFReadTile(tif, r, col, row,0,0) < 0 && img->stoponerr) + break; + if (TIFFReadTile(tif, g, col, row,0,1) < 0 && img->stoponerr) + break; + if (TIFFReadTile(tif, b, col, row,0,2) < 0 && img->stoponerr) + break; + if (alpha && TIFFReadTile(tif,a,col,row,0,3) < 0 && img->stoponerr) + break; + if (col + tw > w) { + /* + * Tile is clipped horizontally. Calculate + * visible portion and skewing factors. + */ + uint32 npix = w - col; + fromskew = tw - npix; + (*callback)(img, udata, col, row, npix, nrow, fromskew, r, g, b, a); + } else { + (*callback)(img, udata, col, row, tw, nrow, 0, r, g, b, a); + } + } } _TIFFfree(buf); return (1); @@ -401,38 +368,35 @@ static int gtTileSeparate(TIFFImageIter *img, void *udata, uint32_t w, * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 - */ -static int gtStripContig(TIFFImageIter *img, void *udata, uint32_t w, - uint32_t h) + */ +static int +gtStripContig(TIFFImageIter* img, void *udata, uint32 w, uint32 h) { - TIFF *tif = img->tif; + TIFF* tif = img->tif; ImageIterTileContigRoutine callback = img->callback.contig; - uint16_t orientation; - uint32_t row, nrow; - u_char *buf; - uint32_t rowsperstrip; - uint32_t imagewidth = img->width; + uint16 orientation; + uint32 row, nrow; + u_char* buf; + uint32 rowsperstrip; + uint32 imagewidth = img->width; tsize_t scanline; - int32_t fromskew; + int32 fromskew; - buf = (u_char *)_TIFFmalloc(TIFFStripSize(tif)); - if (buf == 0) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "No space for strip buffer"); - return (0); + buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif)); + if (buf == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for strip buffer"); + return (0); } orientation = img->orientation; TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); scanline = TIFFScanlineSize(tif); fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += rowsperstrip) - { - nrow = (row + rowsperstrip > h ? h - row : rowsperstrip); - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), buf, - nrow * scanline) < 0 && - img->stoponerr) - break; - (*callback)(img, udata, 0, row, w, nrow, fromskew, buf); + for (row = 0; row < h; row += rowsperstrip) { + nrow = (row + rowsperstrip > h ? h - row : rowsperstrip); + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), + buf, nrow*scanline) < 0 && img->stoponerr) + break; + (*callback)(img, udata, 0, row, w, nrow, fromskew, buf); } _TIFFfree(buf); return (1); @@ -444,58 +408,53 @@ static int gtStripContig(TIFFImageIter *img, void *udata, uint32_t w, * PlanarConfiguration separated * We assume that all such images are RGB. */ -static int gtStripSeparate(TIFFImageIter *img, void *udata, uint32_t w, - uint32_t h) +static int +gtStripSeparate(TIFFImageIter* img, void *udata, uint32 w, uint32 h) { - TIFF *tif = img->tif; + TIFF* tif = img->tif; ImageIterTileSeparateRoutine callback = img->callback.separate; - uint16_t orientation; + uint16 orientation; u_char *buf; u_char *r, *g, *b, *a; - uint32_t row, nrow; + uint32 row, nrow; tsize_t scanline; - uint32_t rowsperstrip; - uint32_t imagewidth = img->width; + uint32 rowsperstrip; + uint32 imagewidth = img->width; tsize_t stripsize; - int32_t fromskew; + int32 fromskew; int alpha = img->alpha; stripsize = TIFFStripSize(tif); - r = buf = (u_char *)_TIFFmalloc(4 * stripsize); - if (buf == 0) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer"); - return (0); + r = buf = (u_char *)_TIFFmalloc(4*stripsize); + if (buf == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for tile buffer"); + return (0); } g = r + stripsize; b = g + stripsize; a = b + stripsize; if (!alpha) - memset(a, 0xff, stripsize); + memset(a, 0xff, stripsize); orientation = img->orientation; TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); scanline = TIFFScanlineSize(tif); fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += rowsperstrip) - { - nrow = (row + rowsperstrip > h ? h - row : rowsperstrip); - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), r, - nrow * scanline) < 0 && - img->stoponerr) - break; - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 1), g, - nrow * scanline) < 0 && - img->stoponerr) - break; - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 2), b, - nrow * scanline) < 0 && - img->stoponerr) - break; - if (alpha && (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 3), - a, nrow * scanline) < 0 && - img->stoponerr)) - break; - (*callback)(img, udata, 0, row, w, nrow, fromskew, r, g, b, a); + for (row = 0; row < h; row += rowsperstrip) { + nrow = (row + rowsperstrip > h ? h - row : rowsperstrip); + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), + r, nrow*scanline) < 0 && img->stoponerr) + break; + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 1), + g, nrow*scanline) < 0 && img->stoponerr) + break; + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 2), + b, nrow*scanline) < 0 && img->stoponerr) + break; + if (alpha && + (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 3), + a, nrow*scanline) < 0 && img->stoponerr)) + break; + (*callback)(img, udata, 0, row, w, nrow, fromskew, r, g, b, a); } _TIFFfree(buf); return (1); @@ -503,18 +462,18 @@ static int gtStripSeparate(TIFFImageIter *img, void *udata, uint32_t w, DECLAREContigCallbackFunc(TestContigCallback) { - printf("Contig Callback called with x = %d, y = %d, w = %d, h = %d, " - "fromskew = %d\n", - x, y, w, h, fromskew); + printf("Contig Callback called with x = %d, y = %d, w = %d, h = %d, fromskew = %d\n", + x, y, w, h, fromskew); } + DECLARESepCallbackFunc(TestSepCallback) { - printf("Sep Callback called with x = %d, y = %d, w = %d, h = %d, fromskew " - "= %d\n", - x, y, w, h, fromskew); + printf("Sep Callback called with x = %d, y = %d, w = %d, h = %d, fromskew = %d\n", + x, y, w, h, fromskew); } + #ifdef MAIN main(int argc, char **argv) { @@ -530,35 +489,35 @@ main(int argc, char **argv) unsigned char *ColorMap; unsigned char *data; - if (argc < 2) - { - fprintf(stderr, "usage: %s tiff_file\n", argv[0]); - exit(1); + if (argc < 2) { + fprintf(stderr,"usage: %s tiff_file\n",argv[0]); + exit(1); } - tif = (TIFF *)PLIGetImage(argv[1], (void *)&data, &ColorMap, &nx, &ny, - &BitsPerSample, &SamplesPerPixel, &isColorMapped, - &isPliFile); - if (tif != NULL) - { + tif = (TIFF *)PLIGetImage(argv[1], (void *) &data, &ColorMap, + &nx, &ny, &BitsPerSample, &SamplesPerPixel, + &isColorMapped, &isPliFile); + if (tif != NULL) { - if (TIFFImageIterBegin(&img, tif, stop, emsg)) - { - /* Here need to set data and callback function! */ - if (img.isContig) - { - img.callback = TestContigCallback; - } - else - { - img.callback = TestSepCallback; - } - ok = TIFFImageIterGet(&img, NULL, img.width, img.height); - TIFFImageIterEnd(&img); - } - else - { - TIFFErrorExtR(tif, TIFFFileName(tif), emsg); - } + if (TIFFImageIterBegin(&img, tif, stop, emsg)) { + /* Here need to set data and callback function! */ + if (img.isContig) { + img.callback = TestContigCallback; + } else { + img.callback = TestSepCallback; + } + ok = TIFFImageIterGet(&img, NULL, img.width, img.height); + TIFFImageIterEnd(&img); + } else { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), emsg); + } } + } #endif +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_imageiter.h b/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_imageiter.h index 9e79f1ebe..4f4fd2791 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_imageiter.h +++ b/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_imageiter.h @@ -7,45 +7,58 @@ typedef struct _TIFFImageIter TIFFImageIter; img->samplesperpixel consecutive samples each containing img->bitspersample bits of data. The array pp is ordered in h consecutive rows of w+fromskew pixels each. */ -typedef void (*ImageIterTileContigRoutine)(TIFFImageIter *, void *, uint32_t, - uint32_t, uint32_t, uint32_t, - int32_t, unsigned char *); -#define DECLAREContigCallbackFunc(name) \ - static void name(TIFFImageIter *img, void *user_data, uint32_t x, \ - uint32_t y, uint32_t w, uint32_t h, int32_t fromskew, \ - u_char *pp) +typedef void (*ImageIterTileContigRoutine) + (TIFFImageIter*, void *, uint32, uint32, uint32, uint32, int32, + unsigned char*); +#define DECLAREContigCallbackFunc(name) \ +static void name(\ + TIFFImageIter* img, \ + void* user_data, \ + uint32 x, uint32 y, \ + uint32 w, uint32 h, \ + int32 fromskew, \ + u_char* pp \ +) -typedef void (*ImageIterTileSeparateRoutine)(TIFFImageIter *, void *, uint32_t, - uint32_t, uint32_t, uint32_t, - int32_t, unsigned char *, - unsigned char *, unsigned char *, - unsigned char *); -#define DECLARESepCallbackFunc(name) \ - static void name(TIFFImageIter *img, void *user_data, uint32_t x, \ - uint32_t y, uint32_t w, uint32_t h, int32_t fromskew, \ - u_char *r, u_char *g, u_char *b, u_char *a) +typedef void (*ImageIterTileSeparateRoutine) + (TIFFImageIter*, void *, uint32, uint32, uint32, uint32, int32, + unsigned char*, unsigned char*, unsigned char*, unsigned char*); +#define DECLARESepCallbackFunc(name) \ +static void name(\ + TIFFImageIter* img, \ + void* user_data, \ + uint32 x, uint32 y, \ + uint32 w, uint32 h,\ + int32 fromskew, \ + u_char* r, u_char* g, u_char* b, u_char* a\ +) -struct _TIFFImageIter -{ - TIFF *tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - 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 photometric; /* image photometric interp */ - uint16_t *redcmap; /* colormap palette */ - uint16_t *greencmap; - uint16_t *bluecmap; - /* get image data routine */ - int (*get)(TIFFImageIter *, void *udata, uint32_t, uint32_t); - union - { - void (*any)(TIFFImageIter *); - ImageIterTileContigRoutine contig; - ImageIterTileSeparateRoutine separate; - } callback; /* fn to exec for each block */ +struct _TIFFImageIter { + TIFF* tif; /* image handle */ + int stoponerr; /* stop on read error */ + int isContig; /* data is packed/separate */ + int alpha; /* type of alpha data present */ + uint32 width; /* image width */ + uint32 height; /* image height */ + uint16 bitspersample; /* image bits/sample */ + uint16 samplesperpixel; /* image samples/pixel */ + uint16 orientation; /* image orientation */ + uint16 photometric; /* image photometric interp */ + uint16* redcmap; /* colormap palette */ + uint16* greencmap; + uint16* bluecmap; + /* get image data routine */ + int (*get)(TIFFImageIter*, void *udata, uint32, uint32); + union { + void (*any)(TIFFImageIter*); + ImageIterTileContigRoutine contig; + ImageIterTileSeparateRoutine separate; + } callback; /* fn to exec for each block */ }; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_pdsdirread.c b/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_pdsdirread.c index 653141d82..cc6231da5 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_pdsdirread.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_pdsdirread.c @@ -3,38 +3,38 @@ * Copyright (c) 1991-1996 Silicon Graphics, Inc. * Copyright (c( 1996 USAF Phillips Laboratory * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library. - * + * * These routines written by Conrad J. Poelman on a single late-night of * March 20-21, 1996. * * The entire purpose of this file is to provide a single external function, - * TIFFReadPrivateDataSubDirectory(). This function is intended for use in - * reading a private subdirectory from a TIFF file into a private structure. The + * TIFFReadPrivateDataSubDirectory(). This function is intended for use in reading a + * private subdirectory from a TIFF file into a private structure. The * actual writing of data into the structure is handled by the setFieldFn(), - * which is passed to TIFFReadPrivateDataSubDirectory() as a parameter. The idea - * is to enable any application wishing to store private subdirectories to do so + * which is passed to TIFFReadPrivateDataSubDirectory() as a parameter. The idea is to + * enable any application wishing to store private subdirectories to do so * easily using this function, without modifying the TIFF library. * * The astute observer will notice that only two functions are at all different @@ -49,45 +49,46 @@ #include "tiffiop.h" -#define IGNORE 0 /* tag placeholder used below */ +#define IGNORE 0 /* tag placeholder used below */ #if HAVE_IEEEFP -#define TIFFCvtIEEEFloatToNative(tif, n, fp) -#define TIFFCvtIEEEDoubleToNative(tif, n, dp) +#define TIFFCvtIEEEFloatToNative(tif, n, fp) +#define TIFFCvtIEEEDoubleToNative(tif, n, dp) #else -extern void TIFFCvtIEEEFloatToNative(TIFF *, uint32_t, float *); -extern void TIFFCvtIEEEDoubleToNative(TIFF *, uint32_t, double *); +extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); +extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); #endif -static void EstimateStripByteCounts(TIFF *, TIFFDirEntry *, uint16_t); -static void MissingRequired(TIFF *, const char *); -static int CheckDirCount(TIFF *, TIFFDirEntry *, uint32_t); -static tsize_t TIFFFetchData(TIFF *, TIFFDirEntry *, char *); -static tsize_t TIFFFetchString(TIFF *, TIFFDirEntry *, char *); -static float TIFFFetchRational(TIFF *, TIFFDirEntry *); -static int TIFFFetchNormalSubTag(TIFF *, TIFFDirEntry *, const TIFFFieldInfo *, - int (*getFieldFn)(TIFF *tif, ttag_t tag, ...)); -static int TIFFFetchPerSampleShorts(TIFF *, TIFFDirEntry *, int *); -static int TIFFFetchPerSampleAnys(TIFF *, TIFFDirEntry *, double *); -static int TIFFFetchShortArray(TIFF *, TIFFDirEntry *, uint16_t *); -static int TIFFFetchStripThing(TIFF *, TIFFDirEntry *, long, uint32_t **); -static int TIFFFetchExtraSamples(TIFF *, TIFFDirEntry *); -static int TIFFFetchRefBlackWhite(TIFF *, TIFFDirEntry *); -static float TIFFFetchFloat(TIFF *, TIFFDirEntry *); -static int TIFFFetchFloatArray(TIFF *, TIFFDirEntry *, float *); -static int TIFFFetchDoubleArray(TIFF *, TIFFDirEntry *, double *); -static int TIFFFetchAnyArray(TIFF *, TIFFDirEntry *, double *); -static int TIFFFetchShortPair(TIFF *, TIFFDirEntry *); +static void EstimateStripByteCounts(TIFF*, TIFFDirEntry*, uint16); +static void MissingRequired(TIFF*, const char*); +static int CheckDirCount(TIFF*, TIFFDirEntry*, uint32); +static tsize_t TIFFFetchData(TIFF*, TIFFDirEntry*, char*); +static tsize_t TIFFFetchString(TIFF*, TIFFDirEntry*, char*); +static float TIFFFetchRational(TIFF*, TIFFDirEntry*); +static int TIFFFetchNormalSubTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*, + int (*getFieldFn)(TIFF *tif,ttag_t tag,...)); +static int TIFFFetchPerSampleShorts(TIFF*, TIFFDirEntry*, int*); +static int TIFFFetchPerSampleAnys(TIFF*, TIFFDirEntry*, double*); +static int TIFFFetchShortArray(TIFF*, TIFFDirEntry*, uint16*); +static int TIFFFetchStripThing(TIFF*, TIFFDirEntry*, long, uint32**); +static int TIFFFetchExtraSamples(TIFF*, TIFFDirEntry*); +static int TIFFFetchRefBlackWhite(TIFF*, TIFFDirEntry*); +static float TIFFFetchFloat(TIFF*, TIFFDirEntry*); +static int TIFFFetchFloatArray(TIFF*, TIFFDirEntry*, float*); +static int TIFFFetchDoubleArray(TIFF*, TIFFDirEntry*, double*); +static int TIFFFetchAnyArray(TIFF*, TIFFDirEntry*, double*); +static int TIFFFetchShortPair(TIFF*, TIFFDirEntry*); #if STRIPCHOP_SUPPORT -static void ChopUpSingleUncompressedStrip(TIFF *); +static void ChopUpSingleUncompressedStrip(TIFF*); #endif -static char *CheckMalloc(TIFF *tif, tsize_t n, const char *what) +static char * +CheckMalloc(TIFF* tif, tsize_t n, const char* what) { - char *cp = (char *)_TIFFmalloc(n); - if (cp == NULL) - TIFFErrorExtR(tif, tif->tif_name, "No space %s", what); - return (cp); + char *cp = (char*)_TIFFmalloc(n); + if (cp == NULL) + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space %s", what); + return (cp); } /* Just as was done with TIFFWritePrivateDataSubDirectory(), here we implement @@ -110,254 +111,233 @@ static char *CheckMalloc(TIFF *tif, tsize_t n, const char *what) any required fields after reading the directory in. */ -int TIFFReadPrivateDataSubDirectory(TIFF *tif, toff_t pdir_offset, - TIFFFieldInfo *field_info, - int (*setFieldFn)(TIFF *tif, ttag_t tag, - ...)) + +int +TIFFReadPrivateDataSubDirectory(TIFF* tif, toff_t pdir_offset, + TIFFFieldInfo *field_info, + int (*setFieldFn)(TIFF *tif, ttag_t tag, ...)) { - register TIFFDirEntry *dp; - register int n; - register TIFFDirectory *td; - TIFFDirEntry *dir; - int iv; - long v; - double dv; - const TIFFFieldInfo *fip; - int fix; - uint16_t dircount; - uint32_t nextdiroff; - char *cp; - int diroutoforderwarning = 0; + register TIFFDirEntry* dp; + register int n; + register TIFFDirectory* td; + TIFFDirEntry* dir; + int iv; + long v; + double dv; + const TIFFFieldInfo* fip; + int fix; + uint16 dircount; + uint32 nextdiroff; + char* cp; + int diroutoforderwarning = 0; - /* Skipped part about checking for directories or compression data. */ + /* Skipped part about checking for directories or compression data. */ - if (!isMapped(tif)) - { - if (!SeekOK(tif, pdir_offset)) - { - TIFFErrorExtR(tif, tif->tif_name, - "Seek error accessing TIFF private subdirectory"); - return (0); - } - if (!ReadOK(tif, &dircount, sizeof(uint16_t))) - { - TIFFErrorExtR(tif, tif->tif_name, - "Can not read TIFF private subdirectory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)CheckMalloc(tif, dircount * sizeof(TIFFDirEntry), - "to read TIFF private subdirectory"); - if (dir == NULL) - return (0); - if (!ReadOK(tif, dir, dircount * sizeof(TIFFDirEntry))) - { - TIFFErrorExtR(tif, tif->tif_name, - "Can not read TIFF private subdirectory"); - goto bad; - } - /* - * Read offset to next directory for sequential scans. - */ - (void)ReadOK(tif, &nextdiroff, sizeof(uint32_t)); - } - else - { - toff_t off = pdir_offset; + if (!isMapped(tif)) { + if (!SeekOK(tif, pdir_offset)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Seek error accessing TIFF private subdirectory"); + return (0); + } + if (!ReadOK(tif, &dircount, sizeof (uint16))) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Can not read TIFF private subdirectory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + dir = (TIFFDirEntry *)CheckMalloc(tif, + dircount * sizeof (TIFFDirEntry), "to read TIFF private subdirectory"); + if (dir == NULL) + return (0); + if (!ReadOK(tif, dir, dircount*sizeof (TIFFDirEntry))) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Can not read TIFF private subdirectory"); + goto bad; + } + /* + * Read offset to next directory for sequential scans. + */ + (void) ReadOK(tif, &nextdiroff, sizeof (uint32)); + } else { + toff_t off = pdir_offset; - if (off + sizeof(short) > tif->tif_size) - { - TIFFErrorExtR(tif, tif->tif_name, - "Can not read TIFF private subdirectory count"); - return (0); - } - else - _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof(uint16_t)); - off += sizeof(uint16_t); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - dir = (TIFFDirEntry *)CheckMalloc(tif, dircount * sizeof(TIFFDirEntry), - "to read TIFF private subdirectory"); - if (dir == NULL) - return (0); - if (off + dircount * sizeof(TIFFDirEntry) > tif->tif_size) - { - TIFFErrorExtR(tif, tif->tif_name, - "Can not read TIFF private subdirectory"); - goto bad; - } - else - _TIFFmemcpy(dir, tif->tif_base + off, - dircount * sizeof(TIFFDirEntry)); - off += dircount * sizeof(TIFFDirEntry); - if (off + sizeof(uint32_t) < tif->tif_size) - _TIFFmemcpy(&nextdiroff, tif->tif_base + off, sizeof(uint32_t)); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdiroff); + if (off + sizeof (short) > tif->tif_size) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Can not read TIFF private subdirectory count"); + return (0); + } else + _TIFFmemcpy(&dircount, tif->tif_base + off, sizeof (uint16)); + off += sizeof (uint16); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + dir = (TIFFDirEntry *)CheckMalloc(tif, + dircount * sizeof (TIFFDirEntry), "to read TIFF private subdirectory"); + if (dir == NULL) + return (0); + if (off + dircount*sizeof (TIFFDirEntry) > tif->tif_size) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Can not read TIFF private subdirectory"); + goto bad; + } else + _TIFFmemcpy(dir, tif->tif_base + off, + dircount*sizeof (TIFFDirEntry)); + off += dircount* sizeof (TIFFDirEntry); + if (off + sizeof (uint32) < tif->tif_size) + _TIFFmemcpy(&nextdiroff, tif->tif_base+off, sizeof (uint32)); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextdiroff); - /* - * Setup default value and then make a pass over - * the fields to check type and tag information, - * and to extract info required to size data - * structures. A second pass is made afterwards - * to read in everything not taken in the first pass. - */ - td = &tif->tif_dir; + /* + * Setup default value and then make a pass over + * the fields to check type and tag information, + * and to extract info required to size data + * structures. A second pass is made afterwards + * to read in everything not taken in the first pass. + */ + td = &tif->tif_dir; + + for (fip = field_info, dp = dir, n = dircount; + n > 0; n--, dp++) { + if (tif->tif_flags & TIFF_SWAB) { + TIFFSwabArrayOfShort(&dp->tdir_tag, 2); + TIFFSwabArrayOfLong(&dp->tdir_count, 2); + } + /* + * Find the field information entry for this tag. + */ + /* + * Silicon Beach (at least) writes unordered + * directory tags (violating the spec). Handle + * it here, but be obnoxious (maybe they'll fix it?). + */ + if (dp->tdir_tag < fip->field_tag) { + if (!diroutoforderwarning) { + TIFFWarning(tif->tif_name, + "invalid TIFF private subdirectory; tags are not sorted in ascending order"); + diroutoforderwarning = 1; + } + fip = field_info; /* O(n^2) */ + } - for (fip = field_info, dp = dir, n = dircount; n > 0; n--, dp++) - { - if (tif->tif_flags & TIFF_SWAB) - { - TIFFSwabArrayOfShort(&dp->tdir_tag, 2); - TIFFSwabArrayOfLong(&dp->tdir_count, 2); - } - /* - * Find the field information entry for this tag. - */ - /* - * Silicon Beach (at least) writes unordered - * directory tags (violating the spec). Handle - * it here, but be obnoxious (maybe they'll fix it?). - */ - if (dp->tdir_tag < fip->field_tag) - { - if (!diroutoforderwarning) - { - TIFFWarning(tif->tif_name, - "invalid TIFF private subdirectory; tags are not " - "sorted in ascending order"); - diroutoforderwarning = 1; - } - fip = field_info; /* O(n^2) */ - } + while (fip->field_tag && fip->field_tag < dp->tdir_tag) + fip++; + if (!fip->field_tag || fip->field_tag != dp->tdir_tag) { + TIFFWarning(tif->tif_name, + "unknown field with tag %d (0x%x) in private subdirectory ignored", + dp->tdir_tag, dp->tdir_tag); + dp->tdir_tag = IGNORE; + fip = field_info;/* restart search */ + continue; + } + /* + * Null out old tags that we ignore. + */ - while (fip->field_tag && fip->field_tag < dp->tdir_tag) - fip++; - if (!fip->field_tag || fip->field_tag != dp->tdir_tag) - { - TIFFWarning(tif->tif_name, - "unknown field with tag %d (0x%x) in private " - "subdirectory ignored", - dp->tdir_tag, dp->tdir_tag); - dp->tdir_tag = IGNORE; - fip = field_info; /* restart search */ - continue; - } - /* - * Null out old tags that we ignore. - */ + /* Not implemented yet, since FIELD_IGNORE is specific to + the main directories. Could pass this in too... */ + if (0 /* && fip->field_bit == FIELD_IGNORE */) { + ignore: + dp->tdir_tag = IGNORE; + continue; + } - /* Not implemented yet, since FIELD_IGNORE is specific to - the main directories. Could pass this in too... */ - if (0 /* && fip->field_bit == FIELD_IGNORE */) - { - ignore: - dp->tdir_tag = IGNORE; - continue; - } + /* + * Check data type. + */ - /* - * Check data type. - */ + while (dp->tdir_type != (u_short)fip->field_type) { + if (fip->field_type == TIFF_ANY) /* wildcard */ + break; + fip++; + if (!fip->field_tag || fip->field_tag != dp->tdir_tag) { + TIFFWarning(tif->tif_name, + "wrong data type %d for \"%s\"; tag ignored", + dp->tdir_type, fip[-1].field_name); + goto ignore; + } + } + /* + * Check count if known in advance. + */ + if (fip->field_readcount != TIFF_VARIABLE) { + uint32 expected = (fip->field_readcount == TIFF_SPP) ? + (uint32) td->td_samplesperpixel : + (uint32) fip->field_readcount; + if (!CheckDirCount(tif, dp, expected)) + goto ignore; + } - while (dp->tdir_type != (u_short)fip->field_type) - { - if (fip->field_type == TIFF_ANY) /* wildcard */ - break; - fip++; - if (!fip->field_tag || fip->field_tag != dp->tdir_tag) - { - TIFFWarning(tif->tif_name, - "wrong data type %d for \"%s\"; tag ignored", - dp->tdir_type, fip[-1].field_name); - goto ignore; - } - } - /* - * Check count if known in advance. - */ - if (fip->field_readcount != TIFF_VARIABLE) - { - uint32_t expected = (fip->field_readcount == TIFF_SPP) - ? (uint32_t)td->td_samplesperpixel - : (uint32_t)fip->field_readcount; - if (!CheckDirCount(tif, dp, expected)) - goto ignore; - } + /* Now read in and process data from field. */ + if (!TIFFFetchNormalSubTag(tif, dp, fip, setFieldFn)) + goto bad; - /* Now read in and process data from field. */ - if (!TIFFFetchNormalSubTag(tif, dp, fip, setFieldFn)) - goto bad; - } + } - if (dir) - _TIFFfree(dir); - return (1); + if (dir) + _TIFFfree(dir); + return (1); bad: - if (dir) - _TIFFfree(dir); - return (0); + if (dir) + _TIFFfree(dir); + return (0); } -static void EstimateStripByteCounts(TIFF *tif, TIFFDirEntry *dir, - uint16_t dircount) +static void +EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) { - register TIFFDirEntry *dp; - register TIFFDirectory *td = &tif->tif_dir; - uint16_t i; + register TIFFDirEntry *dp; + register TIFFDirectory *td = &tif->tif_dir; + uint16 i; - if (td->td_stripbytecount) - _TIFFfree(td->td_stripbytecount); - td->td_stripbytecount = - (uint32_t *)CheckMalloc(tif, td->td_nstrips * sizeof(uint32_t), - "for \"StripByteCounts\" array"); - if (td->td_compression != COMPRESSION_NONE) - { - uint32_t space = - (uint32_t)(sizeof(TIFFHeader) + sizeof(uint16_t) + - (dircount * sizeof(TIFFDirEntry)) + sizeof(uint32_t)); - toff_t filesize = TIFFGetFileSize(tif); - uint16_t n; + if (td->td_stripbytecount) + _TIFFfree(td->td_stripbytecount); + td->td_stripbytecount = (uint32*) + CheckMalloc(tif, td->td_nstrips * sizeof (uint32), + "for \"StripByteCounts\" array"); + if (td->td_compression != COMPRESSION_NONE) { + uint32 space = (uint32)(sizeof (TIFFHeader) + + sizeof (uint16) + + (dircount * sizeof (TIFFDirEntry)) + + sizeof (uint32)); + toff_t filesize = TIFFGetFileSize(tif); + uint16 n; - /* calculate amount of space used by indirect values */ - for (dp = dir, n = dircount; n > 0; n--, dp++) - { - uint32_t cc = dp->tdir_count * TIFFDataWidth(dp->tdir_type); - if (cc > sizeof(uint32_t)) - space += cc; - } - space = (filesize - space) / td->td_samplesperpixel; - for (i = 0; i < td->td_nstrips; i++) - td->td_stripbytecount[i] = space; - /* - * This gross hack handles the case were the offset to - * the last strip is past the place where we think the strip - * should begin. Since a strip of data must be contiguous, - * it's safe to assume that we've overestimated the amount - * of data in the strip and trim this number back accordingly. - */ - i--; - if (td->td_stripoffset[i] + td->td_stripbytecount[i] > filesize) - td->td_stripbytecount[i] = filesize - td->td_stripoffset[i]; - } - else - { - uint32_t rowbytes = TIFFScanlineSize(tif); - uint32_t rowsperstrip = td->td_imagelength / td->td_nstrips; - for (i = 0; i < td->td_nstrips; i++) - td->td_stripbytecount[i] = rowbytes * rowsperstrip; - } - TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); - if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) - td->td_rowsperstrip = td->td_imagelength; + /* calculate amount of space used by indirect values */ + for (dp = dir, n = dircount; n > 0; n--, dp++) { + uint32 cc = dp->tdir_count*TIFFDataWidth(dp->tdir_type); + if (cc > sizeof (uint32)) + space += cc; + } + space = (filesize - space) / td->td_samplesperpixel; + for (i = 0; i < td->td_nstrips; i++) + td->td_stripbytecount[i] = space; + /* + * This gross hack handles the case were the offset to + * the last strip is past the place where we think the strip + * should begin. Since a strip of data must be contiguous, + * it's safe to assume that we've overestimated the amount + * of data in the strip and trim this number back accordingly. + */ + i--; + if (td->td_stripoffset[i] + td->td_stripbytecount[i] > filesize) + td->td_stripbytecount[i] = + filesize - td->td_stripoffset[i]; + } else { + uint32 rowbytes = TIFFScanlineSize(tif); + uint32 rowsperstrip = td->td_imagelength / td->td_nstrips; + for (i = 0; i < td->td_nstrips; i++) + td->td_stripbytecount[i] = rowbytes*rowsperstrip; + } + TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); + if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) + td->td_rowsperstrip = td->td_imagelength; } -static void MissingRequired(TIFF *tif, const char *tagname) +static void +MissingRequired(TIFF* tif, const char* tagname) { - TIFFErrorExtR(tif, tif->tif_name, - "TIFF directory is missing required \"%s\" field", tagname); + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "TIFF directory is missing required \"%s\" field", tagname); } /* @@ -366,107 +346,99 @@ static void MissingRequired(TIFF *tif, const char *tagname) * is expected to skip/ignore the tag if * there is a mismatch. */ -static int CheckDirCount(TIFF *tif, TIFFDirEntry *dir, uint32_t count) +static int +CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) { - if (count != dir->tdir_count) - { - TIFFWarning(tif->tif_name, - "incorrect count for field \"%s\" (%lu, expecting %lu); " - "tag ignored", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, - dir->tdir_count, count); - return (0); - } - return (1); + if (count != dir->tdir_count) { + TIFFWarning(tif->tif_name, + "incorrect count for field \"%s\" (%lu, expecting %lu); tag ignored", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, + dir->tdir_count, count); + return (0); + } + return (1); } /* * Fetch a contiguous directory item. */ -static tsize_t TIFFFetchData(TIFF *tif, TIFFDirEntry *dir, char *cp) +static tsize_t +TIFFFetchData(TIFF* tif, TIFFDirEntry* dir, char* cp) { - int w = TIFFDataWidth(dir->tdir_type); - tsize_t cc = dir->tdir_count * w; + int w = TIFFDataWidth(dir->tdir_type); + tsize_t cc = dir->tdir_count * w; - if (!isMapped(tif)) - { - if (!SeekOK(tif, dir->tdir_offset)) - goto bad; - if (!ReadOK(tif, cp, cc)) - goto bad; - } - else - { - if (dir->tdir_offset + cc > tif->tif_size) - goto bad; - _TIFFmemcpy(cp, tif->tif_base + dir->tdir_offset, cc); - } - if (tif->tif_flags & TIFF_SWAB) - { - switch (dir->tdir_type) - { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16_t *)cp, dir->tdir_count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32_t *)cp, dir->tdir_count); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32_t *)cp, 2 * dir->tdir_count); - break; - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double *)cp, dir->tdir_count); - break; - } - } - return (cc); + if (!isMapped(tif)) { + if (!SeekOK(tif, dir->tdir_offset)) + goto bad; + if (!ReadOK(tif, cp, cc)) + goto bad; + } else { + if (dir->tdir_offset + cc > tif->tif_size) + goto bad; + _TIFFmemcpy(cp, tif->tif_base + dir->tdir_offset, cc); + } + if (tif->tif_flags & TIFF_SWAB) { + switch (dir->tdir_type) { + case TIFF_SHORT: + case TIFF_SSHORT: + TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); + break; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); + break; + case TIFF_DOUBLE: + TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); + break; + } + } + return (cc); bad: - TIFFErrorExtR(tif, tif->tif_name, "Error fetching data for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return ((tsize_t)0); + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error fetching data for field \"%s\"", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); + return ((tsize_t) 0); } /* * Fetch an ASCII item from the file. */ -static tsize_t TIFFFetchString(TIFF *tif, TIFFDirEntry *dir, char *cp) +static tsize_t +TIFFFetchString(TIFF* tif, TIFFDirEntry* dir, char* cp) { - if (dir->tdir_count <= 4) - { - uint32_t l = dir->tdir_offset; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&l); - _TIFFmemcpy(cp, &l, dir->tdir_count); - return (1); - } - return (TIFFFetchData(tif, dir, cp)); + if (dir->tdir_count <= 4) { + uint32 l = dir->tdir_offset; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&l); + _TIFFmemcpy(cp, &l, dir->tdir_count); + return (1); + } + return (TIFFFetchData(tif, dir, cp)); } /* * Convert numerator+denominator to float. */ -static int cvtRational(TIFF *tif, TIFFDirEntry *dir, uint32_t num, - uint32_t denom, float *rv) +static int +cvtRational(TIFF* tif, TIFFDirEntry* dir, uint32 num, uint32 denom, float* rv) { - if (denom == 0) - { - TIFFErrorExtR(tif, tif->tif_name, - "%s: Rational with zero denominator (num = %lu)", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, num); - return (0); - } - else - { - if (dir->tdir_type == TIFF_RATIONAL) - *rv = ((float)num / (float)denom); - else - *rv = ((float)(int32_t)num / (float)(int32_t)denom); - return (1); - } + if (denom == 0) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%s: Rational with zero denominator (num = %lu)", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name, num); + return (0); + } else { + if (dir->tdir_type == TIFF_RATIONAL) + *rv = ((float)num / (float)denom); + else + *rv = ((float)(int32)num / (float)(int32)denom); + return (1); + } } /* @@ -474,15 +446,14 @@ static int cvtRational(TIFF *tif, TIFFDirEntry *dir, uint32_t num, * at offset off and return the value * as a floating point number. */ -static float TIFFFetchRational(TIFF *tif, TIFFDirEntry *dir) +static float +TIFFFetchRational(TIFF* tif, TIFFDirEntry* dir) { - uint32_t l[2]; - float v; + uint32 l[2]; + float v; - return (!TIFFFetchData(tif, dir, (char *)l) || - !cvtRational(tif, dir, l[0], l[1], &v) - ? 1.0f - : v); + return (!TIFFFetchData(tif, dir, (char *)l) || + !cvtRational(tif, dir, l[0], l[1], &v) ? 1.0f : v); } /* @@ -490,205 +461,178 @@ static float TIFFFetchRational(TIFF *tif, TIFFDirEntry *dir) * from the offset field and return it * as a native float. */ -static float TIFFFetchFloat(TIFF *tif, TIFFDirEntry *dir) +static float +TIFFFetchFloat(TIFF* tif, TIFFDirEntry* dir) { - /* This appears to be a flagrant bug in the TIFF library, yet I - actually don't understand how it could have ever worked the old - way. Look at the comments in my new code and you'll understand. */ + /* This appears to be a flagrant bug in the TIFF library, yet I + actually don't understand how it could have ever worked the old + way. Look at the comments in my new code and you'll understand. */ #if (0) - float v = (float)TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); - TIFFCvtIEEEFloatToNative(tif, 1, &v); + float v = (float) + TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); + TIFFCvtIEEEFloatToNative(tif, 1, &v); #else - float v; - /* This is a little bit tricky - if we just cast the uint32_t to a float, - C will perform a numerical conversion, which is not what we want. - We want to take the actual bit pattern in the uint32_t and interpret - it as a float. Thus we cast a uint32_t * into a float * and then - dereference to get v. */ - uint32_t l = - (uint32_t)TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); - v = *(float *)&l; - TIFFCvtIEEEFloatToNative(tif, 1, &v); + float v; + /* This is a little bit tricky - if we just cast the uint32 to a float, + C will perform a numerical conversion, which is not what we want. + We want to take the actual bit pattern in the uint32 and interpret + it as a float. Thus we cast a uint32 * into a float * and then + dereference to get v. */ + uint32 l = (uint32) + TIFFExtractData(tif, dir->tdir_type, dir->tdir_offset); + v = * (float *) &l; + TIFFCvtIEEEFloatToNative(tif, 1, &v); #endif - return (v); + return (v); + } /* * Fetch an array of BYTE or SBYTE values. */ -static int TIFFFetchByteArray(TIFF *tif, TIFFDirEntry *dir, uint16_t *v) +static int +TIFFFetchByteArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) { - if (dir->tdir_count <= 4) - { - /* - * Extract data from offset field. - */ - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) - { - switch (dir->tdir_count) - { - case 4: - v[3] = dir->tdir_offset & 0xff; - case 3: - v[2] = (dir->tdir_offset >> 8) & 0xff; - case 2: - v[1] = (dir->tdir_offset >> 16) & 0xff; - case 1: - v[0] = dir->tdir_offset >> 24; - } - } - else - { - switch (dir->tdir_count) - { - case 4: - v[3] = dir->tdir_offset >> 24; - case 3: - v[2] = (dir->tdir_offset >> 16) & 0xff; - case 2: - v[1] = (dir->tdir_offset >> 8) & 0xff; - case 1: - v[0] = dir->tdir_offset & 0xff; - } - } - return (1); - } - else - return (TIFFFetchData(tif, dir, (char *)v) != 0); /* XXX */ + if (dir->tdir_count <= 4) { + /* + * Extract data from offset field. + */ + if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { + switch (dir->tdir_count) { + case 4: v[3] = dir->tdir_offset & 0xff; + case 3: v[2] = (dir->tdir_offset >> 8) & 0xff; + case 2: v[1] = (dir->tdir_offset >> 16) & 0xff; + case 1: v[0] = dir->tdir_offset >> 24; + } + } else { + switch (dir->tdir_count) { + case 4: v[3] = dir->tdir_offset >> 24; + case 3: v[2] = (dir->tdir_offset >> 16) & 0xff; + case 2: v[1] = (dir->tdir_offset >> 8) & 0xff; + case 1: v[0] = dir->tdir_offset & 0xff; + } + } + return (1); + } else + return (TIFFFetchData(tif, dir, (char*) v) != 0); /* XXX */ } /* * Fetch an array of SHORT or SSHORT values. */ -static int TIFFFetchShortArray(TIFF *tif, TIFFDirEntry *dir, uint16_t *v) +static int +TIFFFetchShortArray(TIFF* tif, TIFFDirEntry* dir, uint16* v) { - if (dir->tdir_count <= 2) - { - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) - { - switch (dir->tdir_count) - { - case 2: - v[1] = dir->tdir_offset & 0xffff; - case 1: - v[0] = dir->tdir_offset >> 16; - } - } - else - { - switch (dir->tdir_count) - { - case 2: - v[1] = dir->tdir_offset >> 16; - case 1: - v[0] = dir->tdir_offset & 0xffff; - } - } - return (1); - } - else - return (TIFFFetchData(tif, dir, (char *)v) != 0); + if (dir->tdir_count <= 2) { + if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { + switch (dir->tdir_count) { + case 2: v[1] = dir->tdir_offset & 0xffff; + case 1: v[0] = dir->tdir_offset >> 16; + } + } else { + switch (dir->tdir_count) { + case 2: v[1] = dir->tdir_offset >> 16; + case 1: v[0] = dir->tdir_offset & 0xffff; + } + } + return (1); + } else + return (TIFFFetchData(tif, dir, (char *)v) != 0); } /* * Fetch a pair of SHORT or BYTE values. */ -static int TIFFFetchShortPair(TIFF *tif, TIFFDirEntry *dir) +static int +TIFFFetchShortPair(TIFF* tif, TIFFDirEntry* dir) { - uint16_t v[2]; - int ok = 0; + uint16 v[2]; + int ok = 0; - switch (dir->tdir_type) - { - case TIFF_SHORT: - case TIFF_SSHORT: - ok = TIFFFetchShortArray(tif, dir, v); - break; - case TIFF_BYTE: - case TIFF_SBYTE: - ok = TIFFFetchByteArray(tif, dir, v); - break; - } - if (ok) - TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); - return (ok); + switch (dir->tdir_type) { + case TIFF_SHORT: + case TIFF_SSHORT: + ok = TIFFFetchShortArray(tif, dir, v); + break; + case TIFF_BYTE: + case TIFF_SBYTE: + ok = TIFFFetchByteArray(tif, dir, v); + break; + } + if (ok) + TIFFSetField(tif, dir->tdir_tag, v[0], v[1]); + return (ok); } /* * Fetch an array of LONG or SLONG values. */ -static int TIFFFetchLongArray(TIFF *tif, TIFFDirEntry *dir, uint32_t *v) +static int +TIFFFetchLongArray(TIFF* tif, TIFFDirEntry* dir, uint32* v) { - if (dir->tdir_count == 1) - { - v[0] = dir->tdir_offset; - return (1); - } - else - return (TIFFFetchData(tif, dir, (char *)v) != 0); + if (dir->tdir_count == 1) { + v[0] = dir->tdir_offset; + return (1); + } else + return (TIFFFetchData(tif, dir, (char*) v) != 0); } /* * Fetch an array of RATIONAL or SRATIONAL values. */ -static int TIFFFetchRationalArray(TIFF *tif, TIFFDirEntry *dir, float *v) +static int +TIFFFetchRationalArray(TIFF* tif, TIFFDirEntry* dir, float* v) { - int ok = 0; - uint32_t *l; + int ok = 0; + uint32* l; - l = (uint32_t *)CheckMalloc(tif, - dir->tdir_count * TIFFDataWidth(dir->tdir_type), - "to fetch array of rationals"); - if (l) - { - if (TIFFFetchData(tif, dir, (char *)l)) - { - uint32_t i; - for (i = 0; i < dir->tdir_count; i++) - { - ok = cvtRational(tif, dir, l[2 * i + 0], l[2 * i + 1], &v[i]); - if (!ok) - break; - } - } - _TIFFfree((char *)l); - } - return (ok); + l = (uint32*)CheckMalloc(tif, + dir->tdir_count*TIFFDataWidth(dir->tdir_type), + "to fetch array of rationals"); + if (l) { + if (TIFFFetchData(tif, dir, (char *)l)) { + uint32 i; + for (i = 0; i < dir->tdir_count; i++) { + ok = cvtRational(tif, dir, + l[2*i+0], l[2*i+1], &v[i]); + if (!ok) + break; + } + } + _TIFFfree((char *)l); + } + return (ok); } /* * Fetch an array of FLOAT values. */ -static int TIFFFetchFloatArray(TIFF *tif, TIFFDirEntry *dir, float *v) +static int +TIFFFetchFloatArray(TIFF* tif, TIFFDirEntry* dir, float* v) { - if (dir->tdir_count == 1) - { - v[0] = *(float *)&dir->tdir_offset; - TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); - return (1); - } - else if (TIFFFetchData(tif, dir, (char *)v)) - { - TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); - return (1); - } - else - return (0); + if (dir->tdir_count == 1) { + v[0] = *(float*) &dir->tdir_offset; + TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); + return (1); + } else if (TIFFFetchData(tif, dir, (char*) v)) { + TIFFCvtIEEEFloatToNative(tif, dir->tdir_count, v); + return (1); + } else + return (0); } /* * Fetch an array of DOUBLE values. */ -static int TIFFFetchDoubleArray(TIFF *tif, TIFFDirEntry *dir, double *v) +static int +TIFFFetchDoubleArray(TIFF* tif, TIFFDirEntry* dir, double* v) { - if (TIFFFetchData(tif, dir, (char *)v)) - { - TIFFCvtIEEEDoubleToNative(tif, dir->tdir_count, v); - return (1); - } - else - return (0); + if (TIFFFetchData(tif, dir, (char*) v)) { + TIFFCvtIEEEDoubleToNative(tif, dir->tdir_count, v); + return (1); + } else + return (0); } /* @@ -702,328 +646,304 @@ static int TIFFFetchDoubleArray(TIFF *tif, TIFFDirEntry *dir, double *v) * and then convert it in place to double (from end * to front of course). */ -static int TIFFFetchAnyArray(TIFF *tif, TIFFDirEntry *dir, double *v) +static int +TIFFFetchAnyArray(TIFF* tif, TIFFDirEntry* dir, double* v) { - int i; + int i; - switch (dir->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - if (!TIFFFetchByteArray(tif, dir, (uint16_t *)v)) - return (0); - if (dir->tdir_type == TIFF_BYTE) - { - uint16_t *vp = (uint16_t *)v; - for (i = dir->tdir_count - 1; i >= 0; i--) - v[i] = vp[i]; - } - else - { - int16_t *vp = (int16_t *)v; - for (i = dir->tdir_count - 1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_SHORT: - case TIFF_SSHORT: - if (!TIFFFetchShortArray(tif, dir, (uint16_t *)v)) - return (0); - if (dir->tdir_type == TIFF_SHORT) - { - uint16_t *vp = (uint16_t *)v; - for (i = dir->tdir_count - 1; i >= 0; i--) - v[i] = vp[i]; - } - else - { - int16_t *vp = (int16_t *)v; - for (i = dir->tdir_count - 1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_LONG: - case TIFF_SLONG: - if (!TIFFFetchLongArray(tif, dir, (uint32_t *)v)) - return (0); - if (dir->tdir_type == TIFF_LONG) - { - uint32_t *vp = (uint32_t *)v; - for (i = dir->tdir_count - 1; i >= 0; i--) - v[i] = vp[i]; - } - else - { - int32_t *vp = (int32_t *)v; - for (i = dir->tdir_count - 1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - if (!TIFFFetchRationalArray(tif, dir, (float *)v)) - return (0); - { - float *vp = (float *)v; - for (i = dir->tdir_count - 1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_FLOAT: - if (!TIFFFetchFloatArray(tif, dir, (float *)v)) - return (0); - { - float *vp = (float *)v; - for (i = dir->tdir_count - 1; i >= 0; i--) - v[i] = vp[i]; - } - break; - case TIFF_DOUBLE: - return (TIFFFetchDoubleArray(tif, dir, (double *)v)); - default: - /* TIFF_NOTYPE */ - /* TIFF_ASCII */ - /* TIFF_UNDEFINED */ - TIFFErrorExtR(tif, tif->tif_name, - "Cannot read TIFF_ANY type %d for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (0); - } - return (1); + switch (dir->tdir_type) { + case TIFF_BYTE: + case TIFF_SBYTE: + if (!TIFFFetchByteArray(tif, dir, (uint16*) v)) + return (0); + if (dir->tdir_type == TIFF_BYTE) { + uint16* vp = (uint16*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } else { + int16* vp = (int16*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_SHORT: + case TIFF_SSHORT: + if (!TIFFFetchShortArray(tif, dir, (uint16*) v)) + return (0); + if (dir->tdir_type == TIFF_SHORT) { + uint16* vp = (uint16*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } else { + int16* vp = (int16*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_LONG: + case TIFF_SLONG: + if (!TIFFFetchLongArray(tif, dir, (uint32*) v)) + return (0); + if (dir->tdir_type == TIFF_LONG) { + uint32* vp = (uint32*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } else { + int32* vp = (int32*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + if (!TIFFFetchRationalArray(tif, dir, (float*) v)) + return (0); + { float* vp = (float*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_FLOAT: + if (!TIFFFetchFloatArray(tif, dir, (float*) v)) + return (0); + { float* vp = (float*) v; + for (i = dir->tdir_count-1; i >= 0; i--) + v[i] = vp[i]; + } + break; + case TIFF_DOUBLE: + return (TIFFFetchDoubleArray(tif, dir, (double*) v)); + default: + /* TIFF_NOTYPE */ + /* TIFF_ASCII */ + /* TIFF_UNDEFINED */ + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Cannot read TIFF_ANY type %d for field \"%s\"", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); + return (0); + } + return (1); } + /* * Fetch a tag that is not handled by special case code. */ /* The standard function TIFFFetchNormalTag() could definitely be replaced with a simple call to this function, just adding TIFFSetField() as the last argument. */ -static int TIFFFetchNormalSubTag(TIFF *tif, TIFFDirEntry *dp, - const TIFFFieldInfo *fip, - int (*setFieldFn)(TIFF *tif, ttag_t tag, ...)) +static int +TIFFFetchNormalSubTag(TIFF* tif, TIFFDirEntry* dp, const TIFFFieldInfo* fip, + int (*setFieldFn)(TIFF *tif, ttag_t tag, ...)) { - static char mesg[] = "to fetch tag value"; - int ok = 0; + static char mesg[] = "to fetch tag value"; + int ok = 0; - if (dp->tdir_count > 1) - { /* array of values */ - char *cp = NULL; + if (dp->tdir_count > 1) { /* array of values */ + char* cp = NULL; - switch (dp->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - /* NB: always expand BYTE values to shorts */ - cp = CheckMalloc(tif, dp->tdir_count * sizeof(uint16_t), mesg); - ok = cp && TIFFFetchByteArray(tif, dp, (uint16_t *)cp); - break; - case TIFF_SHORT: - case TIFF_SSHORT: - cp = CheckMalloc(tif, dp->tdir_count * sizeof(uint16_t), mesg); - ok = cp && TIFFFetchShortArray(tif, dp, (uint16_t *)cp); - break; - case TIFF_LONG: - case TIFF_SLONG: - cp = CheckMalloc(tif, dp->tdir_count * sizeof(uint32_t), mesg); - ok = cp && TIFFFetchLongArray(tif, dp, (uint32_t *)cp); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - cp = CheckMalloc(tif, dp->tdir_count * sizeof(float), mesg); - ok = cp && TIFFFetchRationalArray(tif, dp, (float *)cp); - break; - case TIFF_FLOAT: - cp = CheckMalloc(tif, dp->tdir_count * sizeof(float), mesg); - ok = cp && TIFFFetchFloatArray(tif, dp, (float *)cp); - break; - case TIFF_DOUBLE: - cp = CheckMalloc(tif, dp->tdir_count * sizeof(double), mesg); - ok = cp && TIFFFetchDoubleArray(tif, dp, (double *)cp); - break; - case TIFF_ASCII: - case TIFF_UNDEFINED: /* bit of a cheat... */ - /* - * Some vendors write strings w/o the trailing - * NULL byte, so always append one just in case. - */ - cp = CheckMalloc(tif, dp->tdir_count + 1, mesg); - if (ok = (cp && TIFFFetchString(tif, dp, cp))) - cp[dp->tdir_count] = '\0'; /* XXX */ - break; - } - if (ok) - { - ok = (fip->field_passcount - ? (*setFieldFn)(tif, dp->tdir_tag, dp->tdir_count, cp) - : (*setFieldFn)(tif, dp->tdir_tag, cp)); - } - if (cp != NULL) - _TIFFfree(cp); - } - else if (CheckDirCount(tif, dp, 1)) - { /* singleton value */ - switch (dp->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - /* - * If the tag is also acceptable as a LONG or SLONG - * then (*setFieldFn) will expect an uint32_t parameter - * passed to it (through varargs). Thus, for machines - * where sizeof (int) != sizeof (uint32_t) we must do - * a careful check here. It's hard to say if this - * is worth optimizing. - * - * NB: We use TIFFFieldWithTag here knowing that - * it returns us the first entry in the table - * for the tag and that that entry is for the - * widest potential data type the tag may have. - */ - { - TIFFDataType type = fip->field_type; - if (type != TIFF_LONG && type != TIFF_SLONG) - { - uint16_t v = (uint16_t)TIFFExtractData( - tif, dp->tdir_type, dp->tdir_offset); - ok = (fip->field_passcount - ? (*setFieldFn)(tif, dp->tdir_tag, 1, &v) - : (*setFieldFn)(tif, dp->tdir_tag, v)); - break; - } - } - /* fall through... */ - case TIFF_LONG: - case TIFF_SLONG: - { - uint32_t v32 = - TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); - ok = (fip->field_passcount - ? (*setFieldFn)(tif, dp->tdir_tag, 1, &v32) - : (*setFieldFn)(tif, dp->tdir_tag, v32)); - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - { - float v = - (dp->tdir_type == TIFF_FLOAT ? TIFFFetchFloat(tif, dp) - : TIFFFetchRational(tif, dp)); - ok = (fip->field_passcount - ? (*setFieldFn)(tif, dp->tdir_tag, 1, &v) - : (*setFieldFn)(tif, dp->tdir_tag, v)); - } - break; - case TIFF_DOUBLE: - { - double v; - ok = (TIFFFetchDoubleArray(tif, dp, &v) && - (fip->field_passcount - ? (*setFieldFn)(tif, dp->tdir_tag, 1, &v) - : (*setFieldFn)(tif, dp->tdir_tag, v))); - } - break; - case TIFF_ASCII: - case TIFF_UNDEFINED: /* bit of a cheat... */ - { - char c[2]; - if (ok = (TIFFFetchString(tif, dp, c) != 0)) - { - c[1] = '\0'; /* XXX paranoid */ - ok = (*setFieldFn)(tif, dp->tdir_tag, c); - } - } - break; - } - } - return (ok); + switch (dp->tdir_type) { + case TIFF_BYTE: + case TIFF_SBYTE: + /* NB: always expand BYTE values to shorts */ + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (uint16), mesg); + ok = cp && TIFFFetchByteArray(tif, dp, (uint16*) cp); + break; + case TIFF_SHORT: + case TIFF_SSHORT: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (uint16), mesg); + ok = cp && TIFFFetchShortArray(tif, dp, (uint16*) cp); + break; + case TIFF_LONG: + case TIFF_SLONG: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (uint32), mesg); + ok = cp && TIFFFetchLongArray(tif, dp, (uint32*) cp); + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (float), mesg); + ok = cp && TIFFFetchRationalArray(tif, dp, (float*) cp); + break; + case TIFF_FLOAT: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (float), mesg); + ok = cp && TIFFFetchFloatArray(tif, dp, (float*) cp); + break; + case TIFF_DOUBLE: + cp = CheckMalloc(tif, + dp->tdir_count * sizeof (double), mesg); + ok = cp && TIFFFetchDoubleArray(tif, dp, (double*) cp); + break; + case TIFF_ASCII: + case TIFF_UNDEFINED: /* bit of a cheat... */ + /* + * Some vendors write strings w/o the trailing + * NULL byte, so always append one just in case. + */ + cp = CheckMalloc(tif, dp->tdir_count+1, mesg); + if (ok = (cp && TIFFFetchString(tif, dp, cp))) + cp[dp->tdir_count] = '\0'; /* XXX */ + break; + } + if (ok) { + ok = (fip->field_passcount ? + (*setFieldFn)(tif, dp->tdir_tag, dp->tdir_count, cp) + : (*setFieldFn)(tif, dp->tdir_tag, cp)); + } + if (cp != NULL) + _TIFFfree(cp); + } else if (CheckDirCount(tif, dp, 1)) { /* singleton value */ + switch (dp->tdir_type) { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + /* + * If the tag is also acceptable as a LONG or SLONG + * then (*setFieldFn) will expect an uint32 parameter + * passed to it (through varargs). Thus, for machines + * where sizeof (int) != sizeof (uint32) we must do + * a careful check here. It's hard to say if this + * is worth optimizing. + * + * NB: We use TIFFFieldWithTag here knowing that + * it returns us the first entry in the table + * for the tag and that that entry is for the + * widest potential data type the tag may have. + */ + { TIFFDataType type = fip->field_type; + if (type != TIFF_LONG && type != TIFF_SLONG) { + uint16 v = (uint16) + TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); + ok = (fip->field_passcount ? + (*setFieldFn)(tif, dp->tdir_tag, 1, &v) + : (*setFieldFn)(tif, dp->tdir_tag, v)); + break; + } + } + /* fall through... */ + case TIFF_LONG: + case TIFF_SLONG: + { uint32 v32 = + TIFFExtractData(tif, dp->tdir_type, dp->tdir_offset); + ok = (fip->field_passcount ? + (*setFieldFn)(tif, dp->tdir_tag, 1, &v32) + : (*setFieldFn)(tif, dp->tdir_tag, v32)); + } + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + { float v = (dp->tdir_type == TIFF_FLOAT ? + TIFFFetchFloat(tif, dp) + : TIFFFetchRational(tif, dp)); + ok = (fip->field_passcount ? + (*setFieldFn)(tif, dp->tdir_tag, 1, &v) + : (*setFieldFn)(tif, dp->tdir_tag, v)); + } + break; + case TIFF_DOUBLE: + { double v; + ok = (TIFFFetchDoubleArray(tif, dp, &v) && + (fip->field_passcount ? + (*setFieldFn)(tif, dp->tdir_tag, 1, &v) + : (*setFieldFn)(tif, dp->tdir_tag, v)) + ); + } + break; + case TIFF_ASCII: + case TIFF_UNDEFINED: /* bit of a cheat... */ + { char c[2]; + if (ok = (TIFFFetchString(tif, dp, c) != 0)) { + c[1] = '\0'; /* XXX paranoid */ + ok = (*setFieldFn)(tif, dp->tdir_tag, c); + } + } + break; + } + } + return (ok); } /* Everything after this is exactly duplicated from the standard tif_dirread.c file, necessitated by the fact that they are declared static there so we can't call them! */ -#define NITEMS(x) (sizeof(x) / sizeof(x[0])) +#define NITEMS(x) (sizeof (x) / sizeof (x[0])) /* - * Fetch samples/pixel short values for + * Fetch samples/pixel short values for * the specified tag and verify that * all values are the same. */ -static int TIFFFetchPerSampleShorts(TIFF *tif, TIFFDirEntry *dir, int *pl) +static int +TIFFFetchPerSampleShorts(TIFF* tif, TIFFDirEntry* dir, int* pl) { - int samples = tif->tif_dir.td_samplesperpixel; - int status = 0; + int samples = tif->tif_dir.td_samplesperpixel; + int status = 0; - if (CheckDirCount(tif, dir, (uint32_t)samples)) - { - uint16_t buf[10]; - uint16_t *v = buf; + if (CheckDirCount(tif, dir, (uint32) samples)) { + uint16 buf[10]; + uint16* v = buf; - if (samples > NITEMS(buf)) - v = (uint16_t *)_TIFFmalloc(samples * sizeof(uint16_t)); - if (TIFFFetchShortArray(tif, dir, v)) - { - int i; - for (i = 1; i < samples; i++) - if (v[i] != v[0]) - { - TIFFErrorExtR( - tif, tif->tif_name, - "Cannot handle different per-sample values for field " - "\"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - goto bad; - } - *pl = v[0]; - status = 1; - } - bad: - if (v != buf) - _TIFFfree((char *)v); - } - return (status); + if (samples > NITEMS(buf)) + v = (uint16*) _TIFFmalloc(samples * sizeof (uint16)); + if (TIFFFetchShortArray(tif, dir, v)) { + int i; + for (i = 1; i < samples; i++) + if (v[i] != v[0]) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Cannot handle different per-sample values for field \"%s\"", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); + goto bad; + } + *pl = v[0]; + status = 1; + } + bad: + if (v != buf) + _TIFFfree((char*) v); + } + return (status); } /* - * Fetch samples/pixel ANY values for + * Fetch samples/pixel ANY values for * the specified tag and verify that * all values are the same. */ -static int TIFFFetchPerSampleAnys(TIFF *tif, TIFFDirEntry *dir, double *pl) +static int +TIFFFetchPerSampleAnys(TIFF* tif, TIFFDirEntry* dir, double* pl) { - int samples = (int)tif->tif_dir.td_samplesperpixel; - int status = 0; + int samples = (int) tif->tif_dir.td_samplesperpixel; + int status = 0; - if (CheckDirCount(tif, dir, (uint32_t)samples)) - { - double buf[10]; - double *v = buf; + if (CheckDirCount(tif, dir, (uint32) samples)) { + double buf[10]; + double* v = buf; - if (samples > NITEMS(buf)) - v = (double *)_TIFFmalloc(samples * sizeof(double)); - if (TIFFFetchAnyArray(tif, dir, v)) - { - int i; - for (i = 1; i < samples; i++) - if (v[i] != v[0]) - { - TIFFErrorExtR( - tif, tif->tif_name, - "Cannot handle different per-sample values for field " - "\"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - goto bad; - } - *pl = v[0]; - status = 1; - } - bad: - if (v != buf) - _TIFFfree(v); - } - return (status); + if (samples > NITEMS(buf)) + v = (double*) _TIFFmalloc(samples * sizeof (double)); + if (TIFFFetchAnyArray(tif, dir, v)) { + int i; + for (i = 1; i < samples; i++) + if (v[i] != v[0]) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Cannot handle different per-sample values for field \"%s\"", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); + goto bad; + } + *pl = v[0]; + status = 1; + } + bad: + if (v != buf) + _TIFFfree(v); + } + return (status); } #undef NITEMS @@ -1032,65 +952,63 @@ static int TIFFFetchPerSampleAnys(TIFF *tif, TIFFDirEntry *dir, double *pl) * While this routine says "strips", * in fact it's also used for tiles. */ -static int TIFFFetchStripThing(TIFF *tif, TIFFDirEntry *dir, long nstrips, - uint32_t **lpp) +static int +TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, long nstrips, uint32** lpp) { - register uint32_t *lp; - int status; + register uint32* lp; + int status; - if (!CheckDirCount(tif, dir, (uint32_t)nstrips)) - return (0); - /* - * Allocate space for strip information. - */ - if (*lpp == NULL && - (*lpp = (uint32_t *)CheckMalloc(tif, nstrips * sizeof(uint32_t), - "for strip array")) == NULL) - return (0); - lp = *lpp; - if (dir->tdir_type == (int)TIFF_SHORT) - { - /* - * Handle uint16_t->uint32_t expansion. - */ - uint16_t *dp = (uint16_t *)CheckMalloc( - tif, dir->tdir_count * sizeof(uint16_t), "to fetch strip tag"); - if (dp == NULL) - return (0); - if (status = TIFFFetchShortArray(tif, dir, dp)) - { - register uint16_t *wp = dp; - while (nstrips-- > 0) - *lp++ = *wp++; - } - _TIFFfree((char *)dp); - } - else - status = TIFFFetchLongArray(tif, dir, lp); - return (status); + if (!CheckDirCount(tif, dir, (uint32) nstrips)) + return (0); + /* + * Allocate space for strip information. + */ + if (*lpp == NULL && + (*lpp = (uint32 *)CheckMalloc(tif, + nstrips * sizeof (uint32), "for strip array")) == NULL) + return (0); + lp = *lpp; + if (dir->tdir_type == (int)TIFF_SHORT) { + /* + * Handle uint16->uint32 expansion. + */ + uint16* dp = (uint16*) CheckMalloc(tif, + dir->tdir_count* sizeof (uint16), "to fetch strip tag"); + if (dp == NULL) + return (0); + if (status = TIFFFetchShortArray(tif, dir, dp)) { + register uint16* wp = dp; + while (nstrips-- > 0) + *lp++ = *wp++; + } + _TIFFfree((char*) dp); + } else + status = TIFFFetchLongArray(tif, dir, lp); + return (status); } -#define NITEMS(x) (sizeof(x) / sizeof(x[0])) +#define NITEMS(x) (sizeof (x) / sizeof (x[0])) /* * Fetch and set the ExtraSamples tag. */ -static int TIFFFetchExtraSamples(TIFF *tif, TIFFDirEntry *dir) +static int +TIFFFetchExtraSamples(TIFF* tif, TIFFDirEntry* dir) { - uint16_t buf[10]; - uint16_t *v = buf; - int status; + uint16 buf[10]; + uint16* v = buf; + int status; - if (dir->tdir_count > NITEMS(buf)) - v = (uint16_t *)_TIFFmalloc(dir->tdir_count * sizeof(uint16_t)); - if (dir->tdir_type == TIFF_BYTE) - status = TIFFFetchByteArray(tif, dir, v); - else - status = TIFFFetchShortArray(tif, dir, v); - if (status) - status = TIFFSetField(tif, dir->tdir_tag, dir->tdir_count, v); - if (v != buf) - _TIFFfree((char *)v); - return (status); + if (dir->tdir_count > NITEMS(buf)) + v = (uint16*) _TIFFmalloc(dir->tdir_count * sizeof (uint16)); + if (dir->tdir_type == TIFF_BYTE) + status = TIFFFetchByteArray(tif, dir, v); + else + status = TIFFFetchShortArray(tif, dir, v); + if (status) + status = TIFFSetField(tif, dir->tdir_tag, dir->tdir_count, v); + if (v != buf) + _TIFFfree((char*) v); + return (status); } #undef NITEMS @@ -1098,34 +1016,33 @@ static int TIFFFetchExtraSamples(TIFF *tif, TIFFDirEntry *dir) /* * Fetch and set the RefBlackWhite tag. */ -static int TIFFFetchRefBlackWhite(TIFF *tif, TIFFDirEntry *dir) +static int +TIFFFetchRefBlackWhite(TIFF* tif, TIFFDirEntry* dir) { - static char mesg[] = "for \"ReferenceBlackWhite\" array"; - char *cp; - int ok; + static char mesg[] = "for \"ReferenceBlackWhite\" array"; + char* cp; + int ok; - if (dir->tdir_type == TIFF_RATIONAL) - return (1/*TIFFFetchNormalTag(tif, dir) just so linker won't complain - this part of the code is never used anyway */); - /* - * Handle LONG's for backward compatibility. - */ - cp = CheckMalloc(tif, dir->tdir_count * sizeof(uint32_t), mesg); - if (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32_t *)cp))) - { - float *fp = - (float *)CheckMalloc(tif, dir->tdir_count * sizeof(float), mesg); - if (ok = (fp != NULL)) - { - uint32_t i; - for (i = 0; i < dir->tdir_count; i++) - fp[i] = (float)((uint32_t *)cp)[i]; - ok = TIFFSetField(tif, dir->tdir_tag, fp); - _TIFFfree((char *)fp); - } - } - if (cp) - _TIFFfree(cp); - return (ok); + if (dir->tdir_type == TIFF_RATIONAL) + return (1/*TIFFFetchNormalTag(tif, dir) just so linker won't complain - this part of the code is never used anyway */); + /* + * Handle LONG's for backward compatibility. + */ + cp = CheckMalloc(tif, dir->tdir_count * sizeof (uint32), mesg); + if (ok = (cp && TIFFFetchLongArray(tif, dir, (uint32*) cp))) { + float* fp = (float*) + CheckMalloc(tif, dir->tdir_count * sizeof (float), mesg); + if (ok = (fp != NULL)) { + uint32 i; + for (i = 0; i < dir->tdir_count; i++) + fp[i] = (float)((uint32*) cp)[i]; + ok = TIFFSetField(tif, dir->tdir_tag, fp); + _TIFFfree((char*) fp); + } + } + if (cp) + _TIFFfree(cp); + return (ok); } #endif @@ -1137,74 +1054,76 @@ static int TIFFFetchRefBlackWhite(TIFF *tif, TIFFDirEntry *dir) * for dealing with machines with a limited amount * memory. */ -static void ChopUpSingleUncompressedStrip(TIFF *tif) +static void +ChopUpSingleUncompressedStrip(TIFF* tif) { - register TIFFDirectory *td = &tif->tif_dir; - uint32_t bytecount = td->td_stripbytecount[0]; - uint32_t offset = td->td_stripoffset[0]; - tsize_t rowbytes = TIFFVTileSize(tif, 1), stripbytes; - tstrip_t strip, nstrips, rowsperstrip; - uint32_t *newcounts; - uint32_t *newoffsets; + register TIFFDirectory *td = &tif->tif_dir; + uint32 bytecount = td->td_stripbytecount[0]; + uint32 offset = td->td_stripoffset[0]; + tsize_t rowbytes = TIFFVTileSize(tif, 1), stripbytes; + tstrip_t strip, nstrips, rowsperstrip; + uint32* newcounts; + uint32* newoffsets; - /* - * Make the rows hold at least one - * scanline, but fill 8k if possible. - */ - if (rowbytes > 8192) - { - stripbytes = rowbytes; - rowsperstrip = 1; - } - else - { - rowsperstrip = 8192 / rowbytes; - stripbytes = rowbytes * rowsperstrip; - } - /* never increase the number of strips in an image */ - if (rowsperstrip >= td->td_rowsperstrip) - return; - nstrips = (tstrip_t)TIFFhowmany(bytecount, stripbytes); - newcounts = - (uint32_t *)CheckMalloc(tif, nstrips * sizeof(uint32_t), - "for chopped \"StripByteCounts\" array"); - newoffsets = (uint32_t *)CheckMalloc(tif, nstrips * sizeof(uint32_t), - "for chopped \"StripOffsets\" array"); - if (newcounts == NULL || newoffsets == NULL) - { - /* - * Unable to allocate new strip information, give - * up and use the original one strip information. - */ - if (newcounts != NULL) - _TIFFfree(newcounts); - if (newoffsets != NULL) - _TIFFfree(newoffsets); - return; - } - /* - * Fill the strip information arrays with - * new bytecounts and offsets that reflect - * the broken-up format. - */ - for (strip = 0; strip < nstrips; strip++) - { - if (stripbytes > bytecount) - stripbytes = bytecount; - newcounts[strip] = stripbytes; - newoffsets[strip] = offset; - offset += stripbytes; - bytecount -= stripbytes; - } - /* - * Replace old single strip info with multi-strip info. - */ - td->td_stripsperimage = td->td_nstrips = nstrips; - TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + /* + * Make the rows hold at least one + * scanline, but fill 8k if possible. + */ + if (rowbytes > 8192) { + stripbytes = rowbytes; + rowsperstrip = 1; + } else { + rowsperstrip = 8192 / rowbytes; + stripbytes = rowbytes * rowsperstrip; + } + /* never increase the number of strips in an image */ + if (rowsperstrip >= td->td_rowsperstrip) + return; + nstrips = (tstrip_t) TIFFhowmany(bytecount, stripbytes); + newcounts = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32), + "for chopped \"StripByteCounts\" array"); + newoffsets = (uint32*) CheckMalloc(tif, nstrips * sizeof (uint32), + "for chopped \"StripOffsets\" array"); + if (newcounts == NULL || newoffsets == NULL) { + /* + * Unable to allocate new strip information, give + * up and use the original one strip information. + */ + if (newcounts != NULL) + _TIFFfree(newcounts); + if (newoffsets != NULL) + _TIFFfree(newoffsets); + return; + } + /* + * Fill the strip information arrays with + * new bytecounts and offsets that reflect + * the broken-up format. + */ + for (strip = 0; strip < nstrips; strip++) { + if (stripbytes > bytecount) + stripbytes = bytecount; + newcounts[strip] = stripbytes; + newoffsets[strip] = offset; + offset += stripbytes; + bytecount -= stripbytes; + } + /* + * Replace old single strip info with multi-strip info. + */ + td->td_stripsperimage = td->td_nstrips = nstrips; + TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - _TIFFfree(td->td_stripbytecount); - _TIFFfree(td->td_stripoffset); - td->td_stripbytecount = newcounts; - td->td_stripoffset = newoffsets; + _TIFFfree(td->td_stripbytecount); + _TIFFfree(td->td_stripoffset); + td->td_stripbytecount = newcounts; + td->td_stripoffset = newoffsets; } #endif /* STRIPCHOP_SUPPORT */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_pdsdirwrite.c b/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_pdsdirwrite.c index fdac98ce7..a670bda1c 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_pdsdirwrite.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/pds/tif_pdsdirwrite.c @@ -13,23 +13,23 @@ * Copyright (c) 1991-1996 Silicon Graphics, Inc. * Copyright (c( 1996 USAF Phillips Laboratory * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -60,54 +60,52 @@ #include "tiffiop.h" #if HAVE_IEEEFP -#define TIFFCvtNativeToIEEEFloat(tif, n, fp) -#define TIFFCvtNativeToIEEEDouble(tif, n, dp) +#define TIFFCvtNativeToIEEEFloat(tif, n, fp) +#define TIFFCvtNativeToIEEEDouble(tif, n, dp) #else -extern void TIFFCvtNativeToIEEEFloat(TIFF *, uint32_t, float *); -extern void TIFFCvtNativeToIEEEDouble(TIFF *, uint32_t, double *); +extern void TIFFCvtNativeToIEEEFloat(TIFF*, uint32, float*); +extern void TIFFCvtNativeToIEEEDouble(TIFF*, uint32, double*); #endif -static int TIFFWriteNormalTag(TIFF *, TIFFDirEntry *, const TIFFFieldInfo *); -static int TIFFWriteNormalSubTag(TIFF *, TIFFDirEntry *, const TIFFFieldInfo *, - int (*getFieldFn)(TIFF *tif, ttag_t tag, ...)); -static void TIFFSetupShortLong(TIFF *, ttag_t, TIFFDirEntry *, uint32_t); -static int TIFFSetupShortPair(TIFF *, ttag_t, TIFFDirEntry *); -static int TIFFWritePerSampleShorts(TIFF *, ttag_t, TIFFDirEntry *); -static int TIFFWritePerSampleAnys(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *); -static int TIFFWriteShortTable(TIFF *, ttag_t, TIFFDirEntry *, uint32_t, - uint16_t **); -static int TIFFWriteShortArray(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, - uint32_t, uint16_t *); -static int TIFFWriteLongArray(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, - uint32_t, uint32_t *); -static int TIFFWriteRationalArray(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, - uint32_t, float *); -static int TIFFWriteFloatArray(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, - uint32_t, float *); -static int TIFFWriteDoubleArray(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, - uint32_t, double *); -static int TIFFWriteByteArray(TIFF *, TIFFDirEntry *, char *); -static int TIFFWriteAnyArray(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, - uint32_t, double *); +static int TIFFWriteNormalTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*); +static int TIFFWriteNormalSubTag(TIFF*, TIFFDirEntry*, const TIFFFieldInfo*, + int (*getFieldFn)(TIFF *tif,ttag_t tag,...)); +static void TIFFSetupShortLong(TIFF*, ttag_t, TIFFDirEntry*, uint32); +static int TIFFSetupShortPair(TIFF*, ttag_t, TIFFDirEntry*); +static int TIFFWritePerSampleShorts(TIFF*, ttag_t, TIFFDirEntry*); +static int TIFFWritePerSampleAnys(TIFF*, TIFFDataType, ttag_t, TIFFDirEntry*); +static int TIFFWriteShortTable(TIFF*, ttag_t, TIFFDirEntry*, uint32, uint16**); +static int TIFFWriteShortArray(TIFF*, + TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint16*); +static int TIFFWriteLongArray(TIFF *, + TIFFDataType, ttag_t, TIFFDirEntry*, uint32, uint32*); +static int TIFFWriteRationalArray(TIFF *, + TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*); +static int TIFFWriteFloatArray(TIFF *, + TIFFDataType, ttag_t, TIFFDirEntry*, uint32, float*); +static int TIFFWriteDoubleArray(TIFF *, + TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*); +static int TIFFWriteByteArray(TIFF*, TIFFDirEntry*, char*); +static int TIFFWriteAnyArray(TIFF*, + TIFFDataType, ttag_t, TIFFDirEntry*, uint32, double*); #ifdef COLORIMETRY_SUPPORT -static int TIFFWriteTransferFunction(TIFF *, TIFFDirEntry *); +static int TIFFWriteTransferFunction(TIFF*, TIFFDirEntry*); #endif -static int TIFFWriteData(TIFF *, TIFFDirEntry *, char *); -static int TIFFLinkDirectory(TIFF *); +static int TIFFWriteData(TIFF*, TIFFDirEntry*, char*); +static int TIFFLinkDirectory(TIFF*); -#define WriteRationalPair(type, tag1, v1, tag2, v2) \ - { \ - if (!TIFFWriteRational(tif, type, tag1, dir, v1)) \ - goto bad; \ - if (!TIFFWriteRational(tif, type, tag2, dir + 1, v2)) \ - goto bad; \ - dir++; \ - } -#define TIFFWriteRational(tif, type, tag, dir, v) \ - TIFFWriteRationalArray((tif), (type), (tag), (dir), 1, &(v)) +#define WriteRationalPair(type, tag1, v1, tag2, v2) { \ + if (!TIFFWriteRational(tif, type, tag1, dir, v1)) \ + goto bad; \ + if (!TIFFWriteRational(tif, type, tag2, dir+1, v2)) \ + goto bad; \ + dir++; \ +} +#define TIFFWriteRational(tif, type, tag, dir, v) \ + TIFFWriteRationalArray((tif), (type), (tag), (dir), 1, &(v)) #ifndef TIFFWriteRational -static int TIFFWriteRational(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, - float); +static int TIFFWriteRational(TIFF*, + TIFFDataType, ttag_t, TIFFDirEntry*, float); #endif /* This function will write an entire directory to the disk, and return the @@ -116,7 +114,7 @@ static int TIFFWriteRational(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, calling this function, because some of the fields may have caused various data items to be written out BEFORE writing the directory structure. - This code was basically written by ripping of the TIFFWriteDirectory() + This code was basically written by ripping of the TIFFWriteDirectory() code and generalizing it, using RPS's TIFFWritePliIfd() code for inspiration. My original goal was to make this code general enough that the original TIFFWriteDirectory() could be rewritten to just call this @@ -126,7 +124,7 @@ static int TIFFWriteRational(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, the main, standard TIFF directories that does not apply to special private subdirectories, so such a reimplementation for the sake of eliminating redundant or duplicate code is probably not possible, - unless we also pass in a Main flag to indicate which type of handling + unless we also pass in a Main flag to indiciate which type of handling to do, which would be kind of a hack. I've marked those places where I changed or ripped out code which would have to be re-inserted to generalize this function. If it can be done in a clean and graceful way, @@ -138,183 +136,175 @@ static int TIFFWriteRational(TIFF *, TIFFDataType, ttag_t, TIFFDirEntry *, returning from this call, since otherwise once written out, the user is likely to forget about it and leave data lying around. */ -toff_t TIFFWritePrivateDataSubDirectory( - TIFF *tif, uint32_t pdir_fieldsset[], int pdir_fields_last, - TIFFFieldInfo *field_info, int (*getFieldFn)(TIFF *tif, ttag_t tag, ...)) +toff_t +TIFFWritePrivateDataSubDirectory(TIFF* tif, + uint32 pdir_fieldsset[], int pdir_fields_last, + TIFFFieldInfo *field_info, + int (*getFieldFn)(TIFF *tif, ttag_t tag, ...)) { - uint16_t dircount; - uint32_t diroff, nextdiroff; - ttag_t tag; - uint32_t nfields; - tsize_t dirsize; - char *data; - TIFFDirEntry *dir; - u_long b, *fields, fields_size; - toff_t directory_offset; - TIFFFieldInfo *fip; + uint16 dircount; + uint32 diroff, nextdiroff; + ttag_t tag; + uint32 nfields; + tsize_t dirsize; + char* data; + TIFFDirEntry* dir; + u_long b, *fields, fields_size; + toff_t directory_offset; + TIFFFieldInfo* fip; - /* - * Deleted out all of the encoder flushing and such code from here - - * not necessary for subdirectories. - */ + /* + * Deleted out all of the encoder flushing and such code from here - + * not necessary for subdirectories. + */ - /* Finish writing out any image data. */ - TIFFFlushData(tif); + /* Finish writing out any image data. */ + TIFFFlushData(tif); - /* - * Size the directory so that we can calculate - * offsets for the data items that aren't kept - * in-place in each field. - */ - nfields = 0; - for (b = 0; b <= pdir_fields_last; b++) - if (FieldSet(pdir_fieldsset, b)) - /* Deleted code to make size of first 4 tags 2 - instead of 1. */ - nfields += 1; - dirsize = nfields * sizeof(TIFFDirEntry); - data = (char *)_TIFFmalloc(dirsize); - if (data == NULL) - { - TIFFErrorExtR(tif, tif->tif_name, - "Cannot write private subdirectory, out of space"); - return (0); - } - /* - * Place directory in data section of the file. If there isn't one - * yet, place it at the end of the file. The directory is treated as - * data, so we don't link it into the directory structure at all. - */ - if (tif->tif_dataoff == 0) - tif->tif_dataoff = (TIFFSeekFile(tif, (toff_t)0, SEEK_END) + 1) & ~1; - diroff = tif->tif_dataoff; - tif->tif_dataoff = - (toff_t)(diroff + sizeof(uint16_t) + dirsize + sizeof(toff_t)); - if (tif->tif_dataoff & 1) - tif->tif_dataoff++; - (void)TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET); - /*tif->tif_curdir++;*/ - dir = (TIFFDirEntry *)data; - /* - * Setup external form of directory - * entries and write data items. - */ - /* - * We make a local copy of the fieldsset here so that we don't mess - * up the original one when we call ResetFieldBit(). But I'm not sure - * why the original code calls ResetFieldBit(), since we're already - * going through the fields in order... - * - * fields_size is the number of uint32_t's we will need to hold the - * bit-mask for all of the fields. If our highest field number is - * 100, then we'll need 100 / (8*4)+1 == 4 uint32_t's to hold the - * fieldset. - * - * Unlike the original code, we allocate fields dynamically based - * on the requested pdir_fields_last value, allowing private - * data subdirectories to contain more than the built-in code's limit - * of 95 tags in a directory. - */ - fields_size = pdir_fields_last / (8 * sizeof(uint32_t)) + 1; - fields = _TIFFmalloc(fields_size * sizeof(uint32_t)); - _TIFFmemcpy(fields, pdir_fieldsset, fields_size * sizeof(uint32_t)); + /* + * Size the directory so that we can calculate + * offsets for the data items that aren't kept + * in-place in each field. + */ + nfields = 0; + for (b = 0; b <= pdir_fields_last; b++) + if (FieldSet(pdir_fieldsset, b)) + /* Deleted code to make size of first 4 tags 2 + instead of 1. */ + nfields += 1; + dirsize = nfields * sizeof (TIFFDirEntry); + data = (char*) _TIFFmalloc(dirsize); + if (data == NULL) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Cannot write private subdirectory, out of space"); + return (0); + } + /* + * Place directory in data section of the file. If there isn't one + * yet, place it at the end of the file. The directory is treated as + * data, so we don't link it into the directory structure at all. + */ + if (tif->tif_dataoff == 0) + tif->tif_dataoff =(TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1; + diroff = tif->tif_dataoff; + tif->tif_dataoff = (toff_t)( + diroff + sizeof (uint16) + dirsize + sizeof (toff_t)); + if (tif->tif_dataoff & 1) + tif->tif_dataoff++; + (void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET); + /*tif->tif_curdir++;*/ + dir = (TIFFDirEntry*) data; + /* + * Setup external form of directory + * entries and write data items. + */ + /* + * We make a local copy of the fieldsset here so that we don't mess + * up the original one when we call ResetFieldBit(). But I'm not sure + * why the original code calls ResetFieldBit(), since we're already + * going through the fields in order... + * + * fields_size is the number of uint32's we will need to hold the + * bit-mask for all of the fields. If our highest field number is + * 100, then we'll need 100 / (8*4)+1 == 4 uint32's to hold the + * fieldset. + * + * Unlike the original code, we allocate fields dynamically based + * on the requested pdir_fields_last value, allowing private + * data subdirectories to contain more than the built-in code's limit + * of 95 tags in a directory. + */ + fields_size = pdir_fields_last / (8*sizeof(uint32)) + 1; + fields = _TIFFmalloc(fields_size*sizeof(uint32)); + _TIFFmemcpy(fields, pdir_fieldsset, fields_size * sizeof(uint32)); - /* Deleted "write out extra samples tag" code here. */ + /* Deleted "write out extra samples tag" code here. */ - /* Deleted code for checking a billion little special cases for the - * standard TIFF tags. Should add a general mechanism for overloading - * write function for each field, just like Brian kept telling me!!! - */ - for (fip = field_info; fip->field_tag; fip++) - { - /* Deleted code to check for FIELD_IGNORE!! */ - if (/* fip->field_bit == FIELD_IGNORE || */ - !FieldSet(fields, fip->field_bit)) - continue; - if (!TIFFWriteNormalSubTag(tif, dir, fip, getFieldFn)) - goto bad; - dir++; - ResetFieldBit(fields, fip->field_bit); - } + /* Deleted code for checking a billion little special cases for the + * standard TIFF tags. Should add a general mechanism for overloading + * write function for each field, just like Brian kept telling me!!! + */ + for (fip = field_info; fip->field_tag; fip++) { + /* Deleted code to check for FIELD_IGNORE!! */ + if (/* fip->field_bit == FIELD_IGNORE || */ + !FieldSet(fields, fip->field_bit)) + continue; + if (!TIFFWriteNormalSubTag(tif, dir, fip, getFieldFn)) + goto bad; + dir++; + ResetFieldBit(fields, fip->field_bit); + } - /* Now we've written all of the referenced data, and are about to - write the main directory structure, so grab the tif_dataoff value - now so we can remember where we wrote the directory. */ - directory_offset = tif->tif_dataoff; + /* Now we've written all of the referenced data, and are about to + write the main directory structure, so grab the tif_dataoff value + now so we can remember where we wrote the directory. */ + directory_offset = tif->tif_dataoff; - /* - * Write directory. - */ - dircount = (uint16_t)nfields; - /* Deleted code to link to the next directory - we set it to zero! */ - nextdiroff = 0; - if (tif->tif_flags & TIFF_SWAB) - { - /* - * The file's byte order is opposite to the - * native machine architecture. We overwrite - * the directory information with impunity - * because it'll be released below after we - * write it to the file. Note that all the - * other tag construction routines assume that - * we do this byte-swapping; i.e. they only - * byte-swap indirect data. - */ - for (dir = (TIFFDirEntry *)data; dircount; dir++, dircount--) - { - TIFFSwabArrayOfShort(&dir->tdir_tag, 2); - TIFFSwabArrayOfLong(&dir->tdir_count, 2); - } - dircount = (uint16_t)nfields; - TIFFSwabShort(&dircount); - TIFFSwabLong(&nextdiroff); - } + /* + * Write directory. + */ + dircount = (uint16) nfields; + /* Deleted code to link to the next directory - we set it to zero! */ + nextdiroff = 0; + if (tif->tif_flags & TIFF_SWAB) { + /* + * The file's byte order is opposite to the + * native machine architecture. We overwrite + * the directory information with impunity + * because it'll be released below after we + * write it to the file. Note that all the + * other tag construction routines assume that + * we do this byte-swapping; i.e. they only + * byte-swap indirect data. + */ + for (dir = (TIFFDirEntry*) data; dircount; dir++, dircount--) { + TIFFSwabArrayOfShort(&dir->tdir_tag, 2); + TIFFSwabArrayOfLong(&dir->tdir_count, 2); + } + dircount = (uint16) nfields; + TIFFSwabShort(&dircount); + TIFFSwabLong(&nextdiroff); + } - (void)TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET); - if (!WriteOK(tif, &dircount, sizeof(dircount))) - { - TIFFErrorExtR(tif, tif->tif_name, - "Error writing private subdirectory count"); - goto bad; - } - if (!WriteOK(tif, data, dirsize)) - { - TIFFErrorExtR(tif, tif->tif_name, - "Error writing private subdirectory contents"); - goto bad; - } - if (!WriteOK(tif, &nextdiroff, sizeof(nextdiroff))) - { - TIFFErrorExtR(tif, tif->tif_name, - "Error writing private subdirectory link"); - goto bad; - } - tif->tif_dataoff += sizeof(dircount) + dirsize + sizeof(nextdiroff); + (void) TIFFSeekFile(tif, tif->tif_dataoff, SEEK_SET); + if (!WriteOK(tif, &dircount, sizeof (dircount))) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing private subdirectory count"); + goto bad; + } + if (!WriteOK(tif, data, dirsize)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing private subdirectory contents"); + goto bad; + } + if (!WriteOK(tif, &nextdiroff, sizeof (nextdiroff))) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing private subdirectory link"); + goto bad; + } + tif->tif_dataoff += sizeof(dircount) + dirsize + sizeof(nextdiroff); - _TIFFfree(data); - _TIFFfree(fields); - tif->tif_flags &= ~TIFF_DIRTYDIRECT; + _TIFFfree(data); + _TIFFfree(fields); + tif->tif_flags &= ~TIFF_DIRTYDIRECT; #if (0) - /* This stuff commented out because I don't think we want it for - subdirectories, but I could be wrong. */ - (*tif->tif_cleanup)(tif); + /* This stuff commented out because I don't think we want it for + subdirectories, but I could be wrong. */ + (*tif->tif_cleanup)(tif); - /* - * Reset directory-related state for subsequent - * directories. - */ - TIFFDefaultDirectory(tif); - tif->tif_curoff = 0; - tif->tif_row = (uint32_t)-1; - tif->tif_curstrip = (tstrip_t)-1; + /* + * Reset directory-related state for subsequent + * directories. + */ + TIFFDefaultDirectory(tif); + tif->tif_curoff = 0; + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (tstrip_t) -1; #endif - return (directory_offset); + return (directory_offset); bad: - _TIFFfree(data); - _TIFFfree(fields); - return (0); + _TIFFfree(data); + _TIFFfree(fields); + return (0); } #undef WriteRationalPair @@ -324,187 +314,155 @@ bad: /* The standard function TIFFWriteNormalTag() could definitely be replaced with a simple call to this function, just adding TIFFGetField() as the last argument. */ -static int TIFFWriteNormalSubTag(TIFF *tif, TIFFDirEntry *dir, - const TIFFFieldInfo *fip, - int (*getFieldFn)(TIFF *tif, ttag_t tag, ...)) +static int +TIFFWriteNormalSubTag(TIFF* tif, TIFFDirEntry* dir, const TIFFFieldInfo* fip, + int (*getFieldFn)(TIFF *tif, ttag_t tag, ...)) { - u_short wc = (u_short)fip->field_writecount; + u_short wc = (u_short) fip->field_writecount; - dir->tdir_tag = fip->field_tag; - dir->tdir_type = (u_short)fip->field_type; - dir->tdir_count = wc; -#define WRITEF(x, y) x(tif, fip->field_type, fip->field_tag, dir, wc, y) - switch (fip->field_type) - { - case TIFF_SHORT: - case TIFF_SSHORT: - if (wc > 1) - { - uint16_t *wp; - if (wc == (u_short)TIFF_VARIABLE) - { - (*getFieldFn)(tif, fip->field_tag, &wc, &wp); - dir->tdir_count = wc; - } - else - (*getFieldFn)(tif, fip->field_tag, &wp); - if (!WRITEF(TIFFWriteShortArray, wp)) - return (0); - } - else - { - uint16_t sv; - (*getFieldFn)(tif, fip->field_tag, &sv); - dir->tdir_offset = TIFFInsertData(tif, dir->tdir_type, sv); - } - break; - case TIFF_LONG: - case TIFF_SLONG: - if (wc > 1) - { - uint32_t *lp; - if (wc == (u_short)TIFF_VARIABLE) - { - (*getFieldFn)(tif, fip->field_tag, &wc, &lp); - dir->tdir_count = wc; - } - else - (*getFieldFn)(tif, fip->field_tag, &lp); - if (!WRITEF(TIFFWriteLongArray, lp)) - return (0); - } - else - { - /* XXX handle LONG->SHORT conversion */ - (*getFieldFn)(tif, fip->field_tag, &dir->tdir_offset); - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - if (wc > 1) - { - float *fp; - if (wc == (u_short)TIFF_VARIABLE) - { - (*getFieldFn)(tif, fip->field_tag, &wc, &fp); - dir->tdir_count = wc; - } - else - (*getFieldFn)(tif, fip->field_tag, &fp); - if (!WRITEF(TIFFWriteRationalArray, fp)) - return (0); - } - else - { - float fv; - (*getFieldFn)(tif, fip->field_tag, &fv); - if (!WRITEF(TIFFWriteRationalArray, &fv)) - return (0); - } - break; - case TIFF_FLOAT: - if (wc > 1) - { - float *fp; - if (wc == (u_short)TIFF_VARIABLE) - { - (*getFieldFn)(tif, fip->field_tag, &wc, &fp); - dir->tdir_count = wc; - } - else - (*getFieldFn)(tif, fip->field_tag, &fp); - if (!WRITEF(TIFFWriteFloatArray, fp)) - return (0); - } - else - { - float fv; - (*getFieldFn)(tif, fip->field_tag, &fv); - if (!WRITEF(TIFFWriteFloatArray, &fv)) - return (0); - } - break; - case TIFF_DOUBLE: - /* Hey - I think this is a bug, or at least a "gross - inconsistency", in the TIFF library. Look at the original - TIFF library code below within the "#if (0) ... #else". - Just from the type of *dp, you can see that this code - expects TIFFGetField() to be handed a double ** for - any TIFF_DOUBLE tag, even for the constant wc==1 case. - This is totally inconsistent with other fields (like - TIFF_FLOAT, above) and is also inconsistent with the - TIFFSetField() function for TIFF_DOUBLEs, which expects - to be passed a single double by value for the wc==1 case. - (See the handling of TIFFFetchNormalTag() in tif_dirread.c - for an example.) Maybe this function was written before - TIFFWriteDoubleArray() was written, not that that's an - excuse. Anyway, the new code below is a trivial modification - of the TIFF_FLOAT code above. The fact that even single - doubles get written out in the data segment and get an - offset value stored is irrelevant here - that is all - handled by TIFFWriteDoubleArray(). */ + dir->tdir_tag = fip->field_tag; + dir->tdir_type = (u_short) fip->field_type; + dir->tdir_count = wc; +#define WRITEF(x,y) x(tif, fip->field_type, fip->field_tag, dir, wc, y) + switch (fip->field_type) { + case TIFF_SHORT: + case TIFF_SSHORT: + if (wc > 1) { + uint16* wp; + if (wc == (u_short) TIFF_VARIABLE) { + (*getFieldFn)(tif, fip->field_tag, &wc, &wp); + dir->tdir_count = wc; + } else + (*getFieldFn)(tif, fip->field_tag, &wp); + if (!WRITEF(TIFFWriteShortArray, wp)) + return (0); + } else { + uint16 sv; + (*getFieldFn)(tif, fip->field_tag, &sv); + dir->tdir_offset = + TIFFInsertData(tif, dir->tdir_type, sv); + } + break; + case TIFF_LONG: + case TIFF_SLONG: + if (wc > 1) { + uint32* lp; + if (wc == (u_short) TIFF_VARIABLE) { + (*getFieldFn)(tif, fip->field_tag, &wc, &lp); + dir->tdir_count = wc; + } else + (*getFieldFn)(tif, fip->field_tag, &lp); + if (!WRITEF(TIFFWriteLongArray, lp)) + return (0); + } else { + /* XXX handle LONG->SHORT conversion */ + (*getFieldFn)(tif, fip->field_tag, &dir->tdir_offset); + } + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + if (wc > 1) { + float* fp; + if (wc == (u_short) TIFF_VARIABLE) { + (*getFieldFn)(tif, fip->field_tag, &wc, &fp); + dir->tdir_count = wc; + } else + (*getFieldFn)(tif, fip->field_tag, &fp); + if (!WRITEF(TIFFWriteRationalArray, fp)) + return (0); + } else { + float fv; + (*getFieldFn)(tif, fip->field_tag, &fv); + if (!WRITEF(TIFFWriteRationalArray, &fv)) + return (0); + } + break; + case TIFF_FLOAT: + if (wc > 1) { + float* fp; + if (wc == (u_short) TIFF_VARIABLE) { + (*getFieldFn)(tif, fip->field_tag, &wc, &fp); + dir->tdir_count = wc; + } else + (*getFieldFn)(tif, fip->field_tag, &fp); + if (!WRITEF(TIFFWriteFloatArray, fp)) + return (0); + } else { + float fv; + (*getFieldFn)(tif, fip->field_tag, &fv); + if (!WRITEF(TIFFWriteFloatArray, &fv)) + return (0); + } + break; + case TIFF_DOUBLE: + /* Hey - I think this is a bug, or at least a "gross + inconsistency", in the TIFF library. Look at the original + TIFF library code below within the "#if (0) ... #else". + Just from the type of *dp, you can see that this code + expects TIFFGetField() to be handed a double ** for + any TIFF_DOUBLE tag, even for the constant wc==1 case. + This is totally inconsistent with other fields (like + TIFF_FLOAT, above) and is also inconsistent with the + TIFFSetField() function for TIFF_DOUBLEs, which expects + to be passed a single double by value for the wc==1 case. + (See the handling of TIFFFetchNormalTag() in tif_dirread.c + for an example.) Maybe this function was written before + TIFFWriteDoubleArray() was written, not that that's an + excuse. Anyway, the new code below is a trivial modification + of the TIFF_FLOAT code above. The fact that even single + doubles get written out in the data segment and get an + offset value stored is irrelevant here - that is all + handled by TIFFWriteDoubleArray(). */ #if (0) - { - double *dp; - if (wc == (u_short)TIFF_VARIABLE) - { - (*getFieldFn)(tif, fip->field_tag, &wc, &dp); - dir->tdir_count = wc; - } - else - (*getFieldFn)(tif, fip->field_tag, &dp); - TIFFCvtNativeToIEEEDouble(tif, wc, dp); - if (!TIFFWriteData(tif, dir, (char *)dp)) - return (0); - } + { double* dp; + if (wc == (u_short) TIFF_VARIABLE) { + (*getFieldFn)(tif, fip->field_tag, &wc, &dp); + dir->tdir_count = wc; + } else + (*getFieldFn)(tif, fip->field_tag, &dp); + TIFFCvtNativeToIEEEDouble(tif, wc, dp); + if (!TIFFWriteData(tif, dir, (char*) dp)) + return (0); + } #else - if (wc > 1) - { - double *dp; - if (wc == (u_short)TIFF_VARIABLE) - { - (*getFieldFn)(tif, fip->field_tag, &wc, &dp); - dir->tdir_count = wc; - } - else - (*getFieldFn)(tif, fip->field_tag, &dp); - if (!WRITEF(TIFFWriteDoubleArray, dp)) - return (0); - } - else - { - double dv; - (*getFieldFn)(tif, fip->field_tag, &dv); - if (!WRITEF(TIFFWriteDoubleArray, &dv)) - return (0); - } + if (wc > 1) { + double* dp; + if (wc == (u_short) TIFF_VARIABLE) { + (*getFieldFn)(tif, fip->field_tag, &wc, &dp); + dir->tdir_count = wc; + } else + (*getFieldFn)(tif, fip->field_tag, &dp); + if (!WRITEF(TIFFWriteDoubleArray, dp)) + return (0); + } else { + double dv; + (*getFieldFn)(tif, fip->field_tag, &dv); + if (!WRITEF(TIFFWriteDoubleArray, &dv)) + return (0); + } #endif - break; - case TIFF_ASCII: - { - char *cp; - (*getFieldFn)(tif, fip->field_tag, &cp); - dir->tdir_count = (uint32_t)(strlen(cp) + 1); - if (!TIFFWriteByteArray(tif, dir, cp)) - return (0); - } - break; - case TIFF_UNDEFINED: - { - char *cp; - if (wc == (u_short)TIFF_VARIABLE) - { - (*getFieldFn)(tif, fip->field_tag, &wc, &cp); - dir->tdir_count = wc; - } - else - (*getFieldFn)(tif, fip->field_tag, &cp); - if (!TIFFWriteByteArray(tif, dir, cp)) - return (0); - } - break; - } - return (1); + break; + case TIFF_ASCII: + { char* cp; + (*getFieldFn)(tif, fip->field_tag, &cp); + dir->tdir_count = (uint32) (strlen(cp) + 1); + if (!TIFFWriteByteArray(tif, dir, cp)) + return (0); + } + break; + case TIFF_UNDEFINED: + { char* cp; + if (wc == (u_short) TIFF_VARIABLE) { + (*getFieldFn)(tif, fip->field_tag, &wc, &cp); + dir->tdir_count = wc; + } else + (*getFieldFn)(tif, fip->field_tag, &cp); + if (!TIFFWriteByteArray(tif, dir, cp)) + return (0); + } + break; + } + return (1); } #undef WRITEF @@ -516,21 +474,18 @@ static int TIFFWriteNormalSubTag(TIFF *tif, TIFFDirEntry *dir, * Setup a directory entry with either a SHORT * or LONG type according to the value. */ -static void TIFFSetupShortLong(TIFF *tif, ttag_t tag, TIFFDirEntry *dir, - uint32_t v) +static void +TIFFSetupShortLong(TIFF* tif, ttag_t tag, TIFFDirEntry* dir, uint32 v) { - dir->tdir_tag = tag; - dir->tdir_count = 1; - if (v > 0xffffL) - { - dir->tdir_type = (short)TIFF_LONG; - dir->tdir_offset = v; - } - else - { - dir->tdir_type = (short)TIFF_SHORT; - dir->tdir_offset = TIFFInsertData(tif, (int)TIFF_SHORT, v); - } + dir->tdir_tag = tag; + dir->tdir_count = 1; + if (v > 0xffffL) { + dir->tdir_type = (short) TIFF_LONG; + dir->tdir_offset = v; + } else { + dir->tdir_type = (short) TIFF_SHORT; + dir->tdir_offset = TIFFInsertData(tif, (int) TIFF_SHORT, v); + } } #undef MakeShortDirent @@ -539,35 +494,37 @@ static void TIFFSetupShortLong(TIFF *tif, ttag_t tag, TIFFDirEntry *dir, * Setup a RATIONAL directory entry and * write the associated indirect value. */ -static int TIFFWriteRational(TIFF *tif, TIFFDataType type, ttag_t tag, - TIFFDirEntry *dir, float v) +static int +TIFFWriteRational(TIFF* tif, + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, float v) { - return (TIFFWriteRationalArray(tif, type, tag, dir, 1, &v)); + return (TIFFWriteRationalArray(tif, type, tag, dir, 1, &v)); } #endif -#define NITEMS(x) (sizeof(x) / sizeof(x[0])) +#define NITEMS(x) (sizeof (x) / sizeof (x[0])) /* * Setup a directory entry that references a * samples/pixel array of SHORT values and * (potentially) write the associated indirect * values. */ -static int TIFFWritePerSampleShorts(TIFF *tif, ttag_t tag, TIFFDirEntry *dir) +static int +TIFFWritePerSampleShorts(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) { - uint16_t buf[10], v; - uint16_t *w = buf; - int i, status, samples = tif->tif_dir.td_samplesperpixel; + uint16 buf[10], v; + uint16* w = buf; + int i, status, samples = tif->tif_dir.td_samplesperpixel; - if (samples > NITEMS(buf)) - w = (uint16_t *)_TIFFmalloc(samples * sizeof(uint16_t)); - TIFFGetField(tif, tag, &v); - for (i = 0; i < samples; i++) - w[i] = v; - status = TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, samples, w); - if (w != buf) - _TIFFfree((char *)w); - return (status); + if (samples > NITEMS(buf)) + w = (uint16*) _TIFFmalloc(samples * sizeof (uint16)); + TIFFGetField(tif, tag, &v); + for (i = 0; i < samples; i++) + w[i] = v; + status = TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, samples, w); + if (w != buf) + _TIFFfree((char*) w); + return (status); } /* @@ -575,23 +532,24 @@ static int TIFFWritePerSampleShorts(TIFF *tif, ttag_t tag, TIFFDirEntry *dir) * values and (potentially) write the associated indirect values. The source * data from TIFFGetField() for the specified tag must be returned as double. */ -static int TIFFWritePerSampleAnys(TIFF *tif, TIFFDataType type, ttag_t tag, - TIFFDirEntry *dir) +static int +TIFFWritePerSampleAnys(TIFF* tif, + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir) { - double buf[10], v; - double *w = buf; - int i, status; - int samples = (int)tif->tif_dir.td_samplesperpixel; + double buf[10], v; + double* w = buf; + int i, status; + int samples = (int) tif->tif_dir.td_samplesperpixel; - if (samples > NITEMS(buf)) - w = (double *)_TIFFmalloc(samples * sizeof(double)); - TIFFGetField(tif, tag, &v); - for (i = 0; i < samples; i++) - w[i] = v; - status = TIFFWriteAnyArray(tif, type, tag, dir, samples, w); - if (w != buf) - _TIFFfree(w); - return (status); + if (samples > NITEMS(buf)) + w = (double*) _TIFFmalloc(samples * sizeof (double)); + TIFFGetField(tif, tag, &v); + for (i = 0; i < samples; i++) + w[i] = v; + status = TIFFWriteAnyArray(tif, type, tag, dir, samples, w); + if (w != buf) + _TIFFfree(w); + return (status); } #undef NITEMS @@ -599,12 +557,13 @@ static int TIFFWritePerSampleAnys(TIFF *tif, TIFFDataType type, ttag_t tag, * Setup a pair of shorts that are returned by * value, rather than as a reference to an array. */ -static int TIFFSetupShortPair(TIFF *tif, ttag_t tag, TIFFDirEntry *dir) +static int +TIFFSetupShortPair(TIFF* tif, ttag_t tag, TIFFDirEntry* dir) { - uint16_t v[2]; + uint16 v[2]; - TIFFGetField(tif, tag, &v[0], &v[1]); - return (TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, 2, v)); + TIFFGetField(tif, tag, &v[0], &v[1]); + return (TIFFWriteShortArray(tif, TIFF_SHORT, tag, dir, 2, v)); } /* @@ -612,160 +571,150 @@ static int TIFFSetupShortPair(TIFF *tif, ttag_t tag, TIFFDirEntry *dir) * where M is known to be 2**bitspersample, and write * the associated indirect data. */ -static int TIFFWriteShortTable(TIFF *tif, ttag_t tag, TIFFDirEntry *dir, - uint32_t n, uint16_t **table) +static int +TIFFWriteShortTable(TIFF* tif, + ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16** table) { - uint32_t i, off; + uint32 i, off; - dir->tdir_tag = tag; - dir->tdir_type = (short)TIFF_SHORT; - /* XXX -- yech, fool TIFFWriteData */ - dir->tdir_count = (uint32_t)(1L << tif->tif_dir.td_bitspersample); - off = tif->tif_dataoff; - for (i = 0; i < n; i++) - if (!TIFFWriteData(tif, dir, (char *)table[i])) - return (0); - dir->tdir_count *= n; - dir->tdir_offset = off; - return (1); + dir->tdir_tag = tag; + dir->tdir_type = (short) TIFF_SHORT; + /* XXX -- yech, fool TIFFWriteData */ + dir->tdir_count = (uint32) (1L<tif_dir.td_bitspersample); + off = tif->tif_dataoff; + for (i = 0; i < n; i++) + if (!TIFFWriteData(tif, dir, (char *)table[i])) + return (0); + dir->tdir_count *= n; + dir->tdir_offset = off; + return (1); } /* * Write/copy data associated with an ASCII or opaque tag value. */ -static int TIFFWriteByteArray(TIFF *tif, TIFFDirEntry *dir, char *cp) +static int +TIFFWriteByteArray(TIFF* tif, TIFFDirEntry* dir, char* cp) { - if (dir->tdir_count > 4) - { - if (!TIFFWriteData(tif, dir, cp)) - return (0); - } - else - _TIFFmemcpy(&dir->tdir_offset, cp, dir->tdir_count); - return (1); + if (dir->tdir_count > 4) { + if (!TIFFWriteData(tif, dir, cp)) + return (0); + } else + _TIFFmemcpy(&dir->tdir_offset, cp, dir->tdir_count); + return (1); } /* * Setup a directory entry of an array of SHORT * or SSHORT and write the associated indirect values. */ -static int TIFFWriteShortArray(TIFF *tif, TIFFDataType type, ttag_t tag, - TIFFDirEntry *dir, uint32_t n, uint16_t *v) +static int +TIFFWriteShortArray(TIFF* tif, + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint16* v) { - dir->tdir_tag = tag; - dir->tdir_type = (short)type; - dir->tdir_count = n; - if (n <= 2) - { - if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) - { - dir->tdir_offset = (uint32_t)((long)v[0] << 16); - if (n == 2) - dir->tdir_offset |= v[1] & 0xffff; - } - else - { - dir->tdir_offset = v[0] & 0xffff; - if (n == 2) - dir->tdir_offset |= (long)v[1] << 16; - } - return (1); - } - else - return (TIFFWriteData(tif, dir, (char *)v)); + dir->tdir_tag = tag; + dir->tdir_type = (short) type; + dir->tdir_count = n; + if (n <= 2) { + if (tif->tif_header.tiff_magic == TIFF_BIGENDIAN) { + dir->tdir_offset = (uint32) ((long) v[0] << 16); + if (n == 2) + dir->tdir_offset |= v[1] & 0xffff; + } else { + dir->tdir_offset = v[0] & 0xffff; + if (n == 2) + dir->tdir_offset |= (long) v[1] << 16; + } + return (1); + } else + return (TIFFWriteData(tif, dir, (char*) v)); } /* * Setup a directory entry of an array of LONG * or SLONG and write the associated indirect values. */ -static int TIFFWriteLongArray(TIFF *tif, TIFFDataType type, ttag_t tag, - TIFFDirEntry *dir, uint32_t n, uint32_t *v) +static int +TIFFWriteLongArray(TIFF* tif, + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, uint32* v) { - dir->tdir_tag = tag; - dir->tdir_type = (short)type; - dir->tdir_count = n; - if (n == 1) - { - dir->tdir_offset = v[0]; - return (1); - } - else - return (TIFFWriteData(tif, dir, (char *)v)); + dir->tdir_tag = tag; + dir->tdir_type = (short) type; + dir->tdir_count = n; + if (n == 1) { + dir->tdir_offset = v[0]; + return (1); + } else + return (TIFFWriteData(tif, dir, (char*) v)); } /* * Setup a directory entry of an array of RATIONAL * or SRATIONAL and write the associated indirect values. */ -static int TIFFWriteRationalArray(TIFF *tif, TIFFDataType type, ttag_t tag, - TIFFDirEntry *dir, uint32_t n, float *v) +static int +TIFFWriteRationalArray(TIFF* tif, + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v) { - uint32_t i; - uint32_t *t; - int status; + uint32 i; + uint32* t; + int status; - dir->tdir_tag = tag; - dir->tdir_type = (short)type; - dir->tdir_count = n; - t = (uint32_t *)_TIFFmalloc(2 * n * sizeof(uint32_t)); - for (i = 0; i < n; i++) - { - float fv = v[i]; - int sign = 1; - uint32_t den; + dir->tdir_tag = tag; + dir->tdir_type = (short) type; + dir->tdir_count = n; + t = (uint32*) _TIFFmalloc(2*n * sizeof (uint32)); + for (i = 0; i < n; i++) { + float fv = v[i]; + int sign = 1; + uint32 den; - if (fv < 0) - { - if (type == TIFF_RATIONAL) - { - TIFFWarning(tif->tif_name, - "\"%s\": Information lost writing value (%g) as " - "(unsigned) RATIONAL", - _TIFFFieldWithTag(tif, tag)->field_name, v); - fv = 0; - } - else - fv = -fv, sign = -1; - } - den = 1L; - if (fv > 0) - { - while (fv < 1L << (31 - 3) && den < 1L << (31 - 3)) - fv *= 1 << 3, den *= 1L << 3; - } - t[2 * i + 0] = sign * (fv + 0.5); - t[2 * i + 1] = den; - } - status = TIFFWriteData(tif, dir, (char *)t); - _TIFFfree((char *)t); - return (status); + if (fv < 0) { + if (type == TIFF_RATIONAL) { + TIFFWarning(tif->tif_name, + "\"%s\": Information lost writing value (%g) as (unsigned) RATIONAL", + _TIFFFieldWithTag(tif,tag)->field_name, v); + fv = 0; + } else + fv = -fv, sign = -1; + } + den = 1L; + if (fv > 0) { + while (fv < 1L<<(31-3) && den < 1L<<(31-3)) + fv *= 1<<3, den *= 1L<<3; + } + t[2*i+0] = sign * (fv + 0.5); + t[2*i+1] = den; + } + status = TIFFWriteData(tif, dir, (char *)t); + _TIFFfree((char*) t); + return (status); } -static int TIFFWriteFloatArray(TIFF *tif, TIFFDataType type, ttag_t tag, - TIFFDirEntry *dir, uint32_t n, float *v) +static int +TIFFWriteFloatArray(TIFF* tif, + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, float* v) { - dir->tdir_tag = tag; - dir->tdir_type = (short)type; - dir->tdir_count = n; - TIFFCvtNativeToIEEEFloat(tif, n, v); - if (n == 1) - { - dir->tdir_offset = *(uint32_t *)&v[0]; - return (1); - } - else - return (TIFFWriteData(tif, dir, (char *)v)); + dir->tdir_tag = tag; + dir->tdir_type = (short) type; + dir->tdir_count = n; + TIFFCvtNativeToIEEEFloat(tif, n, v); + if (n == 1) { + dir->tdir_offset = *(uint32*) &v[0]; + return (1); + } else + return (TIFFWriteData(tif, dir, (char*) v)); } -static int TIFFWriteDoubleArray(TIFF *tif, TIFFDataType type, ttag_t tag, - TIFFDirEntry *dir, uint32_t n, double *v) +static int +TIFFWriteDoubleArray(TIFF* tif, + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v) { - dir->tdir_tag = tag; - dir->tdir_type = (short)type; - dir->tdir_count = n; - TIFFCvtNativeToIEEEDouble(tif, n, v); - return (TIFFWriteData(tif, dir, (char *)v)); + dir->tdir_tag = tag; + dir->tdir_type = (short) type; + dir->tdir_count = n; + TIFFCvtNativeToIEEEDouble(tif, n, v); + return (TIFFWriteData(tif, dir, (char*) v)); } /* @@ -777,261 +726,244 @@ static int TIFFWriteDoubleArray(TIFF *tif, TIFFDataType type, ttag_t tag, * type in a temporary buffer and then handed off to the appropriate array * writer. */ -static int TIFFWriteAnyArray(TIFF *tif, TIFFDataType type, ttag_t tag, - TIFFDirEntry *dir, uint32_t n, double *v) +static int +TIFFWriteAnyArray(TIFF* tif, + TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, uint32 n, double* v) { - char buf[10 * sizeof(double)]; - char *w = buf; - int i, status = 0; + char buf[10 * sizeof(double)]; + char* w = buf; + int i, status = 0; - if (n * TIFFDataWidth(type) > sizeof buf) - w = (char *)_TIFFmalloc(n * TIFFDataWidth(type)); - switch (type) - { - case TIFF_BYTE: - { - unsigned char *bp = (unsigned char *)w; - for (i = 0; i < n; i++) - bp[i] = (unsigned char)v[i]; - dir->tdir_tag = tag; - dir->tdir_type = (short)type; - dir->tdir_count = n; - if (!TIFFWriteByteArray(tif, dir, (char *)bp)) - goto out; - } - break; - case TIFF_SBYTE: - { - signed char *bp = (signed char *)w; - for (i = 0; i < n; i++) - bp[i] = (signed char)v[i]; - dir->tdir_tag = tag; - dir->tdir_type = (short)type; - dir->tdir_count = n; - if (!TIFFWriteByteArray(tif, dir, (char *)bp)) - goto out; - } - break; - case TIFF_SHORT: - { - uint16_t *bp = (uint16_t *)w; - for (i = 0; i < n; i++) - bp[i] = (uint16_t)v[i]; - if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16_t *)bp)) - goto out; - } - break; - case TIFF_SSHORT: - { - int16_t *bp = (int16_t *)w; - for (i = 0; i < n; i++) - bp[i] = (int16_t)v[i]; - if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16_t *)bp)) - goto out; - } - break; - case TIFF_LONG: - { - uint32_t *bp = (uint32_t *)w; - for (i = 0; i < n; i++) - bp[i] = (uint32_t)v[i]; - if (!TIFFWriteLongArray(tif, type, tag, dir, n, bp)) - goto out; - } - break; - case TIFF_SLONG: - { - int32_t *bp = (int32_t *)w; - for (i = 0; i < n; i++) - bp[i] = (int32_t)v[i]; - if (!TIFFWriteLongArray(tif, type, tag, dir, n, (uint32_t *)bp)) - goto out; - } - break; - case TIFF_FLOAT: - { - float *bp = (float *)w; - for (i = 0; i < n; i++) - bp[i] = (float)v[i]; - if (!TIFFWriteFloatArray(tif, type, tag, dir, n, bp)) - goto out; - } - break; - case TIFF_DOUBLE: - return (TIFFWriteDoubleArray(tif, type, tag, dir, n, v)); - default: - /* TIFF_NOTYPE */ - /* TIFF_ASCII */ - /* TIFF_UNDEFINED */ - /* TIFF_RATIONAL */ - /* TIFF_SRATIONAL */ - goto out; - } - status = 1; -out: - if (w != buf) - _TIFFfree(w); - return (status); + if (n * TIFFDataWidth(type) > sizeof buf) + w = (char*) _TIFFmalloc(n * TIFFDataWidth(type)); + switch (type) { + case TIFF_BYTE: + { unsigned char* bp = (unsigned char*) w; + for (i = 0; i < n; i++) + bp[i] = (unsigned char) v[i]; + dir->tdir_tag = tag; + dir->tdir_type = (short) type; + dir->tdir_count = n; + if (!TIFFWriteByteArray(tif, dir, (char*) bp)) + goto out; + } + break; + case TIFF_SBYTE: + { signed char* bp = (signed char*) w; + for (i = 0; i < n; i++) + bp[i] = (signed char) v[i]; + dir->tdir_tag = tag; + dir->tdir_type = (short) type; + dir->tdir_count = n; + if (!TIFFWriteByteArray(tif, dir, (char*) bp)) + goto out; + } + break; + case TIFF_SHORT: + { uint16* bp = (uint16*) w; + for (i = 0; i < n; i++) + bp[i] = (uint16) v[i]; + if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp)) + goto out; + } + break; + case TIFF_SSHORT: + { int16* bp = (int16*) w; + for (i = 0; i < n; i++) + bp[i] = (int16) v[i]; + if (!TIFFWriteShortArray(tif, type, tag, dir, n, (uint16*)bp)) + goto out; + } + break; + case TIFF_LONG: + { uint32* bp = (uint32*) w; + for (i = 0; i < n; i++) + bp[i] = (uint32) v[i]; + if (!TIFFWriteLongArray(tif, type, tag, dir, n, bp)) + goto out; + } + break; + case TIFF_SLONG: + { int32* bp = (int32*) w; + for (i = 0; i < n; i++) + bp[i] = (int32) v[i]; + if (!TIFFWriteLongArray(tif, type, tag, dir, n, (uint32*) bp)) + goto out; + } + break; + case TIFF_FLOAT: + { float* bp = (float*) w; + for (i = 0; i < n; i++) + bp[i] = (float) v[i]; + if (!TIFFWriteFloatArray(tif, type, tag, dir, n, bp)) + goto out; + } + break; + case TIFF_DOUBLE: + return (TIFFWriteDoubleArray(tif, type, tag, dir, n, v)); + default: + /* TIFF_NOTYPE */ + /* TIFF_ASCII */ + /* TIFF_UNDEFINED */ + /* TIFF_RATIONAL */ + /* TIFF_SRATIONAL */ + goto out; + } + status = 1; + out: + if (w != buf) + _TIFFfree(w); + return (status); } #ifdef COLORIMETRY_SUPPORT -static int TIFFWriteTransferFunction(TIFF *tif, TIFFDirEntry *dir) +static int +TIFFWriteTransferFunction(TIFF* tif, TIFFDirEntry* dir) { - TIFFDirectory *td = &tif->tif_dir; - tsize_t n = (1L << td->td_bitspersample) * sizeof(uint16_t); - uint16_t **tf = td->td_transferfunction; - int ncols; + TIFFDirectory* td = &tif->tif_dir; + tsize_t n = (1L<td_bitspersample) * sizeof (uint16); + uint16** tf = td->td_transferfunction; + int ncols; - /* - * Check if the table can be written as a single column, - * or if it must be written as 3 columns. Note that we - * write a 3-column tag if there are 2 samples/pixel and - * a single column of data won't suffice--hmm. - */ - switch (td->td_samplesperpixel - td->td_extrasamples) - { - default: - if (_TIFFmemcmp(tf[0], tf[2], n)) - { - ncols = 3; - break; - } - case 2: - if (_TIFFmemcmp(tf[0], tf[1], n)) - { - ncols = 3; - break; - } - case 1: - case 0: - ncols = 1; - } - return (TIFFWriteShortTable(tif, TIFFTAG_TRANSFERFUNCTION, dir, ncols, tf)); + /* + * Check if the table can be written as a single column, + * or if it must be written as 3 columns. Note that we + * write a 3-column tag if there are 2 samples/pixel and + * a single column of data won't suffice--hmm. + */ + switch (td->td_samplesperpixel - td->td_extrasamples) { + default: if (_TIFFmemcmp(tf[0], tf[2], n)) { ncols = 3; break; } + case 2: if (_TIFFmemcmp(tf[0], tf[1], n)) { ncols = 3; break; } + case 1: case 0: ncols = 1; + } + return (TIFFWriteShortTable(tif, + TIFFTAG_TRANSFERFUNCTION, dir, ncols, tf)); } #endif /* * Write a contiguous directory item. */ -static int TIFFWriteData(TIFF *tif, TIFFDirEntry *dir, char *cp) +static int +TIFFWriteData(TIFF* tif, TIFFDirEntry* dir, char* cp) { - tsize_t cc; + tsize_t cc; - if (tif->tif_flags & TIFF_SWAB) - { - switch (dir->tdir_type) - { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16_t *)cp, dir->tdir_count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - TIFFSwabArrayOfLong((uint32_t *)cp, dir->tdir_count); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32_t *)cp, 2 * dir->tdir_count); - break; - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double *)cp, dir->tdir_count); - break; - } - } - dir->tdir_offset = tif->tif_dataoff; - cc = dir->tdir_count * TIFFDataWidth(dir->tdir_type); - if (SeekOK(tif, dir->tdir_offset) && WriteOK(tif, cp, cc)) - { - tif->tif_dataoff += (cc + 1) & ~1; - return (1); - } - TIFFErrorExtR(tif, tif->tif_name, "Error writing data for field \"%s\"", - _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); - return (0); + if (tif->tif_flags & TIFF_SWAB) { + switch (dir->tdir_type) { + case TIFF_SHORT: + case TIFF_SSHORT: + TIFFSwabArrayOfShort((uint16*) cp, dir->tdir_count); + break; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + TIFFSwabArrayOfLong((uint32*) cp, dir->tdir_count); + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + TIFFSwabArrayOfLong((uint32*) cp, 2*dir->tdir_count); + break; + case TIFF_DOUBLE: + TIFFSwabArrayOfDouble((double*) cp, dir->tdir_count); + break; + } + } + dir->tdir_offset = tif->tif_dataoff; + cc = dir->tdir_count * TIFFDataWidth(dir->tdir_type); + if (SeekOK(tif, dir->tdir_offset) && + WriteOK(tif, cp, cc)) { + tif->tif_dataoff += (cc + 1) & ~1; + return (1); + } + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing data for field \"%s\"", + _TIFFFieldWithTag(tif, dir->tdir_tag)->field_name); + return (0); } /* * Link the current directory into the * directory chain for the file. */ -static int TIFFLinkDirectory(TIFF *tif) +static int +TIFFLinkDirectory(TIFF* tif) { - static const char module[] = "TIFFLinkDirectory"; - uint32_t nextdir; - uint32_t diroff; + static const char module[] = "TIFFLinkDirectory"; + uint32 nextdir; + uint32 diroff; - tif->tif_diroff = (TIFFSeekFile(tif, (toff_t)0, SEEK_END) + 1) & ~1; - diroff = (uint32_t)tif->tif_diroff; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&diroff); + tif->tif_diroff = (TIFFSeekFile(tif, (toff_t) 0, SEEK_END)+1) &~ 1; + diroff = (uint32) tif->tif_diroff; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&diroff); #if SUBIFD_SUPPORT - if (tif->tif_flags & TIFF_INSUBIFD) - { - (void)TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof(diroff))) - { - TIFFErrorExtR(tif, module, - "%s: Error writing SubIFD directory link", - tif->tif_name); - return (0); - } - /* - * Advance to the next SubIFD or, if this is - * the last one configured, revert back to the - * normal directory linkage. - */ - if (--tif->tif_nsubifd) - tif->tif_subifdoff += sizeof(diroff); - else - tif->tif_flags &= ~TIFF_INSUBIFD; - return (1); - } + if (tif->tif_flags & TIFF_INSUBIFD) { + (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); + if (!WriteOK(tif, &diroff, sizeof (diroff))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Error writing SubIFD directory link", + tif->tif_name); + return (0); + } + /* + * Advance to the next SubIFD or, if this is + * the last one configured, revert back to the + * normal directory linkage. + */ + if (--tif->tif_nsubifd) + tif->tif_subifdoff += sizeof (diroff); + else + tif->tif_flags &= ~TIFF_INSUBIFD; + return (1); + } #endif - if (tif->tif_header.tiff_diroff == 0) - { - /* - * First directory, overwrite offset in header. - */ - tif->tif_header.tiff_diroff = (uint32_t)tif->tif_diroff; -#define HDROFF(f) ((toff_t) & (((TIFFHeader *)0)->f)) - (void)TIFFSeekFile(tif, HDROFF(tiff_diroff), SEEK_SET); - if (!WriteOK(tif, &diroff, sizeof(diroff))) - { - TIFFErrorExtR(tif, tif->tif_name, "Error writing TIFF header"); - return (0); - } - return (1); - } - /* - * Not the first directory, search to the last and append. - */ - nextdir = tif->tif_header.tiff_diroff; - do - { - uint16_t dircount; + if (tif->tif_header.tiff_diroff == 0) { + /* + * First directory, overwrite offset in header. + */ + tif->tif_header.tiff_diroff = (uint32) tif->tif_diroff; +#define HDROFF(f) ((toff_t) &(((TIFFHeader*) 0)->f)) + (void) TIFFSeekFile(tif, HDROFF(tiff_diroff), SEEK_SET); + if (!WriteOK(tif, &diroff, sizeof (diroff))) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Error writing TIFF header"); + return (0); + } + return (1); + } + /* + * Not the first directory, search to the last and append. + */ + nextdir = tif->tif_header.tiff_diroff; + do { + uint16 dircount; - if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, sizeof(dircount))) - { - TIFFErrorExtR(tif, module, "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - (void)TIFFSeekFile(tif, dircount * sizeof(TIFFDirEntry), SEEK_CUR); - if (!ReadOK(tif, &nextdir, sizeof(nextdir))) - { - TIFFErrorExtR(tif, module, "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir); - } while (nextdir != 0); - (void)TIFFSeekFile(tif, -(toff_t)sizeof(nextdir), SEEK_CUR); - if (!WriteOK(tif, &diroff, sizeof(diroff))) - { - TIFFErrorExtR(tif, module, "Error writing directory link"); - return (0); - } - return (1); + if (!SeekOK(tif, nextdir) || + !ReadOK(tif, &dircount, sizeof (dircount))) { + TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + (void) TIFFSeekFile(tif, + dircount * sizeof (TIFFDirEntry), SEEK_CUR); + if (!ReadOK(tif, &nextdir, sizeof (nextdir))) { + TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory link"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextdir); + } while (nextdir != 0); + (void) TIFFSeekFile(tif, -(toff_t) sizeof (nextdir), SEEK_CUR); + if (!WriteOK(tif, &diroff, sizeof (diroff))) { + TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); + return (0); + } + return (1); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/ras/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/contrib/ras/CMakeLists.txt new file mode 100644 index 000000000..b19a04fa4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/contrib/ras/CMakeLists.txt @@ -0,0 +1,28 @@ +# CMake build for libtiff +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Written by Roger Leigh +# +# 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. + +extra_dist( + README + ras2tif.c + tif2ras.c) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/ras/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/ras/Makefile.am index 92e124bf1..26617edfe 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/ras/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/ras/Makefile.am @@ -24,6 +24,7 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ + CMakeLists.txt \ README \ ras2tif.c \ tif2ras.c diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/ras/ras2tif.c b/thirdparty/SDL2_image/external/libtiff/contrib/ras/ras2tif.c index c2f35a43c..c44b313e3 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/ras/ras2tif.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/ras/ras2tif.c @@ -43,152 +43,157 @@ static char sccsid[] = "@(#)ras2tif.c 1.2 90/03/06"; * real file since seek(2) is used. */ -#include "tiffio.h" -#include #include #include +#include +#include "tiffio.h" typedef int boolean; #define True (1) #define False (0) -#define SCALE(x) (((x) * ((1L << 16) - 1)) / 255) +#define SCALE(x) (((x)*((1L<<16)-1))/255) -boolean Verbose = False; -boolean dummyinput = False; -char *pname; /* program name (used for error messages) */ +boolean Verbose = False; +boolean dummyinput = False; +char *pname; /* program name (used for error messages) */ -void error(s1, s2) char *s1, *s2; +void +error(s1, s2) + char *s1, + *s2; { fprintf(stderr, s1, pname, s2); exit(1); } -void usage() { error("usage: %s -[vq] [-|rasterfile] TIFFfile\n", NULL); } - -main(argc, argv) int argc; -char *argv[]; +void +usage() { - char *inf = NULL; - char *outf = NULL; - FILE *fp; - int depth, i; - long row; - TIFF *tif; - Pixrect *pix; /* The Sun Pixrect */ - colormap_t Colormap; /* The Pixrect Colormap */ - u_short red[256], green[256], blue[256]; - struct tm *ct; + error("usage: %s -[vq] [-|rasterfile] TIFFfile\n", NULL); +} + + +main(argc, argv) + int argc; + char *argv[]; +{ + char *inf = NULL; + char *outf = NULL; + FILE *fp; + int depth, + i; + long row; + TIFF *tif; + Pixrect *pix; /* The Sun Pixrect */ + colormap_t Colormap; /* The Pixrect Colormap */ + u_short red[256], + green[256], + blue[256]; + struct tm *ct; struct timeval tv; - long width, height; - long rowsperstrip; - int year; - short photometric; - short samplesperpixel; - short bitspersample; - int bpsl; + long width, + height; + long rowsperstrip; + int year; + short photometric; + short samplesperpixel; + short bitspersample; + int bpsl; static char *version = "ras2tif 1.0"; static char *datetime = "1990:01:01 12:00:00"; - gettimeofday(&tv, (struct timezone *)NULL); + gettimeofday(&tv, (struct timezone *) NULL); ct = localtime(&tv.tv_sec); - year = 1900 + ct->tm_year; - sprintf(datetime, "%04d:%02d:%02d %02d:%02d:%02d", year, ct->tm_mon + 1, - ct->tm_mday, ct->tm_hour, ct->tm_min, ct->tm_sec); + year=1900 + ct->tm_year; + sprintf(datetime, "%04d:%02d:%02d %02d:%02d:%02d", + year, ct->tm_mon + 1, ct->tm_mday, + ct->tm_hour, ct->tm_min, ct->tm_sec); setbuf(stderr, NULL); pname = argv[0]; - while (--argc) - { - if ((++argv)[0][0] == '-') - { - switch (argv[0][1]) - { - case 'v': - Verbose = True; - break; - case 'q': - usage(); - break; - case '\0': - if (inf == NULL) - dummyinput = True; - else - usage(); - break; - default: - fprintf(stderr, "%s: illegal option -%c.\n", pname, - argv[0][1]); - exit(1); - } - } - else if (inf == NULL && !dummyinput) - { - inf = argv[0]; - } - else if (outf == NULL) - outf = argv[0]; - else - usage(); + while (--argc) { + if ((++argv)[0][0] == '-') { + switch (argv[0][1]) { + case 'v': + Verbose = True; + break; + case 'q': + usage(); + break; + case '\0': + if (inf == NULL) + dummyinput = True; + else + usage(); + break; + default: + fprintf(stderr, "%s: illegal option -%c.\n", pname, + argv[0][1]); + exit(1); + } + } else if (inf == NULL && !dummyinput) { + inf = argv[0]; + } else if (outf == NULL) + outf = argv[0]; + else + usage(); } if (outf == NULL) - error("%s: can't write output file to a stream.\n", NULL); + error("%s: can't write output file to a stream.\n", NULL); - if (dummyinput || inf == NULL) - { - inf = "Standard Input"; - fp = stdin; - } - else if ((fp = fopen(inf, "r")) == NULL) - error("%s: %s couldn't be opened.\n", inf); + if (dummyinput || inf == NULL) { + inf = "Standard Input"; + fp = stdin; + } else if ((fp = fopen(inf, "r")) == NULL) + error("%s: %s couldn't be opened.\n", inf); if (Verbose) - fprintf(stderr, "Reading rasterfile from %s...", inf); + fprintf(stderr, "Reading rasterfile from %s...", inf); pix = pr_load(fp, &Colormap); if (pix == NULL) - error("%s: %s is not a raster file.\n", inf); + error("%s: %s is not a raster file.\n", inf); if (Verbose) - fprintf(stderr, "done.\n"); + fprintf(stderr, "done.\n"); if (Verbose) - fprintf(stderr, "Writing %s...", outf); + fprintf(stderr, "Writing %s...", outf); tif = TIFFOpen(outf, "w"); if (tif == NULL) - error("%s: error opening TIFF file %s", outf); + error("%s: error opening TIFF file %s", outf); width = pix->pr_width; height = pix->pr_height; depth = pix->pr_depth; - switch (depth) - { - case 1: - samplesperpixel = 1; - bitspersample = 1; - photometric = PHOTOMETRIC_MINISBLACK; - break; - case 8: - samplesperpixel = 1; - bitspersample = 8; - photometric = PHOTOMETRIC_PALETTE; - break; - case 24: - samplesperpixel = 3; - bitspersample = 8; - photometric = PHOTOMETRIC_RGB; - break; - case 32: - samplesperpixel = 4; - bitspersample = 8; - photometric = PHOTOMETRIC_RGB; - break; - default: - error("%s: bogus depth: %d\n", depth); + switch (depth) { + case 1: + samplesperpixel = 1; + bitspersample = 1; + photometric = PHOTOMETRIC_MINISBLACK; + break; + case 8: + samplesperpixel = 1; + bitspersample = 8; + photometric = PHOTOMETRIC_PALETTE; + break; + case 24: + samplesperpixel = 3; + bitspersample = 8; + photometric = PHOTOMETRIC_RGB; + break; + case 32: + samplesperpixel = 4; + bitspersample = 8; + photometric = PHOTOMETRIC_RGB; + break; + default: + error("%s: bogus depth: %d\n", depth); } bpsl = ((depth * width + 15) >> 3) & ~1; @@ -212,33 +217,38 @@ char *argv[]; memset(red, 0, sizeof(red)); memset(green, 0, sizeof(green)); memset(blue, 0, sizeof(blue)); - if (depth == 8) - { - TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue); - for (i = 0; i < Colormap.length; i++) - { - red[i] = SCALE(Colormap.map[0][i]); - green[i] = SCALE(Colormap.map[1][i]); - blue[i] = SCALE(Colormap.map[2][i]); - } + if (depth == 8) { + TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue); + for (i = 0; i < Colormap.length; i++) { + red[i] = SCALE(Colormap.map[0][i]); + green[i] = SCALE(Colormap.map[1][i]); + blue[i] = SCALE(Colormap.map[2][i]); + } } if (Verbose) - fprintf(stderr, "%dx%dx%d image, ", width, height, depth); + fprintf(stderr, "%dx%dx%d image, ", width, height, depth); for (row = 0; row < height; row++) - if (TIFFWriteScanline(tif, (u_char *)mprd_addr(mpr_d(pix), 0, row), row, - 0) < 0) - { - fprintf("failed a scanline write (%d)\n", row); - break; - } + if (TIFFWriteScanline(tif, + (u_char *) mprd_addr(mpr_d(pix), 0, row), + row, 0) < 0) { + fprintf("failed a scanline write (%d)\n", row); + break; + } TIFFFlushData(tif); TIFFClose(tif); if (Verbose) - fprintf(stderr, "done.\n"); + fprintf(stderr, "done.\n"); pr_destroy(pix); exit(0); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/ras/tif2ras.c b/thirdparty/SDL2_image/external/libtiff/contrib/ras/tif2ras.c index 9460fde5c..79db104eb 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/ras/tif2ras.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/ras/tif2ras.c @@ -40,295 +40,302 @@ * file since seek(2) is used. */ -#include "tiffio.h" -#include #include +#include +#include "tiffio.h" typedef int boolean; #define True (1) #define False (0) -#define CVT(x) (((x)*255) / ((1L << 16) - 1)) +#define CVT(x) (((x) * 255) / ((1L<<16)-1)) -boolean Verbose = False; -char *pname; /* program name (used for error messages) */ +boolean Verbose = False; +char *pname; /* program name (used for error messages) */ -void error(s1, s2) char *s1, *s2; +void +error(s1, s2) + char *s1, + *s2; { fprintf(stderr, s1, pname, s2); exit(1); } -void usage() { error("usage: %s -[vq] TIFFfile [rasterfile]\n", NULL); } - -main(argc, argv) int argc; -char *argv[]; +void +usage() { - char *inf = NULL; - char *outf = NULL; - FILE *fp; - long width, height; - int depth, numcolors; + error("usage: %s -[vq] TIFFfile [rasterfile]\n", NULL); +} + + +main(argc, argv) + int argc; + char *argv[]; +{ + char *inf = NULL; + char *outf = NULL; + FILE *fp; + long width, + height; + int depth, + numcolors; register TIFF *tif; TIFFDirectory *td; - register u_char *inp, *outp; - register int col, i; + register u_char *inp, + *outp; + register int col, + i; register long row; - u_char *Map = NULL; - u_char *buf; - short bitspersample; - short samplesperpixel; - short photometric; - u_short *redcolormap, *bluecolormap, *greencolormap; + u_char *Map = NULL; + u_char *buf; + short bitspersample; + short samplesperpixel; + short photometric; + u_short *redcolormap, + *bluecolormap, + *greencolormap; - Pixrect *pix; /* The Sun Pixrect */ - colormap_t Colormap; /* The Pixrect Colormap */ - u_char red[256], green[256], blue[256]; + Pixrect *pix; /* The Sun Pixrect */ + colormap_t Colormap; /* The Pixrect Colormap */ + u_char red[256], + green[256], + blue[256]; setbuf(stderr, NULL); pname = argv[0]; - while (--argc) - { - if ((++argv)[0][0] == '-') - switch (argv[0][1]) - { - case 'v': - Verbose = True; - break; - case 'q': - usage(); - break; - default: - fprintf(stderr, "%s: illegal option -%c.\n", pname, - argv[0][1]); - exit(1); - } - else if (inf == NULL) - inf = argv[0]; - else if (outf == NULL) - outf = argv[0]; - else - usage(); + while (--argc) { + if ((++argv)[0][0] == '-') + switch (argv[0][1]) { + case 'v': + Verbose = True; + break; + case 'q': + usage(); + break; + default: + fprintf(stderr, "%s: illegal option -%c.\n", pname, + argv[0][1]); + exit(1); + } + else if (inf == NULL) + inf = argv[0]; + else if (outf == NULL) + outf = argv[0]; + else + usage(); + } if (inf == NULL) - error("%s: can't read input file from a stream.\n", NULL); + error("%s: can't read input file from a stream.\n", NULL); if (Verbose) - fprintf(stderr, "Reading %s...", inf); + fprintf(stderr, "Reading %s...", inf); tif = TIFFOpen(inf, "r"); if (tif == NULL) - error("%s: error opening TIFF file %s", inf); + error("%s: error opening TIFF file %s", inf); if (Verbose) - TIFFPrintDirectory(tif, stderr, True, False, False); + TIFFPrintDirectory(tif, stderr, True, False, False); TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample); if (bitspersample > 8) - error("%s: can't handle more than 8-bits per sample\n", NULL); + error("%s: can't handle more than 8-bits per sample\n", NULL); TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); - switch (samplesperpixel) - { - case 1: - if (bitspersample == 1) - depth = 1; - else - depth = 8; - break; - case 3: - case 4: - depth = 24; - break; - default: - error("%s: only handle 1-channel gray scale or 3-channel color\n"); + switch (samplesperpixel) { + case 1: + if (bitspersample == 1) + depth = 1; + else + depth = 8; + break; + case 3: + case 4: + depth = 24; + break; + default: + error("%s: only handle 1-channel gray scale or 3-channel color\n"); } TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &height); if (Verbose) - fprintf(stderr, "%dx%dx%d image, ", width, height, depth); + fprintf(stderr, "%dx%dx%d image, ", width, height, depth); if (Verbose) - fprintf(stderr, "%d bits/sample, %d samples/pixel, ", bitspersample, - samplesperpixel); + fprintf(stderr, "%d bits/sample, %d samples/pixel, ", + bitspersample, samplesperpixel); pix = mem_create(width, height, depth); - if (pix == (Pixrect *)NULL) - error("%s: can't allocate memory for output pixrect...\n", NULL); + if (pix == (Pixrect *) NULL) + error("%s: can't allocate memory for output pixrect...\n", NULL); numcolors = (1 << bitspersample); TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric); - if (numcolors == 2) - { - if (Verbose) - fprintf(stderr, "monochrome "); - Colormap.type = RMT_NONE; - Colormap.length = 0; - Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL; - } - else - { - switch (photometric) - { - case PHOTOMETRIC_MINISBLACK: - if (Verbose) - fprintf(stderr, "%d graylevels (min=black), ", numcolors); - Map = (u_char *)malloc(numcolors * sizeof(u_char)); - for (i = 0; i < numcolors; i++) - Map[i] = (255 * i) / numcolors; - Colormap.type = RMT_EQUAL_RGB; - Colormap.length = numcolors; - Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map; - break; - case PHOTOMETRIC_MINISWHITE: - if (Verbose) - fprintf(stderr, "%d graylevels (min=white), ", numcolors); - Map = (u_char *)malloc(numcolors * sizeof(u_char)); - for (i = 0; i < numcolors; i++) - Map[i] = 255 - ((255 * i) / numcolors); - Colormap.type = RMT_EQUAL_RGB; - Colormap.length = numcolors; - Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map; - break; - case PHOTOMETRIC_RGB: - if (Verbose) - fprintf(stderr, "truecolor "); - Colormap.type = RMT_NONE; - Colormap.length = 0; - Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL; - break; - case PHOTOMETRIC_PALETTE: - if (Verbose) - fprintf(stderr, "colormapped "); - Colormap.type = RMT_EQUAL_RGB; - Colormap.length = numcolors; - memset(red, 0, sizeof(red)); - memset(green, 0, sizeof(green)); - memset(blue, 0, sizeof(blue)); - TIFFGetField(tif, TIFFTAG_COLORMAP, &redcolormap, - &greencolormap, &bluecolormap); - for (i = 0; i < numcolors; i++) - { - red[i] = (u_char)CVT(redcolormap[i]); - green[i] = (u_char)CVT(greencolormap[i]); - blue[i] = (u_char)CVT(bluecolormap[i]); - } - Colormap.map[0] = red; - Colormap.map[1] = green; - Colormap.map[2] = blue; - break; - case PHOTOMETRIC_MASK: - error("%s: Don't know how to handle PHOTOMETRIC_MASK\n"); - break; - case PHOTOMETRIC_DEPTH: - error("%s: Don't know how to handle PHOTOMETRIC_DEPTH\n"); - break; - default: - error("%s: unknown photometric (cmap): %d\n", photometric); - } + if (numcolors == 2) { + if (Verbose) + fprintf(stderr, "monochrome "); + Colormap.type = RMT_NONE; + Colormap.length = 0; + Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL; + } else { + switch (photometric) { + case PHOTOMETRIC_MINISBLACK: + if (Verbose) + fprintf(stderr, "%d graylevels (min=black), ", numcolors); + Map = (u_char *) malloc(numcolors * sizeof(u_char)); + for (i = 0; i < numcolors; i++) + Map[i] = (255 * i) / numcolors; + Colormap.type = RMT_EQUAL_RGB; + Colormap.length = numcolors; + Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map; + break; + case PHOTOMETRIC_MINISWHITE: + if (Verbose) + fprintf(stderr, "%d graylevels (min=white), ", numcolors); + Map = (u_char *) malloc(numcolors * sizeof(u_char)); + for (i = 0; i < numcolors; i++) + Map[i] = 255 - ((255 * i) / numcolors); + Colormap.type = RMT_EQUAL_RGB; + Colormap.length = numcolors; + Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = Map; + break; + case PHOTOMETRIC_RGB: + if (Verbose) + fprintf(stderr, "truecolor "); + Colormap.type = RMT_NONE; + Colormap.length = 0; + Colormap.map[0] = Colormap.map[1] = Colormap.map[2] = NULL; + break; + case PHOTOMETRIC_PALETTE: + if (Verbose) + fprintf(stderr, "colormapped "); + Colormap.type = RMT_EQUAL_RGB; + Colormap.length = numcolors; + memset(red, 0, sizeof(red)); + memset(green, 0, sizeof(green)); + memset(blue, 0, sizeof(blue)); + TIFFGetField(tif, TIFFTAG_COLORMAP, + &redcolormap, &greencolormap, &bluecolormap); + for (i = 0; i < numcolors; i++) { + red[i] = (u_char) CVT(redcolormap[i]); + green[i] = (u_char) CVT(greencolormap[i]); + blue[i] = (u_char) CVT(bluecolormap[i]); + } + Colormap.map[0] = red; + Colormap.map[1] = green; + Colormap.map[2] = blue; + break; + case PHOTOMETRIC_MASK: + error("%s: Don't know how to handle PHOTOMETRIC_MASK\n"); + break; + case PHOTOMETRIC_DEPTH: + error("%s: Don't know how to handle PHOTOMETRIC_DEPTH\n"); + break; + default: + error("%s: unknown photometric (cmap): %d\n", photometric); + } } - buf = (u_char *)malloc(TIFFScanlineSize(tif)); + buf = (u_char *) malloc(TIFFScanlineSize(tif)); if (buf == NULL) - error("%s: can't allocate memory for scanline buffer...\n", NULL); + error("%s: can't allocate memory for scanline buffer...\n", NULL); - for (row = 0; row < height; row++) - { - if (TIFFReadScanline(tif, buf, row, 0) < 0) - error("%s: bad data read on line: %d\n", row); - inp = buf; - outp = (u_char *)mprd_addr(mpr_d(pix), 0, row); - switch (photometric) - { - case PHOTOMETRIC_RGB: - if (samplesperpixel == 4) - for (col = 0; col < width; col++) - { - *outp++ = *inp++; /* Blue */ - *outp++ = *inp++; /* Green */ - *outp++ = *inp++; /* Red */ - inp++; /* skip alpha channel */ - } - else - for (col = 0; col < width; col++) - { - *outp++ = *inp++; /* Blue */ - *outp++ = *inp++; /* Green */ - *outp++ = *inp++; /* Red */ - } - break; - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - switch (bitspersample) - { - case 1: - for (col = 0; col < ((width + 7) / 8); col++) - *outp++ = *inp++; - break; - case 2: - for (col = 0; col < ((width + 3) / 4); col++) - { - *outp++ = (*inp >> 6) & 3; - *outp++ = (*inp >> 4) & 3; - *outp++ = (*inp >> 2) & 3; - *outp++ = *inp++ & 3; - } - break; - case 4: - for (col = 0; col < width / 2; col++) - { - *outp++ = *inp >> 4; - *outp++ = *inp++ & 0xf; - } - break; - case 8: - for (col = 0; col < width; col++) - *outp++ = *inp++; - break; - default: - error("%s: bad bits/sample: %d\n", bitspersample); - } - break; - case PHOTOMETRIC_PALETTE: - memcpy(outp, inp, width); - break; - default: - error("%s: unknown photometric (write): %d\n", photometric); - } + for (row = 0; row < height; row++) { + if (TIFFReadScanline(tif, buf, row, 0) < 0) + error("%s: bad data read on line: %d\n", row); + inp = buf; + outp = (u_char *) mprd_addr(mpr_d(pix), 0, row); + switch (photometric) { + case PHOTOMETRIC_RGB: + if (samplesperpixel == 4) + for (col = 0; col < width; col++) { + *outp++ = *inp++; /* Blue */ + *outp++ = *inp++; /* Green */ + *outp++ = *inp++; /* Red */ + inp++; /* skip alpha channel */ + } + else + for (col = 0; col < width; col++) { + *outp++ = *inp++; /* Blue */ + *outp++ = *inp++; /* Green */ + *outp++ = *inp++; /* Red */ + } + break; + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + switch (bitspersample) { + case 1: + for (col = 0; col < ((width + 7) / 8); col++) + *outp++ = *inp++; + break; + case 2: + for (col = 0; col < ((width + 3) / 4); col++) { + *outp++ = (*inp >> 6) & 3; + *outp++ = (*inp >> 4) & 3; + *outp++ = (*inp >> 2) & 3; + *outp++ = *inp++ & 3; + } + break; + case 4: + for (col = 0; col < width / 2; col++) { + *outp++ = *inp >> 4; + *outp++ = *inp++ & 0xf; + } + break; + case 8: + for (col = 0; col < width; col++) + *outp++ = *inp++; + break; + default: + error("%s: bad bits/sample: %d\n", bitspersample); + } + break; + case PHOTOMETRIC_PALETTE: + memcpy(outp, inp, width); + break; + default: + error("%s: unknown photometric (write): %d\n", photometric); + } } - free((char *)buf); + free((char *) buf); if (Verbose) - fprintf(stderr, "done.\n"); + fprintf(stderr, "done.\n"); - if (outf == NULL || strcmp(outf, "Standard Output") == 0) - { - outf = "Standard Output"; - fp = stdout; - } - else - { - if (!(fp = fopen(outf, "w"))) - error("%s: %s couldn't be opened for writing.\n", outf); + if (outf == NULL || strcmp(outf, "Standard Output") == 0) { + outf = "Standard Output"; + fp = stdout; + } else { + if (!(fp = fopen(outf, "w"))) + error("%s: %s couldn't be opened for writing.\n", outf); } if (Verbose) - fprintf(stderr, "Writing rasterfile in %s...", outf); + fprintf(stderr, "Writing rasterfile in %s...", outf); if (pr_dump(pix, fp, &Colormap, RT_BYTE_ENCODED, 0) == PIX_ERR) - error("%s: error writing Sun Rasterfile: %s\n", outf); + error("%s: error writing Sun Rasterfile: %s\n", outf); if (Verbose) - fprintf(stderr, "done.\n"); + fprintf(stderr, "done.\n"); pr_destroy(pix); if (fp != stdout) - fclose(fp); + fclose(fp); exit(0); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/stream/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/contrib/stream/CMakeLists.txt new file mode 100644 index 000000000..c874ff64a --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/contrib/stream/CMakeLists.txt @@ -0,0 +1,28 @@ +# CMake build for libtiff +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Written by Roger Leigh +# +# 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. + +extra_dist( + README + tiffstream.cpp + tiffstream.h) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/stream/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/stream/Makefile.am index cd882b321..0324e8656 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/stream/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/stream/Makefile.am @@ -24,6 +24,7 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ + CMakeLists.txt \ README \ tiffstream.cpp \ tiffstream.h diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/stream/tiffstream.cpp b/thirdparty/SDL2_image/external/libtiff/contrib/stream/tiffstream.cpp index 5d7af095e..ffff68758 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/stream/tiffstream.cpp +++ b/thirdparty/SDL2_image/external/libtiff/contrib/stream/tiffstream.cpp @@ -2,213 +2,237 @@ #include "tiffstream.h" -const char *TiffStream::m_name = "TiffStream"; +const char* TiffStream::m_name = "TiffStream"; TiffStream::TiffStream() { m_tif = NULL; + m_inStream = NULL; - m_outStream = NULL; - m_ioStream = NULL; + m_outStream = NULL; + m_ioStream = NULL; - m_streamLength = 0; + m_streamLength = 0; - m_this = reinterpret_cast(this); + m_this = reinterpret_cast(this); }; TiffStream::~TiffStream() { - if (m_tif != NULL) - TIFFClose(m_tif); + if(m_tif != NULL) TIFFClose(m_tif); } -TIFF *TiffStream::makeFileStream(istream *str) +TIFF* +TiffStream::makeFileStream(istream* str) { m_inStream = str; - m_outStream = NULL; - m_ioStream = NULL; + m_outStream = NULL; + m_ioStream = NULL; m_streamLength = getSize(m_this); - m_tif = TIFFClientOpen(m_name, "r", m_this, read, write, seek, close, size, - map, unmap); + m_tif = TIFFClientOpen(m_name, + "r", + m_this, + read, + write, + seek, + close, + size, + map, + unmap); return m_tif; } -TIFF *TiffStream::makeFileStream(ostream *str) +TIFF* +TiffStream::makeFileStream(ostream* str) { - m_inStream = NULL; + m_inStream = NULL; m_outStream = str; - m_ioStream = NULL; - m_streamLength = getSize(m_this); + m_ioStream = NULL; + m_streamLength = getSize(m_this); - m_tif = TIFFClientOpen(m_name, "w", m_this, read, write, seek, close, size, - map, unmap); + m_tif = TIFFClientOpen(m_name, + "w", + m_this, + read, + write, + seek, + close, + size, + map, + unmap); return m_tif; } -TIFF *TiffStream::makeFileStream(iostream *str) +TIFF* +TiffStream::makeFileStream(iostream* str) { - m_inStream = NULL; - m_outStream = NULL; + m_inStream = NULL; + m_outStream = NULL; m_ioStream = str; - m_streamLength = getSize(m_this); + m_streamLength = getSize(m_this); - m_tif = TIFFClientOpen(m_name, "r+w", m_this, read, write, seek, close, - size, map, unmap); + m_tif = TIFFClientOpen(m_name, + "r+w", + m_this, + read, + write, + seek, + close, + size, + map, + unmap); return m_tif; } -tsize_t TiffStream::read(thandle_t fd, tdata_t buf, tsize_t size) +tsize_t +TiffStream::read(thandle_t fd, tdata_t buf, tsize_t size) { - istream *istr; - TiffStream *ts = reinterpret_cast(fd); - if (ts->m_inStream != NULL) - { - istr = ts->m_inStream; - } - else if (ts->m_ioStream != NULL) - { - istr = ts->m_ioStream; - } + istream* istr; + TiffStream* ts = reinterpret_cast(fd); + if(ts->m_inStream != NULL) { + istr = ts->m_inStream; + } else if(ts->m_ioStream != NULL) { + istr = ts->m_ioStream; + } - int remain = ts->m_streamLength - ts->tell(fd); - int actual = remain < size ? remain : size; - istr->read(reinterpret_cast(buf), actual); + int remain = ts->m_streamLength - ts->tell(fd); + int actual = remain < size ? remain : size; + istr->read(reinterpret_cast(buf), actual); return istr->gcount(); } -tsize_t TiffStream::write(thandle_t fd, tdata_t buf, tsize_t size) +tsize_t +TiffStream::write(thandle_t fd, tdata_t buf, tsize_t size) { - TiffStream *ts = reinterpret_cast(fd); - ostream *ostr; - if (ts->m_outStream != NULL) - { - ostr = ts->m_outStream; - } - else if (ts->m_ioStream != NULL) - { - ostr = ts->m_ioStream; - } + TiffStream* ts = reinterpret_cast(fd); + ostream* ostr; + if(ts->m_outStream != NULL) { + ostr = ts->m_outStream; + } else if(ts->m_ioStream != NULL) { + ostr = ts->m_ioStream; + } - streampos start = ostr->tellp(); - ostr->write(reinterpret_cast(buf), size); - return ostr->tellp() - start; + streampos start = ostr->tellp(); + ostr->write(reinterpret_cast(buf), size); + return ostr->tellp() - start; } -toff_t TiffStream::seek(thandle_t fd, toff_t offset, int origin) +toff_t +TiffStream::seek(thandle_t fd, toff_t offset, int origin) { - TiffStream *ts = reinterpret_cast(fd); - if (ts->seekInt(fd, offset, origin) == true) - return offset; - else - return -1; + TiffStream* ts = reinterpret_cast(fd); + if(ts->seekInt(fd, offset, origin) == true) return offset; + else return -1; } -int TiffStream::close(thandle_t fd) +int +TiffStream::close(thandle_t fd) { - TiffStream *ts = reinterpret_cast(fd); - if (ts->m_inStream != NULL) - { - ts->m_inStream = NULL; - return 0; - } - else if (ts->m_outStream != NULL) - { - ts->m_outStream = NULL; - return 0; - } - else if (ts->m_ioStream != NULL) - { - ts->m_ioStream = NULL; - return 0; - } + TiffStream* ts = reinterpret_cast(fd); + if(ts->m_inStream != NULL) { + ts->m_inStream = NULL; + return 0; + } else if(ts->m_outStream != NULL) { + ts->m_outStream = NULL; + return 0; + } else if(ts->m_ioStream != NULL) { + ts->m_ioStream = NULL; + return 0; + } return -1; } -toff_t TiffStream::size(thandle_t fd) +toff_t +TiffStream::size(thandle_t fd) { - TiffStream *ts = reinterpret_cast(fd); + TiffStream* ts = reinterpret_cast(fd); return ts->getSize(fd); } -int TiffStream::map(thandle_t fd, tdata_t *phase, toff_t *psize) { return 0; } - -void TiffStream::unmap(thandle_t fd, tdata_t base, tsize_t size) {} - -unsigned int TiffStream::getSize(thandle_t fd) +int +TiffStream::map(thandle_t fd, tdata_t* phase, toff_t* psize) { - if (!isOpen(fd)) - return 0; - - unsigned int pos = tell(fd); - seekInt(fd, 0, end); - unsigned int size = tell(fd); - seekInt(fd, pos, beg); - - return size; -} - -unsigned int TiffStream::tell(thandle_t fd) -{ - TiffStream *ts = reinterpret_cast(fd); - if (ts->m_inStream != NULL) - { - return ts->m_inStream->tellg(); - } - else if (ts->m_outStream != NULL) - { - return ts->m_outStream->tellp(); - } - else if (ts->m_ioStream != NULL) - { - return ts->m_ioStream->tellg(); - } return 0; } -bool TiffStream::seekInt(thandle_t fd, unsigned int offset, int origin) +void +TiffStream::unmap(thandle_t fd, tdata_t base, tsize_t size) { - if (!isOpen(fd)) - return false; +} - ios::seek_dir org; - switch (origin) - { - case beg: - org = ios::beg; - break; - case cur: - org = ios::cur; - break; - case end: - org = ios::end; - break; - } +unsigned int +TiffStream::getSize(thandle_t fd) +{ + if(!isOpen(fd)) return 0; - TiffStream *ts = reinterpret_cast(fd); - if (ts->m_inStream != NULL) - { - ts->m_inStream->seekg(offset, org); - return true; - } - else if (ts->m_outStream != NULL) - { - ts->m_outStream->seekp(offset, org); - return true; - } - else if (ts->m_ioStream != NULL) - { - ts->m_ioStream->seekg(offset, org); - ts->m_ioStream->seekp(offset, org); - return true; - } + unsigned int pos = tell(fd); + seekInt(fd, 0, end); + unsigned int size = tell(fd); + seekInt(fd, pos, beg); + + return size; +} + +unsigned int +TiffStream::tell(thandle_t fd) +{ + TiffStream* ts = reinterpret_cast(fd); + if(ts->m_inStream != NULL) { + return ts->m_inStream->tellg(); + } else if(ts->m_outStream != NULL) { + return ts->m_outStream->tellp(); + } else if(ts->m_ioStream != NULL) { + return ts->m_ioStream->tellg(); + } + return 0; +} + +bool +TiffStream::seekInt(thandle_t fd, unsigned int offset, int origin) +{ + if(!isOpen(fd)) return false; + + ios::seek_dir org; + switch(origin) { + case beg: + org = ios::beg; + break; + case cur: + org = ios::cur; + break; + case end: + org = ios::end; + break; + } + + TiffStream* ts = reinterpret_cast(fd); + if(ts->m_inStream != NULL) { + ts->m_inStream->seekg(offset, org); + return true; + } else if(ts->m_outStream != NULL) { + ts->m_outStream->seekp(offset, org); + return true; + } else if(ts->m_ioStream != NULL) { + ts->m_ioStream->seekg(offset, org); + ts->m_ioStream->seekp(offset, org); + return true; + } return false; } -bool TiffStream::isOpen(thandle_t fd) +bool +TiffStream::isOpen(thandle_t fd) { - TiffStream *ts = reinterpret_cast(fd); - return (ts->m_inStream != NULL || ts->m_outStream != NULL || - ts->m_ioStream != NULL); -} + TiffStream* ts = reinterpret_cast(fd); + return (ts->m_inStream != NULL || + ts->m_outStream != NULL || + ts->m_ioStream != NULL); +}/* + * Local Variables: + * mode: c++ + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/stream/tiffstream.h b/thirdparty/SDL2_image/external/libtiff/contrib/stream/tiffstream.h index 63a449341..a583ae24b 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/stream/tiffstream.h +++ b/thirdparty/SDL2_image/external/libtiff/contrib/stream/tiffstream.h @@ -7,58 +7,64 @@ #include "tiffio.h" -class TiffStream -{ +class TiffStream { - public: +public: // ctor/dtor TiffStream(); - ~TiffStream(); + ~TiffStream(); - public: - enum SeekDir - { - beg, - cur, - end, +public: + enum SeekDir { + beg, + cur, + end, }; - public: +public: // factory methods - TIFF *makeFileStream(iostream *str); - TIFF *makeFileStream(istream *str); - TIFF *makeFileStream(ostream *str); + TIFF* makeFileStream(iostream* str); + TIFF* makeFileStream(istream* str); + TIFF* makeFileStream(ostream* str); - public: +public: // tiff client methods - static tsize_t read(thandle_t fd, tdata_t buf, tsize_t size); - static tsize_t write(thandle_t fd, tdata_t buf, tsize_t size); - static toff_t seek(thandle_t fd, toff_t offset, int origin); - static toff_t size(thandle_t fd); - static int close(thandle_t fd); - static int map(thandle_t fd, tdata_t *phase, toff_t *psize); - static void unmap(thandle_t fd, tdata_t base, tsize_t size); + static tsize_t read(thandle_t fd, tdata_t buf, tsize_t size); + static tsize_t write(thandle_t fd, tdata_t buf, tsize_t size); + static toff_t seek(thandle_t fd, toff_t offset, int origin); + static toff_t size(thandle_t fd); + static int close(thandle_t fd); + static int map(thandle_t fd, tdata_t* phase, toff_t* psize); + static void unmap(thandle_t fd, tdata_t base, tsize_t size); - public: +public: // query method - TIFF *getTiffHandle() const { return m_tif; } - unsigned int getStreamLength() { return m_streamLength; } + TIFF* getTiffHandle() const { return m_tif; } + unsigned int getStreamLength() { return m_streamLength; } - private: - // internal methods +private: + // internal methods unsigned int getSize(thandle_t fd); - unsigned int tell(thandle_t fd); - bool seekInt(thandle_t fd, unsigned int offset, int origin); - bool isOpen(thandle_t fd); + unsigned int tell(thandle_t fd); + bool seekInt(thandle_t fd, unsigned int offset, int origin); + bool isOpen(thandle_t fd); - private: - thandle_t m_this; - TIFF *m_tif; - static const char *m_name; - istream *m_inStream; - ostream *m_outStream; - iostream *m_ioStream; - int m_streamLength; +private: + thandle_t m_this; + TIFF* m_tif; + static const char* m_name; + istream* m_inStream; + ostream* m_outStream; + iostream* m_ioStream; + int m_streamLength; + }; #endif // _TIFF_STREAM_H_ +/* + * Local Variables: + * mode: c++ + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/ProcessorChecks.cmake b/thirdparty/SDL2_image/external/libtiff/contrib/tags/CMakeLists.txt similarity index 81% rename from thirdparty/SDL2_image/external/libtiff/cmake/ProcessorChecks.cmake rename to thirdparty/SDL2_image/external/libtiff/contrib/tags/CMakeLists.txt index 08e89604e..9945da764 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/ProcessorChecks.cmake +++ b/thirdparty/SDL2_image/external/libtiff/contrib/tags/CMakeLists.txt @@ -1,7 +1,6 @@ -# Processor capability checks +# CMake build for libtiff # # Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh # Written by Roger Leigh # # Permission to use, copy, modify, distribute, and sell this software and @@ -23,14 +22,11 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +extra_dist( + README + listtif.c + maketif.c + xtif_dir.c + xtiffio.h + xtiffiop.h) -include(TestBigEndian) - -# CPU endianness -test_big_endian(HOST_BIG_ENDIAN) -if(HOST_BIG_ENDIAN) - add_definitions(-DWORDS_BIGENDIAN) -endif() - -# IEEE floating point -set(HAVE_IEEEFP 1) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/tags/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/tags/Makefile.am index 0bdec678c..67d996790 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/tags/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/tags/Makefile.am @@ -24,6 +24,7 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ + CMakeLists.txt \ README \ listtif.c \ maketif.c \ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/tags/README b/thirdparty/SDL2_image/external/libtiff/contrib/tags/README index d58a56417..3220b7b1b 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/tags/README +++ b/thirdparty/SDL2_image/external/libtiff/contrib/tags/README @@ -56,7 +56,7 @@ so that multiple clients may be installed. The TIFFExtendProc method that you define should be used to override the TIFF file's "vsetfield" and "vgetfield" methods, so that you can trap your new, private tags, and install their values into -a private directory structure. For your convenience, a new pointer +a private directory structure. For your convienience, a new pointer has also been added to the "TIFF" file structure: tidata_t tif_clientdir; /* client TIFF directory */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/tags/listtif.c b/thirdparty/SDL2_image/external/libtiff/contrib/tags/listtif.c index 71bbd6730..605de8437 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/tags/listtif.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/tags/listtif.c @@ -5,30 +5,35 @@ #include "xtiffio.h" #include -void main(int argc, char *argv[]) +void main(int argc,char *argv[]) { - char *fname = "newtif.tif"; - int flags; + char *fname="newtif.tif"; + int flags; - TIFF *tif = (TIFF *)0; /* TIFF-level descriptor */ - - if (argc > 1) - fname = argv[1]; - - tif = XTIFFOpen(fname, "r"); - if (!tif) - goto failure; - - /* We want the double array listed */ - flags = TIFFPRINT_MYMULTIDOUBLES; - - TIFFPrintDirectory(tif, stdout, flags); - XTIFFClose(tif); - exit(0); + TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */ + if (argc>1) fname=argv[1]; + + tif=XTIFFOpen(fname,"r"); + if (!tif) goto failure; + + /* We want the double array listed */ + flags = TIFFPRINT_MYMULTIDOUBLES; + + TIFFPrintDirectory(tif,stdout,flags); + XTIFFClose(tif); + exit (0); + failure: - printf("failure in listtif\n"); - if (tif) - XTIFFClose(tif); - exit(-1); + printf("failure in listtif\n"); + if (tif) XTIFFClose(tif); + exit (-1); } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/tags/maketif.c b/thirdparty/SDL2_image/external/libtiff/contrib/tags/maketif.c index 1ee85abe3..e965201a6 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/tags/maketif.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/tags/maketif.c @@ -3,8 +3,9 @@ * the XTIFF extended tiff example tags. */ -#include "xtiffio.h" #include +#include "xtiffio.h" + void SetUpTIFFDirectory(TIFF *tif); void WriteImage(TIFF *tif); @@ -14,52 +15,63 @@ void WriteImage(TIFF *tif); void main() { - TIFF *tif = (TIFF *)0; /* TIFF-level descriptor */ - - tif = XTIFFOpen("newtif.tif", "w"); - if (!tif) - goto failure; - - SetUpTIFFDirectory(tif); - WriteImage(tif); - - XTIFFClose(tif); - exit(0); - + TIFF *tif=(TIFF*)0; /* TIFF-level descriptor */ + + tif=XTIFFOpen("newtif.tif","w"); + if (!tif) goto failure; + + SetUpTIFFDirectory(tif); + WriteImage(tif); + + XTIFFClose(tif); + exit (0); + failure: - printf("failure in maketif\n"); - if (tif) - XTIFFClose(tif); - exit(-1); + printf("failure in maketif\n"); + if (tif) XTIFFClose(tif); + exit (-1); } + void SetUpTIFFDirectory(TIFF *tif) { - double mymulti[6] = {0.0, 1.0, 2.0, 3.1415926, 5.0, 1.0}; - uint32_t mysingle = 3456; - char *ascii = "This file was produced by Steven Spielberg. NOT"; + double mymulti[6]={0.0,1.0,2.0, 3.1415926, 5.0,1.0}; + uint32 mysingle=3456; + char *ascii="This file was produced by Steven Spielberg. NOT"; - TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, WIDTH); - TIFFSetField(tif, TIFFTAG_IMAGELENGTH, HEIGHT); - TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); - TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 20); + TIFFSetField(tif,TIFFTAG_IMAGEWIDTH,WIDTH); + TIFFSetField(tif,TIFFTAG_IMAGELENGTH,HEIGHT); + TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE); + TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_MINISBLACK); + TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG); + TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8); + TIFFSetField(tif,TIFFTAG_ROWSPERSTRIP,20); - /* Install the extended TIFF tag examples */ - TIFFSetField(tif, TIFFTAG_EXAMPLE_MULTI, 6, mymulti); - TIFFSetField(tif, TIFFTAG_EXAMPLE_SINGLE, mysingle); - TIFFSetField(tif, TIFFTAG_EXAMPLE_ASCII, ascii); + /* Install the extended TIFF tag examples */ + TIFFSetField(tif,TIFFTAG_EXAMPLE_MULTI,6,mymulti); + TIFFSetField(tif,TIFFTAG_EXAMPLE_SINGLE,mysingle); + TIFFSetField(tif,TIFFTAG_EXAMPLE_ASCII,ascii); } + void WriteImage(TIFF *tif) { - int i; - char buffer[WIDTH]; - - memset(buffer, 0, sizeof(buffer)); - for (i = 0; i < HEIGHT; i++) - if (!TIFFWriteScanline(tif, buffer, i, 0)) - TIFFErrorExtR(tif, "WriteImage", "failure in WriteScanline\n"); + int i; + char buffer[WIDTH]; + + memset(buffer,0,sizeof(buffer)); + for (i=0;itif_clientdata, "WriteImage","failure in WriteScanline\n"); } + + + + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtif_dir.c b/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtif_dir.c index e8398d045..352955267 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtif_dir.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtif_dir.c @@ -10,14 +10,14 @@ * * Author: Niles D. Ritter */ - + #include "xtiffiop.h" #include /* Tiff info structure. * * Entry format: - * { TAGNUMBER, ReadCount, WriteCount, DataType, FIELDNUM, + * { TAGNUMBER, ReadCount, WriteCount, DataType, FIELDNUM, * OkToChange, PassDirCountOnSet, AsciiName } * * For ReadCount, WriteCount, -1 = unknown; used for mult-valued @@ -25,216 +25,219 @@ */ static const TIFFFieldInfo xtiffFieldInfo[] = { - - /* XXX Replace these example tags with your own extended tags */ - {TIFFTAG_EXAMPLE_MULTI, -1, -1, TIFF_DOUBLE, FIELD_EXAMPLE_MULTI, TRUE, - TRUE, "MyMultivaluedTag"}, - {TIFFTAG_EXAMPLE_SINGLE, 1, 1, TIFF_LONG, FIELD_EXAMPLE_SINGLE, TRUE, FALSE, - "MySingleLongTag"}, - {TIFFTAG_EXAMPLE_ASCII, -1, -1, TIFF_ASCII, FIELD_EXAMPLE_ASCII, TRUE, - FALSE, "MyAsciiTag"}, + + /* XXX Replace these example tags with your own extended tags */ + { TIFFTAG_EXAMPLE_MULTI, -1,-1, TIFF_DOUBLE, FIELD_EXAMPLE_MULTI, + TRUE, TRUE, "MyMultivaluedTag" }, + { TIFFTAG_EXAMPLE_SINGLE, 1, 1, TIFF_LONG, FIELD_EXAMPLE_SINGLE, + TRUE, FALSE, "MySingleLongTag" }, + { TIFFTAG_EXAMPLE_ASCII, -1,-1, TIFF_ASCII, FIELD_EXAMPLE_ASCII, + TRUE, FALSE, "MyAsciiTag" }, }; -#define N(a) (sizeof(a) / sizeof(a[0])) +#define N(a) (sizeof (a) / sizeof (a[0])) -static void _XTIFFPrintDirectory(TIFF *tif, FILE *fd, long flags) + +static void +_XTIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) { - xtiff *xt = XTIFFDIR(tif); - XTIFFDirectory *xd = &xt->xtif_dir; - int i, num; + xtiff *xt = XTIFFDIR(tif); + XTIFFDirectory *xd = &xt->xtif_dir; + int i,num; - /* call the inherited method */ - if (PARENT(xt, printdir)) - (PARENT(xt, printdir))(tif, fd, flags); + /* call the inherited method */ + if (PARENT(xt,printdir)) + (PARENT(xt,printdir))(tif,fd,flags); - /* XXX Add field printing here. Replace the three example - * tags implemented below with your own. - */ - - fprintf(fd, "--My Example Tags--\n"); - - /* Our first example tag may have a lot of values, so we - * will only print them out if the TIFFPRINT_MYMULTIDOUBLES - * flag is passed into the print method. - */ - if (TIFFFieldSet(tif, FIELD_EXAMPLE_MULTI)) - { - fprintf(fd, " My Multi-Valued Doubles:"); - if (flags & TIFFPRINT_MYMULTIDOUBLES) - { - double *value = xd->xd_example_multi; - - num = xd->xd_num_multi; - fprintf(fd, "("); - for (i = 0; i < num; i++) - fprintf(fd, " %lg", *value++); - fprintf(fd, ")\n"); - } - else - fprintf(fd, "(present)\n"); - } - - if (TIFFFieldSet(tif, FIELD_EXAMPLE_SINGLE)) - { - fprintf(fd, " My Single Long Tag: %lu\n", xd->xd_example_single); - } - - if (TIFFFieldSet(tif, FIELD_EXAMPLE_ASCII)) - { - _TIFFprintAsciiTag(fd, "My ASCII Tag", xd->xd_example_ascii); - } -} - -static int _XTIFFVSetField(TIFF *tif, ttag_t tag, va_list ap) -{ - xtiff *xt = XTIFFDIR(tif); - XTIFFDirectory *xd = &xt->xtif_dir; - int status = 1; - uint32_t v32 = 0; - int i = 0, v = 0; - va_list ap1 = ap; - - /* va_start is called by the calling routine */ - - switch (tag) - { - /* - * XXX put your extended tags here; replace the implemented - * example tags with your own. - */ - case TIFFTAG_EXAMPLE_MULTI: - /* multi-valued tags need to store the count as well */ - xd->xd_num_multi = (uint16_t)va_arg(ap, int); - _TIFFsetDoubleArray(&xd->xd_example_multi, va_arg(ap, double *), - (long)xd->xd_num_multi); - break; - case TIFFTAG_EXAMPLE_SINGLE: - xd->xd_example_single = va_arg(ap, uint32_t); - break; - case TIFFTAG_EXAMPLE_ASCII: - _TIFFsetString(&xd->xd_example_ascii, va_arg(ap, char *)); - break; - default: - /* call the inherited method */ - return (PARENT(xt, vsetfield))(tif, tag, ap); - break; - } - if (status) - { - /* we have to override the print method here, - * after the compression tags have gotten to it. - * This makes sense because the only time we would - * need the extended print method is if an extended - * tag is set by the reader. + /* XXX Add field printing here. Replace the three example + * tags implemented below with your own. */ - if (!(xt->xtif_flags & XTIFFP_PRINT)) - { - PARENT(xt, printdir) = TIFFMEMBER(tif, printdir); - TIFFMEMBER(tif, printdir) = _XTIFFPrintDirectory; - xt->xtif_flags |= XTIFFP_PRINT; - } - TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); - tif->tif_flags |= TIFF_DIRTYDIRECT; - } - va_end(ap); - return (status); -badvalue: - TIFFErrorExtR(tif, tif->tif_name, "%d: Bad value for \"%s\"", v, - _TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); - return (0); -badvalue32: - TIFFErrorExtR(tif, tif->tif_name, "%ld: Bad value for \"%s\"", v32, - _TIFFFieldWithTag(tif, tag)->field_name); - va_end(ap); - return (0); + + fprintf(fd,"--My Example Tags--\n"); + + /* Our first example tag may have a lot of values, so we + * will only print them out if the TIFFPRINT_MYMULTIDOUBLES + * flag is passed into the print method. + */ + if (TIFFFieldSet(tif,FIELD_EXAMPLE_MULTI)) + { + fprintf(fd, " My Multi-Valued Doubles:"); + if (flags & TIFFPRINT_MYMULTIDOUBLES) + { + double *value = xd->xd_example_multi; + + num = xd->xd_num_multi; + fprintf(fd,"("); + for (i=0;ixd_example_single); + } + + if (TIFFFieldSet(tif,FIELD_EXAMPLE_ASCII)) + { + _TIFFprintAsciiTag(fd,"My ASCII Tag", + xd->xd_example_ascii); + } } -static int _XTIFFVGetField(TIFF *tif, ttag_t tag, va_list ap) +static int +_XTIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) { - xtiff *xt = XTIFFDIR(tif); - XTIFFDirectory *xd = &xt->xtif_dir; + xtiff *xt = XTIFFDIR(tif); + XTIFFDirectory* xd = &xt->xtif_dir; + int status = 1; + uint32 v32=0; + int i=0, v=0; + va_list ap1 = ap; - switch (tag) - { - /* - * XXX put your extended tags here; replace the implemented - * example tags with your own. - */ - case TIFFTAG_EXAMPLE_MULTI: - *va_arg(ap, uint16_t *) = xd->xd_num_multi; - *va_arg(ap, double **) = xd->xd_example_multi; - break; - case TIFFTAG_EXAMPLE_ASCII: - *va_arg(ap, char **) = xd->xd_example_ascii; - break; - case TIFFTAG_EXAMPLE_SINGLE: - *va_arg(ap, uint32_t *) = xd->xd_example_single; - break; - default: - /* return inherited method */ - return (PARENT(xt, vgetfield))(tif, tag, ap); - break; - } - return (1); + /* va_start is called by the calling routine */ + + switch (tag) { + /* + * XXX put your extended tags here; replace the implemented + * example tags with your own. + */ + case TIFFTAG_EXAMPLE_MULTI: + /* multi-valued tags need to store the count as well */ + xd->xd_num_multi = (uint16) va_arg(ap, int); + _TIFFsetDoubleArray(&xd->xd_example_multi, va_arg(ap, double*), + (long) xd->xd_num_multi); + break; + case TIFFTAG_EXAMPLE_SINGLE: + xd->xd_example_single = va_arg(ap, uint32); + break; + case TIFFTAG_EXAMPLE_ASCII: + _TIFFsetString(&xd->xd_example_ascii, va_arg(ap, char*)); + break; + default: + /* call the inherited method */ + return (PARENT(xt,vsetfield))(tif,tag,ap); + break; + } + if (status) { + /* we have to override the print method here, + * after the compression tags have gotten to it. + * This makes sense because the only time we would + * need the extended print method is if an extended + * tag is set by the reader. + */ + if (!(xt->xtif_flags & XTIFFP_PRINT)) + { + PARENT(xt,printdir) = TIFFMEMBER(tif,printdir); + TIFFMEMBER(tif,printdir) = _XTIFFPrintDirectory; + xt->xtif_flags |= XTIFFP_PRINT; + } + TIFFSetFieldBit(tif, _TIFFFieldWithTag(tif, tag)->field_bit); + tif->tif_flags |= TIFF_DIRTYDIRECT; + } + va_end(ap); + return (status); +badvalue: + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%d: Bad value for \"%s\"", v, + _TIFFFieldWithTag(tif, tag)->field_name); + va_end(ap); + return (0); +badvalue32: + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%ld: Bad value for \"%s\"", v32, + _TIFFFieldWithTag(tif, tag)->field_name); + va_end(ap); + return (0); } -#define CleanupField(member) \ - { \ - if (xd->member) \ - { \ - _TIFFfree(xd->member); \ - xd->member = 0; \ - } \ - } + +static int +_XTIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) +{ + xtiff *xt = XTIFFDIR(tif); + XTIFFDirectory* xd = &xt->xtif_dir; + + switch (tag) { + /* + * XXX put your extended tags here; replace the implemented + * example tags with your own. + */ + case TIFFTAG_EXAMPLE_MULTI: + *va_arg(ap, uint16*) = xd->xd_num_multi; + *va_arg(ap, double**) = xd->xd_example_multi; + break; + case TIFFTAG_EXAMPLE_ASCII: + *va_arg(ap, char**) = xd->xd_example_ascii; + break; + case TIFFTAG_EXAMPLE_SINGLE: + *va_arg(ap, uint32*) = xd->xd_example_single; + break; + default: + /* return inherited method */ + return (PARENT(xt,vgetfield))(tif,tag,ap); + break; + } + return (1); +} + +#define CleanupField(member) { \ + if (xd->member) { \ + _TIFFfree(xd->member); \ + xd->member = 0; \ + } \ +} /* * Release storage associated with a directory. */ -static void _XTIFFFreeDirectory(xtiff *xt) +static void +_XTIFFFreeDirectory(xtiff* xt) { - XTIFFDirectory *xd = &xt->xtif_dir; + XTIFFDirectory* xd = &xt->xtif_dir; - /* - * XXX - Purge all Your allocated memory except - * for the xtiff directory itself. This includes - * all fields that require a _TIFFsetXXX call in - * _XTIFFVSetField(). - */ - - CleanupField(xd_example_multi); - CleanupField(xd_example_ascii); + /* + * XXX - Purge all Your allocated memory except + * for the xtiff directory itself. This includes + * all fields that require a _TIFFsetXXX call in + * _XTIFFVSetField(). + */ + + CleanupField(xd_example_multi); + CleanupField(xd_example_ascii); + } #undef CleanupField static void _XTIFFLocalDefaultDirectory(TIFF *tif) { - xtiff *xt = XTIFFDIR(tif); - XTIFFDirectory *xd = &xt->xtif_dir; + xtiff *xt = XTIFFDIR(tif); + XTIFFDirectory* xd = &xt->xtif_dir; - /* Install the extended Tag field info */ - _TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo)); + /* Install the extended Tag field info */ + _TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo)); - /* - * free up any dynamically allocated arrays - * before the new directory is read in. - */ + /* + * free up any dynamically allocated arrays + * before the new directory is read in. + */ + + _XTIFFFreeDirectory(xt); + _TIFFmemset(xt,0,sizeof(xtiff)); - _XTIFFFreeDirectory(xt); - _TIFFmemset(xt, 0, sizeof(xtiff)); + /* Override the tag access methods */ - /* Override the tag access methods */ + PARENT(xt,vsetfield) = TIFFMEMBER(tif,vsetfield); + TIFFMEMBER(tif,vsetfield) = _XTIFFVSetField; + PARENT(xt,vgetfield) = TIFFMEMBER(tif,vgetfield); + TIFFMEMBER(tif,vgetfield) = _XTIFFVGetField; - PARENT(xt, vsetfield) = TIFFMEMBER(tif, vsetfield); - TIFFMEMBER(tif, vsetfield) = _XTIFFVSetField; - PARENT(xt, vgetfield) = TIFFMEMBER(tif, vgetfield); - TIFFMEMBER(tif, vgetfield) = _XTIFFVGetField; - - /* - * XXX Set up any default values here. - */ - - xd->xd_example_single = 234; + /* + * XXX Set up any default values here. + */ + + xd->xd_example_single = 234; } + + /********************************************************************** * Nothing below this line should need to be changed. **********************************************************************/ @@ -247,37 +250,39 @@ static TIFFExtendProc _ParentExtender; * every time a new TIFF directory is opened. */ -static void _XTIFFDefaultDirectory(TIFF *tif) +static void +_XTIFFDefaultDirectory(TIFF *tif) { - xtiff *xt; + xtiff *xt; + + /* Allocate Directory Structure if first time, and install it */ + if (!(tif->tif_flags & XTIFF_INITIALIZED)) + { + xt = _TIFFmalloc(sizeof(xtiff)); + if (!xt) + { + /* handle memory allocation failure here ! */ + return; + } + _TIFFmemset(xt,0,sizeof(xtiff)); + /* + * Install into TIFF structure. + */ + TIFFMEMBER(tif,clientdir) = (tidata_t)xt; + tif->tif_flags |= XTIFF_INITIALIZED; /* don't do this again! */ + } + + /* set up our own defaults */ + _XTIFFLocalDefaultDirectory(tif); - /* Allocate Directory Structure if first time, and install it */ - if (!(tif->tif_flags & XTIFF_INITIALIZED)) - { - xt = _TIFFmalloc(sizeof(xtiff)); - if (!xt) - { - /* handle memory allocation failure here ! */ - return; - } - _TIFFmemset(xt, 0, sizeof(xtiff)); - /* - * Install into TIFF structure. + /* Since an XTIFF client module may have overridden + * the default directory method, we call it now to + * allow it to set up the rest of its own methods. */ - TIFFMEMBER(tif, clientdir) = (tidata_t)xt; - tif->tif_flags |= XTIFF_INITIALIZED; /* don't do this again! */ - } - /* set up our own defaults */ - _XTIFFLocalDefaultDirectory(tif); + if (_ParentExtender) + (*_ParentExtender)(tif); - /* Since an XTIFF client module may have overridden - * the default directory method, we call it now to - * allow it to set up the rest of its own methods. - */ - - if (_ParentExtender) - (*_ParentExtender)(tif); } /* @@ -285,49 +290,61 @@ static void _XTIFFDefaultDirectory(TIFF *tif) * procedure for the TIFF module. */ -static void _XTIFFInitialize(void) +static +void _XTIFFInitialize(void) { - static first_time = 1; - - if (!first_time) - return; /* Been there. Done that. */ - first_time = 0; - - /* Grab the inherited method and install */ - _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory); + static first_time=1; + + if (! first_time) return; /* Been there. Done that. */ + first_time = 0; + + /* Grab the inherited method and install */ + _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory); } + /* * Public File I/O Routines. */ -TIFF *XTIFFOpen(const char *name, const char *mode) +TIFF* +XTIFFOpen(const char* name, const char* mode) { - /* Set up the callback */ - _XTIFFInitialize(); - - /* Open the file; the callback will set everything up - */ - return TIFFOpen(name, mode); + /* Set up the callback */ + _XTIFFInitialize(); + + /* Open the file; the callback will set everything up + */ + return TIFFOpen(name, mode); } -TIFF *XTIFFFdOpen(int fd, const char *name, const char *mode) +TIFF* +XTIFFFdOpen(int fd, const char* name, const char* mode) { - /* Set up the callback */ - _XTIFFInitialize(); + /* Set up the callback */ + _XTIFFInitialize(); - /* Open the file; the callback will set everything up - */ - return TIFFFdOpen(fd, name, mode); + /* Open the file; the callback will set everything up + */ + return TIFFFdOpen(fd, name, mode); } -void XTIFFClose(TIFF *tif) + +void +XTIFFClose(TIFF *tif) { - xtiff *xt = XTIFFDIR(tif); - - /* call inherited function first */ - TIFFClose(tif); - - /* Free up extended allocated memory */ - _XTIFFFreeDirectory(xt); - _TIFFfree(xt); + xtiff *xt = XTIFFDIR(tif); + + /* call inherited function first */ + TIFFClose(tif); + + /* Free up extended allocated memory */ + _XTIFFFreeDirectory(xt); + _TIFFfree(xt); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtiffio.h b/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtiffio.h index 421b98b12..e8600df07 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtiffio.h +++ b/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtiffio.h @@ -14,39 +14,46 @@ #include "tiffio.h" -/* - * XXX Define your private Tag names and values here +/* + * XXX Define your private Tag names and values here */ /* These tags are not valid, but are provided for example */ -#define TIFFTAG_EXAMPLE_MULTI 61234 -#define TIFFTAG_EXAMPLE_SINGLE 61235 -#define TIFFTAG_EXAMPLE_ASCII 61236 +#define TIFFTAG_EXAMPLE_MULTI 61234 +#define TIFFTAG_EXAMPLE_SINGLE 61235 +#define TIFFTAG_EXAMPLE_ASCII 61236 -/* +/* * XXX Define Printing method flags. These * flags may be passed in to TIFFPrintDirectory() to * indicate that those particular field values should * be printed out in full, rather than just an indicator * of whether they are present or not. */ -#define TIFFPRINT_MYMULTIDOUBLES 0x80000000 +#define TIFFPRINT_MYMULTIDOUBLES 0x80000000 /********************************************************************** * Nothing below this line should need to be changed by the user. **********************************************************************/ #if defined(__cplusplus) -extern "C" -{ +extern "C" { #endif - extern TIFF *XTIFFOpen(const char *name, const char *mode); - extern TIFF *XTIFFFdOpen(int fd, const char *name, const char *mode); - extern void XTIFFClose(TIFF *tif); +extern TIFF* XTIFFOpen(const char* name, const char* mode); +extern TIFF* XTIFFFdOpen(int fd, const char* name, const char* mode); +extern void XTIFFClose(TIFF *tif); #if defined(__cplusplus) } #endif #endif /* __xtiffio_h */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtiffiop.h b/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtiffiop.h index 1dd5824a7..9d534a834 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtiffiop.h +++ b/thirdparty/SDL2_image/external/libtiff/contrib/tags/xtiffiop.h @@ -22,20 +22,20 @@ /* XXX - Define number of your extended tags here */ #define NUM_XFIELD 3 -#define XFIELD_BASE (FIELD_LAST - NUM_XFIELD) +#define XFIELD_BASE (FIELD_LAST-NUM_XFIELD) /* XXX - Define your Tag Fields here */ -#define FIELD_EXAMPLE_MULTI (XFIELD_BASE + 0) -#define FIELD_EXAMPLE_SINGLE (XFIELD_BASE + 1) -#define FIELD_EXAMPLE_ASCII (XFIELD_BASE + 2) +#define FIELD_EXAMPLE_MULTI (XFIELD_BASE+0) +#define FIELD_EXAMPLE_SINGLE (XFIELD_BASE+1) +#define FIELD_EXAMPLE_ASCII (XFIELD_BASE+2) + /* XXX - Define Private directory tag structure here */ -struct XTIFFDirectory -{ - uint16_t xd_num_multi; /* dir-count for the multi tag */ - double *xd_example_multi; - uint32_t xd_example_single; - char *xd_example_ascii; +struct XTIFFDirectory { + uint16 xd_num_multi; /* dir-count for the multi tag */ + double* xd_example_multi; + uint32 xd_example_single; + char* xd_example_ascii; }; typedef struct XTIFFDirectory XTIFFDirectory; @@ -43,23 +43,30 @@ typedef struct XTIFFDirectory XTIFFDirectory; * Nothing below this line should need to be changed by the user. **********************************************************************/ -struct xtiff -{ - TIFF *xtif_tif; /* parent TIFF pointer */ - uint32_t xtif_flags; -#define XTIFFP_PRINT 0x00000001 - XTIFFDirectory xtif_dir; /* internal rep of current directory */ - TIFFVSetMethod xtif_vsetfield; /* inherited tag set routine */ - TIFFVGetMethod xtif_vgetfield; /* inherited tag get routine */ - TIFFPrintMethod xtif_printdir; /* inherited dir print method */ +struct xtiff { + TIFF *xtif_tif; /* parent TIFF pointer */ + uint32 xtif_flags; +#define XTIFFP_PRINT 0x00000001 + XTIFFDirectory xtif_dir; /* internal rep of current directory */ + TIFFVSetMethod xtif_vsetfield; /* inherited tag set routine */ + TIFFVGetMethod xtif_vgetfield; /* inherited tag get routine */ + TIFFPrintMethod xtif_printdir; /* inherited dir print method */ }; typedef struct xtiff xtiff; -#define PARENT(xt, pmember) ((xt)->xtif_##pmember) -#define TIFFMEMBER(tf, pmember) ((tf)->tif_##pmember) -#define XTIFFDIR(tif) ((xtiff *)TIFFMEMBER(tif, clientdir)) +#define PARENT(xt,pmember) ((xt)->xtif_ ## pmember) +#define TIFFMEMBER(tf,pmember) ((tf)->tif_ ## pmember) +#define XTIFFDIR(tif) ((xtiff *)TIFFMEMBER(tif,clientdir)) + /* Extended TIFF flags */ #define XTIFF_INITIALIZED 0x80000000 - + #endif /* __xtiffiop_h */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/CMakeLists.txt new file mode 100644 index 000000000..11d124f5d --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/CMakeLists.txt @@ -0,0 +1,30 @@ +# CMake build for libtiff +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Written by Roger Leigh +# +# 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. + +extra_dist( + Makefile.w95 + README.Tiffile + README.tiff2dib + Tiffile.cpp + tiff2dib.c) diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/Makefile.am b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/Makefile.am index 53ededb18..50a1dab06 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/Makefile.am @@ -24,6 +24,7 @@ # Process this file with automake to produce Makefile.in. EXTRA_DIST = \ + CMakeLists.txt \ Makefile.w95 \ README.Tiffile \ README.tiff2dib \ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/README.Tiffile b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/README.Tiffile index 8645f05c2..82c6e5c44 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/README.Tiffile +++ b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/README.Tiffile @@ -2,7 +2,7 @@ Frank, I attached a file that uses RGBA interface (tif_getimage.c) to read a tiff file and convert to a DIB. It's advantage is that it is easy to read *any* -tiff file supported by libtiff and easily convert it to a DIB. The disadvantage +tiff file suported by libtiff and easily convert it to a DIB. The disadvantage is that bilevel (B&W) bitmaps (and all other non-rgba images) are also converted to RGBA, thus taking up 32x as much memory as needed (4 bytes per pixel, rather than 1 bit). I read tiff files, but don't need to diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/README.tiff2dib b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/README.tiff2dib index 75e1254bb..ff70ca1a2 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/README.tiff2dib +++ b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/README.tiff2dib @@ -14,7 +14,7 @@ Here is some information that may help someone. I build the library under Windows 95 as a 32-bit library. The contribution of Scott Wagner (tif_win32.c) worked fine, but -the makefile "makefile.msc" was unusable because it was +the makefile "makefile.msc" was unsable because it was written for DOS or Windows 3.1 and all the files names are limited to 8 characters. @@ -38,7 +38,7 @@ I had to : I also join the source file "tif2dib.c" that I created, it contain the function LoadTIFFinDIB that load a TIFF file and build a memory DIB with it and return the -HANDLE (HDIB) of the memory block containing this DIB. +HANDLE (HDIB) of the memory bloc containing this DIB. Since DIB is the "natural" bitmap format for Windows 3.1, 95 and NT, this function should be useful for some Windows 95 (or NT) developer. diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/Tiffile.cpp b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/Tiffile.cpp index 0ae8d50f4..2f7965d63 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/Tiffile.cpp +++ b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/Tiffile.cpp @@ -1,11 +1,11 @@ #include "StdAfx.h" -// #define STRICT -#include "diblib.h" -#include -#include // MAX_ constants +//#define STRICT #include #include +#include +#include // MAX_ constants +#include "diblib.h" /*-------------------------------------------------------------------- READ TIFF @@ -31,42 +31,44 @@ #include #include + // piggyback some data on top of the RGBA Image -struct TIFFDibImage -{ +struct TIFFDibImage { TIFFRGBAImage tif; - int dibinstalled; -}; + int dibinstalled; +} ; + HANDLE LoadTIFFinDIB(LPCTSTR lpFileName); -HANDLE TIFFRGBA2DIB(TIFFDibImage *dib, uint32_t *raster); +HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32* raster) ; -static void MyWarningHandler(const char *module, const char *fmt, va_list ap) +static void +MyWarningHandler(const char* module, const char* fmt, va_list ap) { // ignore all warnings (unused tags, etc) return; } -static void MyErrorHandler(const char *module, const char *fmt, va_list ap) +static void +MyErrorHandler(const char* module, const char* fmt, va_list ap) { return; } // Turn off the error and warning handlers to check if a valid file. // Necessary because of the way that the Doc loads images and restart files. -int ChkTIFF(LPCTSTR lpszPath) +int ChkTIFF ( LPCTSTR lpszPath ) { int rtn = 0; - TIFFErrorHandler eh; - TIFFErrorHandler wh; + TIFFErrorHandler eh; + TIFFErrorHandler wh; eh = TIFFSetErrorHandler(NULL); wh = TIFFSetWarningHandler(NULL); - TIFF *tif = TIFFOpen(lpszPath, "r"); - if (tif) - { + TIFF* tif = TIFFOpen(lpszPath, "r"); + if (tif) { rtn = 1; TIFFClose(tif); } @@ -77,42 +79,34 @@ int ChkTIFF(LPCTSTR lpszPath) return rtn; } -void DibInstallHack(TIFFDibImage *img); +void DibInstallHack(TIFFDibImage* img) ; -PVOID ReadTIFF(LPCTSTR lpszPath) +PVOID ReadTIFF ( LPCTSTR lpszPath ) { - void *pDIB = 0; - TIFFErrorHandler wh; + void* pDIB = 0; + TIFFErrorHandler wh; wh = TIFFSetWarningHandler(MyWarningHandler); - if (ChkTIFF(lpszPath)) - { - TIFF *tif = TIFFOpen(lpszPath, "r"); - if (tif) - { + if (ChkTIFF(lpszPath)) { + TIFF* tif = TIFFOpen(lpszPath, "r"); + if (tif) { char emsg[1024]; - if (TIFFRGBAImageOK(tif, emsg)) - { + if (TIFFRGBAImageOK(tif, emsg)) { TIFFDibImage img; char emsg[1024]; - if (TIFFRGBAImageBegin(&img.tif, tif, -1, emsg)) - { + if (TIFFRGBAImageBegin(&img.tif, tif, -1, emsg)) { size_t npixels; - uint32_t *raster; + uint32* raster; DibInstallHack(&img); npixels = img.tif.width * img.tif.height; - raster = - (uint32_t *)_TIFFmalloc(npixels * sizeof(uint32_t)); - if (raster != NULL) - { - if (TIFFRGBAImageGet(&img.tif, raster, img.tif.width, - img.tif.height)) - { + raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); + if (raster != NULL) { + if (TIFFRGBAImageGet(&img.tif, raster, img.tif.width, img.tif.height)) { pDIB = TIFFRGBA2DIB(&img, raster); } } @@ -120,9 +114,8 @@ PVOID ReadTIFF(LPCTSTR lpszPath) } TIFFRGBAImageEnd(&img.tif); } - else - { - TRACE("Unable to open image(%s): %s\n", lpszPath, emsg); + else { + TRACE("Unable to open image(%s): %s\n", lpszPath, emsg ); } TIFFClose(tif); } @@ -133,20 +126,22 @@ PVOID ReadTIFF(LPCTSTR lpszPath) return pDIB; } -HANDLE TIFFRGBA2DIB(TIFFDibImage *dib, uint32_t *raster) + + +HANDLE TIFFRGBA2DIB(TIFFDibImage* dib, uint32* raster) { - void *pDIB = 0; - TIFFRGBAImage *img = &dib->tif; + void* pDIB = 0; + TIFFRGBAImage* img = &dib->tif; - uint32_t imageLength; - uint32_t imageWidth; - uint16_t BitsPerSample; - uint16_t SamplePerPixel; - uint32_t RowsPerStrip; - uint16_t PhotometricInterpretation; + uint32 imageLength; + uint32 imageWidth; + uint16 BitsPerSample; + uint16 SamplePerPixel; + uint32 RowsPerStrip; + uint16 PhotometricInterpretation; - BITMAPINFOHEADER bi; - int dwDIBSize; + BITMAPINFOHEADER bi; + int dwDIBSize ; TIFFGetField(img->tif, TIFFTAG_IMAGEWIDTH, &imageWidth); TIFFGetField(img->tif, TIFFTAG_IMAGELENGTH, &imageLength); @@ -155,97 +150,91 @@ HANDLE TIFFRGBA2DIB(TIFFDibImage *dib, uint32_t *raster) TIFFGetField(img->tif, TIFFTAG_SAMPLESPERPIXEL, &SamplePerPixel); TIFFGetField(img->tif, TIFFTAG_PHOTOMETRIC, &PhotometricInterpretation); - if (BitsPerSample == 1 && SamplePerPixel == 1 && dib->dibinstalled) - { // bilevel - bi.biSize = sizeof(BITMAPINFOHEADER); - bi.biWidth = imageWidth; - bi.biHeight = imageLength; - bi.biPlanes = 1; // always - bi.biBitCount = 1; - bi.biCompression = BI_RGB; - bi.biSizeImage = WIDTHBYTES(bi.biWidth * bi.biBitCount) * bi.biHeight; - bi.biXPelsPerMeter = 0; - bi.biYPelsPerMeter = 0; - bi.biClrUsed = 0; // must be zero for RGB compression (none) - bi.biClrImportant = 0; // always + if ( BitsPerSample == 1 && SamplePerPixel == 1 && dib->dibinstalled ) { // bilevel + bi.biSize = sizeof(BITMAPINFOHEADER); + bi.biWidth = imageWidth; + bi.biHeight = imageLength; + bi.biPlanes = 1; // always + bi.biBitCount = 1; + bi.biCompression = BI_RGB; + bi.biSizeImage = WIDTHBYTES(bi.biWidth * bi.biBitCount) * bi.biHeight; + bi.biXPelsPerMeter = 0; + bi.biYPelsPerMeter = 0; + bi.biClrUsed = 0; // must be zero for RGB compression (none) + bi.biClrImportant = 0; // always // Get the size of the DIB - dwDIBSize = GetDIBSize(&bi); + dwDIBSize = GetDIBSize( &bi ); // Allocate for the BITMAPINFO structure and the color table. - pDIB = GlobalAllocPtr(GHND, dwDIBSize); - if (pDIB == 0) - { - return (NULL); + pDIB = GlobalAllocPtr( GHND, dwDIBSize ); + if (pDIB == 0) { + return( NULL ); } // Copy the header info - *((BITMAPINFOHEADER *)pDIB) = bi; + *((BITMAPINFOHEADER*)pDIB) = bi; // Get a pointer to the color table - RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPINFOHEADER)); + RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPINFOHEADER)); - pRgbq[0].rgbRed = 0; - pRgbq[0].rgbBlue = 0; - pRgbq[0].rgbGreen = 0; + pRgbq[0].rgbRed = 0; + pRgbq[0].rgbBlue = 0; + pRgbq[0].rgbGreen = 0; pRgbq[0].rgbReserved = 0; - pRgbq[1].rgbRed = 255; - pRgbq[1].rgbBlue = 255; - pRgbq[1].rgbGreen = 255; + pRgbq[1].rgbRed = 255; + pRgbq[1].rgbBlue = 255; + pRgbq[1].rgbGreen = 255; pRgbq[1].rgbReserved = 255; // Pointers to the bits - // PVOID pbiBits = (LPSTR)pRgbq + bi.biClrUsed * sizeof(RGBQUAD); + //PVOID pbiBits = (LPSTR)pRgbq + bi.biClrUsed * sizeof(RGBQUAD); // // In the BITMAPINFOHEADER documentation, it appears that // there should be no color table for 32 bit images, but // experience shows that the image is off by 3 words if it // is not included. So here it is. - PVOID pbiBits = GetDIBImagePtr( - (BITMAPINFOHEADER *)pDIB); //(LPSTR)pRgbq + 3 * sizeof(RGBQUAD); + PVOID pbiBits = GetDIBImagePtr((BITMAPINFOHEADER*)pDIB); //(LPSTR)pRgbq + 3 * sizeof(RGBQUAD); - int sizeWords = bi.biSizeImage / 4; - RGBQUAD *rgbDib = (RGBQUAD *)pbiBits; - long *rgbTif = (long *)raster; + int sizeWords = bi.biSizeImage/4; + RGBQUAD* rgbDib = (RGBQUAD*)pbiBits; + long* rgbTif = (long*)raster; _TIFFmemcpy(pbiBits, raster, bi.biSizeImage); } - // For now just always default to the RGB 32 bit form. // save as 32 bit - // for simplicity - else if (true /*BitsPerSample == 8 && SamplePerPixel == 3*/) - { // 24 bit color + // For now just always default to the RGB 32 bit form. // save as 32 bit for simplicity + else if ( true /*BitsPerSample == 8 && SamplePerPixel == 3*/ ) { // 24 bit color - bi.biSize = sizeof(BITMAPINFOHEADER); - bi.biWidth = imageWidth; - bi.biHeight = imageLength; - bi.biPlanes = 1; // always - bi.biBitCount = 32; - bi.biCompression = BI_RGB; - bi.biSizeImage = WIDTHBYTES(bi.biWidth * bi.biBitCount) * bi.biHeight; - bi.biXPelsPerMeter = 0; - bi.biYPelsPerMeter = 0; - bi.biClrUsed = 0; // must be zero for RGB compression (none) - bi.biClrImportant = 0; // always + bi.biSize = sizeof(BITMAPINFOHEADER); + bi.biWidth = imageWidth; + bi.biHeight = imageLength; + bi.biPlanes = 1; // always + bi.biBitCount = 32; + bi.biCompression = BI_RGB; + bi.biSizeImage = WIDTHBYTES(bi.biWidth * bi.biBitCount) * bi.biHeight; + bi.biXPelsPerMeter = 0; + bi.biYPelsPerMeter = 0; + bi.biClrUsed = 0; // must be zero for RGB compression (none) + bi.biClrImportant = 0; // always // Get the size of the DIB - dwDIBSize = GetDIBSize(&bi); + dwDIBSize = GetDIBSize( &bi ); // Allocate for the BITMAPINFO structure and the color table. - pDIB = GlobalAllocPtr(GHND, dwDIBSize); - if (pDIB == 0) - { - return (NULL); + pDIB = GlobalAllocPtr( GHND, dwDIBSize ); + if (pDIB == 0) { + return( NULL ); } // Copy the header info - *((BITMAPINFOHEADER *)pDIB) = bi; + *((BITMAPINFOHEADER*)pDIB) = bi; // Get a pointer to the color table - RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPINFOHEADER)); + RGBQUAD *pRgbq = (RGBQUAD *)((LPSTR)pDIB + sizeof(BITMAPINFOHEADER)); // Pointers to the bits - // PVOID pbiBits = (LPSTR)pRgbq + bi.biClrUsed * sizeof(RGBQUAD); + //PVOID pbiBits = (LPSTR)pRgbq + bi.biClrUsed * sizeof(RGBQUAD); // // In the BITMAPINFOHEADER documentation, it appears that // there should be no color table for 32 bit images, but @@ -253,15 +242,15 @@ HANDLE TIFFRGBA2DIB(TIFFDibImage *dib, uint32_t *raster) // is not included. So here it is. PVOID pbiBits = (LPSTR)pRgbq + 3 * sizeof(RGBQUAD); - int sizeWords = bi.biSizeImage / 4; - RGBQUAD *rgbDib = (RGBQUAD *)pbiBits; - long *rgbTif = (long *)raster; + int sizeWords = bi.biSizeImage/4; + RGBQUAD* rgbDib = (RGBQUAD*)pbiBits; + long* rgbTif = (long*)raster; // Swap the byte order while copying - for (int i = 0; i < sizeWords; ++i) + for ( int i = 0 ; i < sizeWords ; ++i ) { - rgbDib[i].rgbRed = TIFFGetR(rgbTif[i]); - rgbDib[i].rgbBlue = TIFFGetB(rgbTif[i]); + rgbDib[i].rgbRed = TIFFGetR(rgbTif[i]); + rgbDib[i].rgbBlue = TIFFGetB(rgbTif[i]); rgbDib[i].rgbGreen = TIFFGetG(rgbTif[i]); rgbDib[i].rgbReserved = 0; } @@ -270,6 +259,9 @@ HANDLE TIFFRGBA2DIB(TIFFDibImage *dib, uint32_t *raster) return pDIB; } + + + /////////////////////////////////////////////////////////////// // // Hacked from tif_getimage.c in libtiff in v3.5.7 @@ -277,42 +269,49 @@ HANDLE TIFFRGBA2DIB(TIFFDibImage *dib, uint32_t *raster) // typedef unsigned char u_char; -#define DECLAREContigPutFunc(name) \ - static void name(TIFFRGBAImage *img, uint32_t *cp, uint32_t x, uint32_t y, \ - uint32_t w, uint32_t h, int32_t fromskew, int32_t toskew, \ - u_char *pp) -#define DECLARESepPutFunc(name) \ - static void name(TIFFRGBAImage *img, uint32_t *cp, uint32_t x, uint32_t y, \ - uint32_t w, uint32_t h, int32_t fromskew, int32_t toskew, \ - u_char *r, u_char *g, u_char *b, u_char *a) +#define DECLAREContigPutFunc(name) \ +static void name(\ + TIFFRGBAImage* img, \ + uint32* cp, \ + uint32 x, uint32 y, \ + uint32 w, uint32 h, \ + int32 fromskew, int32 toskew, \ + u_char* pp \ +) + +#define DECLARESepPutFunc(name) \ +static void name(\ + TIFFRGBAImage* img,\ + uint32* cp,\ + uint32 x, uint32 y, \ + uint32 w, uint32 h,\ + int32 fromskew, int32 toskew,\ + u_char* r, u_char* g, u_char* b, u_char* a\ +) DECLAREContigPutFunc(putContig1bitTile); -static int getStripContig1Bit(TIFFRGBAImage *img, uint32_t *uraster, uint32_t w, - uint32_t h); +static int getStripContig1Bit(TIFFRGBAImage* img, uint32* uraster, uint32 w, uint32 h); -// typdef struct TIFFDibImage { -// TIFFRGBAImage tif; -// dibinstalled; -// } TIFFDibImage ; +//typdef struct TIFFDibImage { +// TIFFRGBAImage tif; +// dibinstalled; +//} TIFFDibImage ; -void DibInstallHack(TIFFDibImage *dib) -{ - TIFFRGBAImage *img = &dib->tif; +void DibInstallHack(TIFFDibImage* dib) { + TIFFRGBAImage* img = &dib->tif; dib->dibinstalled = false; - switch (img->photometric) - { + switch (img->photometric) { case PHOTOMETRIC_MINISWHITE: case PHOTOMETRIC_MINISBLACK: - switch (img->bitspersample) - { - case 1: - img->put.contig = putContig1bitTile; - img->get = getStripContig1Bit; - dib->dibinstalled = true; - break; - } - break; + switch (img->bitspersample) { + case 1: + img->put.contig = putContig1bitTile; + img->get = getStripContig1Bit; + dib->dibinstalled = true; + break; + } + break; } } @@ -325,16 +324,15 @@ DECLAREContigPutFunc(putContig1bitTile) { int samplesperpixel = img->samplesperpixel; - (void)y; + (void) y; fromskew *= samplesperpixel; int wb = WIDTHBYTES(w); - u_char *ucp = (u_char *)cp; + u_char* ucp = (u_char*)cp; - /* Convert 'w' to bytes from pixels (rounded up) */ - w = (w + 7) / 8; + /* Conver 'w' to bytes from pixels (rounded up) */ + w = (w+7)/8; - while (h-- > 0) - { + while (h-- > 0) { _TIFFmemcpy(ucp, pp, w); /* for (x = wb; x-- > 0;) { @@ -350,32 +348,32 @@ DECLAREContigPutFunc(putContig1bitTile) /* * Hacked from the tif_getimage.c file. */ -static uint32_t setorientation(TIFFRGBAImage *img, uint32_t h) +static uint32 +setorientation(TIFFRGBAImage* img, uint32 h) { - TIFF *tif = img->tif; - uint32_t y; + TIFF* tif = img->tif; + uint32 y; - switch (img->orientation) - { - case ORIENTATION_BOTRIGHT: - case ORIENTATION_RIGHTBOT: /* XXX */ - case ORIENTATION_LEFTBOT: /* XXX */ - TIFFWarning(TIFFFileName(tif), "using bottom-left orientation"); - img->orientation = ORIENTATION_BOTLEFT; - /* fall through... */ - case ORIENTATION_BOTLEFT: - y = 0; - break; - case ORIENTATION_TOPRIGHT: - case ORIENTATION_RIGHTTOP: /* XXX */ - case ORIENTATION_LEFTTOP: /* XXX */ - default: - TIFFWarning(TIFFFileName(tif), "using top-left orientation"); - img->orientation = ORIENTATION_TOPLEFT; - /* fall through... */ - case ORIENTATION_TOPLEFT: - y = h - 1; - break; + switch (img->orientation) { + case ORIENTATION_BOTRIGHT: + case ORIENTATION_RIGHTBOT: /* XXX */ + case ORIENTATION_LEFTBOT: /* XXX */ + TIFFWarning(TIFFFileName(tif), "using bottom-left orientation"); + img->orientation = ORIENTATION_BOTLEFT; + /* fall through... */ + case ORIENTATION_BOTLEFT: + y = 0; + break; + case ORIENTATION_TOPRIGHT: + case ORIENTATION_RIGHTTOP: /* XXX */ + case ORIENTATION_LEFTTOP: /* XXX */ + default: + TIFFWarning(TIFFFileName(tif), "using top-left orientation"); + img->orientation = ORIENTATION_TOPLEFT; + /* fall through... */ + case ORIENTATION_TOPLEFT: + y = h-1; + break; } return (y); } @@ -391,56 +389,61 @@ static uint32_t setorientation(TIFFRGBAImage *img, uint32_t h) * This is set up to allow us to just copy the data to the raster * for 1-bit bitmaps */ -static int getStripContig1Bit(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, - uint32_t h) +static int +getStripContig1Bit(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { - TIFF *tif = img->tif; + TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; - uint16_t orientation; - uint32_t row, y, nrow, rowstoread; - uint32_t pos; - u_char *buf; - uint32_t rowsperstrip; - uint32_t imagewidth = img->width; + uint16 orientation; + uint32 row, y, nrow, rowstoread; + uint32 pos; + u_char* buf; + uint32 rowsperstrip; + uint32 imagewidth = img->width; tsize_t scanline; - int32_t fromskew, toskew; + int32 fromskew, toskew; tstrip_t strip; - tsize_t stripsize; - u_char *braster = (u_char *)raster; // byte wide raster - uint32_t wb = WIDTHBYTES(w); + tsize_t stripsize; + u_char* braster = (u_char*)raster; // byte wide raster + uint32 wb = WIDTHBYTES(w); int ret = 1; - buf = (u_char *)_TIFFmalloc(TIFFStripSize(tif)); - if (buf == 0) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "No space for strip buffer"); + buf = (u_char*) _TIFFmalloc(TIFFStripSize(tif)); + if (buf == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "No space for strip buffer"); return (0); } y = setorientation(img, h); orientation = img->orientation; - toskew = -(int32_t)(orientation == ORIENTATION_TOPLEFT ? wb + wb : wb - wb); + toskew = -(int32) (orientation == ORIENTATION_TOPLEFT ? wb+wb : wb-wb); TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); scanline = TIFFScanlineSize(tif); - fromskew = (w < imagewidth ? imagewidth - w : 0) / 8; + fromskew = (w < imagewidth ? imagewidth - w : 0)/8; for (row = 0; row < h; row += nrow) { rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; nrow = (row + rowstoread > h ? h - row : rowstoread); - strip = TIFFComputeStrip(tif, row + img->row_offset, 0); - stripsize = ((row + img->row_offset) % rowsperstrip + nrow) * scanline; - if (TIFFReadEncodedStrip(tif, strip, buf, stripsize) < 0 && - img->stoponerr) + strip = TIFFComputeStrip(tif,row+img->row_offset, 0); + stripsize = ((row + img->row_offset)%rowsperstrip + nrow) * scanline; + if (TIFFReadEncodedStrip(tif, strip, buf, stripsize ) < 0 + && img->stoponerr) { ret = 0; break; } pos = ((row + img->row_offset) % rowsperstrip) * scanline; - (*put)(img, (uint32_t *)(braster + y * wb), 0, y, w, nrow, fromskew, - toskew, buf + pos); - y += (orientation == ORIENTATION_TOPLEFT ? -(int32_t)nrow - : (int32_t)nrow); + (*put)(img, (uint32*)(braster+y*wb), 0, y, w, nrow, fromskew, toskew, buf + pos); + y += (orientation == ORIENTATION_TOPLEFT ?-(int32) nrow : (int32) nrow); } _TIFFfree(buf); return (ret); } + +/* + * Local Variables: + * mode: c++ + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/tiff2dib.c b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/tiff2dib.c index f6ad8a272..2fa2de696 100644 --- a/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/tiff2dib.c +++ b/thirdparty/SDL2_image/external/libtiff/contrib/win_dib/tiff2dib.c @@ -1,39 +1,42 @@ /************************************************************************* * - * Source file for Windows 95/Win32. + * Source file for Windows 95/Win32. * - * The function LoadTIFFinDIB in this source file let you load - * a TIFF file and build a memory DIB with it and return the - * HANDLE (HDIB) of the memory block containing the DIB. - * - * Example : + * The function LoadTIFFinDIB in this source file let you load + * a TIFF file and build a memory DIB with it and return the + * HANDLE (HDIB) of the memory bloc containing the DIB. * + * Example : + * * HDIB hDIB; * hDIB = LoadTIFFinDIB("sample.tif"); * * - * To build this source file you must include the TIFF library + * To build this source file you must include the TIFF library * in your project. * * 4/12/95 Philippe Tenenhaus 100423.3705@compuserve.com * ************************************************************************/ -#include "tiffio.h" + +#include "tiffio.h" #define HDIB HANDLE -#define IS_WIN30_DIB(lpbi) ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER)) -#define CVT(x) (((x)*255L) / ((1L << 16) - 1)) +#define IS_WIN30_DIB(lpbi) ((*(LPDWORD)(lpbi)) == sizeof(BITMAPINFOHEADER)) +#define CVT(x) (((x) * 255L) / ((1L<<16)-1)) static HDIB CreateDIB(DWORD dwWidth, DWORD dwHeight, WORD wBitCount); static LPSTR FindDIBBits(LPSTR lpDIB); static WORD PaletteSize(LPSTR lpDIB); static WORD DIBNumColors(LPSTR lpDIB); -static int checkcmap(int n, uint16_t *r, uint16_t *g, uint16_t *b); +static int checkcmap(int n, uint16* r, uint16* g, uint16* b); + + /************************************************************************* * - * HDIB LoadTIFFinDIB(LPSTR lpFileName) + * HDIB LoadTIFFinDIB(LPSTR lpFileName) * * Parameter: * @@ -46,180 +49,188 @@ static int checkcmap(int n, uint16_t *r, uint16_t *g, uint16_t *b); * Description: * * This function load a TIFF file and build a memory DIB with it - * and return the HANDLE (HDIB) of the memory block containing + * and return the HANDLE (HDIB) of the memory bloc containing * the DIB. * * 4/12/95 Philippe Tenenhaus 100423.3705@compuserve.com * ************************************************************************/ -HDIB LoadTIFFinDIB(LPSTR lpFileName) +HDIB LoadTIFFinDIB(LPSTR lpFileName) { - TIFF *tif; - unsigned long imageLength; - unsigned long imageWidth; - unsigned int BitsPerSample; + TIFF *tif; + unsigned long imageLength; + unsigned long imageWidth; + unsigned int BitsPerSample; unsigned long LineSize; - unsigned int SamplePerPixel; - unsigned long RowsPerStrip; - int PhotometricInterpretation; - long nrow; - unsigned long row; - char *buf; - LPBITMAPINFOHEADER lpDIB; - HDIB hDIB; - char *lpBits; - HGLOBAL hStrip; - int i, l; - int Align; - + unsigned int SamplePerPixel; + unsigned long RowsPerStrip; + int PhotometricInterpretation; + long nrow; + unsigned long row; + char *buf; + LPBITMAPINFOHEADER lpDIB; + HDIB hDIB; + char *lpBits; + HGLOBAL hStrip; + int i,l; + int Align; + tif = TIFFOpen(lpFileName, "r"); - + if (!tif) goto TiffOpenError; - + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength); TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &BitsPerSample); - TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip); - TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip); + TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip); + TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &RowsPerStrip); TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &PhotometricInterpretation); + + LineSize = TIFFScanlineSize(tif); //Number of byte in ine line - LineSize = TIFFScanlineSize(tif); // Number of byte in ine line + SamplePerPixel = (int) (LineSize/imageWidth); - SamplePerPixel = (int)(LineSize / imageWidth); - - // Align = Number of byte to add at the end of each line of the DIB + //Align = Number of byte to add at the end of each line of the DIB Align = 4 - (LineSize % 4); - if (Align == 4) - Align = 0; + if (Align == 4) Align = 0; - // Create a new DIB - hDIB = CreateDIB((DWORD)imageWidth, (DWORD)imageLength, - (WORD)(BitsPerSample * SamplePerPixel)); - lpDIB = (LPBITMAPINFOHEADER)GlobalLock(hDIB); + + //Create a new DIB + hDIB = CreateDIB((DWORD) imageWidth, (DWORD) imageLength, (WORD) +(BitsPerSample*SamplePerPixel)); + lpDIB = (LPBITMAPINFOHEADER) GlobalLock(hDIB); if (!lpDIB) - goto OutOfDIBMemory; - + goto OutOfDIBMemory; + if (lpDIB) - lpBits = FindDIBBits((LPSTR)lpDIB); + lpBits = FindDIBBits((LPSTR) lpDIB); else - lpBits = NULL; + lpBits = NULL; - // In the tiff file the lines are save from up to down - // In a DIB the lines must be save from down to up + //In the tiff file the lines are save from up to down + //In a DIB the lines must be save from down to up if (lpBits) - { - lpBits = FindDIBBits((LPSTR)lpDIB); - lpBits += ((imageWidth * SamplePerPixel) + Align) * (imageLength - 1); - // now lpBits pointe on the bottom line - - hStrip = GlobalAlloc(GHND, TIFFStripSize(tif)); - buf = GlobalLock(hStrip); - + { + lpBits = FindDIBBits((LPSTR) lpDIB); + lpBits+=((imageWidth*SamplePerPixel)+Align)*(imageLength-1); + //now lpBits pointe on the bottom line + + hStrip = GlobalAlloc(GHND,TIFFStripSize(tif)); + buf = GlobalLock(hStrip); + if (!buf) - goto OutOfBufMemory; - - // PhotometricInterpretation = 2 image is RGB - // PhotometricInterpretation = 3 image have a color palette + goto OutOfBufMemory; + + //PhotometricInterpretation = 2 image is RGB + //PhotometricInterpretation = 3 image have a color palette if (PhotometricInterpretation == 3) { - uint16_t *red; - uint16_t *green; - uint16_t *blue; - int16_t i; - LPBITMAPINFO lpbmi; - int Palette16Bits; + uint16* red; + uint16* green; + uint16* blue; + int16 i; + LPBITMAPINFO lpbmi; + int Palette16Bits; + + TIFFGetField(tif, TIFFTAG_COLORMAP, &red, &green, &blue); - TIFFGetField(tif, TIFFTAG_COLORMAP, &red, &green, &blue); - - // Is the palette 16 or 8 bits ? - if (checkcmap(1 << BitsPerSample, red, green, blue) == 16) - Palette16Bits = TRUE; - else - Palette16Bits = FALSE; - - lpbmi = (LPBITMAPINFO)lpDIB; - - // load the palette in the DIB - for (i = (1 << BitsPerSample) - 1; i >= 0; i--) - { - if (Palette16Bits) + //Is the palette 16 or 8 bits ? + if (checkcmap(1<= 0; i--) + { + if (Palette16Bits) { - lpbmi->bmiColors[i].rgbRed = (BYTE)CVT(red[i]); - lpbmi->bmiColors[i].rgbGreen = (BYTE)CVT(green[i]); - lpbmi->bmiColors[i].rgbBlue = (BYTE)CVT(blue[i]); + lpbmi->bmiColors[i].rgbRed =(BYTE) CVT(red[i]); + lpbmi->bmiColors[i].rgbGreen = (BYTE) CVT(green[i]); + lpbmi->bmiColors[i].rgbBlue = (BYTE) CVT(blue[i]); } - else + else { - lpbmi->bmiColors[i].rgbRed = (BYTE)red[i]; - lpbmi->bmiColors[i].rgbGreen = (BYTE)green[i]; - lpbmi->bmiColors[i].rgbBlue = (BYTE)blue[i]; + lpbmi->bmiColors[i].rgbRed = (BYTE) red[i]; + lpbmi->bmiColors[i].rgbGreen = (BYTE) green[i]; + lpbmi->bmiColors[i].rgbBlue = (BYTE) blue[i]; } - } + } + } - - // read the tiff lines and save them in the DIB - // with RGB mode, we have to change the order of the 3 samples RGB - <=> BGR for (row = 0; row < imageLength; row += RowsPerStrip) - { - nrow = (row + RowsPerStrip > imageLength ? imageLength - row - : RowsPerStrip); - if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), buf, - nrow * LineSize) == -1) - { - goto TiffReadError; - } + + //read the tiff lines and save them in the DIB + //with RGB mode, we have to change the order of the 3 samples RGB +<=> BGR + for (row = 0; row < imageLength; row += RowsPerStrip) + { + nrow = (row + RowsPerStrip > imageLength ? imageLength - row : +RowsPerStrip); + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, row, 0), + buf, nrow*LineSize)==-1) + { + goto TiffReadError; + } else - { - for (l = 0; l < nrow; l++) - { - if (SamplePerPixel == 3) - for (i = 0; i < (int)(imageWidth); i++) - { - lpBits[i * SamplePerPixel + 0] = - buf[l * LineSize + i * Sample PerPixel + 2]; - lpBits[i * SamplePerPixel + 1] = - buf[l * LineSize + i * Sample PerPixel + 1]; - lpBits[i * SamplePerPixel + 2] = - buf[l * LineSize + i * Sample PerPixel + 0]; - } - else - memcpy(lpBits, &buf[(int)(l * LineSize)], - (int)imageWidth * SamplePerPixel); + { + for (l = 0; l < nrow; l++) + { + if (SamplePerPixel == 3) + for (i=0;i< (int) (imageWidth);i++) + { + lpBits[i*SamplePerPixel+0]=buf[l*LineSize+i*Sample +PerPixel+2]; + lpBits[i*SamplePerPixel+1]=buf[l*LineSize+i*Sample +PerPixel+1]; + lpBits[i*SamplePerPixel+2]=buf[l*LineSize+i*Sample +PerPixel+0]; + } + else + memcpy(lpBits, &buf[(int) (l*LineSize)], (int) +imageWidth*SamplePerPixel); + + lpBits-=imageWidth*SamplePerPixel+Align; - lpBits -= imageWidth * SamplePerPixel + Align; - } - } - } + } + } + } GlobalUnlock(hStrip); GlobalFree(hStrip); - GlobalUnlock(hDIB); + GlobalUnlock(hDIB); TIFFClose(tif); - } - + } + return hDIB; - -OutOfBufMemory: - -TiffReadError: - GlobalUnlock(hDIB); - GlobalFree(hStrip); -OutOfDIBMemory: - TIFFClose(tif); -TiffOpenError: - return (HANDLE)0; + + OutOfBufMemory: + + TiffReadError: + GlobalUnlock(hDIB); + GlobalFree(hStrip); + OutOfDIBMemory: + TIFFClose(tif); + TiffOpenError: + return (HANDLE) 0; + + } -static int checkcmap(int n, uint16_t *r, uint16_t *g, uint16_t *b) + +static int checkcmap(int n, uint16* r, uint16* g, uint16* b) { while (n-- > 0) if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) - return (16); - + return (16); + return (8); } + + /************************************************************************* * All the following functions were created by microsoft, they are * parts of the sample project "wincap" given with the SDK Win32. @@ -236,124 +247,135 @@ static int checkcmap(int n, uint16_t *r, uint16_t *g, uint16_t *b) HDIB CreateDIB(DWORD dwWidth, DWORD dwHeight, WORD wBitCount) { - BITMAPINFOHEADER bi; // bitmap header - LPBITMAPINFOHEADER lpbi; // pointer to BITMAPINFOHEADER - DWORD dwLen; // size of memory block - HDIB hDIB; - DWORD dwBytesPerLine; // Number of bytes per scanline + BITMAPINFOHEADER bi; // bitmap header + LPBITMAPINFOHEADER lpbi; // pointer to BITMAPINFOHEADER + DWORD dwLen; // size of memory block + HDIB hDIB; + DWORD dwBytesPerLine; // Number of bytes per scanline - // Make sure bits per pixel is valid - if (wBitCount <= 1) - wBitCount = 1; - else if (wBitCount <= 4) - wBitCount = 4; - else if (wBitCount <= 8) - wBitCount = 8; - else if (wBitCount <= 24) - wBitCount = 24; - else - wBitCount = 4; // set default value to 4 if parameter is bogus - // initialize BITMAPINFOHEADER - bi.biSize = sizeof(BITMAPINFOHEADER); - bi.biWidth = dwWidth; // fill in width from parameter - bi.biHeight = dwHeight; // fill in height from parameter - bi.biPlanes = 1; // must be 1 - bi.biBitCount = wBitCount; // from parameter - bi.biCompression = BI_RGB; - bi.biSizeImage = - (dwWidth * dwHeight * wBitCount) / 8; // 0; // 0's here - mean "default" bi.biXPelsPerMeter = 2834; // 0; - bi.biYPelsPerMeter = 2834; // 0; - bi.biClrUsed = 0; - bi.biClrImportant = 0; + // Make sure bits per pixel is valid + if (wBitCount <= 1) + wBitCount = 1; + else if (wBitCount <= 4) + wBitCount = 4; + else if (wBitCount <= 8) + wBitCount = 8; + else if (wBitCount <= 24) + wBitCount = 24; + else + wBitCount = 4; // set default value to 4 if parameter is bogus - // calculate size of memory block required to store the DIB. This - // block should be big enough to hold the BITMAPINFOHEADER, the color - // table, and the bits + // initialize BITMAPINFOHEADER + bi.biSize = sizeof(BITMAPINFOHEADER); + bi.biWidth = dwWidth; // fill in width from parameter + bi.biHeight = dwHeight; // fill in height from parameter + bi.biPlanes = 1; // must be 1 + bi.biBitCount = wBitCount; // from parameter + bi.biCompression = BI_RGB; + bi.biSizeImage = (dwWidth*dwHeight*wBitCount)/8; //0; // 0's here +mean "default" + bi.biXPelsPerMeter = 2834; //0; + bi.biYPelsPerMeter = 2834; //0; + bi.biClrUsed = 0; + bi.biClrImportant = 0; - dwBytesPerLine = (((wBitCount * dwWidth) + 31) / 32 * 4); - dwLen = bi.biSize + PaletteSize((LPSTR)&bi) + (dwBytesPerLine * dwHeight); + // calculate size of memory block required to store the DIB. This + // block should be big enough to hold the BITMAPINFOHEADER, the color + // table, and the bits - // alloc memory block to store our bitmap - hDIB = GlobalAlloc(GHND, dwLen); + dwBytesPerLine = (((wBitCount * dwWidth) + 31) / 32 * 4); + dwLen = bi.biSize + PaletteSize((LPSTR)&bi) + (dwBytesPerLine * dwHeight); - // major bummer if we couldn't get memory block - if (!hDIB) - { - return NULL; - } + // alloc memory block to store our bitmap + hDIB = GlobalAlloc(GHND, dwLen); - // lock memory and get pointer to it - lpbi = (VOID FAR *)GlobalLock(hDIB); + // major bummer if we couldn't get memory block + if (!hDIB) + { + return NULL; + } - // use our bitmap info structure to fill in first part of - // our DIB with the BITMAPINFOHEADER - *lpbi = bi; + // lock memory and get pointer to it + lpbi = (VOID FAR *)GlobalLock(hDIB); - // Since we don't know what the colortable and bits should contain, - // just leave these blank. Unlock the DIB and return the HDIB. + // use our bitmap info structure to fill in first part of + // our DIB with the BITMAPINFOHEADER + *lpbi = bi; - GlobalUnlock(hDIB); + // Since we don't know what the colortable and bits should contain, + // just leave these blank. Unlock the DIB and return the HDIB. - /* return handle to the DIB */ - return hDIB; + GlobalUnlock(hDIB); + + /* return handle to the DIB */ + return hDIB; } + LPSTR FAR FindDIBBits(LPSTR lpDIB) { - return (lpDIB + *(LPDWORD)lpDIB + PaletteSize(lpDIB)); + return (lpDIB + *(LPDWORD)lpDIB + PaletteSize(lpDIB)); } + WORD FAR PaletteSize(LPSTR lpDIB) { - /* calculate the size required by the palette */ - if (IS_WIN30_DIB(lpDIB)) - return (DIBNumColors(lpDIB) * sizeof(RGBQUAD)); - else - return (DIBNumColors(lpDIB) * sizeof(RGBTRIPLE)); + /* calculate the size required by the palette */ + if (IS_WIN30_DIB (lpDIB)) + return (DIBNumColors(lpDIB) * sizeof(RGBQUAD)); + else + return (DIBNumColors(lpDIB) * sizeof(RGBTRIPLE)); } + WORD DIBNumColors(LPSTR lpDIB) { - WORD wBitCount; // DIB bit count + WORD wBitCount; // DIB bit count - /* If this is a Windows-style DIB, the number of colors in the - * color table can be less than the number of bits per pixel - * allows for (i.e. lpbi->biClrUsed can be set to some value). - * If this is the case, return the appropriate value. - */ + /* If this is a Windows-style DIB, the number of colors in the + * color table can be less than the number of bits per pixel + * allows for (i.e. lpbi->biClrUsed can be set to some value). + * If this is the case, return the appropriate value. + */ - if (IS_WIN30_DIB(lpDIB)) - { - DWORD dwClrUsed; + if (IS_WIN30_DIB(lpDIB)) + { + DWORD dwClrUsed; - dwClrUsed = ((LPBITMAPINFOHEADER)lpDIB)->biClrUsed; - if (dwClrUsed) - return (WORD)dwClrUsed; - } + dwClrUsed = ((LPBITMAPINFOHEADER)lpDIB)->biClrUsed; + if (dwClrUsed) + return (WORD)dwClrUsed; + } - /* Calculate the number of colors in the color table based on - * the number of bits per pixel for the DIB. - */ - if (IS_WIN30_DIB(lpDIB)) - wBitCount = ((LPBITMAPINFOHEADER)lpDIB)->biBitCount; - else - wBitCount = ((LPBITMAPCOREHEADER)lpDIB)->bcBitCount; + /* Calculate the number of colors in the color table based on + * the number of bits per pixel for the DIB. + */ + if (IS_WIN30_DIB(lpDIB)) + wBitCount = ((LPBITMAPINFOHEADER)lpDIB)->biBitCount; + else + wBitCount = ((LPBITMAPCOREHEADER)lpDIB)->bcBitCount; - /* return number of colors based on bits per pixel */ - switch (wBitCount) - { - case 1: - return 2; + /* return number of colors based on bits per pixel */ + switch (wBitCount) + { + case 1: + return 2; - case 4: - return 16; + case 4: + return 16; - case 8: - return 256; + case 8: + return 256; - default: - return 0; - } + default: + return 0; + } } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/doc/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/doc/CMakeLists.txt deleted file mode 100644 index 6cc3d2e49..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/CMakeLists.txt +++ /dev/null @@ -1,146 +0,0 @@ -# CMake build for libtiff -# Run "cmake" to generate the build files for your platform -# -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021-2022 Roger Leigh -# Written by Roger Leigh -# -# 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. - -cmake_minimum_required(VERSION 3.2.0) - -include(Sphinx) - -if (BUILD_SPHINX AND SPHINX_BUILD) - # Re-run CMake when the Sphinx configuration is updated - set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/conf.py") - - message(STATUS "Checking manual page dependencies") - - # Create build directory and conf.py - set(sphinx_srcdir "${CMAKE_CURRENT_SOURCE_DIR}") - set(sphinx_builddir "${CMAKE_CURRENT_BINARY_DIR}") - file(MAKE_DIRECTORY "${sphinx_builddir}") - - sphinx_manpages("${sphinx_srcdir}" "${sphinx_builddir}/man" MAN_PAGES) - sphinx_manpage_dependencies("${sphinx_srcdir}" MAN_PAGE_DEPENDENCIES) - sphinx_dependencies("${sphinx_srcdir}" SPHINX_DEPENDENCIES) - - # Generate and install man pages - - unset(man_target) - if(MAN_PAGES) - add_custom_command(OUTPUT ${MAN_PAGES} - COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/cache" - COMMAND ${CMAKE_COMMAND} -E make_directory "${PROJECT_BINARY_DIR}/man" - COMMAND ${SPHINX_BUILD} - -D "release=${LIBTIFF_VERSION_FULL}" - -D "version=${tiff_VERSION_MAJOR}.${tiff_VERSION_MINOR}" - -d "${sphinx_builddir}/cache" - -b man - "${sphinx_srcdir}" "${sphinx_builddir}/man" - WORKING_DIRECTORY "${sphinx_srcdir}" - DEPENDS ${MAN_PAGE_DEPENDENCIES}) - - if(NOT TARGET doc-man) - add_custom_target(doc-man ALL) - endif() - add_custom_target(${PROJECT_NAME}-doc-man DEPENDS ${MAN_PAGES}) - add_dependencies(doc-man ${PROJECT_NAME}-doc-man) - set(man_target ${PROJECT_NAME}-doc-man) - - foreach (man ${MAN_PAGES}) - string(REGEX REPLACE ".*\\.([0-9])[a-z]*\$" "\\1" man_section "${man}") - install(FILES "${man}" - DESTINATION "${CMAKE_INSTALL_MANDIR}/man${man_section}" - COMPONENT "runtime") - endforeach() - endif() - - # Generate and install HTML manual - # Depends on man to allow sharing of cache with parallel build. - - add_custom_command(OUTPUT "${sphinx_builddir}/html/index.html" - COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/cache" - COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/html" - COMMAND ${SPHINX_BUILD} - -D "release=${tiff_VERSION}" - -D "version=${tiff_VERSION_MAJOR}.${tiff_VERSION_MINOR}" - -d "${sphinx_builddir}/cache" - -b html - "${sphinx_srcdir}" "${sphinx_builddir}/html" - WORKING_DIRECTORY "${sphinx_srcdir}" - DEPENDS ${man_target} ${SPHINX_DEPENDENCIES}) - - if(NOT TARGET doc-html) - add_custom_target(doc-html ALL) - endif() - add_custom_target(${PROJECT_NAME}-doc-html DEPENDS "${sphinx_builddir}/html/index.html") - add_dependencies(doc-html ${PROJECT_NAME}-doc-html) - - install(DIRECTORY "${sphinx_builddir}/html" - DESTINATION "${CMAKE_INSTALL_DOCDIR}/manual" - COMPONENT "runtime") - - if(sphinx-linkcheck) - set(sphinx_linkcheck_all ALL) - endif() - - if(NOT TARGET doc-linkcheck) - add_custom_target(doc-linkcheck) - endif() - add_custom_target(${PROJECT_NAME}-doc-linkcheck ${sphinx_linkcheck_all} - COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/cache" - COMMAND ${CMAKE_COMMAND} -E make_directory "${sphinx_builddir}/linkcheck" - COMMAND ${SPHINX_BUILD} - -D "release=${tiff_VERSION}" - -D "version=${tiff_VERSION_MAJOR}.${tiff_VERSION_MINOR}" - -c "${sphinx_builddir}" - -d "${sphinx_builddir}/cache" - -b linkcheck - "${sphinx_srcdir}" "${sphinx_builddir}/linkcheck" - COMMENT "Checking remote links in sphinx documentation" - WORKING_DIRECTORY "${sphinx_srcdir}" - DEPENDS ${man_target} ${SPHINX_DEPENDENCIES}) - add_dependencies(doc-linkcheck ${PROJECT_NAME}-doc-linkcheck) - - if(NOT TARGET doc-locallinkcheck) - add_custom_target(doc-locallinkcheck) - endif() - add_custom_target(${PROJECT_NAME}-doc-locallinkcheck ${sphinx_linkcheck_all} - COMMAND ${CMAKE_COMMAND} - "-DOUTPUT=${sphinx_builddir}/linkcheck/output.txt" - "-DSPHINX_INSTALL_PATH=${PROJECT_NAME}/manual/html" - "-DINTERNAL_REFERENCE=${sphinx_builddir}/html" - "-DEXTERNAL_REFERENCE=${CMAKE_INSTALL_FULL_DATAROOTDIR}/doc" - "-DDOXYGEN_REFERENCE=${PROJECT_BINARY_DIR}/docs/doxygen/api" - "-DDOXYGEN_INSTALL_PATH=${PROJECT_NAME}/api" - -P "${PROJECT_SOURCE_DIR}/cmake/SphinxCheckInternalLinks.cmake" - COMMENT "Checking local links in sphinx documentation" - WORKING_DIRECTORY "${sphinx_srcdir}" - DEPENDS doc-linkcheck) - add_dependencies(doc-locallinkcheck ${PROJECT_NAME}-doc-locallinkcheck) -elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/html-prebuilt/") - install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/html-prebuilt/" - DESTINATION "${CMAKE_INSTALL_DOCDIR}/manual/html" - COMPONENT "runtime") -else() - message(WARNING "Manual pages and HTML manual will not be generated or installed") -endif() diff --git a/thirdparty/SDL2_image/external/libtiff/doc/Makefile.am b/thirdparty/SDL2_image/external/libtiff/doc/Makefile.am deleted file mode 100644 index 56c323e06..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/Makefile.am +++ /dev/null @@ -1,274 +0,0 @@ -# -# Tag Image File Format (TIFF) Software -# -# Copyright (C) 2004, Andrey Kiselev -# -# 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. - -# Process this file with automake to produce Makefile.in. - -docdir = $(LIBTIFF_DOCDIR)/manual - -if TIFF_DOCS -if SPHINX -doc-html: - $(SPHINX_BUILD) \ - -D "release=$(LIBTIFF_VERSION)" \ - -D "version=$(LIBTIFF_MAJOR_VERSION).$(LIBTIFF_MINOR_VERSION)" \ - -d "$(builddir)/cache" \ - -b html \ - "$(srcdir)" "$(builddir)/html" - -doc-man: - $(SPHINX_BUILD) \ - -D "release=$(LIBTIFF_VERSION)" \ - -D "version=$(LIBTIFF_MAJOR_VERSION).$(LIBTIFF_MINOR_VERSION)" \ - -d "$(builddir)/cache" \ - -b man \ - "$(srcdir)" "$(builddir)/man" - -man1_MANS = $(TIFF_MAN1_GEN) -man3_MANS = $(TIFF_MAN3_GEN) - -@TIFF_MAN_RULES@ - -all-local: doc-html doc-man - -clean-local: - rm -r html - rm -r man - rm -r cache - -html_installdir = html -else -# Sphinx not available -doc-html: - echo "HTML documentation generation not configured (sphinx not available)" - exit 1 - -doc-man: - echo "Manual page documentation generation not configured (sphinx not available)" - exit 1 - -man1_MANS = $(TIFF_MAN1_PREBUILT) -man3_MANS = $(TIFF_MAN3_PREBUILT) - -html_installdir = $(srcdir)/html-prebuilt -endif - - -install-data-local: all-local - find $(html_installdir) -type d | sed -e 's;^$(html_installdir);;' | while read dir; do \ - echo " $(MKDIR_P) '$(DESTDIR)$(docdir)$$dir'"; \ - $(MKDIR_P) "$(DESTDIR)$(docdir)$$dir" || exit 1; \ - done - find $(html_installdir) -type f | sed -e 's;^$(html_installdir);;' | while read docfile; do \ - docsubdir=$$(dirname $$docfile); \ - echo "$(INSTALL_DATA) '$(html_installdir)$$docfile' '$(DESTDIR)$(docdir)$$docsubdir'"; \ - $(INSTALL_DATA) "$(html_installdir)$$docfile" "$(DESTDIR)$(docdir)$$docsubdir"; \ - done - -uninstall-local: - echo "rm -r $(DESTDIR)$(docdir)" - rm -r $(DESTDIR)$(docdir) -else -# Documentation generation disabled -doc-html: - echo "HTML documentation generation not configured" - exit 1 - -doc-man: - echo "Manual page documentation generation not configured" - exit 1 -endif - -rst_sources = \ - index.rst \ - build.rst \ - internals.rst \ - tools/tiffgt.rst \ - tools/tiffdither.rst \ - tools/tiff2pdf.rst \ - tools/tiff2ps.rst \ - tools/ppm2tiff.rst \ - tools/raw2tiff.rst \ - tools/fax2tiff.rst \ - tools/tiffcrop.rst \ - tools/tiff2bw.rst \ - tools/fax2ps.rst \ - tools/thumbnail.rst \ - tools/tiffcmp.rst \ - tools/tiffdump.rst \ - tools/tiff2rgba.rst \ - tools/tiffinfo.rst \ - tools/rgb2ycbcr.rst \ - tools/tiffset.rst \ - tools/tiffsplit.rst \ - tools/tiffmedian.rst \ - tools/pal2rgb.rst \ - tools/tiffcp.rst \ - project/license.rst \ - project/index.rst \ - project/acknowledgements.rst \ - project/bugs.rst \ - project/mailinglist.rst \ - addingtags.rst \ - specification/index.rst \ - specification/bigtiff.rst \ - specification/coverage.rst \ - specification/technote2.rst \ - specification/coverage-bigtiff.rst \ - releases/v3.4beta028.rst \ - releases/v4.0.9.rst \ - releases/v3.9.0.rst \ - releases/v4.0.7.rst \ - releases/v3.5.7.rst \ - releases/v4.0.0.rst \ - releases/v3.7.0beta2.rst \ - releases/v3.7.1.rst \ - releases/index.rst \ - releases/v3.8.0.rst \ - releases/v4.1.0.rst \ - releases/historical.rst \ - releases/v3.5.6beta.rst \ - releases/v3.6.1.rst \ - releases/v4.2.0.rst \ - releases/v3.7.0.rst \ - releases/v4.0.1.rst \ - releases/v3.5.1.rst \ - releases/v4.0.10.rst \ - releases/v4.0.6.rst \ - releases/v4.0.8.rst \ - releases/v3.9.1.rst \ - releases/v3.4beta029.rst \ - releases/v4.3.0.rst \ - releases/v3.4beta031.rst \ - releases/v3.7.0alpha.rst \ - releases/v3.6.0.rst \ - releases/v3.4beta036.rst \ - releases/v4.0.4beta.rst \ - releases/v3.8.1.rst \ - releases/v4.4.0.rst \ - releases/v3.4beta035.rst \ - releases/v3.4beta032.rst \ - releases/v3.4beta007.rst \ - releases/v3.9.0beta.rst \ - releases/v3.8.2.rst \ - releases/v3.4beta018.rst \ - releases/v3.7.3.rst \ - releases/v3.4beta016.rst \ - releases/v3.7.4.rst \ - releases/v3.5.2.rst \ - releases/v4.0.5.rst \ - releases/v3.4beta024.rst \ - releases/v3.5.5.rst \ - releases/v4.0.2.rst \ - releases/v3.9.5.rst \ - releases/v3.9.2.rst \ - releases/v3.4beta033.rst \ - releases/v3.4beta034.rst \ - releases/v3.9.3.rst \ - releases/v3.9.4.rst \ - releases/v3.7.0beta.rst \ - releases/v3.5.4.rst \ - releases/v4.0.3.rst \ - releases/v3.5.3.rst \ - releases/v4.0.4.rst \ - releases/v3.7.2.rst \ - releases/v4.5.0.rst \ - releases/v4.5.1.rst \ - functions.rst \ - tools.rst \ - terms.rst \ - contrib.rst \ - functions/TIFFRGBAImage.rst \ - functions/TIFFGetField.rst \ - functions/TIFFSetDirectory.rst \ - functions/TIFFWriteRawStrip.rst \ - functions/TIFFcolor.rst \ - functions/TIFFstrip.rst \ - functions/TIFFReadDirectory.rst \ - functions/TIFFReadRawTile.rst \ - functions/libtiff.rst \ - functions/TIFFPrintDirectory.rst \ - functions/TIFFsize.rst \ - functions/TIFFReadRGBATile.rst \ - functions/TIFFswab.rst \ - functions/TIFFmemory.rst \ - functions/TIFFtile.rst \ - functions/TIFFReadEncodedTile.rst \ - functions/TIFFWriteDirectory.rst \ - functions/TIFFSetField.rst \ - functions/TIFFWriteScanline.rst \ - functions/TIFFClose.rst \ - functions/TIFFFieldName.rst \ - functions/TIFFFieldReadCount.rst \ - functions/TIFFError.rst \ - functions/TIFFOpen.rst \ - functions/TIFFOpenOptions.rst \ - functions/TIFFcodec.rst \ - functions/TIFFFlush.rst \ - functions/TIFFDataWidth.rst \ - functions/TIFFReadRawStrip.rst \ - functions/TIFFReadTile.rst \ - functions/TIFFFieldWriteCount.rst \ - functions/TIFFbuffer.rst \ - functions/TIFFWriteRawTile.rst \ - functions/TIFFWarning.rst \ - functions/TIFFFieldDataType.rst \ - functions/TIFFWriteEncodedStrip.rst \ - functions/TIFFFieldPassCount.rst \ - functions/TIFFReadRGBAImage.rst \ - functions/TIFFReadScanline.rst \ - functions/TIFFReadEncodedStrip.rst \ - functions/TIFFFieldTag.rst \ - functions/TIFFWriteTile.rst \ - functions/TIFFReadRGBAStrip.rst \ - functions/TIFFquery.rst \ - functions/TIFFWriteEncodedTile.rst \ - functions/_TIFFauxiliary.rst \ - functions/_TIFFRewriteField.rst \ - functions/TIFFAccessTagMethods.rst \ - functions/TIFFClientInfo.rst \ - functions/TIFFCreateDirectory.rst \ - functions/TIFFCustomDirectory.rst \ - functions/TIFFCustomTagList.rst \ - functions/TIFFDeferStrileArrayWriting.rst \ - functions/TIFFFieldQuery.rst \ - functions/TIFFMergeFieldInfo.rst \ - functions/TIFFProcFunctions.rst \ - functions/TIFFReadFromUserBuffer.rst \ - functions/TIFFSetTagExtender.rst \ - functions/TIFFStrileQuery.rst \ - libtiff.rst \ - images.rst - -EXTRA_DIST = \ - CMakeLists.txt \ - conf.py \ - specification/bigtiffpr_images \ - images \ - $(rst_sources) - -dist-hook: doc-html doc-man - cp -r html $(distdir)/html-prebuilt - cp -r man $(distdir)/man-prebuilt - -.PHONY: doc-html doc-man diff --git a/thirdparty/SDL2_image/external/libtiff/doc/_static/.gitignore b/thirdparty/SDL2_image/external/libtiff/doc/_static/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/thirdparty/SDL2_image/external/libtiff/doc/addingtags.rst b/thirdparty/SDL2_image/external/libtiff/doc/addingtags.rst deleted file mode 100644 index 96f35a826..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/addingtags.rst +++ /dev/null @@ -1,316 +0,0 @@ -Defining New TIFF Tags -====================== - -Libtiff has built-in knowledge of all the standard TIFF tags, as -well as extensions. The following describes how to add knowledge of -new tags as builtins to libtiff, or how to application specific tags can -be used by applications without modifying libtiff. - -.. _TIFFFieldInfo_Definition: - -TIFFFieldInfo -------------- - -How libtiff manages specific tags is primarily controlled by the -definition for that tag value stored internally as a TIFFFieldInfo structure. -This structure looks like this: - -.. highlight:: c - -:: - - typedef struct { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count / TIFF_VARIABLE / TIFF_VARIABLE2 / TIFF_SPP */ - short field_writecount; /* write count / TIFF_VARIABLE / TIFF_VARIABLE2 */ - TIFFDataType field_type; /* type of associated data */ - unsigned short field_bit; /* bit in fieldsset bit vector */ - unsigned char field_oktochange; /* if true, can change while writing */ - unsigned char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ - } TIFFFieldInfo; - - -.. c:member:: ttag_t TIFFFieldInfo.field_tag - - The tag number. For instance 277 for the - SamplesPerPixel tag. Builtin tags will generally have a ``#define`` in - :file:`tiff.h` for each known tag. - -.. c:member:: short TIFFFieldInfo.field_readcount - - The number of values which should be read. - The special value :c:macro:`TIFF_VARIABLE` (-1) indicates that a variable number of - values may be read. The special value :c:macro:`TIFFTAG_SPP` (-2) indicates that there - should be one value for each sample as defined by :c:macro:`TIFFTAG_SAMPLESPERPIXEL`. - The special value :c:macro:`TIFF_VARIABLE2` (-3) is similar to :c:macro:`TIFF_VARIABLE` - but the required TIFFGetField() count value must be uint32_t* instead of uint16_t* as - for :c:macro:`TIFF_VARIABLE` (-1). - For ASCII fields with variable length, this field is :c:macro:`TIFF_VARIABLE`. - -.. c:member:: short TIFFFieldInfo.field_writecount - - The number of values which should be written. - Generally the same as field_readcount. A few built-in exceptions exist, but - I haven't analysed why they differ. - -.. c:member:: TIFFDataType TIFFFieldInfo.field_type - - Type of the field. One of :c:enumerator:`TIFF_BYTE`, :c:enumerator:`TIFF_ASCII`, - :c:enumerator:`TIFF_SHORT`, :c:enumerator:`TIFF_LONG`, - :c:enumerator:`TIFF_RATIONAL`, :c:enumerator:`TIFF_SBYTE`, - :c:enumerator:`TIFF_UNDEFINED`, :c:enumerator:`TIFF_SSHORT`, - :c:enumerator:`TIFF_SLONG`, :c:enumerator:`TIFF_SRATIONAL`, - :c:enumerator:`TIFF_FLOAT`, :c:enumerator:`TIFF_DOUBLE` or - :c:enumerator:`TIFF_IFD`. - And for BigTIFF :c:enumerator:`TIFF_LONG8`, - :c:enumerator:`TIFF_SLONG8` and :c:enumerator:`TIFF_IFD8`, - which are automatically reverted to 4 byte fields in - ClassicTIFF. - -.. c:member:: unsigned short TIFFFieldInfo.field_bit - - Built-in tags stored in special fields in the - TIFF structure have assigned field numbers to distinguish them (e.g. - :c:macro:`FIELD_SAMPLESPERPIXEL`). New tags should generally just use - :c:macro:`FIELD_CUSTOM` indicating they are stored in the generic tag list. - -.. c:member:: unsigned char TIFFFieldInfo.field_oktochange - - TRUE if it is OK to change this tag value - while an image is being written. FALSE for stuff that must be set once - and then left unchanged (like ImageWidth, or PhotometricInterpretation for - instance). - -.. c:member:: unsigned char TIFFFieldInfo.field_passcount - - If TRUE, then the count value must be passed - in :c:func:`TIFFSetField`, and :c:func:`TIFFGetField`, otherwise the count is not required. - This should generally be TRUE for non-ascii variable count tags unless - the count is implicit (such as with the colormap). - -.. c:member:: char * TIFFFieldInfo.field_name - - A name for the tag. Normally mixed case (studly caps) - like ``StripByteCounts``, and relatively short. - -Within :file:`tif_dirinfo.c` file, the built-in TIFF tags are defined with -:c:struct:`TIFFField` structure that has additional parameters defining the var_arg -interface of :c:func:`TIFFSetField` and :c:func:`TIFFGetField`. - -Various functions exist for getting the internal :c:struct:`TIFFFieldInfo` -definitions, including :c:func:`_TIFFFindFieldInfo`, and -:c:func:`_TIFFFindFieldInfoByName`. See -:file:`tif_dirinfo.c` for details. - -.. _Tag_Auto_registration: - -Default Tag Auto-registration ------------------------------ - -In libtiff 3.6.0 a new mechanism was introduced allowing libtiff to -read unrecognised tags automatically. When an unknown tags is encountered, -it is automatically internally defined with a default name and a type -derived from the tag value in the file. Applications only need to predefine -application specific tags if they need to be able to set them in a file, or -if particular calling conventions are desired for :c:func:`TIFFSetField` and -:c:func:`TIFFGetField`. - -When tags are autodefined like this the :c:member:`field_readcount` and -:c:member:`field_writecount` values are always :c:macro:`TIFF_VARIABLE2` (-3). The -:c:member:`field_passcount` is always TRUE, and the :c:member:`field_bit` is -:c:macro:`FIELD_CUSTOM`. The field name will be ``Tag %d`` where the ``%d`` -is the tag number. - -Thus, to read anonymous auto-registered tags use the following: - -:: - - uint32_t count; - void* value; //has to be a pointer to the expected value type. - TIFFGetField(tif, TIFFTAG_UNKNOWN_TO_LIBTIFF, &count, &value); - - -.. _Define_Application_Tags: - -Defining Application Tags -------------------------- - -For various reasons, it is common for applications to want to define -their own tags to store information outside the core TIFF specification. -This is done by calling :c:func:`TIFFMergeFieldInfo` with one or more -:c:struct:`TIFFFieldInfo`. - -The libgeotiff library provides geospatial information extensions within -a TIFF file. First, an array of :c:struct:`TIFFFieldInfo` is prepared with -information on the new tags: - -:: - - static const TIFFFieldInfo xtiffFieldInfo[] = { - - /* XXX Insert Your tags here */ - { TIFFTAG_GEOPIXELSCALE, -1,-1, TIFF_DOUBLE, FIELD_CUSTOM, - TRUE, TRUE, "GeoPixelScale" }, - { TIFFTAG_GEOTRANSMATRIX, -1,-1, TIFF_DOUBLE, FIELD_CUSTOM, - TRUE, TRUE, "GeoTransformationMatrix" }, - { TIFFTAG_GEOTIEPOINTS, -1,-1, TIFF_DOUBLE, FIELD_CUSTOM, - TRUE, TRUE, "GeoTiePoints" }, - { TIFFTAG_GEOKEYDIRECTORY, -1,-1, TIFF_SHORT, FIELD_CUSTOM, - TRUE, TRUE, "GeoKeyDirectory" }, - { TIFFTAG_GEODOUBLEPARAMS, -1,-1, TIFF_DOUBLE, FIELD_CUSTOM, - TRUE, TRUE, "GeoDoubleParams" }, - { TIFFTAG_GEOASCIIPARAMS, -1,-1, TIFF_ASCII, FIELD_CUSTOM, - TRUE, FALSE, "GeoASCIIParams" } - }; - -In order to define the tags, we call :c:func:`TIFFMergeFieldInfo` on the -desired TIFF handle with the list of :c:struct:`TIFFFieldInfo`. - -:: - - #define N(a) (sizeof (a) / sizeof (a[0])) - - /* Install the extended Tag field info */ - TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo)); - -The tags need to be defined for each TIFF file opened - and when reading -they should be defined before the tags of the file are read, yet a valid -:c:expr:`TIFF *` is needed to merge the tags against. In order to get them -registered at the appropriate part of the setup process, it is necessary -to register our merge function as an extender callback with libtiff. -This is done with :c:func:`TIFFSetTagExtender`. We also keep track of the -previous tag extender (if any) so that we can call it from our extender -allowing a chain of customizations to take effect. - -:: - - static TIFFExtendProc _ParentExtender = NULL; - - static - void _XTIFFInitialize(void) - { - static int first_time=1; - - if (! first_time) return; /* Been there. Done that. */ - first_time = 0; - - /* Grab the inherited method and install */ - _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory); - } - -The extender callback is looks like this. It merges in our new fields -and then calls the next extender if there is one in effect. - -:: - - static void - _XTIFFDefaultDirectory(TIFF *tif) - { - /* Install the extended Tag field info */ - TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo)); - - /* Since an XTIFF client module may have overridden - * the default directory method, we call it now to - * allow it to set up the rest of its own methods. - */ - - if (_ParentExtender) - (*_ParentExtender)(tif); - } - -The above approach ensures that our new definitions are used when reading -or writing any TIFF file. However, since on reading we already have -default definitions for tags, it is usually not critical to pre-define them. -If tag definitions are only required for writing custom tags, you can just -call :c:func:`TIFFMergeFieldInfo` before setting new tags. The whole extender -architecture can then be avoided. - -Adding New Builtin Tags ------------------------ - -A similar approach is taken to the above. However, the :c:struct:`TIFFFieldInfo` -should be added to the :c:expr:`tiffFieldInfo[]` list in :file:`tif_dirinfo.c`. -Ensure that new tags are added in sorted order by the tag number. - -Normally new built-in tags should be defined with :c:macro:`FIELD_CUSTOM`; however, if -it is desirable for the tag value to have it's own field in the :c:struct:`TIFFDirectory` -structure, then you will need to ``#define`` a new :c:macro:`FIELD_` value for it, and -add appropriate handling as follows: - -#. Define the tag in :file:`tiff.h`. -#. Add a field to the directory structure in :file:`tif_dir.h` - and define a ``FIELD_*`` bit (also update the definition of - :c:macro:`FIELD_CODEC` to reflect your addition). -#. Add an entry in the :c:struct:`TIFFFieldInfo` array defined at the top of - :file:`tif_dirinfo.c`. - - .. note:: - - Note that you must keep this array sorted by tag - number and that the widest variant entry for a tag should come - first (e.g. :c:macro:`LONG` before :c:macro:`SHORT`). -#. Add entries in :c:func:`_TIFFVSetField` and :c:func:`_TIFFVGetField` - for the new tag. -#. (*optional*) If the value associated with the tag is not a scalar value - (e.g. the array for ``TransferFunction``) and requires - special processing, - then add the appropriate code to :c:func:`TIFFReadDirectory` and - :c:func:`TIFFWriteDirectory`. You're best off finding a similar tag and - cribbing code. -#. Add support to :c:func:`TIFFPrintDirectory` in :file:`tif_print.c` - to print the tag's value. - -If you want to maintain portability, beware of making assumptions -about data types. Use the typedefs (:c:type:`uint16_t`, etc. when dealing with -data on disk and ``t*_t`` when stuff is in memory) and be careful about -passing items through printf or similar vararg interfaces. - -Adding New Codec-private Tags ------------------------------ - -To add tags that are meaningful *only when a particular compression -algorithm is used* follow these steps: - -#. Define the tag in :file:`tiff.h`. -#. Allocate storage for the tag values in the private state block of - the codec. -#. Insure the state block is created when the codec is initialized. -#. At :c:func:`TIFFInitfoo` time override the method pointers in the - :c:struct:`TIFF` structure for getting, setting and printing tag values. - For example, - - :: - - sp->vgetparent = tif->tif_vgetfield; - tif->tif_vgetfield = fooVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_vsetfield; - tif->tif_vsetfield = fooVSetField; /* hook for codec tags */ - tif->tif_printdir = fooPrintDir; /* hook for codec tags */ - - (Actually you may decide not to override the - :c:member:`tif_printdir` method, but rather just specify it). -#. Create a private :c:struct:`TIFFFieldInfo` array for your tags and - merge them into the core tags at initialization time using - :c:func:`_TIFFMergeFieldInfo`; e.g. - - :: - - _TIFFMergeFieldInfo(tif, fooFieldInfo, N(fooFieldInfo)); - - (where :c:macro:`N` is a macro used liberaly throughout the distributed code). - -#. Fill in the get and set routines. Be sure to call the parent method - for tags that you are not handled directly. Also be sure to set the - ``FIELD_*`` bits for tags that are to be written to the file. Note that - you can create "pseudo-tags" by defining tags that are processed - exclusively in the get/set routines and never written to file (see - the handling of :c:macro:`TIFFTAG_FAXMODE` in :file:`tif_fax3.c` - for an example of this). -#. Fill in the print routine, if appropriate. - -Note that space has been allocated in the ``FIELD_*`` bit space for -codec-private tags. Define your bits as ``FIELD_CODEC+`` to -keep them away from the core tags. If you need more tags than there -is room for, just increase :c:macro:`FIELD_SETLONGS` at the top of -:file:`tiffiop.h`. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/conf.py b/thirdparty/SDL2_image/external/libtiff/doc/conf.py deleted file mode 100644 index dfa46eb49..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/conf.py +++ /dev/null @@ -1,177 +0,0 @@ -# -*- coding: utf-8 -*- -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - -# Substitutions from external build system. -srcdir = None -builddir = None -ext_source_branch = None -ext_source_user = None - - -# -- Project information ----------------------------------------------------- - -project = 'LibTIFF' -copyright = '1988-2022, LibTIFF contributors' -author = 'LibTIFF contributors' - -# The full version, including alpha/beta/rc tags -release = 'UNDEFINED' -version = 'UNDEFINED' - - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.extlinks' -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = [] - -extlinks = { - # GitLab links - 'issue' : ('https://gitlab.com/libtiff/libtiff/-/issues/%s', 'issue #%s'), - 'merge' : ('https://gitlab.com/libtiff/libtiff/-/merge_requests/%s', 'merge request #%s'), - 'commit' : ('https://gitlab.com/libtiff/libtiff/-/commit/%s', 'commit %s'), - 'branch' : ('https://gitlab.com/libtiff/libtiff/-/tree/%s', 'branch %s'), - 'tag' : ('https://gitlab.com/libtiff/libtiff/-/tags/%s', 'tag %s'), - - # Old Bugzilla - 'bugzilla' : ('http://bugzilla.maptools.org/show_bug.cgi?id=%s', 'MapTools bugzilla #%s'), - 'bugzilla-rs' : ('http://bugzilla.remotesensing.org/show_bug.cgi?id=%s', 'Remote Sensing bugzilla #%s [no longer available]'), - - # GDAL - 'gdal-trac' : ('http://trac.osgeo.org/gdal/ticket/%s', 'GDAL trac #%s'), - 'oss-fuzz' : ('https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=%s', 'OSS-Fuzz #%s'), - - # Security - 'cve' : ('https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s', 'CVE-%s'), -} - - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'sphinxdoc' - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] - -html_extra_path = [] - -# -- Options for manual page output -------------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ('functions/libtiff', 'libtiff', 'introduction to libtiff, a library for reading and writing TIFF files', author, '3tiff'), - - ('tools/fax2ps', 'fax2ps', 'convert a TIFF facsimile to compressed PostScriptâ„¢', author, 1), - ('tools/fax2tiff', 'fax2tiff', 'create a TIFF Class F fax file from raw fax data', author, 1), - ('tools/pal2rgb', 'pal2rgb', 'convert a palette color TIFF image to a full color image', author, 1), - ('tools/ppm2tiff', 'ppm2tiff', 'create a TIFF file from PPM, PGM and PBM image files', author, 1), - ('tools/raw2tiff', 'raw2tiff', 'create a TIFF file from a raw data file', author, 1), - ('tools/rgb2ycbcr', 'rgb2ycbcr', 'convert non-YCbCr TIFF images to a YCbCr TIFF image', author, 1), - ('tools/thumbnail', 'thumbnail', 'create a TIFF file with thumbnail images', author, 1), - ('tools/tiff2bw', 'tiff2bw', 'convert a color TIFF image to greyscale', author, 1), - ('tools/tiff2pdf', 'tiff2pdf', 'convert a TIFF image to a PDF document', author, 1), - ('tools/tiff2ps', 'tiff2ps', 'convert TIFF image to PostScriptâ„¢', author, 1), - ('tools/tiff2rgba', 'tiff2rgba', 'convert a TIFF image to RGBA color space', author, 1), - ('tools/tiffcmp', 'tiffcmp', 'compare two TIFF files', author, 1), - ('tools/tiffcp', 'tiffcp', 'copy (and possibly convert) a TIFF file', author, 1), - ('tools/tiffcrop', 'tiffcrop', 'select, copy, crop, convert, extract, and/or process one or more TIFF files', author, 1), - ('tools/tiffdither', 'tiffdither', 'convert a greyscale TIFF image to bilevel using dithering', author, 1), - ('tools/tiffdump', 'tiffdump', 'print verbatim information about TIFF files', author, 1), - ('tools/tiffgt', 'tiffgt', 'display an image stored in a TIFF file (Silicon Graphics version)', author, 1), - ('tools/tiffinfo', 'tiffinfo', 'print information about TIFF files', author, 1), - ('tools/tiffmedian', 'tiffmedian', 'apply the median cut algorithm to data in a TIFF file', author, 1), - ('tools/tiffset', 'tiffset', 'set or unset a field in a TIFF header', author, 1), - ('tools/tiffsplit', 'tiffsplit', 'split a multi-image TIFF into single-image TIFF files', author, 1), - - ('functions/_TIFFauxiliary', '_TIFFauxiliary', 'auxiliary functions', author, '3tiff'), - ('functions/_TIFFRewriteField', '_TIFFRewriteField', 'rewrite a field in the directory on disk', author, '3tiff'), - ('functions/TIFFAccessTagMethods', 'TIFFAccessTagMethods', 'provides read/write access to the TIFFTagMethods', author, '3tiff'), - ('functions/TIFFbuffer', 'TIFFbuffer', 'I/O buffering control routines', author, '3tiff'), - ('functions/TIFFClientInfo', 'TIFFClientInfo', 'provides a method to hand over user defined data from one routine to another', author, '3tiff'), - ('functions/TIFFClose', 'TIFFClose', 'close a previously opened TIFF file', author, '3tiff'), - ('functions/TIFFcodec', 'TIFFcodec', 'codec-related utility routines', author, '3tiff'), - ('functions/TIFFcolor', 'TIFFcolor', 'color conversion routines', author, '3tiff'), - ('functions/TIFFCreateDirectory', 'TIFFCreateDirectory', 'routines to create a directory and retrieve information about directories', author, '3tiff'), - ('functions/TIFFCustomDirectory', 'TIFFCustomDirectory', 'routines to create a custom directory', author, '3tiff'), - ('functions/TIFFCustomTagList', 'TIFFCustomTagList', 'returns information about the custom tag list', author, '3tiff'), - ('functions/TIFFDataWidth', 'TIFFDataWidth', 'get the size of TIFF data types', author, '3tiff'), - ('functions/TIFFDeferStrileArrayWriting', 'TIFFDeferStrileArrayWriting', 'defer strile array writing', author, '3tiff'), - ('functions/TIFFError', 'TIFFError', 'library error handling interface', author, '3tiff'), - ('functions/TIFFFieldDataType', 'TIFFFieldDataType', 'get TIFF data type from field information', author, '3tiff'), - ('functions/TIFFFieldName', 'TIFFFieldName', 'get TIFF field name from field information', author, '3tiff'), - ('functions/TIFFFieldPassCount', 'TIFFFieldPassCount', 'get whether to pass a count to TIFFGetField/TIFFSetField', author, '3tiff'), - ('functions/TIFFFieldQuery', 'TIFFFieldQuery', 'routines to query TIFF field information', author, '3tiff'), - ('functions/TIFFFieldReadCount', 'TIFFFieldReadCount', 'get number of values to be read from field', author, '3tiff'), - ('functions/TIFFFieldTag', 'TIFFFieldTag', 'get TIFF field tag value from field information', author, '3tiff'), - ('functions/TIFFFieldWriteCount', 'TIFFFieldWriteCount', 'get number of values to be written to field', author, '3tiff'), - ('functions/TIFFFlush', 'TIFFFlush', 'flush pending writes to an open TIFF file', author, '3tiff'), - ('functions/TIFFGetField', 'TIFFGetField', 'get the value(s) of a tag in an open TIFF file', author, '3tiff'), - ('functions/TIFFmemory', 'TIFFmemory', 'memory management-related functions for use with TIFF files', author, '3tiff'), - ('functions/TIFFMergeFieldInfo', 'TIFFMergeFieldInfo', 'add application-defined TIFF tags to the list of known libtiff tags', author, '3tiff'), - ('functions/TIFFOpen', 'TIFFOpen', 'open a TIFF file for reading or writing', author, '3tiff'), - ('functions/TIFFPrintDirectory', 'TIFFPrintDirectory', 'print a description of a TIFF directory', author, '3tiff'), - ('functions/TIFFProcFunctions', 'TIFFProcFunctions', 'set TIFF processing functions', author, '3tiff'), - ('functions/TIFFquery', 'TIFFquery', 'query routines', author, '3tiff'), - ('functions/TIFFReadDirectory', 'TIFFReadDirectory', 'get the contents of the next directory in an open TIFF file', author, '3tiff'), - ('functions/TIFFReadEncodedStrip', 'TIFFReadEncodedStrip', 'read and decode a strip of data from an open TIFF file', author, '3tiff'), - ('functions/TIFFReadEncodedTile', 'TIFFReadEncodedTile', 'read and decode a tile of data from an open TIFF file', author, '3tiff'), - ('functions/TIFFReadFromUserBuffer', 'TIFFReadFromUserBuffer', 'decode data using an user defined buffer', author, '3tiff'), - ('functions/TIFFReadRawStrip', 'TIFFReadRawStrip', 'return the undecoded contents of a strip of data from an open TIFF file', author, '3tiff'), - ('functions/TIFFReadRawTile', 'TIFFReadRawTile', 'return an undecoded tile of data from an open TIFF file', author, '3tiff'), - ('functions/TIFFReadRGBAImage', 'TIFFReadRGBAImage', 'read and decode an image into a fixed-format raster', author, '3tiff'), - ('functions/TIFFReadRGBAStrip', 'TIFFReadRGBAStrip', 'read and decode an image strip into a fixed-format raster', author, '3tiff'), - ('functions/TIFFReadRGBATile', 'TIFFReadRGBATile', 'read and decode an image tile into a fixed-format raster', author, '3tiff'), - ('functions/TIFFReadScanline', 'TIFFReadScanline', 'read and decode a scanline of data from an open TIFF file', author, '3tiff'), - ('functions/TIFFReadTile', 'TIFFReadTile', 'read and decode a tile of data from an open TIFF file', author, '3tiff'), - ('functions/TIFFRGBAImage', 'TIFFRGBAImage', 'read and decode an image into a raster', author, '3tiff'), - ('functions/TIFFSetDirectory', 'TIFFSetDirectory', 'set the current directory for an open TIFF file', author, '3tiff'), - ('functions/TIFFSetField', 'TIFFSetField', 'set the value(s) of a tag in a TIFF file open for writing', author, '3tiff'), - ('functions/TIFFSetTagExtender', 'TIFFSetTagExtender', 'register the merge function for user defined tags as an extender callback with libtiff', author, '3tiff'), - ('functions/TIFFsize', 'TIFFsize', 'return the size of various items associated with an open TIFF file', author, '3tiff'), - ('functions/TIFFStrileQuery', 'TIFFStrileQuery', 'get strile byte count and offset', author, '3tiff'), - ('functions/TIFFstrip', 'TIFFstrip', 'strip-related utility routines', author, '3tiff'), - ('functions/TIFFswab', 'TIFFswab', 'byte- and bit-swapping routines', author, '3tiff'), - ('functions/TIFFtile', 'TIFFtile', 'tile-related utility routines', author, '3tiff'), - ('functions/TIFFWarning', 'TIFFWarning', 'library warning interface', author, '3tiff'), - ('functions/TIFFWriteDirectory', 'TIFFWriteDirectory', 'write the current directory in an open TIFF file', author, '3tiff'), - ('functions/TIFFWriteEncodedStrip', 'TIFFWriteEncodedStrip', 'compress and write a strip of data to an open TIFF file', author, '3tiff'), - ('functions/TIFFWriteEncodedTile', 'TIFFWriteEncodedTile', 'compress and write a tile of data to an open TIFF file', author, '3tiff'), - ('functions/TIFFWriteRawStrip', 'TIFFWriteRawStrip', 'write a strip of raw data to an open TIFF file', author, '3tiff'), - ('functions/TIFFWriteRawTile', 'TIFFWriteRawTile', 'write a tile of raw data to an open TIFF file', author, '3tiff'), - ('functions/TIFFWriteScanline', 'TIFFWriteScanline', 'write a scanline to an open TIFF file', author, '3tiff'), - ('functions/TIFFWriteTile', 'TIFFWriteTile', 'encode and write a tile of data to an open TIFF file', author, '3tiff'), -] - -# If true, show URL addresses after external links. -man_show_urls = True diff --git a/thirdparty/SDL2_image/external/libtiff/doc/contrib.rst b/thirdparty/SDL2_image/external/libtiff/doc/contrib.rst deleted file mode 100644 index 0b94970aa..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/contrib.rst +++ /dev/null @@ -1,88 +0,0 @@ -Contributed TIFF Software -========================= - -.. image:: images/smallliz.jpg - :width: 108 - :alt: smallliz - -The :file:`contrib` directory has contributed software that -uses the TIFF library or which is associated with the library -(typically glue and guidance for ports to non-UNIX platforms, or tools that -aren't directly TIFF related). - -.. list-table:: Contributed software - :widths: 5 20 - :header-rows: 1 - - * - Location - - Description - - * - :file:`contrib/dbs` - - various tools from Dan & Chris Sears, including a simple X-based viewer - - * - :file:`contrib/ras` - - two programs by Patrick Naughton for converting - between Sun rasterfile format and TIFF (these - require :file:`libpixrect.a`, as opposed to the one in - tools that doesn't) - - * - :file:`contrib/mac-mpw` - - :file:`contrib/mac-cw` - - scripts and files from Niles Ritter for building - the library and tools under Macintosh/MPW C and - code warrior. - - * - :file:`contrib/acorn` - - scripts and files from Peter Greenham for building - the library and tools on an Acorn RISC OS system. - - * - :file:`contrib/win32` - - scripts and files from Scott Wagner for building - the library under Windows NT and Windows 95. (The makefile.vc in the - libtiff/libtiff directory may be sufficient for most users.) - - * - :file:`contrib/win_dib` - - two separate implementations of TIFF to DIB code suitable for any Win32 - platform. Contributed by Mark James, and Philippe Tenenhaus. - - * - :file:`contrib/ojpeg` - - Patch for IJG JPEG library related to support for some Old JPEG in TIFF files. - Contributed by Scott Marovich. - - * - :file:`contrib/dosdjgpp` - - scripts and files from Alexander Lehmann for building - the library under MSDOS with the DJGPP v2 compiler. - - * - :file:`contrib/tags` - - scripts and files from Niles Ritter for adding private - tag support at runtime, without changing libtiff. - - * - :file:`contrib/mfs` - - code from Mike Johnson to read+write images in memory - without modifying the library - - * - :file:`contrib/pds` - - various routines from Conrad Poelman; a TIFF image iterator and - code to support "private sub-directories" - - * - :file:`contrib/iptcutil` - - A utility by `Bill Radcliffe `_ to - convert an extracted IPTC Newsphoto caption from a binary blob to - ASCII text, and vice versa. IPTC binary blobs can be extracted from - images via the `ImageMagick `_ convert(1) - utility. - - * - :file:`contrib/addtiffo` - - A utility (and supporting subroutine) for building - one or more reduce resolution - overviews to an existing TIFF file. Supplied by - `Frank Warmerdam `_. - - * - :file:`contrib/stream` - - A class (TiffStream) for accessing TIFF files through a C++ stream - interface. Supplied by `Avi Bleiweiss `_. - - -Questions regarding these packages are usually best directed toward -their authors. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions.rst deleted file mode 100644 index 8b721e331..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions.rst +++ /dev/null @@ -1,66 +0,0 @@ -TIFF Functions Overview -======================= - -.. toctree:: - :maxdepth: 1 - :titlesonly: - - functions/libtiff - functions/TIFFAccessTagMethods - functions/TIFFbuffer - functions/TIFFClientInfo - functions/TIFFClose - functions/TIFFcodec - functions/TIFFcolor - functions/TIFFCreateDirectory - functions/TIFFCustomDirectory - functions/TIFFCustomTagList - functions/TIFFDataWidth - functions/TIFFDeferStrileArrayWriting - functions/TIFFError - functions/TIFFFieldDataType - functions/TIFFFieldName - functions/TIFFFieldPassCount - functions/TIFFFieldQuery - functions/TIFFFieldReadCount - functions/TIFFFieldTag - functions/TIFFFieldWriteCount - functions/TIFFFlush - functions/TIFFGetField - functions/TIFFmemory - functions/TIFFMergeFieldInfo - functions/TIFFOpen - functions/TIFFOpenOptions - functions/TIFFPrintDirectory - functions/TIFFProcFunctions - functions/TIFFquery - functions/TIFFReadDirectory - functions/TIFFReadEncodedStrip - functions/TIFFReadEncodedTile - functions/TIFFReadFromUserBuffer - functions/TIFFReadRawStrip - functions/TIFFReadRawTile - functions/TIFFReadRGBAImage - functions/TIFFReadRGBAStrip - functions/TIFFReadRGBATile - functions/TIFFReadScanline - functions/TIFFReadTile - functions/TIFFRGBAImage - functions/TIFFSetDirectory - functions/TIFFSetField - functions/TIFFSetTagExtender - functions/TIFFsize - functions/TIFFStrileQuery - functions/TIFFstrip - functions/TIFFswab - functions/TIFFtile - functions/TIFFWarning - functions/TIFFWriteDirectory - functions/TIFFWriteEncodedStrip - functions/TIFFWriteEncodedTile - functions/TIFFWriteRawStrip - functions/TIFFWriteRawTile - functions/TIFFWriteScanline - functions/TIFFWriteTile - functions/_TIFFauxiliary - functions/_TIFFRewriteField diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFAccessTagMethods.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFAccessTagMethods.rst deleted file mode 100644 index c9a53dc05..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFAccessTagMethods.rst +++ /dev/null @@ -1,30 +0,0 @@ -TIFFAccessTagMethods -==================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: TIFFTagMethods *TIFFAccessTagMethods(TIFF* tif) - -Description ------------ - -This provides read/write access to the TIFFTagMethods within the TIFF -structure to application code without giving access to the private TIFF -structure. - -Diagnostics ------------ - -None - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFClientInfo.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFClientInfo.rst deleted file mode 100644 index 7576d225e..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFClientInfo.rst +++ /dev/null @@ -1,40 +0,0 @@ -TIFFClientInfo -============== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: void *TIFFGetClientInfo(TIFF* tif, const char *name) - -.. c:function:: void TIFFSetClientInfo(TIFF* tif, void *data, const char *name) - -Description ------------ - -.. TODO: Check explanation of clientinfo linked list intention and usage. - -The *clientinfo* linked list provides a method to hand over user defined -data from one routine to another via the internal ``tif`` storage of the -``libtiff`` library. - -:c:func:`TIFFGetClientInfo` returns a pointer to the data of the named entry -in the clientinfo-list. If the *name* is not found ``NULL`` is returned. - -:c:func:`TIFFSetClientInfo` adds or replaces an entry in the clientinfo-list -with the *name* and the pointer to the *data* provided by the caller. - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFClose.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFClose.rst deleted file mode 100644 index cc9f88863..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFClose.rst +++ /dev/null @@ -1,42 +0,0 @@ -TIFFClose -========== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: void TIFFClose(TIFF* tif) - -.. c:function:: void TIFFCleanup(TIFF* tif) - -Description ------------ - -:c:func:`TIFFClose` closes a file that was previously opened with -:c:func:`TIFFOpen`. Any buffered data are flushed to the file, including -the contents of the current directory (if modified); and all resources -are reclaimed. :c:func:`TIFFClose` calls :c:func:`TIFFCleanup` and then -the associated function to close the file handle. - -:c:func:`TIFFCleanup` is an auxiliary function to free the TIFF structure. -The given structure will be completely freed, so you should save opened file -handle and pointer to the close procedure in external variables before -calling :c:func:`TIFFCleanup`, if you will need these ones to close the file. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. -Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFError` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCreateDirectory.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCreateDirectory.rst deleted file mode 100644 index 7c285c056..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCreateDirectory.rst +++ /dev/null @@ -1,79 +0,0 @@ -TIFFCreateDirectory -=================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFCreateDirectory(TIFF* tif) - -.. c:function:: int TIFFFreeDirectory(TIFF* tif) - -.. c:function:: int TIFFUnlinkDirectory(TIFF* tif, tdir_t dirn) - -Description ------------ - -The following routines create or release a directory. - -:c:func:`TIFFCreateDirectory` setup for a directory in a open TIFF file. -The newly created directory will not exist on the file till -:c:func:`TIFFWriteDirectory`, :c:func:`TIFFCheckpointDirectory`, -:c:func:`TIFFFlush` or :c:func:`TIFFClose` is called. -:c:func:`TIFFWriteDirectory` also creates a new directory, -frees the ``*tif`` structure and sets up a new one. - -:c:func:`TIFFFreeDirectory` releases allocated storage associated with a -directory, especially custom-fields. -However, the main part of the directory is not touched. Routine -:c:func:`TIFFCleanup` calls :c:func:`TIFFFreeDirectory` to release -the directory part of the `tif` structure. - -:c:func:`TIFFUnlinkDirectory` unlink the specified directory from the -directory chain. -The parameter *dirn* specifies the subfile/directory -as an integer number, with the first directory numbered one (1). -This is different to :c:func:`TIFFSetDirectory` or :c:func:`TIFFCurrentDirectory` where the first -directory starts with zero (0). - -Directory query functions :c:func:`TIFFCurrentDirectory`, -:c:func:`TIFFCurrentDirOffset`, :c:func:`TIFFLastDirectory` and -:c:func:`TIFFNumberOfDirectories` retrieve information about directories -in an open TIFF file. Be aware that until a directory is -not written to file AND read back, the query functions won't retrieve -the correct information! - -Notes ------ - -Be aware: - -- that until a directory is not written to file AND read back, the - query functions won't retrieve the correct information! -- that the newly created directory will not exist on the file till - :c:func:`TIFFWriteDirectory`, :c:func:`TIFFCheckpointDirectory`, - :c:func:`TIFFFlush` or :c:func:`TIFFClose` has been called. -- that :c:func:`TIFFCreateDirectory` and :c:func:`TIFFWriteDirectory` - create a new directory, free the ``*tif`` structure and set up a new one. -- that unlike :c:func:`TIFFWriteDirectory`, :c:func:`TIFFCheckpointDirectory` - does not free up the directory data structures in memory. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. -Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFCustomDirectory` (3tiff), -:doc:`TIFFquery` (3tiff), -:doc:`TIFFSetDirectory` (3tiff), -:doc:`TIFFWriteDirectory` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCustomDirectory.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCustomDirectory.rst deleted file mode 100644 index 2881a20fc..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCustomDirectory.rst +++ /dev/null @@ -1,207 +0,0 @@ -TIFFCustomDirectory -=================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray) - -.. c:function:: int TIFFCreateEXIFDirectory(TIFF* tif) - -.. c:function:: int TIFFCreateGPSDirectory(TIFF* tif) - -.. c:function:: int TIFFWriteCustomDirectory(TIFF* tif, uint64 *pdiroff) - -.. c:function:: int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray) - -.. c:function:: int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff) - -.. c:function:: int TIFFReadGPSDirectory(TIFF* tif, toff_t diroff) - -.. c:function:: const TIFFFieldArray* _TIFFGetExifFields(void) - -.. c:function:: const TIFFFieldArray* _TIFFGetGpsFields(void) - -Description ------------ - -The following routines create a custom directory and retrieve information -about directories in an open TIFF file. - -:c:func:`TIFFCreateCustomDirectory`, :c:func:`TIFFCreateEXIFDirectory`, -:c:func:`TIFFCreateGPSDirectory` will setup a custom directory or one -of the predefined EXIF or GPS directories and set the context of the -TIFF-handle ``tif`` to that custom directory for functions -like :c:func:`TIFFSetField`. - -:c:func:`TIFFWriteCustomDirectory` will write the contents of the -current custom directory to the file and return the offset to that -directory in :c:var:`pdiroff`. That offset has to be written to the main-IFD: - -.. highlight:: c - -:: - - /* Go back to the first directory, and add the EXIFIFD pointer. */ - TIFFSetDirectory(tif, 0); - TIFFSetField(tif, TIFFTAG_EXIFIFD, pdiroff); - - -:c:func:`TIFFReadCustomDirectory` will read the custom directory from the -arbitrary offset into the :c:var:`infoarray` and sets the context of the -TIFF-handle :c:var:`tif` to that custom directory for functions like -:c:func:`TIFFReadField`. The :c:type:`TIFFFieldArray` :c:var:`infoarray` -has to be according the layout of the custom directory. For the predefined -EXIF and GPS directories, the relevant :c:type:`TIFFFieldArray` definitions -are hidden within the functions :c:func:`TIFFReadEXIFDirectory` and -:c:func:`TIFFReadGPSDirectory` The code is very similar to :c:func:`TIFFReadDirectory`. -The offset to the custom directory diroff has to be read from the -relative TIFF tag first. - -:c:func:`_TIFFGetExifFields` and :c:func:`_TIFFGetGpsFields` will -return a pointer to the ``libtiff`` internal definition list of the -EXIF and GPS tags, respectively. - -Notes ------ - -Be aware - -- that until a directory is not written to file AND read back, the query - functions won't retrieve the correct information! -- that the newly created directory will not exist on the file till - :c:func:`TIFFWriteDirectory`, :c:func:`TIFFCheckpointDirectory`, - :c:func:`TIFFFlush` or :c:func:`TIFFClose` has been called. -- that :c:func:`TIFFCreateDirectory` and :c:func:`TIFFWriteDirectory` - create a new directory, free the ``*tif`` structure and set up a new one. -- that unlike :c:func:`TIFFWriteDirectory`, :c:func:`TIFFCheckpointDirectory` - does not free up the directory data structures in memory. -- that LibTiff does not support custom directory chains - (NextIFD pointing to another IFD). - NextIFD of custom directories is always set to zero - and should be zero when reading. - -Unfortunately to create or read custom directories with predefined fields -it is necessary to include the private tif_dir.h. However, for EXIF and -GPS directories, which have a predefined schema within ``libtiff``, this -is not necessary. There are some test programmes that briefly demonstrate -the creation and reading of EXIF, GPS and custom directories. -See test/custom_dir.c and test/custom_dir_EXIF_231.c - -Hints and detailed instructions -------------------------------- - -Writing TIFF files with more than one directory (IFD) is not easy because -some side effects need to be known. - -The main point here is that there can only be one ``tif`` structure in -the main memory for a file, which can only hold the tags of one directory -at a time. It is useless to work with two different tiffOut1, tiffOut2 -pointers, because there is only ONE TIFF object (TIFF directory) within -the ``libtiff``. If you want to address a second directory in the file, -the tags of the current directory must first be saved in the file, -otherwise they will be lost (overwritten or mixed). Then the ``tif`` -structure in the main memory must be tidied up, otherwise the old tags -will beincluded in the new directory. -This can be done either by creating a new, empty ``tif`` structure or by -reading in an directory previously saved in the file. - -A sequence to handle a second (or third) TIFF directory - in this case -the GPS IFD - is as follows: - -1) Create TIFF file -2) Complete the "normal" metadata -3) Set the tag for the custom directory with a “dummy†value in order to - get the tag reserved. The final value will be inserted lateron. This - prevents the main directory from being written to the file again at an - additional area, leaving the first memory area unused: - -.. highlight:: c - -:: - - TIFFSetField(tiffOut, TIFFTAG_GPSIFD, dir_offset); - -4) Save current TIFF-directory to file. Otherwise, it will be lost. - Remember also the number of the current directory: - -.. highlight:: c - -:: - - TIFFWriteDirectory(tiffOut); - dirNum = TIFFCurrentDirectory(tiffOut); - -5) Create the second TIFF-directory (e.g. custom directory) and set its - fields. The TIFFFieldArray infoarray has to be specified beforehand - somewhere in your private include files. - An example is given for the EXIF directory in tif_dirinfo.c - -.. highlight:: c - -:: - - TIFFCreateCustomDirectory(tiffOut, infoarray); /* for a real custom directory */ - /* or alternatively, use GPS or EXIF with pre-defined TIFFFieldArray IFD field structure */ - TIFFCreateGPSDirectory(tiffOut); - TIFFSetField(tiffOut, GPSTAG_VERSIONID, gpsVersion); /* set fields of the custom directory */ - -Be aware that every :c:func:`TIFFCreateDirectory` or :c:func:`TIFFWriteDirectory` -apparently frees the ``*tif`` structure and sets up a new one! - -6) Write custom directory to file. The offset to that directory in the file - is returned in :c:var:`dir_offset`. - -.. highlight:: c - -:: - - TIFFWriteCustomDirectory(tiffOut, &dir_offset); - -7) Reload the first directory (i.e. the original TIFF directory). - Apparently, this reads the data back from file. - -.. highlight:: c - -:: - - TIFFSetDirectory(tiffOut, dirNum); - -8) Set the correct offset value of the custom directory IFD tag and save - that changes to file. - -.. highlight:: c - -:: - - TIFFSetField(tiffOut, TIFFTAG_GPSIFD, dir_offset); - TIFFWriteDirectory(tiffOut); - -RETURN VALUES -------------- - -1 is returned when the contents are successfully written to the file. -Otherwise, 0 is returned if an error was encountered when writing the -directory contents. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. -Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFCreateDirectory` (3tiff), -:doc:`TIFFquery` (3tiff), -:doc:`TIFFSetDirectory` (3tiff), -:doc:`TIFFWriteDirectory` (3tiff) - diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCustomTagList.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCustomTagList.rst deleted file mode 100644 index 4b18c7b0f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFCustomTagList.rst +++ /dev/null @@ -1,47 +0,0 @@ -TIFFCustomTagList -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFGetTagListCount(TIFF* tif) - -.. c:function:: uint32_t TIFFGetTagListEntry(TIFF* tif, int tag_index) - -Description ------------ - -:c:func:`TIFFGetTagListCount` returns the number of entries in the -custom tag list. - -:c:func:`TIFFGetTagListEntry` returns the tag number of the (n.th - 1) -entry within the custom tag list. -If the :c:var:`tag_index` is larger or equal to the number of entries -in the tag list 0xFFFFFFFF `(=(uint32_t(-1))` is returned. - -Note ----- - -The known tags to ``libtiff`` are define as 'named' tags and a lot of them -as *custom* tags. The custom tag definitions are handled in an internal -custom tag list. This list can also be extended by adding tag definitions -to that list, so that ``libtiff`` is aware of those tags. -See :ref:`Define_Application_Tags` - -Diagnostics ------------ - -none - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFError` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFDataWidth.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFDataWidth.rst deleted file mode 100644 index 8adaef6ba..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFDataWidth.rst +++ /dev/null @@ -1,47 +0,0 @@ -TIFFDataWidth -============= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFDataWidth(TIFFDataType type) - -Description ------------ - -:c:func:`TIFFDataWidth` returns the size of *type* within TIFF file in bytes. -Currently following data types are supported: - -* :c:macro:`TIFF_BYTE` -* :c:macro:`TIFF_ASCII` -* :c:macro:`TIFF_SBYTE` -* :c:macro:`TIFF_UNDEFINED` -* :c:macro:`TIFF_SHORT` -* :c:macro:`TIFF_SSHORT` -* :c:macro:`TIFF_LONG` -* :c:macro:`TIFF_SLONG` -* :c:macro:`TIFF_FLOAT` -* :c:macro:`TIFF_IFD` -* :c:macro:`TIFF_RATIONAL` -* :c:macro:`TIFF_SRATIONAL` -* :c:macro:`TIFF_DOUBLE` -* :c:macro:`TIFF_LONG8` -* :c:macro:`TIFF_SLONG8` -* :c:macro:`TIFF_IFD8` - -Return values -------------- - -:c:func:`TIFFDataWidth` returns a number of bytes occupied by the item -of given type within the TIFF file. 0 returned when unknown data type supplied. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFDeferStrileArrayWriting.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFDeferStrileArrayWriting.rst deleted file mode 100644 index 60ee74692..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFDeferStrileArrayWriting.rst +++ /dev/null @@ -1,67 +0,0 @@ -TIFFDeferStrileArrayWriting -=========================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFDeferStrileArrayWriting(TIFF* tif) - -.. c:function:: int TIFFForceStrileArrayWriting(TIFF* tif) - -Description ------------ - -:c:func:`TIFFDeferStrileArrayWriting` is an advanced writing function -that must be used in a particular sequence, and generally together -with :c:func:`TIFFForceStrileArrayWriting`, to achieve its intended -effect. Their aim is to control when and where the -``StripOffsets`` / ``StripByteCounts`` or ``TileOffsets`` / ``TileByteCounts`` -arrays are written into the file. - -The purpose of this is to generate 'cloud-optimized geotiff' files where -the first KB of the file only contain the IFD entries without the potentially -large strile arrays. Those are written afterwards. - -More precisely, when :c:func:`TIFFWriteCheck` is called, the tag entries for -those arrays will be written with type = count = offset = 0 as a temporary value. - -Its effect is only valid for the current directory, and before -:c:func:`TIFFWriteDirectory` is first called, and will be reset -when changing directory. - -The typical sequence of calls is: - -.. highlight:: c - -:: - - TIFFOpen() - /* or TIFFCreateDirectory(tif) */ - /* Set fields with calls to TIFFSetField(tif, ...) */ - TIFFDeferStrileArrayWriting(tif) - TIFFWriteCheck(tif, ...) - TIFFWriteDirectory(tif) - /* ... potentially create other directories and come back to the above directory */ - TIFFForceStrileArrayWriting(tif) /* emit the arrays at the end of file */ - -Returns -------- - -1 in case of success, 0 otherwise. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. -Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFError.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFError.rst deleted file mode 100644 index 99924adc7..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFError.rst +++ /dev/null @@ -1,102 +0,0 @@ -TIFFError -========= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - #include - -.. c:function:: void TIFFError(const char * module, const char * fmt, ...) - -.. c:function:: void TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...) - -.. c:function:: void TIFFErrorExtR(TIFF *tif, const char* module, const char* fmt, ...) - -.. c:type:: void (*TIFFErrorHandler)(const char * module, const char* fmt, va_list ap) - -.. c:type:: void (*TIFFErrorHandlerExt)(thandle_t fd, const char * module, const char* fmt, va_list ap) - -.. c:type:: int (*TIFFErrorHandlerExtR)(TIFF* tif, void* user_data, const char* module, const char* fmt, va_list ap) - -.. c:function:: TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler) - -.. c:function:: TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler) - -Description ------------ - -:c:func:`TIFFError` invokes the library-wide error handler function -to (normally) write an error message to ``stderr``. -The *fmt* parameter is a :c:func:`printf` format string, and any number -arguments can be supplied. The *module* parameter is interpreted as a -string that, if non-zero, should be printed before the message; it -typically is used to identify the software module in which an error is -detected. - -Applications that desire to capture control in the event of an error -should use :c:func:`TIFFSetErrorHandler` to override the default -error handler. A :c:macro:`NULL` (0) error handler function may be -installed to suppress error messages. - -Two more application-specific error handler callbacks are available, -each with different call parameters and passing parameters to the handler. -Each handler is also linked with an error message function, i.e. -:c:func:`TIFFErrorExt` and :c:func:`TIFFErrorExtR` if the application -intends to call the handler with those extended parameters. - -:c:func:`TIFFErrorExt` provides a file handle as parameter. -Within ``libtiff`` :c:func:`TIFFErrorExt` is called passing ``tif->tif_clientdata`` -as *fd*, which represents the TIFF file handle (file descriptor). -The application-specific and library-wide handler for :c:func:`TIFFErrorExt` -is setup with :c:func:`TIFFSetErrorHandlerExt`. - -:c:func:`TIFFErrorExtR` (introduced with libtiff 4.5) is called with its -TIFF handle and thus provides access to a per-TIFF handle (re-entrant) -error handler. That means for different TIFF handles, different error -handlers can be setup. This application-specific handler -can be setup when a TIFF file is opened with one of the following functions: -:c:func:`TIFFOpenExt`, :c:func:`TIFFOpenWExt`, :c:func:`TIFFFdOpenExt` -or :c:func:`TIFFClientOpenExt`. -Furthermore, a **custom defined data structure** *user_data* for the -error handler can be given along. - -Note ----- - -Both functions :c:func:`TIFFError` and :c:func:`TIFFErrorExt` -each attempt to call both handler functions if they are defined. -First :c:func:`TIFFErrorHandler` is called and then :c:func:`TIFFErrorHandlerExt`. -However, :c:func:`TIFFError` passes a "0" as a file handle to -:c:func:`TIFFErrorHandlerExt`. - -:c:func:`TIFFErrorExtR` tries first to call the per-TIFF handle defined -error handler. If :c:func:`TIFFErrorHandlerExtR` is not defined or -returns 0, :c:func:`TIFFErrorHandler` and then :c:func:`TIFFErrorHandlerExt` -are called. From libtiff 4.5 onwards :c:func:`TIFFErrorExtR` is used -within the ``libtiff`` library where the TIFF handle is available. -Otherwise, :c:func:`TIFFErrorExt` is used! - -Return values -------------- - -:c:func:`TIFFSetErrorHandler` and :c:func:`TIFFSetErrorHandlerExt` -returns a reference to the previous error handler function. - -:c:func:`TIFFErrorHandlerExtR` returns an integer as "stop" to control the call -of further error handler functions within :c:func:`TIFFErrorExtR`: - - - 0: both functions :c:func:`TIFFErrorHandler` and :c:func:`TIFFErrorHandlerExt` are called. - - non-zero: no further error message function is called. - -See also --------- - -:doc:`TIFFWarning` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`libtiff` (3tiff), -printf (3) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldDataType.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldDataType.rst deleted file mode 100644 index a758fcb59..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldDataType.rst +++ /dev/null @@ -1,32 +0,0 @@ -TIFFFieldDataType -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: TIFFDataType TIFFFieldDataType(const TIFFField* fip) - -Description ------------ - -:c:func:`TIFFFieldDataType` returns the data type stored in a TIFF field. -*fip* is a field information pointer previously returned by -:c:func:`TIFFFindField`, :c:func:`TIFFFieldWithTag`, -or :c:func:`TIFFFieldWithName`. - -Return values -------------- - -:c:func:`TIFFFieldDataType` returns a member of the enum type -:c:type:`TIFFDataType`. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldName.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldName.rst deleted file mode 100644 index 85d580ae6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldName.rst +++ /dev/null @@ -1,31 +0,0 @@ -TIFFFieldName -============= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: const char* TIFFFieldName(const TIFFField* fip) - -Description ------------ - -:c:func:`TIFFFieldName` returns the textual name for a TIFF field. -*fip* is a field information pointer previously returned by -:c:func:`TIFFFindField`, :c:func:`TIFFFieldWithTag`, -or :c:func:`TIFFFieldWithName`. - -Return values -------------- - -:c:func:`TIFFFieldName` returns a constant C string. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldPassCount.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldPassCount.rst deleted file mode 100644 index 1278e1102..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldPassCount.rst +++ /dev/null @@ -1,42 +0,0 @@ -TIFFFieldPassCount -================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFFieldPassCount(const TIFFField* fip) - -Description ------------ - -:c:func:`TIFFFieldPassCount` returns true (nonzero) if -:c:func:`TIFFGetField` and :c:func:`TIFFSetField` -expect a :c:var:`count` value to be passed before the actual data pointer. - -:c:var:`fip` is a field information pointer previously returned by -:c:func:`TIFFFindField`, -:c:func:`TIFFFieldWithTag`, -:c:func:`TIFFFieldWithName`. - -When a :c:var:`count` is required, it will be of type :c:type:`uint32_t` -if :c:func:`TIFFFieldReadCount` reports :c:macro:`TIFF_VARIABLE2`, -and of type :c:type:`uint16_t` otherwise. (This distinction is -critical for use of :c:func:`TIFFGetField`, but normally not so for -use of :c:func:`TIFFSetField`.) - -Return values -------------- - -:c:func:`TIFFFieldPassCount` returns an integer that is always 1 (true) -or 0 (false). - -See also --------- - -:doc:`libtiff` diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldQuery.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldQuery.rst deleted file mode 100644 index 644299cbd..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldQuery.rst +++ /dev/null @@ -1,78 +0,0 @@ -TIFFFieldQuery -============== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: const TIFFField* TIFFFieldWithName(TIFF* tif, const char *field_name) - -.. c:function:: const TIFFField* TIFFFieldWithTag(TIFF* tif, uint32_t tag) - -.. c:function:: const TIFFField* TIFFFindField(TIFF* tif, uint32_t tag, TIFFDataType dt) - -.. c:function:: int TIFFFieldIsAnonymous(const TIFFField *fip) - -.. c:function:: int TIFFFieldSetGetSize(const TIFFField *fip) - -.. c:function:: int TIFFFieldSetGetCountSize(const TIFFField* fip) - -Description ------------ - -.. TODO: Check explanation and intended use of functions. - -:c:func:`TIFFFieldWithName` and :c:func:`TIFFFieldWithTag` -return a pointer to TIFF field information structure `fip` by the tag's -*field_name* or its *tag* number. - -:c:func:`TIFFFindField` searches for the TIFF field information structure -`fip` of a given *tag* number and a specific `TIFFDataType dt`. -With dt== :c:macro:`TIFF_ANY` the behaviour is the same than for -*TIFFFieldWithTag()*. - - .. TODO: Check if ``libtiff`` is able to handle tag definitions with two different - definitions. From the code point of view, I don't believe that. - - Such a `TIFFDataType` dependent search could be useful when the same - tag is defined twice but with different data types, which is true for - rare cases like TIFFTAG_XCLIPPATHUNITS. However, the ``libtiff`` does - currently not support multiple definitions of the same tag. - - -The following routines return status information about TIFF fields. - - :c:var:`fip` is a field information pointer previously returned by - `TIFFFindField()`, `TIFFFieldWithTag()`, `TIFFFieldWithName()`. - -:c:func:`TIFFFieldIsAnonymous` returns true (nonzero) if the field, -read from file, is unknown to ``libtiff`` and a anonymous field has -been auto-registered. Return is zero "0" if field is known to ``libtiff``. -See :ref:`Tag_Auto_registration` for more information. - -:c:func:`TIFFFieldSetGetSize` returns the data size in bytes of -the field data type used for ``libtiff`` internal storage. -This is also the data size of the parameter to be provided to -:c:func:`TIFFSetField` and :c:func:`TIFFGetField`. Custom -:c:macro:`TIFF_RATIONAL` values can be stored internally either -as ``float`` or ``double``. :c:func:`TIFFFieldSetGetSize` would -then return "4" or "8", respectively. - -:c:func:`TIFFFieldSetGetCountSize` returns size of ``count`` parameter -of :c:func:`TIFFSetField` and :c:func:`TIFFGetField` and also if it is -required: 0=none, 2= :c:type:`uint16_t`, 4= :c:type:`uint32_t` - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldReadCount.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldReadCount.rst deleted file mode 100644 index 903908082..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldReadCount.rst +++ /dev/null @@ -1,43 +0,0 @@ -TIFFFieldReadCount -================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFFieldReadCount(const TIFFField* fip) - -Description ------------ - -:c:func:`TIFFFieldReadCount` returns the number of values available to be read -from the specified TIFF field; that is, the number of arguments that should be -supplied to :c:func:`TIFFGetField`. For most field types this is a small -positive integer, typically 1 or 2, but there are some special values: - -* :c:macro:`TIFF_VARIABLE` ``= -1`` indicates that a variable number of - values is possible; then, a :c:type:`uint16_t` *count* argument and a - pointer *data* argument must be supplied to :c:func:`TIFFGetField`. -* :c:macro:`TIFF_VARIABLE2` ``= -3`` is the same as :c:macro:`TIFF_VARIABLE` - except that the *count* argument must have type :c:type:`uint32_t`. -* :c:macro:`TIFF_SPP` ``= -2`` indicates that the number of arguments is - equal to the image's number of samples per pixel. - -*fip* is a field information pointer previously returned by -:c:func:`TIFFFindField`, :c:func:`TIFFFieldWithTag`, or -:c:func:`TIFFFieldWithName`. - -Return values -------------- - -:c:func:`TIFFFieldReadCount` returns an integer. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldTag.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldTag.rst deleted file mode 100644 index dbff74603..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldTag.rst +++ /dev/null @@ -1,34 +0,0 @@ -TIFFFieldTag -============ - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: uint32_t TIFFFieldTag(const TIFFField* fip) - -Description ------------ - -:c:func:`TIFFFieldTag` returns the numeric tag value for a TIFF field. -This can be compared to various constants exported by the :program:`libtiff` -header files, such as :c:macro:`TIFFTAG_IMAGEWIDTH`. - -*fip* is a field information pointer previously returned by -:c:func:`TIFFFindField`, :c:func:`TIFFFieldWithTag`, or -:c:func:`TIFFFieldWithName`. - -Return values -------------- - -:c:func:`TIFFFieldTag` returns an integer tag value. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldWriteCount.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldWriteCount.rst deleted file mode 100644 index 1a14e7ba4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFieldWriteCount.rst +++ /dev/null @@ -1,48 +0,0 @@ -TIFFFieldWriteCount -=================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFFieldWriteCount(const TIFFField* fip) - -Description ------------ - -:c:func:`TIFFFieldWriteCount` returns the number of values to be written -into the specified TIFF field; that is, the number of arguments that should -be supplied to :c:func:`TIFFSetField`. For most field types this is a small -positive integer, typically 1 or 2, but there are some special values: - -* :c:macro:`TIFF_VARIABLE` indicates that a variable number of values is - possible; then, a :c:type:`uint16_t` *count* argument and a pointer *data* - argument must be supplied to :c:func:`TIFFSetField`. -* :c:macro:`TIFF_VARIABLE2` is the same as :c:macro:`TIFF_VARIABLE` except - that the *count* argument must have type :c:expr:`uint32_t`. (On most - modern machines, this makes no practical difference, and the *count* - argument can simply be an :c:expr:`int` in either case.) -* :c:type:`TIFF_SPP` indicates that the number of arguments must be equal - to the image's number of samples per pixel. - -*fip* is a field information pointer previously returned by -:c:func:`TIFFFindField`, :c:func:`TIFFFieldWithTag`, or -:c:func:`TIFFFieldWithName`. - -For most field types, :c:func:`TIFFFieldWriteCount` returns the same value as -:c:func:`TIFFFieldReadCount`, but there are some exceptions. - -Return values -------------- - -:c:func:`TIFFFieldWriteCount` returns an integer. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFlush.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFlush.rst deleted file mode 100644 index 6b56148ec..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFFlush.rst +++ /dev/null @@ -1,50 +0,0 @@ -TIFFFlush -========= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFFlush(TIFF* tif) - -.. c:function:: int TIFFFlushData(TIFF* tif) - -Description ------------ - -:c:func:`TIFFFlush` causes any pending writes for the specified file -(including writes for the current directory) to be done. In normal -operation this call is never needed—the library automatically does -any flushing required. - -:c:func:`TIFFFlushData` flushes any pending image data for the specified -file to be written out; directory-related data are not flushed. In normal -operation this call is never needed—the library automatically does any -flushing required. - -Return values -------------- - -0 is returned if an error is encountered, otherwise 1 is returned. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFWriteEncodedStrip` (3tiff), -:doc:`TIFFWriteEncodedTile` (3tiff), -:doc:`TIFFWriteRawStrip` (3tiff), -:doc:`TIFFWriteRawTile` (3tiff), -:doc:`TIFFWriteScanline` (3tiff), -:doc:`TIFFWriteTile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFGetField.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFGetField.rst deleted file mode 100644 index ddd2f68ef..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFGetField.rst +++ /dev/null @@ -1,490 +0,0 @@ -TIFFGetField -============ - -Synopsis --------- - -.. highlight:: c - -:: - - #include - #include - -.. c:function:: int TIFFGetField(TIFF* tif, ttag_t tag, ...) - -.. c:function:: int TIFFVGetField(TIFF* tif, ttag_t tag, va_list ap) - -.. c:function:: int TIFFGetFieldDefaulted(TIFF* tif, ttag_t tag, ...) - -.. c:function:: int TIFFVGetFieldDefaulted(TIFF* tif, ttag_t tag, va_list ap) - -Description ------------ - -:c:func:`TIFFGetField` returns the value of a tag or pseudo-tag associated with the -the current directory of the opened TIFF file *tif*. (A *pseudo-tag* is a -parameter that is used to control the operation of the TIFF library but whose value -is not read or written to the underlying file.) The file must have been previously -opened with :c:func:`TIFFOpen`. The tag is identified by *tag*, one of the values -defined in the include file :file:`tiff.h` (see also the table below). The type and -number of values returned is dependent on the tag being requested. The programming -interface uses a variable argument list as prescribed by the :file:`stdarg.h` -interface. The returned values should only be interpreted if :c:func:`TIFFGetField` -returns 1. - -:c:func:`TIFFVGetField` is functionally equivalent to :c:func:`TIFFGetField` -except that it takes a pointer to a variable argument list. :c:func:`TIFFVGetField` -is useful for layering interfaces on top of the functionality provided by -:c:func:`TIFFGetField`. - -:c:func:`TIFFGetFieldDefaulted` and :c:func:`TIFFVGetFieldDefaulted` are identical -to :c:func:`TIFFGetField` and :c:func:`TIFFVGetField`, respectively, except that if -a tag is not defined in the current directory and it has a default value, then the -default value is returned. - -The tags understood by :program:`libtiff` the number of parameter values, and the -types for the returned values are shown below. The data types are specified as in C -and correspond to the types used to specify tag values to -:c:func:`TIFFSetField`. Remember that :c:func:`TIFFGetField` returns parameter -values, so all the listed data types are pointers to storage where values should be -returned. Consult the TIFF specification (or relevant industry specification) for -information on the meaning of each tag and their possible values. - - .. list-table:: Tag properties - :widths: 5 3 5 10 - :header-rows: 1 - - * - Tag name - - Count - - Types - - Notes - - * - :c:macro:`TIFFTAG_ARTIST` - - 1 - - :c:expr:`const char**` - - - - * - :c:macro:`TIFFTAG_BADFAXLINES` - - 1 - - :c:expr:`uint32_t*` - - - - * - :c:macro:`TIFFTAG_BITSPERSAMPLE` - - 1 - - :c:expr:`uint16_t*` - - - - * - :c:macro:`TIFFTAG_CLEANFAXDATA` - - 1 - - :c:expr:`uint16_t*` - - - - * - :c:macro:`TIFFTAG_COLORMAP` - - 3 - - :c:expr:`const uint16_t**` - - :c:expr:`1< - -.. c:function:: int TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32_t n) - -Description ------------ - -:c:func:`TIFFMergeFieldInfo` is used to add application-defined TIFF tags -to the list of known ``libtiff`` tags. -A brief description is given at :ref:`Define_Application_Tags` -and a description of the :c:struct:`TIFFFieldInfo` array elements can be -found at :ref:`TIFFFFieldInfo definition `. - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`/addingtags`, -:doc:`TIFFSetTagExtender` diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFOpen.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFOpen.rst deleted file mode 100644 index db79d7bcb..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFOpen.rst +++ /dev/null @@ -1,330 +0,0 @@ -TIFFOpen -======== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: TIFF* TIFFOpen(const char* filename, const char* mode) - -.. c:function:: TIFF* TIFFOpenW(const wchar_t* name, const char* mode) - -.. c:function:: TIFF* TIFFFdOpen(const int fd, const char* filename, const char*mode) - -.. c:function:: TIFF* TIFFOpenExt(const char* filename, const char* mode, TIFFOpenOptions* opts) - -.. c:function:: TIFF* TIFFOpenWExt(const wchar_t* name, const char* mode, TIFFOpenOptions* opts) - -.. c:function:: TIFF* TIFFFdOpenExt(const int fd, const char* filename, const char*mode, TIFFOpenOptions* opts) - -.. c:function:: const char * TIFFSetFileName(TIFF* tif) - -.. c:function:: int TIFFSetFileno(TIFF* tif, int fd) - -.. c:function:: int TIFFSetMode(TIFF* tif, int mode) - -.. c:type:: tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t) -.. c:type:: toff_t (*TIFFSeekProc)(thandle_t, toff_t, int) -.. c:type:: int (*TIFFCloseProc)(thandle_t) -.. c:type:: toff_t (*TIFFSizeProc)(thandle_t) -.. c:type:: int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*) -.. c:type:: void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t) - -.. c:function:: TIFF* TIFFClientOpen(const char* filename, const char* mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc) - -.. c:function:: TIFF* TIFFClientOpenExt(const char* filename, const char* mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc, TIFFOpenOptions* opts) - -.. c:function:: thandle_t TIFFClientdata(TIFF* tif) - -.. c:function:: thandle_t TIFFSetClientdata(TIFF* tif, thandle_t newvalue) - -Description ------------ - -:c:func:`TIFFOpen` opens a TIFF file whose name is *filename* -and returns a handle to be used in subsequent calls to routines in -:program:`libtiff`. If the open operation fails, then -:c:macro:`NULL` (0) is returned. The *mode* parameter specifies if -the file is to be opened for reading (``r``) or (``r+``), writing (``w``), or -appending (``a``) and, optionally, whether to override certain -default aspects of library operation (see below Options_). - -The *mode* (``r``) opens only an **existing** file for reading and (``r+``) -for reading and writing. -When a file is opened for appending, existing data will not -be touched; instead new data will be written as additional subfiles. -If an existing file is opened for writing, all previous data is -overwritten. - -If a file is opened for reading, the first TIFF directory in the file -is automatically read. -If a file is opened for writing or appending, a default directory -is automatically created for writing subsequent data. -This directory has all the default values specified in TIFF Revision 6.0: - -* ``BitsPerSample`` = 1, -* ``ThreshHolding`` = "bilevel art scan" -* ``FillOrder`` = 1 (most significant bit of each data byte is filled first) -* ``Orientation`` = 1 (the 0th row represents the visual top of the image, - and the 0th column represents the visual left hand side), -* ``SamplesPerPixel`` = 1, -* ``RowsPerStrip`` = ∞, -* ``ResolutionUnit`` = 2 (inches), and -* ``Compression`` = 1 (no compression). - -To alter these values, or to define values for additional fields, -:c:func:`TIFFSetField` must be used. - -:c:func:`TIFFOpenW` opens a TIFF file with a Unicode filename, for read/writing. - -:c:func:`TIFFFdOpen` is like :c:func:`TIFFOpen` except that it opens a -TIFF file given an open file descriptor *fd*. -The file's name and mode must reflect that of the open descriptor. -Even for write-only mode, ``libtiff`` needs read permissions because -some of its functions need to read back the partially written TIFF file. -The object associated with the file descriptor **must support random access**. -In order to close a TIFF file opened with :c:func:`TIFFFdOpen` -first :c:func:`TIFFCleanup` should be called to free the internal -TIFF structure without closing the file handle and afterwards the -file should be closed using its file descriptor *fd*. - -:c:func:`TIFFOpenExt` (added in libtiff 4.5) is like :c:func:`TIFFOpen`, -but options, such as re-entrant error and warning handlers may be passed -with the *opts* argument. The *opts* argument may be NULL. -Refer to :doc:`TIFFOpenOptions` for allocating and filling the *opts* argument -parameters. The allocated memory for :c:type:`TIFFOpenOptions` -can be released straight after successful execution of the related -"TIFFOpenExt" functions. - -:c:func:`TIFFOpenWExt` (added in libtiff 4.5) is like :c:func:`TIFFOpenExt`, -but opens a TIFF file with a Unicode filename. - -:c:func:`TIFFFdOpenExt` (added in libtiff 4.5) is like :c:func:`TIFFFdOpen`, -but options, such as re-entrant error and warning handlers may be passed -with the *opts* argument. The *opts* argument may be NULL. -Refer to :doc:`TIFFOpenOptions` for filling the *opts* argument. - -:c:func:`TIFFSetFileName` sets the file name in the tif-structure -and returns the old file name. - -:c:func:`TIFFSetFileno` overwrites a copy of the open file's I/O descriptor, -that was saved when the TIFF file was first opened, -and returns the previous value. See note below. - -:c:func:`TIFFSetMode` sets the ``libtiff`` open mode in the tif-structure -and returns the old mode. - -:c:func:`TIFFClientOpen` is like :c:func:`TIFFOpen` except that the caller -supplies a collection of functions that the library will use to do UNIX-like -I/O operations. The *readproc* and *writeproc* functions are called to read -and write data at the current file position. -*seekproc* is called to change the current file position à la :c:func:`lseek` (2). -*closeproc* is invoked to release any resources associated with an open file. -*sizeproc* is invoked to obtain the size in bytes of a file. -*mapproc* and *unmapproc* are called to map and unmap a file's contents in -memory; c.f. :c:func:`mmap` (2) and :c:func:`munmap` (2). -The *clientdata* parameter is an opaque "handle" passed to the client-specified -routines passed as parameters to :c:func:`TIFFClientOpen`. - -:c:func:`TIFFClientOpenExt` (added in libtiff 4.5) is like :c:func:`TIFFClientOpen`, -but options argument *opts* like for :c:func:`TIFFOpenExt` can be passed. - -:c:func:`TIFFClientdata` returns open file's clientdata handle, -which is the real open file's I/O descriptor used by ``libtiff``. -Note: Within tif_unix.c this handle is converted into an integer file descriptor. - -:c:func:`TIFFSetClientdata` sets open file's clientdata, and return previous value. -The clientdata is used as open file's I/O descriptor within ``libtiff``. - -.. note:: - *clientdata* is used as file descriptor or handle of the opened TIFF file within - `libtif`, whereas the file descriptor *fd* (changeable by :c:func:`TIFFSetFileno`) - is only set once to the value of *clientdata* converted to an integer - (in tif_win32.c as well as in tif_unix.c). - When updating the file's clientdata with :c:func:`TIFFSetClientdata`, - the *fd* value is **not** updated. - -Options -------- - -The open mode parameter can include the following flags in -addition to the ``r``, ``r+``, ``w``, and ``a`` flags. -Note however that option flags must follow the read-write-append -specification. - -Note 2: Also for ``w`` the file will be opened with *read access* rights -because ``libtiff`` needs to read back the partially written TIFF file -for some of its functions. - - -``l``: - - When creating a new file force information be written with - Little-Endian byte order (but see below). - By default the library will create new files using the native - CPU byte order. - -``b``: - - When creating a new file force information be written with - Big-Endian byte order (but see below). - By default the library will create new files using the native - CPU byte order. - -``L``: - - Force image data that is read or written to be treated with - bits filled from Least Significant Bit (LSB) to - Most Significant Bit (MSB). - Note that this is the opposite to the way the library has - worked from its inception. - -``B``: - - Force image data that is read or written to be treated with - bits filled from Most Significant Bit (MSB) to - Least Significant Bit (LSB); this is the default. - -``H``: - - Force image data that is read or written to be treated with - bits filled in the same order as the native - CPU. - -``M``: - - Enable the use of memory-mapped files for images opened read-only. - If the underlying system does not support memory-mapped files - or if the specific image being opened cannot be memory-mapped - then the library will fallback to using the normal system interface - for reading information. - By default the library will attempt to use memory-mapped files. - -``m``: - - Disable the use of memory-mapped files. - -``C``: - - Enable the use of "strip chopping" when reading images - that are comprised of a single strip or tile of uncompressed data. - Strip chopping is a mechanism by which the library will automatically - convert the single-strip image to multiple strips, - each of which has about 8 Kilobytes of data. - This facility can be useful in reducing the amount of memory used - to read an image because the library normally reads each strip - in its entirety. - Strip chopping does however alter the apparent contents of the - image because when an image is divided into multiple strips it - looks as though the underlying file contains multiple separate - strips. - Finally, note that default handling of strip chopping is a compile-time - configuration parameter. - The default behaviour, for backwards compatibility, is to enable - strip chopping. - -``c``: - - Disable the use of strip chopping when reading images. - -``h``: - - Read TIFF header only, do not load the first image directory. That could be - useful in case of the broken first directory. We can open the file and proceed - to the other directories. - -``4``: - - ClassicTIFF for creating a file (default) - -``8``: - - BigTIFF for creating a file. - -``D``: - - Enable use of deferred strip/tile offset/bytecount array loading. They will - be loaded the first time they are accessed to. This loading will be done in - its entirety unless the O flag is also specified. - -``O``: - - On-demand loading of values of the strip/tile offset/bytecount arrays, limited - to the requested strip/tile, instead of whole array loading (implies ``D``) - -Byte order ----------- - -The TIFF specification (**all versions**) states that compliant readers -"must be capable of reading images written in either byte order" . -Nonetheless some software that claims to support the reading of -TIFF images is incapable of reading images in anything but the native -CPU byte order on which the software was written. -(Especially notorious are applications written to run on Intel-based machines.) -By default the library will create new files with the native -byte-order of the CPU on which the application is run. -This ensures optimal performance and is portable to any application -that conforms to the TIFF specification. -To force the library to use a specific byte-order when creating -a new file the ``b`` and ``l`` option flags may be included in -the call to open a file; for example, ``wb`` or ``wl``. - -Return values -------------- - -Upon successful completion -:c:func:`TIFFOpen`, :c:func:`TIFFFdOpen`, and :c:func:`TIFFClientOpen` -return a TIFF pointer. Otherwise, :c:macro:`NULL` is returned. - -Diagnostics ------------ - - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. -Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine. - -``"%s": Bad mode``: - - The specified *mode* parameter was not one of ``r`` (read), ``w`` (write), - or ``a`` (append). - -``"%s: Cannot open"``: - - :c:func:`TIFFOpen` was unable to open the specified filename for read/writing. - -``"Cannot read TIFF header"``: - - An error occurred while attempting to read the header information. - -``"Error writing TIFF header"``: - - An error occurred while writing the default header information - for a new file. - -``"Not a TIFF file, bad magic number %d (0x%x)"``: - - The magic number in the header was not (hex) - 0x4d4d or (hex) 0x4949. - -``"Not a TIFF file, bad version number %d (0x%x)"``: - - The version field in the header was not 42 (decimal). - -``"Cannot append to file that has opposite byte ordering"``: - - A file with a byte ordering opposite to the native byte - ordering of the current machine was opened for appending (``a``). - This is a limitation of the library. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFClose` (3tiff), -:doc:`TIFFStrileQuery`, -:doc:`TIFFOpenOptions` \ No newline at end of file diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFOpenOptions.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFOpenOptions.rst deleted file mode 100644 index 5c6756671..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFOpenOptions.rst +++ /dev/null @@ -1,69 +0,0 @@ -TIFFOpenOptions -=============== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:type:: TIFFOpenOptions TIFFOpenOptions - -.. c:function:: TIFFOpenOptions* TIFFOpenOptionsAlloc(void) - -.. c:function:: void TIFFOpenOptionsFree(TIFFOpenOptions*) - -.. c:function:: void TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions* opts, tmsize_t max_single_mem_alloc) - -.. c:function:: void TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions* opts, TIFFErrorHandlerExtR handler, void* errorhandler_user_data) - -.. c:function:: void TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions* opts, TIFFErrorHandlerExtR handler, void* warnhandler_user_data) - -Description ------------ - -:c:type:`TIFFOpenOptions` is an opaque structure which can be passed -to the TIFF open"Ext" functions to define some ``libtiff`` internal settings. -The settings are the maximum single memory allocation limit and -per-TIFF handle (re-entrant) error handler and warning handler functions. -For those handler a pointer to a **custom defined data structure** *user_data* -can be given along. - -:c:func:`TIFFOpenOptionsAlloc` allocates memory for the :c:type:`TIFFOpenOptions` -opaque structure and returns a :c:type:`TIFFOpenOptions` pointer. - -:c:func:`TIFFOpenOptionsFree` releases the allocated memory for -:c:type:`TIFFOpenOptions`. The allocated memory for :c:type:`TIFFOpenOptions` -can be released straight after successful execution of the related -TIFF open"Ext" functions like :c:func:`TIFFOpenExt`. - -:c:func:`TIFFOpenOptionsSetMaxSingleMemAlloc` sets parameter for the -maximum single memory limit in byte that ``libtiff`` internal memory allocation -functions are allowed to request per call. - -:c:func:`TIFFOpenOptionsSetErrorHandlerExtR` sets the function pointer to -an application-specific and per-TIFF handle (re-entrant) error handler. -Furthermore, a pointer to a **custom defined data structure** *errorhandler_user_data* -can be passed. This error handler is invoked through :c:func:`TIFFErrorExtR` -and the *errorhandler_user_data* pointer is given along. -The *errorhandler_user_data* argument may be NULL. - -:c:func:`TIFFOpenOptionsSetWarningHandlerExtR` works like -:c:func:`TIFFOpenOptionsSetErrorHandlerExtR` but for the warning handler, -which is invoked through :c:func:`TIFFWarningExtR` - -Note ----- - -This functionality was introduced with libtiff 4.5. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFError` (3tiff), -:doc:`TIFFWarning` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFPrintDirectory.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFPrintDirectory.rst deleted file mode 100644 index e84af5a9a..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFPrintDirectory.rst +++ /dev/null @@ -1,58 +0,0 @@ -TIFFPrintDirectory -================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: void TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) - -Description ------------ - -:c:func:`TIFFPrintDirectory` prints a description of the current directory -in the specified TIFF file to the standard I/O output stream *fd*. -The *flags* parameter is used to control the "level of detail" -of the printed information; it is a bitwise-or of the flags defined in -:file:`tiffio.h`: - - -================================= ===== =========================== -Name Value Description -================================= ===== =========================== -:c:macro:`TIFFPRINT_NONE` 0x0 no extra info -:c:macro:`TIFFPRINT_STRIPS` 0x1 strips/tiles info -:c:macro:`TIFFPRINT_CURVES` 0x2 color/gray response curves -:c:macro:`TIFFPRINT_COLORMAP` 0x4 colormap -:c:macro:`TIFFPRINT_JPEGQTABLES` 0x100 JPEG Q matrices -:c:macro:`TIFFPRINT_JPEGACTABLES` 0x200 JPEG AC tables -:c:macro:`TIFFPRINT_JPEGDCTABLES` 0x200 JPEG DC tables -================================= ===== =========================== - -Notes ------ - -In C++ the *flags* parameter defaults to 0. - -Return values -------------- - -None. - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadDirectory` (3tiff), -:doc:`TIFFSetDirectory` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFProcFunctions.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFProcFunctions.rst deleted file mode 100644 index 73c77dd29..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFProcFunctions.rst +++ /dev/null @@ -1,57 +0,0 @@ -TIFFProcFunctions -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: TIFFCloseProc TIFFGetCloseProc(TIFF* tif) - -.. c:function:: TIFFMapFileProc TIFFGetMapFileProc(TIFF* tif) - -.. c:function:: TIFFReadWriteProc TIFFGetReadProc(TIFF* tif) - -.. c:function:: TIFFSeekProc TIFFGetSeekProc(TIFF* tif) - -.. c:function:: TIFFSizeProc TIFFGetSizeProc(TIFF* tif) - -.. c:function:: TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF* tif) - -.. c:function:: TIFFReadWriteProc TIFFGetWriteProc(TIFF* tif) - -Description ------------ - -.. TODO: Explain or link to explanation of procedure handling. - -The following routines return ?????? an open TIFF file. - -:c:func:`TIFFGetCloseProc` returns a pointer to file close method. - -:c:func:`TIFFGetMapFileProc` returns a pointer to memory mapping method. - -:c:func:`TIFFGetReadProc` returns a pointer to file read method. - -:c:func:`TIFFGetSeekProc` returns a pointer to file seek method. - -:c:func:`TIFFGetSizeProc` returns a pointer to file size requesting method. - -:c:func:`TIFFGetUnmapFileProc` returns a pointer to memory unmapping method. - -:c:func:`TIFFGetWriteProc` returns a pointer to file write method. - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFOpen` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFRGBAImage.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFRGBAImage.rst deleted file mode 100644 index 119d3efd1..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFRGBAImage.rst +++ /dev/null @@ -1,234 +0,0 @@ -TIFFRGBAImage -============= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:type:: unsigned char TIFFRGBValue - -.. c:type:: struct _TIFFRGBAImage TIFFRGBAImage - -.. c:function:: int TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) - -.. c:function:: int TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stopOnError, char emsg[1024]) - -.. c:function:: int TIFFRGBAImageGet(TIFFRGBAImage* img, uint32_t* raster, uint32_t width, uint32_t height) - -.. c:function:: void TIFFRGBAImageEnd(TIFFRGBAImage* img) - -Description ------------ - -The routines described here provide a high-level interface through which -TIFF images may be read into memory. -Images may be strip- or tile-based and have a variety of different -characteristics: bits/sample, samples/pixel, photometric, etc. -Decoding state is encapsulated in a :c:type:`TIFFRGBAImage` -structure making it possible to capture state for multiple images -and quickly switch between them. -The target raster format can be customized to a particular application's -needs by installing custom routines that manipulate image data -according to application requirements. - -The default usage for these routines is: - -* check if an image can be processed using :c:func:`TIFFRGBAImageOK` -* construct a decoder state block using :c:func:`TIFFRGBAImageBegin` -* read and decode an image into a target raster using - :c:func:`TIFFRGBAImageGet`, and then -* release resources using :c:func:`TIFFRGBAImageEnd` - -:c:func:`TIFFRGBAImageGet` can be called multiple times to decode an -image using different state parameters. -If multiple images are to be displayed and there is not enough -space for each of the decoded rasters, multiple state blocks can -be managed and then calls can be made to :c:func:`TIFFRGBAImageGet` -as needed to display an image. - -The generated raster is assumed to be an array of -*width* × *height* -32-bit entries, where *width* must be less than or equal to the width of -the image (*height* may be any non-zero size). -If the raster dimensions are smaller than the image, the image data -is cropped to the raster bounds. -If the raster height is greater than that of the image, then the -image data are placed in the lower part of the raster. -(Note that the raster is assume to be organized such that the pixel -at location (*x*, *y*) is *raster* [ *y* × *width* + *x* ]; -with the raster origin in the *lower-left hand corner*.) - -Raster pixels are 8-bit packed red, green, blue, alpha samples. -The macros :c:macro:`TIFFGetR`, :c:macro:`TIFFGetG`, :c:macro:`TIFFGetB`, -and :c:macro:`TIFFGetA` should be used to access individual samples. -Images without Associated Alpha matting information have a constant -Alpha of 1.0 (255). - -:c:func:`TIFFRGBAImageGet` converts non-8-bit images by scaling sample -values. Palette, grayscale, bilevel, CMYK, and YCbCr images are -converted to RGB transparently. -Raster pixels are returned uncorrected by any colorimetry information -present in the directory. - -The parameter *stopOnError* specifies how to act if an error is -encountered while reading the image. If *stopOnError* is non-zero, -then an error will terminate the operation; otherwise -:c:func:`TIFFRGBAImageGet` will continue processing data until all the -possible data in the image have been requested. - -Alternate raster formats ------------------------- - -To use the core support for reading and processing TIFF images, but -write the resulting raster data in a different format one need only -override the "put methods" used to store raster data. -These methods are are defined in the :c:type:`TIFFRGBAImage` -structure and initially setup by :c:func:`TIFFRGBAImageBegin` -to point to routines that pack raster data in the default -ABGR pixel format. -Two different routines are used according to the physical organization -of the image data in the file: -``PlanarConfiguration`` = 1 (packed samples), and -``PlanarConfiguration`` = 2 (separated samples). -Note that this mechanism can be used to transform the data before -storing it in the raster. -For example one can convert data to colormap indices for display on a -colormap display. - -Simultaneous raster store and display -------------------------------------- - -It is simple to display an image as it is being read into memory -by overriding the put methods as described above for supporting -alternate raster formats. -Simply keep a reference to the default put methods setup by -:c:func:`TIFFRGBAImageBegin` and then invoke them before or after -each display operation. For example, the -:doc:`/tools/tiffgt` utility uses the following put method to -update the display as the raster is being filled: - -:: - - static void - putContigAndDraw(TIFFRGBAImage* img, uint32_t* raster, - uint32_t x, uint32_t y, uint32_t w, uint32_t h, - int32_t fromskew, int32_t toskew, - unsigned char* cp) - { - (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp); - if (x+w == width) { - w = width; - if (img->orientation == ORIENTATION_TOPLEFT) - lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w); - else - lrectwrite(0, y, w-1, y+h-1, raster); - } - } - -(the original routine provided by the library is saved in the -variable :c:var:`putContig`.) - -Supporting additional TIFF formats ----------------------------------- - -The :c:func:`TIFFRGBAImage` routines support the most commonly -encountered flavors of TIFF. It is possible to extend this support by -overriding the "get method" invoked by :c:func:`TIFFRGBAImageGet` -to read TIFF image data. -Details of doing this are a bit involved, it is best to make a copy -of an existing get method and modify it to suit the needs of an -application. - -Notes ------ - -Samples must be either 1, 2, 4, 8, or 16 bits. -Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. -``SamplesPerPixel`` -``ExtraSamples``). - -Palette image colormaps that appear to be incorrectly written -as 8-bit values are automatically scaled to 16-bits. - -Return values -------------- - -All routines return 1 if the operation was successful. -Otherwise, 0 is returned if an error was encountered and -*stopOnError* is zero. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``"Sorry, can not handle %d-bit pictures"``: - - The image had ``BitsPerSample`` other than 1, 2, 4, 8, or 16. - -``"Sorry, can not handle %d-channel images"``: - - The image had ``SamplesPerPixel`` other than 1, 3, or 4. - -``Missing needed "PhotometricInterpretation" tag``: - - The image did not have a tag that describes how to display - the data. - -``No "PhotometricInterpretation" tag, assuming RGB``: - - The image was missing a tag that describes how to display it, - but because it has 3 or 4 samples/pixel, it is assumed to be - RGB. - -``No "PhotometricInterpretation" tag, assuming min-is-black``: - - The image was missing a tag that describes how to display it, - but because it has 1 sample/pixel, it is assumed to be a grayscale - or bilevel image. - -``"No space for photometric conversion table"``: - - There was insufficient memory for a table used to convert - image samples to 8-bit RGB. - -``Missing required "Colormap" tag``: - - A Palette image did not have a required ``Colormap`` tag. - -``"No space for tile buffer"``: - - There was insufficient memory to allocate an i/o buffer. - -``"No space for strip buffer"``: - - There was insufficient memory to allocate an i/o buffer. - -``"Can not handle format"``: - - The image has a format (combination of ``BitsPerSample``, - ``SamplesPerPixel`` and ``PhotometricInterpretation``) - that can not be handled. - -``"No space for B&W mapping table"``: - - There was insufficient memory to allocate a table used to map - grayscale data to RGB. - -``"No space for Palette mapping table"``: - - There was insufficient memory to allocate a table used to map - data to 8-bit RGB. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadRGBAImage` (3tiff), -:doc:`TIFFReadRGBAStrip` (3tiff), -:doc:`TIFFReadRGBATile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadDirectory.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadDirectory.rst deleted file mode 100644 index 7a1fc0382..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadDirectory.rst +++ /dev/null @@ -1,146 +0,0 @@ -TIFFReadDirectory -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFReadDirectory(TIFF* tif) - -Description ------------ - -Read the next directory in the specified file and make it the current -directory. Applications only need to call :c:func:`TIFFReadDirectory` -to read multiple subfiles in a single TIFF file—(the first directory -in a file is automatically read when :c:func:`TIFFOpen` is called. - -Notes ------ - -If the library is compiled with :c:macro:`STRIPCHOP_SUPPORT` enabled, then -images that have a single uncompressed strip or tile of data are -automatically treated as if they were made up of multiple strips or tiles of -approximately 8 kilobytes each. This operation is done only in-memory; it does -not alter the contents of the file. However, the construction of the "chopped -strips" is visible to the application through the number of strips [tiles] -returned by :c:func:`TIFFNumberOfStrips` [:c:func:`TIFFNumberOfTiles`]. - -Return values -------------- - -If the next directory was successfully read, 1 is returned. Otherwise, 0 is -returned if an error was encountered, or if there are no more directories to -be read. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. -Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine. - -``Seek error accessing TIFF directory``: - - An error occurred while positioning to the location of the - directory. - -``Wrong data type %d for field "%s"``: - - The tag entry in the directory had an incorrect data type. - For example, an ``ImageDescription`` tag with a ``SHORT`` - data type. - -``TIFF directory is missing required "%s" field``: - - The specified tag is required to be present by the TIFF - 5.0 specification, but is missing. - The directory is (usually) unusable. - -``%s: Rational with zero denominator``: - - A directory tag has a ``RATIONAL`` value whose denominator is zero. - -``Incorrect count %d for field "%s" (%lu, expecting %lu); tag ignored``: - - The specified tag's count field is bad. - For example, a count other than 1 for a ``SubFileType`` tag. - -``Cannot handle different per-sample values for field "%s"``: - - The tag has ``SamplesPerPixel`` values and they are not all the same; e.g. - ``BitsPerSample``. The library is unable to handle images of this sort. - -``Count mismatch for field "%s"; expecting %d, got %d``: - - The count field in a tag does not agree with the number expected by the - library. This should never happen, so if it does, the library refuses to - read the directory. - -``Invalid TIFF directory; tags are not sorted in ascending order``: - - The directory tags are not properly sorted as specified - in the TIFF 5.0 specification. This error is not fatal. - -``Ignoring unknown field with tag %d (0x%x)``: - - An unknown tag was encountered in the directory; - the library ignores all such tags. - -``TIFF directory is missing required "ImageLength" field``: - - The image violates the specification by not having a necessary field. - There is no way for the library to recover from this error. - -``TIFF directory is missing required "PlanarConfig" field``: - - The image violates the specification by not having a necessary field. - There is no way for the library to recover from this error. - -``TIFF directory is missing required "StripOffsets" field``: - - The image has multiple strips, but is missing the tag that - specifies the file offset to each strip of data. - There is no way for the library to recover from this error. - -``TIFF directory is missing required "TileOffsets" field``: - - The image has multiple tiles, but is missing the tag that - specifies the file offset to each tile of data. - There is no way for the library to recover from this error. - -``TIFF directory is missing required "StripByteCounts" field``: - - The image has multiple strips, but is missing the tag that - specifies the size of each strip of data. - There is no way for the library to recover from this error. - -``TIFF directory is missing required "StripByteCounts" field, calculating from imagelength``: - - The image violates the specification by not having a necessary field. - However, when the image is comprised of only one strip or tile, the - library will estimate the missing value based on the file size. - -``Bogus "StripByteCounts" field, ignoring and calculating from imagelength``: - - Certain vendors violate the specification by writing zero for - the StripByteCounts tag when they want to leave the value - unspecified. - If the image has a single strip, the library will estimate - the missing value based on the file size. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFCreateDirectory` (3tiff), -:doc:`TIFFCustomDirectory` (3tiff), -:doc:`TIFFquery` (3tiff), -:doc:`TIFFWriteDirectory` (3tiff), -:doc:`TIFFSetDirectory` (3tiff), -:doc:`/multi_page`, -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadEncodedStrip.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadEncodedStrip.rst deleted file mode 100644 index cd75ce393..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadEncodedStrip.rst +++ /dev/null @@ -1,57 +0,0 @@ -TIFFReadEncodedStrip -==================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size) - -Description ------------ - -Read the specified strip of data and place up to *size* bytes of decompressed -information in the (user supplied) data buffer. - -Notes ------ - -The value of *strip* is a "raw strip number". That is, the caller must take -into account whether or not the data are organized in separate planes -(``PlanarConfiguration`` = 2). -To read a full strip of data the data buffer should typically be at least as -large as the number returned by :c:func:`TIFFStripSize`. -If -1 is passed in the *size* parameter, the whole strip will be read. You -should be sure you have enough space allocated for the buffer. - -The library attempts to hide bit- and byte-ordering differences between the -image and the native machine by converting data to the native machine order. -Bit reversal is done if the ``FillOrder`` tag is opposite to the native -machine bit order. 16- and 32-bit samples are automatically byte-swapped if -the file was written with a byte order opposite to the native machine byte -order. - -Return values -------------- - -The actual number of bytes of data that were placed in *buf* is returned; -:c:func:`TIFFReadEncodedStrip` returns -1 if an error was encountered. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadRawStrip` (3tiff), -:doc:`TIFFReadScanline` (3tiff), -:doc:`TIFFReadEncodedTile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadEncodedTile.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadEncodedTile.rst deleted file mode 100644 index 8c99dcf6d..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadEncodedTile.rst +++ /dev/null @@ -1,57 +0,0 @@ -TIFFReadEncodedTile -=================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFReadEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) - -Description ------------ - -Read the specified tile of data and place up to *size* bytes of decompressed -information in the (user supplied) data buffer. - -Notes ------ - -The value of *tile* is a "raw tile number". That is, the caller must take -into account whether or not the data are organized in separate planes -(``PlanarConfiguration`` = 2). -:c:func:`TIFFComputeTile` automatically does this when converting an -(x,y,z,sample) coordinate quadruple to a tile number. To read a full tile -of data the data buffer should be at least as large as the value returned by -:c:func:`TIFFTileSize`. - -The library attempts to hide bit- and byte-ordering differences between the -image and the native machine by converting data to the native machine order. -Bit reversal is done if the ``FillOrder`` tag is opposite to the native -machine bit order. 16- and 32-bit samples are automatically byte-swapped if -the file was written with a byte order opposite to the native machine byte -order. - -Return values -------------- - -The actual number of bytes of data that were placed in *buf* is returned; -:c:func:`TIFFReadEncodedTile` returns -1 if an error was encountered. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadRawTile` (3tiff), -:doc:`TIFFReadTile` (3tiff), -:doc:`TIFFReadEncodedStrip` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadFromUserBuffer.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadFromUserBuffer.rst deleted file mode 100644 index 09807eca9..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadFromUserBuffer.rst +++ /dev/null @@ -1,46 +0,0 @@ -TIFFReadFromUserBuffer -====================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFReadFromUserBuffer(TIFF* tif, uint32_t strile, void* inbuf, tmsize_t insize, void* outbuf, tmsize_t outsize) - -Description ------------ - -Use the provided input buffer (`inbuf`, `insize`) and decompress it -into (`outbuf`, `outsize`). This function replaces the use of -:c:func:`TIFFReadEncodedStrip` / :c:func:`TIFFReadEncodedTile` -when the user can provide the buffer for the input data, for example when -he wants to avoid ``libtiff`` to read the strile offset/count values from the -``StripOffsets`` / ``StripByteCounts`` or ``TileOffsets`` / -``TileByteCounts`` arrays. `inbuf` content must be writable -(if bit reversal is needed). - - -Return values -------------- - -Returns 1 in case of success, 0 otherwise. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadRawStrip` (3tiff), -:doc:`TIFFReadScanline` (3tiff), -:doc:`TIFFReadEncodedStrip` (3tiff), -:doc:`TIFFReadEncodedTile` (3tiff), -:doc:`libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBAImage.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBAImage.rst deleted file mode 100644 index 1bb99bfae..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBAImage.rst +++ /dev/null @@ -1,173 +0,0 @@ -TIFFReadRGBAImage -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:macro:: TIFFGetR(abgr) - - :c:expr:`((abgr) & 0xff)` - -.. c:macro:: TIFFGetG(abgr) - - :c:expr:`(((abgr) >> 8) & 0xff)` - -.. c:macro:: TIFFGetB(abgr) - - :c:expr:`(((abgr) >> 16) & 0xff)` - -.. c:macro:: TIFFGetA(abgr) - - :c:expr:`(((abgr) >> 24) & 0xff)` - -.. c:function:: int TIFFReadRGBAImage(TIFF* tif, uint32_t width, uint32_t height, uint32_t* raster, int stopOnError) - -.. c:function:: int TIFFReadRGBAImageOriented(TIFF* tif, uint32_t width, uint32_t height, uint32_t * raster, int orientation, int stopOnError) - -Description ------------ - -:c:func:`TIFFReadRGBAImage` reads a strip- or tile-based image into memory, -storing the result in the user supplied *raster*. -The raster is assumed to be an array of *width* × *height* 32-bit entries, -where *width* must be less than or equal to the width of the image -(*height* may be any non-zero size). -If the raster dimensions are smaller than the image, the image data is -cropped to the raster bounds. -If the raster height is greater than that of the image, then the image data -are placed in the lower part of the raster. -(Note that the raster is assume to be organized such that the pixel -at location (*x*, *y*) is *raster* [ *y* × *width* + *x* ]; -with the raster origin in the lower-left hand corner.) - -:c:func:`TIFFReadRGBAImageOriented` works like :c:func:`TIFFReadRGBAImage` -except that the user can specify the raster origin position with the -*orientation* parameter. Four orientations are supported: - -* :c:macro:`ORIENTATION_TOPLEFT`: origin in top-left corner, -* :c:macro:`ORIENTATION_TOPRIGHT`: origin in top-right corner, -* :c:macro:`ORIENTATION_BOTLEFT`: origin in bottom-left corner -* :c:macro:`ORIENTATION_BOTRIGHT`: origin in bottom-right corner. - -If you choose :c:macro:`ORIENTATION_BOTLEFT`, the result will be the same -as returned by the :c:func:`TIFFReadRGBAImage`. - -Raster pixels are 8-bit packed red, green, blue, alpha samples. -The macros :c:macro:`TIFFGetR`, :c:macro:`TIFFGetG`, :c:macro:`TIFFGetB`, -and :c:macro:`TIFFGetA` should be used to access individual samples. -Images without Associated Alpha matting information have a constant -Alpha of 1.0 (255). - -:c:func:`TIFFReadRGBAImage` converts non-8-bit images by scaling sample -values. Palette, grayscale, bilevel, CMYK, and YCbCr images are -converted to RGB transparently. -Raster pixels are returned uncorrected by any colorimetry information -present in the directory. - -The parameter *stopOnError* specifies how to act if an error is -encountered while reading the image. If *stopOnError* is non-zero, then -an error will terminate the operation; otherwise :c:func:`TIFFReadRGBAImage` -will continue processing data until all the possible data in the -image have been requested. - -Notes ------ - -In C++ the *stopOnError* parameter defaults to 0. - -``SamplesPerPixel`` must be either 1, 2, 4, 8, or 16 bits. -Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. -``SamplesPerPixel`` minus ``ExtraSamples``). - -Palettte image colormaps that appear to be incorrectly written -as 8-bit values are automatically scaled to 16-bits. - -:c:func:`IFFReadRGBAImage` is just a wrapper around the more general -:doc:`TIFFRGBAImage` facilities. - -Return values -------------- - -1 is returned if the image was successfully read and converted. -Otherwise, 0 is returned if an error was encountered and -*stopOnError* is zero. - -.. TODO: Specify, what the return value is if an error occurs and stopOnError was non-zero. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``"Sorry, can not handle %d-bit pictures"``: - - The image had ``BitsPerSample`` other than 1, 2, 4, 8, or 16. - -``"Sorry, can not handle %d-channel images"``: - - The image had ``SamplesPerPixel`` other than 1, 3, or 4. - -``Missing needed "PhotometricInterpretation" tag``: - - The image did not have a tag that describes how to display - the data. - -``No "PhotometricInterpretation" tag, assuming RGB``: - - The image was missing a tag that describes how to display it, - but because it has 3 or 4 samples/pixel, it is assumed to be - RGB. - -``No "PhotometricInterpretation" tag, assuming min-is-black``: - - The image was missing a tag that describes how to display it, - but because it has 1 sample/pixel, it is assumed to be a grayscale - or bilevel image. - -``"No space for photometric conversion table"``: - - There was insufficient memory for a table used to convert - image samples to 8-bit RGB. - -``Missing required "Colormap" tag``: - - A Palette image did not have a required ``Colormap`` tag. - -``"No space for tile buffer"``: - - There was insufficient memory to allocate an i/o buffer. - -``"No space for strip buffer"``: - - There was insufficient memory to allocate an i/o buffer. - -``"Can not handle format"``: - - The image has a format (combination of ``BitsPerSample``, - ``SamplesPerPixel``, and ``PhotometricInterpretation``) - that :c:func:`TIFFReadRGBAImage` can not handle. - -``"No space for B&W mapping table"``: - - There was insufficient memory to allocate a table used to map - grayscale data to RGB. - -``"No space for Palette mapping table"``: - - There was insufficient memory to allocate a table used to map - data to 8-bit RGB. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFRGBAImage` (3tiff), -:doc:`TIFFReadRGBAStrip` (3tiff), -:doc:`TIFFReadRGBATile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBAStrip.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBAStrip.rst deleted file mode 100644 index 41ebbfc3e..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBAStrip.rst +++ /dev/null @@ -1,139 +0,0 @@ -TIFFReadRGBAStrip -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFReadRGBAStrip(TIFF* tif, uint32_t row, uint32_t* raster) - -.. c:function:: int TIFFReadRGBAStripExt(TIFF* tif, uint32_t row, uint32_t * raster, int stop_on_error) - -Description ------------ - -:c:func:`TIFFReadRGBAStrip` reads a single strip of a strip-based image -into memory, storing the result in the user supplied RGBA *raster*. -The raster is assumed to be an array of ``ImageWidth`` × ``RowsPerStrip`` -32-bit entries, where ``ImageWidth`` is the width of the image -(:c:macro:`TIFFTAG_IMAGEWIDTH`) and ``RowsPerStrip`` is the maximum lines -in a strip (:c:macro:`TIFFTAG_ROWSPERSTRIP`). - -:c:func:`TIFFReadRGBAStripExt` provides the paramater `stop_on_error`. -Its behaviour is described at :doc:`TIFFReadRGBAImage`. - -The *row* value should be the row of the first row in the strip -(*strip* × ``RowsPerStrip``, zero based). - -Note that the raster is assume to be organized such that the pixel at location -(*x*, *y*) is *raster* [ *y* × *width* + *x* ]; with the raster origin in the -*lower-left hand corner* of the strip. That is bottom to top organization. -When reading a partial last strip in the file the last line of the image will -begin at the beginning of the buffer. - -Raster pixels are 8-bit packed red, green, blue, alpha samples. The macros -:c:macro:`TIFFGetR`, :c:macro:`TIFFGetG`, :c:macro:`TIFFGetB`, and -:c:macro:`TIFFGetA` should be used to access individual samples. Images -without Associated Alpha matting information have a constant Alpha of 1.0 -(255). - -See the :doc:`TIFFRGBAImage` page for more details on how various image types -are converted to RGBA values. - -Notes ------ - -Samples must be either 1, 2, 4, 8, or 16 bits. -Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. ``SamplesPerPixel`` -- ``ExtraSamples``). - -Palette image colormaps that appear to be incorrectly written as 8-bit values -are automatically scaled to 16-bits. - -:c:func:`TIFFReadRGBAStrip` is just a wrapper around the more general -:doc:`TIFFRGBAImage` facilities. It's main advantage over the similar -:c:func:`TIFFReadRGBAImage` function is that for large images a single -buffer capable of holding the whole image doesn't need to be allocated, -only enough for one strip. The :c:func:`TIFFReadRGBATile` function -does a similar operation for tiled images. - -Return values -------------- - -1 is returned if the image was successfully read and converted. -Otherwise, 0 is returned if an error was encountered. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``"Sorry, can not handle %d-bit pictures"``: - - The image had ``BitsPerSample`` other than 1, 2, 4, 8, or 16. - -``"Sorry, can not handle %d-channel images"``: - - The image had ``SamplesPerPixel`` other than 1, 3, or 4. - -``Missing needed "PhotometricInterpretation" tag``: - - The image did not have a tag that describes how to display the data. - -``No "PhotometricInterpretation" tag, assuming RGB``: - - The image was missing a tag that describes how to display it, but because it - has 3 or 4 samples/pixel, it is assumed to be RGB. - -``No "PhotometricInterpretation" tag, assuming min-is-black\fP``: - - The image was missing a tag that describes how to display it, but - because it has 1 sample/pixel, it is assumed to be a grayscale or - bilevel image. - -``"No space for photometric conversion table"``: - - There was insufficient memory for a table used to convert image samples to - 8-bit RGB. - -``Missing required "Colormap" tag``: - - A Palette image did not have a required ``Colormap`` tag. - -``"No space for tile buffer"``: - - There was insufficient memory to allocate an i/o buffer. - -``"No space for strip buffer"``: - - There was insufficient memory to allocate an i/o buffer. - -``"Can not handle format"``: - - The image has a format (combination of ``BitsPerSample``, - ``SamplesPerPixel``, and ``PhotometricInterpretation``) - that :c:func:`TIFFReadRGBAImage` can not handle. - -``"No space for B&W mapping table"``: - - There was insufficient memory to allocate a table used to map grayscale data - to RGB. - -``"No space for Palette mapping table"``: - - There was insufficient memory to allocate a table used to map data to 8-bit - RGB. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFRGBAImage` (3tiff), -:doc:`TIFFReadRGBAImage` (3tiff), -:doc:`TIFFReadRGBATile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBATile.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBATile.rst deleted file mode 100644 index 14a3e3c69..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRGBATile.rst +++ /dev/null @@ -1,141 +0,0 @@ -TIFFReadRGBATile -================ - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFReadRGBATile(TIFF* tif, uint32_t x, uint32_t y, uint32_t* raster) - -.. c:function:: int TIFFReadRGBATileExt(TIFF* tif, uint32_t col, uint32_t row, uint32_t * raster, int stop_on_error) - -Description ------------ - -:c:func:`TIFFReadRGBATile` reads a single tile of a tile-based image into -memory, storing the result in the user supplied RGBA *raster*. -The raster is assumed to be an array of ``TileWidth`` × ``TileLength`` -32-bit entries, where ``TileWidth`` is the width of a tile -(:c:macro:`TIFFTAG_TILEWIDTH`) and ``TileLength`` is the height of a -tile (:c:macro:`TIFFTAG_TILELENGTH`). - -:c:func:`TIFFReadRGBATileExt` provides the parameter `stop_on_error`. -Its behaviour is described at :doc:`TIFFReadRGBAImage`. - -The *x* and *y* values are the offsets from the top left corner to the top -left corner of the tile to be read. They must be an exact multiple of the -tile width and length. - -Note that the raster is assume to be organized such that the pixel at -location -(*x*, *y*) is *raster* [ *y* × *width* + *x* ]; with the raster origin -in the *lower-left hand corner* of the tile. That is bottom to top -organization. Edge tiles which partly fall off the image will be filled -out with appropriate zeroed areas. - -Raster pixels are 8-bit packed red, green, blue, alpha samples. The macros -:c:macro:`TIFFGetR`, :c:macro:`TIFFGetG`, :c:macro:`TIFFGetB`, and -:c:macro:`TIFFGetA` should be used to access individual samples. Images -without Associated Alpha matting information have a constant Alpha of 1.0 -(255). - -See the :doc:`TIFFRGBAImage` page for more details on how various image -types are converted to RGBA values. - -Notes ------ - -Samples must be either 1, 2, 4, 8, or 16 bits. -Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. -``SamplesPerPixel`` - ``ExtraSamples``). - -Palette image colormaps that appear to be incorrectly written as 8-bit -values are automatically scaled to 16-bits. - -:c:func:`TIFFReadRGBATile` is just a wrapper around the more general -:doc:`TIFFRGBAImage` facilities. It's main advantage over the similar -:c:func:`TIFFReadRGBAImage` function is that for large images a single -buffer capable of holding the whole image doesn't need to be allocated, -only enough for one tile. The :c:func:`TIFFReadRGBAStrip` function -does a similar operation for stripped images. - -Return values -------------- - -1 is returned if the image was successfully read and converted. -Otherwise, 0 is returned if an error was encountered. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``"Sorry, can not handle %d-bit pictures"``: - - The image had ``BitsPerSample`` other than 1, 2, 4, 8, or 16. - -``"Sorry, can not handle %d-channel images"``: - - The image had ``SamplesPerPixel`` other than 1, 3, or 4. - -``Missing needed "PhotometricInterpretation" tag``: - - The image did not have a tag that describes how to display the data. - -``No "PhotometricInterpretation" tag, assuming RGB``: - - The image was missing a tag that describes how to display it, but because it - has 3 or 4 samples/pixel, it is assumed to be RGB. - -``No "PhotometricInterpretation" tag, assuming min-is-black``: - - The image was missing a tag that describes how to display it, - but because it has 1 sample/pixel, it is assumed to be a grayscale - or bilevel image. - -``"No space for photometric conversion table"``: - - There was insufficient memory for a table used to convert - image samples to 8-bit RGB. - -``Missing required "Colormap" tag``: - - A Palette image did not have a required ``Colormap`` tag. - -``"No space for tile buffer"``: - - There was insufficient memory to allocate an i/o buffer. - -``"No space for strip buffer"``: - - There was insufficient memory to allocate an i/o buffer. - -``"Can not handle format"``: - - The image has a format (combination of ``BitsPerSample``, - ``SamplesPerPixel``, and ``PhotometricInterpretation``) - that :c:func:`TIFFReadRGBAImage` can not handle. - -``"No space for B&W mapping table"``: - - There was insufficient memory to allocate a table used to map - grayscale data to RGB. - -``"No space for Palette mapping table"``: - - There was insufficient memory to allocate a table used to map data to 8-bit - RGB. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFRGBAImage` (3tiff), -:doc:`TIFFReadRGBAImage` (3tiff), -:doc:`TIFFReadRGBAStrip` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRawStrip.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRawStrip.rst deleted file mode 100644 index 70bc00aa7..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRawStrip.rst +++ /dev/null @@ -1,43 +0,0 @@ -TIFFReadRawStrip -================ - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tsize_t TIFFReadRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) - -Description ------------ - -Read the contents of the specified strip into the (user supplied) data buffer. -Note that the value of *strip* is a "raw strip number". That is, the caller -must take into account whether or not the data is organized in separate planes -(``PlanarConfiguration`` = 2). -To read a full strip of data the data buffer should typically be at least as -large as the number returned by :c:func:`TIFFStripSize`. - -Return values -------------- - -The actual number of bytes of data that were placed in *buf* is returned; -:c:func:`TIFFReadRawStrip` returns -1 if an error was encountered. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadEncodedStrip` (3tiff), -:doc:`TIFFReadScanline` (3tiff), -:doc:`TIFFstrip` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRawTile.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRawTile.rst deleted file mode 100644 index 9be650430..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadRawTile.rst +++ /dev/null @@ -1,45 +0,0 @@ -TIFFReadRawTile -=============== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tsize_t TIFFReadRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) - -Description ------------ - -Read the contents of the specified tile into the (user supplied) data buffer. -Note that the value of *tile* is a "raw tile number". That is, the caller -must take into account whether or not the data is organized in separate planes -(``PlanarConfiguration`` = 2). -:c:func:`TIFFComputeTile` automatically does this when converting an -(x,y,z,sample) coordinate quadruple to a tile number. To read a full tile -of data the data buffer should typically be at least as large as the value -returned by :c:func:`TIFFTileSize`. - -Return values -------------- - -The actual number of bytes of data that were placed in *buf* is returned; -:c:func:`TIFFReadRawTile` returns -1 if an error was encountered. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadEncodedTile` (3tiff), -:doc:`TIFFReadTile` (3tiff), -:doc:`TIFFtile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadScanline.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadScanline.rst deleted file mode 100644 index 7a484e0b6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadScanline.rst +++ /dev/null @@ -1,75 +0,0 @@ -TIFFReadScanline -================ - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFReadScanline(TIFF* tif, tdata_t buf, uint32_t row, tsample_t sample) - -Description ------------ - -Read the data for the specified row into the (user supplied) data buffer -*buf*. The data are returned decompressed and, in the native byte- and -bit-ordering, but are otherwise packed (see further below). The buffer -must be large enough to hold an entire scanline of data. Applications -should call the routine :c:func:`TIFFScanlineSize` to find out the size -(in bytes) of a scanline buffer. -The *row* parameter is always used by :c:func:`TIFFReadScanline`; the -*sample* parameter is used only if data are organized in separate planes -(``PlanarConfiguration`` = 2). - -Notes ------ - -The library attempts to hide bit- and byte-ordering differences between the -image and the native machine by converting data to the native machine order. -Bit reversal is done if the ``FillOrder`` tag is opposite to the native -machine bit order. 16- and 32-bit samples are automatically byte-swapped if -the file was written with a byte order opposite to the native machine byte -order, - -In C++ the *sample* parameter defaults to 0. - -Return values -------------- - -:c:func:`TIFFReadScanline` returns -1 if it detects an error; otherwise 1 is -returned. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``"Compression algorithm does not support random access"``: - - Data was requested in a non-sequential order from a file that uses a - compression algorithm and that has ``RowsPerStrip`` greater than one. - That is, data in the image is stored in a compressed form, and with multiple - rows packed into a strip. In this case, the library does not support random - access to the data. The data should either be accessed sequentially, or the - file should be converted so that each strip is made up of one row of data. - -Bugs ----- - -Reading subsampled YCbCR data does not work correctly because, for -``PlanarConfiguration`` = 2, the size of a scanline is not calculated on a -per-sample basis, and for ``PlanarConfiguration`` = 1, the library does not -unpack the block-interleaved samples; use the strip- and -tile-based interfaces to read these formats. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadEncodedStrip` (3tiff), -:doc:`TIFFReadRawStrip` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadTile.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadTile.rst deleted file mode 100644 index a61fa6b1f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFReadTile.rst +++ /dev/null @@ -1,57 +0,0 @@ -TIFFReadTile -============ - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tsize_t TIFFReadTile(TIFF* tif, tdata_t buf, uint32_t x, uint32_t y, uint32_t z, tsample_t sample) - -Description ------------ - -Return the data for the tile *containing* the specified coordinates. The -data placed in *buf* are returned decompressed and, typically, in the -native byte- and bit-ordering, but are otherwise packed (see further -below). The buffer must be large enough to hold an entire tile of data. -Applications should call the routine :c:func:`TIFFTileSize` to find out -the size (in bytes) of a tile buffer. The *x* and *y* parameters are -always used by :c:func:`TIFFReadTile`. The *z* parameter is used if the -image is deeper than 1 slice (``ImageDepth`` > 1). The *sample* -parameter is used only if data are organized in separate planes ( -``PlanarConfiguration`` = 2). - -Notes ------ - -The library attempts to hide bit- and byte-ordering differences between -the image and the native machine by converting data to the native machine -order. Bit reversal is done if the ``FillOrder`` tag is opposite to the -native machine bit order. 16- and 32-bit samples are automatically -byte-swapped if the file was written with a byte order opposite to the -native machine byte order. - -Return values -------------- - -:c:func:`TIFFReadTile` returns -1 if it detects an error; otherwise the -number of bytes in the decoded tile is returned. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -See also --------- - -:doc:`TIFFtile` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadEncodedTile` (3tiff), -:doc:`TIFFReadRawTile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFSetDirectory.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFSetDirectory.rst deleted file mode 100644 index 5d1212f72..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFSetDirectory.rst +++ /dev/null @@ -1,71 +0,0 @@ -TIFFSetDirectory -================ - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFSetDirectory(TIFF* tif, tdir_t dirnum) - -.. c:function:: int TIFFSetSubDirectory(TIFF* tif, uint64_t diroff) - -Description ------------ - -:c:func:`TIFFSetDirectory` changes the current directory and reads its -contents with :c:func:`TIFFReadDirectory`. The parameter *dirnum* -specifies the subfile/directory as an integer number, with the first -directory numbered zero. -:c:func:`TIFFSetDirectory()` only works with main-IFD chains because -allways starts with the first main-IFD and thus is able to reset -the SubIFD reading chain to the main-IFD chain. - -:c:func:`TIFFSetSubDirectory` acts like :c:func:`TIFFSetDirectory`, -except the directory is specified as a file offset instead of an index; -this is required for accessing subdirectories linked through a -``SubIFD`` tag. (see :ref:`MultiPage SubIFD `) - -Directory query functions :c:func:`TIFFCurrentDirectory`, -:c:func:`TIFFCurrentDirOffset`, :c:func:`TIFFLastDirectory` and -:c:func:`TIFFNumberOfDirectories` retrieve information about directories -in an open TIFF file. Be aware that until a directory is -not written to file AND read back, the query functions won't retrieve -the correct information! - -Return values -------------- - -On successful return 1 is returned. Otherwise, 0 is returned if *dirnum* -or *diroff* specifies a non-existent directory, or if an error was -encountered while reading the directory's contents. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``"%s: Error fetching directory count"``: - - An error was encountered while reading the "directory count" field. - -``"%s: Error fetching directory link"``: - - An error was encountered while reading the "link value" that points to the - next directory in a file. - -See also --------- - -:doc:`TIFFquery` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFCreateDirectory` (3tiff), -:doc:`TIFFCustomDirectory` (3tiff), -:doc:`TIFFWriteDirectory` (3tiff), -:doc:`TIFFReadDirectory` (3tiff), -:doc:`/multi_page`, -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFSetField.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFSetField.rst deleted file mode 100644 index 2283d3e69..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFSetField.rst +++ /dev/null @@ -1,402 +0,0 @@ -TIFFSetField -============ - -Synopsis --------- - -.. highlight:: c - -:: - - #include - #include " - -.. c:function:: int TIFFSetField(TIFF* tif, ttag_t tag, ...) - -.. c:function:: int TIFFVSetField(TIFF* tif, ttag_t tag, va_list ap) - -.. c:function:: int TIFFUnsetField(TIFF* tif, uint32_t tag) - -Description ------------ - -:c:func:`TIFFSetField` sets the value of a field or pseudo-tag in the -current directory associated with the open TIFF file *tif*. -(A *pseudo-tag* is a parameter that is used to control the operation of -the TIFF library but whose value is not read or written to the underlying -file.) To set the value of a field the file must have been previously -opened for writing with :c:func:`TIFFOpen`. -Pseudo-tags can be set whether the file was opened for reading or writing. -The field is identified by *tag*, one of the values defined in the include -file :file:`tiff.h` (see also the table below). -The actual value is specified using a variable argument list, as -prescribed by the :file:`stdarg.h` interface. - -:c:func:`TIFFVSetField` is functionally equivalent to :c:func:`TIFFSetField` -except that it takes a pointer to a variable argument list. -:c:func:`TIFFVSetField` is useful for writing routines that are layered on -top of the functionality provided by :c:func:`TIFFSetField`. - -:c:func:`TIFFUnsetField` clears the contents of the field in the internal -structure. If it is a custom field, it is removed from the list of known tags. - -The tags understood by :program:`libtiff`, the number of parameter values, -and the expected types for the parameter values are shown below. -The data types are: - -.. list-table:: Tag data types - :widths: 5 15 - :header-rows: 1 - - * - Type - - Description - - * - :c:expr:`char*` - - a null-terminated string corresponding to the ``ASCII`` data type - * - :c:expr:`uint16_t` - - an unsigned 16-bit value - * - :c:expr:`uint32_t` - - an unsigned 32-bit value; - * - :c:expr:`uint16_t*` - - an array of unsigned 16-bit values. - * - :c:expr:`void*` - - an array of data values of unspecified type. - -Consult the TIFF specification for information on the meaning of each tag. - - .. list-table:: Tag properties - :widths: 5 3 5 10 - :header-rows: 1 - - * - Tag name - - Count - - Types - - Notes - - - * - :c:macro:`TIFFTAG_ARTIST` - - 1 - - :c:expr:`char*` - - - * - :c:macro:`TIFFTAG_BADFAXLINES` - - 1 - - :c:expr:`uint32_t` - - - * - :c:macro:`TIFFTAG_BITSPERSAMPLE` - - 1 - - :c:expr:`uint16_t` - - † - * - :c:macro:`TIFFTAG_CLEANFAXDATA` - - 1 - - :c:expr:`uint16_t` - - - * - :c:macro:`TIFFTAG_COLORMAP` - - 3 - - :c:expr:`uint16_t*` - - :c:expr:`1< 0 - * - :c:macro:`TIFFTAG_SAMPLEFORMAT` - - 1 - - :c:expr:`uint16_t` - - † - * - :c:macro:`TIFFTAG_SAMPLESPERPIXEL` - - 1 - - :c:expr:`uint16_t` - - † value must be ≤ 4 - * - :c:macro:`TIFFTAG_SMAXSAMPLEVALUE` - - 1 - - :c:expr:`double` - - - * - :c:macro:`TIFFTAG_SMINSAMPLEVALUE` - - 1 - - :c:expr:`double` - - - * - :c:macro:`TIFFTAG_SOFTWARE` - - 1 - - :c:expr:`char*` - - - * - :c:macro:`TIFFTAG_STONITS` - - 1 - - :c:expr:`double` - - † - * - :c:macro:`TIFFTAG_SUBFILETYPE` - - 1 - - :c:expr:`uint32_t` - - - * - :c:macro:`TIFFTAG_SUBIFD` - - 2 - - :c:expr:`uint16_t`, :c:expr:`uint64_t*` - - count, offsets array - * - :c:macro:`TIFFTAG_TARGETPRINTER` - - 1 - - :c:expr:`char*` - - - * - :c:macro:`TIFFTAG_THRESHHOLDING` - - 1 - - :c:expr:`uint16_t` - - - * - :c:macro:`TIFFTAG_TILEDEPTH` - - 1 - - :c:expr:`uint32_t` - - † - * - :c:macro:`TIFFTAG_TILELENGTH` - - 1 - - :c:expr:`uint32_t` - - † must be a multiple of 8 - * - :c:macro:`TIFFTAG_TILEWIDTH` - - 1 - - :c:expr:`uint32_t` - - † must be a multiple of 8 - * - :c:macro:`TIFFTAG_TRANSFERFUNCTION` - - 1 or 3‡ - - :c:expr:`uint16_t*` - - :c:expr:`1< - -.. c:function:: TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc extender) - -Description ------------ - -:c:func:`TIFFSetTagExtender` is used to register the merge function -for user defined tags as an extender callback with ``libtiff``. -A brief description can be found at :ref:`define_application_tags`. - -.. note:: - - :c:func:`TIFFSetTagExtender` cannot be used to extend custom directories - (for example EXIF, GPS or other custom directories). - Only the TIFF directory can be extended with additional tags. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`/addingtags` (3tiff), -:doc:`TIFFMergeFieldInfo` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFStrileQuery.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFStrileQuery.rst deleted file mode 100644 index f8631afd1..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFStrileQuery.rst +++ /dev/null @@ -1,75 +0,0 @@ -TIFFStrileQuery -=============== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: uint64_t TIFFGetStrileByteCount(TIFF* tif, uint32_t strile); - -.. c:function:: uint64_t TIFFGetStrileOffset(TIFF* tif, uint32_t strile); - -.. c:function:: uint64_t TIFFGetStrileByteCountWithErr(TIFF* tif, uint32_t strile, int *pbErr); - -.. c:function:: uint64_t TIFFGetStrileOffsetWithErr(TIFF* tif, uint32_t strile, int *pbErr); - -Description ------------ - -Make defer strile offset/bytecount loading available at runtime -and add per-strile offset/bytecount loading capabilities. Part of -this commit makes the behaviour that was previously met when ``libtiff`` -was compiled with ``-DDEFER_STRILE_LOAD`` available for default builds. - -When specifying the new ``D`` (Deferred) :c:func:`TIFFOpen` flag, -the loading of strile offset/bytecount is defered. -In that mode, the ``StripOffsets`` / ``StripByteCounts`` or -``TileOffsets`` / ``TileByteCounts`` arrays are only loaded when first -accessed. This can speed-up the opening of files stored on the network -when just metadata retrieval is needed. - -Another addition is the capability of loading only the values of -the offset/bytecount of the strile of interest instead of the -whole array. This is enabled with the new ``O`` (Ondemand) flag of -:c:func:`TIFFOpen` (which implies ``D``). - -The public :c:func:`TIFFGetStrileOffset`, :c:func:`TIFFGetStrileOffsetWithErr`, -:c:func:`TIFFGetStrileByteCount` and :c:func:`TIFFGetStrileByteCountWithErr` -functions have been added to API. -They are of particular interest when using sparse files (with -``offset == bytecount == 0``) and you want to detect if a strile is -present or not without decompressing the data, or updating an -existing sparse file. - -:c:func:`TIFFGetStrileByteCount` returns the value of the TileByteCounts / -StripByteCounts array for the specified tile/strile. - -:c:func:`TIFFGetStrileByteCountWithErr` additionally provides *pbErr* -as an *int* pointer to an error return variable, -which is set to "0" for successful return or to "1" for an error return. - -:c:func:`TIFFGetStrileOffset` returns the value of the TileOffsets / -StripOffsets array for the specified tile/strile. - -:c:func:`TIFFGetStrileOffsetWithErr` additionally provides *pbErr* -as an *int* pointer to an error return variable, -which is set to "0" for successful return or to "1" for an error return. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. -Likewise, warning messages are directed to the :c:func:`TIFFWarningExtR` routine. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFDeferStrileArrayWriting` (3tiff) - diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWarning.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWarning.rst deleted file mode 100644 index 48467d793..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWarning.rst +++ /dev/null @@ -1,101 +0,0 @@ -TIFFWarning -=========== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - #include - -.. c:function:: void TIFFWarning(const char* module, const char* fmt, ...) - -.. c:function:: void TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...) - -.. c:function:: void TIFFWarningExtR(TIFF *tif, const char* module, const char* fmt, ...) - -.. c:type:: void (*TIFFWarningHandler)(const char * module, const char* fmt, va_list ap) - -.. c:type:: void (*TIFFWarningHandlerExt)(thandle_t fd, const char* module, const char* fmt, va_list ap) - -.. c:type:: int (*TIFFWarningHandlerExtR)(TIFF* tif, void* user_data, const char* module, const char* fmt, va_list ap) - -.. c:function:: TIFFWarningHandler TIFFSetWarningHandler(TIFFWarningHandler handler) - -.. c:function:: TIFFWarningHandlerExt TIFFSetWarningHandlerExt(TIFFWarningHandlerExt handler) - -Description ------------ - -:c:func:`TIFFWarning` invokes the library-wide warning handler function -to (normally) write a warning message to the ``stderr``. -The *fmt* parameter is a :c:func:`printf` format string, and any number -arguments can be supplied. The *module* parameter is interpreted as a -string that, if non-zero, should be printed before the message; it -typically is used to identify the software module in which a warning is -detected. - -Applications that desire to capture control in the event of a warning -should use :c:func:`TIFFSetWarningHandler` to override the default -warning handler. A :c:macro:`NULL` (0) warning handler function may be -installed to suppress warning messages. - -Two more application-specific warning handler callbacks are available, -each with different call parameters and passing parameters to the handler. -Each handler is also linked with a warning message function, i.e. -:c:func:`TIFFWarningExt` and :c:func:`TIFFWarningExtR` if the application -intends to call the handler with those extended parameters. - -:c:func:`TIFFWarningExt` provides a file handle as parameter. -Within ``libtiff`` :c:func:`TIFFWarningExt` is called passing ``tif->tif_clientdata`` -as *fd*, which represents the TIFF file handle (file descriptor). -The application-specific and library-wide handler for :c:func:`TIFFWarningExt` -is setup with :c:func:`TIFFSetWarningHandlerExt`. - -:c:func:`TIFFWarningExtR` (introduced with libtiff 4.5) is called with its -TIFF handle and thus provides access to a per-TIFF handle (re-entrant) -warning handler. That means for different TIFF handles, different warning -handlers can be setup. This application-specific handler -can be setup when a TIFF file is opened with one of the following functions: -:c:func:`TIFFOpenExt`, :c:func:`TIFFOpenWExt`, :c:func:`TIFFFdOpenExt` -or :c:func:`TIFFClientOpenExt`. -Furthermore, a **custom defined data structure** *user_data* for the -warning handler can be given along. - -Note ----- - -Both functions :c:func:`TIFFWarning` and :c:func:`TIFFWarningExt` -each attempt to call both handler functions if they are defined. -First :c:func:`TIFFWarningHandler` is called and then :c:func:`TIFFWarningHandlerExt`. -However, :c:func:`TIFFWarning` passes a "0" as a file handle to -:c:func:`TIFFWarningHandlerExt`. - -:c:func:`TIFFWarningExtR` tries first to call the per-TIFF handle defined -warning handler. If :c:func:`TIFFWarningHandlerExtR` is not defined or -returns 0, :c:func:`TIFFWarningHandler` and then :c:func:`TIFFWarningHandlerExt` -are called. From libtiff 4.5 onwards :c:func:`TIFFWarningExtR` is used -within the ``libtiff`` library. - -Return values -------------- - -:c:func:`TIFFSetWarningHandler` and :c:func:`TIFFSetWarningHandlerExt` -returns a reference to the previous warning handler function. - -:c:func:`TIFFWarningHandlerExtR` returns an integer as "stop" to control the call -of furhter warning handler functions within :c:func:`TIFFWarningExtR`: - - - 0: both functions :c:func:`TIFFWarningHandler` and :c:func:`TIFFWarningHandlerExt` are called. - - non-zero: no further warning message function is called. - -See also --------- - -:doc:`TIFFError` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`libtiff` (3tiff), -printf (3) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteDirectory.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteDirectory.rst deleted file mode 100644 index 00bac0b1f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteDirectory.rst +++ /dev/null @@ -1,140 +0,0 @@ -TIFFWriteDirectory -================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFWriteDirectory(TIFF* tif) - -.. c:function:: int TIFFRewriteDirectory(TIFF* tif) - -.. c:function:: int TIFFCheckpointDirectory(TIFF* tif) - -.. c:function:: void TIFFSetWriteOffset(TIFF* tif, toff_t off) - -.. c:function:: int TIFFWriteCheck(TIFF* tif, int tiles, const char* module) - -Description ------------ - -:c:func:`TIFFWriteDirectory` will write the contents of the current -directory (IFD) to the file and setup to create a new directory (IFD) -using :c:func:`TIFFCreateDirectory`. -Applications only need to call :c:func:`TIFFWriteDirectory` -when writing multiple subfiles (images) to a single TIFF file. -This is called "multi-page TIFF" or "multi-image TIFF" -(see :doc:`/multi_page`). -:c:func:`TIFFWriteDirectory` is automatically called by -:c:func:`TIFFClose` and :c:func:`TIFFFlush` to write a modified -directory if the file is open for writing. - -The :c:func:`TIFFRewriteDirectory` function operates similarly to -:c:func:`TIFFWriteDirectory`, but can be called with directories -previously read or written that already have an established location -in the file. It will rewrite the directory, but instead of placing it -at its old location (as :c:func:`TIFFWriteDirectory` would) it will -place them at the end of the file, correcting the pointer from the -preceding directory or file header to point to it's new location. This -is particularly important in cases where the size of the directory and -pointed to data has grown, so it won't fit in the space available at the -old location. - -The :c:func:`TIFFCheckpointDirectory` writes the current state of the -tiff directory into the file to make what is currently in the file -readable. Unlike :c:func:`TIFFWriteDirectory`, -:c:func:`TIFFCheckpointDirectory` does not free up the directory data -structures in memory, so they can be updated (as strips/tiles are -written) and written again. Reading such a partial file you will at -worst get a tiff read error for the first strip/tile encountered that -is incomplete, but you will at least get all the valid data in the file -before that. When the file is complete, just use -:c:func:`TIFFWriteDirectory` as usual to finish it off cleanly. - -The :c:func:`TIFFSetWriteOffset` sets the current write offset. -This should only be used to set the offset to a known previous location -(very carefully), or to 0 so that the next write gets appended to the end -of the file. - -The :c:func:`TIFFWriteCheck` verify file is writable and that the directory -information is setup properly. In doing the latter we also "freeze" -the state of the directory so that important information is not changed. - -Return values -------------- - -1 is returned when the contents are successfully written to the file. -Otherwise, 0 is returned if an error was encountered when writing -the directory contents. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``"Error post-encoding before directory write"``: - - Before writing the contents of the current directory, any pending data are - flushed. This message indicates that an error occurred while doing this. - -``"Error flushing data before directory write"``: - - Before writing the contents of the current directory, any pending data are - flushed. This message indicates that an error occurred while doing this. - -``"Cannot write directory, out of space"``: - - There was not enough space to allocate a temporary area for the directory - that was to be written. - -``"Error writing directory count"``: - - A write error occurred when writing the count of fields in the directory. - -``"Error writing directory contents"``: - - A write error occurred when writing the directory fields. - -``"Error writing directory link"``: - - A write error occurred when writing the link to the next directory. - -``Error writing data for field "%s"``: - - A write error occurred when writing indirect data for the specified field. - -``"Error writing TIFF header"``: - - A write error occurred when re-writing header at the front of the file. - -``"Error fetching directory count"``: - - A read error occurred when fetching the directory count field for - a previous directory. - This can occur when setting up a link to the directory that is being - written. - -``"Error fetching directory link"``: - - A read error occurred when fetching the directory link field for - a previous directory. - This can occur when setting up a link to the directory that is being - written. - -See also --------- - -:doc:`TIFFquery` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFCreateDirectory` (3tiff), -:doc:`TIFFCustomDirectory` (3tiff), -:doc:`TIFFSetDirectory` (3tiff), -:doc:`TIFFReadDirectory` (3tiff), -:doc:`TIFFError` (3tiff), -:doc:`/multi_page`, -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteEncodedStrip.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteEncodedStrip.rst deleted file mode 100644 index 24fe8d899..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteEncodedStrip.rst +++ /dev/null @@ -1,80 +0,0 @@ -TIFFWriteEncodedStrip -===================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tsize_t TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) - -Description ------------ - -Compress *size* bytes of raw data from *buf* and write the result to the -specified strip; replacing any previously written data. Note that the -value of *strip* is a "raw strip number". That is, the caller must take -into account whether or not the data are organized in separate planes -(``PlanarConfiguration`` = 2). - -Notes ------ - -The library writes encoded data using the native machine byte order. -Correctly implemented TIFF readers are expected to do any necessary -byte-swapping to correctly process image data with ``BitsPerSample`` -greater than 8. - -The strip number must be valid according to the current settings of the -``ImageLength`` and ``RowsPerStrip`` tags. -An image may be dynamically grown by increasing the value of -``ImageLength`` prior to each call to ``TIFFWriteEncodedStrip``. - -Return values -------------- - --1 is returned if an error was encountered. Otherwise, the value of -*size* is returned. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``%s: File not open for writing``: - - The file was opened for reading, not writing. - -``Can not write scanlines to a tiled image``: - - The image is assumed to be organized in tiles because the - ``TileWidth`` and ``TileLength`` tags have been set with - :c:func:`TIFFSetField`. - -``%s: Must set "ImageWidth" before writing data\fP``: - - The image's width has not be set before the first write. See - :c:func:`TIFFSetField` for information on how to do this. - -``%s: Must set "PlanarConfiguration" before writing data``: - - The organization of data has not be defined before the first - write. See :c:func:`TIFFSetField` for information on how to do - this. - -``%s: No space for strip arrays"``: - - There was not enough space for the arrays that hold strip offsets and - byte counts. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFWriteScanline` (3tiff), -:doc:`TIFFWriteRawStrip` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteEncodedTile.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteEncodedTile.rst deleted file mode 100644 index efb07ba9a..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteEncodedTile.rst +++ /dev/null @@ -1,76 +0,0 @@ -TIFFWriteEncodedTile -==================== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tsize_t TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_t size) - -Description ------------ - -Compress *size* bytes of raw data from *buf* and **append** the result -to the end of the specified tile. Note that the value of *tile* is a -"raw tile number". That is, the caller must take into account whether -or not the data are organized in separate planes -(``PlanarConfiguration`` = 2). -:c:func:`TIFFComputeTile` automatically does this when converting an -(x,y,z,sample) coordinate quadruple to a tile number. - -Notes ------ - -The library writes encoded data using the native machine byte order. -Correctly implemented TIFF readers are expected to do any necessary -byte-swapping to correctly process image data with ``BitsPerSample`` -greater than 8. - -Return values -------------- - --1 is returned if an error was encountered. Otherwise, the value of -*size* is returned. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``%s: File not open for writing``: - - The file was opened for reading, not writing. - -``Can not write tiles to a stripped image``: - - The image is assumed to be organized in strips because neither of the - ``TileWidth`` or ``TileLength`` tags have been set with - :c:func:`TIFFSetField`. - -``%s: Must set "ImageWidth" before writing data``: - - The image's width has not been set before the first write. See - :c:func:`TIFFSetField` for information on how to do this. - -``%s: Must set "PlanarConfiguration" before writing data``: - - The organization of data has not be defined before the first write. - See :c:func:`TIFFSetField` for information on how to do this. - -``%s: No space for tile arrays"``: - - There was not enough space for the arrays that hold tile offsets and - byte counts. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFWriteTile` (3tiff), -:doc:`TIFFWriteRawTile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteRawStrip.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteRawStrip.rst deleted file mode 100644 index 73845ee4f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteRawStrip.rst +++ /dev/null @@ -1,75 +0,0 @@ -TIFFWriteRawStrip -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tsize_t TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t buf, tsize_t size) - -Description ------------ - -Append *size* bytes of raw data to the specified strip. - -Notes ------ - -The strip number must be valid according to the current settings of the -``ImageLength`` and ``RowsPerStrip`` tags. -An image may be dynamically grown by increasing the value of -``ImageLength`` prior to each call to :c:func:`TIFFWriteRawStrip`. - -Return values -------------- - --1 is returned if an error occurred. Otherwise, the value of *size* is -returned. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``%s: File not open for writing``: - - The file was opened for reading, not writing. - -``Can not write scanlines to a tiled image``: - - The image is assumed to be organized in tiles because the - ``TileWidth`` and ``TileLength`` tags have been set with - :c:func:`TIFFSetField`. - -``%s: Must set "ImageWidth" before writing data``: - - The image's width has not be set before the first write. - See :c:func:`TIFFSetField` for information on how to do this. - -``%s: Must set "PlanarConfiguration" before writing data``: - - The organization of data has not be defined before the first write. - See :c:func:`TIFFSetField` for information on how to do this. - -``%s: No space for strip arrays"``: - - There was not enough space for the arrays that hold strip - offsets and byte counts. - -``%s: Strip %d out of range, max %d``: - - The specified strip is not a valid strip according to the - currently specified image dimensions. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFWriteEncodedStrip` (3tiff), -:doc:`TIFFWriteScanline` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteRawTile.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteRawTile.rst deleted file mode 100644 index ba547b5fe..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteRawTile.rst +++ /dev/null @@ -1,67 +0,0 @@ -TIFFWriteRawTile -================ - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tsize_t TIFFWriteRawTile(TIFF* tif, ttile_t tile, tdata_t buf, tsize_tsize) - -Description ------------ - -Append *size* bytes of raw data to the specified tile. - -Return values -------------- - --1 is returned if an error occurred. Otherwise, the value of *size* is -returned. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``%s: File not open for writing``: - - The file was opened for reading, not writing. - -``Can not write tiles to a stripped image``: - - The image is assumed to be organized in strips because neither of the - ``TileWidth`` or ``TileLength`` tags have been set with - :c:func:`TIFFSetField`. - -``%s: Must set "ImageWidth" before writing data``: - - The image's width has not be set before the first write. - See :c:func:`TIFFSetField` for information on how to do this. - -``%s: Must set "PlanarConfiguration" before writing data``: - - The organization of data has not be defined before the first write. - See :c:func:`TIFFSetField` for information on how to do this. - -``%s: No space for tile arrays``: - - There was not enough space for the arrays that hold tile offsets and - byte counts. - -``%s: Specified tile %d out of range, max %d``: - - The specified tile is not valid according to the currently specified - image dimensions. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFWriteEncodedTile` (3tiff), -:doc:`TIFFWriteScanline` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteScanline.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteScanline.rst deleted file mode 100644 index 548442d9f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteScanline.rst +++ /dev/null @@ -1,124 +0,0 @@ -TIFFWriteScanline -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32_t row, tsample_t sample) - -Description ------------ - -Write data to a file at the specified row. The *sample* parameter is -used only if data are organized in separate planes -(``PlanarConfiguration`` = 2). -The data are assumed to be uncompressed and in the native bit- and -byte-order of the host machine. The data written to the file is -compressed according to the compression scheme of the current -TIFF directory (see further below). If the current scanline is past the -end of the current subfile, the ``ImageLength`` field is automatically -increased to include the scanline (except for ``PlanarConfiguration`` = 2, -where the ``ImageLength`` cannot be changed once the first data are -written). If the ``ImageLength`` is increased, the ``StripOffsets`` -and ``StripByteCounts`` fields are similarly enlarged to reflect data -written past the previous end of image. - -Notes ------ - -The library writes encoded data using the native machine byte order. -Correctly implemented TIFF readers are expected to do any necessary -byte-swapping to correctly process image data with ``BitsPerSample`` -greater than 8. The library attempts to hide bit-ordering differences -between the image and the native machine by converting data from the -native machine order. - -In C++ the *sample* parameter defaults to 0. - -Once data are written to a file for the current directory, the values of -certain tags may not be altered; see :c:func:`TIFFSetField` for more -information. - -It is not possible to write scanlines to a file that uses a tiled -organization. The routine :c:func:`TIFFIsTiled` can be used to -determine if the file is organized as tiles or strips. - -Return values -------------- - -:c:func:`TIFFWriteScanline` returns -1 if it immediately detects an -error and 1 for a successful write. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -``%s: File not open for writing``: - - The file was opened for reading, not writing. - -``"Can not write scanlines to a tiled image"``: - - An attempt was made to write a scanline to a tiled image. The image - is assumed to be organized in tiles because the ``TileWidth`` and - ``TileLength`` tags have been set with :c:func:`TIFFSetField`. - -``"Compression algorithm does not support random access"``: - - Data was written in a non-sequential order to a file that uses a - compression algorithm and that has ``RowsPerStrip`` greater than one. - That is, data in the image is to be stored in a compressed form, and - with multiple rows packed into a strip. In this case, the library - does not support random access to the data. The data should either be - written as entire strips, sequentially by rows, or the value of - ``RowsPerStrip`` should be set to one. - -``%s: Must set "ImageWidth" before writing data``: - - The image's width has not be set before the first write. - See :c:func:`TIFFSetField` for information on how to do this. - -``%s: Must set "PlanarConfiguration" before writing data``: - - The organization of data has not be defined before the first write. - See :c:func:`TIFFSetField` for information on how to do this. - -``Can not change "ImageLength" when using separate planes``: - - Separate image planes are being used (``PlanarConfiguration`` = 2), - but the number of rows has not been specified before the first write. - The library supports the dynamic growth of an image only when data - are organized in a contiguous manner (``PlanarConfiguration`` = 1). - -``"%d: Sample out of range, max %d"``: - - The *sample* parameter was greater than the value of the - ``SamplesPerPixel`` tag. - -``%s: No space for strip arrays``: - - There was not enough space for the arrays that hold strip offsets and - byte counts. - -Bugs ----- - -Writing subsampled YCbCR data does not work correctly because, for -``PlanarConfiguration`` = 2 the size of a scanline is not calculated on -a per-sample basis, and for ``PlanarConfiguration`` = 1 the library -does not pack the block-interleaved samples. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFWriteEncodedStrip` (3tiff), -:doc:`TIFFWriteRawStrip` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteTile.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteTile.rst deleted file mode 100644 index db8afd16e..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFWriteTile.rst +++ /dev/null @@ -1,51 +0,0 @@ -TIFFWriteTile -============= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -TIFFWriteTile \- encode and write a tile of data to an open TIFF file - -.. c:function:: tsize_t TIFFWriteTile(TIFF* tif, tdata_t buf, uint32_t x, uint32_t y, uint32_t z, tsample_t sample) - -Description ------------ - -Write the data for the tile *containing* the specified coordinates. The -data in *buf* are (potentially) compressed, and written to the -indicated file, normally being appended to the end of the file. The -buffer must be contain an entire tile of data. Applications should -call the routine :c:func:`TIFFTileSize` to find out the size (in bytes) -of a tile buffer. The *x* and *y* parameters are always used by -:c:func:`TIFFWriteTile`. The *z* parameter is used if the image is -deeper than 1 slice (``ImageDepth`` > 1). -The *sample* parameter is used only if data are organized in separate -planes (``PlanarConfiguration`` = 2). - -Return values -------------- - -:c:func:`TIFFWriteTile` returns -1 if it detects an error; otherwise -the number of bytes in the tile is returned. - -Diagnostics ------------ - -All error messages are directed to the :c:func:`TIFFErrorExtR` routine. - -See also --------- - -:doc:`TIFFtile` (3tiff), -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadTile` (3tiff), -:doc:`TIFFWriteScanline` (3tiff), -:doc:`TIFFWriteEncodedTile` (3tiff), -:doc:`TIFFWriteRawTile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFbuffer.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFbuffer.rst deleted file mode 100644 index 4280b23fc..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFbuffer.rst +++ /dev/null @@ -1,57 +0,0 @@ -TIFFbuffer -========== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - - -.. c:function:: int TIFFReadBufferSetup(TIFF* tif, tdata_t buffer, tsize_t size) -.. c:function:: int TIFFWriteBufferSetup(TIFF* tif, tdata_t buffer, tsize_t size) - -Description ------------ - -The following routines are provided for client-control of the I/O buffers -used by the library. Applications need never use these routines; they are -provided only for "intelligent clients" that wish to optimize memory usage -and/or eliminate potential copy operations that can occur when working with -images that have data stored without compression. - -:c:func:`TIFFReadBufferSetup` sets up the data buffer used to read raw (encoded) -data from a file. If the specified pointer is :c:macro:`NULL` (zero), then a -buffer of the appropriate size is allocated. Otherwise the caller must guarantee -that the buffer is large enough to hold any individual strip of raw data. -:c:func:`TIFFReadBufferSetup` returns a non-zero value if the setup was successful -and zero otherwise. - -:c:func:`TIFFWriteBufferSetup` sets up the data buffer used to write raw (encoded) -data to a file. If the specified *size* is -1, then the buffer size is selected to -hold a complete tile or strip, or at least 8 kilobytes, whichever is greater. If -the specified *buffer* is :c:macro:`NULL` (zero), then a buffer of the appropriate -size is dynamically allocated. -:c:func:`TIFFWriteBufferSetup` returns a non-zero value if the setup was successful -and zero otherwise. - -Diagnostics ------------ - -``%s: No space for data buffer at scanline %ld``: - - :c:func:`TIFFReadBufferSetup` was unable to dynamically allocate space - for a data buffer. - -``%s: No space for output buffer``: - - :c:func:`TIFFWriteBufferSetup` was unable to dynamically allocate space - for a data buffer. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFcodec.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFcodec.rst deleted file mode 100644 index d9f658d7f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFcodec.rst +++ /dev/null @@ -1,75 +0,0 @@ -TIFFcodec -========= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: const TIFFCodec* TIFFFindCODEC(uint16_t scheme) - -.. c:function:: TIFFCodec* TIFFRegisterCODEC(uint16_t scheme, const char *method, TIFFInitMethod init) - -.. c:function:: void TIFFUnRegisterCODEC(TIFFCodec * codec) - -.. c:function:: int TIFFIsCODECConfigured(uint16_t scheme) - -.. c:function:: TIFFCodec* TIFFGetConfiguredCODECs(uint16_t scheme) - -.. c:function:: int TIFFSetCompressionScheme(TIFF* tif, int scheme) - - -Description ------------ - -:program:`libtiff` supports a variety of compression schemes implemented -by software *codecs*. Each codec adheres to a modular interface that -provides for the decoding and encoding of image data; as well as some -other methods for initialization, setup, cleanup, and the control of -default strip and tile sizes. Codecs are identified by the associated -value of the TIFF ``Compression`` tag; e.g. 5 for LZW compression. - -.. ToDo: Describe functionality of next functions - -:c:func:`TIFFFindCODEC` ?????? - -:c:func:`TIFFUnRegisterCODEC` ????? - -The :c:func:`TIFFRegisterCODEC` routine can be used to augment or -override the set of codecs available to an application. If the -specified *scheme* already has a registered codec then it is -*overridden* and any images with data encoded with this compression -scheme will be decoded using the supplied codec. - -:c:func:`TIFFIsCODECConfigured` returns 1 if the codec is configured -and working. Otherwise 0 will be returned. - -:c:func:`TIFFGetConfiguredCODECs` gets list of configured codecs, -both built-in and registered by user. Function returns array of -:c:type:`TIFFCodec` records (the last record should be NULL) or NULL -if function failed. Caller is responsible to free this structure. - -:c:func:`TIFFSetCompressionScheme` ???? - - -Diagnostics ------------ - -``No space to register compression scheme %s``: - - :c:func:`TIFFRegisterCODEC` was unable to allocate memory for the - data structures needed to register a codec. - -``Cannot remove compression scheme %s; not registered``: - - :c:func:`TIFFUnRegisterCODEC` did not locate the specified codec in - the table of registered compression schemes. - -See also --------- - -:doc:`libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFcolor.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFcolor.rst deleted file mode 100644 index 3dbd4f7c4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFcolor.rst +++ /dev/null @@ -1,211 +0,0 @@ -TIFFcolor -========= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *ycbcr, float *luma, float *refBlackWhite) - -.. c:function:: void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32_t Y, int32_t Cb, int32_t Cr, uint32_t *R, uint32_t *G, uint32_t *B) - -.. c:function:: int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *displayw, float *refWhite) - -.. c:function:: void TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32_t L, int32_t a, int32_t b, float *X, float *Y, float *Z) - -.. c:function:: void TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z, uint32_t *R, uint32_t *G, uint32_t *B) - -Description ------------ - -TIFF supports several color spaces for images stored in that format. There is -usually a problem of application to handle the data properly and convert -between different colorspaces for displaying and printing purposes. To -simplify this task ``libtiff`` implements several color conversion routines -itself. In particular, these routines used in the :doc:`TIFFRGBAImage` -interface. - -:c:func:`TIFFYCbCrToRGBInit` used to initialize *YCbCr* to *RGB* -conversion state. Allocating and freeing of the *ycbcr* structure -belongs to programmer. :c:struct:`TIFFYCbCrToRGB` is defined in -:file:`tiffio.h` as: - -:: - - typedef struct { /* YCbCr->RGB support */ - TIFFRGBValue* clamptab; /* range clamping table */ - int* Cr_r_tab; - int* Cb_b_tab; - int32_t* Cr_g_tab; - int32_t* Cb_g_tab; - int32_t* Y_tab; - } TIFFYCbCrToRGB; - -*luma* is a float array of three values representing proportions of the -red, green and blue in luminance, Y (see section 21 of the TIFF 6.0 -specification, where YCbCr images are discussed). -:c:macro:`TIFFTAG_YCBCRCOEFFICIENTS` hold these values in TIFF file. -*refBlackWhite* is a float array of 6 values which specifies a pair of -headroom and footroom image data values (codes) for each image component -(see section 20 of the TIFF 6.0 specification where the colorimetry -fields are discussed). -:c:macro:`TIFFTAG_REFERENCEBLACKWHITE` is responsible for storing these -values in TIFF file. The following code snippet should help to -understand the the technique: - -:: - - float *luma, *refBlackWhite; - uint16_t hs, vs; - - /* Initialize structures */ - ycbcr = (TIFFYCbCrToRGB*) - _TIFFmalloc(TIFFroundup(sizeof(TIFFYCbCrToRGB), sizeof(long)) - + 4*256*sizeof(TIFFRGBValue) - + 2*256*sizeof(int) - + 3*256*sizeof(int32_t)); - if (ycbcr == NULL) { - TIFFError("YCbCr->RGB", - "No space for YCbCr->RGB conversion state"); - exit(0); - } - - TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma); - TIFFGetFieldDefaulted(tif, TIFFTAG_REFERENCEBLACKWHITE, &refBlackWhite); - if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) < 0) { - exit(0); - } - - /* Start conversion */ - uint32_t r, g, b; - uint32_t Y; - int32_t Cb, Cr; - - for each pixel in image { - TIFFYCbCrtoRGB(img->ycbcr, Y, Cb, Cr, &r, &g, &b); - } - - /* Free state structure */ - _TIFFfree(ycbcr); - -:c:func:`TIFFCIELabToRGBInit` initializes the *CIE L\*a\*b\* 1976* to -*RGB* conversion state. :c:struct:`TIFFCIELabToRGB` is defined as: - -:: - - #define CIELABTORGB_TABLE_RANGE 1500 - - typedef struct { /* CIE Lab 1976->RGB support */ - int range; /* Size of conversion table */ - float rstep, gstep, bstep; - float X0, Y0, Z0; /* Reference white point */ - TIFFDisplay display; - float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ - float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ - float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ - } TIFFCIELabToRGB; - -*display* is a display device description, declared as: - -:: - - typedef struct { - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCR; /* Light o/p for reference white */ - float d_YCG; - float d_YCB; - uint32_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; - float d_gammaR; /* Gamma values for the three guns */ - float d_gammaG; - float d_gammaB; - } TIFFDisplay; - -For example, one can use sRGB device, which has the following parameters: - -:: - - TIFFDisplay display_sRGB = { - { /* XYZ -> luminance matrix */ - { 3.2410F, -1.5374F, -0.4986F }, - { -0.9692F, 1.8760F, 0.0416F }, - { 0.0556F, -0.2040F, 1.0570F } - }, - 100.0F, 100.0F, 100.0F, /* Light o/p for reference white */ - 255, 255, 255, /* Pixel values for ref. white */ - 1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel */ - 2.4F, 2.4F, 2.4F, /* Gamma values for the three guns */ - }; - -*refWhite* is a color temperature of the reference white. The -:c:macro:`TIFFTAG_WHITEPOINT` contains the chromaticity of the white -point of the image from where the reference white can be calculated -using following formulae: - -:: - - refWhite_Y = 100.0 - - refWhite_X = whitePoint_x / whitePoint_y * refWhite_Y - - refWhite_Z = (1.0 - whitePoint_x - whitePoint_y) / whitePoint_y * refWhite_X - -The conversion itself performed in two steps: at the first one we will convert -*CIE L\*a\*b\* 1976* to *CIE XYZ* using the :c:func:`TIFFCIELabToXYZ` routine, -and at the second step we will convert *CIE XYZ* to *RGB* using -:c:func:`TIFFXYZToRGB`. Look at the code sample below: - -:: - - float *whitePoint; - float refWhite[3]; - - /* Initialize structures */ - img->cielab = (TIFFCIELabToRGB *) - _TIFFmalloc(sizeof(TIFFCIELabToRGB)); - if (!cielab) { - TIFFError("CIE L*a*b*->RGB", - "No space for CIE L*a*b*->RGB conversion state."); - exit(0); - } - - TIFFGetFieldDefaulted(tif, TIFFTAG_WHITEPOINT, &whitePoint); - refWhite[1] = 100.0F; - refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1]; - refWhite[2] = (1.0F - whitePoint[0] - whitePoint[1]) - / whitePoint[1] * refWhite[1]; - if (TIFFCIELabToRGBInit(cielab, &display_sRGB, refWhite) < 0) { - TIFFError("CIE L*a*b*->RGB", - "Failed to initialize CIE L*a*b*->RGB conversion state."); - _TIFFfree(cielab); - exit(0); - } - - /* Now we can start to convert */ - uint32_t r, g, b; - uint32_t L; - int32_t a, b; - float X, Y, Z; - - for each pixel in image { - TIFFCIELabToXYZ(cielab, L, a, b, &X, &Y, &Z); - TIFFXYZToRGB(cielab, X, Y, Z, &r, &g, &b); - } - - /* Don't forget to free the state structure */ - _TIFFfree(cielab); - -See also --------- - -:doc:`TIFFRGBAImage` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFmemory.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFmemory.rst deleted file mode 100644 index 5408cbc13..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFmemory.rst +++ /dev/null @@ -1,61 +0,0 @@ -TIFFmemory -========== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tdata_t _TIFFmalloc(tsize_t size) - -.. c:function:: tdata_t _TIFFrealloc(tdata_t buffer, tsize_t size) - -.. c:function:: void _TIFFfree(tdata_t buffer) - -.. c:function:: void _TIFFmemset(tdata_t s, int c, tsize_t n) - -.. c:function:: void _TIFFmemcpy(tdata_t dest, const tdata_t src, tsize_t n) - -.. c:function:: int _TIFFmemcmp(const tdata_t s1, const tdata_ts2, tsize_t n) - -.. c:function:: void* _TIFFCheckMalloc(TIFF* tif, tmsize_t nmemb, tmsize_t elem_size, const char* what) - -.. c:function:: void* _TIFFCheckRealloc(TIFF* tif, void* buffer, tmsize_t nmemb, tmsize_t elem_size, const char* what) - -Description ------------ - -These routines are provided for writing portable software that uses -:program:`libtiff`; they hide any memory-management related issues, such as -dealing with segmented architectures found on 16-bit machines. - -:c:func:`_TIFFmalloc` and :c:func:`_TIFFrealloc` are used to dynamically -allocate and reallocate memory used by :program:`libtiff`; such as memory -passed into the I/O routines. Memory allocated through these interfaces is -released back to the system using the :c:func:`_TIFFfree` routine. - -Memory allocated through one of the above interfaces can be set to a known -value using :c:func:`_TIFFmemset`, copied to another memory location using -:c:func:`_TIFFmemcpy`, or compared for equality using :c:func:`_TIFFmemcmp`. -These routines conform to the equivalent C routines: -:c:func:`memset`, :c:func:`memcpy`, :c:func:`memcmp`, respectively. - -:c:func:`_TIFFCheckMalloc` and :c:func:`_TIFFCheckRealloc` are checking for -integer overflow before calling :c:func:`_TIFFmalloc` and :c:func:`_TIFFrealloc`, -respectively. - -Diagnostics ------------ - -None. - -See also --------- - -malloc (3), -memory (3), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFquery.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFquery.rst deleted file mode 100644 index 75ccb4e10..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFquery.rst +++ /dev/null @@ -1,131 +0,0 @@ -TIFFquery -========= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tdir_t TIFFCurrentDirectory(TIFF* tif) - -.. c:function:: uint64_t TIFFCurrentDirOffset(TIFF* tif) - -.. c:function:: int TIFFLastDirectory(TIFF* tif) - -.. c:function:: tdir_t TIFFNumberOfDirectories(TIFF* tif) - -.. c:function:: uint32_t TIFFCurrentRow(TIFF* tif) - -.. c:function:: tstrip_t TIFFCurrentStrip(TIFF* tif) - -.. c:function:: ttile_t TIFFCurrentTile(TIFF* tif) - -.. c:function:: int TIFFFileno(TIFF* tif) - -.. c:function:: char* TIFFFileName(TIFF* tif) - -.. c:function:: int TIFFGetMode(TIFF* tif) - -.. c:function:: int TIFFIsTiled(TIFF* tif) - -.. c:function:: int TIFFIsBigEndian(TIFF* tif) - -.. c:function:: int TIFFIsBigTIFF(TIFF* tif) - -.. c:function:: int TIFFIsByteSwapped(TIFF* tif) - -.. c:function:: int TIFFIsMSB2LSB(TIFF* tif) - -.. c:function:: int TIFFIsUpSampled(TIFF* tif) - -.. c:function:: const char* TIFFGetVersion(void) - -Description ------------ - -The following query routines return status information about the directory -structure of an open TIFF file. - -:c:func:`TIFFCurrentDirectory` returns the index of the current directory -(directories are numbered starting at 0). This number is suitable for -use with the :c:func:`TIFFSetDirectory` routine. -A value of 65535 (non-existing directory) is returned if the directory -has not yet been written to the file after opening it. - -:c:func:`TIFFCurrentDirOffset` returns the file offset of the current -directory (instead of an index). -The file offset is suitable for use with the :c:func:`TIFFSetSubDirectory` -routine. This is required for accessing subdirectories linked through a -``SubIFD`` tag. - -:c:func:`TIFFLastDirectory` returns a non-zero value if the current -directory is the last directory in the file; otherwise zero is returned. - -:c:func:`TIFFNumberOfDirectories` returns the number of directories in a -file. Be aware that just created directories, which are not "written" to -file do not count. - -.. note:: Be aware that the return value of the above directory query functions - is not valid until the directory is "written" to file AND read back - e.g. :c:func:`TIFFSetDirectory` or :c:func:`TIFFReadDirectory`. - -The following query routines return information about an open TIFF file -and its image data. - -:c:func:`TIFFCurrentRow`, :c:func:`TIFFCurrentStrip`, and -:c:func:`TIFFCurrentTile` return the current row, strip, and tile, -respectively, that is being read or written. These values are updated each -time a read or write is done. - -:c:func:`TIFFFileno` returns the underlying file descriptor used to access -the TIFF image in the filesystem. - -:c:func:`TIFFFileName` returns the pathname argument passed to -:c:func:`TIFFOpen` or :c:func:`TIFFFdOpen`. - -:c:func:`TIFFGetMode` returns the mode with which the underlying file -was opened. On UNIX systems, this is the value passed to the -:c:func:`open` (2) system call. - -:c:func:`TIFFIsTiled` returns a non-zero value if the image data has a tiled -organization. Zero is returned if the image data is organized in strips. - -:c:func:`TIFFIsBigEndian` returns a non-zero value if the file is BigEndian -and zero if the file is LittleEndian. - -:c:func:`TIFFIsBigTIFF` returns a non-zero value if the file is in -BigTIFF style. - - -:c:func:`TIFFIsByteSwapped` returns a non-zero value if the image data -was in a different byte-order than the host machine. Zero is returned if -the TIFF file and local host byte-orders are the same. Note that -:c:func:`TIFFReadTile`, :c:func:`TIFFReadEncodedStrip` and -:c:func:`TIFFReadScanline` functions already normally perform byte -swapping to local host order if needed. - -:c:func:`TIFFIsMSB2LSB` returns a non-zero value if the image data is being -returned with bit 0 as the most significant bit. - -:c:func:`TIFFIsUpSampled` returns a non-zero value if image data returned -through the read interface routines is being up-sampled. This can be -useful to applications that want to calculate I/O buffer sizes to reflect -this usage (though the usual strip and tile size routines already do this). - -:c:func:`TIFFGetVersion` returns an ``ASCII`` string that has a version -stamp for the TIFF library software. - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`libtiff` (3tiff), -:doc:`TIFFOpen` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFsize.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFsize.rst deleted file mode 100644 index d0e3e7513..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFsize.rst +++ /dev/null @@ -1,51 +0,0 @@ -TIFFsize -======== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: tsize_t TIFFRasterScanlineSize(TIFF* tif) - -.. c:function:: uint64_t TIFFRasterScanlineSize64(TIFF* tif) - -.. c:function:: tsize_t TIFFScanlineSize(TIFF* tif) - -.. c:function:: uint64_t TIFFScanlineSize64(TIFF* tif) - -Description ------------ - -:c:func:`TIFFScanlineSize` returns the size in bytes of a row of data as -it would be returned in a call to :c:func:`TIFFReadScanline`, or as it -would be expected in a call to :c:func:`TIFFWriteScanline`. -Note that this number may be 1/samples-per-pixel if data is -stored as separate planes. -The `ScanlineSize` in case of YCbCrSubsampling is defined as the -strip size divided by the strip height, i.e. the size of a pack of vertical -subsampling lines divided by vertical subsampling. It should thus make -sense when multiplied by a multiple of vertical subsampling. -:c:func:`TIFFScanlineSize64` returns the size as :c:type:`uint64_t`. - -:c:func:`TIFFRasterScanlineSize` returns the size in bytes of a complete -decoded and packed raster scanline. Note that this value may be different -from the value returned by :c:func:`TIFFScanlineSize` if data is stored -as separate planes. -:c:func:`TIFFRasterScanlineSize64` returns the size as :c:type:`uint64_t`. - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`TIFFOpen` (3tiff), -:doc:`TIFFReadScanline` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFstrip.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFstrip.rst deleted file mode 100644 index 9d61f1fa7..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFstrip.rst +++ /dev/null @@ -1,94 +0,0 @@ -TIFFstrip -========= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: uint32_t TIFFDefaultStripSize(TIFF* tif, uint32_t estimate) - -.. c:function:: tmsize_t TIFFStripSize(TIFF* tif) - -.. c:function:: uint64_t TIFFStripSize64(TIFF* tif) - -.. c:function:: tmsize_t TIFFVStripSize(TIFF* tif, uint32_t nrows) - -.. c:function:: uint64_t TIFFVStripSize64(TIFF* tif, uint32_t nrows) - -.. c:function:: tmsize_t TIFFRawStripSize(TIFF* tif, uint32_t strip) - -.. c:function:: uint64_t TIFFRawStripSize64(TIFF* tif, uint32_t strip) - -.. c:function:: tstrip_t TIFFComputeStrip(TIFF* tif, uint32_t row, tsample_t sample) - -.. c:function:: tstrip_t TIFFNumberOfStrips(TIFF* tif) - -.. c:function:: int TIFFSetupStrips(TIFF* tif) - -Description ------------ - -:c:func:`TIFFDefaultStripSize` returns the number of rows for a -reasonable-sized strip according to the current settings of the -``ImageWidth``, ``BitsPerSample`` and ``SamplesPerPixel``, -tags and any compression-specific requirements. If the *estimate* -parameter, sf non-zero, then it is taken as an estimate of the desired strip -size and adjusted according to any compression-specific requirements. The -value returned by this function is typically used to define the -``RowsPerStrip`` tag. In lieu of any unusual requirements -``TIFFDefaultStripSize`` tries to create strips that have approximately -8 kilobytes of uncompressed data. - -:c:func:`TIFFStripSize` returns the equivalent size for a strip of data -as it would be returned in a call to :c:func:`TIFFReadEncodedStrip` -or as it would be expected in a call to :c:func:`TIFFWriteEncodedStrip`. -If an error occurs, 0 is returned. - -:c:func:`TIFFStripSize64` returns the equivalent size for a strip of data -as :c:type:`uint64_t`. -If an error occurs, 0 is returned. - -:c:func:`TIFFVStripSize` returns the number of bytes in a strip with -*nrows* rows of data. -If an error occurs, 0 is returned. - -:c:func:`TIFFVStripSize64` returns the number of bytes in a strip with -*nrows* rows of data as :c:type:`uint64_t`. -If an error occurs, 0 is returned. - -:c:func:`TIFFRawStripSize` returns the number of bytes in a raw strip -(i.e. not decoded). -If an error occurs, 0xFFFFFFFF `(=(tmsize_t(-1))` is returned. - -:c:func:`TIFFRawStripSize64` returns the number of bytes in a raw strip -as :c:type:`uint64_t`. -If an error occurs, 0xFFFFFFFF `(=(uint64_t(-1))` is returned. - -:c:func:`TIFFComputeStrip` returns the strip that contains the specified -coordinates. A valid strip is always returned; out-of-range coordinate -values are clamped to the bounds of the image. The *row* parameter is -always used in calculating a strip. The *sample* parameter is used only -if data are organized in separate planes (``PlanarConfiguration`` = 2). - -:c:func:`TIFFNumberOfStrips` returns the number of strips in the image. - -:c:func:`TIFFSetupStrips` setup or reset strip parameters and strip array memory. - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`TIFFReadEncodedStrip` (3tiff), -:doc:`TIFFReadRawStrip` (3tiff), -:doc:`TIFFWriteEncodedStrip` (3tiff), -:doc:`TIFFWriteRawStrip` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFswab.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFswab.rst deleted file mode 100644 index 0a61defa3..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFswab.rst +++ /dev/null @@ -1,78 +0,0 @@ -TIFFswab -======== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: const unsigned char* TIFFGetBitRevTable(int reversed) - -.. c:function:: void TIFFReverseBits(u_char* data, unsigned long nbytes) - -.. c:function:: void TIFFSwabShort(uint16_t* data) - -.. c:function:: void TIFFSwabLong(uint32_t* data) - -.. c:function:: void TIFFSwabLong8(uint64_t* lp) - -.. c:function:: void TIFFSwabFloat(float* fp) - -.. c:function:: void TIFFSwabDouble(double *dp) - -.. c:function:: void TIFFSwabArrayOfShort(uint16_t* wp, tmsize_t n) - -.. c:function:: void TIFFSwabArrayOfTriples(uint8_t* tp, tmsize_t n) - -.. c:function:: void TIFFSwabArrayOfLong(uint32_t* lp, tmsize_t n) - -.. c:function:: void TIFFSwabArrayOfLong8(uint64_t* lp, tmsize_t n) - -.. c:function:: void TIFFSwabArrayOfFloat(float* fp, tmsize_t n) - -.. c:function:: void TIFFSwabArrayOfDouble(double* dp, tmsize_t n) - -Description ------------ - -The following routines are used by the library to swap 16-, 32- and 64-bit -data and to reverse the order of bits in bytes. - -:c:func:`TIFFSwabShort` and :c:func:`TIFFSwabLong` and :c:func:`TIFFSwabFloat` -swap the bytes in a single 16- and 32-bit item, respectively. - -:c:func:`TIFFSwabLong8` and :c:func:`TIFFSwabDouble` -swap the bytes in a single 64-bit item. - -:c:func:`TIFFSwabArrayOfTriples` swap the first and the third byte of -each triple (three bytes) within the byte array. The second byte of each -triple stays untouched. - -:c:func:`TIFFSwabArrayOfShort` and :c:func:`TIFFSwabArrayOfLong`, -:c:func:`TIFFSwabArrayOfFloat` swap the bytes in an array of 16- and 32-bit -items, respectively. - -:c:func:`TIFFSwabArrayOfLong8` and :c:func:`TIFFSwabArrayOfDouble` -swap the bytes in an array of 64-bit items. - -:c:func:`TIFFReverseBits` replaces each byte in *data* with the -equivalent bit-reversed value. This operation is performed with a -lookup table, which is returned using the :c:func:`TIFFGetBitRevTable` -function. The *reversed* parameter specifies which table should be -returned. Supply *1* if you want bit reversal table. Supply *0* to get -the table that do not reverse bit values. It is a lookup table that can -be used as an "identity function"; i.e. :c:expr:`TIFFNoBitRevTable[n] == n`. - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFtile.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFtile.rst deleted file mode 100644 index 79a74f665..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/TIFFtile.rst +++ /dev/null @@ -1,93 +0,0 @@ -TIFFtile -======== - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: void TIFFDefaultTileSize(TIFF* tif, uint32_t* tw, uint32_t* th) - -.. c:function:: tsize_t TIFFTileSize(TIFF* tif) - -.. c:function:: uint64_t TIFFTileSize64(TIFF* tif) - -.. c:function:: tsize_t TIFFTileRowSize(TIFF* tif) - -.. c:function:: uint64_t TIFFTileRowSize64(TIFF* tif) - -.. c:function:: tsize_t TIFFVTileSize(TIFF* tif, uint32_t nrows) - -.. c:function:: uint64_t TIFFVTileSize64(TIFF* tif, uint32_t nrows) - -.. c:function:: ttile_t TIFFComputeTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, tsample_t sample) - -.. c:function:: int TIFFCheckTile(TIFF* tif, uint32_t x, uint32_t y, uint32_t z, tsample_t sample) - -.. c:function:: ttile_t TIFFNumberOfTiles(TIFF* tif) - -Description ------------ - -:c:func:`TIFFDefaultTileSize` returns the pixel width and height of a -reasonable-sized tile; suitable for setting up the ``TileWidth`` and -``TileLength`` tags. If the *tw* and *th* values passed in are -non-zero, then they are adjusted to reflect any compression-specific -requirements. The returned width and height are constrained to be a -multiple of 16 pixels to conform with the TIFF specification. - -:c:func:`TIFFTileSize` returns the equivalent size for a tile of data -as it would be returned in a call to :c:func:`TIFFReadTile` or as it -would be expected in a call to :c:func:`TIFFWriteTile`. -:c:func:`TIFFTileSize64` returns a :c:type:`uint64_t` number. -If an error occurs, 0 is returned. - -:c:func:`TIFFVTileSize` returns the number of bytes in a row-aligned -tile with *nrows* of data. -:c:func:`TIFFVTileSize64` returns a :c:type:`uint64_t` number. -If an error occurs, 0 is returned. - -:c:func:`TIFFTileRowSize` returns the number of bytes of a row of data -in a tile. -:c:func:`TIFFTileRowSize64` returns a :c:type:`uint64_t` number. -If an error occurs, 0 is returned. - -:c:func:`TIFFComputeTile` returns the tile that contains the specified -coordinates. A valid tile is always returned; out-of-range coordinate -values are clamped to the bounds of the image. The *x* and *y* -parameters are always used in calculating a tile. The *z* -parameter is used if the image is deeper than 1 slice -(``ImageDepth`` > 1). -The *sample* parameter is used only if data are organized in separate -planes (``PlanarConfiguration`` = 2). - -:c:func:`TIFFCheckTile` returns a non-zero value if the supplied -coordinates are within the bounds of the image and zero otherwise. The -*x* parameter is checked against the value of the ``ImageWidth`` tag. -The *y* parameter is checked against the value of the ``ImageLength`` -tag. The *z* parameter is checked against the value of the -``ImageDepth`` tag (if defined). The *sample* parameter is checked -against the value of the ``SamplesPerPixel`` parameter if the data are -organized in separate planes. - -:c:func:`TIFFNumberOfTiles` returns the number of tiles in the image. - -Diagnostics ------------ - -None. - -See also --------- - -:doc:`TIFFReadEncodedTile` (3tiff), -:doc:`TIFFReadRawTile` (3tiff), -:doc:`TIFFReadTile` (3tiff), -:doc:`TIFFWriteEncodedTile` (3tiff), -:doc:`TIFFWriteRawTile` (3tiff), -:doc:`TIFFWriteTile` (3tiff), -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/_TIFFRewriteField.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/_TIFFRewriteField.rst deleted file mode 100644 index 0f4575ba2..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/_TIFFRewriteField.rst +++ /dev/null @@ -1,33 +0,0 @@ -_TIFFRewriteField -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: int _TIFFRewriteField(TIFF* tif, uint16_t tag, TIFFDataType in_datatype, tmsize_t count, void* data) - -Description ------------ - -:c:func:`_TIFFRewriteField` -Rewrite a field in the directory on disk without regard to updating the -TIFF directory structure in memory. Currently only supported for field -that already exist in the on-disk directory. -Mainly used for updating stripoffset / stripbytecount values after -the directory is already on disk. - -Return values -------------- - -Returns zero on failure, and one on success. - -See also --------- - -:doc:`libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/_TIFFauxiliary.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/_TIFFauxiliary.rst deleted file mode 100644 index 46f9a19f0..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/_TIFFauxiliary.rst +++ /dev/null @@ -1,34 +0,0 @@ -_TIFFauxiliary -================= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. c:function:: uint32_t _TIFFClampDoubleToUInt32(double val) - -.. c:function:: uint32_t _TIFFMultiply32(TIFF* tif, uint32_t first, uint32_t second, const char* where) - -.. c:function:: uint64_t _TIFFMultiply64(TIFF* tif, uint64_t first, uint64_t second, const char* where) - -Description ------------ - -:c:func:`_TIFFClampDoubleToUInt32` clamps double values into the range -of :c:type:`uint32_t` (i.e. 0 .. 0xFFFFFFFF) - -:c:func:`_TIFFMultiply32` and :c:func:`_TIFFMultiply64` checks for -an integer overflow of the multiplication result and return the multiplication -result or `0` if an overflow would happen. -The string `where` is printed in the error message in case an overflow -happens and can be used to indicate where the function was called. - -See also --------- - -:doc:`libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/doc/functions/libtiff.rst b/thirdparty/SDL2_image/external/libtiff/doc/functions/libtiff.rst deleted file mode 100644 index d118dec02..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/functions/libtiff.rst +++ /dev/null @@ -1,843 +0,0 @@ -libtiff -======= - -Synopsis --------- - -.. highlight:: c - -:: - - #include - -.. highlight:: shell - -:: - - cc file.c -ltiff - -Description ------------ - -:program:`libtiff` is a library for reading and writing data files encoded with the -*"Tag Image File"* format, Revision 6.0 (or revision 5.0 or revision 4.0). This file -format is suitable for archiving multi-color and monochromatic image data. - -The library supports several compression algorithms, as indicated by the -``Compression`` field, including: -no compression (1), -CCITT 1D Huffman compression (2), -CCITT Group 3 Facsimile compression (3), -CCITT Group 4 Facsimile compression (4), -Lempel-Ziv & Welch compression (5), -baseline JPEG compression (7), -word-aligned 1D Huffman compression (32771), -PackBits compression (32773). -In addition, several nonstandard compression algorithms are supported: the -4-bit compression algorithm used by the -*ThunderScan* program (32809) (decompression only), -NeXT's 2-bit compression algorithm (32766) (decompression only), -an experimental LZ-style algorithm known as Deflate (32946), -and an experimental CIE LogLuv compression scheme designed -for images with high dynamic range (32845 for LogL and 32845 for LogLuv). -Directory information may be in either little- or big-endian byte order; byte -swapping is automatically done by the library. Data bit ordering may be either -Most Significant Bit (``MSB``) to Least Significant Bit (``LSB``) or -LSB to MSB. -Finally, the library does not support files in which the -``BitsPerSample`` , -``Compression`` , -``MinSampleValue`` , -or -``MaxSampleValue`` -fields are defined differently on a per-sample basis -(in Rev. 6.0 the -``Compression`` -tag is not defined on a per-sample basis, so this is immaterial). - -Data types ----------- - -The library makes extensive use of C typedefs to promote portability. -Two sets of typedefs are used, one for communication with clients -of the library and one for internal data structures and parsing of the -TIFF format. -The following typedefs are exposed to users either through function -definitions or through parameters passed through the varargs interfaces. - -.. highlight:: c - -:: - - typedef uint32_t ttag_t; // directory tag - typedef uint32_t tdir_t; // directory index - typedef uint16_t tsample_t; // sample number - typedef uint32_t tstrip_t; // strip number - typedef uint32_t ttile_t; // tile number - typedef int64_t tmsize_t; // signed size type (int32_t on 32-bit platforms) - typedef tmsize_t tsize_t; // i/o size in bytes - typedef void* tdata_t; // image data ref - typedef void* thandle_t; // client data handle - typedef uint64_t toff_t; // file offset - -Note that -:c:type:`tstrip_t`, -:c:type:`ttile_t`, -and -:c:type:`tsize_t` -are constrained to be no more than 32-bit quantities by 32-bit fields they are -stored in in the -TIFF -image. -Likewise -:c:type:`tsample_t` -is limited by the 16-bit field used to store the -``SamplesPerPixel`` -tag. - -:c:type:`tdir_t` -constrains the maximum number of -IFDs -that may appear in an image and may be an arbitrary size (w/o penalty). -Starting with libtiff 4.5.0, tdir_t is a 32-bit unsigned integer. Previously, -it was a 16-bit unsigned integer. - -:c:type:`ttag_t` -must be either int, unsigned int, pointer, or double because the library uses -a varargs interface and -C restricts the type of the parameter before an ellipsis to be a promoted type. -:c:type:`toff_t` -is defined as :c:type:`uint64_t` because TIFF file offsets are (unsigned) 32-bit -quantities, and BigTIFF file offsets are unsigned 64-bit quantities. -A signed value is used because some interfaces return -1 on -error. Finally, note that user-specified data references are passed as opaque -handles and only cast at the lowest layers where their type is presumed. - -.. TODO: Check why this toff_t was switched to unsigned and update description. - -.. _List_of_routines: - -List of routines ----------------- - -The following routines are part of the library. Consult specific manual pages -for details on their operation; on most systems doing :command:`man function-name` -will work. - -.. list-table:: *Libtiff functions* - :widths: 5 20 - :header-rows: 1 - - * - Name - - Description - * - :c:func:`TIFFAccessTagMethods` - - provides read/write access to the TIFFTagMethods within the TIFF structure - to application code without giving access to the private TIFF structure - * - :c:func:`TIFFCheckpointDirectory` - - writes the current state of the directory - * - :c:func:`TIFFCheckTile` - - very x,y,z,sample is within image - * - :c:func:`TIFFCIELabToRGBInit` - - initialize CIE L*a*b* 1976 to RGB conversion state - * - :c:func:`TIFFCIELabToXYZ` - - perform CIE L*a*b* 1976 to CIE XYZ conversion - * - :c:func:`TIFFCleanup` - - auxiliary function to free the TIFF structure - * - :c:func:`TIFFClientdata` - - return open file's clientdata handle, which represents - the file descriptor used within ``libtiff``. - * - :c:func:`TIFFClientOpen` - - open a file for reading or writing - * - :c:func:`TIFFClientOpenExt` - - open a file for reading or writing with options, - such as re-entrant error and warning handlers may be passed - * - :c:func:`TIFFClose` - - close a previously opened TIFF file - * - :c:func:`TIFFComputeStrip` - - return strip containing y,sample - * - :c:func:`TIFFComputeTile` - - return tile containing x,y,z,sample - * - :c:func:`TIFFCreateCustomDirectory` - - setup for a *custom* directory in a open TIFF file - * - :c:func:`TIFFCreateDirectory` - - setup for a directory in a open TIFF file - * - :c:func:`TIFFCreateEXIFDirectory` - - setup for a *EXIF* custom directory in a open TIFF file within a TIFF tag - * - :c:func:`TIFFCreateGPSDirectory` - - setup for a *GPS* custom directory in a open TIFF file within a TIFF tag - * - :c:func:`TIFFCurrentDirectory` - - return index of current directory - * - :c:func:`TIFFCurrentDirOffset` - - return file offset of the current directory (instead of an index) - * - :c:func:`TIFFCurrentRow` - - return index of current scanline - * - :c:func:`TIFFCurrentStrip` - - return index of current strip - * - :c:func:`TIFFCurrentTile` - - return index of current tile - * - :c:func:`TIFFDataWidth` - - return the size of TIFF data types - * - :c:func:`TIFFDefaultStripSize` - - return number of rows for a reasonable-sized strip according to the - current settings of the ImageWidth, BitsPerSample and SamplesPerPixel, - tags and any compression-specific requirements - * - :c:func:`TIFFDefaultTileSize` - - return pixel width and height of a reasonable-sized tile; - suitable for setting up the TileWidth and TileLength tags - * - :c:func:`TIFFDeferStrileArrayWriting` - - is an advanced writing function to control when/where the - [Strip/Tile][Offsets/ByteCounts] arrays are written into the file, - and must be used in a particular sequence together with - TIFFForceStrileArrayWriting() (see description) - * - :c:func:`TIFFError` - - library-wide error handling function printing to ``stderr`` - * - :c:func:`TIFFErrorExt` - - user-specific library-wide error handling function that can be passed - a file handle, which is set to the open TIFF file within ``libtiff`` - * - :c:func:`TIFFErrorExtR` - - user-specific re-entrant library error handling function, - to which its TIFF structure is passed - containing the pointer to a user-specific data object - * - :c:func:`TIFFFdOpen` - - open a file for reading or writing - * - :c:func:`TIFFFdOpenExt` - - open a file for reading or writing with options, - such as re-entrant error and warning handlers may be passed - * - :c:func:`TIFFFieldDataType` - - get data type from field information - * - :c:func:`TIFFFieldIsAnonymous` - - returns if field was unknown to ``libtiff`` and has been auto-registered - * - :c:func:`TIFFFieldName` - - get field name from field information - * - :c:func:`TIFFFieldPassCount` - - get whether to pass a value count to Get/SetField - * - :c:func:`TIFFFieldReadCount` - - get number of values to be read from field - * - :c:func:`TIFFFieldSetGetCountSize` - - returns size of ``count`` parameter of :c:func:`TIFFSetField` and - :c:func:`TIFFGetField` - * - :c:func:`TIFFFieldSetGetSize` - - return data size in bytes of the field data type used for ``libtiff`` - internal storage. - * - :c:func:`TIFFFieldTag` - - get tag value from field information - * - :c:func:`TIFFFieldWithName` - - get field information given field name - * - :c:func:`TIFFFieldWithTag` - - get field information given tag - * - :c:func:`TIFFFieldWriteCount` - - get number of values to be written to field - * - :c:func:`TIFFFileName` - - return name of open file - * - :c:func:`TIFFFileno` - - return open file descriptor - * - :c:func:`TIFFFindCODEC` - - find standard codec for the specific scheme - * - :c:func:`TIFFFindField` - - get field information given tag and data type - * - :c:func:`TIFFFlush` - - flush all pending writes - * - :c:func:`TIFFFlushData` - - flush pending data writes - * - :c:func:`TIFFForceStrileArrayWriting` - - is an advanced writing function that writes the - [Strip/Tile][Offsets/ByteCounts] arrays at the end of the file (see description) - * - :c:func:`TIFFFreeDirectory` - - release storage associated with a directory - * - :c:func:`TIFFGetBitRevTable` - - return bit reversal table - * - :c:func:`TIFFGetClientInfo` - - returns a pointer to the data of the named entry in the clientinfo-list - * - :c:func:`TIFFGetCloseProc` - - returns a pointer to file close method - * - :c:func:`TIFFGetConfiguredCODECs` - - gets list of configured codecs, both built-in and registered by user - * - :c:func:`TIFFGetField` - - return tag value in current directory - * - :c:func:`TIFFGetFieldDefaulted` - - return tag value in current directory with default value set if the - value is not already set and a default is defined - * - :c:func:`TIFFGetMapFileProc` - - returns a pointer to memory mapping method - * - :c:func:`TIFFGetMode` - - return open file mode - * - :c:func:`TIFFGetReadProc` - - returns a pointer to file read method - * - :c:func:`TIFFGetSeekProc` - - returns a pointer to file seek method - * - :c:func:`TIFFGetSizeProc` - - returns a pointer to file size requesting method - * - :c:func:`TIFFGetStrileByteCount` - - return value of the TileByteCounts/StripByteCounts array for the - specified tile/strile - * - :c:func:`TIFFGetStrileByteCountWithErr` - - same as `TIFFGetStrileByteCount()` and additionally provides an error return - * - :c:func:`TIFFGetStrileOffset` - - return value of the TileOffsets/StripOffsets array for the specified tile/strile - * - :c:func:`TIFFGetStrileOffsetWithErr` - - same as `TIFFGetStrileOffset()` and additionally provides an error return - * - :c:func:`TIFFGetTagListCount` - - return number of entries in the custom tag list - * - :c:func:`TIFFGetTagListEntry` - - return tag number of the (n.th - 1) entry within the custom tag list - * - :c:func:`TIFFGetUnmapFileProc` - - returns a pointer to memory unmapping method - * - :c:func:`TIFFGetVersion` - - return library version string - * - :c:func:`TIFFGetWriteProc` - - returns a pointer to file write method - * - :c:func:`TIFFIsBigEndian` - - returns a non-zero value if the file is BigEndian and zero if the file is - LittleEndian - * - :c:func:`TIFFIsBigTIFF` - - returns a non-zero value if the file is in BigTIFF style - * - :c:func:`TIFFIsByteSwapped` - - return true if image data is byte-swapped - * - :c:func:`TIFFIsCODECConfigured` - - check, whether we have working codec - * - :c:func:`TIFFIsMSB2LSB` - - return true if image data is being returned with bit 0 as the most significant bit - * - :c:func:`TIFFIsTiled` - - return true if image data is tiled - * - :c:func:`TIFFIsUpSampled` - - returns a non-zero value if image data returned through the read interface - Routines is being up-sampled - * - :c:func:`TIFFLastDirectory` - - returns a non-zero value if the current directory is the last directory - in the file; otherwise zero is returned - * - :c:func:`TIFFMergeFieldInfo` - - adds application defined TIFF tags to the list of known ``libtiff`` tags - * - :c:func:`TIFFNumberOfDirectories` - - return number of directories in a file - * - :c:func:`TIFFNumberOfStrips` - - return number of strips in an image - * - :c:func:`TIFFNumberOfTiles` - - return number of tiles in an image - * - :c:func:`TIFFOpen` - - open a file for reading or writing - * - :c:func:`TIFFOpenExt` - - open a file for reading or writing with options, - such as re-entrant error and warning handlers may be passed - * - :c:func:`TIFFOpenW` - - opens a TIFF file with a Unicode filename, for read/writing - * - :c:func:`TIFFOpenWExt` - - opens a TIFF file with a Unicode filename, for read/writing - with options, such as re-entrant error and warning handlers may be passed - * - :c:func:`TIFFOpenOptionsAlloc` - - allocates memory for :c:type:`TIFFOpenOptions` opaque structure - * - :c:func:`TIFFOpenOptionsFree` - - releases the allocated memory for :c:type:`TIFFOpenOptions` - * - :c:func:`TIFFOpenOptionsSetMaxSingleMemAlloc` - - limits the maximum single memory allocation within ``libtiff`` - * - :c:func:`TIFFOpenOptionsSetErrorHandlerExtR` - - setup of a user-specific and per-TIFF handle (re-entrant) error handler - * - :c:func:`TIFFOpenOptionsSetWarningHandlerExtR` - - setup of a user-specific and per-TIFF handle (re-entrant) warning handler - * - :c:func:`TIFFPrintDirectory` - - print description of the current directory - * - :c:func:`TIFFRasterScanlineSize` - - returns the size in bytes of a complete decoded and packed raster scanline - * - :c:func:`TIFFRasterScanlineSize64` - - return size as :c:type:`uint64_t` - * - :c:func:`TIFFRawStripSize` - - return number of bytes in a raw strip - * - :c:func:`TIFFRawStripSize64` - - return number of bytes in a raw strip as :c:type:`uint64_t` - * - :c:func:`TIFFReadBufferSetup` - - specify i/o buffer for reading - * - :c:func:`TIFFReadCustomDirectory` - - read the custom directory from the given offset - and set the context of the TIFF-handle tif to that custom directory - * - :c:func:`TIFFReadDirectory` - - read the next directory - * - :c:func:`TIFFReadEncodedStrip` - - read and decode a strip of data - * - :c:func:`TIFFReadEncodedTile` - - read and decode a tile of data - * - :c:func:`TIFFReadEXIFDirectory` - - read the EXIF directory from the given offset - and set the context of the TIFF-handle tif to that EXIF directory - * - :c:func:`TIFFReadFromUserBuffer` - - replaces the use of :c:func:`TIFFReadEncodedStrip` / :c:func:`TIFFReadEncodedTile` - when the user can provide the buffer for the input data - * - :c:func:`TIFFReadGPSDirectory` - - read the GPS directory from the given offset - and set the context of the TIFF-handle tif to that GPS directory - * - :c:func:`TIFFReadRawStrip` - - read a raw strip of data - * - :c:func:`TIFFReadRawTile` - - read a raw tile of data - * - :c:func:`TIFFReadRGBAImage` - - read an image into a fixed format raster - * - :c:func:`TIFFReadRGBAImageOriented` - - works like :c:func:`TIFFReadRGBAImage` except that the user can specify - the raster origin position - * - :c:func:`TIFFReadRGBAStrip` - - reads a single strip of a strip-based image into memory, storing the - result in the user supplied RGBA raster - * - :c:func:`TIFFReadRGBAStripExt` - - same as :c:func:`TIFFReadRGBAStrip` but providing the parameter `stop_on_error` - * - :c:func:`TIFFReadRGBATile` - - reads a single tile of a tile-based image into memory, storing the - result in the user supplied RGBA raster - * - :c:func:`TIFFReadRGBATileExt` - - same as :c:func:`TIFFReadRGBATile` but providing the parameter `stop_on_error` - * - :c:func:`TIFFReadScanline` - - read and decode a row of data - * - :c:func:`TIFFReadTile` - - read and decode a tile of data - * - :c:func:`TIFFRegisterCODEC` - - override standard codec for the specific scheme - * - :c:func:`TIFFReverseBits` - - reverse bits in an array of bytes - * - :c:func:`TIFFRewriteDirectory` - - operates similarly to :c:func:`TIFFWriteDirectory`, but can be called - with directories previously read or written that already have an established - location in the file and places it at the end of the file - * - :c:func:`TIFFRGBAImageBegin` - - setup decoder state for TIFFRGBAImageGet - * - :c:func:`TIFFRGBAImageEnd` - - release TIFFRGBAImage decoder state - * - :c:func:`TIFFRGBAImageGet` - - read and decode an image - * - :c:func:`TIFFRGBAImageOK` - - is image readable by TIFFRGBAImageGet - * - :c:func:`TIFFScanlineSize` - - return size of a scanline - * - :c:func:`TIFFScanlineSize64` - - return size of a scanline as :c:type:`uint64_t` - * - :c:func:`TIFFSetClientdata` - - set open file's clientdata (file descriptor/handle), - and return previous value - * - :c:func:`TIFFSetClientInfo` - - adds or replaces an entry in the clientinfo-list - * - :c:func:`TIFFSetCompressionScheme` - - set compression scheme - * - :c:func:`TIFFSetDirectory` - - set the current directory - * - :c:func:`TIFFSetErrorHandler` - - set error handler function - * - :c:func:`TIFFSetErrorHandlerExt` - - set error handler function with a file handle as parameter - * - :c:func:`TIFFSetField` - - set a tag's value in the current directory - * - :c:func:`TIFFSetFileName` - - sets the file name in the TIFF-structure and returns the old file name - * - :c:func:`TIFFSetFileno` - - overwrites a copy of the open file's I/O descriptor, and return previous value - (refer to detailed description) - * - :c:func:`TIFFSetMode` - - sets the ``libtiff`` open mode in the TIFF-structure and returns the old mode - * - :c:func:`TIFFSetSubDirectory` - - set the current directory - * - :c:func:`TIFFSetTagExtender` - - is used to register the merge function for user defined tags as an - extender callback with ``libtiff`` - * - :c:func:`TIFFSetupStrips` - - setup or reset strip parameters and strip array memory - * - :c:func:`TIFFSetWarningHandler` - - set warning handler function - * - :c:func:`TIFFSetWarningHandlerExt` - - set warning handler function with a file handle as parameter - * - :c:func:`TIFFSetWriteOffset` - - set current write offset - * - :c:func:`TIFFStripSize` - - return size of a strip - * - :c:func:`TIFFStripSize64` - - return equivalent size for a strip of data as :c:type:`uint64_t` - * - :c:func:`TIFFSwabArrayOfDouble` - - swap bytes of an array of doubles - * - :c:func:`TIFFSwabArrayOfFloat` - - swap bytes of an array of floats - * - :c:func:`TIFFSwabArrayOfLong` - - swap bytes of an array of longs - * - :c:func:`TIFFSwabArrayOfLong8` - - swap bytes of an array of uint64_t - * - :c:func:`TIFFSwabArrayOfShort` - - swap bytes of an array of shorts - * - :c:func:`TIFFSwabArrayOfTriples` - - swap the first and third byte of each triple within an array of bytes - * - :c:func:`TIFFSwabDouble` - - swap bytes of double - * - :c:func:`TIFFSwabFloat` - - swap bytes of float - * - :c:func:`TIFFSwabLong` - - swap bytes of long - * - :c:func:`TIFFSwabLong8` - - swap bytes of long long (uint64_t) - * - :c:func:`TIFFSwabShort` - - swap bytes of short - * - :c:func:`TIFFTileRowSize` - - return size of a row in a tile - * - :c:func:`TIFFTileRowSize64` - - return size of a row in a tile as :c:type:`uint64_t` - * - :c:func:`TIFFTileSize` - - return size of a tile - * - :c:func:`TIFFTileSize64` - - return size of a tile as :c:type:`uint64_t` - * - :c:func:`TIFFUnlinkDirectory` - - unlink the specified directory from the directory chain - * - :c:func:`TIFFUnRegisterCODEC` - - unregisters the codec - * - :c:func:`TIFFUnsetField` - - clear the contents of the field in the internal structure - * - :c:func:`TIFFVGetField` - - return tag value in current directory - * - :c:func:`TIFFVGetFieldDefaulted` - - return tag value in current directory - * - :c:func:`TIFFVSetField` - - set a tag's value in the current directory - * - :c:func:`TIFFVStripSize` - - return number of bytes in a strip - * - :c:func:`TIFFVStripSize64` - - return number of bytes in a strip with *nrows* rows of data as :c:type:`uint64_t` - * - :c:func:`TIFFVTileSize` - - returns the number of bytes in a row-aligned tile with *nrows* of data - * - :c:func:`TIFFVTileSize64` - - returns the number of bytes in a row-aligned tile with *nrows* of data - a :c:type:`uint64_t` number - * - :c:func:`TIFFWarning` - - library-wide warning handling function printing to ``stderr`` - * - :c:func:`TIFFWarningExt` - - user-specific library-wide warning handling function that can be passed - a file handle, which is set to the open TIFF file within ``libtiff`` - * - :c:func:`TIFFWarningExtR` - - user-specific re-entrant library warning handling function, - to which its TIFF structure is passed - containing the pointer to a user-specific data object - * - :c:func:`TIFFWriteBufferSetup` - - sets up the data buffer used to write raw (encoded) data to a file - * - :c:func:`TIFFWriteCheck` - - verify file is writable and that the directory information is setup properly - * - :c:func:`TIFFWriteCustomDirectory` - - write the current custom directory (also EXIF or GPS) to file - * - :c:func:`TIFFWriteDirectory` - - write the current directory - * - :c:func:`TIFFWriteEncodedStrip` - - compress and write a strip of data - * - :c:func:`TIFFWriteEncodedTile` - - compress and write a tile of data - * - :c:func:`TIFFWriteRawStrip` - - write a raw strip of data - * - :c:func:`TIFFWriteRawTile` - - write a raw tile of data - * - :c:func:`TIFFWriteScanline` - - write a scanline of data - * - :c:func:`TIFFWriteTile` - - compress and write a tile of data - * - :c:func:`TIFFXYZToRGB` - - perform CIE XYZ to RGB conversion - * - :c:func:`TIFFYCbCrtoRGB` - - perform YCbCr to RGB conversion - * - :c:func:`TIFFYCbCrToRGBInit` - - initialize YCbCr to RGB conversion state - -.. list-table:: *Libtiff auxillary functions* - :widths: 5 20 - :header-rows: 1 - - * - Name - - Description - * - :c:func:`_TIFFCheckMalloc` - - checking for integer overflow before dynamically allocate memory buffer - * - :c:func:`_TIFFCheckRealloc` - - checking for integer overflow before dynamically reallocate memory buffer - * - :c:func:`_TIFFClampDoubleToUInt32` - - clamps double values into the range of :c:type:`uint32_t` (i.e. 0 .. 0xFFFFFFFF) - * - :c:func:`_TIFFfree` - - free memory buffer - * - :c:func:`_TIFFGetExifFields` - - return a pointer to the ``libtiff`` internal definition list of the EXIF tags - * - :c:func:`_TIFFGetGpsFields` - - return a pointer to the ``libtiff`` internal definition list of the GPS tags - * - :c:func:`_TIFFmalloc` - - dynamically allocate memory buffer - * - :c:func:`_TIFFmemcmp` - - compare contents of the memory buffers - * - :c:func:`_TIFFmemcpy` - - copy contents of the one buffer to another - * - :c:func:`_TIFFmemset` - - fill memory buffer with a constant byte - * - :c:func:`_TIFFMultiply32` - - checks for an integer overflow of the multiplication result of `uint32_t` and - return the multiplication result or `0` if an overflow would happen - * - :c:func:`_TIFFMultiply64` - - checks for an integer overflow of the multiplication result of `uint64_t` and - return the multiplication result or `0` if an overflow would happen - * - :c:func:`_TIFFrealloc` - - dynamically reallocate memory buffer - * - :c:func:`_TIFFRewriteField` - - Rewrite a field in the directory on disk without regard - to updating the TIFF directory structure in memory - - -Tag usage ---------- - -For a table of TIFF tags recognized by the library refer to -:doc:`/specification/coverage`. - -"Pseudo tags" -------------- - -In addition to the normal TIFF -tags the library supports a collection of -tags whose values lie in a range outside the valid range of TIFF -tags. These tags are termed *pseudo-tags* -and are used to control various codec-specific functions within the library. -The table below summarizes the defined pseudo-tags. - -.. list-table:: libtiff supported tags - :widths: 10 2 2 15 - :header-rows: 1 - - * - Tag name - - Codec - - R/W - - Library Use/Notes - - * - :c:macro:`TIFFTAG_FAXMODE` - - G3 - - R/W - - general codec operation - * - :c:macro:`TIFFTAG_FAXFILLFUNC` - - G3/G4 - - R/W - - bitmap fill function - * - :c:macro:`TIFFTAG_JPEGQUALITY` - - JPEG - - R/W - - compression quality control - * - :c:macro:`TIFFTAG_JPEGCOLORMODE` - - JPEG - - R/W - - control colorspace conversions - * - :c:macro:`TIFFTAG_JPEGTABLESMODE` - - JPEG - - R/W - - control contents of ``JPEGTables`` tag - * - :c:macro:`TIFFTAG_ZIPQUALITY` - - Deflate - - R/W - - compression quality level - * - :c:macro:`TIFFTAG_PIXARLOGDATAFMT` - - PixarLog - - R/W - - user data format - * - :c:macro:`TIFFTAG_PIXARLOGQUALITY` - - PixarLog - - R/W - - compression quality level - * - :c:macro:`TIFFTAG_SGILOGDATAFMT` - - SGILog - - R/W - - user data format - -:c:macro:`TIFFTAG_FAXMODE`: - - Control the operation of the Group 3 codec. - Possible values (independent bits that can be combined by - or'ing them together) are: - - :c:macro:`FAXMODE_CLASSIC`: - - (enable old-style format in which the ``RTC`` - is written at the end of the last strip), - - :c:macro:`FAXMODE_NORTC`: - - (opposite of :c:macro:`FAXMODE_CLASSIC`; also called - :c:macro:`FAXMODE_CLASSF`), - - :c:macro:`FAXMODE_NOEOL`: - - (do not write ``EOL`` codes at the start of each row of data), - - :c:macro:`FAXMODE_BYTEALIGN`: - - (align each encoded row to an 8-bit boundary), - - :c:macro:`FAXMODE_WORDALIGN`: - - (align each encoded row to an 16-bit boundary), - - The default value is dependent on the compression scheme; this - pseudo-tag is used by the various G3 and G4 codecs to share code. - -:c:macro:`TIFFTAG_FAXFILLFUNC`: - - Control the function used to convert arrays of black and white - runs to packed bit arrays. - This hook can be used to image decoded scanlines in multi-bit - depth rasters (e.g. for display in colormap mode) - or for other purposes. - The default value is a pointer to a builtin function that images - packed bilevel data. - -:c:macro:`TIFFTAG_IPTCNEWSPHOTO`: - - Tag contains image metadata per the IPTC newsphoto spec: Headline, - captioning, credit, etc... Used by most wire services. - -:c:macro:`TIFFTAG_PHOTOSHOP`: - - Tag contains Photoshop captioning information and metadata. Photoshop - uses in parallel and redundantly alongside :c:macro:`IPTCNEWSPHOTO` information. - -:c:macro:`TIFFTAG_JPEGQUALITY`: - - Control the compression quality level used in the baseline algorithm. - Note that quality levels are in the range 0-100 with a default value of 75. - -:c:macro:`TIFFTAG_JPEGCOLORMODE`: - - Control whether or not conversion is done between - RGB and YCbCr colorspaces. - Possible values are: - - :c:macro:`JPEGCOLORMODE_RAW`: - - (do not convert), and - - :c:macro:`JPEGCOLORMODE_RGB`: - - (convert to/from RGB) - - The default value is :c:macro:`JPEGCOLORMODE_RAW`. - -:c:macro:`TIFFTAG_JPEGTABLESMODE`: - - Control the information written in the ``JPEGTables`` tag. - Possible values (independent bits that can be combined by - or'ing them together) are: - - :c:macro:`JPEGTABLESMODE_QUANT`: - - (include quantization tables), and - - :c:macro:`JPEGTABLESMODE_HUFF`: - - (include Huffman encoding tables). - - The default value is :c:expr:`JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF`. - -:c:macro:`TIFFTAG_ZIPQUALITY`: - - Control the compression technique used by the Deflate codec. - Quality levels are in the range 1-9 with larger numbers yielding better - compression at the cost of more computation. - The default quality level is 6 which yields a good time-space tradeoff. - -:c:macro:`TIFFTAG_PIXARLOGDATAFMT`: - - Control the format of user data passed *in* - to the PixarLog codec when encoding and passed - *out* from when decoding. Possible values are: - - :c:macro:`PIXARLOGDATAFMT_8BIT`: - - for 8-bit unsigned pixels, - - :c:macro:`PIXARLOGDATAFMT_8BITABGR`: - - for 8-bit unsigned ABGR-ordered pixels, - - :c:macro:`PIXARLOGDATAFMT_11BITLOG`: - - for 11-bit log-encoded raw data, - - :c:macro:`PIXARLOGDATAFMT_12BITPICIO`: - - for 12-bit PICIO-compatible data, - - :c:macro:`PIXARLOGDATAFMT_16BIT`: - - for 16-bit signed samples, and - - :c:macro:`PIXARLOGDATAFMT_FLOAT`: - - for 32-bit IEEE floating point samples. - -:c:macro:`TIFFTAG_PIXARLOGQUALITY`: - - Control the compression technique used by the PixarLog codec. - This value is treated identically to :c:macro:`TIFFTAG_ZIPQUALITY`; see the - above description. - -:c:macro:`TIFFTAG_SGILOGDATAFMT`: - - Control the format of client data passed *in* - to the SGILog codec when encoding and passed - *out* from when decoding. Possible values are: - - :c:macro:`SGILOGDATAFMT_FLTXYZ`: - - for converting between LogLuv and 32-bit IEEE floating valued XYZ pixels, - - :c:macro:`SGILOGDATAFMT_16BITLUV`: - - for 16-bit encoded Luv pixels, - - :c:macro:`SGILOGDATAFMT_32BITRAW`: - :c:macro:`SGILOGDATAFMT_24BITRAW`: - - for no conversion of data, - - :c:macro:`SGILOGDATAFMT_8BITRGB`: - - for returning 8-bit RGB data (valid only when decoding LogLuv-encoded data), - - :c:macro:`SGILOGDATAFMT_FLTY`: - - for converting between LogL and 32-bit IEEE floating valued Y pixels, - - :c:macro:`SGILOGDATAFMT_16BITL`: - - for 16-bit encoded L pixels, and - - :c:macro:`SGILOGDATAFMT_8BITGRY`: - - for returning 8-bit greyscale data - (valid only when decoding LogL-encoded data). - -Diagnostics ------------ - -All error messages are directed through the :c:func:`TIFFErrorExtR` routine. -By default messages are directed to ``stderr`` in the form: -``module: message\n``. -Warning messages are likewise directed through the -:c:func:`TIFFWarningExtR` routine. - -See also --------- - -:doc:`/tools/fax2tiff`, -:doc:`/tools/pal2rgb`, -:doc:`/tools/ppm2tiff`, -:doc:`/tools/rgb2ycbcr`, -:doc:`/tools/raw2tiff`, -:doc:`/tools/tiff2bw`, -:doc:`/tools/tiffdither`, -:doc:`/tools/tiffdump`, -:doc:`/tools/tiffcp`, -:doc:`/tools/tiffcmp`, -:doc:`/tools/tiffgt`, -:doc:`/tools/tiffinfo`, -:doc:`/tools/tiffmedian`, -:doc:`/tools/tiffsplit`, - -**"Tag Image File Format Specification *Revision 6.0*"**, -an Aldus Technical Memorandum. - -**"The Spirit of TIFF Class F"** , -an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies. - -Bugs ----- - -* The library does not support multi-sample images - where some samples have different bits/sample. - -* The library does not support random access to compressed data - that is organized with more than one row per tile or strip. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images.rst b/thirdparty/SDL2_image/external/libtiff/doc/images.rst deleted file mode 100644 index c275bd129..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/images.rst +++ /dev/null @@ -1,22 +0,0 @@ -TIFF Test Images -################ - -.. image:: images/bali.jpg - :width: 158 - :alt: bali - - -Test images are available for most formats supported by the library. -Most of the images included in the test kit are also part of this -documentation (albeit in TIFF rather than GIF or JFIF). -The images are kept in a separate archive that should be located in -the same directory as this software. - -The latest archive of test images is located at -``_. - -There are two other good sources for TIFF test images: -the contributed software :file:`contrib/dbs` includes several -programs that generate test images suitable for debugging, and -the :program:`tiffcp` program can be used to generate a variety -of images with different storage characteristics. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/index.rst b/thirdparty/SDL2_image/external/libtiff/doc/index.rst deleted file mode 100644 index d08a51ca1..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/index.rst +++ /dev/null @@ -1,66 +0,0 @@ -#################################### -LibTIFF - TIFF Library and Utilities -#################################### - -.. table:: References - :widths: auto - - ===================== ===================================== - Name Reference - ===================== ===================================== - Home Page #1 http://www.simplesystems.org/libtiff/ - Home Page #2 https://libtiff.gitlab.io/libtiff/ - Home Page #3 http://libtiff.maptools.org/ - Latest Stable Release v4.5.1 - Master Download Site `download.osgeo.org `_ - Mailing List `tiff@lists.osgeo.org `_ - List subscription http://lists.osgeo.org/mailman/listinfo/tiff/ - List archive http://www.awaresystems.be/imaging/tiff/tml.html - Source repository https://gitlab.com/libtiff/libtiff - ===================== ===================================== - -The LibTIFF software provides support for the *Tag Image File Format* (TIFF), -a widely used format for storing image data. The latest version of -the TIFF specification is :doc:`specification/index`. - -Included in this software distribution are: - -* a library, :file:`libtiff`, for reading and writing TIFF images -* a small collection of tools for performing simple manipulations of TIFF images -* documentation for the library and tools. - -The :file:`libtiff` library, along with associated tool programs, should handle most of -your needs for reading and writing TIFF images. - -LibTIFF is portable software, supported on various operating systems including -UNIX (Linux, BSD, MacOS X) and Windows. - -.. warning:: - - libtiff v4.5.1 will be the last one supporting most TIFF tools (except tiffinfo, - tiffdump, tiffcp and tiffset), whose maintenance will be discontinued, due - to the lack of contributors able to address reported security issues. - Starting with libtiff v4.6.0, their source code, at this time ,will still be - available in the source distribution, but they will no longer be built by - default, and issues related to them will no longer be accepted in the - libtiff bug tracker. - -The following sections are included in this documentation: - -.. toctree:: - :maxdepth: 2 - :titlesonly: - - specification/index - images - build - terms - libtiff - multi_page - functions - internals - addingtags - tools - contrib - project/index - releases/index diff --git a/thirdparty/SDL2_image/external/libtiff/doc/internals.rst b/thirdparty/SDL2_image/external/libtiff/doc/internals.rst deleted file mode 100644 index 7ea1b5e5a..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/internals.rst +++ /dev/null @@ -1,464 +0,0 @@ -Modifying The TIFF Library -========================== - -.. image:: images/dave.gif - :width: 107 - :alt: dave - -This chapter provides information about the internal structure of -the library, how to control the configuration when building it, and -how to add new support to the library. -The following sections are found in this chapter: - -Library Configuration ---------------------- - -Information on compiling the library is given :doc:`build` -elsewhere in this documentation. -This section describes the low-level mechanisms used to control -the optional parts of the library that are configured at build -time. Control is based on -a collection of C defines that are specified either on the compiler -command line or in a configuration file such as :file:`port.h` -(as generated by the :program:`configure` script for UNIX systems) -or :file:`tiffconf.h`. - -Configuration defines are split into three areas: - -* those that control which compression schemes are - configured as part of the builtin codecs, -* those that control support for groups of tags that - are considered optional, and -* those that control operating system or machine-specific support. - -If the define :c:macro:`COMPRESSION_SUPPORT` is **not defined** -then a default set of compression schemes is automatically -configured: - -* CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4, and 32771), -* the Macintosh PackBits algorithm (compression 32773), -* a 4-bit run-length encoding scheme from ThunderScan (compression 32809), -* a 2-bit encoding scheme used by NeXT (compression 32766), and -* two experimental schemes intended for images with high dynamic range - (compression 34676 and 34677). - -To override the default compression behaviour define -:c:macro:`COMPRESSION_SUPPORT` and then one or more additional defines -to enable configuration of the appropriate codecs (see the table -below); e.g. - -.. highlight:: c - -:: - - #define COMPRESSION_SUPPORT - #define CCITT_SUPPORT - #define PACKBITS_SUPPORT - -Several other compression schemes are configured separately from -the default set because they depend on ancillary software -packages that are not distributed with LibTIFF. - -Support for JPEG compression is controlled by :c:macro:`JPEG_SUPPORT`. -The JPEG codec that comes with LibTIFF is designed for -use with release 5 or later of the Independent JPEG Group's freely -available software distribution. -This software can be retrieved from the directory -``_. - -.. note:: - - Enabling JPEG support automatically enables support for - the TIFF 6.0 colorimetry and YCbCr-related tags. - -Experimental support for the deflate algorithm is controlled by -:c:macro:`DEFLATE_SUPPORT`. -The deflate codec that comes with LibTIFF is designed -for use with version 0.99 or later of the freely available -``libz`` library written by Jean-loup Gailly and Mark Adler. -The data format used by this library is described -in the files -``_, -and -``_, -available in the directory -``_.. -The library can be retried from the directory -``_ -(or try ``_). - -.. warning:: - - **The deflate algorithm is experimental. Do not expect - to exchange files using this compression scheme; - it is included only because the similar, and more common, - LZW algorithm is claimed to be governed by licensing restrictions.** - -By default :file:`tiffconf.h` defines -:c:macro:`COLORIMETRY_SUPPORT`, -:c:macro:`YCBCR_SUPPORT`, -and -:c:macro:`CMYK_SUPPORT`. - - -.. list-table:: :file:`tiffconf.h` defines - :widths: 5 20 - :header-rows: 1 - - * - Define - - Description - - * - :c:macro:`CCITT_SUPPORT` - - CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4, and 32771) - - * - :c:macro:`PACKBITS_SUPPORT` - - Macintosh PackBits algorithm (compression 32773) - - * - :c:macro:`LZW_SUPPORT` - - Lempel-Ziv & Welch (LZW) algorithm (compression 5) - - * - :c:macro:`THUNDER_SUPPORT` - - 4-bit run-length encoding scheme from ThunderScan (compression 32809) - - * - :c:macro:`NEXT_SUPPORT` - - 2-bit encoding scheme used by NeXT (compression 32766) - - * - :c:macro:`OJPEG_SUPPORT` - - obsolete JPEG scheme defined in the 6.0 spec (compression 6) - - * - :c:macro:`JPEG_SUPPORT` - - current JPEG scheme defined in TTN2 (compression 7) - - * - :c:macro:`ZIP_SUPPORT` - - experimental Deflate scheme (compression 32946) - - * - :c:macro:`PIXARLOG_SUPPORT` - - Pixar's compression scheme for high-resolution color images (compression 32909) - - * - :c:macro:`SGILOG_SUPPORT` - - SGI's compression scheme for high-resolution color images (compression 34676 and 34677) - - * - :c:macro:`COLORIMETRY_SUPPORT` - - support for the TIFF 6.0 colorimetry tags - - * - :c:macro:`YCBCR_SUPPORT` - - support for the TIFF 6.0 YCbCr-related tags - - * - :c:macro:`CMYK_SUPPORT` - - support for the TIFF 6.0 CMYK-related tags - - * - :c:macro:`ICC_SUPPORT` - - support for the ICC Profile tag; see - *The ICC Profile Format Specification*, - Annex B.3 "Embedding ICC Profiles in TIFF Files"; - available at - ``_ - -General Portability Comments ----------------------------- - -This software is developed on Silicon Graphics UNIX -systems (big-endian, MIPS CPU, 32-bit ints, -IEEE floating point). -The :program:`configure` shell script generates the appropriate -include files and make files for UNIX systems. -Makefiles exist for non-UNIX platforms that the -code runs on---this work has mostly been done by other people. - -In general, the code is guaranteed to work only on SGI machines. -In practice it is highly portable to any 32-bit or 64-bit system and much -work has been done to insure portability to 16-bit systems. -If you encounter portability problems please return fixes so -that future distributions can be improved. - -The software is written to assume an ANSI C compilation environment. -If your compiler does not support ANSI function prototypes, ``const``, -and :file:`` then you will have to make modifications to the -software. In the past I have tried to support compilers without ``const`` -and systems without :file:``, but I am -**no longer interested in these -antiquated environments**. With the general availability of -the freely available GCC compiler, I -see no reason to incorporate modifications to the software for these -purposes. - -An effort has been made to isolate as many of the -operating system-dependencies -as possible in two files: :file:`tiffcomp.h` and -:file:`libtiff/tif_.c`. The latter file contains -operating system-specific routines to do I/O and I/O-related operations. -The UNIX (:file:`tif_unix.c`) code has had the most use. - -Native CPU byte order is determined through the :c:macro:`WORDS_BIGENDIAN` -definition, which must be set to the appropriate value in :file:`tif_config.h` -by the build system. - -The following defines control general portability: - -.. list-table:: Portability defines - :widths: 5 20 - :header-rows: 1 - - * - Define - - Description - - * - :c:macro:`BSDTYPES` - - Define this if your system does **not** define the - usual BSD typedefs: :c:type:`u_char`, - :c:type:`u_short`, :c:type:`u_int`, :c:type:`u_long`. - - * - :c:macro:`HAVE_IEEEFP` - - Define this as 0 or 1 according to the floating point - format supported by the machine. If your machine does - not support IEEE floating point then you will need to - add support to tif_machdep.c to convert between the - native format and IEEE format. - - * - :c:macro:`HAVE_MMAP` - - Define this if there is *mmap-style* support for - mapping files into memory (used only to read data). - - * - :c:macro:`HOST_FILLORDER` - - Define the native CPU bit order: one of :c:macro:`FILLORDER_MSB2LSB` - or :c:macro:`FILLORDER_LSB2MSB` - - * - :c:macro:`HOST_BIGENDIAN` - - Define the native CPU byte order: 1 if big-endian (Motorola) - or 0 if little-endian (Intel); this may be used - in codecs to optimize code - -On UNIX systems :c:macro:`HAVE_MMAP` is defined through the running of -the :program:`configure` script; otherwise support for memory-mapped -files is disabled. -Note that :file:`tiffcomp.h` defines :c:macro:`HAVE_IEEEFP` to be -1 (:c:macro:`BSDTYPES` is not defined). - -Types and Portability ---------------------- - -The software makes extensive use of C typedefs to promote portability. -Two sets of typedefs are used, one for communication with clients -of the library and one for internal data structures and parsing of the -TIFF format. There are interactions between these two to be careful -of, but for the most part you should be able to deal with portability -purely by fiddling with the following machine-dependent typedefs: - -.. list-table:: Portability typedefs - :widths: 5 15 5 - :header-rows: 1 - - * - Typedef - - Description - - Header - - * - :c:type:`uint8_t` - - 8-bit unsigned integer - - :file:`tiff.h` - - * - :c:type:`int8_t` - - 8-bit signed integer - - :file:`tiff.h` - - * - :c:type:`uint16_t` - - 16-bit unsigned integer - - :file:`tiff.h` - - * - :c:type:`int16_t` - - 16-bit signed integer - - :file:`tiff.h` - - * - :c:type:`uint32_t` - - 32-bit unsigned integer - - :file:`tiff.h` - - * - :c:type:`int32_t` - - 32-bit signed integer - - :file:`tiff.h` - - * - :c:type:`dblparam_t` - - promoted type for floats - - :file:`tiffcomp.h` - -(to clarify :c:type:`dblparam_t`, it is the type that float parameters are -promoted to when passed by value in a function call.) - -The following typedefs are used throughout the library and interfaces -to refer to certain objects whose size is dependent on the TIFF image -structure: - -.. list-table:: TIFF image typedefs - :widths: 10 10 10 - :header-rows: 1 - - * - Typedef - - Type - - Description - - - * - :c:type:`ttag_t` - - :c:expr:`unsigned int` - - directory tag - - * - :c:type:`tdir_t` - - :c:type:`uint16_t` - - directory index - - * - :c:type:`tsample_t` - - :c:type:`uint16_t` - - sample number - - * - :c:type:`tstrip_t` - - :c:type:`uint32_t` - - strip number - - * - :c:type:`ttile_t` - - :c:type:`uint32_t` - - tile number - - * - :c:type:`tsize_t` - - :c:type:`int32_t` - - i/o size in bytes - - * - :c:type:`tdata_t` - - :c:expr:`void *` - - image data ref - - * - :c:type:`thandle_t` - - :c:expr:`void *` - - client data handle - - * - :c:type:`toff_t` - - :c:type:`int32_t` - - file offset (should be off_t) - - * - :c:type:`tidata_t` - - :c:expr:`unsigned char *` - - internal image data - -Note that :c:type:`tstrip_t`, :c:type:`ttile_t`, and :c:type:`tsize_t` -are constrained to be -no more than 32-bit quantities by 32-bit fields they are stored -in in the TIFF image. Likewise :c:type:`tsample_t` is limited by the 16-bit -field used to store the ``SamplesPerPixel`` tag. :c:type:`tdir_t` -constrains -the maximum number of IFDs that may appear in an image and may -be an arbitrary size (without penalty). :c:type:`ttag_t` must be either -:c:expr:`int`, :c:expr:`unsigned int`, pointer, or :c:expr:`double` -because the library uses a varargs -interface and ANSI C restricts the type of the parameter before an -ellipsis to be a promoted type. :c:type:`toff_t` is defined as -:c:type:`int32_t` because -TIFF file offsets are (unsigned) 32-bit quantities. A signed -value is used because some interfaces return -1 on error (sigh). -Finally, note that :c:type:`tidata_t` is used internally to the library to -manipulate internal data. User-specified data references are -passed as opaque handles and only cast at the lowest layers where -their type is presumed. - - -General Comments ----------------- - -The library is designed to hide as much of the details of TIFF from -applications as -possible. In particular, TIFF directories are read in their entirety -into an internal format. Only the tags known by the library are -available to a user and certain tag data may be maintained that a user -does not care about (e.g. transfer function tables). - -Adding New Builtin Codecs -------------------------- - -To add builtin support for a new compression algorithm, you can either -use the "tag-extension" trick to override the handling of the -TIFF Compression tag (see :doc:`addingtags`), -or do the following to add support directly to the core library: - -* Define the tag value in :file:`tiff.h`. -* Edit the file :file:`tif_codec.c` to add an entry to the - :c:var:`_TIFFBuiltinCODECS` array (see how other algorithms are handled). -* Add the appropriate function prototype declaration to - :file:`tiffiop.h` (close to the bottom). -* Create a file with the compression scheme code, by convention files - are named :file:`tif_*.c` (except perhaps on some systems where the - ``tif_`` prefix pushes some filenames over 14 chars. -* Update build configuration to include new source file. - -A codec, say ``foo``, can have many different entry points: - -:: - - TIFFInitfoo(tif, scheme) /* initialize scheme and setup entry points in tif */ - fooSetupDecode(tif) /* called once per IFD after tags has been frozen */ - fooPreDecode(tif, sample) /* called once per strip/tile, after data is read, - but before the first row is decoded */ - fooDecode*(tif, bp, cc, sample) /* decode cc bytes of data into the buffer */ - fooDecodeRow(...) /* called to decode a single scanline */ - fooDecodeStrip(...) /* called to decode an entire strip */ - fooDecodeTile(...) /* called to decode an entire tile */ - fooSetupEncode(tif) /* called once per IFD after tags has been frozen */ - fooPreEncode(tif, sample) /* called once per strip/tile, before the first row in - a strip/tile is encoded */ - fooEncode*(tif, bp, cc, sample)/* encode cc bytes of user data (bp) */ - fooEncodeRow(...) /* called to decode a single scanline */ - fooEncodeStrip(...) /* called to decode an entire strip */ - fooEncodeTile(...) /* called to decode an entire tile */ - fooPostEncode(tif) /* called once per strip/tile, just before data is written */ - fooSeek(tif, row) /* seek forwards row scanlines from the beginning - of a strip (row will always be <0 and >rows/strip */ - fooCleanup(tif) /* called when compression scheme is replaced by user */ - -Note that the encoding and decoding variants are only needed when -a compression algorithm is dependent on the structure of the data. -For example, Group 3 2D encoding and decoding maintains a reference -scanline. The sample parameter identifies which sample is to be -encoded or decoded if the image is organized with ``PlanarConfig=2`` -(separate planes). This is important for algorithms such as JPEG. -If ``PlanarConfig=1`` (interleaved), then sample will always be 0. - -Other Comments --------------- - -The library handles most I/O buffering. There are two data buffers -when decoding data: a raw data buffer that holds all the data in a -strip, and a user-supplied scanline buffer that compression schemes -place decoded data into. When encoding data the data in the -user-supplied scanline buffer is encoded into the raw data buffer (from -where it is written). Decoding routines should never have to explicitly -read data -- a full strip/tile's worth of raw data is read and scanlines -never cross strip boundaries. Encoding routines must be cognizant of -the raw data buffer size and call :c:func:`TIFFFlushData1` when necessary. -Note that any pending data is automatically flushed when a new strip/tile is -started, so there's no need do that in the tif_postencode routine (if -one exists). Bit order is automatically handled by the library when -a raw strip or tile is filled. If the decoded samples are interpreted -by the decoding routine before they are passed back to the user, then -the decoding logic must handle byte-swapping by overriding the -:c:member:`tif_postdecode` -routine (set it to :c:func:`TIFFNoPostDecode`) and doing the required work -internally. For an example of doing this look at the horizontal -differencing code in the routines in :file:`tif_predict.c`. - -The variables :c:member:`tif_rawcc`, :c:member:`tif_rawdata`, and -:c:member:`tif_rawcp` in a :c:struct:`TIFF` structure -are associated with the raw data buffer. :c:member:`tif_rawcc` must be non-zero -for the library to automatically flush data. The variable -:c:member:`tif_scanlinesize` is the size a user's scanline buffer should be. The -variable :c:member:`tif_tilesize` is the size of a tile for tiled images. This -should not normally be used by compression routines, except where it -relates to the compression algorithm. That is, the ``cc`` parameter to the -:c:expr:`tif_decode*` and :c:expr:`tif_encode*` -routines should be used in terminating -decompression/compression. This ensures these routines can be used, -for example, to decode/encode entire strips of data. - -In general, if you have a new compression algorithm to add, work from -the code for an existing routine. In particular, -:file:`tif_dumpmode.c` -has the trivial code for the "nil" compression scheme, -:file:`tif_packbits.c` is a -simple byte-oriented scheme that has to watch out for buffer -boundaries, and :file:`tif_lzw.c` has the LZW scheme that has the most -complexity -- it tracks the buffer boundary at a bit level. -Of course, using a private compression scheme (or private tags) limits -the portability of your TIFF files. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/libtiff.rst b/thirdparty/SDL2_image/external/libtiff/doc/libtiff.rst deleted file mode 100644 index 6a0054c67..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/libtiff.rst +++ /dev/null @@ -1,681 +0,0 @@ -Using The TIFF Library -====================== - -.. image:: images/cat.gif - :width: 113 - :alt: cat - -``libtiff`` is a set of C functions (a library) that support -the manipulation of TIFF image files. -The library requires an ANSI C compilation environment for building -and presumes an ANSI C environment for use. - -``libtiff`` -provides interfaces to image data at several layers of abstraction (and cost). -At the highest level image data can be read into an 8-bit/sample, -ABGR pixel raster format without regard for the underlying data organization, -colorspace, or compression scheme. Below this high-level interface -the library provides scanline-, strip-, and tile-oriented interfaces that -return data decompressed but otherwise untransformed. These interfaces -require that the application first identify the organization of stored -data and select either a strip-based or tile-based API for manipulating -data. At the lowest level the library -provides access to the raw uncompressed strips or tiles, -returning the data exactly as it appears in the file. - -The material presented in this chapter is a basic introduction -to the capabilities of the library; it is not an attempt to describe -everything a developer needs to know about the library or about TIFF. -Detailed information on the interfaces to the library are given in -the :doc:`functions` that accompany this software. -An alphabetic list of all the public functions with a brief description can be found at :ref:`list_of_routines` - -.. warning:: - The following hyperlink does no more work, at least no libtiff introduction: - - Michael Still has also written a useful introduction to libtiff for the - IBM DeveloperWorks site available at - ``_. - - -How to tell which version you have ----------------------------------- - -The software version can be found by looking at the file named -:file:`VERSION` -that is located at the top of the source tree; the precise alpha number -is given in the file :file:`dist/tiff.alpha`. -If you have need to refer to this -specific software, you should identify it as: - -:: - - TIFF - -where ```` is whatever you get from -``cat VERSION`` and ```` is -what you get from ``cat dist/tiff.alpha``. - -Within an application that uses ``libtiff`` the :c:func:`TIFFGetVersion` -routine will return a pointer to a string that contains software version -information. -The library include file :file:`` contains a C pre-processor -define :c:macro:`TIFFLIB_VERSION` that can be used to check library -version compatibility at compile time. - -Library Datatypes ------------------ - -``libtiff`` defines a portable programming interface through the -use of a set of C type definitions. -These definitions, defined in in the files :file:`tiff.h` and -:file:`tiffio.h`, -isolate the ``libtiff`` API from the characteristics -of the underlying machine. -To insure portable code and correct operation, applications that use -``libtiff`` should use the typedefs and follow the function -prototypes for the library API. - -Memory Management ------------------ - -``libtiff`` uses a machine-specific set of routines for managing -dynamically allocated memory. -:c:func:`_TIFFmalloc`, :c:func:`_TIFFrealloc`, and :c:func:`_TIFFfree` -mimic the normal ANSI C routines. -Any dynamically allocated memory that is to be passed into the library -should be allocated using these interfaces in order to insure pointer -compatibility on machines with a segmented architecture. -(On 32-bit UNIX systems these routines just call the normal :c:func:`malloc`, -:c:func:`realloc`, and :c:func:`free` routines in the C library.) - -To deal with segmented pointer issues ``libtiff`` also provides -:c:func:`_TIFFmemcpy`, :c:func:`_TIFFmemset`, and :c:func:`_TIFFmemmove` -routines that mimic the equivalent ANSI C routines, but that are -intended for use with memory allocated through :c:func:`_TIFFmalloc` -and :c:func:`_TIFFrealloc`. - -Error Handling --------------- - -``libtiff`` handles most errors by returning an invalid/erroneous -value when returning from a function call. -Various diagnostic messages may also be generated by the library. -All error messages are directed to a single global error handler -routine that can be specified with a call to :c:func:`TIFFSetErrorHandler`. -Likewise warning messages are directed to a single handler routine -that can be specified with a call to :c:func:`TIFFSetWarningHandler` - -Basic File Handling -------------------- - -The library is modeled after the normal UNIX stdio library. -For example, to read from an existing TIFF image the -file must first be opened: - -.. highlight:: c - -:: - - #include "tiffio.h" - main() - { - TIFF* tif = TIFFOpen("foo.tif", "r"); - /* ... do stuff ... */ - TIFFClose(tif); - } - -The handle returned by :c:func:`TIFFOpen` is *opaque*, that is -the application is not permitted to know about its contents. -All subsequent library calls for this file must pass the handle -as an argument. - -To create or overwrite a TIFF image the file is also opened, but with -a ``"w"`` argument: - -:: - - #include "tiffio.h" - main() - { - TIFF* tif = TIFFOpen("foo.tif", "w"); - ... do stuff ... - TIFFClose(tif); - } - -If the file already exists it is first truncated to zero length. - -.. warning:: - - Unlike the stdio library TIFF image files may not be - opened for both reading and writing; - there is no support for altering the contents of a TIFF file. - -``libtiff`` buffers much information associated with writing a -valid TIFF image. Consequently, when writing a TIFF image it is necessary -to always call :c:func:`TIFFClose` or :c:func:`TIFFFlush` to flush any -buffered information to a file. Note that if you call :c:func:`TIFFClose` -you do not need to call :c:func:`TIFFFlush`. - -TIFF Directories ----------------- - -TIFF supports the storage of multiple images in a single file. -Each image has an associated data structure termed a *directory* -that houses all the information about the format and content of the -image data. -Images in a file are usually related but they do not need to be; it -is perfectly alright to store a color image together with a black and -white image. -Note however that while images may be related their directories are -not. -That is, each directory stands on its own; there is no need to read -an unrelated directory in order to properly interpret the contents -of an image. - -``libtiff`` provides several routines for reading and writing -directories. In normal use there is no need to explicitly -read or write a directory: the library automatically reads the first -directory in a file when opened for reading, and directory information -to be written is automatically accumulated and written when writing -(assuming :c:func:`TIFFClose` or :c:func:`TIFFFlush` are called). - -For a file open for reading the :c:func:`TIFFSetDirectory` routine can -be used to select an arbitrary directory; directories are referenced by -number with the numbering starting at 0. Otherwise the -:c:func:`TIFFReadDirectory` and :c:func:`TIFFWriteDirectory` routines can -be used for sequential access to directories. -For example, to count the number of directories in a file the following -code might be used: - -:: - - #include "tiffio.h" - main(int argc, char* argv[]) - { - TIFF* tif = TIFFOpen(argv[1], "r"); - if (tif) { - int dircount = 0; - do { - dircount++; - } while (TIFFReadDirectory(tif)); - printf("%d directories in %s\n", dircount, argv[1]); - TIFFClose(tif); - } - exit(0); - } - - -Finally, note that there are several routines for querying the -directory status of an open file: -:c:func:`TIFFCurrentDirectory` returns the index of the current -directory and -:c:func:`TIFFLastDirectory` returns an indication of whether the -current directory is the last directory in a file. -There is also a routine, :c:func:`TIFFPrintDirectory`, that can -be called to print a formatted description of the contents of -the current directory; consult the manual page for complete details. - -TIFF Tags ---------- - -Image-related information such as the image width and height, number -of samples, orientation, colorimetric information, etc. -are stored in each image -directory in *fields* or *tags*. -Tags are identified by a number that is usually a value registered -with the Aldus (now Adobe) Corporation. -Beware however that some vendors write -TIFF images with tags that are unregistered; in this case interpreting -their contents is usually a waste of time. - -``libtiff`` reads the contents of a directory all at once -and converts the on-disk information to an appropriate in-memory -form. While the TIFF specification permits an arbitrary set of -tags to be defined and used in a file, the library only understands -a limited set of tags. -Any unknown tags that are encountered in a file are ignored. -There is a mechanism to extend the set of tags the library handles -without modifying the library itself; -this is described in :doc:`addingtags`. - -``libtiff`` provides two interfaces for getting and setting tag -values: :c:func:`TIFFGetField` and :c:func:`TIFFSetField`. -These routines use a variable argument list-style interface to pass -parameters of different type through a single function interface. -The *get interface* takes one or more pointers to memory locations -where the tag values are to be returned and also returns one or -zero according to whether the requested tag is defined in the directory. -The *set interface* takes the tag values either by-reference or -by-value. -The TIFF specification defines -*default values* for some tags. -To get the value of a tag, or its default value if it is undefined, -the :c:func:`TIFFGetFieldDefaulted` interface may be used. - -The manual pages for the tag get and set routines specify the exact data types -and calling conventions required for each tag supported by the library. - -TIFF Compression Schemes ------------------------- - -``libtiff`` includes support for a wide variety of -data compression schemes. -In normal operation a compression scheme is automatically used when -the TIFF ``Compression`` tag is set, either by opening a file -for reading, or by setting the tag when writing. - -Compression schemes are implemented by software modules termed *codecs* -that implement decoder and encoder routines that hook into the -core library i/o support. -Codecs other than those bundled with the library can be registered -for use with the :c:func:`TIFFRegisterCODEC` routine. -This interface can also be used to override the core-library -implementation for a compression scheme. - -Byte Order ----------- - -The TIFF specification says, and has always said, that -*a correct TIFF -reader must handle images in big-endian and little-endian byte order*. -``libtiff`` conforms in this respect. -Consequently there is no means to force a specific -byte order for the data written to a TIFF image file (data is -written in the native order of the host CPU unless appending to -an existing file, in which case it is written in the byte order -specified in the file). - -Data Placement --------------- - -The TIFF specification requires that all information except an -8-byte header can be placed anywhere in a file. -In particular, it is perfectly legitimate for directory information -to be written after the image data itself. -Consequently TIFF is inherently not suitable for passing through a -stream-oriented mechanism such as UNIX pipes. -Software that require that data be organized in a file in a particular -order (e.g. directory information before image data) does not -correctly support TIFF. -``libtiff`` provides no mechanism for controlling the placement -of data in a file; image data is typically written before directory -information. - -TIFFRGBAImage Support ---------------------- - -``libtiff`` provides a high-level interface for reading image -data from a TIFF file. This interface handles the details of -data organization and format for a wide variety of TIFF files; -at least the large majority of those files that one would normally -encounter. Image data is, by default, returned as ABGR -pixels packed into 32-bit words (8 bits per sample). Rectangular -rasters can be read or data can be intercepted at an intermediate -level and packed into memory in a format more suitable to the -application. -The library handles all the details of the format of data stored on -disk and, in most cases, if any colorspace conversions are required: -bilevel to RGB, greyscale to RGB, CMYK to RGB, YCbCr to RGB, 16-bit -samples to 8-bit samples, associated/unassociated alpha, etc. - -There are two ways to read image data using this interface. If -all the data is to be stored in memory and manipulated at once, -then the routine :c:func:`TIFFReadRGBAImage` can be used: - -:: - - #include "tiffio.h" - main(int argc, char* argv[]) - { - TIFF* tif = TIFFOpen(argv[1], "r"); - if (tif) { - uint32_t w, h; - size_t npixels; - uint32_t* raster; - - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - npixels = w * h; - raster = (uint32_t*) _TIFFmalloc(npixels * sizeof (uint32_t)); - if (raster != NULL) { - if (TIFFReadRGBAImage(tif, w, h, raster, 0)) { - ...process raster data... - } - _TIFFfree(raster); - } - TIFFClose(tif); - } - exit(0); - } - -Note above that :c:func:`_TIFFmalloc` is used to allocate memory for -the raster passed to :c:func:`TIFFReadRGBAImage`; this is important -to insure the "appropriate type of memory" is passed on machines -with segmented architectures. - -Alternatively, :c:func:`TIFFReadRGBAImage` can be replaced with a -more low-level interface that permits an application to have more -control over this reading procedure. The equivalent to the above -is: - -:: - - #include "tiffio.h" - main(int argc, char* argv[]) - { - TIFF* tif = TIFFOpen(argv[1], "r"); - if (tif) { - TIFFRGBAImage img; - char emsg[1024]; - - if (TIFFRGBAImageBegin(&img, tif, 0, emsg)) { - size_t npixels; - uint32_t* raster; - - npixels = img.width * img.height; - raster = (uint32_t*) _TIFFmalloc(npixels * sizeof (uint32_t)); - if (raster != NULL) { - if (TIFFRGBAImageGet(&img, raster, img.width, img.height)) { - ...process raster data... - } - _TIFFfree(raster); - } - TIFFRGBAImageEnd(&img); - } else - TIFFError(argv[1], emsg); - TIFFClose(tif); - } - exit(0); - } - -However this usage does not take advantage of the more fine-grained -control that's possible. That is, by using this interface it is -possible to: - -* repeatedly fetch (and manipulate) an image without opening - and closing the file -* interpose a method for packing raster pixel data according to - application-specific needs (or write the data at all) -* interpose methods that handle TIFF formats that are not already - handled by the core library - -The first item means that, for example, image viewers that want to -handle multiple files can cache decoding information in order to -speedup the work required to display a TIFF image. - -The second item is the main reason for this interface. By interposing -a "put method" (the routine that is called to pack pixel data in -the raster) it is possible share the core logic that understands how -to deal with TIFF while packing the resultant pixels in a format that -is optimized for the application. This alternate format might be very -different than the 8-bit per sample ABGR format the library writes by -default. For example, if the application is going to display the image -on an 8-bit colormap display the put routine might take the data and -convert it on-the-fly to the best colormap indices for display. - -The last item permits an application to extend the library -without modifying the core code. -By overriding the code provided an application might add support -for some esoteric flavor of TIFF that it needs, or it might -substitute a packing routine that is able to do optimizations -using application/environment-specific information. - -The TIFF image viewer found in :file:`tools/sgigt.c` is an example -of an application that makes use of the :c:func:`TIFFRGBAImage` -support. - -Scanline-based Image I/O ------------------------- - -The simplest interface provided by ``libtiff`` is a -scanline-oriented interface that can be used to read TIFF -images that have their image data organized in strips -(trying to use this interface to read data written in tiles -will produce errors.) -A scanline is a one pixel high row of image data whose width -is the width of the image. -Data is returned packed if the image data is stored with samples -packed together, or as arrays of separate samples if the data -is stored with samples separated. -The major limitation of the scanline-oriented interface, other -than the need to first identify an existing file as having a -suitable organization, is that random access to individual -scanlines can only be provided when data is not stored in a -compressed format, or when the number of rows in a strip -of image data is set to one (``RowsPerStrip`` is one). - -Two routines are provided for scanline-based i/o: -:c:func:`TIFFReadScanline` -and -:c:func:`TIFFWriteScanline`. -For example, to read the contents of a file that -is assumed to be organized in strips, the following might be used: - -:: - - #include "tiffio.h" - main() - { - TIFF* tif = TIFFOpen("myfile.tif", "r"); - if (tif) { - uint32_t imagelength; - tdata_t buf; - uint32_t row; - - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength); - buf = _TIFFmalloc(TIFFScanlineSize(tif)); - for (row = 0; row < imagelength; row++) - TIFFReadScanline(tif, buf, row, 0); - _TIFFfree(buf); - TIFFClose(tif); - } - } - -:c:func:`TIFFScanlineSize` returns the number of bytes in -a decoded scanline, as returned by :c:func:`TIFFReadScanline`. -Note however that if the file had been create with samples -written in separate planes, then the above code would only -read data that contained the first sample of each pixel; -to handle either case one might use the following instead: - -:: - - #include "tiffio.h" - main() - { - TIFF* tif = TIFFOpen("myfile.tif", "r"); - if (tif) { - uint32_t imagelength; - tdata_t buf; - uint32_t row; - - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength); - TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); - buf = _TIFFmalloc(TIFFScanlineSize(tif)); - if (config == PLANARCONFIG_CONTIG) { - for (row = 0; row < imagelength; row++) - TIFFReadScanline(tif, buf, row, 0); - } else if (config == planarconfig_separate) { - uint16_t s, nsamples; - - tiffgetfield(tif, tifftag_samplesperpixel, &nsamples); - for (s = 0; s < nsamples; s++) - for (row = 0; row < imagelength; row++) - TIFFReadScanline(tif, buf, row, s); - } - _TIFFfree(buf); - TIFFClose(tif); - } - } - -Beware however that if the following code were used instead to -read data in the case ``PLANARCONFIG_SEPARATE``,... - -:: - - for (row = 0; row < imagelength; row++) - for (s = 0; s < nsamples; s++) - TIFFReadScanline(tif, buf, row, s); - -...then problems would arise if ``RowsPerStrip`` was not one -because the order in which scanlines are requested would require -random access to data within strips (something that is not supported -by the library when strips are compressed). - -Strip-oriented Image I/O ------------------------- - -The strip-oriented interfaces provided by the library provide -access to entire strips of data. Unlike the scanline-oriented -calls, data can be read or written compressed or uncompressed. -Accessing data at a strip (or tile) level is often desirable -because there are no complications with regard to random access -to data within strips. - -A simple example of reading an image by strips is: - -:: - - #include "tiffio.h" - main() - { - TIFF* tif = TIFFOpen("myfile.tif", "r"); - if (tif) { - tdata_t buf; - tstrip_t strip; - - buf = _TIFFmalloc(TIFFStripSize(tif)); - for (strip = 0; strip < tiffnumberofstrips(tif); strip++) - tiffreadencodedstrip(tif, strip, buf, (tsize_t) -1); - _TIFFfree(buf); - TIFFClose(tif); - } - } - -Notice how a strip size of ``-1`` is used; :c:func:`TIFFReadEncodedStrip` -will calculate the appropriate size in this case. - -The above code reads strips in the order in which the -data is physically stored in the file. If multiple samples -are present and data is stored with ``PLANARCONFIG_SEPARATE`` -then all the strips of data holding the first sample will be -read, followed by strips for the second sample, etc. - -Finally, note that the last strip of data in an image may have fewer -rows in it than specified by the ``RowsPerStrip`` tag. A -reader should not assume that each decoded strip contains a full -set of rows in it. - -The following is an example of how to read raw strips of data from -a file: - -:: - - #include "tiffio.h" - main() - { - TIFF* tif = TIFFOpen("myfile.tif", "r"); - if (tif) { - tdata_t buf; - tstrip_t strip; - uint32_t* bc; - uint32_t stripsize; - - TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); - stripsize = bc[0]; - buf = _TIFFmalloc(stripsize); - for (strip = 0; strip < tiffnumberofstrips(tif); strip++) { - if (bc[strip] > stripsize) { - buf = _TIFFrealloc(buf, bc[strip]); - stripsize = bc[strip]; - } - TIFFReadRawStrip(tif, strip, buf, bc[strip]); - } - _TIFFfree(buf); - TIFFClose(tif); - } - } - -As above the strips are read in the order in which they are -physically stored in the file; this may be different from the -logical ordering expected by an application. - -Tile-oriented Image I/O ------------------------ - -Tiles of data may be read and written in a manner similar to strips. -With this interface, an image is -broken up into a set of rectangular areas that may have dimensions -less than the image width and height. All the tiles -in an image have the same size, and the tile width and length must each -be a multiple of 16 pixels. Tiles are ordered left-to-right and -top-to-bottom in an image. As for scanlines, samples can be packed -contiguously or separately. When separated, all the tiles for a sample -are colocated in the file. That is, all the tiles for sample 0 appear -before the tiles for sample 1, etc. - -Tiles and strips may also be extended in a z dimension to form -volumes. Data volumes are organized as "slices". That is, all the -data for a slice is colocated. Volumes whose data is organized in -tiles can also have a tile depth so that data can be organized in -cubes. - -There are actually two interfaces for tiles. -One interface is similar to scanlines, to read a tiled image, -code of the following sort might be used: - -:: - - main() - { - TIFF* tif = TIFFOpen("myfile.tif", "r"); - if (tif) { - uint32_t imageWidth, imageLength; - uint32_t tileWidth, tileLength; - uint32_t x, y; - tdata_t buf; - - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength); - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tileWidth); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &tileLength); - buf = _TIFFmalloc(TIFFTileSize(tif)); - for (y = 0; y < imagelength; y += tilelength) - for (x = 0; x < imagewidth; x += tilewidth) - tiffreadtile(tif, buf, x, y, 0); - _TIFFfree(buf); - TIFFClose(tif); - } - } - -(once again, we assume samples are packed contiguously.) - -Alternatively a direct interface to the low-level data is provided -à la strips. Tiles can be read with -:c:func:`TIFFReadEncodedTile` or :c:func:`TIFFReadRawTile`, -and written with :c:func:`TIFFWriteEncodedTile` or -:c:func:`TIFFWriteRawTile`. For example, to read all the tiles in an image: - -:: - - #include "tiffio.h" - main() - { - TIFF* tif = TIFFOpen("myfile.tif", "r"); - if (tif) { - tdata_t buf; - ttile_t tile; - - buf = _TIFFmalloc(TIFFTileSize(tif)); - for (tile = 0; tile < tiffnumberoftiles(tif); tile++) - tiffreadencodedtile(tif, tile, buf, (tsize_t) -1); - _TIFFfree(buf); - TIFFClose(tif); - } - } - -Other Stuff ------------ - -Some other stuff will almost certainly go here... diff --git a/thirdparty/SDL2_image/external/libtiff/doc/multi_page.rst b/thirdparty/SDL2_image/external/libtiff/doc/multi_page.rst deleted file mode 100644 index 9b0776b89..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/multi_page.rst +++ /dev/null @@ -1,213 +0,0 @@ -Multi Page / Multi Image TIFF -============================= - -There may be more than one :ref:`Image File Directory (IFD) ` -in a TIFF file. Each IFD defines a :ref:`subfile `. - -One potential use of *subfiles* is to describe related images, -such as the pages of a facsimile transmission or reduced-resolution images -of the first full-resolution image. -Such files are also named "*multi-page* TIFF" or "*multi-image* TIFF". - -There are two mechanisms for storing multiple images in a TIFF file: - -1. A **main-IFD chain**, where the images are stored in linked IFDs (directories). - This mechanism is widely used. -2. A **SubIFD chain**, where additional images are stored within the SubIFD tag - of a main-IFD. Such child images provide extra information for the parent image - - such as a subsampled version of the parent image. - SubIFD chains are rarely supported. - For SubIFD refer also to - `Adobe PageMaker® 6.0 TIFF Technical Notes `_ - -.. _SubIFDAccess: - -Sub IFD chains --------------- - -In the case of several SubIFDs of a main image, there are two possibilities -that are not even mutually exclusive. - -a. The ``SubIFD`` tag contains an array with all offsets of the SubIFDs. - This is called SubIFD tree and DNG recommends the use of SubIFD trees, - as described in the TIFF-EP specification. SubIFD chains are not supported. -b. The SubIFDs are concatenated with their ``NextIFD`` parameters - to a SubIFD chain. - -LibTiff does support SubIFD chains partially. When the first -``SubIFD`` tag is activated and read with :c:func:`TIFFSetSubDirectory()`, -the following can be parsed with :c:func:`TIFFReadDirectory()`. -The *tif_curdir* is just incremented from its current value -and thus gets arbitrary values when parsing through SubIFD chains. -When the SubIFDs are not chained, each offset -within the SubIFD array has to be activated and read individually. -:c:func:`TIFFSetDirectory()` only works with main-IFD chains because -allways starts with the first main-IFD and thus is able to reset -the SubIFD reading chain to the main-IFD chain. - -Writing Multi Page TIFF ------------------------ - -The following example code shows how to write multi-page TIFF -as main-IFD chain and as SubIFD chain. -``libtiff`` writes SubIFDs as an array of IFDs that are not chained -additionally, as Adobe PageMaker® 6.0 TIFF Technical Notes suggests. - -.. highlight:: c - -:: - - #include - - int main(int argc, const char **argv) - { - TIFF *tiff; - - /* Define the number of pages/images (main-IFDs) you are going to write */ - int number_of_images = 3; - - /* Define the number of sub - IFDs you are going to write */ - #define NUMBER_OF_SUBIFDs 2 - int number_of_sub_IFDs = NUMBER_OF_SUBIFDs; - toff_t sub_IFDs_offsets[NUMBER_OF_SUBIFDs] = { - 0UL}; /* array for SubIFD tag */ - int blnWriteSubIFD = 0; - - if (!(tiff = TIFFOpen("multiPageTiff2.tif", "w"))) - return 1; - - for (int i = 0; i < number_of_images; i++) - { - char pixel[1] = {128}; - - TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, 1); - TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, 1); - TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1); - TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); - - /* For the last but one multi-page image, add a SubIFD e.g. for a - * thumbnail */ - if (number_of_images - 2 == i) - blnWriteSubIFD = 1; - - if (blnWriteSubIFD) - { - /* Now here is the trick: the next n directories written - * will be sub-IFDs of the main-IFD (where n is number_of_sub_IFDs - * specified when you set the TIFFTAG_SUBIFD field. - * The SubIFD offset array sub_IFDs_offsets is filled automatically - * with the proper offset values by the following number_of_sub_IFDs - * TIFFWriteDirectory() calls and updated in the related main-IFD - * with the last call. - */ - if (!TIFFSetField(tiff, TIFFTAG_SUBIFD, number_of_sub_IFDs, - sub_IFDs_offsets)) - return 1; - } - - /* Write dummy pixel to image */ - if (TIFFWriteScanline(tiff, pixel, 0, 0) < 0) - return 1; - /* Write image / directory to file */ - if (!TIFFWriteDirectory(tiff)) - return 1; - - if (blnWriteSubIFD) - { - /* A SubIFD tag has been written for that main-IFD and this - * triggers that pervious TIFFWriteDirectory() to switch to the - * SubIFD-chain for the next number_of_sub_IFDs writings. - * Thus, only the thumbnail images need to be - * set up and written to file using TIFFWriteDirectory(). - * The last of this TIFFWriteDirectory() calls will setup - * the next fresh main-IFD. - */ - for (int i = 0; i < number_of_sub_IFDs; i++) - { - TIFFSetField(tiff, TIFFTAG_IMAGEWIDTH, 1); - TIFFSetField(tiff, TIFFTAG_IMAGELENGTH, 1); - TIFFSetField(tiff, TIFFTAG_SAMPLESPERPIXEL, 1); - TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); - /* SUBFILETYPE tag is not mandatory for SubIFD writing, but a - * good idea to indicate thumbnails */ - if (!TIFFSetField(tiff, TIFFTAG_SUBFILETYPE, - FILETYPE_REDUCEDIMAGE)) - return 1; - - /* Write dummy pixel to thumbnail image */ - pixel[0] = 64; - if (TIFFWriteScanline(tiff, pixel, 0, 0) < 0) - return 1; - /* Writes now in the SubIFD chain */ - if (!TIFFWriteDirectory(tiff)) - return 1; - - blnWriteSubIFD = 0; - } - } - } - TIFFClose(tiff); - return 0; - } - -Reading Multi Page TIFF ------------------------ - -For a reading example see code of `tools/tiffinfo.c` or below: - -.. highlight:: c - -:: - - /* Reading of multi-page and SubIFD images (subfiles) */ - if (!(tiff = TIFFOpen(filename, "r"))) - return 1; - - tdir_t currentDirNumber = TIFFCurrentDirectory(tiff); - - /* The first directory is already read through TIFFOpen() */ - int blnRead = 0; - do - { - /*Check if there are SubIFD subfiles */ - void *ptr; - if (TIFFGetField(tiff, TIFFTAG_SUBIFD, &number_of_sub_IFDs, &ptr)) - { - /* Copy SubIFD array from pointer */ - memcpy(sub_IFDs_offsets, ptr, - number_of_sub_IFDs * sizeof(sub_IFDs_offsets[0])); - - for (int i = 0; i < number_of_sub_IFDs; i++) - { - /* Read first SubIFD directory */ - if (!TIFFSetSubDirectory(tiff, sub_IFDs_offsets[i])) - return 1; - /* Check if there is a SubIFD chain behind the first one from - * the array, as specified by Adobe */ - while (TIFFReadDirectory(tiff)) - /* analyse subfile */ - ; - } - /* Go back to main-IFD chain and re-read that main-IFD directory */ - if (!TIFFSetDirectory(tiff, currentDirNumber)) - return 1; - } - /* Read next main-IFD directory (subfile) */ - blnRead = TIFFReadDirectory(tiff); - currentDirNumber = TIFFCurrentDirectory(tiff); - } while (blnRead); - TIFFClose(tiff); - - - - -See also --------- - -:doc:`terms`, -:doc:`/functions/TIFFSetDirectory` (3tiff), -:doc:`/functions/TIFFWriteDirectory` (3tiff), -`Adobe PageMaker® 6.0 TIFF Technical Notes `_, -`Example from StackOverflow `_ \ No newline at end of file diff --git a/thirdparty/SDL2_image/external/libtiff/doc/project/acknowledgements.rst b/thirdparty/SDL2_image/external/libtiff/doc/project/acknowledgements.rst deleted file mode 100644 index a3d9da968..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/project/acknowledgements.rst +++ /dev/null @@ -1,102 +0,0 @@ -Acknowledgments -=============== - -.. image:: ../images/ring.gif - :width: 124 - :alt: ring - -Maintainers ------------ - -The LibTIFF software was written by Sam Leffler while working for -Silicon Graphics. - -Silicon Graphics has seen fit to allow us to give this work away. It -is free. There is no support or guarantee of any sort as to its -operations, correctness, or whatever. If you do anything useful with -all or parts of it you need to honor the copyright notices. It would -also be nice to be acknowledged. - -LibTIFF as been maintained by cast of others since 1999. - -The persons currently actively maintaining and releasing libtiff are: - -* Even Rouault -* `Bob Friesenhahn `_ - -Significant maintainers in the past (since the 3.5.1 release) were: - -* `Frank Warmerdam `_ -* `Andrey Kiselev `_ -* Joris Van Damme -* Lee Howard - - -Contributors ------------- - -The LZW algorithm is derived from the compress program (the proper attribution -is included in the source code). - -The Group 3 fax stuff originated as code from Jef Poskanzer, but has since -been rewritten several times. The latest version uses an algorithm from -Frank Cringle -- consult :file:`libtiff/mkg3states.c` and -:file:`libtiff/tif_fax3.h` for further information. - -The JPEG support was written by Tom Lane and is dependent on the -excellent work of Tom Lane and the Independent JPEG Group (IJG) who distribute -their work under friendly licensing similar to this software. Joris Van Damme -implemented the robust Old JPEG decoder (as included in libtiff since version -3.9.0, there was another Old JPEG module in older releases, which was -incomplete and unsuitable for many existing images of that format). - -JBIG module was written by Lee Howard and depends on JBIG library from the Markus -Kuhn. - -Many other people have by now helped with bug fixes and code; a few of -the more persistent contributors have been: - -.. list-table:: Contributors - :widths: 10 - :header-rows: 0 - - * - Bjorn P. Brox - * - Dan McCoy - * - J.T. Conklin - * - Richard Minner - * - Frank D. Cringle - * - Richard Mlynarik - * - Soren Pingel Dalsgaard - * - Niles Ritter - * - Steve Johnson - * - Karsten Spang - * - Tom Lane - * - Peter Smith - * - Brent Roman - * - Mike Welles - * - Frank Warmerdam - * - Greg Ward - * - Stanislav Brabec - * - Roman Shpount - * - Peter Skarpetis - * - Arvan Pritchard - * - Bernt Herd - * - Joseph Orost - * - Phil Beffery - * - Ivo Penzar - * - Francois Dagand - * - Albert Chin-A-Young - * - Bruce A. Mallett - * - Dwight Kelly - * - Andrey Kiselev - * - Ross Finlayson - * - Dmitry V. Levin - * - Bob Friesenhahn - * - Lee Howard - * - Joris Van Damme - * - Tavis Ormandy - * - Richard Nolde - * - Even Rouault - * - Roger Leigh - -(apologies to anyone that was inadvertently not listed.) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/project/bugs.rst b/thirdparty/SDL2_image/external/libtiff/doc/project/bugs.rst deleted file mode 100644 index af0d1bac5..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/project/bugs.rst +++ /dev/null @@ -1,49 +0,0 @@ -Reporting Bugs -============== - -.. image:: ../images/cover.jpg - :width: 110 - :alt: cover - - -Overview --------- - -The LibTIFF project uses `GitLab issues `_ -to report and manage bugs and feature requests. - -Please let us know when you find a problem or fix a bug. - -Previously, the project used -`MapTools.org bugzilla `_ -to track bugs. All remaining tickets in that bugzilla instance were -migrated to GitLab issues, and this system should no longer be used. -All bugs filed in a older bugzilla at -`RemoteSensing.org `_ (pre-April 2008) -have unfortunately been lost. - - -Reporting a bug ---------------- - -If you think you've discovered a bug, please first check to see if it is -already known by looking at the list of already reported bugs. Also, please -verify that the problem is still reproducible with the current development -software from GitLab. - -If you'd like to enter a new bug report, you can create a -`new GitLab issue `_ - -Of course, reporting bugs is no substitute for discussion. -Please see the :doc:`mailinglist` page for further details. - - -Reporting a security issue --------------------------- - -If you'd like to inform us about some kind of security issue that should not -be disclosed for a period of time, then you can contact the maintainers directly. -Send a copies of your report to the following people: - -* Frank Warmerdam ``_ -* Bob Friesenhahn ``_. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/project/index.rst b/thirdparty/SDL2_image/external/libtiff/doc/project/index.rst deleted file mode 100644 index f036c8ef4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/project/index.rst +++ /dev/null @@ -1,26 +0,0 @@ -############### -LibTIFF Project -############### - -The LibTIFF project provides free software maintained by a small community of software developers. See -:doc:`acknowledgements` for further details. - -Questions should be sent to the :doc:`mailinglist`. - -.. note:: - - Please do not email the maintainers personally, especially when asking - questions such as "when is the next release?". Please use the public mailing lists. - While the maintainers and contributors to LibTIFF are primarily professional software - developers, none of us are paid to work on LibTIFF directly, and almost all the - activity is voluntary and unpaid. - - -.. toctree:: - :maxdepth: 1 - :titlesonly: - - license - mailinglist - bugs - acknowledgements diff --git a/thirdparty/SDL2_image/external/libtiff/doc/project/license.rst b/thirdparty/SDL2_image/external/libtiff/doc/project/license.rst deleted file mode 100644 index 9c928bff6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/project/license.rst +++ /dev/null @@ -1,24 +0,0 @@ -LibTIFF License -=============== - -| Copyright © 1988-1997 Sam Leffler -| Copyright © 1991-1997 Silicon Graphics, Inc. - -Permission to use, copy, modify, distribute, and sell this software and -its documentation for any purpose is hereby granted without fee, provided -that (i) the above copyright notices and this permission notice appear in -all copies of the software and related documentation, and (ii) the names of -Sam Leffler and Silicon Graphics may not be used in any advertising or -publicity relating to the software without the specific, prior written -permission of Sam Leffler and Silicon Graphics. - -THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - -IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR -ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, -OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -OF THIS SOFTWARE. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/project/mailinglist.rst b/thirdparty/SDL2_image/external/libtiff/doc/project/mailinglist.rst deleted file mode 100644 index 0dd9134b6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/project/mailinglist.rst +++ /dev/null @@ -1,27 +0,0 @@ -Mailing List -============ - - -Overview --------- - -The `tiff@lists.osgeo.org `_ mailing list is for users of the LibTIFF software, and -discussion TIFF issues in general. - - -Subscription ------------- - -The mailing list managed with the Mailman software, and the web interface for subscribing -and managing your access to the list is at: ``_ - -Posts to the list are only accepted from members of the list. - - -Archive -------- - -A `Long Term Archive `_ -including recent messages, and most messages back to 1993, -with search capabilities is available. This archive has been prepared -and hosted by `AWare Systems `_. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/historical.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/historical.rst deleted file mode 100644 index a72482a74..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/historical.rst +++ /dev/null @@ -1,48 +0,0 @@ -Old release history -=================== - -Older LibTIFF releases. - -.. toctree:: - :maxdepth: 1 - :titlesonly: - - v3.9.5 - v3.9.4 - v3.9.3 - v3.9.2 - v3.9.1 - v3.9.0 - v3.9.0beta - v3.8.2 - v3.8.1 - v3.8.0 - v3.7.4 - v3.7.3 - v3.7.2 - v3.7.1 - v3.7.0 - v3.7.0beta2 - v3.7.0beta - v3.7.0alpha - v3.6.1 - v3.6.0 - v3.5.7 - v3.5.6beta - v3.5.5 - v3.5.4 - v3.5.3 - v3.5.2 - v3.5.1 - v3.4beta036 - v3.4beta035 - v3.4beta034 - v3.4beta033 - v3.4beta032 - v3.4beta031 - v3.4beta029 - v3.4beta028 - v3.4beta024 - v3.4beta018 - v3.4beta016 - v3.4beta007 diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/index.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/index.rst deleted file mode 100644 index ea19c92f7..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/index.rst +++ /dev/null @@ -1,28 +0,0 @@ -Release history -=============== - -LibTIFF releases. - -.. toctree:: - :maxdepth: 1 - :titlesonly: - - v4.5.1 - v4.5.0 - v4.4.0 - v4.3.0 - v4.2.0 - v4.1.0 - v4.0.10 - v4.0.9 - v4.0.8 - v4.0.7 - v4.0.6 - v4.0.5 - v4.0.4 - v4.0.4beta - v4.0.3 - v4.0.2 - v4.0.1 - v4.0.0 - historical diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta007.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta007.rst deleted file mode 100644 index 2c9cec9dc..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta007.rst +++ /dev/null @@ -1,75 +0,0 @@ -Changes in TIFF v3.4beta016 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta016 (no release tag) - Previous Version v3.4beta004 (no references to earlier releases exist) - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* bit order was corrected for Pentium systems -* a new define, :c:macro:`HOST_BIGENDIAN`, was added for code that - wants to statically use information about native cpu byte order - - -Library changes ---------------- - -* the G3/G4 decoder was replaced by a new one that is faster and - has smaller state tables -* Niles Ritter's client tag extension hooks were added -* a new routine :c:func:`TIFFCurrentDirOffset` was added for - applications that want to find out the file offset of a TIFF directory -* the calculation of the number of strips in an image was corrected - for images with certain esoteric configurations -* a potential memory leak (very unlikely) was plugged -* the ``TIFFReadRGBAImage`` support was completely rewritten - and new, more flexible support was added for reading images into - a fixed-format raster -* YCbCr to RGB conversion done in the :c:func:`TIFFReadRGBAImage` support - was optimized -* a bug in JPEG support calculation of strip size was corrected -* the LZW decoder was changed to initialize the code table to zero - to lessen potential problems that arise when invalid data is decoded -* :c:func:`tiffcomp.h` is now aware of OS/2 -* some function prototypes in :file:`tiffio.h` and :file:`tiffiop.h` - that contained parameter names have been changed to avoid complaints - from certain compilers - - -Portability support changes ---------------------------- - -* :file:`Makefile.in` has been corrected to use the parameters - chosen by the :program:`configure` script - - -Tools changes -------------- - -* :program:`fax2ps` has been rewritten and moved over from the user - contributed software -* an uninitialized variable in :program:`pal2rgb` has been fixed -* :program:`ras2tiff` now converts 24-bit RGB raster data so that - samples are written in the proper order -* :program:`tiff2ps` has been updated to include fixes - and enhancements from Alberto Accomazzi -* :program:`tiffcp` now has a "``-o``" option to select a directory - by file offset -* :program:`tiffinfo` is now capable of displaying the raw undecoded - image data in a file -* :program:`tiffgt` has been rewritten to use the new ``TIFFRGBAImage`` - support and to handle multiple files diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta016.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta016.rst deleted file mode 100644 index bb72cce9c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta016.rst +++ /dev/null @@ -1,71 +0,0 @@ -Changes in TIFF v3.4beta016 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta016 (no release tag) - Previous Version :doc:`v3.4beta007 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* support was added for configuring the Deflate codec -* support was added for the HTML documentation -* codecs that are not configured for inclusion in the library - are no longer compiled - - -Library changes ---------------- - -* support was added for registering new codecs external to the library - and for overriding the codecs that are builtin to the library -* emulation support for the old ``DataType`` tag was improved -* support was added for the ``SMinSampleValue`` - and ``SMaxSampleValue`` tags -* the library no longer ignores ``TileWidth`` and ``TileLength`` - tags whose values are not a multiple of 16 (per the spec); this - permits old, improperly written, images to be read -* the support for the ``Predictor`` tag was placed in a reusable - module so that it can be shared by multiple codecs -* experimental compression support was added for the Deflate algorithm - (using the freely available zlib package) -* a new routine, :c:func:`TIFFWriteBufferSetup` was added à la the - routine :c:func:`TIFFReadBufferSetup` -* the DSO version of the library is now statically linked with the - JPEG and Deflate libraries; this means applications that link against - the DSO do not also need to link against these ancillary libraries - - -Tools changes -------------- - -* all the tools now use common code to process compress-oriented arguments -* :program:`tiffdump` should now compile on a Macintosh with MPW - - -Documentation changes ---------------------- - -* everything was updated - - -Contributed software changes ----------------------------- - -* :file:`contrib/dbs/xtiff` was made to compile -* :file:`contrib/mac-mpw` is new support for compiling the software on - a Macintosh under MPW -* :file:`contrib/tags` is information on how to use the tag extenion - facilities; consult :file:`contrib/tags/README` for details diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta018.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta018.rst deleted file mode 100644 index bffb023d2..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta018.rst +++ /dev/null @@ -1,50 +0,0 @@ -Changes in TIFF v3.4beta018 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta018 (no release tag) - Previous Version :doc:`v3.4beta016 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* configure now recognizes IRIX 6.x systems -* configure now uses ``ENVOPTS`` when searching for an ANSI - C compiler; this fixes a problem configuring the software under - HP/UX with the native C compiler -* configure now correctly recognizes memory-mapped files are supported - under AIX - - -Library changes ---------------- - -* ``make install`` now properly installs the include files -* some portability fixes from Bjorn Brox -* the G3/G4 codec now warns about decoded rows that are longer than - the image/tile width -* changes from Frank Cringle to make the library work with the - gcc-specific bounds checking software -* miscellaneous fixes to :c:func:`TIFFPrintDirectory` -* bug fix to correct a problem where :c:func:`TIFFWriteRawStrip` - could not be used to automatically grow an image's length - - -Tools changes -------------- - -* fixes from Frank Cringle to update :program:`fax2tiff` -* portability fixes to :program:`tiff2bw` and :program:`tiffcmp` -* :program:`tiffdump` now uses the byte swapping routines in the library diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta024.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta024.rst deleted file mode 100644 index 1713dd3a4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta024.rst +++ /dev/null @@ -1,99 +0,0 @@ -Changes in TIFF v3.4beta024 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta024 (no release tag) - Previous Version :doc:`v3.4beta018 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* It is now possible to setup the software to build only the - library; :program:`configure` recognizes this is the intent when the - :file:`VERSION`, :file:`tiff.alpha`, and :file:`tif_version.c` - files are in the local directory (i.e. :file:`.`) -* :program:`configure` no longer tries to setup HTML materials -* include file directories needed in building the library are now - specified with a ``DIRS_LIBINC`` config parameter -* configure no longer checks for alternate compilers if ``CC`` - is set; if the specified compiler is not found or is not appropriate - the configuration procedure aborts -* the :file:`port.h` file generated by configure is now used only by - the library and as such as have been moved to the :file:`libtiff` - directory -* there is beginning support for building DSO's on systems other than IRIX -* configure now verifies the JPEG and zlib directory pathnames by - checking for well-known include files in these directories -* configure no longer creates the :file:`dist` directory needed only - on SGI machines (for building SGI binary distributions) -* a bug was fixed whereby configure would incorrectly set - ``ENVOPTS`` when building the software with gcc under AIX - - -Library changes ---------------- - -* two new typedefs were added to :file:`tiff.h`: :c:type:`int8` - and :c:type:`uint8` for signed and unsigned 8-bit quantities, - respectively; these are currently used only by - programs in the :file:`tools` directory -* the ``BadFaxLines``, ``CleanFaxData``, and - ``ConsecutiveBadFaxLines`` tags are now supported with - Group 4 compression -* byte order is now correctly identified on 64-bit machines -* a bug was fixed in the PackBits decoder where input data would - appear short when a no-op run was present -* a bug was fixed in calculations with very wide strips -* :c:func:`TIFFWriteEncodedStrip` and :c:func:`TIFFWriteRawStrip` - were extended to support dynamically growing the number of - strips in an image (must set ``ImageLength`` prior to - making calls though) -* :c:func:`TIFFDefaultTileSize` now rounds tile width and height - up to a multiple of 16 pixels, as required by the TIFF 6.0 specification -* the file :file:`version.h` is now built by a new :program:`mkversion` - program; this was done for portability to non-UNIX systems -* support was added for the Acorn RISC OS (from Peter Greenham) -* the builtin codec table is now made ``const`` when compiling - under VMS so that :file:`libtiff` can be built as a shared library -* support for the PowerPC Mac (from Ruedi Boesch) -* support for Windows NT/Windows 95 (from Scott Wagner) - - -Tools changes -------------- - -* the tools no longer include :file:`port.h` -* various portability fixes; mostly to eliminate implicit assumptions - about how long :c:type:`int32` data types are -* PostScript Level II additions to :program:`tiff2ps` from Bjorn Brox -* :program:`sgi2tiff` now handles RGBA images - - -Documentation changes ---------------------- - -* the documentation has been updated to reflect the current state of - the software -* some routines have been moved to different manual pages - to group like-routines together - - -Contributed software changes ----------------------------- - -* support was added for the Acorn RISC OS (from Peter Greenham) -* support for Windows NT/Windows 95 contributed for a previous - version of this software was sort of incorporated (it's broken - right now) (from Scott Wagner) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta028.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta028.rst deleted file mode 100644 index 77cd2fc1e..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta028.rst +++ /dev/null @@ -1,105 +0,0 @@ -Changes in TIFF v3.4beta028 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta028 (no release tag) - Previous Version :doc:`v3.4beta024 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* a "``-noninteractive``" flag was added to configure to - control whether or not it prints and prompts for configuration information -* various typos and fixes were made in configure for the the - library-only build support (this and other configure fixes from - `Richard Mlynarik `_) -* bugs were fixed in the handling of pathnames supplied for external - packages; e.g. ``DIR_JPEG`` -* the handling of ``SETMAKE`` is now done properly -* the default prototype function declaration for :c:func:`pow` was corrected -* a bug was fixed in :file:`libtiff/Makefile.in` that caused installation - to fail on systems without DSO support - - -Library changes ---------------- - -* Acorn RISC O/S support that was accidentally left out of the - left out of the previous distribution is present (from Peter Greenham) -* complaints about unknown and/or unsupported codecs have been - delayed until they are invoked; this permits applications to open - images and look at tags even if the image data is compressed with - an unknown/unsupported compression scheme -* bugs in handling unknown tags have been corrected; applications - that use multiple codecs, each with codec-specific tags, no longer - generate confusing error messages -* a missing pseudo-tag definition in the CCITT G3 codec was fixed - (this problem caused core dumps in the :program:`tiffcp` program) -* pseudo-tags are now treated specially; they are always considered - to be set (i.e. they do not use bits in the ``FIELD_*`` bit-vectors). -* the use of strip chopping can now be controlled on a per-file basis - through a mode parameter supplied when opening a file ("``C``" to - enable strip chopping and "``c``" to disable) -* two bugs were fixed in the writing of opposite-endian byte-order - files -* support was added for three new fax-related tags registered to - SGI: ``FaxRecvParams``, ``FaxRecvTime``, and ``FaxSubAddress`` -* the bit order of image data read and written can now be controlled - on a per-file basis through a mode parameter supplied when opening - a file ("``B``" to force MSB2LSB bit order, "``L``" for LSB2MSB bit - order, and "``H``" for the bit order of the native CPU) -* the byte order of image and tag data written to newly-created files - can now be controlled on a per-file basis through a mode parameter - supplied when opening a file ("``b``" to force Big-Endian byte order - and "``l``" to force Little-Endian byte order) -* the use memory-mapped files for images opened read-only can now - be controlled on a per-file basis through a mode parameter supplied - when opening a file ("``M``" to enable use of memory-mapped files - and "``m``" to disable use) -* the use of the :c:macro:`WIN32` define in :file:`tiffiop.h` has - been replaced by :c:macro:`__WIN32__` - - -Tools changes -------------- - -* :program:`fax2ps` now does a ``save`` and ``restore`` - around each page of PostScript; this fixes a problem with VM - overflow when printing a many-page document on some printers -* a bug in the handling of 3-channel images by :program:`ras2tiff` - was fixed -* :program:`tiffcp` has new options to control the byte order of - newly created files: "``-B``" for Big-Endian byte order, "``-L``" - for Little-Endian byte order; a "``-M``" option to disable the - use of memory-mapped files, and a "``-C``" option to disable the - use of strip chopping -* bugs were fixed in :program:`tiffcp` handling of codec-specific tags - - -Documentation changes ---------------------- - -* the :c:func:`TIFFOpen` page has been updated to reflect the new - optional open mode parameters - -Contributed software changes ----------------------------- - -* :file:`contrib/win95` contains information and code from `Philippe Tenenhaus - <100423.3705@compuserve.com>`_ - about using the software under Windows 95 -* :file:`contrib/winnt` contains information and code from `Dave Dyer - `_ - about using the software under Windows NT diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta029.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta029.rst deleted file mode 100644 index c9112aed4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta029.rst +++ /dev/null @@ -1,52 +0,0 @@ -Changes in TIFF v3.4beta029 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta029 (no release tag) - Previous Version :doc:`v3.4beta028 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* :program:`configure` now relativizes pathname references given in - "``-L``" options (as frequently specified when configuring - ancillary packages) -* problems related to configuring the software on Ultrix 4.4 have - been corrected -* the shell to use in Makefiles and scripts can now be set with the - ``SCRIPT_SH`` configuration parameter -* comments in :file:`config.site` now correctly indicate how to setup the - use of ancillary packages - - -Library changes ---------------- - -* mods for building the software on a Mac using the - MetroWerks CodeWarrior compilers -* a bug in the CCITT T.4/T.6 decoder was fixed where the last codeword in - a strip/tile might not be decoded; this was seen only when decoding - multi-strip images -* a bug in the CCITT RLE codecs was fixed whereby the pseudo tags were not - being properly registered - - -Contributed software changes ----------------------------- - -* :file:`contrib/mac-cw` contains information and code from `Niles Ritter - `_ - about building the software with the MetroWerks CodeWarrior compilers - on Macintosh systems diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta031.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta031.rst deleted file mode 100644 index 638495899..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta031.rst +++ /dev/null @@ -1,59 +0,0 @@ -Changes in TIFF v3.4beta031 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta031 (no release tag) - Previous Version :doc:`v3.4beta029 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* :program:`configure` now captures significantly more information - in the :file:`config.log` file and provides more information when - it is unable to setup a configuration -* support was added for building shared libraries on more systems: - AIX, HPUX, Solaris, and Linux. -* a new configuration parameter ``LIBCOPTS`` was added for - passing arguments to the C compiler to use when building only - the library; this is part of the enhanced support for building - shared libraries -* include files for optional packages that reside in :file:`/usr/include` - are now handled correctly -* build trees may now be configured using either relative or absolute - pathnames to the source distribution -* several new configuration parameters were added, mainly for building - shared libraries: ``DIST_MAJOR``, ``DIST_MINOR``, - ``DIST_ALPHA``, and ``DSOSUF_VERSION`` - - -Library changes ---------------- - -* the Deflate support has been revised: it requires version 0.99 of - the zlib software distribution, **the output format has changed and - is incompatible with previous versions of this library** (each - strip now includes a header read and written by the zlib library) -* the codec name printed by the :c:func:`TIFFPrintDirectory` routine is now - taken from the codec table instead of from a builtin table; this means - that application-defined codecs are handled correctly -* a new symbol was added that contains the library version number; - this can be used to do a compile-time compatibility check of the - library version - -Documentation changes ---------------------- - -* the creation and installation of manual pages was redone; it now - implements the documented "configuration scheme" diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta032.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta032.rst deleted file mode 100644 index 54cd695e4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta032.rst +++ /dev/null @@ -1,53 +0,0 @@ -Changes in TIFF v3.4beta032 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta032 (no release tag) - Previous Version :doc:`v3.4beta031 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* various fixups and subtle improvements to :program:`configure` - from Richard Mlynarik - - -Library changes ---------------- - -* a new codec from Pixar designed for high-resolution color images; - note that this codec is not configured by default -* a bug fix for reading tags with a single ``FLOAT`` value -* change to the :c:func:`TIFFGetField` calling convention: - a tag that has a single value of - type ``DOUBLE`` is now retrieved by passing a - ``double*`` instead of a - ``double**`` (this change makes the handling of tags with - ``DOUBLE`` values identical to the handling of tags with - ``FLOAT`` values) -* fix to VMS support for the handling of floating point values - - -Tools changes -------------- - -* :program:`tiffdump` now handles tags with ``FLOAT`` and ``DOUBLE`` - values - - -Contributed software changes ----------------------------- - -* updates to the Acorn OS support from Peter Greenham diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta033.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta033.rst deleted file mode 100644 index 2299b2bd4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta033.rst +++ /dev/null @@ -1,45 +0,0 @@ -Changes in TIFF v3.4beta033 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta033 (aka the v3.4 release) (no release tag) - Previous Version :doc:`v3.4beta032 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* support was added for building the library as a DSO under OSF/1 - - -Library changes ---------------- - -* fixes to the Pixar codec -* portability mods for VMS - - -Tools changes -------------- - -* fixes to :program:`gif2tiff` and :program:`ppm2tiff` for building under MS/DOS -* portability mods to :program:`fax2ps` and :program:`ycbcr` for VMS - - -Contributed software changes ----------------------------- - -* a new package from Alexander Lehmann - for building the library and tools under MS/DOS with DJGPP v2 -* updated VMS support from Karsten Spang diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta034.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta034.rst deleted file mode 100644 index 1189024ec..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta034.rst +++ /dev/null @@ -1,37 +0,0 @@ -Changes in TIFF v3.4beta034 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta034 (no release tag) - Previous Version :doc:`v3.4beta033 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* support was added for building the library as a DSO under NetBSD -* a bug was fixed in the DSO support for Linux -* the handling of version strings has changed slightly to simplify parsing -* a new parameter, ``TIFFLIBREF``, was added to control how the - library is referenced when linking programs in the :file:`tools` directory - - -Library changes ---------------- - -* DSO creation under Solaris now forces the DSO name with a ``-h`` option -* the interface to the :program:`mkversion` program was changed - to eliminate the need to parse files -* a bug was fixed in the EOL-detection logic of the T.4/T.6 decoder -* ANSI IT8 TIFF/IT tag definitions were added to :file:`tiff.h` diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta035.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta035.rst deleted file mode 100644 index cc96db2f4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta035.rst +++ /dev/null @@ -1,32 +0,0 @@ -Changes in TIFF v3.4beta035 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta035 (no release tag) - Previous Version :doc:`v3.4beta034 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* support was added installing the HTML documentation -* support was added for building the library as a DSO under FreeBSD - - -Library changes ---------------- - -* the interface to the :program:`mkversion` program was restored to - the form used prior to v3.4beta034 -* several portability problems for 16-bit systems were fixed diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta036.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta036.rst deleted file mode 100644 index df3b6159a..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.4beta036.rst +++ /dev/null @@ -1,86 +0,0 @@ -Changes in TIFF v3.4beta036 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.4beta036 (no release tag) - Previous Version :doc:`v3.4beta035 ` - Master Download Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* support was added for building the library as a DSO under HP-UX with - the native C compiler -* tools are now built with explicit pathnames for the DSO under IRIX, - Solaris, and Linux -* DSO configuration support for Linux was changed to require that - :file:`libc.so` only be readable (not executable) - - -Library changes ---------------- - -* support was add for ICC: ``NumberOfInks``, and ``ICCProfile`` -* a memory leak caused by doing ``TIFFSetDirectory(0)`` was fixed -* a bug was fixed whereby certain multi-directory files were not - properly handled when accessed by mapping the data into memory -* the strip chopping support is now always compiled - into the library with the default usage controlled by a - :c:macro:`STRIPCHOP_DEFAULT` configuration parameter -* the strip chopping support no longer chops tiled images -* all static strings are now const---for shared libraries -* the logic for estimating the strip size of images without - ``StripByteCounts`` tag was improved by handling - ``PlanarContig`` images differently from ``PlanarSeparate`` -* a bug was fixed in the G3 codec when converting the Y resolution - of data specified in metric units -* a bug was fixed in the G3/G4 decoder for data where lines terminate - with a ``v0`` code -* the ``TIFFRGBAImage`` support was changed to scale 16-bit colormap - entries more conservatively to avoid problems with applications - that do not generate fully saturated pixel values -* the LZW decoder was changed to use a more conservative scheme when - bounds checking the hash table array; this avoids pitfalls with - systems that load objects into memory in unusual locations -* a bug was fixed in :c:func:`TIFFPrintDirectory` handling of the - ``InkNames`` tag -* :c:func:`TIFFPrintDirectory` now understands ``NumberOfInks`` - and ICC-related tags -* the routines for reading image data now provide more useful information - when a read error is encountered -* support was added for compiling with Microsoft Visual C++ 4.0 - - -Tools changes -------------- - -* a bug was fixed in :program:`pal2rgb` colormap handling -* :program:`tiff2ps`: - - * now includes John Wehle's changes for maintaining - the aspect ratio of images when scaling and for honoring the deadzone - on a page when generating PostScript Level II - * does a better job guarding against the mishandling - of greyscale images - * now correctly converts X- and Y-resolution values - specified in metric units -* :program:`tiffdump`: - - * has a new "``-m``" option to control the maximum number of indirect - data values printed for a tag (by default 24) - * understands several new tags - * now shows any terminating null in ASCII strings - -* :program:`tiffinfo` now suppresses strip chopping when interpreting an image; - a new "``-z``" option has been added to enable strip chopping diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.1.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.1.rst deleted file mode 100644 index 3333d0e15..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.1.rst +++ /dev/null @@ -1,41 +0,0 @@ -Changes in TIFF v3.5.1 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.5.1 (no release tag) - Previous Version v3.4beta037 (missing release notes, go to :doc:`v3.4beta036 `) - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -None. - - -Library changes ---------------- - -* Support was added for IPTC Newsphoto metadata (:c:macro:`TIFFTAG_IPTCNEWSPHOTO`) -* Support was added for photoshop caption handling (:c:macro:`TIFFTAG_PHOTOSHOP`) - - -Contributed software changes ----------------------------- - -* `Bill Radcliffe's `_ :program:`iptcutil` was - added to the :file:`contrib` subdirectory . It can convert an IPTC binary - blob to ASCII text and vice-versa. The blob itself can be extracted - from or added to an image with the `ImageMagick `_ - :program:`convert` (1) utility. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.2.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.2.rst deleted file mode 100644 index 3286f8dd0..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.2.rst +++ /dev/null @@ -1,74 +0,0 @@ -Changes in TIFF v3.5.2 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.5.2 (no release tag) - Previous Version :doc:`v3.5.1 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* Corrected alpha versioning. - -* Removed distinction between alpha and release targets in :file:`Makefile.in`. - -* Added release.stamp target, which tags cvs tree, and updates - :file:`RELEASE-DATE` - -* Added ``releasediff`` target, which diffs tree with source as of - date in :file:`RELEASE-DATE` - -* Ticked up version to 3.5.2 (alpha 01 -- but I think we'll moving - away from alpha/non-alpha distinctions). - - -Library changes ---------------- - -* Added IRIX/gcc, and OSF/1 4.x support on behalf of - `Albert Chin-A-Young `_. - -* Added :c:func:`TIFFReassignTagToIgnore` API on behalf of - `Bruce Cameron `_. Man page still pending. - -* pre-remove :file:`so` link before softlink in ``LINUXdso`` action in - :file:`libtiff/Makefile.in` to avoid failure on ``LINUXdso`` builds other than - the first. - -* Fixed problem with :c:func:`cvtcmap` in :file:`tif_getimage.c` modifying the - colormaps owned by the TIFF handle itself when trying to fixup wrong - (eight bit) colormaps. Corrected by maintaining a private copy of - the colormap. - -* Added :c:func:`TIFFReadRGBATile`/:c:func:`TIFFReadRGBAStrip` support in - :file:`tif_getimage.c`. - -* Applied "``a``" mode fix to :file:`tif_win32.c`/:c:func:`TIFFOpen` as suggested - by `Christopher Lawton `_. - -* Set ``O_BINARY`` for :file:`tif_unix.c` :c:func:`open` ... used on cygwin for instance. - -* Added ``CYGWIN`` case in configure. - -* Applied Francois Dagand's patch to handle fax decompression bug. - (sizes >= 65536 were failing) - - -Contributed software changes ----------------------------- - -* Added :program:`addtiffo` (add overviews to a TIFF file) in contrib. Didn't - put it in tools since part of it is in C++. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.3.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.3.rst deleted file mode 100644 index 987568de2..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.3.rst +++ /dev/null @@ -1,97 +0,0 @@ -Changes in TIFF v3.5.3 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.5.3 (:tag:`Release-v3-5-3`) - Previous Version :doc:`v3.5.2 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Major changes -------------- - -Please note the most important change: **LZW compression has been removed**. - -Unisys has the patent on LZW compression and have been very active in -their enforcement of late, demanding payments of $5000 or more from -websites using unlicensed software to create GIF's. They could well -do the same do persons using libtiff to create LZW compressed TIFF -images. - -From `Burn All GIF's Day `_: - - The catch is that it appears to be difficult or impossible to get a - Unisys license to use LZW in free software that complies with the Open - Source Definition - -Unfortunately, the removal of LZW compression means that saved image size has -grown dramatically. Without a change in the TIFF spec to support -another lossless compression format, this is unavoidable. - -The library can use zip for lossless compression, but as this is not -part of the spec, TIFFs using zip compression may not work with other -software. - -We will be making a patch available that will contain the LZW -compression code for users who have either obtained a license from -Unisys or are willing to risk it. - -LZW decompression is unchanged. - - -Software configuration changes ------------------------------- - -* Added zip creation to release makefile target - - -Library changes ---------------- - -* Added html for :file:`TIFFWriteTile.3t` man page. - -* Added some changes to :file:`tif_write.c` to support rewriting existing - fixed sized tiles and strips. Code mods disabled by default, only - enabled if :c:macro:`REWRITE_HACK` is defined for now. - -* Added :file:`TIFFWriteTile.3t` man page. - -* Added notes on use of :file:`makefile.vc` in :file:`build.html`, and fixed - email subscription address. - -* Did some casts cleaning up to reduce compiler warnings in :file:`tif_fax3.c`, - from `Bruce Cameron `_---modifications of - changes made by Frank (sun cc still complained on cast). - -* fixed various VC++ warnings as suggested by `Gilles Vollant - `_. - -* Modified :file:`TIFFquery.3t` man pages info on :c:func:`TIFFIsByteSwapped` to - not imply applications are responsible for image data swapping. - -* HTML-ized the man pages, added to :file:`html/man`. - -* Removed LZW Compression to comply with Unisys patent extortion. - -* Corrected one remaining ``16 -> 32`` bit value in :file:`tif_fax3.c`, - From `Ivo Penzar `_. - -* Added patch from Ivo Penzar to have :c:func:`TiffAdvanceDirectory` handle - memory mapped files. `Ivo Penzar `_. - - -Contributed software changes ----------------------------- - -* Fixed apocalypse-inducing y2k bug in :file:`contrib/ras/ras2tiff.c` diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.4.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.4.rst deleted file mode 100644 index d0d8349ea..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.4.rst +++ /dev/null @@ -1,45 +0,0 @@ -Changes in TIFF v3.5.4 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.5.4 (:tag:`Release-v3-5-4`) - Previous Version :doc:`v3.5.3 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* None. - - -Library changes ---------------- - -* Added Pixar tag support. Contributed by `Phil Beffery `_. -* Made one more change to :file:`tif_dir.c` for removal of LZW compression. Also added notice - when LZW compression invoked. -* Fixed bug that caused LZW (non) compression to segfault. Added - warning about LZW compression removed being removed, and why. - - -Tools changes -------------- - -* Changed default compression in tools to :c:macro:`TIFF_PACKBITS`, and changed usage descriptions - in tools to reflect removal of LZW compression -* Added ``nostrip`` to install in :file:`tools/Makefile.in` so that debugging - symbols are kept. -* Made Packbits the default compression in :file:`tools/tiff2rgba.c` instead - of LZW. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.5.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.5.rst deleted file mode 100644 index 8c10d529f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.5.rst +++ /dev/null @@ -1,91 +0,0 @@ -Changes in TIFF v3.5.5 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.5.5 (:tag:`Release-v3-5-5`) - Previous Version :doc:`v3.5.4 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* :file:`configure`: added test for libc6 for linux targets. Bug reported by - `Stanislav Brabec `_. -* :file:`configure`: fixed bugs in sed scripts - (applied sed script ``s:/@:s;@:;s:/s;;:;:`` to configure). - fix submitted by `Stanislav Brabec `_. -* :file:`tools/iptcutil` was not in files list, and wasn't being - added to tar archive. :file:`Updated Makefile.in`. -* Added 3.5 docs to :file:`html/Makefile.in`. - Thanks to `Stanislav Brabec `_ -* Fixed :file:`tools/tiffcmp` so that ``stopondiff`` testing works. - Patch care of `Joseph Orost `_. -* Added :file:`fax3sm_winnt.c` to distribution list in :file:`Makefile.in`. -* Added :file:`libtiff/libtiff.def` to ``TIFFILES`` distribution list. - - -Library changes ---------------- - -* :file:`tif_fax3.c`: Fixed serious bug introduced during the ``uint16->uint32`` - conversion for the run arrays. -* Set :c:member:`td_sampleformat` default to :c:macro:`SAMPLEFORMAT_UINT` instead of - :c:macro:`SAMPLEFORMAT_VOID` in :c:func:`TIFFDefaultDirectory` in :file:`tif_dir.c`. -* Added "GetDefaulted" support for :c:macro:`TIFFTAG_SAMPLEFORMAT` in :file:`tif_aux.c`. -* Patched :file:`tif_fax3.c` so that ``dsp->runs`` is allocated a bit bigger - to avoid overruns encountered with :file:`frle_bug.tif`. -* Modified :file:`tif_unix.c` to support 2-4GB seeks if :c:macro:`USE_64BIT_API` is - set to 1, and added default (off) setting in :file:`tiffconf.h`. This - should eventually be set by the configure script somehow. - The original work on all these 2-4GB changes was done by - `Peter Smith `_. -* Modified :file:`tif_win32.c` to support 2-4GB seeks. -* tentatively changed :c:type:`toff_t` to be unsigned instead of signed to - facilitate support for 2-4GB files. -* Updated a variety of files to use :c:type:`toff_t`. Fixed some mixups - between :c:type:`toff_t` and :c:type:`tsize_t`. -* Set :c:member:`tif_rawdatasize` to zero when freeing raw data buffer in - :c:func:`TIFFWriteDirectory`. -* Enabled :c:macro:`REWRITE_HACK` in :file:`tif_write.c` by default. -* Fix bug in :file:`tif_write.c` when switching between reading one directory - and writing to another. -* Made :c:func:`TIFFWriteCheck` public, and added :c:func:`TIFFCreateDirectory` -* Added :doc:`/functions/TIFFmemory` functions to :file:`libtiff.def`. -* Added :file:`libtiff/libtiff.def` to ``TIFFILES`` distribution list. - - -Tools changes -------------- - -* :program:`fax2ps`: - - * Fixed mixup of width and height in bounding box statement - as per submission by `Nalin Dahyabhai `_. - * Modified :c:var:`printruns` to take :c:type:`uint32` instead of :c:type:`uint16`. - Patch courtesy of `Bernt Herd `_. -* Largely reimplemented :file:`contrib/addtiffo` to avoid temp files, - updating the TIFF file in place. Fixed a few other bugs to. -* Altered descriptions in tools to reflect "by default" lzw not supported - - -LZW compression kit changes ---------------------------- - -* created :file:`mangle-src.sh` -- sed scripts to munge src into LZW enabled format. - Thanks to `Stanislav Brabec `_. -* created :file:`Makefile` -* merged :file:`tif_dir.c` with current source. -* Created lzw compression kit, as a new CVS module (``libtiff-lzw-compression-kit``). -* Updated :file:`index.html` to note lzw compression kit. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.6beta.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.6beta.rst deleted file mode 100644 index 55d17bdc3..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.6beta.rst +++ /dev/null @@ -1,135 +0,0 @@ -Changes in TIFF v3.5.6beta -========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.5.6beta (no release tag) - Previous Version :doc:`v3.5.5 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* Added ``GNULDdso`` target and switched linux and freebsd to use it. -* :file:`tools/Makefile.in`: Modified to install properly on SGI. -* :file:`configure`: Fixed DSO test for Linux as per patch from - `Jan Van Buggenhout `_. - - -Library changes ---------------- - -* :file:`tif_dir.c`: Clear :c:macro:`TIFF_ISTILED` flag in :c:macro:`TIFFDefaultDirectory` - as per :bugzilla-rs:`18` - from ``_. - -* Modified :file:`tif_packbits.c` decoding to avoid overrunning the - output buffer, and to issue a warning if data needs to be - discarded. See :bugzilla-rs:`18` - -* Modified :c:func:`TIFFClientOpen` to emit an error on an attempt to - open a compressed file for update (``O_RDWR``/"``r+``") access. This is - because the compressor/decompressor code gets very confused when - the mode is ``O_RDWR``, assuming this means writing only. See - bug :bugzilla-rs:`13` - -* Applied patch for 0x0000 sequences in :file:`tif_fax3.h` definition - of :c:macro:`EXPAND1D` as per bug :bugzilla-rs:`11` (from Roman). - -* Fixed :file:`tiffcomp.h` to avoid win32 stuff if unix ``#defined``, to improve - cygwin compatibility. - -* Applied patch from Roman Shpount to :file:`tif_fax3.c`. This seems to - be a proper fix to the buffer sizing problem. See - :bugzilla-rs:`11` - -* Fixed :file:`tif_getimage.c` to fix overrun bug with YCbCr images without - downsampling. :bugzilla-rs:`10` - Thanks to `Nick Lamb `_ for reporting the - bug and proving the patch. - -* Fixed :file:`tif_jpeg.c` to avoid destroying the decompressor before - we are done access data thanks to bug report from: - `Michael Eckstein `_. - -* :file:`tif_open.c`: Don't set ``MMAP`` for ``O_RDWR`` files. - -* :file:`tif_open.c`: Set :c:macro:`STRIPCHOP_DEFAULT` for ``O_RDWR`` as well as ``O_RDONLY`` - so that files opened for update can be strip chopped too. - -* :file:`tif_read.c`: fixed up bug with files missing rowsperstrip and - the strips per separation fix done a few weeks ago. - -* Tentatively added support for :c:macro:`SAMPLEFORMAT_COMPLEXIEEEFP`, and - :c:macro:`SAMPLEFORMAT_COMPLEXINT`. - -* :file:`index.html`, :file:`bugs.html`: added bugzilla info. - -* :file:`tif_read.c`: fix subtle bug with determining the number of - rows for strips that are the last strip in a separation but - not the last strip of all in :c:func:`TIFFReadEncodedStrip`. - -* Applied 16/32 bit fix to :file:`tif_fax3.c`. Fix supplied by - `Peter Skarpetis `_. - -* Modified :file:`tiffio.h` logic with regard to including :file:`windows.h`. It - won't include it when building with :c:macro:`__CYGWIN__`. - -* :file:`README`: update to mention {REDACTED - defunct web site}, don't list Sam's old - email address. - -* :file:`libtiff/tif_dirread.c`: Don't use estimate strip byte count for - one tile/strip images with an offset, and byte count of zero. These - could be "unpopulated" images. - -* :file:`tif_win32.c`: Applied patch to fix overreads and ovverwrites - caught by BoundsChecker. From `Arvan Pritchard `_ (untested). - -* :file:`tif_getimage.c`: Applied patch to silence VC6 warnings. From - `Arvan Pritchard `__. - -* :file:`tif_lzw.c`: Applied patch to silence VC6 warnings. From - `Arvan Pritchard `__. - -* :file:`libtiff/tif_apple.c`: Applied "Carbon" support patches supplied by - `Leonard Rosenthol `_. May interfere - with correct building on older systems. If so, please let me know. - - -Tools changes -------------- - -* :file:`tools/rgb2ycbcr.c`: fixed output strip size to account for vertical - roundup if rows_per_strip not a multiple of vertical sample size. - -* :file:`tools/tiffsplit.c`: Copy :c:macro:`TIFFTAG_SAMPLEFORMAT`. - -* Modified :program:`tiff2bw` to ensure portions add to 100%, and that - white is properly recovered. See bug - :bugzilla-rs:`15` Patch - c/o `Stanislav Brabec `_ - - -Contributed software changes ----------------------------- - -* :file:`contrib/addtiffo`: Added "averaging" resampling option. - -* Added :file:`contrib/stream` (stream io) code submitted by Avi Bleiweiss. - - -LZW compression kit changes ---------------------------- - -* updated :file:`tif_dir.c` to reflect changes to no-lzw :file:`tif_dir.c`. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.7.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.7.rst deleted file mode 100644 index 97e9a2890..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.5.7.rst +++ /dev/null @@ -1,219 +0,0 @@ -Changes in TIFF v3.5.7 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.5.7 (:tag:`Release-v3-5-7`) - Previous Version :doc:`v3.5.6beta ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Software configuration changes ------------------------------- - -* :file:`libtiff/libtiff.def`: Brent Roman submitted new version adding - several missing entry points. Also add a few other entry points - later. - -* :file:`configure`, :file:`Makefile.in`, etc: added support for ``OPTIMIZER`` being - set from :file:`config.site`. -* :file:`config.guess`: updated wholesale to an FSF version apparently - from 1998 (as opposed to 1994). This is mainly inspired by - providing for MacOS X support. - -* :file:`configure/config.site`: modified to check if ``-lm`` is needed for - ``MACHDEPLIBS`` if not supplied by :file:`config.site`. Needed for Darwin. -* :file:`libtiff/tiff.h`: Applied hack to try and resolve the problem - with the :file:`inttypes.h` include file on AIX. (bug :bugzilla-rs:`39`) - -* :file:`configure`, :file:`*Makefile.in`: Various changes to improve configuration - for HP/UX specifically, and also in general. (bug :bugzilla-rs:`40`) They include: - - * Try to handle :program:`/usr/bin/sh` instead of :program:`/bin/sh` where necessary. - * Upgrade to HP/UX 10.x+ compiler, linker and dso options. - * Fixed :c:func:`mmap` test to avoid ``MMAP_FIXED`` ... it isn't available on HP - * Use ``-${MAKEFLAGS}`` in sub makes from makefiles. - * Fixed ``SCRIPT_SH``/``SHELL`` handling. - -* :file:`configure`: Changes for DSO generation on AIX provided by - `John Marquart `_. - -* :file:`configure`, :file:`libtiff/Makefile.in`: Modified to build DSOs properly - on Darwin thanks to `Robert Krajewski `_ and - `Keisuke Fujii `_. - -* :file:`configure`, :file:`libtiff/Makefile.in`: applied OpenBSD patches as per bug :bugzilla-rs:`61`. - -* :file:`Makefile.in`: added ``DESTDIR`` support as per bug :bugzilla-rs:`60`. - -* :file:`libtiff/tif_jpeg.c`: Define :c:macro:`HAVE_BOOLEAN` on windows if :file:`RPCNDR.H` - has been included. -* :file:`man/Makefile.in`: add :c:func:`TIFFClientOpen` link as per debian submitted - bug :bugzilla-rs:`66`. -* :file:`libtiff/Makefile.in`: Fixed ``@DSOSUB_VERSION`` to be ``@DSOSUF_VERSION@`` - in two places. - - -Library changes ---------------- - -* :file:`tif_fax3.c`: keep :c:var:`rw_mode` flag internal to fax3 state to remember - whether we are encoding or decoding. This is to ensure graceful - recovery if :c:func:`TIFFClientOpen` discovers an attempt to open a compressed - file for "``r+``" access, and subsequently close it, as it resets the - :c:member:`tif_mode` flag to ``O_RDONLY`` in this case to avoid writes, confusing the - compressor's concept of whether it is in encode or decode mode. - -* :file:`tif_luv.c`, :file:`tiff.h`, :file:`tiffio.h`: - New version of TIFF LogLuv (SGILOG) modules contributed by `Greg Ward - `_. He writes: - - * I improved the gamut-mapping function in :file:`tif_luv.c` for imaginary - colors, because some images were being super-saturated on the input - side and this resulted in some strange color shifts in the output. - - * I added a psuedotag in :file:`tiff.h` to control random dithering during - LogLuv encoding. This is turned off by default for 32-bit LogLuv and - on for 24-bit LogLuv output. Dithering improves the average color - accuracy over the image. - - * I added a ``#define`` for :c:macro:`LOG_LUV_PUBLIC`, which is enabled by default in - :file:`tiffio.h`, to expose internal routines for converting between LogLuv and - XYZ coordinates. This is helpful for writing more efficient, - specialized conversion routines, especially for reading LogLuv files. - -* :file:`libtiff/tif_dirinfo.c`: don't declare :c:var:`tiffFieldInfo` static on VMS. - -* Added :c:macro:`TIFFTAG_COPYRIGHT` support. - -* :file:`tif_getimage.c`: Added support for 16bit minisblack/miniswhite - images in RGBA interface. - -* :file:`libtiff/tif_dirinfo.c`: removed duplicate :c:macro:`TIFFTAG_PHOTOSHOP` as per - bug :bugzilla-rs:`44`. - -* :file:`libtiff/tif_dirwrite.c`: Added support for :c:enumerator:`TIFF_VARIABLE2` in the - case of writing :c:enumerator:`TIFF_BYTE`/:c:enumerator:`TIFF_SBYTE` fields as per - bug :bugzilla-rs:`43`. - -* :file:`libtiff/tif_dirinfo.c`: Modified the :c:enumerator:`TIFF_BYTE` definition for - :c:macro:`TIFFTAG_PHOTOSHOP` to use a writecount of :c:enumerator:`TIFF_VARIABLE2` (-3) to - force use of :c:type:`uint32` counts instead of :c:expr:`short` counts. - -* :file:`libtiff/tif_dirinfo.c`: moved pixar and copyright flags to ensure everything is in order. - -* Integrated experimental OJPEG support from Scott Marovich of HP. - -* :file:`libtiff/tif_open.c`: Seek back to zero after failed read, before writing header. - -* :file:`libtiff/tiff.h`, :file:`libtiff/tif_fax3.c`: added check for :c:macro:`__LP64__` - when checking for 64 bit architectures as per bugzilla bug :bugzilla-rs:`67`. - -* :file:`libtiff/tif_getimage.c`: Use :c:func:`memmove` instead of :c:func:`TIFFmemcpy` - in :c:func:`TIFFReadRGBATile` to avoid issues in cases of overlapping - buffers. See bug :bugzilla-rs:`69` in Bugzilla. - -* :file:`libtiff/tif_getimage.c`: Don't complain for CMYK (separated) - images with more than four samples per pixel as per bug :bugzilla-rs:`73`. - -* :file:`libtiff/tif_getimage.c`: relax handling of contig case where - there are extra samples that are supposed to be ignored as per bug :bugzilla-rs:`75`. This - should now work for 8bit greyscale or paletted images. - -* :file:`libtiff/tif_packbits.c`: fixed memory overrun error as per bug :bugzilla-rs:`77`. - -* :file:`libtiff/tif_getimage.c`: Fixed problem with reading strips or - tiles that don't start on a tile boundary. Fix contributed by - Josep Vallverdu (from HP), and further described in bug :bugzilla-rs:`47`. - -* :file:`libtif/tif_fax3.c`: Removed ``#ifdef PURIFY`` logic, and modified to - always use the "safe" version, even if there is a very slight - cost in performance as per bug :bugzilla-rs:`54`. - -* :file:`libtiff/tif_lzw.c`: added dummy :c:func:`LZWSetupEncode` to report an - error about LZW not being available. - -* :file:`libtiff/tif_dir.c`: propagate failure to initialize compression - back from :c:func:`TIFFSetField` as an error status, so applications can - detect failure. - -* :file:`libtiff/tif_lzw.c`: Avoid MS VC++ 5.0 optimization bug as per bug :bugzilla-rs:`78`. - -* :file:`libtiff/tif_dirwrite.c`: added :c:func:`TIFFRewriteDirectory` function. - Updated :c:func:`TIFFWriteDirectory` man page to include :c:func:`TIFFRewriteDirectory`. - -* :file:`libtiff/tiff.h`: I have created :c:macro:`COMPRESSION_CCITT_T4`, - :c:macro:`COMPRESSION_CCITT_T6`, :c:macro:`TIFFTAG_T4OPTIONS` and :c:macro:`TIFFTAG_T6OPTIONS` aliases - in keeping with TIFF 6.0 standard in :file:`tiff.h` as per bug :bugzilla-rs:`83`. - -* Added :c:macro:`PHOTOMETRIC_ITULAB` as per bug :bugzilla-rs:`90`. - - -Tools changes -------------- - -* Brent Roman contributed updated :program:`tiffcp` utility (and :file:`tiffcp.1`) - with support for extracting subimages with the ``,n`` syntax, and also - adding the "``-b``" bias removal flag. - -* :file:`tiff2ps.c`, :file:`tiff2ps.1`: Substantial changes to :program:`tiff2ps` by - Bruce A. Mallett, including a faster encoder, fixes for level - 2 PostScript, and support for the imagemask operator. - -* fax2ps.c: Helge (libtiff at oldach.net) submitted fix - that corrects behaviour for non-Letter paper - sizes. (bug :bugzilla-rs:`35`) It fixes two problems: - - Without scaling ("``-S``") the fax is now centered on the page size specified - with "``-H``" and/or "``-W``". Before, :program:`fax2ps` was using an obscure and practically - useless algorithm to allocate the image relative to Letter sized paper - which sometime sled to useless whitespace on the paper, while at the - same time cutting of the faxes printable area at the opposite border. - - Second, scaling now preserves aspect ratio, which makes unusual faxes - (in particular short ones) print properly. - -* :file:`thumbnail.c`: changed default output compression - to packbits from LZW since LZW isn't generally available. - -* :file:`tiff2rgba.c`: added "``-n``" flag to avoid emitting alpha component. Also added - a man page for :program:`tiff2rgba`. - -* :file:`tiffcmp.c`: Fixed multi samples per pixel support for :c:func:`ContigCompare` - as per bug :bugzilla-rs:`53`. - Updated bug section of tiffcmp.1 to note tiled file issues. - -* :file:`libtiff/tif_getimage.c`: Fixed so that failure is properly - reported by :c:func:`gtTileContig`, :c:func:`gtStripContig`, :c:func:`gtTileSeparate` and - :c:func:`gtStripSeparate` as per bug :bugzilla-rs:`51`. - - -Contributed software changes ----------------------------- - -* Fixed distribution to include :file:`contrib/addtiffo/tif_ovrcache.c` - and :file:`contrib/addtiffo/tif_ovrcache.h`. - - -LZW compression kit changes ---------------------------- - -* Rewrote lzw patching process so that is required to enable full - LZW support is to drop the :file:`tif_lzw.c` from the - ``libtiff-lzw-compression-kit`` over the one in the libtiff directory. - -* Some changes were made to make recovery from failure to - initialize the LZW compressor more graceful. - -* Note that as distributed libtiff support LZW decompression, but - not LZW compression. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.6.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.6.0.rst deleted file mode 100644 index 345c5f188..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.6.0.rst +++ /dev/null @@ -1,372 +0,0 @@ -Changes in TIFF v3.6.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.6.0 (:tag:`Release-v3-6-0`) - Previous Version :doc:`v3.5.7 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Major changes -------------- - -* New utility :program:`raw2tiff` for converting raw rasters into TIFF files. -* Lots of new :program:`tiff2ps` options. -* Lots of new :program:`fax2tiff` options. -* Lots of bug fixes for LZW, JPEG and OJPEG compression. - -Custom Tag Support -^^^^^^^^^^^^^^^^^^ - -The approach to extending libtiff with custom tags has changed radically. -Previously, all internally supported TIFF tags had a place in the -private :c:struct:`TIFFDirectory` structure within libtiff to hold the values (if read), -and a "field number" (ie. :c:macro:`FIELD_SUBFILETYPE`) used to identify that tag. -However, every time a new tag was added to the core, the size of the -:c:struct:`TIFFDirectory` structure would change, breaking any dynamically linked -software that used the private data structures. - -Also, any tag not recognised -by libtiff would not be read and accessible to applications without some -fairly complicated work on the applications part to pre-register the tags -as exemplified by the support for "Geo"TIFF tags by libgeotiff layered on -libtiff. - -Among other things this approach required the extension code -to access the private libtiff structures ... which made the higher level -non-libtiff code be locked into a specific version of libtiff at compile time. -This caused no end of bug reports! - -The new approach is for libtiff to read all tags from TIFF files. Those that -aren't recognised as "core tags" (those having an associated ``FIELD_`` value, -and place for storage in the :c:struct:`TIFFDirectory` structure) are now read into a -dynamic list of extra tags (:c:member:`td_customValues` in :c:struct:`TIFFDirectory`). When a new -tag code is encountered for the first time in a given TIFF file, a new -anonymous tag definition is created for the tag in the tag definition list. -The type, and some other metadata is worked out from the instance encountered. -These fields are known as "custom tags". - -Custom tags can be set and fetched normally using :c:func:`TIFFSetField` and -:c:func:`TIFFGetField`, and appear pretty much like normal tags to application code. -However, they have no impact on internal libtiff processing (such as -compression). Some utilities, such as :program:`tiffcp` will now copy these custom -tags to the new output files. - -As well as the internal work with custom tags, new C API entry points -were added so that extension libraries, such as libgeotiff, could -define new tags more easily without accessing internal data structures. -Because tag handling of extension tags is done via the "custom fields" -mechanism as well, the definition provided externally mostly serves to provide -a meaningful name for the tag. - -The addition of "custom tags" and the altered approach to extending libtiff -with externally defined tags is the primary reason for the shift to the -3.6.x version number from 3.5.x. - -Software configuration changes ------------------------------- - -* :file:`configure`, :file:`config.site`: Fix for large files (>2GiB) support. New - option in the config.site: ``LARGEFILE="yes"``. Should be enough for the large - files I/O. - -* :file:`configure`: Set ``-DPIXARLOG_SUPPORT`` option along with ``-DZIP_SUPPORT``. - -* :file:`html/Makefile.in`: Updated to use :program:`groffhtml` for generating html pages - from man pages. - -* :file:`configure`, :file:`libtiff/Makefile.in`: Added SCO OpenServer 5.0.6 support - from John H. DuBois III. - -* :file:`libtiff/Makefile.vc`, :file:`libtiff/libtiff.def`: Missed declarations added. - -* :file:`libtiff/Makefile.in`, :file:`tools/Makefile.in`: Shared library will not be - stripped when installing, utility binaries will do be stripped. As per bug :bugzilla-rs:`93`. - -* :file:`man/Makefile.in`: Patch ``DESTDIR`` handling as per bug :bugzilla-rs:`95`. - -* :file:`configure`: OpenBSD changes for Sparc64 and DSO version as per bug :bugzilla-rs:`96`. - -* :file:`config.site/configure`: added support for ``OJPEG=yes`` option to enable - OJPEG support from :file:`config.site`. - -* :file:`config.gues`, :file:`config.sub`: Updated from ``_. - -* :file:`configure`: Modify ``CheckForBigEndian`` so it can work in a cross - compiled situation. - -* :file:`configure`, :file:`libtiff/Makefile.in`: Changes for building on MacOS 10.1 - as per bug :bugzilla-rs:`94`. - -* :file:`html/Makefile.in`: added missing images per bug :bugzilla-rs:`92`. - -* :file:`port/Makefile.in`: fixed clean target per bug :bugzilla-rs:`92`. - - -Library changes ---------------- - -* :file:`libtiff/tif_getimage.c`: New function :c:func:`TIFFReadRGBAImageOriented` - implemented to retrieve raster array with user-specified origin position. - -* :file:`libtiff/tif_fax3.c`: Fix wrong line numbering. - -* :file:`libtiff/tif_dirread.c`: Check field counter against number of fields. - -* Store a list of opened IFD to prevent directory looping. - -* :file:`libtiff/tif_jpeg.c`: modified segment_height calculation to always - be a full height tile for tiled images. Also changed error to just - be a warning. - -* :file:`libtiff/tif_lzw.c`: fixed so that decoder state isn't allocated till - :c:func:`LZWSetupDecode`. Needed to read LZW files in "``r+``" mode. - -* :file:`libtiff/tif_dir.c`: fixed up the :c:member:`tif_postdecode` settings responsible - for byte swapping complex image data. - -* :file:`libtiff/tif_open.c`: Removed error if opening a compressed file - in update mode bug (:bugzilla-rs:`198`). - -* :file:`libtiff/tif_write.c`: :c:func:`TIFFWriteCheck` now fails if the image is - a pre-existing compressed image. That is, image writing to pre-existing - compressed images is not allowed. - -* :file:`html/man/*.html`: Web pages regenerated from man pages. - -* :file:`libtiff/tif_jpeg.c`: Hack to ensure that "boolean" is defined properly - on Windows so as to avoid the structure size mismatch error from libjpeg - (bug :bugzilla-rs:`188`). - -* :file:`libtiff/tiff.h`: ``#ifdef USING_VISUALAGE`` around previous Visual Age - AIX porting hack as it screwed up gcc. (bug :bugzilla-rs:`39`) - -* :file:`libtiff/tiff.h`: added :c:macro:`COMPRESSION_JP2000` (34712) for LEAD tools - custom compression. - -* :file:`libtiff/tif_dirread.c`: Another fix for the fetching ``SBYTE`` arrays - by the :c:func:`TIFFFetchByteArray` function. (bug :bugzilla-rs:`52`) - -* :file:`libtiff/tif_dirread.c`: Expand ``v[2]`` to ``v[4]`` in :c:func:`TIFFFetchShortPair` - as per bug :bugzilla-rs:`196`. - -* :file:`libtiff/tif_lzw.c`: Additional consistency checking added in - :c:func:`LZWDecode` and :c:func:`LZWDecodeCompat` fixing bugs - :bugzilla-rs:`190` and :bugzilla-rs:`100`. - -* :file:`libtiff/tif_lzw.c`: Added check for valid code lengths in :c:func:`LZWDecode` - and :c:func:`LZWDecodeCompat`. Fixes bug :bugzilla-rs:`115`. - -* :file:`tif_getimage.c`: Ensure that :c:func:`TIFFRGBAImageBegin` returns the - return code from the underlying pick function as per bug :bugzilla-rs:`177`. - -* :file:`libtiff/tif_jpeg.c`, :file:`libtiff/tif_strip.c`, :file:`libtiff/tif_print.c`: - Hacked :file:`tif_jpeg.c` to fetch :c:macro:`TIFFTAG_YCBCRSUBSAMPLING` from the jpeg - data stream if it isn't present in the tiff tags as per bug :bugzilla-rs:`168`. - -* :file:`libtiff/tif_jpeg.c`: Fixed problem with setting of :c:var:`nrows` in - :c:func:`JPEGDecode` as per bug :bugzilla-rs:`129`. - -* :file:`libtiff/tif_read.c`, :file:`libtiff/tif_write.c`: :c:func:`TIFFReadScanline` and - :c:func:`TIFFWriteScanline` now set :c:member:`tif_row` explicitly in case the codec has - fooled with the value as per bug :bugzilla-rs:`129`. - -* :file:`libtiff/tif_ojpeg.c`: Major upgrade from Scott. Details in bug :bugzilla-rs:`156`. - -* :file:`libtiff/tif_open.c`: Pointers to custom procedures - in :c:func:`TIFFClientOpen` are checked to be not :c:macro:`NULL` pointers. - -* :file:`libtiff/tif_lzw.c`: Assertions in :c:func:`LZWDecode` and :c:func:`LZWDecodeCompat` - replaced by warnings. Now libtiff should read corrupted LZW-compressed - files by skipping bad strips as per bug :bugzilla-rs:`100`. - -* :file:`libtiff/tif_dirwrite.c`, :file:`libtiff/tif_write.c`, :file:`libtiff/tiffio.h`: - :c:func:`TIFFCheckpointDirectory` routine added as per bug :bugzilla-rs:`124`. - The :doc:`/functions/TIFFWriteDirectory` man page discusses this new function as well as the related - :c:func:`TIFFRewriteDirectory`. - -* :file:`libtiff/tif_codec.c`, :file:`libtiff/tif_compress.c`, - :file:`libtiff/tiffiop.h`, :file:`libtiff/tif_getimage.c`: - Introduced additional members ``tif->tif_decodestatus`` and ``tif->tif_encodestatus`` - for correct handling of unconfigured codecs (we should not try to read - data or to define data size without correct codecs). See bug :bugzilla-rs:`119`. - -* :file:`tif_dirread.c`: avoid div-by-zero if :c:var:`rowbytes` is zero in chop func as - per bug :bugzilla-rs:`111`. - -* :file:`libtiff/tiff.h`, :file:`libtiff/tif_dir.c`, :file:`libtiff/tif_dir.h`, - :file:`libtiff/tif_dirinfo.c`, :file:`libtiff/tif_dirread.c`, :file:`libtiff/tif_dirwrite.c`: - Dwight Kelly added get/put code for new tag ``XMLPACKET`` as - defined in Adobe XMP Technote. Added missing ``INKSET`` tag value from TIFF 6.0 - spec ``INKSET_MULTIINK`` (=2). Added missing tags from Adobe TIFF technotes: - ``CLIPPATH``, ``XCLIPPATHUNITS``, ``YCLIPPATHUNITS``, ``OPIIMAGEID``, ``OPIPROXY`` and - ``INDEXED``. Added ``PHOTOMETRIC`` tag value from TIFF technote 4 ``ICCLAB`` (=9). - -* :file:`libtiff/tif_getimage.c`: Additional check for supported codecs added in - :c:func:`TIFFRGBAImageOK`, :c:func:`TIFFReadRGBAImage`, :c:func:`TIFFReadRGBAStrip` and - :c:func:`TIFFReadRGBATile` now use :c:func:`TIFFRGBAImageOK` before reading a per bug - :bugzilla-rs:`110`. - -* :file:`libtiff/tif_dir.c`, :file:`libtiff/tif_dir.h`, :file:`libtiff/tif_dirinfo.c`, - :file:`libtiff/tif_dirread.c`, :file:`libtiff/tif_dirwrite.c`: - Added routine :c:func:`TIFFDataWidth` for determining - :c:enum:`TIFFDataType` sizes instead of working with :c:var:`tiffDataWidth` array - directly as per bug :bugzilla-rs:`109`. - -* :file:`libtiff/tif_dirinfo.c`, :file:`libtiff/tif_dirwrite.c`: Added possibility to - read broken TIFFs with ``LONG`` type used for :c:macro:`TIFFTAG_COMPRESSION`, - :c:macro:`TIFFTAG_BITSPERSAMPLE`, :c:macro:`TIFFTAG_PHOTOMETRIC` as per bug - :bugzilla-rs:`99`. - -* :file:`libtiff/tiff.h`, :file:`libtiff/tif_fax3.c`: Add support for - :c:macro:``__arch64__`` as per bug :bugzilla-rs:`94`. - -* :file:`libtiff/tif_read.c`: Fixed :c:func:`TIFFReadEncodedStrip` to fail if the - decodestrip function returns anything not greater than zero as per bug - :bugzilla-rs:`97`. - -* :file:`libtiff/tif_jpeg.c`: fixed computation of :c:var:`segment_width` for - tiled files to avoid error about it not matching the - ``cinfo.d.image_width`` values ("JPEGPreDecode: Improper JPEG strip/tile - size.") for ITIFF files. Apparently the problem was incorporated since - 3.5.5, presumably during the OJPEG/JPEG work recently. - -* :file:`libtiff/tif_getimage.c`: If :c:macro:`DEFAULT_EXTRASAMPLE_AS_ALPHA` is 1 - (defined in :file:`tiffconf.h` - 1 by default) then the RGBA interface - will assume that a fourth extra sample is ``ASSOCALPHA`` if the - ``EXTRASAMPLE`` value isn't set for it. This changes the behaviour of - the library, but makes it work better with RGBA files produced by - lots of applications that don't mark the alpha values properly. - As per bugs :bugzilla-rs:`93` and :bugzilla-rs:`65`. - -* :file:`libtiff/tif_jpeg.c`: allow jpeg data stream sampling values to - override those from tiff directory. This makes this work with - ImageGear generated files. - - -Tools changes -------------- - -* :program:`tiff2ps`: - - * Added page size setting when creating PS Level 2. - - * Fixed PS comment emitted when FlateDecode is being used. - -* :program:`tiffsplit`: increased the maximum number of pages that can be split. - -* :program:`raw2tiff`: - - * New utility for turning raw raster images into TIFF files - written by Andrey Kiselev. - - * Added option "``-p``" to explicitly select color space of input image data. - -* :program:`tiffmedian`: Support for large (> 2GB) images. - -* :program:`ppm2tiff`: Fixed possible endless loop. - -* :program:`tiff2rgba`: Switched to use :c:func:TIFFReadRGBAImageOriented - instead of :c:func:`TIFFReadRGBAImage`. - -* :program:`tiffcmp`: Fixed problem with unused data comparing (bug :bugzilla-rs:`349`). - "``-z``" option now can be used to set the number of reported different bytes. - -* :program:`tiffcp`: - - * Added possibility to specify value -1 to "``-r``" option to get the entire image as one strip - (bug :bugzilla-rs:`343`). - - * Set the correct ``RowsPerStrip`` and ``PageNumber`` values (bug :bugzilla-rs:`343`). - - * Fixed problem with colorspace conversion for JPEG encoded images (bugs :bugzilla-rs:`23` - and :bugzilla-rs:`275`) - - * Added support for ``Orientation`` tag. - -* :program:`fax2tiff`: - - * Page numbering fixed (bug :bugzilla-rs:`341`). - - * Applied patch from Julien Gaulmin. More switches for :program:`fax2tiff` tool for better control - of input and output (bugs :bugzilla-rs:`272` and :bugzilla-rs:`293`). - - * Updated to reflect latest changes in libtiff per bug :bugzilla-rs:`125`. - -* :program:`ppm2tiff`: PPM header parser improved: now able to skip comments. - -* :program:`tiff2ps`: - - * Sebastian Eken provided patches (bug :bugzilla-rs:`200`) to add new these new switches: - - "``-b #``": - for a bottom margin of # inches - "``-c``": - center image - "``-l #``": - for a left margin of # inches - "``-r``": - rotate the image by 180 degrees - - Also, new features merged with code for shrinking/overlapping. - - * Force deadzone printing when EPS output specified (bug :bugzilla-rs:`325`). - - * Add ability to generate PS Level 3. It basically allows one to use the ``/flateDecode`` - filter for ZIP compressed TIFF images. Patch supplied by Tom Kacvinsky - (bug :bugzilla-rs:`328`). - - * Don't emit ``BeginData``/``EndData`` DSC comments since we are unable to properly - include the amount to skip as per bug :bugzilla-rs:`80`. - - * Added workaround for some software that may crash when last strip of image contains fewer - number of scanlines than specified by the ``/Height`` variable as per bug :bugzilla-rs:`164`. - - * Patch from John Williams to add new functionality for splitting long images in several pages as - per bug :bugzilla-rs:`142`. New switches: - - "``-H #``": - split image if height is more than # inches - "``-L #``": - overLap split images by # inches - - * New commandline switches to override resolution units obtained from the input file per - bug :bugzilla-rs:`131`: - - "``-x``": - override resolution units as centimeters - "``-y``": - override resolution units as inches - - * tiff2ps: Division by zero fixed as per bug :bugzilla-rs:`88`. - -* :program:`tiffdump`: include :c:macro:`TIFFTAG_JPEGTABLES` in tag list. - -* :program:`tiffset`: fix bug in error reporting. - - -Contributed software changes ----------------------------- - -* Fixed distribution to include :file:`contrib/addtiffo/tif_ovrcache.c`, :file:`contrib/addtiffo/tif_ovrcache.h`. - -* :file:`libtiff/contrib/win95`: renamed to :file:`contrib/win_dib`. Added new - :file:`Tiffile.cpp` example of converting TIFF files into a DIB on Win32 as per - bug :bugzilla-rs:`143`. - - -LZW compression kit changes ---------------------------- - -* LZW compression kit synchronized with actual libtiff version. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.6.1.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.6.1.rst deleted file mode 100644 index bb7cbdf43..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.6.1.rst +++ /dev/null @@ -1,135 +0,0 @@ -Changes in TIFF v3.6.1 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.6.1 (:tag:`Release-v3-6-1`) - Previous Version :doc:`v3.6.0 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Major changes -------------- - -* New utility :program:`tiff2pdf` - for converting TIFF images directly into PDF. -* New :doc:`/functions/TIFFcolor` color conversion module. -* Full support for ``Orientation`` tag in ``TIFFRGBAImage`` interface. -* Many bugs fixed. - - -Software configuration changes ------------------------------- - -* :file:`libtiff/makefile.vc`, :file:`tools/makefile.vc`: Support for IJG JPEG library. - -* :file:`Makefile.in`: Add an absolute path to the :file:`test_pics.sh` call. - -* :file:`Makefile.in`: Add an absolute path to the :file:`test_pics.sh` call. - -* :file:`libtiff/tiffcomp.h`: ``#define _BSDTYPES_DEFINED`` when defining BSD typedefs. - -* :file:`configure`, :file:`libtiff/Makefile.in`, :file:`libtiff/mkversion.c`: Relative buildings fixed. - -* :file:`Makefile.in`: Add an absolute path to the :file:`test_pics.sh` call. - - -Library changes ---------------- - -* :file:`libtiff/tif_color.c`, :file:`libtiff/tif_getimage.c`, :file:`libtiff/tiffio.h`: - Added support for ``ReferenceBlackWhite`` tag handling when converted from YCbCr color space as - per bug :bugzilla-rs:`120`. - -* :file:`libtiff/tif_getimage.c`, :file:`libtiff/tif_aux.c`: Read ``WhitePoint`` tag from the - file and properly use it for CIE Lab 1976 to RGB transform. - -* :file:`libtiff/tif_getimage.c`, :file:`libtiff/tiffio.h`: Finally resolved problems with - orientation handling. ``TIFFRGBAImage`` interface now properly supports all - possible orientations, i.e. images will be flipped both in horizontal and - vertical directions if required. 'Known bugs' section now removed from the - appropriate manual pages. - -* :file:`libtiff/tif_luv.c`: Fixed bug in 48-bit to 24-bit conversion routine, - reported by Antonio Scuri. - -* :file:`libtiff/tiffio.h`, :file:`libtiff/tif_codec.c`: Added new function - :c:func:`TIFFIsCODECConfigured`, suggested by Ross Finlayson. - -* :file:`libtiff/tif_ojpeg.c`: :c:func:`TIFFVGetField` function now can properly extract - the fields from the OJPEG files. Patch supplied by Ross Finlayson. - -* :file:`libtiff/tif_dir.h`: :c:func:`_TIFFFindOrRegisterdInfo` declaration replaced - with :c:func:`_TIFFFindOrRegisterFieldInfo` as reported by Ross Finlayson. - -* :file:`libtiff/tif_dirinfo.c`: Implemented binary search in :c:func:`_TIFFMergeFieldInfo`. - Patch supplied by Ross Finlayson. - -* :file:`tif_dirread.c`: do not mark all anonymously defined tags to be ``IGNORE`` (as - it was done in 3.6.0). - -* :file:`libtiff/tiff.h`, :file:`libtiff/tif_dirinfo.c`: Added support for IFD (13) datatype, - introduced in "Adobe PageMaker TIFF Technical Notes". - -* :file:`libtiff/tif_color.c`, :file:`libtiff/tif_getimage.c`, :file:`libtiff/tiffio.h`: New color space - conversion code: CIE L*a*b* 1976 images now supported by the ``TIFFRGBAImage`` - interface. YCbCr to RGB conversion code also moved there and now has - :doc:`/functions/TIFFcolor` publicly available interface. These - routines currently used in ``TIFFRGBAImage`` interface only and not supported in - other libtiff tools yet. So if you want, for example, to convert CIE Lab image - into PostScript file you should do it in two steps: change colorspace to RGB - using :program:`tiff2rgba` utility and then process - it with the :program:`tiff2ps`. - -* :file:`libtiff/tif_tile.c`: Remove spurious use of "s" (sample) in the - ``planarconfig_contig`` case in :c:func:`TIFFComputeTile` as per bug :bugzilla-rs:`387`. - -* :file:`libtiff/tiffiop.h`: New macros: :c:macro:`TIFFmax` and :c:macro:`TIFFmin`. - -* :file:`libtiff/tiffio.h`, :file:`libtiff/tif_strip.c`: Added :c:func:`TIFFRawStripSize` function - as suggested by Chris Hanson. - -* :file:`libtiff/tif_lzw.c`, :file:`libtiff/tif_fax3.c`: Proper support for update mode - as per bug :bugzilla-rs:`424`. - - -Tools changes -------------- - -* :program:`tiff2pdf`:: New tool, written by - Ross Finlayson, to directly convert TIFF files to PDF. - -* :program:`tiffgt`: Unmaintained and platform - dependent sgigt utility removed and replaced with the completely rewritten - portable tool (depend on OpenGL and - GLUT). This tool will not build by default. - -* :program:`ras2tiff`: Properly determine - SUN Rasterfiles with the reverse byte order (it is reported by the magic - header field). Problem reported by Andreas Wiesmann. - -* :program:`raw2tiff`: Implemented image size - guessing using correlation coefficient calculation between two neighbour - lines. - - -Contributed software changes ----------------------------- - -* :file:`contrib/pds/tif_pdsdirread.c`, :file:`contrib/pds/tif_pdsdirwrite.c`: - Use :c:func:`TIFFDataWidth` function instead of :c:var:`tiffDataWidth` array. - -LZW compression kit changes ---------------------------- - -* Proper support for update mode as per bug :bugzilla-rs:`424`. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0.rst deleted file mode 100644 index b04ea491b..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0.rst +++ /dev/null @@ -1,78 +0,0 @@ -Changes in TIFF v3.7.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.7.0 (:tag:`Release-v3-7-0`) - Previous Version :doc:`v3.7.0beta2 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Major changes -------------- - - -* Several bugs found after 3.7.0beta2 release were fixed. - - -Software configuration changes ------------------------------- - -* :file:`ltmain.sh`: Fix for MinGW compilation. - - -Library changes ---------------- - -* :file:`libtiff/tif_dirread.c`, :file:`libtiff/tif_jpeg.c`, :file:`libtiff/tif_luv.c`, - :file:`libtiff/tif_ojpeg.c`, :file:`libtiff/tif_pixarlog.c`, :file:`libtiff/tif_write.c`: - Handle the zero strip/tile sizes properly (Dmitry V. Levin, Marcus Meissner). - -* :file:`libtiff/tif_dirinfo.c`: Type of the :c:macro:`TIFFTAG_SUBIFD` field changed - to :c:enumerator:`TIFF_IFD`. - -* Preliminary support for BigTIFF files: now libtiff can - recognize and reject to open such images. ;-) - -* :file:`libtiff/tif_dir.c`: Initialize :c:member:`td_tilewidth` and :c:member:`td_tilelength` fields - of the :c:struct:`TIFFDirectory` structure with the 0 instead of -1 to avoid - confusing integer overflows in :c:func:`TIFFTileRowSize` for striped images. - -* :file:`libtiff/tif_dirinfo.c`: Fix bug with ``tif_foundfield`` and reallocation - of ``tif_fieldinfo`` as per bug - :bugzilla-rs:`630` - -* :file:`libtiff/tif_compress.c`: Improved error reporting in - :c:func:`TIFFGetConfiguredCODECs` (Dmitry V. Levin). - - -Tools changes -------------- - -* :file:`tiffcmp.c` (:c:func:`leof`): Renamed from "``eof``" in order to avoid - conflict noticed under MinGW. - -* :file:`tiff2pdf.c`: Fixed ``TransferFunction`` tag handling reported - by Ross A. Finlayson. - - -Contributed software changes ----------------------------- - -* None. - - -LZW compression kit changes ---------------------------- - -* This one is not longer needed. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0alpha.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0alpha.rst deleted file mode 100644 index cc254621f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0alpha.rst +++ /dev/null @@ -1,179 +0,0 @@ -Changes in TIFF v3.7.0alpha -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.7.0alpha (:tag:`Release-v3-7-0-alpha`) - Previous Version :doc:`v3.6.1 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Major changes -------------- - -* Significant changes in software configuration: we are switched - to GNU autotools now. - -* :program:`tiffset`: Set any libtiff supported tags. Tags - can be supplied by the mnemonic name or number. - - -Software configuration changes ------------------------------- - -* Get rid of the old configuration system and switch to - GNU autotools. - - -Library changes ---------------- - -* :file:`libtiff/tif_ojpeg.c`: Fixed problem with duplicated ``SOI`` and ``SOF`` - markers as per bug - :bugzilla-rs:`581`. - -* :file:`libtiff/tif_open.c`, :file:`libtiff/tiffio.h`: New function added: - :c:func:`TIFFIsBigEndian`. Function returns nonzero if given was file written - in big-endian order. - -* :file:`libtiff/tif_print.c`: added (untested) support for printing - ``SSHORT``, ``SLONG`` and ``SRATIONAL`` fields. - -* :file:`libtiff/tif_fax3.c`: Avoid reading CCITT compression options - if compression type mismatches. See - :bugzilla-rs:`565`. - -* :file:`libtiff/tif_strip.c`: Never return 0 from the :c:func:`TIFFNumberOfStrips`. - -* :file:`libtiff/tif_dirread.c`: Workaround for broken TIFF writers which - store single ``SampleFormat`` value for multisampled images. See - :bugzilla-rs:`562`. - -* :file:`libtiff/tif_write.c`: Allow in-place updating of the compressed - images (don't work properly with all codecs). For details see GDAL bug - :bugzilla-rs:`534`. - -* :file:`libtiff/tif_jpeg.c`: Workaround for wrong sampling factors used - in the Intergarph JPEG compressed TIFF images as per bug: - :bugzilla-rs:`532`. - -* :file:`libtiff/tif_open.c`: Use dummy :c:func:`mmap`/:c:func:`munmap` functions in - :c:func:`TIFFClientOpen` when the appropriate client functions was not - supplied by user. - -* :file:`libtiff/tif_dirread.c`: Fixed problem with handling :c:enumerator:`TIFF_UNDEFINED` - tag type in :c:func:`TIFFFetchNormalTag` as per bug - :bugzilla-rs:`508`. - -* :file:`libtiff/tif_codec.c`: Fixed typo in ``TIFFInitPackBits`` name as per: - :bugzilla-rs:`494`. - -* :file:`libtiff/tif_fax3.c`: Fixed problem, introdiced in 3.6.1 release, - with the CCITT encoding modes as per bug - :bugzilla-rs:`483`. - We need more work on fax codec to support update mode. - -* :file:`libtiff/tiff.h`: Fixed tag definitions for :c:macro:`TIFFTAG_YCLIPPATHUNITS` - and :c:macro:`TIFFTAG_INDEXED` as per bug - :bugzilla-rs:`475`. - -* :file:`libtiff/tif_win32.c`, :file:`libtiff/tif_unix.c`: Check whether the pointer is - :c:macro:`NULL` before proceeding further as per bug - :bugzilla-rs:`474`. - - Check results, returned by the :c:func:`TIFFFdOpen` before returning and close - file if :c:func:`TIFFFdOpen` failed as per bug - :bugzilla-rs:`468`. - -* :file:`libtiff/libtiff.def`, :file:`libtiff/tif_close.c`, - :file:`libtiff/tiffio.h`, :file:`libtiff/tif_open.c`: - Separate :c:func:`TIFFCleanup` from the :c:func:`TIFFClose` in order to fix the bug - :bugzilla-rs:`468`. - -* :file:`libtiff/tif_dirwrite.c`: Fixed handling of writable ASCII tags - that are ``field_passcount=TRUE`` properly. Arguably anonymous custom - tags should be declared as ``passcount=FALSE``, but I don't want to change - that without a careful review. - -* :file:`libtiff/tif_write.c`: Fixed reporting size of the buffer in case - of stripped image in :c:func:`TIFFWriteBufferSetup`. As per bug - :bugzilla-rs:`460`. - -* :file:`libtiff/tif_dir.c`: Incomplete cleanup in :c:func:`TIFFFreeDirectory`, - patch from Gerben Koopmans. - -* :file:`libtiff/tif_dirread.c`: Check :c:member:`field_passcount` value before setting - the value of undefined type, patch from Gerben Koopmans. - -* :file:`libtiff/tiff.h`, :file:`libtiff/tif_fax3.c`: - Fixes for AMD 64 platform as suggested by Jeremy C. Reed. - -* :file:`libtiff/tif_win32.c`: Fixed problem with :c:func:`_TIFFrealloc` when - the :c:macro:`NULL` pointer passed. Patch supplied by Larry Grill. - - -Tools changes -------------- - -* :program:`tiffset`: Set any libtiff supported tags. Tags - can be supplied by the mnemonic name or number. - -* :file:`ycbcr.c`: fixed :c:func:`main` declaration as per: - :bugzilla-rs:`513`. - -* :program:`tiffsplit`: Don't forget - to copy ``PhotometricInterpretation`` tag. - -* :program:`tiffsplit`: - - * Fixed problem with - unproperly written multibyte files. Now output files will be written - using the same byte order flag as in the input image. See - :bugzilla-rs:`574`. - - * Copy ``JPEGTables`` - tag contents for JPEG compressed images. Reported by Artem Mirolubov. - -* :program:`tiffcp`: - - * Close output file on normal exit. - - * Don't emit warnings - when ``Orientation`` tag does not present in the input image. - - * Properly set - Photometric Interpretation in case of JPEG compression of grayscale - images. - - * Fixed problem with wrong - interpretation of the ``InkNames`` tag as per bug - :bugzilla-rs:`466`. - Memory leak fixed. - - * Fixed problem with - wrong ``PhotometricInterpretation`` setting for non-RGB images. - - -Contributed software changes ----------------------------- - -* Outdated stuff removed. - -* Almost all programs are synchronized with the current libtiff - and should compile without problems. - - -LZW compression kit changes ---------------------------- - -* No changes. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0beta.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0beta.rst deleted file mode 100644 index 8239faaee..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0beta.rst +++ /dev/null @@ -1,98 +0,0 @@ -Changes in TIFF v3.7.0beta -========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.7.0beta (:tag:`Release-v3-7-0beta`) - Previous Version :doc:`v3.7.0alpha ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Major changes -------------- - -* LZW compression enabled by default. You don't need the separate - compression kit anymore. - -* :program:`bmp2tiff`: Added new utility to convert Windows BMP files - into TIFFs. - -* The first attempt to implement a test suite. - - -Software configuration changes ------------------------------- - -* Many portability fixes in the new autotooled build suite. - - -Library changes ---------------- - -* :file:`libtiff/tif_luv.c`, :file:`libtiff/tif_next.c`, :file:`libtiff/tif_thunder.c`: - Several buffer overruns fixed, as noted by Chris Evans. - -* BSD data types (:c:type:`u_char`, :c:type:`u_short`, :c:type:`u_int`, :c:type:`u_long`) - is no longer used internally in the libtiff. Should result in simpler configuration - and better portability. - -* :file:`libtiff/tiff.h`: Fix column tagging. Reference current Adobe XMP - specification. Reference libtiff bug tracking system to submit - private tag additions. - -* :file:`libtiff/tif_dirread.c`: Don't reject to read tags of the - ``SamplesPerPixel`` size when the tag count is greater than number of - samples as per bug - :bugzilla-rs:`576`. - -* :file:`libtiff/tiffio.h`, :file:`libtiff/tif_open.c`: Applied patches from - Joris Van Damme to avoid requirement for :file:`tiffiop.h` inclusion in - some applications. Look for details here: - ``_. - -* :file:`libtiff/tiffiop.h`, :file:`libtiff/tif_dirinfo.c`: Fixed problem with the static - variable as per bug - :bugzilla-rs:`593`. - -* :file:`libtiff/tif_lzw.c`: LZW compression code is merged back from the - separate package. All libtiff tools are updated to not advertise an - absence of LZW support. - -* :file:`libtiff/tif_dir.c`: Call :c:func:`TIFFError` instead of producing warnings - when setting custom tags by value. Reported by Eric Fieleke. - - -Tools changes -------------- - -* :program:`tiff2ps`: Avoid zero division in :c:func:`setupPageState` function; - properly initialize array in :c:func:`PSDataBW`. - -* :program:`tiff2pdf`: Multiple bugfixes. - -* :program:`ras2tiff`: Fixed issue with missed big-endian checks as per bug - :bugzilla-rs:`586`. - -* :program:`bmp2tiff`: Added new utility to convert Windows BMP files - into TIFFs. - - -Contributed software changes ----------------------------- - -* No changes. - -LZW compression kit changes ---------------------------- - -* This one is not longer needed. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0beta2.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0beta2.rst deleted file mode 100644 index 832123c35..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.0beta2.rst +++ /dev/null @@ -1,69 +0,0 @@ -Changes in TIFF v3.7.0beta2 -=========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.7.0beta2 (:tag:`Release-v3-7-0beta2`) - Previous Version :doc:`v3.7.0beta ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Major changes -------------- - -* The code has been reviewed by Dmitry Levin: added checks - for values, returned by the space allocation functions, fixed - problems with the possible integer overflows. - - -Software configuration changes ------------------------------- - -* Several fixes in the test suite. - - -Library changes ---------------- - -* Preliminary support for BigTIFF files: now libtiff can - recognize and reject to open such images. ;-) - -* :file:`libtiff/tif_dirinfo.c`: changed type of XMLPacket (tag 700) to - :c:enumerator:`TIFF_BYTE` instead of :c:enumerator:`TIFF_UNDEFINED` to comply with the info - in the Adobe XMP Specification. - -* Added many checks for integer overflow and for successful space - allocations in the different parts of library. Code review - completed by Dmitry V. Levin. - -* :file:`libtiff/tiffio.h`, :file:`libtiff/tif_compress.c`: Added - :c:func:`TIFFGetConfiguredCODECs` function to get the list of configured codecs. - - -Tools changes -------------- - -* :file:`tiff2bw`: Write ``ImageWidth``/``ImageHeight`` tags to output file, as - noted by Gennady Khokhorin. - - -Contributed software changes ----------------------------- - -* No changes. - - -LZW compression kit changes ---------------------------- - -* This one is not longer needed. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.1.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.1.rst deleted file mode 100644 index bf8bffe2c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.1.rst +++ /dev/null @@ -1,160 +0,0 @@ -Changes in TIFF v3.7.1 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.7.1 (:tag:`Release-v3-7-1`) - Previous Version :doc:`v3.7.0 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - - -Major changes -------------- - -* This is mostly bugfix release. Most important fix is the one - related to wrong custom tag read/write code. - - -Software configuration changes ------------------------------- - -* :file:`autogen.sh`: :program:`aclocal` and :program:`autoheader` - should be executed after :program:`libtoolize`. - Also add ``-I .`` to aclocal invocation to check - current directory for macros. - -* nmake.opt: Link with the :file:`user32.lib` in windowed mode. As per bug - :bugzilla-rs:`697` - -* :file:`nmake.opt`, :file:`makefile.vc`: make it easier to rename the libtiff DLL. - -* :file:`configure`, :file:`configure.ac`: Added ``--enable-rpath`` option to embed - linker paths into library binary. - - -Library changes ---------------- - -* :file:`tiff.h`: Revert back libtiff data type definitions as per - bug :bugzilla-rs:`687` - -* :file:`tif_dirread.c`: Do not forget about :c:macro:`TIFF_VARIABLE2` when - checking for tag count in :c:func:`TIFFReadDirectory` function. As per bug - :bugzilla-rs:`713` - -* :file:`tif_getimage.c`: Support for multiple-alpha-channelled - RGB-images as per bug - :bugzilla-rs:`718` - -* :file:`tif_getimage.c`: ``#define A1`` bracketing for clean build on - SunPro compiler. - -* :file:`tif_dirwrite.c`: Always write :c:macro:`TIFFTAG_SUBIFD` using ``LONG`` type - as per bugs - :bugzilla-rs:`703` and - :bugzilla-rs:`704`. - -* :file:`tif_win32.c`: Use :c:expr:`char*` strings instead of :c:type:`TCHAR` in windowed - mode as per bug - :bugzilla-rs:`697` - -* :file:`tif_dir.c`, :file:`tif_dirread.c`: Remove :c:func:`TIFFReassignTagToIgnore` - call from the :c:func:`TIFFReadDirectory` function. :c:func:`TIFFReassignTagToIgnore` - must be removed in the future, as it was never used properly. As per - bug :bugzilla-rs:`692` - -* :file:`tif_jpeg.c`: Added a work-around in order to allow - compilation with the heavily modified version of libjpeg delivered - with Cygwin. - -* :file:`tif_dir.c`: Properly handle tags, which have the :c:type:`uint32` - counts. As per bug - :bugzilla-rs:`693` - -* :file:`tif_unix.c`: Make UNIX module compilable (and usable) - on Windows. - -* :file:`tiff.h`: Added Adobe DNG tags. - -* :file:`tif_aux.c`: Set the appropriate ``ReferenceBlackWhite`` array for - YCbCr image which lacks that tag (noted by Hans Petter Selasky). - -* :file:`tif_color.c`: Division by zero fixed (Hans Petter Selasky). - -* :file:`tif_stream.cxx`, :file:`tiffio.h`: Added C++ stream interface - contributed by Edward Lam (see - :bugzilla-rs:`654` - for details). Those who want to use C++ streams should - ``#include ``. - -* :file:`tif_open.c`: Removed :c:func:`close` in :c:func:`TIFFClientOpen` if file - is bad. This is the callers responsibility. - :bugzilla-rs:`651` - -* :file:`tiffio.h`, :file:`tif_win32.c`, :file:`libtiff.def`: Added :c:func:`TIFFOpenW` - function to work with the double byte strings (used to represent - filenames in some locales). As per bug - :bugzilla-rs:`625` - -* :file:`tif_dirread.c`: Fixed problem when fetching ``BitsPerSample`` and - ``Compression`` tags of type ``LONG`` from broken TIFFs as per bug - :bugzilla-rs:`662` - -* :file:`tif_dirinfo.c`: Fixed definition for ``TIFFTAG_RICHTIFFIPTC``, - the writecount should have :c:type:`uint32` type. As per bug - :bugzilla-rs:`662` - -* :file:`tif_write.c`: Fixed wrong ``if()`` statement in - :c:func:`TIFFAppendToStrip` function as per bug - :bugzilla-rs:`660` - -* :file:`tif_dirinfo.c`: Change definition for ``TIFFTAG_EXTRASAMPLES`` - field. The caller should supply a count when setting this field. As - per bug :bugzilla-rs:`648`. - -* :file:`tif_jpeg.c`, :file:`tif_ojpeg.c`: ``TIFFTAG_JPEGTABLES`` should have - uint32 count. Use this type everywhere. - -* :file:`tif_next.c`: avoid use of :c:type:`u_long` and :c:type:`u_char` types. - -* :file:`tif_fax3.c`: Fixed case with the wrong decode routines - choosing when the incorrect ``Group4Options`` tag set. As per bug - :bugzilla-rs:`323` - -* :file:`tif_dirwrite.c`: Fixed problem with passing count variable of - wrong type when writing the :c:macro:`TIFF_BYTE`/:c:macro:`TIFF_SBYTE` tags in - :c:func:`TIFFWriteNormalTag`. - -* :file:`tif_compress.c`: Zero division problem fixed (Vladimir Nadvornik, - Dmitry V. Levin). - - -Tools changes -------------- - -* :file:`fax2ps.c`: Be able to extract the first page (#0). As per bug - :bugzilla-rs:`690` - -* :file:`tiff2ps.c`: Fixed wrong variable data type when read ``Position`` - tags (Tristan Hill). - -* :file:`tiff2ps.c`: Fixed wrong variable data type when read ``Resolution`` - tags (Peter Fales). - -* :file:`tiffset.c`: Check the :c:func:`malloc` return value (Dmitry V. Levin). - - -Contributed software changes ----------------------------- - -* None. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.2.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.2.rst deleted file mode 100644 index b7369cd72..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.2.rst +++ /dev/null @@ -1,142 +0,0 @@ -Changes in TIFF v3.7.2 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.7.2 (:tag:`Release-v3-7-2`) - Previous Version :doc:`v3.7.1 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - -Major changes -------------- - -* Maintenance release. Many bugfixes in the build environment - and compatibility improvements. - - -Software configuration changes ------------------------------- - -* :file:`configure.ac`: Use ``-rpath`` option instead of ``-R`` as per bug - :bugzilla-rs:`732` - -* :file:`tif_stream.cxx`: Fixes for C++ stream interface from - Michael Rinne and Edward Lam. - -* :file:`configure.ac`: Make the documentation directory location - configurable via the ``--with-docdir`` option (as suggested by - Jeremy C. Reed). - -* Place the C++ stream API in the separate library called - ``libtiffxx`` to avoid unneeded dependencies. Probably there will be - more C++ API in the future. As per bugs - :bugzilla-rs:`733` - and :bugzilla-rs:`730` - -* :file:`configure`, :file:`configure.ac`: Replace ``--disable-c++`` with the - ``--disable-cxx`` option as per bug - :bugzilla-rs:`730`. - - -Library changes ---------------- - -* Applied patch from Lee Howard to support a new tag ``TIFFTAG_FAXDCS`` - (34911) used in HylaFax software. As per bug - :bugzilla-rs:`771` - -* :file:`tif_open.c`: Remove unnecessary :c:func:`TIFFSeekFile` call as per - bug :bugzilla-rs:`756` - -* :file:`tiff.h`: Changed the :c:type:`int8` definition to be always :c:expr:`signed char` - as per bug - :bugzilla-rs:`727` - -* :file:`tiffio.h`: Move :c:func:`TIFFOpenW` function into the ``extern "C"{}`` - block as per bug - :bugzilla-rs:`763` - -* :file:`tif_dirread.c`: Estimate strip size in case of wrong or - suspicious values in the tags. As per bugs - :bugzilla-rs:`705` - and :bugzilla-rs:`320` - -* :file:`tif_color.c`: Use double as the second argument of :c:func:`pow` - function in :c:func:`TIFFCIELabToRGBInit`. As per bug - :bugzilla-rs:`741` - -* :file:`tif_pixarlog.c`: Avoid warnings when converting float to - integer as per bug - :bugzilla-rs:`740` - -* :file:`tif_getimage.c`: Always fill the error message buffer in - :c:func:`TIFFRGBAImageBegin` as per bug - :bugzilla-rs:`739` - -* :file:`tif_jpeg.c`: Added ability to read/write the fax specific - :c:macro:`TIFFTAG_FAXRECVPARAMS`, :c:macro:`TIFFTAG_FAXSUBADDRESS` - and :c:macro:`TIFFTAG_FAXRECVTIME` tags as per bug - :bugzilla-rs:`736` - -* :file:`tif_win32.c`: Fixed message formatting in functions - :c:func:`Win32WarningHandler` and :c:func:`Win32ErrorHandler` as per bug - :bugzilla-rs:`735` - -* :file:`tiffio.h`: Move the color conversion routines in the ``extern - "C"`` section as per bug - :bugzilla-rs:`727` - -* :file:`tiff.h`: Restore back the workaround for AIX Visual Age C - compiler to avoid double definition of BSD types as per bug - :bugzilla-rs:`39` - -* :file:`tif_getimage.c`: More fixes for multiple-alpha-channelled - RGB-images as per bug - :bugzilla-rs:`713` - - -Tools changes -------------- - -* :file:`tiffcmp.c`: Added ability to compare the 32-bit integer and - floating point data; complain on unsupported bit depths. - -* :file:`tiffcmp.c`: Use properly sized buffer in short arrays comparison - as per bug - :bugzilla-rs:`785` - -* :file:`fax2ps.c`: Replace insecure :c:func:`mktemp` function with the - :c:func:`tmpfile` as per bug - :bugzilla-rs:`786` - -* :file:`tiffgt.c`: Fix problem on big-endian CPUs so that images - display more correctly. Images display brighter than they should - on a Sun workstation. - -* :file:`tiff2ps.c`: Fixed problem with page sizes as per bug - :bugzilla-rs:`742` - -* :file:`tiff2ps.c`: Interpret the "``-w``" and "``-h``" options independently. As - per bug - :bugzilla-rs:`689` - -* :file:`tiffdump.c`: Fixed problem when read broken TIFFs with the - wrong tag counts (Dmitry V. Levin, Martin Pitt). - -* :file:`tiffset.c`: Convert character option to integer value as per - bug :bugzilla-rs:`725`. - -Contributed software changes ----------------------------- - -* None. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.3.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.3.rst deleted file mode 100644 index c558e0d5c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.3.rst +++ /dev/null @@ -1,169 +0,0 @@ -Changes in TIFF v3.7.3 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.7.3 (:tag:`Release-v3-7-3`) - Previous Version :doc:`v3.7.2 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - -Major changes -------------- - -* Replace runtime endianness check with the compile time one. - -* Added support for the new predictor type (floating point - predictor), defined at the TIFF Technical Note 3. - -* Added Support for custom tags, passed by value. - -* Added support for all DNG tags. - - -Software configuration changes ------------------------------- - -* Do not use empty ``-R`` option when linking with ``--enable-rpath``. - -* Added workaround for OpenBSD/MirOS soname problem as per bug - :bugzilla-rs:`838` - -* Fixed parallel compilation of the libtiff and - libtiffxx libraries as per bug - :bugzilla-rs:`826` - -* :file:`configure.ac`, :file:`libtiff/Makefile.am`: Use libtool machinery to pass - ``rpath`` option. - -* :file:`make.opt`: Build with Win32 CRT library by default. - - -Library changes ---------------- - -* :file:`tiffiop.h`, :file:`tif_open.c`: Added open option "``h``" to avoid reading - the first IFD when needed. As per bug - :bugzilla-rs:`875` - -* :file:`tiff.h`: Use correct :c:expr:`int` size on Sparc 64bit/Sun compiler - platform. As per bug - :bugzilla-rs:`855` - -* :file:`tif_dirinfo.c`: Added support for ``ClipPath``, ``XClipPathUnits`` - and ``YClipPathUnits`` tags. - -* :file:`tif_dirinfo.c`, :file:`tif_dir.h`, :file:`tif_dir.c`, :file:`tif_print.c`: Make - ``DocumentName``, ``Artist``, ``HostComputer``, ``ImageDescription``, ``Make``, ``Model``, - ``Copyright``, ``DateTime``, ``PageName``, ``TextureFormat``, ``TextureWrapModes`` and - ``TargetPrinter`` tags custom. - -* :file:`tif_jpeg.c`: Cleanup the codec state depending on :c:macro:`TIFF_CODERSETUP` - flag (to fix memory leaks). - -* :file:`tif_dirwrite.c`: Use :c:member:`tdir_count` when calling - :c:func:`TIFFCvtNativeToIEEEDouble` in the :c:func:`TIFFWriteDoubleArray` function as - per bug :bugzilla-rs:`845` - -* :file:`tif_dirinfo.c`, :file:`tif_print.c`: :c:func:`TIFFFetchByteArray` returns - :c:type:`uint16` array when fetching the ``BYTE`` and ``SBYTE`` fields, so we should - consider result as pointer to :c:type:`uint16` array and not as array of :c:expr:`char`. - As per bug - :bugzilla-rs:`831` - -* :file:`tif_dir.c`: More efficient custom tags retrieval as per bug - :bugzilla-rs:`830` - -* :file:`tif_win32.c`: Use ``FILE_SHARE_READ | FILE_SHARE_WRITE`` share - mode in :c:func:`CreateFile` call as per bug - :bugzilla-rs:`829` - -* :file:`tif_jpeg.c`: Substantial fix for :program:`addtiffo` problems with - JPEG encoded TIFF files. Pre-allocate lots of space for jpegtables - in directory. - -* :file:`tif_dirread.c`: Changed the code that computes - ``stripbytecount[0]`` if it appears bogus to ignore if ``stripoffset[0]`` is - zero. This is a common case with GDAL indicating a "null" tile/strip. - -* :file:`tif_jpeg.c`: added ``LIB_JPEG_MK1`` support in :c:func:`JPEGDecodeRaw`. - -* :file:`tif_dirread.c`: Ensure that broken files with too many - values in :c:func:`TIFFFetchPerSampleShorts`, :c:func:`TIFFFetchPerSampleLongs` and - :c:func:`TIFFFetchPerSampleAnys` work ok instead of crashing. - :bugzilla-rs:`843` - -* :file:`tif_predict.h`, :file:`tif_predict.c`: Added ability to decode and encode - floating point predictor, as per TIFF Technical Note 3. - See http://chriscox.org/TIFF_TN3_Draft2.pdf for details. - -* :file:`tiffio.h`, :file:`tiffiop.h`, :file:`tif_dir.c`, :file:`tif_read.c`, :file:`tif_swab.c`: - Added :c:func:`_TIFFSwab24BitData` and :c:func:`TIFFSwabArrayOfLong` functions used to - swap 24-bit floating point values. - -* :file:`tiff.h`: Added predictor constants. - -* :file:`tiffiop.h`, :file:`tif_dir.c`: Use :c:type:`uint32` type for appropriate values - in :c:func:`_TIFFVSetField` function. Inspired by the bug - :bugzilla-rs:`816` - -* :file:`tif_open.c`: Do not read header in case the output file should - be truncated (Ron). - -* :file:`tif_dirinfo.c`, :file:`tif_config.h`.vc: Use :c:func:`lfind` instead of :c:func:`bsearch` - in :c:func:`_TIFFFindFieldInfoByName` function (Ron). - -* :file:`tif_dir.c`, :file:`tif_print.c`: Properly handle all data types in custom - tags. - -* :file:`dirinfo.c`: Added DNG tags. - -* :file:`tiff.h`: Added missed DNG tag (``LensInfo``); added DNG 1.1.0.0 tags. - -* :file:`tif_dir.c`, :file:`tif_print.c`: Added Support for custom tags, passed - by value. - -* :file:`tiff.h`, :file:`tif_dirinfo.c`, :file:`tiffiop.h`: Added EXIF related tags. - - -Tools changes -------------- - -* :file:`tiff2pdf.c`: Print two characters per loop in the - :c:func:`t2p_write_pdf_trailer`. As per bug - :bugzilla-rs:`594` - -* :file:`tiffgt.c`: Use MacOS X OpenGL framework when appropriate. As - per bug :bugzilla-rs:`844` - -* :file:`ppm2tiff.c`: Fixed format string when read PPM file header with - the :c:func:`fscanf` function. As per bug - :bugzilla-rs:`861` - -* :file:`tiffsplit.c`: Check for ``JPEGTables`` tag presence before copying. - -* :file:`tiff2pdfr.c`: Calculate the tile width properly; added new - option "``-b``" to use interpolation in output PDF files (Bruno Ledoux). - -* :file:`tiffdither.c`: Copy the `PhotometricInterpretation` tag from the - input file. - -* :file:`tif2pdf.c`: Fixed problem with alpha channel handling as per - bug :bugzilla-rs:`794`. - - -Contributed software changes ----------------------------- - -* :file:`addtiffo/tif_overview.c`, :file:`addtiffo/tif_ovrcache.c`, - :file:`addtiffo/tif_ovrcache.h`: - Make overviews working for contiguous images. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.4.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.4.rst deleted file mode 100644 index 4ee369aca..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.7.4.rst +++ /dev/null @@ -1,84 +0,0 @@ -Changes in TIFF v3.7.4 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.7.4 (:tag:`Release-v3-7-4`) - Previous Version :doc:`v3.7.3 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - -Major changes -------------- - -* Fixed important bug in custom tags handling code. - - -Software configuration changes ------------------------------- - -* Applied patch from Patrick Welche (all scripts moved in the - :file:`config` and :file:`m4` directories). - -* :file:`SConstruct`, :file:`libtiff/SConstruct`: Added the first very preliminary - support for SCons software building tool (``_). - This is experimental infrastructure and it will exist along with the - autotools stuff. - -* :file:`port/lfind.c`: Added :c:func:`lfind` replacement module. - - -Library changes ---------------- - -* :file:`tif_dir.c`: When prefreeing ``tv->value`` in :c:func:`TIFFSetFieldV` - also set it to :c:macro:`NULL` to avoid double free when re-setting custom - string fields as per: - :bugzilla-rs:`922` - -* tif_dir.c: Fixed up support for swapping "double complex" - values (128 bits as 2 64 bits doubles). GDAL gcore tests now - pass on bigendian (macosx) system. - -* :file:`libtiff/tif_dirread.c`, :file:`libtiff/tif_dirinfo.c`: Do not upcast ``BYTE`` to - ``SHORT`` in the :c:func:`TIFFFetchByteArray`. Remove :c:func:`TIFFFetchExtraSamples` - function, use :c:func:`TIFFFetchNormalTag` instead as per bug - :bugzilla-rs:`831` - - Remove :c:func:`TIFFFetchExtraSamples` function, use :c:func:`TIFFFetchNormalTag` - instead. - -* :file:`tif_print.c`: Fixed printing of the ``BYTE`` and ``SBYTE`` arrays. - -* :file:`tif_write.c`: Do not check the ``PlanarConfiguration`` field in - the :c:func:`TIFFWriteCheck` function in case of single band images (as per - TIFF spec). - -* :file:`libtiff/tif_dir.c`, :file:`libtiff/tif_dir.h`, - :file:`libtiff/tif_dirinfo.c`, :file:`libtiff/tif_print.c`: - Make ``FieldOfViewCotangent``, ``MatrixWorldToScreen``, ``MatrixWorldToCamera``, - ``ImageFullWidth``, ``ImageFullLength`` and ``PrimaryChromaticities`` tags custom. - -Tools changes -------------- - -* :file:`tiffcp.c`: Fixed ``WhitePoint`` tag copying. - - -Contributed software changes ----------------------------- - -* :file:`tiffdump.c`: Added support for :c:enumerator:`TIFF_IFD` datatype. - -* :file:`addtiffo/tif_overview.c`, :file:`addtiffo/tif_ovrcache.c`, - :file:`addtiffo/tif_ovrcache.h`: - Make overviews working for contiguous images. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.0.rst deleted file mode 100644 index 5ba272872..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.0.rst +++ /dev/null @@ -1,140 +0,0 @@ -Changes in TIFF v3.8.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.8.0 (:tag:`Release-v3-8-0`) - Previous Version :doc:`v3.7.4 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - -Major changes -------------- - -* Read-only support for custom directories (e.g. EXIF directory). - -* Preliminary support for MS MDI format. - - -Software configuration changes ------------------------------- - -* Make the default strip size configurable via the - ``--with-default-strip-size`` and :c:macro:`STRIP_SIZE_DEFAULT` options. - - -Library changes ---------------- - -* :file:`tiffio.h`: Added :c:macro:`VC_EXTRALEAN` definition before including - :file:`windows.h`, to reduce the compile time. - -* :file:`tif_jpeg.c`: Improve compilation under MinGW. - -* :file:`tif_aux.c`, :file:`tif_dir.c`, :file:`tif_dir.h`, :file:`tif_dirwrite.c`, - :file:`tif_print.c`, :file:`tif_getimage.c`: Make ``InkSet``, ``NumberOfInks``, ``DotRange`` and - ``StoNits`` tags custom. - -* :file:`tif_aux.c`, :file:`tif_dir.c`, :file:`tif_dir.h`, :file:`tif_print.c`: Make - ``WhitePoint`` tag custom. - -* :file:`tiffio.h`: fixed typo that potentially resulted in - redefininition of :c:macro:`USE_WIN32_FILEIO` - -* :file:`tif_dir.c`, :file:`tif_dir.h`, :file:`tif_print.c`: Make ``RichTIFFIPTC``, - ``Photoshop`` and ``ICCProfile`` tags custom. - -* :file:`libtiff/*`, :file:`contrib/*`: Added 'dual-mode' error handling, enabling - newer code to get context indicator in error handler and still - remain compatible with older code: Done :c:func:`TIFFError` calls everywhere - except in tools. - -* :file:`tiffinfo.c`: Print ``EXIF`` directory contents if exist. - -* :file:`tif_dirinfo.c`, :file:`tif_dirread.c`, :file:`tif_dir.h`, :file:`tif_dir.c`: - Custom directory read-only support. - -* :file:`tif_aux.c`, :file:`tif_dirinfo.c`, :file:`tif_dirread.c`, :file:`tif_dir.h`, - :file:`tif_dir.c`, :file:`tif_print.c`: Make ``YCbCrCoefficients`` and ``ReferenceBlackWhite`` - tags custom. - -* :file:`tif_dirread.c`: One more workaround for broken ``StripByteCounts`` - tag. Handle the case when ``StripByteCounts`` array filled with - completely wrong values. - -* :file:`tif_dirinfo.c`: Release file descriptor in case of failure - in the :c:func:`TIFFOpenW` function as per bug - :bugzilla-rs:`1003` - -* :file:`tif_dirinfo.c`: Correctly use :c:func:`bsearch` and :c:func:`lfind` - functions as per bug - :bugzilla-rs:`1008` - -* :file:`tif_open.c`, :file:`tiff.h`, :file:`tiffdump.c`: Incorporate preliminary support - for MS MDI format. - :bugzilla-rs:`1002` - -* libtiff.def, :file:`tiffiop.h`, :file:`tiffio.h`: Made :c:func:`TIFFFreeDirectory` - public. - -* :file:`/tif_dirinfo.c`: Make ``XResolution``, ``YResolution`` and - ``ResolutionUnit`` tags modifiable during write process. As per bug - :bugzilla-rs:`977` - -* :file:`if_dirread.c`: Don't try and split single strips into "0" strips - in :c:func:`ChopUpSingleUncompressedStrip`. This happens in some degenerate - cases (like 1×1 files with ``stripbytecounts==0`` (:file:`gtsmall.jp2` embed tiff) - -* :file:`tif_fax3.c`: changed '`at scanline ...`' style warning/errors - with incorrect use of tif_row, to '`at line ... of - strip/tile ...`' style. - - -Tools changes -------------- - -* :file:`tiffcp.c`: Added many error reporting messages; fixed integer - overflow as per bug - :bugzilla-rs:`789` - -* :file:`tiffcp.c`: Return non-zero status when reading fails. - -* :file:`fax2tiff.c`: Properly calculate sizes of temporary arrays - as per bug - :bugzilla-rs:`943` - -* :file:`fax2tiff.c`: Added option `-r` to set RowsPerStrip parameter - as per bug - :bugzilla-rs:`944` - -* :file:`tiffdump.c`: Fixed :c:var:`typeshift` and :c:var:`typemask` arrays initialization - problem as per bug - :bugzilla-rs:`946` - -* :file:`bmp2tiff.c`: Fixed possible integer overflow error as per bug - :bugzilla-rs:`965` - -* :file:`tiffsplit.c`: Copy fax related fields over split parts - as per bug - :bugzilla-rs:`983` - -* :file:`tiffdump.c`: Fixed crash when reading malformed tags. - -* :file:`tiff2pdf.c`: Added missed ``break`` statement as per bug - :bugzilla-rs:`932` - - -Contributed software changes ----------------------------- - -* :file:`contrib/addtiffo/*`: Major upgrade by Joris to support subsampled - YCbCr images in jpeg compressed TIFF files. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.1.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.1.rst deleted file mode 100644 index e6bd081ca..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.1.rst +++ /dev/null @@ -1,147 +0,0 @@ -Changes in TIFF v3.8.1 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.8.1 (:tag:`Release-v3-8-1`) - Previous Version :doc:`v3.8.0 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - -Major changes -------------- - -* Bug-fix release. - - -Software configuration changes ------------------------------- - -* libtool related stuff updated from the 2.1a branch. - -* Fix ``with_default_strip_size`` comparison as reported by - Norihiko Murase. - - -Library changes ---------------- - -* :file:`tif_dirread.c`: Fixed error reporting in :c:func:`TIFFFetchAnyArray` - function as per bug - :bugzilla-rs:`1102` - -* :file:`tif_jpeg.c`, :file:`tif_pixarlog.c`, :file:`tif_fax3.c`, :file:`tif_zip.c`: - Properly restore ``setfield``/``getfield`` methods in cleanup functions. As - per bug - :bugzilla-rs:`1102` - -* :file:`tif_lzw.c`, :file:`tif_pixarlog.c`, :file:`tif_zip.c`: Use - :c:func:`TIFFPredictorCleanup` in codec cleanup methods. As per bug - :bugzilla-rs:`1102` - -* :file:`tif_predict.c`, :file:`tif_predict.h`: Added new function - :c:func:`TIFFPredictorCleanup` to restore parent decode/encode/field methods. - -* :file:`tif_dirread.c`: Fixed integer overflow condition in - :c:func:`TIFFFetchData` function. As per bug - :bugzilla-rs:`1102` - -* :file:`tif_ojpeg.c`: Set the ``ReferenceBlackWhite`` with the - :c:func:`TIFFSetField` method, not directly. As per bug - :bugzilla-rs:`1043` - -* :file:`tif_write.c`: Small code rearrangement in :c:func:`TIFFWriteScanline` - to avoid crash as per bug - :bugzilla-rs:`1081` - -* :file:`tif_dirwrite.c`: Properly write ``TIFFTAG_DOTRANGE`` tag as per - bug :bugzilla-rs:`1088` - -* :file:`tif_print.c`: Properly read :c:macro:`TIFFTAG_PAGENUMBER`, - :c:macro:`TIFFTAG_HALFTONEHINTS`, :c:macro:`TIFFTAG_YCBCRSUBSAMPLING` - and :c:macro:`TIFFTAG_DOTRANGE` tags as per bug - :bugzilla-rs:`1088` - -* :file:`tif_tile.c`: Fix error reporting in :c:func:`TIFFCheckTile` as per - bug :bugzilla-rs:`1063` - -* :file:`tif_color.c`: Avoid overflow in case of wrong input as per - bug :bugzilla-rs:`1065` - -* :file:`tif_dirinfo.c`: Use :c:enumerator:`TIFF_NOTYPE` instead of 0 when - appropriate. As per bug - :bugzilla-rs:`1033` - -* :file:`tif_aux.c`: Fixed type of temporary variable in - :c:func:`_TIFFCheckMalloc` as per bug - :bugzilla-rs:`103` - -* :file:`tif_aux.c`: Return static array when fetching default - ``YCbCrCoefficients`` (another problem, reported a the - :bugzilla-rs:`1029` - entry). - -* :file:`tif_dir.c`: Special handling for ``PageNumber``, ``HalftoneHints``, - ``YCbCrSubsampling`` and ``DotRange`` tags as per bugs - :bugzilla-rs:`1029` - :bugzilla-rs:`1034` - -* :file:`tif_dirread.c`: Use :c:func:`_TIFFGetExifFieldInfo` instead of - :c:func:`_TIFFGetFieldInfo` in :c:func:`TIFFReadEXIFDirectory` call as per bug - :bugzilla-rs:`1026` - -* :file:`tif_dirinfo.c`: Change definitions for :c:macro:`TIFFTAG_ICCPROFILE`, - :c:macro:`TIFFTAG_PHOTOSHOP`, :c:macro:`TIFFTAG_RICHTIFFIPTC`, - :c:macro:`TIFFTAG_XMLPACKET`: readcount should be :c:type:`uint32` value. - - -Tools changes -------------- - -* :file:`ppm2tiff.c`: Added support for PBM files as per bug - :bugzilla-rs:`1044` - -* :file:`tiff2pdf.c`: Functions :c:func:`t2p_sample_rgbaa_to_rgb` and - :c:func:`t2p_sample_rgba_to_rgb` was used in place of each other, that was - resulted in problems with RGBA images with associated alpha. - As per bug - :bugzilla-rs:`1097` - -* :file:`tiff2ps.c`: Properly scale all the pages when converting - multipage TIFF with /width/height/center options set. As per bug - :bugzilla-rs:`1080` - -* :file:`tiff2pdf.c`: Do not create output file until all option checks - will be done. As per bug - :bugzilla-rs:`1072` - -* :file:`bmp2tiff.c`: Added ability to create multipage TIFFs from the - list of input files as per bug - :bugzilla-rs:`1077` - -* :file:`tiffgt.c`: Avoid crashing in case of image unsupported by - TIFFRGBAImage interface. - -* :file:`tiff2pdf.c`: Fixed support for non-YCbCr encoded JPEG - compressed TIFF files, per submission from Dan Cobra. - -* :program:`bmp2tiff`, :program:`pal2rgb`, :program:`ppm2tiff`, :program:`ras2tiff`, - :program:`raw2tiff`, :program:`sgi2tiff`, :program:`tiff2bw`, :program:`tiffcp`: - Fixed jpeg option processing so ``-c jpeg:r:50`` works - properly as per bug: - :bugzilla-rs:`1025` - -Contributed software changes ----------------------------- - -None. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.2.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.2.rst deleted file mode 100644 index ef33685e6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.8.2.rst +++ /dev/null @@ -1,76 +0,0 @@ -Changes in TIFF v3.8.2 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.8.2 (:tag:`Release-v3-8-2`) - Previous Version :doc:`v3.8.1 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - -Major changes -------------- - -* Bug-fix release. - - -Software configuration changes ------------------------------- - -* :file:`tools/Makefile.am`: Use runtime paths linker flags when rpath - option enabled. - -* Makefiles improvements as per bug :bugzilla-rs:`1128` - -* Fixed win32 I/O functions usage as per bug :bugzilla-rs:`1127` - - -Library changes ---------------- - -* :file:`tif_strip.c`: Take subsampling in account when calculating - :c:func:`TIFFScanlineSize`. - -* :file:`tif_jpeg.c`, :file:`tif_fax3.c`, :file:`tif_zip.c`, :file:`tif_pixarlog.c`, - :file:`tif_lzw.c`, :file:`tif_luv.c`: Use :c:func:`_TIFFSetDefaultCompressionState` in all - codec cleanup methods. As per bug :bugzilla-rs:`1120` - -* :file:`tif_jpeg.c`: Do not cleanup codec state in :c:func:`TIFFInitJPEG`. As - per bug :bugzilla-rs:`1119` - -* :file:`tif_dir.c`: Use :c:expr:`double` type instead of :c:type:`dblparam_t`. - -* :file:`tif_dirread.c`: Do not check the ``PlanarConfig`` tag presence - in :c:func:`TIFFReadDirectory`, because it is always set at the start of - function and we allow TIFFs without that tag set. - - -Tools changes -------------- - -* :file:`tiffcp.c`: Do not set ``RowsPerStrip`` bigger than image length. - -* :file:`fax2tiff.c`: Fixed wrong :c:func:`TIFFerror` invocations as per bug - :bugzilla-rs:`1125` - -* :file:`fax2ps.c`: Fixed reading the input stream from stdin as per bug - :bugzilla-rs:`1124` - -* :file:`raw2tiff.c`: Do not set ``RowsPerStrip`` larger than ``ImageLength``. - As per bug :bugzilla-rs:`1110` - - -Contributed software changes ----------------------------- - -None. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.0.rst deleted file mode 100644 index e256199b1..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.0.rst +++ /dev/null @@ -1,203 +0,0 @@ -Changes in TIFF v3.9.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.9.0 (:tag:`Release-v3-9-0`) - Previous Version :doc:`v3.9.0beta ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* All of the major changes since 3.8.0 were incorporated in - the v3.9.0beta release. This is a stable release from a - stable maintenance branch which incorporates many bug and - security fixes needed by existing users of 3.X.X series - libraries. Any future major changes will be in the 4.0.X - series of releases. - - -Software configuration changes ------------------------------- - -* Updated autotools: Autoconf 2.64, Automake 1.11, libtool - 2.2.6. - -* Enabled support for Automake silent build rules - (``--enable-silent-rules`` or ``make V=0``) - -* Enabled support for Automake colorized tests. - -* Added detection of a 64-bit integer type so that bundled - utilities (like :program:`tiffcrop`) can use it when necessary. Note - that this version of libtiff does not require a 64-bit integer - type but libtiff 4.0 does. - - -Library changes ---------------- - -* :file:`libtiff/Makefile.am`, :file:`libtiff/Makefile.v`: Do not distribute - :file:`tiffconf.h`, remove :file:`tif_config.h`/:file:`tiffconf.h` during cleaning. As - per bug :bugzilla-rs:`1573` - -* :file:`tif_dirinfo.c`: :c:func:`_TIFFMergeFields()` now only merges in - field definitions that are missing. Existing definitions are - silently ignored. (:bugzilla-rs:`1585`) - -* :file:`tif_write.c`: Rip out the fancy logic in - :c:func:`TIFFAppendToStrip` for establishing if an existing tile can - be rewritten to the same location by comparing the current - size to all the other blocks in the same directory. This is - dangerous in many situations and can easily corrupt a file. - (observed in esoteric GDAL situation that's hard to document). - This change involves leaving the :c:expr:`stripbytecount[]` values - unaltered till :c:func:`TIFFAppendToStrip`. Now we only write a block - back to the same location it used to be at if the new data is - the same size or smaller - otherwise we move it to the end of - file. - -* :file:`tif_dirwrite.c`: Try to avoid writing out a full - readbuffer of tile data when writing the directory just - because we have :c:macro:`TIFF_BEENWRITING` at some point in the past. This - was causing odd junk to be written out in a tile of data when - a single tile had an interleaving of reading and writing with - reading last. (highlighted by gdal - :file:`autotest/gcore/tif_write.py` test 7.) - -* :file:`tif_predict.c`: use working buffer in :c:func:`PredictorEncodeTile` - to avoid modifying callers buffer. - :gdal-trac:`1965` - -* :file:`tif_predict.c`, :file:`tif_predict.h`, :file:`tif_lzw.c`, :file:`tif_zip.c`: Improvements so - that predictor based encoding and decoding works in read-write - update mode properly. - :gdal-trac:`1948` - -* :file:`configure.com`, :file:`libtiff/tif_vms.c`: Better OpenVMS - support. Patches from Alexey Chupahin. - -* :file:`tif_fax3.c`: fix leak of ``FAXCS`` state (per bug :bugzilla-rs:`1603`). - -* :file:`tif_fax3.c`: Make :c:func:`find0span` and :c:func:`find1span` non-inline - to make MSVC 6.0 compiler happy. - -* :file:`tif_codec.c`: Avoid :c:macro:`NULL` pointer dereferencing for exotic - compression codec codes. - -* :file:`tif_dirread.c`: zero ``tif->tif_dir`` after freeing the - directory in :c:func:`TIFFReadCustomDirectory`. I don't exactly - remember why this was important. - -* :file:`tif_dirwrite.c`: Fix potential memory leak writing large - double tags. - -* :file:`tif_dirread.c`: Fix unchecked :c:func:`malloc` result. - -* :file:`libtiff/tif_lzw.c`: Properly zero out the codetable. As - per bug :bugzilla:`1929` - -* :file:`libtiff/tif_lzw.c`: Properly zero out the string - table. Fixes :cve:`2008-2327` security issue. - -* :file:`libtiff/tif_jbig.c`: Support the JBIG-KIT 2.0 - (compatibility with the older versions retained). - -* :file:`libtiff/tif_getimage.c`, :file:`tiffio.h`: removed all use of - ``UaToAa`` and ``Bitmap16to8`` arrays in :c:struct:`TIFFRGBAImage` structure to - restore ABI compatibility. These were just an attempt to - speed up processing with precalculated tables. - :bugzilla:`1979` - -* :file:`libtiff/tif_codec.c`: Avoid printing ``c->name`` if it does not exist. - -* :file:`libtiff/tif_getimage.c`, :file:`tiffio.h`: More ABI corrections. - Removed ``SubsamplingHor/Ver`` from :c:struct:`TIFFRGBAImage` structure. - :bugzilla:`1980` - -* :file:`libtiff/tif_jpeg.c`: Avoid errors if the application - writes a full strip for the last partial strip in a jpeg - compressed file. :bugzilla:`1981` - -* :file:`libtiff/tiffio.h`: GCC will now validate format - specifications for :c:func:`TIFFError`, :c:func:`TIFFErrorExt`, :c:func:`TIFFWarning`, - and :c:func:`TIFFWarningExt` in order to reveal bugs. Cleaned up - resulting warnings throughout for 32 bit build only. - -* :file:`libtiff/tiffiop.h`: Add private type declarations for - :c:type:`int64`, and :c:type:`uint64` so that bundled utilities (like :program:`tiffcrop`) - can use it when necessary. - -* :file:`libtiff/tif_predict.c`: Add support for 32bit integer - horz. predictors. - :bugzilla:`1911` - -* :file:`libtiff/tif_luv.c`: Fix handling of tiled logluv images. - :bugzilla:`2005` - -* :file:`libtiff/tif_write.c`: do not override the planar - configuration to be contig for one sample files if planar - configuration is already set. - :bugzilla:`2057` - -* :file:`libtiff/tif_lzw.c`: Fix buffer underflow bug. - :bugzilla:`2065` - -* :file:`libtiff/tif_luv.c`: correct return codes from ``encoderow`` to - be 1 on success instead of zero. - :bugzilla:`2069` - -* :file:`libtiff/tif_print.c` (:c:func:`TIFFPrintDirectory`): Applied patch - for "tag error may cause segfault in tif_print.c." - :bugzilla:`1896` - - -Tools changes -------------- - -* :file:`tools/tiff2pdf.c`: Fixed setting of alpha value per report - on list. - -* :file:`tools/tiffsplit.c`: Get rid of unsafe :c:func:`strcpy`/:c:func:`strcat` - calls when doing the filename/path construction. - -* :file:`tools/tiff2pdf.c`: More appropriate format string in - :c:func:`t2p_write_pdf_string`; avoid signed/unsigned mismatch. - -* :file:`tools/tiffsplit.c`: Use dynamically allocated array - instead of static when constructing output file names. - -* :file:`tools/tiffcrop.c`, :file:`man/tiffcrop.1`: Incorporated - significant functionality update from Richard Nolde. - -* :file:`tools/tiff2ps.c`: Incorporated significant functionality - update from Richard Nolde. In particular, support for - rotating the image by 90, 180, 270, and 'auto' has been added. - -* :file:`tools/tiff2ps.c`: Remove spurious message printed to - ``stderr``. - -* :file:`tools/tiffsplit.c`: fix ``sampleformat`` to be :c:type:`shortv` instead - of :c:type:`longv`. - -* :file:`tools/rgb2ycbcr.c`, :file:`tools/tiff2rgba.c`: Applied patch for - :cve:`2009-2347` libtiff: integer overflows in various - inter-color space conversion tools. - :bugzilla:`2079` - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.0beta.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.0beta.rst deleted file mode 100644 index 932097dc6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.0beta.rst +++ /dev/null @@ -1,225 +0,0 @@ -Changes in TIFF v3.9.0beta -========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.9.0beta (:tag:`Release-v3-9-0beta`) - Previous Version :doc:`v3.8.2 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). -If you don't find something listed here, then it was not done in this -timeframe, or it was not considered important enough to be mentioned. -The following information is located here: - -Major changes -------------- - -* New :program:`tiffcrop` utility contributed by Richard Nolde. - :program:`tiffcrop` does the same as :program:`tiffcp`, but also can crop, - extract, rotate and mirror images. - -* :file:`tif_jbig.c`: Added support for JBIG compression scheme - (34661 code), contributed by Lee Howard. - -* Totally new implementation of OJPEG module from - Joris Van Damme. No need to patch libjpeg anymore. Many OJPEG files - should be supported now that was not supported previously. - -Software configuration changes ------------------------------- - -* :file:`tif_config.wince.h`, :file:`tiffconf.wince.h`, :file:`tif_wince.c`: WinCE-specific - compatibility stuff from Mateusz Loskot. - -* Rename :file:`config.h.vc` and :file:`tif_config.h.vc` to :file:`config.vc.h` and - :file:`tif_config.vc.h` for easier identification by folks using an IDE. - -* :file:`configure`, :file:`configure.ac`: OJPEG support enabled by default (i.e., - when conformant JPEG support is enabled). - -* :file:`README.vms`, :file:`Makefile.am`, :file:`configure.com`, :file:`libtiff/Makefile.am`, - :file:`libtiff/tif_config.h-vms`, :file:`libtiff/tif_stream.cxx`, - :file:`libtiff/tif_vms.c`, :file:`libtiff/tiffconf.h-vms`: - Added support for OpenVMS by Alexey Chupahin. - -* :file:`nmake.opt`: use ``/EHsc`` for VS2005 compatibility. Also define - :c:macro:`_CRT_SECURE_NO_DEPRECATE` to avoid noise on VS2005. - - -Library changes ---------------- - -* :file:`tif_dirinfo.c` (:c:func:`_TIFFFindFieldInfo`): Don't attempt to - :c:func:`bsearch` on a :c:macro:`NULL` fieldinfo list. - (:c:func:`_TIFFFindFieldInfoByName`): Don't attempt to :c:func:`lfind` on a :c:macro:`NULL` - fieldinfo list. - -* :file:`tif_jpeg.c`: Changed :c:func:`JPEGInitializeLibJPEG` so that it - will convert from decompressor to compressor or compress to decompress - if required by the force arguments. This works around a problem in - where the :c:func:`JPEGFixupTestSubsampling` may cause a decompressor to - be setup on a directory when later a compressor is required with the - force flag set. Occurs with the :program:`addtiffo` program for instance. - -* :file:`tif_dirwrite.c`: Fixed swapping of byte arrays stored - in-place in tag offsets as per bug - :bugzilla-rs:`1363` - -* :file:`tif_getimage.c`: workaround for "Fractional scanline" error - reading OJPEG images with rowsperstrip that is not a multiple of - vertical subsampling factor. This bug is mentioned in - :bugzilla-rs:`1390` and - ``_ - -* :file:`tif_dirread.c`: Added special function to handle - ``SubjectDistance`` EXIF tag as per bug - :bugzilla-rs:`1362` - -* :file:`tif_dirread.c`, :file:`tif_read.c`: Type of the byte counters - changed from :c:type:`tsize_t` to :c:type:`uint32` to be able to work with data arrays - larger than 2GB. Fixes bug - :bugzilla-rs:`890`. - Idea submitted by Matt Hancher. - -* :file:`tif_dir.c`: Workaround for incorrect TIFFs with - ``ExtraSamples == 999`` produced by Corel Draw. As per bug - :bugzilla-rs:`1490` - -* :file:`tif_write.c`: :c:func:`TIFFAppendToStrip` - clear sorted flag if - we move a strip. - :bugzilla-rs:`1359` - -* :file:`tif_fax3.c`: Save the state of printdir codec dependent method. - -* :file:`tif_jpeg.c`: Save the state of printdir codec dependent method - as per bug - :bugzilla-rs:`1273` - -* :file:`tif_win32.c`: Fixed problem with offset value manipulation - as per bug - :bugzilla-rs:`1322` - -* :file:`tif_fax3.c`, :file:`tif_next.c`, :file:`tif_pixarlog.c`: Fixed multiple - vulnerabilities, as per Gentoo bug (): - ``_ - -* :file:`tif_lzw.c`, :file:`tif_zip.c`: Fixed problems with mixing - encoding and decoding on the same read-write TIFF handle. The LZW - code can now maintain encode and decode state at the same time. The - ZIP code will switch back and forth as needed. - :bugzilla-rs:`757` - -* :file:`tif_msdos.c`: Avoid handle leak for failed opens. - c/o Thierry Pierron - -* :file:`tif_dirwrite.c`: take care not to flush out buffer of strip/tile - data in :c:func:`_TIFFWriteDirectory` if :c:macro:`TIFF_BEENWRITING` not set. Relates - to bug report by Peng Gao with black strip at bottom of images. - -* :file:`tif_dirwrite.c`: make sure to use :c:type:`uint32` for wordcount in - :c:func:`TIFFWriteNormalTag` if ``writecount`` is :c:macro:`VARIABLE2` for ASCII fields. - It already seems to have been done for other field types. Needed - for :program:`tiffset` on files with geotiff ascii text. - -* :file:`tif_dirinfo.c`: Added missed EXIF tag ``ColorSpace`` (40961). - -* :file:`tif_dirread.c`: Move IFD fetching code in the separate - function :c:func:`TIFFFetchDirectory` avoiding code duplication in - :c:func:`TIFFReadDirectory` and :c:func:`TIFFReadCustomDirectory`. - -* :file:`tif_readdir.c`: Added case in :c:func:`EstimateStripByteCounts` for tiled - files. Modified :c:func:`TIFFReadDirectory` to not invoke - :c:func:`EstimateStripByteCounts` for case where entry 0 and 1 are unequal but - one of them is zero. - :bugzilla-rs:`1204` - -* :file:`tif_open.c`, :file:`tif_dirread.c`, :file:`tiffiop.h`: Move IFD looping - checking code in the separate function :c:func:`TIFFCheckDirOffset`. - -* :file:`tif_aux.c`: Added :c:func:`_TIFFCheckRealloc` function. - -* :file:`tif_fax3.c`: Fixed problems in fax decoder as per bug - :bugzilla-rs:`1194` - -* :file:`tif_jbig.c`: Added support for JBIG compression scheme - (34661 code) contributed by Lee Howard. As per bug - :bugzilla-rs:`896`. - -* :file:`tif_getimage.c`: Added support for planarconfig separate - non-subsampled YCbCr (i.e. separate YCbCr with subsampling ``[1,1]``). - -* :file:`tif_getimage.c`: Revision of all RGB(A) put routines: - - * Conversion of unassociated alpha to associated alpha - now done with more performant LUT, and calculation more - correct. - * Conversion of 16bit data to 8bit data now done with - more performant LUT, and calculation more correct - * Bugfix of handling of 16bit RGB with unassociated alpha - -* :file:`tif_ojpeg.c`: totally new implementation - -* :file:`tif_getimage.c`: removed :c:macro:`TIFFTAG_JPEGCOLORMODE` handling - of OJPEG images in favor of tif_getimage.c native handling of - YCbCr and desubsampling. - -* :file:`tif_jpeg.c`: :c:func:`JPEGVSetField` so that altering the photometric - interpretation causes the "upsampled" flag to be recomputed. Fixes - peculiar bug where photometric flag had to be set before jpegcolormode - flag. - -Tools changes -------------- - -* :file:`tiff2ps.c`: Added support 16-bit images as per bug - :bugzilla-rs:`1566`. - Patch from William Bader. - -* :file:`tiff2pdf.c`: Fix for :c:macro:`TIFFTAG_JPEGTABLES` tag fetching and - significant upgrade of the whole utility as per bug - :bugzilla-rs:`1560`. - Now we don't need :file:`tiffiop.h` in :program:`tiff2pdf` anymore and will open output - PDF file using :c:func:`TIFFClientOpen` machinery as it is implemented - by Leon Bottou. - -* :file:`tiffcrop.c`: New tiffcrop utility contributed - by Richard Nolde. As per bug - :bugzilla-rs:`1383` - -* :file:`tiff2pdf.c`: Do not assume inches when the resolution units - do not specified. As per bug - :bugzilla-rs:`1366` - -* :file:`tiffset.c`: Properly handle tags with :c:macro:`TIFF_VARIABLE` writecount. - As per bug - :bugzilla-rs:`1350` - -* :file:`tif2rgba.c`: This utility does not work properly on big-endian - architectures. It was fixed including the bug - :bugzilla-rs:`1149` - -* :file:`tiff2pdf.c`: Fix handling of ``-q`` values. - :bugzilla-rs:`587` - -* :file:`tiffcmp.c`: Fixed floating point comparison logic as per bug - :bugzilla-rs:`1191` - -* :file:`tiff2pdf.c`: Fixed buffer overflow condition in - :c:func:`t2p_write_pdf_string` as per bug - :bugzilla-rs:`1196` - -Contributed software changes ----------------------------- - -* :file:`contrib/addtiffo/tif_overview.c`: Fix problems with odd sized - output blocks in :c:func:`TIFF_DownSample_Subsampled` - (:bugzilla-rs:`1542`). - -* :file:`contrib/dbs/xtiff/xtiff.c`: Make xtiff utility compilable. - Though it is still far from the state of being working and useful. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.1.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.1.rst deleted file mode 100644 index 24a370920..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.1.rst +++ /dev/null @@ -1,63 +0,0 @@ -Changes in TIFF v3.9.1 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.9.1 (:tag:`Release-v3-9-1`) - Previous Version :doc:`v3.9.0 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* This is a bug-fix release for several bugs (two of which - are dire) which were discovered in the 3.9.0 release. - - -Software configuration changes ------------------------------- - -* Several defines were missing from :file:`tif_config.vc.h` which - are necessary to compile the library using MSVC. - -* Colorized tests were actually not enabled as expected. - Parallel tests mode is now also enabled so that tests can be - run in parallel, and test output is sent to :file:`.log` files. - - -Library changes ---------------- - -* :file:`libtiff/tif_write.c` (:c:func:`TIFFAppendToStrip`): Remove cast - which caused libtiff to output a wrong last strip with - byte-count and strip-offset of zero. This cast was added on - the day of the 3.9.0 release. - -* :file:`libtiff/tif_dirwrite.c`: Back out changes from 2007-11-22 - that resulted in the final strip not being written in some - circumstances. - :bugzilla:`2088` - - -Tools changes -------------- - -None - - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.2.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.2.rst deleted file mode 100644 index 961a27aec..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.2.rst +++ /dev/null @@ -1,67 +0,0 @@ -Changes in TIFF v3.9.2 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.9.2 (:tag:`Release-v3-9-2`) - Previous Version :doc:`v3.9.1 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* Fixes a number of bugs present in the 3.9.1 release. - -* OJPEG support updated to work with IJG JPEG 7 release. - -* :program:`tiffcrop` validated for most TIFF storage subformats and sample depths. - - -Software configuration changes ------------------------------- - -* x86_64 now uses the same default fill order as i386. - - -Library changes ---------------- - -* Writing tags with an array value of type :c:enumerator:`TIFF_DOUBLE` now - returns correct error status. The :c:macro:`TIFFTAG_SMINSAMPLEVALUE` and - :c:macro:`TIFFTAG_SMAXSAMPLEVALUE` tags failed to write without this fix. - -* OJPEG decoder now works with IJG JPEG 7. Resolves "Bug - 2090 - OJPEG crash with libjpeg v7". - :bugzilla:`2090` - -* Eliminate most GCC "dereferencing type-punned pointer" - warnings. - - -Tools changes -------------- - -* New :program:`tiffcrop` from Richard Nolde. Major updates to add - significant functionality for reading and writing tile based - images with bit depths not a multiple of 8 which cannot be - handled by :program:`tiffcp`. - -* Allow building tools with GCC using the ``-Wformat - -Werror=format-security`` flags. - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.3.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.3.rst deleted file mode 100644 index 071278895..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.3.rst +++ /dev/null @@ -1,105 +0,0 @@ -Changes in TIFF v3.9.3 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.9.3 (:tag:`Release-v3-9-3`) - Previous Version :doc:`v3.9.2 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* Fixes for :cve:`2010-1411`. - -* Various reported bug fixes. - - -Software configuration changes ------------------------------- - -* libtool is updated to version 2.2.10. - - -Library changes ---------------- - -* Fix a couple of issues that trigger failures in some - cases when using :c:func:`TIFFReadScanline` with JPEG compressed - subsampled ycbcr images. - :bugzilla:`1936` - -* Ensure tile and scanline sizes are reset when moving to - new directories. - :bugzilla:`1936` - -* Do not generate a ``JPEGTables`` tag when creating the JPEG - TIFF as is is not required in order to prevent it from being - unused and filled with invalid data. (Leave it to be - generated by later activity.) - :bugzilla:`2135` - -* Don't return error on badly-terminated MMR strips. - :bugzilla:`2029` - -* Have :c:macro:`TIFFTAG_REFERENCEBLACKWHITE` always print 6 floats - instead of ``2*SamplesPerPixel``. - :bugzilla:`2186` - -* Ensure that JPEG quality is always set in - :c:func:`JPEGPreEncode`, not just when we want to output local tables. - Otherwise the quality used during compression may not be right - and might not match the tables in the tables tag. This bug - only occurs when seeking between directories in the midst of - writing blocks. :gdal-trac:`3539` - -* OJPEG: Report an error and avoid a crash if the input - file is so broken that the strip offsets are not defined. - -* Eliminate FAX3 decoder buffer overrun possibility - (:cve:`2010-1411`). - -* Restore ``ReferenceBlackWhite`` as a non-custom field. This - avoids a multi-thread reentrancy problem as well as fixing - output of wrong tag value due to redundant definitions for the - same tag in the :c:expr:`tiffFieldInfo[]` array. Resolves - :bugzilla:`2185` - -Tools changes -------------- - -* :program:`tiff2pdf`: Write the JPEG SOI headers into the TIFF strip - data rather than skipping them. This fixes the ability to view in - Acrobat Reader, Evince, and Ghostscript. - :bugzilla:`2135` - -* :program:`ppm2tiff`: While case for parsing comment line - requires extra parenthesis to work as expected. Reported by - Thomas Sinclair. - -* :program:`tiffcp`: add a new option ``-x`` to force merged tiff - file ``PAGENUMBER`` value in sequence for users who care the page - sequence, this will also prevent :program:`tiff2pdf` from creating pdf file from - the merged tiff file with wrong page sequence. - -* :program:`tiffcp`: Applied Tom Lane's patch to reject YCbCr - subsampled data since :program:`tiffcp` currently doesn't support it. - :bugzilla:`2097` - - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.4.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.4.rst deleted file mode 100644 index f95bb7ece..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.4.rst +++ /dev/null @@ -1,69 +0,0 @@ -Changes in TIFF v3.9.4 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.9.4 (:tag:`Release-v3-9-4`) - Previous Version :doc:`v3.9.3 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* Complete the fixes for :cve:`2009-2347`. - -* :program:`tiffcrop` now supports custom page sizes. - - -Software configuration changes ------------------------------- - -* None. - - -Library changes ---------------- - -* Fixed inadequate validation of the ``SubjectDistance`` field. - -* Fixed bad handling of out of order tags definated late by a codec. - -* Avoid re-preparing jpeg tables unnecessarily. - - -Tools changes -------------- - -* :program:`tiffcrop`: Added an option to allow the user to specify a - custom page size on the command line. Fix the case where a - page size specified with a fractional part was being coerced - to an integer by retyping the variables that define the paper - size. Corrected European page size dimensions. - -* :program:`tiff2rgba`: Completed fixes for ":cve:`2009-2347` libtiff: - integer overflows in various inter-color space conversion - tools". :bugzilla:`2079` - -* :program:`tiff2pdf`: Fix assorted bugs in :program:`tiff2pdf`: missing ``return`` - in :c:func:`t2p_read_tiff_size` causes ``t2p->tiff_datasize`` to be set entirely - wrong for :c:macro:`COMPRESSION_JPEG` case, resulting in memory stomp if actual - size is larger. Also, there are a bunch of places that try to - :c:func:`memset` a malloc'd buffer before checking for malloc failure, which - would result in core dump if there actually were a failure. - - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.5.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.5.rst deleted file mode 100644 index 1246debba..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v3.9.5.rst +++ /dev/null @@ -1,217 +0,0 @@ -Changes in TIFF v3.9.5 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v3.9.5 (:tag:`Release-v3-9-5`) - Previous Version :doc:`v3.9.4 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* None - - -Software configuration changes ------------------------------- - -* :file:`configure.ac`: Should use ``AC_CANONICAL_HOST`` since host specifies - the run-time target whereas target is used to specify the final - output target if the package is a build tool (like a compiler), - which libtiff is not. Resolves :bugzilla:`2307` "Use - AC_CANONICAL_HOST macro". - - -Library changes ---------------- - -* :file:`libtiff/tif_getimage.c`: Check the number of samples per pixel when - working with YCbCr image in :c:func:`PickContigCase`. As per bug - :bugzilla:`2216` - -* :file:`libtiff/tif_dir.c`: Set the bogus post-decoding hook when processing - :c:macro:`TIFFTAG_BITSPERSAMPLE` in :c:func:`_TIFFVSetField` for the case of 8 bit when - we don't need any post-processing. That helps to reset the hook if we - previously set this field to some other value and the hook was - initialized accordingly. As per bug - :bugzilla:`2035` - -* :file:`libtiff/tif_getimage.c`: Avoid wrong math du to the signed/unsigned - integer type conversions. As per bug - :bugzilla:`2207` - -* :file:`libtiff/tif_dirinfo.c`: Don't use assertions in :c:func:`_TIFFFieldWithTag` - and :c:func:`_TIFFFieldWithName` if the tag is not found in the tag table. - This should be normal situation and returned :c:macro:`NULL` value should be - properly handled by the caller. - -* :file:`libtiff/{tif_dirwrite.c, tif_print.c}`: Properly handle ``DotRange`` - tag as it can be either byte or short size and should be set and read - by value, not as an array. As per bug - :bugzilla:`2116` - -* :file:`libtiff/tif_dirread.c`: Really reset the tag count in :c:func:`CheckDirCount` - to expected value as the warning message suggests. As per bug - :bugzilla:`1963` - -* :file:`libtiff/tif_open.c`: Fix mode check before opening a file. - :bugzilla:`1906` - -* :file:`libtiff/tif_jpeg.c`, :file:`libtiff/tif_strip.c`: apply patch for - :cve:`2010-3087` per bug - :bugzilla:`2140` - -* :file:`libtiff/tif_dirread.c`: fix crash when reading a badly-constructed - TIFF per :bugzilla:`1994` - -* :file:`libtiff/tif_ojpeg.c`: fix buffer overflow on problem data - :bugzilla:`1999` - -* :file:`libtiff/tif_dirread.c`: modify warnings - :bugzilla:`2016` - -* :file:`libtiff/tif_jpeg.c`: fix use of clumplines calculation - :bugzilla:`2149` - -* :file:`libtiff/tif_color.c`: prevent crash in handling bad TIFFs - resolves :cve:`2010-2595`, - :bugzilla:`2208` - -* :file:`libtiff/tif_dirread.c`: fix needless tag ordering warning - :bugzilla:`2210` - -* :file:`libtiff/tif_jpeg.c`: reduce usage of ``JCS_UNKNOWN`` in order - to improve compatibility with various viewers - submitted by e-mail from `Dwight Kelly `_ - -* :file:`libtiff/tif_strip.c`: use :c:func:`TIFFGetFieldDefaulted` instead - of :c:func:`TIFFGetField` when we assume that it will succeed - :bugzilla:`2215` - -* :file:`libtiff/tif_dirread.c`: tolerate some cases where - ``FIELD_COLORMAP`` is missing - :bugzilla:`2189` - -* :file:`libtiff/tif_jpeg.c`: Fix regressions with 2 and 3 band images - caused by commit on 2010-12-14. Submitted by e-mail from - `Even Rouault `_ - -* :file:`libtiff/tif_dirwrite.c`: Avoid undefined behaviour when casting from - :c:expr:`float` to :c:expr:`unsigned int` in :c:func:`TIFFWriteRationalArray` as reported by - Kareem Shehata. - -* :file:`libtiff/tif_fax3.h`: Protect against a fax ``VL(n)`` codeword commanding - a move left. Without this, a malicious input file can generate an - indefinitely large series of runs without ``a0`` ever reaching the right - margin, thus overrunning our buffer of run lengths. Per :cve:`2011-0192`. - This is a modified version of a patch proposed by Drew Yao of Apple - Product Security. It adds an :c:func:`unexpected` report, and disallows the - equality case, since emitting a run without increasing ``a0`` still allows - buffer overrun. - -* :file:`libtiff/tif_fax3.h`: Fix to last change allowing zero length - runs at the start of a scanline---needed for legal cases. - -* :file:`libtiff/tif_thunder.c`: Correct potential buffer overflow with - thunder encoded files with wrong bitspersample set. The libtiff - development team would like to thank Marin Barbella and TippingPoint's - Zero Day Initiative for reporting this vulnerability (ZDI-CAN-1004, - :cve:`2011-1167`). - :bugzilla:`2300` - -* :file:`libtiff/tiffiop.h`: avoid declaring :c:type:`int64`/:c:type:`uint64` on AIX with XLC - where they are already available. (:bugzilla:`2301`) - - -Tools changes -------------- - -* :file:`tools/tiffcrop.c`: Patch from Richard Nolde. Reject YCbCr - subsampled data since tiffcrop currently doesn't support it. Fix - JPEG support. - -* :file:`tools/tiffcp.c`: Initialize buffer arrays with zero to avoid - referencing to uninitialized memory in some cases (e.g. when tile size - set bigger than the image size). - -* :file:`tools/tiff2pdf.c`: Better generation of ID field in - :c:func:`t2p_write_pdf_trailer`. Get rid of GCC aliasing warnings. - -* :file:`tools/tiff2pdf.c`: Fixed computation of the tile buffer size when - converting JPEG encoded tiles. - -* :file:`tools/tiff2pdf.c`: Better handling of string fields, use static - string buffers instead of dynamically allocated, use :c:func:`strncpy` instead - of :c:func:`strcpy`, control the string lengths. - -* :file:`tools/tiff2bw.c`, :file:`tools/thumbnail.c`, :file:`tools/pal2rgb.c`: Fix the count for - ``WhitePoint`` tag as per bug - :bugzilla:`2042` - -* :file:`tools/tiffdump.c`: Use :c:func:`PrintData` function instead of - :c:func:`PrintByte`/:c:func:`PrintShort`/:c:func:`PrintLong`. Should fix an issue reported at - :bugzilla:`2116` - -* :file:`tools/tiffset.c`: Properly handle ``TIFFTAG_PAGENUMBER``, - ``TIFFTAG_HALFTONEHINTS``, ``TIFFTAG_YCBCRSUBSAMPLING``, ``TIFFTAG_DOTRANGE`` - which should be set by value. - -* :file:`tools/tiffdump.c`: Avoid integer overflows computing the buffer size - for large directories. As per bug - :bugzilla:`2218` - -* :file:`tools/tiff2pdf.c`: Fixed ID buffer filling in - :c:func:`t2p_write_pdf_trailer`, thanks to Dmitry V. Levin. - -* :file:`tools/tiffcrop.c`: Patch from Richard Nolde to avoid a - potentially unterminated buffer due to using an exceptionally long - file name. - -* :file:`tools/tiff2ps.c`: improvements and enhancements from Richard Nolde - with additional command line options for Document Title, - Document Creator, and Page Orientation - -* :file:`tools/tiffsplit.c`: abort when reading a TIFF without a byte-count - per :bugzilla:`1996` - -* :file:`tools/tiff2pdf.c`: add fill-page option - :bugzilla:`2051` - -* :file:`tools/fax2ps.c`: replace unsafe :c:func:`tmpfile` with :c:func:`mkstemp` - :bugzilla:`2118` - -* :file:`tools/tiff2pdf.c`: fix colors for images with RGBA - interleaved data - :bugzilla:`2250` - -* :file:`tools/tiffcrop.c`: new release by Richard Nolde - :bugzilla:`2004` - -* :file:`tools/fax2ps.c`: be consistent with page-numbering - :bugzilla:`2225` - -* :file:`tools/gif2tiff.c`: fix buffer overrun - :bugzilla:`2270` - -* :file:`tools/fax2ps.c` (:c:func:`main`): Use :c:func:`tmpfile` rather than :c:func:`mkstemp` since - it is much more portable. Tmpfile is included in ISO/IEC - 9899:1990 and the WIN32 CRT. - - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.0.rst deleted file mode 100644 index 21b0102ff..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.0.rst +++ /dev/null @@ -1,213 +0,0 @@ -Changes in TIFF v4.0.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.0 (:tag:`Release-v4-0-0`) - Previous Version :doc:`v3.9.5 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. Please consult -the ChangeLog file in the source package for full change details. The -following information is located here: - - -Major changes -------------- - -BigTIFF support changes: - -* The ``options`` parameter in the :c:func:`TIFFOpen` and :c:func:`TIFFClientOpen` funcs has - been extended. When creating new files, you can add option ``4`` to - specify you want to create a ClassicTIFF file, though that is the - default and the option is not strictly necessary. (As such, old - calling code will continue to function and create ClassicTIFF files.) - Or you can add option ``8`` to specify you want to create a BigTIFF file - instead. This new option is also reflected in some of the tools we - already upgraded. For instance, you can use the ``-8`` option on :program:`tiffcp` to - have :program:`tiffcp` produce BigTIFF files instead of the default ClassicTIFF. - (Whilst an additional option is provided for version selection when - creating new files, no such option is necessary when reading TIFF - files. LibTiff reads ClassicTIFF and BigTIFF both, and the application - does not need to be aware which TIFF version an opened file is.) - -* Although the tag count in BigTIFF is 64bit, we restricted the - count in the implementation to a much more reasonable size. This is - necessary in current implementation, because all tag data gets read - automatically in the IFD reading stage, so if there's half a dozen - private tags with multiple gigabytes of data that causes considerable - overhead even if the application level is never interested in these - tags. Our choice to ignore tags with data longer then a certain sanity - value is much needed as things stand. We also recommend to step away - from writing tiles that are 8 kilobyte in their uncompressed form, or - writing single-line strips, in really big files, resulting in mega's - of tiles or strips. It's much more efficient to choose bigger tile or - strip sizes, up to several megabyte if needed, and have a few kilo of - tiles or strips instead. - -* Although it's rare, some application code does directly access - file offsets. Some of these are automatically upgraded because they - used the :c:type:`toff_t` type, others need to be aware that the datatype - changed and need to start using :c:type:`toff_t` or :c:type:`uint64`. This impacts access - to tags like the ``EXIF`` IFD tag, for example, or the ``SubIfds`` tag, or to - ``StripOffsets`` or ``TileOffsets``, the return type of functions like - :c:func:`TIFFCurrentDirOffset`, and a parameter type to functions like - :c:func:`TIFFSetSubDirectory`. - -* Although it's rare, some application code does use structures - like :c:struct:`TIFFHeader` or :c:struct:`TIFFDirEntry` that used to be an exact binary - representation of TIFF structures. These need to change. The old - TIFFHeader structure is replaced by the new TIFFHeaderClassic, - TIFFHeaderBig, and TIFFHeaderCommon structures that are an exact - binary representation of the ClassicTIFF and BigTIFF header, and of - the part that is common to both. There is no new equivalent for the - old :c:struct:`TIFFDirEntry` structure (or more precisely, there is still a - :c:struct:`TIFFDirEntry` structure, but it is changed, moved to library-private - definition, and no longer an exact binary representation of the tag - structure of either TIFF version). - -* Sizer functions, like :c:func:`TIFFTileSize` or :c:func:`TIFFScanlineSize` and the - like, return a :c:func:`tmsize_t` value (:c:func:`tmsize_t` is defined as :c:type:`int32` on 32bit - machines, and :c:type:`int64` on 64bit machines, and as such it is meant to - represent signed memory sizes). This is because we figure 98% of the - calling code uses the return value as sizes in allocations and the - like. So, any overflow that is theoretically possible with BigTIFF - when LibTiff is running on a 32bit system, is best detected inside the - sizer functions and it is best to return a type that makes sense as a - memory size. If your calling code is the exception and is interested - in actual file size, you best use the newer :c:func:`TIFFTileSize64` or - :c:func:`TIFFScanlineSize64` function that returns an :c:type:`uint64` type. - -* These TIFF tags require a 64-bit type as an argument in - libtiff 4.0.0: - - * :c:macro:`TIFFTAG_FREEBYTECOUNTS` - * :c:macro:`TIFFTAG_FREEOFFSETS` - * :c:macro:`TIFFTAG_STRIPBYTECOUNTS` - * :c:macro:`TIFFTAG_STRIPOFFSETS` - * :c:macro:`TIFFTAG_TILEBYTECOUNTS` - * :c:macro:`TIFFTAG_TILEOFFSETS` - -Other important backward incompatible changes in the public API: - -* :c:func:`TIFFRewriteField` renamed into :c:func:`_TIFFRewriteField` and moved out - from the public interface (from :file:`tiffio.h` to :file:`tiffiop.h`). Type of its - ``count`` parameter changed from :c:type:`uint32` to :c:type:`tmsize_t`. - -* :c:func:`TIFFMergeFieldInfo` returns non-void result now. It returns 0 - if successful and -1 if failed. Though this is now obsoleted function - and should not be used in new programs. Use the new tag extension - scheme instead. - -* :c:func:`TIFFFieldWithTag` and :c:func:`TIFFFieldWithName` functions now return - pointer to :c:struct:`TIFFField` constant object instead of :c:struct:`TIFFFieldInfo`. - -* :c:func:`TIFFReassignTagToIgnore` function and :c:enum:`TIFFIgnoreSense` enumeration - have been removed. They was unused and never been used properly. - Should be unneeded for high-level applications. - -* :c:struct:`TIFFTagValue` structure removed from the public :file:`tiffio.h` - to private :file:`tif_dir.h` and not accessible anymore. It should be unneeded - for high-level applications. - - -Software configuration changes ------------------------------- - -Updated autotools: Autoconf 2.68, Automake 1.11.1, libtool 2.4. - -* Enabled support for Automake silent build rules - (``--enable-silent-rules`` or ``make V=0``) - -* Enabled support for Automake colorized and parallel tests. - -* Added detection of 64-bit integer types since libtiff 4.0 - requires use of 64-bit signed and unsigned integer types. - -* Libtiff now provides a more comprehensive test suite with - over 72 tests, which may be executed on Unix-like systems, or - under Microsoft Windows using MinGW/MSYS or Cygwin. - -* ``--disable-lzma`` configure option to disable use of liblzma. - -* ``--enable-defer-strile-load`` configure option to enable - experimental deferred strip/tile offset/size loading. May - cause some extremely sophisticated uses of libtiff to fail. - -* ``--enable-chunky-strip-read`` configure option to enable - experimental enable reading large strips in chunks in - :c:func:`TIFFReadScanline`. - -* Now always uses WIN32 native I/O functions for Microsoft - Windows except for under Cygwin. - -* Now provides a pkg-config support file (libtiff-4.pc). - - -Library changes ---------------- - -* Patches/fixes made to stable libtiff (v3.9.X) are also - applied to 4.0.0. There are too many to list here. See the - distribution :file:`ChangeLog` for a detailed change list. - -* There is considerable change in some files like - :c:func:`tif_dirread` and :c:func:`tif_dirwrite`. These changes don't impact - backwards compatibility, they are mostly a clean rewrite that - does allow BigTIFF support as well as somewhat more robust - reading of the unexpected already and will also serve future - API extension but does not impact current API or functionality - in a negative way that you need to know about. - -* Although there is still a functional definition for types - like :c:type:`toff_t` (file offset), :c:type:`tstrip_t` (strip index number), etc, - we recommend against using these in newer code. We have - learned that it is next to impossible to use these - consistently and make real abstraction of the binary format of - these types. Instead, at a certain level we always end up - doing casts anyway, and taking the exact binary format into - account, so these types are nothing but dangerously misleading - and obfuscating. You do not need to update calling code that - uses them, as 99.9% of such code will continue to work. But we - recommend against using them in newer calling code, and we - started replacing them with binary clear types like :c:type:`uint16`, - :c:type:`uint32` and such in the library. - -* We do use and will continue to use one functional type - that is an exception to the above rule, being :c:type:`tmsize_t`. This - is a signed memory size type, i.e. it is :c:type:`int32` on 32bit - machines, or :c:type:`int64` on 64bit machines. - -* Optionally support LZMA compression via TIFF tag 34925. - :program:`tiffcp` supports compression levels similar to ``-c lzma:p1`` or - ``-c zip:p9`` for setting the LZMA compression parameters. - -* Optionally defer the load of strip/tile offset and size - tags for optimized scanning of directories. Enabled with the - ``--enable-defer-strile-load`` configure option (:c:macro:`DEFER_STRILE_LOAD` - ``#define`` in :file:`tif_config.h`). - -* Optionally enable experimental support for reading big - strips in chunks. Enabled with the ``--enable-chunky-strip-read`` - configure option. - - -Tools changes -------------- - -* :program:`tiffset`: add ``-d`` and ``-sd`` switches to allow operation on - a particular directory, not just the first. - - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.1.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.1.rst deleted file mode 100644 index a618290a6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.1.rst +++ /dev/null @@ -1,60 +0,0 @@ -Changes in TIFF v4.0.1 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.1 (:tag:`Release-v4-0-1`) - Previous Version :doc:`v4.0.0 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* None - - -Software configuration changes ------------------------------- - -* ``--enable-ld-version-script``: New :program:`configure` option to - enable shared library symbol versioning on ELF-based systems - (e.g. Linux and FreeBSD) which use the GNU linker. This - allows multiple major versions of libtiff to be loaded - simultaneously into the same application or library without - conflict, as long as all libtiffs involved are built with - versioned symbols. This option is not enabled by default. - -* Added libtiff private dependency on ``-llzma`` for pkg-config. - - -Library changes ---------------- - -* :file:`libtiff/tif_dir.c`, :file:`libtiff/tif_dirread.c`: Extra caution around - assumption tag fetching is always successful. - -* :file:`libtiff/tif_jpeg.c`: Extra caution for case where :c:var:`sp` is :c:macro:`NULL`. - - -Tools changes -------------- - -* None - - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.10.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.10.rst deleted file mode 100644 index 8be8d02b8..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.10.rst +++ /dev/null @@ -1,239 +0,0 @@ -Changes in TIFF v4.0.10 -======================= - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.10 (:tag:`v4.0.10`) - Previous Version :doc:`v4.0.9 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* The libtiff source repository is changed from CVS to Git and the master libtiff source repository is now at - `Gitlab `_. - This is the first release to be made from the new Git repository. - - -Software configuration changes ------------------------------- - -* Minimum CMake version is now v2.8.11 for the CMake-based build. - -* Libwebp will be automatically detected and used by configure/cmake if present. - -* Libzstd will be automatically detected and used by configure/cmake if present. - - -Library changes ---------------- - -* Added ZSTD compression codec. - `Zstandard `_ or zstd as - short version, is a fast lossless compression algorithm, targeting - real-time compression scenarios at zlib-level and better - compression ratios. It's backed by a very fast entropy stage, - provided by Huff0 and FSE library. - - We require libzstd >= 1.0.0 so as to be able to use streaming - compression and decompression methods. - - The default compression level we have selected is 9 (range goes - from 1 to 22), which experimentally offers equivalent or better - compression ratio than the default deflate/ZIP level of 6, and - much faster compression. - - For example on a 6600×4400 16bit image, ``tiffcp -c zip`` runs in - 10.7 seconds, while ``tiffcp -c zstd`` runs in 5.3 - seconds. Decompression time for zip is 840 ms, and for zstd 650 - ms. File size is 42735936 for zip, and 42586822 for zstd. Similar - findings on other images. - - On a 25894×16701 16bit image: - - .. table:: Compressor Relative Performance - :widths: auto - - =========== ================ ================== =========== - Compressor Compression time Decompression time File size - =========== ================ ================== =========== - ZSTD 35 s 3.2 s 399,700,498 - ZIP/Deflate 1m 20 s 4.9 s 419,622,336 - =========== ================ ================== =========== - - Please note that ``COMPRESSION_ZSTD`` is self-assigned the id 50000 - by the libtiff project and is not officially registered with Adobe - since Adobe's registration function is defunct. - -* Added WebP compression codec. - - `WebP `_ is - a high performance compressor intended for photos as commonly used - on the Web. The WebP encoder is not designed for huge images, but - serves very well for compressing strips and tiles in TIFF as long - as the strips or tiles do not exceed the capability of the - encoder. - - As a test of compression performance metrics, GraphicsMagick - was used on an extremely high quality 8-bit TIFF image from a - Hasselblad H4D-200MS camera with pixel dimensions of - 16352×12264. The image was re-encoded with 1024×1024 tiles and - various compression algorithms, using default settings for each - algorithm. Based on this test, the compression and decompression - performance (in iterations per second), the resulting file size, - and the calculated total PSNR are provided here. It can be seen - that WebP provided excellent encode and decode performance, and - the compressed file size was very small: - - - .. table:: Compressor Relative Performance - :widths: auto - - ========== ============ ============= ========= ===== - Compressor Compression Decompression File size PSNR - ========== ============ ============= ========= ===== - None 0.536 iter/s 1.506 iter/s 576.03MiB ∞ - LZW 0.105 iter/s 0.266 iter/s 270.68MiB ∞ - ZStd 0.020 iter/s 0.518 iter/s 238.42MiB ∞ - LZMA 0.009 iter/s 0.056 iter/s 247.61MiB ∞ - ZIP 0.009 iter/s 0.301 iter/s 247.88MiB ∞ - JPEG 0.446 iter/s 0.760 iter/s 18.59MiB 39.00 - WebP 0.019 iter/s 0.330 iter/s 9.38MiB 37.78 - ========== ============ ============= ========= ===== - - Please note that ``COMPRESSION_WEBP`` is self-assigned the id 50001 - by the libtiff project and is not officially registered with Adobe - since Adobe's registration function is defunct. - -* :c:func:`TIFFPrintDirectory`: fix null pointer dereference on corrupted - file. Fixes :bugzilla:`Bug 2770 - NULL Pointer Dereference in tiffinfo.c with crafted TIFF - image <2770>`. - -* :c:func:`_TIFFVGetField`: fix heap out-of-bounds access when requesting - ``TIFFTAG_NUMBEROFINKS`` on a EXIF - directory. Fixes :bugzilla:`Bug 2765 - Heap Out-Of-Bounds Memory Access - 68122422 - <2765>`. - Reported by Google Autofuzz project. - -* Fix a memory leak in :c:func:`TIFFStreamOpen`. :c:func:`TIFFStreamOpen` allocates a - new ``tiff{o,i}s_data``, but if :c:func:`TIFFClientOpen` fails then that struct is - leaked. - -* Fix for bug 2772. It is possible to craft a TIFF document where - the IFD list is circular, leading to an infinite loop while - traversing the chain. The libtiff directory reader has a failsafe - that will break out of this loop after reading 65535 directory - entries, but it will continue processing, consuming time and - resources to process what is essentially a bogus TIFFdocument. - - This change fixes the above behavior by breaking out of processing - when a TIFF document has >= 65535 directories and terminating with an - error. - -* :c:func:`ChopUpSingleUncompressedStrip`: avoid memory exhaustion - (:cve:`2017-11613`). In :c:func:`ChopUpSingleUncompressedStrip`, if the - computed number of strips is big enough and we are in read only - mode, validate that the file size is consistent with that number of - strips to avoid useless attempts at allocating a lot of memory for - the :c:member:`td_stripbytecount` and :c:member:`td_stripoffset` - arrays. Fixes :bugzilla:`Bug 2724 - memory exhaustion in ChopUpSingleUncompressedStrip - <2724>`. - -* Port code: Add :c:func:`strtol`, :c:func:`strtoll` and :c:func:`strtoull`. Also update - :c:func:`strtoul`. All use the same implementation from NetBSD libc. - -* Fix for :cve:`2018-7456` "NULL pointer dereference in - :c:func:`TIFFPrintDirectory`". - -* :c:func:`TIFFWriteDirectorySec`: avoid - assertion. Fixes :bugzilla:`Bug 2795 - There is a reachable assertion abort in function - TIFFWriteDirectorySec() of libtiff 4.0.9. A crafted input will lead - to remote denial of attack. (:cve:`2018-10963`) - <2795>`. - -* :c:func:`LZWDecodeCompat`: fix potential index-out-of-bounds - write. Fixes :bugzilla:`Bug - 2780 - A heap-buffer-overflow in function LZWDecodeCompat in - libtiff4.0.9 (:cve:`2018-8905`) - <2780>`. - The fix consists in using the - similar code as :c:func:`LZWDecode` to validate we don't write outside of - the output buffer. - -* Remove builtin support for GUI warning and error message - boxes. Now warnings always go to the console by default unless - applications define their own warning and error handlers. - - GUI applications (and Windows CE) are required to define such handlers. - -* Add tag and pseudo-tag definitions for ESRI LERC codec (out of - tree codec whose source is - at ``_. - -* Fix libtiff 4.0.8 regression when reading LZW-compressed strips with scanline API - Fixes :bugzilla:`Bug 2800 - Regression: Opening a tiff file with v4.0.9 gives an error with LZWDecode - <2800>`. - -* :c:func:`TIFFSetupStrips`: avoid potential :c:type:`uint32` overflow on 32-bit - systems with large number of strips. Probably relates - to :bugzilla:`Bug - 2788 - Heap Buffer Overflow in TIFFWriteScanline of tif_write.c - (:cve:`2018-10779`) - <2788>`. - -* Fix out-of-bound read on some tiled images. - -* Avoid potential :c:type:`int32` overflows in :c:func:`multiply_ms`. - -* Only read/write ``TIFFTAG_GROUP3OPTIONS`` or ``TIFFTAG_GROUP4OPTIONS`` - if compression is ``COMPRESSION_CCITTFAX3`` or - ``COMPRESSION_CCITTFAX4``. - -* JBIG: fix potential out-of-bounds write in :c:func:`JBIGDecode`. Also - fix a (harmless) potential use of uninitialized memory when - ``tif->tif_rawsize > tif->tif_rawcc``. In case libtiff is compiled with - ``CHUNKY_STRIP_READ_SUPPORT``, make sure that whole strip data is - provided to :c:func:`JBIGDecode`. - -* :c:func:`LZMAPreEncode`: emit verbose error if :c:func:`lzma_stream_encoder` fails - (typically because not enough memory available) - - -Tools changes -------------- - -* :program:`tiff2pdf`: Fix - :cve:`2017-9935`, :bugzilla:`Bug - 2704 - There is a heap based buffer overflow in the tiff2pdf tool of - the libtiff library. A crafted TIFF document can lead to a heap - based buffer overflow resulting in multiple damages. - <2704>`. - -* :program:`pal2rgb`: Add workaround to pal2rgb buffer overflow. - -* :program:`tiffset`: Add support for :c:macro:`LONG8`, :c:macro:`SLONG8` and :c:macro:`IFD8` field types - -* :program:`tiff2bw`: avoid null pointer dereference in case of out of memory - situation. Fixes :bugzilla:`Bug - 2819 - There is a NULL pointer dereference at function LZWDecode in - libtiff 4.0.9 (:cve:`2018-18661`) - <2819>`. - - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.2.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.2.rst deleted file mode 100644 index 394f0523f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.2.rst +++ /dev/null @@ -1,64 +0,0 @@ -Changes in TIFF v4.0.2 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.2 (:tag:`Release-v4-0-2`) - Previous Version :doc:`v4.0.1 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here - - -Major changes -------------- - -* None - - -Software configuration changes ------------------------------- - -* None - - -Library changes ---------------- - -* :file:`tif_getimage.c`: added support for _SEPARATED CMYK images. - -* :file:`tif_getimage.c`: Added support for greyscale + alpha. - -* Added :c:func:`TIFFCreateCustomDirectory` and :file:`TIFFCreateEXIFDirectory` functions. - -* :file:`tif_print.c`: Lots of fixes around printing corrupt or hostile input. - -* Improve handling of corrupt ycbcrsubsampling values. - -* :file:`tif_unix.c`: use :c:func:`strerror` to get meaningful error messages. - -* :file:`tif_jpeg.c`: fix serious bugs in :c:func:`JPEGDecodeRaw`. - -* :file:`tif_jpeg.c`: Fix size overflow (zdi-can-1221, :cve:`2012-1173`). - - -Tools changes -------------- - -* :program:`tiff2pdf`: Defend against integer overflows while - calculating required buffer sizes (:cve:`2012-2113`). - - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.3.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.3.rst deleted file mode 100644 index 868967e7c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.3.rst +++ /dev/null @@ -1,68 +0,0 @@ -Changes in TIFF v4.0.3 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.3 (:tag:`Release-v4-0-3`) - Previous Version :doc:`v4.0.2 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* None - - -Software configuration changes ------------------------------- - -* Updated to use Automake 1.12.4. Avoids security problem with - ``make distcheck`` (:cve:`2012-3386`). - - -Library changes ---------------- - -* Various memory buffer access fixes. - -* Fix handling when writing RGBA jpeg compressed imagery (:gdal-trac:`4732`). - -* Fix to work properly with IJG JPEG 7+. - -* New functions :c:func:`TIFFFieldTag`, :c:func:`TIFFFieldName`, - :c:func:`TIFFFieldDataType`, :c:func:`TIFFFieldPassCount`, :c:func:`TIFFFieldReadCount`, - :c:func:`TIFFFieldWriteCount` to use as external accessors for the opaque - type :c:type:`TIFFField`. - -* Fix bug rewriting image tiles in a compressed file (:gdal-trac:`4771`). - -* Add TIFF/FX tag support in libtiff. - - -Tools changes -------------- - -* :program:`tiff2pdf`: Fail when :c:func:`TIFFSetDirectory` fails. This prevents - core dumps or perhaps even arbitrary code execution when processing - a corrupt input file (:cve:`2012-3401`). - -* :program:`tiff2pdf`: Fix two places where :c:member:`t2p_error` didn't get set after a - :c:func:`malloc` failure. No crash risk AFAICS, but the program might not - report exit code 1 as desired. - - -Contributed software changes ----------------------------- - -* None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.4.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.4.rst deleted file mode 100644 index b211b76b2..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.4.rst +++ /dev/null @@ -1,191 +0,0 @@ -Changes in TIFF v4.0.4 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.4 (:tag:`Release-v4-0-4`) - Previous Version :doc:`v4.0.4beta ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* None - - -Software configuration changes ------------------------------- - -* :bugzilla:`2405`: Correct shell equality operator. -* :bugzilla:`2498`: Adds an option to select the file I/O style on Windows hosts. - - -Library changes ---------------- - -* :c:func:`TIFFNumberOfDirectories`: Coverity 1134470 "Logically dead code" - -* :file:`tif_dirread.c`: - - * :c:func:`TIFFReadDirEntryDoubleArray`: Coverity 298626 "Logically dead code". - * :c:func:`TIFFReadDirEntryFloatArray`: Coverity 298627 "Logically dead code". - * :c:func:`TIFFReadDirEntryIfd8Array`: Coverity 298628 "Logically dead code". - * :c:func:`TIFFReadDirEntrySlong8Array`: Coverity 298629 "Logically dead code" - -* :file:`tif_dirwrite.c` - - * :c:func:`_TIFFRewriteField`: Coverity 1024310 "Resource leak". - -* :file:`tif_jpeg.c` - - * :c:func:`JPEGCleanup`: Coverity 298624 "Dereference before null check". - * :c:func:`JPEGDecode`: Coverity 602597 "Operands don't affect result". - -* :file:`tif_getimage.c` - - * :bugzilla:`2409`: Correct reading of certain tiled TIFFs. - -* :file:`tif_luv.c` - - * :c:func:`LogLuvDecodeStrip`: Coverity 991239 "Division or modulo by zero". - * :c:func:`LogLuvDecodeTile`: Coverity 991227 "Division or modulo by zero". - * :c:func:`LogLuvEncodeStrip`: Coverity 991240 "Division or modulo by zero". - * :c:func:`LogLuvEncodeTile`: Coverity 991241 "Division or modulo by zero". - -* :file:`tif_lzw.c` - - * Decode files that contain consecutive :c:macro:`CODE_CLEAR` codes. - -* :file:`tif_ojpeg.c` - - * :c:func:`OJPEGReadBufferFill`: Coverity 603400 "Missing break in switch". - * :c:func:`OJPEGReadHeaderInfoSecStreamDht`: Coverity 601720 "Resource leak". - -* :file:`tif_read.c` - - * :c:func:`TIFFStartTile`: Coverity 715973 and 715974 "Division or modulo by zero". - -* :file:`tif_unix.c` - - * :bugzilla:`2510`: Fix several harmless but still annoying warnings. - -* :file:`tif_write` - - * :c:func:`TIFFWriteEncodedStrip`: Coverity 715975 "Division or modulo by zero". - * :c:func:`TIFFWriteEncodedTile`: Coverity 715976 and 715977 "Division or modulo by zero". - * :c:func:`TIFFWriteRawStrip`: Coverity 715978 "Division or modulo by zero". - * :c:func:`TIFFWriteScanline`: Coverity 715979 "Division or modulo by zero". - - -Tools changes -------------- - -* :program:`bmp2tiff` - - * Coverity 1024225 "Untrusted value as argument". - * Coverity 1024678 "Unchecked return value from library". - * Coverity 1024679 "Unchecked return value from library". - * Coverity 1214160 "Ignoring number of bytes read". - -* :program:`gif2tiff` - - * Coverity 1024222 "Untrusted value as argument". - * Coverity 1024890 "Ignoring number of bytes read". - * Coverity 1024891 "Ignoring number of bytes read". - * Coverity 1024892 "Ignoring number of bytes read". - * Coverity 1024893 "Ignoring number of bytes read". - * Coverity 1024894 "Ignoring number of bytes read". - -* :program:`ras2tiff` - - * Corrected Sun Raster header definition to be safe for - 64-bit systems. Add some header validations. Fixes many - (unspecified) Coverity issues. - * Coverity 1024223 "Untrusted value as argument". - * Coverity 1301206: "Integer handling issues (BAD_SHIFT)". - -* :program:`raw2tiff` - - * Coverity 1024887 "Unchecked return value from library". - * Coverity 1024888 "Unchecked return value from library". - * Coverity 1024889 "Unchecked return value from library". - * Coverity 1214162 "Ignoring number of bytes read". - - -* :program:`tiff2pdf` - - * :bugzilla:`2078`: Suppress initial output of the header. - * :bugzilla:`2150`: Change ColorTransform from "0" to "1". - * Take care in using the return value from :c:func:`snprintf`. - * Coverity 1024181 "Structurally dead code". - * Coverity 1024181 "Structurally dead code". - * Coverity 1227690 "Unused value". - * Coverity 298621 "Resource leak". - -* :program:`tiff2ps` - - * Correct sizing and scaling problems with output document. - -* :program:`tiffcp` - - * Coverity 1024306, 1024307, 1024308, 1024309 "Resource leak". - -* :program:`tiffcrop` - - * Correctly copy the compression tag from the source TIFF. - * Coverity 1024545 "Division or modulo by zero". - * Coverity 1024586 "Logically dead code". - * Coverity 1024796 "Nesting level does not match indentation". - * Coverity 1024797 "Nesting level does not match indentation". - * Coverity 1294542 "Logical vs. bitwise operator". - * Coverity 1299740 "Out-of-bounds write". - * Coverity 1299741 "Dereference before null check". - -* :program:`tiffdither` - - * Check memory allocations for failure. Also check - multiplication overflow. (Fixes #2501, :cve:`2014-8128`) - -* :program:`tiffgt.c` - - * :bugzilla:`2401`: Appropriately call :c:func:`glFlush`. - -* :program:`tiffmedian` - - * Coverity 1024386 "Out-of-bounds read". - * Coverity 1024386 "Out-of-bounds read". - * Coverity 1024795 "Nesting level does not match indentation". - * Coverity 1024795 "Nesting level does not match indentation". - -:program:`tiffsplit` - - * Coverity 1024304 "Resource leak". - * Coverity 1024305 "Resource leak". - - -Contributed software changes ----------------------------- - -* :program:`addtiffo` - - * Check buffer size calculation for overflow. - * Coverity 298615 "Resource leak". - * Coverity 1024649 "Unintended sign extension". - -* :program:`iptcutil` - - * Coverity 1024468 "Infinite loop". - * Coverity 1024727 "Truncated stdio return value". - * Coverity 1214240 "Untrusted loop bound". diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.4beta.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.4beta.rst deleted file mode 100644 index f281d6364..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.4beta.rst +++ /dev/null @@ -1,236 +0,0 @@ -Changes in TIFF v4.0.4beta -========================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.4beta (:tag:`Release-v4-0-4beta`) - Previous Version :doc:`v4.0.3 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- -* None - - -Software configuration changes ------------------------------- - -* Updated to use Automake 1.15 and Libtool 2.4.5 - - -Library changes ---------------- - -* :c:func:`TIFFCheckDirOffset`: avoid :c:type:`uint16` overflow - when reading more than 65535 directories, and effectively error out when - reaching that limit. - -* :c:func:`TIFFNumberOfDirectories`: generate error in case of directory count - overflow. - -* :c:func:`TIFFAdvanceDirectory`: If nextdir is found to - be defective, then set it to zero before returning error in order - to terminate processing of truncated TIFF. - -* JPEG-in-TIFF: recognize ``SOF2``, ``SOF9`` and ``SOF10`` - markers to avoid emitting a warning. Fix for compatibility with mozjpeg library. - Note: the default settings of mozjpeg will produce progressive scans, which - is forbidden by the TechNote. - -* JPEG-in-TIFF: Fix regression introduced in 3.9.3/4.0.0 that caused - all tiles/strips to include quantization tables even when the jpegtablesmode - had the :c:macro:`JPEGTABLESMODE_QUANT` bit set. - Also add explicit removal of Huffman tables when jpegtablesmode has the - :c:macro:`JPEGTABLESMODE_HUFF` bit set, which avoids Huffman tables to be emitted in the - first tile/strip (only useful in update scenarios. create-only was - fine) - -* JPEG-in-TIFF: fix segfault in :c:func:`JPEGFixupTagsSubsampling` on - corrupted image where ``tif->tif_dir.td_stripoffset == NULL``. - (:bugzilla:`2471`) - -* NeXT codec: add new tests to check that we don't read outside of - the compressed input stream buffer. - -* NeXT codec: check that ``BitsPerSample`` = 2. Fixes - :bugzilla:`2487` (:cve:`2014-8129`) - -* NeXT codec: in the "run mode", use tilewidth for tiled images - instead of imagewidth to avoid crash - -* tif_getimage.c: in OJPEG case, fix checks on strile width/height - in the ``putcontig8bitYCbCr42tile``, ``putcontig8bitYCbCr41tile`` and - ``putcontig8bitYCbCr21tile`` cases. - -* in :c:func:`TIFFDefaultDirectory`, reset any already existing - extended tags installed by user code through the extender mechaninm before - calling the extender callback (GDAL #5054) - -* Fix warnings about unused parameters. - -* Fix various typos in comments found by Debian lintian tool (GDAL #5756) - -* tif_getimage.c: avoid divide by zero on invalid YCbCr subsampling. - (:bugzilla:`2235`) - -* :file:`tif_dirread.c`: In :c:func:`EstimateStripByteCounts`, check return code - of :c:func:`_TIFFFillStriles`. This solves crashing bug on corrupted - images generated by afl. - -* :file:`tif_read.c`: fix several invalid comparisons of a :c:type:`uint64` value with - ``<= 0`` by casting it to :c:type:`int64` first. This solves crashing bug on corrupted - images generated by afl. - -* :c:func:`TIFFSetField`: refuse to set negative values for - :c:macro:`TIFFTAG_XRESOLUTION` and :c:macro:`TIFFTAG_YRESOLUTION` that cause asserts when writing - the directory - -* :c:func:`TIFFReadDirectory`: refuse to read ``ColorMap`` or - ``TransferFunction`` if ``BitsPerSample`` has not yet been read, otherwise reading - it later will cause user code to crash if ``BitsPerSample > 1`` - -* :c:func:`TIFFRGBAImageOK`: return FALSE if LOGLUV with - ``SamplesPerPixel != 3``, or if CIELAB with - ``SamplesPerPixel != 3`` or ``BitsPerSample != 8`` - -* :file:`tif_config.vc.h`: no longer use ``#define snprintf _snprintf`` with - Visual Studio 2015 aka VC 14 aka MSVC 1900 - -* LZW codec: prevent potential null dereference of ``sp->dec_codetab`` in :c:func:`LZWPreDecode` - (:bugzilla:`2459`) - -* :c:func:`TIFFReadBufferSetup`: avoid passing -1 size - to :c:func:`TIFFmalloc` if passed user buffer size is 0 - (:bugzilla:`2459`) - -* :c:func:`TIFFReadDirEntryOutputErr`: Incorrect - count for tag should be a warning rather than an error since - errors terminate processing. - -* :file:`tif_dirinfo.c` (``TIFFField``) : Fix data type for :c:macro:`TIFFTAG_GLOBALPARAMETERSIFD` tag. - -* Add definitions for TIFF/EP ``CFARepeatPatternDim`` and ``CFAPattern`` tags - (:bugzilla:`2457`) - -* :file:`tif_codec.c`, :file:`tif_dirinfo.c`: Enlarge some fixed-size buffers that weren't - large enough, and eliminate substantially all uses of ``sprintf(buf, - ...)`` in favor of using ``snprintf(buf, sizeof(buf), ...)`` - -* :file:`configure.ac`: Improve pkg-config static linking by adding ``-lm`` to ``Libs.private`` when needed. - -* :file:`tif_write.c`: :c:type:`tmsize_t` related casting warning fixed for - 64bit linux. - -* :file:`tif_read.c`: :c:type:`uint64`/:c:type:`tmsize_t` change for MSVC warnings. - (:bugzilla:`2427`) - -* Fix :c:func:`TIFFPrintDirectory` handling of - :c:member:`field_passcount` fields: it had the :c:macro:`TIFF_VARIABLE` and - :c:macro:`TIFF_VARIABLE2` cases backwards. - -* PixarLog codec: Improve previous patch for :cve:`2012-4447` - (to enlarge :c:member:`tbuf` for possible partial stride at end) so that - overflow in the integer addition is detected. - -* :file:`tif_{unix,vms,win32}.c` (:c:func:`_TIFFmalloc`): ANSI C does not - require :c:func:`malloc` to return :c:macro:`NULL` pointer if requested allocation - size is zero. Assure that :c:func:`_TIFFmalloc` does. - -* :file:`tif_zip.c`: Avoid crash on :c:macro:`NULL` error messages. - - -Tools changes -------------- -* :program:`tiff2pdf` Fix various crashes and memory buffer access errors (oCERT-2014-013). -* :program:`tiff2pdf` fix buffer overflow on some YCbCr JPEG compressed images. - (:bugzilla:`2445`) -* :program:`tiff2pdf` fix buffer overflow on YCbCr JPEG compressed image. - (:bugzilla:`2443`) -* :program:`tiff2pdf` check return code of :c:func:`TIFFGetField` when reading :c:macro:`TIFFTAG_SAMPLESPERPIXEL` -* :program:`tiff2pdf` fix crash due to invalid tile count. -* :program:`tiff2pdf` Detect invalid settings of ``BitsPerSample``/``SamplesPerPixel`` for CIELAB / ITULAB -* :program:`tiff2pdf` Assure that memory size calculations for - :c:func:`_TIFFmalloc` do not overflow the range of :c:type:`tmsize_t`. -* :program:`tiff2pdf` Avoid crash when :c:macro:`TIFFTAG_TRANSFERFUNCTION` tag returns one channel, - with the other two channels set to :c:macro:`NULL`. -* :program:`tiff2pdf` close PDF file. (:bugzilla:`2479`) -* :program:`tiff2pdf` Preserve input file directory order when pages - are tagged with the same page number. -* :program:`tiff2pdf.c` terminate after failure of allocating ycbcr buffer - (:bugzilla:`2449`, :cve:`2013-4232`) -* :program:`tiff2pdf` Rewrite JPEG marker parsing in - :c:func:`t2p_process_jpeg_strip` to be at least marginally competent. The - approach is still fundamentally flawed, but at least now it won't - stomp all over memory when given bogus input. Fixes :cve:`2013-1960`. -* :program:`tiffdump` Guard against arithmetic overflow when calculating allocation buffer sizes. -* :program:`tiffdump` fix crash due to overflow of entry count. -* :program:`tiffdump` Fix double-free bug. -* :program:`tiffdump` detect cycle in TIFF directory chaining. - (:bugzilla:`2463`) -* :program:`tiffdump` avoid passing a :c:macro:`NULL` pointer to :c:func:`read` if :c:func:`seek` failed before. - (:bugzilla:`2459`) -* :program:`tiff2bw` when ``Photometric = RGB``, the utility only works if ``SamplesPerPixel = 3``. Enforce that. - (:bugzilla:2485`, :cve:`2014-8127`) -* :program:`pal2rgb`, :program:`thumbnail`: fix crash by disabling :c:macro:`TIFFTAG_INKNAMES` copying. - (:bugzilla:`#2484`, :cve:`2014-8127`) -* :program:`thumbnail` fix out-of-buffer write. - (:bugzilla:`2489`, :cve:`2014-8128`) -* :program:`thumbnail`, :program:`tiffcmp`: only read/write :c:macro:`TIFFTAG_GROUP3OPTIONS` - or :c:macro:`TIFFTAG_GROUP4OPTIONS` if compression is :c:macro:`COMPRESSION_CCITTFAX3` or - :c:macro:`COMPRESSION_CCITTFAX4`. - (:bugzilla:`2493`, :cve:`2014-8128`) -* :program:`tiffcp` fix crash when converting YCbCr JPEG-compressed to none. - (:bugzilla:`2480`) -* :program:`bmp2tiff` fix crash due to int overflow related to input BMP dimensions -* :program:`tiffcrop` fix crash due to invalid ``TileWidth``/``TileHeight`` -* :program:`tiffcrop` fix segfault if bad value passed to ``-Z`` option - (:bugzilla:`2459`) and add missing ``va_end`` in :c:func:`dump_info` -* :program:`thumbnail`, :program:`tiffcrop`: "fix" heap read over-run found with - Valgrind and Address Sanitizer on test suite -* :program:`fax2ps` check :c:func:`malloc`/:c:func:`realloc` result. (:bugzilla:`2470`) -* :program:`gif2tiff` apply patch for :cve:`2013-4243`. (:bugzilla:`2451`) -* :program:`gif2tiff` fix possible OOB write. (:bugzilla:`2452`, :cve:`2013-4244`) -* :program:`gif2tiff` Be more careful about corrupt or hostile input files (:bugzilla:`2450`, :cve:`2013-4231`) -* :program:`tiff2rgba` fix usage message in that zip was wrongly described -* :program:`tiffinfo` Default various values fetched with :c:func:`TIFFGetField` to avoid being uninitialized. -* :program:`tiff2ps` Fix bug in auto rotate option code. -* :program:`ppm2tiff` avoid zero size buffer vulnerability (:cve:`2012-4564`). - check the linebytes calculation too, get the :c:func:`max` calculation - straight, avoid redundant error messages, check for :c:func:`malloc` - failure. -* :program:`tiffset` now supports a ``-u`` option to unset a tag. - (:bugzilla:`2419`) -* Fix warnings about unused parameters. -* :program:`rgb2ycbcr`, :program:`tiff2bw`, :program:`tiff2pdf`, :program:`tiff2ps`, :program:`tiffcrop`, :program:`tiffdither`: - Enlarge some fixed-size buffers that weren't - large enough, and eliminate substantially all uses of ``sprintf(buf, - ...)`` in favor of using ``snprintf(buf, sizeof(buf), ...)``, so as to - protect against overflow of fixed-size buffers. This responds in - particular to :cve:`2013-1961` concerning overflow in :file:`tiff2pdf.c`'s - :c:func:`t2p_write_pdf_page`. -* :file:`html/man/tiff2ps.1.html`, :file:`html/man/tiffcp.1.html`, - :file:`html/man/tiffdither.1.html`, :file:`man/tiff2ps.1`, :file:`man/tiffcp.1`, - :file:`man/tiffdither.1`, :file:`tools/tiff2ps.c`, :file:`tools/tiffcp.c`, - :file:`tools/tiffdither.c`: Sync tool usage printouts and man pages with - reality - - -Contributed software changes ----------------------------- - -* Fix warnings about variables set but not used. -* :file:`contrib/dbs/xtiff/xtiff.c`: Enlarge some fixed-size buffers that weren't - large enough, and eliminate substantially all uses of ``sprintf(buf, - ...)`` in favor of using ``snprintf(buf, sizeof(buf), ...)``, so as to - protect against overflow of fixed-size buffers. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.5.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.5.rst deleted file mode 100644 index 56cd7f55b..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.5.rst +++ /dev/null @@ -1,85 +0,0 @@ -Changes in TIFF v4.0.5 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.5 (:tag:`Release-v4-0-5`) - Previous Version :doc:`v4.0.4 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* Support for configure/build using CMake. -* Support for large (> 2GB) files under Microsoft Windows. - - -Software configuration changes ------------------------------- - -* :file:`CMakeLists.txt` / CMake - - * Configuration and building using CMake is now supported - under Microsoft Windows and on Unix-type systems. - -* :file:`configure.ac` / :program:`configure` - - * Test for and use :c:func:`fseeko` if it is available. This allows - supporting large files on Unix-type systems with a 32-bit :c:expr:`long` - type and a 64-bit :c:type:`off_t` type. - - -Library changes ---------------- - -* :file:`tiffiop.h`: - - * Macros added to use 64-bit equivalents for all standard I/O - and POSIX APIs used by libtiff and its tools which are limited - to 2GB in Windows builds. Note that these 64-bit equivalents - were introduced by the CRT provided with Visual Studio 2005 and - if the necessary CRT is not installed on the target computer, - the program will not run. The wrapper macros will not be - activated unless the definition :c:macro:`_MSC_VER` is at least 1400 or - :c:macro:``__MSVCRT_VERSION__`` is at least ``0x800``. - -* :file:`tif_unix.c`: - - * Updated to support large files under Microsoft Windows. - This makes :file:`tif_unix.c` a completely viable candidate for use - under Windows (in spite of its name) if the CRT is modern - enough. Please note that :file:`tif_win32.c` already supported large - files, but only :program:`tiffinfo` and :program:`tiffdump` made any provision to - support large files under Windows. - * :c:func:`_tiffReadProc` and :c:func:`_tiffWriteProc` are modified to chunk - I/O to a maximum size of 2GB for extremely large I/O - requests. This surmounts limitations in the Microsoft Windows - :c:func:`read` and :c:func:`write` APIs (which are limited to the range of a - 32-bit :c:expr:`int`), and may avoid poor behavior with extremely large - I/O requests on other systems. - - -Tools changes -------------- - -* All tools - - * Updated to use I/O wrapper macros from :file:`tiffiop.h` in order - to support large files under Microsoft Windows. - - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.6.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.6.rst deleted file mode 100644 index 526169661..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.6.rst +++ /dev/null @@ -1,77 +0,0 @@ -Changes in TIFF v4.0.6 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.6 (:tag:`Release-v4-0-6`) - Previous Version :doc:`v4.0.5 ` - Master Download Site ``_ - Master HTTP Site ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* Now builds with CMake 2.8.9 and newer (previously required 3.0.0) - - -Software configuration changes ------------------------------- - -* :file:`CMakeLists.txt` / CMake - - * Supports CMake 2.8.9 and later. - * Add missing file which wasn't being distributed, causing - unit tests to fail. - * Make shared/static library building configurable. - * CMake reads all version information directly from - :file:`configure.ac` to avoid duplication of values. - * CMake builds are now included in ``distcheck`` target. - -* :file:`Makefile.am` - - * Autotools `make distcheck` now tests the CMake-based build - if CMake is available. - - -Library changes ---------------- - -* Fixes to avoid undefined behaviour of signed types (C - standard compliance). -* Fixes to avoid possible isses when casting to unsigned char. -* Fixes to avoid undefined behaviour with shifts. -* Fix generation of output with 16 bit or 32 bit integer, when - byte swapping is needed, in horizontal predictor (:bugzilla:`2521`). -* Fix decoding when there is a single pixel to decode (unlikely - case...) and byte swapping is involved. -* Add add explicit masking with ``0xff`` before casting to :c:type:`uchar` in - floating-point horizontal differencing and accumulation routines. -* Eliminate requirement for and use of 64-bit constant values. - - -Tools changes -------------- - -* :program:`tiffgt` - - * Silence glut API deprecation warnings on MacOS X. - -* :program:`fax2ps` - - * Detect failure to write to temporary file. - - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.7.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.7.rst deleted file mode 100644 index d7dccaf35..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.7.rst +++ /dev/null @@ -1,350 +0,0 @@ -Changes in TIFF v4.0.7 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.7 (:tag:`Release-v4-0-7`) - Previous Version :doc:`v4.0.6 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - -Major changes -------------- - -* The libtiff tools :program:`bmp2tiff`, :program:`gif2tiff`, :program:`ras2tiff`, :program:`sgi2tiff`, - :program:`sgisv`, and :program:`ycbcr` are completely removed from the distribution. - these tools were written in the late 1980s and early 1990s for - test and demonstration purposes. In some cases the tools were - never updated to support updates to the file format, or the - file formats are now rarely used. In all cases these tools - increased the libtiff security and maintenance exposure beyond - the value offered by the tool. - -Software configuration changes ------------------------------- - -* None - -Library changes ---------------- - -* :file:`libtiff/tif_dirread.c`: in :c:func:`TIFFFetchNormalTag`, do not - dereference :c:macro:`NULL` pointer when values of tags with - :c:macro:`TIFF_SETGET_C16_ASCII` / :c:macro:`TIFF_SETGET_C32_ASCII` access are - 0-byte arrays. Fixes - :bugzilla:`2593` (regression - introduced by previous fix done on 2016-11-11 for - :cve:`2016-9297`). Reported by Henri Salo. Assigned as - :cve:`2016-9448` - -* :file:`libtiff/tif_aux.c`: fix crash in :c:func:`TIFFVGetFieldDefaulted` when - requesting Predictor tag and that the zip/lzw codec is not - configured. Fixes - :bugzilla:`2591` - -* :file:`libtiff/tif_dirread.c`: in :c:func:`TIFFFetchNormalTag`, make sure - that values of tags with :c:macro:`TIFF_SETGET_C16_ASCII` / - :c:macro:`TIFF_SETGET_C32_ASCII` access are :c:macro:`NULL` terminated, to avoid - potential read outside buffer in :c:func:`_TIFFPrintField`. Fixes - :bugzilla:`2590` - -* :file:`libtiff/tif_dirread.c`: reject images with OJPEG compression - that have no ``TileOffsets``/``StripOffsets`` tag, when OJPEG - compression is disabled. Prevent :c:macro:`NULL` pointer dereference in - :c:func:`TIFFReadRawStrip1` and other functions that expect - :c:member:`td_stripbytecount` to be non :c:macro:`NULL`. Fixes - :bugzilla:`2585` - -* :file:`libtiff/tif_strip.c`: make :c:func:`TIFFNumberOfStrips` return the - ``td->td_nstrips`` value when it is non-zero, instead of - recomputing it. This is needed in :c:macro:`TIFF_STRIPCHOP` mode where - :c:member:`td_nstrips` is modified. Fixes a read outsize of array in - :program:`tiffsplit` (or other utilities using :c:func:`TIFFNumberOfStrips`). - Fixes :bugzilla:`2587` - (:cve:`2016-9273`) - -* :file:`libtiff/tif_predict.h`, :file:`libtiff/tif_predict.c`: Replace - assertions by runtime checks to avoid assertions in debug - mode, or buffer overflows in release mode. Can happen when - dealing with unusual tile size like YCbCr with - subsampling. Reported as MSVR 35105 by Axel Souchet & Vishal - Chauhan from the MSRC Vulnerabilities & Mitigations - -* :file:`libtiff/tif_dir.c`: discard values of ``SMinSampleValue`` and - ``SMaxSampleValue`` when they have been read and the value of - ``SamplesPerPixel`` is changed afterwards (like when reading a - OJPEG compressed image with a missing ``SamplesPerPixel`` tag, and - whose photometric is ``RGB`` or ``YCbCr``, forcing ``SamplesPerPixel`` - being 3). Otherwise when rewriting the directory (for example - with tiffset, we will expect 3 values whereas the array had - been allocated with just one), thus causing a out of bound - read access. Fixes - :bugzilla:`2500` - (:cve:`2014-8127`, duplicate: :cve:`2016-3658`) - -* :file:`libtiff/tif_dirwrite.c`: avoid :c:macro:`NULL` pointer dereference on - :c:member:`td_stripoffset` when writing directory, if :c:macro:`FIELD_STRIPOFFSETS` - was artificially set for a hack case in OJPEG case. Fixes - :bugzilla:`2500` - (:cve:`2014-8127`, duplicate: :cve:`2016-3658`) - -* :file:`libtiff/tif_getimage.c` (:c:func:`TIFFRGBAImageOK`): Reject attempts to - read floating point images. - -* :file:`libtiff/tif_predict.c` (:c:func:`PredictorSetup`): Enforce - bits-per-sample requirements of floating point predictor (3). - Fixes :cve:`2016-3622` "Divide By Zero in the :program:`tiff2rgba` tool." - -* :file:`libtiff/tif_pixarlog.c`: fix out-of-bounds write vulnerabilities - in heap allocated buffers. Reported as MSVR 35094. Discovered by - Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities & - Mitigations team. - -* :file:`libtiff/tif_write.c`: fix issue in error code path of - :c:func:`TIFFFlushData1` that didn't reset the :c:member:`tif_rawcc` and :c:member:`tif_rawcp` - members. I'm not completely sure if that could happen in - practice outside of the odd behaviour of :c:func:`t2p_seekproc` of - tiff2pdf). The report points that a better fix could be to - check the return value of :c:func:`TIFFFlushData1` in places where it - isn't done currently, but it seems this patch is enough. - Reported as MSVR 35095. Discovered by Axel Souchet & Vishal - Chauhan & Suha Can from the MSRC Vulnerabilities & Mitigations - team. - -* :file:`libtiff/tif_pixarlog.c`: Fix write buffer overflow in - :c:func:`PixarLogEncode` if more input samples are provided than - expected by :c:func:`PixarLogSetupEncode`. Idea based on - :file:`libtiff-CVE-2016-3990.patch` from - :file:`libtiff-4.0.3-25.el7_2.src.rpm` by Nikola Forro, but with - different and simpler check. (:bugzilla:`2544`) - -* :file:`libtiff/tif_read.c`: Fix out-of-bounds read on memory-mapped - files in :c:func:`TIFFReadRawStrip1` and :c:func:`TIFFReadRawTile1` when - ``stripoffset`` is beyond :c:type:`tmsize_t` max value (reported by Mathias - Svensson) - -* :file:`libtiff/tif_read.c`: make :c:func:`TIFFReadEncodedStrip` and - :c:func:`TIFFReadEncodedTile` directly use user provided buffer when - no compression (and other conditions) to save a :c:func:`memcpy` - -* :file:`libtiff/tif_write.c`: make :c:func:`TIFFWriteEncodedStrip` and - :c:func:`TIFFWriteEncodedTile` directly use user provided buffer when - no compression to save a :c:func:`memcpy`. - -* :file:`libtiff/tif_luv.c`: validate that for :c:macro:`COMPRESSION_SGILOG` and - :c:macro:`PHOTOMETRIC_LOGL`, there is only one sample per pixel. Avoid - potential invalid memory write on corrupted/unexpected images - when using the :c:func:`TIFFRGBAImageBegin` interface (reported by - Clay Wood) - -* :file:`libtiff/tif_pixarlog.c`: fix potential buffer write overrun in - :c:func:`PixarLogDecode` on corrupted/unexpected images (reported by - Mathias Svensson) (:cve:`2016-5875`) - -* libtiff/libtiff.def: Added ``_TIFFMultiply32`` and - ``_TIFFMultiply64`` to libtiff.def - -* :file:`libtiff/tif_config.vc.h` (:c:macro:`HAVE_SNPRINTF`): Add a '1' to the - :c:macro:`HAVE_SNPRINTF` definition. - -* :file:`libtiff/tif_config.vc.h` (:c:macro:`HAVE_SNPRINTF`): Applied patch by - Edward Lam to define :c:macro:`HAVE_SNPRINTF` for Visual Studio 2015. - -* :file:`libtiff/tif_dirread.c`: when compiled with :c:macro:`DEFER_STRILE_LOAD`, - fix regression, introduced on 2014-12-23, when reading a - one-strip file without a ``StripByteCounts`` tag. GDAL #6490 - -* :file:`libtiff/*`: upstream typo fixes (mostly contributed by Kurt - Schwehr) coming from GDAL internal libtiff - -* :file:`libtiff/tif_fax3.h`: make :c:member:`Param` member of :c:struct:`TIFFFaxTabEnt` - structure a :c:type:`uint16` to reduce size of the binary. - -* :file:`libtiff/tif_read.c`, :file:`tif_dirread.c`: fix indentation issues - raised by GCC 6 ``-Wmisleading-indentation`` - -* :file:`libtiff/tif_pixarlog.c`: avoid zlib error messages to pass a - :c:macro:`NULL` string to ``%s`` formatter, which is undefined behaviour in - :c:func:`sprintf`. - -* :file:`libtiff/tif_next.c`: fix potential out-of-bound write in :c:func:`NeXTDecode` - triggered by ``_ - (:bugzilla:`2508`) - -* :file:`libtiff/tif_luv.c`: fix potential out-of-bound writes in - decode functions in non debug builds by replacing :c:func:`assert` by - regular ``if`` checks (:bugzilla:`2522`). Fix potential - out-of-bound reads in case of short input data. - -* :file:`libtiff/tif_getimage.c`: fix out-of-bound reads in - :c:type:`TIFFRGBAImage` interface in case of unsupported values of - ``SamplesPerPixel``/``ExtraSamples`` for LogLUV / CIELab. Add explicit - call to :c:func:`TIFFRGBAImageOK` in :c:func:`TIFFRGBAImageBegin`. Fix - :cve:`2015-8665` reported by limingxing and :cve:`2015-8683` - reported by zzf of Alibaba. - -* :file:`libtiff/tif_dirread.c`: workaround false positive warning of - Clang Static Analyzer about :c:macro:`NULL` pointer dereference in - :c:func:`TIFFCheckDirOffset`. - -* :file:`libtiff/tif_fax3.c`: remove dead assignment in - :c:func:`Fax3PutEOLgdal`. Found by Clang Static Analyzer - -* :file:`libtiff/tif_dirwrite.c`: fix truncation to 32 bit of file - offsets in :c:func:`TIFFLinkDirectory` and :c:func:`TIFFWriteDirectorySec` - when aligning directory offsets on a even offset (affects - BigTIFF). This was a regression of the changeset of - 2015-10-19. - -* :file:`libtiff/tif_write.c`: :c:func:`TIFFWriteEncodedStrip` and - :c:func:`TIFFWriteEncodedTile` should return -1 in case of failure of - :c:func:`tif_encodestrip` as documented - -* :file:`libtiff/tif_dumpmode.c`: :c:func:`DumpModeEncode` should return 0 in - case of failure so that the above mentioned functions detect - the error. - -* :file:`libtiff/*.c`: fix MSVC warnings related to cast shortening and - assignment within conditional expression - -* :file:`libtiff/*.c`: fix clang -Wshorten-64-to-32 warnings - -* :file:`libtiff/tif_dirread.c`: prevent reading ColorMap or - TransferFunction if ``BitsPerPixel`` > 24, so as to avoid huge - memory allocation and file read attempts - -* :file:`libtiff/tif_dirread.c`: remove duplicated assignment (reported - by Clang static analyzer) - -* :file:`libtiff/tif_dir.c`, :file:`libtiff/tif_dirinfo.c`, - :file:`libtiff/tif_compress.c`, :file:`libtiff/tif_jpeg_12.c`: suppress - warnings about 'no previous declaration/prototype' - -* :file:`libtiff/tiffiop.h`, :file:`libtiff/tif_dirwrite.c`: suffix constants - by U to fix 'warning: negative integer implicitly converted to - unsigned type' warning (part of ``-Wconversion``) - -* :file:`libtiff/tif_dir.c`, :file:`libtiff/tif_dirread.c`, - :file:`libtiff/tif_getimage.c`, :file:`libtiff/tif_print.c`: fix ``-Wshadow`` - warnings (only in :file:`libtiff/`) - - -Tools changes -------------- - -* tools/Makefile.am: The libtiff tools :program:`bmp2tiff`, :program:`gif2tiff`, - :program:`ras2tiff`, :program:`sgi2tiff`, :program:`sgisv`, and :program:`ycbcr` are completely removed - from the distribution. The libtiff tools :program:`rgb2ycbcr` and - :program:`thumbnail` are only built in the build tree for testing. Old - files are put in new :file:`archive` subdirectory of the source - repository, but not in distribution archives. These changes - are made in order to lessen the maintenance burden. - -* :file:`tools/tiff2pdf.c`: avoid undefined behaviour related to - overlapping of source and destination buffer in :c:func:`memcpy` call - in :c:func:`t2p_sample_rgbaa_to_rgb` Fixes - :bugzilla:`2577` - -* :file:`tools/tiff2pdf.c`: fix potential integer overflows on 32 bit - builds in :c:func:`t2p_read_tiff_size` Fixes - :bugzilla:`2576` - -* :file:`tools/fax2tiff.c`: fix segfault when specifying ``-r`` without - argument. Patch by Yuriy M. Kaminskiy. Fixes - :bugzilla:`2572` - -* :file:`tools/tiffinfo.c`: fix out-of-bound read on some tiled images. - (:bugzilla:`2517`) - -* :file:`tools/tiffcrop.c`: fix multiple uint32 overflows in - :c:func:`writeBufferToSeparateStrips`, :c:func:`writeBufferToContigTiles` and - :c:func:`writeBufferToSeparateTiles` that could cause heap buffer - overflows. Reported by Henri Salo from Nixu Corporation. - Fixes :bugzilla:`2592` - -* :file:`tools/tiffcrop.c`: fix out-of-bound read of up to 3 bytes in - :c:func:`readContigTilesIntoBuffer`. Reported as MSVR 35092 by Axel - Souchet & Vishal Chauhan from the MSRC Vulnerabilities & - Mitigations team. - -* :file:`tools/tiff2pdf.c`: fix write buffer overflow of 2 bytes on - JPEG compressed images. Reported by Tyler Bohan of Cisco Talos - as TALOS-CAN-0187 / :cve:`2016-5652`. Also prevents writing 2 - extra uninitialized bytes to the file stream. - -* :file:`tools/tiffcp.c`: fix out-of-bounds write on tiled images with odd - tile width vs image width. Reported as MSVR 35103 - by Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities & - Mitigations team. - -* :file:`tools/tiff2pdf.c`: fix read -largely- outsize of buffer in - :c:func:`t2p_readwrite_pdf_image_tile`, causing crash, when reading a - JPEG compressed image with :c:macro:`TIFFTAG_JPEGTABLES` length being - one. Reported as MSVR 35101 by Axel Souchet and Vishal - Chauhan from the MSRC Vulnerabilities & Mitigations team. - -* :file:`tools/tiffcp.c`: fix read of undefined variable in case of - missing required tags. Found on test case of MSVR 35100. - -* :file:`tools/tiffcrop.c`: fix read of undefined buffer in - :c:func:`readContigStripsIntoBuffer` due to uint16 overflow. Probably - not a security issue but I can be wrong. Reported as MSVR - 35100 by Axel Souchet from the MSRC Vulnerabilities & - Mitigations team. - -* :file:`tools/tiffcrop.c`: fix various out-of-bounds write - vulnerabilities in heap or stack allocated buffers. Reported - as MSVR 35093, MSVR 35096 and MSVR 35097. Discovered by Axel - Souchet and Vishal Chauhan from the MSRC Vulnerabilities & - Mitigations team. - -* :file:`tools/tiff2pdf.c`: fix out-of-bounds write vulnerabilities in - heap allocate buffer in :c:func:`t2p_process_jpeg_strip`. Reported as - MSVR 35098. Discovered by Axel Souchet and Vishal Chauhan from - the MSRC Vulnerabilities & Mitigations team. - -* :file:`tools/tiff2bw.c`: fix weight computation that could result of - color value overflow (no security implication). Fix :bugzilla:`2550`. - Patch by Frank Freudenberg. - -* :file:`tools/rgb2ycbcr.c`: validate values of ``-v`` and ``-h`` parameters to - avoid potential divide by zero. Fixes :cve:`2016-3623` (:bugzilla:`2569`) - -* :file:`tools/tiffcrop.c`: Fix out-of-bounds write in :c:func:`loadImage`. - From patch :file:`libtiff-CVE-2016-3991.patch` from - :file:`libtiff-4.0.3-25.el7_2.src.rpm` by Nikola Forro (:bugzilla:`2543`) - -* :file:`tools/tiff2rgba.c`: Fix integer overflow in size of allocated - buffer, when ``-b`` mode is enabled, that could result in - out-of-bounds write. Based initially on patch - :file:`tiff-CVE-2016-3945.patch` from :file:`libtiff-4.0.3-25.el7_2.src.rpm` - by Nikola Forro, with correction for invalid tests that - rejected valid files. (:bugzilla:`2545`) - -* :file:`tools/tiffcrop.c`: Avoid access outside of stack allocated - array on a tiled separate TIFF with more than 8 samples per - pixel. Reported by Kaixiang Zhang of the Cloud Security Team, - Qihoo 360 (:cve:`2016-5321` / :cve:`2016-5323` , :bugzilla:`2558` / - :bugzilla:`2559`) - -* :file:`tools/tiffdump.c`: fix a few misaligned 64-bit reads warned by - ``-fsanitize`` - -* :file:`tools/tiffdump.c` (:c:func:`ReadDirectory`): Remove :c:type:`uint32` cast to - :c:func:`_TIFFmalloc` argument which resulted in Coverity report. - Added more mutiplication overflow checks. - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.8.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.8.rst deleted file mode 100644 index 00ec2d89e..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.8.rst +++ /dev/null @@ -1,390 +0,0 @@ -Changes in TIFF v4.0.8 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.8 (:tag:`Release-v4-0-8`) - Previous Version :doc:`v4.0.7 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* None - - -Software configuration changes ------------------------------- - -* None - - -Library changes ---------------- - -* :file:`libtiff/tif_getimage.c`, :file:`libtiff/tif_open.c`: add parenthesis - to fix cppcheck ``clarifyCalculation`` warnings - -* :file:`libtiff/tif_predict.c`, :file:`libtiff/tif_print.c`: fix printf - unsigned vs signed formatting (cppcheck - ``invalidPrintfArgType_uint`` warnings) - -* :file:`libtiff/tif_read.c`, :file:`libtiff/tiffiop.h`: fix :c:type:`uint32` overflow in - :c:func:`TIFFReadEncodedStrip` that caused an integer division by - zero. Reported by Agostino Sarubbo. Fixes - :bugzilla:`2596` - -* :file:`libtiff/tif_pixarlog.c`, :file:`libtiff/tif_luv.c`: fix heap-based - buffer overflow on generation of PixarLog / LUV compressed - files, with ``ColorMap``, ``TransferFunction`` attached and nasty - plays with ``bitspersample``. The fix for LUV has not been - tested, but suffers from the same kind of issue of PixarLog. - Reported by Agostino Sarubbo. Fixes - :bugzilla:`2604` - -* :file:`libtiff/tif_strip.c`: revert the change in - :c:func:`TIFFNumberOfStrips` done for - :bugzilla:`2587` / - :cve:`2016-9273` since the above change is a better fix that - makes it unnecessary. - -* :file:`libtiff/tif_dirread.c`: modify :c:func:`ChopUpSingleUncompressedStrip` - to instantiate compute ``nstrips`` as - ``TIFFhowmany_32(td->td_imagelength, rowsperstrip)``, instead of a - logic based on the total size of data. Which is faulty is the - total size of data is not sufficient to fill the whole image, - and thus results in reading outside of the - ``StripByCounts``/``StripOffsets`` arrays when using - :c:func:`TIFFReadScanline`. Reported by Agostino Sarubbo. Fixes - :bugzilla:`2608`. - -* :file:`libtiff/tif_ojpeg.c`: make :c:func:`OJPEGDecode` early exit in case of - failure in :c:func:`OJPEGPreDecode`. This will avoid a divide by zero, - and potential other issues. Reported by Agostino Sarubbo. - Fixes :bugzilla:`2611` - -* :file:`libtiff/tif_write.c`: fix misleading indentation as warned by GCC. - - -* :file:`libtiff/tif_fax3.h`: revert change done on 2016-01-09 that - made :c:member:`Param` member of :c:struct:`TIFFFaxTabEnt` structure a :c:type:`uint16` to - reduce size of the binary. It happens that the Hylafax - software uses the tables that follow this typedef - (:c:var:`TIFFFaxMainTable`, :c:var:`TIFFFaxWhiteTable`, :c:var:`TIFFFaxBlackTable`), - although they are not in a public libtiff header. Raised by - Lee Howard. Fixes - :bugzilla:`2636` - -* :file:`libtiff/tiffio.h`, :file:`libtiff/tif_getimage.c`: add - :c:func:`TIFFReadRGBAStripExt` and :c:func:`TIFFReadRGBATileExt` variants of - the functions without ext, with an extra argument to control - the ``stop_on_error`` behaviour. - -* :file:`libtiff/tif_getimage.c`: fix potential memory leaks in error - code path of :c:func:`TIFFRGBAImageBegin`. Fixes - :bugzilla:`2627` - -* :file:`libtiff/tif_jpeg.c`: increase libjpeg max memory usable to 10 - MB instead of libjpeg 1MB default. This helps when creating - files with "big" tile, without using libjpeg temporary files. - Related to https://trac.osgeo.org/gdal/ticket/6757 - -* :file:`libtiff/tif_jpeg.c`: avoid integer division by zero in - :c:func:`JPEGSetupEncode` when horizontal or vertical sampling is set - to 0. Fixes :bugzilla:`2653` - -* :file:`libtiff/tif_dirwrite.c`: in - :c:func:`TIFFWriteDirectoryTagCheckedRational`, replace assertion by - runtime check to error out if passed value is strictly - negative. Fixes - :bugzilla:`2535` - -* :file:`libtiff/tif_dirread.c`: avoid division by floating point 0 in - :c:func:`TIFFReadDirEntryCheckedRational` and - :c:func:`TIFFReadDirEntryCheckedSrational`, and return 0 in that case - (instead of infinity as before presumably) Apparently some - sanitizers do not like those divisions by zero. Fixes - :bugzilla:`2644` - -* :file:`libtiff/tif_dir.c`, :file:`tif_dirread.c`, :file:`tif_dirwrite.c`: implement - various clampings of double to other data types to avoid - undefined behaviour if the output range isn't big enough to - hold the input value. Fixes - :bugzilla:`2643`, - :bugzilla:`2642`, - :bugzilla:`2646`, - :bugzilla:`2647` - -* :file:`libtiff/tif_jpeg.c`: validate ``BitsPerSample`` in - :c:func:`JPEGSetupEncode` to avoid undefined behaviour caused by - invalid shift exponent. Fixes - :bugzilla:`2648` - -* :file:`libtiff/tif_read.c`: avoid potential undefined behaviour on - signed integer addition in :c:func:`TIFFReadRawStrip1` in :c:func:`isMapped` - case. Fixes :bugzilla:`2650` - -* :file:`libtiff/tif_getimage.c`: add explicit :c:func:`uint32` cast in - :c:var:`putagreytile` to avoid ``UndefinedBehaviorSanitizer`` warning. - Patch by Nicolás Peña. Fixes - :bugzilla:`2658` - -* :file:`libtiff/tif_read.c`: :c:func:`TIFFReadBufferSetup`: use :c:func:`_TIFFcalloc` - to zero initialize :c:member:`tif_rawdata`. Fixes - :bugzilla:`2651` - -* :file:`libtiff/tiffio.h`, :file:`tif_unix.c`, :file:`tif_win32.c`, :file:`tif_vms.c`: add - :c:func:`_TIFFcalloc` - -* :file:`libtiff/tif_luv.c`, :file:`tif_lzw.c`, :file:`tif_packbits.c`: return 0 in - Encode functions instead of -1 when :c:func:`TIFFFlushData1` fails. - Fixes :bugzilla:`2130` - -* :file:`libtiff/tif_ojpeg.c`: fix leak in - :c:func:`OJPEGReadHeaderInfoSecTablesQTable`, - :c:func:`OJPEGReadHeaderInfoSecTablesDcTable` and - :c:func:`OJPEGReadHeaderInfoSecTablesAcTable` when read fails. Patch by - Nicolás Peña. Fixes - :bugzilla:`2659` - -* :file:`libtiff/tif_jpeg.c`: only run :c:func:`JPEGFixupTagsSubsampling` if - the ``YCbCrSubsampling`` tag is not explicitly present. This helps - a bit to reduce the I/O amount when the tag is present - (especially on cloud hosted files). - -* :file:`libtiff/tif_lzw.c`: in :c:func:`LZWPostEncode`, increase, if - necessary, the code bit-width after flushing the remaining - code and before emitting the EOI code. Fixes - :bugzilla:`1982` - -* :file:`libtiff/tif_pixarlog.c`: fix memory leak in error code path of - :c:func:`PixarLogSetupDecode`. Patch by Nicolás Peña. Fixes - :bugzilla:`2665` - -* :file:`libtiff/tif_fax3.c`, :file:`tif_predict.c`, :file:`tif_getimage.c`: fix GCC 7 - ``-Wimplicit-fallthrough`` warnings. - -* :file:`libtiff/tif_dirread.c`: fix memory leak in non - :c:macro:`DEFER_STRILE_LOAD` mode (ie default) when there is both a - ``StripOffsets`` and ``TileOffsets`` tag, or a ``StripByteCounts`` and - ``TileByteCounts``. Fixes - :bugzilla:`2689` - -* :file:`libtiff/tif_ojpeg.c`: fix potential memory leak in - :c:func:`OJPEGReadHeaderInfoSecTablesQTable`, - :c:func:`OJPEGReadHeaderInfoSecTablesDcTable` and - :c:func:`OJPEGReadHeaderInfoSecTablesAcTable`. Patch by Nicolás Peña. - Fixes :bugzilla:`2670` - -* :file:`libtiff/tif_fax3.c`: avoid crash in :c:func:`Fax3Close` on empty file. - Patch by Alan Coopersmith + complement by myself. Fixes - :bugzilla:`2673` - -* :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStrip`: add limitation to the - number of bytes read in case ``td_stripbytecount[strip]`` is - bigger than reasonable, so as to avoid excessive memory - allocation. - -* :file:`libtiff/tif_zip.c`, :file:`tif_pixarlog.c`, :file:`tif_predict.c`: fix memory - leak when the underlying codec (ZIP, PixarLog) succeeds its - :c:func:`setupdecode` method, but :c:func:`PredictorSetup` fails. Credit to - OSS-Fuzz (locally run, on GDAL) - -* :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStrip` and :c:func:`TIFFFillTile`: avoid - excessive memory allocation in case of shorten files. Only - effective on 64 bit builds and non-mapped cases. Credit to - OSS-Fuzz (locally run, on GDAL) - -* :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStripPartial` / :c:func:`TIFFSeek`, - avoid potential integer overflows with read_ahead in - :c:macro:`CHUNKY_STRIP_READ_SUPPORT` mode. Should - especially occur on 32 bit platforms. - -* :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStripPartial`: avoid excessive - memory allocation in case of shorten files. Only effective on - 64 bit builds. Credit to OSS-Fuzz (locally run, on GDAL) - -* :file:`libtiff/tif_read.c`: update :c:member:`tif_rawcc` in - :c:macro:`CHUNKY_STRIP_READ_SUPPORT` mode with :c:member:`tif_rawdataloaded` when - calling :c:func:`TIFFStartStrip` or :c:func:`TIFFFillStripPartial`. This - avoids reading beyond :c:func:`tif_rawdata` when ``bytecount > - tif_rawdatasize``. Fixes - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1545. - Credit to OSS-Fuzz - -* :file:`libtiff/tif_color.c`: avoid potential :c:type:`int32` overflow in - :c:func:`TIFFYCbCrToRGBInit`. Fixes - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1533 - Credit to OSS-Fuzz - -* :file:`libtiff/tif_pixarlog.c`, :file:`tif_luv.c`: avoid potential :c:type:`int32` - overflows in :c:func:`multiply_ms` and :c:func:`add_ms`. Fixes - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1558 - Credit to OSS-Fuzz - -* :file:`libtiff/tif_packbits.c`: fix out-of-buffer read in - :c:func:`PackBitsDecode`. Fixes - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1563 - Credit to OSS-Fuzz - -* :file:`libtiff/tif_luv.c`: :c:func:`LogL16InitState`: avoid excessive memory - allocation when ``RowsPerStrip`` tag is missing. - Credit to OSS-Fuzz (locally run, on GDAL) - -* :file:`libtiff/tif_lzw.c`: update dec_bitsleft at beginning of - LZWDecode(), and update tif_rawcc at end of LZWDecode(). This - is needed to properly work with the latest chnges in - tif_read.c in CHUNKY_STRIP_READ_SUPPORT mode. - -* :file:`libtiff/tif_pixarlog.c`: :c:func:`PixarLogDecode`: resync :c:member:`tif_rawcp` - with :c:member:`next_in` and :c:member:`tif_rawcc` with :c:member:`avail_in` at beginning and end - of function, similarly to what is done in :c:func:`LZWDecode`. Likely - needed so that it works properly with latest chnges in - :file:`tif_read.c` in :c:macro:`CHUNKY_STRIP_READ_SUPPORT` mode. But untested... - -* :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: add basic - validation of :c:var:`luma` and :c:var:`refBlackWhite` coefficients (just check - they are not NaN for now), to avoid potential :c:expr:`float` to :c:expr:`int` - overflows. Fixes - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1663 - Credit to OSS Fuzz - -* :file:`libtiff/tif_read.c`: :c:func:`_TIFFVSetField`: fix outside range cast - of :c:expr:`double` to :c:expr:`float`. Credit to Google Autofuzz project - -* :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: check ``luma[1]`` - is not zero to avoid division by zero. Fixes - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1665 - Credit to OSS Fuzz - -* :file:`libtiff/tif_read.c`: :c:func:`_TIFFVSetField`: fix outside range cast - of :c:expr:`double` to :c:expr:`float`. Credit to Google Autofuzz project - -* :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: check ``luma[1]`` - is not zero to avoid division by zero. Fixes - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1665 - Credit to OSS Fuzz - -* :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: stricter - validation for :c:var:`refBlackWhite` coefficients values. To avoid - invalid :c:expr:`float` to :c:expr:`int32` conversion. Fixes - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1718 - Credit to OSS Fuzz - - -Tools changes -------------- - -* :file:`tools/fax2tiff.c` (:c:func:`main`): Applied patch by Jörg Ahrens to fix - passing client data for Win32 builds using :file:`tif_win32.c` - (:c:macro:`USE_WIN32_FILEIO` defined) for file I/O. Patch was provided - via email on November 20, 2016. - -* :file:`tools/tiffcp.c`: avoid :c:type:`uint32` underflow in :c:func:`cpDecodedStrips` - that can cause various issues, such as buffer overflows in the - library. Reported by Agostino Sarubbo. Fixes - :bugzilla:`2598` - -* :file:`tools/tiffcrop.c`: fix :c:func:`readContigStripsIntoBuffer` in ``-i`` - (ignore) mode so that the output buffer is correctly - incremented to avoid write outside bounds. Reported by - Agostino Sarubbo. Fixes - :bugzilla:`2620` - -* :file:`tools/tiffcrop.c`: add 3 extra bytes at end of strip buffer in - :c:func:`readSeparateStripsIntoBuffer` to avoid read outside of heap - allocated buffer. Reported by Agostino Sarubbo. Fixes - :bugzilla:`2621` - -* :file:`tools/tiffcrop.c`: fix integer division by zero when - ``BitsPerSample`` is missing. Reported by Agostino Sarubbo. - Fixes :bugzilla:`2619` - -* :file:`tools/tiffinfo.c`: fix null pointer dereference in ``-r`` mode - when the image has no ``StripByteCount`` tag. Reported by - Agostino Sarubbo. Fixes - :bugzilla:`2594` - -* :file:`tools/tiffcp.c`: avoid potential division by zero if - ``BitsPerSamples`` tag is missing. Reported by Agostino Sarubbo. - Fixes :bugzilla:`2597` - -* :file:`tools/tif_dir.c`: when ``TIFFGetField(, TIFFTAG_NUMBEROFINKS, )`` - is called, limit the return number of inks to ``SamplesPerPixel``, - so that code that parses ink names doesn't go past the end of - the buffer. Reported by Agostino Sarubbo. Fixes - :bugzilla:`2599` - -* :file:`tools/tiffcp.c`: avoid potential division by zero if - ``BitsPerSamples`` tag is missing. Reported by Agostino Sarubbo. - Fixes :bugzilla:`2607` - -* :file:`tools/tiffcp.c`: fix :c:type:`uint32` underflow/overflow that can cause - heap-based buffer overflow. Reported by Agostino Sarubbo. - Fixes :bugzilla:`2610` - -* :file:`tools/tiffcp.c`: replace ``assert( (bps % 8) == 0 )`` by a non - assert check. Reported by Agostino Sarubbo. Fixes - :bugzilla:`2605` - -* :file:`tools/tiff2ps.c`: fix 2 heap-based buffer overflows (in - :c:func:`PSDataBW` and :c:func:`PSDataColorContig`). Reported by Agostino Sarubbo. - Fixes :bugzilla:`2633` and - :bugzilla:`2634`. - -* :file:`tools/tiff2pdf.c`: prevent heap-based buffer overflow in ``-j`` - mode on a paletted image. Note: this fix errors out before the - overflow happens. There could probably be a better fix. Fixes - :bugzilla:`2635` - -* :file:`tools/tiff2pdf.c`: fix wrong usage of :c:func:`memcpy` that can - trigger unspecified behaviour. Fixes - :bugzilla:`2638` - -* :file:`tools/tiff2pdf.c`: avoid potential invalid memory read in - :c:func:`t2p_writeproc`. Fixes - :bugzilla:`2639` - -* :file:`tools/tiff2pdf.c`: avoid potential heap-based overflow in - :c:func:`t2p_readwrite_pdf_image_tile`. Fixes - :bugzilla:`2640` - -* :file:`tools/tiffcrop.c`: remove extraneous :c:func:`TIFFClose` in error code - path, that caused double free. Related to - :bugzilla:`2535` - -* :file:`tools/tiffcp.c`: error out cleanly in :c:func:`cpContig2SeparateByRow` - and :c:func:`cpSeparate2ContigByRow` if ``BitsPerSample != 8`` to avoid heap - based overflow. Fixes - :bugzilla:`2656` and - :bugzilla:`2657` - -* :file:`tools/raw2tiff.c`: avoid integer division by zero. Fixes - :bugzilla:`2631` - -* :file:`tools/tiff2ps.c`: call :c:func:`TIFFClose` in error code paths. - -* :file:`tools/fax2tiff.c`: emit appropriate message if the input file - is empty. Patch by Alan Coopersmith. Fixes - :bugzilla:`2672` - -* :file:`tools/tiff2bw.c`: close :c:struct:`TIFF` handle in error code path. Fixes - :bugzilla:`2677` - - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.9.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.9.rst deleted file mode 100644 index 7a5318da0..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.0.9.rst +++ /dev/null @@ -1,317 +0,0 @@ -Changes in TIFF v4.0.9 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.0.9 (:tag:`Release-v4-0-9`) - Previous Version :doc:`v4.0.8 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here: - - -Major changes -------------- - -* None - - -Software configuration changes ------------------------------- - -* :file:`test/Makefile.am`: Add some tests for tiff2bw. -* :file:`.appveyor.yml`, :file:`.travis.yml`, :file:`build/travis-ci`: apply patches - :file:`0001-ci-Travis-script-improvements.patch` and - :file:`0002-ci-Invoke-helper-script-via-shell.patch` by Roger Leigh - (sent to mailing list) -* :file:`.travis.yml`, :file:`build/travis-ci`: new files from - :file:`0001-ci-Add-Travis-support-for-Linux-builds-with-Autoconf.patch` by - Roger Leigh (sent to mailing list on 2017-06-08). - This patch adds support for the Travis-CI service. -* :file:`.appveyor.yml`: new file from - :file:`0002-ci-Add-AppVeyor-support.patch` by Roger Leigh (sent to mailing - list on 2017-06-08). - This patch adds a :file:`.appveyor.yml` file to the top-level. This allows - one to opt in to having a branch built on Windows with Cygwin, - MinGW and MSVC automatically when a branch is pushed to GitHub, - GitLab, BitBucket or any other supported git hosting service. -* :file:`CMakeLists.txt`, :file:`test/CMakeLists.txt`, :file:`test/TiffTestCommon.cmake`: apply - patch :file:`0001-cmake-Improve-Cygwin-and-MingGW-test-support.patch` from Roger - Leigh (sent to mailing list on 2017-06-08). - This patch makes the CMake build system support running the tests - with MinGW or Cygwin. - -* :file:`test/tiffcp-lzw-compat.sh`, :file:`test/images/quad-lzw-compat.tiff`: new files - to test old-style LZW decompression -* :file:`test/common.sh`, :file:`Makefile.am`, :file:`CMakeList.txt`: updated with above -* :file:`test/Makefile.am`: add missing reference to images/quad-lzw-compat.tiff - to fix ``make distcheck``. Patch by Roger Leigh -* :file:`nmake.opt`: support a ``DEBUG=1`` option, so as to adjust ``OPTFLAGS`` and use - ``/MDd`` runtime in debug mode. - - -Library changes ---------------- - -* :file:`libtiff/tif_color.c`: :c:func:`TIFFYCbCrToRGBInit`: stricter clamping to avoid - :c:type:`int32` overflow in :c:func:`TIFFYCbCrtoRGB`. - Fixes :oss-fuzz:`1844`. - Credit to OSS Fuzz - -* :file:`libtiff/tif_getimage.c`: :c:func:`initYCbCrConversion`: stricter validation for - ``refBlackWhite`` coefficients values. To avoid invalid ``float->int32`` conversion - (when ``refBlackWhite[0] == 2147483648.f``) - Fixes :oss-fuzz:`1907`. - Credit to OSS Fuzz - -* :file:`libtiff/tif_dirinfo.c`, :file:`tif_dirread.c`: add :c:func:`_TIFFCheckFieldIsValidForCodec`, - and use it in :c:func:`TIFFReadDirectory` so as to ignore fields whose tag is a - codec-specified tag but this codec is not enabled. This avoids :c:func:`TIFFGetField` - to behave differently depending on whether the codec is enabled or not, and - thus can avoid stack based buffer overflows in a number of TIFF utilities - such as :program:`tiffsplit`, :program:`tiffcmp`, :program:`thumbnail`, etc. - Patch derived from :file:`0063-Handle-properly-CODEC-specific-tags.patch` - (:bugzilla:`2580`) by Raphaël Hertzog. - Fixes: - :bugzilla:`2580`, - :bugzilla:`2693`, - :bugzilla:`2625` (:cve:`2016-10095`), - :bugzilla:`2564` (:cve:`2015-7554`), - :bugzilla:`2561` (:cve:`2016-5318`), - :bugzilla:`2499` (:cve:`2014-8128`), - :bugzilla:`2441`, - :bugzilla:`2433`. - -* :file:`libtiff/tif_swab.c`: if :c:macro:`DISABLE_CHECK_TIFFSWABMACROS` is defined, do not do - the ``#ifdef TIFFSwabXXX`` checks. Make it easier for GDAL to rename the symbols - of its internal libtiff copy. - -* :file:`libtiff/tif_dirread.c`: fix regression of libtiff 4.0.8 in - :c:func:`ChopUpSingleUncompressedStrip` regarding update of newly single-strip - uncompressed files whose bytecount is 0. Before the change of 2016-12-03, - the condition ``bytecount==0`` used to trigger an early exit/disabling of - strip chop. Re-introduce that in update mode. Otherwise this cause - later incorrect setting for the value of ``StripByteCounts``/``StripOffsets``. - (:gdal-trac:`6924`). -* :file:`libtiff/tif_dirread.c`: :c:func:`TIFFFetchStripThing`: limit the number of items - read in ``StripOffsets``/``StripByteCounts`` tags to the number of strips to avoid - excessive memory allocation. - Fixes :oss-fuzz:`2215`. - Credit to OSS Fuzz -* :file:`libtiff/tif_getimage.c`: avoid many (harmless) :c:expr:`unsigned int` overflows. -* :file:`libtiff/tif_fax3.c`: avoid :c:expr:`unsigned int` overflow in :c:func:`Fax3Encode2DRow`. Could - potentially be a bug with huge rows. -* :file:`libtiff/tif_jpeg.c`: avoid (harmless) :c:expr:`unsigned int` overflow on tiled images. -* :file:`libtiff/tif_dirread.c`: avoid :c:expr:`unsigned int` overflow in :c:func:`EstimateStripByteCounts` - and ``BYTECOUNTLOOKSBAD`` when file is too short. -* :file:`libtiff/tif_predict.c`: decorate legitimate functions where :c:expr:`unsigned int` - overflow occur with :c:macro:`TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW` -* :file:`libtiff/tif_dirread.c`: avoid :c:expr:`unsigned int` overflow in :c:func:`EstimateStripByteCounts` -* :file:`libtiff/tiffiop.h`: add :c:macro:`TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW` macro to - disable CLang warnings raised by ``-fsanitize=undefined,unsigned-integer-overflow`` -* :file:`libtiff/tif_jpeg.c`: add anti-denial of service measure to avoid excessive - CPU consumption on progressive JPEGs with a huge number of scans. - See ``_. - - .. note:: - - Only affects libtiff since 2014-12-29 where support of non-baseline JPEG - was added. - -* :file:`libtiff/tif_jpeg.c`: error out at decoding time if anticipated libjpeg - memory allocation is above 100 MB. libjpeg in case of multiple scans, - which is allowed even in baseline JPEG, if components are spread over several - scans and not interleavedin a single one, needs to allocate memory (or - backing store) for the whole strip/tile. - See ``_. - This limitation may be overridden by setting the - ``LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC`` environment variable, or recompiling - libtiff with a custom value of :c:macro:`TIFF_LIBJPEG_LARGEST_MEM_ALLOC` macro. -* :file:`libtiff/tif_jbig.c`: fix memory leak in error code path of :c:func:`JBIGDecode`. - Fixes :bugzilla:`2706`. - Reported by team OWL337 -* :file:`libtiff/tif_dirread.c`: in :c:func:`TIFFReadDirEntryFloat`, check that a - double value can fit in a float before casting. Patch by Nicolas RUFF -* :file:`libtiff/tiffiop.h`, :file:`libtiff/tif_jpeg.c`, :file:`libtiff/tif_jpeg_12.c`, - :file:`libtiff/tif_read.c`: make :c:func:`TIFFReadScanline` works in - :c:macro:`CHUNKY_STRIP_READ_SUPPORT` mode with JPEG stream with multiple scans. - Also make configurable through a ``LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER`` - environment variable the maximum number of scans allowed. Defaults to - 100. -* :file:`libtiff/tif_read.c`: :c:func:`TIFFFillTile`: add limitation to the number - of bytes read in case td_stripbytecount[strip] is bigger than - reasonable, so as to avoid excessive memory allocation (similarly to - what was done for :c:func:`TIFFFileStrip` on 2017-05-10) -* :file:`libtiff/tif_getimage.c`: use :c:func:`_TIFFReadEncodedStripAndAllocBuffer`. - Fixes :bugzilla:`2708` and - :oss-fuzz:`2433`. - Credit to OSS Fuzz -* :file:`libtiff/tif_read.c`, tiffiop.h: add a :c:func:`_TIFFReadEncodedStripAndAllocBuffer` - function, variant of :c:func:`TIFFReadEncodedStrip` that allocates the - decoded buffer only after a first successful :c:func:`TIFFFillStrip`. This avoids - excessive memory allocation on corrupted files. -* :file:`libtiff/tif_dirwrite.c`: in :c:func:`TIFFWriteDirectoryTagCheckedXXXX` - functions associated with LONG8/SLONG8 data type, replace assertion that - the file is BigTIFF, by a non-fatal error. - Fixes :bugzilla:`2712` - Reported by team OWL337 -* :file:`libtiff/tif_read.c`: :c:func:`TIFFStartTile`: set tif_rawcc to - tif_rawdataloaded when it is set. Similarly to :c:func:`TIFFStartStrip`. - This issue was revealed by the change of 2017-06-30 in :c:func:`TIFFFileTile`, - limiting the number of bytes read. But it could probably have been hit - too in CHUNKY_STRIP_READ_SUPPORT mode previously ? - Fixes :oss-fuzz:`2454` - Credit to OSS Fuzz -* :file:`libtiff/tif_error.c, tif_warning.c`: correctly use va_list when both - an old-style and new-style warning/error handlers are installed. - Patch by Paavo Helde (sent on the mailing list) -* :file:`libtiff/tif_getimage.c`: use :c:func:`_TIFFReadTileAndAllocBuffer`. - Fixes :oss-fuzz:`2470` - Credit to OSS Fuzz. -* :file:`libtiff/tif_read.c`, tiffiop.h: add a :c:func:`_TIFFReadEncodedTileAndAllocBuffer` - and :c:func:`_TIFFReadTileAndAllocBuffer` variants of :c:func:`TIFFReadEncodedTile` and - :c:func:`TIFFReadTile` that allocates the decoded buffer only after a first - successful :c:func:`TIFFFillTile`. This avoids excessive memory allocation - on corrupted files. -* :file:`libtiff/tif_pixarlog.c`: avoid excessive memory allocation on decoding - when RowsPerStrip tag is not defined (and thus td_rowsperstrip == UINT_MAX) - Fixes :oss-fuzz:`2554` - Credit to OSS Fuzz -* :file:`libtiff/tif_lzw.c`: fix 4.0.8 regression in the decoding of old-style LZW - compressed files. -* :file:`libtiff/tif_lzw.c`: fix potential out-of-buffer read on 1-byte LZW - strips. Crashing issue only on memory mapped files, where the strip - offset is the last byte of the file, and the file size is a multiple - of one page size on the CPU architecture (typically 4096). Credit - to myself :-) -* :file:`libtiff/tif_dir.c`: avoid potential null pointer dereference in - :c:func:`_TIFFVGetField` on corrupted TIFFTAG_NUMBEROFINKS tag instance. - Fixes :bugzilla:`2713` -* :file:`tools/tiff2pdf.c`: prevent heap buffer overflow write in "Raw" - mode on ``PlanarConfig=Contig`` input images. - Fixes :bugzilla:`2715` - Reported by team OWL337 -* :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStrip` / :c:func:`TIFFFillTile`. - Complementary fix for :bugzilla:`2708` - in the :c:func:`isMapped` case, so as to avoid excessive memory allocation - when we need a temporary buffer but the file is truncated. -* :file:`libtiff/tif_read.c`: :c:func:`TIFFFillStrip` / :c:func:`TIFFFillTile`. - Complementary fix for :bugzilla:`2708` - in the :c:func:`isMapped` case, so as to avoid excessive memory allocation - when we need a temporary buffer but the file is truncated. -* :file:`libtiff/tif_read.c`: in :c:func:`TIFFFetchStripThing`, only grow the - arrays that hold StripOffsets/StripByteCounts, when they are smaller - than the expected number of striles, up to 1 million striles, and - error out beyond. Can be tweaked by setting the environment variable - ``LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT``. - This partially goes against a change added on 2002-12-17 to accept - those arrays of wrong sizes, but is needed to avoid denial of services. - Fixes :oss-fuzz:`2350` - Credit to OSS Fuzz -* :file:`libtiff/tif_read.c`: in :c:func:`TIFFFetchStripThing`, only grow the - arrays that hold ``StripOffsets``/``StripByteCounts``, when they are smaller - than the expected number of striles, up to 1 million striles, and - error out beyond. Can be tweaked by setting the environment variable - ``LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT``. - This partially goes against a change added on 2002-12-17 to accept - those arrays of wrong sizes, but is needed to avoid denial of services. - Fixes :oss-fuzz:`2350` - Credit to OSS Fuzz -* :file:`libtiff/tif_read.c`: add protection against excessive memory - allocation attempts in :c:func:`TIFFReadDirEntryArray` on short files. - Effective for mmap'ed case. And non-mmap'ed case, but restricted - to 64bit builds. - Fixes :bugzilla:`2675` -* :file:`libtiff/tif_read.c`: add protection against excessive memory - allocation attempts in :c:func:`TIFFReadDirEntryArray` on short files. - Effective for mmap'ed case. And non-mmap'ed case, but restricted - to 64bit builds. - Fixes :bugzilla:`2675` -* :file:`libtiff/tif_luv.c`: :c:func:`LogLuvInitState`: avoid excessive memory - allocation when ``RowsPerStrip`` tag is missing. - Fixes :oss-fuzz:`2683` - Credit to OSS-Fuzz -* :file:`libtiff/tif_getimage.c`: :c:func:`gtTileContig` and :c:func:`gtTileSeparate`: - properly break from loops on error when ``stoponerr`` is set, instead - of going on iterating on row based loop. -* :file:`libtiff/tif_getimage.c`: fix fromskew computation when to-be-skipped - pixel number is not a multiple of the horizontal subsampling, and - also in some other cases. Impact ``putcontig8bitYCbCr44tile``, - ``putcontig8bitYCbCr42tile``, ``putcontig8bitYCbCr41tile``, - ``putcontig8bitYCbCr21tile`` and ``putcontig8bitYCbCr12tile``. - Fixes :bugzilla:`2637` (discovered by Agostino Sarubbo) - and :oss-fuzz:`2691` (credit to OSS Fuzz) -* :file:`libtiff/tif_luv.c`: further reduce memory requirements for temporary - buffer when ``RowsPerStrip >= image_length`` in :c:func:`LogLuvInitState` and - :c:func:`LogL16InitState`. - Fixes :oss-fuzz:`2700` - Credit to OSS Fuzz -* :file:`libtiff/tif_dirwrite.c`: replace assertion related to not finding the - ``SubIFD`` tag by runtime check (in :c:func:`TIFFWriteDirectorySec`) - Fixes :bugzilla:`2727` - Reported by team OWL337 -* :file:`libtiff/tif_dirwrite.c`: replace assertion to tag value not fitting - on :c:type:`uint32` when selecting the value of ``SubIFD`` tag by runtime check - (in :c:func:`TIFFWriteDirectoryTagSubifd`). - Fixes :bugzilla:`2728` - Reported by team OWL337 -* :file:`libtiff/tif_jpeg.c`: accept reading the last strip of a JPEG compressed - file if the codestream height is larger than the truncated height of the - strip. Emit a warning in this situation since this is non compliant. -* :file:`libtiff/tiffiop.h`, :c:type:`tif_aux.c`: redirect :c:func:`SeekOK` macro to a :c:func:`_TIFFSeekoK` - function that checks if the offset is not bigger than :c:macro:`INT64_MAX`, so as - to avoid a ``-1`` error return code of :c:func:`TIFFSeekFile` to match a required - seek to :c:macro:`UINT64_MAX`/``-1``. - Fixes :bugzilla:`2726` - Adapted from proposal by Nicolas Ruff. -* :file:`libtiff/tif_dirread.c`: add :c:macro:`NULL` check to avoid likely false positive - null-pointer dereference warning by CLang Static Analyzer. -* :file:`libtiff/libtiff.def`: add :c:func:`TIFFReadRGBAStripExt` and :c:func:`TIFFReadRGBATileExt` - Fixes :bugzilla:`2735` -* :file:`libtiff/tif_jpeg.c`: add compatibility with libjpeg-turbo 1.5.2 that - honours ``max_memory_to_use > 0``. - Cf ``_. -* :file:`libtiff/tif_getimage.c`: avoid floating point division by zero in - :c:func:`initCIELabConversion` - Fixes :oss-fuzz:`3733` - Credit to OSS Fuzz - - -Tools changes -------------- - -* :file:`tools/tiff2pdf.c`: prevent heap buffer overflow write in "Raw" - mode on ``PlanarConfig=Contig`` input images. - Fixes :bugzilla:`2715` - Reported by team OWL337 -* :file:`tools/tiffset.c`: fix setting a single value for the ``ExtraSamples`` tag - (and other tags with variable number of values). - So ``tiffset -s ExtraSamples 1 X``. This only worked - when setting 2 or more values, but not just one. -* :file:`tools/fax2tiff.c` (``_FAX_Client_Data``): Pass ``FAX_Client_Data`` as the - client data. This client data is not used at all at the moment, - but it makes the most sense. Issue that the value of - ``client_data.fd`` was passed where a pointer is expected was reported - via email by Gerald Schade on Sun, 29 Oct 2017. -* :file:`tools/tiff2pdf.c` (``t2p_sample_realize_palette``): Fix possible - arithmetic overflow in bounds checking code and eliminate - comparison between signed and unsigned type. -* :file:`tools/tiff2bw.c` (:c:func:`main`): Free memory allocated in the :program:`tiff2bw` - program. This is in response to the report associated with - :cve:`2017-16232` but does not solve the extremely high memory usage - with the associated POC file. - - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.1.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.1.0.rst deleted file mode 100644 index 112346fb5..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.1.0.rst +++ /dev/null @@ -1,98 +0,0 @@ -Changes in TIFF v4.1.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.1.0 (:tag:`v4.1.0`) - Previous Version :doc:`v4.0.10 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - ====================== ========================================== - -This document describes the changes made to the software between the -*previous* and *current* versions (see above). If you don't -find something listed here, then it was not done in this timeframe, or -it was not considered important enough to be mentioned. The following -information is located here. A change summary is also provided by the -:file:`ChangeLog` file included in the release package and by the Git commit -history: - - -Major changes -------------- - -* Make defer strile offset/bytecount loading available at runtime - and add per-strile offset/bytecount loading capabilities. Part of - this commit makes the behaviour that was previously met when libtiff - was compiled with ``-DDEFER_STRILE_LOAD`` available for default builds - when specifying the new ``D`` (Deferred) :c:func:`TIFFOpen` flag. In that - mode, the [``Tile``/``Strip``][``ByteCounts``/``Offsets``] arrays are only loaded - when first accessed. This can speed-up the opening of files stored - on the network when just metadata retrieval is needed. - - Another addition is the capability of loading only the values of - the offset/bytecount of the strile of interest instead of the - whole array. This is enabled with the new ``O`` (Ondemand) flag of - :c:func:`TIFFOpen` (which implies ``D``). - - The public :c:func:`TIFFGetStrileOffset`, - :c:func:`TIFFGetStrileOffsetWithErr`, - :c:func:`TIFFGetStrileByteCount` and - :c:func:`TIFFGetStrileByteCountWithErr` functions have been added to - API. They are of particular interest when using sparse files (with - ``offset == bytecount == 0``) and you want to detect if a strile is - present or not without decompressing the data, or updating an - existing sparse file. - -* The BigTIFF writer now optimizes file size by using 32-bit ``LONG`` - values (rather than 64-bit) where it is reasonable and safe to do - so. Likewise, the 16-bit ``SHORT`` type is used when possible for - ``StripByteCounts``/``TileByteCounts``. - - -Software configuration changes ------------------------------- - -* The ``WIN32`` build now uses :file:`tif_win32.c` when building with CMake. - -* Properly set value of :c:macro:`HOST_FILLORDER` to :c:macro:`LSB2MSB` for Windows - CMake builds. It was not being properly set! - - -Library changes ---------------- - -* Changes in the libtiff library may be viewed on-line - `Libtiff Library Commits `_.. - -* New function :c:func:`TIFFReadFromUserBuffer` which replaces the use of - :c:func:`TIFFReadEncodedStrip`/:c:func:`TIFFReadEncodedTile` when the user can - provide the buffer for the input data, for example when he wants - to avoid libtiff to read the strile offset/count values from the - ``[Strip|Tile][Offsets/ByteCounts]`` array. - -* New functions :c:func:`TIFFDeferStrileArrayWriting` and :c:func:`TIFFForceStrileArrayWriting`. - Those advanced writing functions must be used in a particular sequence - to make their intended effect. Their aim is to control when/where - the ``[Strip/Tile][Offsets/ByteCounts]`` arrays are written into the file. - - The purpose of this is to generate 'cloud-optimized geotiff' files where - the first KB of the file only contain the IFD entries without the potentially - large strile arrays. Those are written afterwards. - - -Tools changes -------------- - -* Changes in the libtiff utilities may be viewed on-line - at `Libtiff Tools Commits `_. - - -Contributed software changes ----------------------------- - -* Changes in the libtiff contrib area may be viewed on-line - at `Libtiff Contrib Commits `_. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.2.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.2.0.rst deleted file mode 100644 index e1e8d5812..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.2.0.rst +++ /dev/null @@ -1,103 +0,0 @@ -Changes in TIFF v4.2.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.2.0 (:tag:`v4.2.0`) - Previous Version :doc:`v4.1.0 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - Master HTTP Site #3 ``_ - ====================== ========================================== - -This document provides a summary of significant changes made to the -software between the *previous* and *current* versions (see -above). A fully-detailed change summary is provided by the :file:`ChangeLog` file -included in the release package and by the Git commit history: - - -Major changes -------------- - -* Optional support for using libdeflate is added. -* Many of the tools now support a memory usage limit. - - -Software configuration changes ------------------------------- - -* The Microsoft Windows 'nmake' build is resuscitated and provides - a default ``HAVE_STRTOLL`` setting in 'nmake.opt' which is suitable for - MSVC++ 14.0 ("Visual Studio 2015") and later but may be disabled in - order to compile with earlier compiler versions. - -* mingw-w64 cmake build fixes to not add libm - - -Library changes ---------------- - -* A great many issues discovered by fuzzers (via oss-fuzz and other reports) have been addressed. -* EXIF 2.32 and GPS tags and functionality have been upgraded: - - * Existing EXIF field definition of tags are upgraded to EXIF version 2.3.2 - * EXIF-GPS structure, tags and access functions are added as special ``CustomDirectory`` (like it was done for EXIF). - * Reading error for FileSource and SceneType tags corrected. - -* Make ``TIFFTAG_CFAPATTERN`` variable count. - -* Cmake configuration fixes for big-endian targets. - -* Added support for optional building against libdeflate for - faster Zip/Deflate compression/decompression. - - We now have 2 kinds of builds with the Zip/Deflate codec: - - * zlib only - * zlib + libdeflate - - Speed improvements in the 35%-50% range can be expected when libdeflate is used. - Compression level up to 12 is now supported (capped to 9 when zlib is used). - Still requires zlib for situations where libdeflate cannot be used (that - is for scanline access, since libdeflate has no streaming mode) - - Pseudo-tag ``TIFFTAG_DEFLATE_SUBCODEC=DEFLATE_SUBCODEC_ZLIB/DEFLATE_SUBCODEC_LIBDEFLATE`` - is added to control which subcodec (zlib or libdeflate) should be used (it defaults - of course to libdeflate, when it is available). - This is mostly aimed at being used on the writing side, to be able to reproduce - output of previous libtiff versions at a binary level, in situations where this would - be really needed. Or as a safety belt in case there would be unforeseen issues - with using libdeflate. - It can be used to know when libdeflate is available at runtime (``DEFLATE_SUBCODEC_LIBDEFLATE`` - will be the default value in that situation). - - Of course, deflate codestreams produced by libdeflate can be read by zlib, and vice-versa. - - -Tools changes -------------- - -* A great many issues discovered by fuzzers (via oss-fuzz and other reports) have been addressed. - -* :program:`ppm2tiff`: support any bps value from 1 to 16. - -* :program:`tiff2ps`, :program:`tiff2rgba`: A default memory limit is now enforced (256MiB) and a ``-M`` option is added to allow the user to adjust the limit. - -* :program:`tiff2pdf`, :program:`tiffcp`: A default memory limit is now enforced (256MiB) and a ``-m`` option is added to allow the user to adjust the limit. - -* :program:`tiffcrop`: A default memory limit is now enforced (256MiB) and a ``-k`` option is added to allow the user to adjust the limit. - -* :program:`tiff2pdf`: fix "raw" copy of Deflate streams. - -* :program:`tiff2pdf.c`: properly calculate datasize when saving to JPEG YCbCr - -* :program:`tiffcp`: disable strip chopping when trying to convert to JBIG compression - - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.3.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.3.0.rst deleted file mode 100644 index 0e2587757..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.3.0.rst +++ /dev/null @@ -1,85 +0,0 @@ -Changes in TIFF v4.3.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.3.0 (:tag:`v4.3.0`) - Previous Version :doc:`v4.2.0 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - Master HTTP Site #3 ``_ - ====================== ========================================== - -This document provides a summary of significant changes made to the -software between the *previous* and *current* versions (see -above). A fully-detailed change summary is provided by the :file:`ChangeLog` file -included in the release package and by the Git commit history: - -Major changes -------------- - -* Build and usage of the library and its utilities requires a C99 capable - compiler. - -* New optional codec for the LERC (Limited Error Raster Compression) compression scheme. - To have it available, configure libtiff against the SDK available at - ``_ - -* CMake build: revamp of build scripts - -Software configuration changes ------------------------------- - -* cmake: revamp of the cmake build scripts. There are impacts on the case of - some options. - -* cmake: update minimum version and policy version to 3.9. - -* Remove NMake build support. The functionality provided by the NMake build - is now completely superseded by the CMake build. - -* Remove antiquated Scons and makefile.lcc build support. - -* Remove non-functional VMS and WinCE support. - -* :file:`autogen.sh` now updates :file:`config.guess` and :file:`config.sub` from master gnulib version. - -Library changes ---------------- - -* Use of :c:type:`int8`, :c:type:`uint8`, :c:type:`int16`, :c:type:`uint16`, - :c:type:`int32`, :c:type:`uint32`, :c:type:`int64`, :c:type:`uint64` - typedefs is now deprecated. libtiff code and headers no longer use them, - and use their C99 standard equivalents (with ``_t`` suffix). Those typedefs - are still available, with deprecation warnings, but external code is strongly - encouraged to use the corresponding C99 :file:`stdint.h` types. The deprecated - types might be removed in a future release. - -* Removal of unused, or now useless due to C99 availability, functions in :file:`port/` - -* A few issues spotted by static code analysis tools fixed. Compiler - warnings addressed. - -Tools changes -------------- - -* In usage text, insert a line of text summarizing each tool's purpose - -* tiff tools: made display of compression methods and their parameters - conditional on their actual availability - -* :program:`tiff2ps`: exit the loop in case of error (#232) - -* :program:`tiff2pdf`: check that tiff_datasize fits in a signed :c:type:`tsize_t` (#202) - -* :program:`tiffsplit`: exit with :c:macro:`EXIT_FAILURE` if there are extra args on the command line - -* :program:`tiffcmp`: fix comparaison with pixels that are fractional number of bytes (#53) - -Contributed software changes ----------------------------- - -* :file:`iptcutil.c` - set ``#ifdef _WIN32`` (was ``#ifdef WIN32``, which failed at build time) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.4.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.4.0.rst deleted file mode 100644 index 22c40e1f1..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.4.0.rst +++ /dev/null @@ -1,98 +0,0 @@ -Changes in TIFF v4.4.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.4.0 (:tag:`v4.4.0`) - Previous Version :doc:`v4.3.0 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - Master HTTP Site #3 ``_ - ====================== ========================================== - -This document provides a summary of significant changes made to the -software between the *previous* and *current* versions (see -above). A fully-detailed change summary is provided by the :file:`ChangeLog` file -included in the release package and by the Git commit history: - -Major changes -------------- - -None - -Software configuration changes ------------------------------- - -* Handle absolute paths in pkg-config file (:issue:`333`) -* Correct fix for the pkgconf file relative paths. -* cmake: allow running the tests with a read-only source directory. -* cmake: Fix ``STRIPCHOP_DEFAULT`` value in CMake builds. -* build: Fix static library imports in mingw related to LERC -* Fix version in :file:`libtiff-4.pc.in`, and CMake build: Add requirements to pc file -* cmake: Fix build with CMake 3.10. -* cmake: Export tiff targets. -* Make ``LERC_SUPPORT`` conditional on ``ZLIB_SUPPORT`` - -Library changes ---------------- - -New/improved functionalities: - -* :c:func:`TIFFIsBigTiff` function added. -* Functions :c:func:`TIFFFieldSetGetSize` and :c:func:`TIFFieldSetGetCountSize` added. -* :c:func:`LZWDecode`: major speed improvements (~30% faster) -* Predictor 2 (horizontal differenciation): support 64-bit -* Support libjpeg 9d - -Bug fixes: - -* Remove incorrect assert (:issue:`329`) -* avoid hang in :c:func:`TIFFRewriteDirectory` if a classic file > 4 GB is attempted to be created -* :file:`tif_jbig.c`: fix crash when reading a file with multiple IFD in memory-mapped mode and when bit reversal is needed (fixes :issue:`385`) -* :c:func:`TIFFFetchNormalTag`: avoid calling :c:func:`memcpy` with a null source pointer and size of zero (fixes :issue:`383`) -* :c:func:`TIFFWriteDirectoryTagData`: turn assertion on data length into a runtime check -* :c:func:`TIFFFetchStripThing`: avoid calling :c:func:`memcpy` with a null source pointer and size of zero (fixes :issue:`362`) -* :c:func:`TIFFReadDirectory`: avoid calling :c:func:`memcpy` with a null source pointer and size of zero (fixes :issue:`362`) -* :c:func:`TIFFYCbCrToRGBInit`: avoid Integer-overflow -* ``TIFFGetField(TIFFTAG_STRIPBYTECOUNTS/TIFFTAG_STRIPOFFSETS)``: return error if returned pointer is NULL (fixes :issue:`342`) -* OJPEG: avoid assertion when using :c:func:`TIFFReadScanline` (fixes :issue:`337`) -* :c:func:`TIFFReadDirectory`: fix OJPEG hack (fixes :issue:`319`) -* LZW codec: fix support for strips/tiles > 2 GB on Windows -* :c:func:`TIFFAppendToStrip`: fix rewrite-in-place logic (fixes :issue:`309`) -* Fix :c:func:`TIFFRewriteDirectory` discarding directories. -* :c:func:`TIFFReadCustomDirectory`: avoid crash when reading SubjectDistance tag on a non EXIF directory (:issue:`316`) -* Fix Segmentation fault printing GPS directory if ``Altitude`` tag is present -* :file:`tif_jpeg.c`: do not emit progressive scans with mozjpeg. (:issue:`266`) -* :c:func:`_TIFFRewriteField`: fix when writing a IFD with a single tile that is a sparse one, on big endian hosts -* Fix all remaining uses of legacy Deflate compression id and warn on use. - -Tools changes -------------- - -Bug fixes: - -* :program:`tiffcrop`: Fix issue :issue:`330` and some more from 320 to 349. -* :program:`tiffcrop`: fix issue :issue:`395`: generation of strange section images. -* :program:`tiffcrop`: fix issue :issue:`380` and :issue:`382` heap buffer overflow in extractImageSection -* :program:`tiffcrop`: fix FPE (:issue:`393`) -* :program:`tiffcrop`: buffsize check formula in :c:func:`loadImage` amended (fixes :issue:`273`, :issue:`275`) -* :program:`tiffcrop.c`: Fix issue :issue:`352` heap-buffer-overflow by correcting :c:type:`uint32_t` underflow. -* :program:`tiff2pdf`: handle 8-bit palette colormap. -* :program:`tiffcp`: avoid buffer overflow in "mode" string (fixes :issue:`400`) -* :program:`tiffcp`: Fix incomprehensible setting of orientation tag (fixes :issue:`29`) -* :program:`tiffcp`: do not try to fetch compressor-specific tags when not appropriate (fixes :issue:`396`) -* :program:`tiffcp`: fix heap buffer overflow (:issue:`278`) -* :program:`tiff2ps`: In :c:func:`limitMalloc` check for negative size (fixes :issue:`284`) -* :program:`tiffinfo`: add a ``-M`` switch to define the maximum heap allocation, and default it to 256 MiB (fixes :issue:`287`, :issue:`290`) -* :program:`tiffinfo`: limit more memory allocations using ``-M`` switch (fixes :issue:`288`) -* :program:`tiffset`: fix global-buffer-overflow for ASCII tags where count is required (fixes :issue:`355`) -* :program:`raw2tiff`: check that band number if not zero to avoid floating point exception(fixes :issue:`338`) -* :program:`tiffinfo`/:program:`tiffdump`: improve output for GDAL tags. - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.5.0.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.5.0.rst deleted file mode 100644 index a287b2153..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.5.0.rst +++ /dev/null @@ -1,142 +0,0 @@ -Changes in TIFF v4.5.0 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.5.0 (:tag:`v4.5.0`) - Previous Version :doc:`v4.4.0 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - Master HTTP Site #3 ``_ - ====================== ========================================== - -This document provides a summary of significant changes made to the -software between the *previous* and *current* versions (see -above). A fully-detailed change summary is provided by the :file:`ChangeLog` file -included in the release package and by the Git commit history: - -Major changes -------------- - -* Whole code base reformatting of .c/.h files using new .clang-format format -* Documentation changed from static HTML and man pages to Restructured Text - (rst). HTML and man pages are now build artifacts. - -Software configuration changes ------------------------------- - -* SONAME version bumped to 6 due to changes in symbol versioning. -* autoconf/cmake: detect (not yet released) libjpeg-turbo 2.2 to take into - its capability of handling both 8-bit JPEG and 12-bit JPEG in a single build. -* autoconf/cmake: detect sphinx-build to build HTML and man pages -* CMakeLists.txt: fix warning with -Wdev -* CMake: correctly set default value of 'lzma' option when liblzma is detected - (:issue:`482`) -* CMake: Moved linking of CMath::CMath into CMath_LIBRARY check. -* Fix CMake build to be compatible with FetchContent. -* cmake: Correct duplicate definition of _CRT_SECURE_NO_WARNINGS (:issue:`443`) -* cmake: Fixes for Visual Studio 2022. -* Adds Requires.private generation so that pkg-config can correctly find - the dependencies of libtiff. -* Fix dependency on libm on Android -* cmake: libtiffxx is static on win32 -* Fix build in tif_lzw.c -* CMake: Add options for disabling tools, tests, contrib and docs. - -Library changes ---------------- - -New/improved functionalities: - -* Addition of an open option concept with the new functions - :c:func:`TIFFOpenExt`, :c:func:`TIFFOpenWExt`, :c:func:`TIFFFdOpenExt`, - :c:func:`TIFFClientOpenExt`, :c:func:`TIFFOpenOptionsAlloc`, - :c:func:`TIFFOpenOptionsFree` -* Leveraging above mentioned open option concept, addition of a new capability - to limit the size of a single dynamic memory allocation done - by the library with :c:func:`TIFFOpenOptionsSetMaxSingleMemAlloc` -* Leveraging above mentioned open option concept, addition of a new capability - to specify per-TIFF handle re-entrant error and warning callbacks - with :c:func:`TIFFOpenOptionsSetErrorHandlerExtR` and - :c:func:`TIFFOpenOptionsSetWarningHandlerExtR` -* Related to IFD-Loop detection refactoring, the number of IFDs that libtiff - can browse through has been extended from 65535 to 1048576. This value is - a build-time setting that can be configured with CMake's TIFF_MAX_DIR_COUNT - variable or autoconf's --with-max-dir-count option. - -API/ABI breaks: - -* tdir_t type updated to uint32_t. This type is now used for the return value of - :c:func:`TIFFCurrentDirectory` and :c:func:`TIFFNumberOfDirectories`, and - as the argument of :c:func:`TIFFSetDirectory` and :c:func:`TIFFUnlinkDirectory` - -Bug fixes: - -* TIFFWriteRawStrip(): restore capabilities to append data in the current strip - (:issue:`489`) -* _TIFFReadEncodedTileAndAllocBuffer(): avoid excessive memory allocation on - broken files (:issue:`479`) -* TIFFReadRGBATileExt(): fix (unsigned) integer overflow on strips/tiles > 2 GB - (oss-fuzz #53137) -* Replace sprintf calls with snprintf to fix warnings on macOS 13 SDK -* Added warning messages for FIELD_IGNORE tags for writing and for - TIFF_SETGET_UNDEFINED for reading added. (:issue:`438`) -* tif_dirinfo.c: fix TIFFTAG_CLIPPATH tag declaration (:issue:`439`) -* tif_dirinfo.c: fix TIFFTAG_COMPRESSION and _BITSPERSAMPLE tag declaration - (:issue:`364`) -* Revised handling of TIFFTAG_INKNAMES and related TIFFTAG_NUMBEROFINKS value - (:issue:`149`, :issue:`150`, :issue:`152`, :issue:`168`, :issue:`250`, - :issue:`269`,:issue:`398`, CVE-2022-3599, :issue:`456`) -* TIFFAdvanceDirectory(): fix unsigned-integer-overflow in mapped case - (oss-fuzz #52309) -* Improved/fixes IFD-Loop Handling (:issue:`455`). -* Update getimage to support large raster images. -* Presetting of default tag values extended (e.g. PlanarConfig). (:issue:`449`) -* Deal with RichTIFFIPTC tag written with LONG type (:issue:`225`) -* TIFFSetValue(): Writing IFD8 & LONG8 tags to ClassicTIFF corrected - (:issue:`442`) -* tif_jpeg.c: allow to pass -DEXPECTED_JPEG_LIB_VERSION=number to do optional - compile-time version check -* TIFFReadFromUserBuffer(): fix clearing of TIFF_CODERSETUP flag that could - cause issues with reading JPEG compressed files -* _TIFFCheckFieldIsValidForCodec(): return FALSE when passed a codec-specific - tag and the codec is not configured (:issue:`433`, :issue:`486`, - CVE-2022-34526) -* Add basic 16 bit cielab support. -* WEBP codec: avoid temporary buffer and memcpy() on whole tile/strip decoding -* tif_predict.c: make horAcc8() work with icc (ICC) 2021.6.0 20220226 -O2 - -Tools changes -------------- - -New/improved functionality: - -* :program:`tiffinfo`: Updated to parse through SubIFDs and show their tags. - -Bug fixes: - -* :program:`tiffcrop`: add check if (bps != 1) in writeSingleSection() - (:issue:`169`) -* :program:`tiffcrop`: Fix too many 'mode' options on command line - (:issue:`470` and :issue:`450`) -* :program:`tiffcrop`: Fix memory allocation to require a larger buffer - (:issue:`271`, :issue:`381`, :issue:`386`, :issue:`388`, :issue:`389`, - :issue:`435`, CVE-2022-3570, CVE-2022-3598) -* :program:`tiffcrop`: disable incompatibility of -Z, -X, -Y, -z options with - any PAGE_MODE_x option (:issue:`411`, CVE-2022-3627, :issue:`413`, - CVE-2022-3597, :issue:`426`, CVE-2022-3626) -* :program:`tiffcrop`: -S option mutually exclusive (:issue:`349`, - :issue:`414`, :issue:`422`, :issue:`423`, :issue:`424`) -* :program:`tiffcrop`: fix floating-point exception (:issue:`415`, - :issue:`427`, :issue:`428`, CVE-2022-2056, CVE-2022-2057, CVE-2022-2058) -* :program:`tiff2pdf`: Don't try to seek into stdout (:issue:`441`) -* :program:`tiffinfo`: update curdir from uint16_t to tdir_t for more than 64k - IFD handling. - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.5.1.rst b/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.5.1.rst deleted file mode 100644 index 3496dccf3..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/releases/v4.5.1.rst +++ /dev/null @@ -1,177 +0,0 @@ -Changes in TIFF v4.5.1 -====================== - -.. table:: References - :widths: auto - - ====================== ========================================== - Current Version v4.5.1 (:tag:`v4.5.1`) - Previous Version :doc:`v4.5.0 ` - Master Download Site ``_ - Master HTTP Site #1 ``_ - Master HTTP Site #2 ``_ - Master HTTP Site #3 ``_ - ====================== ========================================== - -This document provides a summary of significant changes made to the -software between the *previous* and *current* versions (see -above). A fully-detailed change summary is provided by the :file:`ChangeLog` file -included in the release package and by the Git commit history: - -.. warning:: - - This version will be the last one supporting most TIFF tools (except tiffinfo, - tiffdump, tiffcp and tiffset), whose maintenance will be discontinued, due - to the lack of contributors able to address reported security issues. - Starting with libtiff v4.6.0, their source code, at this time ,will still be - available in the source distribution, but they will no longer be built by - default, and issues related to them will no longer be accepted in the - libtiff bug tracker. - -Major changes -------------- - -None - -Software configuration changes ------------------------------- - -* Definition of tags reformatted (clang-format off) for better - readability of tag comments in tiff.h and tif_dirinfo.c - -* Do not install libtiff-4.pc when tiff-install is reset. - -* Add versioninfo resource files for DLL and tools - compiled with Windows MSVC and MINGW. - -* Disable clang-formatting for tif_config.h.cmake.in and - tiffconf.h.cmake.in because sensitive for CMake scripts. - -* CMake: make WebP component name compatible with upstream ConfigWebP.cmake - -* CMake: make Findliblzma with upstream CMake config file - -* CMake: FindDeflate.cmake: fix several errors (:issue:`526`). - -* CMake: FindLERC.cmake: version string return added. - -* CMake: export TiffConfig.cmake and TiffConfigVersion.cmake files - -* CMake: fix export of INTERFACE_INCLUDE_DIRECTORIES - -Library changes ---------------- - -New/improved functionalities: - -* Hardcode HOST_FILLORDER to FILLORDER_LSB2MSB and make 'H' flag of - :c:func:`TIFFOpen` to warn and an alias of FILLORDER_MSB2LSB. - :file:`tif_lerc.c`: use WORDS_BIGENDIAN instead of HOST_BIGENDIAN. - -* Optimize relative seeking within :c:func:`TIFFSetDirectory` - by using the learned list of IFD offsets. - -* Improve internal IFD offset and directory number map handling. - -* Behavior of :c:func:`TIFFOpen` mode "r+" in the Windows implementation - adjusted to that of Linux. - -API/ABI breaks: - -* None - -Bug fixes: - -* TIFFDirectory td_fieldsset type changed from unsigned long, which can - be 32 or 64 bits, to uint32_t (fixes :issue:`484`). - -* tif_ojpeg.c: checking for division by zero (fixes :issue:`554`). - -* LZWDecode(): avoid crash when trying to read again from a strip whith - a missing end-of-information marker (fixes :issue:`548`). - -* Fixed runtime error: applying zero offset to null pointer - in :c:func:`countInkNamesString`. - -* Fixing crash in :c:func:`TIFFUnlinkDirectory` when called with - directory number zero ("TIFFUnlinkDirectory(**0**)") as well as fixing - incorrect behaviour when unlinking the first directory. - -* tif_luv: check and correct for NaN data in :c:func:`uv_encode` - (:issue:`530`). - -* :c:func:`TIFFClose` avoid NULL pointer dereferencing - (:issue:`515`). - -* tif_hash_set.c: include tif_hash_set.h after tif_config.h - to let a chance for GDAL symbol renaming trick. - -* Fax3: fix failure to decode some fax3 number_of_images - and add test for Fax3 decoding issues - (:issue:`513`). - -* :c:func:`TIFFSetDirectory` and :c:func:`TIFFWriteDirectorySec` - avoid harmless unsigned-integer-overflow - (due to gdal oss-fuzz #54311 and #54343). - -* :file:`tif_ojpeg.c`: fix :issue:`554` by checking for division by zero - in OJPEGWriteHeaderInfo(). - -* LZWDecode(): avoid crash when trying to read again from a strip whith - a missing end-of-information marker (:issue:`548`). - -Documentation -------------- - -* mention TIFFSetTagExtender() cannot add tags to custom directories. - -* manpage: add multi page TIFF and SubIFDs description and read / write example. - -Tools changes -------------- - -New/improved functionality: - -* None - -Bug fixes: - -* :program:`tiffcrop`: Consider error return of writeSelections() (fixes :issue:`553`). - -* :program:`tiffcrop`: fix memory leak - (:issue:`475`). - -* :program:`tiffcrop`: do not reuse input buffer for subsequent images - (:issue:`527`). - -* :program:`tiffcrop`: Amend rotateImage() not to toggle the input - (main) image width and length parameters when only cropped image - sections are rotated. Remove buffptr from region structure - because never used. Fixes - :issue:`492`, :issue:`493`, :issue:`494`, :issue:`495`, - :issue:`499`, :issue:`518`, :issue:`519`. - -* :program:`tiffcrop`: correctly update buffersize after rotateImage() - (:issue:`520`). - -* :program:`tiffcrop`: added check for assumption on composite images. Fixes - :issue:`496`, :issue:`497`, :issue:`498`, :issue:`500`, :issue:`501`. - -* :program:`tiffmedian`: avoid zero num_colors - (:issue:`477`). - -* :program:`fax2ps`: fix buffer overflow in qsort function pcompar - (:issue:`475`). - -* :program:`tiffset`: get filesize to allocate only the required memory - (:issue:`241`). - -* :program:`tiffcrop`: fix :issue:`553` by considering error return of writeSelections(). - -* tif_ovrcache.c: check :c:func:`TIFFSetSubDirectory` return value (CID 1524573). - - -Contributed software changes ----------------------------- - -None diff --git a/thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiff.rst b/thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiff.rst deleted file mode 100644 index 9c48968ff..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiff.rst +++ /dev/null @@ -1,90 +0,0 @@ -BigTIFF Design -============== - - -This design details a 64-bit (larger than 4GB) TIFF format specification. -The design is based on a proposal by Steve Carlsen of Adobe, with input -from various other parties. - - -Briefly -------- - -* Version = 43 -* 8-byte offset to first IFD -* Value/Offset fields are 8 bytes -* 8-byte offset to the next IFD -* add ``TIFFType`` of ``LONG8``, an 8 byte (unsigned) int -* ``StripOffsets`` and ``TileOffsets`` and ``ByteCounts`` can be LONG8 - - -More Detail ------------ - -* The Version ID, in header bytes 2-3, formerly decimal 42, now changes to **43** -* Header bytes 4-5 contain the decimal number **8**. - - * If there is some other number here, a reader should give up. - * This is to provide a nice way to move to 16-byte pointers some day. - -* Header bytes 6-7 are reserved and must be **zero**. - - * If they're not, a reader should give up. - -* Header bytes 8-15 contain the 8-byte offset to the first IFD. -* Value/Offset fields are 8 bytes long, and take up bytes 8-15 in an IFD entry. - - * If the value is ≤ 8 bytes, it must be stored in the field. - * All values must begin at an 8-byte-aligned address. - -* 8-byte offset to the Next_IFD, at the end of an IFD. -* To keep IFD entries 8-byte-aligned, we begin with an 8-byte (instead of 2-byte) count of the number of directory entries. -* Add ``TIFFTypes`` of ``LONG8`` (= 16), an 8 byte (unsigned) int, and ``SLONG8`` (= 17). -* Add ``TIFFType`` ``IFD8`` (=18) an 8byte IFD offset. -* ``StripOffsets`` and ``TileOffsets`` and ``ByteCounts`` may be ``LONG8`` or the traditionally allowed ``LONG`` or ``SHORT``. - -* The proposed extension is :file:`.tf8`, and call it "8-Byte TIFF". - - Otherwise, it's just like "original TIFF." ("TIFF Classic?") - - -Open Issues ------------ - -* What to call the new format - - * ChrisCox -- I don't think end users will understand what "8-byte TIFF" means - * AndreyKiselev - 23 Sep 2004 -- What about TIFF64? "64" is a widely used buzzword and should be directly associated with the 64-bit offsets and 64-bit architectures. - -* What 3 character file extension to use (gotta be DOS compatible) -* What 4 character file type to use (for Macintosh) -* What MIME type to use - - -Samples -------- - -`Example files `_ -from Joris Van Damme. - - -Changes -------- - -* ``TIFFType`` 13 is ``ttIFD``, 14 is assigned to ``ttUnicode``, and 15 is assigned to ``ttComplex``. So, I changed the types for ``ttLong8`` and ``ttSLong8`` to 16 and 17, respectively. - - * AndreyKiselev - 23 Sep 2004 -- Where are these fields defined? Is there any new Technical Note or something? And what is encoding behind the word "Unicode"? - * ChrisCox - 27 Sep 2004 -- They are in the Adobe TIFF definitions. I am still working on releasing updated TIFF documentation. - -* Added list of open issues. -* settle on version 43 -* cleanup -* ``TIFFType`` 18 (8 byte IFD) added. - -* Clarified that fields which may be ``LONG8`` can also be one of the old supported types. - - -See also --------- - -`AWare Systems' informal overview of the BigTIFF proposal `_. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/specification/coverage-bigtiff.rst b/thirdparty/SDL2_image/external/libtiff/doc/specification/coverage-bigtiff.rst deleted file mode 100644 index 20e3497f6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/specification/coverage-bigtiff.rst +++ /dev/null @@ -1,58 +0,0 @@ -LibTIFF Coverage of the BigTIFF Specification -============================================= - -Since LibTIFF version 4.0.0, the BigTIFF format specification has been implemented within LibTIFF. -BigTIFF is a backward-compatible extension to the `TIFF `_ -file format. - -BigTIFF logically extends the original TIFF file format (referred to as 'ClassicTIFF' from now on). -The BigTIFF specification is the result of work by a variety of parties on the LibTIFF mailing list, including -the then current LibTIFF maintainers, Joris Van Damme and Adobe staff. The BigTIFF specification has not yet -been officially approved by the TIFF specification owner (Adobe), but implementation within LibTIFF -could accelerate that process. For more information on the BigTIFF file format, we recommend AWare Systems' -`BigTIFF page `_. - -BigTIFF is especially useful for people and vendors that are confronted with very large images, and -still seek to use an open, simple, and extendable format. This requirement is frequently encountered in the -geospatial field, but also concerns large format scanners, medical imaging and other fields. - -The LibTiff BigTIFF support was made possible by four sponsors funding the project. The programming work was -primarily done by `Joris Van Damme (AWare Systems) `_. -The sponsors for the BigTIFF support work in LibTIFF, in alphabetical order: - -.. list-table:: Sponsors - :widths: 5 20 - :header-rows: 0 - - * - .. image:: bigtiffpr_images/esri.png - :width: 100% - :alt: ESRI - - `ESRI `_ has been giving customers around the world the power to - think and plan geographically since 1969. As the leader in GIS, ESRI applies innovative technologies to help - organizations create, analyze, and visualize information for more informed decisions. Running on more than - a million desktops and thousands of servers, ESRI applications are the foundation of the world's mapping and - spatial analysis infrastructure. - * - .. image:: bigtiffpr_images/leica.png - :width: 100% - :alt: Leica Geosystems Geospatial Imaging - - `Leica Geosystems Geospatial Imaging `_ offers a - range of workflow solutions for photogrammetry, mapping, remote sensing, catalog management and exploitation - of geospatial imagery. Enterprise organizations use this imagery as the basis for generating information for - both education and decision making processes. Those who use Leica Geosystems products every day trust them - for their precision, seamless integration, interoperability and superior customer support. - * - .. image:: bigtiffpr_images/safe.png - :width: 100% - :alt: Safe Software - - `Safe Software `_ is the maker of FME, a powerful spatial ETL (Extract, - Transform and Load) tool that enables true data interoperability. FME manages the translation, - transformation, integration and web-based distribution of geospatial data in 200 GIS, CAD, raster and - database formats. Safe Software's FME technology is also embedded in numerous market-leading GIS and - ETL applications. - * - .. image:: bigtiffpr_images/weogeo.png - :width: 100% - :alt: WeoGeo - - `WeoGeo `_ is a web-based data management resource for the geospatial - industry that allows the free market exchange of mapping related imagery products, featuring an innovative - solution that efficiently manages digital mapping files of any size. With an intuitive user interface - and the scalable power of Amazon Web Services (AWS), geospatial professionals can view, sort, search, - and share complex, high volume maps quickly and effectively. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/specification/coverage.rst b/thirdparty/SDL2_image/external/libtiff/doc/specification/coverage.rst deleted file mode 100644 index fa5c06d82..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/specification/coverage.rst +++ /dev/null @@ -1,1690 +0,0 @@ -LibTIFF Coverage of the TIFF 6.0 Specification -============================================== - -The library is capable of dealing with images that are written to -follow the 5.0 or 6.0 TIFF spec. There is also considerable support -for some of the more esoteric portions of the 6.0 TIFF spec. - -Baseline --------- - -.. list-table:: Core requirements - :widths: 5 20 - :header-rows: 0 - - * - Core requirements - - Both ``MM`` and ``II`` byte orders are handled. - Both packed and separated planar configuration of samples. - Any number of samples per pixel (memory permitting). - Any image width and height (memory permitting). - Multiple subfiles can be read and written. - Editing is **not** supported in that related subfiles (e.g. - a reduced resolution version of an image) are not automatically - updated. - - Tags handled: ``ExtraSamples``, ``ImageWidth``, - ``ImageLength``, ``NewSubfileType``, ``ResolutionUnit``. - ``Rowsperstrip``, ``StripOffsets``, ``StripByteCounts``, - ``XResolution``, ``YResolution`` - - * - Tiled Images - - ``TileWidth``, ``TileLength``, ``TileOffsets``, - ``TileByteCounts`` - - * - Image Colorimetry Information - - ``WhitePoint``, ``PrimaryChromaticities``, ``TransferFunction``, - ``ReferenceBlackWhite`` - - * - Class B for bilevel images - - ``SamplesPerPixel`` = 1 - - ``BitsPerSample`` = 1 - - ``Compression`` = 1 (none), 2 (CCITT 1D), or 32773 (PackBits) - - ``PhotometricInterpretation`` = 0 (Min-is-White), 1 (Min-is-Black) - - * - Class G for grayscale images - - ``SamplesPerPixel`` = 1 - - ``BitsPerSample`` = 4, 8 - - ``Compression`` = 1 (none) 5 (LZW) - - ``PhotometricInterpretation`` = 0 (Min-is-White), 1 (Min-is-Black) - - * - Class P for palette color images - - ``SamplesPerPixel`` = 1 - - ``BitsPerSample`` = 1-8 - - ``Compression`` = 1 (none) 5 (LZW) - - ``PhotometricInterpretation`` = 3 (Palette RGB) - - ``ColorMap`` - - * - Class R for RGB full color images - - ``SamplesPerPixel`` = 3 - - ``BitsPerSample`` = <8,8,8> - - ``PlanarConfiguration`` = 1, 2 - - ``Compression`` = 1 (none) 5 (LZW) - - ``PhotometricInterpretation`` = 2 (RGB) - - * - Class F for facsimile - - (*Class B tags plus...*) - - ``Compression`` = 3 (CCITT Group 3), 4 (CCITT Group 4) - - ``FillOrder`` = 1 (MSB), 2 (LSB) - - ``Group3Options`` = 1 (2d encoding), 4 (zero fill), 5 (2d+fill) - - ``ImageWidth`` = 1728, 2048, 2482 - - ``NewSubFileType`` = 2 - - ``ResolutionUnit`` = 2 (Inch), 3 (Centimeter) - - ``PageNumber``, - ``XResolution``, - ``YResolution``, - ``Software``, - ``BadFaxLines``, - ``CleanFaxData``, - ``ConsecutiveBadFaxLines``, - ``DateTime``, - ``DocumentName``, - ``ImageDescription``, - ``Orientation`` - - * - Class S for separated images - - ``SamplesPerPixel`` = 4 - - ``PlanarConfiguration`` = 1, 2 - - ``Compression`` = 1 (none), 5 (LZW) - - ``PhotometricInterpretation`` = 5 (Separated) - - ``InkSet`` = 1 (CMYK) - - ``DotRange``, - ``InkNames``, - ``DotRange``, - ``TargetPrinter`` - - * - Class Y for YCbCr images - - ``SamplesPerPixel`` = 3 - - ``BitsPerSample`` = <8,8,8> - - ``PlanarConfiguration`` = 1, 2 - - ``Compression`` = 1 (none), 5 (LZW), 7 (JPEG) - - ``PhotometricInterpretation`` = 6 (YCbCr) - - ``YCbCrCoefficients``, - ``YCbCrSubsampling``, - ``YCbCrPositioning`` - - (*colorimetry info from Appendix H; see above*) - - * - Class "JPEG" for JPEG images (per TTN2) - - ``PhotometricInterpretation`` = 1 (grayscale), 2 (RGB), 5 (CMYK), 6 (YCbCr) - - (*Class Y tags if YCbCr*) - - (*Class S tags if CMYK*) - - ``Compression`` = 7 (JPEG) - -In addition, the library supports some optional compression algorithms -that are, in some cases, of dubious value. - -.. list-table:: Compression algorithms - :widths: 5 20 - :header-rows: 1 - - * - Compression tag value - - Compression algorithm - * - 32766 - - NeXT 2-bit encoding - * - 32809 - - ThunderScan 4-bit encoding - * - 32909 - - Pixar companded 11-bit ZIP encoding - * - 32946 - - PKZIP-style Deflate encoding (experimental) - * - 34676 - - SGI 32-bit Log Luminance encoding (experimental) - * - 34677 - - SGI 24-bit Log Luminance encoding (experimental) - -Note that there is no support for the JPEG-related tags defined -in the 6.0 specification; the JPEG support is based on the post-6.0 -proposal given in TIFF Technical Note #2. - -.. note:: - - For more information on the experimental Log Luminance encoding - consult the materials available at - http://www.anyhere.com/gward/pixformat/tiffluv.html. - -The following table shows the tags that are recognized -and how they are used by the library. If no use is indicated, -then the library reads and writes the tag, but does not use it internally. -For the meaning of the tags look in https://www.awaresystems.be/imaging/tiff/tifftags.html - -:file:`libtiff` supports also many private tags allocated for organizations that wish to -store additional information in a TIFF file. -Tags for TIFF/EP and for Digital Negative (DNG) Specification 1.1.0 -are included. - -Note that some tags are meaningful only when a particular -compression scheme is being used; e.g. ``Group3Options`` -is only useful if ``Compression`` -is set to CCITT Group 3 encoding. -Tags of this sort are considered *codec-specific* -tags and the library does not recognize them except when the -``Compression`` -tag has been previously set to the relevant compression scheme. - -Tags Recognized by LibTIFF --------------------------- - -.. list-table:: Tags used by libtiff - :widths: 5 1 1 5 - :header-rows: 1 - - * - Tag Name - - Value - - R/W< - - Library's Use (Comments) - - * - ``SubfileType`` - - 254 - - R/W - - none (also known as ``NewSubfileType``) - - * - ``OldSubfileType`` - - 255 - - R/W - - parsed but ignored (also known as ``SubFileType``) - - * - ``ImageWidth`` - - 256 - - R/W - - lots - - * - ``ImageLength`` - - 257 - - R/W - - lots - - * - ``BitsPerSample`` - - 258 - - R/W - - lots - - * - ``Compression`` - - 259 - - R/W - - to select appropriate codec - - * - ``PhotometricInterpretation`` - - 262 - - R/W - - lots - - * - ``Thresholding`` - - 263 - - R/W - - (tag in tif.h wrongly written as "Threshholding") - - * - ``CellWidth`` - - 264 - - R/W - - - - * - ``CellLength`` - - 265 - - R/W - - - - * - ``FillOrder`` - - 266 - - R/W - - control bit order - - * - ``DocumentName`` - - 269 - - R/W - - - - * - ``ImageDescription`` - - 270 - - R/W - - - - * - ``Make`` - - 271 - - R/W - - - - * - ``Model`` - - 272 - - R/W - - - - * - ``StripOffsets`` - - 273 - - R/W - - data i/o - - * - ``Orientation`` - - 274 - - R/W - - - - * - ``SamplesPerPixel`` - - 277 - - R/W - - lots - - * - ``RowsPerStrip`` - - 278 - - R/W - - data i/o - - * - ``StripByteCounts`` - - 279 - - R/W - - data i/o - - * - ``MinSampleValue`` - - 280 - - R/W - - - - * - ``MaxSampleValue`` - - 281 - - R/W - - - - * - ``XResolution`` - - 282 - - R/W - - - - * - ``YResolution`` - - 283 - - R/W - - used by Group 3 2d encoder - - * - ``PlanarConfiguration`` - - 284 - - R/W - - data i/o - - * - ``PageName`` - - 285 - - R/W - - - - * - ``XPosition`` - - 286 - - R/W - - - - * - ``YPosition`` - - 287 - - R/W - - - - * - ``FreeOffsets`` - - 288 - - R/W - - parsed but ignored - - * - ``FreeByteCounts`` - - 289 - - R/W - - parsed but ignored - - * - ``GrayResponseUnit`` - - 290 - - R/W - - parsed but ignored - - * - ``GrayResponseCurve`` - - 291 - - R/W - - parsed but ignored - - * - ``ResolutionUnit`` - - 296 - - R/W - - used by Group 3 2d encoder - - * - ``PageNumber`` - - 297 - - R/W - - - - * - ``ColorResponseUnit`` - - 300 - - R/W - - parsed but ignored - - * - ``TransferFunction`` - - 301 - - R/W - - - - * - ``Software`` - - 305 - - R/W - - - - * - ``DateTime`` - - 306 - - R/W - - - - * - ``Artist`` - - 315 - - R/W - - - - * - ``HostComputer`` - - 316 - - R/W - - - - * - ``WhitePoint`` - - 318 - - R/W - - - - * - ``PrimaryChromaticities`` - - 319 - - R/W - - - - * - ``ColorMap`` - - 320 - - R/W - - - - * - ``HalftoneHints`` - - 321 - - R/W - - - - * - ``TileWidth`` - - 322 - - R/W - - data i/o - - * - ``TileLength`` - - 323 - - R/W - - data i/o - - * - ``TileOffsets`` - - 324 - - R/W - - data i/o - - * - ``TileByteCounts`` - - 325 - - R/W - - data i/o - - * - ``SubIFD`` - - 330 - - R/W - - subimage descriptor support - - * - ``InkSet`` - - 332 - - R/W - - - - * - ``InkNames`` - - 333 - - R/W - - - - * - ``NumberOfInks`` - - 334 - - R/W - - - - * - ``DotRange`` - - 336 - - R/W - - - - * - ``TargetPrinter`` - - 337 - - R/W - - - - * - ``ExtraSamples`` - - 338 - - R/W - - lots - - * - ``SampleFormat`` - - 339 - - R/W - - - - * - ``SMinSampleValue`` - - 340 - - R/W - - - - * - ``SMaxSampleValue`` - - 341 - - R/W - - - - * - ``ClipPath`` - - 343 - - R/W - - - - * - ``XClipPathUnits`` - - 344 - - R/W - - - - * - ``YClipPathUnits`` - - 345 - - R/W - - - - * - ``YCbCrCoefficients`` - - 529 - - R/W - - used by ``TIFFReadRGBAImage`` support - - * - ``YCbCrSubsampling`` - - 530 - - R/W - - tile / strip size calculations - - * - ``YCbCrPositioning`` - - 531 - - R/W - - - - * - ``ReferenceBlackWhite`` - - 532 - - R/W - - - - * - ``XMLPacket`` - - 700 - - R/W - - - - * - ``Matteing`` - - 32995 - - R - - none (obsoleted by ``ExtraSamples`` tag) - - * - ``DataType`` - - 32996 - - R - - none (obsoleted by ``SampleFormat`` tag) - - * - ``ImageDepth`` - - 32997 - - R/W - - tile / strip size calculations - - * - ``TileDepth`` - - 32998 - - R/W - - tile / strip size calculations - - * - ``ImageFullWidth`` - - 33300 - - R/W - - - - * - ``ImageFullLength`` - - 33301 - - R/W - - - - * - ``TextureFormat`` - - 33302 - - R/W - - - - * - ``TextureWrapModes`` - - 33303 - - R/W - - - - * - ``FieldOfViewCotangent`` - - 33304 - - R/W - - - - * - ``MatrixWorldToScreen`` - - 33305 - - R/W - - - - * - ``MatrixWorldToCamera`` - - 33306 - - R/W - - - - * - ``Copyright`` - - 33432 - - R/W - - - - * - ``RichTIFFIPTC`` - - 33723 - - R/W - - (also known as TIFF/EP IPTC/NAA; - :file:`libtiff` type is UNDEFINED or BYTE, - but often times incorrectly specified as LONG, - because TIFF/EP (ISO/DIS 12234-2) specifies type LONG or ASCII) - - * - ``Photoshop`` - - 34377 - - R/W - - - - * - ``EXIFIFDOffset`` - - 34665 - - R/W - - - - * - ``ICC Profile`` - - 34675 - - R/W - - - - * - ``GPSIFDOffset`` - - 34853 - - R/W - - - - * - ``FaxRecvParams`` - - 34908 - - R/W - - - - * - ``FaxSubAddress`` - - 34909 - - R/W - - - - * - ``FaxRecvTime`` - - 34910 - - R/W - - - - * - ``FaxDcs`` - - 34911 - - R/W - - - - * - ``StoNits`` - - 37439 - - R/W - - - - * - ``Adobe Photoshop Document Data Block`` - - 37724 - - R/W - - - - * - ``InteroperabilityIFDOffset`` - - 40965 - - R/W - - - - * - ``DNGVersion`` - - 50706 - - R/W - - DNG 1.0 tags - - * - ``DNGBackwardVersion`` - - 50707 - - R/W - - - - * - ``UniqueCameraModel`` - - 50708 - - R/W - - - - * - ``LocalizedCameraModel`` - - 50709 - - R/W - - - - * - ``CFAPlaneColor`` - - 50710 - - R/W - - - - * - ``CFALayout`` - - 50711 - - R/W - - - - * - ``LinearizationTable`` - - 50712 - - R/W - - - - * - ``BlackLevelRepeatDim`` - - 50713 - - R/W - - - - * - ``BlackLevel`` - - 50714 - - R/W - - - - * - ``BlackLevelDeltaH`` - - 50715 - - R/W - - - - * - ``BlackLevelDeltaV`` - - 50716 - - R/W - - - - * - ``WhiteLevel`` - - 50717 - - R/W - - - - * - ``DefaultScale`` - - 50718 - - R/W - - - - * - ``DefaultCropOrigin`` - - 50719 - - R/W - - - - * - ``DefaultCropSize`` - - 50720 - - R/W - - - - * - ``ColorMatrix1`` - - 50721 - - R/W - - - - * - ``ColorMatrix2`` - - 50722 - - R/W - - - - * - ``CameraCalibration1`` - - 50723 - - R/W - - - - * - ``CameraCalibration2`` - - 50724 - - R/W - - - - * - ``ReductionMatrix1`` - - 50725 - - R/W - - - - * - ``ReductionMatrix2`` - - 50726 - - R/W - - - - * - ``AnalogBalance`` - - 50727 - - R/W - - - - * - ``AsShotNeutral`` - - 50728 - - R/W - - - - * - ``AsShotWhiteXY`` - - 50729 - - R/W - - - - * - ``BaselineExposure`` - - 50730 - - R/W - - - - * - ``BaselineNoise`` - - 50731 - - R/W - - - - * - ``BaselineSharpness`` - - 50732 - - R/W - - - - * - ``BayerGreenSplit`` - - 50733 - - R/W - - - - * - ``LinearResponseLimit`` - - 50734 - - R/W - - - - * - ``CameraSerialNumber`` - - 50735 - - R/W - - - - * - ``LensInfo`` - - 50736 - - R/W - - - - * - ``ChromaBlurRadius`` - - 50737 - - R/W - - - - * - ``AntiAliasStrength`` - - 50738 - - R/W - - - - * - ``ShadowScale`` - - 50739 - - R/W - - - - * - ``DNGPrivateData`` - - 50740 - - R/W - - - - * - ``MakerNoteSafety`` - - 50741 - - R/W - - - - * - ``CalibrationIlluminant1`` - - 50778 - - R/W - - - - * - ``CalibrationIlluminant2`` - - 50779 - - R/W - - - - * - ``BestQualityScale`` - - 50780 - - R/W - - - - * - ``RawDataUniqueID`` - - 50781 - - R/W - - - - * - ``OriginalRawFileName`` - - 50827 - - R/W - - - - * - ``OriginalRawFileData`` - - 50828 - - R/W - - - - * - ``ActiveArea`` - - 50829 - - R/W - - - - * - ``MaskedAreas`` - - 50830 - - R/W - - - - * - ``AsShotICCProfile`` - - 50831 - - R/W - - - - * - ``AsShotPreProfileMatrix`` - - 50832 - - R/W - - - - * - ``CurrentICCProfile`` - - 50833 - - R/W - - - - * - ``CurrentPreProfileMatrix`` - - 50834 - - R/W - - - - * - ``PerSample`` - - 65563 - - R/W - - (only internal pseudo tag) - - * - ``Indexed`` - - 346 - - R/W - - TIFF/FX tags - - * - ``GlobalParametersIFD`` - - 400 - - R/W - - - - * - ``ProfileType`` - - 401 - - R/W - - - - * - ``FaxProfile`` - - 402 - - R/W - - - - * - ``CodingMethods`` - - 403 - - R/W - - - - * - ``VersionYear`` - - 404 - - R/W - - - - * - ``ModeNumber`` - - 405 - - R/W - - - - * - ``Decode`` - - 433 - - R/W - - - - * - ``ImageBaseColor`` - - 434 - - R/W - - - - * - ``T82Options`` - - 435 - - R/W - - - - * - ``StripRowCounts`` - - 559 - - R/W - - part of RFC 2301 for fax - - * - ``ImageLayer`` - - 34732 - - R/W - - - -The ``Matteing`` and ``DataType`` -tags have been obsoleted by the 6.0 -``ExtraSamples`` and ``SampleFormat`` tags. -Consult the documentation on the -``ExtraSamples`` tag and Associated Alpha for elaboration. Note however -that if you use Associated Alpha, you are expected to save data that is -pre-multipled by Alpha. If this means nothing to you, check out -Porter & Duff's paper in the '84 SIGGRAPH proceedings: "Compositing Digital -Images". - -Tag ``RichTIFFIPTC`` (33723) is defined wrongly in TIFF/EP definition as "LONG or ASCII". -``libtiff`` defines it as "UNDEFINED or BYTE". - -The ``ImageDepth`` -tag is a non-standard, but registered tag that specifies -the Z-dimension of volumetric data. The combination of ``ImageWidth``, -``ImageLength``, and ``ImageDepth``, -defines a 3D volume of pixels that are -further specified by ``BitsPerSample`` and -``SamplesPerPixel``. The ``TileDepth`` -tag (also non-standard, but registered) can be used to specified a -subvolume "tiling" of a volume of data. - -The Colorimetry, and CMYK tags are additions that appear in TIFF 6.0. -Consult the TIFF 6.0 specification and :doc:`index`. - -Codecs / Compression --------------------- - -The following tags are used by codecs. - -.. list-table:: Codec / Compression Tags used by libtiff - :widths: 5 1 1 5 - :header-rows: 1 - - * - Tag Name - - Value - - R/W< - - Library's Use (Comments) - - * - ``Predictor`` - - 317 - - R/W - - LZW codec - - * - ``JPEGTables`` - - 347 - - R/W - - JPEG - - * - ``JpegInterchangeFormat`` - - 513 - - R/W - - OJPEG - - * - ``JpegInterchangeFormatLength`` - - 514 - - R/W - - OJPEG - - * - ``JpegQTables`` - - 519 - - R/W - - OJPEG - - * - ``JpegDcTables`` - - 520 - - R/W - - OJPEG - - * - ``JpegAcTables`` - - 521 - - R/W - - OJPEG - - * - ``JpegProc`` - - 512 - - R/W - - OJPEG - - * - ``JpegRestartInterval`` - - 515 - - R/W - - OJPEG - - * - ``BadFaxLines`` - - 326 - - R/W - - CCITT / fax - - * - ``CleanFaxData`` - - 327 - - R/W - - CCITT / fax - - * - ``ConsecutiveBadFaxLines`` - - 328 - - R/W - - CCITT / fax - - * - ``Group3Options`` - - 292 - - R/W - - CCITT / fax - - * - ``Group4Options`` - - 293 - - R/W - - CCITT / fax - - * - ``LercParameters`` - - 50674 - - R/W - - LERC - -Note: This *codec-specific* -tags and the library does not recognize them except when the -``Compression`` -tag has been previously set to the relevant compression scheme. - -The JPEG-related tag is specified in -:doc:`technote2`, which defines -a revised JPEG-in-TIFF scheme (revised over the appendix that was -part of the TIFF 6.0 specification). - -EXIF / GPS Custom IFDs ----------------------- - -In addition to the standard TIFF tags, :file:`libtiff` has predefined IFDs -(image file directories) with the tags for EXIF (version 2.32) and EXIF-GPS -as custom directories. -For reading / writing of this IFDs refer to :doc:`/functions/TIFFCustomDirectory`. - -EXIF Custom Tags -................ - -.. list-table:: EXIF 2.32 Tags used by libtiff - :widths: 5 1 1 5 - :header-rows: 1 - - * - Tag Name - - Value - - R/W< - - Library's Use (Comments) - - * - ``ExposureTime`` - - 33434 - - R/W - - - - * - ``FNumber`` - - 33437 - - R/W - - - - * - ``ExposureProgram`` - - 34850 - - R/W - - - - * - ``SpectralSensitivity`` - - 34852 - - R/W - - - - * - ``ISOSpeedRatings`` - - 34855 - - R/W - - After EXIF 2.2.1 ISOSpeedRatings is named ``PhotographicSensitivity``. - In addition, while "Count=Any", only 1 count should be used. - - * - ``OptoelectricConversionFactor`` - - 34856 - - R/W - - - - * - ``SensitivityType`` - - 34864 - - R/W - - - - * - ``StandardOutputSensitivity`` - - 34865 - - R/W - - - - * - ``RecommendedExposureIndex`` - - 34866 - - R/W - - - - * - ``ISOSpeed`` - - 34867 - - R/W - - - - * - ``ISOSpeedLatitudeyyy`` - - 34868 - - R/W - - - - * - ``ISOSpeedLatitudezzz`` - - 34869 - - R/W - - - - * - ``ExifVersion`` - - 36864 - - R/W - - - - * - ``DateTimeOriginal`` - - 36867 - - R/W - - - - * - ``DateTimeDigitized`` - - 36868 - - R/W - - - - * - ``OffsetTime`` - - 36880 - - R/W - - - - * - ``OffsetTimeOriginal`` - - 36881 - - R/W - - - - * - ``OffsetTimeDigitized`` - - 36882 - - R/W - - - - * - ``ComponentsConfiguration`` - - 37121 - - R/W - - - - * - ``CompressedBitsPerPixel`` - - 37122 - - R/W - - - - * - ``ShutterSpeedValue`` - - 37377 - - R/W - - - - * - ``ApertureValue`` - - 37378 - - R/W - - - - * - ``BrightnessValue`` - - 37379 - - R/W - - - - * - ``ExposureBiasValue`` - - 37380 - - R/W - - - - * - ``MaxApertureValue`` - - 37381 - - R/W - - - - * - ``SubjectDistance`` - - 37382 - - R/W - - - - * - ``MeteringMode`` - - 37383 - - R/W - - - - * - ``LightSource`` - - 37384 - - R/W - - - - * - ``Flash`` - - 37385 - - R/W - - - - * - ``FocalLength`` - - 37386 - - R/W - - - - * - ``SubjectArea`` - - 37396 - - R/W - - - - * - ``MakerNote`` - - 37500 - - R/W - - - - * - ``UserComment`` - - 37510 - - R/W - - - - * - ``SubSecTime`` - - 37520 - - R/W - - - - * - ``SubSecTimeOriginal`` - - 37521 - - R/W - - - - * - ``SubSecTimeDigitized`` - - 37522 - - R/W - - - - * - ``Temperature`` - - 37888 - - R/W - - - - * - ``Humidity`` - - 37889 - - R/W - - - - * - ``Pressure`` - - 37890 - - R/W - - - - * - ``WaterDepth`` - - 37891 - - R/W - - - - * - ``Acceleration`` - - 37892 - - R/W - - - - * - ``CameraElevationAngle`` - - 37893 - - R/W - - - - * - ``FlashpixVersion`` - - 40960 - - R/W - - - - * - ``ColorSpace`` - - 40961 - - R/W - - - - * - ``PixelXDimension`` - - 40962 - - R/W - - - - * - ``PixelYDimension`` - - 40963 - - R/W - - - - * - ``RelatedSoundFile`` - - 40964 - - R/W - - - - * - ``FlashEnergy`` - - 41483 - - R/W - - - - * - ``SpatialFrequencyResponse`` - - 41484 - - R/W - - - - * - ``FocalPlaneXResolution`` - - 41486 - - R/W - - - - * - ``FocalPlaneYResolution`` - - 41487 - - R/W - - - - * - ``FocalPlaneResolutionUnit`` - - 41488 - - R/W - - - - * - ``SubjectLocation`` - - 41492 - - R/W - - - - * - ``ExposureIndex`` - - 41493 - - R/W - - - - * - ``SensingMethod`` - - 41495 - - R/W - - - - * - ``FileSource`` - - 41728 - - R/W - - - - * - ``SceneType`` - - 41729 - - R/W - - - - * - ``CFAPattern`` - - 41730 - - R/W - - - - * - ``CustomRendered`` - - 41985 - - R/W - - - - * - ``ExposureMode`` - - 41986 - - R/W - - - - * - ``WhiteBalance`` - - 41987 - - R/W - - - - * - ``DigitalZoomRatio`` - - 41988 - - R/W - - - - * - ``FocalLengthIn35mmFilm`` - - 41989 - - R/W - - - - * - ``SceneCaptureType`` - - 41990 - - R/W - - - - * - ``GainControl`` - - 41991 - - R/W - - - - * - ``Contrast`` - - 41992 - - R/W - - - - * - ``Saturation`` - - 41993 - - R/W - - - - * - ``Sharpness`` - - 41994 - - R/W - - - - * - ``DeviceSettingDescription`` - - 41995 - - R/W - - - - * - ``SubjectDistanceRange`` - - 41996 - - R/W - - - - * - ``ImageUniqueID`` - - 42016 - - R/W - - - - * - ``CameraOwnerName`` - - 42032 - - R/W - - - - * - ``BodySerialNumber`` - - 42033 - - R/W - - - - * - ``LensSpecification`` - - 42034 - - R/W - - - - * - ``LensMake`` - - 42035 - - R/W - - - - * - ``LensModel`` - - 42036 - - R/W - - - - * - ``LensSerialNumber`` - - 42037 - - R/W - - - - * - ``Gamma`` - - 42240 - - R/W - - - - * - ``CompositeImage`` - - 42080 - - R/W - - - - * - ``SourceImageNumberOfCompositeImage`` - - 42081 - - R/W - - - - * - ``SourceExposureTimesOfCompositeImage`` - - 42082 - - R/W - - - -GPS Custom Tags -............... - -.. list-table:: GPS 2.32 Tags used by libtiff - :widths: 5 1 1 5 - :header-rows: 1 - - * - Tag Name - - Value - - R/W< - - Library's Use (Comments) - - * - ``VersionID`` - - 0 - - R/W - - - - * - ``LatitudeRef`` - - 1 - - R/W - - - - * - ``Latitude`` - - 2 - - R/W - - - - * - ``LongitudeRef`` - - 3 - - R/W - - - - * - ``Longitude`` - - 4 - - R/W - - - - * - ``AltitudeRef`` - - 5 - - R/W - - - - * - ``Altitude`` - - 6 - - R/W - - - - * - ``TimeStamp`` - - 7 - - R/W - - - - * - ``Satellites`` - - 8 - - R/W - - - - * - ``Status`` - - 9 - - R/W - - - - * - ``MeasureMode`` - - 10 - - R/W - - - - * - ``DOP`` - - 11 - - R/W - - - - * - ``SpeedRef`` - - 12 - - R/W - - - - * - ``Speed`` - - 13 - - R/W - - - - * - ``TrackRef`` - - 14 - - R/W - - - - * - ``Track`` - - 15 - - R/W - - - - * - ``ImgDirectionRef`` - - 16 - - R/W - - - - * - ``ImgDirection`` - - 17 - - R/W - - - - * - ``MapDatum`` - - 18 - - R/W - - - - * - ``DestLatitudeRef`` - - 19 - - R/W - - - - * - ``DestLatitude`` - - 20 - - R/W - - - - * - ``DestLongitudeRef`` - - 21 - - R/W - - - - * - ``DestLongitude`` - - 22 - - R/W - - - - * - ``DestBearingRef`` - - 23 - - R/W - - - - * - ``DestBearing`` - - 24 - - R/W - - - - * - ``DestDistanceRef`` - - 25 - - R/W - - - - * - ``DestDistance`` - - 26 - - R/W - - - - * - ``ProcessingMethod`` - - 27 - - R/W - - - - * - ``AreaInformation`` - - 28 - - R/W - - - - * - ``DateStamp`` - - 29 - - R/W - - - - * - ``Differential`` - - 30 - - R/W - - - - * - ``HorizontalPositioningError`` - - 31 - - R/W - - - diff --git a/thirdparty/SDL2_image/external/libtiff/doc/specification/index.rst b/thirdparty/SDL2_image/external/libtiff/doc/specification/index.rst deleted file mode 100644 index 2b56a2766..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/specification/index.rst +++ /dev/null @@ -1,38 +0,0 @@ -TIFF File Format Specification -============================== - -.. image:: ../images/jim.gif - :width: 139 - :alt: jim - -A copy of the 6.0 specification is available from Adobe at -``_ -or from the libtiff -ftp site at ``_. - -Draft :doc:`technote2` covers problems -with the TIFF 6.0 design for embedding JPEG-compressed data in TIFF, and -describes an alternative. - -Other Adobe information on TIFF can be retrieved from -``_. - -Joris Van Damme maintains a list of known tags and their descriptions and -definitions. It is available online at -``_. - -There is a FAQ, related both to TIFF format and libtiff library: -``_. - -A design for a TIFF variation supporting files larger than 4GB is detailed in :doc:`bigtiff`. - -The LibTIFF coverage of the TIFF 6.0 specification is detailed in :doc:`coverage`. - -.. toctree:: - :maxdepth: 1 - :titlesonly: - - technote2 - bigtiff - coverage - coverage-bigtiff diff --git a/thirdparty/SDL2_image/external/libtiff/doc/terms.rst b/thirdparty/SDL2_image/external/libtiff/doc/terms.rst deleted file mode 100644 index 3d4012a6f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/terms.rst +++ /dev/null @@ -1,79 +0,0 @@ -Terminology -=========== - -.. image:: images/strike.gif - :width: 128 - :alt: strike - -The following definitions are used throughout this documentation. -They are consistent with the terminology used in the TIFF 6.0 specification. - -Sample: - The unit of information stored in an image; often called a - channel elsewhere. Sample values are numbers, usually unsigned - integers, but possibly in some other format if the SampleFormat - tag is specified in a TIFF - -Pixel: - A collection of one or more samples that go together. - -Row: - An Nx1 rectangular collection of pixels. - -Tile: - An NxM rectangular organization of data (or pixels). - -Strip: - A tile whose width is the full image width. - -Compression: - A scheme by which pixel or sample data are stored in - an encoded form, specifically with the intent of reducing the - storage cost. - -Codec: - Software that implements the decoding and encoding algorithms - of a compression scheme. - -.. _ImageFileDirectory: - -Image File Directory (IFD): - An Image File Directory - in short also *directory* - - contains information about the image, - as well as pointers (offsets) to the actual image data - within the on-disk file. - An IFD points either to the next IFD or shows with a ''0'' - that it is the last IFD in the IFD-chain. - -Multi Images per TIFF file: - There may be more than one IFD in a TIFF file. - Each IFD defines a *subfile*. - One potential use of *subfiles* is to describe related images, - such as the pages of a facsimile transmission. - Such files are also named "*multi-page* TIFF" or "*multi-image* TIFF". - Refer also to :doc:`/multi_page`. - -.. _SubFile: - -Subfile: - *Subfile* is a term in the TIFF 6.0 specification for - an image and its associated *Image File Directory (IFD)* - in a TIFF file containing one or more images. - -In order to better understand how TIFF works (and consequently this -software) it is important to recognize the distinction between the -physical organization of image data as it is stored in a TIFF and how -the data is interpreted and manipulated as pixels in an image. TIFF -supports a wide variety of storage and data compression schemes that -can be used to optimize retrieval time and/or minimize storage space. -These on-disk formats are independent of the image characteristics; it -is the responsibility of the TIFF reader to process the on-disk storage -into an in-memory format suitable for an application. Furthermore, it -is the responsibility of the application to properly interpret the -visual characteristics of the image data. TIFF defines a framework for -specifying the on-disk storage format and image characteristics with -few restrictions. This permits significant complexity that can be -daunting. Good applications that handle TIFF work by handling as wide -a range of storage formats as possible, while constraining the -acceptable image characteristics to those that make sense for the -application. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools.rst deleted file mode 100644 index df102f04e..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools.rst +++ /dev/null @@ -1,155 +0,0 @@ -TIFF Tools Overview -=================== - -.. image:: images/quad.jpg - :width: 144 - :alt: quad - -This software distribution comes with a small collection of -programs for converting non-TIFF format images to TIFF and for -manipulating and interrogating the contents of TIFF images. Several -of these tools are useful in their own right. Many of them however -are more intended to serve as programming examples for using the -TIFF library. - -Manual pages ------------- - -.. toctree:: - :maxdepth: 1 - :titlesonly: - - tools/fax2ps - tools/fax2tiff - tools/pal2rgb - tools/ppm2tiff - tools/raw2tiff - tools/rgb2ycbcr - tools/thumbnail - tools/tiff2bw - tools/tiff2pdf - tools/tiff2ps - tools/tiff2rgba - tools/tiffcmp - tools/tiffcp - tools/tiffcrop - tools/tiffdither - tools/tiffdump - tools/tiffgt - tools/tiffinfo - tools/tiffmedian - tools/tiffset - tools/tiffsplit - -Device-dependent Programs -------------------------- - -There are two device-dependent programs that serve as simple -examples for writing programs to display and save TIFF images. - -.. list-table:: Device-dependent programs - :widths: 5 20 - :header-rows: 1 - - * - Tool - - Description - - * - :doc:`tools/tiffgt` - - Display the contents of one or more TIFF images using OpenGL. - The software makes extensive use of the ``TIFFRGBAImage`` - facilities described elsewhere. - -Device-independent Programs ---------------------------- - -The remaining programs should be device-independent: - -.. list-table:: Device-dependent programs - :widths: 5 20 - :header-rows: 1 - - * - Tool - - Description - - * - :doc:`tools/fax2ps` - - Convert a Group 3- or Group 4- compressed TIFF to PostScript - that is significantly more compressed than is generated by - :program:`tiff2ps` (unless :program:`tiff2ps` writes PS Level II) - - * - :doc:`tools/fax2tiff` - - Convert raw Group 3 or Group 4 facsimile data to TIFF - - * - :doc:`tools/pal2rgb` - - Convert a Palette-style image to a full color RGB image by - applying the colormap - - * - :doc:`tools/ppm2tiff` - - A quick hack that converts 8-bit PPM format images to TIFF - - * - :doc:`tools/raw2tiff` - - Create a TIFF file from raw data - - * - :doc:`tools/rgb2ycbcr` - - Convert an RGB, grayscale, or bilevel TIFF image to a YCbCr - TIFF image; it's mainly provided for testing - - * - :doc:`tools/thumbnail` - - Copy a bilevel TIFF to one that includes 8-bit greyscale - "thumbnail images" for each page; it is provided as an example of - how one might use the ``SubIFD`` tag (and the library support - for it) - - * - :doc:`tools/tiff2bw` - - A simple program to convert a color image to grayscale - - * - :doc:`tools/tiff2pdf` - - Convert TIFF images to PDF - - * - :doc:`tools/tiff2ps` - - Convert TIFF images to PostScript - - * - :doc:`tools/tiff2rgba` - - Convert a TIFF image to RGBA color space - - * - :doc:`tools/tiffcmp` - - Compare the contents of two TIFF files (it does not check all - the directory information, but does check all the data) - - * - :doc:`tools/tiffcp` - - Copy, concatenate, and convert TIFF images (e.g. switching from - ``Compression=5`` to ``Compression=1``) - - * - :doc:`tools/tiffcrop` - - Provides selection of images from within one or more multi-image - TIFF files, with orthogonal rotation, mirroring, cropping, and - extraction of multiple sections and exporting to one or more files. - It extends the functionality of :program:`tiffcp` to support additional bit - depths in strips and tiles and enhances the selection capabilities of - tiffsplit. Bilevel images can be inverted and images may be split into - segments to fit on multiple /pages/ (standard paper sizes), plus other - functions described in the tiffcrop man page - - * - :doc:`tools/tiffdither` - - Dither a b&w image into a bilevel image (suitable for use - in creating fax files) - - * - :doc:`tools/tiffdump` - - Display the verbatim contents of the TIFF directory in a file - (it's very useful for debugging bogus files that you may get from - someone that claims they support TIFF) - - * - :doc:`tools/tiffinfo` - - Display information about one or more TIFF files - - * - :doc:`tools/tiffmedian` - - A version of Paul Heckbert's median cut program that reads an - RGB TIFF image, and creates a TIFF palette file as a result - - * - :doc:`tools/tiffset` - - Set a field in a TIFF header - - * - :doc:`tools/tiffsplit` - - Create one or more single-image files from a (possibly) - multi-image file - -Check out the manual pages for details about the above programs. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/fax2ps.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/fax2ps.rst deleted file mode 100644 index 48dbafd75..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/fax2ps.rst +++ /dev/null @@ -1,129 +0,0 @@ -fax2ps -====== - -.. program:: fax2ps - -Synopsis --------- - -**fax2ps** [ *options* ] [ *file …* ] - -Description ------------ - -:program:`fax2ps` reads one or more TIFF -facsimile image files and prints a compressed form of -PostScript on the standard output that is suitable for printing. - -By default, each page is scaled to reflect the -image dimensions and resolutions stored in the file. -The :option:`-x` and :option:`-y` -options can be used to specify the horizontal and vertical -image resolutions (lines/inch), respectively. -If the :option:`-S` -option is specified, each page is scaled to fill an output page. -The default output page is 8.5 by 11 inches. -Alternate page dimensions can be specified in inches with the -:option:`-W` and :option:`-H` -options. - -By default :program:`fax2ps` -generates PostScript for all pages in the file. -The :option:`-p` -option can be used to select one or more pages from -a multi-page document. - - -:program:`fax2ps` -generates a compressed form of PostScript that is -optimized for sending pages of text to a PostScript -printer attached to a host through a low-speed link (such -as a serial line). -Each output page is filled with white and then only -the black areas are drawn. -The PostScript specification of the black drawing operations -is optimized by using a special font that encodes the -move-draw operations required to fill -the black regions on the page. -This compression scheme typically results in a substantially -reduced PostScript description, relative to the straightforward -imaging of the page with a PostScript -``image`` -operator. -This algorithm can, however, be ineffective -for continuous-tone and white-on-black images. -For these images, it sometimes is more efficient to send -the raster bitmap image directly; see -.BR tiff2ps (1). - -Options -------- - -.. option:: -p number - - Print only the indicated page. - Multiple pages may be printed by specifying - this option more than once. - -.. option:: -x resolution - - Use *resolution* - as the horizontal resolution, in dots/inch, of the image data. - By default this value is taken from the file. - -.. option:: -y resolution - - Use *resolution* - as the vertical resolution, in lines/inch, of the image data. - By default this value is taken from the file. - -.. option:: -S - - Scale each page of image data to fill the output page dimensions. - By default images are presented according to the dimension - information recorded in the TIFF file. - -.. option:: -W width - - Use *width* - as the width, in inches, of the output page. - -.. option:: -H height - - Use *height* - as the height, in inches, of the output page. - -Diagnostics ------------ - -Some messages about malformed TIFF images come from the -TIFF library. - -Various messages about badly formatted facsimile images -may be generated due to transmission errors in received -facsimile. -:program:`fax2ps` -attempts to recover from such data errors by resynchronizing -decoding at the end of the current scanline. -This can result in long horizontal black lines in the resultant -PostScript image. - -Notes ------ - -If the destination printer supports PostScript Level II then -it is always faster to just send the encoded bitmap generated -by the :program:`tiff2ps` program. - -Bugs ----- - -:program:`fax2ps` -should probably figure out when it is doing a poor -job of compressing the output and just generate -PostScript to image the bitmap raster instead. - -See also --------- - -:doc`tiff2ps` (1), :doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/fax2tiff.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/fax2tiff.rst deleted file mode 100644 index fcf56e7cf..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/fax2tiff.rst +++ /dev/null @@ -1,246 +0,0 @@ -fax2tiff -======== - -.. program:: fax2tiff - -Synopsis --------- - -**fax2tiff** [ *options* ] [ **-o** *output.tif* ] *input.raw* - -Description ------------ - -:program:`fax2tiff` creates a TIFF file containing CCITT -Group 3 or Group 4 encoded data from one or more files containing "raw" -Group 3 or Group 4 encoded data (typically obtained directly from a fax modem). -By default, each row of data in the resultant TIFF -file is 1-dimensionally encoded and -padded or truncated to 1728 pixels, as needed. -The resultant image is a set of low resolution (98 lines/inch) -or medium resolution (196 lines/inch) -pages, each of which is a single strip of data. -The generated file conforms to the TIFF -Class F (FAX) specification for storing facsimile data. -This means, in particular, that each page of the data does -**not** include the trailing -*"return to control"* (``RTC``) code; as required -for transmission by the CCITT Group 3 specifications. -The old, "classic", format is created if the -:option:`-c` option is used. -(The Class F format can also be requested with the -:option:`-f` option.) - -The default name of the output image is :file:`fax.tif`; -this can be changed with the :option:`-o` option. -Each input file is assumed to be a separate page of facsimile data -from the same document. -The order in which input files are specified on the command -line is the order in which the resultant pages appear in the -output file. - -Options -------- - -Options that affect the interpretation of input data are: - -.. option:: -3 - - Assume input data is CCITT Group 3 encoded (default). - -.. option:: -4 - - Assume input data is CCITT Group 4 encoded. - -.. option:: -U - - Assume input data is uncompressed (Group 3 or Group 4). - -.. option:: -1 - - Assume input data is encoded with the 1-dimensional version of the CCITT - Group 3 Huffman encoding algorithm (default). - -.. option:: -2 - - Assume input data is 2-dimensional version of the CCITT - Group 3 Huffman encoding algorithm. - -.. option:: -P - - Assume input data is **not** - EOL-aligned (default). This option has effect with Group 3 encoded input only. - -.. option:: -A - - Assume input data is EOL-aligned. This option has effect with Group 3 - encoded input only. - -.. option:: -M - - Treat input data as having bits filled from most significant bit (``MSB``) to most least bit (``LSB``). - -.. option:: -L - - Treat input data as having bits filled from least significant bit (``LSB``) to most significant bit - (``MSB``) (default). - -.. option:: -B - - Assume input data was encoded with black as 0 and white as 1. - -.. option:: -W - - Assume input data was encoded with black as 1 and white as 0 (default). - -.. option:: -R - - Specify the vertical resolution, in lines/inch, of the input images. - By default input are assumed to have a vertical resolution of 196 lines/inch. - If images are low resolution facsimile, a value of 98 lines/inch should - be specified. - -.. option:: -X - - Specify the width, in pixels, of the input images. - By default input are assumed to have a width of 1728 pixels. - -Options that affect the output file format are: - -.. option:: -o - - Specify the name of the output file. - - -.. option:: -7 - - Force output to be compressed with the CCITT - Group 3 Huffman encoding algorithm (default). - -.. option:: -8 - - Force output to be compressed with the CCITT - Group 4 Huffman encoding. - -.. option:: -u - - Force output to be uncompressed (Group 3 or Group 4). - -.. option:: -5 - - Force output to be encoded with the 1-dimensional version of the CCITT - Group 3 Huffman encoding algorithm. - -.. option:: -6 - - Force output to be encoded with the 2-dimensional version of the CCITT - Group 3 Huffman encoding algorithm (default). - -.. option:: -a - - Force the last bit of each *"End Of Line"* (``EOL``) - code to land on a byte boundary (default). This "zero padding" will - be reflected in the contents of the ``Group3Options`` - tag of the resultant TIFF file. This option has effect with Group 3 encoded output only. - -.. option:: -p - - Do not EOL-align output. This option has effect with Group 3 encoded - output only. - -.. option:: -c - - Generate "classic" Group 3 TIFF format. - -.. option:: -f - - Generate TIFF Class F (TIFF/F) format (default). - -.. option:: -m - - Force output data to have bits filled from most significant bit (``MSB``) - to most least bit (``LSB``). - -.. option:: -l - - Force output data to have bits filled from least significant bit (``LSB``) - to most significant bit (``MSB``) (default). - -.. option:: -r - - Specify the number of rows (scanlines) in each strip of data - written to the output file. - By default (or when value ``0`` is specified), :program:`tiffcp` - attempts to set the rows/strip - that no more than 8 kilobytes of data appear in a strip (with except of G3/G4 - compression schemes). If you specify special value ``-1`` - it will results in infinite number of the rows per strip. The entire image - will be the one strip in that case. This is default in case of G3/G4 output - compression schemes. - -.. option:: -s - - Stretch the input image vertically by writing each input row of - data twice to the output file. - -.. option:: -v - - Force :program:`fax2tiff` - to print the number of rows of data it retrieved from the input file. - -.. option:: -z - - Force output to be compressed with the LZW encoding. - -Diagnostics ------------ - -The following warnings and errors come from the decoding -routines in the library. - -**"Warning, %s: Premature EOL at scanline %d (x %d).\en"**: - - The input data had a row that was shorter than the expected width. - The row is padded with white. - -**"%s: Premature EOF at scanline %d (x %d).\en"**: - - The decoder ran out of data in the middle of a scanline. - The resultant row is padded with white. - -**"%s: Bad code word at row %d, x %d\en"**: - - An invalid Group 3 ``code`` - was encountered while decoding the input file. - The row number and horizontal position is given. - The remainder of the input row is discarded, while - the corresponding output row is padded with white. - -**"%s: Bad 2D code word at scanline %d.\en"**: - - An invalid Group 4 or 2D Group 3 ``code`` - was encountered while decoding the input file. - The row number and horizontal position is given. - The remainder of the input row is discarded, while - the corresponding output row is padded with white. - -Bugs ----- - -Input data are assumed to have a a "top left" orientation; -it should be possible to override this assumption -from the command line. - -See also --------- - -"CCITT Recommendation T.4" -(Standardization of Group 3 Facsimile Apparatus for Document Transmission). - -"The Spirit of TIFF Class F", -an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies. - -:doc:`tiffinfo` (1), -:doc:`tiffdither` (1), -:doc:`tiffgt` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/pal2rgb.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/pal2rgb.rst deleted file mode 100644 index 9f949ab04..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/pal2rgb.rst +++ /dev/null @@ -1,80 +0,0 @@ -pal2rgb -======= - -.. program:: pal2rgb - -Synopsis --------- - -**pal2rgb** [ *options* ] *input.tif* *output.tif* - -Description ------------ - -:program:`pal2rgb` converts a palette color image to a full color image by -applying the colormap of the palette image to each sample to generate a full color -RGB image. - -Options -------- - -Options that affect the interpretation of input data are: - -.. option:: -C numentries - - This option overrides the default behavior of :program:`pal2rgb` - in determining whether or not - colormap entries contain 16-bit or 8-bit values. - By default the colormap is inspected and - if no colormap entry greater than 255 is found, - the colormap is assumed to have only 8-bit values; otherwise - 16-bit values (as required by the TIFF - specification) are assumed. - The - :option:`-C` - option can be used to explicitly specify the number of - bits for colormap entries: - :command:`-C 8` for 8-bit values, - :command:`-C 16` for 16-bit values. - -Options that affect the output file format are: - -.. option:: -p planarconfig - - Explicitly select the planar configuration used in organizing - data samples in the output image: - :command:`-p contig` for samples packed contiguously, and - :command:`-p separate` for samples stored separately. - By default samples are packed. - -.. option:: -c compress - - Use the specified compression algorithm to encoded image data - in the output file: - :command:`-c packbits` for Macintosh Packbits, - :command:`-c lzw` for Lempel-Ziv & Welch, - :command:`-c zip` for Deflate, - :command:`-c none` - for no compression. - If no compression-related option is specified, the input - file's compression algorithm is used. - -.. option:: -r striprows - - Explicitly specify the number of rows in each strip of the - output file. If the :option:`-r` - option is not specified, a number is selected such that each - output strip has approximately 8 kilobytes of data in it. - -Bugs ----- - -Only 8-bit images are handled. - -See also --------- - -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`tiffmedian` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/ppm2tiff.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/ppm2tiff.rst deleted file mode 100644 index c69f8ffdb..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/ppm2tiff.rst +++ /dev/null @@ -1,56 +0,0 @@ -ppm2tiff -======== - -.. program:: ppm2tiff - -Synopsis - -**ppm2tiff** [ *options* ] [ *input.ppm* ] *output.tif* - -Description ------------ - -:program:`ppm2tiff` converts a file in the PPM, PGM and PBM image formats to -TIFF. By default, the TIFF image is created with data samples packed -(``PlanarConfiguration=1``), compressed with the Packbits algorithm -(``Compression=32773``), and with each strip no more than 8 kilobytes. -These characteristics can be overridden, or explicitly specified with the -options described below. - -If the PPM file contains greyscale data, then the ``PhotometricInterpretation`` -tag is set to 1 (min-is-black), otherwise it is set to 2 (RGB). - -If no PPM file is specified on the command line, :program:`ppm2tiff` -will read from the standard input. - -Options -------- - -.. option:: -c compress - - Specify a compression scheme to use when writing image data: - :command:`-c none` for no compression, - :command:`-c packbits` for PackBits compression (will be used by default), - :command:`-c lzw` for Lempel-Ziv & Welch compression, - :command:`-c jpeg` for baseline JPEG compression, - :command:`-c zip` for Deflate compression, - :command:`-c g3` for CCITT Group 3 (T.4) compression, and - :command:`-c g4` for CCITT Group 4 (T.6) compression. - -.. option:: -r striprows - - Write data with a specified number of rows per strip; by default the number of - rows/strip is selected so that each strip is approximately 8 kilobytes. - -.. option:: -R resolution - - Mark the resultant image to have the specified X and Y resolution (in - dots/inch). - -See also --------- - -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`tiffmedian` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/raw2tiff.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/raw2tiff.rst deleted file mode 100644 index a9378dab0..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/raw2tiff.rst +++ /dev/null @@ -1,143 +0,0 @@ -raw2tiff -======== - -.. program:: raw2tiff - - -Synopsis --------- - -**raw2tiff** [ *options ] *input.raw* *output.tif* - -Description ------------ - -:program:`raw2tiff` converts a raw byte sequence into TIFF. -By default, the TIFF image is created with data samples packed -(``PlanarConfiguration=1``), compressed with the PackBits algorithm -(``Compression=32773``), and with each strip no more than 8 kilobytes. -These characteristics can overridden, or explicitly specified -with the options described below. - -Options -------- - -.. option:: -H number - - Size of input image file header in bytes (0 by default). This amount of data - just will be skipped from the start of file while reading. - -.. option:: -w number - - Width of input image in pixels (can be guessed, see :ref:`raw-guess` below). - -.. option: -l number - - length of input image in lines (can be guessed, see :ref:`raw-guess` below). - -:option: -b number - - number of bands in input image (1 by default). - -.. option:: -d datatype - - type of samples in input image, where *datatype* may be one of: - - ========= =================================== - Data type Description - ========= =================================== - byte 8-bit unsigned integer (default) - short 16-bit unsigned integer - long 32-bit unsigned integer - sbyte 8-bit signed integer - sshort 16-bit signed integer - slong 32-bit signed integer - float 32-bit IEEE floating point - double 64-bit IEEE floating point - ========= =================================== - -.. option:: -i config - - type of sample interleaving in input image, where *config* may be one of: - - ============= ================================ - Configuration Description - ============= ================================ - pixel pixel interleaved data (default) - band band interleaved data. - ============= ================================ - -.. option:: -p photo - - photometric interpretation (color space) of the input image, where *photo* may - be one of: - - =========== ============================================== - Photometric Description - =========== ============================================== - miniswhite white color represented with 0 value - minisblack black color represented with 0 value (default) - rgb image has RGB color model - cmyk image has CMYK (separated) color model - ycbcr image has YCbCr color model - cielab image has CIE L*a*b color model - icclab image has ICC L*a*b color model - itulab image has ITU L*a*b color model - =========== ============================================== - -.. option:: -s - - swap bytes fetched from the input file. - -.. option:: -L - - input data has LSB2MSB bit order (default). - -.. option:: -M - - input data has MSB2LSB bit order. - -.. option:: -c - - Specify a compression scheme to use when writing image data: - :command:`-c none` for no compression, - :command:`-c packbits` for the PackBits compression algorithm (the default), - :command:`-c jpeg` for the baseline JPEG compression algorithm, - :command:`-c zip` for the Deflate compression algorithm, - :command:`\-c lzw` for Lempel-Ziv & Welch. - -.. option -r striprows - - Write data with a specified number of rows per strip; - by default the number of rows/strip is selected so that each strip - is approximately 8 kilobytes. - -.. _raw-guess: - -Guessing the image geometry ---------------------------- - -:program:`raw2tif` can guess image width and height in case one or both of these parameters are -not specified. If you omit one of those parameters, the complementary one will -be calculated based on the file size (taking into account header size, number -of bands and data type). If you omit both parameters, the statistical approach -will be used. Utility will compute correlation coefficient between two lines -at the image center using several appropriate line sizes and the highest -absolute value of the coefficient will indicate the right line size. That is -why you should be cautious with the very large images, because guessing -process may take a while (depending on your system performance). Of course, the -utility can't guess the header size, number of bands and data type, so it -should be specified manually. If you don't know anything about your image, -just try with the several combinations of those options. - -There is no magic, it is just a mathematical statistics, so it can be wrong -in some cases. But for most ordinary images guessing method will work fine. - -See also --------- - -:doc:`pal2rgb` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`tiffmedian` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/rgb2ycbcr.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/rgb2ycbcr.rst deleted file mode 100644 index 70a92e02c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/rgb2ycbcr.rst +++ /dev/null @@ -1,63 +0,0 @@ -rgb2ycbcr -========= - -.. program:: rgb2ycbcr - -Synopsis --------- - -**rgb2ycbcr** [ *options* ] *src1.tif src2.tif … dst.tif* - -Description ------------ - -:program:`rgb2ycbcr` converts RGB color, greyscale, or bi-level TIFF -images to YCbCr images by transforming and sampling pixel data. If multiple -files are specified on the command line each source file is converted to a -separate directory in the destination file. - -By default, chrominance samples are created by sampling -2 by 2 blocks of luminance values; this can be changed with the -:option:`-h` and :option:`-v` options. -Output data are compressed with the ``PackBits`` -compression scheme, by default; an alternate scheme can be selected with the -:option:`-c` option. -By default, output data are compressed in strips with -the number of rows in each strip selected so that the -size of a strip is never more than 8 kilobytes; -the :option:`-r` -option can be used to explicitly set the number of -rows per strip. - -Options -------- - -.. option:: -c compress - - Specify a compression scheme to use when writing image data: - :command:`-c none` for no compression, - :command:`-c packbits` for the PackBits compression algorithm (the default), - :command:`-c jpeg` for the JPEG compression algorithm, - :command:`\-c zip` for the deflate compression algorithm, and - :command:`-c lzw` for Lempel-Ziv & Welch. - -.. option:: -h size - - Set the horizontal sampling dimension to one of: 1, 2 (default), or 4. - -.. option:: -r striprows - - Write data with a specified number of rows per strip; - by default the number of rows/strip is selected so that each strip - is approximately 8 kilobytes. - -.. option:: -v size - - Set the vertical sampling dimension to one of: 1, 2 (default), or 4. - -See also --------- - -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/thumbnail.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/thumbnail.rst deleted file mode 100644 index 46f241dd2..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/thumbnail.rst +++ /dev/null @@ -1,66 +0,0 @@ -thumbnail -========= - -.. program:: thumbnail - -Synopsis --------- - -**thumbnail** [ *options* ] *input.tif* *output.tif* - -Description ------------ - -:program:`thumbnail` is a program written to show how one might use the -``SubIFD`` tag (#330) to store thumbnail images. -:program:`thumbnail` -copies a TIFF Class F facsimile file to the output file -and for each image an 8-bit greyscale "thumbnail sketch" is created. -The output file contains the thumbnail image with the associated -full-resolution page linked below with the SubIFD tag. - -By default, thumbnail images are 216 pixels wide by 274 pixels high. -Pixels are calculated by sampling and filtering the input image -with each pixel value passed through a contrast curve. - -Options -------- - -.. option:: -w width - - Specify the width of thumbnail images in pixels. - -.. option:: -h height - - Specify the height of thumbnail images in pixels. - -.. option:: -c contrast - - Specify a contrast curve to apply in generating the thumbnail images. - By default pixels values are passed through a linear contrast curve - that simply maps the pixel value ranges. Alternative curves are: - - ====== ====================== - Curve Description - ====== ====================== - exp50 50% exponential curve - exp60 60% exponential curve - exp70 70% exponential curve - exp80 80% exponential curve - exp90 90% exponential curve - exp pure exponential curve - linear linear curve - ====== ====================== - -Bugs ----- - -There are no options to control the format of the saved thumbnail images. - -See also --------- - -:doc:`tiffdump` (1), -:doc:`tiffgt` (1), -:doc:`tiffinfo` (1), -:doc:`/functions/libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2bw.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2bw.rst deleted file mode 100644 index 0ac324857..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2bw.rst +++ /dev/null @@ -1,60 +0,0 @@ -tiff2bw -======= - -.. program:: tiff2bw - -Synopsis --------- - -**tiff2bw** [ *options* ] *input.tif* *output.tif* - -Description ------------ - -:program:`tiff2bw` converts an RGB or Palette color TIFF -image to a greyscale image by -combining percentages of the red, green, and blue channels. -By default, output samples are created by taking -28% of the red channel, 59% of the green channel, and 11% of -the blue channel. To alter these percentages, the -:option:`-R`, :option:`-G`, and :option:`-B` options may be used. - -Options -------- - -.. option:: -c compress - - Specify a compression scheme to use when writing image data: - :command:`-c none` for no compression, - :command:`-c packbits` for the PackBits compression algorithm, - :command:`-c zip` for the Deflate compression algorithm, - :command:`-c g3` for the CCITT Group 3 compression algorithm, - :command:`-c g4` for the CCITT Group 4 compression algorithm, - :command:`-c lzw` for Lempel-Ziv & Welch (the default). - -.. option:: -r striprows - - Write data with a specified number of rows per strip; - by default the number of rows/strip is selected so that each strip - is approximately 8 kilobytes. - -.. option:: -R redperc - - Specify the percentage of the red channel to use (default 28). - -.. option:: -G greenperc - - Specify the percentage of the green channel to use (default 59). - -.. option:: -B blueperc - - Specify the percentage of the blue channel to use (default 11). - -See also --------- - -:doc:`pal2rgb` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`tiffmedian` (1), -:doc:`/functions/libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2pdf.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2pdf.rst deleted file mode 100644 index 36fc054f4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2pdf.rst +++ /dev/null @@ -1,211 +0,0 @@ -tiff2pdf -======== - -.. program:: tiff2pdf - -Synopsis --------- - -**tiff2pdf** [ *options* ] *input.tiff* - -Description ------------ - -:program:`tiff2pdf` opens a TIFF image and writes a PDF document to standard output. - -The program converts one TIFF file to one PDF file, including multiple page -TIFF files, tiled TIFF files, black and white. grayscale, and color TIFF -files that contain data of TIFF photometric interpretations of bilevel, -grayscale, RGB, YCbCr, CMYK separation, and ICC L*a*b* as supported by -:program:`libtiff` and PDF. - -If you have multiple TIFF files to convert into one PDF file then use :program:`tiffcp` -or other program to concatenate the files into a multiple page TIFF file. -If the input TIFF file is of huge dimensions (greater than 10000 pixels height -or width) convert the input image to a tiled TIFF if it is not already. - -The standard output is standard output. Set the output file name with the -:option:`-o` option. - -All black and white files are compressed into a single strip CCITT G4 Fax -compressed PDF, unless tiled, where tiled black and white images are -compressed into tiled CCITT G4 Fax compressed PDF, -:program:`libtiff` CCITT support is assumed. - -Color and grayscale data can be compressed using either JPEG compression, -ITU-T T.81, or Zip/Deflate LZ77 compression. Set the compression type using -the :option:`-j` or :option:`-z` options. JPEG compression support -requires that :program:`libtiff` be configured with JPEG support, and -Zip/Deflate compression support requires that :program:`libtiff` -be configured with Zip support. Use only one or the other of -:option:`-j` and :option:`-z`. - -If the input TIFF contains single strip CCITT G4 Fax compressed information, -then that is written to the PDF file without transcoding, unless the options -of no compression and no passthrough are set, :option:`-d` and :option:`-n`. - -If the input TIFF contains JPEG or single strip Zip/Deflate compressed -information, and they are configured, then that is written to the PDF file -without transcoding, unless the options of no compression and no passthrough -are set. - -The default page size upon which the TIFF image is placed is determined by -the resolution and extent of the image data. Default values for the TIFF -image resolution can be set using the :option:`-x` and :option:`-y` -options. The page size can be set using the :option:`-p` -option for paper size, or :option:`-w` and :option:`-l` -for paper width and length, then each page of the TIFF image is centered on -its page. The distance unit for default resolution and page width and -length can be set by the :option:`-u` option, the default unit is inch. - -Various items of the output document information can be set with the -:option:`-e`, :option:`-c`, :option:`-a`, :option:`-t`, :option:`-s`, -and :option:`-k` options. Setting the argument of the option to ``""`` for these -tags causes the relevant document information field to be not written. Some -of the document information values otherwise get their information from the -input TIFF image, the software, author, document name, and image description. - -The Portable Document Format (PDF) specification is copyrighted by Adobe -Systems, Incorporated. - -Options -------- - -.. option:: -o output-file - - Set the output to go to file *output-file* - -.. option:: -j - - Compress with JPEG (requires :program:`libjpeg` configured with - :program:`libtiff`). - -.. option:: -z - - Compress with Zip/Deflate (requires :program`zlib` configured with - :program:`libtiff`). - -.. option:: -q quality - - Set the compression quality, 1-100 for JPEG. - -.. option:: -n - - Do not allow data to be converted without uncompressing, no compressed - data passthrough. - -.. option:: -b - - Set PDF ``Interpolate`` user preference. - -.. option:: -d - - Do not compress (decompress). - -.. option:: -i - - Invert colors. - -.. option:: -p paper-size - - Set paper size, e.g., ``letter``, ``legal``, ``A4``. - -.. option:: -F - - Cause the tiff to fill the PDF page. - -.. option:: -u [ i | m ] - - Set distance unit, ``i`` for inch, ``m`` for centimeter. - -.. option:: -w width - - Set width in units. - -.. option:: -l length - - Set length in units. - -.. option:: -x xres - - Set x/width resolution default. - -.. option:: -y yres - - Set y/length resolution default. - -.. option:: -r [ d | o ] - - Set ``d`` for resolution default for images without resolution, - ``o`` for resolution override for all images. - -.. option:: -f - - Set PDF ``Fit Window`` user preference. - -.. option:: -e YYYYMMDDHHMMSS - - Set document information date, overrides image or current date/time default, - ``YYYYMMDDHHMMSS``. - -.. option:: -c creator - - Set document information creator, overrides image software default. - -.. option:: -a author - - Set document information author, overrides image artist default. - -.. option:: -t title - - Set document information title, overrides image document name default. - -.. option:: -s subject - - Set document information subject, overrides image image description default. - -.. option:: -k keywords - - Set document information keywords. - -.. option:: -m size - - Set memory allocation limit (in MiB). Default is 256MiB. Set to 0 to disable the limit. - -.. option:: -h - - List usage reminder to stderr and exit. - -Examples --------- - -The following example would generate the file output.pdf from input.tiff: - -.. highlight:: shell - -:: - - tiff2pdf -o output.pdf input.tiff - -The following example would generate PDF output from input.tiff and write it -to standard output: - -:: - - tiff2pdf input.tiff - -The following example would generate the file output.pdf from input.tiff, -putting the image pages on a letter sized page, compressing the output -with JPEG, with JPEG quality 75, setting the title to ``Document``, and setting -the ``Fit Window`` option: - -:: - - tiff2pdf -p letter -j -q 75 -t "Document" -f -o output.pdf input.tiff - -See also --------- - -:doc:`tiffcp` (1), -:doc:`tiff2ps` (1), -:doc:`/functions/libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2ps.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2ps.rst deleted file mode 100644 index fc88b4d46..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2ps.rst +++ /dev/null @@ -1,251 +0,0 @@ -tiff2ps -======== - -.. program:: tiff2ps - -Synopsis --------- - -**tiff2ps** [ *options* ] *input.tif* … - -Description ------------ - -:program:`tiff2ps` reads TIFF images and writes PostScript™ or Encapsulated -PostScript™ (EPS) on the standard output. By default :program:`tiff2ps` -writes Encapsulated PostScript™ for the first image in the specified -TIFF image file. - -By default, :program:`tiff2ps` will generate PostScript™ that fills a -printed area specified by the TIFF tags in the input file. -If the file does not contain ``XResolution`` or ``YResolution`` -tags, then the printed area is set according to the image dimensions. -The :option:`-w` and :option:`-h` options (see below) -can be used to set the dimensions of the printed area in inches; -overriding any relevant TIFF tags. - -The PostScript™ generated for RGB, palette, and CMYK images uses the -``colorimage`` operator. The PostScript™ generated for greyscale and -bilevel images uses the ``image`` operator. When the ``colorimage`` -operator is used, PostScript™ code to emulate this operator -on older PostScript™ printers is also generated. -Note that this emulation code can be very slow. - -Color images with associated alpha data are composited over -a white background. - -Options -------- - -.. option:: -1 - - Generate PostScript™ Level 1 (the default). - -.. option:: -2 - - Generate PostScript™ Level 2. - -.. option:: -3 - - Generate PostScript™ Level 3. It basically allows one to use the ```/flateDecode`` - filter for ZIP compressed TIFF images. - -.. option:: -8 - - Disable use of ASCII85 encoding with PostScript™ Level 2/3. - -.. option:: -a - - Generate output for all IFDs (pages) in the input file. - -.. option:: -b margin - - Specify the bottom margin for the output (in inches). This does not affect - the height of the printed image. - -.. option:: -c - - Center the image in the output. This option only shows an effect if both - the :option:`-w` and the :option:`-h` option are given. - -.. option:: -C name - - Specify the document creator name. - -.. option:: -d dir - - Set the initial TIFF - directory to the specified directory number. - (NB: Directories are numbered starting at zero.) - This option is useful for selecting individual pages in a - multi-page (e.g. facsimile) file. - -.. option:: -D - - Enable duplex printing (two pages per sheet of paper). - -.. option:: -e - - Force the generation of Encapsulated PostScript™ (implies - :option:`-z`). - -.. option:: -h size - - Specify the vertical size of the printed area (in inches). - -.. option:: -H - - Specify the maximum height of image (in inches). Images with larger sizes will - be split in several pages. Option :option:`-L` - may be used for specifying size of split images overlapping. - -.. option:: -i - - Enable/disable pixel interpolation. This option requires a - single numeric value: zero to disable pixel interpolation and - non-zero to enable. The default is enabled. - -.. option:: -L - - Specify the size of overlapping for split images (in inches). Used in - conjunction with :option:`-H` and :option:`-W` options. - -.. option:: -l - - Specify the left margin for the output (in inches). This does not affect - the width of the printed image. - -.. option:: -M size - - Set maximum memory allocation size (in MiB). The default is 256MiB. - Set to 0 to disable the limit. - - -.. option:: -m - - Where possible render using the ``imagemask`` PostScript™ operator instead of the - ``image`` operator. When this option is specified :program:`tiff2ps` will use - ``imagemask`` for rendering 1 bit deep images. If this option is not specified - or if the image depth is greater than 1 then the ``image`` operator is used. - -.. option:: -o ifdoffset - - Set the initial TIFF directory to the IFD at the specified file offset. - This option is useful for selecting thumbnail images and the - like which are hidden using the ``SubIFD`` tag. - -.. option:: -O - - Write PostScript™ to specified file instead of standard output. - -.. option:: -p - - Force the generation of (non-Encapsulated) PostScript™. - -.. option:: -P L|P - - Set optional PageOrientation DSC comment to Landscape or Portrait. - -.. option:: -r 90|180|270|auto - - Rotate image by 90, 180, 270 degrees or auto. Auto picks the best - fit for the image on the specified paper size (eg portrait - or landscape) if :option:`-h` or :option:`-w` is specified. Rotation is in degrees - counterclockwise. Auto rotates 90 degrees ccw to produce landscape. - -.. option:: -s - - Generate output for a single IFD (page) in the input file. - -.. option:: -t title - - Specify the document title string. - -.. option:: -T - - Print pages for top edge binding. - -.. option:: -w size - - Specify the horizontal size of the printed area (in inches). - -.. option:: -W size - - Specify the maximum width of image (in inches). Images with larger sizes will - be split in several pages. Options :option:`-L` and :option:`-W` - are mutually exclusive. - -.. option:: -x - - Override resolution units specified in the TIFF as centimeters. - -.. option:: -y - - Override resolution units specified in the TIFF as inches. - -.. option:: -z - - When generating PostScript™ Level 2, data is scaled so that it does not - image into the ``deadzone`` on a page (the outer margin that the printing device - is unable to mark). This option suppresses this behavior. - When PostScript™ Level 1 is generated, data is imaged to the entire printed - page and this option has no affect. - -Examples --------- - -The following generates PostScript™ Level 2 for all pages of a facsimile: - -.. highlight:: shell - -:: - - tiff2ps \-a2 fax.tif | lpr - -Note also that if you have version 2.6.1 or newer of Ghostscript then you -can efficiently preview facsimile generated with the above command. - -To generate Encapsulated PostScript™ for a the image at directory 2 -of an image use: - -:: - - tiff2ps \-d 1 foo.tif - -(Notice that directories are numbered starting at zero.) - -If you have a long image, it may be split in several pages: - -:: - - tiff2ps \-h11 \-w8.5 \-H14 \-L.5 foo.tif > foo.ps - -The page size is set to 8.5x11 by :option:`-w` and :option:`-h` -options. We will accept a small amount of vertical compression, so -:option:`-H` set to 14. Any pages between 11 and 14 inches will be fit onto one page. -Pages longer than 14 inches are cut off at 11 and continued on the next -page. The :command:`-L.5` -option says to repeat a half inch on the next page (to improve readability). - -Bugs ----- - -Because PostScript™ does not support the notion of a colormap, -8-bit palette images produce 24-bit PostScript™ images. -This conversion results in output that is six times -bigger than the original image and which takes a long time -to send to a printer over a serial line. -Matters are even worse for 4-, 2-, and 1-bit palette images. - -Does not handle tiled images when generating PostScript™ Level I output. - -See also --------- - -:doc:`pal2rgb` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`tiffgt` (1), -:doc:`tiffmedian` (1), -:doc:`tiff2bw` (1), -:doc:`/functions/libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2rgba.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2rgba.rst deleted file mode 100644 index d547dc3e3..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiff2rgba.rst +++ /dev/null @@ -1,72 +0,0 @@ -tiff2rgba -========= - -.. program:: tiff2rgba - -Synopsis --------- - -**tiff2rgba** [ *options* ] *input.tif* *output.tif* - -Description ------------ - -:program:`tiff2rgba` converts a wide variety of TIFF images into an RGBA TIFF image. This -includes the ability to translate different color spaces and photometric -interpretation into RGBA, support for alpha blending, and translation -of many different bit depths into a 32bit RGBA image. - -Internally this program is implemented using the :c:func:`TIFFReadRGBAImage` -function, and it suffers any limitations of that function. This includes -limited support for > 8 ``BitsPerSample`` images, and flaws with some -esoteric combinations of ``BitsPerSample``, photometric interpretation, -block organization and planar configuration. - -The generated images are stripped images with four samples per pixel -(red, green, blue and alpha) or if the :option:`-n` flag is used, three samples -per pixel (red, green, and blue). The resulting images are always planar -configuration contiguous. For this reason, this program is a useful utility -for transform exotic TIFF files into a form ingestible by almost any TIFF -supporting software. - -Options -------- - -.. option:: -c - - Specify a compression scheme to use when writing image data: - :command:`-c none` for no compression (the default), - :command:`-c packbits` for the PackBits compression algorithm, - :command:`-c zip` for the Deflate compression algorithm, - :command:`-c jpeg` for the JPEG compression algorithm, and - :command:`-c lzw` for Lempel-Ziv & Welch. - -.. option:: -r striprows - - Write data with a specified number of rows per strip; - by default the number of rows/strip is selected so that each strip - is approximately 8 kilobytes. - - -.. option:: -b - - Process the image one block (strip/tile) at a time instead of by reading - the whole image into memory at once. This may be necessary for very large - images on systems with limited RAM. - -.. option:: -n - - Drop the alpha component from the output file, producing a pure RGB file. - Currently this does not work if the :option:`-b` flag is also in effect. - -.. option:: -M size - - Set maximum memory allocation size (in MiB). The default is 256MiB. - Set to 0 to disable the limit. - -See also --------- - -:doc:`tiff2bw` (1), -:doc:`/functions/TIFFReadRGBAImage` (3tiff), -:doc:`/functions/libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcmp.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcmp.rst deleted file mode 100644 index ac85c4fc2..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcmp.rst +++ /dev/null @@ -1,59 +0,0 @@ -tiff2cmp -======== - -.. program:: tiffcmp - -Synopsis --------- - -**tiffcmp** [ *options* ] *file1.tif* *file2.tif* - -Description ------------ - -:program:`tiffcmp` compares the tags and data in two files created according -to the Tagged Image File Format, Revision 6.0. -The schemes used for compressing data in each file -are immaterial when data are compared\-data are compared on -a scanline-by-scanline basis after decompression. -Most directory tags are checked; notable exceptions are: -``GrayResponseCurve``, ``ColorResponseCurve``, and ``ColorMap`` tags. -Data will not be compared if any of the ``BitsPerSample``, -``SamplesPerPixel``, or ``ImageWidth`` values are not equal. -By default, :program:`tiffcmp` will terminate if it encounters any difference. - -Options -------- - -.. option:: -l - - List each byte of image data that differs between the files. - -.. option:: -z number - - List specified number of image data bytes that differs between the files. - -.. option:: -t - - Ignore any differences in directory tags. - -Bugs ----- - -Tags that are not recognized by the library are not -compared; they may also generate spurious diagnostics. - -The image data of tiled files is not compared, since the :c:func:`TIFFReadScanline` -function is used. An error will be reported for tiled files. - -The pixel and/or sample number reported in differences may be off -in some exotic cases. - -See also --------- - -:doc:`pal2rgb` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`tiffmedian` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcp.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcp.rst deleted file mode 100644 index b38c69f43..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcp.rst +++ /dev/null @@ -1,255 +0,0 @@ -tiffcp -====== - -.. program:: tiffcp - -Synopsis --------- - -**tiffcp** [ *options* ] *src1.tif* … *srcN.tif* *dst.tif* - -Description ------------ -:program:`tiffcp` combines one or more files created according -to the Tag Image File Format, Revision 6.0 into a single TIFF file. -Because the output file may be compressed using a different -algorithm than the input files, :program:`tiffcp` is most often -used to convert between different compression schemes. - -By default, :program:`tiffcp` will copy all the understood tags in a -TIFF directory of an input file to the associated directory in the output file. - -:program:`tiffcp` can be used to reorganize the storage characteristics of data -in a file, but it is explicitly intended to not alter or convert -the image data content in any way. - -Options -------- - -.. option:: -a - - Append to an existing output file instead of overwriting it. - -.. option:: -b image - - subtract the following monochrome image from all others - processed. This can be used to remove a noise bias - from a set of images. This bias image is typically an - image of noise the camera saw with its shutter closed. - -.. option:: -B - - Force output to be written with Big-Endian byte order. - This option only has an effect when the output file is created or - overwritten and not when it is appended to. - -.. option:: -C - - Suppress the use of "strip chopping" when reading images - that have a single strip/tile of uncompressed data. - -.. option:: -c - - Specify the compression to use for data written to the output file: - :command:`-c none` for no compression, - :command:`-c packbits` for PackBits compression, - :command:`-c lzw` for Lempel-Ziv & Welch compression, - :command:`-c zip` for Deflate compression, - :command:`-c lzma` for LZMA2 compression, - :command:`-c jpeg` for baseline JPEG compression, - :command:`-c g3` for CCITT Group 3 (T.4) compression, - :command:`-c g4` for CCITT Group 4 (T.6) compression, or - :command:`-c sgilog` for SGILOG compression. - - By default :program:`tiffcp` will compress data according to the - value of the ``Compression`` tag found in the source file. - - The CCITT Group 3 and Group 4 compression algorithms can only - be used with bilevel data. - - Group 3 compression can be specified together with several - T.4-specific options: - - * ``1d`` for 1-dimensional encoding, - * ``2d`` for 2-dimensional encoding, and - * ``fill`` to force each encoded scanline to be zero-filled so that the - terminating EOL code lies on a byte boundary. - - Group 3-specific options are specified by appending a ``:``-separated - list to the ``g3`` option; e.g. :command:`-c g3:2d:fill` - to get 2D-encoded data with byte-aligned EOL codes. - - LZW, Deflate and LZMA2 compression can be specified together with a - ``predictor`` value. A predictor value of 2 causes each scanline of the output image to - undergo horizontal differencing before it is encoded; a value of 1 forces each - scanline to be encoded without differencing. A value 3 is for floating point - predictor which you can use if the encoded data are in floating point format. - LZW-specific options are specified by appending a ``:``-separated list to the - ``lzw`` option; e.g. :command:`-c lzw:2` for LZW compression with horizontal differencing. - - Deflate and LZMA2 encoders support various compression levels (or encoder presets) set as - character ``p`` and a preset number. ``p1`` is the fastest one with the worst - compression ratio and ``p9`` is the slowest but with the best possible ratio; - e.g. :command:`-c zip:3:p9` for - Deflate encoding with maximum compression level and floating point predictor. - - For the Deflate codec, and in a libtiff build with libdeflate enabled, ``p12`` is - actually the maximum level. - - For the Deflate codec, and in a libtiff build with libdeflate enabled, ``s0`` can be used to - require zlib to be used, and ``s1`` for libdeflate (defaults to libdeflate when - it is available). - -.. option:: -f fillorder - - Specify the bit fill order to use in writing output data. By default, :program:`tiffcp` - will create a new file with the same fill order as the original. Specifying :command:`\-f lsb2msb` - will force data to be written with the ``FillOrder`` tag set to ``LSB2MSB``, while - :command:`\-f msb2lsb` will force data to be written with the ``FillOrder`` tag set to - ``MSB2LSB``. - -.. option:: -i - - Ignore non-fatal read errors and continue processing of the input file. - -.. option:: -l - - Specify the length of a tile (in pixels). - - :program:`tiffcp` attempts to set the tile dimensions so - that no more than 8 kilobytes of data appear in a tile. - -.. option:: -L - - Force output to be written with Little-Endian byte order. - This option only has an effect when the output file is created or - overwritten and not when it is appended to. - -.. option:: -M - - Suppress the use of memory-mapped files when reading images. - -.. option:: -o offset - - Set initial directory offset. - -.. option:: -p - - Specify the planar configuration to use in writing image data - that has one 8-bit sample per pixel. By default, :program:`tiffcp` - will create a new file with the same planar configuration as - the original. Specifying :command:`\-p contig` - will force data to be written with multi-sample data packed - together, while :command:`-p separate` - will force samples to be written in separate planes. - -.. option:: -r - - Specify the number of rows (scanlines) in each strip of data - written to the output file. By default (or when value **0** - is specified), :program:`tiffcp` attempts to set the rows/strip - that no more than 8 kilobytes of data appear in a strip. If you specify - special value **-1** it will results in infinite number of the rows per - strip. The entire image will be the one strip in that case. - -.. option:: -s - - Force the output file to be written with data organized in strips - (rather than tiles). - -.. option:: -t - - Force the output file to be written with data organized in tiles (rather than - strips). options can be used to force the resultant image to be written as - strips or tiles of data, respectively. - -.. option:: -w - - Specify the width of a tile (in pixels). :program::`tiffcp` - attempts to set the tile dimensions so that no more than 8 kilobytes of data - appear in a tile. - -.. option:: -x - - Force the output file to be written with ``PAGENUMBER`` value in sequence. - -.. option:: -8 - - Write BigTIFF instead of classic TIFF format. - -.. option:: -,= character - - substitute *character* for ``,`` - in parsing image directory indices - in files. This is necessary if filenames contain commas. - Note that ``-,=`` - with whitespace immediately following will disable - the special meaning of the ``,`` entirely. See examples. - -.. option:: -m size - - Set maximum memory allocation size (in MiB). The default is 256MiB. - Set to 0 to disable the limit. - -Examples --------- - -The following concatenates two files and writes the result using LZW encoding: - -.. highlight:: shell - -:: - - tiffcp -c lzw a.tif b.tif result.tif - -To convert a G3 1d-encoded TIFF to a single strip of G4-encoded data the following might be used: - -:: - - tiffcp -c g4 -r 10000 g3.tif g4.tif - -(1000 is just a number that is larger than the number of rows in -the source file.) - -To extract a selected set of images from a multi-image TIFF file, the file -name may be immediately followed by a ``,`` separated list of image directory -indices. The first image is always in directory 0. Thus, to copy the 1st and -3rd images of image file :file:`album.tif` to :file:`result.tif`: - -:: - - tiffcp album.tif,0,2 result.tif - -A trailing comma denotes remaining images in sequence. The following command -will copy all image with except the first one: - -:: - - tiffcp album.tif,1, result.tif - -Given file :file:`CCD.tif` whose first image is a noise bias -followed by images which include that bias, -subtract the noise from all those images following it -(while decompressing) with the command: - -:: - - tiffcp -c none -b CCD.tif CCD.tif,1, result.tif - -If the file above were named :file:`CCD,X.tif`, the ``-,=`` -option would be required to correctly parse this filename with image numbers, -as follows: - -:: - - tiffcp -c none -,=% -b CCD,X.tif CCD,X%1%.tif result.tif - -See also --------- - -:doc:`pal2rgb` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcmp` (1), -:doc:`tiffmedian` (1), -:doc:`tiffsplit` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcrop.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcrop.rst deleted file mode 100644 index d7d89ca13..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffcrop.rst +++ /dev/null @@ -1,547 +0,0 @@ -tiffcrop -======== - -.. program:: tiffcrop - -Synopsis --------- - -**tiffcrop** [ *options* ] *src1.tif* … *srcN.tif* *dst.tif* - -Description ------------ - -:program:`tiffcrop` processes one or more files created according -to the Tag Image File Format, Revision 6.0, specification -into one or more TIFF file(s). -:program:`tiffcrop` is most often used to extract portions of an image for processing -with bar code recognizer or OCR software when that software cannot -restrict the region of interest to a specific portion of the image -or to improve efficiency when the regions of interest must be rotated. -It can also be used to subdivide all or part of a processed image into -smaller sections and export individual images or sections of images -as separate files or separate images within one or more files derived -from the original input image or images. - -The available functions can be grouped broadly into three classes: - -#. Those that select individual images or sections of images from the input files. - The options :option:`-N` for sequences or lists of individual images in the input files, - :option:`-Z` for zones, :option:`-z` for regions, :option:`-X` and :option:`-Y` for fixed sized selections, - :option:`-m` for margins, :option:`-U` for units, and :option:`-E` for edge reference provide a variety of - ways to specify portions of the input image. - -#. Those that allow the individual images or selections to be exported to one or - more output files in different groupings and control the organization of the - data in the output images. The options :option:`-P` for page size grouping, :option:`-S` for - subdivision into columns and rows and :option:`-e` for export mode options that produce - one or more files from each input image. The options :option:`-r`, :option:`-s`, :option:`-t`, :option:`-w` control - strip and tile format and sizes while :option:`-B`, :option:`-L`, :option:`-c`, :option:`-f` modify the endian addressing - scheme, the compression options, and the bit fill sequence of images as they - are written. - -#. Those that perform some action on each image that is selected from the input file. - The options include :option:`-R` for rotate, :option:`-I` for inversion of the photometric - interpretation and/or data values, and :option:`-F` to flip (mirror) the image horizontally - or vertically. - -Functions are applied to the input image(s) in the following order: -cropping, fixed area extraction, zone and region extraction, -inversion, mirroring, rotation. - -Functions are applied to the output image(s) in the following order: -export mode options for grouping zones, regions, or images into -one or more files, *or* row and column divisions with output margins, -*or* page size divisions with page orientation options. - -Finally, strip, tile, byte order, output resolution, and compression options are -applied to all output images. - -The output file(s) may be organized and compressed using a different -algorithm from the input files. -By default, :program:`tiffcrop` will copy all the understood tags in a TIFF -directory of an input file to the associated directory in the output file. -Options can be used to force the resultant image to be written as strips -or tiles of data, respectively. - -:program:`tiffcrop` can be used to reorganize the storage characteristics of data -in a file, and to reorganize, extract, rotate, and otherwise -process the image data as specified at the same time whereas -:program:`tiffcp` does not alter the image data within the file. - -Using the options for selecting individual input images and the -options for exporting images and/or segments defined as zones or -regions of each input image, :program:`tiffcrop` can perform the -functions of :program:`tiffcp` and :program:`tiffsplit` in a single pass -while applying multiple operations to individual selections or images. - -Options -------- - -.. option:: -h - - Display the syntax summary for tiffcrop. - -.. option:: -v - - Report the current version and last modification date for tiffcrop. - -.. option:: -N odd|even|#,#-#,#|last - - Specify one or more series or range(s) of images within each file to process. - The words ``odd`` or ``even`` - may be used to specify all odd or even numbered images counting from one. - Note that internally, TIFF images are numbered from zero rather than one - but since this convention is not obvious to most users, :program:`tiffcrop` used 1 - to specify the first image in a multipage file. The word ``last`` - may be used in place of a number in the sequence to indicate the - final image in the file without knowing how many images there are. - Ranges of images may be specified with a dash and multiple sets - can be indicated by joining them in a comma-separated list. eg. use - ``-N 1,5-7,last`` - to process the 1st, 5th through 7th, and final image in the file. - -.. option:: -E top|bottom|left|right - - Specify the ``top``, ``bottom``, ``left``, or ``right`` edge as the reference from - which to calculate the width and length of crop regions or sequence - of positions for zones. When used with the :option:`-e` option for exporting - zones or regions, the reference edge determines how composite images - are arranged. Using ``-E left`` or ``-E right`` causes successive zones or - regions to be merged horizontally whereas using ``-E top`` or ``-E bottom`` - causes successive zones or regions to be arranged vertically. This - option has no effect on export layout when multiple zones or regions - are not being exported to composite images. Edges may be abbreviated - to the first letter. - -.. option:: -e combined|divided|image|multiple|separate - - Specify the export mode for images and selections from input images. - The final filename on the command line is considered to be the - destination file or filename stem for automatically generated - sequences of files. Modes may be abbreviated to the first letter. - - .. list-table:: Export modes - :widths: 5 20 - :header-rows: 1 - - * - Export mode - - Description - - * - combined - - All images and selections are written to a single file with - multiple selections from one image combined into a single image (default) - * - divided - - All images and selections are written to a single file - with each selection from one image written to a new image - * - image - - Each input image is written to a new file (numeric filename sequence) - with multiple selections from the image combined into one image - * - multiple - - Each input image is written to a new file (numeric filename sequence) - with each selection from the image written to a new image - * - separate - - Individual selections from each image are written to separate files - -.. option:: -U in|cm|px - - Specify the type of units to apply to dimensions for margins and - crop regions for input and output images. Inches or centimeters - are converted to pixels using the resolution unit specified in the - TIFF file (which defaults to inches if not specified in the IFD). - -.. option:: -m top,left,bottom,right - - Specify margins to be removed from the input image. The order must - be *top*, *left*, *bottom*, *right* with only commas separating the elements - of the list. Margins are scaled according to the current units and - removed before any other extractions are computed. - -.. option:: -X # - - Set the horizontal (X-axis) dimension of a region to extract relative to - the specified origin reference. If the origin is the top or bottom - edge, the X axis value will be assumed to start at the left edge. - -.. option:: -Y # - - Set the vertical (Y-axis) dimension of a region to extract relative to - the specified origin reference. If the origin is the left or right - edge, the Y axis value will be assumed to start at the top. - -.. option:: -Z #:#,#:# - - Specify zones of the image designated as position X of Y equal sized portions - measured from the reference edge, eg 1:3 would be first third of the - image starting from the reference edge minus any margins specified - for the confining edges. Multiple zones can be specified as a comma - separated list but they must reference the same edge. To extract the - top quarter and the bottom third of an image you would use - ``-Z 1:4,3:3``. - -.. option:: -z x1,y1,x2,y2: ... :xN,yN,xN+1,yN+1 - - Specify a series of coordinates to define regions for processing and exporting. - The coordinates represent the top left and lower right corners of each region - in the current units, eg inch, cm, or pixels. Pixels are counted from one to - width or height and inches or cm are calculated from image resolution data. - - Each colon delimited series of four values represents the horizontal and vertical - offsets from the top and left edges of the image, regardless of the edge specified - with the :option:`-E` option. The first and third values represent the horizontal offsets of - the corner points from the left edge while the second and fourth values represent - the vertical offsets from the top edge. - -.. option:: -F horiz|vert - - Flip, ie mirror, the image or extracted region horizontally or vertically. - -.. option:: -R 90|180|270 - - Rotate the image or extracted region 90, 180, or 270 degrees clockwise. - -.. option:: -I [black|white|data|both] - - Invert color space, eg dark to light for bilevel and grayscale images. - This can be used to modify negative images to positive or to correct - images that have the ``PHOTOMETRIC_INTERPRETATION`` tag set incorrectly. - If the value is black or white, the ``PHOTOMETRIC_INTERPRETATION`` tag is set to - MinIsBlack or MinIsWhite, without altering the image data. If the argument - is data or both, the data values of the image are modified. Specifying both - inverts the data and the ``PHOTOMETRIC_INTERPRETATION`` tag, whereas using data - inverts the data but not the ``PHOTOMETRIC_INTERPRETATION`` tag. - No support for modifying the color space of color images in this release. - -.. option:: -H # - - Set the horizontal resolution of output images to *#*, - expressed in the current units. - -.. option:: -V # - - Set the vertical resolution of the output images to *#* - expressed in the current units. - -.. option:: -J # - - Set the horizontal margin of an output page size to *#* - expressed in the current units when sectioning image into *columns* × *rows* - subimages using the :option:`-S` ``cols:rows`` option. - -.. option:: -K # - - Set the vertical margin of an output page size to *#* - expressed in the current units when sectioning image into *columns* × *rows* - subimages using the :option:`-S` ``cols:rows`` option. - -.. option:: -O portrait|landscape|auto - - Set the output orientation of the pages or sections. - Auto will use the arrangement that requires the fewest pages. - This option is only meaningful in conjunction with the :option:`-P` - option to format an image to fit on a specific paper size. - -.. option:: -P page - - Format the output images to fit on page size paper. Use - ``-P list`` to show the supported page sizes and dimensions. - You can define a custom page size by entering the width and length of the - page in the current units with the following format ``#.#x#.#``. - -.. option:: -S cols:rows - - Divide each image into cols across and rows down equal sections. - -.. option:: -B - - Force output to be written with Big-Endian byte order. - This option only has an effect when the output file is created or - overwritten and not when it is appended to. - -.. option:: -C - - Suppress the use of "strip chopping" when reading images - that have a single strip/tile of uncompressed data. - -.. option:: -c - - Specify the compression to use for data written to the output file: - :command:`-c none` for no compression, - :command:`-c packbits` for PackBits compression, - :command:`-c lzw` for Lempel-Ziv & Welch compression, - :command:`-c jpeg` for baseline JPEG compression. - :command:`-c zip` for Deflate compression, - :command:`-c g3` for CCITT Group 3 (T.4) compression, - :command:`-c g4` for CCITT Group 4 (T.6) compression. - By default :program:`tiffcrop` will compress data according to the value of the - ``Compression`` tag found in the source file. - - The CCITT Group 3 and Group 4 compression algorithms can only - be used with bilevel data. - - Group 3 compression can be specified together with several - T.4-specific options: - ``1d`` for 1-dimensional encoding, - ``2d`` for 2-dimensional encoding, - ``fill`` to force each encoded scanline to be zero-filled so that the - terminating EOL code lies on a byte boundary. - Group 3-specific options are specified by appending a ``:``-separated - list to the ``g3`` option; e.g. ``-c g3:2d:fill`` - to get 2D-encoded data with byte-aligned EOL codes. - - LZW compression can be specified together with a ``predictor`` - value. A predictor value of 2 causes - each scanline of the output image to undergo horizontal - differencing before it is encoded; a value - of 1 forces each scanline to be encoded without differencing. - LZW-specific options are specified by appending a ``:``-separated - list to the ``lzw`` option; e.g. ``-c lzw:2`` for LZW - compression with horizontal differencing. - -.. option:: -f - - Specify the bit fill order to use in writing output data. - By default, :program:`tiffcrop` - will create a new file with the same fill order as the original. - Specifying - ``-f lsb2msb`` - will force data to be written with the ``FillOrder`` tag set to - ``LSB2MSB``, while - ``-f msb2lsb`` will force data to be written with the ``FillOrder`` - tag set to ``MSB2LSB``. - -.. option:: -i - - Ignore non-fatal read errors and continue processing of the input file. - -.. option:: -k size - - Set maximum memory allocation size (in MiB). The default is 256MiB. - Set to 0 to disable the limit. - -.. option:: -l - - Specify the length of a tile (in pixels). - :program:`tiffcrop` attempts to set the tile dimensions so - that no more than 8 kilobytes of data appear in a tile. - -.. option:: -L - - Force output to be written with Little-Endian byte order. - This option only has an effect when the output file is created or - overwritten and not when it is appended to. - -.. option:: -M - - Suppress the use of memory-mapped files when reading images. - -.. option:: -p - - Specify the planar configuration to use in writing image data - that has more than one sample per pixel. - By default, :program:`tiffcrop` - will create a new file with the same planar configuration as - the original. - Specifying :command:`-p contig` - will force data to be written with multi-sample data packed - together, while - :command:`-p separate` - will force samples to be written in separate planes. - -.. option:: -r - - Specify the number of rows (scanlines) in each strip of data - written to the output file. - By default (or when value **0** is specified), :program:`tiffcrop` - attempts to set the rows/strip that no more than 8 kilobytes of - data appear in a strip. If you specify the special value - **-1** it will results in infinite number of the rows per strip. The entire image - will be the one strip in that case. - -.. option:: -s - - Force the output file to be written with data organized in strips - (rather than tiles). - -.. option:: -t - - Force the output file to be written with data organized in tiles - (rather than strips). - -.. option:: -w - - Specify the width of a tile (in pixels). - :program:`tiffcrop` attempts to set the tile dimensions so - that no more than 8 kilobytes of data appear in a tile. - -.. option:: -D opt1:value1,opt2:value2,opt3:value3:opt4:value4 - - Debug and dump facility - - Display program progress and/or dump raw data to non-TIFF files. - Options include the following and must be joined as a comma - separated list. The use of this option is generally limited to - program debugging and development of future options. An equal sign - may be substituted for the colon in option:value pairs. - - ``debug:N``: - - Display limited program progress indicators where larger *N* - increases the level of detail. - - ``format:txt|raw``: - - Format any logged data as ASCII text or raw binary - values. ASCII text dumps include strings of ones and zeroes representing - the binary values in the image data plus identifying headers. - - ``level:N``: - - Specify the level of detail presented in the dump files. - This can vary from dumps of the entire input or output image data to dumps - of data processed by specific functions. Current range of levels is 1 to 3. - - ``input:full-path-to-directory/input-dumpname``: - - ``output:full-path-to-directory/output-dumpname``: - - When dump files are being written, each image will be written to a separate - file with the name built by adding a numeric sequence value to the dumpname - and an extension of :file:`.txt` for ASCII dumps or :file:`.bin` for binary dumps. - - The four debug/dump options are independent, though it makes little sense to - specify a dump file without specifying a detail level. - - Note: :program:`tiffcrop` may be compiled with :command:`-DDEVELMODE` to enable - additional very low level debug reporting. - -However, not all option combinations are permitted. - - Note 1: The (-X|-Y), -Z, -z and -S options are mutually exclusive. - In no case should the options be applied to a given selection successively. - - Note 2: Any of the -X, -Y, -Z and -z options together with other PAGE_MODE_x options - such as -H, -V, -P, -J or -K are not supported and may cause buffer overflows. - -Examples --------- - -The following concatenates two files and writes the result using LZW -encoding: - -.. highlight:: shell - -:: - - tiffcrop -c lzw a.tif b.tif result.tif - -To convert a G3 1d-encoded TIFF to a single strip of G4-encoded data the following might be used: - -:: - - tiffcrop -c g4 -r 10000 g3.tif g4.tif - -(1000 is just a number that is larger than the number of rows in -the source file.) - -To extract a selected set of images from a multi-image TIFF file -use the :option:`-N` option described above. Thus, to copy the 1st and 3rd -images of image file :file:`album.tif` to :file:`result.tif`: - -:: - - tiffcrop -N 1,3 album.tif result.tif - -Invert a bilevel image scan of a microfilmed document and crop off margins of -0.25 inches on the left and right, 0.5 inch on the top, and 0.75 inch on the -bottom. From the remaining portion of the image, select the second and third -quarters, ie, one half of the area left from the center to each margin: - -:: - - tiffcrop -U in -m 0.5,0.25,0.75,0.25 -E left -Z 2:4,3:4 -I both MicrofilmNegative.tif MicrofilmPostiveCenter.tif - -Extract only the final image of a large Architectural E sized -multipage TIFF file and rotate it 90 degrees clockwise while -reformatting the output to fit on tabloid sized sheets with one -quarter of an inch on each side: - -:: - - tiffcrop -N last -R 90 -O auto -P tabloid -U in -J 0.25 -K 0.25 -H 300 -V 300 Big-PlatMap.tif BigPlatMap-Tabloid.tif - -The output images will have a specified resolution of 300 dpi in both -directions. The orientation of each page will be determined by whichever -choice requires the fewest pages. To specify a specific orientation, use -the portrait or landscape option. The paper size option does not resample -the image. It breaks each original image into a series of smaller images -that will fit on the target paper size at the specified resolution. - -Extract two regions 2048 pixels wide by 2048 pixels high from each page of -a multi-page input file and write each region to a separate output file: - -:: - - tiffcrop -U px -z 1,1,2048,2048:1,2049,2048,4097 -e separate CheckScans.tiff Check - -The output file names will use the stem :file:`Check` with a numeric suffix which is -incremented for each region of each image, eg :file:`Check-001.tiff`, -:file:`Check-002.tiff` … :file:`Check-NNN.tiff`. To produce a unique file for each page -of the input image with one new image for each region of the input image on that page -change the export option to ``-e multiple``. - -Notes ------ - -In general, bilevel, grayscale, palette and RGB(A) data with bit depths -from 1 to 32 bits should work in both interleaved and separate plane -formats. Unlike :program:`tiffcp`, :program:`tiffcrop` can read and write tiled images with -bits per sample that are not a multiple of 8 in both interleaved and -separate planar format. Floating point data types are supported at -bit depths of 16, 24, 32 and 64 bits per sample. - -Not all images can be converted from one compression scheme to another. -Data with some photometric interpretations and/or bit depths are tied to -specific compression schemes and vice-versa, e.g. Group 3/4 compression -is only usable for bilevel data. JPEG compression is only usable on 8 -bit per sample data (or 12 bit if :program:`libtiff` -was compiled with 12 bit JPEG support). Support for OJPEG compressed -images is problematic at best. Since OJPEG compression is no longer -supported for writing images with LibTIFF, these images will be updated -to the newer JPEG compression when they are copied or processed. This -may cause the image to appear color shifted or distorted after conversion. -In some cases, it is possible to remove the original compression from -image data using the option ``-c none``. - -:program:`tiffcrop` does not currently provide options to up or downsample data to -different bit depths or convert data from one photometric interpretation -to another, e.g. 16 bits per sample to 8 bits per sample or RGB to grayscale. - -:program:`tiffcrop` is very loosely derived from code in :program:`tiffcp` -with extensive modifications and additions to support the selection of input -images and regions and the exporting of them to one or more output files in -various groupings. The image manipulation routines are entirely new and -additional ones may be added in the future. It will handle tiled images with -bit depths that are not a multiple of eight that tiffcp may refuse to read. - -:program:`tiffcrop` was designed to handle large files containing many moderate sized images -with memory usage that is independent of the number of images in the file. -In order to support compression modes that are not based on individual -scanlines, e.g. JPEG, it now reads images by strip or tile rather than by -individual scanlines. In addition to the memory required by the input and -output buffers associated with :program:`libtiff` -one or more buffers at least as large as the largest image to be read are -required. The design favors large volume document processing uses over -scientific or graphical manipulation of large datasets as might be found -in research or remote sensing scenarios. - -See also --------- - -:doc:`pal2rgb` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcmp` (1), -:doc:`tiffcp` (1), -:doc:`tiffmedian` (1), -:doc:`tiffsplit` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffdither.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffdither.rst deleted file mode 100644 index 9183259b0..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffdither.rst +++ /dev/null @@ -1,93 +0,0 @@ -tiffdither -========== - -.. program:: tiffdither - -Synopsis --------- - -**tiffdither** [ *options* ] *input.tif* *output.tif* - -Description ------------ - -:program:`tiffdither` converts a single channel 8-bit greyscale image to a bilevel image -using Floyd-Steinberg error propagation with thresholding. - -Options -------- - -.. option:: -c compress - - Specify the compression to use for data written to the output file: - - =========== =================================== - Compression Description - =========== =================================== - none no compression - packbits PackBits compression - lzw Lempel-Ziv & Welch compression - zip Deflate compression - g3 CCITT Group 3 (T.4) compression - g4 for CCITT Group 4 (T.6) compression - =========== =================================== - - By default :program:`tiffdither` - will compress data according to the value of the - ``Compression`` tag found in the source file. - - The CCITT Group 3 and Group 4 compression algorithms can only - be used with bilevel data. - - Group 3 compression can be specified together with several - T.4-specific options: - ``1d`` for 1-dimensional encoding, - ``2d`` for 2-dimensional encoding, and - ``fill`` to force each encoded scanline to be zero-filled so that the - terminating EOL code lies on a byte boundary. - Group 3-specific options are specified by appending a ``:``-separated - list to the ``g3`` option; e.g. ``-c g3:2d:fill`` - to get 2D-encoded data with byte-aligned EOL codes. - - LZW compression can be specified together with a ``predictor`` value. - A predictor value of 2 causes each scanline of the output image to undergo - horizontal differencing before it is encoded; a value - of 1 forces each scanline to be encoded without differencing. - LZW-specific options are specified by appending a ``:``-separated - list to the ``lzw`` option; e.g. ``-c lzw:2`` for LZW - compression with horizontal differencing. - -.. option:: -f - - Specify the bit fill order to use in writing output data. - By default, :program:`tiffdither` - will create a new file with the same fill order as the original. - Specifying - :command:`-f lsb2msb` will force data to be written with the - ``FillOrder`` tag set to ``LSB2MSB``, while - :command:`-f msb2lsb` will force data to be written with the - ``FillOrder`` tag set to ``MSB2LSB``. - -.. option:: -r - - Make each strip have no more than the given number of rows. - -.. option:: -t - - Set the threshold value for dithering. - By default the threshold value is 128. - -Notes ------ - -The dither algorithm is taken from the :program:`tiffmedian` -program (written by Paul Heckbert). - -See also --------- - -:doc:`pal2rgb` (1), -:doc:`fax2tiff` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`tiff2bw` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffdump.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffdump.rst deleted file mode 100644 index 713f17dee..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffdump.rst +++ /dev/null @@ -1,52 +0,0 @@ -tiffdump -======== - -.. program:: tiffdump - -Synopsis --------- - -**tiffdump** [ *options* ] *name* … - -Description ------------ - -:program:`tiffdump` displays directory information from files created according -to the Tag Image File Format, Revision 6.0. -The header of each TIFF file (magic number, version, and first directory offset) -is displayed, followed by the tag contents of each directory in the file. -For each tag, the name, data type, count, and value(s) is displayed. -When the symbolic name for a tag or data type is known, the symbolic -name is displayed followed by it's numeric (decimal) value. -Tag values are displayed enclosed in ``<>`` characters immediately -preceded by the value of the count field. -For example, an ``ImageWidth`` -tag might be displayed as ``ImageWidth (256) SHORT (3) 1<800>``. - -:program:`tiffdump` is particularly useful for investigating the contents of -TIFF files that :program:`libtiff` does not understand. - -Options -------- - -.. option:: -h - - Force numeric data to be printed in hexadecimal rather than the - default decimal. - -.. option:: -m items - - Change the number of indirect data items that are printed. By default, this - will be 24. - -.. option:: -o offset - - Dump the contents of the IFD at the a particular file offset. - The file offset may be specified using the usual C-style syntax; - i.e. a leading ``0x`` for hexadecimal and a leading ``0`` for octal. - -See also --------- - -:doc:`tiffinfo` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffgt.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffgt.rst deleted file mode 100644 index ad83f4348..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffgt.rst +++ /dev/null @@ -1,186 +0,0 @@ -tiffgt -====== - -.. program:: tiffgt - -Synopsis --------- - -**tiffgt** [ *options* ] *input.tif* … - -Description ------------ - -:program:`tiffgt` displays one or more images stored using the -Tag Image File Format, Revision 6.0. - -:program:`tiffgt` correctly handles files with any of the following characteristics: - - .. list-table:: Supported tag values - :widths: 5 20 - :header-rows: 1 - - * - Tag - - Value - - * - BitsPerSample - - 1, 2, 4, 8, 16 - * - SamplesPerPixel - - 1, 3, 4 (the 4th sample is ignored) - * - PhotometricInterpretation - - 0 (min-is-white), 1 (min-is-black), 2 (RGB), 3 (palette), 6 (YCbCr) - * - PlanarConfiguration - - 1 (contiguous), 2 (separate) - * - Orientation - - 1 (top-left), 4 (bottom-left) - -Data may be organized as strips or tiles and may be -compressed with any of the compression algorithms supported -by the :program:`libtiff` library. - -For palette images (``PhotometricInterpretation=3``), :program:`tiffgt` -inspects the colormap values and assumes either 16-bit -or 8-bit values according to the maximum value. -That is, if no colormap entry greater than 255 is found, -:program:`tiffgt` assumes the colormap has only 8-bit values; otherwise -it assumes 16-bit values. -This inspection is done to handle old images written by -previous (incorrect) versions of -:program:`libtiff`. - -:program:`tiffgt` can be used to display multiple images one-at-a-time. -The left mouse button switches the display to the first image in the -*next* file in the list of files specified on the command line. -The right mouse button switches to the first image in the -*previous* file in the list. -The middle mouse button causes the first image in the first file -specified on the command line to be displayed. -In addition the following keyboard commands are recognized: - - .. list-table:: Action keys - :widths: 2 23 - :header-rows: 1 - - * - Key - - Description - - * - :kbd:`b` - - Use a ``PhotometricInterpretation`` - of ``MinIsBlack`` in displaying the current image - * - :kbd:`l` - - Use a ``FillOrder`` of lsb-to-msb in decoding the current image - * - :kbd:`m` - - Use a ``FillOrder`` of msb-to-lsb in decoding the current image - * - :kbd:`c` - - Use a colormap visual to display the current image - * - :kbd:`r` - - Use a true color (24-bit RGB) visual to display the current image - * - :kbd:`w` - - Use a ``PhotometricInterpretation`` of ``MinIsWhite`` in displaying - the current image - * - :kbd:`W` - - Toggle (enable/disable) display of warning messages from the - TIFF library when decoding images - * - :kbd:`E` - - Toggle (enable/disable) display of error messages from the - TIFF library when decoding images. - * - :kbd:`z` - - Reset all parameters to their default settings (``FillOrder``, - ``PhotometricInterpretation``, handling of warnings and errors) - * - :kbd:`PageUp` - - Display the previous image in the current file or the last - image in the previous file - * - :kbd:`PageDown` - - Display the next image in the current file or the first image - in the next file - * - :kbd:`Home` - - Display the first image in the current file - * - :kbd:`End` - - Display the last image in the current file (unimplemented) - -Options -------- - -.. option:: -c - - Force image display in a colormap window. - -.. option:: -d - - Specify an image to display by directory number. - By default the first image in the file is displayed. - Directories are numbered starting at zero. - -.. option:: -e - - Enable reporting of error messages from the TIFF library. - By default :program:`tiffgt` silently ignores images that cannot be read. - -.. option:: -f - - Force :program:`tiffgt` to run as a foreground process. - By default :program:`tiffgt` will place itself in the background once it - has opened the requested image file. - -.. option:: -l - - Force the presumed bit ordering to be LSB to MSB. - -.. option:: -m - - Force the presumed bit ordering to be MSB to LSB. - - -.. option:: -o - - Specify an image to display by directory offset. - By default the first image in the file is displayed. - Directories offsets may be specified using C-style syntax; - i.e. a leading ``0x`` for hexadecimal and a leading ``0`` for octal. - - -.. option:: -p - - Override the value of the ``PhotometricInterpretation`` - tag; the parameter may be one of: ``miniswhite`` , - ``minisblack``, ``rgb``, ``palette``, ``mask``, - ``separated``, ``ycbcr``, and ``cielab``. - -.. option:: -r - - Force image display in a full color window. - -.. option:: -s - - Stop on the first read error. - By default all errors in the input data are ignored and - :program:`tiffgt` - does it's best to display as much of an image as possible. - -.. option:: -w - - Enable reporting of warning messages from the TIFF library. - By default :program:`tiffgt` - ignores warning messages generated when reading an image. - -.. option:: -v - - Place information in the title bar describing - what type of window (full color or colormap) is being - used, the name of the input file, and the directory - index of the image (if non-zero). - By default, the window type is not shown in the title bar. - -Bugs ----- - -Images wider and taller than the display are silently truncated to avoid -crashing old versions of the window manager. - -See also --------- - -:doc:`tiffdump` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffinfo.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffinfo.rst deleted file mode 100644 index 864e1e8b3..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffinfo.rst +++ /dev/null @@ -1,65 +0,0 @@ -tiffinfo -======== - -.. program:: tiffinfo - -Synopsis --------- - -**tiffinfo** [ *options* ] *input.tif* … - -Description ------------ - -:program:`tiffinfo` displays information about files created according -to the Tag Image File Format, Revision 6.0. By default, the contents of -each TIFF directory in each file are displayed, with the value of each -tag shown symbolically (where sensible). - -Options -------- - -.. option:: -c - - Display the colormap and color/gray response curves, if present. - -.. option:: -D - - In addition to displaying the directory tags, - read and decompress all the data in each image (but not display it). - -.. option:: -d - - In addition to displaying the directory tags, - print each byte of decompressed data in hexadecimal. - -.. option:: -j - - Display any JPEG-related tags that are present. - -.. option:: -o - - Set the initial TIFF directory according to the specified file offset. - The file offset may be specified using the usual C-style syntax; - i.e. a leading ``0x`` for hexadecimal and a leading ``0`` for octal. - -.. option:: -s - - Display the offsets and byte counts for each data strip in a directory. - -.. option:: -z - - Enable strip chopping when reading image data. - -.. option:: -# - - Set the initial TIFF directory to *#*. - -See also --------- - -:doc:`pal2rgb`, -:doc:`tiffcp`, -:doc:`tiffcmp`, -:doc:`tiffmedian`, -:doc:`/functions/libtiff` diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffmedian.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffmedian.rst deleted file mode 100644 index db0f687c9..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffmedian.rst +++ /dev/null @@ -1,73 +0,0 @@ -tiffmedian -========== - -.. program:: tiffmedian - -Synopsis --------- - -**tiffmedian** [ *options* ] *input.tif* *output.tif* - -Description ------------ - -:program:`tiffmedian` applies the median cut algorithm to an RGB -image in *input.tif* to generate a palette image that is written to -*output.tif*. The generated colormap has, by default, 256 entries. -The image data is quantized by mapping each pixel to the closest color -values in the colormap. - -Options -------- - -.. option:: -c - - Specify the compression to use for data written to the output file: - :command:`-c none` for no compression, - :command:`-c packbits` for PackBits compression, - :command:`-c lzw` for Lempel-Ziv & Welch compression, - :command:`-c zip` for Deflate compression. - - By default :program:`tiffmedian` will compress data according to the - value of the ``Compression`` tag found in the source file. - - LZW compression can be specified together with a ``predictor`` value. - A predictor value of 2 causes each scanline of the output image to - undergo horizontal differencing before it is encoded; a value of 1 - forces each scanline to be encoded without differencing. - LZW-specific options are specified by appending a ``:``-separated - list to the ``lzw`` option; e.g. ``-c lzw:2`` for LZW compression - with horizontal differencing. - -.. option:: -C - - Specify the number of entries to use in the generated colormap. - By default all 256 entries/colors are used. - -.. option:: -f - - Apply Floyd-Steinberg dithering before selecting a colormap entry. - -.. option:: -r - - Specify the number of rows (scanlines) in each strip of data - written to the output file. By default, :program:`tiffmedian` - attempts to set the rows/strip that no more than 8 kilobytes of - data appear in a strip. - -Notes ------ - -This program is derived from Paul Heckbert's :program:`median` program. - -See also --------- - -:doc:`pal2rgb` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`tiffcmp` (1), -:doc:`/functions/libtiff` (3tiff), - -**"Color Image Quantization for Frame Buffer Display"**, -Paul Heckbert, SIGGRAPH proceedings, 1982, pp. 297-307. diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffset.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffset.rst deleted file mode 100644 index d58cecdc4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffset.rst +++ /dev/null @@ -1,82 +0,0 @@ -tiffset -======== - -.. program:: tiffset - -Synopsis --------- - -**tiffset** [ *options* ] *filename.tif* - -Description ------------ - -:program:`tiffset` sets the value of a TIFF header to a specified value -or removes an existing setting. - -Options -------- - -.. option:: -d dirnumber - - Change the current directory (starting at 0). - -.. option:: -s tagnumber [ count ] value … - - Set the value of the named tag to the value or values specified. - -.. option:: -sd diroffset - - Change the current directory by offset. - -.. option:: -sf tagnumber filename - - Set the value of the tag to the contents of filename. This option is - supported for ASCII tags only. - -.. option:: -u tagnumber - - Unset the tag. - -Examples --------- - -The following example sets the image description tag (270) of :file:`a.tif` to -the contents of the file :file:`descrip`: - -.. highlight:: shell - -:: - - tiffset -sf 270 descrip a.tif - -The following example sets the artist tag (315) of :file:`a.tif` to the string -``Anonymous``: - -:: - - tiffset -s 315 Anonymous a.tif - - -This example sets the resolution of the file :file:`a.tif` to 300 dpi: - -:: - - tiffset -s 296 2 a.tif - tiffset -s 282 300.0 a.tif - tiffset -s 283 300.0 a.tif - -Set the photometric interpretation of the third page of :file:`a.tif` to -min-is-black (ie. inverts it): - -:: - - tiffset -d 2 -s 262 1 a.tif - -See also --------- - -:doc:`tiffdump` (1), -:doc:`tiffinfo` (1), -:doc:`tiffcp` (1), -:doc:`/functions/libtiff` (3tiff) diff --git a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffsplit.rst b/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffsplit.rst deleted file mode 100644 index 8bddb9898..000000000 --- a/thirdparty/SDL2_image/external/libtiff/doc/tools/tiffsplit.rst +++ /dev/null @@ -1,52 +0,0 @@ -tiffsplit -========= - -.. program:: tiffsplit - -Synopsis --------- - -**tiffsplit** *src.tif* [ *prefix* ] - -Description ------------ - -:program:`tiffsplit` takes a multi-directory (page) TIFF -file and creates one or more single-directory (page) TIFF -files from it. -The output files are given names created by concatenating -a prefix, a lexically ordered suffix in the range [aaa--zzz], -the suffix :file:`.tif` -(e.g. :file:`xaaa.tif`, :file:`xaab.tif`, :file:`…`, :file:`xzzz.tif`). -If a prefix is not specified on the command line, the default prefix of -:file:`x` is used. - -Options -------- - -None. - -Exit status ------------ - -:program:`tiffsplit` exits with one of the following values: - -0: - - Success - -1: - - An error occurred either reading the input or writing results. - -Bugs ----- - -Only a select set of "known tags" are copied when splitting. - -See also --------- - -:doc:`tiffcp` (1), -:doc:`tiffinfo` (1), -:doc:`/functions/libtiff` (3tiff), diff --git a/thirdparty/SDL2_image/external/libtiff/html/BigTIFFProposal.html b/thirdparty/SDL2_image/external/libtiff/html/BigTIFFProposal.html new file mode 100644 index 000000000..c64909f2a --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/BigTIFFProposal.html @@ -0,0 +1,99 @@ + + + + Proposal to Implement BigTIFF Support in LibTiff + + +

Proposal to Implement BigTIFF Support in LibTiff

+

NEWS: We have located all four required sponsors. There are no more + open slots. We will issue appropriate press release shortly.

+

0. Summary

+

BigTIFF logically extends the original TIFF file format (referred to as + 'ClassicTIFF' from this point on), breaking the 4 gigabyte boundary, in theory + allowing files up to 18,000 petabytes in size. The BigTIFF specification is the + result of work by a variety of parties on the LibTiff mailing list, including + the current LibTiff maintainers, Joris Van Damme and Adobe staff. The BigTIFF + specification has not yet been officially approved by the TIFF specification + owner (Adobe) but implementation within LibTiff could accelerate that + process.

+

For more information on the BigTIFF file format, we recommend + AWare Systems' + BigTIFF page.

+

BigTIFF is expected to be especially useful for people and vendors that are + confronted with unusually large images, and still seek to use an open, simple, + and extendable format. This requirement is frequently seen in the geospatial + field, but also affects large format scanners, medical imaging and other + fields.

+

1. Sponsoring

+

It is planned that LibTiff 4.0, the BigTIFF upgrade to LibTiff, would start + March 1, 2007. A preliminary version (LibTiff 4.0alpha1) will be operational by + June 15, 2007. Testing and final release improvements for LibTiff 4.0 will be + completed by July 30, 2007.

+

The LibTiff BigTIFF upgrade team is seeking USD 24,000 from four sponsors (USD + 6,000 each) to fund the project. Sponsorship payment will be invoiced upon + delivery of the LibTiff 4.0alpha1 release (on or before June 15) with a 30 day + payable, giving time for some technical review.

+

In addition to the benefits of open interchange of BigTIFF data that comes from + support in a public and free open source codec, sponsors will be given proper + public acknowledgment. During development, they will be mentioned in the + appropriate sections of the LibTiff and AWare Systems site.

+

When LibTiff 4.0 with BigTIFF support is released, they will additionally + receive public acknowledgment in a formal press release, distributed widely to + news venues in the imaging and geospatial industries.

+

A 'migration guide' document or any functional equivalent thereof will be + included in the standard free distribution, but sponsors will additionally + receive up to 20 hours of consulting and support on any BigTIFF migration issues + that they may be facing, and/or any additional related requests they may have.

+

2. Development and Testing

+

The work will primarily be done by Joris Van Damme on behalf of his company + AWare Systems. Joris was closely involved in the drafting of the BigTIFF file + format proposal, and has also developed the proprietary AWare Systems TIFF + codec that already supports BigTIFF. Joris Van Damme has a deep understanding + of the TIFF format, and has been acting as a LibTiff co-maintainer for over a + year, contributing the upgraded OJPEG codec as well as several other + improvements.

+

Joris and AWare Systems have agreed to crosstest their proprietary codec and + LibTiff's support for BigTIFF extensively. Joris will also extend the test image + library included with LibTiff, with a number of varying BigTIFF test files. + These files will primarily include test files with issues that relate closely + to the BigTIFF file format and the difference with ClassicTIFF. For instance, + in BigTIFF the datatypes TIFF_LONG, TIFF_LONG8, TIFF_IFD and TIFF_IFD8 are all + valid for tags pointing to additional IFDs, and thus files will be included to + illustrate and enable testing all of these. Additionally, Joris will build a + tool to enable creating test files that exceed 4 gigabyte, as these can of + course not be included in the test suite in a more direct manner, and a tool to + convert files from ClassicTIFF to BigTIFF, as well as the other way around for + source BigTIFF files that do not exceed 4 gigabyte in size.

+

Frank Warmerdam has also agreed to be involved in a consulting and validation + role. Frank has been LibTiff's primary maintainer since approximately the year + 2000, develops large-image exploitation software for the geospatial industry + (GDAL) and is currently President of the Open Source Geospatial Foundation + (OSGeo). Frank will also be ensuring that BigTIFF improvements are made + accessible to all users of the GDAL library.

+

3. Implementation Strategy

+

Many people who have a need for BigTIFF, use LibTiff already. We thus plan to + support BigTIFF in LibTiff, applying a minimum change strategy much like the + one that was applied in the creation of the new file format in the first + place.

+

To support BigTIFF, we will use a 64bit integer datatype. It is anticipated + that some older platforms will not be able to comply with this need, and for + that reason we will encapsulate all required changes inside a conditional + compilation switch.

+

While it is anticipated that there will be ABI (application binary interface) + changes as part of a BigTIFF support upgrade to LibTiff, and possibly some + more to support other major upgrades to LibTiff, the plan is such that + the source level API will remain compatible for most LibTiff applications. + Applications using specialized interfaces may require some minor source code + changes, but we will provide backwards compatibility to support the majority + of existing application level code.

+

The resulting LibTiff version would transparently support reading traditional + 32bit ClassicTIFF files, and 64bit BigTIFF files, as well as writing either + ClassicTIFF or BigTIFF files based on a flag in the TIFFOpen/TIFFClientOpen call.

+

4. Intellectual Property and Licensing

+

The licensing agreement of LibTiff will remain unchanged.

+

5. Contact information

+

Please contact Frank Warmerdam and/or + Joris Van Damme for more information + on sponsorship agreements.

+ + \ No newline at end of file diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/JBIGCodec.cmake b/thirdparty/SDL2_image/external/libtiff/html/CMakeLists.txt similarity index 53% rename from thirdparty/SDL2_image/external/libtiff/cmake/JBIGCodec.cmake rename to thirdparty/SDL2_image/external/libtiff/html/CMakeLists.txt index a43500281..5f34e1e55 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/JBIGCodec.cmake +++ b/thirdparty/SDL2_image/external/libtiff/html/CMakeLists.txt @@ -1,7 +1,6 @@ -# Checks for JBIG codec support +# CMake build for libtiff # # Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh # Written by Roger Leigh # # Permission to use, copy, modify, distribute, and sell this software and @@ -23,25 +22,66 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +set(docfiles + addingtags.html + bugs.html + build.html + contrib.html + document.html + images.html + index.html + internals.html + intro.html + libtiff.html + misc.html + support.html + TIFFTechNote2.html + tools.html + v3.4beta007.html + v3.4beta016.html + v3.4beta018.html + v3.4beta024.html + v3.4beta028.html + v3.4beta029.html + v3.4beta031.html + v3.4beta032.html + v3.4beta033.html + v3.4beta034.html + v3.4beta035.html + v3.4beta036.html + v3.5.1.html + v3.5.2.html + v3.5.3.html + v3.5.4.html + v3.5.5.html + v3.5.6-beta.html + v3.5.7.html + v3.6.0.html + v3.6.1.html + v3.7.0alpha.html + v3.7.0beta.html + v3.7.0beta2.html + v3.7.0.html + v3.7.1.html + v3.7.2.html + v3.7.3.html + v3.7.4.html + v3.8.0.html + v3.8.1.html + v3.8.2.html + v3.9.0beta.html + v3.9.1.html + v3.9.2.html + v4.0.0.html + v4.0.1.html + v4.0.2.html + v4.0.3.html + v4.0.4beta.html) -# JBIG-KIT -set(JBIG_SUPPORT FALSE) +install(FILES ${docfiles} + DESTINATION "${LIBTIFF_DOCDIR}/html") -find_package(JBIG) - -if(JBIG_FOUND) - set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS}) - set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES}) - check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN) - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) -endif() - -option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ${JBIG_FOUND}) - -if (jbig AND JBIG_FOUND) - set(JBIG_SUPPORT TRUE) -endif() +add_subdirectory(images) +add_subdirectory(man) +extra_dist(${docfiles}) diff --git a/thirdparty/SDL2_image/external/libtiff/html/Makefile.am b/thirdparty/SDL2_image/external/libtiff/html/Makefile.am new file mode 100644 index 000000000..2929b8ed4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/Makefile.am @@ -0,0 +1,99 @@ +# +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2004, Andrey Kiselev +# +# 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. + +# Process this file with automake to produce Makefile.in. + +docdir = $(LIBTIFF_DOCDIR)/html + +docfiles = \ + addingtags.html \ + bugs.html \ + build.html \ + contrib.html \ + document.html \ + images.html \ + index.html \ + internals.html \ + intro.html \ + libtiff.html \ + misc.html \ + support.html \ + TIFFTechNote2.html \ + tools.html \ + v3.4beta007.html \ + v3.4beta016.html \ + v3.4beta018.html \ + v3.4beta024.html \ + v3.4beta028.html \ + v3.4beta029.html \ + v3.4beta031.html \ + v3.4beta032.html \ + v3.4beta033.html \ + v3.4beta034.html \ + v3.4beta035.html \ + v3.4beta036.html \ + v3.5.1.html \ + v3.5.2.html \ + v3.5.3.html \ + v3.5.4.html \ + v3.5.5.html \ + v3.5.6-beta.html \ + v3.5.7.html \ + v3.6.0.html \ + v3.6.1.html \ + v3.7.0alpha.html \ + v3.7.0beta.html \ + v3.7.0beta2.html \ + v3.7.0.html \ + v3.7.1.html \ + v3.7.2.html \ + v3.7.3.html \ + v3.7.4.html \ + v3.8.0.html \ + v3.8.1.html \ + v3.8.2.html \ + v3.9.0beta.html \ + v3.9.1.html \ + v3.9.2.html \ + v4.0.0.html \ + v4.0.1.html \ + v4.0.2.html \ + v4.0.3.html \ + v4.0.4beta.html \ + v4.0.4.html \ + v4.0.5.html \ + v4.0.6.html \ + v4.0.7.html \ + v4.0.8.html \ + v4.0.9.html \ + v4.0.10.html \ + v4.1.0.html \ + v4.2.0.html + +dist_doc_DATA = $(docfiles) + +SUBDIRS = images man + +EXTRA_DIST = \ + CMakeLists.txt diff --git a/thirdparty/SDL2_image/external/libtiff/doc/specification/technote2.rst b/thirdparty/SDL2_image/external/libtiff/html/TIFFTechNote2.html similarity index 61% rename from thirdparty/SDL2_image/external/libtiff/doc/specification/technote2.rst rename to thirdparty/SDL2_image/external/libtiff/html/TIFFTechNote2.html index 2133d576d..92bace466 100644 --- a/thirdparty/SDL2_image/external/libtiff/doc/specification/technote2.rst +++ b/thirdparty/SDL2_image/external/libtiff/html/TIFFTechNote2.html @@ -1,7 +1,6 @@ -DRAFT TIFF Technical Note #2 -############################ - -17-Mar-95 +
+DRAFT TIFF Technical Note #2				17-Mar-95
+============================
 
 This Technical Note describes serious problems that have been found in
 TIFF 6.0's design for embedding JPEG-compressed data in TIFF (Section 22
@@ -38,51 +37,51 @@ without sufficient thought for future extension and without regard to
 well-established TIFF conventions.  Here are some of the significant
 problems:
 
-* The ``JPEGxxTable`` fields do not store the table data directly in the
-  IFD/field structure; rather, the fields hold pointers to information
-  elsewhere in the file.  This requires special-purpose code to be added to
-  *every* TIFF-manipulating application, whether it needs to decode JPEG
-  image data or not.  Even a trivial TIFF editor, for example a program to
-  add an ``ImageDescription`` field to a TIFF file, must be explicitly aware of
-  the internal structure of the JPEG-related tables, or else it will probably
-  break the file.  Every other auxiliary field in the TIFF spec contains
-  data, not pointers, and can be copied or relocated by standard code that
-  doesn't know anything about the particular field.  This is a crucial
-  property of the TIFF format that must not be given up.
+* The JPEGxxTable fields do not store the table data directly in the
+IFD/field structure; rather, the fields hold pointers to information
+elsewhere in the file.  This requires special-purpose code to be added to
+*every* TIFF-manipulating application, whether it needs to decode JPEG
+image data or not.  Even a trivial TIFF editor, for example a program to
+add an ImageDescription field to a TIFF file, must be explicitly aware of
+the internal structure of the JPEG-related tables, or else it will probably
+break the file.  Every other auxiliary field in the TIFF spec contains
+data, not pointers, and can be copied or relocated by standard code that
+doesn't know anything about the particular field.  This is a crucial
+property of the TIFF format that must not be given up.
 
 * To manipulate these fields, the TIFF control logic is required to know a
-  great deal about JPEG details, for example such arcana as how to compute
-  the length of a Huffman code table --- the length is not supplied in the
-  field structure and can only be found by inspecting the table contents.
-  This is again a violation of good software practice.  Moreover, it will
-  prevent easy adoption of future JPEG extensions that might change these
-  low-level details.
-  
+great deal about JPEG details, for example such arcana as how to compute
+the length of a Huffman code table --- the length is not supplied in the
+field structure and can only be found by inspecting the table contents.
+This is again a violation of good software practice.  Moreover, it will
+prevent easy adoption of future JPEG extensions that might change these
+low-level details.
+
 * The design neglects the fact that baseline JPEG codecs support only two
-  sets of Huffman tables: it specifies a separate table for each color
-  component.  This implies that encoders must waste space (by storing
-  duplicate Huffman tables) or else violate the well-founded TIFF convention
-  that prohibits duplicate pointers.  Furthermore, baseline decoders must
-  test to find out which tables are identical, a waste of time and code
-  space.
+sets of Huffman tables: it specifies a separate table for each color
+component.  This implies that encoders must waste space (by storing
+duplicate Huffman tables) or else violate the well-founded TIFF convention
+that prohibits duplicate pointers.  Furthermore, baseline decoders must
+test to find out which tables are identical, a waste of time and code
+space.
 
-* The ``JPEGInterchangeFormat`` field also violates TIFF's proscription against
-  duplicate pointers: the normal strip/tile pointers are expected to point
-  into the larger data area pointed to by ``JPEGInterchangeFormat``.  All TIFF
-  editing applications must be specifically aware of this relationship, since
-  they must maintain it or else delete the ``JPEGInterchangeFormat field``.  The
-  ``JPEGxxTables`` fields are also likely to point into the ``JPEGInterchangeFormat``
-  area, creating additional pointer relationships that must be maintained.
+* The JPEGInterchangeFormat field also violates TIFF's proscription against
+duplicate pointers: the normal strip/tile pointers are expected to point
+into the larger data area pointed to by JPEGInterchangeFormat.  All TIFF
+editing applications must be specifically aware of this relationship, since
+they must maintain it or else delete the JPEGInterchangeFormat field.  The
+JPEGxxTables fields are also likely to point into the JPEGInterchangeFormat
+area, creating additional pointer relationships that must be maintained.
 
-* The ``JPEGQTables`` field is fixed at a byte per table entry; there is no
-  way to support 16-bit quantization values.  This is a serious impediment
-  to extending TIFF to use 12-bit JPEG.
+* The JPEGQTables field is fixed at a byte per table entry; there is no
+way to support 16-bit quantization values.  This is a serious impediment
+to extending TIFF to use 12-bit JPEG.
 
 * The 6.0 design cannot support using different quantization tables in
-  different strips/tiles of an image (so as to encode some areas at higher
-  quality than others).  Furthermore, since quantization tables are tied
-  one-for-one to color components, the design cannot support table switching
-  options that are likely to be added in future JPEG revisions.
+different strips/tiles of an image (so as to encode some areas at higher
+quality than others).  Furthermore, since quantization tables are tied
+one-for-one to color components, the design cannot support table switching
+options that are likely to be added in future JPEG revisions.
 
 
 Ambiguities
@@ -91,17 +90,17 @@ Ambiguities
 Several incompatible interpretations are possible for 6.0's treatment of
 JPEG restart markers:
 
-* It is unclear whether restart markers must be omitted at TIFF segment
-  (strip/tile) boundaries, or whether they are optional.
+  * It is unclear whether restart markers must be omitted at TIFF segment
+    (strip/tile) boundaries, or whether they are optional.
 
-* It is unclear whether the segment size is required to be chosen as
-  a multiple of the specified restart interval (if any); perhaps the
-  JPEG codec is supposed to be reset at each segment boundary as if
-  there were a restart marker there, even if the boundary does not fall
-  at a multiple of the nominal restart interval.
+  * It is unclear whether the segment size is required to be chosen as
+    a multiple of the specified restart interval (if any); perhaps the
+    JPEG codec is supposed to be reset at each segment boundary as if
+    there were a restart marker there, even if the boundary does not fall
+    at a multiple of the nominal restart interval.
 
-* The spec fails to address the question of restart marker numbering:
-  do the numbers begin again within each segment, or not?
+  * The spec fails to address the question of restart marker numbering:
+    do the numbers begin again within each segment, or not?
 
 That last point is particularly nasty.  If we make numbering begin again
 within each segment, we give up the ability to impose a TIFF strip/tile
@@ -162,15 +161,15 @@ extensions to the ISO standard.  It should also be far easier to implement
 using unmodified JPEG codecs.
 
 To reduce overhead in multi-segment TIFF files, we allow JPEG overhead
-tables to be stored just once in a ``JPEGTables`` auxiliary field.  This
+tables to be stored just once in a JPEGTables auxiliary field.  This
 feature does not violate the integrity of the JPEG datastreams, because it
 uses the notions of "tables-only datastreams" and "abbreviated image
 datastreams" as defined by the ISO standard.
 
 To prevent confusion with the old design, the new design is given a new
-``Compression`` tag value, ``Compression=7``.  Readers that need to handle
+Compression tag value, Compression=7.  Readers that need to handle
 existing 6.0 JPEG files may read both old and new files, using whatever
-interpretation of the 6.0 spec they did before.  ``Compression`` tag value 6
+interpretation of the 6.0 spec they did before.  Compression tag value 6
 and the field tag numbers defined by 6.0 section 22 will remain reserved
 indefinitely, even though detailed descriptions of them will be dropped
 from future editions of the TIFF specification.
@@ -250,13 +249,13 @@ ISO JPEG compression standard only.  The ISO standard is applied to the
 same data that would be stored in the TIFF file if no compression were
 used.  Therefore, if color conversion or downsampling are used, they must
 be reflected in the regular TIFF fields; these steps are not considered to
-be implicit in the JPEG compression tag value.  ``PhotometricInterpretation``
+be implicit in the JPEG compression tag value.  PhotometricInterpretation
 and related fields shall describe the color space actually stored in the
 file.  With the TIFF 6.0 field definitions, downsampling is permissible
-only for YCbCr data, and it must correspond to the ``YCbCrSubSampling`` field.
+only for YCbCr data, and it must correspond to the YCbCrSubSampling field.
 (Note that the default value for this field is not 1,1; so the default for
 YCbCr is to apply downsampling!)  It is likely that future versions of TIFF
-will provide additional ``PhotometricInterpretation`` values and a more general
+will provide additional PhotometricInterpretation values and a more general
 way of defining subsampling, so as to allow more flexibility in
 JPEG-compressed files.  But that issue is not addressed in this Tech Note.
 
@@ -266,11 +265,11 @@ downsampling, so that the application may supply full-size RGB data which
 is nonetheless converted to downsampled YCbCr.  This is an implementation
 convenience which does not excuse the TIFF control layer from its
 responsibility to know what is really going on.  The
-``PhotometricInterpretation`` and subsampling fields written to the file must
+PhotometricInterpretation and subsampling fields written to the file must
 describe what is actually in the file.
 
-A JPEG-compressed TIFF file will typically have ``PhotometricInterpretation =
-YCbCr`` and ``YCbCrSubSampling = [2,1]`` or ``[2,2]``, unless the source data was
+A JPEG-compressed TIFF file will typically have PhotometricInterpretation =
+YCbCr and YCbCrSubSampling = [2,1] or [2,2], unless the source data was
 grayscale or CMYK.
 
 
@@ -281,7 +280,7 @@ JPEG compression works in either strip-based or tile-based TIFF files.
 Rather than repeating "strip or tile" constantly, we will use the term
 "segment" to mean either a strip or a tile.
 
-When the ``Compression`` field has the value 7, each image segment contains
+When the Compression field has the value 7, each image segment contains
 a complete JPEG datastream which is valid according to the ISO JPEG
 standard (ISO/IEC 10918-1).  Any sequential JPEG process can be used,
 including lossless JPEG, but progressive and hierarchical processes are not
@@ -295,101 +294,97 @@ JPEG datastream according to the ISO JPEG standard's rules for
 interchange-format or abbreviated-image-format data.  The datastream shall
 contain a single JPEG frame storing that segment of the image.  The
 required JPEG markers within a segment are:
-
-* ``SOI`` (must appear at very beginning of segment)
-* ``SOFn``
-* ``SOS`` (one for each scan, if there is more than one scan)
-* ``EOI`` (must appear at very end of segment)
-
-The actual compressed data follows ``SOS``; it may contain ``RSTn`` markers if ``DRI``
+	SOI	(must appear at very beginning of segment)
+	SOFn
+	SOS	(one for each scan, if there is more than one scan)
+	EOI	(must appear at very end of segment)
+The actual compressed data follows SOS; it may contain RSTn markers if DRI
 is used.
 
-Additional JPEG "tables and miscellaneous" markers may appear between ``SOI``
-and ``SOFn``, between ``SOFn`` and ``SOS``, and before each subsequent ``SOS`` if there is
+Additional JPEG "tables and miscellaneous" markers may appear between SOI
+and SOFn, between SOFn and SOS, and before each subsequent SOS if there is
 more than one scan.  These markers include:
-
-* ``DQT``
-* ``DHT``
-* ``DAC`` (not to appear unless arithmetic coding is used)
-* ``DRI``
-* ``APPn`` (shall be ignored by TIFF readers)
-* ``COM`` (shall be ignored by TIFF readers)
-
-``DNL`` markers shall not be used in TIFF files.  Readers should abort if any
+	DQT
+	DHT
+	DAC	(not to appear unless arithmetic coding is used)
+	DRI
+	APPn	(shall be ignored by TIFF readers)
+	COM	(shall be ignored by TIFF readers)
+DNL markers shall not be used in TIFF files.  Readers should abort if any
 other marker type is found, especially the JPEG reserved markers;
 occurrence of such a marker is likely to indicate a JPEG extension.
 
 The tables/miscellaneous markers may appear in any order.  Readers are
-cautioned that although the ``SOFn`` marker refers to ``DQT`` tables, JPEG does not
-require those tables to precede the ``SOFn``, only the ``SOS``.  Missing-table
+cautioned that although the SOFn marker refers to DQT tables, JPEG does not
+require those tables to precede the SOFn, only the SOS.  Missing-table
 checks should be made when SOS is reached.
 
-If no ``JPEGTables`` field is used, then each image segment shall be a complete
+If no JPEGTables field is used, then each image segment shall be a complete
 JPEG interchange datastream.  Each segment must define all the tables it
 references.  To allow readers to decode segments in any order, no segment
 may rely on tables being carried over from a previous segment.
 
-When a ``JPEGTables`` field is used, image segments may omit tables that have
-been specified in the ``JPEGTables`` field.  Further details appear below.
+When a JPEGTables field is used, image segments may omit tables that have
+been specified in the JPEGTables field.  Further details appear below.
 
-The ``SOFn`` marker shall be of type ``SOF0`` for strict baseline JPEG data, of
-type ``SOF1`` for non-baseline lossy JPEG data, or of type ``SOF3`` for lossless
-JPEG data.  (``SOF9`` or ``SOF11`` would be used for arithmetic coding.)  All
+The SOFn marker shall be of type SOF0 for strict baseline JPEG data, of
+type SOF1 for non-baseline lossy JPEG data, or of type SOF3 for lossless
+JPEG data.  (SOF9 or SOF11 would be used for arithmetic coding.)  All
 segments of a JPEG-compressed TIFF image shall use the same JPEG
-compression process, in particular the same ``SOFn`` type.
+compression process, in particular the same SOFn type.
 
-The data precision field of the ``SOFn`` marker shall agree with the TIFF
-``BitsPerSample`` field.  (Note that when ``PlanarConfiguration=1``, this implies
-that all components must have the same ``BitsPerSample`` value; when
-``PlanarConfiguration=2``, different components could have different bit
-depths.)  For ``SOF0`` only precision 8 is permitted; for ``SOF1``, precision 8 or
-12 is permitted; for ``SOF3``, precisions 2 to 16 are permitted.
+The data precision field of the SOFn marker shall agree with the TIFF
+BitsPerSample field.  (Note that when PlanarConfiguration=1, this implies
+that all components must have the same BitsPerSample value; when
+PlanarConfiguration=2, different components could have different bit
+depths.)  For SOF0 only precision 8 is permitted; for SOF1, precision 8 or
+12 is permitted; for SOF3, precisions 2 to 16 are permitted.
 
-The image dimensions given in the ``SOFn`` marker shall agree with the logical
-dimensions of that particular strip or tile.  For strip images, the ``SOFn``
-image width shall equal ``ImageWidth`` and the height shall equal ``RowsPerStrip``,
-except in the last strip; its ``SOFn`` height shall equal the number of rows
-remaining in the ``ImageLength``.  (In other words, no padding data is counted
-in the ``SOFn`` dimensions.)  For tile images, each ``SOFn`` shall have width
-``TileWidth`` and height ``TileHeight``; adding and removing any padding needed in
+The image dimensions given in the SOFn marker shall agree with the logical
+dimensions of that particular strip or tile.  For strip images, the SOFn
+image width shall equal ImageWidth and the height shall equal RowsPerStrip,
+except in the last strip; its SOFn height shall equal the number of rows
+remaining in the ImageLength.  (In other words, no padding data is counted
+in the SOFn dimensions.)  For tile images, each SOFn shall have width
+TileWidth and height TileHeight; adding and removing any padding needed in
 the edge tiles is the concern of some higher level of the TIFF software.
-(The dimensional rules are slightly different when ``PlanarConfiguration=2``,
+(The dimensional rules are slightly different when PlanarConfiguration=2,
 as described below.)
 
 The ISO JPEG standard only permits images up to 65535 pixels in width or
-height, due to 2-byte fields in the ``SOFn`` markers.  In TIFF, this limits
+height, due to 2-byte fields in the SOFn markers.  In TIFF, this limits
 the size of an individual JPEG-compressed strip or tile, but the total
 image size can be greater.
 
-The number of components in the JPEG datastream shall equal ``SamplesPerPixel``
-for ``PlanarConfiguration=1``, and shall be 1 for ``PlanarConfiguration=2``.  The
+The number of components in the JPEG datastream shall equal SamplesPerPixel
+for PlanarConfiguration=1, and shall be 1 for PlanarConfiguration=2.  The
 components shall be stored in the same order as they are described at the
-TIFF field level.  (This applies both to their order in the ``SOFn`` marker,
+TIFF field level.  (This applies both to their order in the SOFn marker,
 and to the order in which they are scanned if multiple JPEG scans are
 used.)  The component ID bytes are arbitrary so long as each component
 within an image segment is given a distinct ID.  To avoid any possible
 confusion, we require that all segments of a TIFF image use the same ID
 code for a given component.
 
-In ``PlanarConfiguration 1``, the sampling factors given in ``SOFn`` markers shall
+In PlanarConfiguration 1, the sampling factors given in SOFn markers shall
 agree with the sampling factors defined by the related TIFF fields (or with
 the default values that are specified in the absence of those fields).
 
-When DCT-based JPEG is used in a strip TIFF file, ``RowsPerStrip`` is required
+When DCT-based JPEG is used in a strip TIFF file, RowsPerStrip is required
 to be a multiple of 8 times the largest vertical sampling factor, i.e., a
 multiple of the height of an interleaved MCU.  (For simplicity of
 specification, we require this even if the data is not actually
-interleaved.)  For example, if ``YCbCrSubSampling = [2,2]`` then ``RowsPerStrip``
+interleaved.)  For example, if YCbCrSubSampling = [2,2] then RowsPerStrip
 must be a multiple of 16.  An exception to this rule is made for
-single-strip images (``RowsPerStrip >= ImageLength``): the exact value of
-``RowsPerStrip`` is unimportant in that case.  This rule ensures that no data
+single-strip images (RowsPerStrip >= ImageLength): the exact value of
+RowsPerStrip is unimportant in that case.  This rule ensures that no data
 padding is needed at the bottom of a strip, except perhaps the last strip.
 Any padding required at the right edge of the image, or at the bottom of
 the last strip, is expected to occur internally to the JPEG codec.
 
-When DCT-based JPEG is used in a tiled TIFF file, ``TileLength`` is required
+When DCT-based JPEG is used in a tiled TIFF file, TileLength is required
 to be a multiple of 8 times the largest vertical sampling factor, i.e.,
-a multiple of the height of an interleaved MCU; and ``TileWidth`` is required
+a multiple of the height of an interleaved MCU; and TileWidth is required
 to be a multiple of 8 times the largest horizontal sampling factor, i.e.,
 a multiple of the width of an interleaved MCU.  (For simplicity of
 specification, we require this even if the data is not actually
@@ -407,20 +402,18 @@ the surrounding TIFF file.
 JPEGTables field
 ----------------
 
-The only auxiliary TIFF field added for ``Compression=7`` is the optional
-``JPEGTables`` field.  The purpose of ``JPEGTables`` is to predefine JPEG
+The only auxiliary TIFF field added for Compression=7 is the optional
+JPEGTables field.  The purpose of JPEGTables is to predefine JPEG
 quantization and/or Huffman tables for subsequent use by JPEG image
 segments.  When this is done, these rather bulky tables need not be
 duplicated in each segment, thus saving space and processing time.
-``JPEGTables`` may be used even in a single-segment file, although there is no
+JPEGTables may be used even in a single-segment file, although there is no
 space savings in that case.
 
-``JPEGTables``:
-
-  * Tag = 347 (15B.H)
-  * Type = UNDEFINED
-  * N = number of bytes in tables datastream, typically a few hundred
-
+JPEGTables:
+	Tag = 347 (15B.H)
+	Type = UNDEFINED
+	N = number of bytes in tables datastream, typically a few hundred
 JPEGTables provides default JPEG quantization and/or Huffman tables which
 are used whenever a segment datastream does not contain its own tables, as
 specified below.
@@ -437,33 +430,31 @@ file.
 
 When the JPEGTables field is present, it shall contain a valid JPEG
 "abbreviated table specification" datastream.  This datastream shall begin
-with ``SOI`` and end with ``EOI``.  It may contain zero or more JPEG "tables and
+with SOI and end with EOI.  It may contain zero or more JPEG "tables and
 miscellaneous" markers, namely:
-
-* ``DQT``
-* ``DHT``
-* ``DAC`` (not to appear unless arithmetic coding is used)
-* ``DRI``
-* ``APPn*`` (shall be ignored by TIFF readers)
-* ``COM`` (shall be ignored by TIFF readers)
-
-Since JPEG defines the ``SOI`` marker to reset the ``DAC`` and ``DRI`` state, these two
+	DQT
+	DHT
+	DAC	(not to appear unless arithmetic coding is used)
+	DRI
+	APPn	(shall be ignored by TIFF readers)
+	COM	(shall be ignored by TIFF readers)
+Since JPEG defines the SOI marker to reset the DAC and DRI state, these two
 markers' values cannot be carried over into any image datastream, and thus
-they are effectively no-ops in the ``JPEGTables`` field.  To avoid confusion,
-it is recommended that writers not place ``DAC`` or ``DRI`` markers in ``JPEGTables``.
+they are effectively no-ops in the JPEGTables field.  To avoid confusion,
+it is recommended that writers not place DAC or DRI markers in JPEGTables.
 However readers must properly skip over them if they appear.
 
-When ``JPEGTables`` is present, readers shall load the table specifications
-contained in ``JPEGTables`` before processing image segment datastreams.
+When JPEGTables is present, readers shall load the table specifications
+contained in JPEGTables before processing image segment datastreams.
 Image segments may simply refer to these preloaded tables without defining
 them.  An image segment can still define and use its own tables, subject to
 the restrictions below.
 
-An image segment may not redefine any table defined in ``JPEGTables``.  (This
+An image segment may not redefine any table defined in JPEGTables.  (This
 restriction is imposed to allow readers to process image segments in random
-order without having to reload ``JPEGTables`` between segments.)  Therefore, use
-of ``JPEGTables`` divides the available table slots into two groups: "global"
-slots are defined in ``JPEGTables`` and may be used but not redefined by
+order without having to reload JPEGTables between segments.)  Therefore, use
+of JPEGTables divides the available table slots into two groups: "global"
+slots are defined in JPEGTables and may be used but not redefined by
 segments; "local" slots are available for local definition and use in each
 segment.  To permit random access, a segment may not reference any local
 tables that it does not itself define.
@@ -472,27 +463,27 @@ tables that it does not itself define.
 Special considerations for PlanarConfiguration 2
 ------------------------------------------------
 
-In ``PlanarConfiguration`` 2, each image segment contains data for only one
+In PlanarConfiguration 2, each image segment contains data for only one
 color component.  To avoid confusing the JPEG codec, we wish the segments
 to look like valid single-channel (i.e., grayscale) JPEG datastreams.  This
-means that different rules must be used for the ``SOFn`` parameters.
+means that different rules must be used for the SOFn parameters.
 
-In ``PlanarConfiguration`` 2, the dimensions given in the ``SOFn`` of a subsampled
-component shall be scaled down by the sampling factors compared to the ``SOFn``
-dimensions that would be used in ``PlanarConfiguration`` 1.  This is necessary
+In PlanarConfiguration 2, the dimensions given in the SOFn of a subsampled
+component shall be scaled down by the sampling factors compared to the SOFn
+dimensions that would be used in PlanarConfiguration 1.  This is necessary
 to match the actual number of samples stored in that segment, so that the
 JPEG codec doesn't complain about too much or too little data.  In strip
 TIFF files the computed dimensions may need to be rounded up to the next
 integer; in tiled files, the restrictions on tile size make this case
 impossible.
 
-Furthermore, all ``SOFn`` sampling factors shall be given as 1.  (This is
+Furthermore, all SOFn sampling factors shall be given as 1.  (This is
 merely to avoid confusion, since the sampling factors in a single-channel
 JPEG datastream have no real effect.)
 
 Any downsampling will need to happen externally to the JPEG codec, since
 JPEG sampling factors are defined with reference to the full-precision
-component.  In ``PlanarConfiguration`` 2, the JPEG codec will be working on
+component.  In PlanarConfiguration 2, the JPEG codec will be working on
 only one component at a time and thus will have no reference component to
 downsample against.
 
@@ -508,50 +499,45 @@ themselves to this subset unless there is very good reason to do otherwise.
 
 Use the ISO baseline JPEG process: 8-bit data precision, Huffman coding,
 with no more than 2 DC and 2 AC Huffman tables.  Note that this implies
-``BitsPerSample`` = 8 for each component.  We recommend deviating from baseline
+BitsPerSample = 8 for each component.  We recommend deviating from baseline
 JPEG only if 12-bit data precision or lossless coding is required.
 
 Use no subsampling (all JPEG sampling factors = 1) for color spaces other
 than YCbCr.  (This is, in fact, required with the TIFF 6.0 field
 definitions, but may not be so in future revisions.)  For YCbCr, use one of
 the following choices:
-
-======================  =====================
-YCbCrSubSampling field  JPEG sampling factors
-======================  =====================
-1,1                     1h1v, 1h1v, 1h1v
-2,1                     2h1v, 1h1v, 1h1v
-2,2 (default value)     2h2v, 1h1v, 1h1v
-======================  =====================
-
+	YCbCrSubSampling field		JPEG sampling factors
+	1,1				1h1v, 1h1v, 1h1v
+	2,1				2h1v, 1h1v, 1h1v
+	2,2  (default value)		2h2v, 1h1v, 1h1v
 We recommend that RGB source data be converted to YCbCr for best compression
 results.  Other source data colorspaces should probably be left alone.
 Minimal readers need not support JPEG images with colorspaces other than
-YCbCr and grayscale (`PhotometricInterpretation` = 6 or 1).
+YCbCr and grayscale (PhotometricInterpretation = 6 or 1).
 
 A minimal reader also need not support JPEG YCbCr images with nondefault
-values of ``YCbCrCoefficients`` or ``YCbCrPositioning``, nor with values of
-``ReferenceBlackWhite`` other than [0,255,128,255,128,255].  (These values
+values of YCbCrCoefficients or YCbCrPositioning, nor with values of
+ReferenceBlackWhite other than [0,255,128,255,128,255].  (These values
 correspond to the RGB<=>YCbCr conversion specified by JFIF, which is widely
 implemented in JPEG codecs.)
 
-Writers are reminded that a ``ReferenceBlackWhite`` field *must* be included
-when ``PhotometricInterpretation`` is YCbCr, because the default
-``ReferenceBlackWhite`` values are inappropriate for YCbCr.
+Writers are reminded that a ReferenceBlackWhite field *must* be included
+when PhotometricInterpretation is YCbCr, because the default
+ReferenceBlackWhite values are inappropriate for YCbCr.
 
-If any subsampling is used, ``PlanarConfiguration=1`` is preferred to avoid the
-possibly-confusing requirements of ``PlanarConfiguration=2``.  In any case,
-readers are not required to support ``PlanarConfiguration=2``.
+If any subsampling is used, PlanarConfiguration=1 is preferred to avoid the
+possibly-confusing requirements of PlanarConfiguration=2.  In any case,
+readers are not required to support PlanarConfiguration=2.
 
 If possible, use a single interleaved scan in each image segment.  This is
-not legal JPEG if there are more than 4 ``SamplesPerPixel`` or if the sampling
+not legal JPEG if there are more than 4 SamplesPerPixel or if the sampling
 factors are such that more than 10 blocks would be needed per MCU; in that
 case, use a separate scan for each component.  (The recommended color
 spaces and sampling factors will not run into that restriction, so a
 minimal reader need not support more than one scan per segment.)
 
 To claim TIFF/JPEG compatibility, readers shall support multiple-strip TIFF
-files and the optional ``JPEGTables`` field; it is not acceptable to read only
+files and the optional JPEGTables field; it is not acceptable to read only
 single-datastream files.  Support for tiled TIFF files is strongly
 recommended but not required.
 
@@ -559,7 +545,7 @@ recommended but not required.
 Other recommendations for implementors
 --------------------------------------
 
-The TIFF tag ``Compression=7`` guarantees only that the compressed data is
+The TIFF tag Compression=7 guarantees only that the compressed data is
 represented as ISO JPEG datastreams.  Since JPEG is a large and evolving
 standard, readers should apply careful error checking to the JPEG markers
 to ensure that the compression process is within their capabilities.  In
@@ -574,12 +560,12 @@ software implementation.  It is desirable to check only one image segment
 to find out whether the fast hardware can be used.  Thus, writers should
 try to ensure that all segments of an image look as much "alike" as
 possible: there should be no variation in scan layout, use of options such
-as ``DRI``, etc.  Ideally, segments will be processed identically except
+as DRI, etc.  Ideally, segments will be processed identically except
 perhaps for using different local quantization or entropy-coding tables.
 
-Writers should avoid including "noise" JPEG markers (``COM`` and ``APPn`` markers).
+Writers should avoid including "noise" JPEG markers (COM and APPn markers).
 Standard TIFF fields provide a better way to transport any non-image data.
-Some JPEG codecs may change behavior if they see an ``APPn`` marker they
+Some JPEG codecs may change behavior if they see an APPn marker they
 think they understand; since the TIFF spec requires these markers to be
 ignored, this behavior is undesirable.
 
@@ -589,18 +575,18 @@ TIFF simply by dropping the interchange datastream into a single strip.
 strips; splitting the image is somewhat more work but may give better
 results.)  Conversion from TIFF to interchange JPEG is more complex.  A
 strip-based TIFF/JPEG file can be converted fairly easily if all strips use
-identical JPEG tables and no ``RSTn`` markers: just delete the overhead markers
-and insert ``RSTn`` markers between strips.  Converting tiled images is harder,
+identical JPEG tables and no RSTn markers: just delete the overhead markers
+and insert RSTn markers between strips.  Converting tiled images is harder,
 since the data will usually not be in the right order (unless the tiles are
 only one MCU high).  This can still be done losslessly, but it will require
 undoing and redoing the entropy coding so that the DC coefficient
 differences can be updated.
 
-There is no default value for ``JPEGTables``: standard TIFF files must define all
+There is no default value for JPEGTables: standard TIFF files must define all
 tables that they reference.  For some closed systems in which many files will
-have identical tables, it might make sense to define a default ``JPEGTables``
+have identical tables, it might make sense to define a default JPEGTables
 value to avoid actually storing the tables.  Or even better, invent a
-private field selecting one of N default ``JPEGTables`` settings, so as to allow
+private field selecting one of N default JPEGTables settings, so as to allow
 for future expansion.  Either of these must be regarded as a private
 extension that will render the files unreadable by other applications.
 
@@ -645,76 +631,77 @@ of JPEG compression on odd-size images.]
 Add the following paragraphs to the Section 21 introduction (p. 89),
 just after the paragraph beginning "When a Class Y image is subsampled":
 
-    In a subsampled image, it is understood that all TIFF image
-    dimensions are measured in terms of the highest-resolution
-    (luminance) component.  In particular, ``ImageWidth``, ``ImageLength``,
-    ``RowsPerStrip``, ``TileWidth``, ``TileLength``, ``XResolution``, and ``YResolution``
-    are measured in luminance samples.
+	In a subsampled image, it is understood that all TIFF image
+	dimensions are measured in terms of the highest-resolution
+	(luminance) component.  In particular, ImageWidth, ImageLength,
+	RowsPerStrip, TileWidth, TileLength, XResolution, and YResolution
+	are measured in luminance samples.
 
-    ``RowsPerStrip``, ``TileWidth``, and ``TileLength`` are constrained so that
-    there are an integral number of samples of each component in a
-    complete strip or tile.  However, ``ImageWidth``/``ImageLength`` are not
-    constrained.  If an odd-size image is to be converted to subsampled
-    format, the writer should pad the source data to a multiple of the
-    sampling factors by replication of the last column and/or row, then
-    downsample.  The number of luminance samples actually stored in the
-    file will be a multiple of the sampling factors.  Conversely,
-    readers must ignore any extra data (outside the specified image
-    dimensions) after upsampling.
+	RowsPerStrip, TileWidth, and TileLength are constrained so that
+	there are an integral number of samples of each component in a
+	complete strip or tile.  However, ImageWidth/ImageLength are not
+	constrained.  If an odd-size image is to be converted to subsampled
+	format, the writer should pad the source data to a multiple of the
+	sampling factors by replication of the last column and/or row, then
+	downsample.  The number of luminance samples actually stored in the
+	file will be a multiple of the sampling factors.  Conversely,
+	readers must ignore any extra data (outside the specified image
+	dimensions) after upsampling.
 
-    When ``PlanarConfiguration=2``, each strip or tile covers the same
-    image area despite subsampling; that is, the total number of strips
-    or tiles in the image is the same for each component.  Therefore
-    strips or tiles of the subsampled components contain fewer samples
-    than strips or tiles of the luminance component.
+	When PlanarConfiguration=2, each strip or tile covers the same
+	image area despite subsampling; that is, the total number of strips
+	or tiles in the image is the same for each component.  Therefore
+	strips or tiles of the subsampled components contain fewer samples
+	than strips or tiles of the luminance component.
 
-    If there are extra samples per pixel (see field ``ExtraSamples``),
-    these data channels have the same number of samples as the
-    luminance component.
+	If there are extra samples per pixel (see field ExtraSamples),
+	these data channels have the same number of samples as the
+	luminance component.
 
-Rewrite the ``YCbCrSubSampling`` field description (pp 91-92) as follows
+Rewrite the YCbCrSubSampling field description (pp 91-92) as follows
 (largely to eliminate possibly-misleading references to
-``ImageWidth``/``ImageLength`` of the subsampled components):
+ImageWidth/ImageLength of the subsampled components):
 
-    (first paragraph unchanged)
+	(first paragraph unchanged)
 
-    The two elements of this field are defined as follows:
+	The two elements of this field are defined as follows:
 
-    Short 0: ``ChromaSubsampleHoriz``:
+	Short 0: ChromaSubsampleHoriz:
 
-        1 = there are equal numbers of luma and chroma samples horizontally.
+	1 = there are equal numbers of luma and chroma samples horizontally.
 
-        2 = there are twice as many luma samples as chroma samples
-        horizontally.
+	2 = there are twice as many luma samples as chroma samples
+	horizontally.
 
-        4 = there are four times as many luma samples as chroma samples
-        horizontally.
+	4 = there are four times as many luma samples as chroma samples
+	horizontally.
 
-    Short 1: ``ChromaSubsampleVert``:
+	Short 1: ChromaSubsampleVert:
 
-        1 = there are equal numbers of luma and chroma samples vertically.
+	1 = there are equal numbers of luma and chroma samples vertically.
 
-        2 = there are twice as many luma samples as chroma samples
-        vertically.
+	2 = there are twice as many luma samples as chroma samples
+	vertically.
 
-        4 = there are four times as many luma samples as chroma samples
-        vertically.
+	4 = there are four times as many luma samples as chroma samples
+	vertically.
 
-    ``ChromaSubsampleVert`` shall always be less than or equal to
-    ``ChromaSubsampleHoriz``.  Note that Cb and Cr have the same sampling
-    ratios.
+	ChromaSubsampleVert shall always be less than or equal to
+	ChromaSubsampleHoriz.  Note that Cb and Cr have the same sampling
+	ratios.
 
-    In a strip TIFF file, ``RowsPerStrip`` is required to be an integer
-    multiple of ``ChromaSubSampleVert`` (unless ``RowsPerStrip >=
-    ImageLength``, in which case its exact value is unimportant).
-    If ``ImageWidth`` and ``ImageLength`` are not multiples of
-    ``ChromaSubsampleHoriz`` and ``ChromaSubsampleVert`` respectively, then the
-    source data shall be padded to the next integer multiple of these
-    values before downsampling.
+	In a strip TIFF file, RowsPerStrip is required to be an integer
+	multiple of ChromaSubSampleVert (unless RowsPerStrip >=
+	ImageLength, in which case its exact value is unimportant).
+	If ImageWidth and ImageLength are not multiples of
+	ChromaSubsampleHoriz and ChromaSubsampleVert respectively, then the
+	source data shall be padded to the next integer multiple of these
+	values before downsampling.
 
-    In a tiled TIFF file, ``TileWidth`` must be an integer multiple of
-    ``ChromaSubsampleHoriz`` and ``TileLength`` must be an integer multiple of
-    ``ChromaSubsampleVert``.  Padding will occur to tile boundaries.
+	In a tiled TIFF file, TileWidth must be an integer multiple of
+	ChromaSubsampleHoriz and TileLength must be an integer multiple of
+	ChromaSubsampleVert.  Padding will occur to tile boundaries.
 
-    The default values of this field are [ 2,2 ].  Thus, YCbCr data is
-    downsampled by default!
+	The default values of this field are [ 2,2 ].  Thus, YCbCr data is
+	downsampled by default!
+
diff --git a/thirdparty/SDL2_image/external/libtiff/html/addingtags.html b/thirdparty/SDL2_image/external/libtiff/html/addingtags.html new file mode 100644 index 000000000..bd4b972ae --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/addingtags.html @@ -0,0 +1,297 @@ + + + + +Modifying The TIFF Library + + + + + +

+Defining New TIFF Tags +

+ +Libtiff has built-in knowledge of all the standard TIFF tags, as +well as extensions. The following describes how to add knowledge of +new tags as builtins to libtiff, or how to application specific tags can +be used by applications without modifying libtiff. +

+ +

TIFFFieldInfo

+ +How libtiff manages specific tags is primarily controlled by the +definition for that tag value stored internally as a TIFFFieldInfo structure. +This structure looks like this: +

+ +

+typedef	struct {
+  ttag_t    field_tag;          /* field's tag */
+  short	    field_readcount;    /* read count/TIFF_VARIABLE/TIFF_SPP */
+  short	    field_writecount;   /* write count/TIFF_VARIABLE */
+  TIFFDataType field_type;      /* type of associated data */
+  unsigned short field_bit;     /* bit in fieldsset bit vector */
+  unsigned char field_oktochange;/* if true, can change while writing */
+  unsigned char field_passcount;/* if true, pass dir count on set */
+  char	*field_name;		/* ASCII name */
+} TIFFFieldInfo;
+
+ +
    +
  • field_tag: the tag number. For instance 277 for the +SamplesPerPixel tag. Builtin tags will generally have a #define in +tiff.h for each known tag.

    + +

  • field_readcount: The number of values which should be read. +The special value TIFF_VARIABLE (-1) indicates that a variable number of +values may be read. The special value TIFFTAG_SPP (-2) indicates that there +should be one value for each sample as defined by TIFFTAG_SAMPLESPERPIXEL. +The special value TIFF_VARIABLE2 (-3) is presumably similar to TIFF_VARIABLE +though I am not sure what the distinction in behaviour is. This field +is TIFF_VARIABLE for variable length ascii fields.

    + +

  • field_writecount: The number of values which should be written. +Generally the same as field_readcount. A few built-in exceptions exist, but +I haven't analysed why they differ.

    + +

  • field_type: Type of the field. One of TIFF_BYTE, TIFF_ASCII, +TIFF_SHORT, TIFF_LONG, TIFF_RATIONAL, TIFF_SBYTE, TIFF_UNDEFINED, +TIFF_SSHORT, TIFF_SLONG, TIFF_SRATIONAL, TIFF_FLOAT, TIFF_DOUBLE or +TIFF_IFD. Note that some fields can support more than one type (for +instance short and long). These fields should have multiple TIFFFieldInfos. +

    + +

  • field_bit: Built-in tags stored in special fields in the +TIFF structure have assigned field numbers to distinguish them (ie. +FIELD_SAMPLESPERPIXEL). New tags should generally just use +FIELD_CUSTOM indicating they are stored in the generic tag list.

    + +

  • field_oktochange: TRUE if it is OK to change this tag value +while an image is being written. FALSE for stuff that must be set once +and then left unchanged (like ImageWidth, or PhotometricInterpretation for +instance).

    + +

  • field_passcount: If TRUE, then the count value must be passed +in TIFFSetField(), and TIFFGetField(), otherwise the count is not required. +This should generally be TRUE for non-ascii variable count tags unless +the count is implicit (such as with the colormap).

    + +

  • field_name: A name for the tag. Normally mixed case (studly caps) +like "StripByteCounts" and relatively short.

    + +

+ +A TIFFFieldInfo definition exists for each built-in tag in the tif_dirinfo.c +file. Some tags which support multiple data types have more than one +definition, one per data type supported.

+ +Various functions exist for getting the internal TIFFFieldInfo definitions, +including _TIFFFindFieldInfo(), and _TIFFFindFieldInfoByName(). See +tif_dirinfo.c for details. There must be some mechanism to get the whole +list, though I don't see it off hand.

+ +

Default Tag Auto-registration

+ +In libtiff 3.6.0 a new mechanism was introduced allowing libtiff to +read unrecognised tags automatically. When an unknown tags is encountered, +it is automatically internally defined with a default name and a type +derived from the tag value in the file. Applications only need to predefine +application specific tags if they need to be able to set them in a file, or +if particular calling conventions are desired for TIFFSetField() and +TIFFGetField().

+ +When tags are autodefined like this the field_readcount and +field_writecount values are always TIFF_VARIABLE. The +field_passcount is always TRUE, and the field_bit is +FIELD_CUSTOM. The field name will be "Tag %d" where the %d is the tag +number.

+ +

Defining Application Tags

+ +For various reasons, it is common for applications to want to define +their own tags to store information outside the core TIFF specification. +This is done by calling TIFFMergeFieldInfo() with one or more TIFFFieldInfos. +

+ +The libgeotiff library provides geospatial information extensions within +a TIFF file. First, a set of TIFFFieldInfo's is prepared with information +on the new tags:

+ +

+static const TIFFFieldInfo xtiffFieldInfo[] = {
+  
+  /* XXX Insert Your tags here */
+    { TIFFTAG_GEOPIXELSCALE,	-1,-1, TIFF_DOUBLE,	FIELD_CUSTOM,
+      TRUE,	TRUE,	"GeoPixelScale" },
+    { TIFFTAG_GEOTRANSMATRIX,	-1,-1, TIFF_DOUBLE,	FIELD_CUSTOM,
+      TRUE,	TRUE,	"GeoTransformationMatrix" },
+    { TIFFTAG_GEOTIEPOINTS,	-1,-1, TIFF_DOUBLE,	FIELD_CUSTOM,
+      TRUE,	TRUE,	"GeoTiePoints" },
+    { TIFFTAG_GEOKEYDIRECTORY, -1,-1, TIFF_SHORT,	FIELD_CUSTOM,
+      TRUE,	TRUE,	"GeoKeyDirectory" },
+    { TIFFTAG_GEODOUBLEPARAMS,	-1,-1, TIFF_DOUBLE,	FIELD_CUSTOM,
+      TRUE,	TRUE,	"GeoDoubleParams" },
+    { TIFFTAG_GEOASCIIPARAMS,	-1,-1, TIFF_ASCII,	FIELD_CUSTOM,
+      TRUE,	FALSE,	"GeoASCIIParams" }
+};
+
+ +In order to define the tags, we call TIFFMergeFieldInfo() on the +desired TIFF handle with the list of TIFFFieldInfos.

+ +

+#define	N(a)	(sizeof (a) / sizeof (a[0]))
+
+    /* Install the extended Tag field info */
+    TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));
+
+ +The tags need to be defined for each TIFF file opened - and when reading +they should be defined before the tags of the file are read, yet a valid +TIFF * is needed to merge the tags against. In order to get them +registered at the appropriate part of the setup process, it is necessary +to register our merge function as an extender callback with libtiff. +This is done with TIFFSetTagExtender(). We also keep track of the +previous tag extender (if any) so that we can call it from our extender +allowing a chain of customizations to take effect.

+ +

+static TIFFExtendProc _ParentExtender = NULL;
+
+static
+void _XTIFFInitialize(void)
+{
+    static int first_time=1;
+	
+    if (! first_time) return; /* Been there. Done that. */
+    first_time = 0;
+	
+    /* Grab the inherited method and install */
+    _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory);
+}
+
+ +The extender callback is looks like this. It merges in our new fields +and then calls the next extender if there is one in effect.

+ +

+static void
+_XTIFFDefaultDirectory(TIFF *tif)
+{
+    /* Install the extended Tag field info */
+    TIFFMergeFieldInfo(tif, xtiffFieldInfo, N(xtiffFieldInfo));
+
+    /* Since an XTIFF client module may have overridden
+     * the default directory method, we call it now to
+     * allow it to set up the rest of its own methods.
+     */
+
+    if (_ParentExtender) 
+        (*_ParentExtender)(tif);
+}
+
+ +The above approach ensures that our new definitions are used when reading +or writing any TIFF file. However, since on reading we already have +default definitions for tags, it is usually not critical to pre-define them. +If tag definitions are only required for writing custom tags, you can just +call TIFFMergeFieldInfo() before setting new tags. The whole extender +architecture can then be avoided.

+ +

Adding New Builtin Tags

+

+A similar approach is taken to the above. However, the TIFFFieldInfo +should be added to the tiffFieldInfo[] list in tif_dirinfo.c. Ensure that +new tags are added in sorted order by the tag number.

+ +Normally new built-in tags should be defined with FIELD_CUSTOM; however, if +it is desirable for the tag value to have it's own field in the TIFFDirectory +structure, then you will need to #define a new FIELD_ value for it, and +add appropriate handling as follows: + + +

    +
  1. Define the tag in tiff.h. +
  2. Add a field to the directory structure in tif_dir.h + and define a FIELD_* bit (also update the definition of + FIELD_CODEC to reflect your addition). +
  3. Add an entry in the TIFFFieldInfo array defined at the top of + tif_dirinfo.c. + Note that you must keep this array sorted by tag + number and that the widest variant entry for a tag should come + first (e.g. LONG before SHORT). +
  4. Add entries in _TIFFVSetField() and _TIFFVGetField() + for the new tag. +
  5. (optional) If the value associated with the tag is not a scalar value + (e.g. the array for TransferFunction) and requires + special processing, + then add the appropriate code to TIFFReadDirectory() and + TIFFWriteDirectory(). You're best off finding a similar tag and + cribbing code. +
  6. Add support to TIFFPrintDirectory() in tif_print.c + to print the tag's value. +
+ +

+If you want to maintain portability, beware of making assumptions +about data types. Use the typedefs (uint16, etc. when dealing with +data on disk and t*_t when stuff is in memory) and be careful about +passing items through printf or similar vararg interfaces. + +

Adding New Codec-private Tags

+

+To add tags that are meaningful only when a particular compression +algorithm is used follow these steps: + +

    +
  1. Define the tag in tiff.h. +
  2. Allocate storage for the tag values in the private state block of + the codec. +
  3. Insure the state block is created when the codec is initialized. +
  4. At TIFFInitfoo time override the method pointers in the + TIFF structure + for getting, setting and printing tag values. For example, +
    +    sp->vgetparent = tif->tif_vgetfield;
    +    tif->tif_vgetfield = fooVGetField;	/* hook for codec tags */
    +    sp->vsetparent = tif->tif_vsetfield;
    +    tif->tif_vsetfield = fooVSetField;	/* hook for codec tags */
    +    tif->tif_printdir = fooPrintDir;	/* hook for codec tags */
    +
    + (Actually you may decide not to override the + tif_printdir method, but rather just specify it). +
  5. Create a private TIFFFieldInfo array for your tags and + merge them into the core tags at initialization time using + _TIFFMergeFieldInfo; e.g. +
    +    _TIFFMergeFieldInfo(tif, fooFieldInfo, N(fooFieldInfo));
    +
    + (where N is a macro used liberaly throughout the distributed code). +
  6. Fill in the get and set routines. Be sure to call the parent method + for tags that you are not handled directly. Also be sure to set the + FIELD_* bits for tags that are to be written to the file. Note that + you can create ``pseudo-tags'' by defining tags that are processed + exclusively in the get/set routines and never written to file (see + the handling of TIFFTAG_FAXMODE in tif_fax3.c + for an example of this). +
  7. Fill in the print routine, if appropriate. +
+ +Note that space has been allocated in the FIELD_* bit space for +codec-private tags. Define your bits as FIELD_CODEC+<offset> to +keep them away from the core tags. If you need more tags than there +is room for, just increase FIELD_SETLONGS at the top of +tiffiop.h. + +
+ +Last updated: $Date: 2016-09-25 20:05:44 $ + + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/bigtiffdesign.html b/thirdparty/SDL2_image/external/libtiff/html/bigtiffdesign.html new file mode 100644 index 000000000..814c28af1 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/bigtiffdesign.html @@ -0,0 +1,81 @@ + + + +BigTIFF Design + + + +

BigTIFF Design

+ +

This is the HTML equivalent of a former Wiki working place for preparing a 64-bit (larger than 4GB) TIFF +format specification. The design is based on a proposal by Steve Carlsen of Adobe, with input from various +other parties.

+ +

Briefly

+
    +
  • Version = 43
  • + +
  • 8-byte offset to first IFD
  • +
  • Value/Offset fields are 8 bytes
  • +
  • 8-byte offset to the next IFD
  • +
  • add TIFFType of LONG8, an 8 byte (unsigned) int
  • +
  • StripOffsets and TileOffsets and ByteCounts can be LONG8
  • +
+ +

More Detail

+
    +
  • The Version ID, in header bytes 2-3, formerly decimal 42, now changes to 43
  • + +
  • Header bytes 4-5 contain the decimal number 8.
      +
    • If there is some other number here, a reader should give up.
    • +
    • This is to provide a nice way to move to 16-byte pointers some day.
  • +
  • Header bytes 6-7 are reserved and must be zero.
      +
    • If they're not, a reader should give up.
  • +
  • Header bytes 8-15 contain the 8-byte offset to the first IFD.
  • +
  • Value/Offset fields are 8 bytes long, and take up bytes 8-15 in an IFD entry.
      + +
    • If the value is <= 8 bytes, it must be stored in the field.
    • +
    • All values must begin at an 8-byte-aligned address.
  • +
  • 8-byte offset to the Next_IFD, at the end of an IFD.
  • +
  • To keep IFD entries 8-byte-aligned, we begin with an 8-byte (instead of 2-byte) count of the number of directory entries.
  • +
  • Add TIFFTypes of LONG8 (= 16), an 8 byte (unsigned) int, and SLONG8 (= 17).
  • +
  • Add TIFFType IFD8 (=18) an 8byte IFD offset.
  • +
  • StripOffsets and TileOffsets and ByteCounts may be LONG8 or the traditionally allowed LONG or SHORT.
  • + +
  • The proposed extension is ".tf8", and call it "8-Byte TIFF".
  • +
+

Otherwise, it's just like "original TIFF." ("TIFF Classic?")

+ +

Open Issues

+
    +
  • What to call the new format
      +
    • ChrisCox -- I don't think end users will understand what "8-byte TIFF" means
    • +
    • AndreyKiselev - 23 Sep 2004 -- What about TIFF64? "64" is a widely used buzzword and should be directly associated with the 64-bit offsets and 64-bit architectures.
  • + +
  • What 3 character file extension to use (gotta be DOS compatible)
  • +
  • What 4 character file type to use (for Macintosh)
  • +
  • What MIME type to use
  • +
+ +

Samples

+

Example files from Joris Van Damme

+ +

Changes

+ +
    +
  • TIFFType 13 is ttIFD, 14 is assigned to ttUnicode, and 15 is assigned to ttComplex. So, I changed the types for ttLong8 and ttSLong8 to 16 and 17, respectively.
      +
    • AndreyKiselev - 23 Sep 2004 -- Where are these fields defined? Is there any new Technical Note or something? And what is encoding behind the word "Unicode"?
    • +
    • ChrisCox - 27 Sep 2004 -- They are in the Adobe TIFF definitions. I am still working on releasing updated TIFF documentation.
  • +
  • Added list of open issues.
  • +
  • settle on version 43
  • +
  • cleanup
  • +
  • TIFFType 18 (8 byte IFD) added.
  • + +
  • Clarified that fields which may be LONG8 can also be one of the old supported types.
  • +
+ +

See also

+

AWare Systems' informal overview of the BigTIFF proposal

+ + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/bigtiffpr.html b/thirdparty/SDL2_image/external/libtiff/html/bigtiffpr.html new file mode 100644 index 000000000..578c46f27 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/bigtiffpr.html @@ -0,0 +1,77 @@ + + + + Extending LibTiff library with support for the new BigTIFF format + + + + +

Extending LibTiff library with support for the new BigTIFF format

+

+ LibTiff maintainers have started work on LibTiff 4.0, + the next major upgrade of the time-proven TIFF + codec. This upgrade will include support for the new BigTIFF file format. It is planned a preliminary + version (LibTiff 4.0alpha1) will be operational by June 15, 2007. Testing and final release improvements + for LibTiff 4.0 will be completed by July 30, 2007. +

+

+ BigTIFF logically extends the original TIFF file format (referred to as 'ClassicTIFF' from now on), + breaking the 4 gigabyte boundary, with 64bit offsets allowing files up to 18,000 petabytes in size. The + BigTIFF specification is the result of work by a variety of parties on the LibTiff mailing list, including + the current LibTiff maintainers, Joris Van Damme and Adobe staff. The BigTIFF specification has not yet + been officially approved by the TIFF specification owner (Adobe), but implementation within LibTiff + could accelerate that process. For more information on the BigTIFF file format, we recommend AWare Systems' + BigTIFF page. +

+

+ BigTIFF will be especially useful for people and vendors that are confronted with very large images, and + still seek to use an open, simple, and extendable format. This requirement is frequently encountered in the + geospatial field, but also concerns large format scanners, medical imaging and other fields. +

+

+ The LibTiff BigTIFF upgrade is made possible by four sponsors funding the project. The programming work will + primarily be done by Joris Van Damme (AWare Systems). + LibTiff's licensing agreement will remain unchanged. More details on the project itself, are available from + the BigTIFF in LibTiff project page. +

+

+ The sponsors are, in alphabetical order: +

+ + + + + + + + + + + + + + + + + + + +
ESRIESRI has been giving customers around the world the power to + think and plan geographically since 1969. As the leader in GIS, ESRI applies innovative technologies to help + organizations create, analyze, and visualize information for more informed decisions. Running on more than + a million desktops and thousands of servers, ESRI applications are the foundation of the world's mapping and + spatial analysis infrastructure.
Leica Geosystems Geospatial ImagingLeica Geosystems Geospatial Imaging offers a + range of workflow solutions for photogrammetry, mapping, remote sensing, catalog management and exploitation + of geospatial imagery. Enterprise organizations use this imagery as the basis for generating information for + both education and decision making processes. Those who use Leica Geosystems products every day trust them + for their precision, seamless integration, interoperability and superior customer support.
Safe SoftwareSafe Software is the maker of FME, a powerful spatial ETL (Extract, + Transform and Load) tool that enables true data interoperability. FME manages the translation, + transformation, integration and web-based distribution of geospatial data in 200 GIS, CAD, raster and + database formats. Safe Software's FME technology is also embedded in numerous market-leading GIS and + ETL applications.
WeoGeoWeoGeo is a web-based data management resource for the geospatial + industry that allows the free market exchange of mapping related imagery products, featuring an innovative + solution that efficiently manages digital mapping files of any size. With an intuitive user interface + and the scalable power of Amazon Web Services (AWS), geospatial professionals can view, sort, search, + and share complex, high volume maps quickly and effectively.
+ + diff --git a/thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiffpr_images/esri.png b/thirdparty/SDL2_image/external/libtiff/html/bigtiffpr_images/esri.png similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiffpr_images/esri.png rename to thirdparty/SDL2_image/external/libtiff/html/bigtiffpr_images/esri.png diff --git a/thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiffpr_images/leica.png b/thirdparty/SDL2_image/external/libtiff/html/bigtiffpr_images/leica.png similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiffpr_images/leica.png rename to thirdparty/SDL2_image/external/libtiff/html/bigtiffpr_images/leica.png diff --git a/thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiffpr_images/safe.png b/thirdparty/SDL2_image/external/libtiff/html/bigtiffpr_images/safe.png similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiffpr_images/safe.png rename to thirdparty/SDL2_image/external/libtiff/html/bigtiffpr_images/safe.png diff --git a/thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiffpr_images/weogeo.png b/thirdparty/SDL2_image/external/libtiff/html/bigtiffpr_images/weogeo.png similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/specification/bigtiffpr_images/weogeo.png rename to thirdparty/SDL2_image/external/libtiff/html/bigtiffpr_images/weogeo.png diff --git a/thirdparty/SDL2_image/external/libtiff/html/bugs.html b/thirdparty/SDL2_image/external/libtiff/html/bugs.html new file mode 100644 index 000000000..a05a46592 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/bugs.html @@ -0,0 +1,67 @@ + + + +Bugs and the TIFF Mailing List + + + +

+cover +Bugs, Bugzilla, and the TIFF Mailing List +

+ +

+This software is free. Please let us know when you find a problem or +fix a bug. + +

+The project is using +GitLab issues since October 2019. +Previously, the project used MapTools.org +bugzilla to track bugs: remaining tickets in that bugzilla instance have been +migrated to GitLab issues. All bugs filed in a older bugzilla at +bugzilla.remotesensing.org (pre April 2008) have unfortunately been lost. +

+If you think you've discovered a bug, please first check to see if it is +already known by looking at the list of already reported bugs. Also verify that +the problem is still reproducible with the current development software +from CVS. +

+If you'd like to enter a new bug, you can do so at +https://gitlab.com/libtiff/libtiff/issues/new. +

+If you'd like to inform us about some kind of security issue that should not +be disclosed for a period of time, then you can contact maintainers directly. +Send a copies of your report to the following people: Frank Warmerdam +<warmerdam@pobox.com> and +Bob Friesenhahn +<bfriesen@simple.dallas.tx.us>. +

+ +Of course, reporting bugs is no substitute for discussion. The +tiff@lists.osgeo.org mailing +list is for users of this software, and discussion TIFF issues in general. +It is managed with the Mailman software, and the web interface for subscribing +and managing your access to the list is at:

+ + http://lists.osgeo.org/mailman/listinfo/tiff

+ +Posts to the list are only accepted from members of the list in order +to limit the amount of spam propagated.

+ +A Long Term +Archive including recent messages, and most messages back to 1993, +with search capabilities is available, and +has been prepared and hosted by AWare +Systems.

+ + +


+ +Last updated: 2019-10-01 + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/build.html b/thirdparty/SDL2_image/external/libtiff/html/build.html new file mode 100644 index 000000000..4186645b8 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/build.html @@ -0,0 +1,737 @@ + + + +Building the TIFF Software Distribution + + + +

cramps +Building the Software Distribution

+ +
+This chapter contains step-by-step instructions on how to configure +and build the TIFF software distribution. The software is most +easily built on a UNIX system, but with a little bit of work it can +easily be built and used on other non-UNIX platforms. +
+ +

Building on all systems with CMake

CMake may be used to +generate build files for most common build systems and IDEs, and +supports all UNIX-like systems as well as Windows. See +the CMake website for further +details. To build the software on you need to first run +cmake to configure the build and generate the system-specific +build files. This reads the top-level CMakeLists.txt file, +which probes the target system for necessary tools and functions, +checks any options you specified to configure the build, and then +outputs build files configured for your system. If using Unix +Makefiles, once configuration is done, you simply +run make (or gmake) to build the software and +then make install to do the installation. For other build +systems, you do the equivalent steps with the tool for that system. +For example, on any UNIX system: +
+
+% cd ./tiff-4.0.5
+% cmake
+    ...lots of messages...
+% make
+    ...lots of messages...
+% make test
+    ...lots of messages...
+# make install
+
+Building is dependent on a make utility and a C +(and optionally a C++ compiler), so you will need these tools. +

In general, the software is designed such that the following +targets will always be available

+
+
+make [all]      build stuff
+make test       run the test suite
+make install    build and install stuff
+make clean      remove object files, executables and cruft
+
+ +
+

Build Trees

+There are two schemes for configuring and building the software. If +you intend to build the software for only one target system, you +can configure the software so that it is built in the same +directories as the source code. +
+
+% gzip -dc tiff-4.0.5.tar.gz | tar -xf -
+% cd ./tiff-4.0.5
+% cmake
+% make
+% make test
+% make install
+
+

Otherwise, you can configure a build tree that is parallel to +the source tree hierarchy (or in some completely different place) +but which contains only configured files and files created during +the build procedure.

+
+
+% gzip -dc tiff-4.0.5.tar.gz | tar -xf -
+% mkdir tiff-4.0.5-build
+% cd ./tiff-4.0.5-build
+% cmake ../tiff-4.0.5
+% make
+% make test
+% make install
+
+This second scheme is useful for: +
    +
  • building multiple targets from a single source tree
  • +
  • building from a read-only source tree (e.g. if you receive the +distribution on CD-ROM)
  • +
  • sharing the source files via a network, but building on +multiple systems
  • +
  • keeping the source tree clean +(unlike autoconf, cmake does not provide +a distclean target, so out of source builds are +recommended)
  • +
+ +
+

Generators

The default generator for UNIX is Unix +Makefiles, and on Windows is NMake Makefiles or MSBuild +depending upon the setup. Run cmake --help to list all the +generators available for your platform. For example, to use the Ninja +build system on UNIX or +Windows: +
+cmake -G Ninja
+cmake --build .
+ctest -V
+cmake --build . --target install
+
+

Note that cmake --build . is a build-system-independent way +of building a target; you can always use the build system directly.

+

Alternatively, using the MSBuild system on Windows (64-bit Release +build with VS2013): +

+
+cmake -G "Visual Studio 12 2013 Win64"
+cmake --build . --config Release
+ctest -V -C Release
+cmake --build . --config Release --target install
+
+With the above configuration, it's also possible to open the generated +solution file with the Visual Studio IDE as well as building on the +command-line. + +
+

Configuration Options

+The configuration process is critical to the proper compilation, +installation, and operation of the +software. The CMakeLists.txt script runs a series of tests to +decide whether or not the target system supports required +functionality and, if it does not, whether it can emulate or +workaround the missing functions. After running cmake, check +the CMakeCache.txt file; this contains all the results of the +checks performed and the options set by the user. If cmake +failed to run, check CMakeFiles/CMakeOutput.log +and CMakeFiles/CMakeError.log; these should record the error +which caused the failure. +

A second function of the configure script is to set the default +configuration parameters for the software. Of particular note are the +directories where the software is to be installed. By default the +software is installed in the /usr/local hierarchy. To change +this behaviour the appropriate parameters can be specified on the +command line. Run cmake --help to get a full list of possible +options, and cmake -LH to list all the configurable options for +this software package, or cmake -LAH to show all advanced +options in addition. Standard installation related options are shown +below.

+
+
+Installation directories:
+  CMAKE_INSTALL_PREFIX
+
+Fine tuning of the installation directories:
+  CMAKE_INSTALL_BINDIR            user executables [PREFIX/bin]
+  CMAKE_INSTALL_SBINDIR           system admin executables [PREFIX/sbin]
+  CMAKE_INSTALL_LIBEXECDIR        program executables [PREFIX/libexec]
+  CMAKE_INSTALL_SYSCONFDIR        read-only single-machine data [PREFIX/etc]
+  CMAKE_INSTALL_SHAREDSTATEDIR    modifiable architecture-independent data [PREFIX/com]
+  CMAKE_INSTALL_LOCALSTATEDIR     modifiable single-machine data [PREFIX/var]
+  CMAKE_INSTALL_LIBDIR            object code libraries [PREFIX/lib]
+  CMAKE_INSTALL_INCLUDEDIR        C header files [PREFIX/include]
+  CMAKE_INSTALL_OLDINCLUDEDIR     C header files for non-gcc [/usr/include]
+  CMAKE_INSTALL_DATAROOTDIR       read-only arch.-independent data root [PREFIX/share]
+  CMAKE_INSTALL_DATADIR           read-only architecture-independent data [DATAROOTDIR]
+  CMAKE_INSTALL_LOCALEDIR         locale-dependent data [DATAROOTDIR/locale]
+  CMAKE_INSTALL_MANDIR            man documentation [DATAROOTDIR/man]
+  CMAKE_INSTALL_DOCDIR            documentation root [DATAROOTDIR/doc/tiff]
+
+
+Also see the +CMake documentation +for additional variables which may be set. + +
+

Configuring Optional Packages/Support

+The TIFF software comes with several packages that are installed +only as needed, or only if specifically configured at the time the +configure script is run. Packages can be configured via the +cmake commandline parameters. +
+
Static/Shared Objects Support
+
BUILD_SHARED_LIBS[=ON|OFF]    build shared +libraries [default=ON]
+

This option controls whether or not to configure the software +to build a shared and static binaries for the TIFF library. Use of +shared libraries can significantly reduce the disk space needed for +users of the TIFF software. If shared libraries are not used then +the code is statically linked into each application that uses it. +

+

ld-version-script[=ON|OFF]  Enable linker version +script (default is ON)

+

Add shared library symbol versioning on ELF-based systems (e.g. +Linux and FreeBSD) which use the GNU linker. This is needed if +several major versions of libtiff might be loaded at once into the +same program.

+
+
JPEG Support
+
jpeg[=ON|OFF]        enable IJG JPEG +library usage (required for JPEG compression, enabled by default)
+JPEG_INCLUDE_DIR=DIR location of IJG +JPEG library headers
+JPEG_LIBRARY=DIR     location of IJG JPEG +library binary)
+
The JPEG package enables support for the handling of +TIFF images with JPEG-encoded data. Support for JPEG-encoded data +requires the Independent JPEG Group (IJG) libjpeg +distribution; this software is available at http://www.ijg.org/. cmake +script automatically tries to search for a working IJG JPEG +installation. If it fails to find library, JPEG support will be +automatically disabled. If you want specify the exact paths to +library binary and headers, use above options for that.
+
ZIP Support
+
The ZIP support enables support for the handling of TIFF +images with deflate-encoded data (enabled by default if +available). Support for deflate-encoded data requires the freely +available zlib distribution written by Jean-loup Gailly and +Mark Adler; this software is available at http://www.zlib.org/.
+
+
+ +

Building on a UNIX System with Autoconf

+To build the software on a UNIX system you need to first run the +configure shell script that is located in the top level of the +source directory. This script probes the target system for +necessary tools and functions and constructs a build environment in +which the software may be compiled. Once configuration is done, you +simply run make (or gmake) to build the software +and then make install to do the installation; for example: +
+
+% cd ./tiff-4.0.5
+% ./configure
+    ...lots of messages...
+% make
+    ...lots of messages...
+% make check
+    ...lots of messages...
+# make install
+
+Supplied makefiles are dependent on a make utility and a C +(and optionally a C++ compiler), so you will need these tools. +

In general, the software is designed such that the following +should be ``make-able'' in each directory:

+
+
+make [all]      build stuff
+make check      run the test suite
+make install    build and install stuff
+make clean      remove object files, executables and cruft
+make distclean  remove everything, that can be recreated
+
+Note that after running "make distclean" the +configure script must be run again to create the Makefiles +and other make-related files. +
+

Build Trees

+There are two schemes for configuring and building the software. If +you intend to build the software for only one target system, you +can configure the software so that it is built in the same +directories as the source code. +
+
+% gzip -dc tiff-4.0.5.tar.gz | tar -xf -
+% cd ./tiff-4.0.5
+% ./configure
+% make
+% make check
+% make install
+
+

Otherwise, you can configure a build tree that is parallel to +the source tree hierarchy (or in some completely different place) +but which contains only configured files and files created during +the build procedure.

+
+
+% gzip -dc tiff-4.0.5.tar.gz | tar -xf -
+% mkdir tiff-4.0.5-build
+% cd ./tiff-4.0.5-build
+% ../tiff-4.0.5/configure
+% make
+% make check
+% make install
+
+This second scheme is useful for: +
    +
  • building multiple targets from a single source tree
  • +
  • building from a read-only source tree (e.g. if you receive the +distribution on CD-ROM)
  • +
  • sharing the source files via a network, but building on +multiple systems
  • +
+ +
+

Configuration Options

+The configuration process is critical to the proper compilation, +installation, and operation of the software. The configure script +runs a series of tests to decide whether or not the target system +supports required functionality and, if it does not, whether it can +emulate or workaround the missing functions. This procedure is +fairly complicated and, due to the nonstandard nature of most UNIX +systems, prone to error. The first time that you configure the +software for use you should check the output from the configure +script and look for anything that does not make sense for your +system. +

A second function of the configure script is to set the default +configuration parameters for the software. Of particular note are +the directories where the software is to be installed. By default +the software is installed in the /usr/local hierarchy. To +change this behaviour the appropriate parameters can be specified +on the command line to configure. Run ./configure --help to +get a full list of possible options. Standard installation related +options are shown below.

+
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [/usr/local]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, `make install' will install all the files in
+`/usr/local/bin', `/usr/local/lib' etc.  You can specify
+an installation prefix other than `/usr/local' using `--prefix',
+for instance `--prefix=$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/tiff]
+  --htmldir=DIR           html documentation [DOCDIR]
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+
+ +
+

Configuring Optional Packages/Support

+The TIFF software comes with several packages that are installed +only as needed, or only if specifically configured at the time the +configure script is run. Packages can be configured via the +configure script commandline parameters. +
+
Static/Shared Objects Support
+
--enable-shared[=PKGS]    build shared +libraries [default=yes]
+--enable-static[=PKGS]    build static +libraries [default=yes]
+

These options control whether or not to configure the software +to build a shared and static binaries for the TIFF library. Use of +shared libraries can significantly reduce the disk space needed for +users of the TIFF software. If shared libraries are not used then +the code is statically linked into each application that uses it. +By default both types of binaries is configured.

+

+--enable-rpath             Enable +runtime linker paths (-R libtool option)

+

Add library directories (see other options below) to the TIFF +library run-time linker path.

+

--enable-ld-version-script  Enable linker version +script (default is disabled)

+

Add shared library symbol versioning on ELF-based systems (e.g. +Linux and FreeBSD) which use the GNU linker. This is needed if +several major versions of libtiff might be loaded at once into the +same program.

+
+
JPEG Support
+
--disable-jpeg    disable IJG JPEG +library usage (required for JPEG compression, enabled by default) +--with-jpeg-include-dir=DIR    location of IJG +JPEG library headers +--with-jpeg-lib-dir=DIR    location of IJG JPEG +library binary)
+
The JPEG package enables support for the handling of +TIFF images with JPEG-encoded data. Support for JPEG-encoded data +requires the Independent JPEG Group (IJG) libjpeg +distribution; this software is available at http://www.ijg.org/. configure +script automatically tries to search for a working IJG JPEG +installation. If it fails to find library, JPEG support will be +automatically disabled. If you want specify the exact paths to +library binary and headers, use above switches for that.
+
ZIP Support
+
The ZIP support enables support for the handling of +TIFF images with deflate-encoded data. Support for deflate-encoded +data requires the freely available zlib distribution +written by Jean-loup Gailly and Mark Adler; this software is +available at http://www.zlib.org/. If ZIP support is +enabled the DIRS_LIBINC and DIR_GZLIB parameters +should also be set (see below). By default this package is not +configured.
+
+
+ +

Building the Software under Windows 2000/XP/7/8/10 with nmake

+With Microsoft Visual C++ installed, and properly configured for +commandline use (you will likely need to source VCVARS32.BAT in +AUTOEXEC.bAT or somewhere similar) you should be able to use the +provided makefile.vc. +

The source package is delivered using Unix line termination +conventions, which work with MSVC but do not work with Windows +'notepad'. If you use unzip from the Info-Zip package, you +can extract the files using Windows normal line termination +conventions with a command similar to:

+
+  unzip -aa -a tiff-4.0.5.zip
+
+

By default the nmake-based libtiff build does not depend on any +additional libraries. Normally libtiff should be built with at least +JPEG and ZIP support so that it can open JPEG and ZIP-compressed TIFF +files. In order to add additional libraries (e.g. libjpeg, zlib, +jbigkit), build those libraries according to their own particular +build instructions, and then edit 'nmake.opt' (using a capable +plain-text editor) to enable use of the libraries, including +specifying where the libraries are installed. It is also necessary to +edit libtiff/tiffconf.vc.h to enable the related configuration defines +(JPEG_SUPPORT, OJPEG_SUPPORT, PIXARLOG_SUPPORT, +ZIP_SUPPORT), or to disable features which are normally +included by default. Ignore the comment at the top of the +libtiff/tiffconf.vc.h file which says that it has no influence on the +build, because the statement is not true for Windows. Please note that +the nmake build copies tiffconf.vc.h to tiffconf.h, and copies +tif_config.vc.h to tif_config.h, overwriting any files which may be +present. Likewise, the 'nmake clean' step removes those files.

+

To build using the provided makefile.vc you may use:

+
+  C:\tiff-4.0.5> nmake /f makefile.vc clean
+  C:\tiff-4.0.5> nmake /f makefile.vc
+
+    or (the hard way)
+
+  C:\tiff-4.0.5> cd port
+  C:\tiff-4.0.5\port> nmake /f makefile.vc clean
+  C:\tiff-4.0.5\port> nmake /f makefile.vc
+  C:\tiff-4.0.5> cd ../libtiff
+  C:\tiff-4.0.5\libtiff> nmake /f makefile.vc clean
+  C:\tiff-4.0.5\libtiff> nmake /f makefile.vc
+  C:\tiff-4.0.5\libtiff> cd ..\tools
+  C:\tiff-4.0.5\tools> nmake /f makefile.vc clean
+  C:\tiff-4.0.5\tools> nmake /f makefile.vc
+
+

This will build the library +file libtiff\libtiff\libtiff.lib.

+

The makefile also builds a DLL (libtiff.dll) with an associated +import library (libtiff_i.lib). Any builds using libtiff will need to +include the LIBTIFF\LIBTIFF directory in the include path.

+

The libtiff\tools\makefile.vc should build .exe's for +all the standard TIFF tool programs.

+
+ +

Building the Software on a VMS System

+The VMS port was done by Karsten Spang (krs@kampsax.dk), who also "sort of" +maintains it. The VMS specific files are not in the main +directories. Instead they are placed under +[.CONTRIB.VMS...] in the distribution tree. Installation: +It is assumed that you have unpacked the tar file into a VMS +directory tree, in this text called DISK:[TIFF]. +
    +
  1. Move the VMS specific files to their proper directories. +
    +$ SET DEFAULT DISK:[TIFF.CONTRIB.VMS]
    +$ RENAME [.LIBTIFF]*.* [-.-.LIBTIFF]
    +$ RENAME [.TOOLS]*.* [-.-.TOOLS]
    +
  2. +
  3. Compile the library. +
    +$ SET DEFAULT DISK:[TIFF.LIBTIFF]
    +$ @MAKEVMS
    +
  4. +
  5. Compile the tools. +
    +$ SET DEFAULT DISK:[TIFF.TOOLS]
    +$ @MAKEVMS
    +
  6. +
  7. Define the programs. +
    +$ DEFINE TIFFSHR DISK:[TIFF.LIBTIFF]TIFFSHR
    +$ FAX2PS    :==$DISK:[TIFF.TOOLS]FAX2PS
    +$ FAX2TIFF  :==$DISK:[TIFF.TOOLS]FAX2TIFF
    +$ GIF2TIFF  :==$DISK:[TIFF.TOOLS]GIF2TIFF
    +$ PAL2RGB   :==$DISK:[TIFF.TOOLS]PAL2RGB
    +$ PPM2TIFF  :==$DISK:[TIFF.TOOLS]PPM2TIFF
    +$ RAS2TIFF  :==$DISK:[TIFF.TOOLS]RAS2TIFF
    +$ RGB2YCBCR :==$DISK:[TIFF.TOOLS]RGB2YCBCR
    +$ THUMBNAIL :==$DISK:[TIFF.TOOLS]THUMBNAIL
    +$ TIFF2BW   :==$DISK:[TIFF.TOOLS]TIFF2BW
    +$ TIFF2PS   :==$DISK:[TIFF.TOOLS]TIFF2PS
    +$ TIFFCMP   :==$DISK:[TIFF.TOOLS]TIFFCMP
    +$ TIFFCP    :==$DISK:[TIFF.TOOLS]TIFFCP
    +$ TIFFDITHER:==$DISK:[TIFF.TOOLS]TIFFDITHER
    +$ TIFFDUMP  :==$DISK:[TIFF.TOOLS]TIFFDUMP
    +$ TIFFINFO  :==$DISK:[TIFF.TOOLS]TIFFINFO
    +$ TIFFMEDIAN:==$DISK:[TIFF.TOOLS]TIFFMEDIAN
    +$ TIFFSPLIT :==$DISK:[TIFF.TOOLS]TIFFSPLIT
    +$ YCBCR     :==$DISK:[TIFF.TOOLS]YCBCR
    +
  8. +
+You will want to add these lines to your LOGIN.COM file, +after changing the name of the directory that you have used on your +machine. +

This release has been tested on OpenVMS/VAX 5.5-2, using VAX C +3.2. A previous release was tested under OpenVMS/AXP ?.? using DEC +C ?.?, it is believed that this release as well works on AXP. The +code contains some GNU C specific things. This does *not* imply, +however, that the VAX/GCC configuration has been tested, *it has +not*.

+

The command procedures (MAKEVMS.COM) for building the +library and tools, is believed to choose the correct options for +the VAX and AXP cases automatically.

+

On the AXP, IEEE floating point is used by default. If you want +VAX floating point, remove the /FLOAT=IEEE_FLOAT +qualifier, and change HAVE_IEEEFP=1 to +HAVE_IEEEFP=0 in the MAKEVMS.COM files in both +the libtiff and tools directories.

+

Compiling your own program on a VMS system:

+When compiling a source file in which you "#include +<tiffio.h>", use the following command +
+    $ CC/INCLUDE=DISK:[TIFF.LIBTIFF]
+
+This ensures that the header file is found. On the AXP, also add +/FLOAT=IEEE_FLOAT (if used when building the library). +

Linking your own program to the TIFF library on a VMS +system:

+You can link to the library in two ways: Either using the shareable +library, or using the object library. On the VAX these +possibilities are: +
    +
  1. Using the shareable TIFF library. +
    +$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/OPTIONS,SYS$INPUT:/OPTIONS
    +    SYS$SHARE:VAXCRTL/SHAREABLE
    +
  2. +
  3. Using the TIFF object library. +
    +$ LINK MY_PROGRAM, -
    +    DISK:[TIFF.LIBTIFF]TIFF/LIBRARY/INCLUDE=(TIF_FAX3SM,TIF_CODEC), -
    +    SYS$INPUT:/OPTIONS
    +    SYS$SHARE:VAXCRTL/SHAREABLE
    +
  4. +
+On AXP (and possibly also using DEC C on VAX) the corresponding +commands are +
    +
  1. Using the shareable TIFF library. +
    +$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/OPTIONS
    +
  2. +
  3. Using the TIFF object library. +
    +$ LINK MY_PROGRAM,DISK:[TIFF.LIBTIFF]TIFF/LIBRARY
    +
  4. +
+Method 1 uses the shortest link time and smallest .EXE +files, but it requires that TIFFSHR is defined as above at +link time and at run time. Using the compilation +procedure above, the tools are linked in this way. +

Method 2 gives somewhat longer link time and larger +.EXE files, but does not require TIFFSHR to be +defined. This method is recommended if you want to run your program +on another machine, and for some reason don't want to have the +library on that machine. If you plan to have more than one program +(including the tools) on the machine, it is recommended that you +copy the library to the other machine and use method 1.

+
+ +

Building the Software on Other Systems

+This section contains information that might be useful if you are +working on a non-UNIX system that is not directly supported. All +library-related files described below are located in the +libtiff directory. +

The library requires two files that are generated +on-the-fly. The file tif_fax3sm.c has the state +tables for the Group 3 and Group 4 decoders. This file is generated +by the mkg3states program on a UNIX system; for +example,

+
+
+
+cd libtiff
+cc -o mkg3states mkg3states.c
+rm -f tif_fax3sm.c
+./mkg3states -c const tif_fax3sm.c
+
+
+The -c option can be used to control whether or not the +resutling tables are generated with a const declaration. +The -s option can be used to specify a C storage class for +the table declarations. The -b option can be used to force +data values to be explicitly bracketed with ``{}'' (apparently +needed for some MS-Windows compilers); otherwise the structures are +emitted in as compact a format as possible. Consult the source code +for this program if you have questions. +

The second file required to build the library, version.h, +contains the version information returned by the +TIFFGetVersion routine. This file is built on most systems +using the mkversion program and the contents of the +VERSION and tiff.alpha files; for example,

+
+
+cd libtiff
+cc -o mkversion mkversion.c
+rm -f version.h
+./mkversion -v ../VERSION -a ../dist/tiff.alpha version.h
+
+

Otherwise, when building the library on a non-UNIX system be +sure to consult the files tiffcomp.h and tiffconf.h. +The former contains system compatibility definitions while the +latter is provided so that the software configuration can be +controlled on systems that do not support the make facility for +building the software.

+

Systems without a 32-bit compiler may not be able to handle some +of the codecs in the library; especially the Group 3 and 4 decoder. +If you encounter problems try disabling support for a particular +codec; consult the documentation.

+

Programs in the tools directory are written to assume an ANSI C +compilation environment. There may be a few POSIX'isms as well. The +code in the port directory is provided to emulate routines +that may be missing on some systems. On UNIX systems the +configure script automatically figures out which routines +are not present on a system and enables the use of the equivalent +emulation routines from the port directory. It may be +necessary to manually do this work on a non-UNIX system.

+
+

Checking out the Software

+

Assuming you have working versions of tiffgt and +tiffsv, you can just use them to view any of the sample +images available for testing (see the section +on obtaining the test images). Otherwise, you can do a cursory +check of the library with the tiffcp and tiffcmp +programs. For example,

+
+
+tiffcp -lzw cramps.tif x.tif
+tiffcmp cramps.tif x.tif
+
+

(tiffcmp should be silent if the files compare +correctly).

+
+

Table of Contents

+The following files makup the core library: +
+libtiff/tiff.h                  TIFF spec definitions
+libtiff/tiffcomp.h              non-UNIX OS-compatibility definitions
+libtiff/tiffconf.h              non-UNIX configuration definitions
+libtiff/tiffio.h                public TIFF library definitions
+libtiff/tiffiop.h               private TIFF library definitions
+libtiff/t4.h                    CCITT Group 3/4 code tables+definitions
+libtiff/tif_dir.h               private defs for TIFF directory handling
+libtiff/tif_fax3.h              CCITT Group 3/4-related definitions
+libtiff/tif_predict.h           private defs for Predictor tag support
+libtiff/uvcode.h                LogL/LogLuv codec-specific definitions
+libtiff/version.h               version string (generated by Makefile)
+libtiff/tif_apple.c             Apple-related OS support
+libtiff/tif_atari.c             Atari-related OS support
+libtiff/tif_aux.c               auxiliary directory-related functions
+libtiff/tif_close.c             close an open TIFF file
+libtiff/tif_codec.c             configuration table of builtin codecs
+libtiff/tif_compress.c          compression scheme support
+libtiff/tif_dir.c               directory tag interface code
+libtiff/tif_dirinfo.c           directory known tag support code
+libtiff/tif_dirread.c           directory reading code
+libtiff/tif_dirwrite.c          directory writing code
+libtiff/tif_dumpmode.c          "no" compression codec
+libtiff/tif_error.c             library error handler
+libtiff/tif_fax3.c              CCITT Group 3 and 4 codec
+libtiff/tif_fax3sm.c            G3/G4 state tables (generated by mkg3states)
+libtiff/tif_flush.c             i/o and directory state flushing
+libtiff/tif_getimage.c          TIFFRGBAImage support
+libtiff/tif_jpeg.c              JPEG codec (interface to the IJG distribution)
+libtiff/tif_luv.c               SGI LogL/LogLuv codec
+libtiff/tif_lzw.c               LZW codec
+libtiff/tif_msdos.c             MSDOS-related OS support
+libtiff/tif_next.c              NeXT 2-bit scheme codec (decoding only)
+libtiff/tif_open.c              open and simply query code
+libtiff/tif_packbits.c          Packbits codec
+libtiff/tif_pixarlog.c          Pixar codec
+libtiff/tif_predict.c           Predictor tag support
+libtiff/tif_print.c             directory printing support
+libtiff/tif_read.c              image data reading support
+libtiff/tif_strip.c             some strip-related code
+libtiff/tif_swab.c              byte and bit swapping support
+libtiff/tif_thunder.c           Thunderscan codec (decoding only)
+libtiff/tif_tile.c              some tile-related code
+libtiff/tif_unix.c              UNIX-related OS support
+libtiff/tif_version.c           library version support
+libtiff/tif_vms.c               VMS-related OS support
+libtiff/tif_warning.c           library warning handler
+libtiff/tif_win3.c              Windows-3.1-related OS support
+libtiff/tif_win32.c             Win32 (95/98/NT) related OS support
+libtiff/tif_write.c             image data writing support
+libtiff/tif_zip.c               Deflate codec
+
+libtiff/mkg3states.c            program to generate G3/G4 decoder state tables
+libtiff/mkspans.c               program to generate black-white span tables
+libtiff/mkversion.c             program to generate libtiff/version.h.
+
+
+Last updated: $Date: 2015-08-29 15:30:11 $ + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/contrib.html b/thirdparty/SDL2_image/external/libtiff/html/contrib.html new file mode 100644 index 000000000..9a6706580 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/contrib.html @@ -0,0 +1,212 @@ + + + + +Contributed TIFF Software + + + + +

+smallliz +Contributed TIFF Software +

+ + +

+The contrib directory has contributed software that +uses the TIFF library or which is associated with the library +(typically glue and guidance for ports to non-UNIX platforms, or tools that +aren't directly TIFF related). + +
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+contrib/vms + +scripts and files from Karsten Spang for building + the library and tools under VMS +
+contrib/dbs + +various tools from Dan & Chris Sears, including a simple X-based viewer +
+contrib/ras + +two programs by Patrick Naughton for converting + between Sun rasterfile format and TIFF (these + require libpixrect.a, as opposed to the one in + tools that doesn't) +
+contrib/mac-mpw
+contrib/mac-cw +
+scripts and files from Niles Ritter for building +the library and tools under Macintosh/MPW C and +code warrior. +
+contrib/acorn + +scripts and files from Peter Greenham for building + the library and tools on an Acorn RISC OS system. +
+contrib/win32 + +scripts and files from Scott Wagner for building +the library under Windows NT and Windows 95. (The makefile.vc in the +libtiff/libtiff directory may be sufficient for most users.) +
+contrib/win_dib + +two separate implementations of TIFF to DIB code suitable for any Win32 +platform. Contributed by Mark James, and Philippe Tenenhaus. +
+contrib/ojpeg + +Patch for IJG JPEG library related to support for some Old JPEG in TIFF files. +Contributed by Scott Marovich. +
+contrib/dosdjgpp + +scripts and files from Alexander Lehmann for building + the library under MSDOS with the DJGPP v2 compiler. +
+contrib/tags + +scripts and files from Niles Ritter for adding private + tag support at runtime, without changing libtiff. +
+contrib/mfs + +code from Mike Johnson to read+write images in memory +without modifying the library +
+contrib/pds + +various routines from Conrad Poelman; a TIFF image iterator and + code to support ``private sub-directories'' +
+contrib/iptcutil + + +A utility by Bill Radcliffe to +convert an extracted IPTC Newsphoto caption from a binary blob to +ASCII text, and vice versa. IPTC binary blobs can be extracted from +images via the ImageMagick convert(1) +utility. + + +
+contrib/addtiffo + + +A utility (and supporting subroutine) for building +one or more reduce resolution +overviews to an existing TIFF file. Supplied by +Frank Warmerdam. + +
+contrib/stream + + +A class (TiffStream) for accessing TIFF files through a C++ stream +interface. Supplied by Avi Bleiweiss. + +
+ +

+Questions regarding these packages are usually best directed toward +their authors. + +

+


+ +Last updated: $Date: 2016-09-25 20:05:44 $ + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/document.html b/thirdparty/SDL2_image/external/libtiff/html/document.html new file mode 100644 index 000000000..a97509330 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/document.html @@ -0,0 +1,57 @@ + + + + +TIFF Documentation + + + + +

+jim +TIFF Documentation +

+ +

+A copy of the 6.0 specification is available from Adobe at +http://partners.adobe.com/public/developer/en/tiff/TIFF6.pdf, or from the libtiff +ftp site at +https://download.osgeo.org/libtiff/doc/TIFF6.pdf.

+ +

+Draft TIFF Technical Note #2 covers problems +with the TIFF 6.0 design for embedding JPEG-compressed data in TIFF, and +describes an alternative.

+ +Other Adobe information on TIFF can be retrieved from: + + +http://partners.adobe.com/public/developer/tiff/index.html + +

+Joris Van Damme maintains a list of known tags and their descriptions and +definitions. It is available online at + +http://www.awaresystems.be/imaging/tiff/tifftags.html + +

+There is a FAQ, related both to TIFF format and libtiff library: + +http://www.awaresystems.be/imaging/tiff/faq.html + +

+There is a preliminary BigTIFF Design for +a TIFF variation supporting files larger than 4GB. + +


+ +
+ Last updated: $Date: 2016-09-25 20:05:44 $ +
+ + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/images.html b/thirdparty/SDL2_image/external/libtiff/html/images.html new file mode 100644 index 000000000..c93f38bf2 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/images.html @@ -0,0 +1,46 @@ + + + + +TIFF Test Images + + + + +

+bali +TIFF Test Images +

+ +

+Test images are available for most formats supported by the library. +Most of the images included in the test kit are also part of this +documentation (albeit in TIFF rather than GIF or JFIF). +The images are kept in a separate archive that should be located in +the same directory as this software. + +
+ +

+The latest archive of test images is located at + +https://download.osgeo.org/libtiff/pics-3.8.0.tar.gz + +

+There are two other good sources for TIFF test images: +the contributed software contrib/dbs includes several +programs that generate test images suitable for debugging, and +the tiffcp program can be used to generate a variety +of images with different storage characteristics. + +

+


+ +Last updated: $Date: 2016-09-25 20:05:44 $ + + + diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/LZMACodec.cmake b/thirdparty/SDL2_image/external/libtiff/html/images/CMakeLists.txt similarity index 78% rename from thirdparty/SDL2_image/external/libtiff/cmake/LZMACodec.cmake rename to thirdparty/SDL2_image/external/libtiff/html/images/CMakeLists.txt index c51afe828..e25f9f62c 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/LZMACodec.cmake +++ b/thirdparty/SDL2_image/external/libtiff/html/images/CMakeLists.txt @@ -1,7 +1,6 @@ -# Checks for LZMA codec support +# CMake build for libtiff # # Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh # Written by Roger Leigh # # Permission to use, copy, modify, distribute, and sell this software and @@ -23,12 +22,25 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +set(docfiles + back.gif + bali.jpg + cat.gif + cover.jpg + cramps.gif + dave.gif + info.gif + jello.jpg + jim.gif + note.gif + oxford.gif + quad.jpg + ring.gif + smallliz.jpg + strike.gif + warning.gif) -# liblzma2 -set(LZMA_SUPPORT FALSE) -find_package(liblzma) +install(FILES ${docfiles} + DESTINATION "${LIBTIFF_DOCDIR}/html/images") -option(lzma "use liblzma (required for LZMA2 compression)" ${LIBLZMA_FOUND}) -if (lzma AND LIBLZMA_FOUND) - set(LZMA_SUPPORT TRUE) -endif() +extra_dist(${docfiles}) diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/ReleaseScript.cmake b/thirdparty/SDL2_image/external/libtiff/html/images/Makefile.am similarity index 66% rename from thirdparty/SDL2_image/external/libtiff/cmake/ReleaseScript.cmake rename to thirdparty/SDL2_image/external/libtiff/html/images/Makefile.am index 31cdbfe38..979c8582a 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/ReleaseScript.cmake +++ b/thirdparty/SDL2_image/external/libtiff/html/images/Makefile.am @@ -1,32 +1,49 @@ -# Release support +# Tag Image File Format (TIFF) Software # -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh +# Copyright (C) 2004, Andrey Kiselev # -# Permission to use, copy, modify, distribute, and sell this software and +# Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -string(TIMESTAMP LIBTIFF_RELEASE_DATE "%Y%m%d") +# Process this file with automake to produce Makefile.in. -message(STATUS "Setting release version to ${LIBTIFF_VERSION}") -message(STATUS "Setting release date to ${LIBTIFF_RELEASE_DATE}") +docdir = $(LIBTIFF_DOCDIR)/html/images -configure_file("${SOURCE_DIR}/libtiff/tiffvers.h.cmake.in" - "${SOURCE_DIR}/libtiff/tiffvers.h" - @ONLY) +docfiles = \ + back.gif \ + bali.jpg \ + cat.gif \ + cover.jpg \ + cramps.gif \ + dave.gif \ + info.gif \ + jello.jpg \ + jim.gif \ + note.gif \ + oxford.gif \ + quad.jpg \ + ring.gif \ + smallliz.jpg \ + strike.gif \ + warning.gif + +dist_doc_DATA = $(docfiles) + +EXTRA_DIST = \ + CMakeLists.txt diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/back.gif b/thirdparty/SDL2_image/external/libtiff/html/images/back.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/back.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/back.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/bali.jpg b/thirdparty/SDL2_image/external/libtiff/html/images/bali.jpg similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/bali.jpg rename to thirdparty/SDL2_image/external/libtiff/html/images/bali.jpg diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/cat.gif b/thirdparty/SDL2_image/external/libtiff/html/images/cat.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/cat.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/cat.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/cover.jpg b/thirdparty/SDL2_image/external/libtiff/html/images/cover.jpg similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/cover.jpg rename to thirdparty/SDL2_image/external/libtiff/html/images/cover.jpg diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/cramps.gif b/thirdparty/SDL2_image/external/libtiff/html/images/cramps.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/cramps.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/cramps.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/dave.gif b/thirdparty/SDL2_image/external/libtiff/html/images/dave.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/dave.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/dave.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/info.gif b/thirdparty/SDL2_image/external/libtiff/html/images/info.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/info.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/info.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/jello.jpg b/thirdparty/SDL2_image/external/libtiff/html/images/jello.jpg similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/jello.jpg rename to thirdparty/SDL2_image/external/libtiff/html/images/jello.jpg diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/jim.gif b/thirdparty/SDL2_image/external/libtiff/html/images/jim.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/jim.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/jim.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/note.gif b/thirdparty/SDL2_image/external/libtiff/html/images/note.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/note.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/note.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/oxford.gif b/thirdparty/SDL2_image/external/libtiff/html/images/oxford.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/oxford.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/oxford.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/quad.jpg b/thirdparty/SDL2_image/external/libtiff/html/images/quad.jpg similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/quad.jpg rename to thirdparty/SDL2_image/external/libtiff/html/images/quad.jpg diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/ring.gif b/thirdparty/SDL2_image/external/libtiff/html/images/ring.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/ring.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/ring.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/smallliz.jpg b/thirdparty/SDL2_image/external/libtiff/html/images/smallliz.jpg similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/smallliz.jpg rename to thirdparty/SDL2_image/external/libtiff/html/images/smallliz.jpg diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/strike.gif b/thirdparty/SDL2_image/external/libtiff/html/images/strike.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/strike.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/strike.gif diff --git a/thirdparty/SDL2_image/external/libtiff/doc/images/warning.gif b/thirdparty/SDL2_image/external/libtiff/html/images/warning.gif similarity index 100% rename from thirdparty/SDL2_image/external/libtiff/doc/images/warning.gif rename to thirdparty/SDL2_image/external/libtiff/html/images/warning.gif diff --git a/thirdparty/SDL2_image/external/libtiff/html/index.html b/thirdparty/SDL2_image/external/libtiff/html/index.html new file mode 100644 index 000000000..fd7b5f775 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/index.html @@ -0,0 +1,120 @@ + + + + LibTIFF - TIFF Library and Utilities + + + + + +

LibTIFF - TIFF Library and Utilities

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Home Page #1http://www.simplesystems.org/libtiff/
Home Page #2https://libtiff.gitlab.io/libtiff/
Home Page #3http://libtiff.maptools.org/
Latest Stable Releasev4.2.0
Master Download Sitedownload.osgeo.org, directory libtiff
Mailing Listtiff@lists.osgeo.org, + Subscription, + Archive. + Please, read the TIFF FAQ + before asking questions.
git repositoryhttps://gitlab.com/libtiff/libtiff
+
+

+ This software provides support for the Tag Image File Format (TIFF), + a widely used format for storing image data. The latest version of + the TIFF specification is available on-line + in several different formats. +

+

+ Included in this software distribution is a library, libtiff, for + reading and writing TIFF, a small collection of tools for doing + simple manipulations of TIFF images, and documentation on the + library and tools. Libtiff is a portable software, it was built + and tested on various systems: UNIX flavors (Linux, BSD, Solaris, + MacOS X), Windows, and OpenVMS. It should be possible to port + libtiff and additional tools on other OSes. +

+

+ The library, along with associated tool programs, should handle most of + your needs for reading and writing TIFF images on 32- and 64-bit + machines. +

+

+ The software was originally authored and maintained by Sam Leffler + but has been maintained by a cast of others since 1999. +

+

+ Questions should be sent to the TIFF mailing list: + tiff@lists.osgeo.org, with + a subscription interface at + http://lists.osgeo.org/mailman/listinfo/tiff. +

+

+ The persons currently actively maintaining and releasing libtiff + are Even Rouault + and Bob Friesenhahn. +

+

Significant maintainers in the past (since the 3.5.1 release) are + Frank Warmerdam, + Andrey Kiselev, + Joris Van Damme, and Lee Howard. +

+

+ The following sections are included in this documentation: +

+ +

+ BigTIFF News +

+ +
+

+ Last updated 2019-11-03 +

+ + diff --git a/thirdparty/SDL2_image/external/libtiff/html/internals.html b/thirdparty/SDL2_image/external/libtiff/html/internals.html new file mode 100644 index 000000000..20061ef04 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/internals.html @@ -0,0 +1,583 @@ + + + + +Modifying The TIFF Library + + + + +

+dave +Modifying The TIFF Library +

+ + +

+This chapter provides information about the internal structure of +the library, how to control the configuration when building it, and +how to add new support to the library. +The following sections are found in this chapter: + +

+ + +
+

Library Configuration

+

+Information on compiling the library is given +elsewhere in this documentation. +This section describes the low-level mechanisms used to control +the optional parts of the library that are configured at build +time. Control is based on +a collection of C defines that are specified either on the compiler +command line or in a configuration file such as port.h +(as generated by the configure script for UNIX systems) +or tiffconf.h. + +

+Configuration defines are split into three areas: +

    +
  • those that control which compression schemes are + configured as part of the builtin codecs, +
  • those that control support for groups of tags that + are considered optional, and +
  • those that control operating system or machine-specific support. +
+ +

+If the define COMPRESSION_SUPPORT is not defined +then a default set of compression schemes is automatically +configured: +

    +
  • CCITT Group 3 and 4 algorithms (compression codes 2, 3, 4, and 32771), +
  • the Macintosh PackBits algorithm (compression 32773), +
  • a 4-bit run-length encoding scheme from ThunderScan (compression 32809), +
  • a 2-bit encoding scheme used by NeXT (compression 32766), and +
  • two experimental schemes intended for images with high dynamic range +(compression 34676 and 34677). +
+ +

+ +To override the default compression behaviour define +COMPRESSION_SUPPORT and then one or more additional defines +to enable configuration of the appropriate codecs (see the table +below); e.g. + +

+#define	COMPRESSION_SUPPORT
+#define	CCITT_SUPPORT
+#define	PACKBITS_SUPPORT
+
+ +Several other compression schemes are configured separately from +the default set because they depend on ancillary software +packages that are not distributed with libtiff. + +

+Support for JPEG compression is controlled by JPEG_SUPPORT. +The JPEG codec that comes with libtiff is designed for +use with release 5 or later of the Independent JPEG Group's freely +available software distribution. +This software can be retrieved from the directory +ftp.uu.net:/graphics/jpeg/. + + +

+NOTE: +Enabling JPEG support automatically enables support for +the TIFF 6.0 colorimetry and YCbCr-related tags. + +

+Experimental support for the deflate algorithm is controlled by +DEFLATE_SUPPORT. +The deflate codec that comes with libtiff is designed +for use with version 0.99 or later of the freely available +libz library written by Jean-loup Gailly and Mark Adler. +The data format used by this library is described +in the files +zlib-3.1.doc, +and +deflate-1.1.doc, +available in the directory +ftp.uu.net:/pub/archiving/zip/doc. +The library can be retried from the directory +ftp.uu.net:/pub/archiving/zip/zlib/ +(or try quest.jpl.nasa.gov:/beta/zlib/). + +

+NOTE: +The deflate algorithm is experimental. Do not expect +to exchange files using this compression scheme; +it is included only because the similar, and more common, +LZW algorithm is claimed to be governed by licensing restrictions. + + +

+By default tiffconf.h defines +COLORIMETRY_SUPPORT, +YCBCR_SUPPORT, +and +CMYK_SUPPORT. + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DefineDescription
CCITT_SUPPORTCCITT Group 3 and 4 algorithms (compression codes 2, 3, 4, + and 32771)
PACKBITS_SUPPORTMacintosh PackBits algorithm (compression 32773)
LZW_SUPPORTLempel-Ziv & Welch (LZW) algorithm (compression 5)
THUNDER_SUPPORT4-bit +run-length encoding scheme from ThunderScan (compression 32809)
NEXT_SUPPORT2-bit encoding scheme used by NeXT (compression 32766)
OJPEG_SUPPORTobsolete JPEG scheme defined in the 6.0 spec (compression 6)
JPEG_SUPPORTcurrent JPEG scheme defined in TTN2 (compression 7)
ZIP_SUPPORTexperimental Deflate scheme (compression 32946)
PIXARLOG_SUPPORTPixar's compression scheme for high-resolution color images (compression 32909)
SGILOG_SUPPORTSGI's compression scheme for high-resolution color images (compression 34676 and 34677)
COLORIMETRY_SUPPORTsupport for the TIFF 6.0 colorimetry tags
YCBCR_SUPPORTsupport for the TIFF 6.0 YCbCr-related tags
CMYK_SUPPORTsupport for the TIFF 6.0 CMYK-related tags
ICC_SUPPORTsupport for the ICC Profile tag; see +The ICC Profile Format Specification, +Annex B.3 "Embedding ICC Profiles in TIFF Files"; +available at +http://www.color.org +
+ +


+

General Portability Comments

+

+This software is developed on Silicon Graphics UNIX +systems (big-endian, MIPS CPU, 32-bit ints, +IEEE floating point). +The configure shell script generates the appropriate +include files and make files for UNIX systems. +Makefiles exist for non-UNIX platforms that the +code runs on -- this work has mostly been done by other people. + +

+In general, the code is guaranteed to work only on SGI machines. +In practice it is highly portable to any 32-bit or 64-bit system and much +work has been done to insure portability to 16-bit systems. +If you encounter portability problems please return fixes so +that future distributions can be improved. + +

+The software is written to assume an ANSI C compilation environment. +If your compiler does not support ANSI function prototypes, const, +and <stdarg.h> then you will have to make modifications to the +software. In the past I have tried to support compilers without const +and systems without <stdarg.h>, but I am +no longer interested in these +antiquated environments. With the general availability of +the freely available GCC compiler, I +see no reason to incorporate modifications to the software for these +purposes. + +

+An effort has been made to isolate as many of the +operating system-dependencies +as possible in two files: tiffcomp.h and +libtiff/tif_<os>.c. The latter file contains +operating system-specific routines to do I/O and I/O-related operations. +The UNIX (tif_unix.c), +Macintosh (tif_apple.c), +and VMS (tif_vms.c) +code has had the most use; +the MS/DOS support (tif_msdos.c) assumes +some level of UNIX system call emulation (i.e. +open, +read, +write, +fstat, +malloc, +free). + +

+Native CPU byte order is determined on the fly by +the library and does not need to be specified. +The HOST_FILLORDER and HOST_BIGENDIAN +definitions are not currently used, but may be employed by +codecs for optimization purposes. + +

+The following defines control general portability: + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
BSDTYPESDefine this if your system does NOT define the + usual BSD typedefs: u_char, + u_short, u_int, u_long.
HAVE_IEEEFPDefine this as 0 or 1 according to the floating point + format suported by the machine. If your machine does + not support IEEE floating point then you will need to + add support to tif_machdep.c to convert between the + native format and IEEE format.
HAVE_MMAPDefine this if there is mmap-style support for +mapping files into memory (used only to read data).
HOST_FILLORDERDefine the native CPU bit order: one of FILLORDER_MSB2LSB + or FILLORDER_LSB2MSB
HOST_BIGENDIANDefine the native CPU byte order: 1 if big-endian (Motorola) + or 0 if little-endian (Intel); this may be used + in codecs to optimize code
+ +

+On UNIX systems HAVE_MMAP is defined through the running of +the configure script; otherwise support for memory-mapped +files is disabled. +Note that tiffcomp.h defines HAVE_IEEEFP to be +1 (BSDTYPES is not defined). + + +


+

Types and Portability

+

+The software makes extensive use of C typedefs to promote portability. +Two sets of typedefs are used, one for communication with clients +of the library and one for internal data structures and parsing of the +TIFF format. There are interactions between these two to be careful +of, but for the most part you should be able to deal with portability +purely by fiddling with the following machine-dependent typedefs: + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
uint88-bit unsigned integertiff.h
int88-bit signed integertiff.h
uint1616-bit unsigned integertiff.h
int1616-bit signed integertiff.h
uint3232-bit unsigned integertiff.h
int3232-bit signed integertiff.h
dblparam_tpromoted type for floatstiffcomp.h
+ +

+(to clarify dblparam_t, it is the type that float parameters are +promoted to when passed by value in a function call.) + +

+The following typedefs are used throughout the library and interfaces +to refer to certain objects whose size is dependent on the TIFF image +structure: + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
typedef unsigned int ttag_t; directory tag
typedef uint16 tdir_t; directory index
typedef uint16 tsample_t; sample number
typedef uint32 tstrip_t; strip number
typedef uint32 ttile_t; tile number
typedef int32 tsize_t; i/o size in bytes
typedef void* tdata_t; image data ref
typedef void* thandle_t; client data handle
typedef int32 toff_t; file offset (should be off_t)
typedef unsigned char* tidata_t; internal image data
+ +

+Note that tstrip_t, ttile_t, and tsize_t +are constrained to be +no more than 32-bit quantities by 32-bit fields they are stored +in in the TIFF image. Likewise tsample_t is limited by the 16-bit +field used to store the SamplesPerPixel tag. tdir_t +constrains +the maximum number of IFDs that may appear in an image and may +be an arbitrary size (without penalty). ttag_t must be either +int, unsigned int, pointer, or double +because the library uses a varargs +interface and ANSI C restricts the type of the parameter before an +ellipsis to be a promoted type. toff_t is defined as +int32 because +TIFF file offsets are (unsigned) 32-bit quantities. A signed +value is used because some interfaces return -1 on error (sigh). +Finally, note that tidata_t is used internally to the library to +manipulate internal data. User-specified data references are +passed as opaque handles and only cast at the lowest layers where +their type is presumed. + + +


+

General Comments

+

+The library is designed to hide as much of the details of TIFF from +applications as +possible. In particular, TIFF directories are read in their entirety +into an internal format. Only the tags known by the library are +available to a user and certain tag data may be maintained that a user +does not care about (e.g. transfer function tables). + +


+

Adding New Builtin Codecs

+

+ +To add builtin support for a new compression algorithm, you can either +use the "tag-extension" trick to override the handling of the +TIFF Compression tag (see Adding New Tags), +or do the following to add support directly to the core library: + +

    +
  1. Define the tag value in tiff.h. +
  2. Edit the file tif_codec.c to add an entry to the + _TIFFBuiltinCODECS array (see how other algorithms are handled). +
  3. Add the appropriate function prototype declaration to + tiffiop.h (close to the bottom). +
  4. Create a file with the compression scheme code, by convention files + are named tif_*.c (except perhaps on some systems where the + tif_ prefix pushes some filenames over 14 chars. +
  5. Edit Makefile.in (and any other Makefiles) + to include the new source file. +
+ +

+A codec, say foo, can have many different entry points: + +

+TIFFInitfoo(tif, scheme)/* initialize scheme and setup entry points in tif */
+fooSetupDecode(tif)	/* called once per IFD after tags has been frozen */
+fooPreDecode(tif, sample)/* called once per strip/tile, after data is read,
+			    but before the first row is decoded */
+fooDecode*(tif, bp, cc, sample)/* decode cc bytes of data into the buffer */
+    fooDecodeRow(...)	/* called to decode a single scanline */
+    fooDecodeStrip(...)	/* called to decode an entire strip */
+    fooDecodeTile(...)	/* called to decode an entire tile */
+fooSetupEncode(tif)	/* called once per IFD after tags has been frozen */
+fooPreEncode(tif, sample)/* called once per strip/tile, before the first row in
+			    a strip/tile is encoded */
+fooEncode*(tif, bp, cc, sample)/* encode cc bytes of user data (bp) */
+    fooEncodeRow(...)	/* called to decode a single scanline */
+    fooEncodeStrip(...)	/* called to decode an entire strip */
+    fooEncodeTile(...)	/* called to decode an entire tile */
+fooPostEncode(tif)	/* called once per strip/tile, just before data is written */
+fooSeek(tif, row)	/* seek forwards row scanlines from the beginning
+			   of a strip (row will always be >0 and <rows/strip */
+fooCleanup(tif)		/* called when compression scheme is replaced by user */
+
+ +

+Note that the encoding and decoding variants are only needed when +a compression algorithm is dependent on the structure of the data. +For example, Group 3 2D encoding and decoding maintains a reference +scanline. The sample parameter identifies which sample is to be +encoded or decoded if the image is organized with PlanarConfig=2 +(separate planes). This is important for algorithms such as JPEG. +If PlanarConfig=1 (interleaved), then sample will always be 0. + +


+

Other Comments

+

+The library handles most I/O buffering. There are two data buffers +when decoding data: a raw data buffer that holds all the data in a +strip, and a user-supplied scanline buffer that compression schemes +place decoded data into. When encoding data the data in the +user-supplied scanline buffer is encoded into the raw data buffer (from +where it is written). Decoding routines should never have to explicitly +read data -- a full strip/tile's worth of raw data is read and scanlines +never cross strip boundaries. Encoding routines must be cognizant of +the raw data buffer size and call TIFFFlushData1() when necessary. +Note that any pending data is automatically flushed when a new strip/tile is +started, so there's no need do that in the tif_postencode routine (if +one exists). Bit order is automatically handled by the library when +a raw strip or tile is filled. If the decoded samples are interpreted +by the decoding routine before they are passed back to the user, then +the decoding logic must handle byte-swapping by overriding the +tif_postdecode +routine (set it to TIFFNoPostDecode) and doing the required work +internally. For an example of doing this look at the horizontal +differencing code in the routines in tif_predict.c. + +

+The variables tif_rawcc, tif_rawdata, and +tif_rawcp in a TIFF structure +are associated with the raw data buffer. tif_rawcc must be non-zero +for the library to automatically flush data. The variable +tif_scanlinesize is the size a user's scanline buffer should be. The +variable tif_tilesize is the size of a tile for tiled images. This +should not normally be used by compression routines, except where it +relates to the compression algorithm. That is, the cc parameter to the +tif_decode* and tif_encode* +routines should be used in terminating +decompression/compression. This ensures these routines can be used, +for example, to decode/encode entire strips of data. + +

+In general, if you have a new compression algorithm to add, work from +the code for an existing routine. In particular, +tif_dumpmode.c +has the trivial code for the "nil" compression scheme, +tif_packbits.c is a +simple byte-oriented scheme that has to watch out for buffer +boundaries, and tif_lzw.c has the LZW scheme that has the most +complexity -- it tracks the buffer boundary at a bit level. +Of course, using a private compression scheme (or private tags) limits +the portability of your TIFF files. + +

+


+ +Last updated: $Date: 2016-09-25 20:05:44 $ + + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/intro.html b/thirdparty/SDL2_image/external/libtiff/html/intro.html new file mode 100644 index 000000000..ad3b2d918 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/intro.html @@ -0,0 +1,73 @@ + + + + +Introduction to the TIFF Documentation + + + + +

+strike +Introduction to the TIFF Documentation +

+ + +

+The following definitions are used throughout this documentation. +They are consistent with the terminology used in the TIFF 6.0 specification. + +

+
Sample +
The unit of information stored in an image; often called a + channel elsewhere. Sample values are numbers, usually unsigned + integers, but possibly in some other format if the SampleFormat + tag is specified in a TIFF +
Pixel +
A collection of one or more samples that go together. +
Row +
An Nx1 rectangular collection of pixels. +
Tile +
An NxM rectangular organization of data (or pixels). +
Strip +
A tile whose width is the full image width. +
Compression +
A scheme by which pixel or sample data are stored in + an encoded form, specifically with the intent of reducing the + storage cost. +
Codec +
Software that implements the decoding and encoding algorithms + of a compression scheme. +
+ +

+In order to better understand how TIFF works (and consequently this +software) it is important to recognize the distinction between the +physical organization of image data as it is stored in a TIFF and how +the data is interpreted and manipulated as pixels in an image. TIFF +supports a wide variety of storage and data compression schemes that +can be used to optimize retrieval time and/or minimize storage space. +These on-disk formats are independent of the image characteristics; it +is the responsibility of the TIFF reader to process the on-disk storage +into an in-memory format suitable for an application. Furthermore, it +is the responsibility of the application to properly interpret the +visual characteristics of the image data. TIFF defines a framework for +specifying the on-disk storage format and image characteristics with +few restrictions. This permits significant complexity that can be +daunting. Good applications that handle TIFF work by handling as wide +a range of storage formats as possible, while constraining the +acceptable image characteristics to those that make sense for the +application. + + +

+


+ +Last updated: $Date: 2016-09-25 20:05:44 $ + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/libtiff.html b/thirdparty/SDL2_image/external/libtiff/html/libtiff.html new file mode 100644 index 000000000..cda66b5aa --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/libtiff.html @@ -0,0 +1,747 @@ + + + + Using The TIFF Library + + + + + + + + + + +
+

Using The TIFF Library

+

+ libtiff is a set of C functions (a library) that support + the manipulation of TIFF image files. + The library requires an ANSI C compilation environment for building + and presumes an ANSI C environment for use. +

+
+
+

+ libtiff + provides interfaces to image data at several layers of abstraction (and cost). + At the highest level image data can be read into an 8-bit/sample, + ABGR pixel raster format without regard for the underlying data organization, + colorspace, or compression scheme. Below this high-level interface + the library provides scanline-, strip-, and tile-oriented interfaces that + return data decompressed but otherwise untransformed. These interfaces + require that the application first identify the organization of stored + data and select either a strip-based or tile-based API for manipulating + data. At the lowest level the library + provides access to the raw uncompressed strips or tiles, + returning the data exactly as it appears in the file. +

+

+ The material presented in this chapter is a basic introduction + to the capabilities of the library; it is not an attempt to describe + everything a developer needs to know about the library or about TIFF. + Detailed information on the interfaces to the library are given in + the UNIX manual pages that accompany + this software. +

+

+ Michael Still has also written a useful introduction to libtiff for the + IBM DeveloperWorks site available at + http://www.ibm.com/developerworks/linux/library/l-libtiff. +

+

+ The following sections are found in this chapter: +

+ +
+

How to tell which version you have

+

+ The software version can be found by looking at the file named + VERSION + that is located at the top of the source tree; the precise alpha number + is given in the file dist/tiff.alpha. + If you have need to refer to this + specific software, you should identify it as: +

+

+ TIFF <version> <alpha> +

+

+ where <version> is whatever you get from + "cat VERSION" and <alpha> is + what you get from "cat dist/tiff.alpha". +

+

+ Within an application that uses libtiff the TIFFGetVersion + routine will return a pointer to a string that contains software version + information. + The library include file <tiffio.h> contains a C pre-processor + define TIFFLIB_VERSION that can be used to check library + version compatibility at compile time. +

+
+

Library Datatypes

+

+ libtiff defines a portable programming interface through the + use of a set of C type definitions. + These definitions, defined in in the files tiff.h and + tiffio.h, + isolate the libtiff API from the characteristics + of the underlying machine. + To insure portable code and correct operation, applications that use + libtiff should use the typedefs and follow the function + prototypes for the library API. +

+
+

Memory Management

+

+ libtiff uses a machine-specific set of routines for managing + dynamically allocated memory. + _TIFFmalloc, _TIFFrealloc, and _TIFFfree + mimic the normal ANSI C routines. + Any dynamically allocated memory that is to be passed into the library + should be allocated using these interfaces in order to insure pointer + compatibility on machines with a segmented architecture. + (On 32-bit UNIX systems these routines just call the normal malloc, + realloc, and free routines in the C library.) +

+

+ To deal with segmented pointer issues libtiff also provides + _TIFFmemcpy, _TIFFmemset, and _TIFFmemmove + routines that mimic the equivalent ANSI C routines, but that are + intended for use with memory allocated through _TIFFmalloc + and _TIFFrealloc. +

+
+

Error Handling

+

+ libtiff handles most errors by returning an invalid/erroneous + value when returning from a function call. + Various diagnostic messages may also be generated by the library. + All error messages are directed to a single global error handler + routine that can be specified with a call to TIFFSetErrorHandler. + Likewise warning messages are directed to a single handler routine + that can be specified with a call to TIFFSetWarningHandler +

+
+

Basic File Handling

+

+ The library is modeled after the normal UNIX stdio library. + For example, to read from an existing TIFF image the + file must first be opened: +

+

+ #include "tiffio.h"
+ main()
+ {
+     TIFF* tif = TIFFOpen("foo.tif", "r");
+     ... do stuff ...
+     TIFFClose(tif);
+ }
+

+

+ The handle returned by TIFFOpen is opaque, that is + the application is not permitted to know about its contents. + All subsequent library calls for this file must pass the handle + as an argument. +

+

+ To create or overwrite a TIFF image the file is also opened, but with + a "w" argument: +

+

+ #include "tiffio.h"
+ main()
+ {
+     TIFF* tif = TIFFOpen("foo.tif", "w");
+     ... do stuff ...
+     TIFFClose(tif);
+ }
+

+

+ If the file already exists it is first truncated to zero length. +

+ + + + + +
Note that unlike the stdio library TIFF image files may not be + opened for both reading and writing; + there is no support for altering the contents of a TIFF file.
+

+ libtiff buffers much information associated with writing a + valid TIFF image. Consequently, when writing a TIFF image it is necessary + to always call TIFFClose or TIFFFlush to flush any + buffered information to a file. Note that if you call TIFFClose + you do not need to call TIFFFlush. +

+
+

TIFF Directories

+

+ TIFF supports the storage of multiple images in a single file. + Each image has an associated data structure termed a directory + that houses all the information about the format and content of the + image data. + Images in a file are usually related but they do not need to be; it + is perfectly alright to store a color image together with a black and + white image. + Note however that while images may be related their directories are + not. + That is, each directory stands on its own; their is no need to read + an unrelated directory in order to properly interpret the contents + of an image. +

+

+ libtiff provides several routines for reading and writing + directories. In normal use there is no need to explicitly + read or write a directory: the library automatically reads the first + directory in a file when opened for reading, and directory information + to be written is automatically accumulated and written when writing + (assuming TIFFClose or TIFFFlush are called). +

+

+ For a file open for reading the TIFFSetDirectory routine can + be used to select an arbitrary directory; directories are referenced by + number with the numbering starting at 0. Otherwise the + TIFFReadDirectory and TIFFWriteDirectory routines can + be used for sequential access to directories. + For example, to count the number of directories in a file the following + code might be used: +

+

+ #include "tiffio.h"
+ main(int argc, char* argv[])
+ {
+     TIFF* tif = TIFFOpen(argv[1], "r");
+     if (tif) {
+         int dircount = 0;
+         do {
+             dircount++;
+         } while (TIFFReadDirectory(tif));
+         printf("%d directories in %s\n", dircount, argv[1]);
+         TIFFClose(tif);
+     }
+     exit(0);
+ }
+

+

+ Finally, note that there are several routines for querying the + directory status of an open file: + TIFFCurrentDirectory returns the index of the current + directory and + TIFFLastDirectory returns an indication of whether the + current directory is the last directory in a file. + There is also a routine, TIFFPrintDirectory, that can + be called to print a formatted description of the contents of + the current directory; consult the manual page for complete details. +

+
+

TIFF Tags

+

+ Image-related information such as the image width and height, number + of samples, orientation, colorimetric information, etc. + are stored in each image + directory in fields or tags. + Tags are identified by a number that is usually a value registered + with the Aldus (now Adobe) Corporation. + Beware however that some vendors write + TIFF images with tags that are unregistered; in this case interpreting + their contents is usually a waste of time. +

+

+ libtiff reads the contents of a directory all at once + and converts the on-disk information to an appropriate in-memory + form. While the TIFF specification permits an arbitrary set of + tags to be defined and used in a file, the library only understands + a limited set of tags. + Any unknown tags that are encountered in a file are ignored. + There is a mechanism to extend the set of tags the library handles + without modifying the library itself; + this is described elsewhere. +

+

+ libtiff provides two interfaces for getting and setting tag + values: TIFFGetField and TIFFSetField. + These routines use a variable argument list-style interface to pass + parameters of different type through a single function interface. + The get interface takes one or more pointers to memory locations + where the tag values are to be returned and also returns one or + zero according to whether the requested tag is defined in the directory. + The set interface takes the tag values either by-reference or + by-value. + The TIFF specification defines + default values for some tags. + To get the value of a tag, or its default value if it is undefined, + the TIFFGetFieldDefaulted interface may be used. +

+

+ The manual pages for the tag get and set routines specifiy the exact data types + and calling conventions required for each tag supported by the library. +

+
+

TIFF Compression Schemes

+

+ libtiff includes support for a wide variety of + data compression schemes. + In normal operation a compression scheme is automatically used when + the TIFF Compression tag is set, either by opening a file + for reading, or by setting the tag when writing. +

+

+ Compression schemes are implemented by software modules termed codecs + that implement decoder and encoder routines that hook into the + core library i/o support. + Codecs other than those bundled with the library can be registered + for use with the TIFFRegisterCODEC routine. + This interface can also be used to override the core-library + implementation for a compression scheme. +

+
+

Byte Order

+

+ The TIFF specification says, and has always said, that + a correct TIFF + reader must handle images in big-endian and little-endian byte order. + libtiff conforms in this respect. + Consequently there is no means to force a specific + byte order for the data written to a TIFF image file (data is + written in the native order of the host CPU unless appending to + an existing file, in which case it is written in the byte order + specified in the file). +

+
+

Data Placement

+

+ The TIFF specification requires that all information except an + 8-byte header can be placed anywhere in a file. + In particular, it is perfectly legitimate for directory information + to be written after the image data itself. + Consequently TIFF is inherently not suitable for passing through a + stream-oriented mechanism such as UNIX pipes. + Software that require that data be organized in a file in a particular + order (e.g. directory information before image data) does not + correctly support TIFF. + libtiff provides no mechanism for controlling the placement + of data in a file; image data is typically written before directory + information. +

+
+

TIFFRGBAImage Support

+

+ libtiff provides a high-level interface for reading image + data from a TIFF file. This interface handles the details of + data organization and format for a wide variety of TIFF files; + at least the large majority of those files that one would normally + encounter. Image data is, by default, returned as ABGR + pixels packed into 32-bit words (8 bits per sample). Rectangular + rasters can be read or data can be intercepted at an intermediate + level and packed into memory in a format more suitable to the + application. + The library handles all the details of the format of data stored on + disk and, in most cases, if any colorspace conversions are required: + bilevel to RGB, greyscale to RGB, CMYK to RGB, YCbCr to RGB, 16-bit + samples to 8-bit samples, associated/unassociated alpha, etc. +

+

+ There are two ways to read image data using this interface. If + all the data is to be stored in memory and manipulated at once, + then the routine TIFFReadRGBAImage can be used: +

+

+

+ #include "tiffio.h"
+ main(int argc, char* argv[])
+ {
+     TIFF* tif = TIFFOpen(argv[1], "r");
+     if (tif) {
+         uint32 w, h;
+         size_t npixels;
+         uint32* raster;
+         
+         TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w);
+         TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h);
+         npixels = w * h;
+         raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
+         if (raster != NULL) {
+             if (TIFFReadRGBAImage(tif, w, h, raster, 0)) {
+                 ...process raster data...
+             }
+             _TIFFfree(raster);
+         }
+         TIFFClose(tif);
+     }
+     exit(0);
+ }
+

+

+ Note above that _TIFFmalloc is used to allocate memory for + the raster passed to TIFFReadRGBAImage; this is important + to insure the ``appropriate type of memory'' is passed on machines + with segmented architectures. +

+

+ Alternatively, TIFFReadRGBAImage can be replaced with a + more low-level interface that permits an application to have more + control over this reading procedure. The equivalent to the above + is: +

+

+ #include "tiffio.h"
+ main(int argc, char* argv[])
+ {
+     TIFF* tif = TIFFOpen(argv[1], "r");
+     if (tif) {
+         TIFFRGBAImage img;
+         char emsg[1024];
+         
+         if (TIFFRGBAImageBegin(&img, tif, 0, emsg)) {
+             size_t npixels;
+             uint32* raster;
+             
+             npixels = img.width * img.height;
+             raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32));
+             if (raster != NULL) {
+                 if (TIFFRGBAImageGet(&img, raster, img.width, img.height)) {
+                     ...process raster data...
+                 }
+                 _TIFFfree(raster);
+             }
+             TIFFRGBAImageEnd(&img);
+         } else
+             TIFFError(argv[1], emsg);
+         TIFFClose(tif);
+     }
+     exit(0);
+ }
+

+

+ However this usage does not take advantage of the more fine-grained + control that's possible. That is, by using this interface it is + possible to: +

+
    +
  • repeatedly fetch (and manipulate) an image without opening + and closing the file
  • +
  • interpose a method for packing raster pixel data according to + application-specific needs (or write the data at all)
  • +
  • interpose methods that handle TIFF formats that are not already + handled by the core library
  • +
+

+ The first item means that, for example, image viewers that want to + handle multiple files can cache decoding information in order to + speedup the work required to display a TIFF image. +

+

+ The second item is the main reason for this interface. By interposing + a "put method" (the routine that is called to pack pixel data in + the raster) it is possible share the core logic that understands how + to deal with TIFF while packing the resultant pixels in a format that + is optimized for the application. This alternate format might be very + different than the 8-bit per sample ABGR format the library writes by + default. For example, if the application is going to display the image + on an 8-bit colormap display the put routine might take the data and + convert it on-the-fly to the best colormap indices for display. +

+

+ The last item permits an application to extend the library + without modifying the core code. + By overriding the code provided an application might add support + for some esoteric flavor of TIFF that it needs, or it might + substitute a packing routine that is able to do optimizations + using application/environment-specific information. +

+

+ The TIFF image viewer found in tools/sgigt.c is an example + of an application that makes use of the TIFFRGBAImage + support. +

+
+

Scanline-based Image I/O

+

+ The simplest interface provided by libtiff is a + scanline-oriented interface that can be used to read TIFF + images that have their image data organized in strips + (trying to use this interface to read data written in tiles + will produce errors.) + A scanline is a one pixel high row of image data whose width + is the width of the image. + Data is returned packed if the image data is stored with samples + packed together, or as arrays of separate samples if the data + is stored with samples separated. + The major limitation of the scanline-oriented interface, other + than the need to first identify an existing file as having a + suitable organization, is that random access to individual + scanlines can only be provided when data is not stored in a + compressed format, or when the number of rows in a strip + of image data is set to one (RowsPerStrip is one). +

+

+ Two routines are provided for scanline-based i/o: + TIFFReadScanline + and + TIFFWriteScanline. + For example, to read the contents of a file that + is assumed to be organized in strips, the following might be used: +

+

+ #include "tiffio.h"
+ main()
+ {
+     TIFF* tif = TIFFOpen("myfile.tif", "r");
+     if (tif) {
+         uint32 imagelength;
+         tdata_t buf;
+         uint32 row;
+         
+         TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
+         buf = _TIFFmalloc(TIFFScanlineSize(tif));
+         for (row = 0; row < imagelength; row++)
+             TIFFReadScanline(tif, buf, row, 0);
+         _TIFFfree(buf);
+         TIFFClose(tif);
+     }
+ }
+

+

+ TIFFScanlineSize returns the number of bytes in + a decoded scanline, as returned by TIFFReadScanline. + Note however that if the file had been create with samples + written in separate planes, then the above code would only + read data that contained the first sample of each pixel; + to handle either case one might use the following instead: +

+

+ #include "tiffio.h"
+ main()
+ {
+     TIFF* tif = TIFFOpen("myfile.tif", "r");
+     if (tif) {
+         uint32 imagelength;
+         tdata_t buf;
+         uint32 row;
+         
+         TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
+         TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config);
+         buf = _TIFFmalloc(TIFFScanlineSize(tif));
+         if (config == PLANARCONFIG_CONTIG) {
+             for (row = 0; row < imagelength; row++)
+                 TIFFReadScanline(tif, buf, row, 0);
+         } else if (config == planarconfig_separate) {
+             uint16 s, nsamples;
+             
+             tiffgetfield(tif, tifftag_samplesperpixel, &nsamples);
+             for (s = 0; s < nsamples; s++)
+                 for (row = 0; row < imagelength; row++)
+                     TIFFReadScanline(tif, buf, row, s);
+         }
+         _TIFFfree(buf);
+         TIFFClose(tif);
+     }
+ }
+

+

+ Beware however that if the following code were used instead to + read data in the case PLANARCONFIG_SEPARATE,... +

+

+             for (row = 0; row < imagelength; row++)
+                 for (s = 0; s < nsamples; s++)
+                     TIFFReadScanline(tif, buf, row, s);
+

+

+ ...then problems would arise if RowsPerStrip was not one + because the order in which scanlines are requested would require + random access to data within strips (something that is not supported + by the library when strips are compressed). +

+
+

Strip-oriented Image I/O

+

+ The strip-oriented interfaces provided by the library provide + access to entire strips of data. Unlike the scanline-oriented + calls, data can be read or written compressed or uncompressed. + Accessing data at a strip (or tile) level is often desirable + because there are no complications with regard to random access + to data within strips. +

+

+ A simple example of reading an image by strips is: +

+

+ #include "tiffio.h"
+ main()
+ {
+     TIFF* tif = TIFFOpen("myfile.tif", "r");
+     if (tif) {
+         tdata_t buf;
+         tstrip_t strip;
+         
+         buf = _TIFFmalloc(TIFFStripSize(tif));
+         for (strip = 0; strip < tiffnumberofstrips(tif); strip++)
+             tiffreadencodedstrip(tif, strip, buf, (tsize_t) -1);
+         _TIFFfree(buf);
+         TIFFClose(tif);
+     }
+ }
+

+

+ Notice how a strip size of -1 is used; TIFFReadEncodedStrip + will calculate the appropriate size in this case. +

+

+ The above code reads strips in the order in which the + data is physically stored in the file. If multiple samples + are present and data is stored with PLANARCONFIG_SEPARATE + then all the strips of data holding the first sample will be + read, followed by strips for the second sample, etc. +

+

+ Finally, note that the last strip of data in an image may have fewer + rows in it than specified by the RowsPerStrip tag. A + reader should not assume that each decoded strip contains a full + set of rows in it. +

+

+ The following is an example of how to read raw strips of data from + a file: +

+

+ #include "tiffio.h"
+ main()
+ {
+     TIFF* tif = TIFFOpen("myfile.tif", "r");
+     if (tif) {
+         tdata_t buf;
+         tstrip_t strip;
+         uint32* bc;
+         uint32 stripsize;
+         
+         TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc);
+         stripsize = bc[0];
+         buf = _TIFFmalloc(stripsize);
+         for (strip = 0; strip < tiffnumberofstrips(tif); strip++) {
+             if (bc[strip] > stripsize) {
+                 buf = _TIFFrealloc(buf, bc[strip]);
+                 stripsize = bc[strip];
+             }
+             TIFFReadRawStrip(tif, strip, buf, bc[strip]);
+         }
+         _TIFFfree(buf);
+         TIFFClose(tif);
+     }
+ }
+

+

+ As above the strips are read in the order in which they are + physically stored in the file; this may be different from the + logical ordering expected by an application. +

+
+

Tile-oriented Image I/O

+

+ Tiles of data may be read and written in a manner similar to strips. + With this interface, an image is + broken up into a set of rectangular areas that may have dimensions + less than the image width and height. All the tiles + in an image have the same size, and the tile width and length must each + be a multiple of 16 pixels. Tiles are ordered left-to-right and + top-to-bottom in an image. As for scanlines, samples can be packed + contiguously or separately. When separated, all the tiles for a sample + are colocated in the file. That is, all the tiles for sample 0 appear + before the tiles for sample 1, etc. +

+

+ Tiles and strips may also be extended in a z dimension to form + volumes. Data volumes are organized as "slices". That is, all the + data for a slice is colocated. Volumes whose data is organized in + tiles can also have a tile depth so that data can be organized in + cubes. +

+

+ There are actually two interfaces for tiles. + One interface is similar to scanlines, to read a tiled image, + code of the following sort might be used: +

+

+ main()
+ {
+     TIFF* tif = TIFFOpen("myfile.tif", "r");
+     if (tif) {
+         uint32 imageWidth, imageLength;
+         uint32 tileWidth, tileLength;
+         uint32 x, y;
+         tdata_t buf;
+         
+         TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imageWidth);
+         TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imageLength);
+         TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tileWidth);
+         TIFFGetField(tif, TIFFTAG_TILELENGTH, &tileLength);
+         buf = _TIFFmalloc(TIFFTileSize(tif));
+         for (y = 0; y < imagelength; y += tilelength)
+             for (x = 0; x < imagewidth; x += tilewidth)
+                 tiffreadtile(tif, buf, x, y, 0);
+         _TIFFfree(buf);
+         TIFFClose(tif);
+     }
+ }
+

+

+ (once again, we assume samples are packed contiguously.) +

+

+ Alternatively a direct interface to the low-level data is provided + a la strips. Tiles can be read with + TIFFReadEncodedTile or TIFFReadRawTile, + and written with TIFFWriteEncodedTile or + TIFFWriteRawTile. For example, to read all the tiles in an image: +

+

+ #include "tiffio.h"
+ main()
+ {
+     TIFF* tif = TIFFOpen("myfile.tif", "r");
+     if (tif) {
+         tdata_t buf;
+         ttile_t tile;
+         
+         buf = _TIFFmalloc(TIFFTileSize(tif));
+         for (tile = 0; tile < tiffnumberoftiles(tif); tile++)
+             tiffreadencodedtile(tif, tile, buf, (tsize_t) -1);
+         _TIFFfree(buf);
+         TIFFClose(tif);
+     }
+ }
+

+
+

Other Stuff

+

+ Some other stuff will almost certainly go here... +

+
+

+ Last updated: $Date: 2016-09-25 20:05:44 $ +

+ + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/html/man/CMakeLists.txt new file mode 100644 index 000000000..897a0e732 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/CMakeLists.txt @@ -0,0 +1,108 @@ +# CMake build for libtiff +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Written by Roger Leigh +# +# 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. + +set(indexfile index.html) + +set(docfiles + libtiff.3tiff.html + TIFFbuffer.3tiff.html + TIFFClose.3tiff.html + TIFFcodec.3tiff.html + TIFFcolor.3tiff.html + TIFFDataWidth.3tiff.html + TIFFError.3tiff.html + TIFFFieldDataType.3tiff.html + TIFFFieldName.3tiff.html + TIFFFieldPassCount.3tiff.html + TIFFFieldReadCount.3tiff.html + TIFFFieldTag.3tiff.html + TIFFFieldWriteCount.3tiff.html + TIFFFlush.3tiff.html + TIFFGetField.3tiff.html + TIFFmemory.3tiff.html + TIFFOpen.3tiff.html + TIFFPrintDirectory.3tiff.html + TIFFquery.3tiff.html + TIFFReadDirectory.3tiff.html + TIFFReadEncodedStrip.3tiff.html + TIFFReadEncodedTile.3tiff.html + TIFFReadRawStrip.3tiff.html + TIFFReadRawTile.3tiff.html + TIFFReadRGBAImage.3tiff.html + TIFFReadRGBAStrip.3tiff.html + TIFFReadRGBATile.3tiff.html + TIFFReadScanline.3tiff.html + TIFFReadTile.3tiff.html + TIFFRGBAImage.3tiff.html + TIFFSetDirectory.3tiff.html + TIFFSetField.3tiff.html + TIFFsize.3tiff.html + TIFFstrip.3tiff.html + TIFFswab.3tiff.html + TIFFtile.3tiff.html + TIFFWarning.3tiff.html + TIFFWriteDirectory.3tiff.html + TIFFWriteEncodedStrip.3tiff.html + TIFFWriteEncodedTile.3tiff.html + TIFFWriteRawStrip.3tiff.html + TIFFWriteRawTile.3tiff.html + TIFFWriteScanline.3tiff.html + TIFFWriteTile.3tiff.html + fax2ps.1.html + fax2tiff.1.html + pal2rgb.1.html + ppm2tiff.1.html + raw2tiff.1.html + tiff2bw.1.html + tiff2pdf.1.html + tiff2ps.1.html + tiff2rgba.1.html + tiffcmp.1.html + tiffcp.1.html + tiffcrop.1.html + tiffdither.1.html + tiffdump.1.html + tiffgt.1.html + tiffinfo.1.html + tiffmedian.1.html + tiffset.1.html + tiffsplit.1.html) + +set(doc_DATA ${indexfile} ${docfiles}) + +extra_dist(${doc_DATA}) + +install(FILES ${doc_DATA} + DESTINATION "${LIBTIFF_DOCDIR}/html/man") + +# htmldoc target to regenerate HTML files +string(REPLACE ";" "^" escaped_docfiles "${docfiles}") +add_custom_target(htmldoc + COMMAND "${CMAKE_COMMAND}" + "-DMANSRCDIR=${PROJECT_SOURCE_DIR}/man" + "-DHTMLMANDIR=${PROJECT_SOURCE_DIR}/html/man" + "-DINDEXFILE=${indexfile}" + "-DDOCFILES=${escaped_docfiles}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/HtmlDoc.cmake") + diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/LinkerChecks.cmake b/thirdparty/SDL2_image/external/libtiff/html/man/HtmlDoc.cmake similarity index 56% rename from thirdparty/SDL2_image/external/libtiff/cmake/LinkerChecks.cmake rename to thirdparty/SDL2_image/external/libtiff/html/man/HtmlDoc.cmake index ad1f0f9ff..7e5a1a0c2 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/LinkerChecks.cmake +++ b/thirdparty/SDL2_image/external/libtiff/html/man/HtmlDoc.cmake @@ -1,7 +1,6 @@ -# Check linker capabilities +# CMake documentation generation for libtiff # # Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh # Written by Roger Leigh # # Permission to use, copy, modify, distribute, and sell this software and @@ -23,28 +22,29 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +string(REPLACE "^" ";" DOCFILES "${DOCFILES}") -include(CheckCSourceCompiles) +set(INDEXSTART "Libtiff HTML manpage index

    Man Pages

    ") +set(INDEXEND "

") - -option(ld-version-script "Enable linker version script" ON) - -# Check if LD supports linker scripts. -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { - global: sym; -}; - -VERS_2 { - global: sym; -} VERS_1; +set(indexcontent "${INDEXSTART} ") -set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) -set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map") -check_c_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT) -set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) -file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") -if (ld-version-script AND HAVE_LD_VERSION_SCRIPT) - set(HAVE_LD_VERSION_SCRIPT TRUE) -else() - set(HAVE_LD_VERSION_SCRIPT FALSE) -endif() + +foreach(doc ${DOCFILES}) + string(REGEX REPLACE "(.*)\\.html$" "\\1" man "${doc}") + execute_process(COMMAND groff -Thtml -mandoc "${MANSRCDIR}/${man}" + OUTPUT_FILE "${HTMLMANDIR}/${doc}" + RESULT_VARIABLE GROFF_STATUS) + if(GROFF_STATUS) + message(FATAL_ERROR "Groff failed to generate HTML manpage") + endif() + message(STATUS "Generated ${HTMLMANDIR}/${doc} from ${MANSRCDIR}/${man}") + + set(indexcontent "${indexcontent}
  • ${man} +") +endforeach() + +set(indexcontent "${indexcontent}${INDEXEND} +") +file(WRITE "${HTMLMANDIR}/${INDEXFILE}" "${indexcontent}") +message(STATUS "Generated ${HTMLMANDIR}/${INDEXFILE}") diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/Makefile.am b/thirdparty/SDL2_image/external/libtiff/html/man/Makefile.am new file mode 100644 index 000000000..3ed00d448 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/Makefile.am @@ -0,0 +1,122 @@ +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2004, Andrey Kiselev +# +# 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. + +# Process this file with automake to produce Makefile.in. + +docdir = $(LIBTIFF_DOCDIR)/html/man +MANSRCDIR = $(top_srcdir)/man +HTMLMANDIR = $(top_srcdir)/html/man + +GROFF = groff -Thtml -mandoc +ECHO = echo + +indexfile = index.html +docfiles = \ + libtiff.3tiff.html \ + TIFFbuffer.3tiff.html \ + TIFFClose.3tiff.html \ + TIFFcodec.3tiff.html \ + TIFFcolor.3tiff.html \ + TIFFDataWidth.3tiff.html \ + TIFFError.3tiff.html \ + TIFFFieldDataType.3tiff.html \ + TIFFFieldName.3tiff.html \ + TIFFFieldPassCount.3tiff.html \ + TIFFFieldReadCount.3tiff.html \ + TIFFFieldTag.3tiff.html \ + TIFFFieldWriteCount.3tiff.html \ + TIFFFlush.3tiff.html \ + TIFFGetField.3tiff.html \ + TIFFmemory.3tiff.html \ + TIFFOpen.3tiff.html \ + TIFFPrintDirectory.3tiff.html \ + TIFFquery.3tiff.html \ + TIFFReadDirectory.3tiff.html \ + TIFFReadEncodedStrip.3tiff.html \ + TIFFReadEncodedTile.3tiff.html \ + TIFFReadRawStrip.3tiff.html \ + TIFFReadRawTile.3tiff.html \ + TIFFReadRGBAImage.3tiff.html \ + TIFFReadRGBAStrip.3tiff.html \ + TIFFReadRGBATile.3tiff.html \ + TIFFReadScanline.3tiff.html \ + TIFFReadTile.3tiff.html \ + TIFFRGBAImage.3tiff.html \ + TIFFSetDirectory.3tiff.html \ + TIFFSetField.3tiff.html \ + TIFFsize.3tiff.html \ + TIFFstrip.3tiff.html \ + TIFFswab.3tiff.html \ + TIFFtile.3tiff.html \ + TIFFWarning.3tiff.html \ + TIFFWriteDirectory.3tiff.html \ + TIFFWriteEncodedStrip.3tiff.html \ + TIFFWriteEncodedTile.3tiff.html \ + TIFFWriteRawStrip.3tiff.html \ + TIFFWriteRawTile.3tiff.html \ + TIFFWriteScanline.3tiff.html \ + TIFFWriteTile.3tiff.html \ + fax2ps.1.html \ + fax2tiff.1.html \ + pal2rgb.1.html \ + ppm2tiff.1.html \ + raw2tiff.1.html \ + tiff2bw.1.html \ + tiff2pdf.1.html \ + tiff2ps.1.html \ + tiff2rgba.1.html \ + tiffcmp.1.html \ + tiffcp.1.html \ + tiffcrop.1.html \ + tiffdither.1.html \ + tiffdump.1.html \ + tiffgt.1.html \ + tiffinfo.1.html \ + tiffmedian.1.html \ + tiffset.1.html \ + tiffsplit.1.html + +dist_doc_DATA = $(indexfile) $(docfiles) + +INDEXSTART = 'Libtiff HTML manpage index

      Man Pages

      ' +INDEXEND = '

    ' + +.PHONY: index +index: + ${ECHO} ${INDEXSTART} > $(indexfile) + for i in $(docfiles); do \ + ${ECHO} '
  • '$$i'' >> $(indexfile); \ + done + ${ECHO} ${INDEXEND} >> $(indexfile) + +manpages = $(docfiles:.html=) + +.PHONY: htmldoc +htmldoc: + for i in $(manpages); do \ + ${GROFF} $(MANSRCDIR)/$$i > $(HTMLMANDIR)/$$i.html; \ + done + +EXTRA_DIST = \ + CMakeLists.txt \ + HtmlDoc.cmake diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFClose.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFClose.3tiff.html new file mode 100644 index 000000000..908dcc70f --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFClose.3tiff.html @@ -0,0 +1,87 @@ + + + + + + +TIFFClose + + + +

    TIFFClose

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFClose − close a previously opened +TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    void TIFFClose(TIFF *tif)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFClose closes a file that was previously opened +with TIFFOpen(3TIFF). Any buffered data are flushed +to the file, including the contents of the current directory +(if modified); and all resources are reclaimed.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the routine. Likewise, +warning messages are directed to the +TIFFWarning(3TIFF) routine.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    libtiff(3TIFF), TIFFOpen(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFDataWidth.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFDataWidth.3tiff.html new file mode 100644 index 000000000..9eede0608 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFDataWidth.3tiff.html @@ -0,0 +1,98 @@ + + + + + + +TIFFDataWidth + + + +

    TIFFDataWidth

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFDataWidth − Get the size of TIFF data types

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    int TIFFDataWidth(TIFFDataType +type)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFDataWidth returns a size of type in +bytes. Currently following data types are supported:
    +TIFF_BYTE
    +TIFF_ASCII
    +TIFF_SBYTE
    +TIFF_UNDEFINED
    +TIFF_SHORT
    +TIFF_SSHORT
    +TIFF_LONG
    +TIFF_SLONG
    +TIFF_FLOAT
    +TIFF_IFD
    +TIFF_RATIONAL
    +TIFF_SRATIONAL
    +TIFF_DOUBLE

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    TIFFDataWidth returns a number of bytes occupied +by the item of given type. 0 returned when uknown data type +supplied.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    libtiff(3TIFF),

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFError.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFError.3tiff.html new file mode 100644 index 000000000..cd30c7edd --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFError.3tiff.html @@ -0,0 +1,106 @@ + + + + + + +TIFFError + + + +

    TIFFError

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFError, TIFFSetErrorHandler − library error +handling interface

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    void TIFFError(const char *module, const +char *fmt, ...)

    + +

    #include <stdarg.h>

    + +

    typedef void (*TIFFErrorHandler)(const char +*module, const char *fmt, +va_list ap);
    +TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler +handler);

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFError invokes the library-wide error handling +function to (normally) write an error message to the +stderr. The fmt parameter is a +printf(3S) format string, and any number arguments +can be supplied. The module parameter, if non-zero, +is printed before the message; it typically is used to +identify the software module in which an error is +detected.

    + +

    Applications that desire to capture control in the event +of an error should use TIFFSetErrorHandler to +override the default error handler. A NULL +(0) error handling function may be installed to suppress +error messages.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    TIFFSetErrorHandler returns a reference to the +previous error handling function.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFWarning(3TIFF), libtiff(3TIFF), +printf(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldDataType.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldDataType.3tiff.html new file mode 100644 index 000000000..2270a5c95 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldDataType.3tiff.html @@ -0,0 +1,89 @@ + + + + + + + + + +TIFFFieldDataType + + + + +

    TIFFFieldDataType

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + + +

    TIFFFieldDataType +− Get TIFF data type from field information

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + + +

    TIFFDataType +TIFFFieldDataType(const TIFFField* +fip)

    + +

    DESCRIPTION + +

    + + + +

    TIFFFieldDataType +returns the data type stored in a TIFF field.

    + +

    fip is a +field information pointer previously returned by +TIFFFindField, TIFFFieldWithTag, or +TIFFFieldWithName.

    + +

    RETURN VALUES + +

    + + + +

    TIFFFieldDataType +returns a member of the enum type TIFFDataType.

    + +

    SEE ALSO + +

    + + + +

    libtiff(3TIFF),

    + +

    Libtiff library +home page: http://www.simplesystems.org/libtiff/

    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldName.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldName.3tiff.html new file mode 100644 index 000000000..df4ee5064 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldName.3tiff.html @@ -0,0 +1,86 @@ + + + + + + + + + +TIFFFieldName + + + + +

    TIFFFieldName

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + +

    TIFFFieldName +− Get TIFF field name from field information

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + +

    const char* +TIFFFieldName(const TIFFField* fip)

    + +

    DESCRIPTION + +

    + + + +

    TIFFFieldName +returns the textual name for a TIFF field.

    + +

    fip is a +field information pointer previously returned by +TIFFFindField, TIFFFieldWithTag, or +TIFFFieldWithName.

    + +

    RETURN VALUES + +

    + + + +

    TIFFFieldName +returns a constant C string.

    + +

    SEE ALSO + +

    + + + +

    libtiff(3TIFF),

    + +

    Libtiff library +home page: http://www.simplesystems.org/libtiff/

    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldPassCount.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldPassCount.3tiff.html new file mode 100644 index 000000000..5dc312625 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldPassCount.3tiff.html @@ -0,0 +1,98 @@ + + + + + + + + + +TIFFFieldPassCount + + + + +

    TIFFFieldPassCount

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + + +

    TIFFFieldPassCount +− Get whether to pass a count to TIFFGet/SetField

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + +

    int +TIFFFieldPassCount(const TIFFField* +fip)

    + +

    DESCRIPTION + +

    + + + +

    TIFFFieldPassCount +returns true (nonzero) if TIFFGetField and +TIFFSetField expect a count value to be passed +before the actual data pointer.

    + +

    fip is a +field information pointer previously returned by +TIFFFindField, TIFFFieldWithTag, or +TIFFFieldWithName.

    + +

    When a +count is required, it will be of type uint32 +when TIFFFieldReadCount reports +TIFF_VARIABLE2, and of type uint16 otherwise. +(This distinction is critical for use of +TIFFGetField, but normally not so for use of +TIFFSetField.)

    + +

    RETURN VALUES + +

    + + + +

    TIFFFieldPassCount +returns an integer that is always 1 (true) or 0 (false).

    + +

    SEE ALSO + +

    + + + +

    libtiff(3TIFF),

    + +

    Libtiff library +home page: http://www.simplesystems.org/libtiff/

    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldReadCount.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldReadCount.3tiff.html new file mode 100644 index 000000000..d800a861c --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldReadCount.3tiff.html @@ -0,0 +1,101 @@ + + + + + + + + + +TIFFFieldReadCount + + + + +

    TIFFFieldReadCount

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + + +

    TIFFFieldReadCount +− Get number of values to be read from field

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + +

    int +TIFFFieldReadCount(const TIFFField* +fip)

    + +

    DESCRIPTION + +

    + + + +

    TIFFFieldReadCount +returns the number of values available to be read from the +specified TIFF field; that is, the number of arguments that +should be supplied to TIFFGetField. For most field +types this is a small positive integer, typically 1 or 2, +but there are some special values:
    +TIFF_VARIABLE
    indicates that a variable number of values +is possible; then, a uint16 count argument and +a pointer data argument must be supplied to +TIFFGetField.
    +TIFF_VARIABLE2
    is the same as TIFF_VARIABLE +except that the count argument must have type +uint32.
    +TIFF_SPP
    indicates that the number of arguments is equal +to the image’s number of samples per pixel.

    + +

    fip is a +field information pointer previously returned by +TIFFFindField, TIFFFieldWithTag, or +TIFFFieldWithName.

    + +

    RETURN VALUES + +

    + + + +

    TIFFFieldReadCount +returns an integer.

    + +

    SEE ALSO + +

    + + + +

    libtiff(3TIFF),

    + +

    Libtiff library +home page: http://www.simplesystems.org/libtiff/

    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldTag.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldTag.3tiff.html new file mode 100644 index 000000000..b1fdea0f1 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldTag.3tiff.html @@ -0,0 +1,88 @@ + + + + + + + + + +TIFFFieldTag + + + + +

    TIFFFieldTag

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + +

    TIFFFieldTag +− Get TIFF field tag value from field information

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + +

    uint32 +TIFFFieldTag(const TIFFField* fip)

    + +

    DESCRIPTION + +

    + + + +

    TIFFFieldTag +returns the numeric tag value for a TIFF field. This can be +compared to various constants exported by the libtiff +header files, such as TIFFTAG_IMAGEWIDTH.

    + +

    fip is a +field information pointer previously returned by +TIFFFindField, TIFFFieldWithTag, or +TIFFFieldWithName.

    + +

    RETURN VALUES + +

    + + + +

    TIFFFieldTag +returns an integer tag value.

    + +

    SEE ALSO + +

    + + + +

    libtiff(3TIFF),

    + +

    Libtiff library +home page: http://www.simplesystems.org/libtiff/

    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldWriteCount.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldWriteCount.3tiff.html new file mode 100644 index 000000000..0d446bc73 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFieldWriteCount.3tiff.html @@ -0,0 +1,108 @@ + + + + + + + + + +TIFFFieldWriteCount + + + + +

    TIFFFieldWriteCount

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + + +

    TIFFFieldWriteCount +− Get number of values to be written to field

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + +

    int +TIFFFieldWriteCount(const TIFFField* +fip)

    + +

    DESCRIPTION + +

    + + + +

    TIFFFieldWriteCount +returns the number of values to be written into the +specified TIFF field; that is, the number of arguments that +should be supplied to TIFFSetField. For most field +types this is a small positive integer, typically 1 or 2, +but there are some special values:
    +TIFF_VARIABLE
    indicates that a variable number of values +is possible; then, a uint16 count argument and +a pointer data argument must be supplied to +TIFFSetField.
    +TIFF_VARIABLE2
    is the same as TIFF_VARIABLE +except that the count argument must have type +uint32. (On most modern machines, this makes no +practical difference, and the count argument can +simply be an int in either case.)
    +TIFF_SPP
    indicates that the number of arguments must be +equal to the image’s number of samples per pixel.

    + +

    fip is a +field information pointer previously returned by +TIFFFindField, TIFFFieldWithTag, or +TIFFFieldWithName.

    + +

    For most field +types, TIFFFieldWriteCount returns the same value as +TIFFFieldReadCount, but there are some +exceptions.

    + +

    RETURN VALUES + +

    + + + +

    TIFFFieldWriteCount +returns an integer.

    + +

    SEE ALSO + +

    + + + +

    libtiff(3TIFF),

    + +

    Libtiff library +home page: http://www.simplesystems.org/libtiff/

    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFlush.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFlush.3tiff.html new file mode 100644 index 000000000..77782e64f --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFFlush.3tiff.html @@ -0,0 +1,113 @@ + + + + + + +TIFFFlush + + + +

    TIFFFlush

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFFlush, TIFFFlushData − flush pending writes to +an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    int TIFFFlush(TIFF *tif)
    +int TIFFFlushData(TIFF *
    tif)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFFlush causes any pending writes for the +specified file (including writes for the current directory) +to be done. In normal operation this call is never needed +− the library automatically does any flushing +required.

    + +

    TIFFFlushData flushes any pending image data for +the specified file to be written out; directory-related data +are not flushed. In normal operation this call is never +needed − the library automatically does any flushing +required.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    0 is returned if an error is encountered, otherwise 1 is +returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFWriteEncodedStrip(3TIFF), +TIFFWriteEncodedTile(3TIFF), +TIFFWriteRawStrip(3TIFF), +TIFFWriteRawTile(3TIFF), +TIFFWriteScanline(3TIFF), TIFFWriteTile(3TIFF) +libtiff(3TIFF),

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFGetField.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFGetField.3tiff.html new file mode 100644 index 000000000..cbbb8be76 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFGetField.3tiff.html @@ -0,0 +1,1969 @@ + + + + + + + + + +TIFFGetField + + + + +

    TIFFGetField

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +AUTOREGISTERED TAGS
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + +

    TIFFGetField, +TIFFVGetField − get the value(s) of a tag in an open +TIFF file

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + +

    int +TIFFGetField(TIFF *tif, ttag_t +tag, ...)

    + +

    #include +<stdarg.h>

    + +

    int +TIFFVGetField(TIFF *tif, ttag_t +tag, va_list ap)
    +int TIFFGetFieldDefaulted(TIFF *
    tif, +ttag_t tag, ...)
    +int TIFFVGetFieldDefaulted(TIFF *
    tif, +ttag_t tag, va_list ap)

    + +

    DESCRIPTION + +

    + + + +

    TIFFGetField +returns the value of a tag or pseudo-tag associated with the +the current directory of the opened TIFF file +tif. (A pseudo-tag is a parameter that is used +to control the operation of the TIFF library +but whose value is not read or written to the underlying +file.) The file must have been previously opened with +TIFFOpen(3TIFF). The tag is identified by tag, +one of the values defined in the include file tiff.h +(see also the table below). The type and number of values +returned is dependent on the tag being requested. The +programming interface uses a variable argument list as +prescribed by the stdarg(3) interface. The returned +values should only be interpreted if TIFFGetField +returns 1.

    + + +

    TIFFVGetField +is functionally equivalent to TIFFGetField except +that it takes a pointer to a variable argument list. +TIFFVGetField is useful for layering interfaces on +top of the functionality provided by +TIFFGetField.

    + + +

    TIFFGetFieldDefaulted +and TIFFVGetFieldDefaulted are identical to +TIFFGetField and TIFFVGetField, except that if +a tag is not defined in the current directory and it has a +default value, then the default value is returned.

    + +

    The tags +understood by libtiff(3TIFF), the number of parameter +values, and the types for the returned values are shown +below. The data types are specified as in C and correspond +to the types used to specify tag values to +TIFFSetField(3TIFF). Remember that +TIFFGetField returns parameter values, so all the +listed data types are pointers to storage where values +should be returned. Consult the TIFF +specification (or relevant industry specification) for +information on the meaning of each tag and their possible +values.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +

    Tag Name

    + + +

    Count

    +
    + + +

    Types

    + + +

    Notes

    + + +

    TIFFTAG_ARTIST

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_BADFAXLINES

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_BITSPERSAMPLE

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_CLEANFAXDATA

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_COLORMAP

    + + +

    3

    +
    + + +

    uint16**

    + + +

    1<<BitsPerSample arrays

    + + +

    TIFFTAG_COMPRESSION

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_CONSECUTIVEBADFAXLINES

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_COPYRIGHT

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_DATATYPE

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_DATETIME

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_DOCUMENTNAME

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_DOTRANGE

    + + +

    2

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_EXTRASAMPLES

    + + +

    2

    +
    + + +

    uint16*,uint16**

    + + +

    count & types array

    + + +

    TIFFTAG_FAXFILLFUNC

    + + +

    1

    +
    + + +

    TIFFFaxFillFunc*

    + + +

    G3/G4 compression pseudo-tag

    + + +

    TIFFTAG_FAXMODE

    + + +

    1

    +
    + + +

    int*

    + + +

    G3/G4 compression pseudo-tag

    + + +

    TIFFTAG_FILLORDER

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_GROUP3OPTIONS

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_GROUP4OPTIONS

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_HALFTONEHINTS

    + + +

    2

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_HOSTCOMPUTER

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_ICCPROFILE

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count, profile data

    + + +

    TIFFTAG_IMAGEDEPTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_IMAGEDESCRIPTION

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_IMAGELENGTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_IMAGEWIDTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_INKNAMES

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_INKSET

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_JPEGCOLORMODE

    + + +

    1

    +
    + + +

    int*

    + + +

    JPEG pseudo-tag

    + + +

    TIFFTAG_JPEGQUALITY

    + + +

    1

    +
    + + +

    int*

    + + +

    JPEG pseudo-tag

    + + +

    TIFFTAG_JPEGTABLES

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count & tables

    + + +

    TIFFTAG_JPEGTABLESMODE

    + + +

    1

    +
    + + +

    int*

    + + +

    JPEG pseudo-tag

    + + +

    TIFFTAG_MAKE

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_MATTEING

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_MAXSAMPLEVALUE

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_MINSAMPLEVALUE

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_MODEL

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_ORIENTATION

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PAGENAME

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_PAGENUMBER

    + + +

    2

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PHOTOMETRIC

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PHOTOSHOP

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count, data

    + + +

    TIFFTAG_PLANARCONFIG

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PREDICTOR

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_PRIMARYCHROMATICITIES

    + + +

    1

    +
    + + +

    float**

    + + +

    6-entry array

    + + +

    TIFFTAG_REFERENCEBLACKWHITE

    + + +

    1

    +
    + + +

    float**

    + + +

    6-entry array

    + + +

    TIFFTAG_RESOLUTIONUNIT

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_RICHTIFFIPTC

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count, data

    + + +

    TIFFTAG_ROWSPERSTRIP

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_SAMPLEFORMAT

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_SAMPLESPERPIXEL

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_SMAXSAMPLEVALUE

    + + +

    1

    +
    + + +

    double*

    +
    + + +

    TIFFTAG_SMINSAMPLEVALUE

    + + +

    1

    +
    + + +

    double*

    +
    + + +

    TIFFTAG_SOFTWARE

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_STONITS

    + + +

    1

    +
    + + +

    double**

    +
    + + +

    TIFFTAG_STRIPBYTECOUNTS

    + + +

    1

    +
    + + +

    uint32**

    +
    + + +

    TIFFTAG_STRIPOFFSETS

    + + +

    1

    +
    + + +

    uint32**

    +
    + + +

    TIFFTAG_SUBFILETYPE

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_SUBIFD

    + + +

    2

    +
    + + +

    uint16*,uint32**

    + + +

    count & offsets array

    + + +

    TIFFTAG_TARGETPRINTER

    + + +

    1

    +
    + + +

    char**

    +
    + + +

    TIFFTAG_THRESHHOLDING

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_TILEBYTECOUNTS

    + + +

    1

    +
    + + +

    uint32**

    +
    + + +

    TIFFTAG_TILEDEPTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_TILELENGTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_TILEOFFSETS

    + + +

    1

    +
    + + +

    uint32**

    +
    + + +

    TIFFTAG_TILEWIDTH

    + + +

    1

    +
    + + +

    uint32*

    +
    + + +

    TIFFTAG_TRANSFERFUNCTION

    + + +

    1 or 3†

    + + +

    uint16**1<<BitsPerSample entry arrays

    + + +

    TIFFTAG_WHITEPOINT

    + + +

    1

    +
    + + +

    float**

    + + +

    2-entry array

    + + +

    TIFFTAG_XMLPACKET

    + + +

    2

    +
    + + +

    uint32*,void**

    + + +

    count, data

    + + +

    TIFFTAG_XPOSITION

    + + +

    1

    +
    + + +

    float*

    +
    + + +

    TIFFTAG_XRESOLUTION

    + + +

    1

    +
    + + +

    float*

    +
    + + +

    TIFFTAG_YCBCRCOEFFICIENTS

    + + +

    1

    +
    + + +

    float**

    + + +

    3-entry array

    + + +

    TIFFTAG_YCBCRPOSITIONING

    + + +

    1

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_YCBCRSUBSAMPLING

    + + +

    2

    +
    + + +

    uint16*

    +
    + + +

    TIFFTAG_YPOSITION

    + + +

    1

    +
    + + +

    float*

    +
    + + +

    TIFFTAG_YRESOLUTION

    + + +

    1

    +
    + + +

    float*‡

    +
    + +

    † If +SamplesPerPixel is one, then a single array is +returned; otherwise three arrays are returned.
    +‡ The contents of this field are quite complex. See +The ICC Profile Format Specification, Annex B.3 +"Embedding ICC Profiles in TIFF Files" (available +at http://www.color.org) for an explanation.

    + +

    AUTOREGISTERED TAGS + +

    + + +

    If you +can’t find the tag in the table above that means this +is unsupported tag. But you still be able to read it’s +value if you know the data type of that tag. For example, if +you want to read the LONG value from the tag 33424 and ASCII +string from the tag 36867 you can use the following +code:

    + +

    uint16 count; +
    +void *data;

    + + +

    TIFFGetField(tiff, +33424, &count, &data);
    +printf("Tag %d: %d, count %d0, 33424, *(uint32 *)data, +count);
    +TIFFGetField(tiff, 36867, &count, &data);
    +printf("Tag %d: %s, count %d0, 36867, (char *)data, +count);

    + +

    is not +supported by libtiff(3TIFF), library

    + +

    RETURN VALUES + +

    + + +

    1 is returned +if the tag is defined in the current directory; otherwise a +0 is returned.

    + +

    DIAGNOSTICS + +

    + + +

    All error +messages are directed to the TIFFError(3TIFF) +routine.

    + +

    Unknown +field, tag 0x%x. An unknown tag was supplied.

    + +

    SEE ALSO + +

    + + + +

    TIFFOpen(3TIFF), +TIFFSetField(3TIFF), TIFFSetDirectory(3TIFF), +TIFFReadDirectory(3TIFF), +TIFFWriteDirectory(3TIFF) libtiff(3TIFF),

    + +

    Libtiff library +home page: http://www.simplesystems.org/libtiff/

    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFOpen.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFOpen.3tiff.html new file mode 100644 index 000000000..2379121f1 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFOpen.3tiff.html @@ -0,0 +1,421 @@ + + + + + + +TIFFOpen + + + +

    TIFFOpen

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +BYTE ORDER
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFOpen, TIFFFdOpen, TIFFClientOpen − open a +TIFF file for reading or writing

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    TIFF* TIFFOpen(const char *filename, +const char *mode)
    +TIFF* TIFFFdOpen(const int
    fd, const char +*filename, const char +*mode)

    + +

    typedef tsize_t (*TIFFReadWriteProc)(thandle_t, +tdata_t, tsize_t);
    +typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);
    +typedef int (*TIFFCloseProc)(thandle_t);
    +typedef toff_t (*TIFFSizeProc)(thandle_t);
    +typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, +toff_t*);
    +typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, +toff_t);

    + +

    TIFF* TIFFClientOpen(const char +*filename, const char *mode, +thandle_t clientdata, TIFFReadWriteProc +readproc, TIFFReadWriteProc +writeproc, TIFFSeekProc seekproc, +TIFFCloseProc closeproc, TIFFSizeProc +sizeproc, TIFFMapFileProc mapproc, +TIFFUnmapFileProc unmapproc)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFOpen opens a TIFF file whose +name is filename and returns a handle to be used in +subsequent calls to routines in libtiff. If the open +operation fails, then zero is returned. The mode +parameter specifies if the file is to be opened for reading +(‘‘r’’), writing +(‘‘w’’), or appending +(‘‘a’’) and, optionally, whether to +override certain default aspects of library operation (see +below). When a file is opened for appending, existing data +will not be touched; instead new data will be written as +additional subfiles. If an existing file is opened for +writing, all previous data is overwritten.

    + +

    If a file is opened for reading, the first +TIFF directory in the file is automatically +read (also see TIFFSetDirectory(3TIFF) for reading +directories other than the first). If a file is opened for +writing or appending, a default directory is automatically +created for writing subsequent data. This directory has all +the default values specified in TIFF Revision +6.0: BitsPerSample=1, ThreshHolding=bilevel +art scan, FillOrder=1 (most significant bit of each +data byte is filled first), Orientation=1 (the 0th +row represents the visual top of the image, and the 0th +column represents the visual left hand side), +SamplesPerPixel=1, RowsPerStrip=infinity, +ResolutionUnit=2 (inches), and Compression=1 +(no compression). To alter these values, or to define values +for additional fields, TIFFSetField(3TIFF) must be +used.

    + +

    TIFFFdOpen is like TIFFOpen except that it +opens a TIFF file given an open file +descriptor fd. The file’s name and mode must +reflect that of the open descriptor. The object associated +with the file descriptor must support random +access.

    + +

    TIFFClientOpen is like TIFFOpen except that +the caller supplies a collection of functions that the +library will use to do UNIX -like I/O +operations. The readproc and writeproc are +called to read and write data at the current file position. +seekproc is called to change the current file +position a la lseek(2). closeproc is invoked +to release any resources associated with an open file. +sizeproc is invoked to obtain the size in bytes of a +file. mapproc and unmapproc are called to map +and unmap a file’s contents in memory; c.f. +mmap(2) and munmap(2). The clientdata +parameter is an opaque ‘‘handle’’ +passed to the client-specified routines passed as parameters +to TIFFClientOpen.

    +
    + +

    OPTIONS

    + + + + + +
    +

    The open mode parameter can include the following flags +in addition to the ‘‘r’’, +‘‘w’’, and +‘‘a’’ flags. Note however that +option flags must follow the read-write-append +specification.

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    l

    +
    + +

    When creating a new file force information be written +with Little-Endian byte order (but see below). By default +the library will create new files using the native +CPU byte order.

    +
    +
    + +

    b

    +
    + +

    When creating a new file force information be written +with Big-Endian byte order (but see below). By default the +library will create new files using the native +CPU byte order.

    +
    +
    + +

    L

    +
    + +

    Force image data that is read or written to be treated +with bits filled from Least Significant Bit ( +LSB ) to Most Significant Bit ( +MSB ). Note that this is the opposite to the +way the library has worked from its inception.

    +
    +
    + +

    B

    +
    + +

    Force image data that is read or written to be treated +with bits filled from Most Significant Bit ( +MSB ) to Least Significant Bit ( +LSB ); this is the default.

    +
    +
    + +

    H

    +
    + +

    Force image data that is read or written to be treated +with bits filled in the same order as the native +CPU.

    +
    +
    + +

    M

    +
    + +

    Enable the use of memory-mapped files for images opened +read-only. If the underlying system does not support +memory-mapped files or if the specific image being opened +cannot be memory-mapped then the library will fallback to +using the normal system interface for reading information. +By default the library will attempt to use memory-mapped +files.

    +
    +
    + +

    m

    +
    + +

    Disable the use of memory-mapped files.

    +
    +
    + +

    C

    +
    + +

    Enable the use of ‘‘strip +chopping’’ when reading images that are +comprised of a single strip or tile of uncompressed data. +Strip chopping is a mechanism by which the library will +automatically convert the single-strip image to multiple +strips, each of which has about 8 Kilobytes of data. This +facility can be useful in reducing the amount of memory used +to read an image because the library normally reads each +strip in its entirety. Strip chopping does however alter the +apparent contents of the image because when an image is +divided into multiple strips it looks as though the +underlying file contains multiple separate strips. Finally, +note that default handling of strip chopping is a +compile-time configuration parameter. The default behaviour, +for backwards compatibility, is to enable strip +chopping.

    +
    +
    + +

    c

    +
    + +

    Disable the use of strip chopping when reading +images.

    +
    +
    + +

    h

    +
    + +

    Read TIFF header only, do not load the first image +directory. That could be useful in case of the broken first +directory. We can open the file and proceed to the other +directories.

    +
    +
    + +

    BYTE ORDER

    + + + + + +
    +

    The TIFF specification (all +versions) states that compliant readers must be +capable of reading images written in either byte order. +Nonetheless some software that claims to support the reading +of TIFF images is incapable of reading images +in anything but the native CPU byte order on +which the software was written. (Especially notorious are +applications written to run on Intel-based machines.) By +default the library will create new files with the native +byte-order of the CPU on which the +application is run. This ensures optimal performance and is +portable to any application that conforms to the TIFF +specification. To force the library to use a specific +byte-order when creating a new file the +‘‘b’’ and +‘‘l’’ option flags may be included +in the call to open a file; for example, +‘‘wb’’ or +‘‘wl’’.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    Upon successful completion TIFFOpen, +TIFFFdOpen, and TIFFClientOpen return a +TIFF pointer. Otherwise, NULL is +returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine. Likewise, warning messages +are directed to the TIFFWarning(3TIFF) routine.

    + +

    "%s": Bad mode. The specified +mode parameter was not one of +‘‘r’’ (read), +‘‘w’’ (write), or +‘‘a’’ (append).

    + +

    %s: Cannot open. TIFFOpen() was unable to +open the specified filename for read/writing.

    + +

    Cannot read TIFF header. An error occurred while +attempting to read the header information.

    + +

    Error writing TIFF header. An error occurred while +writing the default header information for a new file.

    + +

    Not a TIFF file, bad magic number %d (0x%x). The +magic number in the header was not (hex) 0x4d4d or (hex) +0x4949.

    + +

    Not a TIFF file, bad version number %d (0x%x). The +version field in the header was not 42 (decimal).

    + +

    Cannot append to file that has opposite byte +ordering. A file with a byte ordering opposite to the +native byte ordering of the current machine was opened for +appending (‘‘a’’). This is a +limitation of the library.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    libtiff(3TIFF), TIFFClose(3TIFF)

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFPrintDirectory.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFPrintDirectory.3tiff.html new file mode 100644 index 000000000..f4dca6e44 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFPrintDirectory.3tiff.html @@ -0,0 +1,225 @@ + + + + + + +TIFFPrintDirectory + + + +

    TIFFPrintDirectory

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFPrintDirectory − print a description of a +TIFF directory

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    void TIFFPrintDirectory(TIFF *tif, FILE +*fd, long flags)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFPrintDirectory prints a description of the +current directory in the specified TIFF file +to the standard I/O output stream fd. The +flags parameter is used to control the level of +detail of the printed information; it is a bit-or of the +flags defined in tiffio.h:

    + + +

    #define TIFFPRINT_NONE 0x0 /* no extra info */

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    #define

    +
    + +

    TIFFPRINT_STRIPS

    +
    + +

    0x1

    +
    + +

    /* strips/tiles info */

    +
    + +

    #define

    +
    + +

    TIFFPRINT_CURVES

    +
    + +

    0x2

    +
    + +

    /* color/gray response curves */

    +
    + +

    #define

    +
    + +

    TIFFPRINT_COLORMAP

    +
    + +

    0x4

    +
    + +

    /* colormap */

    +
    + +

    #define

    +
    + +

    TIFFPRINT_JPEGQTABLES

    +
    + +

    0x100

    +
    + +

    /* JPEG Q matrices */

    +
    + +

    #define

    +
    + +

    TIFFPRINT_JPEGACTABLES

    +
    + +

    0x200

    +
    + +

    /* JPEG AC tables */

    +
    + +

    #define

    +
    + +

    TIFFPRINT_JPEGDCTABLES

    +
    + +

    0x200

    +
    + +

    /* JPEG DC tables */

    +
    + +

    NOTES

    + + + + + +
    +

    In C++ the flags parameter defaults to 0.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    None.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    None.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    libtiff(3TIFF), TIFFOpen(3TIFF), +TIFFReadDirectory(3TIFF), +TIFFSetDirectory(3TIFF)

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFRGBAImage.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFRGBAImage.3tiff.html new file mode 100644 index 000000000..83581f115 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFRGBAImage.3tiff.html @@ -0,0 +1,319 @@ + + + + + + +TIFFRGBAImage + + + +

    TIFFRGBAImage

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +ALTERNATE RASTER FORMATS
    +SIMULTANEOUS RASTER STORE AND DISPLAY
    +SUPPORTING ADDITIONAL TIFF FORMATS
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet, +TIFFRGBAImageEnd − read and decode an image into a +raster

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    typedef unsigned char TIFFRGBValue; typedef struct +_TIFFRGBAImage TIFFRGBAImage;

    + +

    int TIFFRGBAImageOK(TIFF *tif, char +emsg[1024])
    +int TIFFRGBAImageBegin(TIFFRGBAImage *
    img, +TIFF* tif, int stopOnError, +char emsg[1024])
    +int TIFFRGBAImageGet(TIFFRGBAImage *
    img, +uint32* raster, uint32 width , +uint32 height)
    +void TIFFRGBAImageEnd(TIFFRGBAImage +*
    img)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    The routines described here provide a high-level +interface through which TIFF images may be +read into memory. Images may be strip- or tile-based and +have a variety of different characteristics: bits/sample, +samples/pixel, photometric, etc. Decoding state is +encapsulated in a TIFFRGBAImage structure making it +possible to capture state for multiple images and quickly +switch between them. The target raster format can be +customized to a particular application’s needs by +installing custom routines that manipulate image data +according to application requirements.

    + +

    The default usage for these routines is: check if an +image can be processed using TIFFRGBAImageOK, +construct a decoder state block using +TIFFRGBAImageBegin, read and decode an image into a +target raster using TIFFRGBAImageGet, and then +release resources using TIFFRGBAImageEnd. +TIFFRGBAImageGet can be called multiple times to +decode an image using different state parameters. If +multiple images are to be displayed and there is not enough +space for each of the decoded rasters, multiple state blocks +can be managed and then calls can be made to +TIFFRGBAImageGet as needed to display an image.

    + +

    The generated raster is assumed to be an array of +width times height 32-bit entries, where +width must be less than or equal to the width of the +image (height may be any non-zero size). If the +raster dimensions are smaller than the image, the image data +is cropped to the raster bounds. If the raster height is +greater than that of the image, then the image data are +placed in the lower part of the raster. (Note that the +raster is assume to be organized such that the pixel at +location (x,y) is +raster[y*width+x]; with the +raster origin in the lower-left hand corner.)

    + +

    Raster pixels are 8-bit packed red, green, blue, alpha +samples. The macros TIFFGetR, TIFFGetG, +TIFFGetB, and TIFFGetA should be used to +access individual samples. Images without Associated Alpha +matting information have a constant Alpha of 1.0 (255).

    + +

    TIFFRGBAImageGet converts non-8-bit images by +scaling sample values. Palette, grayscale, bilevel, +CMYK , and YCbCr images are converted to +RGB transparently. Raster pixels are returned +uncorrected by any colorimetry information present in the +directory.

    + +

    The parameter stopOnError specifies how to act if +an error is encountered while reading the image. If +stopOnError is non-zero, then an error will terminate +the operation; otherwise TIFFRGBAImageGet will +continue processing data until all the possible data in the +image have been requested.

    +
    + +

    ALTERNATE RASTER FORMATS

    + + + + + +
    +

    To use the core support for reading and processing +TIFF images, but write the resulting raster +data in a different format one need only override the +‘‘put methods’’ used to store +raster data. These methods are are defined in the +TIFFRGBAImage structure and initially setup by +TIFFRGBAImageBegin to point to routines that pack +raster data in the default ABGR pixel format. +Two different routines are used according to the physical +organization of the image data in the file: +PlanarConfiguration=1 (packed samples), and +PlanarConfiguration=2 (separated samples). Note that +this mechanism can be used to transform the data before +storing it in the raster. For example one can convert data +to colormap indices for display on a colormap display.

    +
    + +

    SIMULTANEOUS RASTER STORE AND DISPLAY

    + + + + + +
    +

    It is simple to display an image as it is being read into +memory by overriding the put methods as described above for +supporting alternate raster formats. Simply keep a reference +to the default put methods setup by +TIFFRGBAImageBegin and then invoke them before or +after each display operation. For example, the +tiffgt(1) utility uses the following put method to +update the display as the raster is being filled:

    + +
    static void
    +putContigAndDraw(TIFFRGBAImage* img, uint32* raster,
    +    uint32 x, uint32 y, uint32 w, uint32 h,
    +    int32 fromskew, int32 toskew,
    +    unsigned char* cp)
    +{
    +    (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp);
    +    if (x+w == width) {
    +     w = width;
    +     if (img->orientation == ORIENTATION_TOPLEFT)
    +         lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w);
    +     else
    +         lrectwrite(0, y, w-1, y+h-1, raster);
    +    }
    +}
    +
    + +

    (the original routine provided by the library is saved in +the variable putContig.)

    +
    + +

    SUPPORTING ADDITIONAL TIFF FORMATS

    + + + + + +
    +

    The TIFFRGBAImage routines support the most +commonly encountered flavors of TIFF. It is +possible to extend this support by overriding the +‘‘get method’’ invoked by +TIFFRGBAImageGet to read TIFF image +data. Details of doing this are a bit involved, it is best +to make a copy of an existing get method and modify it to +suit the needs of an application.

    +
    + +

    NOTES

    + + + + + +
    +

    Samples must be either 1, 2, 4, 8, or 16 bits. +Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. +SamplesPerPixel minus ExtraSamples).

    + +

    Palette image colormaps that appear to be incorrectly +written as 8-bit values are automatically scaled to +16-bits.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    All routines return 1 if the operation was successful. +Otherwise, 0 is returned if an error was encountered and +stopOnError is zero.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    Sorry, can not handle %d-bit pictures. The image +had BitsPerSample other than 1, 2, 4, 8, or 16.

    + +

    Sorry, can not handle %d-channel images. The image +had SamplesPerPixel other than 1, 3, or 4.

    + +

    Missing needed "PhotometricInterpretation" +tag. The image did not have a tag that describes how to +display the data.

    + +

    No "PhotometricInterpretation" tag, assuming +RGB. The image was missing a tag that describes how to +display it, but because it has 3 or 4 samples/pixel, it is +assumed to be RGB.

    + +

    No "PhotometricInterpretation" tag, assuming +min-is-black. The image was missing a tag that describes +how to display it, but because it has 1 sample/pixel, it is +assumed to be a grayscale or bilevel image.

    + +

    No space for photometric conversion table. There +was insufficient memory for a table used to convert image +samples to 8-bit RGB.

    + +

    Missing required "Colormap" tag. A +Palette image did not have a required Colormap +tag.

    + +

    No space for tile buffer. There was insufficient +memory to allocate an i/o buffer.

    + +

    No space for strip buffer. There was insufficient +memory to allocate an i/o buffer.

    + +

    Can not handle format. The image has a format +(combination of BitsPerSample, +SamplesPerPixel, and +PhotometricInterpretation) that can not be +handled.

    + +

    No space for B&W mapping table. There was +insufficient memory to allocate a table used to map +grayscale data to RGB.

    + +

    No space for Palette mapping table. There was +insufficient memory to allocate a table used to map data to +8-bit RGB.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), TIFFReadRGBAImage(3TIFF), +TIFFReadRGBAImageOriented(3TIFF), +TIFFReadRGBAStrip(3TIFF), +TIFFReadRGBATile(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadDirectory.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadDirectory.3tiff.html new file mode 100644 index 000000000..5e4004db7 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadDirectory.3tiff.html @@ -0,0 +1,218 @@ + + + + + + +TIFFReadDirectory + + + +

    TIFFReadDirectory

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadDirectory − get the contents of the +next directory in an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    int TIFFReadDirectory(TIFF +*tif)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Read the next directory in the specified file and +make it the current directory. Applications only need to +call TIFFReadDirectory to read multiple subfiles in a +single TIFF file— the first directory in a +file is automatically read when TIFFOpen is +called.

    +
    + +

    NOTES

    + + + + + +
    +

    If the library is compiled with +STRIPCHOP_SUPPORT enabled, then images that have a +single uncompressed strip or tile of data are automatically +treated as if they were made up of multiple strips or tiles +of approximately 8 kilobytes each. This operation is done +only in-memory; it does not alter the contents of the file. +However, the construction of the ‘‘chopped +strips’’ is visible to the application through +the number of strips [tiles] returned by +TIFFNumberOfStrips +[TIFFNumberOfTiles].

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    If the next directory was successfully read, 1 is +returned. Otherwise, 0 is returned if an error was +encountered, or if there are no more directories to be +read.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine. All warning messages are +directed to the TIFFWarning(3TIFF) routine.

    + +

    Seek error accessing TIFF directory. An error +occurred while positioning to the location of the +directory.

    + +

    Wrong data type %d for field "%s". +The tag entry in the directory had an incorrect data type. +For example, an ImageDescription tag with a +SHORT data type.

    + +

    TIFF directory is missing required "%s" +field. The specified tag is required to be present by +the TIFF 5.0 specification, but is missing. The +directory is (usually) unusable.

    + +

    %s: Rational with zero denominator. A +directory tag has a RATIONAL value whose +denominator is zero.

    + +

    Incorrect count %d for field "%s" (%lu, +expecting %lu); tag ignored. The specified tag’s +count field is bad. For example, a count other than 1 for a +SubFileType tag.

    + +

    Cannot handle different per-sample values for +field "%s". The tag has SamplesPerPixel +values and they are not all the same; e.g. +BitsPerSample. The library is unable to handle images +of this sort.

    + +

    Count mismatch for field "%s"; +expecting %d, got %d. The count field in a tag does not +agree with the number expected by the library. This should +never happen, so if it does, the library refuses to read the +directory.

    + +

    Invalid TIFF directory; tags are not sorted in +ascending order. The directory tags are not properly +sorted as specified in the TIFF 5.0 +specification. This error is not fatal.

    + +

    Ignoring unknown field with tag %d (0x%x). An +unknown tag was encountered in the directory; the library +ignores all such tags.

    + +

    TIFF directory is missing required +"ImageLength" field. The image violates the +specification by not having a necessary field. There is no +way for the library to recover from this error.

    + +

    TIFF directory is missing required +"PlanarConfig" field. The image violates the +specification by not having a necessary field. There is no +way for the library to recover from this error.

    + +

    TIFF directory is missing required +"StripOffsets" field. The image has multiple +strips, but is missing the tag that specifies the file +offset to each strip of data. There is no way for the +library to recover from this error.

    + +

    TIFF directory is missing required +"TileOffsets" field. The image has multiple +tiles, but is missing the tag that specifies the file offset +to each tile of data. There is no way for the library to +recover from this error.

    + +

    TIFF directory is missing required +"StripByteCounts" field. The image has +multiple strips, but is missing the tag that specifies the +size of each strip of data. There is no way for the library +to recover from this error.

    + +

    TIFF directory is missing required +"StripByteCounts" field, calculating from +imagelength. The image violates the specification by not +having a necessary field. However, when the image is +comprised of only one strip or tile, the library will +estimate the missing value based on the file size.

    + +

    Bogus "StripByteCounts" field, ignoring +and calculating from imagelength. Certain vendors +violate the specification by writing zero for the +StripByteCounts tag when they want to leave the value +unspecified. If the image has a single strip, the library +will estimate the missing value based on the file +size.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFWriteDirectory(3TIFF), +TIFFSetDirectory(3TIFF), +TIFFSetSubDirectory(3TIFF), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadEncodedStrip.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadEncodedStrip.3tiff.html new file mode 100644 index 000000000..c942063fc --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadEncodedStrip.3tiff.html @@ -0,0 +1,133 @@ + + + + + + +TIFFReadEncodedStrip + + + +

    TIFFReadEncodedStrip

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadEncodedStrip − read and decode a strip +of data from an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFReadEncodedStrip(TIFF +*tif, tstrip_t strip, +tdata_t buf, tsize_t +size)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Read the specified strip of data and place up to +size bytes of decompressed information in the (user +supplied) data buffer.

    +
    + +

    NOTES

    + + + + + +
    +

    The value of strip is a ‘‘raw +strip number.’’ That is, the caller must take +into account whether or not the data are organized in +separate planes (PlanarConfiguration=2). To read a +full strip of data the data buffer should typically be at +least as large as the number returned by +TIFFStripSize(3TIFF). If the -1 passed in size +parameter, the whole strip will be read. You should be sure +you have enough space allocated for the buffer.

    + +

    The library attempts to hide bit- and byte-ordering +differences between the image and the native machine by +converting data to the native machine order. Bit reversal is +done if the FillOrder tag is opposite to the native +machine bit order. 16- and 32-bit samples are automatically +byte-swapped if the file was written with a byte order +opposite to the native machine byte order,

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    The actual number of bytes of data that were placed +in buf is returned; TIFFReadEncodedStrip +returns −1 if an error was encountered.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFReadRawStrip(3TIFF), +TIFFReadScanline(3TIFF), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadEncodedTile.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadEncodedTile.3tiff.html new file mode 100644 index 000000000..92eb72a37 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadEncodedTile.3tiff.html @@ -0,0 +1,130 @@ + + + + + + +TIFFReadEncodedTile + + + +

    TIFFReadEncodedTile

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadEncodedTile − read and decode a tile of +data from an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    int TIFFReadEncodedTile(TIFF *tif, +ttile_t tile, tdata_t buf, +tsize_t size)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Read the specified tile of data and place up to +size bytes of decompressed information in the (user +supplied) data buffer.

    +
    + +

    NOTES

    + + + + + +
    +

    The value of tile is a ‘‘raw tile +number.’’ That is, the caller must take into +account whether or not the data are organized in separate +planes (PlanarConfiguration=2). +TIFFComputeTile automatically does this when +converting an (x,y,z,sample) coordinate quadruple to a tile +number. To read a full tile of data the data buffer should +be at least as large as the value returned by +TIFFTileSize.

    + +

    The library attempts to hide bit- and byte-ordering +differences between the image and the native machine by +converting data to the native machine order. Bit reversal is +done if the FillOrder tag is opposite to the native +machine bit order. 16- and 32-bit samples are automatically +byte-swapped if the file was written with a byte order +opposite to the native machine byte order,

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    The actual number of bytes of data that were placed in +buf is returned; TIFFReadEncodedTile returns +−1 if an error was encountered.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), TIFFReadRawTile(3TIFF), +TIFFReadTile(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBAImage.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBAImage.3tiff.html new file mode 100644 index 000000000..f648f0990 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBAImage.3tiff.html @@ -0,0 +1,301 @@ + + + + + + +TIFFReadRGBAImage + + + +

    TIFFReadRGBAImage

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadRGBAImage, TIFFReadRGBAImageOriented − read +and decode an image into a fixed-format raster

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    #define TIFFGetR(abgr) ((abgr) & 0xff)
    +#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
    +#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
    +#define TIFFGetA(abgr) (((abgr) >> 24) & +0xff)

    + +

    int TIFFReadRGBAImage(TIFF *tif, +uint32 width, uint32 height, +uint32 *raster, int +stopOnError)
    +int TIFFReadRGBAImageOriented(TIFF *
    tif, +uint32 width, uint32 height, +uint32 *raster, int orientation, +int stopOnError)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFReadRGBAImage reads a strip- or tile-based +image into memory, storing the result in the user supplied +raster. The raster is assumed to be an array of +width times height 32-bit entries, where +width must be less than or equal to the width of the +image (height may be any non-zero size). If the +raster dimensions are smaller than the image, the image data +is cropped to the raster bounds. If the raster height is +greater than that of the image, then the image data are +placed in the lower part of the raster. (Note that the +raster is assume to be organized such that the pixel at +location (x,y) is +raster[y*width+x]; with the +raster origin in the lower-left hand corner.)

    + +

    TIFFReadRGBAImageOriented works like +TIFFReadRGBAImage with except of that user can +specify the raster origin position with the +orientation parameter. Four orientations +supported:

    +
    + + + + + +
    +

    ORIENTATION_TOPLEFT

    + + + + + +
    +

    origin in top-left corner,

    +
    + + + + + +
    +

    ORIENTATION_TOPRIGHT

    + + + + + +
    +

    origin in top-right corner,

    +
    + + + + + +
    +

    ORIENTATION_BOTLEFT

    + + + + + +
    +

    origin in bottom-left corner and

    +
    + + + + + +
    +

    ORIENTATION_BOTRIGHT

    + + + + + +
    +

    origin in bottom-right corner.

    +
    + + + + + +
    +

    If you choose ORIENTATION_BOTLEFT result will be +the same as returned by the TIFFReadRGBAImage.

    + +

    Raster pixels are 8-bit packed red, green, blue, alpha +samples. The macros TIFFGetR, TIFFGetG, +TIFFGetB, and TIFFGetA should be used to +access individual samples. Images without Associated Alpha +matting information have a constant Alpha of 1.0 (255).

    + +

    TIFFReadRGBAImage converts non-8-bit images by +scaling sample values. Palette, grayscale, bilevel, +CMYK , and YCbCr images are converted to +RGB transparently. Raster pixels are returned +uncorrected by any colorimetry information present in the +directory.

    + +

    The paramater stopOnError specifies how to act if +an error is encountered while reading the image. If +stopOnError is non-zero, then an error will terminate +the operation; otherwise TIFFReadRGBAImage will +continue processing data until all the possible data in the +image have been requested.

    +
    + +

    NOTES

    + + + + + +
    +

    In C++ the stopOnError parameter defaults to +0.

    + +

    Samples must be either 1, 2, 4, 8, or 16 bits. +Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. +SamplesPerPixel minus ExtraSamples).

    + +

    Palettte image colormaps that appear to be incorrectly +written as 8-bit values are automatically scaled to +16-bits.

    + +

    TIFFReadRGBAImage is just a wrapper around the +more general TIFFRGBAImage(3TIFF) facilities.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    1 is returned if the image was successfully read and +converted. Otherwise, 0 is returned if an error was +encountered and stopOnError is zero.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    Sorry, can not handle %d-bit pictures. The image +had BitsPerSample other than 1, 2, 4, 8, or 16.

    + +

    Sorry, can not handle %d-channel images. The image +had SamplesPerPixel other than 1, 3, or 4.

    + +

    Missing needed "PhotometricInterpretation" +tag. The image did not have a tag that describes how to +display the data.

    + +

    No "PhotometricInterpretation" tag, assuming +RGB. The image was missing a tag that describes how to +display it, but because it has 3 or 4 samples/pixel, it is +assumed to be RGB.

    + +

    No "PhotometricInterpretation" tag, assuming +min-is-black. The image was missing a tag that describes +how to display it, but because it has 1 sample/pixel, it is +assumed to be a grayscale or bilevel image.

    + +

    No space for photometric conversion table. There +was insufficient memory for a table used to convert image +samples to 8-bit RGB.

    + +

    Missing required "Colormap" tag. A +Palette image did not have a required Colormap +tag.

    + +

    No space for tile buffer. There was insufficient +memory to allocate an i/o buffer.

    + +

    No space for strip buffer. There was insufficient +memory to allocate an i/o buffer.

    + +

    Can not handle format. The image has a format +(combination of BitsPerSample, +SamplesPerPixel, and +PhotometricInterpretation) that +TIFFReadRGBAImage can not handle.

    + +

    No space for B&W mapping table. There was +insufficient memory to allocate a table used to map +grayscale data to RGB.

    + +

    No space for Palette mapping table. There was +insufficient memory to allocate a table used to map data to +8-bit RGB.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), TIFFRGBAImage(3TIFF), +TIFFReadRGBAStrip(3TIFF), +TIFFReadRGBATile(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBAStrip.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBAStrip.3tiff.html new file mode 100644 index 000000000..3358df7dc --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBAStrip.3tiff.html @@ -0,0 +1,208 @@ + + + + + + +TIFFReadRGBAStrip + + + +

    TIFFReadRGBAStrip

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadRGBAStrip − read and decode an image strip +into a fixed-format raster

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    #define TIFFGetR(abgr) ((abgr) & 0xff)
    +#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)
    +#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)
    +#define TIFFGetA(abgr) (((abgr) >> 24) & +0xff)

    + +

    int TIFFReadRGBAStrip(TIFF *tif, +uint32 row, uint32 +*raster)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFReadRGBAStrip reads a single strip of a +strip-based image into memory, storing the result in the +user supplied RGBA raster. The raster is assumed to +be an array of width times rowsperstrip 32-bit entries, +where width is the width of the image (TIFFTAG_IMAGEWIDTH) +and rowsperstrip is the maximum lines in a strip +(TIFFTAG_ROWSPERSTRIP).

    + +

    The row value should be the row of the first row +in the strip (strip * rowsperstrip, zero based).

    + +

    Note that the raster is assume to be organized such that +the pixel at location (x,y) is +raster[y*width+x]; with the +raster origin in the lower-left hand corner of the +strip. That is bottom to top organization. When reading a +partial last strip in the file the last line of the image +will begin at the beginning of the buffer.

    + +

    Raster pixels are 8-bit packed red, green, blue, alpha +samples. The macros TIFFGetR, TIFFGetG, +TIFFGetB, and TIFFGetA should be used to +access individual samples. Images without Associated Alpha +matting information have a constant Alpha of 1.0 (255).

    + +

    See the TIFFRGBAImage(3TIFF) page for more details +on how various image types are converted to RGBA values.

    +
    + +

    NOTES

    + + + + + +
    +

    Samples must be either 1, 2, 4, 8, or 16 bits. +Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. +SamplesPerPixel minus ExtraSamples).

    + +

    Palette image colormaps that appear to be incorrectly +written as 8-bit values are automatically scaled to +16-bits.

    + +

    TIFFReadRGBAStrip is just a wrapper around the +more general TIFFRGBAImage(3TIFF) facilities. +It’s main advantage over the similar +TIFFReadRGBAImage() function is that for large images +a single buffer capable of holding the whole image +doesn’t need to be allocated, only enough for one +strip. The TIFFReadRGBATile() function does a similar +operation for tiled images.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    1 is returned if the image was successfully read and +converted. Otherwise, 0 is returned if an error was +encountered.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    Sorry, can not handle %d-bit pictures. The image +had BitsPerSample other than 1, 2, 4, 8, or 16.

    + +

    Sorry, can not handle %d-channel images. The image +had SamplesPerPixel other than 1, 3, or 4.

    + +

    Missing needed "PhotometricInterpretation" +tag. The image did not have a tag that describes how to +display the data.

    + +

    No "PhotometricInterpretation" tag, assuming +RGB. The image was missing a tag that describes how to +display it, but because it has 3 or 4 samples/pixel, it is +assumed to be RGB.

    + +

    No "PhotometricInterpretation" tag, assuming +min-is-black. The image was missing a tag that describes +how to display it, but because it has 1 sample/pixel, it is +assumed to be a grayscale or bilevel image.

    + +

    No space for photometric conversion table. There +was insufficient memory for a table used to convert image +samples to 8-bit RGB.

    + +

    Missing required "Colormap" tag. A +Palette image did not have a required Colormap +tag.

    + +

    No space for tile buffer. There was insufficient +memory to allocate an i/o buffer.

    + +

    No space for strip buffer. There was insufficient +memory to allocate an i/o buffer.

    + +

    Can not handle format. The image has a format +(combination of BitsPerSample, +SamplesPerPixel, and +PhotometricInterpretation) that +TIFFReadRGBAImage can not handle.

    + +

    No space for B&W mapping table. There was +insufficient memory to allocate a table used to map +grayscale data to RGB.

    + +

    No space for Palette mapping table. There was +insufficient memory to allocate a table used to map data to +8-bit RGB.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), TIFFRGBAImage(3TIFF), +TIFFReadRGBAImage(3TIFF), +TIFFReadRGBATile(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBATile.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBATile.3tiff.html new file mode 100644 index 000000000..bdbb43cc3 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRGBATile.3tiff.html @@ -0,0 +1,261 @@ + + + + + + +TIFFReadRGBATile + + + +

    TIFFReadRGBATile

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadRGBATile − read and decode an image tile +into a fixed-format raster

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    #define TIFFGetR(abgr)

    +
    + +

    ((abgr) & 0xff)

    +
    + +

    #define TIFFGetG(abgr)

    +
    + +

    (((abgr) >> 8) & 0xff)

    +
    + +

    #define TIFFGetB(abgr)

    +
    + +

    (((abgr) >> 16) & 0xff)

    +
    + +

    #define TIFFGetA(abgr)

    +
    + +

    (((abgr) >> 24) & 0xff)

    +
    + + + + + +
    +

    int TIFFReadRGBATile(TIFF *tif, +uint32 x, uint32 y, uint32 +*raster)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFReadRGBATile reads a single tile of a +tile-based image into memory, storing the result in the user +supplied RGBA raster. The raster is assumed to be an +array of width times length 32-bit entries, where width is +the width of a tile (TIFFTAG_TILEWIDTH) and length is the +height of a tile (TIFFTAG_TILELENGTH).

    + +

    The x and y values are the offsets from the +top left corner to the top left corner of the tile to be +read. They must be an exact multiple of the tile width and +length.

    + +

    Note that the raster is assume to be organized such that +the pixel at location (x,y) is +raster[y*width+x]; with the +raster origin in the lower-left hand corner of the +tile. That is bottom to top organization. Edge tiles which +partly fall off the image will be filled out with +appropriate zeroed areas.

    + +

    Raster pixels are 8-bit packed red, green, blue, alpha +samples. The macros TIFFGetR, TIFFGetG, +TIFFGetB, and TIFFGetA should be used to +access individual samples. Images without Associated Alpha +matting information have a constant Alpha of 1.0 (255).

    + +

    See the TIFFRGBAImage(3TIFF) page for more details +on how various image types are converted to RGBA values.

    +
    + +

    NOTES

    + + + + + +
    +

    Samples must be either 1, 2, 4, 8, or 16 bits. +Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. +SamplesPerPixel minus ExtraSamples).

    + +

    Palette image colormaps that appear to be incorrectly +written as 8-bit values are automatically scaled to +16-bits.

    + +

    TIFFReadRGBATile is just a wrapper around the more +general TIFFRGBAImage(3TIFF) facilities. It’s +main advantage over the similar TIFFReadRGBAImage() +function is that for large images a single buffer capable of +holding the whole image doesn’t need to be allocated, +only enough for one tile. The TIFFReadRGBAStrip() +function does a similar operation for stripped images.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    1 is returned if the image was successfully read and +converted. Otherwise, 0 is returned if an error was +encountered.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    Sorry, can not handle %d-bit pictures. The image +had BitsPerSample other than 1, 2, 4, 8, or 16.

    + +

    Sorry, can not handle %d-channel images. The image +had SamplesPerPixel other than 1, 3, or 4.

    + +

    Missing needed "PhotometricInterpretation" +tag. The image did not have a tag that describes how to +display the data.

    + +

    No "PhotometricInterpretation" tag, assuming +RGB. The image was missing a tag that describes how to +display it, but because it has 3 or 4 samples/pixel, it is +assumed to be RGB.

    + +

    No "PhotometricInterpretation" tag, assuming +min-is-black. The image was missing a tag that describes +how to display it, but because it has 1 sample/pixel, it is +assumed to be a grayscale or bilevel image.

    + +

    No space for photometric conversion table. There +was insufficient memory for a table used to convert image +samples to 8-bit RGB.

    + +

    Missing required "Colormap" tag. A +Palette image did not have a required Colormap +tag.

    + +

    No space for tile buffer. There was insufficient +memory to allocate an i/o buffer.

    + +

    No space for strip buffer. There was insufficient +memory to allocate an i/o buffer.

    + +

    Can not handle format. The image has a format +(combination of BitsPerSample, +SamplesPerPixel, and +PhotometricInterpretation) that +TIFFReadRGBAImage can not handle.

    + +

    No space for B&W mapping table. There was +insufficient memory to allocate a table used to map +grayscale data to RGB.

    + +

    No space for Palette mapping table. There was +insufficient memory to allocate a table used to map data to +8-bit RGB.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), TIFFRGBAImage(3TIFF), +TIFFReadRGBAImage(3TIFF), +TIFFReadRGBAStrip(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRawStrip.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRawStrip.3tiff.html new file mode 100644 index 000000000..d8ea9d981 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRawStrip.3tiff.html @@ -0,0 +1,109 @@ + + + + + + +TIFFReadRawStrip + + + +

    TIFFReadRawStrip

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadRawStrip − return the undecoded contents of +a strip of data from an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFReadRawStrip(TIFF *tif, +tstrip_t strip, tdata_t buf, +tsize_t size)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Read the contents of the specified strip into the (user +supplied) data buffer. Note that the value of strip +is a ‘‘raw strip number.’’ That is, +the caller must take into account whether or not the data is +organized in separate planes (PlanarConfiguration=2). +To read a full strip of data the data buffer should +typically be at least as large as the number returned by +TIFFStripSize.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    The actual number of bytes of data that were placed in +buf is returned; TIFFReadRawStrip returns +−1 if an error was encountered.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFReadEncodedStrip(3TIFF), +TIFFReadScanline(3TIFF), TIFFStripSize(3TIFF), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRawTile.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRawTile.3tiff.html new file mode 100644 index 000000000..0065d2cf0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadRawTile.3tiff.html @@ -0,0 +1,111 @@ + + + + + + +TIFFReadRawTile + + + +

    TIFFReadRawTile

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadRawTile − return an undecoded tile of data +from an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFReadRawTile(TIFF *tif, +ttile_t tile, tdata_t buf, +tsize_t size)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Read the contents of the specified tile into the (user +supplied) data buffer. Note that the value of tile is +a ‘‘raw tile number.’’ That is, the +caller must take into account whether or not the data is +organized in separate planes (PlanarConfiguration=2). +TIFFComputeTile automatically does this when +converting an (x,y,z,sample) coordinate quadruple to a tile +number. To read a full tile of data the data buffer should +typically be at least as large as the value returned by +TIFFTileSize.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    The actual number of bytes of data that were placed in +buf is returned; TIFFReadEncodedTile returns +−1 if an error was encountered.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFReadEncodedTile(3TIFF), +TIFFReadTile(3TIFF), TIFFTileSize(3TIFF), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadScanline.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadScanline.3tiff.html new file mode 100644 index 000000000..79f17fcd9 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadScanline.3tiff.html @@ -0,0 +1,157 @@ + + + + + + +TIFFReadScanline + + + +

    TIFFReadScanline

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadScanline − read and decode a scanline of +data from an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    int TIFFReadScanline(TIFF *tif, +tdata_t buf, uint32 row, +tsample_t sample)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Read the data for the specified row into the (user +supplied) data buffer buf. The data are returned +decompressed and, in the native byte- and bit-ordering, but +are otherwise packed (see further below). The buffer must be +large enough to hold an entire scanline of data. +Applications should call the routine TIFFScanlineSize +to find out the size (in bytes) of a scanline buffer. The +row parameter is always used by +TIFFReadScanline; the sample parameter is used +only if data are organized in separate planes +(PlanarConfiguration=2).

    +
    + +

    NOTES

    + + + + + +
    +

    The library attempts to hide bit- and byte-ordering +differences between the image and the native machine by +converting data to the native machine order. Bit reversal is +done if the FillOrder tag is opposite to the native +machine bit order. 16- and 32-bit samples are automatically +byte-swapped if the file was written with a byte order +opposite to the native machine byte order,

    + +

    In C++ the sample parameter defaults to 0.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    TIFFReadScanline returns −1 if it detects an +error; otherwise 1 is returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    Compression algorithm does not support random +access. Data was requested in a non-sequential order +from a file that uses a compression algorithm and that has +RowsPerStrip greater than one. That is, data in the +image is stored in a compressed form, and with multiple rows +packed into a strip. In this case, the library does not +support random access to the data. The data should either be +accessed sequentially, or the file should be converted so +that each strip is made up of one row of data.

    +
    + +

    BUGS

    + + + + + +
    +

    Reading subsampled YCbCR data does not work correctly +because, for PlanarConfiguration=2 the size of a +scanline is not calculated on a per-sample basis, and for +PlanarConfiguration=1 the library does not unpack the +block-interleaved samples; use the strip- and tile-based +interfaces to read these formats.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFReadEncodedStrip(3TIFF), +TIFFReadRawStrip(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadTile.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadTile.3tiff.html new file mode 100644 index 000000000..26054803b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFReadTile.3tiff.html @@ -0,0 +1,133 @@ + + + + + + +TIFFReadTile + + + +

    TIFFReadTile

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadTile − read and decode a tile of data from +an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFReadTile(TIFF *tif, +tdata_t buf, uint32 x, +uint32 y, uint32 z, +tsample_t sample)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Return the data for the tile containing the +specified coordinates. The data placed in buf are +returned decompressed and, typically, in the native byte- +and bit-ordering, but are otherwise packed (see further +below). The buffer must be large enough to hold an entire +tile of data. Applications should call the routine +TIFFTileSize to find out the size (in bytes) of a +tile buffer. The x and y parameters are always +used by TIFFReadTile. The z parameter is used +if the image is deeper than 1 slice +(ImageDepth>1). The sample parameter is +used only if data are organized in separate planes +(PlanarConfiguration=2).

    +
    + +

    NOTES

    + + + + + +
    +

    The library attempts to hide bit- and byte-ordering +differences between the image and the native machine by +converting data to the native machine order. Bit reversal is +done if the FillOrder tag is opposite to the native +machine bit order. 16- and 32-bit samples are automatically +byte-swapped if the file was written with a byte order +opposite to the native machine byte order,

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    TIFFReadTile returns −1 if it detects an +error; otherwise the number of bytes in the decoded tile is +returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFCheckTile(3TIFF), +TIFFComputeTile(3TIFF), TIFFOpen(3TIFF), +TIFFReadEncodedTile(3TIFF), +TIFFReadRawTile(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFSetDirectory.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFSetDirectory.3tiff.html new file mode 100644 index 000000000..c34340562 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFSetDirectory.3tiff.html @@ -0,0 +1,122 @@ + + + + + + +TIFFSetDirectory + + + +

    TIFFSetDirectory

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFSetDirectory, TIFFSetSubDirectory − set the +current directory for an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    int TIFFSetDirectory(TIFF *tif, +tdir_t dirnum)
    +int TIFFSetSubDirectory(TIFF *
    tif, uint32 +diroff)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFSetDirectory changes the current directory and +reads its contents with TIFFReadDirectory. The +parameter dirnum specifies the subfile/directory as +an integer number, with the first directory numbered +zero.

    + +

    TIFFSetSubDirectory acts like +TIFFSetDirectory, except the directory is specified +as a file offset instead of an index; this is required for +accessing subdirectories linked through a SubIFD +tag.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    On successful return 1 is returned. Otherwise, 0 is +returned if dirnum or diroff specifies a +non-existent directory, or if an error was encountered while +reading the directory’s contents.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    %s: Error fetching directory count. An error was +encountered while reading the ‘‘directory +count’’ field.

    + +

    %s: Error fetching directory link. An error was +encountered while reading the ‘‘link +value’’ that points to the next directory in a +file.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFCurrentDirectory(3TIFF), +TIFFOpen(3TIFF), TIFFReadDirectory(3TIFF), +TIFFWriteDirectory(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFSetField.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFSetField.3tiff.html new file mode 100644 index 000000000..ce6a88b08 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFSetField.3tiff.html @@ -0,0 +1,1865 @@ + + + + + + + + + +TIFFSetField + + + + +

    TIFFSetField

    + +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + + +

    NAME + +

    + + +

    TIFFSetField, +TIFFVSetField − set the value(s) of a tag in a +TIFF file open for writing

    + +

    SYNOPSIS + +

    + + +

    #include +<tiffio.h>

    + +

    int +TIFFSetField(TIFF *tif, ttag_t +tag, ...)

    + +

    #include +<stdarg.h>

    + +

    int +TIFFVSetField(TIFF *tif, ttag_t +tag, va_list ap)

    + +

    DESCRIPTION + +

    + + + +

    TIFFSetField +sets the value of a field or pseudo-tag in the current +directory associated with the open TIFF file +tif. (A pseudo-tag is a parameter that is used +to control the operation of the TIFF library +but whose value is not read or written to the underlying +file.) To set the value of a field the file must have been +previously opened for writing with TIFFOpen(3TIFF); +pseudo-tags can be set whether the file was opened for +reading or writing. The field is identified by tag, +one of the values defined in the include file tiff.h +(see also the table below). The actual value is specified +using a variable argument list, as prescribed by the +stdarg(3) interface (or, on some machines, the +varargs(3) interface.)

    + + +

    TIFFVSetField +is functionally equivalent to TIFFSetField except +that it takes a pointer to a variable argument list. +TIFFVSetField is useful for writing routines that are +layered on top of the functionality provided by +TIFFSetField.

    + +

    The tags +understood by libtiff, the number of parameter +values, and the expected types for the parameter values are +shown below. The data types are: char* is +null-terminated string and corresponds to the +ASCII data type; uint16 is an unsigned +16-bit value; uint32 is an unsigned 32-bit value; +uint16* is an array of unsigned 16-bit values. +void* is an array of data values of unspecified +type.

    + +

    Consult the +TIFF specification for information on the +meaning of each tag.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + +

    Tag Name

    + + +

    Count

    +
    + + +

    Types

    + + +

    Notes

    + + +

    TIFFTAG_ARTIST

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_BADFAXLINES

    + + +

    1

    +
    + + +

    uint32

    +
    + + +

    TIFFTAG_BITSPERSAMPLE

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_CLEANFAXDATA

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_COLORMAP

    + + +

    3

    +
    + + +

    uint16*

    + + +

    1<<BitsPerSample arrays

    + + +

    TIFFTAG_COMPRESSION

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_CONSECUTIVEBADFAXLINES

    + + +

    1

    +
    + + +

    uint32

    +
    + + +

    TIFFTAG_COPYRIGHT

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_DATETIME

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_DOCUMENTNAME

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_DOTRANGE

    + + +

    2

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_EXTRASAMPLES

    + + +

    2

    +
    + + +

    uint16,uint16*

    + + +

    † count & types array

    + + +

    TIFFTAG_FAXFILLFUNC

    + + +

    1

    +
    + + +

    TIFFFaxFillFunc

    + + +

    G3/G4 compression pseudo-tag

    + + +

    TIFFTAG_FAXMODE

    + + +

    1

    +
    + + +

    int

    + + +

    † G3/G4 compression pseudo-tag

    + + +

    TIFFTAG_FILLORDER

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_GROUP3OPTIONS

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_GROUP4OPTIONS

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_HALFTONEHINTS

    + + +

    2

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_HOSTCOMPUTER

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_ICCPROFILE

    + + +

    2

    +
    + + +

    uint32,void*

    + + +

    count, profile data

    + + +

    TIFFTAG_IMAGEDEPTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_IMAGEDESCRIPTION

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_IMAGELENGTH

    + + +

    1

    +
    + + +

    uint32

    +
    + + +

    TIFFTAG_IMAGEWIDTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_INKNAMES

    + + +

    2

    +
    + + +

    uint16, char*

    +
    + + +

    TIFFTAG_INKSET

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_JPEGCOLORMODE

    + + +

    1

    +
    + + +

    int

    + + +

    † JPEG pseudo-tag

    + + +

    TIFFTAG_JPEGQUALITY

    + + +

    1

    +
    + + +

    int

    + + +

    JPEG pseudo-tag

    + + +

    TIFFTAG_JPEGTABLES

    + + +

    2

    +
    + + +

    uint32*,void*

    + + +

    † count & tables

    + + +

    TIFFTAG_JPEGTABLESMODE

    + + +

    1

    +
    + + +

    int

    + + +

    † JPEG pseudo-tag

    + + +

    TIFFTAG_MAKE

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_MATTEING

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_MAXSAMPLEVALUE

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_MINSAMPLEVALUE

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_MODEL

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_ORIENTATION

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_PAGENAME

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_PAGENUMBER

    + + +

    2

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_PHOTOMETRIC

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_PHOTOSHOP

    + + +

    ?

    +
    + + +

    uint32,void*

    + + +

    count, data

    + + +

    TIFFTAG_PLANARCONFIG

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_PREDICTOR

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_PRIMARYCHROMATICITIES

    + + +

    1

    +
    + + +

    float*

    + + +

    6-entry array

    + + +

    TIFFTAG_REFERENCEBLACKWHITE

    + + +

    1

    +
    + + +

    float*

    + + +

    † 6-entry array

    + + +

    TIFFTAG_RESOLUTIONUNIT

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_RICHTIFFIPTC

    + + +

    2

    +
    + + +

    uint32,void*

    + + +

    count, data

    + + +

    TIFFTAG_ROWSPERSTRIP

    + + +

    1

    +
    + + +

    uint32

    + + +

    † must be > 0

    + + +

    TIFFTAG_SAMPLEFORMAT

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_SAMPLESPERPIXEL

    + + +

    1

    +
    + + +

    uint16

    + + +

    † value must be <= 4

    + + +

    TIFFTAG_SMAXSAMPLEVALUE

    + + +

    1

    +
    + + +

    double

    +
    + + +

    TIFFTAG_SMINSAMPLEVALUE

    + + +

    1

    +
    + + +

    double

    +
    + + +

    TIFFTAG_SOFTWARE

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_STONITS

    + + +

    1

    +
    + + +

    double

    + + +

    + + +

    TIFFTAG_SUBFILETYPE

    + + +

    1

    +
    + + +

    uint32

    +
    + + +

    TIFFTAG_SUBIFD

    + + +

    2

    +
    + + +

    uint16,uint32*

    + + +

    count & offsets array

    + + +

    TIFFTAG_TARGETPRINTER

    + + +

    1

    +
    + + +

    char*

    +
    + + +

    TIFFTAG_THRESHHOLDING

    + + +

    1

    +
    + + +

    uint16

    +
    + + +

    TIFFTAG_TILEDEPTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    + + +

    TIFFTAG_TILELENGTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    † must be a multiple of 8

    + + +

    TIFFTAG_TILEWIDTH

    + + +

    1

    +
    + + +

    uint32

    + + +

    † must be a multiple of 8

    + + +

    TIFFTAG_TRANSFERFUNCTION

    + + +

    1 or 3‡ uint16*

    + + +

    1<<BitsPerSample entry arrays

    + + +

    TIFFTAG_WHITEPOINT

    + + +

    1

    +
    + + +

    float*

    + + +

    2-entry array

    + + +

    TIFFTAG_XMLPACKET

    + + +

    2

    +
    + + +

    uint32,void*

    + + +

    count, data

    + + +

    TIFFTAG_XPOSITION

    + + +

    1

    +
    + + +

    float

    +
    + + +

    TIFFTAG_XRESOLUTION

    + + +

    1

    +
    + + +

    float

    +
    + + +

    TIFFTAG_YCBCRCOEFFICIENTS

    + + +

    1

    +
    + + +

    float*

    + + +

    † 3-entry array

    + + +

    TIFFTAG_YCBCRPOSITIONING

    + + +

    1

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_YCBCRSAMPLING

    + + +

    2

    +
    + + +

    uint16

    + + +

    + + +

    TIFFTAG_YPOSITION

    + + +

    1

    +
    + + +

    float

    +
    + + +

    TIFFTAG_YRESOLUTION

    + + +

    1

    +
    + + +

    float

    +
    + +

    † Tag may not have its +values changed once data is written.
    +‡ If SamplesPerPixel is one, then a single +array is passed; otherwise three arrays should be passed. +
    +* The contents of this field are quite complex. See The +ICC Profile Format Specification, Annex B.3 +"Embedding ICC Profiles in TIFF Files" (available +at http://www.color.org) for an explanation.

    + +

    RETURN VALUES + +

    + + +

    1 is returned +if the operation was successful. Otherwise, 0 is returned if +an error was detected.

    + +

    DIAGNOSTICS + +

    + + +

    All error +messages are directed to the TIFFError(3TIFF) +routine.

    + +

    %s: Cannot +modify tag "%s" while writing. Data has +already been written to the file, so the specified +tag’s value can not be changed. This restriction is +applied to all tags that affect the format of written +data.

    + +

    %d: Bad +value for "%s". An invalid value was supplied +for the named tag.

    + +

    SEE ALSO + +

    + + + +

    TIFFOpen(3TIFF), +TIFFGetField(3TIFF), TIFFSetDirectory(3TIFF), +TIFFWriteDirectory(3TIFF), +TIFFReadDirectory(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library +home page: http://www.simplesystems.org/libtiff/

    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWarning.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWarning.3tiff.html new file mode 100644 index 000000000..856cd40bb --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWarning.3tiff.html @@ -0,0 +1,108 @@ + + + + + + +TIFFWarning + + + +

    TIFFWarning

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFWarning, TIFFSetWarningHandler − library +warning interface

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    void TIFFWarning(const char *module, +const char *fmt, ...)

    + +

    #include <stdarg.h>

    + +

    typedef void (*TIFFWarningHandler)(const char +*module, const char *fmt, +va_list ap);

    + +

    TIFFWarningHandler +TIFFSetWarningHandler(TIFFWarningHandler +handler);

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFWarning invokes the library-wide warning +handler function to (normally) write a warning message to +the stderr. The fmt parameter is a +printf(3S) format string, and any number arguments +can be supplied. The module parameter is interpreted +as a string that, if non-zero, should be printed before the +message; it typically is used to identify the software +module in which a warning is detected.

    + +

    Applications that desire to capture control in the event +of a warning should use TIFFSetWarningHandler to +override the default warning handler. A NULL +(0) warning handler function may be installed to suppress +error messages.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    TIFFSetWarningHandler returns a reference to the +previous error handling function.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFError(3TIFF), libtiff(3TIFF), +printf(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteDirectory.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteDirectory.3tiff.html new file mode 100644 index 000000000..6483aa6ac --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteDirectory.3tiff.html @@ -0,0 +1,176 @@ + + + + + + +TIFFWriteDirectory + + + +

    TIFFWriteDirectory

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFWriteDirectory, TIFFRewriteDirectory, +TIFFCheckpointDirectory − write the current directory +in an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    int TIFFWriteDirectory(TIFF *tif)
    +int TIFFRewriteDirectory(TIFF *
    tif)
    +int TIFFCheckpointDirectory(TIFF *
    tif)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFWriteDirectory will write the contents of the +current directory to the file and setup to create a new +subfile in the same file. Applications only need to call +TIFFWriteDirectory when writing multiple subfiles to +a single TIFF file. TIFFWriteDirectory +is automatically called by TIFFClose and +TIFFFlush to write a modified directory if the file +is open for writing.

    + +

    The TIFFRewriteDirectory function operates +similarly to TIFFWriteDirectory, but can be called +with directories previously read or written that already +have an established location in the file. It will rewrite +the directory, but instead of place it at it’s old +location (as TIFFWriteDirectory would) it will place +them at the end of the file, correcting the pointer from the +preceding directory or file header to point to it’s +new location. This is particularly important in cases where +the size of the directory and pointed to data has grown, so +it won’t fit in the space available at the old +location.

    + +

    The TIFFCheckpointDirectory writes the current +state of the tiff directory into the file to make what is +currently in the file readable. Unlike +TIFFWriteDirectory, TIFFCheckpointDirectory does not +free up the directory data structures in memory, so they can +be updated (as strips/tiles are written) and written again. +Reading such a partial file you will at worst get a tiff +read error for the first strip/tile encountered that is +incomplete, but you will at least get all the valid data in +the file before that. When the file is complete, just use +TIFFWriteDirectory as usual to finish it off +cleanly.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    1 is returned when the contents are successfully written +to the file. Otherwise, 0 is returned if an error was +encountered when writing the directory contents.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    Error post-encoding before directory write. Before +writing the contents of the current directory, any pending +data are flushed. This message indicates that an error +occurred while doing this.

    + +

    Error flushing data before directory write. Before +writing the contents of the current directory, any pending +data are flushed. This message indicates that an error +occurred while doing this.

    + +

    Cannot write directory, out of space. There was +not enough space to allocate a temporary area for the +directory that was to be written.

    + +

    Error writing directory count. A write error +occurred when writing the count of fields in the +directory.

    + +

    Error writing directory contents. A write error +occurred when writing the directory fields.

    + +

    Error writing directory link. A write error +occurred when writing the link to the next directory.

    + +

    Error writing data for field "%s". A +write error occurred when writing indirect data for the +specified field.

    + +

    Error writing TIFF header. A write error occurred +when re-writing header at the front of the file.

    + +

    Error fetching directory count. A read error +occurred when fetching the directory count field for a +previous directory. This can occur when setting up a link to +the directory that is being written.

    + +

    Error fetching directory link. A read error +occurred when fetching the directory link field for a +previous directory. This can occur when setting up a link to +the directory that is being written.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), TIFFError(3TIFF), +TIFFReadDirectory(3TIFF), +TIFFSetDirectory(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteEncodedStrip.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteEncodedStrip.3tiff.html new file mode 100644 index 000000000..cf7a488f0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteEncodedStrip.3tiff.html @@ -0,0 +1,153 @@ + + + + + + +TIFFWriteEncodedStrip + + + +

    TIFFWriteEncodedStrip

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFWritedEncodedStrip − compress and write a +strip of data to an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFWriteEncodedStrip(TIFF +*tif, tstrip_t strip, +tdata_t buf, tsize_t +size)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Compress size bytes of raw data from +buf and write the result to the specified strip; +replacing any previously written data. Note that the value +of strip is a ‘‘raw strip +number.’’ That is, the caller must take into +account whether or not the data are organized in separate +planes (PlanarConfiguration=2).

    +
    + +

    NOTES

    + + + + + +
    +

    The library writes encoded data using the native +machine byte order. Correctly implemented TIFF +readers are expected to do any necessary byte-swapping +to correctly process image data with BitsPerSample greater +than 8.

    + +

    The strip number must be valid according to the +current settings of the ImageLength and +RowsPerStrip tags. An image may be dynamically grown +by increasing the value of ImageLength prior to each +call to TIFFWriteEncodedStrip.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    −1 is returned if an error was encountered. +Otherwise, the value of size is returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    %s: File not open for writing. The file was +opened for reading, not writing.

    + +

    Can not write scanlines to a tiled image. The +image is assumed to be organized in tiles because the +TileWidth and TileLength tags have been set +with TIFFSetField(3TIFF).

    + +

    %s: Must set "ImageWidth" before +writing data. The image’s width has not be set +before the first write. See TIFFSetField(3TIFF) for +information on how to do this.

    + +

    %s: Must set "PlanarConfiguration" +before writing data. The organization of data has not be +defined before the first write. See +TIFFSetField(3TIFF) for information on how to do +this.

    + +

    %s: No space for strip arrays". There +was not enough space for the arrays that hold strip offsets +and byte counts.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFWriteScanline(3TIFF), +TIFFWriteRawStrip(3TIFF), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteEncodedTile.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteEncodedTile.3tiff.html new file mode 100644 index 000000000..8cd441128 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteEncodedTile.3tiff.html @@ -0,0 +1,147 @@ + + + + + + +TIFFWriteEncodedTile + + + +

    TIFFWriteEncodedTile

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFWritedEncodedTile − compress and write a +tile of data to an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFWriteEncodedTile(TIFF +*tif, ttile_t tile, tdata_t +buf, tsize_t size)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Compress size bytes of raw data from +buf and append the result to the end of the +specified tile. Note that the value of tile is a +‘‘raw tile number.’’ That is, the +caller must take into account whether or not the data are +organized in separate places (PlanarConfiguration=2). +TIFFComputeTile automatically does this when +converting an (x,y,z,sample) coordinate quadruple to a tile +number.

    +
    + +

    NOTES

    + + + + + +
    +

    The library writes encoded data using the native +machine byte order. Correctly implemented TIFF +readers are expected to do any necessary byte-swapping +to correctly process image data with BitsPerSample greater +than 8.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    −1 is returned if an error was encountered. +Otherwise, the value of size is returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    %s: File not open for writing. The file was +opened for reading, not writing.

    + +

    Can not write tiles to a stripped image. The +image is assumed to be organized in strips because neither +of the TileWidth or TileLength tags have been +set with TIFFSetField(3TIFF).

    + +

    %s: Must set "ImageWidth" before +writing data. The image’s width has not be set +before the first write. See TIFFSetField(3TIFF) for +information on how to do this.

    + +

    %s: Must set "PlanarConfiguration" +before writing data. The organization of data has not be +defined before the first write. See +TIFFSetField(3TIFF) for information on how to do +this.

    + +

    %s: No space for tile arrays". There was +not enough space for the arrays that hold tile offsets and +byte counts.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), TIFFWriteTile(3TIFF), +TIFFWriteRawTile(3TIFF), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteRawStrip.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteRawStrip.3tiff.html new file mode 100644 index 000000000..3379b8b04 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteRawStrip.3tiff.html @@ -0,0 +1,144 @@ + + + + + + +TIFFWriteRawstrip + + + +

    TIFFWriteRawstrip

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFWriteRawStrip − write a strip of raw data to an +open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFWriteRawStrip(TIFF *tif, +tstrip_t strip, tdata_t buf, +tsize_t size)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Append size bytes of raw data to the specified +strip.

    +
    + +

    NOTES

    + + + + + +
    +

    The strip number must be valid according to the current +settings of the ImageLength and RowsPerStrip +tags. An image may be dynamically grown by increasing the +value of ImageLength prior to each call to +TIFFWriteRawStrip.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    −1 is returned if an error occurred. Otherwise, the +value of size is returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    %s: File not open for writing. The file was opened +for reading, not writing.

    + +

    Can not write scanlines to a tiled image. The +image is assumed to be organized in tiles because the +TileWidth and TileLength tags have been set +with TIFFSetField(3TIFF).

    + +

    %s: Must set "ImageWidth" before writing +data. The image’s width has not be set before the +first write. See TIFFSetField(3TIFF) for information +on how to do this.

    + +

    %s: Must set "PlanarConfiguration" before +writing data. The organization of data has not be +defined before the first write. See +TIFFSetField(3TIFF) for information on how to do +this.

    + +

    %s: No space for strip arrays". There was not +enough space for the arrays that hold strip offsets and byte +counts.

    + +

    %s: Strip %d out of range, max %d. The specified +strip is not a valid strip according to the currently +specified image dimensions.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFWriteEncodedStrip(3TIFF), +TIFFWriteScanline(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteRawTile.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteRawTile.3tiff.html new file mode 100644 index 000000000..92d64f0f8 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteRawTile.3tiff.html @@ -0,0 +1,128 @@ + + + + + + +TIFFWriteRawtile + + + +

    TIFFWriteRawtile

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFWriteRawTile − write a tile of raw data to an +open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFWriteRawTile(TIFF *tif, +ttile_t tile, tdata_t buf, +tsize_t size)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Append size bytes of raw data to the specified +tile.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    −1 is returned if an error occurred. Otherwise, the +value of size is returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    %s: File not open for writing. The file was opened +for reading, not writing.

    + +

    Can not write tiles to a stripped image. The image +is assumed to be organized in strips because neither of the +TileWidth or TileLength tags have been set +with TIFFSetField(3TIFF).

    + +

    %s: Must set "ImageWidth" before writing +data. The image’s width has not be set before the +first write. See TIFFSetField(3TIFF) for information +on how to do this.

    + +

    %s: Must set "PlanarConfiguration" before +writing data. The organization of data has not be +defined before the first write. See +TIFFSetField(3TIFF) for information on how to do +this.

    + +

    %s: No space for tile arrays". There was not +enough space for the arrays that hold tile offsets and byte +counts.

    + +

    %s: Specified tile %d out of range, max %d. The +specified tile is not valid according to the currently +specified image dimensions.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFWriteEncodedTile(3TIFF), +TIFFWriteScanline(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteScanline.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteScanline.3tiff.html new file mode 100644 index 000000000..8f3002170 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteScanline.3tiff.html @@ -0,0 +1,206 @@ + + + + + + +TIFFWriteScanline + + + +

    TIFFWriteScanline

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +NOTES
    +RETURN VALUES
    +DIAGNOSTICS
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFWriteScanline − write a scanline to an open +TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    int TIFFWriteScanline(TIFF *tif, +tdata_t buf, uint32 row, +tsample_t sample)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Write data to a file at the specified row. The +sample parameter is used only if data are organized +in separate planes (PlanarConfiguration=2). The data +are assumed to be uncompressed and in the native bit- and +byte-order of the host machine. The data written to the file +is compressed according to the compression scheme of the +current TIFF directory (see further below). +If the current scanline is past the end of the current +subfile, the ImageLength field is automatically +increased to include the scanline (except for +PlanarConfiguration=2, where the ImageLength +cannot be changed once the first data are written). If the +ImageLength is increased, the StripOffsets and +StripByteCounts fields are similarly enlarged to +reflect data written past the previous end of image.

    +
    + +

    NOTES

    + + + + + +
    +

    The library writes encoded data using the native machine +byte order. Correctly implemented TIFF +readers are expected to do any necessary byte-swapping to +correctly process image data with BitsPerSample greater than +8. The library attempts to hide bit-ordering differences +between the image and the native machine by converting data +from the native machine order.

    + +

    In C++ the sample parameter defaults to 0.

    + +

    Once data are written to a file for the current +directory, the values of certain tags may not be altered; +see TIFFSetField(3TIFF) for more information.

    + +

    It is not possible to write scanlines to a file that uses +a tiled organization. The routine TIFFIsTiled can be +used to determine if the file is organized as tiles or +strips.

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    TIFFWriteScanline returns −1 if it +immediately detects an error and 1 for a successful +write.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    + +

    %s: File not open for writing . The file was +opened for reading, not writing.

    + +

    Can not write scanlines to a tiled image. An +attempt was made to write a scanline to a tiled image. The +image is assumed to be organized in tiles because the +TileWidth and TileLength tags have been set +with TIFFSetField(3TIFF).

    + +

    Compression algorithm does not support random +access. Data was written in a non-sequential order to a +file that uses a compression algorithm and that has +RowsPerStrip greater than one. That is, data in the +image is to be stored in a compressed form, and with +multiple rows packed into a strip. In this case, the library +does not support random access to the data. The data should +either be written as entire strips, sequentially by rows, or +the value of RowsPerStrip should be set to one.

    + +

    %s: Must set "ImageWidth" before writing +data. The image’s width has not be set before the +first write. See TIFFSetField(3TIFF) for information +on how to do this.

    + +

    %s: Must set "PlanarConfiguration" before +writing data. The organization of data has not be +defined before the first write. See +TIFFSetField(3TIFF) for information on how to do +this.

    + +

    Can not change "ImageLength" when using +separate planes. Separate image planes are being used +(PlanarConfiguration=2), but the number of rows has +not been specified before the first write. The library +supports the dynamic growth of an image only when data are +organized in a contiguous manner +(PlanarConfiguration=1).

    + +

    %d: Sample out of range, max %d. The sample +parameter was greater than the value of the SamplesPerPixel +tag.

    + +

    %s: No space for strip arrays . There was not +enough space for the arrays that hold strip offsets and byte +counts.

    +
    + +

    BUGS

    + + + + + +
    +

    Writing subsampled YCbCR data does not work correctly +because, for PlanarConfiguration=2 the size of a +scanline is not calculated on a per-sample basis, and for +PlanarConfiguration=1 the library does not pack the +block-interleaved samples.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), +TIFFWriteEncodedStrip(3TIFF), +TIFFWriteRawStrip(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteTile.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteTile.3tiff.html new file mode 100644 index 000000000..d450ee128 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFWriteTile.3tiff.html @@ -0,0 +1,115 @@ + + + + + + +TIFFWriteTile + + + +

    TIFFWriteTile

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +RETURN VALUES
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFWriteTile − encode and write a tile of data to +an open TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFWriteTile(TIFF *tif, +tdata_t buf, uint32 x, +uint32 y, uint32 z, +tsample_t sample)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Write the data for the tile containing the +specified coordinates. The data in buf are is +(potentially) compressed, and written to the indicated file, +normally being appended to the end of the file. The buffer +must be contain an entire tile of data. Applications should +call the routine TIFFTileSize to find out the size +(in bytes) of a tile buffer. The x and y +parameters are always used by TIFFWriteTile. The +z parameter is used if the image is deeper than 1 +slice (ImageDepth>1). The sample parameter +is used only if data are organized in separate planes +(PlanarConfiguration=2).

    +
    + +

    RETURN VALUES

    + + + + + +
    +

    TIFFWriteTile returns −1 if it detects an +error; otherwise the number of bytes in the tile is +returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    All error messages are directed to the +TIFFError(3TIFF) routine.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFCheckTile(3TIFF), +TIFFComputeTile(3TIFF), TIFFOpen(3TIFF), +TIFFReadTile(3TIFF), TIFFWriteScanline(3TIFF), +TIFFWriteEncodedTile(3TIFF), +TIFFWriteRawTile(3TIFF), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFbuffer.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFbuffer.3tiff.html new file mode 100644 index 000000000..d96621d07 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFbuffer.3tiff.html @@ -0,0 +1,116 @@ + + + + + + +TIFFBUFFER + + + +

    TIFFBUFFER

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFReadBufferSetup, TIFFWriteBufferSetup − I/O +buffering control routines

    +
    + +

    SYNOPSIS

    + + + + + +
    +
    #include <tiffio.h>
    +
    +int TIFFReadBufferSetup(TIFF *tif, tdata_t buffer, tsize_t size);
    +int TIFFWriteBufferSetup(TIFF *tif, tdata_t buffer, tsize_t size);
    +
    +
    + +

    DESCRIPTION

    + + + + + + +
    +

    The following routines are provided for client-control of +the I/O buffers used by the library. Applications need never +use these routines; they are provided only for +‘‘intelligent clients’’ that wish to +optimize memory usage and/or eliminate potential copy +operations that can occur when working with images that have +data stored without compression.

    + +

    TIFFReadBufferSetup sets up the data buffer used +to read raw (encoded) data from a file. If the specified +pointer is NULL (zero), then a buffer of the +appropriate size is allocated. Otherwise the caller must +guarantee that the buffer is large enough to hold any +individual strip of raw data. TIFFReadBufferSetup +returns a non-zero value if the setup was successful and +zero otherwise.

    + +

    TIFFWriteBufferSetup sets up the data buffer used +to write raw (encoded) data to a file. If the specified +size is −1 then the buffer size is selected to +hold a complete tile or strip, or at least 8 kilobytes, +whichever is greater. If the specified buffer is +NULL (zero), then a buffer of the appropriate +size is dynamically allocated. TIFFWriteBufferSetup +returns a non-zero value if the setup was successful and +zero otherwise.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    %s: No space for data buffer at scanline %ld. +TIFFReadBufferSetup was unable to dynamically +allocate space for a data buffer.

    + +

    %s: No space for output buffer. +TIFFWriteBufferSetup was unable to dynamically +allocate space for a data buffer.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFcodec.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFcodec.3tiff.html new file mode 100644 index 000000000..e18c0ed49 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFcodec.3tiff.html @@ -0,0 +1,116 @@ + + + + + + +CODEC + + + +

    CODEC

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFFindCODEC, TIFFRegisterCODEC, TIFFUnRegisterCODEC, +TIFFIsCODECConfigured − codec-related utility +routines

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    const TIFFCodec* TIFFFindCODEC(uint16 +scheme);
    +TIFFCodec* TIFFRegisterCODEC(uint16
    scheme, +const char *method, TIFFInitMethod +init);
    +void TIFFUnRegisterCODEC(TIFFCodec +*
    codec);
    +int TIFFIsCODECConfigured(uint16
    +scheme);

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    libtiff supports a variety of compression schemes +implemented by software codecs. Each codec adheres to +a modular interface that provides for the decoding and +encoding of image data; as well as some other methods for +initialization, setup, cleanup, and the control of default +strip and tile sizes. Codecs are identified by the +associated value of the TIFF +Compression tag; e.g. 5 for LZW +compression.

    + +

    The TIFFRegisterCODEC routine can be used to +augment or override the set of codecs available to an +application. If the specified scheme already has a +registered codec then it is overridden and any images +with data encoded with this compression scheme will be +decoded using the supplied coded.

    + +

    TIFFIsCODECConfigured returns 1 if the codec is +configured and working. Otherwise 0 will be returned.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    No space to register compression scheme %s. +TIFFRegisterCODEC was unable to allocate memory for +the data structures needed to register a codec.

    + +

    Cannot remove compression scheme %s; not +registered. TIFFUnRegisterCODEC did not locate +the specified codec in the table of registered compression +schemes.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFcolor.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFcolor.3tiff.html new file mode 100644 index 000000000..e598ae6ea --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFcolor.3tiff.html @@ -0,0 +1,975 @@ + + + + + + +COLOR + + + +

    COLOR

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFYCbCrToRGBInit, TIFFYCbCrtoRGB, TIFFCIELabToRGBInit, +TIFFCIELabToXYZ, TIFFXYZToRGB − color conversion +routines.

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB +*ycbcr, float *luma, float +*refBlackWhite");"
    +void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *
    ycbcr, +uint32 Y, int32 Cb, int32 +Cr, uint32 *R, uint32 +*G, uint32 *B );

    + +

    int TIFFCIELabToRGBInit(TIFFCIELabToRGB +*cielab, TIFFDisplay *display, +float *refWhite);
    +void TIFFCIELabToXYZ(TIFFCIELabToRGB *
    cielab, +uint32 L, int32 a, int32 +b, float *X, float *Y, +float *Z);
    +void TIFFXYZToRGB(TIFFCIELabToRGB *
    cielab, +float X, float Y, float +Z",uint32*"R, +uint32 *G, uint32 *B);

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFF supports several color spaces for images stored in +that format. There is usually a problem of application to +handle the data properly and convert between different +colorspaces for displaying and printing purposes. To +simplify this task libtiff implements several color +conversion routines itself. In particular, these routines +used in TIFFRGBAImage(3TIFF) interface.

    + +

    TIFFYCbCrToRGBInit() used to initialize +YCbCr to RGB conversion state. Allocating and +freeing of the ycbcr structure belongs to programmer. +TIFFYCbCrToRGB defined in tiffio.h as

    +
    + + + + + +
    +
    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;
    +} TIFFYCbCrToRGB;

    + + + + + +
    +

    luma is a float array of three values representing +proportions of the red, green and blue in luminance, Y (see +section 21 of the TIFF 6.0 specification, where the YCbCr +images discussed). TIFFTAG_YCBCRCOEFFICIENTS holds +that values in TIFF file. refBlackWhite is a float +array of 6 values which specifies a pair of headroom and +footroom image data values (codes) for each image component +(see section 20 of the TIFF 6.0 specification where the +colorinmetry fields discussed). +TIFFTAG_REFERENCEBLACKWHITE is responsible for +storing these values in TIFF file. Following code snippet +should helps to understand the the technique:

    +
    + + + + + +
    +
    float *luma, *refBlackWhite;
    +uint16 hs, vs;
    +
    +/* Initialize structures */
    +ycbcr = (TIFFYCbCrToRGB*)
    +
    +
    + + + + + + + + + + + + + + + +
    + +

    _TIFFmalloc(TIFFroundup(sizeof(TIFFYCbCrToRGB), +sizeof(long))

    +
    + +

    + 4*256*sizeof(TIFFRGBValue)

    +
    + +

    + 2*256*sizeof(int)

    +
    + +

    + 3*256*sizeof(int32));

    +
    + + + + + +
    +

    if (ycbcr == NULL) {
    +TIFFError("YCbCr->RGB",

    + + + + + + + +
    + + +

    "No space for YCbCr->RGB conversion +state");

    +
    +
    + + + + + +
    +

    exit(0);
    +}

    + +

    TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, +&luma);
    +TIFFGetFieldDefaulted(tif, TIFFTAG_REFERENCEBLACKWHITE, +&refBlackWhite);
    +if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) < +0)

    + + + + + +
    + +

    exit(0);

    +
    + + + + + +
    +

    /* Start conversion */
    +uint32 r, g, b;
    +uint32 Y;
    +int32 Cb, Cr;

    + +

    for each pixel in image

    + + + + + +
    + +

    TIFFYCbCrtoRGB(img->ycbcr, Y, Cb, Cr, &r, &g, +&b);

    +
    + + + + + +
    +

    /* Free state structure */
    +_TIFFfree(ycbcr);

    + + + + + +
    +

    TIFFCIELabToRGBInit() initializes the CIE +L*a*b* 1976 to RGB conversion state. +TIFFCIELabToRGB defined as

    +
    + + + + + +
    +
    #define CIELABTORGB_TABLE_RANGE 1500
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    typedef struct {

    +
    + + +

    /* CIE Lab 1976->RGB support */

    +
    +
    + + +

    int

    +
    + +

    range;

    +
    + + +

    /* Size of conversion table */

    +
    +
    + + +

    float

    +
    + +

    rstep, gstep, bstep;

    +
    +
    + + +

    float

    +
    + +

    X0, Y0, Z0;

    +
    + +

    /* Reference white point */

    +
    +
    + +

    TIFFDisplay display;

    +
    +
    + + +

    float

    +
    + +

    Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr +to r */

    +
    +
    + + +

    float

    +
    + +

    Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg +to g */

    +
    +
    + + +

    float

    +
    + +

    Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb +to b */

    +
    +
    + + + + + +
    +

    } TIFFCIELabToRGB;

    + + + + + +
    +

    display is a display device description, declared +as

    +
    + + + + + +
    +
    typedef struct {
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    float d_mat[3][3]; /* XYZ -> luminance matrix */

    +
    + +

    float d_YCR; /* Light o/p for reference white */

    +
    + +

    float d_YCG;

    +
    + +

    float d_YCB;

    +
    + +

    uint32 d_Vrwr; /* Pixel values for ref. white */

    +
    + +

    uint32 d_Vrwg;

    +
    + +

    uint32 d_Vrwb;

    +
    + +

    float d_Y0R; /* Residual light for black pixel */

    +
    + +

    float d_Y0G;

    +
    + +

    float d_Y0B;

    +
    + +

    float d_gammaR; /* Gamma values for the three guns +*/

    +
    + +

    float d_gammaG;

    +
    + +

    float d_gammaB;

    +
    + + + + + +
    +

    } TIFFDisplay;

    + + + + + +
    +

    For example, the one can use sRGB device, which has the +following parameters:

    +
    + + + + + +
    +
    TIFFDisplay display_sRGB = {
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    { /* XYZ -> luminance matrix */

    +
    +
    + + +

    { 3.2410F, -1.5374F, -0.4986F },

    +
    +
    + + +

    { -0.9692F, 1.8760F, 0.0416F },

    +
    +
    + + +

    { 0.0556F, -0.2040F, 1.0570F }

    +
    +
    + +

    },

    +
    + +
    + +

    100.0F, 100.0F, 100.0F, /* Light o/p for reference white +*/

    +
    +
    + +

    255, 255, 255, /* Pixel values for ref. white */

    +
    +
    + +

    1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel +*/

    +
    +
    + +

    2.4F, 2.4F, 2.4F, /* Gamma values for the three guns +*/

    +
    +
    + + + + + +
    +

    };

    + + + + + +
    +

    refWhite is a color temperature of the reference +white. The TIFFTAG_WHITEPOINT contains the +chromaticity of the white point of the image from where the +reference white can be calculated using following +formulae:

    +
    + + + + + +
    +

    refWhite_Y = 100.0
    +refWhite_X = whitePoint_x / whitePoint_y * refWhite_Y
    +refWhite_Z = (1.0 - whitePoint_x - whitePoint_y) / +whitePoint_y * refWhite_X

    + + + + + +
    +

    The conversion itself performed in two steps: at the +first one we will convert CIE L*a*b* 1976 to CIE +XYZ using TIFFCIELabToXYZ() routine, and at the +second step we will convert CIE XYZ to RGB +using TIFFXYZToRGB(). Look at the code sample +below:

    +
    + + + + + +
    +
    float   *whitePoint;
    +float   refWhite[3];
    +
    +/* Initialize structures */
    +img->cielab = (TIFFCIELabToRGB *)
    +
    +
    + + + + + + +
    + +

    _TIFFmalloc(sizeof(TIFFCIELabToRGB));

    +
    + + + + + +
    +

    if (!cielab) {

    + + + + + + + + + + + + + + + + + + + + +
    + +

    TIFFError("CIE L*a*b*->RGB",

    +
    +
    + + +

    "No space for CIE L*a*b*->RGB conversion +state.");

    +
    +
    + +

    exit(0);

    +
    +
    + + + + + +
    +

    }

    + +

    TIFFGetFieldDefaulted(tif, TIFFTAG_WHITEPOINT, +&whitePoint);
    +refWhite[1] = 100.0F;
    +refWhite[0] = whitePoint[0] / whitePoint[1] * +refWhite[1];
    +refWhite[2] = (1.0F - whitePoint[0] - +whitePoint[1])

    + + + + + +
    + +

    / whitePoint[1] * refWhite[1];

    +
    + + + + + +
    +

    if (TIFFCIELabToRGBInit(cielab, &display_sRGB, +refWhite) < 0) {

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    TIFFError("CIE L*a*b*->RGB",

    +
    +
    + + +

    "Failed to initialize CIE L*a*b*->RGB conversion +state.");

    +
    +
    + +

    _TIFFfree(cielab);

    +
    +
    + +

    exit(0);

    +
    +
    + + + + + +
    +

    }

    + +

    /* Now we can start to convert */
    +uint32 r, g, b;
    +uint32 L;
    +int32 a, b;
    +float X, Y, Z;

    + +

    for each pixel in image

    + + + + + + + + +
    + +

    TIFFCIELabToXYZ(cielab, L, a, b, &X, &Y, +&Z);

    +
    + +

    TIFFXYZToRGB(cielab, X, Y, Z, &r, &g, +&b);

    +
    + + + + + +
    +

    /* Don’t forget to free the state structure */
    +_TIFFfree(cielab);

    + +

    SEE ALSO

    + + + + + +
    +

    TIFFRGBAImage(3TIFF) libtiff(3TIFF),

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFmemory.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFmemory.3tiff.html new file mode 100644 index 000000000..283be9bdf --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFmemory.3tiff.html @@ -0,0 +1,110 @@ + + + + + + +MEMORY + + + +

    MEMORY

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    _TIFFmalloc, _TIFFrealloc, _TIFFfree, _TIFFmemset, +_TIFFmemcpy, _TIFFmemcmp, − memory management-related +functions for use with TIFF files

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tdata_t _TIFFmalloc(tsize_t size);
    +tdata_t _TIFFrealloc(tdata_t
    buffer, +tsize_t size);
    +void _TIFFfree(tdata_t
    buffer);
    +void _TIFFmemset(tdata_t
    s, int +c, tsize_t n);
    +void _TIFFmemcpy(tdata_t
    dest, const +tdata_t src, tsize_t n);
    +int _TIFFmemcmp(const tdata_t
    s1, const +tdata_t s2, tsize_t n);

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    These routines are provided for writing portable software +that uses libtiff; they hide any memory-management +related issues, such as dealing with segmented architectures +found on 16-bit machines.

    + +

    _TIFFmalloc and _TIFFrealloc are used to +dynamically allocate and reallocate memory used by +libtiff; such as memory passed into the I/O routines. +Memory allocated through these interfaces is released back +to the system using the _TIFFfree routine.

    + +

    Memory allocated through one of the above interfaces can +be set to a known value using _TIFFmemset, copied to +another memory location using _TIFFmemcpy, or +compared for equality using _TIFFmemcmp. These +routines conform to the equivalent ANSI C +routines: memset, memcpy, and memcmp, +respectively.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    None.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    malloc(3), memory(3), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFquery.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFquery.3tiff.html new file mode 100644 index 000000000..2b47fc3de --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFquery.3tiff.html @@ -0,0 +1,148 @@ + + + + + + +QUERY + + + +

    QUERY

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFCurrentRow, TIFFCurrentStrip, TIFFCurrentTile, +TIFFCurrentDirectory, TIFFLastDirectory, TIFFFileno, +TIFFFileName, TIFFGetMode, TIFFIsTiled, TIFFIsByteSwapped, +TIFFIsUpSampled, TIFFIsMSB2LSB, TIFFGetVersion − query +routines

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    uint32 TIFFCurrentRow(TIFF* tif)
    +tstrip_t TIFFCurrentStrip(TIFF*
    tif)
    +ttile_t TIFFCurrentTile(TIFF*
    tif)
    +tdir_t TIFFCurrentDirectory(TIFF*
    tif)
    +int TIFFLastDirectory(TIFF*
    tif)
    +int TIFFFileno(TIFF*
    tif)
    +char* TIFFFileName(TIFF*
    tif)
    +int TIFFGetMode(TIFF*
    tif)
    +int TIFFIsTiled(TIFF*
    tif)
    +int TIFFIsByteSwapped(TIFF*
    tif)
    +int TIFFIsUpSampled(TIFF*
    tif)
    +int TIFFIsMSB2LSB(TIFF*
    tif)
    +const char* TIFFGetVersion(void)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    The following routines return status information about an +open TIFF file.

    + +

    TIFFCurrentDirectory returns the index of the +current directory (directories are numbered starting at 0). +This number is suitable for use with the +TIFFSetDirectory routine.

    + +

    TIFFLastDirectory returns a non-zero value if the +current directory is the last directory in the file; +otherwise zero is returned.

    + +

    TIFFCurrentRow, TIFFCurrentStrip, and +TIFFCurrentTile, return the current row, strip, and +tile, respectively, that is being read or written. These +values are updated each time a read or write is done.

    + +

    TIFFFileno returns the underlying file descriptor +used to access the TIFF image in the +filesystem.

    + +

    TIFFFileName returns the pathname argument passed +to TIFFOpen or TIFFFdOpen.

    + +

    TIFFGetMode returns the mode with which the +underlying file was opened. On UNIX systems, +this is the value passed to the open(2) system +call.

    + +

    TIFFIsTiled returns a non-zero value if the image +data has a tiled organization. Zero is returned if the image +data is organized in strips.

    + +

    TIFFIsByteSwapped returns a non-zero value if the +image data was in a different byte-order than the host +machine. Zero is returned if the TIFF file and local host +byte-orders are the same. Note that TIFFReadTile(), +TIFFReadStrip() and TIFFReadScanline() functions already +normally perform byte swapping to local host order if +needed.

    + +

    TIFFIsUpSampled returns a non-zero value if image +data returned through the read interface routines is being +up-sampled. This can be useful to applications that want to +calculate I/O buffer sizes to reflect this usage (though the +usual strip and tile size routines already do this).

    + +

    TIFFIsMSB2LSB returns a non-zero value if the +image data is being returned with bit 0 as the most +significant bit.

    + +

    TIFFGetVersion returns an ASCII +string that has a version stamp for the TIFF +library software.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    None.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    libtiff(3TIFF), TIFFOpen(3TIFF), +TIFFFdOpen(3TIFF)

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFsize.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFsize.3tiff.html new file mode 100644 index 000000000..f2e2b7724 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFsize.3tiff.html @@ -0,0 +1,95 @@ + + + + + + +TIFFSIZE + + + +

    TIFFSIZE

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFScanlineSize, TIFFRasterScanlineSize, − return +the size of various items associated with an open +TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    tsize_t TIFFRasterScanlineSize(TIFF +*tif)
    +tsize_t TIFFScanlineSize(TIFF *
    tif)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFScanlineSize returns the size in bytes of a +row of data as it would be returned in a call to +TIFFReadScanline, or as it would be expected in a +call to TIFFWriteScanline.

    + +

    TIFFRasterScanlineSize returns the size in bytes +of a complete decoded and packed raster scanline. Note that +this value may be different from the value returned by +TIFFScanlineSize if data is stored as separate +planes.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    None.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFOpen(3TIFF), TIFFReadScanline(3TIFF), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFstrip.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFstrip.3tiff.html new file mode 100644 index 000000000..ae6b7903d --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFstrip.3tiff.html @@ -0,0 +1,129 @@ + + + + + + +TIFFSTRIP + + + +

    TIFFSTRIP

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFDefaultStripSize, TIFFStripSize, TIFFVStripSize, +TIFFRawStripSize, TIFFComputeStrip, TIFFNumberOfStrips +− strip-related utility routines

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    uint32 TIFFDefaultStripSize(TIFF *tif, +uint32 estimate)
    +tsize_t TIFFStripSize(TIFF *
    tif)
    +tsize_t TIFFVStripSize(TIFF *
    tif, uint32 +nrows)
    +tsize_t TIFFRawStripSize(TIFF *
    tif, +tstrip_t strip)
    +tstrip_t TIFFComputeStrip(TIFF *
    tif, +uint32 row, tsample_t +sample)
    +tstrip_t TIFFNumberOfStrips(TIFF *
    tif)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFDefaultStripSize returns the number of rows +for a reasonable-sized strip according to the current +settings of the ImageWidth, BitsPerSample, +SamplesPerPixel, tags and any compression-specific +requirements. If the estimate parameter, if non-zero, +then it is taken as an estimate of the desired strip size +and adjusted according to any compression-specific +requirements. The value returned by this function is +typically used to define the RowsPerStrip tag. In +lieu of any unusual requirements TIFFDefaultStripSize +tries to create strips that have approximately 8 kilobytes +of uncompressed data.

    + +

    TIFFStripSize returns the equivalent size for a +strip of data as it would be returned in a call to +TIFFReadEncodedStrip or as it would be expected in a +call to TIFFWriteEncodedStrip.

    + +

    TIFFVStripSize returns the number of bytes in a +strip with nrows rows of data.

    + +

    TIFFRawStripSize returns the number of bytes in a +raw strip (i.e. not decoded).

    + +

    TIFFComputeStrip returns the strip that contains +the specified coordinates. A valid strip is always returned; +out-of-range coordinate values are clamped to the bounds of +the image. The row parameter is always used in +calculating a strip. The sample parameter is used +only if data are organized in separate planes +(PlanarConfiguration=2).

    + +

    TIFFNumberOfStrips returns the number of strips in +the image.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    None.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFReadEncodedStrip(3TIFF), +TIFFReadRawStrip(3TIFF), +TIFFWriteEncodedStrip(3TIFF), +TIFFWriteRawStrip(3TIFF), libtiff(3TIFF),

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFswab.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFswab.3tiff.html new file mode 100644 index 000000000..3f7ebfef8 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFswab.3tiff.html @@ -0,0 +1,110 @@ + + + + + + +SWAB + + + +

    SWAB

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFGetBitRevTable, TIFFReverseBits, TIFFSwabShort, +TIFFSwabLong, TIFFSwabArrayOfShort, TIFFSwabArrayOfLong +− byte- and bit-swapping routines

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    const unsigned char* TIFFGetBitRevTable(int +reversed)
    +void TIFFReverseBits(u_char *
    data, unsigned +long nbytes)
    +void TIFFSwabShort(uint16 *
    data)
    +void TIFFSwabLong(uint32 *
    data)
    +void TIFFSwabArrayOfShort(uint16 *
    data, +unsigned long nshorts)
    +void TIFFSwabArrayOfLong(uint32 *
    data, +unsigned long nlongs)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    The following routines are used by the library to swap +16- and 32-bit data and to reverse the order of bits in +bytes.

    + +

    TIFFSwabShort and TIFFSwabLong swap the +bytes in a single 16-bit and 32-bit item, respectively. +TIFFSwabArrayOfShort and TIFFSwabArrayOfLong +swap the bytes in an array of 16-bit and 32-bit items, +respectively.

    + +

    TIFFReverseBits replaces each byte in data +with the equivalent bit-reversed value. This operation is +performed with a lookup table, which is returned using the +TIFFGetBitRevTable function. reversed +parameter specifies which table should be returned. Supply +1 if you want bit reversal table. Supply 0 to +get the table that do not reverse bit values. It is a lookup +table that can be used as an identity function; i.e. +TIFFNoBitRevTable[n] == n.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    None.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/TIFFtile.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFtile.3tiff.html new file mode 100644 index 000000000..b69cc9198 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/TIFFtile.3tiff.html @@ -0,0 +1,141 @@ + + + + + + +TIFFTILE + + + +

    TIFFTILE

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DIAGNOSTICS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    TIFFTileSize, TIFFTileRowSize, TIFFVTileSize, +TIFFDefaultTileSize, TIFFComputeTile, TIFFCheckTile, +TIFFNumberOfTiles − tile-related utility routines

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    void TIFFDefaultTileSize(TIFF *tif, +uint32 *tw, uint32 *th)
    +tsize_t TIFFTileSize(TIFF *
    tif)
    +tsize_t TIFFTileRowSize(TIFF *
    tif)
    +tsize_t TIFFVTileSize(TIFF *
    tif, uint32 +nrows)
    +ttile_t TIFFComputeTile(TIFF *
    tif, uint32 +x, uint32 y, uint32 z, +tsample_t sample)
    +int TIFFCheckTile(TIFF *
    tif, uint32 +x, uint32 y, uint32 z, +tsample_t sample)
    +ttile_t TIFFNumberOfTiles(TIFF *
    tif)

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    TIFFDefaultTileSize returns the pixel width and +height of a reasonable-sized tile; suitable for setting up +the TileWidth and TileLength tags. If the +tw and th values passed in are non-zero, then +they are adjusted to reflect any compression-specific +requirements. The returned width and height are constrained +to be a multiple of 16 pixels to conform with the +TIFF specification.

    + +

    TIFFTileSize returns the equivalent size for a +tile of data as it would be returned in a call to +TIFFReadTile or as it would be expected in a call to +TIFFWriteTile.

    + +

    TIFFVTileSize returns the number of bytes in a +row-aligned tile with nrows of data.

    + +

    TIFFTileRowSize returns the number of bytes of a +row of data in a tile.

    + +

    TIFFComputeTile returns the tile that contains the +specified coordinates. A valid tile is always returned; +out-of-range coordinate values are clamped to the bounds of +the image. The x and y parameters are always +used in calculating a tile. The z parameter is used +if the image is deeper than 1 slice +(ImageDepth>1). The sample parameter is +used only if data are organized in separate planes +(PlanarConfiguration=2).

    + +

    TIFFCheckTile returns a non-zero value if the +supplied coordinates are within the bounds of the image and +zero otherwise. The x parameter is checked against +the value of the ImageWidth tag. The y +parameter is checked against the value of the +ImageLength tag. The z parameter is checked +against the value of the ImageDepth tag (if defined). +The sample parameter is checked against the value of +the SamplesPerPixel parameter if the data are +organized in separate planes.

    + +

    TIFFNumberOfTiles returns the number of tiles in +the image.

    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    None.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    TIFFReadEncodedTile(3TIFF), +TIFFReadRawTile(3TIFF), TIFFReadTile(3TIFF), +TIFFWriteEncodedTile(3TIFF), +TIFFWriteRawTile(3TIFF), TIFFWriteTile(3TIFF), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/fax2ps.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/fax2ps.1.html new file mode 100644 index 000000000..7c5c1f3ea --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/fax2ps.1.html @@ -0,0 +1,252 @@ + + + + + + +FAX2PS + + + +

    FAX2PS

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +DIAGNOSTICS
    +NOTES
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    fax2ps − convert a TIFF facsimile to +compressed PostScript™

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    fax2ps [ options ] [ file ... ]

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    fax2ps reads one or more TIFF +facsimile image files and prints a compressed form of +PostScript on the standard output that is suitable for +printing.

    + +

    By default, each page is scaled to reflect the image +dimensions and resolutions stored in the file. The +−x and −y options can be used to +specify the horizontal and vertical image resolutions +(lines/inch), respectively. If the −S option is +specified, each page is scaled to fill an output page. The +default output page is 8.5 by 11 inches. Alternate page +dimensions can be specified in inches with the +−W and −H options.

    + +

    By default fax2ps generates PostScript for all +pages in the file. The −p option can be used to +select one or more pages from a multi-page document.

    + +

    fax2ps generates a compressed form of PostScript +that is optimized for sending pages of text to a PostScript +printer attached to a host through a low-speed link (such as +a serial line). Each output page is filled with white and +then only the black areas are drawn. The PostScript +specification of the black drawing operations is optimized +by using a special font that encodes the move-draw +operations required to fill the black regions on the page. +This compression scheme typically results in a substantially +reduced PostScript description, relative to the +straightforward imaging of the page with a PostScript +image operator. This algorithm can, however, be +ineffective for continuous-tone and white-on-black images. +For these images, it sometimes is more efficient to send the +raster bitmap image directly; see tiff2ps(1).

    +
    + +

    OPTIONS

    + + + + + + + +
    + +

    −p number

    +
    + +

    Print only the indicated page. Multiple pages may be +printed by specifying this option more than once.

    +
    +
    + + + + + +
    +

    −x resolution

    + + + + + +
    +

    Use resolution as the horizontal resolution, in +dots/inch, of the image data. By default this value is taken +from the file.

    +
    + + + + + +
    +

    −y resolution

    + + + + + +
    +

    Use resolution as the vertical resolution, in +lines/inch, of the image data. By default this value is +taken from the file.

    +
    + + + + + + + + + + + + + + + + + +
    + +

    −S

    +
    + +

    Scale each page of image data to fill the output page +dimensions. By default images are presented according to the +dimension information recorded in the TIFF +file.

    +
    +
    + +

    −W width

    +
    + +

    Use width as the width, in inches, of the output +page.

    +
    +
    + +

    −H height

    +
    + +

    Use height as the height, in inches, of the +output page.

    +
    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    Some messages about malformed TIFF images +come from the TIFF library.

    + +

    Various messages about badly formatted facsimile images +may be generated due to transmission errors in received +facsimile. fax2ps attempts to recover from such data +errors by resynchronizing decoding at the end of the current +scanline. This can result in long horizontal black lines in +the resultant PostScript image.

    +
    + +

    NOTES

    + + + + + +
    +

    If the destination printer supports PostScript Level II +then it is always faster to just send the encoded bitmap +generated by the tiff2ps(1) program.

    +
    + +

    BUGS

    + + + + + +
    +

    fax2ps should probably figure out when it is doing +a poor job of compressing the output and just generate +PostScript to image the bitmap raster instead.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    tiff2ps(1), libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/fax2tiff.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/fax2tiff.1.html new file mode 100644 index 000000000..a1c1b0b6f --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/fax2tiff.1.html @@ -0,0 +1,607 @@ + + + + + + +FAX2TIFF + + + +

    FAX2TIFF

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +DIAGNOSTICS
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    fax2tiff − create a TIFF Class F fax +file from raw fax data

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    fax2tiff [ options ] [ −o +output.tif ] input.raw

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Fax2tiff creates a TIFF file +containing CCITT Group 3 or Group 4 encoded +data from one or more files containing +‘‘raw’’ Group 3 or Group 4 encoded +data (typically obtained directly from a fax modem). By +default, each row of data in the resultant +TIFF file is 1-dimensionally encoded and +padded or truncated to 1728 pixels, as needed. The resultant +image is a set of low resolution (98 lines/inch) or medium +resolution (196 lines/inch) pages, each of which is a single +strip of data. The generated file conforms to the +TIFF Class F ( FAX ) +specification for storing facsimile data. This means, in +particular, that each page of the data does not +include the trailing return to control ( +RTC ) code; as required for transmission by +the CCITT Group 3 specifications. The old, +‘‘classic’’, format is created if +the −c option is used. (The Class F format can +also be requested with the −f option.)

    + +

    The default name of the output image is fax.tif; +this can be changed with the −o option. Each +input file is assumed to be a separate page of facsimile +data from the same document. The order in which input files +are specified on the command line is the order in which the +resultant pages appear in the output file.

    +
    + +

    OPTIONS

    + + + + + +
    +

    Options that affect the interpretation of input data +are:

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −3

    +
    + +

    Assume input data is CCITT Group 3 +encoded (default).

    +
    +
    + +

    −4

    +
    + +

    Assume input data is CCITT Group 4 +encoded.

    +
    +
    + +

    −U

    +
    + +

    Assume input data is uncompressed (Group 3 or Group +4).

    +
    +
    + +

    −1

    +
    + +

    Assume input data is encoded with the 1-dimensional +version of the CCITT Group 3 Huffman encoding +algorithm (default).

    +
    +
    + +

    −2

    +
    + +

    Assume input data is 2-dimensional version of the +CCITT Group 3 Huffman encoding algorithm.

    +
    +
    + +

    −P

    +
    + +

    Assume input data is not EOL-aligned (default). +This option has effect with Group 3 encoded input only.

    +
    +
    + +

    −A

    +
    + +

    Assume input data is EOL-aligned. This option has effect +with Group 3 encoded input only.

    +
    +
    + +

    −M

    +
    + +

    Treat input data as having bits filled from most +significant bit ( MSB ) to most least bit ( +LSB ).

    +
    +
    + +

    −L

    +
    + +

    Treat input data as having bits filled from least +significant bit ( LSB ) to most significant +bit ( MSB ) (default).

    +
    +
    + +

    −B

    +
    + +

    Assume input data was encoded with black as 0 and white +as 1.

    +
    +
    + +

    −W

    +
    + +

    Assume input data was encoded with black as 1 and white +as 0 (default).

    +
    +
    + +

    −R

    +
    + +

    Specify the vertical resolution, in lines/inch, of the +input images. By default input are assumed to have a +vertical resolution of 196 lines/inch. If images are low +resolution facsimile, a value of 98 lines/inch should be +specified.

    +
    +
    + +

    −X

    +
    + +

    Specify the width, in pixels, of the input images. By +default input are assumed to have a width of 1728 +pixels.

    +
    +
    + + + + + +
    +

    Options that affect the output file format are:

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −o

    +
    + +

    Specify the name of the output file.

    +
    +
    + +

    −7

    +
    + +

    Force output to be compressed with the +CCITT Group 3 Huffman encoding algorithm +(default).

    +
    +
    + +

    −8

    +
    + +

    Force output to be compressed with the +CCITT Group 4 Huffman encoding.

    +
    +
    + +

    −u

    +
    + +

    Force output to be uncompressed (Group 3 or Group +4).

    +
    +
    + +

    −5

    +
    + +

    Force output to be encoded with the 1-dimensional +version of the CCITT Group 3 Huffman encoding +algorithm.

    +
    +
    + +

    −6

    +
    + +

    Force output to be encoded with the 2-dimensional +version of the CCITT Group 3 Huffman encoding +algorithm (default).

    +
    +
    + +

    −a

    +
    + +

    Force the last bit of each End Of Line ( +EOL ) code to land on a byte boundary +(default). This ‘‘zero padding’’ +will be reflected in the contents of the +Group3Options tag of the resultant +TIFF file. This option has effect with Group +3 encoded output only.

    +
    +
    + +

    −p

    +
    + +

    Do not EOL-align output. This option has effect with +Group 3 encoded output only.

    +
    +
    + +

    −c

    +
    + +

    Generate "classic" Group 3 TIFF format.

    +
    +
    + +

    −f

    +
    + +

    Generate TIFF Class F (TIFF/F) format (default).

    +
    +
    + +

    −m

    +
    + +

    Force output data to have bits filled from most +significant bit ( MSB ) to most least bit ( +LSB ).

    +
    +
    + +

    −l

    +
    + +

    Force output data to have bits filled from least +significant bit ( LSB ) to most significant +bit ( MSB ) (default).

    +
    +
    + +

    −r

    +
    + +

    Specify the number of rows (scanlines) in each strip of +data written to the output file. By default (or when value +0 is specified), tiffcp attempts to set the +rows/strip that no more than 8 kilobytes of data appear in a +strip (with except of G3/G4 compression schemes). If you +specify special value −1 it will results in +infinite number of the rows per strip. The entire image will +be the one strip in that case. This is default in case of +G3/G4 output compression schemes.

    +
    +
    + +

    −s

    +
    + +

    Stretch the input image vertically by writing each input +row of data twice to the output file.

    +
    +
    + +

    −v

    +
    + +

    Force fax2tiff to print the number of rows of +data it retrieved from the input file.

    +
    +
    + +

    −z

    +
    + +

    Force output to be compressed with the LZW encoding.

    +
    +
    + +

    DIAGNOSTICS

    + + + + + +
    +

    The following warnings and errors come from the decoding +routines in the library.

    + +

    Warning, %s: Premature EOL at scanline %d (x +%d).\n. The input data had a row that was shorter than +the expected width. The row is padded with white.

    + +

    %s: Premature EOF at scanline %d (x %d).\n. The +decoder ran out of data in the middle of a scanline. The +resultant row is padded with white.

    + +

    %s: Bad code word at row %d, x %d\n. An invalid +Group 3 code was encountered while decoding the input +file. The row number and horizontal position is given. The +remainder of the input row is discarded, while the +corresponding output row is padded with white.

    + +

    %s: Bad 2D code word at scanline %d.\n. An invalid +Group 4 or 2D Group 3 code was encountered while +decoding the input file. The row number and horizontal +position is given. The remainder of the input row is +discarded, while the corresponding output row is padded with +white.

    +
    + +

    BUGS

    + + + + + +
    +

    Input data are assumed to have a a ‘‘top +left’’ orientation; it should be possible to +override this assumption from the command line.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    CCITT Recommendation T.4 +(Standardization of Group 3 Facsimile Apparatus for Document +Transmission).

    + +

    The Spirit of TIFF Class F, an appendix to the +TIFF 5.0 specification prepared by Cygnet Technologies.

    + +

    tiffinfo(1), tiffdither(1), +tiffgt(1), libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/index.html b/thirdparty/SDL2_image/external/libtiff/html/man/index.html new file mode 100644 index 000000000..4456f990a --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/index.html @@ -0,0 +1,64 @@ +Libtiff HTML manpage index diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/libtiff.3tiff.html b/thirdparty/SDL2_image/external/libtiff/html/man/libtiff.3tiff.html new file mode 100644 index 000000000..931ae94b4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/libtiff.3tiff.html @@ -0,0 +1,1150 @@ + + + + + + +INTRO + + + +

    INTRO

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +DATA TYPES
    +LIST OF ROUTINES
    +TAG USAGE
    +PSEUDO TAGS
    +DIAGNOSTICS
    +SEE ALSO
    +BUGS
    + +
    + +

    NAME

    + + + + + +
    +

    libtiff − introduction to libtiff, a +library for reading and writing TIFF +files

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    #include <tiffio.h>

    + +

    cc file.c -ltiff

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    libtiff is a library for reading and writing +data files encoded with the Tag Image File format, +Revision 6.0 (or revision 5.0 or revision 4.0). This file +format is suitable for archiving multi-color and +monochromatic image data.

    + +

    The library supports several compression algorithms, +as indicated by the Compression field, including: no +compression (1), CCITT 1D Huffman compression +(2), CCITT Group 3 Facsimile compression +(3), CCITT Group 4 Facsimile compression (4), +Lempel-Ziv & Welch compression (5), baseline JPEG +compression (7), word-aligned 1D Huffman compression +(32771), and PackBits compression (32773). In addition, +several nonstandard compression algorithms are supported: +the 4-bit compression algorithm used by the +ThunderScan program (32809) (decompression only), +NeXT’s 2-bit compression algorithm (32766) +(decompression only), an experimental LZ-style algorithm +known as Deflate (32946), and an experimental CIE LogLuv +compression scheme designed for images with high dynamic +range (32845 for LogL and 32845 for LogLuv). Directory +information may be in either little- or big-endian byte +order−byte swapping is automatically done by the +library. Data bit ordering may be either Most Significant +Bit ( MSB ) to Least Significant Bit ( LSB +) or LSB to MSB. Finally, the +library does not support files in which the +BitsPerSample, Compression, +MinSampleValue, or MaxSampleValue fields are +defined differently on a per-sample basis (in Rev. 6.0 the +Compression tag is not defined on a per-sample basis, +so this is immaterial).

    +
    + +

    DATA TYPES

    + + + + + +
    +

    The library makes extensive use of C typedefs to +promote portability. Two sets of typedefs are used, one for +communication with clients of the library and one for +internal data structures and parsing of the TIFF +format. The following typedefs are exposed to users +either through function definitions or through parameters +passed through the varargs interfaces.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    typedef unsigned short uint16;

    +
    + +

    16-bit unsigned integer

    +
    + +

    typedef unsigned <thing> +uint32;

    +
    + +

    32-bit unsigned integer

    +
    + +

    typedef unsigned int ttag_t;

    +
    + +

    directory tag

    +
    + +

    typedef uint16 tdir_t;

    +
    + +

    directory index

    +
    + +

    typedef uint16 tsample_t;

    +
    + +

    sample number

    +
    + +

    typedef uint32 tstrip_t;

    +
    + +

    strip number

    +
    + +

    typedef uint32 ttile_t;

    +
    + +

    tile number

    +
    + +

    typedef int32 tsize_t;

    +
    + +

    i/o size in bytes

    +
    + +

    typedef void* tdata_t;

    +
    + +

    image data ref

    +
    + +

    typedef void* thandle_t;

    +
    + +

    client data handle

    +
    + +

    typedef int32 toff_t;

    +
    + +

    file offset

    +
    + + + + + +
    +

    Note that tstrip_t, ttile_t, and +tsize_t are constrained to be no more than 32-bit +quantities by 32-bit fields they are stored in in the +TIFF image. Likewise tsample_t is limited by the +16-bit field used to store the SamplesPerPixel tag. +tdir_t constrains the maximum number of IFDs +that may appear in an image and may be an arbitrary +size (w/o penalty). ttag_t must be either int, +unsigned int, pointer, or double because the library uses a +varargs interface and ANSI C restricts the type +of the parameter before an ellipsis to be a promoted type. +toff_t is defined as int32 because TIFF file offsets +are (unsigned) 32-bit quantities. A signed value is used +because some interfaces return −1 on error. Finally, +note that user-specified data references are passed as +opaque handles and only cast at the lowest layers where +their type is presumed.

    +
    + +

    LIST OF ROUTINES

    + + + + + +
    +

    The following routines are part of the library. +Consult specific manual pages for details on their +operation; on most systems doing ‘‘man +function-name’’ will work.

    + + +

    Name Description

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    TIFFCheckpointDirectory

    +
    + +

    writes the current state of the directory

    +
    + +

    TIFFCheckTile

    +
    + +

    very x,y,z,sample is within image

    +
    + +

    TIFFCIELabToRGBInit

    +
    + +

    initialize CIE L*a*b* 1976 to RGB conversion +state

    +
    + +

    TIFFCIELabToXYZ

    +
    + +

    perform CIE L*a*b* 1976 to CIE XYZ +conversion

    +
    + +

    TIFFClientOpen

    +
    + +

    open a file for reading or writing

    +
    + +

    TIFFClose

    +
    + +

    close an open file

    +
    + +

    TIFFComputeStrip

    +
    + +

    return strip containing y,sample

    +
    + +

    TIFFComputeTile

    +
    + +

    return tile containing x,y,z,sample

    +
    + +

    TIFFCurrentDirectory

    +
    + +

    return index of current directory

    +
    + +

    TIFFCurrentRow

    +
    + +

    return index of current scanline

    +
    + +

    TIFFCurrentStrip

    +
    + +

    return index of current strip

    +
    + +

    TIFFCurrentTile

    +
    + +

    return index of current tile

    +
    + +

    TIFFDataWidth

    +
    + +

    return the size of TIFF data types

    +
    + +

    TIFFError

    +
    + +

    library error handler

    +
    + +

    TIFFFdOpen

    +
    + +

    open a file for reading or writing

    +
    + +

    TIFFFileName

    +
    + +

    return name of open file

    +
    + +

    TIFFFileno

    +
    + +

    return open file descriptor

    +
    + +

    TIFFFindCODEC

    +
    + +

    find standard codec for the specific +scheme

    +
    + +

    TIFFFlush

    +
    + +

    flush all pending writes

    +
    + +

    TIFFFlushData

    +
    + +

    flush pending data writes

    +
    + +

    TIFFGetBitRevTable

    +
    + +

    return bit reversal table

    +
    + +

    TIFFGetField

    +
    + +

    return tag value in current directory

    +
    + +

    TIFFGetFieldDefaulted

    +
    + +

    return tag value in current directory

    +
    + +

    TIFFGetMode

    +
    + +

    return open file mode

    +
    + +

    TIFFGetVersion

    +
    + +

    return library version string

    +
    + +

    TIFFIsCODECConfigured

    +
    + +

    check, whether we have working codec

    +
    + +

    TIFFIsMSB2LSB

    +
    + +

    return true if image data is being +returned

    +
    + +

    with bit 0 as the most significant bit

    +
    + +

    TIFFIsTiled

    +
    + +

    return true if image data is tiled

    +
    + +

    TIFFIsByteSwapped

    +
    + +

    return true if image data is byte-swapped

    +
    + +

    TIFFNumberOfStrips

    +
    + +

    return number of strips in an image

    +
    + +

    TIFFNumberOfTiles

    +
    + +

    return number of tiles in an image

    +
    + +

    TIFFOpen

    +
    + +

    open a file for reading or writing

    +
    + +

    TIFFPrintDirectory

    +
    + +

    print description of the current +directory

    +
    + +

    TIFFReadBufferSetup

    +
    + +

    specify i/o buffer for reading

    +
    + +

    TIFFReadDirectory

    +
    + +

    read the next directory

    +
    + +

    TIFFReadEncodedStrip

    +
    + +

    read and decode a strip of data

    +
    + +

    TIFFReadEncodedTile

    +
    + +

    read and decode a tile of data

    +
    + +

    TIFFReadRawStrip

    +
    + +

    read a raw strip of data

    +
    + +

    TIFFReadRawTile

    +
    + +

    read a raw tile of data

    +
    + +

    TIFFReadRGBAImage

    +
    + +

    read an image into a fixed format raster

    +
    + +

    TIFFReadScanline

    +
    + +

    read and decode a row of data

    +
    + +

    TIFFReadTile

    +
    + +

    read and decode a tile of data

    +
    + +

    TIFFRegisterCODEC

    +
    + +

    override standard codec for the specific +scheme

    +
    + +

    TIFFReverseBits

    +
    + +

    reverse bits in an array of bytes

    +
    + +

    TIFFRGBAImageBegin

    +
    + +

    setup decoder state for TIFFRGBAImageGet

    +
    + +

    TIFFRGBAImageEnd

    +
    + +

    release TIFFRGBAImage decoder state

    +
    + +

    TIFFRGBAImageGet

    +
    + +

    read and decode an image

    +
    + +

    TIFFRGBAImageOK

    +
    + +

    is image readable by TIFFRGBAImageGet

    +
    + +

    TIFFScanlineSize

    +
    + +

    return size of a scanline

    +
    + +

    TIFFSetDirectory

    +
    + +

    set the current directory

    +
    + +

    TIFFSetSubDirectory

    +
    + +

    set the current directory

    +
    + +

    TIFFSetErrorHandler

    +
    + +

    set error handler function

    +
    + +

    TIFFSetField

    +
    + +

    set a tag’s value in the current +directory

    +
    + +

    TIFFSetWarningHandler

    +
    + +

    set warning handler function

    +
    + +

    TIFFStripSize

    +
    + +

    returns size of a strip

    +
    + +

    TIFFRawStripSize

    +
    + +

    returns the number of bytes in a raw +strip

    +
    + +

    TIFFSwabShort

    +
    + +

    swap bytes of short

    +
    + +

    TIFFSwabLong

    +
    + +

    swap bytes of long

    +
    + +

    TIFFSwabArrayOfShort

    +
    + +

    swap bytes of an array of shorts

    +
    + +

    TIFFSwabArrayOfLong

    +
    + +

    swap bytes of an array of longs

    +
    + +

    TIFFTileRowSize

    +
    + +

    return size of a row in a tile

    +
    + +

    TIFFTileSize

    +
    + +

    return size of a tile

    +
    + +

    TIFFUnRegisterCODEC

    +
    + +

    unregisters the codec

    +
    + +

    TIFFVGetField

    +
    + +

    return tag value in current directory

    +
    + +

    TIFFVGetFieldDefaulted

    +
    + +

    return tag value in current directory

    +
    + +

    TIFFVSetField

    +
    + +

    set a tag’s value in the current +directory

    +
    + +

    TIFFVStripSize

    +
    + +

    returns the number of bytes in a strip

    +
    + +

    TIFFWarning

    +
    + +

    library warning handler

    +
    + +

    TIFFWriteDirectory

    +
    + +

    write the current directory

    +
    + +

    TIFFWriteEncodedStrip

    +
    + +

    compress and write a strip of data

    +
    + +

    TIFFWriteEncodedTile

    +
    + +

    compress and write a tile of data

    +
    + +

    TIFFWriteRawStrip

    +
    + +

    write a raw strip of data

    +
    + +

    TIFFWriteRawTile

    +
    + +

    write a raw tile of data

    +
    + +

    TIFFWriteScanline

    +
    + +

    write a scanline of data

    +
    + +

    TIFFWriteTile

    +
    + +

    compress and write a tile of data

    +
    + +

    TIFFXYZToRGB

    +
    + +

    perform CIE XYZ to RGB conversion

    +
    + +

    TIFFYCbCrToRGBInit

    +
    + +

    initialize YCbCr to RGB conversion state

    +
    + +

    TIFFYCbCrtoRGB

    +
    + +

    perform YCbCr to RGB conversion

    +
    + + + + + +
    +

    Auxiliary functions:

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    _TIFFfree

    +
    + +

    free memory buffer

    +
    + +

    _TIFFmalloc

    +
    + +

    dynamically allocate memory buffer

    +
    + +

    _TIFFmemcmp

    +
    + +

    compare contents of the memory buffers

    +
    + +

    _TIFFmemcpy

    +
    + +

    copy contents of the one buffer to +another

    +
    + +

    _TIFFmemset

    +
    + +

    fill memory buffer with a constant byte

    +
    + +

    _TIFFrealloc

    +
    + +

    dynamically reallocate memory buffer

    +
    + +

    TAG USAGE

    + + + + +
    +

    The table below lists the TIFF tags that +are recognized and handled by the library. If no use is +indicated in the table, then the library reads and writes +the tag, but does not use it internally. Note that some tags +are meaningful only when a particul \ No newline at end of file diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/pal2rgb.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/pal2rgb.1.html new file mode 100644 index 000000000..42ecdc17c --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/pal2rgb.1.html @@ -0,0 +1,189 @@ + + + + + + +PAL2RGB + + + +

    PAL2RGB

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    pal2rgb − convert a palette color +TIFF image to a full color image

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    pal2rgb [ options ] input.tif +output.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Pal2rgb converts a palette color +TIFF image to a full color image by applying +the colormap of the palette image to each sample to generate +a full color RGB image.

    +
    + +

    OPTIONS

    + + + + + +
    +

    Options that affect the interpretation of input data +are:

    +
    + + + + + + + + +
    + +

    −C

    +
    + +

    This option overrides the default behavior of +pal2rgb in determining whether or not colormap +entries contain 16-bit or 8-bit values. By default the +colormap is inspected and if no colormap entry greater than +255 is found, the colormap is assumed to have only 8-bit +values; otherwise 16-bit values (as required by the +TIFF specification) are assumed. The +−C option can be used to explicitly specify the +number of bits for colormap entries: −C 8 for +8-bit values, −C 16 for 16-bit values.

    +
    +
    + + + + + +
    +

    Options that affect the output file format are:

    +
    + + + + + + + + + + + + + + + + + + + + +
    + +

    −p

    +
    + +

    Explicitly select the planar configuration used in +organizing data samples in the output image: −p +contig for samples packed contiguously, and −p +separate for samples stored separately. By default +samples are packed.

    +
    +
    + +

    −c

    +
    + +

    Use the specific compression algorithm to encoded image +data in the output file: −c packbits for +Macintosh Packbits, −c lzw for Lempel-Ziv & +Welch, −c zip for Deflate, −c none +for no compression. If no compression-related option is +specified, the input file’s compression algorithm is +used.

    +
    +
    + +

    −r

    +
    + +

    Explicitly specify the number of rows in each strip of +the output file. If the −r option is not +specified, a number is selected such that each output strip +has approximately 8 kilobytes of data in it.

    +
    +
    + +

    BUGS

    + + + + + +
    +

    Only 8-bit images are handled.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    tiffinfo(1), tiffcp(1), +tiffmedian(1), libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/ppm2tiff.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/ppm2tiff.1.html new file mode 100644 index 000000000..79a89f2ee --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/ppm2tiff.1.html @@ -0,0 +1,141 @@ + + + + + + +PPM2TIFF + + + +

    PPM2TIFF

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    ppm2tiff − create a TIFF file from +PPM, PGM and PBM image +files

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    ppm2tiff [ options ] [ input.ppm ] +output.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    ppm2tiff converts a file in the PPM, +PGM and PBM image formats to +TIFF. By default, the TIFF +image is created with data samples packed +(PlanarConfiguration=1), compressed with the Packbits +algorithm (Compression=32773), and with each strip no +more than 8 kilobytes. These characteristics can be +overridden, or explicitly specified with the options +described below

    + +

    If the PPM file contains greyscale data, +then the PhotometricInterpretation tag is set to 1 +(min-is-black), otherwise it is set to 2 (RGB).

    + +

    If no PPM file is specified on the command +line, ppm2tiff will read from the standard input.

    +
    + +

    OPTIONS

    + + + + + + + + + + + + + + + + + + + + +
    + +

    −c

    +
    + +

    Specify a compression scheme to use when writing image +data: none for no compression, packbits for +PackBits compression (will be used by default), lzw +for Lempel-Ziv & Welch compression, jpeg for +baseline JPEG compression, zip for Deflate +compression, g3 for CCITT Group 3 (T.4) compression, +and g4 for CCITT Group 4 (T.6) compression.

    +
    +
    + +

    −r

    +
    + +

    Write data with a specified number of rows per strip; by +default the number of rows/strip is selected so that each +strip is approximately 8 kilobytes.

    +
    +
    + +

    −R

    +
    + +

    Mark the resultant image to have the specified X and Y +resolution (in dots/inch).

    +
    +
    + +

    SEE ALSO

    + + + + + +
    +

    tiffinfo(1), tiffcp(1), +tiffmedian(1), libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/raw2tiff.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/raw2tiff.1.html new file mode 100644 index 000000000..59d5506b2 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/raw2tiff.1.html @@ -0,0 +1,510 @@ + + + + + + +RAW2TIFF + + + +

    RAW2TIFF

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +GUESSING THE IMAGE GEOMETRY
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    raw2tiff − create a TIFF file from a +raw data

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    raw2tiff [ options ] input.raw +output.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    raw2tiff converts a raw byte sequence into +TIFF. By default, the TIFF +image is created with data samples packed +(PlanarConfiguration=1), compressed with the PackBits +algorithm (Compression=32773), and with each strip no +more than 8 kilobytes. These characteristics can overridden, +or explicitly specified with the options described +below.

    +
    + +

    OPTIONS

    + + + + + +
    +

    −H number

    + + + + + +
    +

    size of input image file header in bytes (0 by default). +This amount of data just will be skipped from the start of +file while reading.

    +
    + + + + + +
    +

    −w number

    + + + + + +
    +

    width of input image in pixels (can be guessed, see +GUESSING THE IMAGE GEOMETRY +below).

    +
    + + + + + +
    +

    −l number

    + + + + + +
    +

    length of input image in lines (can be guessed, see +GUESSING THE IMAGE GEOMETRY +below).

    +
    + + + + + +
    +

    −b number

    + + + + + +
    +

    number of bands in input image (1 by default).

    +
    + + + + + +
    +

    −d data_type

    + + + + + +
    +

    type of samples in input image, where data_type +may be:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    byte

    +
    + +

    8-bit unsigned integer (default),

    +
    + +

    short

    +
    + +

    16-bit unsigned integer,

    +
    + +

    long

    +
    + +

    32-bit unsigned integer,

    +
    + +

    sbyte

    +
    + +

    8-bit signed integer,

    +
    + +

    sshort

    +
    + +

    16-bit signed integer,

    +
    + +

    slong

    +
    + +

    32-bit signed integer,

    +
    + +

    float

    +
    + +

    32-bit IEEE floating point,

    +
    + +

    double

    +
    + +

    64-bit IEEE floating point.

    +
    + + + + + +
    +

    −i config

    + + + + + +
    +

    type of samples interleaving in input image, where +config may be:

    + + + + + + + + + + +
    + +

    pixel

    +
    + +

    pixel interleaved data (default),

    +
    + +

    band

    +
    + +

    band interleaved data.

    +
    + + + + + +
    +

    −p photo

    + + + + + +
    +

    photometric interpretation (color space) of the input +image, where photo may be:

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    miniswhite

    +
    + +

    white color represented with 0 value,

    +
    + +

    minisblack

    +
    + +

    black color represented with 0 value (default),

    +
    + +

    rgb

    +
    + +

    image has RGB color model,

    +
    + +

    cmyk

    +
    + +

    image has CMYK (separated) color model,

    +
    + +

    ycbcr

    +
    + +

    image has YCbCr color model,

    +
    + +

    cielab

    +
    + +

    image has CIE L*a*b color model,

    +
    + +

    icclab

    +
    + +

    image has ICC L*a*b color model,

    +
    + +

    itulab

    +
    + +

    image has ITU L*a*b color model.

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −s

    +
    + +

    swap bytes fetched from the input file.

    +
    +
    + +

    −L

    +
    + +

    input data has LSB2MSB bit order (default).

    +
    +
    + +

    −M

    +
    + +

    input data has MSB2LSB bit order.

    +
    +
    + +

    −c

    +
    + +

    Specify a compression scheme to use when writing image +data: −c none for no compression, −c +packbits for the PackBits compression algorithm (the +default), −c jpeg for the baseline JPEG +compression algorithm, −c zip for the Deflate +compression algorithm, and −c lzw for +Lempel-Ziv & Welch.

    +
    +
    + + + + + +
    +

    −r number

    + + + + + +
    +

    Write data with a specified number of rows per strip; by +default the number of rows/strip is selected so that each +strip is approximately 8 kilobytes.

    +
    + +

    GUESSING THE IMAGE GEOMETRY

    + + + + + +
    +

    raw2tiff can guess image width and height in case +one or both of these parameters are not specified. If you +omit one of those parameters, the complementary one will be +calculated based on the file size (taking into account +header size, number of bands and data type). If you omit +both parameters, the statistical approach will be used. +Utility will compute correlation coefficient between two +lines at the image center using several appropriate line +sizes and the highest absolute value of the coefficient will +indicate the right line size. That is why you should be +cautious with the very large images, because guessing +process may take a while (depending on your system +performance). Of course, the utility can’t guess the +header size, number of bands and data type, so it should be +specified manually. If you don’t know anything about +your image, just try with the several combinations of those +options.

    + +

    There is no magic, it is just a mathematical statistics, +so it can be wrong in some cases. But for most ordinary +images guessing method will work fine.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    pal2rgb(1), tiffcp(1), +tiffmedian(1), libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/rgb2ycbcr.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/rgb2ycbcr.1.html new file mode 100644 index 000000000..6e481f79d --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/rgb2ycbcr.1.html @@ -0,0 +1,155 @@ + + + + + + +RGB2YCBCR + + + +

    RGB2YCBCR

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    rgb2ycbcr − convert non-YCbCr TIFF +images to a YCbCr TIFF image

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    rgb2ycbcr [ options ] src1.tif src2.tif +... dst.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    rgb2ycbcr converts RGB color, +greyscale, or bi-level TIFF images to YCbCr +images by transforming and sampling pixel data. If multiple +files are specified on the command line each source file is +converted to a separate directory in the destination +file.

    + +

    By default, chrominance samples are created by sampling 2 +by 2 blocks of luminance values; this can be changed with +the −h and −v options. Output data +are compressed with the PackBits compression +scheme, by default; an alternate scheme can be selected with +the −c option. By default, output data are +compressed in strips with the number of rows in each strip +selected so that the size of a strip is never more than 8 +kilobytes; the −r option can be used to +explicitly set the number of rows per strip.

    +
    + +

    OPTIONS

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −c

    +
    + +

    Specify a compression scheme to use when writing image +data: −c none for no compression, −c +packbits for the PackBits compression algorithm (the +default), −c jpeg for the JPEG compression +algorithm, −c zip for the deflate compression +algorithm, and −c lzw for Lempel-Ziv & +Welch.

    +
    +
    + +

    −h

    +
    + +

    Set the horizontal sampling dimension to one of: 1, 2 +(default), or 4.

    +
    +
    + +

    −r

    +
    + +

    Write data with a specified number of rows per strip; by +default the number of rows/strip is selected so that each +strip is approximately 8 kilobytes.

    +
    +
    + +

    −v

    +
    + +

    Set the vertical sampling dimension to one of: 1, 2 +(default), or 4.

    +
    +
    + +

    SEE ALSO

    + + + + + +
    +

    tiffinfo(1), tiffcp(1), +libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/thumbnail.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/thumbnail.1.html new file mode 100644 index 000000000..8b114137f --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/thumbnail.1.html @@ -0,0 +1,148 @@ + + + + + + +THUMBNAIL + + + +

    THUMBNAIL

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    thumbnail − create a TIFF file with +thumbnail images

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    thumbnail [ options ] input.tif +output.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    thumbnail is a program written to show how one +might use the SubIFD tag (#330) to store thumbnail images. +thumbnail copies a TIFF Class F +facsimile file to the output file and for each image an +8-bit greyscale thumbnail sketch. The output file +contains the thumbnail image with the associated +full-resolution page linked below with the SubIFD tag.

    + +

    By default, thumbnail images are 216 pixels wide by 274 +pixels high. Pixels are calculated by sampling and filtering +the input image with each pixel value passed through a +contrast curve.

    +
    + +

    OPTIONS

    + + + + + + + + + + + + + + + + + + + + +
    + +

    −w

    +
    + +

    Specify the width of thumbnail images in pixels.

    +
    +
    + +

    −h

    +
    + +

    Specify the height of thumbnail images in pixels.

    +
    +
    + +

    −c

    +
    + +

    Specify a contrast curve to apply in generating the +thumbnail images. By default pixels values are passed +through a linear contrast curve that simply maps the pixel +value ranges. Alternative curves are: exp50 for a 50% +exponential curve, exp60 for a 60% exponential curve, +exp70 for a 70% exponential curve, exp80 for a +80% exponential curve, exp90 for a 90% exponential +curve, exp for a pure exponential curve, +linear for a linear curve.

    +
    +
    + +

    BUGS

    + + + + + +
    +

    There are no options to control the format of the saved +thumbnail images.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    tiffdump(1), tiffgt(1), tiffinfo(1), +libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiff2bw.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiff2bw.1.html new file mode 100644 index 000000000..413808ecf --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiff2bw.1.html @@ -0,0 +1,161 @@ + + + + + + +TIFF2BW + + + +

    TIFF2BW

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiff2bw − convert a color TIFF image +to greyscale

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiff2bw [ options ] input.tif +output.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Tiff2bw converts an RGB or Palette +color TIFF image to a greyscale image by +combining percentages of the red, green, and blue channels. +By default, output samples are created by taking 28% of the +red channel, 59% of the green channel, and 11% of the blue +channel. To alter these percentages, the −R, +−G, and −B options may be +used.

    +
    + +

    OPTIONS

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −c

    +
    + +

    Specify a compression scheme to use when writing image +data: −c none for no compression, −c +packbits for the PackBits compression algorithm, +−c zip for the Deflate compression algorithm, +−c g3 for the CCITT Group 3 compression +algorithm, −c g4 for the CCITT Group 4 +compression algorithm, and −c lzw for +Lempel-Ziv & Welch (the default).

    +
    +
    + +

    −r

    +
    + +

    Write data with a specified number of rows per strip; by +default the number of rows/strip is selected so that each +strip is approximately 8 kilobytes.

    +
    +
    + +

    −R

    +
    + +

    Specify the percentage of the red channel to use +(default 28).

    +
    +
    + +

    −G

    +
    + +

    Specify the percentage of the green channel to use +(default 59).

    +
    +
    + +

    −B

    +
    + +

    Specify the percentage of the blue channel to use +(default 11).

    +
    +
    + +

    SEE ALSO

    + + + + + +
    +

    pal2rgb(1), tiffinfo(1), tiffcp(1), +tiffmedian(1), libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiff2pdf.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiff2pdf.1.html new file mode 100644 index 000000000..1feaf6b73 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiff2pdf.1.html @@ -0,0 +1,609 @@ + + + + + + +TIFF2PDF + + + +

    TIFF2PDF

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +EXAMPLES
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiff2pdf − convert a TIFF image to a PDF +document

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiff2pdf [ options ] input.tiff

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    tiff2pdf opens a TIFF image and writes a PDF +document to standard output.

    + +

    The program converts one TIFF file to one PDF file, +including multiple page TIFF files, tiled TIFF files, black +and white. grayscale, and color TIFF files that contain data +of TIFF photometric interpretations of bilevel, grayscale, +RGB, YCbCr, CMYK separation, and ICC L*a*b* as supported by +libtiff and PDF.

    + +

    If you have multiple TIFF files to convert into one PDF +file then use tiffcp or other program to concatenate +the files into a multiple page TIFF file. If the input TIFF +file is of huge dimensions (greater than 10000 pixels height +or width) convert the input image to a tiled TIFF if it is +not already.

    + +

    The standard output is standard output. Set the output +file name with the −o output.pdf +option.

    + +

    All black and white files are compressed into a single +strip CCITT G4 Fax compressed PDF, unless tiled, where tiled +black and white images are compressed into tiled CCITT G4 +Fax compressed PDF, libtiff CCITT support is +assumed.

    + +

    Color and grayscale data can be compressed using either +JPEG compression, ITU-T T.81, or Zip/Deflate LZ77 +compression. Set the compression type using the +−j or −z options. JPEG compression +support requires that libtiff be configured with JPEG +support, and Zip/Deflate compression support requires that +libtiff be configured with Zip support, in +tiffconf.h. Use only one or the other of −j and +−z.

    + +

    If the input TIFF contains single strip CCITT G4 Fax +compressed information, then that is written to the PDF file +without transcoding, unless the options of no compression +and no passthrough are set, −d and +−n.

    + +

    If the input TIFF contains JPEG or single strip +Zip/Deflate compressed information, and they are configured, +then that is written to the PDF file without transcoding, +unless the options of no compression and no passthrough are +set.

    + +

    The default page size upon which the TIFF image is placed +is determined by the resolution and extent of the image +data. Default values for the TIFF image resolution can be +set using the −x and −y options. +The page size can be set using the −p option +for paper size, or −w and −l for +paper width and length, then each page of the TIFF image is +centered on its page. The distance unit for default +resolution and page width and length can be set by the +−u option, the default unit is inch.

    + +

    Various items of the output document information can be +set with the −e, −c, +−a, −t, −s, and +−k options. Setting the argument of the option +to "" for these tags causes the relevant document +information field to be not written. Some of the document +information values otherwise get their information from the +input TIFF image, the software, author, document name, and +image description.

    + +

    The Portable Document Format (PDF) specification is +copyrighted by Adobe Systems, Incorporated.

    +
    + +

    OPTIONS

    + + + + + +
    +

    −o output-file

    + + + + + +
    +

    Set the output to go to file. output-file

    +
    + + + + + + + + + + + + +
    + +

    −j

    +
    + +

    Compress with JPEG (requires libjpeg configured +with libtiff).

    +
    + +

    −z

    +
    + +

    Compress with Zip/Deflate (requires zlib +configured with libtiff).

    +
    + + + + + +
    +

    −q quality

    + + + + + +
    +

    Set the compression quality, 1-100 for JPEG.

    +
    + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −n

    +
    + +

    Do not allow data to be converted without uncompressing, +no compressed data passthrough.

    +
    + +

    −b

    +
    + +

    Set PDF ‘‘Interpolate’’ user +preference.

    +
    + +

    −d

    +
    + +

    Do not compress (decompress).

    +
    + +

    −i

    +
    + +

    Invert colors.

    +
    + + + + + +
    +

    −p paper-size

    + + + + + +
    +

    Set paper size, e.g., letter, legal, +A4.

    +
    + + + + + +
    +

    −u [i|m]

    + + + + + +
    +

    Set distance unit, i for inch, m for +centimeter.

    +
    + + + + + +
    +

    −w width

    + + + + + +
    +

    Set width in units.

    +
    + + + + + +
    +

    −l length

    + + + + + +
    +

    Set length in units.

    +
    + + + + + +
    +

    −x xres

    + + + + + +
    +

    Set x/width resolution default.

    +
    + + + + + +
    +

    −y yres

    + + + + + +
    +

    Set y/length resolution default.

    +
    + + + + + +
    +

    −r [d|o]

    + + + + + +
    +

    Set d for resolution default for images without +resolution, o for resolution override for all +images.

    +
    + + + + + + + + +
    + +

    −f

    +
    + +

    Set PDF ‘‘Fit Window’’ user +preference.

    +
    +
    + + + + + +
    +

    −e YYYYMMDDHHMMSS

    + + + + + +
    +

    Set document information date, overrides image or current +date/time default, YYYYMMDDHHMMSS.

    +
    + + + + + +
    +

    −c creator

    + + + + + +
    +

    Set document information creator, overrides image +software default.

    +
    + + + + + +
    +

    −a author

    + + + + + +
    +

    Set document information author, overrides image artist +default.

    +
    + + + + + +
    +

    −t title

    + + + + + +
    +

    Set document information title, overrides image document +name default.

    +
    + + + + + +
    +

    −s subject

    + + + + + +
    +

    Set document information subject, overrides image image +description default.

    +
    + + + + + +
    +

    −k keywords

    + + + + + +
    +

    Set document information keywords.

    +
    + + + + + + + + +
    + +

    −h

    +
    + +

    List usage reminder to stderr and exit.

    +
    +
    + +

    EXAMPLES

    + + + + + +
    +

    The following example would generate the file output.pdf +from input.tiff.

    + + + + + +
    +
    tiff2pdf −o output.pdf input.tiff
    +
    +
    + + + + + + +
    +

    The following example would generate PDF output from +input.tiff and write it to standard output.

    + + + + + +
    +
    tiff2pdf input.tiff
    +
    +
    + + + + + + +
    +

    The following example would generate the file output.pdf +from input.tiff, putting the image pages on a letter sized +page, compressing the output with JPEG, with JPEG quality +75, setting the title to +‘‘Document’’, and setting the +‘‘Fit Window’’ option.

    + + + + + +
    +
    tiff2pdf −p letter −j −q 75 −t "Document" −f −o output.pdf input.tiff
    +
    +
    + +

    BUGS

    + + + + + + +
    +

    Please report bugs via the web interface at

    +
    + + + + + +
    + +

    http://bugzilla.remotesensing.org/enter_bug.cgi?product=libtiff

    +
    + +

    SEE ALSO

    + + + + + +
    +

    libtiff(3), tiffcp(1), +tiff2ps(1)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiff2ps.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiff2ps.1.html new file mode 100644 index 000000000..7b309b0f1 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiff2ps.1.html @@ -0,0 +1,639 @@ + + + + + + +TIFF2PS + + + +

    TIFF2PS

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +EXAMPLES
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiff2ps − convert a TIFF image to +PostScript™

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiff2ps [ options ] input.tif +...

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    tiff2ps reads TIFF images and +writes PostScript or Encapsulated PostScript (EPS) on the +standard output. By default, tiff2ps writes +Encapsulated PostScript for the first image in the specified +TIFF image file.

    + +

    By default, tiff2ps will generate PostScript that +fills a printed area specified by the TIFF +tags in the input file. If the file does not contain +XResolution or YResolution tags, then the +printed area is set according to the image dimensions. The +−w and −h options (see below) can +be used to set the dimensions of the printed area in inches; +overriding any relevant TIFF tags.

    + +

    The PostScript generated for RGB, palette, +and CMYK images uses the colorimage +operator. The PostScript generated for greyscale and bilevel +images uses the image operator. When the +colorimage operator is used, PostScript code to +emulate this operator on older PostScript printers is also +generated. Note that this emulation code can be very +slow.

    + +

    Color images with associated alpha data are composited +over a white background.

    +
    + +

    OPTIONS

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −1

    +
    + +

    Generate PostScript Level 1 (the default).

    +
    +
    + +

    −2

    +
    + +

    Generate PostScript Level 2.

    +
    +
    + +

    −3

    +
    + +

    Generate PostScript Level 3. It basically allows one to +use the /flateDecode filter for ZIP compressed TIFF +images.

    +
    +
    + +

    −8

    +
    + +

    Disable use of ASCII85 encoding with PostScript Level 2/3.

    +
    +
    + +

    −a

    +
    + +

    Generate output for all IFDs (pages) in the input +file.

    +
    +
    + +

    −b

    +
    + +

    Specify the bottom margin for the output (in inches). +This does not affect the height of the printed image.

    +
    +
    + +

    −c

    +
    + +

    Center the image in the output. This option only shows +an effect if both the −w and the +−h option are given.

    +
    +
    + +

    −C

    +
    + +

    Specify the document creator name.

    +
    +
    + +

    −d

    +
    + +

    Set the initial TIFF directory to the +specified directory number. (NB: Directories are numbered +starting at zero.) This option is useful for selecting +individual pages in a multi-page (e.g. facsimile) file.

    +
    +
    + +

    −D

    +
    + +

    Enable duplex printing (two pages per sheet of paper).

    +
    +
    + +

    −e

    +
    + +

    Force the generation of Encapsulated PostScript (implies +−z).

    +
    +
    + +

    −h

    +
    + +

    Specify the vertical size of the printed area (in +inches).

    +
    +
    + +

    −H

    +
    + +

    Specify the maximum height of image (in inches). Images +with larger sizes will be split in several pages. Option +−L may be used for specifying size of split +images overlapping.

    +
    +
    + +

    −i

    +
    + +

    Enable/disable pixel interpolation. This option requires +a single numeric value: zero to disable pixel interpolation +and non-zero to enable. The default is enabled.

    +
    +
    + +

    −L

    +
    + +

    Specify the size of overlapping for split images (in +inches). Used in conjunction with −H and −W +options.

    +
    +
    + +

    −l

    +
    + +

    Specify the left margin for the output (in inches). This +does not affect the width of the printed image.

    +
    +
    + +

    −m

    +
    + +

    Where possible render using the imagemask +PostScript operator instead of the image operator. +When this option is specified tiff2ps will use +imagemask for rendering 1 bit deep images. If this +option is not specified or if the image depth is greater +than 1 then the image operator is used.

    +
    +
    + +

    −o

    +
    + +

    Set the initial TIFF directory to the +IFD at the specified file offset. This option +is useful for selecting thumbnail images and the like which +are hidden using the SubIFD tag.

    +
    +
    + +

    −O

    +
    + +

    Write PostScript to specified file instead of standard output.

    +
    +
    + +

    −p

    +
    + +

    Force the generation of (non-Encapsulated) +PostScript.

    +
    +
    + +

    −P

    +
    + +

    Set optional PageOrientation DSC comment to Landscape or Portrait.

    +
    +
    + +

    −r

    +
    + +

    Rotate image by 180 degrees.

    +
    +
    + +

    −s

    +
    + +

    Generate output for a single IFD (page) in the input +file.

    +
    +
    + +

    −t

    +
    + +

    Specify the document title string.

    +
    +
    + +

    −T

    +
    + +

    Print pages for top edge binding.

    +
    +
    + +

    −w

    +
    + +

    Specify the horizontal size of the printed area (in +inches).

    +
    +
    + +

    −W

    +
    + +

    Specify the maximum width of image (in inches). Images +with larger sizes will be split in several pages. Option +−L may be used for specifying size of split +images overlapping.

    +
    +
    + +

    −x

    +
    + +

    Override resolution units specified in the TIFF as +centimeters.

    +
    +
    + +

    −y

    +
    + +

    Override resolution units specified in the TIFF as +inches.

    +
    +
    + +

    −z

    +
    + +

    When generating PostScript Level 2, data is scaled so +that it does not image into the deadzone on a page +(the outer margin that the printing device is unable to +mark). This option suppresses this behavior. When PostScript +Level 1 is generated, data is imaged to the entire printed +page and this option has no affect.

    +
    +
    + +

    EXAMPLES

    + + + + + +
    +

    The following generates PostScript Level 2 for all pages +of a facsimile:

    + + + + + +
    +
    tiff2ps −a2 fax.tif | lpr
    +
    +
    + + + + + + +
    +

    Note also that if you have version 2.6.1 or newer of +Ghostscript then you can efficiently preview facsimile +generated with the above command.

    + +

    To generate Encapsulated PostScript for a the image at +directory 2 of an image use:

    + + + + + +
    +
    tiff2ps −d 1 foo.tif
    +
    +
    + + + + + + +
    +

    (Notice that directories are numbered starting at +zero.)

    + +

    If you have a long image, it may be split in several +pages:

    + + + + + +
    +
    tiff2ps −h11 −w8.5 −H14 −L.5 foo.tif > foo.ps
    +
    +
    + + + + + + +
    +

    The page size is set to 8.5x11 by −w and +−h options. We will accept a small amount of +vertical compression, so −H set to 14. Any +pages between 11 and 14 inches will be fit onto one page. +Pages longer than 14 inches are cut off at 11 and continued +on the next page. The −L.5 option says to +repeat a half inch on the next page (to improve +readability).

    +
    + +

    BUGS

    + + + + + +
    +

    Because PostScript does not support the notion of a +colormap, 8-bit palette images produce 24-bit PostScript +images. This conversion results in output that is six times +bigger than the original image and which takes a long time +to send to a printer over a serial line. Matters are even +worse for 4-, 2-, and 1-bit palette images.

    + +

    Does not handle tiled images when generating PostScript +Level I output.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    pal2rgb(1), tiffinfo(1), tiffcp(1), +tiffgt(1), tiffmedian(1), tiff2bw(1), +tiffsv(1), libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiff2rgba.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiff2rgba.1.html new file mode 100644 index 000000000..203f7deff --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiff2rgba.1.html @@ -0,0 +1,162 @@ + + + + + + +TIFF2RGBA + + + +

    TIFF2RGBA

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiff2rgba − convert a TIFF image to +RGBA color space

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiff2rgba [ options ] input.tif +output.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Tiff2rgba converts a wide variety of TIFF images +into an RGBA TIFF image. This includes the ability to +translate different color spaces and photometric +interpretation into RGBA, support for alpha blending, and +translation of many different bit depths into a 32bit RGBA +image.

    + +

    Internally this program is implemented using the +TIFFReadRGBAImage() function, and it suffers any +limitations of that image. This includes limited support for +> 8 BitsPerSample images, and flaws with some esoteric +combinations of BitsPerSample, photometric interpretation, +block organization and planar configuration.

    + +

    The generated images are stripped images with four +samples per pixel (red, green, blue and alpha) or if the +−n flag is used, three samples per pixel (red, +green, and blue). The resulting images are always planar +configuration contiguous. For this reason, this program is a +useful utility for transform exotic TIFF files into a form +ingestible by almost any TIFF supporting software.

    +
    + +

    OPTIONS

    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −c

    +
    + +

    Specify a compression scheme to use when writing image +data: −c none for no compression (the default), +−c packbits for the PackBits compression +algorithm, −c zip for the Deflate compression +algorithm, −c jpeg for the JPEG compression +algorithm, and −c lzw for Lempel-Ziv & +Welch.

    +
    +
    + +

    −r

    +
    + +

    Write data with a specified number of rows per strip; by +default the number of rows/strip is selected so that each +strip is approximately 8 kilobytes.

    +
    +
    + +

    −b

    +
    + +

    Process the image one block (strip/tile) at a time +instead of by reading the whole image into memory at once. +This may be necessary for very large images on systems with +limited RAM.

    +
    +
    + +

    −n

    +
    + +

    Drop the alpha component from the output file, producing +a pure RGB file. Currently this does not work if the +−b flag is also in effect.

    +
    +
    + +

    SEE ALSO

    + + + + + +
    +

    tiff2bw(1), TIFFReadRGBAImage(3t), +libtiff(3)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffcmp.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffcmp.1.html new file mode 100644 index 000000000..d1474cafa --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffcmp.1.html @@ -0,0 +1,156 @@ + + + + + + +TIFFCMP + + + +

    TIFFCMP

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffcmp − compare two TIFF files

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffcmp [ options ] file1.tif +file2.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Tiffcmp compares the tags and data in two files +created according to the Tagged Image File Format, Revision +6.0. The schemes used for compressing data in each file are +immaterial when data are compared−data are compared on +a scanline-by-scanline basis after decompression. Most +directory tags are checked; notable exceptions are: +GrayResponseCurve, ColorResponseCurve, and +ColorMap tags. Data will not be compared if any of +the BitsPerSample, SamplesPerPixel, or +ImageWidth values are not equal. By default, +tiffcmp will terminate if it encounters any +difference.

    +
    + +

    OPTIONS

    + + + + + + + + +
    + +

    −l

    +
    + +

    List each byte of image data that differs between the +files.

    +
    +
    + + + + + +
    +

    −z number

    + + + + + +
    +

    List specified number of image data bytes that differs +between the files.

    +
    + + + + + + + + +
    + +

    −t

    +
    + +

    Ignore any differences in directory tags.

    +
    +
    + +

    BUGS

    + + + + + +
    +

    Tags that are not recognized by the library are not +compared; they may also generate spurious diagnostics.

    + +

    The image data of tiled files is not compared, since the +TIFFReadScanline() function is used. An error will be +reported for tiled files.

    + +

    The pixel and/or sample number reported in differences +may be off in some exotic cases.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    pal2rgb(1), tiffcp(1), +tiffmedian(1), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffcp.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffcp.1.html new file mode 100644 index 000000000..a376f94ec --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffcp.1.html @@ -0,0 +1,569 @@ + + + + + + +TIFFCP + + + +

    TIFFCP

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +EXAMPLES
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffcp − copy (and possibly convert) a +TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffcp [ options ] src1.tif ... srcN.tif +dst.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    tiffcp combines one or more files created +according to the Tag Image File Format, Revision 6.0 into a +single TIFF file. Because the output file may +be compressed using a different algorithm than the input +files, tiffcp is most often used to convert between +different compression schemes.

    + +

    By default, tiffcp will copy all the understood +tags in a TIFF directory of an input file to +the associated directory in the output file.

    + +

    tiffcp can be used to reorganize the storage +characteristics of data in a file, but it is explicitly +intended to not alter or convert the image data content in +any way.

    +
    + +

    OPTIONS

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +

    −a

    +
    + +

    Append to an existing output file instead of overwriting it.

    +
    +
    +

    −b

    +

    subtract the following monochrome image from all others +processed. This can be used to remove a noise bias from a +set of images. This bias image is typically an image of +noise the camera saw with its shutter closed.

    +
    +
    + +

    −B

    +
    + +

    Force output to be written with Big-Endian byte order. +This option only has an effect when the output file is +created or overwritten and not when it is appended to.

    +
    +
    + +

    −C

    +
    + +

    Suppress the use of ‘‘strip +chopping’’ when reading images that have a +single strip/tile of uncompressed data.

    +
    +
    + +

    −c

    +
    + +

    Specify the compression to use for data written to the +output file: none for no compression, packbits +for PackBits compression, lzw for Lempel-Ziv & +Welch compression, jpeg for baseline JPEG +compression, zip for Deflate compression, g3 +for CCITT Group 3 (T.4) compression, g4 for CCITT +Group 4 (T.6) compression, or sgilog for SGILOG compression. +By default tiffcp will +compress data according to the value of the +Compression tag found in the source file.

    +
    +
    + + + + + +
    +

    The CCITT Group 3 and Group 4 compression +algorithms can only be used with bilevel data.

    + +

    Group 3 compression can be specified together with +several T.4-specific options: 1d for 1-dimensional +encoding, 2d for 2-dimensional encoding, and +fill to force each encoded scanline to be zero-filled +so that the terminating EOL code lies on a byte boundary. +Group 3-specific options are specified by appending a +‘‘:’’-separated list to the +‘‘g3’’ option; e.g. −c +g3:2d:fill to get 2D-encoded data with byte-aligned EOL +codes.

    + +

    LZW compression can be specified together +with a predictor value. A predictor value of 2 causes +each scanline of the output image to undergo horizontal +differencing before it is encoded; a value of 1 forces each +scanline to be encoded without differencing. LZW-specific +options are specified by appending a +‘‘:’’-separated list to the +‘‘lzw’’ option; e.g. −c +lzw:2 for LZW compression with horizontal +differencing.

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −f

    +
    + +

    Specify the bit fill order to use in writing output +data. By default, tiffcp will create a new file with +the same fill order as the original. Specifying −f +lsb2msb will force data to be written with the FillOrder +tag set to LSB2MSB, while −f +msb2lsb will force data to be written with the FillOrder +tag set to MSB2LSB.

    +
    +
    + +

    −i

    +
    + +

    Ignore non-fatal read errors and continue processing of +the input file.

    +
    +
    + +

    −l

    +
    + +

    Specify the length of a tile (in pixels). tiffcp +attempts to set the tile dimensions so that no more than 8 +kilobytes of data appear in a tile.

    +
    +
    + +

    −L

    +
    + +

    Force output to be written with Little-Endian byte +order. This option only has an effect when the output file +is created or overwritten and not when it is appended +to.

    +
    +
    + +

    −M

    +
    + +

    Suppress the use of memory-mapped files when reading +images.

    +
    +
    + +

    −o

    +
    + +

    Set initial directory offset.

    +
    +
    + +

    −p

    +
    + +

    Specify the planar configuration to use in writing image +data that has one 8-bit sample per pixel. By default, +tiffcp will create a new file with the same planar +configuration as the original. Specifying −p +contig will force data to be written with multi-sample +data packed together, while −p separate will +force samples to be written in separate planes.

    +
    +
    + +

    −r

    +
    + +

    Specify the number of rows (scanlines) in each strip of +data written to the output file. By default (or when value +0 is specified), tiffcp attempts to set the +rows/strip that no more than 8 kilobytes of data appear in a +strip. If you specify special value −1 it will +results in infinite number of the rows per strip. The entire +image will be the one strip in that case.

    +
    +
    + +

    −s

    +
    + +

    Force the output file to be written with data organized +in strips (rather than tiles).

    +
    +
    + +

    −t

    +
    + +

    Force the output file to be written with data organized +in tiles (rather than strips). options can be used to force +the resultant image to be written as strips or tiles of +data, respectively.

    +
    +
    + +

    −w

    +
    + +

    Specify the width of a tile (in pixels). tiffcp +attempts to set the tile dimensions so that no more than 8 +kilobytes of data appear in a tile. tiffcp attempts +to set the tile dimensions so that no more than 8 kilobytes +of data appear in a tile.

    +
    +
    + +

    −x

    +
    + +

    Force the output file to be written with PAGENUMBER value +in sequence.

    +
    +
    + +

    −8

    +
    + +

    Write BigTIFF instead of classic TIFF format.

    +
    +
    + + + + + +
    +

    −,=character

    + + + + + +
    +

    substitute character for ‘,’ in +parsing image directory indices in files. This is necessary +if filenames contain commas. Note that −,= with +whitespace immediately following will disable the special +meaning of the ‘,’ entirely. See examples.

    +
    + +

    EXAMPLES

    + + + + + +
    +

    The following concatenates two files and writes the +result using LZW encoding:

    + + + + + +
    +
    tiffcp −c lzw a.tif b.tif result.tif
    +
    +
    + + + + + + +
    +

    To convert a G3 1d-encoded TIFF to a +single strip of G4-encoded data the following might be +used:

    + + + + + +
    +
    tiffcp −c g4 −r 10000 g3.tif g4.tif
    +
    +
    + + + + + + +
    +

    (1000 is just a number that is larger than the number of +rows in the source file.)

    + +

    To extract a selected set of images from a multi-image +TIFF file, the file name may be immediately followed by a +‘,’ separated list of image directory indices. +The first image is always in directory 0. Thus, to copy the +1st and 3rd images of image file +‘‘album.tif’’ to +‘‘result.tif’’:

    + + + + + +
    +
    tiffcp album.tif,0,2 result.tif
    +
    +
    + + + + + + +
    +

    A trailing comma denotes remaining images in sequence. +The following command will copy all image with except the +first one:

    + + + + + +
    +
    tiffcp album.tif,1, result.tif
    +
    +
    + + + + + + +
    +

    Given file ‘‘CCD.tif’’ whose +first image is a noise bias followed by images which include +that bias, subtract the noise from all those images +following it (while decompressing) with the +command:

    + + + + + +
    +
    tiffcp −c none −b CCD.tif CCD.tif,1, result.tif
    +
    +
    + + + + + + +
    +

    If the file above were named +‘‘CCD,X.tif’’, the −,= +option would be required to correctly parse this filename +with image numbers, as follows:

    + + + + + +
    +
    tiffcp −c none −,=% −b CCD,X.tif CCD,X%1%.tif result.tif
    +
    +
    +
    + +

    SEE ALSO

    + + + + + + +
    +

    pal2rgb(1), tiffinfo(1), tiffcmp(1), +tiffmedian(1), tiffsplit(1), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffcrop.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffcrop.1.html new file mode 100644 index 000000000..4c868db92 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffcrop.1.html @@ -0,0 +1,684 @@ + + + + + + +TIFFCROP + + + +

    TIFFCROP

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +EXAMPLES
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffcrop − copy (and possibly convert and crop or +process) a TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffcrop [ options ] src1.tif ... +srcN.tif dst.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    tiffcrop combines one or more files created +according to the Tag Image File Format, Revision 6.0 into a +single TIFF file. The output file may be +compressed using a different algorithm than the input files. +tiffcrop is most often used to extract portions of an +image for processing with bar code recognizer or OCR +software when that software cannot restrict the region of +interest to a specific portion of the image or to improve +efficiency when the regions of interest must be rotated.

    + +

    By default, tiffcrop will copy all the understood +tags in a TIFF directory of an input file to +the associated directory in the output file.

    + +

    tiffcrop can be used to reorganize the storage +characteristics of data in a file, and it will alter or +convert the image data content as specified at the same +time, unlike tiffcp.

    + +

    tiffcrop will behave exactly like tiffcp if none +of the new options are specified.

    +
    + +

    OPTIONS

    + + + + + +
    +

    −N odd|even|#,#-#,#|last

    + + + + + +
    +

    sequences and ranges of images within file to process. +The words odd or even may be used to specify +all odd or even numbered images. The word last may be +used in place of a number in the sequence to indicate the +final image in the file without knowing how many images +there are. Ranges of images may be specified with a dash and +multiple sets can be indicated by joining them in a +comma-separated list. e.g.. use −N 1,5-7,last +to process the 1st, 5th through 7th, and final image in the +file.

    +
    + + + + + +
    +

    −E top|bottom|left|right

    + + + + + +
    +

    use the top, bottom, left, or right edge as origin +reference for width and length of crop regions. May be +abbreviated to first letter.

    +
    + + + + + +
    +

    −U in|cm|px

    + + + + + +
    +

    units to apply to dimensions for margins and crop +regions. Inches or centimeters are converted to pixels using +the resolution unit specified in the TIFF file (which +defaults to inches if not specified in the IFD).

    +
    + + + + + +
    +

    −m #,#,#,#

    + + + + + +
    +

    margins to be removed from the image. The order must be +top, left, bottom, right with only commas separating the +elements of the list. Margins are scaled according to the +current units and removed before any other extractions are +computed. Capital M was in use.

    +
    + + + + + + + + + + + + + + +
    + +

    −X #

    +
    + +

    horizontal (X-axis) dimension of a region to extract +relative to the specified origin reference. If the origin is +the top or bottom edge, the X axis value will be assumed to +start at the left edge.

    +
    +
    + +

    −Y #

    +
    + +

    vertical (Y-axis) dimension of a region to extract +relative to the specified origin reference. If the origin is +the left or right edge, the Y axis value will be assumed to +start at the top.

    +
    +
    + + + + + +
    +

    −Z #:#,#:#

    + + + + + +
    +

    zones of the image designated as position X of Y equal +sized portions measured from the reference edge, e.g. 1:3 +would be first third of the image starting from the +reference edge minus any margins specified for the confining +edges. Multiple zones can be specified as a comma separated +list but they must reference the same edge. To extract the +top quarter and the bottom third of an image you would use +−Z 1:4,3:3.

    +
    + + + + + +
    +

    −F horiz|vert

    + + + + + +
    +

    flip, i.e. mirror, the image or extracted region +horizontally or vertically.

    +
    + + + + + +
    +

    −R 90|180|270

    + + + + + +
    +

    rotate the image or extracted region 90, 180, or 270 +degrees clockwise.

    +
    + + + + + + + + +
    + +

    −I

    +
    + +

    invert the colorspace values for grayscale and bi-level +images. This would be used to correct negative images that +have incorrect PHOTOMETRIC INTERPRETATION tags. No support +for color images.

    +
    +
    + + + + + +
    +

    −b image

    + + + + + +
    +

    subtract the following monochrome image from all others +processed. This can be used to remove a noise bias from a +set of images. This bias image is typically an image of +noise the camera saw with its shutter closed. Bias image +support is not available with options for cropping, +rotating, or inverting the image.

    +
    + + + + + + + + + + + + + + + + + + + + +
    + +

    −B

    +
    + +

    Force output to be written with Big-Endian byte order. +This option only has an effect when the output file is +created or overwritten and not when it is appended to.

    +
    +
    + +

    −C

    +
    + +

    Suppress the use of ‘‘strip +chopping’’ when reading images that have a +single strip/tile of uncompressed data.

    +
    +
    + +

    −c

    +
    + +

    Specify the compression to use for data written to the +output file: none for no compression, packbits +for PackBits compression, lzw for Lempel-Ziv & +Welch compression, jpeg for baseline JPEG +compression, zip for Deflate compression, g3 +for CCITT Group 3 (T.4) compression, and g4 for CCITT +Group 4 (T.6) compression. By default tiffcrop will +compress data according to the value of the +Compression tag found in the source file.

    +
    +
    + + + + + +
    +

    The CCITT Group 3 and Group 4 compression +algorithms can only be used with bi-level data.

    + +

    Group 3 compression can be specified together with +several T.4-specific options: 1d for 1-dimensional +encoding, 2d for 2-dimensional encoding, and +fill to force each encoded scanline to be zero-filled +so that the terminating EOL code lies on a byte boundary. +Group 3-specific options are specified by appending a +‘‘:’’-separated list to the +‘‘g3’’ option; e.g. −c +g3:2d:fill to get 2D-encoded data with byte-aligned EOL +codes.

    + +

    LZW compression can be specified together +with a predictor value. A predictor value of 2 causes +each scanline of the output image to undergo horizontal +differencing before it is encoded; a value of 1 forces each +scanline to be encoded without differencing. LZW-specific +options are specified by appending a +‘‘:’’-separated list to the +‘‘lzw’’ option; e.g. −c +lzw:2 for LZW compression with horizontal +differencing.

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −f

    +
    + +

    Specify the bit fill order to use in writing output +data. By default, tiffcrop will create a new file +with the same fill order as the original. Specifying +−f lsb2msb will force data to be written with +the FillOrder tag set to LSB2MSB, while +−f msb2lsb will force data to be written with +the FillOrder tag set to MSB2LSB.

    +
    +
    + +

    −i

    +
    + +

    Ignore non-fatal read errors and continue processing of +the input file.

    +
    +
    + +

    −l

    +
    + +

    Specify the length of a tile (in pixels). +tiffcrop attempts to set the tile dimensions so that +no more than 8 kilobytes of data appear in a tile.

    +
    +
    + +

    −L

    +
    + +

    Force output to be written with Little-Endian byte +order. This option only has an effect when the output file +is created or overwritten and not when it is appended +to.

    +
    +
    + +

    −M

    +
    + +

    Suppress the use of memory-mapped files when reading +images.

    +
    +
    + +

    −p

    +
    + +

    Specify the planar configuration to use in writing image +data that has one 8-bit sample per pixel. By default, +tiffcrop will create a new file with the same planar +configuration as the original. Specifying −p +contig will force data to be written with multi-sample +data packed together, while −p separate will +force samples to be written in separate planes.

    +
    +
    + +

    −r

    +
    + +

    Specify the number of rows (scanlines) in each strip of +data written to the output file. By default (or when value +0 is specified), tiffcrop attempts to set the +rows/strip that no more than 8 kilobytes of data appear in a +strip. If you specify special value -1 it will +results in infinite number of the rows per strip. The entire +image will be the one strip in that case.

    +
    +
    + +

    −s

    +
    + +

    Force the output file to be written with data organized +in strips (rather than tiles).

    +
    +
    + +

    −t

    +
    + +

    Force the output file to be written with data organized +in tiles (rather than strips). options can be used to force +the resultant image to be written as strips or tiles of +data, respectively.

    +
    +
    + +

    −w

    +
    + +

    Specify the width of a tile (in pixels). tiffcrop +attempts to set the tile dimensions so that no more than 8 +kilobytes of data appear in a tile. tiffcrop attempts +to set the tile dimensions so that no more than 8 kilobytes +of data appear in a tile.

    +
    +
    + + + + + +
    +

    −,={character}

    + + + + + +
    +

    substitute {character} for ’,’ in parsing +image directory indices in files. This is necessary if +filenames contain commas. Note that ’,=’ with +whitespace immediately following will disable the special +meaning of the ’,’ entirely. See examples.

    +
    + +

    EXAMPLES

    + + + + + +
    +

    The following concatenates two files and writes the +result using LZW encoding:

    + + + + + +
    +
    tiffcrop -c lzw a.tif b.tif result.tif
    +
    +
    + + + + + + +
    +

    To convert a G3 1d-encoded TIFF to a +single strip of G4-encoded data the following might be +used:

    + + + + + +
    +
    tiffcrop -c g4 -r 10000 g3.tif g4.tif
    +
    +
    + + + + + + +
    +

    (1000 is just a number that is larger than the number of +rows in the source file.)

    + +

    To extract a selected set of images from a multi-image +TIFF file use the -N option described above. Thus, to copy +the 1st and 3rd images of image file "album.tif" +to "result.tif":

    + + + + + +
    +
    tiffcrop -N 1,3 album.tif result.tif
    +
    +
    + + + + + + +
    +

    Given file "CCD.tif" whose first image is a +noise bias followed by images which include that bias, +subtract the noise from all those images following it (while +decompressing) with the command:

    + + + + + +
    +
    tiffcrop -c none -b CCD.tif CCD.tif -d 2 result.tif
    +
    +
    + +

    SEE ALSO

    + + + + + + +
    +

    pal2rgb(1), tiffinfo(1), tiffcmp(1), +tiffcp(1), tiffmedian(1), tiffsplit(1), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffdither.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffdither.1.html new file mode 100644 index 000000000..40e3d6edb --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffdither.1.html @@ -0,0 +1,196 @@ + + + + + + +TIFFDITHER + + + +

    TIFFDITHER

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +NOTES
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffdither − convert a greyscale image to bilevel +using dithering

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffdither [ options ] input.tif +output.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    tiffdither converts a single channel 8-bit +greyscale image to a bilevel image using Floyd-Steinberg +error propagation with thresholding.

    +
    + +

    OPTIONS

    + + + + + + + + +
    + +

    −c

    +
    + +

    Specify the compression to use for data written to the +output file: none for no compression, packbits +for PackBits compression, lzw for Lempel-Ziv & +Welch compression, zip for Deflate compression, +g3 for CCITT Group 3 (T.4) compression, and g4 +for CCITT Group 4 (T.6) compression. By default +tiffdither will compress data according to the value +of the Compression tag found in the source file.

    +
    +
    + + + + + +
    +

    The CCITT Group 3 and Group 4 compression +algorithms can only be used with bilevel data.

    + +

    Group 3 compression can be specified together with +several T.4-specific options: 1d for 1-dimensional +encoding, 2d for 2-dimensional encoding, and +fill to force each encoded scanline to be zero-filled +so that the terminating EOL code lies on a byte boundary. +Group 3-specific options are specified by appending a +‘‘:’’-separated list to the +‘‘g3’’ option; e.g. −c +g3:2d:fill to get 2D-encoded data with byte-aligned EOL +codes.

    + +

    LZW compression can be specified together +with a predictor value. A predictor value of 2 causes +each scanline of the output image to undergo horizontal +differencing before it is encoded; a value of 1 forces each +scanline to be encoded without differencing. LZW-specific +options are specified by appending a +‘‘:’’-separated list to the +‘‘lzw’’ option; e.g. −c +lzw:2 for LZW compression with horizontal +differencing.

    +
    + + + + + + + + + + + + + + + + + + + + +
    + +

    −f

    +
    + +

    Specify the bit fill order to use in writing output +data. By default, tiffdither will create a new file +with the same fill order as the original. Specifying +−f lsb2msb will force data to be written with +the FillOrder tag set to LSB2MSB , +while −f msb2lsb will force data to be written +with the Fill- Order tag set to MSB2LSB +.

    +
    +
    + +

    −r

    +
    + +

    Make each strip have no more than the given number of rows.

    +
    +
    + +

    −t

    +
    + +

    Set the threshold value for dithering. By default the +threshold value is 128.

    +
    +
    + +

    NOTES

    + + + + + +
    +

    The dither algorithm is taken from the +tiffmedian(1) program (written by Paul Heckbert).

    +
    + +

    SEE ALSO

    + + + + + +
    +

    pal2rgb(1), fax2tiff(1), +tiffinfo(1), tiffcp(1), tiff2bw(1), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffdump.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffdump.1.html new file mode 100644 index 000000000..7a23feb63 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffdump.1.html @@ -0,0 +1,145 @@ + + + + + + +TIFFDUMP + + + +

    TIFFDUMP

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffdump − print verbatim information about +TIFF files

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffdump [ options ] name ...

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    tiffdump displays directory information from files +created according to the Tag Image File Format, Revision +6.0. The header of each TIFF file (magic +number, version, and first directory offset) is displayed, +followed by the tag contents of each directory in the file. +For each tag, the name, data type, count, and value(s) is +displayed. When the symbolic name for a tag or data type is +known, the symbolic name is displayed followed by it’s +numeric (decimal) value. Tag values are displayed enclosed +in ‘‘<>’’ characters +immediately preceded by the value of the count field. For +example, an ImageWidth tag might be displayed as +‘‘ImageWidth (256) SHORT (3) +1<800>’’.

    + +

    tiffdump is particularly useful for investigating +the contents of TIFF files that +libtiff does not understand.

    +
    + +

    OPTIONS

    + + + + + + + + +
    + +

    −h

    +
    + +

    Force numeric data to be printed in hexadecimal rather +than the default decimal.

    +
    +
    + + + + + +
    +

    −m items

    + + + + + +
    +

    Change the number of indirect data items that are +printed. By default, this will be 24.

    +
    + + + + + +
    +

    −o offset

    + + + + + +
    +

    Dump the contents of the IFD at the a +particular file offset. The file offset may be specified +using the usual C-style syntax; i.e. a leading +‘‘0x’’ for hexadecimal and a leading +‘‘0’’ for octal.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    tiffinfo(1), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffgt.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffgt.1.html new file mode 100644 index 000000000..d8fcef507 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffgt.1.html @@ -0,0 +1,551 @@ + + + + + + +TIFFGT + + + +

    TIFFGT

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffgt − display an image stored in a +TIFF file (Silicon Graphics version)

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffgt [ options ] input.tif ...

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    tiffgt displays one or more images stored using +the Tag Image File Format, Revision 6.0. Each image is +placed in a fixed size window that the user must position on +the display (unless configured otherwise through X +defaults). If the display has fewer than 24 bitplanes, or if +the image does not warrant full color, then +RGB color values are mapped to the closest +values that exist in the colormap (this is done using the +rgbi routine found in the graphics utility library +−lgutil.)

    + +

    tiffgt correctly handles files with any of the +following characteristics:

    + + + + + + + + + + + + + + + + + + + + + + +
    + +

    BitsPerSample

    +
    + +

    1, 2, 4, 8, 16

    +
    + +

    SamplesPerPixel

    +
    + +

    1, 3, 4 (the 4th sample is ignored)

    +
    + +

    PhotometricInterpretation

    +
    + +

    0 (min-is-white), 1 (min-is-black), 2 (RGB), 3 +(palette), 6 (YCbCr)

    +
    + +

    PlanarConfiguration

    +
    + +

    1 (contiguous), 2 (separate)

    +
    + +

    Orientation

    +
    + +

    1 (top-left), 4 (bottom-left)

    +
    + + + + + +
    +

    Data may be organized as strips or tiles and may be +compressed with any of the compression algorithms supported +by the libtiff(3) library.

    + +

    For palette images (PhotometricInterpretation=3), +tiffgt inspects the colormap values and assumes +either 16-bit or 8-bit values according to the maximum +value. That is, if no colormap entry greater than 255 is +found, tiffgt assumes the colormap has only 8-bit +values; otherwise it assumes 16-bit values. This inspection +is done to handle old images written by previous (incorrect) +versions of libtiff.

    + +

    tiffgt can be used to display multiple images +one-at-a-time. The left mouse button switches the display to +the first image in the next file in the list of files +specified on the command line. The right mouse button +switches to the first image in the previous file in +the list. The middle mouse button causes the first image in +the first file specified on the command line to be +displayed. In addition the following keyboard commands are +recognized:

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    b

    +
    + +

    Use a PhotometricInterpretation of MinIsBlack in +displaying the current image.

    +
    +
    + +

    l

    +
    + +

    Use a FillOrder of lsb-to-msb in decoding the +current image.

    +
    +
    + +

    m

    +
    + +

    Use a FillOrder of msb-to-lsb in decoding the +current image.

    +
    +
    + +

    c

    +
    + +

    Use a colormap visual to display the current image.

    +
    +
    + +

    r

    +
    + +

    Use a true color (24-bit RGB) visual to display the +current image.

    +
    +
    + +

    w

    +
    + +

    Use a PhotometricInterpretation of MinIsWhite in +displaying the current image.

    +
    +
    + +

    W

    +
    + +

    Toggle (enable/disable) display of warning messages from +the TIFF library when decoding images.

    +
    +
    + +

    E

    +
    + +

    Toggle (enable/disable) display of error messages from +the TIFF library when decoding images.

    +
    +
    + +

    z

    +
    + +

    Reset all parameters to their default settings +(FillOrder, PhotometricInterpretation, +handling of warnings and errors).

    +
    +
    + +

    PageUp

    +
    + +

    Display the previous image in the current file or the +last image in the previous file.

    +
    +
    + + + + + +
    +

    PageDown

    + + + + + +
    +

    Display the next image in the current file or the first +image in the next file.

    +
    + + + + + + + + + + + + + + +
    + +

    Home

    +
    + +

    Display the first image in the current file.

    +
    +
    + +

    End

    +
    + +

    Display the last image in the current file +(unimplemented).

    +
    +
    + +

    OPTIONS

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −c

    +
    + +

    Force image display in a colormap window.

    +
    +
    + +

    −d

    +
    + +

    Specify an image to display by directory number. By +default the first image in the file is displayed. +Directories are numbered starting at zero.

    +
    +
    + +

    −e

    +
    + +

    Enable reporting of error messages from the +TIFF library. By default tiffgt +silently ignores images that cannot be read.

    +
    +
    + +

    −f

    +
    + +

    Force tiffgt to run as a foreground process. By +default tiffgt will place itself in the background +once it has opened the requested image file.

    +
    +
    + +

    −l

    +
    + +

    Force the presumed bit ordering to be LSB +to MSB.

    +
    +
    + +

    −m

    +
    + +

    Force the presumed bit ordering to be MSB +to LSB.

    +
    +
    + +

    −o

    +
    + +

    Specify an image to display by directory offset. By +default the first image in the file is displayed. +Directories offsets may be specified using C-style syntax; +i.e. a leading ‘‘0x’’ for +hexadecimal and a leading ‘‘0’’ for +octal.

    +
    +
    + +

    −p

    +
    + +

    Override the value of the +PhotometricInterpretation tag; the parameter may be +one of: miniswhite, minisblack, rgb, +palette, mask, separated, ycbcr, +and cielab.

    +
    +
    + +

    −r

    +
    + +

    Force image display in a full color window.

    +
    +
    + +

    −s

    +
    + +

    Stop on the first read error. By default all errors in +the input data are ignored and tiffgt does it’s +best to display as much of an image as possible.

    +
    +
    + +

    −w

    +
    + +

    Enable reporting of warning messages from the +TIFF library. By default tiffgt +ignores warning messages generated when reading an +image.

    +
    +
    + +

    −v

    +
    + +

    Place information in the title bar describing what type +of window (full color or colormap) is being used, the name +of the input file, and the directory index of the image (if +non-zero). By default, the window type is not shown in the +title bar.

    +
    +
    + +

    BUGS

    + + + + + +
    +

    Images wider and taller than the display are silently +truncated to avoid crashing old versions of the window +manager.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    tiffdump(1), tiffinfo(1), tiffcp(1), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffinfo.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffinfo.1.html new file mode 100644 index 000000000..9accdd514 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffinfo.1.html @@ -0,0 +1,196 @@ + + + + + + +TIFFINFO + + + +

    TIFFINFO

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffinfo − print information about +TIFF files

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffinfo [ options ] input.tif +...

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Tiffinfo displays information about files created +according to the Tag Image File Format, Revision 6.0. By +default, the contents of each TIFF directory +in each file is displayed, with the value of each tag shown +symbolically (where sensible).

    +
    + +

    OPTIONS

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    −c

    +
    + +

    Display the colormap and color/gray response curves, if +present.

    +
    +
    + +

    −D

    +
    + +

    In addition to displaying the directory tags, read and +decompress all the data in each image (but not display +it).

    +
    +
    + +

    −d

    +
    + +

    In addition to displaying the directory tags, print each +byte of decompressed data in hexadecimal.

    +
    +
    + +

    −j

    +
    + +

    Display any JPEG -related tags that are +present.

    +
    +
    + +

    −o

    +
    + +

    Set the initial TIFF directory according +to the specified file offset. The file offset may be +specified using the usual C-style syntax; i.e. a leading +‘‘0x’’ for hexadecimal and a leading +‘‘0’’ for octal.

    +
    +
    + +

    −s

    +
    + +

    Display the offsets and byte counts for each data strip +in a directory.

    +
    +
    + +

    −z

    +
    + +

    Enable strip chopping when reading image data.

    +
    +
    + +

    −#

    +
    + +

    Set the initial TIFF directory to +#.

    +
    +
    + +

    SEE ALSO

    + + + + + +
    +

    pal2rgb(1), tiffcp(1), tiffcmp(1), +tiffmedian(1), libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffmedian.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffmedian.1.html new file mode 100644 index 000000000..ec6d0b1c0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffmedian.1.html @@ -0,0 +1,183 @@ + + + + + + +TIFFMEDIAN + + + +

    TIFFMEDIAN

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +NOTES
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffmedian − apply the median cut algorithm to data +in a TIFF file

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffmedian [ options ] input.tif +output.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    tiffmedian applies the median cut algorithm to an +RGB image in input.tif to generate a +palette image that is written to output.tif. The +generated colormap has, by default, 256 entries. The image +data is quantized by mapping each pixel to the closest color +values in the colormap.

    +
    + +

    OPTIONS

    + + + + + + + + +
    + +

    −c

    +
    + +

    Specify the compression to use for data written to the +output file: none for no compression, packbits +for PackBits compression, lzw for Lempel-Ziv & +Welch compression, and zip for Deflate compression. +By default tiffmedian will compress data according to +the value of the Compression tag found in the source +file.

    +
    +
    + + + + + +
    +

    LZW compression can be specified together +with a predictor value. A predictor value of 2 causes +each scanline of the output image to undergo horizontal +differencing before it is encoded; a value of 1 forces each +scanline to be encoded without differencing. LZW-specific +options are specified by appending a +‘‘:’’-separated list to the +‘‘lzw’’ option; e.g. −c +lzw:2 for LZW compression with horizontal +differencing.

    +
    + + + + + + + + + + + + + + + + + + + + +
    + +

    −C

    +
    + +

    Specify the number of entries to use in the generated +colormap. By default all 256 entries/colors are used.

    +
    +
    + +

    −f

    +
    + +

    Apply Floyd-Steinberg dithering before selecting a +colormap entry.

    +
    +
    + +

    −r

    +
    + +

    Specify the number of rows (scanlines) in each strip of +data written to the output file. By default, +tiffmedian attempts to set the rows/strip that no +more than 8 kilobytes of data appear in a strip.

    +
    +
    + +

    NOTES

    + + + + + +
    +

    This program is derived from Paul Heckbert’s +median program.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    pal2rgb(1), tiffinfo(1), tiffcp(1), +tiffcmp(1), libtiff(3TIFF)

    + +

    Color Image Quantization for Frame Buffer Display, +Paul Heckbert, SIGGRAPH proceedings, 1982, pp. 297-307.

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffset.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffset.1.html new file mode 100644 index 000000000..0c30b0106 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffset.1.html @@ -0,0 +1,176 @@ + + + + + + +TIFFSET + + + +

    TIFFSET

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +EXAMPLES
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffset − set a field in a TIFF +header

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffset [ options ] filename.tif

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    Tiffset sets the value of a TIFF +header to a specified value.

    +
    + +

    OPTIONS

    + + + + + +
    +

    −s tagnumber [ count ] +value ...

    + + + + + +
    +

    Set the value of the named tag to the value or values +specified.

    +
    + + + + + +
    +

    −sf tagnumber filename

    + + + + + +
    +

    Set the value of the tag to the contents of filename. +This option is supported for ASCII tags only.

    +
    + +

    EXAMPLES

    + + + + + +
    +

    The following example sets the image description tag +(270) of a.tif to the contents of the file descrip:

    + + + + + +
    +
    tiffset −sf 270 descrip a.tif
    +
    +
    + + + + + + +
    +

    The following example sets the artist tag (315) of a.tif +to the string +‘‘Anonymous’’:

    + + + + + +
    +
    tiffset −s 305 Anonymous a.tif
    +
    +
    + + + + + + +
    +

    This example sets the resolution of the file a.tif to 300 +dpi:

    + + + + + +
    +
    tiffset −s 296 2 a.tif
    +tiffset −s 282 300.0 a.tif
    +tiffset −s 283 300.0 a.tif
    +
    +
    + +

    SEE ALSO

    + + + + + + +
    +

    tiffdump(1), tiffinfo(1), tiffcp(1), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/man/tiffsplit.1.html b/thirdparty/SDL2_image/external/libtiff/html/man/tiffsplit.1.html new file mode 100644 index 000000000..5cf8dd85b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/man/tiffsplit.1.html @@ -0,0 +1,102 @@ + + + + + + +TIFFSPLIT + + + +

    TIFFSPLIT

    +NAME
    +SYNOPSIS
    +DESCRIPTION
    +OPTIONS
    +BUGS
    +SEE ALSO
    + +
    + +

    NAME

    + + + + + +
    +

    tiffsplit − split a multi-image TIFF +into single-image TIFF files

    +
    + +

    SYNOPSIS

    + + + + + +
    +

    tiffsplit src.tif [ prefix ]

    +
    + +

    DESCRIPTION

    + + + + + +
    +

    tiffsplit takes a multi-directory (page) +TIFF file and creates one or more +single-directory (page) TIFF files from it. +The output files are given names created by concatenating a +prefix, a lexically ordered suffix in the range +[aaa-zzz], the suffix .tif (e.g. +xaaa.tif, xaab.tif, xzzz.tif). If a +prefix is not specified on the command line, the default +prefix of x is used.

    +
    + +

    OPTIONS

    + + + + + +
    +

    None.

    +
    + +

    BUGS

    + + + + + +
    +

    Only a select set of ‘‘known +tags’’ is copied when splitting.

    +
    + +

    SEE ALSO

    + + + + + +
    +

    tiffcp(1), tiffinfo(1), +libtiff(3TIFF)

    + +

    Libtiff library home page: +http://www.simplesystems.org/libtiff/

    +
    +
    + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/misc.html b/thirdparty/SDL2_image/external/libtiff/html/misc.html new file mode 100644 index 000000000..69d3ba18b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/misc.html @@ -0,0 +1,121 @@ + + + + +Acknowledgments and Other Issues + + + + +

    +ring +Acknowledgments and Other Issues +

    + +

    +Silicon Graphics has seen fit to allow us to give this work away. It +is free. There is no support or guarantee of any sort as to its +operations, correctness, or whatever. If you do anything useful with +all or parts of it you need to honor the copyright notices. It would +also be nice to be acknowledged.

    + +
    + +

    Acknowledgements

    + +The libtiff software was written by Sam Leffler while working for +Silicon Graphics.

    + +The LZW algorithm is derived from the compress program (the proper attribution +is included in the source code). The Group 3 fax stuff originated as code +from Jef Poskanzer, but has since been rewritten several times. The latest +version uses an algorithm from Frank Cringle -- consult +libtiff/mkg3states.c and libtiff/tif_fax3.h for further +information. The JPEG support was written by Tom Lane and is dependent on the +excellent work of Tom Lane and the Independent JPEG Group (IJG) who distribute +their work under friendly licensing similar to this software. Joris Van Damme +implemented the robust Old JPEG decoder (as included in libtiff since version +3.9.0, there was another Old JPEG module in older releases, which was +incomplete and unsuitable for many existing images of that format). JBIG +module was written by Lee Howard and depends on JBIG library from the Markus +Kuhn. Many other people have by now helped with bug fixes and code; a few of +the more persistent contributors have been: + +

    +    Bjorn P. Brox
    +    Dan McCoy
    +    J.T. Conklin                
    +    Richard Minner
    +    Frank D. Cringle        
    +    Richard Mlynarik
    +    Soren Pingel Dalsgaard  
    +    Niles Ritter
    +    Steve Johnson           
    +    Karsten Spang
    +    Tom Lane               
    +    Peter Smith
    +    Brent Roman            
    +    Mike Welles
    +    Frank Warmerdam
    +    Greg Ward
    +    Stanislav Brabec        
    +    Roman Shpount
    +    Peter Skarpetis        
    +    Arvan Pritchard
    +    Bernt Herd             
    +    Joseph Orost
    +    Phil Beffery           
    +    Ivo Penzar
    +    Francois Dagand        
    +    Albert Chin-A-Young
    +    Bruce A. Mallett
    +    Dwight Kelly
    +    Andrey Kiselev
    +    Ross Finlayson
    +    Dmitry V. Levin
    +    Bob Friesenhahn
    +    Lee Howard
    +    Joris Van Damme
    +    Tavis Ormandy
    +    Richard Nolde
    +    Even Rouault
    +
    + +(my apology to anyone that was inadvertently not listed.) + +

    Use and Copyright

    + +
    
    +Copyright (c) 1988-1997 Sam Leffler
    +Copyright (c) 1991-1997 Silicon Graphics, Inc.
    +
    +Permission to use, copy, modify, distribute, and sell this software and 
    +its documentation for any purpose is hereby granted without fee, provided
    +that (i) the above copyright notices and this permission notice appear in
    +all copies of the software and related documentation, and (ii) the names of
    +Sam Leffler and Silicon Graphics may not be used in any advertising or
    +publicity relating to the software without the specific, prior written
    +permission of Sam Leffler and Silicon Graphics.
    +
    +THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
    +EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
    +WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
    +
    +IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
    +ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
    +OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
    +WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
    +LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
    +OF THIS SOFTWARE.
    +
    + +
    + + +Last updated: $Date: 2016-09-25 20:05:44 $ + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/support.html b/thirdparty/SDL2_image/external/libtiff/html/support.html new file mode 100644 index 000000000..e29d2d0d9 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/support.html @@ -0,0 +1,655 @@ + + + + TIFF 6.0 Specification Coverage + + + + + + + + + + +
    +

    TIFF 6.0 Specification Coverage

    +

    + The library is capable of dealing with images that are written to + follow the 5.0 or 6.0 TIFF spec. There is also considerable support + for some of the more esoteric portions of the 6.0 TIFF spec. +

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Core requirements +

    + Both "MM" and "II" byte orders are handled. + Both packed and separated planar configuration of samples. + Any number of samples per pixel (memory permitting). + Any image width and height (memory permitting). + Multiple subfiles can be read and written. + Editing is not supported in that related subfiles (e.g. + a reduced resolution version of an image) are not automatically + updated. +

    +

    + Tags handled: ExtraSamples, ImageWidth, + ImageLength, NewSubfileType, ResolutionUnit. + Rowsperstrip, StripOffsets, StripByteCounts, + XResolution, YResolution +

    +
    Tiled ImagesTileWidth, TileLength, TileOffsets, + TileByteCounts
    Image Colorimetry InformationWhitePoint, PrimaryChromaticities, TransferFunction, + ReferenceBlackWhite
    Class B for bilevel imagesSamplesPerPixel = 1
    + BitsPerSample = 1
    + Compression = 1 (none), 2 (CCITT 1D), or 32773 (PackBits)
    + PhotometricInterpretation = 0 (Min-is-White), 1 (Min-is-Black)
    Class G for grayscale imagesSamplesPerPixel = 1
    + BitsPerSample = 4, 8
    + Compression = 1 (none) 5 (LZW)
    + PhotometricInterpretation = 0 (Min-is-White), 1 (Min-is-Black)
    Class P for palette color imagesSamplesPerPixel = 1
    + BitsPerSample = 1-8
    + Compression = 1 (none) 5 (LZW)
    + PhotometricInterpretation = 3 (Palette RGB)
    + ColorMap
    Class R for RGB full color imagesSamplesPerPixel = 3
    + BitsPerSample = <8,8,8>
    + PlanarConfiguration = 1, 2
    + Compression = 1 (none) 5 (LZW)
    + PhotometricInterpretation = 2 (RGB)
    Class F for facsimile(Class B tags plus...)
    + Compression = 3 (CCITT Group 3), 4 (CCITT Group 4)
    + FillOrder = 1 (MSB), 2 (LSB)
    + Group3Options = 1 (2d encoding), 4 (zero fill), 5 (2d+fill)
    + ImageWidth = 1728, 2048, 2482
    + NewSubFileType = 2
    + ResolutionUnit = 2 (Inch), 3 (Centimeter)
    + PageNumber, + XResolution, + YResolution, + Software, + BadFaxLines, + CleanFaxData, + ConsecutiveBadFaxLines, + DateTime, + DocumentName, + ImageDescription, + Orientation
    Class S for separated imagesSamplesPerPixel = 4
    + PlanarConfiguration = 1, 2
    + Compression = 1 (none), 5 (LZW)
    + PhotometricInterpretation = 5 (Separated)
    + InkSet = 1 (CMYK)
    + DotRange, + InkNames, + DotRange, + TargetPrinter
    Class Y for YCbCr imagesSamplesPerPixel = 3
    + BitsPerSample = <8,8,8>
    + PlanarConfiguration = 1, 2
    + Compression = 1 (none), 5 (LZW), 7 (JPEG)
    + PhotometricInterpretation = 6 (YCbCr)
    + YCbCrCoefficients, + YCbCrSubsampling, + YCbCrPositioning
    + (colorimetry info from Appendix H; see above)
    Class "JPEG" for JPEG images (per TTN2)PhotometricInterpretation = 1 (grayscale), 2 (RGB), 5 (CMYK), 6 (YCbCr)
    + (Class Y tags if YCbCr)
    + (Class S tags if CMYK)
    + Compression = 7 (JPEG)
    +

    + In addition, the library supports some optional compression algorithms + that are, in some cases, of dubious value. +

    + + + + + + + + +
    Compression tag valueCompression algorithm
    32766NeXT 2-bit encoding
    32809ThunderScan 4-bit encoding
    32909Pixar companded 11-bit ZIP encoding
    32946PKZIP-style Deflate encoding (experimental)
    34676SGI 32-bit Log Luminance encoding (experimental)
    34677SGI 24-bit Log Luminance encoding (experimental)
    +
    +

    + Note that there is no support for the JPEG-related tags defined + in the 6.0 specification; the JPEG support is based on the post-6.0 + proposal given in TIFF Technical Note #2. +

    + + + + + +
    For more information on the experimental Log Luminance encoding + consult the materials available at + http://www.anyhere.com/gward/pixformat/tiffluv.html.
    +
    +

    + The following table shows the tags that are recognized + and how they are used by the library. If no use is indicated, + then the library reads and writes the tag, but does not use it internally. +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Tag NameValueR/WLibrary's Use (Comments)
    NewSubFileType254R/Wnone (called SubFileType in <tiff.h>)
    SubFileType255R/Wnone (called OSubFileType in <tiff.h>)
    ImageWidth256R/Wlots
    ImageLength257R/Wlots
    BitsPerSample258R/Wlots
    Compression259R/Wto select appropriate codec
    PhotometricInterpretation262R/Wlots
    Thresholding263R/W 
    CellWidth264 parsed but ignored
    CellLength265 parsed but ignored
    FillOrder266R/Wcontrol bit order
    DocumentName269R/W 
    ImageDescription270R/W 
    Make271R/W 
    Model272R/W 
    StripOffsets273R/Wdata i/o
    Orientation274R/W 
    SamplesPerPixel277R/Wlots
    RowsPerStrip278R/Wdata i/o
    StripByteCounts279R/Wdata i/o
    MinSampleValue280R/W 
    MaxSampleValue281R/W 
    XResolution282R/W 
    YResolution283R/Wused by Group 3 2d encoder
    PlanarConfiguration284R/Wdata i/o
    PageName285R/W 
    XPosition286R/W 
    YPosition286R/W 
    FreeOffsets288 parsed but ignored
    FreeByteCounts289 parsed but ignored
    GrayResponseUnit290 parsed but ignored
    GrayResponseCurve291 parsed but ignored
    Group3Options292R/Wused by Group 3 codec
    Group4Options293R/W 
    ResolutionUnit296R/Wused by Group 3 2d encoder
    PageNumber297R/W 
    ColorResponseUnit300 parsed but ignored
    TransferFunction301R/W 
    Software305R/W 
    DateTime306R/W 
    Artist315R/W 
    HostComputer316R/W 
    Predictor317R/Wused by LZW codec
    WhitePoint318R/W 
    PrimaryChromacities319R/W 
    ColorMap320R/W 
    TileWidth322R/Wdata i/o
    TileLength323R/Wdata i/o
    TileOffsets324R/Wdata i/o
    TileByteCounts324R/Wdata i/o
    BadFaxLines326R/W 
    CleanFaxData327R/W 
    ConsecutiveBadFaxLines328R/W 
    SubIFD330R/Wsubimage descriptor support
    InkSet332R/W 
    InkNames333R/W 
    DotRange336R/W 
    TargetPrinter337R/W 
    ExtraSamples338R/Wlots
    SampleFormat339R/W 
    SMinSampleValue340R/W 
    SMaxSampleValue341R/W 
    JPEGTables347R/Wused by JPEG codec
    YCbCrCoefficients529R/Wused by TIFFReadRGBAImage support
    YCbCrSubsampling530R/Wtile/strip size calculations
    YCbCrPositioning531R/W 
    ReferenceBlackWhite532R/W 
    Matteing32995Rnone (obsoleted by ExtraSamples tag)
    DataType32996Rnone (obsoleted by SampleFormat tag)
    ImageDepth32997R/Wtile/strip calculations
    TileDepth32998R/Wtile/strip calculations
    StoNits37439R/W 
    +

    + The Matteing and DataType + tags have been obsoleted by the 6.0 + ExtraSamples and SampleFormat tags. + Consult the documentation on the + ExtraSamples tag and Associated Alpha for elaboration. Note however + that if you use Associated Alpha, you are expected to save data that is + pre-multipled by Alpha. If this means nothing to you, check out + Porter & Duff's paper in the '84 SIGGRAPH proceedings: "Compositing Digital + Images". +

    +

    + The ImageDepth + tag is a non-standard, but registered tag that specifies + the Z-dimension of volumetric data. The combination of ImageWidth, + ImageLength, and ImageDepth, + defines a 3D volume of pixels that are + further specified by BitsPerSample and + SamplesPerPixel. The TileDepth + tag (also non-standard, but registered) can be used to specified a + subvolume "tiling" of a volume of data. +

    +

    + The Colorimetry, and CMYK tags are additions that appear in TIFF 6.0. + Consult the TIFF 6.0 specification included in the doc directory + and online. +

    +

    + The JPEG-related tag is specified in + TIFF Technical Note #2 which defines + a revised JPEG-in-TIFF scheme (revised over that appendix that was + part of the TIFF 6.0 specification). +

    +
    +

    + Last updated: $Date: 2016-09-25 20:05:45 $ +

    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/tools.html b/thirdparty/SDL2_image/external/libtiff/html/tools.html new file mode 100644 index 000000000..d567ad8ad --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/tools.html @@ -0,0 +1,142 @@ + + + +TIFF Tools Overview + + + +

    quad +TIFF Tools Overview

    +

    This software distribution comes with a small collection of +programs for converting non-TIFF format images to TIFF and for +manipulating and interrogating the contents of TIFF images. Several +of these tools are useful in their own right. Many of them however +are more intended to serve as programming examples for using the +TIFF library.

    +

    Device-dependent Programs

    +There are two device-dependent programs that serve as simple +examples for writing programs to display and save TIFF images. + + + + + +
    +tiffgt    Display the contents of one or more TIFF images using OpenGL. +The software makes extensive use of the TIFFRGBAImage +facilities described elsewhere.
    +

    Device-independent Programs

    +The remaining programs should be device-independent: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    fax2psConvert a Group 3- or Group 4- compressed TIFF to PostScript +that is significantly more compressed than is generated by +tiff2ps (unless tiff2ps writes PS Level II)
    fax2tiffConvert raw Group 3 or Group 4 facsimile data to TIFF
    pal2rgbConvert a Palette-style image to a full color RGB image by +applying the colormap
    ppm2tiffA quick hack that converts 8-bit PPM format images to TIFF
    raw2tiffCreate a TIFF file from raw data
    rgb2ycbcrConvert an RGB, grayscale, or bilevel TIFF image to a YCbCr +TIFF image; it's mainly provided for testing
    thumbnailCopy a bilevel TIFF to one that includes 8-bit greyscale +"thumbnail images" for each page; it is provided as an example of +how one might use the SubIFD tag (and the library support +for it)
    tiff2bwA simple program to convert a color image to grayscale
    tiff2pdfConvert TIFF images to PDF
    tiff2psConvert TIFF images to PostScript
    tiff2rgbaConvert a TIFF image to RGBA color space
    tiffcmpCompare the contents of two TIFF files (it does not check all +the directory information, but does check all the data)
    tiffcpCopy, concatenate, and convert TIFF images (e.g. switching from +Compression=5 to Compression=1)
    tiffcropProvides selection of images from within one or more multi-image +TIFF files, with orthogonal rotation, mirroring, cropping, and +extraction of multiple sections and exporting to one or more files. +It extends the functionality of tiffcp to support additional bit +depths in strips and tiles and enhances the selection capabilities of +tiffsplit. Bilevel images can be inverted and images may be split into +segments to fit on multiple /pages/ (standard paper sizes), plus other +functions described in the tiffcrop man page
    tiffditherDither a b&w image into a bilevel image (suitable for use +in creating fax files)
    tiffdumpDisplay the verbatim contents of the TIFF directory in a file +(it's very useful for debugging bogus files that you may get from +someone that claims they support TIFF)
    tiffinfoDisplay information about one or more TIFF files.
    tiffmedianA version of Paul Heckbert's median cut program that reads an +RGB TIFF image, and creates a TIFF palette file as a result
    tiffsetSet a field in a TIFF header
    tiffsplitCreate one or more single-image files from a (possibly) +multi-image file
    +

    Check out the manual pages for details about the above +programs.

    +
    +Last updated: $Date: 2016-06-05 19:54:00 $ + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta007.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta007.html new file mode 100644 index 000000000..c2b51f0a4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta007.html @@ -0,0 +1,113 @@ + + + + +Changes in TIFF v3.4beta007 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • bit order was corrected for Pentium systems +
    • a new define, HOST_BIGENDIAN, was added for code that + wants to statically use information about native cpu byte order +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • the G3/G4 decoder was replaced by a new one that is faster and + has smaller state tables +
    • Niles Ritter's client tag extension hooks were added +
    • a new routine TIFFCurrentDirOffset was added for + applications that want to find out the file offset of a TIFF directory +
    • the calculation of the number of strips in an image was corected + for images with certain esoteric configurations +
    • a potential memory leak (very unlikely) was plugged +
    • the TIFFReadRGBAImage support was completely rewritten + and new, more flexible support was added for reading images into + a fixed-format raster +
    • YCbCr to RGB conversion done in the TIFFReadRGBAImage support + was optimized +
    • a bug in JPEG support calculation of strip size was corrected +
    • the LZW decoder was changed to initialize the code table to zero + to lessen potential problems that arise when invalid data is decoded +
    • tiffcomp.h is now aware of OS/2 +
    • some function prototypes in tiffio.h and tiffiop.h + that contained parameter + names have been changed to avoid complaints from certain compilers +
    + +


    + +CHANGES IN THE PORTABILITY SUPPORT: + +
      +
    • Makefile.in has been corrected to use the parameters + chosen by the configure script +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • fax2ps has been rewritten and moved over from the user + contributed software +
    • an uninitialized variable in pal2rgb has been fixed +
    • ras2tiff now converts 24-bit RGB raster data so that + samples are written in the proper order +
    • tiff2ps has been updated to include fixes + and enhancements from Alberto Accomazzi +
    • tiffcp now has a -o option to select a directory + by file offset +
    • tiffinfo is now capable of displaying the raw undecoded + image data in a file +
    • tiffgt has been rewritten to use the new TIFFRGBAImage + support and to handle multiple files +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta016.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta016.html new file mode 100644 index 000000000..110353842 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta016.html @@ -0,0 +1,123 @@ + + + + +Changes in TIFF v3.4beta016 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • support was added for configuring the Deflate codec +
    • support was added for the HTML documentation +
    • codecs that are not configured for inclusion in the library + are no longer compiled +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • support was added for registering new codecs external to the library + and for overriding the codecs that are builtin to the library +
    • emulation support for the old DataType tag was improved +
    • suppport was added for the SMinSampleValue + and SMaxSampleValue tags +
    • the library no longer ignores TileWidth and TileLength + tags whose values are not a multiple of 16 (per the spec); this + permits old, improperly written, images to be read +
    • the support for the Predictor tag was placed in a reusable + module so that it can be shared by multiple codecs +
    • experimental compression support was added for the Deflate algorithm + (using the freely available zlib package) +
    • a new routine, TIFFWriteBufferSetup was added a la the + routine TIFFReadBufferSetup +
    • the DSO version of the library is now statically linked with the + JPEG and Deflate libraries; this means applications that link against + the DSO do not also need to link against these ancillary libraries +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • all the tools now use common code to process compress-oriented arguments +
    • tiffdump should now compile on a Macintosh with MPW +
    + +


    + +CHANGES IN THE MANUAL PAGES: + +
      +
    • everything was updated +
    + +


    + +CHANGES IN THE DOCUMENTATION: + +
      +
    • everything was updated +
    + +


    + +CHANGES IN CONTRIBUTED SOFTWARE: + +
      +
    • contrib/dbs/xtiff was made to compile +
    • contrib/mac-mpw is new support for compiling the software on + a Macintosh under MPW; consult the documentation + for details +
    • contrib/tags is information on how to use the tag extenion + facilities; consult + contrib/tags/README for details +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta018.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta018.html new file mode 100644 index 000000000..63ffb4972 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta018.html @@ -0,0 +1,85 @@ + + + + +Changes in TIFF v3.4beta018 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • configure now recognizes IRIX 6.x systems +
    • configure now uses ENVOPTS when searching for an ANSI + C compiler; this fixes a problem configuring the software under + HP/UX with the native C compiler +
    • configure now correctly recognizes memory-mapped files are supported + under AIX +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • make install now properly installs the include files +
    • some portability fixes from Bjorn Brox +
    • the G3/G4 codec now warns about decoded rows that are longer than + the image/tile width +
    • changes from Frank Cringle to make the library work with the + gcc-specific bounds checking software +
    • miscellaneous fixes to TIFFPrintDirectory +
    • bug fix to correct a problem where TIFFWriteRawStrip + could not be used to automatically grow an image's length +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • fixes from Frank Cringle to update fax2tiff +
    • portability fixes to tiff2bw and tiffcmp +
    • tiffdump now uses the byte swapping routines in the library +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta024.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta024.html new file mode 100644 index 000000000..ec82840c1 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta024.html @@ -0,0 +1,140 @@ + + + + +Changes in TIFF v3.4beta024 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • It is now possible to setup the software to build only the + library; configure reconizes this is the intent when the + VERSION, tiff.alpha, and tif_version.c + files are in the local directory (i.e. ``.'') +
    • configure no longer tries to setup HTML materials +
    • include file directories needed in building the library are now + specified with a DIRS_LIBINC config parameter +
    • configure no longer checks for alternate compilers if CC + is set; if the specified compiler is not found or is not appropriate + the configuration procedure aborts +
    • the port.h file generated by configure is now used only by + the library and as such as have been moved to the libtiff + directory +
    • there is beginning support for building DSO's on systems other than IRIX +
    • configure now verifies the JPEG and zlib directory pathnames by + checking for well-known include files in these directories +
    • configure no longer creates the dist directory needed only + on SGI machines (for building SGI binary distributions) +
    • a bug was fixed whereby configure would incorrectly set + ENVOPTS when building the software with gcc under AIX +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • two new typedefs were added to tiff.h: int8 + and uint8 for signed and unsigned 8-bit quantities, + respectively; these are currently used only by + programs in the tools directory +
    • the BadFaxLines, CleanFaxData, and + ConsecutiveBadFaxLines tags are now supported with + Group 4 compression +
    • byte order is now correctly identified on 64-bit machines +
    • a bug was fixed in the PackBits decoder where input data would + appear short when a no-op run was present +
    • a bug was fixed in calculations with very wide strips +
    • TIFFWriteEncodedStrip and TIFFWriteRawStrip + were extended to support dynamically growing the number of + strips in an image (must set ImageLength prior to + making calls though) +
    • TIFFDefaultTileSize now rounds tile width and height + up to a multiple of 16 pixels, as required by the TIFF 6.0 specification +
    • the file version.h is now built by a new mkversion + program; this was done for portability to non-UNIX systems +
    • support was added for the Acorn RISC OS (from Peter Greenham) +
    • the builtin codec table is now made const when compiling + under VMS so that libtiff can be built as a shared library +
    • support for the PowerPC Mac (from Ruedi Boesch) +
    • support for Window NT/Window 95 (from Scott Wagner) +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • the tools no longer include port.h +
    • various portability fixes; mostly to eliminate implicit assumptions + about how long int32 data types are +
    • PostScript Level II additions to tiff2ps from Bjorn Brox +
    • sgi2tiff now handles RGBA images +
    + +


    + +CHANGES IN THE MANUAL PAGES: + +
      +
    • the documentation has been updated to reflect the current state of + the software +
    • some routines have been moved to different manual pages + to group like-routines together +
    + +


    + +CHANGES IN THE CONTRIBUTED SOFTWARE: + +
      +
    • support was added for the Acorn RISC OS (from Peter Greenham) +
    • support for Windows NT/Windows 95 contributed for a previous + version of this software was sort of incorporated (it's broken + right now) (from Scott Wagner) +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta028.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta028.html new file mode 100644 index 000000000..5ae0e4909 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta028.html @@ -0,0 +1,147 @@ + + + + +Changes in TIFF v3.4beta028 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • a -noninteractive flag was added to configure to + control whether or not it prints and prompts for configuration information +
    • various typos and fixes were made in configure for the the + library-only build support (this and other configure fixes from + Richard Mlynarik <mly@adoc.xerox.com>) +
    • bugs were fixed in the handling of pathnames supplied for external + packages; e.g. DIR_JPEG +
    • the handling of SETMAKE is now done properly +
    • the default prototype function declaration for pow was corrected +
    • a bug was fixed in libtiff/Makefile.in that caused installation + to fail on systems without DSO support +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • Acorn RISC O/S support that was accidentally left out of the + left out of the previous distribution is present (from Peter Greenham) +
    • complaints about unknown and/or unsupported codecs have been + delayed until they are invoked; this permits applications to open + images and look at tags even if the image data is compressed with + an unknown/unsupported compression scheme +
    • bugs in handling unknown tags have been corrected; applications + that use multiple codecs, each with codec-specific tags, no longer + generate confusing error messages +
    • a missing pseudo-tag definition in the CCITT G3 codec was fixed + (this problem caused core dumps in the tiffcp program) +
    • pseudo-tags are now treated specially; they are always considered + to be set (i.e. they do not use bits in the FIELD_* bit-vectors). +
    • the use of strip chopping can now be controlled on a per-file basis + through a mode parameter supplied when opening a file (``C'' to + enable strip chopping and ``c'' to disable) +
    • two bugs were fixed in the writing of opposite-endian byte-order + files +
    • support was added for three new fax-related tags registered to + SGI: FaxRecvParams, FaxRecvTime, and FaxSubAddress +
    • the bit order of image data read and written can now be controlled + on a per-file basis through a mode parameter supplied when opening + a file (``B'' to force MSB2LSB bit order, ``L'' for LSB2MSB bit + order, and ``H'' for the bit order of the native CPU) +
    • the byte order of image and tag data written to newly-created files + can now be controlled on a per-file basis through a mode parameter + supplied when openening a file (``b'' to force Big-Endian byte order + and ``l'' to force Little-Endian byte order) +
    • the use memory-mapped files for images opened read-only can now + be controlled on a per-file basis through a mode parameter supplied + when opening a file (``M'' to enable use of memory-mapped files + and ``m'' to disable use) +
    • the use of the WIN32 define in tiffiop.h has + been replaced by __WIN32__ +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • fax2ps now does a save and restore + around each page of PostScript; this fixes a problem with VM + overflow when printing a many-page document on some printers +
    • a bug in the handling of 3-channel images by ras2tiff + was fixed +
    • tiffcp has new options to control the byte order of + newly created files: -B for Big-Endian byte order, -L + for Little-Endian byte order; a -M option to disable the + use of memory-mapped files, and a -C option to disable the + use of strip chopping +
    • bugs were fixed in tiffcp's handling of codec-specific tags +
    + +


    + +CHANGES IN THE MANUAL PAGES: + +
      +
    • the TIFFOpen page has been updated to reflect the new + optional open mode parameters +
    + +


    + +CHANGES IN THE CONTRIBUTED SOFTWARE: + +
      +
    • contrib/win95 contains information and code from Philippe Tenenhaus + <100423.3705@compuserve.com> + about using the software under Windows 95 +
    • contrib/winnt contains information and code from Dave Dyer + <ddyer@triple-i.com> + about using the software under Windows NT +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta029.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta029.html new file mode 100644 index 000000000..580cfc49c --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta029.html @@ -0,0 +1,87 @@ + + + + +Changes in TIFF v3.4beta029 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • configure now relativizes pathname references given in + -L options (as frequently specified when configuring + ancillary packages) +
    • problems related to configuring the software on Ultrix 4.4 have + been corrected +
    • the shell to use in Makefiles and scripts can now be set with the + SCRIPT_SH configuration parameter +
    • comments in config.site now correctly indicate how to setup the + use of ancillary packages +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • mods for building the software on a Mac using the + MetroWerks CodeWarrior compilers +
    • a bug in the CCITT T.4/T.6 decoder was fixed where the last codeword in + a strip/tile might not be decoded; this was seen only when decoding + multi-strip images +
    • a bug in the CCITT RLE codecs was fixed whereby the pseudo tags were not + being properly registered +
    + +


    + +CHANGES IN THE CONTRIBUTED SOFTWARE: + +
      +
    • contrib/mac-cw contains information and code from Niles Ritter + <ndr@tazboy.jpl.nasa.gov> + about building the software with the MetroWerks CodeWarrior compilers + on Macintosh systems +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta031.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta031.html new file mode 100644 index 000000000..2dff63494 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta031.html @@ -0,0 +1,95 @@ + + + + +Changes in TIFF v3.4beta031 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • configure now captures significantly more information + in the config.log file and provides more information when + it is unable to setup a configuration +
    • support was added for building shared libraries on more systems: + AIX, HPUX, Solaris, and Linux. +
    • a new configuration parameter LIBCOPTS was added for + passing arguments to the C compiler to use when building only + the library; this is part of the enhanced support for building + shared libraries +
    • include files for optional packages that reside in /usr/include + are now handled correctly +
    • build trees may now be configured using either relative or absolute + pathnames to the source distribution +
    • several new configuration parameters were added, mainly for building + shared libraries: DIST_MAJOR, DIST_MINOR, + DIST_ALPHA, and DSOSUF_VERSION +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • the Deflate support has been revised: it requires version 0.99 of + the zlib software distribution, the output format has changed and + is incompatible with previous versions of this library (each + strip now includes a header read and written by the zlib library) +
    • the codec name printed by the TIFFPrintDirectory routine is now + taken from the codec table instead of from a builtin table; this means + that application-defined codecs are handled correctly +
    • a new symbol was added that contains the library version number; + this can be used to do a compile-time compatibility check of the + library version +
    + +


    + +CHANGES IN THE MANUAL PAGES: + +
      +
    • the creation and installation of manual pages was redone; it now + implements the documented ``configuration scheme'' +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta032.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta032.html new file mode 100644 index 000000000..8ac2cc2d6 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta032.html @@ -0,0 +1,91 @@ + + + + +Changes in TIFF v3.4beta032 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • various fixups and subtle improvements to configure + from Richard Mlynarik +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • a new codec from Pixar designed for high-resolution color images; + note that this codec is not configured by default +
    • a bug fix for reading tags with a single FLOAT value +
    • change to the TIFFGetField calling convention: + a tag that has a single value of + type DOUBLE is now retrieved by passing a + ``double*'' instead of a + ``double**'' (this change makes the handling of tags with + DOUBLE values identical to the handling of tags with + FLOAT values) +
    • fix to VMS support for the handling of floating point values +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • tiffdump now handles tags with FLOAT and DOUBLE + values +
    + +


    + +CHANGES IN THE CONTRIBUTED SOFTWARE: + +
      +
    • updates to the Acorn OS support from Peter Greenham +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta033.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta033.html new file mode 100644 index 000000000..256b3f8e5 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta033.html @@ -0,0 +1,83 @@ + + + + +Changes in TIFF v3.4beta033 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • support was added for building the library as a DSO under OSF/1 +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • fixes to the Pixar codec +
    • portability mods for VMS +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • fixes to gif2tiff and ppm2tiff for building under MS/DOS +
    • portability mods to fax2ps and ycbcr for VMS +
    + +


    + +CHANGES IN THE CONTRIBUTED SOFTWARE: + +
      +
    • a new package from Alexander Lehmann + for building the library and tools under MS/DOS with DJGPP v2 +
    • updated VMS support from Karsten Spang +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta034.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta034.html new file mode 100644 index 000000000..33ca2f194 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta034.html @@ -0,0 +1,69 @@ + + + + +Changes in TIFF v3.4beta034 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • support was added for building the library as a DSO under NetBSD +
    • a bug was fixed in the DSO support for Linux +
    • the handling of version strings has changed slightly to simplify parsing +
    • a new parameter, TIFFLIBREF, was added to control how the + library is referenced when linking programs in the tools directory +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • DSO creation under Solaris now forces the DSO name with a -h option +
    • the interface to the mkversion program was changed + to eliminate the need to parse files +
    • a bug was fixed in the EOL-detection logic of the T.4/T.6 decoder +
    • ANSI IT8 TIFF/IT tag definitions were added to tiff.h +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta035.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta035.html new file mode 100644 index 000000000..51e4116c9 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta035.html @@ -0,0 +1,64 @@ + + + + +Changes in TIFF v3.4beta035 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • support was added installing the HTML documentation +
    • support was added for building the library as a DSO under FreeBSD +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • the interface to the mkversion program was restored to + the form used prior to v3.4beta034 +
    • several portability problems for 16-bit systems were fixed +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.4beta036.html b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta036.html new file mode 100644 index 000000000..91c2721f8 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.4beta036.html @@ -0,0 +1,118 @@ + + + + +Changes in TIFF v3.4beta036 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • support was added for building the library as a DSO under HP-UX with + the native C compiler +
    • tools are now built with explicit pathnames for the DSO under IRIX, + Solaris, and Linux +
    • DSO configuration support for Linux was changed to require that + libc.so only be readable (not executable) +
    + +


    + +CHANGES IN LIBTIFF: + +
      +
    • support was add for ICC: NumberOfInks, and ICCProfile +
    • a memory leak caused by doing TIFFSetDirectory(0) was fixed +
    • a bug was fixed whereby certain multi-directory files were not + properly handled when accessed by mapping the data into memory +
    • the strip chopping support is now always compiled + into the library with the default usage controlled by a + STRIPCHOP_DEFAULT configuration parameter +
    • the strip chopping support no longer chops tiled images +
    • all static strings are now const--for shared libraries +
    • the logic for estimating the strip size of images without + a StripByteCounts tag was improved by handling + PlanarContig images differently from PlanarSeparate +
    • a bug was fixed in the G3 codec when converting the Y resolution + of data specified in metric units +
    • a bug was fixed in the G3/G4 decoder for data where lines terminate + with a v0 code +
    • the TIFFRGBAImage support was changed to scale 16-bit colormap + entries more conservatively to avoid problems with applications + that do not generate fully saturated pixel values +
    • the LZW decoder was changed to use a more conservative scheme when + bounds checking the hash table array; this avoids pitfalls with + systems that load objects into memory in unusual locations +
    • a bug was fixed in TIFFPrintDirectory's handling of the + InkNames tag +
    • TIFFPrintDirectory now understands NumberOfInks + and ICC-related tags +
    • the routines for reading image data now provide more useful information + when a read error is encountered +
    • support was added for compiling with Microsoft Visual C++ 4.0 +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • a bug was fixed in pal2rgb's colormap handling +
    • tiff2ps now includes John Wehle's changes for maintaining + the aspect ratio + of images when scaling and for honoring the deadzone on a page when + generating PostScript Level II +
    • tiff2ps does a better job guarding against the mishandling + of greyscale images +
    • tiff2ps now correctly converts X- and Y-resolution values + specified in metric units +
    • tiffdump has a new -m option to control the maximum + number of indirect + data values printed for a tag (by default 24) +
    • tiffdump understands several new tags +
    • tiffdump now shows any terminating null in ASCII strings +
    • tiffinfo now suppresses strip chopping when interpreting an image; + a new -z option has been added to enable strip chopping +
    + + TIFF home page.
    + +
    + +
    +Sam Leffler / sam@engr.sgi.com +Last updated $Date: 2016-09-25 20:05:45 $. +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.5.1.html b/thirdparty/SDL2_image/external/libtiff/html/v3.5.1.html new file mode 100644 index 000000000..559f5496b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.5.1.html @@ -0,0 +1,76 @@ + + + + +Changes in TIFF v3.5.1 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • None of consequence +
    + +


    + +CHANGES IN LIBTIFF: + + +
      +
    • Support was added for IPTC Newsphoto metadata (TIFFTAGE_IPTCNEWSPHOTO) +
    • Support was added for photoshop caption handling (TIFFTAG_PHOTOSHOP) +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • Bill Radcliffe's iptcutil was +added to the "contrib" subdirectory . It can convert an IPTC binary +blob to ASCII text and vice-versa. The blob itself can be extracted +from or added to an image with the ImageMagick convert(1) +utility. +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.5.2.html b/thirdparty/SDL2_image/external/libtiff/html/v3.5.2.html new file mode 100644 index 000000000..2c4cbf510 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.5.2.html @@ -0,0 +1,109 @@ + + + + +Changes in TIFF v3.5.2 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    + +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • Corrected alpha versioning. + +
    • Removed distinction between alpha and release targets in Makefile.in. + +
    • Added release.stamp target, which tags cvs tree, and updates + "RELEASE-DATE" + +
    • Added releasediff target, which diffs tree with source as of + date in "RELEASE-DATE" + +
    • Ticked up version to 3.5.2 (alpha 01 -- but I think we'll moving + away from alpha/non-alpha distinctions). + +
    + +


    + +CHANGES IN LIBTIFF: + + +
      +
    • Added IRIX/gcc, and OSF/1 4.x support on behalf of + Albert Chin-A-Young + +
    • Added TIFFReassignTagToIgnore() API on behalf of + Bruce Cameron . Man page still pending. + +
    • pre-remove so link before softlink in LINUXdso action in + libtiff/Makefile.in to avoid failure on LINUXdso builds other than + the first. + +
    • Fixed problem with cvtcmap() in tif_getimage.c modifying the + colormaps owned by the TIFF handle itself when trying to fixup wrong + (eight bit) colormaps. Corrected by maintaining a private copy of + the colormap. + +
    • Added TIFFReadRGBATile()/TIFFReadRGBAStrip() support in + tif_getimage.c. + +
    • Applied "a" mode fix to tif_win32.c/TIFFOpen() as suggested + by Christopher Lawton + +
    • Set O_BINARY for tif_unix.c open() ... used on cygwin for instance. + +
    • Added CYGWIN case in configure. + +
    • Applied Francois Dagand's patch to handle fax decompression bug. + (sizes >= 65536 were failing) +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • Added addtiffo (add overviews to a TIFF file) in contrib. Didn't + put it in tools since part of it is in C++. +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.5.3.html b/thirdparty/SDL2_image/external/libtiff/html/v3.5.3.html new file mode 100644 index 000000000..0aabcaa8d --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.5.3.html @@ -0,0 +1,133 @@ + + + + +Changes in TIFF v3.5.3 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +The ChangeLog will follow, but please note the most important change: +LZW compression has been removed. +

    +Unisys has the patent on LZW compression and have been very active in +their enforcement of late, demanding payments of $5000 or more from +websites using unlicensed software to create GIF's. They could well +do the same do persons using libtiff to create LZW compressed TIFF +images. +

    +From Burn All GIF's Day: +
    +The catch is that it appears to be difficult or impossible to get a +Unisys license to use LZW in free software that complies with the Open +Source Definition +

    +Unfortunately, the removal of LZW compression means that saved image size has +grown dramatically. Without a change in the TIFF spec to support +another lossless compression format, this is unavoidable. +

    +The library can use zip for lossless compression, but as this is not +part of the spec, TIFFs using zip compression may not work with other +software +

    +We will be making a patch available that will contain the LZW +compression code for users who have either obtained a license from +Unisys or are willing to risk it. +

    +LZW decompression is unchanged. +

    +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • Added zip creation to release makefile target + + +
    + +


    + +CHANGES IN LIBTIFF: + + +
      + +
    • Added html for TIFFWriteTile.3t man page. + +
    • Added some changes to tif_write.c to support rewriting existing + fixed sized tiles and strips. Code mods disabled by default, only + enabled if REWRITE_HACK is defined for now. + +
    • Added TIFFWriteTile.3t man page. + +
    • Added notes on use of makefile.vc in build.html, and fixed + email subscription address. + +
    • Fixed apocalypse-inducing y2k bug in contrib/ras/ras2tiff.c + +
    • Did some casts cleaning up to reduce compiler warnings in tif_fax3.c, + from Bruce Carmeron -- modifications of + changes made by Frank (sun cc still complained on cast). + +
    • fixed various VC++ warnings as suggested by Gilles Vollant + . + +
    • Modified TIFFquery.3t man pages info on TIFFIsByteSwapped() to + not imply applications are responsible for image data swapping. + +
    • HTML-ized the man pages, added to html/man + +
    • Removed LZW Compression to comply with Unisys patent extortion. + +
    • Corrected one remaining 16 -> 32 bit value in tif_fax3.c, + From Ivo Penzar Added patch from Ivo Penzar to have TiffAdvanceDirectory handle + memory mapped files. +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • Fixed apocalypse-inducing y2k bug in contrib/ras/ras2tiff.c +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.5.4.html b/thirdparty/SDL2_image/external/libtiff/html/v3.5.4.html new file mode 100644 index 000000000..c9fdcf655 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.5.4.html @@ -0,0 +1,89 @@ + + + + +Changes in TIFF v3.5.4 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • None + + +
    + +


    + +CHANGES IN LIBTIFF: + + +
      + +
    • Added Pixar tag support. Contributed by Phil Beffery + +
    • Made one more change to tif_dir.c for removal of LZW compression. Also added notice + when LZW compression invoked. + +
    • Fixed bug that caused LZW (non) compression to segfault. Added + warning about LZW compression removed being removed, and why. + +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • Changed default compression in tools to TIFF_PACKBITS, and changed usage descriptions + in tools to reflect removal of LZW compression + +
    • Added nostrip to install in tools/Makefile.in so that debugging + symbols are kept. + +
    • Made Packbits the default compression in tools/tiff2rgba.c instead + of LZW. + + +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.5.5.html b/thirdparty/SDL2_image/external/libtiff/html/v3.5.5.html new file mode 100644 index 000000000..aa606fd10 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.5.5.html @@ -0,0 +1,156 @@ + + + + +Changes in TIFF v3.5.5 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • configure: added test for libc6 for linux targets. Bug reported by + Stanislav Brabec + +
    • configure: fixed bugs in sed scripts + (applied sed script s:/@:s;@:;s:/s;;:;: to configure). + fix submitted by Stanislav Brabec + +
    • tools/iptcutil was not in files list, and wasn't being + added to tar archive. Updated Makefile.in. + +
    • Added 3.5 docs to html/Makefile.in. + Thanks to Stanislav Brabec + +
    • Fixed tools/tiffcmp so that stopondiff testing works. + Patch care of Joseph Orost . + +
    • Added fax3sm_winnt.c to distribution list in Makefile.in. + +
    • Added libtiff/libtiff.def to TIFFILES distribution list. +
    + +


    + +CHANGES IN LIBTIFF: + + +
      +
    • tif_fax3.c: Fixed serious bug introduced during the uint16->uint32 + conversion for the run arrays. + +
    • Set td_sampleformat default to SAMPLEFORMAT_UINT instead of + SAMPLEFORMAT_VOID in TIFFDefaultDirectory() in tif_dir.c. + +
    • Added "GetDefaulted" support for TIFFTAG_SAMPLEFORMAT in tif_aux.c. + +
    • Patched tif_fax3.c so that dsp->runs is allocated a bit bigger + to avoid overruns encountered with frle_bug.tif. + + +
    • Modified tif_unix.c to support 2-4GB seeks if USE_64BIT_API is + set to 1, and added default (off) setting in tiffconf.h. This + should eventually be set by the configure script somehow. + + The original work on all these 2-4GB changes was done by + Peter Smith (psmith@creo.com). + +
    • Modified tif_win32.c to support 2-4GB seeks. + +
    • tentatively changed toff_t to be unsigned instead of signed to + facilitate support for 2-4GB files. + +
    • Updated a variety of files to use toff_t. Fixed some mixups + between toff_t and tsize_t. + +
    • Set tif_rawdatasize to zero when freeing raw data buffer in + TIFFWriteDirectory(). + +
    • Enabled "REWRITE_HACK" in tif_write.c by default. + +
    • Fix bug in tif_write.c when switching between reading one directory + and writing to another. + +
    • Made TIFFWriteCheck() public, and added TIFFCreateDirectory() + +
    • Added TIFFmemory(3t) functions to libtiff.def. + +
    • Added libtiff/libtiff.def to TIFFILES distribution list. +
    + +


    + +CHANGES IN THE TOOLS: + +
      +
    • fax2ps: Fixed mixup of width and height in bounding box statement + as per submission by Nalin Dahyabhai . + +
    • fax2ps: Modified printruns to take uint32 instead of uint16. + Patch courtesy of Bernt Herd + + +
    • Largely reimplemented contrib/addtiffo to avoid temp files, + updating the TIFF file in place. Fixed a few other bugs to. + +
    • Altered descriptions in tools to reflect "by default" lzw not supported +
    + +


    + +CHANGES IN THE LZW COMPRESSION KIT +
      +
    • created mangle-src.sh -- sed scripts to munge src into LZW enabled format. Thanks to Stanislav Brabec + +
    • created Makefile + +
    • merged tif_dir.c with current source. + + +
    • Created lzw compression kit, as a new CVS module (libtiff-lzw-compression-kit). + +
    • Updated index.html to note lzw compression kit. + +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.5.6-beta.html b/thirdparty/SDL2_image/external/libtiff/html/v3.5.6-beta.html new file mode 100644 index 000000000..81f11a362 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.5.6-beta.html @@ -0,0 +1,186 @@ + + + + +Changes in TIFF v3.5.6 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • Added GNULDdso target and switched linux and freebsd to use it. +
    • tools/Makefile.in: Modified to install properly on SGI. +
    • configure: Fixed DSO test for Linux as per patch from + Jan Van Buggenhout . + +
    + +


    + +CHANGES IN LIBTIFF: + + +
      + +
    • tif_dir.c: Clear TIFF_ISTILED flag in TIFFDefaultDirectory + as per http://bugzilla.remotesensing.org/show_bug.cgi?id=18 + from vandrove@vc.cvut.cz. + +
    • Modified tif_packbits.c decoding to avoid overrunning the + output buffer, and to issue a warning if data needs to be + discarded. See http://bugzilla.remotesensing.org/show_bug.cgi?id=18 + +
    • Modified TIFFClientOpen() to emit an error on an attempt to + open a comperessed file for update (O_RDWR/r+) access. This is + because the compressor/decompressor code gets very confused when + the mode is O_RDWR, assuming this means writing only. See + bug http://bugzilla.remotesensing.org/show_bug.cgi?id=13 + +
    • Applied patch for 0x0000 sequences in tif_fax3.h's definition + of EXPAND1D() as per bug 11 (from Roman). + +
    • Fixed tiffcomp.h to avoid win32 stuff if unix #defined, to improve + cygwin compatibility. + +
    • Applied patch from Roman Shpount to tif_fax3.c. This seems to + be a proper fix to the buffer sizing problem. See + http://bugzilla.remotesensing.org/show_bug.cgi?id=11 + +
    • Fixed tif_getimage.c to fix overrun bug with YCbCr images without + downsampling. http://bugzilla.remotesensing.org/show_bug.cgi?id=10 + Thanks to Nick Lamb for reporting the + bug and proving the patch. + +
    • Fixed tif_jpeg.c so avoid destroying the decompressor before + we are done access data thanks to bug report from: + Michael Eckstein . + +
    • tif_open.c: Don't set MMAP for O_RDWR files. + +
    • tif_open.c: Set STRIPCHOP_DEFAULT for O_RDWR as well as O_RDONLY + so that files opened for update can be strip chopped too. + +
    • tif_read.c: fixed up bug with files missing rowsperstrip and + the strips per separation fix done a few weeks ago. + +
    • Tentatively added support for SAMPLEFORMAT_COMPLEXIEEEFP, and + SAMPLEFORMAT_COMPLEXINT. + +
    • index.html, bugs.html: added bugzilla info. + +
    • tif_read.c: fix subtle bug with determining the number of + rows for strips that are the last strip in a separation but + not the last strip of all in TIFFReadEncodedStrip(). + +
    • Applied 16/32 bit fix to tif_fax3.c. Fix supplied by + Peter Skarpetis + +
    • Modified tiffio.h logic with regard to including windows.h. It + won't include it when building with __CYGWIN__. + +
    • README: update to mention {REDACTED - defunct web site}, don't list Sam's old + email address. + +
    • libtiff/tif_dirread.c: Don't use estimate strip byte count for + one tile/strip images with an offset, and byte count of zero. These + could be "unpopulated" images. + +
    • tif_win32.c: Applied patch to fix overreads and ovverwrites + caught by BoundsChecker. From Arvan Pritchard + (untested). + +
    • tif_getimage.c: Applied patch to silence VC6 warnings. From + Arvan Pritchard + +
    • tif_lzw.c: Applied patch to silence VC6 warnings. From + Arvan Pritchard + +
    • libtiff/tif_apple.c: Applied "Carbon" support patches supplied by + Leonard Rosenthol . May interfere + with correct building on older systems. If so, please let me know. + + +
    + +


    + +CHANGES IN THE TOOLS: + +
      + +
    • tools/rgb2ycbcr.c: fixed output strip size to account for vertical + roundup if rows_per_strip not a multiple of vertical sample size. + +
    • tools/tiffsplit.c: Copy TIFFTAG_SAMPLEFORMAT. + +
    • Modified tiff2bw to ensure portions add to 100%, and that + white is properly recovered. See bug + http://bugzilla.remotesensing.org/show_bug.cgi?id=15 Patch + c/o Stanislav Brabec + +
    + +


    + +CHANGES IN CONTRIB: + +
      + +
    • contrib/addtiffo: Added "averaging" resampling option. + +
    • Added contrib/stream (stream io) code submitted by Avi Bleiweiss. + +
    + +


    + +CHANGES IN THE LZW COMPRESSION KIT +
      + +
    • updated tif_dir.c to reflect changes to no-lzw tif_dir.c + +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.5.7.html b/thirdparty/SDL2_image/external/libtiff/html/v3.5.7.html new file mode 100644 index 000000000..a58b7e5a6 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.5.7.html @@ -0,0 +1,260 @@ + + + + +Changes in TIFF v3.5.7 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • libtiff/libtiff.def: Brent Roman submitted new version adding +serveral missing entry points. Also add a few other entry points +later. + +
    • configure, Makefile.in, etc: added support for OPTIMIZER being + set from config.site. +
    • config.guess: updated wholesale to an FSF version apparently + from 1998 (as opposed to 1994). This is mainly inspired by + providing for MacOS X support. + +
    • configure/config.site: modified to check if -lm is needed for + MACHDEPLIBS if not supplied by config.site. Needed for Darwin. +
    • libtiff/tiff.h: Applied hac to try and resolve the problem + with the inttypes.h include file on AIX. (Bug 39) + +
    • configure, *Makefile.in: Various changes to improve configuration + for HP/UX specifically, and also in general. (Bug 40) They include: +
        +
      • Try to handle /usr/bin/sh instead of /bin/sh where necessary. +
      • Upgrade to HP/UX 10.x+ compiler, linker and dso options. +
      • Fixed mmap() test to avoid MMAP_FIXED ... it isn't available on HP +
      • Use -${MAKEFLAGS} in sub makes from makefiles. +
      • Fixed SCRIPT_SH/SHELL handling. +
      +
    • configure: Changes for DSO generation on AIX provided by + John Marquart . + +
    • configure, libtiff/Makefile.in: Modified to build DSOs properly + on Darwin thanks to Robert Krajewski (rpk@alum.mit.edu) and + Keisuke Fujii (fujiik@jlcuxf.kek.jp). + +
    • configure, libtiff/Makefile.in: applied OpenBSD patches as per bug 61. + +
    • Makefile.in: added DESTDIR support as per bug 60. + +
    • libtiff/tif_jpeg.c: Define HAVE_BOOLEAN on windows if RPCNDR.H + has been included. +
    • man/Makefile.in: add TIFFClientOpen link as per debian submitted + bug 66. +
    • libtiff/Makefile.in: Fixed @DSOSUB_VERSION to be @DSOSUF_VERSION@ + in two places. +
    + +


    + + + +CHANGES IN LIBTIFF: + + +
      +
    • tif_fax3.c: keep rw_mode flag internal to fax3 state to remember + whether we are encoding or decoding. This is to ensure graceful + recovery if TIFFClientOpen() discovers an attempt to open a compressed + file for "r+" access, and subsequently close it, as it resets the + tif_mode flag to O_RDONLY in this case to avoid writes, confusing the + compressor's concept of whether it is in encode or decode mode. +
    • tif_luv.c/tiff.h/tiffio.h: + New version of TIFF LogLuv (SGILOG) modules contributed by Greg Ward + (greg@shutterfly.com). He writes: + +
        +
      1. I improved the gamut-mapping function in tif_luv.c for imaginary + colors, because some images were being super-saturated on the input + side and this resulted in some strange color shifts in the output. + +
      2. I added a psuedotag in tiff.h to control random dithering during + LogLuv encoding. This is turned off by default for 32-bit LogLuv and + on for 24-bit LogLuv output. Dithering improves the average color + accuracy over the image. + +
      3. I added a #define for LOG_LUV_PUBLIC, which is enabled by default in + tiffio.h, to expose internal routines for converting between LogLuv and + XYZ coordinates. This is helpful for writing more efficient, + specialized conversion routines, especially for reading LogLuv files. +
      + +
    • libtiff/tif_dirinfo.c: don't declare tiffFieldInfo static on VMS. + +
    • Added TIFFTAG_COPYRIGHT support. +
    • tif_getimage.c: Added support for 16bit minisblack/miniswhite + images in RGBA interface. +
    • libtiff/tif_dirinfo.c: removed duplicate TIFFTAG_PHOTOSHOP as per + bug 44. +
    • libtiff/tif_dirwrite.c: Added support for TIFF_VARIABLE2 in the + case of writing TIFF_BYTE/TIFF_SBYTE fields as per bug 43. + +
    • libtiff/tif_dirinfo.c: Modified the TIFF_BYTE definition for + TIFFTAG_PHOTOSHOP to use a writecount of TIFF_VARIABLE2 (-3) to + force use of uint32 counts instead of short counts. + +
    • libtiff/tif_dirinfo.c: moved pixar and copyright flags to + ensure everything is in order. + +
    • Integrated experimental OJPEG support from Scott Marovich of HP. + +
    • libtiff/tif_open.c: Seek back to zero after failed read, + before writing header. + +
    • libtiff/tiff.h, libtiff/tif_fax3.c: added check for __LP64__ + when checking for 64 bit architectures as per bugzilla bug 67. +
    • libtiff/tif_getimage.c: Use memmove() instead of TIFFmemcpy() + in TIFFReadRGBATile() to avoid issues in cases of overlapping + buffers. See Bug 69 in Bugzilla. +
    • libtiff/tif_getimage.c: Don't complain for CMYK (separated) + images with more than four samples per pixel as per bug 73. + +
    • libtiff/tif_getimage.c: relax handling of contig case where +there are extra samples that are supposed to be ignored as per bug 75. This +should now work for 8bit greyscale or palletted images. + +
    • libtiff/tif_packbits.c: fixed memory overrun error as per bug 77. + +
    • libtiff/tif_getimage.c: Fixed problem with reading strips or +tiles that don't start on a tile boundary. Fix contributed by +Josep Vallverdu (from HP), and further described in bug 47. + +
    • libtif/tif_fax3.c: Removed #ifdef PURIFY logic, and modified to + always use the "safe" version, even if there is a very slight + cost in performance as per bug 54. +
    • libtiff/tif_lzw.c: added dummy LZWSetupEncode() to report an + error about LZW not being available. + +
    • libtiff/tif_dir.c: propagate failure to initialize compression + back from TIFFSetField() as an error status, so applications can + detect failure. + +
    • libtiff/tif_lzw.c: Avoid MS VC++ 5.0 optimization bug as per bug 78. + +
    • libtiff/tif_dirwrite.c: added TIFFRewriteDirectory() function. +Updated TIFFWriteDirectory man page to include TIFFRewriteDirectory. + +
    • libtiff/tiff.h: I have created COMPRESSION_CCITT_T4, + COMPRESSION_CCITT_T6, TIFFTAG_T4OPTIONS and TIFFTAG_T6OPTIONS aliases + in keeping with TIFF 6.0 standard in tiff.h as per bug 83. + +
    • Added PHOTOMETRIC_ITULAB as per bug 90. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      +
    • Brent Roman contributed updated tiffcp utility (and tiffcp.1) + with support for extracting subimages with the ,n syntax, and also + adding the -b bias removal flag. +
    • tiff2ps.c/tiff2ps.1: Substantial changes to tiff2ps by + Bruce A. Mallett, including a faster encoder, fixes for level + 2 PostScript, and support for the imagemask operator. +
    • fax2ps.c: Helge (libtiff at oldach.net) submitted fix +that corrects behaviour for non-Letter paper +sizes. (Bug 35) It fixes two problems: +
      + Without scaling (-S) the fax is now centered on the page size specified + with -H and/or -W. Before, fax2ps was using an obscure and practically + useless algorithm to allocate the image relative to Letter sized paper + which sometime sled to useless whitespace on the paper, while at the + same time cutting of the faxes printable area at the opposite border. +
      + + Second, scaling now preserves aspect ratio, which makes unusual faxes + (in particular short ones) print properly. + +
    • thumbnail.c: changed default output compression + to packbits from LZW since LZW isn't generally available. +
    • tiff2rgba.c: added -n flag to avoid emitting alpha component. Also added +a man page for tiff2rgba. + +
    • tiffcmp.c: Fixed multi samples per pixel support for ContigCompare +as per bug 53. +Updated bug section of tiffcmp.1 to note tiled file issues. + +
    • libtiff/tif_getimage.c: Fixed so that failure is properly + reported by gtTileContig, gtStripContig, gtTileSeparate and + gtStripSeparate as per bug 51. + + +
    + +


    + + + +CHANGES IN THE LZW COMPRESSION KIT: +
      +
    • Rewrote lzw patching process so that is required to enable full + LZW support is to drop the tif_lzw.c from the + libtiff-lzw-compression-kit over the one in the libtiff directory. + +
    • Some changes were made to make recovery from failure to + initialize the LZW compressor more graceful. + +
    • Note that as distributed libtiff support LZW decompression, but + not LZW compression. +
    + + + +CHANGES IN THE CONTRIB AREA: +
      +
    • Fixed distribution to include contrib/addtiffo/tif_ovrcache.{c,h}. +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.6.0.html b/thirdparty/SDL2_image/external/libtiff/html/v3.6.0.html new file mode 100644 index 000000000..1a3ba4a93 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.6.0.html @@ -0,0 +1,435 @@ + + + + +Changes in TIFF v3.6.0 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • New utility raw2tiff +for converting raw rasters into TIFF files. +
    • Lots of new tiff2ps options. +
    • Lots of new fax2tiff options. +
    • Lots of bug fixes for LZW, JPEG and OJPEG compression. +
    + +

    Custom Tag Support

    + +The approach to extending libtiff with custom tags has changed radically. +Previously, all internally supported TIFF tags had a place in the +private TIFFDirectory structure within libtiff to hold the values (if read), +and a "field number" (ie. FIELD_SUBFILETYPE) used to identify that tag. +However, every time a new tag was added to the core, the size of the +TIFFDirectory structure would changing, breaking any dynamically linked +software that used the private data structures.

    + +Also, any tag not recognised +by libtiff would not be read and accessible to applications without some +fairly complicated work on the applications part to pre-register the tags +as exemplified by the support for "Geo"TIFF tags by libgeotiff layered on +libtiff.

    + +Among other things this approach required the extension code +to access the private libtiff structures ... which made the higher level +non-libtiff code be locked into a specific version of libtiff at compile time. +This caused no end of bug reports!

    + +The new approach is for libtiff to read all tags from TIFF files. Those that +aren't recognised as "core tags" (those having an associated FIELD_ value, +and place for storage in the TIFFDirectory structure) are now read into a +dynamic list of extra tags (td_customValues in TIFFDirectory). When a new +tag code is encountered for the first time in a given TIFF file, a new +anonymous tag definition is created for the tag in the tag definition list. +The type, and some other metadata is worked out from the instance encountered. +These fields are known as "custom tags".

    + +Custom tags can be set and fetched normally using TIFFSetField() and +TIFFGetField(), and appear pretty much like normal tags to application code. +However, they have no impact on internal libtiff processing (such as +compression). Some utilities, such as tiffcp will now copy these custom +tags to the new output files.

    + +As well as the internal work with custom tags, new C API entry points +were added so that extension libraries, such as libgeotiff, could +define new tags more easily without accessing internal data structures. +Because tag handling of extension tags is done via the "custom fields" +mechanism as well, the definition provided externally mostly serves to provide +a meaningful name for the tag. + +The addition of "custom tags" and the altered approach to extending libtiff +with externally defined tags is the primary reason for the shift to the +3.6.x version number from 3.5.x.

    + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • configure, config.site: Fix for large files (>2GiB) support. New +option in the config.site: LARGEFILE="yes". Should be enougth for the large +files I/O. + +
    • configure: Set -DPIXARLOG_SUPPORT option along with -DZIP_SUPPORT. + +
    • html/Makefile.in: Updated to use groffhtml for generating html pages +from man pages. + +
    • configure, libtiff/Makefile.in: Added SCO OpenServer 5.0.6 support +from John H. DuBois III. + +
    • libtiff/{Makefile.vc, libtiff.def}: Missed declarations added. + +
    • libtiff/Makefile.in, tools/Makefile.in: Shared library will not be +stripped when installing, utility binaries will do be stripped. As per bug 93. + +
    • man/Makefile.in: Patch DESTDIR handling as per bug 95. + +
    • configure: OpenBSD changes for Sparc64 and DSO version as per bug 96. + +
    • config.site/configure: added support for OJPEG=yes option to enable +OJPEG support from config.site. + +
    • config.guess, config.sub: Updated from ftp.gnu.org/pub/config. + +
    • configure: Modify CheckForBigEndian so it can work in a cross +compiled situation. + +
    • configure, libtiff/Makefile.in: Changes for building on MacOS 10.1 +as per bug 94. + +
    • html/Makefile.in: added missing images per bug 92. + +
    • port/Makefile.in: fixed clean target per bug 92. +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • libtiff/tif_getimage.c: New function TIFFReadRGBAImageOriented() +implemented to retrieve raster array with user-specified origin position. + +
    • libtiff/tif_fax3.c: Fix wrong line numbering. + +
    • libtiff/tif_dirread.c: Check field counter against number of fields. + +
    • Store a list of opened IFD to prevent directory looping. + +
    • libtiff/tif_jpeg.c: modified segment_height calculation to always +be a full height tile for tiled images. Also changed error to just +be a warning. + +
    • libtiff/tif_lzw.c: fixed so that decoder state isn't allocated till +LZWSetupDecode(). Needed to read LZW files in "r+" mode. + +
    • libtiff/tif_dir.c: fixed up the tif_postdecode settings responsible +for byte swapping complex image data. + +
    • libtiff/tif_open.c: Removed error if opening a compressed file +in update mode bug (198). + +
    • libtiff/tif_write.c: TIFFWriteCheck() now fails if the image is +a pre-existing compressed image. That is, image writing to pre-existing +compressed images is not allowed. + +
    • html/man/*.html: Web pages regenerated from man pages. + +
    • libtiff/tif_jpeg.c: Hack to ensure that "boolean" is defined properly +on Windows so as to avoid the structure size mismatch error from libjpeg +(bug 188). + +
    • libtiff/tiff.h: #ifdef USING_VISUALAGE around previous Visual Age +AIX porting hack as it screwed up gcc. (bug 39) + +
    • libtiff/tiff.h: added COMPRESSION_JP2000 (34712) for LEAD tools +custom compression. + +
    • libtiff/tif_dirread.c: Another fix for the fetching SBYTE arrays +by the TIFFFetchByteArray() function. (bug 52) + +
    • libtiff/tif_dirread.c: Expand v[2] to v[4] in TIFFFetchShortPair() +as per bug 196. + +
    • libtiff/tif_lzw.c: Additional consistency checking added in +LZWDecode() and LZWDecodeCompat() fixing bugs 190 and 100. + +
    • libtiff/tif_lzw.c: Added check for valid code lengths in LZWDecode() +and LZWDecodeCompat(). Fixes bug 115. + +
    • tif_getimage.c: Ensure that TIFFRGBAImageBegin() returns the +return code from the underlying pick function as per bug 177. + +
    • libtiff/{tif_jpeg.c,tif_strip.c,tif_print.c}: Hacked tif_jpeg.c to +fetch TIFFTAG_YCBCRSUBSAMPLING from the jpeg data stream if it isn't +present in the tiff tags as per bug 168. + +
    • libtiff/tif_jpeg.c: Fixed problem with setting of nrows in +JPEGDecode() as per bug 129. + +
    • libtiff/tif_read.c, libtiff/tif_write.c: TIFFReadScanline() and +TIFFWriteScanline() now set tif_row explicitly in case the codec has +fooled with the value as per bug 129. + +
    • libtiff/tif_ojpeg.c: Major upgrade from Scott. Details in bug 156. + +
    • libtiff/tif_open.c: Pointers to custom procedures +in TIFFClientOpen() are checked to be not NULL-pointers. + +
    • libtiff/tif_lzw.c: Assertions in LZWDecode and LZWDecodeCompat +replaced by warnings. Now libtiff should read corrupted LZW-compressed +files by skipping bad strips as per bug 100. + +
    • libtiff/: tif_dirwrite.c, tif_write.c, tiffio.h: +TIFFCheckpointDirectory() +routine added as per bug 124. The +TIFFWriteDirectory +man page discusses this new function as well as the related +TIFFRewriteDirectory(). + +
    • libtiff/: tif_codec.c, tif_compress.c, tiffiop.h, tif_getimage.c: +Introduced +additional members tif->tif_decodestatus and tif->tif_encodestatus +for correct handling of unconfigured codecs (we should not try to read +data or to define data size without correct codecs). See bug 119. + +
    • tif_dirread.c: avoid div-by-zero if rowbytes is zero in chop func as +per bug 111. + +
    • libtiff/: tiff.h, tif_dir.c, tif_dir.h, tif_dirinfo.c, tif_dirread.c, +tif_dirwrite.c: Dwight Kelly added get/put code for new tag XMLPACKET as +defined in Adobe XMP Technote. Added missing INKSET tag value from TIFF 6.0 +spec INKSET_MULTIINK (=2). Added missing tags from Adobe TIFF technotes: +CLIPPATH, XCLIPPATHUNITS, YCLIPPATHUNITS, OPIIMAGEID, OPIPROXY and +INDEXED. Added PHOTOMETRIC tag value from TIFF technote 4 ICCLAB (=9). + +
    • libtiff/tif_getimage.c: Additional check for supported codecs added in +TIFFRGBAImageOK, TIFFReadRGBAImage, TIFFReadRGBAStrip and TIFFReadRGBATile now +use TIFFRGBAImageOK before reading a per bug 110. + +
    • libtiff/: tif_dir.c, tif_dir.h, tif_dirinfo.c, tif_dirread.c, +tif_dirwrite.c: Added routine +TIFFDataWidth for determining +TIFFDataType sizes instead of working with tiffDataWidth array +directly as per bug 109. + +
    • libtiff/: tif_dirinfo.c, tif_dirwrite.c: Added possibility to +read broken TIFFs with LONG type used for TIFFTAG_COMPRESSION, +TIFFTAG_BITSPERSAMPLE, TIFFTAG_PHOTOMETRIC as per bug 99. + +
    • libtiff/{tiff.h,tif_fax3.c}: Add support for __arch64__ as per bug 94. + +
    • libtiff/tif_read.c: Fixed TIFFReadEncodedStrip() to fail if the +decodestrip function returns anything not greater than zero as per bug 97. + +
    • libtiff/tif_jpeg.c: fixed computation of segment_width for +tiles files to avoid error about it not matching the +cinfo.d.image_width values ("JPEGPreDecode: Improper JPEG strip/tile +size.") for ITIFF files. Apparently the problem was incorporated since +3.5.5, presumably during the OJPEG/JPEG work recently. + +
    • libtiff/tif_getimage.c: If DEFAULT_EXTRASAMPLE_AS_ALPHA is 1 +(defined in tiffconf.h - 1 by default) then the RGBA interface +will assume that a fourth extra sample is ASSOCALPHA if the +EXTRASAMPLE value isn't set for it. This changes the behaviour of +the library, but makes it work better with RGBA files produced by +lots of applications that don't mark the alpha values properly. +As per bugs 93 and 65. + +
    • libtiff/tif_jpeg.c: allow jpeg data stream sampling values to +override those from tiff directory. This makes this work with +ImageGear generated files. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tiff2ps: Added page size setting +when creating PS Level 2. + +
    • tiff2ps: Fixed PS comment emitted when +FlateDecode is being used. + +
    • tiffsplit: increased the maximum +number of pages that can be split. + +
    • raw2tiff: Added option `-p' to +explicitly select color space of input image data. + +
    • tiffmedian: Suppiort for large +(> 2GB) images. + +
    • ppm2tiff: Fixed possible endless loop. + +
    • tiff2rgba: Switched to use +TIFFReadRGBAImageOriented() +instead of TIFFReadRGBAImage(). + +
    • tiffcmp: Fixed problem with unused data +comparing (bug 349). `-z' option now can be used to set the number of reported +different bytes. + +
    • tiffcp: Added possibility to specify +value -1 to -r option to get the entire image as one strip (bug 343). + +
    • tiffcp: Set the correct RowsPerStrip +and PageNumber values (bug 343). + +
    • fax2tiff: Page numbering fixed (bug +341). + +
    • ppm2tiff: PPM header parser improved: +now able to skip comments. + +
    • tiff2ps: Force deadzone printing when +EPS output specified (bug 325). + +
    • tiff2ps: Add ability to generate +PS Level 3. It basically allows one to use the /flateDecode filter for ZIP +compressed TIFF images. Patch supplied by Tom Kacvinsky (bug 328). + +
    • tiffcp: Fixed problem with colorspace +conversion for JPEG encoded images (bugs 23 and 275) + +
    • fax2tiff: Applied patch from +Julien Gaulmin. More switches for fax2tiff tool for better control +of input and output (bugs 272 and 293). + +
    • raw2tiff: +New utility for turning raw raster images into TIFF files +written by Andrey Kiselev. + +
    • tiff2ps: +Sebastian Eken provided patches (bug 200) to add new these new +switches: +
        +
      • -b #: for a bottom margin of # inches +
      • -c: center image +
      • -l #: for a left margin of # inches +
      • -r: rotate the image by 180 degrees +
      + +Also, new features merged with code for shrinking/overlapping. + +
    • tiff2ps: Don't emit BeginData/EndData +DSC comments since we are unable to properly include the amount to skip +as per bug 80. + +
    • tiff2ps: Added workaround for some +software that may crash when last strip of image contains fewer number +of scanlines than specified by the `/Height' variable as per bug 164. + +
    • tiff2ps: Patch from John Williams to add new +functionality for tiff2ps utility splitting long images in several pages as +per bug 142. New switches: +
        +
      • -H #: split image if height is more than # inches +
      • -L #: overLap split images by # inches +
      + +
    • tiff2ps: New commandline +switches to override resolution units obtained from the input file per bug 131: +
        +
      • -x: override resolution units as centimeters +
      • -y: override resolution units as inches +
      + +
    • fax2tiff: Updated to reflect +latest changes in libtiff per bug 125. + +
    • tiff2ps: Division by zero fixed as per bug 88. + +
    • tiffcp: +Added support for 'Orientation' tag. + +
    • tiffdump: +include TIFFTAG_JPEGTABLES in tag list. + +
    • tiffset: fix bug in error reporting. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: +
      + +
    • Fixed distribution to include contrib/addtiffo/tif_ovrcache.{c,h}. +
    • libtiff/contrib/win95: renamed to contrib/win_dib. Added new +Tiffile.cpp example of converting TIFF files into a DIB on Win32 as per +bug 143. + +
    + + + +CHANGES IN THE LZW COMPRESSION +KIT: +
      + +
    • LZW compression kit synchronized with actual libtiff version. + +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.6.1.html b/thirdparty/SDL2_image/external/libtiff/html/v3.6.1.html new file mode 100644 index 000000000..6a357f4c9 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.6.1.html @@ -0,0 +1,200 @@ + + + + +Changes in TIFF v3.6.1 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + + + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • libtiff/makefile.vc, tools/makefile.vc: Support for IJG JPEG library. + +
    • Makefile.in: Add an absolute path to the test_pics.sh call. + +
    • Makefile.in: Add an absolute path to the test_pics.sh call. + +
    • libtiff/tiffcomp.h: #define _BSDTYPES_DEFINED when defining BSD typedefs. + +
    • configure, libtiff/{Makefile.in, mkversion.c}: Relative buildings fixed. + +
    • Makefile.in: Add an absolute path to the test_pics.sh call. + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • libtiff/{tif_color.c, tif_getimage.c, tiffio.h}: Added support +for ReferenceBlackWhite tag handling when converted from YCbCr color space as +per bug 120. + +
    • libtiff/{tif_getimage.c, tif_aux.c}: Read WhitePoint tag from the +file and properly use it for CIE Lab 1976 to RGB transform. + +
    • libtiff/{tif_getimage.c, tiffio.h}: Finally resolved problems with +orientation handling. TIFFRGBAImage interface now properly supports all +possible orientations, i.e. images will be flipped both in horizontal and +vertical directions if required. 'Known bugs' section now removed from the +appropriate manual pages. + +
    • libtiff/tif_luv.c: Fixed bug in 48-bit to 24-bit conversion routine, +reported by Antonio Scuri. + +
    • libtiff/{tiffio.h, tif_codec.c}: Added new function +TIFFIsCODECConfigured(), suggested by Ross Finlayson. + +
    • libtiff/tif_ojpeg.c: TIFFVGetField() function now can properly extract +the fields from the OJPEG files. Patch supplied by Ross Finlayson. + +
    • libtiff/tif_dir.h: _TIFFFindOrRegisterdInfo declaration replaced +with _TIFFFindOrRegisterFieldInfo as reported by Ross Finlayson. + +
    • libtiff/tif_dirinfo.c: Implemented binary search in _TIFFMergeFieldInfo(). +Patch supplied by Ross Finlayson. + +
    • tif_dirread.c: do not mark all anonymously defined tags to be IGNOREd (as +it was done in 3.6.0). + +
    • libtiff/{tiff.h, tif_dirinfo.c}: Added support for IFD (13) datatype, +introduced in "Adobe PageMaker TIFF Technical Notes". + +
    • libtiff/{tif_color.c, tif_getimage.c, tiffio.h}: New color space +conversion code: CIE L*a*b* 1976 images now supported by the TIFFRGBAImage +interface. YCbCr to RGB conversion code also moved there and now has +publicly available interface. These +routines currently used in TIFFRGBAImage interface only and not supported in +other libtiff tools yet. So if you want, for example, to convert CIE Lab image +into PostScript file you should do it in two steps: chnge colorspace to RGB +using tiff2rgba utility abd then process +it with the tiff2ps. + +
    • libtiff/tif_tile.c: Remove spurious use of "s" (sample) in the +planarconfig_contig case in TIFFComputeTile() as per bug 387 + +
    • libtiff/tiffiop.h: New macros: TIFFmax and TIFFmin. + +
    • libtiff/{tiffio.h, tif_strip.c}: Added TIFFRawStripSize() function +as suggested by Chris Hanson. + +
    • libtiff/{tif_lzw.c, tif_fax3.c}: Proper support for update mode +as per bug 424. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tiff2pdf: New tool, written by +Ross Finlayson, to directly convert TIFF files to PDF. + +
    • tiffgt: Unmaintained and platform +dependent sgigt utility removed and replaced with the completely rewritten +portable tiffgt tool (depend on OpenGL and +GLUT). This tool will not build by default. + +
    • ras2tiff: Properly determine +SUN Rasterfiles with the reverse byte order (it is reported by the magic +header field). Problem reported by Andreas Wiesmann. + +
    • raw2tiff: Implemented image size +guessing using correlation coefficient calculation between two neighbour +lines. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: +
      + +
    • contrib/pds/{tif_pdsdirread.c, tif_pdsdirwrite.c}: Use TIFFDataWidth() +function insted of tiffDataWidth array. + +
    + + + +CHANGES IN THE LZW COMPRESSION +KIT: +
      + +
    • Proper support for update mode as per bug 424. + +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.7.0.html b/thirdparty/SDL2_image/external/libtiff/html/v3.7.0.html new file mode 100644 index 000000000..9c0819a42 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.7.0.html @@ -0,0 +1,145 @@ + + + + + Changes in TIFF v3.7.0 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • Several bugs found after 3.7.0beta2 release were fixed. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • ltmain.sh: Fix for MinGW compilation. +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • libtiff/{tif_dirread.c, tif_jpeg.c, tif_luv.c, tif_ojpeg.c, + tif_pixarlog.c, tif_write.c}: Handle the zero strip/tile sizes + properly (Dmitry V. Levin, Marcus Meissner). + +
    • libtiff/tif_dirinfo.c: Type of the TIFFTAG_SUBIFD field changed + to TIFF_IFD. + +
    • Preliminary support for BigTIFF files: now libtiff can + recognize and reject to open such images. ;-) + +
    • libtiff/tif_dir.c: Initialize td_tilewidth and td_tilelength fields + of the TIFFDirectory structure with the 0 instead of -1 to avoid + confusing integer overflows in TIFFTileRowSize() for striped images. + +
    • libtiff/tif_dir.c: Initialize td_tilewidth and td_tilelength fields + of the TIFFDirectory structure with the 0 instead of -1 to avoid + confusing integer overflows in TIFFTileRowSize() for striped images. + +
    • libtiff/tif_dirinfo.c: Fix bug with tif_foundfield and reallocation + of tif_fieldinfo as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=630 + +
    • libtiff/tif_compress.c: Improved error reporting in + TIFFGetConfiguredCODECs() (Dmitry V. Levin). + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      +
    • tiffcmp.c (leof): Renamed from 'eof' in order to avoid + conflict noticed under MinGW. + +
    • tiff2pdf.c: Fixed TransferFunction tag handling reported + by Ross A. Finlayson. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • No changes. + +
    + + + +CHANGES IN THE LZW COMPRESSION +KIT: +
      + +
    • This one is not longer needed. + +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.7.0alpha.html b/thirdparty/SDL2_image/external/libtiff/html/v3.7.0alpha.html new file mode 100644 index 000000000..39b63238b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.7.0alpha.html @@ -0,0 +1,250 @@ + + + + + Changes in TIFF v3.7.0alpha + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • Significant changes in software configuration: we are switched + to GNU autotools now. + +
    • tiffset: tiffset now can set any libtiff supported tags. Tags + can be supplied by the mnemonic name or number. +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • Get rid of the old configuration system and switch to + GNU autotools. +
    + +


    + + + +CHANGES IN LIBTIFF: + + + +


    + + + +CHANGES IN THE TOOLS: + +
      +
    • tiffset: tiffset now can set any libtiff supported tags. Tags + can be supplied by the mnemonic name or number. + +
    • ycbcr.c: fixed main() declaration as per: + + http://bugzilla.remotesensing.org/show_bug.cgi?id=513. + +
    • tiffsplit: Don't forget + to copy Photometric Interpretation tag. + +
    • tiffsplit: Fixed problem with + unproperly written multibyte files. Now output files will be written + using the same byte order flag as in the input image. See + . + +
    • tiffsplit: Copy JPEGTables + tag contents for JPEG compressed images. Reported by Artem Mirolubov. + +
    • tiffcp: Close output file + on normal exit. + +
    • tiffcp: Don't emit warnings + when Orientation tag does not present in the input image. + +
    • tiffcp: Properly set + Photometric Interpretation in case of JPEG compression of grayscale + images. + +
    • tiffcp: Fixed problem with wrong + interpretation of the InkNames tag as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=466. + Memory leak fixed. + +
    • tiffcp: Fixed problem with + wrong Photometric setting for non-RGB images. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • Outdated stuff removed. + +
    • Almost all programs are sinchronized with the current libtiff + and should compile without problems. + +
    + + + +CHANGES IN THE LZW COMPRESSION +KIT: +
      + +
    • No changes. + +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.7.0beta.html b/thirdparty/SDL2_image/external/libtiff/html/v3.7.0beta.html new file mode 100644 index 000000000..f646480fa --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.7.0beta.html @@ -0,0 +1,163 @@ + + + + + Changes in TIFF v3.7.0beta + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • LZW compression enabled by default. You don't need the separate + compression kit anymore. + +
    • bmp2tiff: Added new utility to convert Windows BMP files + into TIFFs. + +
    • The first attempt to implement a test suite. +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • Many portability fixes in the new autotooled build suite. +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • libtiff/{tif_luv.c, tif_next.c, tif_thunder.c}: Several buffer + overruns fixed, as noted by Chris Evans. + +
    • BSD data types (u_char, u_short, u_int, u_long) is no longer + used internally in the libtiff. Should result in simpler configuration + and better portability. + +
    • libtiff/tiff.h: Fix column tagging. Reference current Adobe XMP + specification. Reference libtiff bug tracking system to submit + private tag additions. + +
    • libtiff/tif_dirread.c: Don't reject to read tags of the + SamplesPerPixel size when the tag count is greater than number of + samples as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=576. + +
    • libtiff/{tiffio.h, tif_open.c}: Applied patches from + Joris Van Damme to avoid requirement for tiffiop.h inclusion in + some applications. Look for details here: + + http://www.asmail.be/msg0054799560.html. + +
    • libtiff/{tiffiop.h, tif_dirinfo.c}: Fixed problem with the static + variable as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=593. + +
    • libtiff/tif_lzw.c: LZW compression code is merged back from the + separate package. All libtiff tools are updated to not advertise an + abcence of LZW support. + +
    • libtiff/tif_dir.c: Call TIFFError() instead of producing warnings + when setting custom tags by value. Reported by Eric Fieleke. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      +
    • tiff2ps: Avoid zero division in setupPageState() function; + properly initialize array in PSDataBW(). + +
    • tiff2pdf: Multiple bugfixes. + +
    • ras2tiff: Fixed issue with missed big-endian checks as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=586. + +
    • bmp2tiff: Added new utility to convert Windows BMP files + into TIFFs. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • No changes. + +
    + + + +CHANGES IN THE LZW COMPRESSION +KIT: +
      + +
    • This one is not longer needed. + +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.7.0beta2.html b/thirdparty/SDL2_image/external/libtiff/html/v3.7.0beta2.html new file mode 100644 index 000000000..41ba6c3af --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.7.0beta2.html @@ -0,0 +1,132 @@ + + + + + Changes in TIFF v3.7.0beta2 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • The code has been reviewed by Dmitry Levin: added checks + for values, returned by the space allocation functions, fixed + problems with the possible integer overflows. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • Several fixes in the test suite. +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • Preliminary support for BigTIFF files: now libtiff can + recognize and reject to open such images. ;-) + +
    • libtiff/tif_dirinfo.c: changed type of XMLPacket (tag 700) to + TIFFTAG_BYTE instead of TIFFTAG_UNDEFINED to comply with the info + in the Adobe XMP Specification. + +
    • Added many checks for integer overflow and for successful space + allocations in the different parts of library. Code review + completed by Dmitry V. Levin. + +
    • libtiff/{tiffio.h, tif_compress.c}: Added + TIFFGetConfiguredCODECs()function to get the list of configured codecs. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      +
    • tiff2bw: Write ImageWidth/Height tags to output file, as + noted by Gennady Khokhorin. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • No changes. + +
    + + + +CHANGES IN THE LZW COMPRESSION +KIT: +
      + +
    • This one is not longer needed. + +
    + + TIFF home page.
    + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.7.1.html b/thirdparty/SDL2_image/external/libtiff/html/v3.7.1.html new file mode 100644 index 000000000..164b40598 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.7.1.html @@ -0,0 +1,234 @@ + + + + + Changes in TIFF v3.7.1 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • This is mostly bugfix release. Most important fix is the one + related to wrong custom tag read/write code. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • autogen.sh: aclocal and autoheader should be executed after + libtoolize. Also add '-I .' to aclocal invocation to check + current directory for macros. + +
    • nmake.opt: Link with the user32.lib in windowed mode. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=697 + +
    • nmake.opt, makefile.vc: make it easier to rename the libtiff DLL. + +
    • configure, configure.ac: Added --enable-rpath option to embed + linker paths into library binary. + +
    + +


    + + + +CHANGES IN LIBTIFF: + + + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • fax2ps.c: Be able to extract the first page (#0). As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=690 + +
    • tiff2ps.c: Fixed wrong variable data type when read Position + tags (Tristan Hill). + +
    • tiff2ps.c: Fixed wrong variable data type when read Resolution + tags (Peter Fales). + +
    • tiffset.c: Check the malloc return value (Dmitry V. Levin). + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • No changes. + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.7.2.html b/thirdparty/SDL2_image/external/libtiff/html/v3.7.2.html new file mode 100644 index 000000000..d396021e4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.7.2.html @@ -0,0 +1,223 @@ + + + + + Changes in TIFF v3.7.2 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • Maintenance release. Many bugfixes in the build environment + and compatibility improvements. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + + + +


    + + + +CHANGES IN LIBTIFF: + + + +


    + + + +CHANGES IN THE TOOLS: + + + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • No changes. + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.7.3.html b/thirdparty/SDL2_image/external/libtiff/html/v3.7.3.html new file mode 100644 index 000000000..54978c8ff --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.7.3.html @@ -0,0 +1,231 @@ + + + + + Changes in TIFF v3.7.3 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • Replace runtime endianness check with the compile time one. + +
    • Added support for the new predictor type (floating point + predictor), defined at the TIFF Technical Note 3. + +
    • Added Support for custom tags, passed by value. + Added support for all DNG tags. +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + + + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • tiffiop.h, tif_open.c: Added open option 'h' to avoid reading + the first IFD when needed. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=875 + +
    • tiff.h: Use correct int size on Sparc 64bit/Sun compiler + platform. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=855 + +
    • tif_dirinfo.c: Added support for ClipPath, XClipPathUnits + and YClipPathUnits tags. + +
    • tif_dirinfo.c, tif_dir.h, tif_dir.c, tif_print.c: Make + DocumentName, Artist, HostComputer, ImageDescription, Make, Model, + Copyright, DateTime, PageName, TextureFormat, TextureWrapModes and + TargetPrinter tags custom. + +
    • tif_jpeg.c: Cleanup the codec state depending on TIFF_CODERSETUP + flag (to fix memory leaks). + +
    • tif_dirwrite.c: Use tdir_count when calling + TIFFCvtNativeToIEEEDouble() in the TIFFWriteDoubleArray() function as + per bug + http://bugzilla.remotesensing.org/show_bug.cgi?id=845 + +
    • tif_dirinfo.c, tif_print.c: TIFFFetchByteArray() returns + uint16 array when fetching the BYTE and SBYTE fields, so we should + consider result as pointer to uint16 array and not as array of chars. + As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=831 + +
    • tif_dir.c: More efficient custom tags retrieval as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=830 + +
    • tif_win32.c: Use FILE_SHARE_READ | FILE_SHARE_WRITE share + mode in CreateFile() call as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=829 + +
    • tif_jpeg.c: Substantial fix for addtiffo problems with + JPEG encoded TIFF files. Pre-allocate lots of space for jpegtables + in directory. + +
    • tif_dirread.c: Changed the code that computes + stripbytecount[0] if it appears bogus to ignore if stripoffset[0] is + zero. This is a common case with GDAL indicating a "null" tile/strip. + +
    • tif_jpeg.c: added LIB_JPEG_MK1 support in JPEGDecodeRaw(). + +
    • tif_dirread.c: Ensure that broken files with too many + values in PerSampleShorts, TIFFFetchPerSampleLongs and + TIFFFetchPerSampleAnys work ok instead of crashing. + + http://bugzilla.remotesensing.org/show_bug.cgi?id=843 + +
    • tif_predict.h, tif_predict.c: Added ability to decode and encode + floating point predictor, as per TIFF Technical Note 3. + See http://chriscox.org/TIFF_TN3_Draft2.pdf for details. + +
    • tiffio.h, tiffiop.h, tif_dir.c, tif_read.c, tif_swab.c: + Added _TIFFSwab24BitData() and TIFFSwabArrayOfLong() functions used to + swap 24-bit floating point values. + +
    • tiff.h: Added predictor constants. + +
    • tiffiop.h, tif_dir.c: Use uint32 type for appropriate values + in _TIFFVSetField() function. Inspired by the bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=816 + +
    • tif_open.c: Do not read header in case the output file should + be truncated (Ron). + +
    • tif_dirinfo.c, tif_config.h.vc: Use lfind() instead of bsearch() + in _TIFFFindFieldInfoByName() function (Ron). + +
    • tif_dir.c, tif_print.c: Properly handle all data types in custom + tags. + +
    • dirinfo.c: Added DNG tags. + +
    • tiff.h: Added missed DNG tag (LensInfo); added DNG 1.1.0.0 tags. + +
    • tif_dir.c, tif_print.c: Added Support for custom tags, passed + by value. + +
    • tiff.h, tif_dirinfo.c, tiffiop.h: Added EXIF related tags. +
    + +


    + + + +CHANGES IN THE TOOLS: + + + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • addtiffo/{tif_overview.c, tif_ovrcache.c, tif_ovrcache.h}: + Make overviews working for contiguous images. + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.7.4.html b/thirdparty/SDL2_image/external/libtiff/html/v3.7.4.html new file mode 100644 index 000000000..eeb0f3cac --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.7.4.html @@ -0,0 +1,134 @@ + + + + + Changes in TIFF v3.7.4 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • Fixed important bug in custom tags handling code.. +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • Applied patch from Patrick Welche (all scripts moved in the + 'config' and 'm4' directories). + +
    • SConstruct, libtiff/SConstruct: Added the first very preliminary + support for SCons software building tool (http://www.scons.org/). + This is experimental infrastructure and it will exist along with the + autotools stuff. + +
    • port/lfind.c: Added lfind() replacement module. +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • tif_dir.c: When prefreeing tv->value in TIFFSetFieldV + also set it to NULL to avoid double free when re-setting custom + string fields as per: + + http://bugzilla.remotesensing.org/show_bug.cgi?id=922 + +
    • tif_dir.c: Fixed up support for swapping "double complex" + values (128 bits as 2 64 bits doubles). GDAL gcore tests now + pass on bigendian (macosx) system. + +
    • libtiff/{tif_dirread.c, tif_dirinfo.c}: Do not upcast BYTEs to + SHORTs in the TIFFFetchByteArray(). Remove TIFFFetchExtraSamples() + function, use TIFFFetchNormalTag() instead as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=831 + + Remove TIFFFetchExtraSamples() function, use TIFFFetchNormalTag() + instead. + +
    • tif_print.c: Fixed printing of the BYTE and SBYTE arrays. + +
    • tif_write.c: Do not check the PlanarConfiguration field in + the TIFFWriteCheck() function in case of single band images (as per + TIFF spec). + +
    • libtiff/{tif_dir.c, tif_dir.h, tif_dirinfo.c, tif_print.c}: + Make FieldOfViewCotangent, MatrixWorldToScreen, MatrixWorldToCamera, + ImageFullWidth, ImageFullLength and PrimaryChromaticities tags custom. +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      +
    • tiffcp.c: Fixed WhitePoint tag copying. +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      +
    • tiffdump.c: Added support for TIFF_IFD datatype. + +
    • addtiffo/{tif_overview.c, tif_ovrcache.c, tif_ovrcache.h}: + Make overviews working for contiguous images. + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.8.0.html b/thirdparty/SDL2_image/external/libtiff/html/v3.8.0.html new file mode 100644 index 000000000..81a8b0c65 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.8.0.html @@ -0,0 +1,200 @@ + + + + + Changes in TIFF v3.8.0 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • Read-only support for custom directories (e.g. EXIF directory). + +
    • Preliminary support for MS MDI format. +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • Make the default strip size configurable via the + --with-default-strip-size and STRIP_SIZE_DEFAULT options. +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • tiffio.h: Added VC_EXTRALEAN definition before including + windows.h, to reduce the compile time. + +
    • tif_jpeg.c: Improve compilation under MinGW. + +
    • {tif_aux.c, tif_dir.c, tif_dir.h, tif_dirwrite.c, + tif_print.c, tif_getimage.c}: Make InkSet, NumberOfInks, DotRange and + StoNits tags custom. + +
    • {tif_aux.c, tif_dir.c, tif_dir.h, tif_print.c}: Make + WhitePoint tag custom. + +
    • tiffio.h: fixed typo that potentially resulted in + redefininition of USE_WIN32_FILEIO + +
    • {tif_dir.c, tif_dir.h, tif_print.c}: Make RichTIFFIPTC, + Photoshop and ICCProfile tags custom. + +
    • libtiff/*, contrib/*: Added 'dual-mode' error handling, enabling + newer code to get context indicator in error handler and still + remain compatible with older code: Done TIFFError calls everywhere + except in tools. + +
    • tiffinfo.c: Print EXIF directory contents if exist. + +
    • {tif_dirinfo.c, tif_dirread.c, tif_dir.h, tif_dir.c}: + Custom directory read-only support. + +
    • {tif_aux.c, tif_dirinfo.c, tif_dirread.c, tif_dir.h, + tif_dir.c, tif_print.c}: Make YCbCrCoefficients and ReferenceBlackWhite + tags custom. + +
    • tif_dirread.c: One more workaround for broken StripByteCounts + tag. Handle the case when StripByteCounts array filled with + completely wrong values. + +
    • tif_dirinfo.c: Release file descriptor in case of failure + in the TIFFOpenW() function as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1003 + +
    • tif_dirinfo.c: Correctly yse bsearch() and lfind() + functions as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1008 + +
    • tif_open.c, tiff.h, tiffdump.c: Incorporate preliminary support + for MS MDI format. + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1002 + +
    • libtiff.def, tiffiop.h, tiffio.h: Made TIFFFreeDirectory + public. + +
    • /tif_dirinfo.c: Make XResolution, YResolution and + ResolutionUnit tags modifiable during write process. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=977 + +
    • if_dirread.c: Don't try and split single strips into "0" strips + in ChopUpSingleUncompressedStrip. This happens in some degenerate + cases (like 1x1 files with stripbytecounts==0 (gtsmall.jp2 embed tiff) + +
    • tif_fax3.c: changed 'at scanline ...' style warning/errors + with incorrect use of tif_row, to 'at line ... of + strip/tile ...' style. +
    + +


    + + + +CHANGES IN THE TOOLS: + + + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      +
    • contrib/addtiffo/*: Major upgrade by Joris to support subsampled + YCbCr images in jpeg compressed TIFF files. + +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.8.1.html b/thirdparty/SDL2_image/external/libtiff/html/v3.8.1.html new file mode 100644 index 000000000..0fe7d9c06 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.8.1.html @@ -0,0 +1,218 @@ + + + + + Changes in TIFF v3.8.1 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • Bug-fix release. +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      +
    • libtool related stuff updated from the 2.1a branch. + +
    • Fix with_default_strip_size comparison as reported by + Norihiko Murase. +
    + +


    + + + +CHANGES IN LIBTIFF: + + + +


    + + + +CHANGES IN THE TOOLS: + + + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      +
    + +Last updated $Date: 2016-09-25 20:05:45 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.8.2.html b/thirdparty/SDL2_image/external/libtiff/html/v3.8.2.html new file mode 100644 index 000000000..41bb2e55c --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.8.2.html @@ -0,0 +1,138 @@ + + + + + Changes in TIFF v3.8.2 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • Bug-fix release. +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + + + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • tif_strip.c: Take subsampling in account when calculating + TIFFScanlineSize(). + +
    • tif_jpeg.c, tif_fax3.c, tif_zip.c, tif_pixarlog.c, + tif_lzw.c, tif_luv.c: Use _TIFFSetDefaultCompressionState() in all + codec cleanup methods. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1120 + +
    • tif_jpeg.c: Do not cleanup codec state in TIFFInitJPEG(). As + per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1119 + +
    • tif_dir.c: Use double type instead of dblparam_t. + +
    • tif_dirread.c: Do not check the PlanarConfig tag presence + in TIFFReadDirectory, because it is always set at the start of + function and we allow TIFFs without that tag set. + +
    + +


    + + + +CHANGES IN THE TOOLS: + + + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      +
    + +Last updated $Date: 2016-09-25 20:05:46 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.9.0.html b/thirdparty/SDL2_image/external/libtiff/html/v3.9.0.html new file mode 100644 index 000000000..540e7cf2a --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.9.0.html @@ -0,0 +1,262 @@ + + + + + Changes in TIFF v3.9.0 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • All of the major changes since 3.8.0 were incorporated in + the v3.9.0beta release. This is a stable release from a + stable maintenance branch which incorporates many bug and + security fixes needed by existing users of 3.X.X series + libraries. Any future major changes will be in the 4.0.X + series of releases. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • Updated autotools: Autoconf 2.64, Automake 1.11, libtool + 2.2.6. + +
    • Enabled support for Automake silent build rules + (--enable-silent-rules or 'make V=0') + +
    • Enabled support for Automake colorized tests. + +
    • Added detection of a 64-bit integer type so that bundled + utilities (like tiffcrop) can use it when necessary. Note + that this version of libtiff does not require a 64-bit integer + type but libtiff 4.0 does. + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • libtiff/{Makefile.am, Makefile.v}: Do not distribute + tiffconf.h, remove tif_config.h/tiffconf.h during cleaning. As + per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=1573 + +
    • tif_dirinfo.c: _TIFFMergeFields() now only merges in + field definitions that are missing. Existing definitions are + silently ignored. (Bug #1585) + +
    • tif_write.c: Rip out the fancy logic in + TIFFAppendToStrip() for establishing if an existing tile can + be rewritten to the same location by comparing the current + size to all the other blocks in the same directory. This is + dangerous in many situations and can easily corrupt a file. + (observed in esoteric GDAL situation that's hard to document). + This change involves leaving the stripbytecount[] values + unaltered till TIFFAppendToStrip(). Now we only write a block + back to the same location it used to be at if the new data is + the same size or smaller - otherwise we move it to the end of + file. + +
    • tif_dirwrite.c: Try to avoid writing out a full + readbuffer of tile data when writing the directory just + because we have BEENWRITING at some point in the past. This + was causing odd junk to be written out in a tile of data when + a single tile had an interleaving of reading and writing with + reading last. (highlighted by gdal + autotest/gcore/tif_write.py test 7. + +
    • tif_predict.c: use working buffer in PredictorEncodeTile + to avoid modifying callers buffer. http://trac.osgeo.org/gdal/ticket/1965 + +
    • tif_predict.c/h, tif_lzw.c, tif_zip.c: Improvements so + that predictor based encoding and decoding works in read-write + update mode properly. http://trac.osgeo.org/gdal/ticket/1948 + +
    • configure.com, libtiff/tif_vms.c: Better OpenVMS + support. Patches from Alexey Chupahin. + +
    • tif_fax3.c: fix leak of FAXCS state (per bug 1603). + +
    • tif_fax3.c: Make find0span() and find1span() non-inline + to make MSVC 6.0 compiler happy. + +
    • tif_codec.c: Avoid NULL pointer dereferencing for exotic + compression codec codes. + +
    • tif_dirread.c: zero tif->tif_dir after freeing the + directory in TIFFReadCustomDirectory(). I don't exactly + remember why this was important. + +
    • tif_dirwrite.c: Fix potential memory leak writing large + double tags. + +
    • tif_dirread.c: Fix unchecked malloc result. + +
    • libtiff/tif_lzw.c: Properly zero out the codetable. As + per bug http://bugzilla.maptools.org/show_bug.cgi?id=1929 + +
    • libtiff/tif_lzw.c: Properly zero out the string + table. Fixes CVE-2008-2327 security issue. + +
    • libtiff/tif_jbig.c: Support the JBIG-KIT 2.0 + (compatibility with the older versions retained). + +
    • libtiff/tif_getimage.c,tiffio.h: removed all use of + UaToAa and Bitmap16to8 arrays in TIFFRGBAImage structure to + restore ABI compatibility. These were just an attempt to + speed up processing with precalculated tables. http://bugzilla.maptools.org/show_bug.cgi?id=1979 + +
    • libtiff/tif_codec.c: Avoid printing c->name if it does not exist. + +
    • libtiff/tif_getimage.c, tiffio.h: More ABI corrections. + Removed SubsamplingHor/Ver from TIFFRGBAImage structure. http://bugzilla.maptools.org/show_bug.cgi?id=1980 + +
    • libtiff/tif_jpeg.c: Avoid errors if the application + writes a full strip for the last partial strip in a jpeg + compressed file. http://bugzilla.maptools.org/show_bug.cgi?id=1981 + +
    • libtiff/tiffio.h: GCC will now validate format + specifications for TIFFError(), TIFFErrorExt(), TIFFWarning(), + and TIFFWarningExt() in order to reveal bugs. Cleaned up + resulting warnings throughout for 32 bit build only. + +
    • libtiff/tiffiop.h: Add private type declarations for + int64, and uint64 so that bundled utilities (like tiffcrop) + can use it when necessary. + +
    • libtiff/tif_predict.c: Add support for 32bit integer + horz. predictors. + http://bugzilla.maptools.org/show_bug.cgi?id=1911 + +
    • libtiff/tif_luv.c: Fix handling of tiled logluv images. + http://bugzilla.maptools.org/show_bug.cgi?id=2005 + +
    • libtiff/tif_write.c: do not override the planar + configuration to be contig for one sample files if planar + configuration is already set. http://bugzilla.maptools.org/show_bug.cgi?id=2057 + +
    • libtiff/tif_lzw.c: Fix buffer underflow bug. http://bugzilla.maptools.org/show_bug.cgi?id=2065 + +
    • libtiff/tif_luv.c: correct return codes from encoderow to + be 1 on success instead of zero. http://bugzilla.maptools.org/show_bug.cgi?id=2069 + +
    • libtiff/tif_print.c (TIFFPrintDirectory): Applied patch + for "tag error may cause segfault in tif_print.c." http://bugzilla.maptools.org/show_bug.cgi?id=1896 + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      +
    • tools/tiff2pdf.c: Fixed setting of alpha value per report + on list. + +
    • tools/tiffsplit.c: Get rid of unsafe strcpy()/strcat() + calls when doing the filename/path construction. + +
    • tools/tiff2pdf.c: More appropriate format string in + t2p_write_pdf_string(); avoid signed/unsigned mismatch. + +
    • tools/tiffsplit.c: Use dynamically allocated array + instead of static when constructing output file names. + +
    • tools/tiffcrop.c, man/tiffcrop.1: Incorporated + significant functionality update from Richard Nolde. + +
    • tools/tiff2ps.c: Incorporated significant functionality + update from Richard Nolde. In particular, support for + rotating the image by 90, 180, 270, and 'auto' has been added. + +
    • tools/tiff2ps.c: Remove spurious message printed to + stderr. + +
    • tools/tiffsplit.c: fix sampleformat to be shortv instead + of longv. + +
    • tools/{rgb2ycbcr.c, tiff2rgba.c}: Applied patch for + CVE-2009-2347 libtiff: integer overflows in various + inter-color space conversion tools. http://bugzilla.maptools.org/show_bug.cgi?id=2079 + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:46 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.9.0beta.html b/thirdparty/SDL2_image/external/libtiff/html/v3.9.0beta.html new file mode 100644 index 000000000..56f32ed33 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.9.0beta.html @@ -0,0 +1,305 @@ + + + + + Changes in TIFF v3.9.0beta + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). +If you don't find something listed here, then it was not done in this +timeframe, or it was not considered important enough to be mentioned. +The following information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • New tiffcrop utility contributed by Richard Nolde. + tiffcrop does the same as tiffcp, but also can crop, + extract, rotate and mirror images. + +
    • tif_jbig.c: Added support for JBIG compression scheme + (34661 code), contributed by Lee Howard. + +
    • Totally new implementation of OJPEG module from + Joris Van Damme. No need to patch libjpeg anymore. Many OJPEG files + should be supported now that was not supported previously. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • tif_config.wince.h, tiffconf.wince.h, tif_wince.c: WinCE-specific + compatibility stuff from Mateusz Loskot. + +
    • Rename config.h.vc and tif_config.h.vc to config.vc.h and + tif_config.vc.h for easier identification by folks using an IDE. + +
    • configure, configure.ac: OJPEG support enabled by default (i.e., + whe the conformant JPEG support enabled). + +
    • README.vms, Makefile.am, configure.com, libtiff/{Makefile.am, + tif_config.h-vms, tif_stream.cxx, tif_vms.c, tiffconf.h-vms}: + Added support for OpenVMS by Alexey Chupahin. + +
    • nmake.opt: use /EHsc for VS2005 compatibility. Also define + _CRT_SECURE_NO_DEPRECATE to avoid noise on VS2005. + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • tif_dirinfo.c (_TIFFFindFieldInfo): Don't attempt to + bsearch() on a NULL fieldinfo list. + (_TIFFFindFieldInfoByName): Don't attempt to lfind() on a NULL + fieldinfo list. + +
    • tif_jpeg.c: Changed JPEGInitializeLibJPEG() so that it + will convert from decompressor to compressor or compress to decompress + if required by the force arguments. This works around a problem in + where the JPEGFixupTestSubsampling() may cause a decompressor to + be setup on a directory when later a compressor is required with the + force flag set. Occurs with the addtiffo program for instance. + +
    • tif_dirwrite.c: Fixed swapping of byte arrays stored + in-place in tag offsets as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1363 + +
    • tif_getimage.c: workaround for 'Fractional scanline' error + reading OJPEG images with rowsperstrip that is not a multiple of + vertical subsampling factor. This bug is mentioned in + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1390 and + + http://www.asmail.be/msg0054766825.html + +
    • tif_dirread.c: Added special function to handle + SubjectDistance EXIF tag as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1362 + +
    • tif_dirread.c, tif_read.c: Type of the byte counters + changed from tsize_t to uint32 to be able to work with data arrays + larger than 2GB. Fixes bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=89 + Idea submitted by Matt Hancher. + +
    • tif_dir.c: Workaround for incorrect TIFFs with + ExtraSamples == 999 produced by Corel Draw. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1490 + +
    • tif_write.c: TIFFAppendToStrip() - clear sorted flag if + we move a strip. + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1359 + +
    • tif_fax3.c: Save the state of printdir codec dependent method. + +
    • tif_jpeg.c: Save the state of printdir codec dependent method + as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1273 + +
    • tif_win32.c: Fixed problem with offset value manipulation + as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1322 + +
    • tif_fax3.c, tif_next.c, tif_pixarlog.c: Fixed multiple + vulnerabilities, as per Gentoo bug (): + + http://bugs.gentoo.org/show_bug.cgi?id=142383 + +
    • tif_lzw.c, tif_zip.c: Fixed problems with mixing + encoding and decoding on the same read-write TIFF handle. The LZW + code can now maintain encode and decode state at the same time. The + ZIP code will switch back and forth as needed. + + http://bugzilla.remotesensing.org/show_bug.cgi?id=757 + +
    • tif_msdos.c: Avoid handle leak for failed opens. + c/o Thierry Pierron + +
    • tif_dirwrite.c: take care not to flush out buffer of strip/tile + data in _TIFFWriteDirectory if TIFF_BEENWRITING not set. Relates + to bug report by Peng Gao with black strip at bottom of images. + +
    • tif_dirwrite.c: make sure to use uint32 for wordcount in + TIFFWriteNormanTag if writecount is VARIABLE2 for ASCII fields. + It already seems to have been done for other field types. Needed + for "tiffset" on files with geotiff ascii text. + +
    • tif_dirinfo.c: Added missed EXIF tag ColorSpace (40961). + +
    • tif_dirread.c: Move IFD fetching code in the separate + function TIFFFetchDirectory() avoiding code duplication in + TIFFReadDirectory() and TIFFReadCustomDirectory(). + +
    • tif_readdir.c: Added case in EstimateStripByteCounts() for tiled + files. Modified TIFFReadDirectory() to not invoke + EstimateStripByteCounts() for case where entry 0 and 1 are unequal but + one of them is zero. + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1204 + +
    • tif_open.c, tif_dirread.c, tiffiop.h: Move IFD looping + checking code in the separate function TIFFCheckDirOffset(). + +
    • tif_aux.c: Added _TIFFCheckRealloc() function. + +
    • tif_fax3.c: Fixed problems in fax decoder as per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=1194 + +
    • tif_jbig.c: Added support for JBIG compression scheme + (34661 code) contributed by Lee Howard. As per bug + + http://bugzilla.remotesensing.org/show_bug.cgi?id=896 + +
    • tif_getimage.c: Added support for planarconfig separate + non-subsampled YCbCr (i.e. separate YCbCr with subsampling [1,1]). + +
    • tif_getimage.c: Revision of all RGB(A) put routines: +
        +
      • Conversion of unassociated alpha to associated alpha + now done with more performant LUT, and calculation more + correct. +
      • Conversion of 16bit data to 8bit data now done with + more performant LUT, and calculation more correct +
      • Bugfix of handling of 16bit RGB with unassociated alpha +
      + +
    • tif_ojpeg.c: totally new implementation + +
    • tif_getimage.c: removed TIFFTAG_JPEGCOLORMODE handling + of OJPEG images in favor of tif_getimage.c native handling of + YCbCr and desubsampling. + +
    • tif_jpeg.c: JPEGVSetField() so that altering the photometric + interpretation causes the "upsampled" flag to be recomputed. Fixes + peculiar bug where photometric flag had to be set before jpegcolormode + flag. + +
    + +


    + + + +CHANGES IN THE TOOLS: + + + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • contrib/addtiffo/tif_overview.c: Fix problems with odd sized + output blocks in TIFF_DownSample_Subsampled() (bug 1542). + +
    • contrib/dbs/xtiff/xtiff.c: Make xtiff utility compilable. + Though it is still far from the state of being working and useful. + +
    + +Last updated $Date: 2016-09-25 20:05:46 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.9.1.html b/thirdparty/SDL2_image/external/libtiff/html/v3.9.1.html new file mode 100644 index 000000000..1f369a832 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.9.1.html @@ -0,0 +1,116 @@ + + + + + Changes in TIFF v3.9.1 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      +
    • This is a bug-fix release for several bugs (two of which + are dire) which were discovered in the 3.9.0 release. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • Several defines were missing from tif_config.vc.h which + are necessary to compile the library using MSVC. + +
    • Colorized tests were actually not enabled as expected. + Parallel tests mode is now also enabled so that tests can be + run in parallel, and test output is sent to .log files. + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • libtiff/tif_write.c (TIFFAppendToStrip): Remove cast + which caused libtiff to output a wrong last strip with + byte-count and strip-offset of zero. This cast was added on + the day of the 3.9.0 release. + +
    • libtiff/tif_dirwrite.c: Back out changes from 2007-11-22 + that resulted in the final strip not being written in some + circumstances. + http://bugzilla.maptools.org/show_bug.cgi?id=2088 + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      +
    • None + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.9.2.html b/thirdparty/SDL2_image/external/libtiff/html/v3.9.2.html new file mode 100644 index 000000000..a190a3015 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.9.2.html @@ -0,0 +1,123 @@ + + + + + Changes in TIFF v3.9.2 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • Fixes a number of bugs present in the 3.9.1 release. + +
    • OJPEG support updated to work with IJG JPEG 7 release. + +
    • Tiffcrop validated for most TIFF storage subformats and sample depths. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • x86_64 now uses the same default fill order as i386. + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • Writing tags with an array value of type TIFF_DOUBLE now + returns correct error status. The TIFFTAG_SMINSAMPLEVALUE and + TIFFTAG_SMAXSAMPLEVALUE tags failed to write without this fix. + +
    • OJPEG decoder now works with IJG JPEG 7. Resolves "Bug + 2090 - OJPEG crash with libjpeg v7". + http://bugzilla.maptools.org/show_bug.cgi?id=2090 + +
    • Eliminate most GCC "dereferencing type-punned pointer" + warnings. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • New tiffcrop from Richard Nolde. Major updates to add + significant functionality for reading and writing tile based + images with bit depths not a multiple of 8 which cannot be + handled by tiffcp. + +
    • Allow building tools with GCC using the "-Wformat + -Werror=format-security" flags. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.9.3.html b/thirdparty/SDL2_image/external/libtiff/html/v3.9.3.html new file mode 100644 index 000000000..52a9f087b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.9.3.html @@ -0,0 +1,161 @@ + + + + + Changes in TIFF v3.9.3 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • Fixes for CVE-2010-1411. + +
    • Various reported bug fixes. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • libtool is updated to version 2.2.10. + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • Fix a couple of issues that trigger failures in some + cases when using TIFFReadScanline() with JPEG compressed + subsampled ycbcr images. + http://bugzilla.maptools.org/show_bug.cgi?id=1936 + +
    • Ensure tile and scanline sizes are reset when moving to + new directories. + http://bugzilla.maptools.org/show_bug.cgi?id=1936 + +
    • Do not generate a JPEGTables tag when creating the JPEG + TIFF as is is not required in order to prevent it from being + unused and filled with invalid data. (Leave it to be + generated by later activity.) + http://bugzilla.maptools.org/show_bug.cgi?id=2135 + +
    • Don't return error on badly-terminated MMR strips. + http://bugzilla.maptools.org/show_bug.cgi?id=2029 + +
    • Have TIFFTAG_REFERENCEBLACKWHITE always print 6 floats + instead of 2*SamplesPerPixel. + http://bugzilla.maptools.org/show_bug.cgi?id=2186 + +
    • Ensure that JPEG quality is always set in + JPEGPreEncode(), not just when we want to output local tables. + Otherwise the quality used during compression may not be right + and might not match the tables in the tables tag. This bug + only occurs when seeking between directories in the midst of + writing blocks. http://trac.osgeo.org/gdal/ticket/3539 + +
    • OJPEG: Report an error and avoid a crash if the input + file is so broken that the strip offsets are not defined. + +
    • Eliminate FAX3 decoder buffer overrun possibility + (CVE-2010-1411). + +
    • Restore ReferenceBlackWhite as a non-custom field. This + avoids a multi-thread reentrancy problem as well as fixing + output of wrong tag value due to redundant definitions for the + same tag in the tiffFieldInfo[] array. Resolves + http://bugzilla.maptools.org/show_bug.cgi?id=2185 + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tiff2pdf: Write the JPEG SOI headers into the TIFF strip + data rather than skipping them. This fixes the ability to view in + Acrobat Reader, Evince, and Ghostscript. + http://bugzilla.maptools.org/show_bug.cgi?id=2135 + +
    • ppm2tiff: While case for parsing comment line + requires extra parenthesis to work as expected. Reported by + Thomas Sinclair. + +
    • tiffcp: add a new option -x to force merged tiff + file PAGENUMBER value in sequence for users who care the page + sequence, this will also prevent tiff2pdf from creating pdf file from + the merged tiff file with wrong page sequence. + +
    • tiffcp: Applied Tom Lane's patch to reject YCbCr + subsampled data since tiffcp currently doesn't support it. + http://bugzilla.maptools.org/show_bug.cgi?id=2097 + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.9.4.html b/thirdparty/SDL2_image/external/libtiff/html/v3.9.4.html new file mode 100644 index 000000000..3f5ef5c7a --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.9.4.html @@ -0,0 +1,126 @@ + + + + + Changes in TIFF v3.9.4 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • Complete the fixes for CVE-2009-2347. + +
    • Tiffcrop now supports custom page sizes. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • None. + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • Fixed inadequate validation of the SubjectDistance field. + +
    • Fixed bad handling of out of order tags definated late by + a codec. + +
    • Avoid re-preparing jpeg tables unnecessarily. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tiffcrop: Added an option to allow the user to specify a + custom page size on the command line. Fix the case where a + page size specified with a fractional part was being coerced + to an integer by retyping the variables that define the paper + size. Corrected European page size dimensions. + +
    • tiff2rgba: Completed fixes for "CVE-2009-2347 libtiff: + integer overflows in various inter-color space conversion + tools". http://bugzilla.maptools.org/show_bug.cgi?id=2079 + +
    • tiff2pdf: Fix assorted bugs in tiff2pdf: missing "return" + in t2p_read_tiff_size() causes t2p->tiff_datasize to be set entirely + wrong for COMPRESSION_JPEG case, resulting in memory stomp if actual + size is larger. Also, there are a bunch of places that try to + memset() a malloc'd buffer before checking for malloc failure, which + would result in core dump if there actually were a failure. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v3.9.5.html b/thirdparty/SDL2_image/external/libtiff/html/v3.9.5.html new file mode 100644 index 000000000..666220f3a --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v3.9.5.html @@ -0,0 +1,271 @@ + + + + + Changes in TIFF v3.9.5 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • None + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • configure.ac: Should use AC_CANONICAL_HOST since host specifies + the run-time target whereas target is used to specify the final + output target if the package is a build tool (like a compiler), + which libtiff is not. Resolves libtiff bug 2307 "Use + AC_CANONICAL_HOST macro". + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • libtiff/tif_getimage.c: Check the number of samples per pixel when + working with YCbCr image in PickContigCase(). As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2216 + +
    • libtiff/tif_dir.c: Set the bogus post-decoding hook when processing + TIFFTAG_BITSPERSAMPLE in _TIFFVSetField() for the case of 8 bit when + we don't need any post-processing. That helps to reset the hook if we + previously set this field to some other value and the hook was + initialized accordingly. As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2035 + +
    • libtiff/tif_getimage.c: Avoid wrong math du to the signed/unsigned + integer type conversions. As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2207 + +
    • libtiff/tif_dirinfo.c: Don't use assertions in _TIFFFieldWithTag() + and _TIFFFieldWithName() if the tag is not found in the tag table. + This should be normal situation and returned NULL value should be + properly handled by the caller. + +
    • libtiff/{tif_dirwrite.c, tif_print.c}: Properly handle "DotRange" + tag as it can be either byte or short size and should be set and read + by value, not as an array. As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2116 + +
    • libtiff/tif_dirread.c: Really reset the tag count in CheckDirCount() + to expected value as the warning message suggests. As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=1963 + +
    • libtiff/tif_open.c: Fix mode check before opening a file. + http://bugzilla.maptools.org/show_bug.cgi?id=1906 + +
    • libtiff/tif_jpeg.c, libtiff/tif_strip.c: apply patch for + CVE-2010-3087 per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2140 + +
    • libtiff/tif_dirread.c: fix crash when reading a badly-constructed + TIFF per http://bugzilla.maptools.org/show_bug.cgi?id=1994 + +
    • libtiff/tif_ojpeg.c: fix buffer overflow on problem data + http://bugzilla.maptools.org/show_bug.cgi?id=1999 + +
    • libtiff/tif_dirread.c: modify warnings + http://bugzilla.maptools.org/show_bug.cgi?id=2016 + +
    • libtiff/tif_jpeg.c: fix use of clumplines calculation + http://bugzilla.maptools.org/show_bug.cgi?id=2149 + +
    • libtiff/tif_color.c: prevent crash in handling bad TIFFs + resolves CVE-2010-2595 + http://bugzilla.maptools.org/show_bug.cgi?id=2208 + +
    • libtiff/tif_dirread.c: fix needless tag ordering warning + http://bugzilla.maptools.org/show_bug.cgi?id=2210 + +
    • libtiff/tif_jpeg.c: reduce usage of JCS_UNKNOWN in order + to improve compatibility with various viewers + submitted by e-mail from Dwight Kelly + +
    • libtiff/tif_strip.c: use TIFFGetFieldDefaulted instead + of TIFFGetField when we assume that it will succeed + http://bugzilla.maptools.org/show_bug.cgi?id=2215 + +
    • libtiff/tif_dirread.c: tolerate some cases where + FIELD_COLORMAP is missing + http://bugzilla.maptools.org/show_bug.cgi?id=2189 + +
    • libtiff/tif_jpeg.c: Fix regressions with 2 and 3 band images + caused by commit on 2010-12-14. Submitted by e-mail from + Even Rouault + +
    • libtiff/tif_dirwrite.c: Avoid undefined behaviour when casting from + float to unsigned integer in TIFFWriteRationalArray() as reported by + Kareem Shehata. + +
    • libtiff/tif_fax3.h: Protect against a fax VL(n) codeword commanding + a move left. Without this, a malicious input file can generate an + indefinitely large series of runs without a0 ever reaching the right + margin, thus overrunning our buffer of run lengths. Per CVE-2011-0192. + This is a modified version of a patch proposed by Drew Yao of Apple + Product Security. It adds an unexpected() report, and disallows the + equality case, since emitting a run without increasing a0 still allows + buffer overrun. + +
    • libtiff/tif_fax3.h: Fix to last change allowing zero length + runs at the start of a scanline - needed for legal cases. + +
    • libtiff/tif_thunder.c: Correct potential buffer overflow with + thunder encoded files with wrong bitspersample set. The libtiff + development team would like to thank Marin Barbella and TippingPoint's + Zero Day Initiative for reporting this vulnerability (ZDI-CAN-1004, + CVE-2011-1167). + http://bugzilla.maptools.org/show_bug.cgi?id=2300 + +
    • libtiff/tiffiop.h: avoid declaring int64/uint64 on AIX with XLC + where they are already available. (#2301) +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tools/tiffcrop.c: Patch from Richard Nolde. Reject YCbCr + subsampled data since tiffcrop currently doesn't support it. Fix + JPEG support. + +
    • tools/tiffcp.c: Initialize buffer arrays with zero to avoid + referencing to uninitialized memory in some cases (e.g. when tile size + set bigger than the image size). + +
    • tools/tiff2pdf.c: Better generation of ID field in + t2p_write_pdf_trailer(). Get rid of GCC aliasing warnings. + +
    • tools/tiff2pdf.c: Fixed computation of the tile buffer size when + converting JPEG encoded tiles. + +
    • tools/tiff2pdf.c: Better handling of string fields, use static + string buffers instead of dynamically allocated, use strncpy() instead + of strcpy(), control the string lengths. + +
    • tools/{tiff2bw.c, thumbnail.c, pal2rgb.c}: Fix the count for + WhitePoint tag as per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2042 + +
    • tools/tiffdump.c: Use PrintData() function instead of + PrintByte/Short/Long(). Should fix an issue reported at + http://bugzilla.maptools.org/show_bug.cgi?id=2116 + +
    • tools/tiffset.c: Properly handle TIFFTAG_PAGENUMBER, + TIFFTAG_HALFTONEHINTS, TIFFTAG_YCBCRSUBSAMPLING, TIFFTAG_DOTRANGE + which should be set by value. + +
    • tools/tiffdump.c: Avoid integer overflows computing the buffer size + for large directories. As per bug + http://bugzilla.maptools.org/show_bug.cgi?id=2218 + +
    • tools/tiff2pdf.c: Fixed ID buffer filling in + t2p_write_pdf_trailer(), thanks to Dmitry V. Levin. + +
    • tools/tiffcrop.c: Patch from Richard Nolde to avoid a + potentially unterminated buffer due to using an exceptionally long + file name. + +
    • tools/tiff2ps.c: improvements and enhancements from Richard Nolde + with additional command line options for Document Title, + Document Creator, and Page Orientation + +
    • tools/tiffsplit.c: abort when reading a TIFF without a byte-count + per http://bugzilla.maptools.org/show_bug.cgi?id=1996 + +
    • tools/tiff2pdf.c: add fill-page option + http://bugzilla.maptools.org/show_bug.cgi?id=2051 + +
    • tools/fax2ps.c: replace unsafe tmpfile() with mkstemp() + http://bugzilla.maptools.org/show_bug.cgi?id=2118 + +
    • tools/tiff2pdf.c: fix colors for images with RGBA + interleaved data + http://bugzilla.maptools.org/show_bug.cgi?id=2250 + +
    • tools/tiffcrop.c: new release by Richard Nolde + http://bugzilla.maptools.org/show_bug.cgi?id=2004 + +
    • tools/fax2ps.c: be consistent with page-numbering + http://bugzilla.maptools.org/show_bug.cgi?id=2225 + +
    • tools/gif2tiff.c: fix buffer overrun + http://bugzilla.maptools.org/show_bug.cgi?id=2270 + +
    • tools/fax2ps.c (main): Use tmpfile() rather than mkstemp() since + it is much more portable. Tmpfile is included in ISO/IEC + 9899:1990 and the WIN32 CRT. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.0.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.0.html new file mode 100644 index 000000000..a7e9bb636 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.0.html @@ -0,0 +1,270 @@ + + + + + Changes in TIFF v4.0.0 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. Please consult +the ChangeLog file in the source package for full change details. The +following information is located here: +

    +

    +


    + + + +

    MAJOR CHANGES:

    + +BigTIFF support changes: + +
      + +
    • The options parameter in the TIFFOpen and TIFFClientOpen funcs has + been extended. When creating new files, you can add option '4' to + specify you want to create a ClassicTIFF file, though that is the + default and the option is not strictly necessary. (As such, old + calling code will continue to function and create ClassicTIFF files.) + Or you can add option '8' to specify you want to create a BigTIFF file + instead. This new option is also reflected in some of the tools we + already upgraded. For instance, you can use the -8 option on tiffcp to + have tiffcp produce BigTIFF files instead of the default ClassicTIFF. + (Whilst on additional option is provided for version selection when + creating new files, no such option is necessary when reading TIFF + files. LibTiff reads ClassicTIFF and BigTIFF both, and the application + does not need to be aware which TIFF version an opened file is.) + +
    • Although the tag count in BigTIFF is 64bit, we restricted the + count in the implementation to a much more reasonable size. This is + necessary in current implementation, because all tag data gets read + automatically in the IFD reading stage, so if there's half a dozen + private tags with multiple gigabytes of data that causes considerable + overhead even if the application level is never interested in these + tags. Our choice to ignore tags with data longer then a certain sanity + value is much needed as things stand. We also recommend to step away + from writing tiles that are 8 kilobyte in their uncompressed form, or + writing single-line strips, in really big files, resulting in mega's + of tiles or strips. It's much more efficient to choose bigger tile or + strip sizes, up to several megabyte if needed, and have a few kilo of + tiles or strips instead. + +
    • Although it's rare, some application code does directly access + file offsets. Some of these are automatically upgraded because they + used the toff_t type, others need to be aware that the datatype + changed and need to start using toff_t or uint64. This impacts access + to tags like the EXIF IFD tag, for example, or the SubIfds tag, or to + StripOffsets or TileOffsets, the return type of functions like + TIFFCurrentDirOffset, and a parameter type to functions like + TIFFSetSubDirectory. + +
    • Although it's rare, some application code does use structures + like TIFFHeader or TIFFDirEntry that used to be an exact binary + representation of TIFF structures. These need to change. The old + TIFFHeader structure is replaced by the new TIFFHeaderClassic, + TIFFHeaderBig, and TIFFHeaderCommon structures that are an exact + binary representation of the ClassicTIFF and BigTIFF header, and of + the part that is common to both. There is no new equivalent for the + old TIFFDirEntry structure (or more precisely, there is still a + TIFFDirEntry structure, but it is changed, moved to library-private + definition, and no longer an exact binary representation of the tag + structure of either TIFF version). + +
    • Sizer functions, like TIFFTileSize or TIFFScanlineSize and the + like, return a tmsize_t value (tmsize_t is defined as int32 on 32bit + machines, and int64 on 64bit machines, and as such it is meant to + represent signed memory sizes). This is because we figure 98% of the + calling code uses the return value as sizes in allocations and the + like. So, any overflow that is theoretically possible with BigTIFF + when LibTiff is running on a 32bit system, is best detected inside the + sizer functions and it is best to return a type that makes sense as a + memory size. If your calling code is the exception and is interested + in actual file size, you best use the newer TIFFTileSize64 or + TIFFScanlineSize64 function that returns an uint64 type. + +
    • These TIFF tags require a 64-bit type as an argument in + libtiff 4.0.0: +
        +
      • TIFFTAG_FREEBYTECOUNTS +
      • TIFFTAG_FREEOFFSETS +
      • TIFFTAG_STRIPBYTECOUNTS +
      • TIFFTAG_STRIPOFFSETS +
      • TIFFTAG_TILEBYTECOUNTS +
      • TIFFTAG_TILEOFFSETS +
      + +
    + +Other important backward incompatible changes in the public API: + +
      +
    • TIFFRewriteField() renamed into _TIFFRewriteField() and moved out + from the public interface (from tiffio.h to tiffiop.h). Type of its + 'count' parameter changed from uint32 to tmsize_t. + +
    • TIFFMergeFieldInfo() returns non-void result now. It returns 0 + if successful and -1 if failed. Though this is now obsoleted function + and should not be used in new programs. Use the new tag extension + scheme instead. + +
    • TIFFFieldWithTag() and TIFFFieldWithName() functions now return + pointer to TIFFField constant object instead of TIFFFieldInfo. + +
    • TIFFReassignTagToIgnore() function and TIFFIgnoreSense enumeration + have been removed. They was unused and never been used properly. + Should be unneeded for high-level applications. + +
    • TIFFTagValue structure removed from the public tiffio.h + to private tif_dir.h and not accessible anymore. It should be unneeded + for high-level applications. + +
    + +


    + + +

    CHANGES IN THE SOFTWARE CONFIGURATION:

    + +
      + +
    • Updated autotools: Autoconf 2.68, Automake 1.11.1, libtool + 2.4. + +
    • Enabled support for Automake silent build rules + (--enable-silent-rules or 'make V=0') + +
    • Enabled support for Automake colorized and parallel tests. + +
    • Added detection of 64-bit integer types since libtiff 4.0 + requires use of 64-bit signed and unsigned integer types. + +
    • Libtiff now provides a more comprehensive test suite with + over 72 tests, which may be executed on Unix-like systems, or + under Microsoft Windows using MinGW/MSYS or Cygwin. + +
    • --disable-lzma configure option to disable use of liblzma. + +
    • --enable-defer-strile-load configure option to enable + experimental deferred strip/tile offset/size loading. May + cause some extremely sophisticated uses of libtiff to fail. + +
    • --enable-chunky-strip-read configure option to enable + experimental enable reading large strips in chunks in + TIFFReadScanline(). + +
    • Now always uses WIN32 native I/O functions for Microsoft + Windows except for under Cygwin. + +
    • Now provides a pkg-config support file (libtiff-4.pc). + +
    + +


    + + + +

    CHANGES IN LIBTIFF:

    + +
      + +
    • Patches/fixes made to stable libtiff (v3.9.X) are also + applied to 4.0.0. There are too many to list here. See the + distribution ChangeLog for a detailed change list. + +
    • There is considerable change in some files like + tif_dirread and tif_dirwrite. These changes don't impact + backwards compatibility, they are mostly a clean rewrite that + does allow BigTIFF support as well as somewhat more robust + reading of the unexpected already and will also serve future + API extension but does not impact current API or functionality + in a negative way that you need to know about. + +
    • Although there is still a functional definition for types + like toff_t (file offset), tstrip_t (strip index number), etc, + we recommend against using these in newer code. We have + learned that it is next to impossible to use these + consistently and make real abstraction of the binary format of + these types. Instead, at a certain level we always end up + doing casts anyway, and taking the exact binary format into + account, so these types are nothing but dangerously misleading + and obfuscating. You do not need to update calling code that + uses them, as 99.9% of such code will continue to work. But we + recommend against using them in newer calling code, and we + started replacing them with binary clear types like uint16, + uint32 and such in the library. + +
    • We do use and will continue to use one functional type + that is an exception to the above rule, being tmsize_t. This + is a signed memory size type, i.e. it is int32 on 32bit + machines, or int64 on 64bit machines. + +
    • Optionally support LZMA compression via TIFF tag 34925. + Tiffcp supports compression levels similar to "-c lzma:p1" or + "-c zip:p9 for setting the LZMA compression parameters. + +
    • Optionally defer the load of strip/tile offset and size + tags for optimized scanning of directories. Enabled with the + --enable-defer-strile-load configure option (DEFER_STRILE_LOAD + #define in tif_config.h). + +
    • Optionally enable experimental support for reading big + strips in chunks. Enabled with the --enable-chunky-strip-read + configure option. + +
    + +


    + + + +

    CHANGES IN THE TOOLS:

    + +
      + +
    • tiffset: add -d and -sd switches to allow operation on + a particular directory, not just the first. + +
    + +


    + + + +

    CHANGES IN THE CONTRIB AREA:

    + +
      +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.1.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.1.html new file mode 100644 index 000000000..5e9271738 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.1.html @@ -0,0 +1,114 @@ + + + + + Changes in TIFF v4.0.1 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • None + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • --enable-ld-version-script: New configure option to + enable shared library symbol versioning on ELF-based systems + (e.g. Linux and FreeBSD) which use the GNU linker. This + allows multiple major versions of libtiff to be loaded + simultaneously into the same application or library without + conflict, as long as all libtiffs involved are built with + versioned symbols. This option is not enabled by default. + +
    • Added libtiff private dependency on -llzma for pkg-config. + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      +
    • libtiff/tif_dir.c, libtiff/tif_dirread.c: Extra caution around + assumption tag fetching is always successful. + +
    • libtiff/tif_jpeg.c: Extra caution for case where sp is NULL. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • None + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.10.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.10.html new file mode 100644 index 000000000..578404e19 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.10.html @@ -0,0 +1,327 @@ + + + + + Changes in TIFF v4.0.10 + + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • The libtiff source repository is changed from CVS to Git and the master libtiff source repository is now at Gitlab. This is the first release to be made from the new Git repository.
    • + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • Minimum CMake version is now v2.8.11 for the CMake-based build.
    • + +
    • Libwebp will be automatically detected and used by configure/cmake if present. + +
    • Libzstd will be automatically detected and used by configure/cmake if present. + + +
    + +


    + + + +CHANGES IN LIBTIFF: + + + +


    + + + +CHANGES IN THE TOOLS: + + + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None
    • + +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.2.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.2.html new file mode 100644 index 000000000..cbed8b895 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.2.html @@ -0,0 +1,119 @@ + + + + + Changes in TIFF v4.0.2 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • None + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • None + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • tif_getimage.c: added support for _SEPARATED CMYK images. + +
    • tif_getimage.c: Added support for greyscale + alpha. + +
    • Added TIFFCreateCustomDirectory() and TIFFCreateEXIFDirectory() functions. +
    • tif_print.c: Lots of fixes around printing corrupt or + hostile input. + +
    • Improve handling of corrupt ycbcrsubsampling values. + +
    • tif_unix.c: use strerror to get meaningful error messages. + +
    • tif_jpeg.c: fix serious bugs in JPEGDecodeRaw(). + +
    • tif_jpeg.c: Fix size overflow (zdi-can-1221,CVE-2012-1173). + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tiff2pdf: Defend against integer overflows while + calculating required buffer sizes (CVE-2012-2113). + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.3.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.3.html new file mode 100644 index 000000000..e034c3f07 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.3.html @@ -0,0 +1,126 @@ + + + + + Changes in TIFF v4.0.3 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • None + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • Updated to use Automake 1.12.4. Avoids security problem with + 'make distcheck' (CVE-2012-3386). + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • Various memory buffer access fixes. + +
    • Fix handling when writing RGBA jpeg compressed imagery + (http://trac.osgeo.org/gdal/ticket/4732). + +
    • Fix to work properly with IJG JPEG 7+. + +
    • New functions TIFFFieldTag(), TIFFFieldName(), + TIFFFieldDataType(), TIFFFieldPassCount(), TIFFFieldReadCount(), + TIFFFieldWriteCount() to use as external accessors for the opaque + type TIFFField. + +
    • Fix bug rewriting image tiles in a compressed + file (http://trac.osgeo.org/gdal/ticket/4771). + +
    • Add TIFF/FX tag support in libtiff. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tiff2pdf: Fail when TIFFSetDirectory() fails. This prevents + core dumps or perhaps even arbitrary code execution when processing + a corrupt input file (CVE-2012-3401). + +
    • tiff2pdf: Fix two places where t2p_error didn't get set after a + malloc failure. No crash risk AFAICS, but the program might not + report exit code 1 as desired. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.4.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.4.html new file mode 100644 index 000000000..61c311017 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.4.html @@ -0,0 +1,275 @@ + + + + + Changes in TIFF v4.0.4 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • None + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • configure.ac / configure +
        +
      • Bugzilla Bug #2405: Correct shell equality operator. +
      • Bugzilla Bug #2498: Adds an option to select the file I/O style on Windows hosts. +
      + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • tif_dir.c: +
        +
      • TIFFNumberOfDirectories: Coverity 1134470 "Logically dead code" +
      + +
    • tif_dirread.c: +
        +
      • TIFFReadDirEntryDoubleArray: Coverity 298626 "Logically dead code". +
      • TIFFReadDirEntryFloatArray: Coverity 298627 "Logically dead code". +
      • TIFFReadDirEntryIfd8Array: Coverity 298628 "Logically dead code". +
      • TIFFReadDirEntrySlong8Array: Coverity 298629 "Logically dead code" +
      + +
    • tif_dirwrite.c +
        +
      • _TIFFRewriteField: Coverity 1024310 "Resource leak". +
      + +
    • tif_jpeg.c +
        +
      • JPEGCleanup: Coverity 298624 "Dereference before null check". +
      • JPEGDecode: Coverity 602597 "Operands don't affect result". +
      + +
    • tif_getimage.c +
        +
      • Bugzilla Bug #2409: Correct reading of certain tiled TIFFs. +
      + +
    • tif_luv.c +
        +
      • LogLuvDecodeStrip: Coverity 991239 "Division or modulo by zero". +
      • LogLuvDecodeTile: Coverity 991227 "Division or modulo by zero". +
      • LogLuvEncodeStrip: Coverity 991240 "Division or modulo by zero". +
      • LogLuvEncodeTile: Coverity 991241 "Division or modulo by zero". +
      + +
    • tif_lzw.c +
        +
      • Decode files that contain consecutive CODE_CLEAR codes. +
      + +
    • tif_ojpeg.c +
        +
      • OJPEGReadBufferFill: Coverity 603400 "Missing break in switch". +
      • OJPEGReadHeaderInfoSecStreamDht: Coverity 601720 "Resource leak". +
      + +
    • tif_read.c +
        +
      • TIFFStartTile: Coverity 715973 and 715974 "Division or modulo by zero". +
      + +
    • tif_unix.c +
        +
      • Bugzilla Bug #2510: Fix several harmless but still annoying warnings. +
      + +
    • tif_write +
        +
      • TIFFWriteEncodedStrip: Coverity 715975 "Division or modulo by zero". +
      • TIFFWriteEncodedTile: Coverity 715976 and 715977 "Division or modulo by zero". +
      • TIFFWriteRawStrip: Coverity 715978 "Division or modulo by zero". +
      • TIFFWriteScanline: Coverity 715979 "Division or modulo by zero". +
      + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • bmp2tiff +
        +
      • Coverity 1024225 "Untrusted value as argument". +
      • Coverity 1024678 "Unchecked return value from library". +
      • Coverity 1024679 "Unchecked return value from library". +
      • Coverity 1214160 "Ignoring number of bytes read". +
      + +
    • gif2tiff +
        +
      • Coverity 1024222 "Untrusted value as argument". +
      • Coverity 1024890 "Ignoring number of bytes read". +
      • Coverity 1024891 "Ignoring number of bytes read". +
      • Coverity 1024892 "Ignoring number of bytes read". +
      • Coverity 1024893 "Ignoring number of bytes read". +
      • Coverity 1024894 "Ignoring number of bytes read". +
      + +
    • ras2tiff +
        +
      • Corrected Sun Raster header definition to be safe for + 64-bit systems. Add some header validations. Fixes many + (unspecified) Coverity issues. +
      • Coverity 1024223 "Untrusted value as argument". +
      • Coverity 1301206: "Integer handling issues (BAD_SHIFT)". +
      + +
    • raw2tiff +
        +
      • Coverity 1024887 "Unchecked return value from library". +
      • Coverity 1024888 "Unchecked return value from library". +
      • Coverity 1024889 "Unchecked return value from library". +
      • Coverity 1214162 "Ignoring number of bytes read". +
      + +
    • tiff2pdf +
        +
      • Bugzilla Bug #2078. Suppress initial output of the header. +
      • Bugzilla Bug #2150. Change ColorTransform from "0" to "1". +
      • Take care in using the return value from snprintf(). +
      • Coverity 1024181 "Structurally dead code". +
      • Coverity 1024181 "Structurally dead code". +
      • Coverity 1227690 "Unused value". +
      • Coverity 298621 "Resource leak". +
      + +
    • tiff2ps +
        +
      • Correct sizing and scaling problems with output document. +
      + +
    • tiffcp +
        +
      • Coverity 1024306, 1024307, 1024308, 1024309 "Resource leak". +
      + +
    • tiffcrop +
        +
      • Correctly copy the compression tag from the source TIFF. +
      • Coverity 1024545 "Division or modulo by zero". +
      • Coverity 1024586 "Logically dead code". +
      • Coverity 1024796 "Nesting level does not match indentation". +
      • Coverity 1024797 "Nesting level does not match indentation". +
      • Coverity 1294542 "Logical vs. bitwise operator". +
      • Coverity 1299740 "Out-of-bounds write". +
      • Coverity 1299741 "Dereference before null check". +
      + +
    • tiffdither +
        +
      • Check memory allocations for failure. Also check + multiplication overflow. (Fixes #2501, CVE-2014-8128) +
      + +
    • tiffgt.c +
        +
      • Bugzilla Bug #2401. Appropriately call glFlush(). +
      + +
    • tiffmedian +
        +
      • Coverity 1024386 "Out-of-bounds read". +
      • Coverity 1024386 "Out-of-bounds read". +
      • Coverity 1024795 "Nesting level does not match indentation". +
      • Coverity 1024795 "Nesting level does not match indentation". +
      + +
    • tiffsplit +
        +
      • Coverity 1024304 "Resource leak". +
      • Coverity 1024305 "Resource leak". +
      + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • addtiffo +
        +
      • Check buffer size calculation for overflow. +
      • Coverity 298615 "Resource leak". +
      • Coverity 1024649 "Unintended sign extension". +
      + +
    • iptcutil +
        +
      • Coverity 1024468 "Infinite loop". +
      • Coverity 1024727 "Truncated stdio return value". +
      • Coverity 1214240 "Untrusted loop bound". +
      + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.4beta.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.4beta.html new file mode 100644 index 000000000..e9e70a559 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.4beta.html @@ -0,0 +1,292 @@ + + + + + Changes in TIFF v4.0.4beta + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • None + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • Updated to use Automake 1.15 and Libtool 2.4.5 + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • TIFFCheckDirOffset(): avoid uint16 overflow + when reading more than 65535 directories, and effectively error out when + eaching that limit. + +
    • TIFFNumberOfDirectories(): generate error in case of directory count + overflow. + +
    • TIFFAdvanceDirectory(): If nextdir is found to + be defective, then set it to zero before returning error in order + to terminate processing of truncated TIFF. + +
    • JPEG-in-TIFF: recognize SOF2, SOF9 and SOF10 + markers to avoid emitting a warning. Fix for compatibility with mozjpeg library. + Note: the default settings of mozjpeg will produce progressive scans, which + is forbidden by the TechNote. + +
    • JPEG-in-TIFF: Fix regression introduced in 3.9.3/4.0.0 that caused + all tiles/strips to include quantization tables even when the jpegtablesmode + had the JPEGTABLESMODE_QUANT bit set. + Also add explicit removal of Huffman tables when jpegtablesmode has the + JPEGTABLESMODE_HUFF bit set, which avoids Huffman tables to be emitted in the + first tile/strip (only useful in update scenarios. create-only was + fine) + +
    • JPEG-in-TIFF: fix segfault in JPEGFixupTagsSubsampling() on + corrupted image where tif->tif_dir.td_stripoffset == NULL. + (#2471) + +
    • NeXT codec: add new tests to check that we don't read outside of + the compressed input stream buffer. + +
    • NeXT codec: check that BitsPerSample = 2. Fixes + #2487 (CVE-2014-8129) + +
    • NeXT codec: in the "run mode", use tilewidth for tiled images + instead of imagewidth to avoid crash + +
    • tif_getimage.c: in OJPEG case, fix checks on strile width/height + in the putcontig8bitYCbCr42tile, putcontig8bitYCbCr41tile and + putcontig8bitYCbCr21tile cases. + +
    • in TIFFDefaultDirectory(), reset any already existing + extented tags installed by user code through the extender mechaninm before + calling the extender callback (GDAL #5054) + +
    • Fix warnings about unused parameters. + +
    • Fix various typos in comments found by Debian lintian tool (GDAL #5756) + +
    • tif_getimage.c: avoid divide by zero on invalid YCbCr subsampling. + (#2235) + +
    • tif_dirread.c: In EstimateStripByteCounts(), check return code + of _TIFFFillStriles(). This solves crashing bug on corrupted + images generated by afl. + +
    • tif_read.c: fix several invalid comparisons of a uint64 value with + <= 0 by casting it to int64 first. This solves crashing bug on corrupted + images generated by afl. + +
    • TIFFSetField(): refuse to set negative values for + TIFFTAG_XRESOLUTION and TIFFTAG_YRESOLUTION that cause asserts when writing + the directory + +
    • TIFFReadDirectory(): refuse to read ColorMap or + TransferFunction if BitsPerSample has not yet been read, otherwise reading + it later will cause user code to crash if BitsPerSample > 1 + +
    • TIFFRGBAImageOK(): return FALSE if LOGLUV with + SamplesPerPixel != 3, or if CIELAB with SamplesPerPixel != 3 or BitsPerSample != 8 + +
    • tif_config.vc.h: no longer use "#define snprintf _snprintf" with + Visual Studio 2015 aka VC 14 aka MSVC 1900 + +
    • LZW codec: prevent potential null dereference of sp->dec_codetab in LZWPreDecode + (#2459) + +
    • TIFFReadBufferSetup(): avoid passing -1 size + to TIFFmalloc() if passed user buffer size is 0 + (#2459) + +
    • TIFFReadDirEntryOutputErr(): Incorrect + count for tag should be a warning rather than an error since + errors terminate processing. + +
    • tif_dirinfo.c (TIFFField) : Fix data type for TIFFTAG_GLOBALPARAMETERSIFD tag. + +
    • Add definitions for TIFF/EP CFARepeatPatternDim and CFAPattern tags + (#2457) + +
    • tif_codec.c, tif_dirinfo.c: Enlarge some fixed-size buffers that weren't + large enough, and eliminate substantially all uses of sprintf(buf, + ...) in favor of using snprintf(buf, sizeof(buf), ...) +
    • configure.ac: Improve pkg-config static linking by adding -lm to Libs.private when needed. + +
    • tif_write.c: tmsize_t related casting warning fixed for + 64bit linux. + +
    • tif_read.c: uint64/tmsize_t change for MSVC warnings. + (#2427) + +
    • Fix TIFFPrintDirectory's handling of + field_passcount fields: it had the TIFF_VARIABLE and + TIFF_VARIABLE2 cases backwards. + +
    • PixarLog codec: Improve previous patch for CVE-2012-4447 + (to enlarge tbuf for possible partial stride at end) so that + overflow in the integer addition is detected. + +
    • tif_{unix,vms,win32}.c (_TIFFmalloc): ANSI C does not + require malloc() to return NULL pointer if requested allocation + size is zero. Assure that _TIFFmalloc does. + +
    • tif_zip.c: Avoid crash on NULL error messages. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tiff2pdf: Fis various crashes and memory buffer access errors (oCERT-2014-013). +
    • tiff2pdf: fix buffer overflow on some YCbCr JPEG compressed images. + (#2445) +
    • tiff2pdf: fix buffer overflow on YCbCr JPEG compressed image. + (#2443) +
    • tiff2pdf: check return code of TIFFGetField() when reading TIFFTAG_SAMPLESPERPIXEL +
    • tiff2pdf: fix crash due to invalid tile count. +
    • tiff2pdf: Detect invalid settings of BitsPerSample/SamplesPerPixel for CIELAB / ITULAB +
    • tiff2pdf: Assure that memory size calculations for + _TIFFmalloc() do not overflow the range of tmsize_t. +
    • tiff2pdf: Avoid crash when TIFFTAG_TRANSFERFUNCTION tag returns one channel, + with the other two channels set to NULL. +
    • tiff2pdf: close PDF file. (#2479) +
    • tiff2pdf: Preserve input file directory order when pages + are tagged with the same page number. +
    • tiff2pdf.c: terminate after failure of allocating ycbcr buffer + (#2449 CVE-2013-4232) +
    • tiff2pdf: Rewrite JPEG marker parsing in + t2p_process_jpeg_strip to be at least marginally competent. The + approach is still fundamentally flawed, but at least now it won't + stomp all over memory when given bogus input. Fixes CVE-2013-1960. +
    • tiffdump: Guard against arithmetic overflow when calculating allocation buffer sizes. +
    • tiffdump: fix crash due to overflow of entry count. +
    • tiffdump: Fix double-free bug. +
    • tiffdump: detect cycle in TIFF directory chaining. + (#2463) +
    • tiffdump: avoid passing a NULL pointer to read() if seek() failed before. + (#2459) +
    • tiff2bw: when Photometric=RGB, the utility only works if SamplesPerPixel = 3. Enforce that. + (#2485, CVE-2014-8127) +
    • pal2rgb, thumbnail: fix crash by disabling TIFFTAG_INKNAMES copying. + (#2484, CVE-2014-8127) +
    • thumbnail: fix out-of-buffer write. + (#2489, CVE-2014-8128) +
    • thumbnail, tiffcmp: only read/write TIFFTAG_GROUP3OPTIONS + or TIFFTAG_GROUP4OPTIONS if compression is COMPRESSION_CCITTFAX3 or + COMPRESSION_CCITTFAX4. + (#2493, CVE-2014-8128) +
    • tiffcp: fix crash when converting YCbCr JPEG-compressed to none. + (#2480) +
    • bmp2tiff: fix crash due to int overflow related to input BMP dimensions +
    • tiffcrop: fix crash due to invalid TileWidth/TileHeight +
    • tiffcrop: fix segfault if bad value passed to -Z option + ( #2459) + and add missing va_end in dump_info +
    • thumbnail, tiffcrop: "fix" heap read over-run found with + Valgrind and Address Sanitizer on test suite +
    • fax2ps: check malloc()/realloc() result. (#2470) +
    • gif2tiff: apply patch for CVE-2013-4243. (#2451) +
    • gif2tiff: fix possible OOB write. (#2452, CVE-2013-4244) +
    • gif2tiff: Be more careful about corrupt or hostile input files (#2450, CVE-2013-4231) +
    • tiff2rgba: fix usage message in that zip was wrongly described +
    • tiffinfo: Default various values fetched with TIFFGetField() to avoid being uninitialized. +
    • tiff2ps: Fix bug in auto rotate option code. +
    • ppm2tiff: avoid zero size buffer vulnerability (CVE-2012-4564). + check the linebytes calculation too, get the max() calculation + straight, avoid redundant error messages, check for malloc + failure. +
    • tiffset: now supports a -u option to unset a tag. + (#2419) +
    • Fix warnings about unused parameters. +
    • rgb2ycbcr, tiff2bw, tiff2pdf, tiff2ps, tiffcrop, tiffdither : + Enlarge some fixed-size buffers that weren't + large enough, and eliminate substantially all uses of sprintf(buf, + ...) in favor of using snprintf(buf, sizeof(buf), ...), so as to + protect against overflow of fixed-size buffers. This responds in + particular to CVE-2013-1961 concerning overflow in tiff2pdf.c's + t2p_write_pdf_page(). +
    • html/man/tiff2ps.1.html, html/man/tiffcp.1.html, + html/man/tiffdither.1.html, man/tiff2ps.1, man/tiffcp.1, + man/tiffdither.1, tools/tiff2ps.c, tools/tiffcp.c, + tools/tiffdither.c: Sync tool usage printouts and man pages with + reality + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • Fix warnings about variables set but not used. +
    • contrib/dbs/xtiff/xtiff.c: Enlarge some fixed-size buffers that weren't + large enough, and eliminate substantially all uses of sprintf(buf, + ...) in favor of using snprintf(buf, sizeof(buf), ...), so as to + protect against overflow of fixed-size buffers. +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.5.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.5.html new file mode 100644 index 000000000..a3354704d --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.5.html @@ -0,0 +1,149 @@ + + + + + Changes in TIFF v4.0.5 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • Support for configure/build using CMake. +
    • Support for large (> 2GB) files under Microsoft Windows. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • CMakeLists.txt / CMake +
        +
      • Configuration and building using CMake is now supported + under Microsoft Windows and on Unix-type systems. +
      +
    • + +
    • configure.ac / configure +
        +
      • Test for and use fseeko() if it is available. This allows + supporting large files on Unix-type systems with a 32-bit 'long' + type and a 64-bit 'off_t' type. +
      +
    • + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • tiffiop.h: +
        +
      • Macros added to use 64-bit equivalents for all standard I/O + and POSIX APIs used by libtiff and its tools which are limited + to 2GB in Windows builds. Note that these 64-bit equivalents + were introduced by the CRT provided with Visual Studio 2005 and + if the necessary CRT is not installed on the target computer, + the program will not run. The wrapper macros will not be + activated unless the definition _MSC_VER is at least 1400 or + __MSVCRT_VERSION__ is at least 0x800. +
      + +
    • tif_unix.c: +
        +
      • Updated to support large files under Microsoft Windows. + This makes tif_unix.c a completely viable candidate for use + under Windows (in spite of its name) if the CRT is modern + enough. Please note that tif_win32.c already supported large + files, but only 'tiffinfo' and 'tiffdump' made any provision to + support large files under Windows. +
      • _tiffReadProc() and _tiffWriteProc() are modified to chunk + I/O to a maximum size of 2GB for extremely large I/O + requests. This surmounts limitations in the Microsoft Windows + read() and write() APIs (which are limited to the range of a + 32-bit 'int'), and may avoid poor behavior with extremely large + I/O requests on other systems. +
      + + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • All tools +
        +
      • Updated to use I/O wrapper macros from tiffiop.h in order + to support large files under Microsoft Windows. +
      + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.6.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.6.html new file mode 100644 index 000000000..dbca5c86e --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.6.html @@ -0,0 +1,140 @@ + + + + + Changes in TIFF v4.0.6 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • Now builds with CMake 2.8.9 and newer (previously required 3.0.0) + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • CMakeLists.txt / CMake +
        +
      • Supports CMake 2.8.9 and later. +
      • Add missing file which wasn't being distributed, causing + unit tests to fail. +
      • Make shared/static library building configurable. +
      • CMake reads all version information directly from + configure.ac to avoid duplication of values. +
      • CMake builds are now included in 'distcheck' target. +
      +
    • + +
    • Makefile.am +
        +
      • Autotools 'make distcheck' now tests the CMake-based build + if CMake is available. +
      +
    • + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • Fixes to avoid undefined behaviour of signed types (C + standard compliance). +
    • Fixes to avoid possible isses when casting to unsigned char. +
    • Fixes to avoid undefined behaviour with shifts. +
    • Fix generation of output with 16 bit or 32 bit integer, when + byte swapping is needed, in horizontal predictor (#2521). +
    • Fix decoding when there is a single pixel to decode (unlikely + case...) and byte swapping is involved. +
    • Add add explicit masking with 0xff before casting to uchar in + floating-point horizontal differencing and accumulation routines. +
    • Eliminate requirement for and use of 64-bit constant values. + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tiffgt +
        +
      • Silence glut API deprecation warnings on MacOS X. +
      + + +
    • fax2ps +
        +
      • Detect failure to write to temporary file. +
      + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-09-25 20:05:47 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.7.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.7.html new file mode 100644 index 000000000..4f92c129c --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.7.html @@ -0,0 +1,412 @@ + + + + + Changes in TIFF v4.0.7 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • The libtiff tools bmp2tiff, gif2tiff, ras2tiff, sgi2tiff, + sgisv, and ycbcr are completely removed from the distribution. + These tools were written in the late 1980s and early 1990s for + test and demonstration purposes. In some cases the tools were + never updated to support updates to the file format, or the + file formats are now rarely used. In all cases these tools + increased the libtiff security and maintenance exposure beyond + the value offered by the tool. + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • None + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • libtiff/tif_dirread.c: in TIFFFetchNormalTag(), do not + dereference NULL pointer when values of tags with + TIFF_SETGET_C16_ASCII / TIFF_SETGET_C32_ASCII access are + 0-byte arrays. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2593 (regression + introduced by previous fix done on 2016-11-11 for + CVE-2016-9297). Reported by Henri Salo. Assigned as + CVE-2016-9448 + +
    • libtiff/tif_aux.c: fix crash in TIFFVGetFieldDefaulted() when + requesting Predictor tag and that the zip/lzw codec is not + configured. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2591 + +
    • libtiff/tif_dirread.c: in TIFFFetchNormalTag(), make sure + that values of tags with TIFF_SETGET_C16_ASCII / + TIFF_SETGET_C32_ASCII access are null terminated, to avoid + potential read outside buffer in _TIFFPrintField(). Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2590 + +
    • libtiff/tif_dirread.c: reject images with OJPEG compression + that have no TileOffsets/StripOffsets tag, when OJPEG + compression is disabled. Prevent null pointer dereference in + TIFFReadRawStrip1() and other functions that expect + td_stripbytecount to be non NULL. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2585 + +
    • libtiff/tif_strip.c: make TIFFNumberOfStrips() return the + td->td_nstrips value when it is non-zero, instead of + recomputing it. This is needed in TIFF_STRIPCHOP mode where + td_nstrips is modified. Fixes a read outsize of array in + tiffsplit (or other utilities using TIFFNumberOfStrips()). + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2587 + (CVE-2016-9273) + +
    • libtiff/tif_predict.h, libtiff/tif_predict.c: Replace + assertions by runtime checks to avoid assertions in debug + mode, or buffer overflows in release mode. Can happen when + dealing with unusual tile size like YCbCr with + subsampling. Reported as MSVR 35105 by Axel Souchet & Vishal + Chauhan from the MSRC Vulnerabilities & Mitigations + +
    • libtiff/tif_dir.c: discard values of SMinSampleValue and + SMaxSampleValue when they have been read and the value of + SamplesPerPixel is changed afterwards (like when reading a + OJPEG compressed image with a missing SamplesPerPixel tag, and + whose photometric is RGB or YCbCr, forcing SamplesPerPixel + being 3). Otherwise when rewriting the directory (for example + with tiffset, we will expect 3 values whereas the array had + been allocated with just one), thus causing a out of bound + read access. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2500 + (CVE-2014-8127, duplicate: CVE-2016-3658) + +
    • libtiff/tif_dirwrite.c: avoid null pointer dereference on + td_stripoffset when writing directory, if FIELD_STRIPOFFSETS + was artificially set for a hack case in OJPEG case. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2500 + (CVE-2014-8127, duplicate: CVE-2016-3658) + +
    • libtiff/tif_getimage.c (TIFFRGBAImageOK): Reject attempts to + read floating point images. + +
    • libtiff/tif_predict.c (PredictorSetup): Enforce + bits-per-sample requirements of floating point predictor (3). + Fixes CVE-2016-3622 "Divide By Zero in the tiff2rgba tool." + +
    • libtiff/tif_pixarlog.c: fix out-of-bounds write vulnerabilities + in heap allocated buffers. Reported as MSVR 35094. Discovered by + Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities & + Mitigations team. + +
    • libtiff/tif_write.c: fix issue in error code path of + TIFFFlushData1() that didn't reset the tif_rawcc and tif_rawcp + members. I'm not completely sure if that could happen in + practice outside of the odd behaviour of t2p_seekproc() of + tiff2pdf). The report points that a better fix could be to + check the return value of TIFFFlushData1() in places where it + isn't done currently, but it seems this patch is enough. + Reported as MSVR 35095. Discovered by Axel Souchet & Vishal + Chauhan & Suha Can from the MSRC Vulnerabilities & Mitigations + team. + +
    • libtiff/tif_pixarlog.c: Fix write buffer overflow in + PixarLogEncode if more input samples are provided than + expected by PixarLogSetupEncode. Idea based on + libtiff-CVE-2016-3990.patch from + libtiff-4.0.3-25.el7_2.src.rpm by Nikola Forro, but with + different and simpler check. (bugzilla #2544) + +
    • libtiff/tif_read.c: Fix out-of-bounds read on memory-mapped + files in TIFFReadRawStrip1() and TIFFReadRawTile1() when + stripoffset is beyond tmsize_t max value (reported by Mathias + Svensson) + +
    • libtiff/tif_read.c: make TIFFReadEncodedStrip() and + TIFFReadEncodedTile() directly use user provided buffer when + no compression (and other conditions) to save a memcpy() + +
    • libtiff/tif_write.c: make TIFFWriteEncodedStrip() and + TIFFWriteEncodedTile() directly use user provided buffer when + no compression to save a memcpy(). + +
    • libtiff/tif_luv.c: validate that for COMPRESSION_SGILOG and + PHOTOMETRIC_LOGL, there is only one sample per pixel. Avoid + potential invalid memory write on corrupted/unexpected images + when using the TIFFRGBAImageBegin() interface (reported by + Clay Wood) + +
    • libtiff/tif_pixarlog.c: fix potential buffer write overrun in + PixarLogDecode() on corrupted/unexpected images (reported by + Mathias Svensson) (CVE-2016-5875) + +
    • libtiff/libtiff.def: Added _TIFFMultiply32 and + _TIFFMultiply64 to libtiff.def + +
    • libtiff/tif_config.vc.h (HAVE_SNPRINTF): Add a '1' to the + HAVE_SNPRINTF definition. + +
    • libtiff/tif_config.vc.h (HAVE_SNPRINTF): Applied patch by + Edward Lam to define HAVE_SNPRINTF for Visual Studio 2015. + +
    • libtiff/tif_dirread.c: when compiled with DEFER_STRILE_LOAD, + fix regression, introduced on 2014-12-23, when reading a + one-strip file without a StripByteCounts tag. GDAL #6490 + +
    • libtiff/*: upstream typo fixes (mostly contributed by Kurt + Schwehr) coming from GDAL internal libtiff + +
    • libtiff/tif_fax3.h: make Param member of TIFFFaxTabEnt + structure a uint16 to reduce size of the binary. + +
    • libtiff/tif_read.c, tif_dirread.c: fix indentation issues + raised by GCC 6 -Wmisleading-indentation + +
    • libtiff/tif_pixarlog.c: avoid zlib error messages to pass a + NULL string to %s formatter, which is undefined behaviour in + sprintf(). + +
    • libtiff/tif_next.c: fix potential out-of-bound write in NeXTDecode() + triggered by http://lcamtuf.coredump.cx/afl/vulns/libtiff5.tif + (bugzilla #2508) + +
    • libtiff/tif_luv.c: fix potential out-of-bound writes in + decode functions in non debug builds by replacing assert()s by + regular if checks (bugzilla #2522). Fix potential + out-of-bound reads in case of short input data. + +
    • libtiff/tif_getimage.c: fix out-of-bound reads in + TIFFRGBAImage interface in case of unsupported values of + SamplesPerPixel/ExtraSamples for LogLUV / CIELab. Add explicit + call to TIFFRGBAImageOK() in TIFFRGBAImageBegin(). Fix + CVE-2015-8665 reported by limingxing and CVE-2015-8683 + reported by zzf of Alibaba. + +
    • libtiff/tif_dirread.c: workaround false positive warning of + Clang Static Analyzer about null pointer dereference in + TIFFCheckDirOffset(). + +
    • libtiff/tif_fax3.c: remove dead assignment in + Fax3PutEOLgdal(). Found by Clang Static Analyzer + +
    • libtiff/tif_dirwrite.c: fix truncation to 32 bit of file + offsets in TIFFLinkDirectory() and TIFFWriteDirectorySec() + when aligning directory offsets on a even offset (affects + BigTIFF). This was a regression of the changeset of + 2015-10-19. + +
    • libtiff/tif_write.c: TIFFWriteEncodedStrip() and + TIFFWriteEncodedTile() should return -1 in case of failure of + tif_encodestrip() as documented + +
    • libtiff/tif_dumpmode.c: DumpModeEncode() should return 0 in + case of failure so that the above mentionned functions detect + the error. + +
    • libtiff/*.c: fix MSVC warnings related to cast shortening and + assignment within conditional expression + +
    • libtiff/*.c: fix clang -Wshorten-64-to-32 warnings + +
    • libtiff/tif_dirread.c: prevent reading ColorMap or + TransferFunction if BitsPerPixel > 24, so as to avoid huge + memory allocation and file read attempts + +
    • libtiff/tif_dirread.c: remove duplicated assignment (reported + by Clang static analyzer) + +
    • libtiff/tif_dir.c, libtiff/tif_dirinfo.c, + libtiff/tif_compress.c, libtiff/tif_jpeg_12.c: suppress + warnings about 'no previous declaration/prototype' + +
    • libtiff/tiffiop.h, libtiff/tif_dirwrite.c: suffix constants + by U to fix 'warning: negative integer implicitly converted to + unsigned type' warning (part of -Wconversion) + +
    • libtiff/tif_dir.c, libtiff/tif_dirread.c, + libtiff/tif_getimage.c, libtiff/tif_print.c: fix -Wshadow + warnings (only in libtiff/) + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tools/Makefile.am: The libtiff tools bmp2tiff, gif2tiff, + ras2tiff, sgi2tiff, sgisv, and ycbcr are completely removed + from the distribution. The libtiff tools rgb2ycbcr and + thumbnail are only built in the build tree for testing. Old + files are put in new 'archive' subdirectory of the source + repository, but not in distribution archives. These changes + are made in order to lessen the maintenance burden. + +
    • tools/tiff2pdf.c: avoid undefined behaviour related to + overlapping of source and destination buffer in memcpy() call + in t2p_sample_rgbaa_to_rgb() Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2577 + +
    • tools/tiff2pdf.c: fix potential integer overflows on 32 bit + builds in t2p_read_tiff_size() Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2576 + +
    • tools/fax2tiff.c: fix segfault when specifying -r without + argument. Patch by Yuriy M. Kaminskiy. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2572 + +
    • tools/tiffinfo.c: fix out-of-bound read on some tiled images. + (http://bugzilla.maptools.org/show_bug.cgi?id=2517) + +
    • tools/tiffcrop.c: fix multiple uint32 overflows in + writeBufferToSeparateStrips(), writeBufferToContigTiles() and + writeBufferToSeparateTiles() that could cause heap buffer + overflows. Reported by Henri Salo from Nixu Corporation. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2592 + +
    • tools/tiffcrop.c: fix out-of-bound read of up to 3 bytes in + readContigTilesIntoBuffer(). Reported as MSVR 35092 by Axel + Souchet & Vishal Chauhan from the MSRC Vulnerabilities & + Mitigations team. + +
    • tools/tiff2pdf.c: fix write buffer overflow of 2 bytes on + JPEG compressed images. Reported by Tyler Bohan of Cisco Talos + as TALOS-CAN-0187 / CVE-2016-5652. Also prevents writing 2 + extra uninitialized bytes to the file stream. + +
    • tools/tiffcp.c: fix out-of-bounds write on tiled images with odd + tile width vs image width. Reported as MSVR 35103 + by Axel Souchet and Vishal Chauhan from the MSRC Vulnerabilities & + Mitigations team. + +
    • tools/tiff2pdf.c: fix read -largely- outsize of buffer in + t2p_readwrite_pdf_image_tile(), causing crash, when reading a + JPEG compressed image with TIFFTAG_JPEGTABLES length being + one. Reported as MSVR 35101 by Axel Souchet and Vishal + Chauhan from the MSRC Vulnerabilities & Mitigations team. + +
    • tools/tiffcp.c: fix read of undefined variable in case of + missing required tags. Found on test case of MSVR 35100. + +
    • tools/tiffcrop.c: fix read of undefined buffer in + readContigStripsIntoBuffer() due to uint16 overflow. Probably + not a security issue but I can be wrong. Reported as MSVR + 35100 by Axel Souchet from the MSRC Vulnerabilities & + Mitigations team. + +
    • tools/tiffcrop.c: fix various out-of-bounds write + vulnerabilities in heap or stack allocated buffers. Reported + as MSVR 35093, MSVR 35096 and MSVR 35097. Discovered by Axel + Souchet and Vishal Chauhan from the MSRC Vulnerabilities & + Mitigations team. + +
    • tools/tiff2pdf.c: fix out-of-bounds write vulnerabilities in + heap allocate buffer in t2p_process_jpeg_strip(). Reported as + MSVR 35098. Discovered by Axel Souchet and Vishal Chauhan from + the MSRC Vulnerabilities & Mitigations team. + +
    • tools/tiff2bw.c: fix weight computation that could result of + color value overflow (no security implication). Fix bugzilla + #2550. Patch by Frank Freudenberg. + +
    • tools/rgb2ycbcr.c: validate values of -v and -h parameters to + avoid potential divide by zero. Fixes CVE-2016-3623 (bugzilla #2569) + +
    • tools/tiffcrop.c: Fix out-of-bounds write in loadImage(). + From patch libtiff-CVE-2016-3991.patch from + libtiff-4.0.3-25.el7_2.src.rpm by Nikola Forro (bugzilla + #2543) + +
    • tools/tiff2rgba.c: Fix integer overflow in size of allocated + buffer, when -b mode is enabled, that could result in + out-of-bounds write. Based initially on patch + tiff-CVE-2016-3945.patch from libtiff-4.0.3-25.el7_2.src.rpm + by Nikola Forro, with correction for invalid tests that + rejected valid files. (bugzilla #2545) + +
    • tools/tiffcrop.c: Avoid access outside of stack allocated + array on a tiled separate TIFF with more than 8 samples per + pixel. Reported by Kaixiang Zhang of the Cloud Security Team, + Qihoo 360 (CVE-2016-5321 / CVE-2016-5323 , bugzilla #2558 / + #2559) + +
    • tools/tiffdump.c: fix a few misaligned 64-bit reads warned by + -fsanitize + +
    • tools/tiffdump.c (ReadDirectory): Remove uint32 cast to + _TIFFmalloc() argument which resulted in Coverity report. + Added more mutiplication overflow checks. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2016-11-19 17:47:40 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.8.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.8.html new file mode 100644 index 000000000..bd3f751c1 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.8.html @@ -0,0 +1,446 @@ + + + + + Changes in TIFF v4.0.8 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • None + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • None + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • libtiff/tif_getimage.c, libtiff/tif_open.c: add parenthesis + to fix cppcheck clarifyCalculation warnings * + libtiff/tif_predict.c, libtiff/tif_print.c: fix printf + unsigned vs signed formatting (cppcheck + invalidPrintfArgType_uint warnings) + +
    • libtiff/tif_read.c, libtiff/tiffiop.h: fix uint32 overflow in + TIFFReadEncodedStrip() that caused an integer division by + zero. Reported by Agostino Sarubbo. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2596 + +
    • libtiff/tif_pixarlog.c, libtiff/tif_luv.c: fix heap-based + buffer overflow on generation of PixarLog / LUV compressed + files, with ColorMap, TransferFunction attached and nasty + plays with bitspersample. The fix for LUV has not been + tested, but suffers from the same kind of issue of PixarLog. + Reported by Agostino Sarubbo. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2604 + +
    • libtiff/tif_strip.c: revert the change in + TIFFNumberOfStrips() done for + http://bugzilla.maptools.org/show_bug.cgi?id=2587 / + CVE-2016-9273 since the above change is a better fix that + makes it unnecessary. + +
    • libtiff/tif_dirread.c: modify ChopUpSingleUncompressedStrip() + to instanciate compute ntrips as + TIFFhowmany_32(td->td_imagelength, rowsperstrip), instead of a + logic based on the total size of data. Which is faulty is the + total size of data is not sufficient to fill the whole image, + and thus results in reading outside of the + StripByCounts/StripOffsets arrays when using + TIFFReadScanline(). Reported by Agostino Sarubbo. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2608. + +
    • libtiff/tif_ojpeg.c: make OJPEGDecode() early exit in case of + failure in OJPEGPreDecode(). This will avoid a divide by zero, + and potential other issues. Reported by Agostino Sarubbo. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2611 + +
    • libtiff/tif_write.c: fix misleading indentation as warned by GCC. + + +
    • libtiff/tif_fax3.h: revert change done on 2016-01-09 that + made Param member of TIFFFaxTabEnt structure a uint16 to + reduce size of the binary. It happens that the Hylafax + software uses the tables that follow this typedef + (TIFFFaxMainTable, TIFFFaxWhiteTable, TIFFFaxBlackTable), + although they are not in a public libtiff header. Raised by + Lee Howard. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2636 + +
    • libtiff/tiffio.h, libtiff/tif_getimage.c: add + TIFFReadRGBAStripExt() and TIFFReadRGBATileExt() variants of + the functions without ext, with an extra argument to control + the stop_on_error behaviour. + +
    • libtiff/tif_getimage.c: fix potential memory leaks in error + code path of TIFFRGBAImageBegin(). Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2627 + +
    • libtiff/tif_jpeg.c: increase libjpeg max memory usable to 10 + MB instead of libjpeg 1MB default. This helps when creating + files with "big" tile, without using libjpeg temporary files. + Related to https://trac.osgeo.org/gdal/ticket/6757 + +
    • libtiff/tif_jpeg.c: avoid integer division by zero in + JPEGSetupEncode() when horizontal or vertical sampling is set + to 0. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2653 + +
    • libtiff/tif_dirwrite.c: in + TIFFWriteDirectoryTagCheckedRational, replace assertion by + runtime check to error out if passed value is strictly + negative. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2535 + +
    • libtiff/tif_dirread.c: avoid division by floating point 0 in + TIFFReadDirEntryCheckedRational() and + TIFFReadDirEntryCheckedSrational(), and return 0 in that case + (instead of infinity as before presumably) Apparently some + sanitizers do not like those divisions by zero. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2644 + +
    • libtiff/tif_dir.c, tif_dirread.c, tif_dirwrite.c: implement + various clampings of double to other data types to avoid + undefined behaviour if the output range isn't big enough to + hold the input value. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2643 + http://bugzilla.maptools.org/show_bug.cgi?id=2642 + http://bugzilla.maptools.org/show_bug.cgi?id=2646 + http://bugzilla.maptools.org/show_bug.cgi?id=2647 + +
    • libtiff/tif_jpeg.c: validate BitsPerSample in + JPEGSetupEncode() to avoid undefined behaviour caused by + invalid shift exponent. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2648 + +
    • libtiff/tif_read.c: avoid potential undefined behaviour on + signed integer addition in TIFFReadRawStrip1() in isMapped() + case. Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2650 + +
    • libtiff/tif_getimage.c: add explicit uint32 cast in + putagreytile to avoid UndefinedBehaviorSanitizer warning. + Patch by Nicolás Peña. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2658 + +
    • libtiff/tif_read.c: TIFFReadBufferSetup(): use _TIFFcalloc() + to zero initialize tif_rawdata. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2651 + +
    • libtiff/tiffio.h, tif_unix.c, tif_win32.c, tif_vms.c: add + _TIFFcalloc() + +
    • libtiff/tif_luv.c, tif_lzw.c, tif_packbits.c: return 0 in + Encode functions instead of -1 when TIFFFlushData1() fails. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2130 + +
    • libtiff/tif_ojpeg.c: fix leak in + OJPEGReadHeaderInfoSecTablesQTable, + OJPEGReadHeaderInfoSecTablesDcTable and + OJPEGReadHeaderInfoSecTablesAcTable when read fails. Patch by + Nicolás Peña. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2659 + +
    • libtiff/tif_jpeg.c: only run JPEGFixupTagsSubsampling() if + the YCbCrSubsampling tag is not explicitly present. This helps + a bit to reduce the I/O amount when the tag is present + (especially on cloud hosted files). + +
    • libtiff/tif_lzw.c: in LZWPostEncode(), increase, if + necessary, the code bit-width after flushing the remaining + code and before emitting the EOI code. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=1982 + +
    • libtiff/tif_pixarlog.c: fix memory leak in error code path of + PixarLogSetupDecode(). Patch by Nicolás Peña. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2665 + +
    • libtiff/tif_fax3.c, tif_predict.c, tif_getimage.c: fix GCC 7 + -Wimplicit-fallthrough warnings. + +
    • libtiff/tif_dirread.c: fix memory leak in non + DEFER_STRILE_LOAD mode (ie default) when there is both a + StripOffsets and TileOffsets tag, or a StripByteCounts and + TileByteCounts Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2689 + +
    • libtiff/tif_ojpeg.c: fix potential memory leak in + OJPEGReadHeaderInfoSecTablesQTable, + OJPEGReadHeaderInfoSecTablesDcTable and + OJPEGReadHeaderInfoSecTablesAcTable Patch by Nicolás Peña. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2670 + +
    • libtiff/tif_fax3.c: avoid crash in Fax3Close() on empty file. + Patch by Alan Coopersmith + complement by myself. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2673 + +
    • libtiff/tif_read.c: TIFFFillStrip(): add limitation to the + number of bytes read in case td_stripbytecount[strip] is + bigger than reasonable, so as to avoid excessive memory + allocation. + +
    • libtiff/tif_zip.c, tif_pixarlog.c, tif_predict.c: fix memory + leak when the underlying codec (ZIP, PixarLog) succeeds its + setupdecode() method, but PredictorSetup fails. Credit to + OSS-Fuzz (locally run, on GDAL) + +
    • libtiff/tif_read.c: TIFFFillStrip() and TIFFFillTile(): avoid + excessive memory allocation in case of shorten files. Only + effective on 64 bit builds and non-mapped cases. Credit to + OSS-Fuzz (locally run, on GDAL) + +
    • libtiff/tif_read.c: TIFFFillStripPartial() / TIFFSeek(), + avoid potential integer overflows with read_ahead in + CHUNKY_STRIP_READ_SUPPORT mode. Should + especially occur on 32 bit platforms. + +
    • libtiff/tif_read.c: TIFFFillStripPartial(): avoid excessive + memory allocation in case of shorten files. Only effective on + 64 bit builds. Credit to OSS-Fuzz (locally run, on GDAL) + +
    • libtiff/tif_read.c: update tif_rawcc in + CHUNKY_STRIP_READ_SUPPORT mode with tif_rawdataloaded when + calling TIFFStartStrip() or TIFFFillStripPartial(). This + avoids reading beyond tif_rawdata when bytecount > + tif_rawdatasize. Fixes + https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1545. + Credit to OSS-Fuzz + +
    • libtiff/tif_color.c: avoid potential int32 overflow in + TIFFYCbCrToRGBInit() Fixes + https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1533 + Credit to OSS-Fuzz + +
    • libtiff/tif_pixarlog.c, tif_luv.c: avoid potential int32 + overflows in multiply_ms() and add_ms(). Fixes + https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1558 + Credit to OSS-Fuzz + +
    • libtiff/tif_packbits.c: fix out-of-buffer read in + PackBitsDecode() Fixes + https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1563 + Credit to OSS-Fuzz + +
    • libtiff/tif_luv.c: LogL16InitState(): avoid excessive memory + allocation when RowsPerStrip tag is missing. + Credit to OSS-Fuzz (locally run, on GDAL) + +
    • libtiff/tif_lzw.c: update dec_bitsleft at beginning of + LZWDecode(), and update tif_rawcc at end of LZWDecode(). This + is needed to properly work with the latest chnges in + tif_read.c in CHUNKY_STRIP_READ_SUPPORT mode. + +
    • libtiff/tif_pixarlog.c: PixarLogDecode(): resync tif_rawcp + with next_in and tif_rawcc with avail_in at beginning and end + of function, similarly to what is done in LZWDecode(). Likely + needed so that it works properly with latest chnges in + tif_read.c in CHUNKY_STRIP_READ_SUPPORT mode. But untested... + +
    • libtiff/tif_getimage.c: initYCbCrConversion(): add basic + validation of luma and refBlackWhite coefficients (just check + they are not NaN for now), to avoid potential float to int + overflows. Fixes + https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1663 + Credit to OSS Fuzz + +
    • libtiff/tif_read.c: _TIFFVSetField(): fix outside range cast + of double to float. Credit to Google Autofuzz project + +
    • libtiff/tif_getimage.c: initYCbCrConversion(): check luma[1] + is not zero to avoid division by zero. Fixes + https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1665 + Credit to OSS Fuzz + +
    • libtiff/tif_read.c: _TIFFVSetField(): fix outside range cast + of double to float. Credit to Google Autofuzz project + +
    • libtiff/tif_getimage.c: initYCbCrConversion(): check luma[1] + is not zero to avoid division by zero. Fixes + https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1665 + Credit to OSS Fuzz + +
    • libtiff/tif_getimage.c: initYCbCrConversion(): stricter + validation for refBlackWhite coefficients values. To avoid + invalid float->int32 conversion. Fixes + https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1718 + Credit to OSS Fuzz + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tools/fax2tiff.c (main): Applied patch by Jörg Ahrens to fix + passing client data for Win32 builds using tif_win32.c + (USE_WIN32_FILEIO defined) for file I/O. Patch was provided + via email on November 20, 2016. + +
    • tools/tiffcp.c: avoid uint32 underflow in cpDecodedStrips + that can cause various issues, such as buffer overflows in the + library. Reported by Agostino Sarubbo. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2598 + +
    • tools/tiffcrop.c: fix readContigStripsIntoBuffer() in -i + (ignore) mode so that the output buffer is correctly + incremented to avoid write outside bounds. Reported by + Agostino Sarubbo. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2620 + +
    • tools/tiffcrop.c: add 3 extra bytes at end of strip buffer in + readSeparateStripsIntoBuffer() to avoid read outside of heap + allocated buffer. Reported by Agostino Sarubbo. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2621 + +
    • tools/tiffcrop.c: fix integer division by zero when + BitsPerSample is missing. Reported by Agostino Sarubbo. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2619 + +
    • tools/tiffinfo.c: fix null pointer dereference in -r mode + when the image has no StripByteCount tag. Reported by + Agostino Sarubbo. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2594 + +
    • tools/tiffcp.c: avoid potential division by zero is + BitsPerSamples tag is missing. Reported by Agostino Sarubbo. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2597 + +
    • tools/tif_dir.c: when TIFFGetField(, TIFFTAG_NUMBEROFINKS, ) + is called, limit the return number of inks to SamplesPerPixel, + so that code that parses ink names doesn't go past the end of + the buffer. Reported by Agostino Sarubbo. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2599 + +
    • tools/tiffcp.c: avoid potential division by zero is + BitsPerSamples tag is missing. Reported by Agostino Sarubbo. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2607 + +
    • tools/tiffcp.c: fix uint32 underflow/overflow that can cause + heap-based buffer overflow. Reported by Agostino Sarubbo. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2610 + +
    • tools/tiffcp.c: replace assert( (bps % 8) == 0 ) by a non + assert check. Reported by Agostino Sarubbo. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2605 + +
    • tools/tiff2ps.c: fix 2 heap-based buffer overflows (in + PSDataBW and PSDataColorContig). Reported by Agostino Sarubbo. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2633 and + http://bugzilla.maptools.org/show_bug.cgi?id=2634. + +
    • tools/tiff2pdf.c: prevent heap-based buffer overflow in -j + mode on a paletted image. Note: this fix errors out before the + overflow happens. There could probably be a better fix. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2635 + +
    • tools/tiff2pdf.c: fix wrong usage of memcpy() that can + trigger unspecified behaviour. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2638 + +
    • tools/tiff2pdf.c: avoid potential invalid memory read in + t2p_writeproc. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2639 + +
    • tools/tiff2pdf.c: avoid potential heap-based overflow in + t2p_readwrite_pdf_image_tile(). Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2640 + +
    • tools/tiffcrop.c: remove extraneous TIFFClose() in error code + path, that caused double free. Related to + http://bugzilla.maptools.org/show_bug.cgi?id=2535 + +
    • tools/tiffcp.c: error out cleanly in cpContig2SeparateByRow + and cpSeparate2ContigByRow if BitsPerSample != 8 to avoid heap + based overflow. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2656 and + http://bugzilla.maptools.org/show_bug.cgi?id=2657 + +
    • tools/raw2tiff.c: avoid integer division by zero. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2631 + +
    • tools/tiff2ps.c: call TIFFClose() in error code paths. + +
    • tools/fax2tiff.c: emit appropriate message if the input file + is empty. Patch by Alan Coopersmith. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2672 + +
    • tools/tiff2bw.c: close TIFF handle in error code path. Fixes + http://bugzilla.maptools.org/show_bug.cgi?id=2677 + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2017-05-21 17:47:46 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.0.9.html b/thirdparty/SDL2_image/external/libtiff/html/v4.0.9.html new file mode 100644 index 000000000..19b370a42 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.0.9.html @@ -0,0 +1,374 @@ + + + + + Changes in TIFF v4.0.9 + + + + + + + +TIFF CHANGE INFORMATION + + + + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • None + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • test/Makefile.am: Add some tests for tiff2bw. +
    • * .appveyor.yml, .travis.yml, build/travis-ci: apply patches + 0001-ci-Travis-script-improvements.patch and + 0002-ci-Invoke-helper-script-via-shell.patch by Roger Leigh + (sent to mailing list) +
    • .travis.yml, build/travis-ci: new files from + 0001-ci-Add-Travis-support-for-Linux-builds-with-Autoconf.patch by + Roger Leigh (sent to mailing list on 2017-06-08) + This patch adds support for the Travis-CI service. +
    • .appveyor.yml: new file from + 0002-ci-Add-AppVeyor-support.patch by Roger Leigh (sent to mailing + list on 2017-06-08) + This patch adds a .appveyor.yml file to the top-level. This allows + one to opt in to having a branch built on Windows with Cygwin, + MinGW and MSVC automatically when a branch is pushed to GitHub, + GitLab, BitBucket or any other supported git hosting service. +
    • CMakeLists.txt, test/CMakeLists.txt, test/TiffTestCommon.cmake: apply + patch 0001-cmake-Improve-Cygwin-and-MingGW-test-support.patch from Roger + Leigh (sent to mailing list on 2017-06-08) + This patch makes the CMake build system support running the tests + with MinGW or Cygwin. + +
    • test/tiffcp-lzw-compat.sh, test/images/quad-lzw-compat.tiff: new files + to test old-style LZW decompression +
    • test/common.sh, Makefile.am, CMakeList.txt: updated with above +
    • test/Makefile.am: add missing reference to images/quad-lzw-compat.tiff + to fix "make distcheck". Patch by Roger Leigh +
    • nmake.opt: support a DEBUG=1 option, so as to adjust OPTFLAGS and use + /MDd runtime in debug mode. + + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • libtiff/tif_color.c: TIFFYCbCrToRGBInit(): stricter clamping to avoid + int32 overflow in TIFFYCbCrtoRGB(). + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1844 + Credit to OSS Fuzz + +
    • libtiff/tif_getimage.c: initYCbCrConversion(): stricter validation for + refBlackWhite coefficients values. To avoid invalid float->int32 conversion + (when refBlackWhite[0] == 2147483648.f) + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1907 + Credit to OSS Fuzz + +
    • libtiff/tif_dirinfo.c, tif_dirread.c: add _TIFFCheckFieldIsValidForCodec(), + and use it in TIFFReadDirectory() so as to ignore fields whose tag is a + codec-specified tag but this codec is not enabled. This avoids TIFFGetField() + to behave differently depending on whether the codec is enabled or not, and + thus can avoid stack based buffer overflows in a number of TIFF utilities + such as tiffsplit, tiffcmp, thumbnail, etc. + Patch derived from 0063-Handle-properly-CODEC-specific-tags.patch + (http://bugzilla.maptools.org/show_bug.cgi?id=2580) by Raphaël Hertzog. + Fixes: + http://bugzilla.maptools.org/show_bug.cgi?id=2580 + http://bugzilla.maptools.org/show_bug.cgi?id=2693 + http://bugzilla.maptools.org/show_bug.cgi?id=2625 (CVE-2016-10095) + http://bugzilla.maptools.org/show_bug.cgi?id=2564 (CVE-2015-7554) + http://bugzilla.maptools.org/show_bug.cgi?id=2561 (CVE-2016-5318) + http://bugzilla.maptools.org/show_bug.cgi?id=2499 (CVE-2014-8128) + http://bugzilla.maptools.org/show_bug.cgi?id=2441 + http://bugzilla.maptools.org/show_bug.cgi?id=2433 + +
    • libtiff/tif_swab.c: if DISABLE_CHECK_TIFFSWABMACROS is defined, do not do + the #ifdef TIFFSwabXXX checks. Make it easier for GDAL to rename the symbols + of its internal libtiff copy. + + +
    • libtiff/tif_dirread.c: fix regression of libtiff 4.0.8 in + ChopUpSingleUncompressedStrip() regarding update of newly single-strip + uncompressed files whose bytecount is 0. Before the change of 2016-12-03, + the condition bytecount==0 used to trigger an early exit/disabling of + strip chop. Re-introduce that in update mode. Otherwise this cause + later incorrect setting for the value of StripByCounts/StripOffsets. + ( https://trac.osgeo.org/gdal/ticket/6924 ) +
    • libtiff/tif_dirread.c: TIFFFetchStripThing(): limit the number of items + read in StripOffsets/StripByteCounts tags to the number of strips to avoid + excessive memory allocation. + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2215 + Credit to OSS Fuzz +
    • libtiff/tif_getimage.c: avoid many (harmless) unsigned int overflows. +
    • libtiff/tif_fax3.c: avoid unsigned int overflow in Fax3Encode2DRow(). Could + potentially be a bug with huge rows. +
    • libtiff/tif_jpeg.c: avoid (harmless) unsigned int overflow on tiled images. +
    • libtiff/tif_dirread.c: avoid unsigned int overflow in EstimateStripByteCounts() + and BYTECOUNTLOOKSBAD when file is too short. +
    • libtiff/tif_predict.c: decorate legitimate functions where unsigned int + overflow occur with TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW + * libtiff/tif_dirread.c: avoid unsigned int overflow in EstimateStripByteCounts() +
    • libtiff/tiffiop.h: add TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW macro to + disable CLang warnings raised by -fsanitize=undefined,unsigned-integer-overflow +
    • libtiff/tif_jpeg.c: add anti-denial of service measure to avoid excessive + CPU consumption on progressive JPEGs with a huge number of scans. + See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf + Note: only affects libtiff since 2014-12-29 where support of non-baseline JPEG + was added. + +
    • libtiff/tif_jpeg.c: error out at decoding time if anticipated libjpeg + memory allocation is above 100 MB. libjpeg in case of multiple scans, + which is allowed even in baseline JPEG, if components are spread over several + scans and not interleavedin a single one, needs to allocate memory (or + backing store) for the whole strip/tile. + See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf + This limitation may be overriden by setting the + LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, or recompiling + libtiff with a custom value of TIFF_LIBJPEG_LARGEST_MEM_ALLOC macro. +
    • libtiff/tif_jbig.c: fix memory leak in error code path of JBIGDecode() + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2706 + Reported by team OWL337 +
    • libtiff/tif_dirread.c: in TIFFReadDirEntryFloat(), check that a + double value can fit in a float before casting. Patch by Nicolas RUFF +
    • libtiff/tiffiop.h, libtiff/tif_jpeg.c, libtiff/tif_jpeg_12.c, + libtiff/tif_read.c: make TIFFReadScanline() works in + CHUNKY_STRIP_READ_SUPPORT mode with JPEG stream with multiple scans. + Also make configurable through a LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER + environment variable the maximum number of scans allowed. Defaults to + 100. +
    • libtiff/tif_read.c: TIFFFillTile(): add limitation to the number + of bytes read in case td_stripbytecount[strip] is bigger than + reasonable, so as to avoid excessive memory allocation (similarly to + what was done for TIFFFileStrip() on 2017-05-10) +
    • libtiff/tif_getimage.c: use _TIFFReadEncodedStripAndAllocBuffer(). + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2708 and + https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2433 . + Credit to OSS Fuzz +
    • libtiff/tif_read.c, tiffiop.h: add a _TIFFReadEncodedStripAndAllocBuffer() + function, variant of TIFFReadEncodedStrip() that allocates the + decoded buffer only after a first successful TIFFFillStrip(). This avoids + excessive memory allocation on corrupted files. +
    • libtiff/tif_dirwrite.c: in TIFFWriteDirectoryTagCheckedXXXX() + functions associated with LONG8/SLONG8 data type, replace assertion that + the file is BigTIFF, by a non-fatal error. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2712 + Reported by team OWL337 +
    • libtiff/tif_read.c: TIFFStartTile(): set tif_rawcc to + tif_rawdataloaded when it is set. Similarly to TIFFStartStrip(). + This issue was revealed by the change of 2017-06-30 in TIFFFileTile(), + limiting the number of bytes read. But it could probably have been hit + too in CHUNKY_STRIP_READ_SUPPORT mode previously ? + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2454 + Credit to OSS Fuzz +
    • libtiff/tif_error.c, tif_warning.c: correctly use va_list when both + an old-style and new-style warning/error handlers are installed. + Patch by Paavo Helde (sent on the mailing list) +
    • libtiff/tif_getimage.c: use _TIFFReadTileAndAllocBuffer(). + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2470 + Credit to OSS Fuzz. +
    • libtiff/tif_read.c, tiffiop.h: add a _TIFFReadEncodedTileAndAllocBuffer() + and _TIFFReadTileAndAllocBuffer() variants of TIFFReadEncodedTile() and + TIFFReadTile() that allocates the decoded buffer only after a first + successful TIFFFillTile(). This avoids excessive memory allocation + on corrupted files. +
    • libtiff/tif_pixarlog.c: avoid excessive memory allocation on decoding + when RowsPerStrip tag is not defined (and thus td_rowsperstrip == UINT_MAX) + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2554 + Credit to OSS Fuzz +
    • libtiff/tif_lzw.c: fix 4.0.8 regression in the decoding of old-style LZW + compressed files. +
    • libtiff/tif_lzw.c: fix potential out-of-buffer read on 1-byte LZW + strips. Crashing issue only on memory mapped files, where the strip + offset is the last byte of the file, and the file size is a multiple + of one page size on the CPU architecture (typically 4096). Credit + to myself :-) +
    • libtiff/tif_dir.c: avoid potential null pointer dereference in + _TIFFVGetField() on corrupted TIFFTAG_NUMBEROFINKS tag instance. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2713 +
    • tools/tiff2pdf.c: prevent heap buffer overflow write in "Raw" + mode on PlanarConfig=Contig input images. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2715 + Reported by team OWL337 +
    • libtiff/tif_read.c: TIFFFillStrip() / TIFFFillTile(). + Complementary fix for http://bugzilla.maptools.org/show_bug.cgi?id=2708 + in the isMapped() case, so as to avoid excessive memory allocation + when we need a temporary buffer but the file is truncated. +
    • libtiff/tif_read.c: TIFFFillStrip() / TIFFFillTile(). + Complementary fix for http://bugzilla.maptools.org/show_bug.cgi?id=2708 + in the isMapped() case, so as to avoid excessive memory allocation + when we need a temporary buffer but the file is truncated. +
    • libtiff/tif_read.c: in TIFFFetchStripThing(), only grow the + arrays that hold StripOffsets/StripByteCounts, when they are smaller + than the expected number of striles, up to 1 million striles, and + error out beyond. Can be tweaked by setting the environment variable + LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT. + This partially goes against a change added on 2002-12-17 to accept + those arrays of wrong sizes, but is needed to avoid denial of services. + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2350 + Credit to OSS Fuzz +
    • libtiff/tif_read.c: in TIFFFetchStripThing(), only grow the + arrays that hold StripOffsets/StripByteCounts, when they are smaller + than the expected number of striles, up to 1 million striles, and + error out beyond. Can be tweaked by setting the environment variable + LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT. + This partially goes against a change added on 2002-12-17 to accept + those arrays of wrong sizes, but is needed to avoid denial of services. + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2350 + Credit to OSS Fuzz +
    • libtiff/tif_read.c: add protection against excessive memory + allocation attempts in TIFFReadDirEntryArray() on short files. + Effective for mmap'ed case. And non-mmap'ed case, but restricted + to 64bit builds. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2675 +
    • libtiff/tif_read.c: add protection against excessive memory + allocation attempts in TIFFReadDirEntryArray() on short files. + Effective for mmap'ed case. And non-mmap'ed case, but restricted + to 64bit builds. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2675 +
    • libtiff/tif_luv.c: LogLuvInitState(): avoid excessive memory + allocation when RowsPerStrip tag is missing. + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2683 + Credit to OSS-Fuzz +
    • libtiff/tif_getimage.c: gtTileContig() and gtTileSeparate(): + properly break from loops on error when stoponerr is set, instead + of going on iterating on row based loop. +
    • libtiff/tif_getimage.c: fix fromskew computation when to-be-skipped + pixel number is not a multiple of the horizontal subsampling, and + also in some other cases. Impact putcontig8bitYCbCr44tile, + putcontig8bitYCbCr42tile, putcontig8bitYCbCr41tile, + putcontig8bitYCbCr21tile and putcontig8bitYCbCr12tile + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2637 (discovered + by Agostino Sarubbo) + and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2691 (credit + to OSS Fuzz) +
    • libtiff/tif_luv.c: further reduce memory requirements for temporary + buffer when RowsPerStrip >= image_length in LogLuvInitState() and + LogL16InitState(). + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2700 + Credit to OSS Fuzz +
    • libtiff/tif_dirwrite.c: replace assertion related to not finding the + SubIFD tag by runtime check (in TIFFWriteDirectorySec()) + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2727 + Reported by team OWL337 +
    • libtiff/tif_dirwrite.c: replace assertion to tag value not fitting + on uint32 when selecting the value of SubIFD tag by runtime check + (in TIFFWriteDirectoryTagSubifd()). + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2728 + Reported by team OWL337 +
    • libtiff/tif_jpeg.c: accept reading the last strip of a JPEG compressed + file if the codestream height is larger than the truncated height of the + strip. Emit a warning in this situation since this is non compliant. +
    • libtiff/tiffiop.h, tif_aux.c: redirect SeekOK() macro to a _TIFFSeekoK() + function that checks if the offset is not bigger than INT64_MAX, so as + to avoid a -1 error return code of TIFFSeekFile() to match a required + seek to UINT64_MAX/-1. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2726 + Adapted from proposal by Nicolas Ruff. +
    • libtiff/tif_dirread.c: add NULL check to avoid likely false positive + null-pointer dereference warning by CLang Static Analyzer. +
    • libtiff/libtiff.def: add TIFFReadRGBAStripExt and TIFFReadRGBATileExt + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2735 +
    • libtiff/tif_jpeg.c: add compatibility with libjpeg-turbo 1.5.2 that + honours max_memory_to_use > 0. + Cf https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162 +
    • libtiff/tif_getimage.c: avoid floating point division by zero in + initCIELabConversion() + Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3733 + Credit to OSS Fuzz +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • tools/tiff2pdf.c: prevent heap buffer overflow write in "Raw" + mode on PlanarConfig=Contig input images. + Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2715 + Reported by team OWL337 +
    • tools/tiffset.c: fix setting a single value for the ExtraSamples tag + (and other tags with variable number of values). + So 'tiffset -s ExtraSamples 1 X'. This only worked + when setting 2 or more values, but not just one. +
    • tools/fax2tiff.c (_FAX_Client_Data): Pass FAX_Client_Data as the + client data. This client data is not used at all at the moment, + but it makes the most sense. Issue that the value of + client_data.fd was passed where a pointer is expected was reported + via email by Gerald Schade on Sun, 29 Oct 2017. +
    • tools/tiff2pdf.c (t2p_sample_realize_palette): Fix possible + arithmetic overflow in bounds checking code and eliminate + comparison between signed and unsigned type. +
    • tools/tiff2bw.c (main): Free memory allocated in the tiff2bw + program. This is in response to the report associated with + CVE-2017-16232 but does not solve the extremely high memory usage + with the associated POC file. + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None + +
    + +Last updated $Date: 2017-11-18 19:38:06 $. + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.1.0.html b/thirdparty/SDL2_image/external/libtiff/html/v4.1.0.html new file mode 100644 index 000000000..80dac5bfc --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.1.0.html @@ -0,0 +1,205 @@ + + + + + Changes in TIFF v4.1.0 + + + + + + + +TIFF CHANGE INFORMATION + + +
    +
    +Current Version: v4.1.0
    +Previous Version: v4.0.10
    +Master Download Site: +download.osgeo.org, directory pub/libtiff<
    +Master HTTP Site #1: +http://www.simplesystems.org/libtiff/
    +Master HTTP Site #2: +http://libtiff.maptools.org/ +
    +
    + +

    +This document describes the changes made to the software between the +previous and current versions (see above). If you don't +find something listed here, then it was not done in this timeframe, or +it was not considered important enough to be mentioned. The following +information is located here. A change summary is also provided by the +ChangeLog file included in the release package and by the Git commit +history: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • Make defer strile offset/bytecount loading available at runtime + and add per-strile offset/bytecount loading capabilities. Part of + this commit makes the behaviour that was previously met when libtiff + was compiled with -DDEFER_STRILE_LOAD available for default builds + when specifying the new 'D' (Deferred) TIFFOpen() flag. In that + mode, the [Tile/Strip][ByteCounts/Offsets] arrays are only loaded + when first accessed. This can speed-up the opening of files stored + on the network when just metadata retrieval is needed. + + Another addition is the capability of loading only the values of + the offset/bytecount of the strile of interest instead of the + whole array. This is enabled with the new 'O' (Ondemand) flag of + TIFFOpen() (which implies 'D'). + + The public TIFFGetStrileOffset[WithErr]() and + TIFFGetStrileByteCount[WithErr]() functions have been added to + API. They are of particular interest when using sparse files (with + offset == bytecount == 0) and you want to detect if a strile is + present or not without decompressing the data, or updating an + existing sparse file. +
    • + +
    • The BigTIFF writer now optimizes file size by using 32-bit LONG + values (rather than 64-bit) where it is reasonable and safe to do + so. Likewise, the 16-bit SHORT type is used when possible for + StripByteCounts/TileByteCounts. +
    • + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • The WIN32 build now uses tif_win32.c when building with CMake.
    • + +
    • Properly set value of HOST_FILLORDER to LSB2MSB for Windows + CMake builds. It was not being properly set!
    • + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • + Changes in the libtiff library may be viewed on-line + at Libtiff + Library Commits. +
    • + +
    • + New function TIFFReadFromUserBuffer() which replaces the use of + TIFFReadEncodedStrip()/TIFFReadEncodedTile() when the user can + provide the buffer for the input data, for example when he wants + to avoid libtiff to read the strile offset/count values from the + [Strip|Tile][Offsets/ByteCounts] array. +
    • + +
    • + New functions TIFFDeferStrileArrayWriting() and TIFFForceStrileArrayWriting() + Those advanced writing functions must be used in a particular sequence + to make their intended effect. Their aim is to control when/where + the [Strip/Tile][Offsets/ByteCounts] arrays are written into the file. + + The purpose of this is to generate 'cloud-optimized geotiff' files where + the first KB of the file only contain the IFD entries without the potentially + large strile arrays. Those are written afterwards. +
    • + +
    + +


    + + + +CHANGES IN THE TOOLS: + + + +


    + + + +CHANGES IN THE CONTRIB AREA: + + + + + diff --git a/thirdparty/SDL2_image/external/libtiff/html/v4.2.0.html b/thirdparty/SDL2_image/external/libtiff/html/v4.2.0.html new file mode 100644 index 000000000..c81ecdd25 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/html/v4.2.0.html @@ -0,0 +1,205 @@ + + + + + Changes in TIFF v4.2.0 + + + + + + + +TIFF CHANGE INFORMATION + + +
    +
    +Current Version: v4.2.0
    +Previous Version: v4.1.0
    +Master Download Site: +download.osgeo.org, directory pub/libtiff<
    +Master HTTP Site #1: +http://www.simplesystems.org/libtiff/
    +Master HTTP Site #2: +http://libtiff.maptools.org/ +
    +
    + +

    +This document provides a summary of significant changes made to the +software between the previous and current versions (see +above). A fully-detailed change summary is provided by the ChangeLog file +included in the release package and by the Git commit history: +

    +

    +


    + + + +MAJOR CHANGES: + +
      + +
    • Optional support for using libdeflate is added.
    • + +
    • Many of the tools now support a memory usage limit.
    • + +
    + + +


    + + +CHANGES IN THE SOFTWARE CONFIGURATION: + +
      + +
    • The Microsoft Windows 'nmake' build is resuscitated and provides + a default HAVE_STRTOLL setting in 'nmake.opt' which is suitable for + MSVC++ 14.0 ("Visual Studio 2015") and later but may be disabled in + order to compile with earlier compiler versions.
    • + +
    • mingw-w64 cmake build fixes to not add libm
    • + +
    + +


    + + + +CHANGES IN LIBTIFF: + +
      + +
    • A great many issues discovered by fuzzers (via oss-fuzz and other reports) have been addressed.
    • + +
    • EXIF 2.32 and GPS tags and functionality have been upgraded: +
        +
      • Existing EXIF field definition of tags are upgraded to EXIF version 2.3.2
      • +
      • EXIF-GPS structure, tags and access functions are added as special CustomDirectory (like it was done for EXIF).
      • +
      • Reading error for FileSource and SceneType tags corrected.
      • +
      + +
    • Make TIFFTAG_CFAPATTERN variable count.
    • + +
    • Cmake configuration fixes for big-endian targets.
    • + +
    • Added support for optional building against libdeflate for + faster Zip/Deflate compression/decompression.

      + +

      We now have 2 kinds of builds with the Zip/Deflate codec:

      +
        +
      • zlib only
      • +
      • zlib + libdeflate
      • +
      + +

      Speed improvements in the 35%-50% range can be expected when libdeflate is used. + Compression level up to 12 is now supported (capped to 9 when zlib is used). + Still requires zlib for situations where libdeflate cannot be used (that + is for scanline access, since libdeflate has no streaming mode)

      + +

      Pseudo-tag TIFFTAG_DEFLATE_SUBCODEC=DEFLATE_SUBCODEC_ZLIB/DEFLATE_SUBCODEC_LIBDEFLATE + is added to control which subcodec (zlib or libdeflate) should be used (it defaults + of course to libdeflate, when it is available). + This is mostly aimed at being used on the writing side, to be able to reproduce + output of previous libtiff versions at a binary level, in situations where this would + be really needed. Or as a safety belt in case there would be unforeseen issues + with using libdeflate. + It can be used to know when libdeflate is available at runtime (DEFLATE_SUBCODEC_LIBDEFLATE + will be the default value in that situation).

      +

      Of course, deflate codestreams produced by libdeflate can be read by zlib, and vice-versa.

      + +
    • + +
    + +


    + + + +CHANGES IN THE TOOLS: + +
      + +
    • A great many issues discovered by fuzzers (via oss-fuzz and other reports) have been addressed.
    • + +
    • ppm2tiff: support any bps value from 1 to 16.
    • + +
    • tiff2ps, tiff2rgba: A default memory limit is now enforced (256MiB) and a '-M' option is added to allow the user to adjust the limit.
    • + +
    • tiff2pdf, tiffcp: A default memory limit is now enforced (256MiB) and a '-m' option is added to allow the user to adjust the limit.
    • + +
    • tiffcrop: A default memory limit is now enforced (256MiB) and a '-k' option is added to allow the user to adjust the limit.
    • + +
    • tiff2pdf: fix "raw" copy of Deflate streams.
    • + +
    • tiff2pdf.c: properly calculate datasize when saving to JPEG YCbCr
    • + +
    • tiffcp: disable strip chopping when trying to convert to JBIG compression
    • + +
    + +


    + + + +CHANGES IN THE CONTRIB AREA: + +
      + +
    • None
    • + +
    + + + diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff-4.pc.in b/thirdparty/SDL2_image/external/libtiff/libtiff-4.pc.in index 92305ac5f..abe75a62e 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff-4.pc.in +++ b/thirdparty/SDL2_image/external/libtiff/libtiff-4.pc.in @@ -5,8 +5,7 @@ includedir=@includedir@ Name: libtiff Description: Tag Image File Format (TIFF) library. -Version: @LIBTIFF_MAJOR_VERSION@.@LIBTIFF_MINOR_VERSION@.@LIBTIFF_MICRO_VERSION@ +Version: @VERSION@ Libs: -L${libdir} -ltiff Libs.private: @tiff_libs_private@ Cflags: -I${includedir} -Requires.private: @tiff_requires_private@ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/libtiff/CMakeLists.txt old mode 100755 new mode 100644 index 5d2a29ca6..e485d509b --- a/thirdparty/SDL2_image/external/libtiff/libtiff/CMakeLists.txt +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/CMakeLists.txt @@ -30,145 +30,97 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tiffconf.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h @ONLY) -set(tiff_public_HEADERS - tiff.h - tiffio.h - tiffvers.h - ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h) +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_private_HEADERS - t4.h - tif_dir.h - tif_predict.h - tiffiop.h - uvcode.h - ${CMAKE_CURRENT_BINARY_DIR}/tif_config.h) +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) -add_library(tiff libtiff.def) -add_library(TIFF::tiff ALIAS tiff) +set(nodist_tiff_HEADERS + ${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h) -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_hash_set.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) +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) if(USE_WIN32_FILEIO) - target_sources(tiff PRIVATE tif_win32.c) + extra_dist(tif_unix.c) + list(APPEND tiff_SOURCES tif_win32.c) else() - target_sources(tiff PRIVATE tif_unix.c) + extra_dist(tif_win32.c) + list(APPEND tiff_SOURCES tif_unix.c) endif() +add_library(tiff ${tiff_SOURCES} ${tiff_HEADERS} ${nodist_tiff_HEADERS} + ${tiff_port_SOURCES} libtiff.def) target_include_directories(tiff PUBLIC - $ - $ - $ - PRIVATE - ${TIFF_INCLUDES} + "$" + "$" + "$" ) - -# MSVC specific resource preparation -if (WIN32 AND MSVC) - message(STATUS "Include resource version information for LibTIFF") - target_sources(tiff PRIVATE tif_win32_versioninfo.rc) - source_group("Resource Files" FILES tif_win32_versioninfo.rc) -endif () - - -set(tiff_libs_private_list "") # cmake list -set(tiff_requires_private "") # cmake string - -if(ZIP_SUPPORT) - target_link_libraries(tiff PRIVATE ZLIB::ZLIB) - string(APPEND tiff_requires_private " zlib") -endif() -if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT) - target_link_libraries(tiff PRIVATE Deflate::Deflate) - list(APPEND tiff_libs_private_list "${Deflate_LIBRARY}") -endif() -if(JPEG_SUPPORT) - target_link_libraries(tiff PRIVATE JPEG::JPEG) - string(APPEND tiff_requires_private " libjpeg") - if(HAVE_JPEGTURBO_DUAL_MODE_8_12) - target_compile_definitions(tiff PRIVATE HAVE_JPEGTURBO_DUAL_MODE_8_12) - elseif(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) - list(APPEND tiff_libs_private_list "${JBIG_LIBRARY}") -endif() -if(LERC_SUPPORT) - target_link_libraries(tiff PRIVATE LERC::LERC) - list(APPEND tiff_libs_private_list "${LERC_LIBRARY}") - if(NOT BUILD_SHARED_LIBS) - set_target_properties(tiff PROPERTIES COMPILE_DEFINITIONS LERC_STATIC) - endif() -endif() -if(LZMA_SUPPORT) - target_link_libraries(tiff PRIVATE liblzma::liblzma) - string(APPEND tiff_requires_private " liblzma") -endif() -if(ZSTD_SUPPORT) - target_link_libraries(tiff PRIVATE ZSTD::ZSTD) - string(APPEND tiff_requires_private " libzstd") -endif() -if(WEBP_SUPPORT) - target_link_libraries(tiff PRIVATE WebP::webp) - string(APPEND tiff_requires_private " libwebp") -endif() -if(CMath_LIBRARY) - target_link_libraries(tiff PRIVATE CMath::CMath) - list(APPEND tiff_libs_private_list "${CMath_LIBRARY}") -endif() - -set(tiff_libs_private_list "${tiff_libs_private_list}" PARENT_SCOPE) -set(tiff_requires_private "${tiff_requires_private}" PARENT_SCOPE) - +target_link_libraries(tiff ${TIFF_LIBRARY_DEPS}) set_target_properties(tiff PROPERTIES SOVERSION ${SO_COMPATVERSION}) if(NOT CYGWIN) # This property causes shared libraries on Linux to have the full version @@ -177,56 +129,26 @@ if(NOT CYGWIN) # seems to be the default. set_target_properties(tiff PROPERTIES VERSION ${SO_VERSION}) endif() -if(HAVE_LD_VERSION_SCRIPT) +if(WIN32) +# Windows links with libtiff.def, nothing else needed. +elseif(APPLE) + set_target_properties(tiff PROPERTIES LINK_FLAGS + "-Wl,-exported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libtiff.exp") +elseif(HAVE_LD_VERSION_SCRIPT) set_target_properties(tiff PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libtiff.map") endif() -if(tiff-install) - export(TARGETS tiff NAMESPACE TIFF:: FILE "${CMAKE_CURRENT_BINARY_DIR}/libtiffTargets.cmake") - install(TARGETS tiff EXPORT TiffTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS tiff + RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) - install(FILES ${tiff_public_HEADERS} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") - - set(TIFF_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/tiff) - install(EXPORT TiffTargets - FILE TiffTargets.cmake - NAMESPACE TIFF:: - DESTINATION ${TIFF_CONFIGDIR} - ) - - include(CMakePackageConfigHelpers) - write_basic_package_version_file( - TiffConfigVersion.cmake - VERSION ${LIBTIFF_VERSION} - COMPATIBILITY SameMajorVersion) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TiffConfigVersion.cmake DESTINATION ${TIFF_CONFIGDIR}) - - configure_file(${PROJECT_SOURCE_DIR}/cmake/TiffConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/TiffConfig.cmake @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/TiffConfig.cmake DESTINATION ${TIFF_CONFIGDIR}) -endif() +install(FILES ${tiff_HEADERS} ${nodist_tiff_HEADERS} + DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") if(CXX_SUPPORT) - set(tiffxx_HEADERS - tiffio.hxx) - - # No .def file for this library. - if (WIN32) - add_library(tiffxx STATIC ../placeholder.h) - else() - add_library(tiffxx ../placeholder.h) - endif() - - add_library(TIFF::CXX ALIAS tiffxx) - - target_sources(tiffxx PRIVATE - ${tiffxx_HEADERS} - tif_stream.cxx) + add_library(tiffxx ${tiffxx_SOURCES} ${tiffxx_HEADERS}) target_link_libraries(tiffxx tiff) set_target_properties(tiffxx PROPERTIES SOVERSION ${SO_COMPATVERSION}) if(NOT CYGWIN) @@ -241,26 +163,12 @@ if(CXX_SUPPORT) "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libtiffxx.map") endif() - if(tiff-install) - install(TARGETS tiffxx - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS tiffxx + RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) + + install(FILES ${tiffxx_HEADERS} + DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") - install(FILES ${tiffxx_HEADERS} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") - endif() - -endif() - -if(NOT CMAKE_CROSSCOMPILING) - add_executable(tiff_mkg3states ../placeholder.h) - target_sources(tiff_mkg3states PRIVATE mkg3states.c tif_fax3.h) - target_link_libraries(tiff_mkg3states tiff tiff_port) - - add_custom_target(tiff_faxtable - DEPENDS tiff_mkg3states - COMMAND ${CMAKE_COMMAND} -E rm "tif_fax3sm.c" - COMMAND tiff_mkg3states -b -c const "tif_fax3sm.c" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") endif() diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.am b/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.am index 1d1a35d7b..d94ff637a 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.am @@ -29,12 +29,18 @@ 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 \ - tif_win32_versioninfo.rc + tiffconf.vc.h \ + tiffconf.wince.h libtiffinclude_HEADERS = \ tiff.h \ @@ -48,7 +54,6 @@ endif noinst_HEADERS = \ t4.h \ tif_dir.h \ - tif_hash_set.h \ tif_predict.h \ tiffiop.h \ uvcode.h @@ -73,11 +78,9 @@ libtiff_la_SOURCES = \ tif_fax3sm.c \ tif_flush.c \ tif_getimage.c \ - tif_hash_set.c \ tif_jbig.c \ tif_jpeg.c \ tif_jpeg_12.c \ - tif_lerc.c \ tif_luv.c \ tif_lzma.c \ tif_lzw.c \ @@ -125,6 +128,10 @@ endif if HAVE_LD_VERSION_SCRIPT libtiff_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtiff.map endif +if HAVE_DARWIN_EXPORTS +libtiff_la_LDFLAGS += -Wl,-exported_symbols_list,$(srcdir)/libtiff.exp +endif +libtiff_la_LIBADD = $(LIBPORT) libtiffxx_la_LDFLAGS = \ -no-undefined \ @@ -135,7 +142,7 @@ endif if HAVE_LD_VERSION_SCRIPT libtiffxx_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libtiffxx.map endif -libtiffxx_la_LIBADD = $(LIBTIFF) +libtiffxx_la_LIBADD = $(LIBTIFF) $(LIBPORT) libtiffxx_la_DEPENDENCIES = libtiff.la # @@ -150,16 +157,3 @@ mkg3states_LDADD = $(LIBPORT) faxtable: mkg3states (rm -f tif_fax3sm.c && ./mkg3states -b -c const tif_fax3sm.c) -if STATIC_LERC -extra_CPPFLAGS = -DLERC_STATIC -else -extra_CPPFLAGS = -endif - -if HAVE_JPEGTURBO_DUAL_MODE_8_12 -JPEGTURBO_CPPFLAGS = -DHAVE_JPEGTURBO_DUAL_MODE_8_12 -else -JPEGTURBO_CPPFLAGS = -endif - -AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port $(extra_CPPFLAGS) $(JPEGTURBO_CPPFLAGS) diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.lcc b/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.lcc new file mode 100644 index 000000000..fa7abb5dc --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.lcc @@ -0,0 +1,128 @@ +# +# Tag Image File Format Library +# +# Copyright (c) 1988-1997 Sam Leffler +# Copyright (c) 1991-1997 Silicon Graphics, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Stanford 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. +# +DESTDIR=. +# +INSTALL=install +NULL= + +IPATH= -I. -I../jpeg +CONF_LIBRARY=\ + ${NULL} +COPTS= -Oloop -cwagshf -d1 -b0 -v -DNDEBUG -rr -j135i +CFLAGS= ${COPTS} ${IPATH} ${CONF_LIBRARY} +# +INCS= tiff.h tiffio.h +SRCS= tif_fax3.c \ + tif_fax4.c \ + tif_aux.c \ + tif_atari.c \ + tif_ccittrle.c \ + tif_close.c \ + tif_compress.c \ + tif_dir.c \ + tif_dirinfo.c \ + tif_dirread.c \ + tif_dirwrite.c \ + tif_dumpmode.c \ + tif_error.c \ + tif_getimage.c \ + tif_jpeg.c \ + tif_flush.c \ + tif_lzw.c \ + tif_next.c \ + tif_open.c \ + tif_packbits.c \ + tif_print.c \ + tif_read.c \ + tif_swab.c \ + tif_strip.c \ + tif_thunder.c \ + tif_tile.c \ + tif_version.c \ + tif_warning.c \ + tif_write.c \ + ${NULL} +OBJS= tif_fax3.o \ + tif_fax4.o \ + tif_aux.o \ + tif_atari.o \ + tif_ccittrle.o \ + tif_close.o \ + tif_compress.o \ + tif_dir.o \ + tif_dirinfo.o \ + tif_dirread.o \ + tif_dirwrite.o \ + tif_dumpmode.o \ + tif_error.o \ + tif_getimage.o \ + tif_jpeg.o \ + tif_flush.o \ + tif_lzw.o \ + tif_next.o \ + tif_open.o \ + tif_packbits.o \ + tif_print.o \ + tif_read.o \ + tif_swab.o \ + tif_strip.o \ + tif_thunder.o \ + tif_tile.o \ + tif_version.o \ + tif_warning.o \ + tif_write.o \ + ${NULL} +ALL= tiffrnb.lib + +all: ${ALL} + +${ALL}: ${OBJS} + ${AR} ${ARFLAGS} $@ r $< + +${OBJS}: tiffio.h tiff.h tiffcomp.h tiffiop.h tiffconf.h +tif_fax3.o: tif_fax3.c g3states.h t4.h tif_fax3.h + +g3states.h: mkg3states.c t4.h + ${CC} -o mkg3states.ttp ${CFLAGS} mkg3states.c + ./mkg3states -c > g3states.h + +install: all installh + -for i in ${ALL}; do \ + ${INSTALL} -c -m 644 $$i ${DESTDIR}/lib/$$i; \ + done + +installh: ${INCS} + -for i in ${INCS}; do \ + h=`basename $$i`; \ + cmp -s $$i ${DESTDIR}/include/$$h || \ + ${INSTALL} -c -m 444 $$i ${DESTDIR}/include/$$h; \ + done + +clean: + rm -f ${ALL} ${OBJS} mkg3states.ttp mkg3states.o g3states.h + +tags: ${SRCS} + ${CTAGS} ${SRCS} diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.vc b/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.vc new file mode 100644 index 000000000..5aac3310e --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/Makefile.vc @@ -0,0 +1,100 @@ +# Copyright (C) 2004, Andrey Kiselev +# +# 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/thirdparty/SDL2_image/external/libtiff/libtiff/SConstruct b/thirdparty/SDL2_image/external/libtiff/libtiff/SConstruct new file mode 100644 index 000000000..af3daace0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/SConstruct @@ -0,0 +1,71 @@ +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2005, Andrey Kiselev +# +# 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/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.def b/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.def index 22cbb1aa2..b2d03fe7b 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.def +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.def @@ -5,7 +5,6 @@ EXPORTS TIFFAccessTagMethods TIFFCheckpointDirectory TIFFCleanup TIFFClientOpen - TIFFClientOpenExt TIFFClientdata TIFFClose TIFFComputeStrip @@ -25,20 +24,15 @@ EXPORTS TIFFAccessTagMethods TIFFDeferStrileArrayWriting TIFFError TIFFErrorExt - TIFFErrorExtR TIFFFdOpen - TIFFFdOpenExt TIFFFieldDataType TIFFFieldName TIFFFieldPassCount TIFFFieldReadCount - TIFFFieldIsAnonymous TIFFFieldTag TIFFFieldWithName TIFFFieldWithTag TIFFFieldWriteCount - TIFFFieldSetGetSize - TIFFFieldSetGetCountSize TIFFFileName TIFFFileno TIFFFindCODEC @@ -68,7 +62,6 @@ EXPORTS TIFFAccessTagMethods TIFFGetVersion TIFFGetWriteProc TIFFIsBigEndian - TIFFIsBigTIFF TIFFIsByteSwapped TIFFIsCODECConfigured TIFFIsMSB2LSB @@ -80,14 +73,7 @@ EXPORTS TIFFAccessTagMethods TIFFNumberOfStrips TIFFNumberOfTiles TIFFOpen - TIFFOpenExt TIFFOpenW - TIFFOpenWExt - TIFFOpenOptionsAlloc - TIFFOpenOptionsFree - TIFFOpenOptionsSetMaxSingleMemAlloc - TIFFOpenOptionsSetErrorHandlerExtR - TIFFOpenOptionsSetWarningHandlerExtR TIFFPrintDirectory TIFFRGBAImageBegin TIFFRGBAImageEnd @@ -165,7 +151,6 @@ EXPORTS TIFFAccessTagMethods TIFFVTileSize64 TIFFWarning TIFFWarningExt - TIFFWarningExtR TIFFWriteBufferSetup TIFFWriteCheck TIFFWriteCustomDirectory @@ -181,7 +166,6 @@ EXPORTS TIFFAccessTagMethods TIFFYCbCrtoRGB _TIFFCheckMalloc _TIFFCheckRealloc - _TIFFClampDoubleToUInt32 _TIFFRewriteField _TIFFfree _TIFFmalloc diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.exp b/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.exp new file mode 100644 index 000000000..dac3e4db4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.exp @@ -0,0 +1,178 @@ +_TIFFAccessTagMethods +_TIFFCIELabToRGBInit +_TIFFCIELabToXYZ +_TIFFCheckTile +_TIFFCheckpointDirectory +_TIFFCleanup +_TIFFClientOpen +_TIFFClientdata +_TIFFClose +_TIFFComputeStrip +_TIFFComputeTile +_TIFFCreateCustomDirectory +_TIFFCreateDirectory +_TIFFCreateEXIFDirectory +_TIFFCreateGPSDirectory +_TIFFCurrentDirOffset +_TIFFCurrentDirectory +_TIFFCurrentRow +_TIFFCurrentStrip +_TIFFCurrentTile +_TIFFDataWidth +_TIFFDefaultStripSize +_TIFFDefaultTileSize +_TIFFDeferStrileArrayWriting +_TIFFError +_TIFFErrorExt +_TIFFFdOpen +_TIFFFieldDataType +_TIFFFieldName +_TIFFFieldPassCount +_TIFFFieldReadCount +_TIFFFieldTag +_TIFFFieldWithName +_TIFFFieldWithTag +_TIFFFieldWriteCount +_TIFFFileName +_TIFFFileno +_TIFFFindCODEC +_TIFFFindField +_TIFFFlush +_TIFFFlushData +_TIFFForceStrileArrayWriting +_TIFFFreeDirectory +_TIFFGetBitRevTable +_TIFFGetClientInfo +_TIFFGetCloseProc +_TIFFGetConfiguredCODECs +_TIFFGetField +_TIFFGetFieldDefaulted +_TIFFGetMapFileProc +_TIFFGetMode +_TIFFGetReadProc +_TIFFGetSeekProc +_TIFFGetSizeProc +_TIFFGetStrileByteCount +_TIFFGetStrileByteCountWithErr +_TIFFGetStrileOffset +_TIFFGetStrileOffsetWithErr +_TIFFGetTagListCount +_TIFFGetTagListEntry +_TIFFGetUnmapFileProc +_TIFFGetVersion +_TIFFGetWriteProc +_TIFFIsBigEndian +_TIFFIsByteSwapped +_TIFFIsCODECConfigured +_TIFFIsMSB2LSB +_TIFFIsTiled +_TIFFIsUpSampled +_TIFFLastDirectory +_TIFFMergeFieldInfo +_TIFFNumberOfDirectories +_TIFFNumberOfStrips +_TIFFNumberOfTiles +_TIFFOpen +_TIFFPrintDirectory +_TIFFRGBAImageBegin +_TIFFRGBAImageEnd +_TIFFRGBAImageGet +_TIFFRGBAImageOK +_TIFFRasterScanlineSize +_TIFFRasterScanlineSize64 +_TIFFRawStripSize +_TIFFRawStripSize64 +_TIFFReadBufferSetup +_TIFFReadCustomDirectory +_TIFFReadDirectory +_TIFFReadEXIFDirectory +_TIFFReadGPSDirectory +_TIFFReadEncodedStrip +_TIFFReadEncodedTile +_TIFFReadFromUserBuffer +_TIFFReadRGBAImage +_TIFFReadRGBAImageOriented +_TIFFReadRGBAStrip +_TIFFReadRGBAStripExt +_TIFFReadRGBATile +_TIFFReadRGBATileExt +_TIFFReadRawStrip +_TIFFReadRawTile +_TIFFReadScanline +_TIFFReadTile +_TIFFRegisterCODEC +_TIFFReverseBits +_TIFFRewriteDirectory +_TIFFScanlineSize +_TIFFScanlineSize64 +_TIFFSetClientInfo +_TIFFSetClientdata +_TIFFSetCompressionScheme +_TIFFSetDirectory +_TIFFSetErrorHandler +_TIFFSetErrorHandlerExt +_TIFFSetField +_TIFFSetFileName +_TIFFSetFileno +_TIFFSetMode +_TIFFSetSubDirectory +_TIFFSetTagExtender +_TIFFSetWarningHandler +_TIFFSetWarningHandlerExt +_TIFFSetWriteOffset +_TIFFSetupStrips +_TIFFStripSize +_TIFFStripSize64 +_TIFFSwabArrayOfDouble +_TIFFSwabArrayOfFloat +_TIFFSwabArrayOfLong +_TIFFSwabArrayOfLong8 +_TIFFSwabArrayOfShort +_TIFFSwabArrayOfTriples +_TIFFSwabDouble +_TIFFSwabFloat +_TIFFSwabLong +_TIFFSwabLong8 +_TIFFSwabShort +_TIFFTileRowSize +_TIFFTileRowSize64 +_TIFFTileSize +_TIFFTileSize64 +_TIFFUnRegisterCODEC +_TIFFUnlinkDirectory +_TIFFUnsetField +_TIFFVGetField +_TIFFVGetFieldDefaulted +_TIFFVSetField +_TIFFVStripSize +_TIFFVStripSize64 +_TIFFVTileSize +_TIFFVTileSize64 +_TIFFWarning +_TIFFWarningExt +_TIFFWriteBufferSetup +_TIFFWriteCheck +_TIFFWriteCustomDirectory +_TIFFWriteDirectory +_TIFFWriteEncodedStrip +_TIFFWriteEncodedTile +_TIFFWriteRawStrip +_TIFFWriteRawTile +_TIFFWriteScanline +_TIFFWriteTile +_TIFFXYZToRGB +_TIFFYCbCrToRGBInit +_TIFFYCbCrtoRGB +__TIFFCheckMalloc +__TIFFCheckRealloc +__TIFFRewriteField +__TIFFfree +__TIFFmalloc +__TIFFmemcmp +__TIFFmemcpy +__TIFFmemset +__TIFFrealloc +__TIFFMultiply32 +__TIFFMultiply64 +__TIFFGetExifFields +__TIFFGetGpsFields diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.map b/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.map index 05da6d7e9..077bcaa01 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.map +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/libtiff.map @@ -1,4 +1,4 @@ -LIBTIFF_4.0 { +libtiff.so.5 { global: TIFFAccessTagMethods; TIFFCIELabToRGBInit; @@ -11,7 +11,10 @@ LIBTIFF_4.0 { TIFFClose; TIFFComputeStrip; TIFFComputeTile; + TIFFCreateCustomDirectory; TIFFCreateDirectory; + TIFFCreateEXIFDirectory; + TIFFCreateGPSDirectory; TIFFCurrentDirOffset; TIFFCurrentDirectory; TIFFCurrentRow; @@ -20,17 +23,25 @@ LIBTIFF_4.0 { TIFFDataWidth; TIFFDefaultStripSize; TIFFDefaultTileSize; + TIFFDeferStrileArrayWriting; TIFFError; TIFFErrorExt; TIFFFdOpen; + TIFFFieldDataType; + TIFFFieldName; + TIFFFieldPassCount; + TIFFFieldReadCount; + TIFFFieldTag; TIFFFieldWithName; TIFFFieldWithTag; + TIFFFieldWriteCount; TIFFFileName; TIFFFileno; TIFFFindCODEC; TIFFFindField; TIFFFlush; TIFFFlushData; + TIFFForceStrileArrayWriting; TIFFFreeDirectory; TIFFGetBitRevTable; TIFFGetClientInfo; @@ -43,6 +54,10 @@ LIBTIFF_4.0 { TIFFGetReadProc; TIFFGetSeekProc; TIFFGetSizeProc; + TIFFGetStrileByteCount; + TIFFGetStrileByteCountWithErr; + TIFFGetStrileOffset; + TIFFGetStrileOffsetWithErr; TIFFGetTagListCount; TIFFGetTagListEntry; TIFFGetUnmapFileProc; @@ -74,12 +89,16 @@ LIBTIFF_4.0 { TIFFReadCustomDirectory; TIFFReadDirectory; TIFFReadEXIFDirectory; + TIFFReadGPSDirectory; TIFFReadEncodedStrip; TIFFReadEncodedTile; + TIFFReadFromUserBuffer; TIFFReadRGBAImage; TIFFReadRGBAImageOriented; TIFFReadRGBAStrip; + TIFFReadRGBAStripExt; TIFFReadRGBATile; + TIFFReadRGBATileExt; TIFFReadRawStrip; TIFFReadRawTile; TIFFReadScanline; @@ -91,6 +110,7 @@ LIBTIFF_4.0 { TIFFScanlineSize64; TIFFSetClientInfo; TIFFSetClientdata; + TIFFSetCompressionScheme; TIFFSetDirectory; TIFFSetErrorHandler; TIFFSetErrorHandlerExt; @@ -135,6 +155,7 @@ LIBTIFF_4.0 { TIFFWarningExt; TIFFWriteBufferSetup; TIFFWriteCheck; + TIFFWriteCustomDirectory; TIFFWriteDirectory; TIFFWriteEncodedStrip; TIFFWriteEncodedTile; @@ -145,72 +166,19 @@ LIBTIFF_4.0 { TIFFXYZToRGB; TIFFYCbCrToRGBInit; TIFFYCbCrtoRGB; - _TIFFfree; - _TIFFmalloc; - _TIFFmemcmp; - _TIFFmemcpy; - _TIFFmemset; - _TIFFrealloc; - + _TIFFCheckMalloc; + _TIFFCheckRealloc; + _TIFFRewriteField; + _TIFFfree; + _TIFFmalloc; + _TIFFmemcmp; + _TIFFmemcpy; + _TIFFmemset; + _TIFFrealloc; + _TIFFMultiply32; + _TIFFMultiply64; + _TIFFGetExifFields; + _TIFFGetGpsFields; local: *; }; - -LIBTIFF_4.1 { - _TIFFCheckMalloc; - _TIFFCheckRealloc; - _TIFFMultiply32; - _TIFFMultiply64; - _TIFFRewriteField; - TIFFCreateCustomDirectory; - TIFFCreateEXIFDirectory; - TIFFDeferStrileArrayWriting; - TIFFFieldDataType; - TIFFFieldName; - TIFFFieldPassCount; - TIFFFieldReadCount; - TIFFFieldTag; - TIFFFieldWriteCount; - TIFFForceStrileArrayWriting; - TIFFGetStrileByteCount; - TIFFGetStrileByteCountWithErr; - TIFFGetStrileOffset; - TIFFGetStrileOffsetWithErr; - TIFFReadFromUserBuffer; - TIFFReadRGBAStripExt; - TIFFReadRGBATileExt; - TIFFSetCompressionScheme; - TIFFWriteCustomDirectory; -} LIBTIFF_4.0; - -LIBTIFF_4.2 { - TIFFCreateGPSDirectory; - TIFFReadGPSDirectory; - _TIFFGetExifFields; - _TIFFGetGpsFields; -} LIBTIFF_4.1; - -LIBTIFF_4.3 { -} LIBTIFF_4.2; - -LIBTIFF_4.4 { - TIFFFieldIsAnonymous; - TIFFFieldSetGetSize; - TIFFFieldSetGetCountSize; - TIFFIsBigTIFF; -} LIBTIFF_4.3; - -LIBTIFF_4.5 { - _TIFFClampDoubleToUInt32; - TIFFClientOpenExt; - TIFFFdOpenExt; - TIFFOpenExt; - TIFFOpenWExt; - TIFFErrorExtR; - TIFFWarningExtR; - TIFFOpenOptionsAlloc; - TIFFOpenOptionsFree; - TIFFOpenOptionsSetMaxSingleMemAlloc; - TIFFOpenOptionsSetErrorHandlerExtR; - TIFFOpenOptionsSetWarningHandlerExtR; -} LIBTIFF_4.4; diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/mingw/tif_config.h b/thirdparty/SDL2_image/external/libtiff/libtiff/mingw/tif_config.h new file mode 100644 index 000000000..34de0db38 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/mingw/tif_config.h @@ -0,0 +1,374 @@ +/* libtiff/tif_config.h. Generated from tif_config.h.in by configure. */ +/* libtiff/tif_config.h.in. Generated from configure.ac by autoheader. */ + +/* Support CCITT Group 3 & 4 algorithms */ +#define CCITT_SUPPORT 1 + +/* Pick up YCbCr subsampling info from the JPEG data stream to support files + lacking the tag (default enabled). */ +/* #undef CHECK_JPEG_YCBCR_SUBSAMPLING */ + +/* enable partial strip reading for large strips */ +/* #undef CHUNKY_STRIP_READ_SUPPORT */ + +/* 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. */ +#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 + +/* enable deferred strip/tile offset/size loading (experimental) */ +/* #undef DEFER_STRILE_LOAD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. + */ +/* #undef HAVE_DECL_OPTARG */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DLFCN_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +/* #undef HAVE_FSEEKO */ + +/* Define to 1 if you have the `getopt' function. */ +/* #undef HAVE_GETOPT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GLUT_GLUT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GL_GLUT_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GL_GLU_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_GL_GL_H */ + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ +#define HAVE_IEEEFP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_IO_H 1 + +/* Define to 1 if you have the `jbg_newlen' function. */ +/* #undef HAVE_JBG_NEWLEN */ + +/* Define to 1 if you have the `lfind' function. */ +#define HAVE_LFIND 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mmap' function. */ +/* #undef HAVE_MMAP */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_OPENGL_GLU_H */ + +/* Define to 1 if you have the 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 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 `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strcasecmp' function. */ +#define HAVE_STRCASECMP 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strtol' function. */ +#define HAVE_STRTOL 1 + +/* Define to 1 if you have the `strtoll' function. */ +#define HAVE_STRTOLL 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if you have the `strtoull' function. */ +#define HAVE_STRTOULL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the 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 header file. */ +#define HAVE_WINDOWS_H 1 + +/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian + (Intel) */ +#define HOST_BIGENDIAN 0 + +/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +/* Support ISO JBIG compression (requires JBIG-KIT library) */ +/* #undef JBIG_SUPPORT */ + +/* 8/12 bit libjpeg dual mode enabled */ +/* #undef JPEG_DUAL_MODE_8_12 */ + +/* Support JPEG compression (requires IJG JPEG library) */ +/* #undef JPEG_SUPPORT */ + +/* Support libdeflate enhanced compression */ +/* #undef LIBDEFLATE_SUPPORT */ + +/* 12bit libjpeg primary include file with path */ +/* #undef LIBJPEG_12_PATH */ + +/* Support LogLuv high dynamic range encoding */ +#define LOGLUV_SUPPORT 1 + +/* Support LZMA2 compression */ +/* #undef LZMA_SUPPORT */ + +/* Support LZW algorithm */ +#define LZW_SUPPORT 1 + +/* Support Microsoft Document Imaging format */ +#define MDI_SUPPORT 1 + +/* Support NeXT 2-bit RLE algorithm */ +#define NEXT_SUPPORT 1 + +/* Support Old JPEG compresson (read-only) */ +/* #undef OJPEG_SUPPORT */ + +/* Name of package */ +#define PACKAGE "tiff" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "tiff@lists.maptools.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "LibTIFF Software" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "LibTIFF Software 4.2.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "tiff" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "4.2.0" + +/* Support Macintosh PackBits algorithm */ +#define PACKBITS_SUPPORT 1 + +/* 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. */ +#define SIZEOF_SIGNED_INT 4 + +/* The size of `signed long', as computed by sizeof. */ +#define SIZEOF_SIGNED_LONG 4 + +/* The size of `signed long long', as computed by sizeof. */ +#define SIZEOF_SIGNED_LONG_LONG 8 + +/* The size of `size_t', as computed by sizeof. */ +#ifdef _WIN64 +#define SIZEOF_SIZE_T 8 +#else +#define SIZEOF_SIZE_T 4 +#endif + +/* The size of `unsigned char *', as computed by sizeof. */ +#ifdef _WIN64 +#define SIZEOF_UNSIGNED_CHAR_P 8 +#else +#define SIZEOF_UNSIGNED_CHAR_P 4 +#endif + +/* The size of `unsigned int', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_INT 4 + +/* The size of `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 4 + +/* The size of `unsigned long long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG_LONG 8 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Support strip chopping (whether or not to convert single-strip uncompressed + images to mutiple strips of specified size to reduce memory usage) */ +#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP + +/* Default size of the strip in bytes (when strip chopping enabled) */ +#define STRIP_SIZE_DEFAULT 8192 + +/* Enable SubIFD tag (330) support */ +#define SUBIFD_SUPPORT 1 + +/* Support ThunderScan 4-bit RLE algorithm */ +#define THUNDER_SUPPORT 1 + +/* Signed 16-bit type */ +#define TIFF_INT16_T signed short + +/* Signed 32-bit type formatter */ +#define TIFF_INT32_FORMAT "%d" + +/* Signed 32-bit type */ +#define TIFF_INT32_T signed int + +/* Signed 64-bit type formatter */ +#define TIFF_INT64_FORMAT "%I64d" + +/* Signed 64-bit type */ +#define TIFF_INT64_T signed long long + +/* Signed 8-bit type */ +#define TIFF_INT8_T signed char + +/* Pointer difference type formatter */ +#define TIFF_PTRDIFF_FORMAT "%ld" + +/* Pointer difference type */ +#define TIFF_PTRDIFF_T ptrdiff_t + +/* Size type formatter */ +#ifdef _WIN64 +#define TIFF_SIZE_FORMAT "%I64u" +#else +#define TIFF_SIZE_FORMAT "%u" +#endif + +/* Unsigned size type */ +#ifdef _WIN64 +#define TIFF_SIZE_T unsigned long long +#else +#define TIFF_SIZE_T unsigned int +#endif + +/* Signed size type formatter */ +#ifdef _WIN64 +#define TIFF_SSIZE_FORMAT "%I64d" +#else +#define TIFF_SSIZE_FORMAT "%d" +#endif + +/* Signed size type */ +#ifdef _WIN64 +#define TIFF_SSIZE_T signed long long +#else +#define TIFF_SSIZE_T signed int +#endif + +/* Unsigned 16-bit type */ +#define TIFF_UINT16_T unsigned short + +/* Unsigned 32-bit type formatter */ +#define TIFF_UINT32_FORMAT "%u" + +/* Unsigned 32-bit type */ +#define TIFF_UINT32_T unsigned int + +/* Unsigned 64-bit type formatter */ +#define TIFF_UINT64_FORMAT "%I64u" + +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T unsigned long long + +/* Unsigned 8-bit type */ +#define TIFF_UINT8_T unsigned char + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* define to use win32 IO system */ +#define USE_WIN32_FILEIO 1 + +/* Version number of package */ +#define VERSION "4.2.0" + +/* Support webp compression */ +/* #undef WEBP_SUPPORT */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +/* #undef WORDS_BIGENDIAN */ + +/* Support Deflate compression */ +/* #undef ZIP_SUPPORT */ + +/* Support zstd compression */ +/* #undef ZSTD_SUPPORT */ + +/* Number of bits in a file offset, on hosts where this is settable. */ +/* #undef _FILE_OFFSET_BITS */ + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +/* #undef _LARGEFILE_SOURCE */ + +/* Define for large files, on AIX-style hosts. */ +/* #undef _LARGE_FILES */ + +/* 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 */ +#endif + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/mingw/tiffconf.h b/thirdparty/SDL2_image/external/libtiff/libtiff/mingw/tiffconf.h new file mode 100644 index 000000000..7bd087a34 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/mingw/tiffconf.h @@ -0,0 +1,126 @@ +/* libtiff/tiffconf.h. Generated from tiffconf.h.in by configure. */ +/* + Configuration defines for installed libtiff. + This file maintained for backward compatibility. Do not use definitions + from this file in your programs. +*/ + +#ifndef _TIFFCONF_ +#define _TIFFCONF_ + +/* Signed 16-bit type */ +#define TIFF_INT16_T signed short + +/* Signed 32-bit type */ +#define TIFF_INT32_T signed int + +/* Signed 64-bit type */ +#define TIFF_INT64_T signed long long + +/* Signed 8-bit type */ +#define TIFF_INT8_T signed char + +/* Unsigned 16-bit type */ +#define TIFF_UINT16_T unsigned short + +/* Unsigned 32-bit type */ +#define TIFF_UINT32_T unsigned int + +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T unsigned long long + +/* Unsigned 8-bit type */ +#define TIFF_UINT8_T unsigned char + +/* Signed size type */ +#if defined _WIN64 +#define TIFF_SSIZE_T signed long long +#else +#define TIFF_SSIZE_T signed int +#endif + +/* Pointer difference type */ +#define TIFF_PTRDIFF_T ptrdiff_t + +/* 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 JBIG compression (requires JBIG-KIT library) */ +/* #undef JBIG_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 libdeflate enhanced compression */ +/* #undef LIBDEFLATE_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). */ +/* #undef CHECK_JPEG_YCBCR_SUBSAMPLING */ + +/* Support MS MDI magic number files as TIFF */ +#define MDI_SUPPORT 1 + +/* + * Feature support definitions. + * XXX: These macros are obsoleted. Don't use them in your apps! + * Macros stays here for backward compatibility and should be always defined. + */ +#define COLORIMETRY_SUPPORT +#define YCBCR_SUPPORT +#define CMYK_SUPPORT +#define ICC_SUPPORT +#define PHOTOSHOP_SUPPORT +#define IPTC_SUPPORT + +#endif /* _TIFFCONF_ */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/mkg3states.c b/thirdparty/SDL2_image/external/libtiff/libtiff/mkg3states.c index f32113a31..2cb9174c6 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/mkg3states.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/mkg3states.c @@ -2,23 +2,23 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -27,7 +27,6 @@ * in Frank Cringle's viewfax program; * Copyright (C) 1990, 1995 Frank D. Cringle. */ -#include "libport.h" #include "tif_config.h" #include @@ -35,206 +34,386 @@ #include #ifdef HAVE_UNISTD_H -#include +# include #endif #include "tif_fax3.h" -#define streq(a, b) (strcmp(a, b) == 0) +#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 */ TIFFFaxTabEnt MainTable[128]; TIFFFaxTabEnt WhiteTable[4096]; TIFFFaxTabEnt BlackTable[8192]; -struct proto -{ - uint16_t code; /* right justified, lsb-first, zero filled */ - uint16_t val; /* (pixel count)<<4 + code width */ +struct proto { + uint16 code; /* right justified, lsb-first, zero filled */ + uint16 val; /* (pixel count)<<4 + code width */ }; -static struct proto Pass[] = {{0x0008, 4}, {0, 0}}; +static struct proto Pass[] = { +{ 0x0008, 4 }, +{ 0, 0 } +}; -static struct proto Horiz[] = {{0x0004, 3}, {0, 0}}; +static struct proto Horiz[] = { +{ 0x0004, 3 }, +{ 0, 0 } +}; -static struct proto V0[] = {{0x0001, 1}, {0, 0}}; +static struct proto V0[] = { +{ 0x0001, 1 }, +{ 0, 0 } +}; -static struct proto VR[] = {{0x0006, (1 << 4) + 3}, - {0x0030, (2 << 4) + 6}, - {0x0060, (3 << 4) + 7}, - {0, 0}}; +static struct proto VR[] = { +{ 0x0006, (1<<4)+3 }, +{ 0x0030, (2<<4)+6 }, +{ 0x0060, (3<<4)+7 }, +{ 0, 0 } +}; -static struct proto VL[] = {{0x0002, (1 << 4) + 3}, - {0x0010, (2 << 4) + 6}, - {0x0020, (3 << 4) + 7}, - {0, 0}}; +static struct proto VL[] = { +{ 0x0002, (1<<4)+3 }, +{ 0x0010, (2<<4)+6 }, +{ 0x0020, (3<<4)+7 }, +{ 0, 0 } +}; -static struct proto Ext[] = {{0x0040, 7}, {0, 0}}; +static struct proto Ext[] = { +{ 0x0040, 7 }, +{ 0, 0 } +}; -static struct proto EOLV[] = {{0x0000, 7}, {0, 0}}; +static struct proto EOLV[] = { +{ 0x0000, 7 }, +{ 0, 0 } +}; static struct proto MakeUpW[] = { - {0x001b, 1029}, {0x0009, 2053}, {0x003a, 3078}, {0x0076, 4103}, - {0x006c, 5128}, {0x00ec, 6152}, {0x0026, 7176}, {0x00a6, 8200}, - {0x0016, 9224}, {0x00e6, 10248}, {0x0066, 11273}, {0x0166, 12297}, - {0x0096, 13321}, {0x0196, 14345}, {0x0056, 15369}, {0x0156, 16393}, - {0x00d6, 17417}, {0x01d6, 18441}, {0x0036, 19465}, {0x0136, 20489}, - {0x00b6, 21513}, {0x01b6, 22537}, {0x0032, 23561}, {0x0132, 24585}, - {0x00b2, 25609}, {0x0006, 26630}, {0x01b2, 27657}, {0, 0}}; +{ 0x001b, 1029 }, +{ 0x0009, 2053 }, +{ 0x003a, 3078 }, +{ 0x0076, 4103 }, +{ 0x006c, 5128 }, +{ 0x00ec, 6152 }, +{ 0x0026, 7176 }, +{ 0x00a6, 8200 }, +{ 0x0016, 9224 }, +{ 0x00e6, 10248 }, +{ 0x0066, 11273 }, +{ 0x0166, 12297 }, +{ 0x0096, 13321 }, +{ 0x0196, 14345 }, +{ 0x0056, 15369 }, +{ 0x0156, 16393 }, +{ 0x00d6, 17417 }, +{ 0x01d6, 18441 }, +{ 0x0036, 19465 }, +{ 0x0136, 20489 }, +{ 0x00b6, 21513 }, +{ 0x01b6, 22537 }, +{ 0x0032, 23561 }, +{ 0x0132, 24585 }, +{ 0x00b2, 25609 }, +{ 0x0006, 26630 }, +{ 0x01b2, 27657 }, +{ 0, 0 } +}; static struct proto MakeUpB[] = { - {0x03c0, 1034}, {0x0130, 2060}, {0x0930, 3084}, {0x0da0, 4108}, - {0x0cc0, 5132}, {0x02c0, 6156}, {0x0ac0, 7180}, {0x06c0, 8205}, - {0x16c0, 9229}, {0x0a40, 10253}, {0x1a40, 11277}, {0x0640, 12301}, - {0x1640, 13325}, {0x09c0, 14349}, {0x19c0, 15373}, {0x05c0, 16397}, - {0x15c0, 17421}, {0x0dc0, 18445}, {0x1dc0, 19469}, {0x0940, 20493}, - {0x1940, 21517}, {0x0540, 22541}, {0x1540, 23565}, {0x0b40, 24589}, - {0x1b40, 25613}, {0x04c0, 26637}, {0x14c0, 27661}, {0, 0}}; +{ 0x03c0, 1034 }, +{ 0x0130, 2060 }, +{ 0x0930, 3084 }, +{ 0x0da0, 4108 }, +{ 0x0cc0, 5132 }, +{ 0x02c0, 6156 }, +{ 0x0ac0, 7180 }, +{ 0x06c0, 8205 }, +{ 0x16c0, 9229 }, +{ 0x0a40, 10253 }, +{ 0x1a40, 11277 }, +{ 0x0640, 12301 }, +{ 0x1640, 13325 }, +{ 0x09c0, 14349 }, +{ 0x19c0, 15373 }, +{ 0x05c0, 16397 }, +{ 0x15c0, 17421 }, +{ 0x0dc0, 18445 }, +{ 0x1dc0, 19469 }, +{ 0x0940, 20493 }, +{ 0x1940, 21517 }, +{ 0x0540, 22541 }, +{ 0x1540, 23565 }, +{ 0x0b40, 24589 }, +{ 0x1b40, 25613 }, +{ 0x04c0, 26637 }, +{ 0x14c0, 27661 }, +{ 0, 0 } +}; static struct proto MakeUp[] = { - {0x0080, 28683}, {0x0180, 29707}, {0x0580, 30731}, {0x0480, 31756}, - {0x0c80, 32780}, {0x0280, 33804}, {0x0a80, 34828}, {0x0680, 35852}, - {0x0e80, 36876}, {0x0380, 37900}, {0x0b80, 38924}, {0x0780, 39948}, - {0x0f80, 40972}, {0, 0}}; +{ 0x0080, 28683 }, +{ 0x0180, 29707 }, +{ 0x0580, 30731 }, +{ 0x0480, 31756 }, +{ 0x0c80, 32780 }, +{ 0x0280, 33804 }, +{ 0x0a80, 34828 }, +{ 0x0680, 35852 }, +{ 0x0e80, 36876 }, +{ 0x0380, 37900 }, +{ 0x0b80, 38924 }, +{ 0x0780, 39948 }, +{ 0x0f80, 40972 }, +{ 0, 0 } +}; static struct proto TermW[] = { - {0x00ac, 8}, {0x0038, 22}, {0x000e, 36}, {0x0001, 52}, {0x000d, 68}, - {0x0003, 84}, {0x0007, 100}, {0x000f, 116}, {0x0019, 133}, {0x0005, 149}, - {0x001c, 165}, {0x0002, 181}, {0x0004, 198}, {0x0030, 214}, {0x000b, 230}, - {0x002b, 246}, {0x0015, 262}, {0x0035, 278}, {0x0072, 295}, {0x0018, 311}, - {0x0008, 327}, {0x0074, 343}, {0x0060, 359}, {0x0010, 375}, {0x000a, 391}, - {0x006a, 407}, {0x0064, 423}, {0x0012, 439}, {0x000c, 455}, {0x0040, 472}, - {0x00c0, 488}, {0x0058, 504}, {0x00d8, 520}, {0x0048, 536}, {0x00c8, 552}, - {0x0028, 568}, {0x00a8, 584}, {0x0068, 600}, {0x00e8, 616}, {0x0014, 632}, - {0x0094, 648}, {0x0054, 664}, {0x00d4, 680}, {0x0034, 696}, {0x00b4, 712}, - {0x0020, 728}, {0x00a0, 744}, {0x0050, 760}, {0x00d0, 776}, {0x004a, 792}, - {0x00ca, 808}, {0x002a, 824}, {0x00aa, 840}, {0x0024, 856}, {0x00a4, 872}, - {0x001a, 888}, {0x009a, 904}, {0x005a, 920}, {0x00da, 936}, {0x0052, 952}, - {0x00d2, 968}, {0x004c, 984}, {0x00cc, 1000}, {0x002c, 1016}, {0, 0}}; +{ 0x00ac, 8 }, +{ 0x0038, 22 }, +{ 0x000e, 36 }, +{ 0x0001, 52 }, +{ 0x000d, 68 }, +{ 0x0003, 84 }, +{ 0x0007, 100 }, +{ 0x000f, 116 }, +{ 0x0019, 133 }, +{ 0x0005, 149 }, +{ 0x001c, 165 }, +{ 0x0002, 181 }, +{ 0x0004, 198 }, +{ 0x0030, 214 }, +{ 0x000b, 230 }, +{ 0x002b, 246 }, +{ 0x0015, 262 }, +{ 0x0035, 278 }, +{ 0x0072, 295 }, +{ 0x0018, 311 }, +{ 0x0008, 327 }, +{ 0x0074, 343 }, +{ 0x0060, 359 }, +{ 0x0010, 375 }, +{ 0x000a, 391 }, +{ 0x006a, 407 }, +{ 0x0064, 423 }, +{ 0x0012, 439 }, +{ 0x000c, 455 }, +{ 0x0040, 472 }, +{ 0x00c0, 488 }, +{ 0x0058, 504 }, +{ 0x00d8, 520 }, +{ 0x0048, 536 }, +{ 0x00c8, 552 }, +{ 0x0028, 568 }, +{ 0x00a8, 584 }, +{ 0x0068, 600 }, +{ 0x00e8, 616 }, +{ 0x0014, 632 }, +{ 0x0094, 648 }, +{ 0x0054, 664 }, +{ 0x00d4, 680 }, +{ 0x0034, 696 }, +{ 0x00b4, 712 }, +{ 0x0020, 728 }, +{ 0x00a0, 744 }, +{ 0x0050, 760 }, +{ 0x00d0, 776 }, +{ 0x004a, 792 }, +{ 0x00ca, 808 }, +{ 0x002a, 824 }, +{ 0x00aa, 840 }, +{ 0x0024, 856 }, +{ 0x00a4, 872 }, +{ 0x001a, 888 }, +{ 0x009a, 904 }, +{ 0x005a, 920 }, +{ 0x00da, 936 }, +{ 0x0052, 952 }, +{ 0x00d2, 968 }, +{ 0x004c, 984 }, +{ 0x00cc, 1000 }, +{ 0x002c, 1016 }, +{ 0, 0 } +}; static struct proto TermB[] = { - {0x03b0, 10}, {0x0002, 19}, {0x0003, 34}, {0x0001, 50}, {0x0006, 67}, - {0x000c, 84}, {0x0004, 100}, {0x0018, 117}, {0x0028, 134}, {0x0008, 150}, - {0x0010, 167}, {0x0050, 183}, {0x0070, 199}, {0x0020, 216}, {0x00e0, 232}, - {0x0030, 249}, {0x03a0, 266}, {0x0060, 282}, {0x0040, 298}, {0x0730, 315}, - {0x00b0, 331}, {0x01b0, 347}, {0x0760, 363}, {0x00a0, 379}, {0x0740, 395}, - {0x00c0, 411}, {0x0530, 428}, {0x0d30, 444}, {0x0330, 460}, {0x0b30, 476}, - {0x0160, 492}, {0x0960, 508}, {0x0560, 524}, {0x0d60, 540}, {0x04b0, 556}, - {0x0cb0, 572}, {0x02b0, 588}, {0x0ab0, 604}, {0x06b0, 620}, {0x0eb0, 636}, - {0x0360, 652}, {0x0b60, 668}, {0x05b0, 684}, {0x0db0, 700}, {0x02a0, 716}, - {0x0aa0, 732}, {0x06a0, 748}, {0x0ea0, 764}, {0x0260, 780}, {0x0a60, 796}, - {0x04a0, 812}, {0x0ca0, 828}, {0x0240, 844}, {0x0ec0, 860}, {0x01c0, 876}, - {0x0e40, 892}, {0x0140, 908}, {0x01a0, 924}, {0x09a0, 940}, {0x0d40, 956}, - {0x0340, 972}, {0x05a0, 988}, {0x0660, 1004}, {0x0e60, 1020}, {0, 0}}; +{ 0x03b0, 10 }, +{ 0x0002, 19 }, +{ 0x0003, 34 }, +{ 0x0001, 50 }, +{ 0x0006, 67 }, +{ 0x000c, 84 }, +{ 0x0004, 100 }, +{ 0x0018, 117 }, +{ 0x0028, 134 }, +{ 0x0008, 150 }, +{ 0x0010, 167 }, +{ 0x0050, 183 }, +{ 0x0070, 199 }, +{ 0x0020, 216 }, +{ 0x00e0, 232 }, +{ 0x0030, 249 }, +{ 0x03a0, 266 }, +{ 0x0060, 282 }, +{ 0x0040, 298 }, +{ 0x0730, 315 }, +{ 0x00b0, 331 }, +{ 0x01b0, 347 }, +{ 0x0760, 363 }, +{ 0x00a0, 379 }, +{ 0x0740, 395 }, +{ 0x00c0, 411 }, +{ 0x0530, 428 }, +{ 0x0d30, 444 }, +{ 0x0330, 460 }, +{ 0x0b30, 476 }, +{ 0x0160, 492 }, +{ 0x0960, 508 }, +{ 0x0560, 524 }, +{ 0x0d60, 540 }, +{ 0x04b0, 556 }, +{ 0x0cb0, 572 }, +{ 0x02b0, 588 }, +{ 0x0ab0, 604 }, +{ 0x06b0, 620 }, +{ 0x0eb0, 636 }, +{ 0x0360, 652 }, +{ 0x0b60, 668 }, +{ 0x05b0, 684 }, +{ 0x0db0, 700 }, +{ 0x02a0, 716 }, +{ 0x0aa0, 732 }, +{ 0x06a0, 748 }, +{ 0x0ea0, 764 }, +{ 0x0260, 780 }, +{ 0x0a60, 796 }, +{ 0x04a0, 812 }, +{ 0x0ca0, 828 }, +{ 0x0240, 844 }, +{ 0x0ec0, 860 }, +{ 0x01c0, 876 }, +{ 0x0e40, 892 }, +{ 0x0140, 908 }, +{ 0x01a0, 924 }, +{ 0x09a0, 940 }, +{ 0x0d40, 956 }, +{ 0x0340, 972 }, +{ 0x05a0, 988 }, +{ 0x0660, 1004 }, +{ 0x0e60, 1020 }, +{ 0, 0 } +}; -static struct proto EOLH[] = {{0x0000, 11}, {0, 0}}; +static struct proto EOLH[] = { +{ 0x0000, 11 }, +{ 0, 0 } +}; -static void FillTable(TIFFFaxTabEnt *T, int Size, struct proto *P, int State) +static void +FillTable(TIFFFaxTabEnt *T, int Size, struct proto *P, int State) { int limit = 1 << Size; - while (P->val) - { - int width = P->val & 15; - int param = P->val >> 4; - int incr = 1 << width; - int code; - for (code = P->code; code < limit; code += incr) - { - TIFFFaxTabEnt *E = T + code; - E->State = State; - E->Width = width; - E->Param = param; - } - P++; + while (P->val) { + int width = P->val & 15; + int param = P->val >> 4; + int incr = 1 << width; + int code; + for (code = P->code; code < limit; code += incr) { + TIFFFaxTabEnt *E = T+code; + E->State = State; + E->Width = width; + E->Param = param; + } + P++; } } -static char *storage_class = ""; -static char *const_class = ""; -static int packoutput = 1; -static char *prebrace = ""; -static char *postbrace = ""; +static char* storage_class = ""; +static char* const_class = ""; +static int packoutput = 1; +static char* prebrace = ""; +static char* postbrace = ""; -void WriteTable(FILE *fd, const TIFFFaxTabEnt *T, int Size, const char *name) +void +WriteTable(FILE* fd, const TIFFFaxTabEnt* T, int Size, const char* name) { int i; - char *sep; + char* sep; - fprintf(fd, "%s %s TIFFFaxTabEnt %s[%d] = {", storage_class, const_class, - name, Size); - if (packoutput) - { - sep = "\n"; - for (i = 0; i < Size; i++) - { - fprintf(fd, "%s%s%d,%d,%d%s", sep, prebrace, T->State, T->Width, - (int)T->Param, postbrace); - if (((i + 1) % 10) == 0) - sep = ",\n"; - else - sep = ","; - T++; - } - } - else - { - sep = "\n "; - for (i = 0; i < Size; i++) - { - fprintf(fd, "%s%s%3d,%3d,%4d%s", sep, prebrace, T->State, T->Width, - (int)T->Param, postbrace); - if (((i + 1) % 6) == 0) - sep = ",\n "; - else - sep = ","; - T++; - } + fprintf(fd, "%s %s TIFFFaxTabEnt %s[%d] = {", + storage_class, const_class, name, Size); + if (packoutput) { + sep = "\n"; + for (i = 0; i < Size; i++) { + fprintf(fd, "%s%s%d,%d,%d%s", + sep, prebrace, T->State, T->Width, (int) T->Param, postbrace); + if (((i+1) % 10) == 0) + sep = ",\n"; + else + sep = ","; + T++; + } + } else { + sep = "\n "; + for (i = 0; i < Size; i++) { + fprintf(fd, "%s%s%3d,%3d,%4d%s", + sep, prebrace, T->State, T->Width, (int) T->Param, postbrace); + if (((i+1) % 6) == 0) + sep = ",\n "; + else + sep = ","; + T++; + } } fprintf(fd, "\n};\n"); } /* initialise the huffman code tables */ -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - FILE *fd; - char *outputfile; + FILE* fd; + char* outputfile; int c; #if !HAVE_DECL_OPTARG extern int optind; - extern char *optarg; + extern char* optarg; #endif while ((c = getopt(argc, argv, "c:s:bp")) != -1) - switch (c) - { - case 'c': - const_class = optarg; - break; - case 's': - storage_class = optarg; - break; - case 'p': - packoutput = 0; - break; - case 'b': - prebrace = "{"; - postbrace = "}"; - break; - case '?': - fprintf(stderr, - "usage: %s [-c const] [-s storage] [-p] [-b] file\n", - argv[0]); - return (-1); - } + switch (c) { + case 'c': + const_class = optarg; + break; + case 's': + storage_class = optarg; + break; + case 'p': + packoutput = 0; + break; + case 'b': + prebrace = "{"; + postbrace = "}"; + break; + case '?': + fprintf(stderr, + "usage: %s [-c const] [-s storage] [-p] [-b] file\n", + argv[0]); + return (-1); + } outputfile = optind < argc ? argv[optind] : "g3states.h"; fd = fopen(outputfile, "w"); - if (fd == NULL) - { - fprintf(stderr, "%s: %s: Cannot create output file.\n", argv[0], - outputfile); - return (-2); + if (fd == NULL) { + fprintf(stderr, "%s: %s: Cannot create output file.\n", + argv[0], outputfile); + return (-2); } FillTable(MainTable, 7, Pass, S_Pass); FillTable(MainTable, 7, Horiz, S_Horiz); @@ -254,19 +433,20 @@ int main(int argc, char *argv[]) fprintf(fd, "/* WARNING, this file was automatically generated by the\n"); fprintf(fd, " mkg3states program */\n"); - fprintf(fd, "#include \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); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/mkspans.c b/thirdparty/SDL2_image/external/libtiff/libtiff/mkspans.c index 24c63ab7f..c7c5bdd08 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/mkspans.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/mkspans.c @@ -2,75 +2,79 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include #include +#include /* * Hack program to construct tables used to find * runs of zeros and ones in Group 3 Fax encoding. */ -dumparray(name, runs) char *name; -unsigned char runs[256]; +dumparray(name, runs) + char *name; + unsigned char runs[256]; { - int i; - char *sep; - printf("static unsigned char %s[256] = {\n", name); - sep = " "; - for (i = 0; i < 256; i++) - { - printf("%s%d", sep, runs[i]); - if (((i + 1) % 16) == 0) - { - printf(", /* 0x%02x - 0x%02x */\n", i - 15, i); - sep = " "; - } - else - sep = ", "; - } - printf("\n};\n"); + int i; + char *sep; + printf("static unsigned char %s[256] = {\n", name); + sep = " "; + for (i = 0; i < 256; i++) { + printf("%s%d", sep, runs[i]); + if (((i + 1) % 16) == 0) { + printf(", /* 0x%02x - 0x%02x */\n", i-15, i); + sep = " "; + } else + sep = ", "; + } + printf("\n};\n"); } main() { - unsigned char runs[2][256]; + unsigned char runs[2][256]; - memset(runs[0], 0, 256 * sizeof(char)); - memset(runs[1], 0, 256 * sizeof(char)); - { - register int run, runlen, i; - runlen = 1; - for (run = 0x80; run != 0xff; run = (run >> 1) | 0x80) - { - for (i = run - 1; i >= 0; i--) - { - runs[1][run | i] = runlen; - runs[0][(~(run | i)) & 0xff] = runlen; - } - runlen++; - } - runs[1][0xff] = runs[0][0] = 8; - } - dumparray("bruns", runs[0]); - dumparray("wruns", runs[1]); + memset(runs[0], 0, 256*sizeof (char)); + memset(runs[1], 0, 256*sizeof (char)); + { register int run, runlen, i; + runlen = 1; + for (run = 0x80; run != 0xff; run = (run>>1)|0x80) { + for (i = run-1; i >= 0; i--) { + runs[1][run|i] = runlen; + runs[0][(~(run|i)) & 0xff] = runlen; + } + runlen++; + } + runs[1][0xff] = runs[0][0] = 8; + } + dumparray("bruns", runs[0]); + dumparray("wruns", runs[1]); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/t4.h b/thirdparty/SDL2_image/external/libtiff/libtiff/t4.h index f933d4a33..fb0951a16 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/t4.h +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/t4.h @@ -23,27 +23,26 @@ */ #ifndef _T4_ -#define _T4_ +#define _T4_ /* * CCITT T.4 1D Huffman runlength codes and * related definitions. Given the small sizes * of these tables it does not seem * worthwhile to make code & length 8 bits. */ -typedef struct tableentry -{ - unsigned short length; /* bit length of g3 code */ - unsigned short code; /* g3 code */ - short runlen; /* run length in bits */ +typedef struct tableentry { + unsigned short length; /* bit length of g3 code */ + unsigned short code; /* g3 code */ + short runlen; /* run length in bits */ } tableentry; -#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ +#define EOL 0x001 /* EOL code value - 0000 0000 0000 1 */ /* status values returned instead of a run length */ -#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ -#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ -#define G3CODE_EOF -3 /* end of input data */ -#define G3CODE_INCOMP -4 /* incomplete run code */ +#define G3CODE_EOL -1 /* NB: ACT_EOL - ACT_WRUNT */ +#define G3CODE_INVALID -2 /* NB: ACT_INVALID - ACT_WRUNT */ +#define G3CODE_EOF -3 /* end of input data */ +#define G3CODE_INCOMP -4 /* incomplete run code */ /* * Note that these tables are ordered such that the @@ -55,230 +54,237 @@ typedef struct tableentry */ #ifdef G3CODES const tableentry TIFFFaxWhiteCodes[] = { - {8, 0x35, 0}, /* 0011 0101 */ - {6, 0x7, 1}, /* 0001 11 */ - {4, 0x7, 2}, /* 0111 */ - {4, 0x8, 3}, /* 1000 */ - {4, 0xB, 4}, /* 1011 */ - {4, 0xC, 5}, /* 1100 */ - {4, 0xE, 6}, /* 1110 */ - {4, 0xF, 7}, /* 1111 */ - {5, 0x13, 8}, /* 1001 1 */ - {5, 0x14, 9}, /* 1010 0 */ - {5, 0x7, 10}, /* 0011 1 */ - {5, 0x8, 11}, /* 0100 0 */ - {6, 0x8, 12}, /* 0010 00 */ - {6, 0x3, 13}, /* 0000 11 */ - {6, 0x34, 14}, /* 1101 00 */ - {6, 0x35, 15}, /* 1101 01 */ - {6, 0x2A, 16}, /* 1010 10 */ - {6, 0x2B, 17}, /* 1010 11 */ - {7, 0x27, 18}, /* 0100 111 */ - {7, 0xC, 19}, /* 0001 100 */ - {7, 0x8, 20}, /* 0001 000 */ - {7, 0x17, 21}, /* 0010 111 */ - {7, 0x3, 22}, /* 0000 011 */ - {7, 0x4, 23}, /* 0000 100 */ - {7, 0x28, 24}, /* 0101 000 */ - {7, 0x2B, 25}, /* 0101 011 */ - {7, 0x13, 26}, /* 0010 011 */ - {7, 0x24, 27}, /* 0100 100 */ - {7, 0x18, 28}, /* 0011 000 */ - {8, 0x2, 29}, /* 0000 0010 */ - {8, 0x3, 30}, /* 0000 0011 */ - {8, 0x1A, 31}, /* 0001 1010 */ - {8, 0x1B, 32}, /* 0001 1011 */ - {8, 0x12, 33}, /* 0001 0010 */ - {8, 0x13, 34}, /* 0001 0011 */ - {8, 0x14, 35}, /* 0001 0100 */ - {8, 0x15, 36}, /* 0001 0101 */ - {8, 0x16, 37}, /* 0001 0110 */ - {8, 0x17, 38}, /* 0001 0111 */ - {8, 0x28, 39}, /* 0010 1000 */ - {8, 0x29, 40}, /* 0010 1001 */ - {8, 0x2A, 41}, /* 0010 1010 */ - {8, 0x2B, 42}, /* 0010 1011 */ - {8, 0x2C, 43}, /* 0010 1100 */ - {8, 0x2D, 44}, /* 0010 1101 */ - {8, 0x4, 45}, /* 0000 0100 */ - {8, 0x5, 46}, /* 0000 0101 */ - {8, 0xA, 47}, /* 0000 1010 */ - {8, 0xB, 48}, /* 0000 1011 */ - {8, 0x52, 49}, /* 0101 0010 */ - {8, 0x53, 50}, /* 0101 0011 */ - {8, 0x54, 51}, /* 0101 0100 */ - {8, 0x55, 52}, /* 0101 0101 */ - {8, 0x24, 53}, /* 0010 0100 */ - {8, 0x25, 54}, /* 0010 0101 */ - {8, 0x58, 55}, /* 0101 1000 */ - {8, 0x59, 56}, /* 0101 1001 */ - {8, 0x5A, 57}, /* 0101 1010 */ - {8, 0x5B, 58}, /* 0101 1011 */ - {8, 0x4A, 59}, /* 0100 1010 */ - {8, 0x4B, 60}, /* 0100 1011 */ - {8, 0x32, 61}, /* 0011 0010 */ - {8, 0x33, 62}, /* 0011 0011 */ - {8, 0x34, 63}, /* 0011 0100 */ - {5, 0x1B, 64}, /* 1101 1 */ - {5, 0x12, 128}, /* 1001 0 */ - {6, 0x17, 192}, /* 0101 11 */ - {7, 0x37, 256}, /* 0110 111 */ - {8, 0x36, 320}, /* 0011 0110 */ - {8, 0x37, 384}, /* 0011 0111 */ - {8, 0x64, 448}, /* 0110 0100 */ - {8, 0x65, 512}, /* 0110 0101 */ - {8, 0x68, 576}, /* 0110 1000 */ - {8, 0x67, 640}, /* 0110 0111 */ - {9, 0xCC, 704}, /* 0110 0110 0 */ - {9, 0xCD, 768}, /* 0110 0110 1 */ - {9, 0xD2, 832}, /* 0110 1001 0 */ - {9, 0xD3, 896}, /* 0110 1001 1 */ - {9, 0xD4, 960}, /* 0110 1010 0 */ - {9, 0xD5, 1024}, /* 0110 1010 1 */ - {9, 0xD6, 1088}, /* 0110 1011 0 */ - {9, 0xD7, 1152}, /* 0110 1011 1 */ - {9, 0xD8, 1216}, /* 0110 1100 0 */ - {9, 0xD9, 1280}, /* 0110 1100 1 */ - {9, 0xDA, 1344}, /* 0110 1101 0 */ - {9, 0xDB, 1408}, /* 0110 1101 1 */ - {9, 0x98, 1472}, /* 0100 1100 0 */ - {9, 0x99, 1536}, /* 0100 1100 1 */ - {9, 0x9A, 1600}, /* 0100 1101 0 */ - {6, 0x18, 1664}, /* 0110 00 */ - {9, 0x9B, 1728}, /* 0100 1101 1 */ - {11, 0x8, 1792}, /* 0000 0001 000 */ - {11, 0xC, 1856}, /* 0000 0001 100 */ - {11, 0xD, 1920}, /* 0000 0001 101 */ - {12, 0x12, 1984}, /* 0000 0001 0010 */ - {12, 0x13, 2048}, /* 0000 0001 0011 */ - {12, 0x14, 2112}, /* 0000 0001 0100 */ - {12, 0x15, 2176}, /* 0000 0001 0101 */ - {12, 0x16, 2240}, /* 0000 0001 0110 */ - {12, 0x17, 2304}, /* 0000 0001 0111 */ - {12, 0x1C, 2368}, /* 0000 0001 1100 */ - {12, 0x1D, 2432}, /* 0000 0001 1101 */ - {12, 0x1E, 2496}, /* 0000 0001 1110 */ - {12, 0x1F, 2560}, /* 0000 0001 1111 */ - {12, 0x1, G3CODE_EOL}, /* 0000 0000 0001 */ - {9, 0x1, G3CODE_INVALID}, /* 0000 0000 1 */ - {10, 0x1, G3CODE_INVALID}, /* 0000 0000 01 */ - {11, 0x1, G3CODE_INVALID}, /* 0000 0000 001 */ - {12, 0x0, G3CODE_INVALID}, /* 0000 0000 0000 */ + { 8, 0x35, 0 }, /* 0011 0101 */ + { 6, 0x7, 1 }, /* 0001 11 */ + { 4, 0x7, 2 }, /* 0111 */ + { 4, 0x8, 3 }, /* 1000 */ + { 4, 0xB, 4 }, /* 1011 */ + { 4, 0xC, 5 }, /* 1100 */ + { 4, 0xE, 6 }, /* 1110 */ + { 4, 0xF, 7 }, /* 1111 */ + { 5, 0x13, 8 }, /* 1001 1 */ + { 5, 0x14, 9 }, /* 1010 0 */ + { 5, 0x7, 10 }, /* 0011 1 */ + { 5, 0x8, 11 }, /* 0100 0 */ + { 6, 0x8, 12 }, /* 0010 00 */ + { 6, 0x3, 13 }, /* 0000 11 */ + { 6, 0x34, 14 }, /* 1101 00 */ + { 6, 0x35, 15 }, /* 1101 01 */ + { 6, 0x2A, 16 }, /* 1010 10 */ + { 6, 0x2B, 17 }, /* 1010 11 */ + { 7, 0x27, 18 }, /* 0100 111 */ + { 7, 0xC, 19 }, /* 0001 100 */ + { 7, 0x8, 20 }, /* 0001 000 */ + { 7, 0x17, 21 }, /* 0010 111 */ + { 7, 0x3, 22 }, /* 0000 011 */ + { 7, 0x4, 23 }, /* 0000 100 */ + { 7, 0x28, 24 }, /* 0101 000 */ + { 7, 0x2B, 25 }, /* 0101 011 */ + { 7, 0x13, 26 }, /* 0010 011 */ + { 7, 0x24, 27 }, /* 0100 100 */ + { 7, 0x18, 28 }, /* 0011 000 */ + { 8, 0x2, 29 }, /* 0000 0010 */ + { 8, 0x3, 30 }, /* 0000 0011 */ + { 8, 0x1A, 31 }, /* 0001 1010 */ + { 8, 0x1B, 32 }, /* 0001 1011 */ + { 8, 0x12, 33 }, /* 0001 0010 */ + { 8, 0x13, 34 }, /* 0001 0011 */ + { 8, 0x14, 35 }, /* 0001 0100 */ + { 8, 0x15, 36 }, /* 0001 0101 */ + { 8, 0x16, 37 }, /* 0001 0110 */ + { 8, 0x17, 38 }, /* 0001 0111 */ + { 8, 0x28, 39 }, /* 0010 1000 */ + { 8, 0x29, 40 }, /* 0010 1001 */ + { 8, 0x2A, 41 }, /* 0010 1010 */ + { 8, 0x2B, 42 }, /* 0010 1011 */ + { 8, 0x2C, 43 }, /* 0010 1100 */ + { 8, 0x2D, 44 }, /* 0010 1101 */ + { 8, 0x4, 45 }, /* 0000 0100 */ + { 8, 0x5, 46 }, /* 0000 0101 */ + { 8, 0xA, 47 }, /* 0000 1010 */ + { 8, 0xB, 48 }, /* 0000 1011 */ + { 8, 0x52, 49 }, /* 0101 0010 */ + { 8, 0x53, 50 }, /* 0101 0011 */ + { 8, 0x54, 51 }, /* 0101 0100 */ + { 8, 0x55, 52 }, /* 0101 0101 */ + { 8, 0x24, 53 }, /* 0010 0100 */ + { 8, 0x25, 54 }, /* 0010 0101 */ + { 8, 0x58, 55 }, /* 0101 1000 */ + { 8, 0x59, 56 }, /* 0101 1001 */ + { 8, 0x5A, 57 }, /* 0101 1010 */ + { 8, 0x5B, 58 }, /* 0101 1011 */ + { 8, 0x4A, 59 }, /* 0100 1010 */ + { 8, 0x4B, 60 }, /* 0100 1011 */ + { 8, 0x32, 61 }, /* 0011 0010 */ + { 8, 0x33, 62 }, /* 0011 0011 */ + { 8, 0x34, 63 }, /* 0011 0100 */ + { 5, 0x1B, 64 }, /* 1101 1 */ + { 5, 0x12, 128 }, /* 1001 0 */ + { 6, 0x17, 192 }, /* 0101 11 */ + { 7, 0x37, 256 }, /* 0110 111 */ + { 8, 0x36, 320 }, /* 0011 0110 */ + { 8, 0x37, 384 }, /* 0011 0111 */ + { 8, 0x64, 448 }, /* 0110 0100 */ + { 8, 0x65, 512 }, /* 0110 0101 */ + { 8, 0x68, 576 }, /* 0110 1000 */ + { 8, 0x67, 640 }, /* 0110 0111 */ + { 9, 0xCC, 704 }, /* 0110 0110 0 */ + { 9, 0xCD, 768 }, /* 0110 0110 1 */ + { 9, 0xD2, 832 }, /* 0110 1001 0 */ + { 9, 0xD3, 896 }, /* 0110 1001 1 */ + { 9, 0xD4, 960 }, /* 0110 1010 0 */ + { 9, 0xD5, 1024 }, /* 0110 1010 1 */ + { 9, 0xD6, 1088 }, /* 0110 1011 0 */ + { 9, 0xD7, 1152 }, /* 0110 1011 1 */ + { 9, 0xD8, 1216 }, /* 0110 1100 0 */ + { 9, 0xD9, 1280 }, /* 0110 1100 1 */ + { 9, 0xDA, 1344 }, /* 0110 1101 0 */ + { 9, 0xDB, 1408 }, /* 0110 1101 1 */ + { 9, 0x98, 1472 }, /* 0100 1100 0 */ + { 9, 0x99, 1536 }, /* 0100 1100 1 */ + { 9, 0x9A, 1600 }, /* 0100 1101 0 */ + { 6, 0x18, 1664 }, /* 0110 00 */ + { 9, 0x9B, 1728 }, /* 0100 1101 1 */ + { 11, 0x8, 1792 }, /* 0000 0001 000 */ + { 11, 0xC, 1856 }, /* 0000 0001 100 */ + { 11, 0xD, 1920 }, /* 0000 0001 101 */ + { 12, 0x12, 1984 }, /* 0000 0001 0010 */ + { 12, 0x13, 2048 }, /* 0000 0001 0011 */ + { 12, 0x14, 2112 }, /* 0000 0001 0100 */ + { 12, 0x15, 2176 }, /* 0000 0001 0101 */ + { 12, 0x16, 2240 }, /* 0000 0001 0110 */ + { 12, 0x17, 2304 }, /* 0000 0001 0111 */ + { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ + { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ + { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ + { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ + { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ + { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ + { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ + { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ + { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ }; const tableentry TIFFFaxBlackCodes[] = { - {10, 0x37, 0}, /* 0000 1101 11 */ - {3, 0x2, 1}, /* 010 */ - {2, 0x3, 2}, /* 11 */ - {2, 0x2, 3}, /* 10 */ - {3, 0x3, 4}, /* 011 */ - {4, 0x3, 5}, /* 0011 */ - {4, 0x2, 6}, /* 0010 */ - {5, 0x3, 7}, /* 0001 1 */ - {6, 0x5, 8}, /* 0001 01 */ - {6, 0x4, 9}, /* 0001 00 */ - {7, 0x4, 10}, /* 0000 100 */ - {7, 0x5, 11}, /* 0000 101 */ - {7, 0x7, 12}, /* 0000 111 */ - {8, 0x4, 13}, /* 0000 0100 */ - {8, 0x7, 14}, /* 0000 0111 */ - {9, 0x18, 15}, /* 0000 1100 0 */ - {10, 0x17, 16}, /* 0000 0101 11 */ - {10, 0x18, 17}, /* 0000 0110 00 */ - {10, 0x8, 18}, /* 0000 0010 00 */ - {11, 0x67, 19}, /* 0000 1100 111 */ - {11, 0x68, 20}, /* 0000 1101 000 */ - {11, 0x6C, 21}, /* 0000 1101 100 */ - {11, 0x37, 22}, /* 0000 0110 111 */ - {11, 0x28, 23}, /* 0000 0101 000 */ - {11, 0x17, 24}, /* 0000 0010 111 */ - {11, 0x18, 25}, /* 0000 0011 000 */ - {12, 0xCA, 26}, /* 0000 1100 1010 */ - {12, 0xCB, 27}, /* 0000 1100 1011 */ - {12, 0xCC, 28}, /* 0000 1100 1100 */ - {12, 0xCD, 29}, /* 0000 1100 1101 */ - {12, 0x68, 30}, /* 0000 0110 1000 */ - {12, 0x69, 31}, /* 0000 0110 1001 */ - {12, 0x6A, 32}, /* 0000 0110 1010 */ - {12, 0x6B, 33}, /* 0000 0110 1011 */ - {12, 0xD2, 34}, /* 0000 1101 0010 */ - {12, 0xD3, 35}, /* 0000 1101 0011 */ - {12, 0xD4, 36}, /* 0000 1101 0100 */ - {12, 0xD5, 37}, /* 0000 1101 0101 */ - {12, 0xD6, 38}, /* 0000 1101 0110 */ - {12, 0xD7, 39}, /* 0000 1101 0111 */ - {12, 0x6C, 40}, /* 0000 0110 1100 */ - {12, 0x6D, 41}, /* 0000 0110 1101 */ - {12, 0xDA, 42}, /* 0000 1101 1010 */ - {12, 0xDB, 43}, /* 0000 1101 1011 */ - {12, 0x54, 44}, /* 0000 0101 0100 */ - {12, 0x55, 45}, /* 0000 0101 0101 */ - {12, 0x56, 46}, /* 0000 0101 0110 */ - {12, 0x57, 47}, /* 0000 0101 0111 */ - {12, 0x64, 48}, /* 0000 0110 0100 */ - {12, 0x65, 49}, /* 0000 0110 0101 */ - {12, 0x52, 50}, /* 0000 0101 0010 */ - {12, 0x53, 51}, /* 0000 0101 0011 */ - {12, 0x24, 52}, /* 0000 0010 0100 */ - {12, 0x37, 53}, /* 0000 0011 0111 */ - {12, 0x38, 54}, /* 0000 0011 1000 */ - {12, 0x27, 55}, /* 0000 0010 0111 */ - {12, 0x28, 56}, /* 0000 0010 1000 */ - {12, 0x58, 57}, /* 0000 0101 1000 */ - {12, 0x59, 58}, /* 0000 0101 1001 */ - {12, 0x2B, 59}, /* 0000 0010 1011 */ - {12, 0x2C, 60}, /* 0000 0010 1100 */ - {12, 0x5A, 61}, /* 0000 0101 1010 */ - {12, 0x66, 62}, /* 0000 0110 0110 */ - {12, 0x67, 63}, /* 0000 0110 0111 */ - {10, 0xF, 64}, /* 0000 0011 11 */ - {12, 0xC8, 128}, /* 0000 1100 1000 */ - {12, 0xC9, 192}, /* 0000 1100 1001 */ - {12, 0x5B, 256}, /* 0000 0101 1011 */ - {12, 0x33, 320}, /* 0000 0011 0011 */ - {12, 0x34, 384}, /* 0000 0011 0100 */ - {12, 0x35, 448}, /* 0000 0011 0101 */ - {13, 0x6C, 512}, /* 0000 0011 0110 0 */ - {13, 0x6D, 576}, /* 0000 0011 0110 1 */ - {13, 0x4A, 640}, /* 0000 0010 0101 0 */ - {13, 0x4B, 704}, /* 0000 0010 0101 1 */ - {13, 0x4C, 768}, /* 0000 0010 0110 0 */ - {13, 0x4D, 832}, /* 0000 0010 0110 1 */ - {13, 0x72, 896}, /* 0000 0011 1001 0 */ - {13, 0x73, 960}, /* 0000 0011 1001 1 */ - {13, 0x74, 1024}, /* 0000 0011 1010 0 */ - {13, 0x75, 1088}, /* 0000 0011 1010 1 */ - {13, 0x76, 1152}, /* 0000 0011 1011 0 */ - {13, 0x77, 1216}, /* 0000 0011 1011 1 */ - {13, 0x52, 1280}, /* 0000 0010 1001 0 */ - {13, 0x53, 1344}, /* 0000 0010 1001 1 */ - {13, 0x54, 1408}, /* 0000 0010 1010 0 */ - {13, 0x55, 1472}, /* 0000 0010 1010 1 */ - {13, 0x5A, 1536}, /* 0000 0010 1101 0 */ - {13, 0x5B, 1600}, /* 0000 0010 1101 1 */ - {13, 0x64, 1664}, /* 0000 0011 0010 0 */ - {13, 0x65, 1728}, /* 0000 0011 0010 1 */ - {11, 0x8, 1792}, /* 0000 0001 000 */ - {11, 0xC, 1856}, /* 0000 0001 100 */ - {11, 0xD, 1920}, /* 0000 0001 101 */ - {12, 0x12, 1984}, /* 0000 0001 0010 */ - {12, 0x13, 2048}, /* 0000 0001 0011 */ - {12, 0x14, 2112}, /* 0000 0001 0100 */ - {12, 0x15, 2176}, /* 0000 0001 0101 */ - {12, 0x16, 2240}, /* 0000 0001 0110 */ - {12, 0x17, 2304}, /* 0000 0001 0111 */ - {12, 0x1C, 2368}, /* 0000 0001 1100 */ - {12, 0x1D, 2432}, /* 0000 0001 1101 */ - {12, 0x1E, 2496}, /* 0000 0001 1110 */ - {12, 0x1F, 2560}, /* 0000 0001 1111 */ - {12, 0x1, G3CODE_EOL}, /* 0000 0000 0001 */ - {9, 0x1, G3CODE_INVALID}, /* 0000 0000 1 */ - {10, 0x1, G3CODE_INVALID}, /* 0000 0000 01 */ - {11, 0x1, G3CODE_INVALID}, /* 0000 0000 001 */ - {12, 0x0, G3CODE_INVALID}, /* 0000 0000 0000 */ + { 10, 0x37, 0 }, /* 0000 1101 11 */ + { 3, 0x2, 1 }, /* 010 */ + { 2, 0x3, 2 }, /* 11 */ + { 2, 0x2, 3 }, /* 10 */ + { 3, 0x3, 4 }, /* 011 */ + { 4, 0x3, 5 }, /* 0011 */ + { 4, 0x2, 6 }, /* 0010 */ + { 5, 0x3, 7 }, /* 0001 1 */ + { 6, 0x5, 8 }, /* 0001 01 */ + { 6, 0x4, 9 }, /* 0001 00 */ + { 7, 0x4, 10 }, /* 0000 100 */ + { 7, 0x5, 11 }, /* 0000 101 */ + { 7, 0x7, 12 }, /* 0000 111 */ + { 8, 0x4, 13 }, /* 0000 0100 */ + { 8, 0x7, 14 }, /* 0000 0111 */ + { 9, 0x18, 15 }, /* 0000 1100 0 */ + { 10, 0x17, 16 }, /* 0000 0101 11 */ + { 10, 0x18, 17 }, /* 0000 0110 00 */ + { 10, 0x8, 18 }, /* 0000 0010 00 */ + { 11, 0x67, 19 }, /* 0000 1100 111 */ + { 11, 0x68, 20 }, /* 0000 1101 000 */ + { 11, 0x6C, 21 }, /* 0000 1101 100 */ + { 11, 0x37, 22 }, /* 0000 0110 111 */ + { 11, 0x28, 23 }, /* 0000 0101 000 */ + { 11, 0x17, 24 }, /* 0000 0010 111 */ + { 11, 0x18, 25 }, /* 0000 0011 000 */ + { 12, 0xCA, 26 }, /* 0000 1100 1010 */ + { 12, 0xCB, 27 }, /* 0000 1100 1011 */ + { 12, 0xCC, 28 }, /* 0000 1100 1100 */ + { 12, 0xCD, 29 }, /* 0000 1100 1101 */ + { 12, 0x68, 30 }, /* 0000 0110 1000 */ + { 12, 0x69, 31 }, /* 0000 0110 1001 */ + { 12, 0x6A, 32 }, /* 0000 0110 1010 */ + { 12, 0x6B, 33 }, /* 0000 0110 1011 */ + { 12, 0xD2, 34 }, /* 0000 1101 0010 */ + { 12, 0xD3, 35 }, /* 0000 1101 0011 */ + { 12, 0xD4, 36 }, /* 0000 1101 0100 */ + { 12, 0xD5, 37 }, /* 0000 1101 0101 */ + { 12, 0xD6, 38 }, /* 0000 1101 0110 */ + { 12, 0xD7, 39 }, /* 0000 1101 0111 */ + { 12, 0x6C, 40 }, /* 0000 0110 1100 */ + { 12, 0x6D, 41 }, /* 0000 0110 1101 */ + { 12, 0xDA, 42 }, /* 0000 1101 1010 */ + { 12, 0xDB, 43 }, /* 0000 1101 1011 */ + { 12, 0x54, 44 }, /* 0000 0101 0100 */ + { 12, 0x55, 45 }, /* 0000 0101 0101 */ + { 12, 0x56, 46 }, /* 0000 0101 0110 */ + { 12, 0x57, 47 }, /* 0000 0101 0111 */ + { 12, 0x64, 48 }, /* 0000 0110 0100 */ + { 12, 0x65, 49 }, /* 0000 0110 0101 */ + { 12, 0x52, 50 }, /* 0000 0101 0010 */ + { 12, 0x53, 51 }, /* 0000 0101 0011 */ + { 12, 0x24, 52 }, /* 0000 0010 0100 */ + { 12, 0x37, 53 }, /* 0000 0011 0111 */ + { 12, 0x38, 54 }, /* 0000 0011 1000 */ + { 12, 0x27, 55 }, /* 0000 0010 0111 */ + { 12, 0x28, 56 }, /* 0000 0010 1000 */ + { 12, 0x58, 57 }, /* 0000 0101 1000 */ + { 12, 0x59, 58 }, /* 0000 0101 1001 */ + { 12, 0x2B, 59 }, /* 0000 0010 1011 */ + { 12, 0x2C, 60 }, /* 0000 0010 1100 */ + { 12, 0x5A, 61 }, /* 0000 0101 1010 */ + { 12, 0x66, 62 }, /* 0000 0110 0110 */ + { 12, 0x67, 63 }, /* 0000 0110 0111 */ + { 10, 0xF, 64 }, /* 0000 0011 11 */ + { 12, 0xC8, 128 }, /* 0000 1100 1000 */ + { 12, 0xC9, 192 }, /* 0000 1100 1001 */ + { 12, 0x5B, 256 }, /* 0000 0101 1011 */ + { 12, 0x33, 320 }, /* 0000 0011 0011 */ + { 12, 0x34, 384 }, /* 0000 0011 0100 */ + { 12, 0x35, 448 }, /* 0000 0011 0101 */ + { 13, 0x6C, 512 }, /* 0000 0011 0110 0 */ + { 13, 0x6D, 576 }, /* 0000 0011 0110 1 */ + { 13, 0x4A, 640 }, /* 0000 0010 0101 0 */ + { 13, 0x4B, 704 }, /* 0000 0010 0101 1 */ + { 13, 0x4C, 768 }, /* 0000 0010 0110 0 */ + { 13, 0x4D, 832 }, /* 0000 0010 0110 1 */ + { 13, 0x72, 896 }, /* 0000 0011 1001 0 */ + { 13, 0x73, 960 }, /* 0000 0011 1001 1 */ + { 13, 0x74, 1024 }, /* 0000 0011 1010 0 */ + { 13, 0x75, 1088 }, /* 0000 0011 1010 1 */ + { 13, 0x76, 1152 }, /* 0000 0011 1011 0 */ + { 13, 0x77, 1216 }, /* 0000 0011 1011 1 */ + { 13, 0x52, 1280 }, /* 0000 0010 1001 0 */ + { 13, 0x53, 1344 }, /* 0000 0010 1001 1 */ + { 13, 0x54, 1408 }, /* 0000 0010 1010 0 */ + { 13, 0x55, 1472 }, /* 0000 0010 1010 1 */ + { 13, 0x5A, 1536 }, /* 0000 0010 1101 0 */ + { 13, 0x5B, 1600 }, /* 0000 0010 1101 1 */ + { 13, 0x64, 1664 }, /* 0000 0011 0010 0 */ + { 13, 0x65, 1728 }, /* 0000 0011 0010 1 */ + { 11, 0x8, 1792 }, /* 0000 0001 000 */ + { 11, 0xC, 1856 }, /* 0000 0001 100 */ + { 11, 0xD, 1920 }, /* 0000 0001 101 */ + { 12, 0x12, 1984 }, /* 0000 0001 0010 */ + { 12, 0x13, 2048 }, /* 0000 0001 0011 */ + { 12, 0x14, 2112 }, /* 0000 0001 0100 */ + { 12, 0x15, 2176 }, /* 0000 0001 0101 */ + { 12, 0x16, 2240 }, /* 0000 0001 0110 */ + { 12, 0x17, 2304 }, /* 0000 0001 0111 */ + { 12, 0x1C, 2368 }, /* 0000 0001 1100 */ + { 12, 0x1D, 2432 }, /* 0000 0001 1101 */ + { 12, 0x1E, 2496 }, /* 0000 0001 1110 */ + { 12, 0x1F, 2560 }, /* 0000 0001 1111 */ + { 12, 0x1, G3CODE_EOL }, /* 0000 0000 0001 */ + { 9, 0x1, G3CODE_INVALID }, /* 0000 0000 1 */ + { 10, 0x1, G3CODE_INVALID }, /* 0000 0000 01 */ + { 11, 0x1, G3CODE_INVALID }, /* 0000 0000 001 */ + { 12, 0x0, G3CODE_INVALID }, /* 0000 0000 0000 */ }; #else extern const tableentry TIFFFaxWhiteCodes[]; extern const tableentry TIFFFaxBlackCodes[]; #endif #endif /* _T4_ */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_aux.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_aux.c index 49855bb0b..c9f190545 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_aux.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_aux.c @@ -2,23 +2,23 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -27,180 +27,173 @@ * * Auxiliary Support Routines. */ -#include "tif_predict.h" #include "tiffiop.h" -#include +#include "tif_predict.h" #include +#include -uint32_t _TIFFMultiply32(TIFF *tif, uint32_t first, uint32_t second, - const char *where) +uint32 +_TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where) { - if (second && first > UINT32_MAX / second) - { - TIFFErrorExtR(tif, where, "Integer overflow in %s", where); - return 0; - } + if (second && first > TIFF_UINT32_MAX / second) { + TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); + return 0; + } - return first * second; + return first * second; } -uint64_t _TIFFMultiply64(TIFF *tif, uint64_t first, uint64_t second, - const char *where) +uint64 +_TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where) { - if (second && first > UINT64_MAX / second) - { - TIFFErrorExtR(tif, where, "Integer overflow in %s", where); - return 0; - } + if (second && first > TIFF_UINT64_MAX / second) { + TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); + return 0; + } - return first * second; + return first * second; } -tmsize_t _TIFFMultiplySSize(TIFF *tif, tmsize_t first, tmsize_t second, - const char *where) +tmsize_t +_TIFFMultiplySSize(TIFF* tif, tmsize_t first, tmsize_t second, const char* where) { - if (first <= 0 || second <= 0) + if( first <= 0 || second <= 0 ) { - if (tif != NULL && where != NULL) + if( tif != NULL && where != NULL ) { - TIFFErrorExtR(tif, where, - "Invalid argument to _TIFFMultiplySSize() in %s", - where); + TIFFErrorExt(tif->tif_clientdata, where, + "Invalid argument to _TIFFMultiplySSize() in %s", where); } return 0; } - if (first > TIFF_TMSIZE_T_MAX / second) + if( first > TIFF_TMSIZE_T_MAX / second ) { - if (tif != NULL && where != NULL) + if( tif != NULL && where != NULL ) { - TIFFErrorExtR(tif, where, "Integer overflow in %s", where); + TIFFErrorExt(tif->tif_clientdata, where, + "Integer overflow in %s", where); } return 0; } return first * second; } -tmsize_t _TIFFCastUInt64ToSSize(TIFF *tif, uint64_t val, const char *module) +tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64 val, const char* module) { - if (val > (uint64_t)TIFF_TMSIZE_T_MAX) + if( val > (uint64)TIFF_TMSIZE_T_MAX ) { - if (tif != NULL && module != NULL) + if( tif != NULL && module != NULL ) { - TIFFErrorExtR(tif, module, "Integer overflow"); + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); } return 0; } return (tmsize_t)val; } -void *_TIFFCheckRealloc(TIFF *tif, void *buffer, tmsize_t nmemb, - tmsize_t elem_size, const char *what) +void* +_TIFFCheckRealloc(TIFF* tif, void* buffer, + tmsize_t nmemb, tmsize_t elem_size, const char* what) { - void *cp = NULL; - tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL); - /* - * Check for integer overflow. - */ - if (count != 0) - { - cp = _TIFFreallocExt(tif, buffer, count); - } + void* cp = NULL; + tmsize_t count = _TIFFMultiplySSize(tif, nmemb, elem_size, NULL); + /* + * Check for integer overflow. + */ + if (count != 0) + { + cp = _TIFFrealloc(buffer, count); + } - if (cp == NULL) - { - TIFFErrorExtR(tif, tif->tif_name, - "Failed to allocate memory for %s " - "(%" TIFF_SSIZE_FORMAT " elements of %" TIFF_SSIZE_FORMAT - " bytes each)", - what, nmemb, elem_size); - } + if (cp == NULL) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Failed to allocate memory for %s " + "(%ld elements of %ld bytes each)", + what,(long) nmemb, (long) elem_size); + } - return cp; + return cp; } -void *_TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, - const char *what) +void* +_TIFFCheckMalloc(TIFF* tif, tmsize_t nmemb, tmsize_t elem_size, const char* what) { - return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what); + return _TIFFCheckRealloc(tif, NULL, nmemb, elem_size, what); } -static int TIFFDefaultTransferFunction(TIFF *tif, TIFFDirectory *td) +static int +TIFFDefaultTransferFunction(TIFFDirectory* td) { - uint16_t **tf = td->td_transferfunction; - tmsize_t i, n, nbytes; + uint16 **tf = td->td_transferfunction; + tmsize_t i, n, nbytes; - tf[0] = tf[1] = tf[2] = 0; - if (td->td_bitspersample >= sizeof(tmsize_t) * 8 - 2) - return 0; + tf[0] = tf[1] = tf[2] = 0; + if (td->td_bitspersample >= sizeof(tmsize_t) * 8 - 2) + return 0; - n = ((tmsize_t)1) << td->td_bitspersample; - nbytes = n * sizeof(uint16_t); - tf[0] = (uint16_t *)_TIFFmallocExt(tif, 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_t)floor(65535. * pow(t, 2.2) + .5); - } + n = ((tmsize_t)1)<td_bitspersample; + nbytes = n * sizeof (uint16); + tf[0] = (uint16 *)_TIFFmalloc(nbytes); + if (tf[0] == NULL) + return 0; + tf[0][0] = 0; + for (i = 1; i < n; i++) { + double t = (double)i/((double) n-1.); + tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5); + } - if (td->td_samplesperpixel - td->td_extrasamples > 1) - { - tf[1] = (uint16_t *)_TIFFmallocExt(tif, nbytes); - if (tf[1] == NULL) - goto bad; - _TIFFmemcpy(tf[1], tf[0], nbytes); - tf[2] = (uint16_t *)_TIFFmallocExt(tif, nbytes); - if (tf[2] == NULL) - goto bad; - _TIFFmemcpy(tf[2], tf[0], nbytes); - } - return 1; + if (td->td_samplesperpixel - td->td_extrasamples > 1) { + tf[1] = (uint16 *)_TIFFmalloc(nbytes); + if(tf[1] == NULL) + goto bad; + _TIFFmemcpy(tf[1], tf[0], nbytes); + tf[2] = (uint16 *)_TIFFmalloc(nbytes); + if (tf[2] == NULL) + goto bad; + _TIFFmemcpy(tf[2], tf[0], nbytes); + } + return 1; bad: - if (tf[0]) - _TIFFfreeExt(tif, tf[0]); - if (tf[1]) - _TIFFfreeExt(tif, tf[1]); - if (tf[2]) - _TIFFfreeExt(tif, tf[2]); - tf[0] = tf[1] = tf[2] = 0; - return 0; + if (tf[0]) + _TIFFfree(tf[0]); + if (tf[1]) + _TIFFfree(tf[1]); + if (tf[2]) + _TIFFfree(tf[2]); + tf[0] = tf[1] = tf[2] = 0; + return 0; } -static int TIFFDefaultRefBlackWhite(TIFF *tif, TIFFDirectory *td) +static int +TIFFDefaultRefBlackWhite(TIFFDirectory* td) { - int i; + int i; - td->td_refblackwhite = (float *)_TIFFmallocExt(tif, 6 * sizeof(float)); - if (td->td_refblackwhite == NULL) - return 0; - if (td->td_photometric == PHOTOMETRIC_YCBCR) - { - /* - * YCbCr (Class Y) images must have the ReferenceBlackWhite - * tag set. Fix the broken images, which lacks that tag. - */ - td->td_refblackwhite[0] = 0.0F; - td->td_refblackwhite[1] = td->td_refblackwhite[3] = - td->td_refblackwhite[5] = 255.0F; - td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F; - } - else - { - /* - * Assume RGB (Class R) - */ - for (i = 0; i < 3; i++) - { - td->td_refblackwhite[2 * i + 0] = 0; - td->td_refblackwhite[2 * i + 1] = - (float)((1L << td->td_bitspersample) - 1L); - } - } - return 1; + td->td_refblackwhite = (float *)_TIFFmalloc(6*sizeof (float)); + if (td->td_refblackwhite == NULL) + return 0; + if (td->td_photometric == PHOTOMETRIC_YCBCR) { + /* + * YCbCr (Class Y) images must have the ReferenceBlackWhite + * tag set. Fix the broken images, which lacks that tag. + */ + td->td_refblackwhite[0] = 0.0F; + td->td_refblackwhite[1] = td->td_refblackwhite[3] = + td->td_refblackwhite[5] = 255.0F; + td->td_refblackwhite[2] = td->td_refblackwhite[4] = 128.0F; + } else { + /* + * Assume RGB (Class R) + */ + for (i = 0; i < 3; i++) { + td->td_refblackwhite[2*i+0] = 0; + td->td_refblackwhite[2*i+1] = + (float)((1L<td_bitspersample)-1L); + } + } + return 1; } /* @@ -211,248 +204,216 @@ static int TIFFDefaultRefBlackWhite(TIFF *tif, TIFFDirectory *td) * explicit values so that defaults exist only one * place in the library -- in TIFFDefaultDirectory. */ -int TIFFVGetFieldDefaulted(TIFF *tif, uint32_t tag, va_list ap) +int +TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) { - TIFFDirectory *td = &tif->tif_dir; + TIFFDirectory *td = &tif->tif_dir; - if (TIFFVGetField(tif, tag, ap)) - return (1); - switch (tag) + if (TIFFVGetField(tif, tag, ap)) + return (1); + switch (tag) { + case TIFFTAG_SUBFILETYPE: + *va_arg(ap, uint32 *) = td->td_subfiletype; + return (1); + case TIFFTAG_BITSPERSAMPLE: + *va_arg(ap, uint16 *) = td->td_bitspersample; + return (1); + case TIFFTAG_THRESHHOLDING: + *va_arg(ap, uint16 *) = td->td_threshholding; + return (1); + case TIFFTAG_FILLORDER: + *va_arg(ap, uint16 *) = td->td_fillorder; + return (1); + case TIFFTAG_ORIENTATION: + *va_arg(ap, uint16 *) = td->td_orientation; + return (1); + case TIFFTAG_SAMPLESPERPIXEL: + *va_arg(ap, uint16 *) = td->td_samplesperpixel; + return (1); + case TIFFTAG_ROWSPERSTRIP: + *va_arg(ap, uint32 *) = td->td_rowsperstrip; + return (1); + case TIFFTAG_MINSAMPLEVALUE: + *va_arg(ap, uint16 *) = td->td_minsamplevalue; + return (1); + case TIFFTAG_MAXSAMPLEVALUE: + *va_arg(ap, uint16 *) = td->td_maxsamplevalue; + return (1); + case TIFFTAG_PLANARCONFIG: + *va_arg(ap, uint16 *) = td->td_planarconfig; + return (1); + case TIFFTAG_RESOLUTIONUNIT: + *va_arg(ap, uint16 *) = td->td_resolutionunit; + return (1); + case TIFFTAG_PREDICTOR: { - case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32_t *) = td->td_subfiletype; - return (1); - case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16_t *) = td->td_bitspersample; - return (1); - case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16_t *) = td->td_threshholding; - return (1); - case TIFFTAG_FILLORDER: - *va_arg(ap, uint16_t *) = td->td_fillorder; - return (1); - case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16_t *) = td->td_orientation; - return (1); - case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16_t *) = td->td_samplesperpixel; - return (1); - case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32_t *) = td->td_rowsperstrip; - return (1); - case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16_t *) = td->td_minsamplevalue; - return (1); - case TIFFTAG_MAXSAMPLEVALUE: + TIFFPredictorState* sp = (TIFFPredictorState*) tif->tif_data; + if( sp == NULL ) { - uint16_t maxsamplevalue; - /* td_bitspersample=1 is always set in TIFFDefaultDirectory(). - * Therefore, td_maxsamplevalue has to be re-calculated in - * TIFFGetFieldDefaulted(). */ - if (td->td_bitspersample > 0) - { - /* This shift operation into a uint16_t limits the value to - * 65535 even if td_bitspersamle is > 16 */ - if (td->td_bitspersample <= 16) - { - maxsamplevalue = (1 << td->td_bitspersample) - - 1; /* 2**(BitsPerSample) - 1 */ - } - else - { - maxsamplevalue = 65535; - } - } - else - { - maxsamplevalue = 0; - } - *va_arg(ap, uint16_t *) = maxsamplevalue; - return (1); + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Cannot get \"Predictor\" tag as plugin is not configured"); + *va_arg(ap, uint16*) = 0; + return 0; } - case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16_t *) = td->td_planarconfig; - return (1); - case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16_t *) = td->td_resolutionunit; - return (1); - case TIFFTAG_PREDICTOR: - { - TIFFPredictorState *sp = (TIFFPredictorState *)tif->tif_data; - if (sp == NULL) - { - TIFFErrorExtR( - tif, tif->tif_name, - "Cannot get \"Predictor\" tag as plugin is not configured"); - *va_arg(ap, uint16_t *) = 0; - return 0; - } - *va_arg(ap, uint16_t *) = (uint16_t)sp->predictor; - return 1; - } - case TIFFTAG_DOTRANGE: - *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_t *) = INKSET_CMYK; - return 1; - case TIFFTAG_NUMBEROFINKS: - *va_arg(ap, uint16_t *) = 4; - return (1); - case TIFFTAG_EXTRASAMPLES: - *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_t *) = - (td->td_extrasamples == 1 && - td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); - return (1); - case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32_t *) = td->td_tiledepth; - return (1); - case TIFFTAG_DATATYPE: - *va_arg(ap, uint16_t *) = td->td_sampleformat - 1; - return (1); - case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16_t *) = td->td_sampleformat; - return (1); - case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32_t *) = td->td_imagedepth; - return (1); - case TIFFTAG_YCBCRCOEFFICIENTS: - { - /* defaults are from CCIR Recommendation 601-1 */ - static const float ycbcrcoeffs[] = {0.299f, 0.587f, 0.114f}; - *va_arg(ap, const float **) = ycbcrcoeffs; - return 1; - } - case TIFFTAG_YCBCRSUBSAMPLING: - *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_t *) = td->td_ycbcrpositioning; - return (1); - case TIFFTAG_WHITEPOINT: - { - /* TIFF 6.0 specification tells that it is no default - value for the WhitePoint, but AdobePhotoshop TIFF - Technical Note tells that it should be CIE D50. */ - static const float whitepoint[] = { - D50_X0 / (D50_X0 + D50_Y0 + D50_Z0), - D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0)}; - *va_arg(ap, const float **) = whitepoint; - return 1; - } - case TIFFTAG_TRANSFERFUNCTION: - if (!td->td_transferfunction[0] && - !TIFFDefaultTransferFunction(tif, td)) - { - TIFFErrorExtR(tif, tif->tif_name, - "No space for \"TransferFunction\" tag"); - return (0); - } - *va_arg(ap, const uint16_t **) = td->td_transferfunction[0]; - if (td->td_samplesperpixel - td->td_extrasamples > 1) - { - *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: - if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(tif, td)) - return (0); - *va_arg(ap, const float **) = td->td_refblackwhite; - return (1); + *va_arg(ap, uint16*) = (uint16) sp->predictor; + return 1; } - return 0; + case TIFFTAG_DOTRANGE: + *va_arg(ap, uint16 *) = 0; + *va_arg(ap, uint16 *) = (1<td_bitspersample)-1; + return (1); + case TIFFTAG_INKSET: + *va_arg(ap, uint16 *) = INKSET_CMYK; + return 1; + case TIFFTAG_NUMBEROFINKS: + *va_arg(ap, uint16 *) = 4; + return (1); + case TIFFTAG_EXTRASAMPLES: + *va_arg(ap, uint16 *) = td->td_extrasamples; + *va_arg(ap, const uint16 **) = td->td_sampleinfo; + return (1); + case TIFFTAG_MATTEING: + *va_arg(ap, uint16 *) = + (td->td_extrasamples == 1 && + td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); + return (1); + case TIFFTAG_TILEDEPTH: + *va_arg(ap, uint32 *) = td->td_tiledepth; + return (1); + case TIFFTAG_DATATYPE: + *va_arg(ap, uint16 *) = td->td_sampleformat-1; + return (1); + case TIFFTAG_SAMPLEFORMAT: + *va_arg(ap, uint16 *) = td->td_sampleformat; + return(1); + case TIFFTAG_IMAGEDEPTH: + *va_arg(ap, uint32 *) = td->td_imagedepth; + return (1); + case TIFFTAG_YCBCRCOEFFICIENTS: + { + /* defaults are from CCIR Recommendation 601-1 */ + static const float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f }; + *va_arg(ap, const float **) = ycbcrcoeffs; + return 1; + } + case TIFFTAG_YCBCRSUBSAMPLING: + *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1]; + return (1); + case TIFFTAG_YCBCRPOSITIONING: + *va_arg(ap, uint16 *) = td->td_ycbcrpositioning; + return (1); + case TIFFTAG_WHITEPOINT: + { + /* TIFF 6.0 specification tells that it is no default + value for the WhitePoint, but AdobePhotoshop TIFF + Technical Note tells that it should be CIE D50. */ + static const float whitepoint[] = { + D50_X0 / (D50_X0 + D50_Y0 + D50_Z0), + D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0) + }; + *va_arg(ap, const float **) = whitepoint; + return 1; + } + case TIFFTAG_TRANSFERFUNCTION: + if (!td->td_transferfunction[0] && + !TIFFDefaultTransferFunction(td)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag"); + return (0); + } + *va_arg(ap, const uint16 **) = 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]; + } + return (1); + case TIFFTAG_REFERENCEBLACKWHITE: + if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td)) + return (0); + *va_arg(ap, const float **) = td->td_refblackwhite; + return (1); + } + return 0; } /* * Like TIFFGetField, but return any default * value if the tag is not present in the directory. */ -int TIFFGetFieldDefaulted(TIFF *tif, uint32_t tag, ...) +int +TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...) { - int ok; - va_list ap; + int ok; + va_list ap; - va_start(ap, tag); - ok = TIFFVGetFieldDefaulted(tif, tag, ap); - va_end(ap); - return (ok); + va_start(ap, tag); + ok = TIFFVGetFieldDefaulted(tif, tag, ap); + va_end(ap); + return (ok); } -struct _Int64Parts -{ - int32_t low, high; +struct _Int64Parts { + int32 low, high; }; -typedef union -{ - struct _Int64Parts part; - int64_t value; +typedef union { + struct _Int64Parts part; + int64 value; } _Int64; -float _TIFFUInt64ToFloat(uint64_t ui64) +float +_TIFFUInt64ToFloat(uint64 ui64) { - _Int64 i; + _Int64 i; - i.value = ui64; - if (i.part.high >= 0) - { - return (float)i.value; - } - else - { - long double df; - df = (long double)i.value; - df += 18446744073709551616.0; /* adding 2**64 */ - return (float)df; - } + i.value = ui64; + if (i.part.high >= 0) { + return (float)i.value; + } else { + long double df; + df = (long double)i.value; + df += 18446744073709551616.0; /* adding 2**64 */ + return (float)df; + } } -double _TIFFUInt64ToDouble(uint64_t ui64) +double +_TIFFUInt64ToDouble(uint64 ui64) { - _Int64 i; + _Int64 i; - i.value = ui64; - if (i.part.high >= 0) - { - return (double)i.value; - } - else - { - long double df; - df = (long double)i.value; - df += 18446744073709551616.0; /* adding 2**64 */ - return (double)df; - } + i.value = ui64; + if (i.part.high >= 0) { + return (double)i.value; + } else { + long double df; + df = (long double)i.value; + df += 18446744073709551616.0; /* adding 2**64 */ + return (double)df; + } } -float _TIFFClampDoubleToFloat(double val) +float _TIFFClampDoubleToFloat( double val ) { - if (val > FLT_MAX) + if( val > FLT_MAX ) return FLT_MAX; - if (val < -FLT_MAX) + if( val < -FLT_MAX ) return -FLT_MAX; return (float)val; } -uint32_t _TIFFClampDoubleToUInt32(double val) -{ - if (val < 0) - return 0; - if (val > 0xFFFFFFFFU || val != val) - return 0xFFFFFFFFU; - return (uint32_t)val; -} - -int _TIFFSeekOK(TIFF *tif, toff_t off) +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_t)0) / 2 && TIFFSeekFile(tif, off, SEEK_SET) == off; + return off <= (~(uint64)0)/2 && TIFFSeekFile(tif,off,SEEK_SET)==off; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_close.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_close.c index 907d7f139..7e23aac6e 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_close.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_close.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -37,98 +37,75 @@ * completely freed, so you should save opened file handle and pointer * to the close procedure in external variables before calling * _TIFFCleanup(), if you will need these ones to close the file. - * + * * @param tif A TIFF pointer. */ -void TIFFCleanup(TIFF *tif) +void +TIFFCleanup(TIFF* tif) { - /* - * Flush buffered data and directory (if dirty). - */ - if (tif->tif_mode != O_RDONLY) - TIFFFlush(tif); - (*tif->tif_cleanup)(tif); - TIFFFreeDirectory(tif); + /* + * Flush buffered data and directory (if dirty). + */ + if (tif->tif_mode != O_RDONLY) + TIFFFlush(tif); + (*tif->tif_cleanup)(tif); + TIFFFreeDirectory(tif); - _TIFFCleanupIFDOffsetAndNumberMaps(tif); + if (tif->tif_dirlist) + _TIFFfree(tif->tif_dirlist); - /* - * Clean up client info links. - */ - while (tif->tif_clientinfo) - { - TIFFClientInfoLink *psLink = tif->tif_clientinfo; + /* + * Clean up client info links. + */ + while( tif->tif_clientinfo ) + { + TIFFClientInfoLink *psLink = tif->tif_clientinfo; - tif->tif_clientinfo = psLink->next; - _TIFFfreeExt(tif, psLink->name); - _TIFFfreeExt(tif, psLink); - } + tif->tif_clientinfo = psLink->next; + _TIFFfree( psLink->name ); + _TIFFfree( psLink ); + } - if (tif->tif_rawdata && (tif->tif_flags & TIFF_MYBUFFER)) - _TIFFfreeExt(tif, tif->tif_rawdata); - if (isMapped(tif)) - TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size); + if (tif->tif_rawdata && (tif->tif_flags&TIFF_MYBUFFER)) + _TIFFfree(tif->tif_rawdata); + if (isMapped(tif)) + TIFFUnmapFileContents(tif, tif->tif_base, (toff_t)tif->tif_size); - /* - * Clean up custom fields. - */ - if (tif->tif_fields && tif->tif_nfields > 0) - { - uint32_t i; + /* + * Clean up custom fields. + */ + if (tif->tif_fields && tif->tif_nfields > 0) { + uint32 i; - for (i = 0; i < tif->tif_nfields; i++) - { - TIFFField *fld = tif->tif_fields[i]; - if (fld->field_name != NULL) - { - if (fld->field_bit == FIELD_CUSTOM && - /* caution: tif_fields[i] must not be the beginning of a - * fields-array. Otherwise the following tags are also freed - * with the first free(). - */ - TIFFFieldIsAnonymous(fld)) - { - _TIFFfreeExt(tif, fld->field_name); - _TIFFfreeExt(tif, fld); + for (i = 0; i < tif->tif_nfields; i++) { + TIFFField *fld = tif->tif_fields[i]; + if (fld->field_name != NULL) { + if (fld->field_bit == FIELD_CUSTOM && + /* catuion: tif_fields[i] must not be the beginning of a fields-array. + * Otherwise the following tags are also freed with the first free(). + */ + TIFFFieldIsAnonymous(fld)) { + _TIFFfree(fld->field_name); + _TIFFfree(fld); + } + } + } + + _TIFFfree(tif->tif_fields); + } + + if (tif->tif_nfieldscompat > 0) { + uint32 i; + + for (i = 0; i < tif->tif_nfieldscompat; i++) { + if (tif->tif_fieldscompat[i].allocated_size) + _TIFFfree(tif->tif_fieldscompat[i].fields); } - } + _TIFFfree(tif->tif_fieldscompat); } - _TIFFfreeExt(tif, tif->tif_fields); - } - - if (tif->tif_nfieldscompat > 0) - { - uint32_t i; - - for (i = 0; i < tif->tif_nfieldscompat; i++) - { - if (tif->tif_fieldscompat[i].allocated_size) - _TIFFfreeExt(tif, tif->tif_fieldscompat[i].fields); - } - _TIFFfreeExt(tif, tif->tif_fieldscompat); - } - - _TIFFfreeExt(NULL, tif); -} - -/************************************************************************/ -/* _TIFFCleanupIFDOffsetAndNumberMaps() */ -/************************************************************************/ - -void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif) -{ - if (tif->tif_map_dir_offset_to_number) - { - TIFFHashSetDestroy(tif->tif_map_dir_offset_to_number); - tif->tif_map_dir_offset_to_number = NULL; - } - if (tif->tif_map_dir_number_to_offset) - { - TIFFHashSetDestroy(tif->tif_map_dir_number_to_offset); - tif->tif_map_dir_number_to_offset = NULL; - } + _TIFFfree(tif); } /************************************************************************/ @@ -141,18 +118,28 @@ void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif) * TIFFClose closes a file that was previously opened with TIFFOpen(). * Any buffered data are flushed to the file, including the contents of * the current directory (if modified); and all resources are reclaimed. - * + * * @param tif A TIFF pointer. */ -void TIFFClose(TIFF *tif) +void +TIFFClose(TIFF* tif) { - if (tif != NULL) - { - TIFFCloseProc closeproc = tif->tif_closeproc; - thandle_t fd = tif->tif_clientdata; + if (tif != NULL) { + TIFFCloseProc closeproc = tif->tif_closeproc; + thandle_t fd = tif->tif_clientdata; - TIFFCleanup(tif); - (void)(*closeproc)(fd); - } + TIFFCleanup(tif); + (void)(*closeproc)(fd); + } } + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_codec.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_codec.c index d499b63a5..b6c04f01d 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_codec.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_codec.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -29,7 +29,7 @@ */ #include "tiffiop.h" -static int NotConfigured(TIFF *, int); +static int NotConfigured(TIFF*, int); #ifndef LZW_SUPPORT #define TIFFInitLZW NotConfigured @@ -67,9 +67,6 @@ 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 @@ -83,53 +80,58 @@ static int NotConfigured(TIFF *, int); /* * Compression schemes statically built into the library. */ +#ifdef VMS const TIFFCodec _TIFFBuiltinCODECS[] = { - {"None", COMPRESSION_NONE, TIFFInitDumpMode}, - {"LZW", COMPRESSION_LZW, TIFFInitLZW}, - {"PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits}, - {"ThunderScan", COMPRESSION_THUNDERSCAN, TIFFInitThunderScan}, - {"NeXT", COMPRESSION_NEXT, TIFFInitNeXT}, - {"JPEG", COMPRESSION_JPEG, TIFFInitJPEG}, - {"Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG}, - {"CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE}, - {"CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW}, - {"CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3}, - {"CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4}, - {"ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG}, - {"Deflate", COMPRESSION_DEFLATE, TIFFInitZIP}, - {"AdobeDeflate", COMPRESSION_ADOBE_DEFLATE, TIFFInitZIP}, - {"PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog}, - {"SGILog", COMPRESSION_SGILOG, TIFFInitSGILog}, - {"SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog}, - {"LZMA", COMPRESSION_LZMA, TIFFInitLZMA}, - {"ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD}, - {"WEBP", COMPRESSION_WEBP, TIFFInitWebP}, - {"LERC", COMPRESSION_LERC, TIFFInitLERC}, - {NULL, 0, NULL}}; +#else +TIFFCodec _TIFFBuiltinCODECS[] = { +#endif + { "None", COMPRESSION_NONE, TIFFInitDumpMode }, + { "LZW", COMPRESSION_LZW, TIFFInitLZW }, + { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, + { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan }, + { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT }, + { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG }, + { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG }, + { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE }, + { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, + { "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, + { "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, + { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG }, + { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP }, + { "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP }, + { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog }, + { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog }, + { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog }, + { "LZMA", COMPRESSION_LZMA, TIFFInitLZMA }, + { "ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD }, + { "WEBP", COMPRESSION_WEBP, TIFFInitWebP }, + { NULL, 0, NULL } +}; -static int _notConfigured(TIFF *tif) +static int +_notConfigured(TIFF* tif) { - const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression); - char compression_code[20]; - - snprintf(compression_code, sizeof(compression_code), "%" PRIu16, - tif->tif_dir.td_compression); - TIFFErrorExtR(tif, tif->tif_name, - "%s compression support is not configured", - c ? c->name : compression_code); - return (0); + const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); + char compression_code[20]; + + sprintf(compression_code, "%d",tif->tif_dir.td_compression ); + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%s compression support is not configured", + c ? c->name : compression_code ); + return (0); } -static int NotConfigured(TIFF *tif, int scheme) +static int +NotConfigured(TIFF* tif, int scheme) { - (void)scheme; + (void) scheme; - tif->tif_fixuptags = _notConfigured; - tif->tif_decodestatus = FALSE; - tif->tif_setupdecode = _notConfigured; - tif->tif_encodestatus = FALSE; - tif->tif_setupencode = _notConfigured; - return (1); + tif->tif_fixuptags = _notConfigured; + tif->tif_decodestatus = FALSE; + tif->tif_setupdecode = _notConfigured; + tif->tif_encodestatus = FALSE; + tif->tif_setupencode = _notConfigured; + return (1); } /************************************************************************/ @@ -143,21 +145,27 @@ static int NotConfigured(TIFF *tif, int scheme) * 0 will be returned. */ -int TIFFIsCODECConfigured(uint16_t scheme) +int +TIFFIsCODECConfigured(uint16 scheme) { - const TIFFCodec *codec = TIFFFindCODEC(scheme); + const TIFFCodec* codec = TIFFFindCODEC(scheme); - if (codec == NULL) - { - return 0; - } - if (codec->init == NULL) - { - return 0; - } - if (codec->init != NotConfigured) - { - return 1; - } - return 0; + if(codec == NULL) { + return 0; + } + if(codec->init == NULL) { + return 0; + } + if(codec->init != NotConfigured){ + return 1; + } + return 0; } + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_color.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_color.c index 2d7dcac6f..8fae40ea4 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_color.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_color.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -40,191 +40,173 @@ /* * Convert color value from the CIE L*a*b* 1976 space to CIE XYZ. */ -void TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a, int32_t b, - float *X, float *Y, float *Z) +void +TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32 l, int32 a, int32 b, + float *X, float *Y, float *Z) { - TIFFCIELab16ToXYZ(cielab, l * 257, a * 256, b * 256, X, Y, Z); + float L = (float)l * 100.0F / 255.0F; + float cby, tmp; + + if( L < 8.856F ) { + *Y = (L * cielab->Y0) / 903.292F; + cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F; + } else { + cby = (L + 16.0F) / 116.0F; + *Y = cielab->Y0 * cby * cby * cby; + } + + tmp = (float)a / 500.0F + cby; + if( tmp < 0.2069F ) + *X = cielab->X0 * (tmp - 0.13793F) / 7.787F; + else + *X = cielab->X0 * tmp * tmp * tmp; + + tmp = cby - (float)b / 200.0F; + if( tmp < 0.2069F ) + *Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F; + else + *Z = cielab->Z0 * tmp * tmp * tmp; } -/* - * For CIELab encoded in 16 bits, L is an unsigned integer range [0,65535]. - * The a* and b* components are signed integers range [-32768,32767]. The 16 - * bit chrominance values are encoded as 256 times the 1976 CIE a* and b* - * values - */ -void TIFFCIELab16ToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a, - int32_t b, float *X, float *Y, float *Z) -{ - float L = (float)l * 100.0F / 65535.0F; - float cby, tmp; - - if (L < 8.856F) - { - *Y = (L * cielab->Y0) / 903.292F; - cby = 7.787F * (*Y / cielab->Y0) + 16.0F / 116.0F; - } - else - { - cby = (L + 16.0F) / 116.0F; - *Y = cielab->Y0 * cby * cby * cby; - } - - tmp = (float)a / 256.0F / 500.0F + cby; - if (tmp < 0.2069F) - *X = cielab->X0 * (tmp - 0.13793F) / 7.787F; - else - *X = cielab->X0 * tmp * tmp * tmp; - - tmp = cby - (float)b / 256.0F / 200.0F; - if (tmp < 0.2069F) - *Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F; - else - *Z = cielab->Z0 * tmp * tmp * tmp; -} - -#define RINT(R) ((uint32_t)((R) > 0 ? ((R) + 0.5) : ((R)-0.5))) +#define RINT(R) ((uint32)((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_t *r, uint32_t *g, uint32_t *b) +void +TIFFXYZToRGB(TIFFCIELabToRGB *cielab, float X, float Y, float Z, + uint32 *r, uint32 *g, uint32 *b) { - int i; - float Yr, Yg, Yb; - float *matrix = &cielab->display.d_mat[0][0]; + int i; + float Yr, Yg, Yb; + float *matrix = &cielab->display.d_mat[0][0]; - /* Multiply through the matrix to get luminosity values. */ - Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z; - Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z; - Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z; + /* Multiply through the matrix to get luminosity values. */ + Yr = matrix[0] * X + matrix[1] * Y + matrix[2] * Z; + Yg = matrix[3] * X + matrix[4] * Y + matrix[5] * Z; + Yb = matrix[6] * X + matrix[7] * Y + matrix[8] * Z; - /* Clip input */ - Yr = TIFFmax(Yr, cielab->display.d_Y0R); - Yg = TIFFmax(Yg, cielab->display.d_Y0G); - Yb = TIFFmax(Yb, cielab->display.d_Y0B); + /* Clip input */ + Yr = TIFFmax(Yr, cielab->display.d_Y0R); + Yg = TIFFmax(Yg, cielab->display.d_Y0G); + Yb = TIFFmax(Yb, cielab->display.d_Y0B); - /* Avoid overflow in case of wrong input values */ - Yr = TIFFmin(Yr, cielab->display.d_YCR); - Yg = TIFFmin(Yg, cielab->display.d_YCG); - Yb = TIFFmin(Yb, cielab->display.d_YCB); + /* Avoid overflow in case of wrong input values */ + Yr = TIFFmin(Yr, cielab->display.d_YCR); + Yg = TIFFmin(Yg, cielab->display.d_YCG); + Yb = TIFFmin(Yb, cielab->display.d_YCB); - /* Turn luminosity to colour value. */ - i = (int)((Yr - cielab->display.d_Y0R) / cielab->rstep); - i = TIFFmin(cielab->range, i); - *r = RINT(cielab->Yr2r[i]); + /* Turn luminosity to colour value. */ + i = (int)((Yr - cielab->display.d_Y0R) / cielab->rstep); + i = TIFFmin(cielab->range, i); + *r = RINT(cielab->Yr2r[i]); - i = (int)((Yg - cielab->display.d_Y0G) / cielab->gstep); - i = TIFFmin(cielab->range, i); - *g = RINT(cielab->Yg2g[i]); + i = (int)((Yg - cielab->display.d_Y0G) / cielab->gstep); + i = TIFFmin(cielab->range, i); + *g = RINT(cielab->Yg2g[i]); - i = (int)((Yb - cielab->display.d_Y0B) / cielab->bstep); - i = TIFFmin(cielab->range, i); - *b = RINT(cielab->Yb2b[i]); + i = (int)((Yb - cielab->display.d_Y0B) / cielab->bstep); + i = TIFFmin(cielab->range, i); + *b = RINT(cielab->Yb2b[i]); - /* Clip output. */ - *r = TIFFmin(*r, cielab->display.d_Vrwr); - *g = TIFFmin(*g, cielab->display.d_Vrwg); - *b = TIFFmin(*b, cielab->display.d_Vrwb); + /* Clip output. */ + *r = TIFFmin(*r, cielab->display.d_Vrwr); + *g = TIFFmin(*g, cielab->display.d_Vrwg); + *b = TIFFmin(*b, cielab->display.d_Vrwb); } #undef RINT -/* +/* * Allocate conversion state structures and make look_up tables for * the Yr,Yb,Yg <=> r,g,b conversions. */ -int TIFFCIELabToRGBInit(TIFFCIELabToRGB *cielab, const TIFFDisplay *display, - float *refWhite) +int +TIFFCIELabToRGBInit(TIFFCIELabToRGB* cielab, + const TIFFDisplay *display, float *refWhite) { - int i; - double dfGamma; + int i; + double dfGamma; - cielab->range = CIELABTORGB_TABLE_RANGE; + cielab->range = CIELABTORGB_TABLE_RANGE; - _TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay)); + _TIFFmemcpy(&cielab->display, display, sizeof(TIFFDisplay)); - /* Red */ - dfGamma = 1.0 / cielab->display.d_gammaR; - cielab->rstep = - (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range; - for (i = 0; i <= cielab->range; i++) - { - cielab->Yr2r[i] = cielab->display.d_Vrwr * - ((float)pow((double)i / cielab->range, dfGamma)); - } + /* Red */ + dfGamma = 1.0 / cielab->display.d_gammaR ; + cielab->rstep = + (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range; + for(i = 0; i <= cielab->range; i++) { + cielab->Yr2r[i] = cielab->display.d_Vrwr + * ((float)pow((double)i / cielab->range, dfGamma)); + } - /* Green */ - dfGamma = 1.0 / cielab->display.d_gammaG; - cielab->gstep = - (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range; - for (i = 0; i <= cielab->range; i++) - { - cielab->Yg2g[i] = cielab->display.d_Vrwg * - ((float)pow((double)i / cielab->range, dfGamma)); - } + /* Green */ + dfGamma = 1.0 / cielab->display.d_gammaG ; + cielab->gstep = + (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range; + for(i = 0; i <= cielab->range; i++) { + cielab->Yg2g[i] = cielab->display.d_Vrwg + * ((float)pow((double)i / cielab->range, dfGamma)); + } - /* Blue */ - dfGamma = 1.0 / cielab->display.d_gammaB; - cielab->bstep = - (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range; - for (i = 0; i <= cielab->range; i++) - { - cielab->Yb2b[i] = cielab->display.d_Vrwb * - ((float)pow((double)i / cielab->range, dfGamma)); - } + /* Blue */ + dfGamma = 1.0 / cielab->display.d_gammaB ; + cielab->bstep = + (cielab->display.d_YCR - cielab->display.d_Y0R) / cielab->range; + for(i = 0; i <= cielab->range; i++) { + cielab->Yb2b[i] = cielab->display.d_Vrwb + * ((float)pow((double)i / cielab->range, dfGamma)); + } - /* Init reference white point */ - cielab->X0 = refWhite[0]; - cielab->Y0 = refWhite[1]; - cielab->Z0 = refWhite[2]; + /* Init reference white point */ + cielab->X0 = refWhite[0]; + cielab->Y0 = refWhite[1]; + cielab->Z0 = refWhite[2]; - return 0; + return 0; } -/* +/* * Convert color value from the YCbCr space to RGB. * The colorspace conversion algorithm comes from the IJG v5a code; * see below for more information on how it works. */ -#define SHIFT 16 -#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)) -/* !((f)>=(min)) written that way to deal with NaN */ -#define CLAMP(f, min, max) \ - ((!((f) >= (min))) ? (min) : (f) > (max) ? (max) : (f)) -#define HICLAMP(f, max) ((f) > (max) ? (max) : (f)) +#define SHIFT 16 +#define FIX(x) ((int32)((x) * (1L<(max)?(max):(f)) +#define HICLAMP(f,max) ((f)>(max)?(max):(f)) -void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32_t Y, int32_t Cb, int32_t Cr, - uint32_t *r, uint32_t *g, uint32_t *b) +void +TIFFYCbCrtoRGB(TIFFYCbCrToRGB *ycbcr, uint32 Y, int32 Cb, int32 Cr, + uint32 *r, uint32 *g, uint32 *b) { - int32_t i; + int32 i; - /* XXX: Only 8-bit YCbCr input supported for now */ - Y = HICLAMP(Y, 255); - Cb = CLAMP(Cb, 0, 255); - Cr = CLAMP(Cr, 0, 255); + /* XXX: Only 8-bit YCbCr input supported for now */ + Y = HICLAMP(Y, 255); + Cb = CLAMP(Cb, 0, 255); + Cr = CLAMP(Cr, 0, 255); - i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr]; - *r = CLAMP(i, 0, 255); - i = ycbcr->Y_tab[Y] + - (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT); - *g = CLAMP(i, 0, 255); - i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb]; - *b = CLAMP(i, 0, 255); + i = ycbcr->Y_tab[Y] + ycbcr->Cr_r_tab[Cr]; + *r = CLAMP(i, 0, 255); + i = ycbcr->Y_tab[Y] + + (int)((ycbcr->Cb_g_tab[Cb] + ycbcr->Cr_g_tab[Cr]) >> SHIFT); + *g = CLAMP(i, 0, 255); + i = ycbcr->Y_tab[Y] + ycbcr->Cb_b_tab[Cb]; + *b = CLAMP(i, 0, 255); } /* Clamp function for sanitization purposes. Normally clamping should not */ /* occur for well behaved chroma and refBlackWhite coefficients */ static float CLAMPw(float v, float vmin, float vmax) { - if (v < vmin) + if( v < vmin ) { /* printf("%f clamped to %f\n", v, vmin); */ return vmin; } - if (v > vmax) + if( v > vmax ) { /* printf("%f clamped to %f\n", v, vmax); */ return vmax; @@ -248,75 +230,78 @@ static float CLAMPw(float v, float vmin, float vmax) * pre-calculating possible values indexed by Cb and Cr (this code * assumes conversion is being done for 8-bit samples). */ -int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *ycbcr, float *luma, float *refBlackWhite) +int +TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, float *luma, float *refBlackWhite) { - TIFFRGBValue *clamptab; + TIFFRGBValue* clamptab; int i; + +#define LumaRed luma[0] +#define LumaGreen luma[1] +#define LumaBlue luma[2] -#define LumaRed luma[0] -#define LumaGreen luma[1] -#define LumaBlue luma[2] - - clamptab = - (TIFFRGBValue *)((uint8_t *)ycbcr + - TIFFroundup_32(sizeof(TIFFYCbCrToRGB), sizeof(long))); - _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ + clamptab = (TIFFRGBValue*)( + (uint8*) ycbcr+TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long))); + _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ ycbcr->clamptab = (clamptab += 256); for (i = 0; i < 256; i++) - clamptab[i] = (TIFFRGBValue)i; - _TIFFmemset(clamptab + 256, 255, 2 * 256); /* v > 255 => 255 */ - ycbcr->Cr_r_tab = (int *)(clamptab + 3 * 256); + clamptab[i] = (TIFFRGBValue) i; + _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */ + ycbcr->Cr_r_tab = (int*) (clamptab + 3*256); ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256; - ycbcr->Cr_g_tab = (int32_t *)(ycbcr->Cb_b_tab + 256); + ycbcr->Cr_g_tab = (int32*) (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_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; + { float f1 = 2-2*LumaRed; int32 D1 = FIX(CLAMP(f1,0.0F,2.0F)); + float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(CLAMP(f2,0.0F,2.0F)); + float f3 = 2-2*LumaBlue; int32 D3 = FIX(CLAMP(f3,0.0F,2.0F)); + float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(CLAMP(f4,0.0F,2.0F)); + int x; #undef LumaBlue #undef LumaGreen #undef LumaRed + + /* + * i is the actual input pixel value in the range 0..255 + * Cb and Cr values are in the range -128..127 (actually + * they are in a range defined by the ReferenceBlackWhite + * tag) so there is some range shifting to do here when + * 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, + refBlackWhite[5] - 128.0F, 127), + -128.0F * 32, 128.0F * 32); + int32 Cb = (int32)CLAMPw(Code2V(x, refBlackWhite[2] - 128.0F, + refBlackWhite[3] - 128.0F, 127), + -128.0F * 32, 128.0F * 32); - /* - * i is the actual input pixel value in the range 0..255 - * Cb and Cr values are in the range -128..127 (actually - * they are in a range defined by the ReferenceBlackWhite - * tag) so there is some range shifting to do here when - * constructing tables indexed by the raw pixel data. - */ - for (i = 0, x = -128; i < 256; i++, x++) - { - int32_t Cr = (int32_t)CLAMPw(Code2V(x, refBlackWhite[4] - 128.0F, - refBlackWhite[5] - 128.0F, 127), - -128.0F * 32, 128.0F * 32); - 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_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_t)CLAMPw( - Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255), - -128.0F * 32, 128.0F * 32); - } + ycbcr->Cr_r_tab[i] = (int32)((D1*Cr + ONE_HALF)>>SHIFT); + ycbcr->Cb_b_tab[i] = (int32)((D3*Cb + ONE_HALF)>>SHIFT); + ycbcr->Cr_g_tab[i] = D2*Cr; + ycbcr->Cb_g_tab[i] = D4*Cb + ONE_HALF; + ycbcr->Y_tab[i] = + (int32)CLAMPw(Code2V(x + 128, refBlackWhite[0], refBlackWhite[1], 255), + -128.0F * 32, 128.0F * 32); + } } return 0; } -#undef HICLAMP -#undef CLAMP -#undef Code2V -#undef SHIFT -#undef ONE_HALF -#undef FIX +#undef HICLAMP +#undef CLAMP +#undef Code2V +#undef SHIFT +#undef ONE_HALF +#undef FIX + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_compress.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_compress.c index c6e17d3e1..915478f50 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_compress.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_compress.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -29,152 +29,145 @@ */ #include "tiffiop.h" -static int TIFFNoEncode(TIFF *tif, const char *method) +static int +TIFFNoEncode(TIFF* tif, const char* method) { - const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression); + const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - if (c) - { - TIFFErrorExtR(tif, tif->tif_name, "%s %s encoding is not implemented", - c->name, method); - } - else - { - TIFFErrorExtR(tif, tif->tif_name, - "Compression scheme %" PRIu16 - " %s encoding is not implemented", - tif->tif_dir.td_compression, method); - } - return (-1); + if (c) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%s %s encoding is not implemented", + c->name, method); + } else { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Compression scheme %u %s encoding is not implemented", + tif->tif_dir.td_compression, method); + } + return (-1); } -int _TIFFNoRowEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s) +int +_TIFFNoRowEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { - (void)pp; - (void)cc; - (void)s; - return (TIFFNoEncode(tif, "scanline")); + (void) pp; (void) cc; (void) s; + return (TIFFNoEncode(tif, "scanline")); } -int _TIFFNoStripEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s) +int +_TIFFNoStripEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { - (void)pp; - (void)cc; - (void)s; - return (TIFFNoEncode(tif, "strip")); + (void) pp; (void) cc; (void) s; + return (TIFFNoEncode(tif, "strip")); } -int _TIFFNoTileEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s) +int +_TIFFNoTileEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { - (void)pp; - (void)cc; - (void)s; - return (TIFFNoEncode(tif, "tile")); + (void) pp; (void) cc; (void) s; + return (TIFFNoEncode(tif, "tile")); } -static int TIFFNoDecode(TIFF *tif, const char *method) +static int +TIFFNoDecode(TIFF* tif, const char* method) { - const TIFFCodec *c = TIFFFindCODEC(tif->tif_dir.td_compression); + const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); - if (c) - TIFFErrorExtR(tif, tif->tif_name, "%s %s decoding is not implemented", - c->name, method); - else - TIFFErrorExtR(tif, tif->tif_name, - "Compression scheme %" PRIu16 - " %s decoding is not implemented", - tif->tif_dir.td_compression, method); - return (0); + if (c) + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%s %s decoding is not implemented", + c->name, method); + else + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Compression scheme %u %s decoding is not implemented", + tif->tif_dir.td_compression, method); + return (0); } -static int _TIFFNoFixupTags(TIFF *tif) +static int +_TIFFNoFixupTags(TIFF* tif) { - (void)tif; - return (1); + (void) tif; + return (1); } -int _TIFFNoRowDecode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s) +int +_TIFFNoRowDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { - (void)pp; - (void)cc; - (void)s; - return (TIFFNoDecode(tif, "scanline")); + (void) pp; (void) cc; (void) s; + return (TIFFNoDecode(tif, "scanline")); } -int _TIFFNoStripDecode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s) +int +_TIFFNoStripDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { - (void)pp; - (void)cc; - (void)s; - return (TIFFNoDecode(tif, "strip")); + (void) pp; (void) cc; (void) s; + return (TIFFNoDecode(tif, "strip")); } -int _TIFFNoTileDecode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s) +int +_TIFFNoTileDecode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { - (void)pp; - (void)cc; - (void)s; - return (TIFFNoDecode(tif, "tile")); + (void) pp; (void) cc; (void) s; + return (TIFFNoDecode(tif, "tile")); } -int _TIFFNoSeek(TIFF *tif, uint32_t off) +int +_TIFFNoSeek(TIFF* tif, uint32 off) { - (void)off; - TIFFErrorExtR(tif, tif->tif_name, - "Compression algorithm does not support random access"); - return (0); + (void) off; + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Compression algorithm does not support random access"); + return (0); } -int _TIFFNoPreCode(TIFF *tif, uint16_t s) +int +_TIFFNoPreCode(TIFF* tif, uint16 s) { - (void)tif; - (void)s; - return (1); + (void) tif; (void) s; + return (1); } -static int _TIFFtrue(TIFF *tif) -{ - (void)tif; - return (1); -} -static void _TIFFvoid(TIFF *tif) { (void)tif; } +static int _TIFFtrue(TIFF* tif) { (void) tif; return (1); } +static void _TIFFvoid(TIFF* tif) { (void) tif; } -void _TIFFSetDefaultCompressionState(TIFF *tif) +void +_TIFFSetDefaultCompressionState(TIFF* tif) { - tif->tif_fixuptags = _TIFFNoFixupTags; - tif->tif_decodestatus = TRUE; - tif->tif_setupdecode = _TIFFtrue; - tif->tif_predecode = _TIFFNoPreCode; - tif->tif_decoderow = _TIFFNoRowDecode; - tif->tif_decodestrip = _TIFFNoStripDecode; - tif->tif_decodetile = _TIFFNoTileDecode; - tif->tif_encodestatus = TRUE; - tif->tif_setupencode = _TIFFtrue; - tif->tif_preencode = _TIFFNoPreCode; - tif->tif_postencode = _TIFFtrue; - tif->tif_encoderow = _TIFFNoRowEncode; - tif->tif_encodestrip = _TIFFNoStripEncode; - tif->tif_encodetile = _TIFFNoTileEncode; - tif->tif_close = _TIFFvoid; - tif->tif_seek = _TIFFNoSeek; - tif->tif_cleanup = _TIFFvoid; - tif->tif_defstripsize = _TIFFDefaultStripSize; - tif->tif_deftilesize = _TIFFDefaultTileSize; - tif->tif_flags &= ~(TIFF_NOBITREV | TIFF_NOREADRAW); + tif->tif_fixuptags = _TIFFNoFixupTags; + tif->tif_decodestatus = TRUE; + tif->tif_setupdecode = _TIFFtrue; + tif->tif_predecode = _TIFFNoPreCode; + tif->tif_decoderow = _TIFFNoRowDecode; + tif->tif_decodestrip = _TIFFNoStripDecode; + tif->tif_decodetile = _TIFFNoTileDecode; + tif->tif_encodestatus = TRUE; + tif->tif_setupencode = _TIFFtrue; + tif->tif_preencode = _TIFFNoPreCode; + tif->tif_postencode = _TIFFtrue; + tif->tif_encoderow = _TIFFNoRowEncode; + tif->tif_encodestrip = _TIFFNoStripEncode; + tif->tif_encodetile = _TIFFNoTileEncode; + tif->tif_close = _TIFFvoid; + tif->tif_seek = _TIFFNoSeek; + tif->tif_cleanup = _TIFFvoid; + tif->tif_defstripsize = _TIFFDefaultStripSize; + tif->tif_deftilesize = _TIFFDefaultTileSize; + tif->tif_flags &= ~(TIFF_NOBITREV|TIFF_NOREADRAW); } -int TIFFSetCompressionScheme(TIFF *tif, int scheme) +int +TIFFSetCompressionScheme(TIFF* tif, int scheme) { - const TIFFCodec *c = TIFFFindCODEC((uint16_t)scheme); + const TIFFCodec *c = TIFFFindCODEC((uint16) scheme); - _TIFFSetDefaultCompressionState(tif); - /* - * Don't treat an unknown compression scheme as an error. - * This permits applications to open files with data that - * the library does not have builtin support for, but which - * may still be meaningful. - */ - return (c ? (*c->init)(tif, scheme) : 1); + _TIFFSetDefaultCompressionState(tif); + /* + * Don't treat an unknown compression scheme as an error. + * This permits applications to open files with data that + * the library does not have builtin support for, but which + * may still be meaningful. + */ + return (c ? (*c->init)(tif, scheme) : 1); } /* @@ -182,68 +175,64 @@ int TIFFSetCompressionScheme(TIFF *tif, int scheme) * schemes can also override the builtin versions provided * by this library. */ -typedef struct _codec -{ - struct _codec *next; - TIFFCodec *info; +typedef struct _codec { + struct _codec* next; + TIFFCodec* info; } codec_t; -static codec_t *registeredCODECS = NULL; +static codec_t* registeredCODECS = NULL; -const TIFFCodec *TIFFFindCODEC(uint16_t scheme) +const TIFFCodec* +TIFFFindCODEC(uint16 scheme) { - const TIFFCodec *c; - codec_t *cd; + const TIFFCodec* c; + codec_t* cd; - for (cd = registeredCODECS; cd; cd = cd->next) - if (cd->info->scheme == scheme) - return ((const TIFFCodec *)cd->info); - for (c = _TIFFBuiltinCODECS; c->name; c++) - if (c->scheme == scheme) - return (c); - return ((const TIFFCodec *)0); + for (cd = registeredCODECS; cd; cd = cd->next) + if (cd->info->scheme == scheme) + return ((const TIFFCodec*) cd->info); + for (c = _TIFFBuiltinCODECS; c->name; c++) + if (c->scheme == scheme) + return (c); + return ((const TIFFCodec*) 0); } -TIFFCodec *TIFFRegisterCODEC(uint16_t scheme, const char *name, - TIFFInitMethod init) +TIFFCodec* +TIFFRegisterCODEC(uint16 scheme, const char* name, TIFFInitMethod init) { - codec_t *cd = (codec_t *)_TIFFmallocExt( - NULL, - (tmsize_t)(sizeof(codec_t) + sizeof(TIFFCodec) + strlen(name) + 1)); + codec_t* cd = (codec_t*) + _TIFFmalloc((tmsize_t)(sizeof (codec_t) + sizeof (TIFFCodec) + strlen(name)+1)); - if (cd != NULL) - { - cd->info = (TIFFCodec *)((uint8_t *)cd + sizeof(codec_t)); - cd->info->name = (char *)((uint8_t *)cd->info + sizeof(TIFFCodec)); - strcpy(cd->info->name, name); - cd->info->scheme = scheme; - cd->info->init = init; - cd->next = registeredCODECS; - registeredCODECS = cd; - } - else - { - TIFFErrorExt(0, "TIFFRegisterCODEC", - "No space to register compression scheme %s", name); - return NULL; - } - return (cd->info); + if (cd != NULL) { + cd->info = (TIFFCodec*) ((uint8*) cd + sizeof (codec_t)); + cd->info->name = (char*) + ((uint8*) cd->info + sizeof (TIFFCodec)); + strcpy(cd->info->name, name); + cd->info->scheme = scheme; + cd->info->init = init; + cd->next = registeredCODECS; + registeredCODECS = cd; + } else { + TIFFErrorExt(0, "TIFFRegisterCODEC", + "No space to register compression scheme %s", name); + return NULL; + } + return (cd->info); } -void TIFFUnRegisterCODEC(TIFFCodec *c) +void +TIFFUnRegisterCODEC(TIFFCodec* c) { - codec_t *cd; - codec_t **pcd; + codec_t* cd; + codec_t** pcd; - for (pcd = ®isteredCODECS; (cd = *pcd) != NULL; pcd = &cd->next) - if (cd->info == c) - { - *pcd = cd->next; - _TIFFfreeExt(NULL, cd); - return; - } - TIFFErrorExt(0, "TIFFUnRegisterCODEC", - "Cannot remove compression scheme %s; not registered", - c->name); + for (pcd = ®isteredCODECS; (cd = *pcd) != NULL; pcd = &cd->next) + if (cd->info == c) { + *pcd = cd->next; + _TIFFfree(cd); + return; + } + TIFFErrorExt(0, "TIFFUnRegisterCODEC", + "Cannot remove compression scheme %s; not registered", c->name); } /************************************************************************/ @@ -253,58 +242,61 @@ void TIFFUnRegisterCODEC(TIFFCodec *c) /** * Get list of configured codecs, both built-in and registered by user. * Caller is responsible to free this structure. - * + * * @return returns array of TIFFCodec records (the last record should be NULL) * or NULL if function failed. */ -TIFFCodec *TIFFGetConfiguredCODECs() +TIFFCodec* +TIFFGetConfiguredCODECs() { - int i = 1; - codec_t *cd; - const TIFFCodec *c; - TIFFCodec *codecs = NULL; - TIFFCodec *new_codecs; + int i = 1; + codec_t *cd; + const TIFFCodec* c; + TIFFCodec* codecs = NULL; + TIFFCodec* new_codecs; - for (cd = registeredCODECS; cd; cd = cd->next) - { - new_codecs = - (TIFFCodec *)_TIFFreallocExt(NULL, codecs, i * sizeof(TIFFCodec)); - if (!new_codecs) - { - _TIFFfreeExt(NULL, codecs); - return NULL; - } - codecs = new_codecs; - _TIFFmemcpy(codecs + i - 1, cd->info, sizeof(TIFFCodec)); - i++; - } - for (c = _TIFFBuiltinCODECS; c->name; c++) - { - if (TIFFIsCODECConfigured(c->scheme)) - { - new_codecs = (TIFFCodec *)_TIFFreallocExt(NULL, codecs, - i * sizeof(TIFFCodec)); - if (!new_codecs) - { - _TIFFfreeExt(NULL, codecs); - return NULL; - } - codecs = new_codecs; - _TIFFmemcpy(codecs + i - 1, (const void *)c, sizeof(TIFFCodec)); - i++; - } - } + for (cd = registeredCODECS; cd; cd = cd->next) { + new_codecs = (TIFFCodec *) + _TIFFrealloc(codecs, i * sizeof(TIFFCodec)); + if (!new_codecs) { + _TIFFfree (codecs); + return NULL; + } + codecs = new_codecs; + _TIFFmemcpy(codecs + i - 1, cd->info, sizeof(TIFFCodec)); + i++; + } + for (c = _TIFFBuiltinCODECS; c->name; c++) { + if (TIFFIsCODECConfigured(c->scheme)) { + new_codecs = (TIFFCodec *) + _TIFFrealloc(codecs, i * sizeof(TIFFCodec)); + if (!new_codecs) { + _TIFFfree (codecs); + return NULL; + } + codecs = new_codecs; + _TIFFmemcpy(codecs + i - 1, (const void*)c, sizeof(TIFFCodec)); + i++; + } + } - new_codecs = - (TIFFCodec *)_TIFFreallocExt(NULL, codecs, i * sizeof(TIFFCodec)); - if (!new_codecs) - { - _TIFFfreeExt(NULL, codecs); - return NULL; - } - codecs = new_codecs; - _TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec)); + new_codecs = (TIFFCodec *) _TIFFrealloc(codecs, i * sizeof(TIFFCodec)); + if (!new_codecs) { + _TIFFfree (codecs); + return NULL; + } + codecs = new_codecs; + _TIFFmemset(codecs + i - 1, 0, sizeof(TIFFCodec)); - return codecs; + return codecs; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h-vms b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h-vms new file mode 100644 index 000000000..d653bd827 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h-vms @@ -0,0 +1,46 @@ +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the 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 header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +//#define HAVE_IO_H 1 + +/* Define to 1 if you have the 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/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h.cmake.in b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h.cmake.in index 1547af46d..06be65277 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h.cmake.in +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h.cmake.in @@ -1,14 +1,6 @@ -/* clang-format off */ -/* clang-format disabled because CMake scripts are very sensitive to the - * formatting of this file. configure_file variables of type "@VAR@" are - * modified by clang-format and won't be substituted. - */ - /* 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 @@ -28,15 +20,12 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_ASSERT_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 header file. */ +#cmakedefine HAVE_DLFCN_H 1 /* Define to 1 if you have the 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 @@ -52,12 +41,18 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_GL_GL_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H 1 + /* Define to 1 if you have the 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 @@ -67,12 +62,42 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_OPENGL_GL_H 1 +/* Define to 1 if you have the 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 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 header file. */ #cmakedefine HAVE_STRINGS_H 1 +/* Define to 1 if you have the 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 header file. */ +#cmakedefine HAVE_SYS_TIME_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_TYPES_H 1 @@ -80,17 +105,20 @@ #cmakedefine HAVE_UNISTD_H 1 /* 8/12 bit libjpeg dual mode enabled */ -#cmakedefine JPEG_DUAL_MODE_8_12 1 1 - -/* Support LERC compression */ -#cmakedefine LERC_SUPPORT 1 +#cmakedefine JPEG_DUAL_MODE_8_12 1 /* 12bit libjpeg primary include file with path */ -#define LIBJPEG_12_PATH "@LIBJPEG_12_PATH@" +#cmakedefine 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@" @@ -112,14 +140,62 @@ /* Define to the version of this package. */ #define PACKAGE_VERSION "@PACKAGE_VERSION@" -/* Size of size_t */ +/* 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 `size_t', as computed by sizeof. */ #define SIZEOF_SIZE_T @SIZEOF_SIZE_T@ +/* 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@ + /* Default size of the strip in bytes (when strip chopping enabled) */ #define STRIP_SIZE_DEFAULT @STRIP_SIZE_DEFAULT@ -/** Maximum number of TIFF IFDs that libtiff can iterate through in a file. */ -#define TIFF_MAX_DIR_COUNT @TIFF_MAX_DIR_COUNT@ +/* 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 and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if your declares `struct tm'. */ +#cmakedefine TM_IN_SYS_TIME 1 /* define to use win32 IO system */ #cmakedefine USE_WIN32_FILEIO 1 @@ -127,13 +203,6 @@ /* 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 @@ -146,21 +215,17 @@ # endif #endif -#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" +/* Number of bits in a file offset, on hosts where this is settable. */ +#define _FILE_OFFSET_BITS @FILE_OFFSET_BITS@ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#define inline @INLINE_KEYWORD@ #endif -/* clang-format on */ +/* Define to `long int' if does not define. */ +#undef off_t + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h.in b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h.in deleted file mode 100644 index 87c08bb7b..000000000 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.h.in +++ /dev/null @@ -1,182 +0,0 @@ -/* clang-format off */ -/* clang-format disabled because CMake scripts are very sensitive to the - * formatting of this file. configure_file variables of type "@VAR@" are - * modified by clang-format and won't be substituted. - */ - -/* libtiff/tif_config.h.in. Not generated, but originated from autoheader. */ - -#include "tiffconf.h" - -/* Support CCITT Group 3 & 4 algorithms */ -#undef CCITT_SUPPORT - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#undef CHECK_JPEG_YCBCR_SUBSAMPLING - -/* enable partial strip reading for large strips (experimental) */ -#undef CHUNKY_STRIP_READ_SUPPORT - -/* Support C++ stream API (requires C++ compiler) */ -#undef CXX_SUPPORT - -/* enable deferred strip/tile offset/size loading */ -#undef DEFER_STRILE_LOAD - -/* Define to 1 if you have the header file. */ -#undef HAVE_ASSERT_H - -/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't. - */ -#undef HAVE_DECL_OPTARG - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ -#undef HAVE_FSEEKO - -/* Define to 1 if you have the `getopt' function. */ -#undef HAVE_GETOPT - -/* Define to 1 if you have the header file. */ -#undef HAVE_GLUT_GLUT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_GL_GLUT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_GL_GLU_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_GL_GL_H - -/* Define to 1 if you have the 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 `mmap' function. */ -#undef HAVE_MMAP - -/* Define to 1 if you have the header file. */ -#undef HAVE_OPENGL_GLU_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_OPENGL_GL_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 header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* 8/12 bit libjpeg dual mode enabled */ -#undef JPEG_DUAL_MODE_8_12 - -/* Support LERC compression */ -#undef LERC_SUPPORT - -/* 12bit libjpeg primary include file with path */ -#undef LIBJPEG_12_PATH - -/* Support LZMA2 compression */ -#undef LZMA_SUPPORT - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* The size of `size_t', as computed by sizeof. */ -#undef SIZEOF_SIZE_T - -/* Default size of the strip in bytes (when strip chopping enabled) */ -#undef STRIP_SIZE_DEFAULT - -/* Maximum number of TIFF IFDs that libtiff can iterate through in a file. */ -#undef TIFF_MAX_DIR_COUNT - -/* define to use win32 IO system */ -#undef USE_WIN32_FILEIO - -/* Version number of package */ -#undef VERSION - -/* Support webp compression */ -#undef WEBP_SUPPORT - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -# undef WORDS_BIGENDIAN -# endif -#endif - -/* Support zstd compression */ -#undef ZSTD_SUPPORT - -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - -/* Number of bits in a file offset, on hosts where this is settable. */ -#undef _FILE_OFFSET_BITS - -/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ -#undef _LARGEFILE_SOURCE - -/* Define for large files, on AIX-style hosts. */ -#undef _LARGE_FILES - -#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 - -/* clang-format on */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.vc.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.vc.h new file mode 100644 index 000000000..939594f89 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.vc.h @@ -0,0 +1,150 @@ +#ifndef _TIF_CONFIG_H_ +#define _TIF_CONFIG_H_ + +/* Define to 1 if you have the header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the 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 header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_IO_H 1 + +/* Define to 1 if you have the 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 declaration of `optarg', and to 0 if you don't. */ +#define HAVE_DECL_OPTARG 0 + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of a `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* Signed 64-bit type formatter */ +#define TIFF_INT64_FORMAT "%I64d" + +/* Signed 64-bit type */ +#define TIFF_INT64_T signed __int64 + +/* Unsigned 64-bit type formatter */ +#define TIFF_UINT64_FORMAT "%I64u" + +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T unsigned __int64 + +#if _WIN64 +/* + Windows 64-bit build +*/ + +/* Pointer difference type */ +# define TIFF_PTRDIFF_T TIFF_INT64_T + +/* The size of `size_t', as computed by sizeof. */ +# define SIZEOF_SIZE_T 8 + +/* Size type formatter */ +# define TIFF_SIZE_FORMAT TIFF_INT64_FORMAT + +/* Unsigned size type */ +# define TIFF_SIZE_T TIFF_UINT64_T + +/* Signed size type formatter */ +# define TIFF_SSIZE_FORMAT TIFF_INT64_FORMAT + +/* Signed size type */ +# define TIFF_SSIZE_T TIFF_INT64_T + +#else +/* + Windows 32-bit build +*/ + +/* Pointer difference type */ +# define TIFF_PTRDIFF_T signed int + +/* The size of `size_t', as computed by sizeof. */ +# define SIZEOF_SIZE_T 4 + +/* Size type formatter */ +# define TIFF_SIZE_FORMAT "%u" + +/* Size type formatter */ +# define TIFF_SIZE_FORMAT "%u" + +/* Unsigned size type */ +# define TIFF_SIZE_T unsigned int + +/* Signed size type formatter */ +# define TIFF_SSIZE_FORMAT "%d" + +/* Signed size type */ +# define TIFF_SSIZE_T signed int + +#endif + +/* Set the native cpu bit order */ +#define HOST_FILLORDER FILLORDER_LSB2MSB + +/* + 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 +#endif + +/* 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 + +#pragma warning(disable : 4996) /* function deprecation warnings */ + +#endif /* _TIF_CONFIG_H_ */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.wince.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.wince.h new file mode 100644 index 000000000..e85e2e62c --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_config.wince.h @@ -0,0 +1,69 @@ +/* + * 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 header file. */ +#define HAVE_ASSERT_H 1 + +/* Define to 1 if you have the 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 header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#define HAVE_IO_H 1 + +/* Define to 1 if you have the 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/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dir.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dir.c index 850062183..af7432369 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dir.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dir.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -29,1077 +29,805 @@ * (and also some miscellaneous stuff) */ #include "tiffiop.h" -#include /*--: for Rational2Double */ -#include +#include /*--: for Rational2Double */ /* * These are used in the backwards compatibility code... */ -#define DATATYPE_VOID 0 /* !untyped data */ -#define DATATYPE_INT 1 /* !signed integer data */ -#define DATATYPE_UINT 2 /* !unsigned integer data */ -#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */ +#define DATATYPE_VOID 0 /* !untyped data */ +#define DATATYPE_INT 1 /* !signed integer data */ +#define DATATYPE_UINT 2 /* !unsigned integer data */ +#define DATATYPE_IEEEFP 3 /* !IEEE floating point data */ -static void setByteArray(TIFF *tif, void **vpp, const void *vp, size_t nmemb, - size_t elem_size) +static void +setByteArray(void** vpp, void* vp, size_t nmemb, size_t elem_size) { - if (*vpp) - { - _TIFFfreeExt(tif, *vpp); - *vpp = 0; - } - if (vp) - { - tmsize_t bytes = _TIFFMultiplySSize(NULL, nmemb, elem_size, NULL); - if (bytes) - *vpp = (void *)_TIFFmallocExt(tif, bytes); - if (*vpp) - _TIFFmemcpy(*vpp, vp, bytes); - } -} -void _TIFFsetByteArray(void **vpp, const void *vp, uint32_t n) -{ - setByteArray(NULL, vpp, vp, n, 1); -} -void _TIFFsetByteArrayExt(TIFF *tif, void **vpp, const void *vp, uint32_t n) -{ - setByteArray(tif, vpp, vp, n, 1); + if (*vpp) { + _TIFFfree(*vpp); + *vpp = 0; + } + if (vp) { + tmsize_t bytes = _TIFFMultiplySSize(NULL, nmemb, elem_size, NULL); + if (bytes) + *vpp = (void*) _TIFFmalloc(bytes); + if (*vpp) + _TIFFmemcpy(*vpp, vp, bytes); + } } +void _TIFFsetByteArray(void** vpp, void* vp, uint32 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) + { 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) + { setByteArray((void**) fpp, (void*) fp, n, sizeof (float)); } +void _TIFFsetDoubleArray(double** dpp, double* dp, uint32 n) + { setByteArray((void**) dpp, (void*) dp, n, sizeof (double)); } -static void _TIFFsetNString(TIFF *tif, char **cpp, const char *cp, uint32_t n) +static void +setDoubleArrayOneValue(double** vpp, double value, size_t nmemb) { - setByteArray(tif, (void **)cpp, cp, n, 1); -} - -void _TIFFsetShortArray(uint16_t **wpp, const uint16_t *wp, uint32_t n) -{ - setByteArray(NULL, (void **)wpp, wp, n, sizeof(uint16_t)); -} -void _TIFFsetShortArrayExt(TIFF *tif, uint16_t **wpp, const uint16_t *wp, - uint32_t n) -{ - setByteArray(tif, (void **)wpp, wp, n, sizeof(uint16_t)); -} - -void _TIFFsetLongArray(uint32_t **lpp, const uint32_t *lp, uint32_t n) -{ - setByteArray(NULL, (void **)lpp, lp, n, sizeof(uint32_t)); -} -void _TIFFsetLongArrayExt(TIFF *tif, uint32_t **lpp, const uint32_t *lp, - uint32_t n) -{ - setByteArray(tif, (void **)lpp, lp, n, sizeof(uint32_t)); -} - -static void _TIFFsetLong8Array(TIFF *tif, uint64_t **lpp, const uint64_t *lp, - uint32_t n) -{ - setByteArray(tif, (void **)lpp, lp, n, sizeof(uint64_t)); -} - -void _TIFFsetFloatArray(float **fpp, const float *fp, uint32_t n) -{ - setByteArray(NULL, (void **)fpp, fp, n, sizeof(float)); -} -void _TIFFsetFloatArrayExt(TIFF *tif, float **fpp, const float *fp, uint32_t n) -{ - setByteArray(tif, (void **)fpp, fp, n, sizeof(float)); -} - -void _TIFFsetDoubleArray(double **dpp, const double *dp, uint32_t n) -{ - setByteArray(NULL, (void **)dpp, dp, n, sizeof(double)); -} -void _TIFFsetDoubleArrayExt(TIFF *tif, double **dpp, const double *dp, - uint32_t n) -{ - setByteArray(tif, (void **)dpp, dp, n, sizeof(double)); -} - -static void setDoubleArrayOneValue(TIFF *tif, double **vpp, double value, - size_t nmemb) -{ - if (*vpp) - _TIFFfreeExt(tif, *vpp); - *vpp = _TIFFmallocExt(tif, nmemb * sizeof(double)); - if (*vpp) - { - while (nmemb--) - ((double *)*vpp)[nmemb] = value; - } + if (*vpp) + _TIFFfree(*vpp); + *vpp = _TIFFmalloc(nmemb*sizeof(double)); + if (*vpp) + { + while (nmemb--) + ((double*)*vpp)[nmemb] = value; + } } /* * Install extra samples information. */ -static int setExtraSamples(TIFF *tif, va_list ap, uint32_t *v) +static int +setExtraSamples(TIFF* tif, va_list ap, uint32* v) { /* XXX: Unassociated alpha data == 999 is a known Corel Draw bug, see below */ -#define EXTRASAMPLE_COREL_UNASSALPHA 999 +#define EXTRASAMPLE_COREL_UNASSALPHA 999 - uint16_t *va; - uint32_t i; - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "setExtraSamples"; + uint16* va; + uint32 i; + TIFFDirectory* td = &tif->tif_dir; + static const char module[] = "setExtraSamples"; - *v = (uint16_t)va_arg(ap, uint16_vap); - if ((uint16_t)*v > td->td_samplesperpixel) - return 0; - va = va_arg(ap, uint16_t *); - if (*v > 0 && va == NULL) /* typically missing param */ - return 0; - for (i = 0; i < *v; i++) - { - if (va[i] > EXTRASAMPLE_UNASSALPHA) + *v = (uint16) va_arg(ap, uint16_vap); + if ((uint16) *v > td->td_samplesperpixel) + return 0; + va = va_arg(ap, uint16*); + if (*v > 0 && va == NULL) /* typically missing param */ + return 0; + for (i = 0; i < *v; i++) { + if (va[i] > EXTRASAMPLE_UNASSALPHA) { + /* + * XXX: Corel Draw is known to produce incorrect + * ExtraSamples tags which must be patched here if we + * want to be able to open some of the damaged TIFF + * files: + */ + if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA) + va[i] = EXTRASAMPLE_UNASSALPHA; + else + return 0; + } + } + + if ( td->td_transferfunction[0] != NULL && (td->td_samplesperpixel - *v > 1) && + !(td->td_samplesperpixel - td->td_extrasamples > 1)) { - /* - * XXX: Corel Draw is known to produce incorrect - * ExtraSamples tags which must be patched here if we - * want to be able to open some of the damaged TIFF - * files: - */ - if (va[i] == EXTRASAMPLE_COREL_UNASSALPHA) - va[i] = EXTRASAMPLE_UNASSALPHA; - else - return 0; + TIFFWarningExt(tif->tif_clientdata,module, + "ExtraSamples tag value is changing, " + "but TransferFunction was read with a different value. Canceling it"); + TIFFClrFieldBit(tif,FIELD_TRANSFERFUNCTION); + _TIFFfree(td->td_transferfunction[0]); + td->td_transferfunction[0] = NULL; } - } - if (td->td_transferfunction[0] != NULL && - (td->td_samplesperpixel - *v > 1) && - !(td->td_samplesperpixel - td->td_extrasamples > 1)) - { - TIFFWarningExtR(tif, module, - "ExtraSamples tag value is changing, " - "but TransferFunction was read with a different value. " - "Canceling it"); - TIFFClrFieldBit(tif, FIELD_TRANSFERFUNCTION); - _TIFFfreeExt(tif, td->td_transferfunction[0]); - td->td_transferfunction[0] = NULL; - } - - td->td_extrasamples = (uint16_t)*v; - _TIFFsetShortArrayExt(tif, &td->td_sampleinfo, va, td->td_extrasamples); - return 1; + td->td_extrasamples = (uint16) *v; + _TIFFsetShortArray(&td->td_sampleinfo, va, td->td_extrasamples); + return 1; #undef EXTRASAMPLE_COREL_UNASSALPHA } /* - * Count ink names separated by \0. Returns + * Count ink names separated by \0. Returns * zero if the ink names are not as expected. */ -static uint16_t countInkNamesString(TIFF *tif, uint32_t slen, const char *s) +static uint16 +countInkNamesString(TIFF *tif, uint32 slen, const char *s) { - uint16_t i = 0; - - if (slen > 0) - { + uint16 i = 0; const char *ep = s + slen; const char *cp = s; - do - { - for (; cp < ep && *cp != '\0'; cp++) - { - } - if (cp >= ep) - goto bad; - cp++; /* skip \0 */ - i++; - } while (cp < ep); - return (i); - } + + if (slen > 0) { + do { + for (; cp < ep && *cp != '\0'; cp++) {} + if (cp >= ep) + goto bad; + cp++; /* skip \0 */ + i++; + } while (cp < ep); + return (i); + } bad: - TIFFErrorExtR(tif, "TIFFSetField", - "%s: Invalid InkNames value; no NUL at given buffer end " - "location %" PRIu32 ", after %" PRIu16 " ink", - tif->tif_name, slen, i); - return (0); + TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", + "%s: Invalid InkNames value; no NUL at given buffer end location %u, after %u ink", + tif->tif_name, slen, i); + return (0); } -static int _TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap) +static int +_TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) { - static const char module[] = "_TIFFVSetField"; + static const char module[] = "_TIFFVSetField"; - TIFFDirectory *td = &tif->tif_dir; - int status = 1; - uint32_t v32, v; + TIFFDirectory* td = &tif->tif_dir; + int status = 1; + uint32 v32, i, v; double dblval; - char *s; - const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); - uint32_t standard_tag = tag; - if (fip == NULL) /* cannot happen since OkToChangeTag() already checks it */ - return 0; - /* - * We want to force the custom code to be used for custom - * fields even if the tag happens to match a well known - * one - important for reinterpreted handling of standard - * tag values in custom directories (i.e. EXIF) - */ - if (fip->field_bit == FIELD_CUSTOM) - { - standard_tag = 0; - } + char* s; + const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); + uint32 standard_tag = tag; + if( fip == NULL ) /* cannot happen since OkToChangeTag() already checks it */ + return 0; + /* + * We want to force the custom code to be used for custom + * fields even if the tag happens to match a well known + * one - important for reinterpreted handling of standard + * tag values in custom directories (i.e. EXIF) + */ + if (fip->field_bit == FIELD_CUSTOM) { + standard_tag = 0; + } - switch (standard_tag) - { - case TIFFTAG_SUBFILETYPE: - td->td_subfiletype = (uint32_t)va_arg(ap, uint32_t); - break; - case TIFFTAG_IMAGEWIDTH: - td->td_imagewidth = (uint32_t)va_arg(ap, uint32_t); - break; - case TIFFTAG_IMAGELENGTH: - td->td_imagelength = (uint32_t)va_arg(ap, uint32_t); - break; - case TIFFTAG_BITSPERSAMPLE: - 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 - * to be ordered, compression code can override this behavior - * in the setup method if it wants to roll the post decoding - * work in with its normal work. - */ - if (tif->tif_flags & TIFF_SWAB) + switch (standard_tag) { + case TIFFTAG_SUBFILETYPE: + td->td_subfiletype = (uint32) va_arg(ap, uint32); + break; + case TIFFTAG_IMAGEWIDTH: + td->td_imagewidth = (uint32) va_arg(ap, uint32); + break; + case TIFFTAG_IMAGELENGTH: + td->td_imagelength = (uint32) va_arg(ap, uint32); + break; + case TIFFTAG_BITSPERSAMPLE: + td->td_bitspersample = (uint16) 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 + * to be ordered, compression code can override this behavior + * in the setup method if it wants to roll the post decoding + * work in with its normal work. + */ + if (tif->tif_flags & TIFF_SWAB) { + if (td->td_bitspersample == 8) + tif->tif_postdecode = _TIFFNoPostDecode; + else if (td->td_bitspersample == 16) + tif->tif_postdecode = _TIFFSwab16BitData; + else if (td->td_bitspersample == 24) + tif->tif_postdecode = _TIFFSwab24BitData; + else if (td->td_bitspersample == 32) + tif->tif_postdecode = _TIFFSwab32BitData; + else if (td->td_bitspersample == 64) + tif->tif_postdecode = _TIFFSwab64BitData; + else if (td->td_bitspersample == 128) /* two 64's */ + tif->tif_postdecode = _TIFFSwab64BitData; + } + break; + case TIFFTAG_COMPRESSION: + v = (uint16) 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) + break; + (*tif->tif_cleanup)(tif); + tif->tif_flags &= ~TIFF_CODERSETUP; + } + /* + * Setup new compression routine state. + */ + if( (status = TIFFSetCompressionScheme(tif, v)) != 0 ) + td->td_compression = (uint16) v; + else + status = 0; + break; + case TIFFTAG_PHOTOMETRIC: + td->td_photometric = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_THRESHHOLDING: + td->td_threshholding = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_FILLORDER: + v = (uint16) va_arg(ap, uint16_vap); + if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) + goto badvalue; + td->td_fillorder = (uint16) v; + break; + case TIFFTAG_ORIENTATION: + v = (uint16) va_arg(ap, uint16_vap); + if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) + goto badvalue; + else + td->td_orientation = (uint16) v; + break; + case TIFFTAG_SAMPLESPERPIXEL: + v = (uint16) va_arg(ap, uint16_vap); + if (v == 0) + goto badvalue; + if( v != td->td_samplesperpixel ) + { + /* See http://bugzilla.maptools.org/show_bug.cgi?id=2500 */ + if( td->td_sminsamplevalue != NULL ) { - if (td->td_bitspersample == 8) - tif->tif_postdecode = _TIFFNoPostDecode; - else if (td->td_bitspersample == 16) - tif->tif_postdecode = _TIFFSwab16BitData; - else if (td->td_bitspersample == 24) - tif->tif_postdecode = _TIFFSwab24BitData; - else if (td->td_bitspersample == 32) - tif->tif_postdecode = _TIFFSwab32BitData; - else if (td->td_bitspersample == 64) - tif->tif_postdecode = _TIFFSwab64BitData; - else if (td->td_bitspersample == 128) /* two 64's */ - tif->tif_postdecode = _TIFFSwab64BitData; + TIFFWarningExt(tif->tif_clientdata,module, + "SamplesPerPixel tag value is changing, " + "but SMinSampleValue tag was read with a different value. Canceling it"); + TIFFClrFieldBit(tif,FIELD_SMINSAMPLEVALUE); + _TIFFfree(td->td_sminsamplevalue); + td->td_sminsamplevalue = NULL; } - break; - case TIFFTAG_COMPRESSION: - v = (uint16_t)va_arg(ap, uint16_vap); - /* - * If we're changing the compression scheme, notify the - * previous module so that it can cleanup any state it's - * setup. - */ - if (TIFFFieldSet(tif, FIELD_COMPRESSION)) + if( td->td_smaxsamplevalue != NULL ) { - if ((uint32_t)td->td_compression == v) - break; - (*tif->tif_cleanup)(tif); - tif->tif_flags &= ~TIFF_CODERSETUP; + TIFFWarningExt(tif->tif_clientdata,module, + "SamplesPerPixel tag value is changing, " + "but SMaxSampleValue tag was read with a different value. Canceling it"); + TIFFClrFieldBit(tif,FIELD_SMAXSAMPLEVALUE); + _TIFFfree(td->td_smaxsamplevalue); + td->td_smaxsamplevalue = NULL; } - /* - * Setup new compression routine state. - */ - if ((status = TIFFSetCompressionScheme(tif, v)) != 0) - td->td_compression = (uint16_t)v; - else - status = 0; - break; - case TIFFTAG_PHOTOMETRIC: - td->td_photometric = (uint16_t)va_arg(ap, uint16_vap); - break; - case TIFFTAG_THRESHHOLDING: - td->td_threshholding = (uint16_t)va_arg(ap, uint16_vap); - break; - case TIFFTAG_FILLORDER: - v = (uint16_t)va_arg(ap, uint16_vap); - if (v != FILLORDER_LSB2MSB && v != FILLORDER_MSB2LSB) - goto badvalue; - td->td_fillorder = (uint16_t)v; - break; - case TIFFTAG_ORIENTATION: - v = (uint16_t)va_arg(ap, uint16_vap); - if (v < ORIENTATION_TOPLEFT || ORIENTATION_LEFTBOT < v) - goto badvalue; - else - td->td_orientation = (uint16_t)v; - break; - case TIFFTAG_SAMPLESPERPIXEL: - v = (uint16_t)va_arg(ap, uint16_vap); - if (v == 0) - goto badvalue; - if (v != td->td_samplesperpixel) + /* Test if 3 transfer functions instead of just one are now needed + See http://bugzilla.maptools.org/show_bug.cgi?id=2820 */ + if( td->td_transferfunction[0] != NULL && (v - td->td_extrasamples > 1) && + !(td->td_samplesperpixel - td->td_extrasamples > 1)) { - /* See http://bugzilla.maptools.org/show_bug.cgi?id=2500 */ - if (td->td_sminsamplevalue != NULL) - { - TIFFWarningExtR(tif, module, - "SamplesPerPixel tag value is changing, " - "but SMinSampleValue tag was read with a " - "different value. Canceling it"); - TIFFClrFieldBit(tif, FIELD_SMINSAMPLEVALUE); - _TIFFfreeExt(tif, td->td_sminsamplevalue); - td->td_sminsamplevalue = NULL; - } - if (td->td_smaxsamplevalue != NULL) - { - TIFFWarningExtR(tif, module, - "SamplesPerPixel tag value is changing, " - "but SMaxSampleValue tag was read with a " - "different value. Canceling it"); - TIFFClrFieldBit(tif, FIELD_SMAXSAMPLEVALUE); - _TIFFfreeExt(tif, td->td_smaxsamplevalue); - td->td_smaxsamplevalue = NULL; - } - /* Test if 3 transfer functions instead of just one are now - needed See http://bugzilla.maptools.org/show_bug.cgi?id=2820 - */ - if (td->td_transferfunction[0] != NULL && - (v - td->td_extrasamples > 1) && - !(td->td_samplesperpixel - td->td_extrasamples > 1)) - { - TIFFWarningExtR(tif, module, - "SamplesPerPixel tag value is changing, " - "but TransferFunction was read with a " - "different value. Canceling it"); - TIFFClrFieldBit(tif, FIELD_TRANSFERFUNCTION); - _TIFFfreeExt(tif, td->td_transferfunction[0]); + TIFFWarningExt(tif->tif_clientdata,module, + "SamplesPerPixel tag value is changing, " + "but TransferFunction was read with a different value. Canceling it"); + TIFFClrFieldBit(tif,FIELD_TRANSFERFUNCTION); + _TIFFfree(td->td_transferfunction[0]); td->td_transferfunction[0] = NULL; - } - } - td->td_samplesperpixel = (uint16_t)v; - break; - case TIFFTAG_ROWSPERSTRIP: - v32 = (uint32_t)va_arg(ap, uint32_t); - if (v32 == 0) - goto badvalue32; - td->td_rowsperstrip = v32; - if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) - { - td->td_tilelength = v32; - td->td_tilewidth = td->td_imagewidth; - } - break; - case TIFFTAG_MINSAMPLEVALUE: - td->td_minsamplevalue = (uint16_t)va_arg(ap, uint16_vap); - break; - case TIFFTAG_MAXSAMPLEVALUE: - td->td_maxsamplevalue = (uint16_t)va_arg(ap, uint16_vap); - break; - case TIFFTAG_SMINSAMPLEVALUE: - if (tif->tif_flags & TIFF_PERSAMPLE) - _TIFFsetDoubleArrayExt(tif, &td->td_sminsamplevalue, - va_arg(ap, double *), - td->td_samplesperpixel); - else - setDoubleArrayOneValue(tif, &td->td_sminsamplevalue, - va_arg(ap, double), - td->td_samplesperpixel); - break; - case TIFFTAG_SMAXSAMPLEVALUE: - if (tif->tif_flags & TIFF_PERSAMPLE) - _TIFFsetDoubleArrayExt(tif, &td->td_smaxsamplevalue, - va_arg(ap, double *), - td->td_samplesperpixel); - else - setDoubleArrayOneValue(tif, &td->td_smaxsamplevalue, - va_arg(ap, double), - td->td_samplesperpixel); - break; - case TIFFTAG_XRESOLUTION: - dblval = va_arg(ap, double); - if (dblval != dblval || dblval < 0) - goto badvaluedouble; - td->td_xresolution = _TIFFClampDoubleToFloat(dblval); - break; - case TIFFTAG_YRESOLUTION: - dblval = va_arg(ap, double); - if (dblval != dblval || dblval < 0) - goto badvaluedouble; - td->td_yresolution = _TIFFClampDoubleToFloat(dblval); - break; - case TIFFTAG_PLANARCONFIG: - v = (uint16_t)va_arg(ap, uint16_vap); - if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) - goto badvalue; - td->td_planarconfig = (uint16_t)v; - break; - case TIFFTAG_XPOSITION: - td->td_xposition = _TIFFClampDoubleToFloat(va_arg(ap, double)); - break; - case TIFFTAG_YPOSITION: - td->td_yposition = _TIFFClampDoubleToFloat(va_arg(ap, double)); - break; - case TIFFTAG_RESOLUTIONUNIT: - v = (uint16_t)va_arg(ap, uint16_vap); - if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) - goto badvalue; - td->td_resolutionunit = (uint16_t)v; - break; - case TIFFTAG_PAGENUMBER: - 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_t)va_arg(ap, uint16_vap); - td->td_halftonehints[1] = (uint16_t)va_arg(ap, uint16_vap); - break; - case TIFFTAG_COLORMAP: - v32 = (uint32_t)(1L << td->td_bitspersample); - _TIFFsetShortArrayExt(tif, &td->td_colormap[0], - va_arg(ap, uint16_t *), v32); - _TIFFsetShortArrayExt(tif, &td->td_colormap[1], - va_arg(ap, uint16_t *), v32); - _TIFFsetShortArrayExt(tif, &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_t)va_arg(ap, uint16_vap)) != 0); - if (td->td_extrasamples) - { - uint16_t sv = EXTRASAMPLE_ASSOCALPHA; - _TIFFsetShortArrayExt(tif, &td->td_sampleinfo, &sv, 1); - } - break; - case TIFFTAG_TILEWIDTH: - v32 = (uint32_t)va_arg(ap, uint32_t); - if (v32 % 16) - { - if (tif->tif_mode != O_RDONLY) - goto badvalue32; - TIFFWarningExtR( - tif, tif->tif_name, - "Nonstandard tile width %" PRIu32 ", convert file", v32); - } - td->td_tilewidth = v32; - tif->tif_flags |= TIFF_ISTILED; - break; - case TIFFTAG_TILELENGTH: - v32 = (uint32_t)va_arg(ap, uint32_t); - if (v32 % 16) - { - if (tif->tif_mode != O_RDONLY) - goto badvalue32; - TIFFWarningExtR( - tif, tif->tif_name, - "Nonstandard tile length %" PRIu32 ", convert file", v32); - } - td->td_tilelength = v32; - tif->tif_flags |= TIFF_ISTILED; - break; - case TIFFTAG_TILEDEPTH: - v32 = (uint32_t)va_arg(ap, uint32_t); - if (v32 == 0) - goto badvalue32; - td->td_tiledepth = v32; - break; - case TIFFTAG_DATATYPE: - v = (uint16_t)va_arg(ap, uint16_vap); - switch (v) - { - case DATATYPE_VOID: - v = SAMPLEFORMAT_VOID; - break; - case DATATYPE_INT: - v = SAMPLEFORMAT_INT; - break; - case DATATYPE_UINT: - v = SAMPLEFORMAT_UINT; - break; - case DATATYPE_IEEEFP: - v = SAMPLEFORMAT_IEEEFP; - break; - default: - goto badvalue; - } - td->td_sampleformat = (uint16_t)v; - break; - case TIFFTAG_SAMPLEFORMAT: - v = (uint16_t)va_arg(ap, uint16_vap); - if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v) - goto badvalue; - td->td_sampleformat = (uint16_t)v; - - /* Try to fix up the SWAB function for complex data. */ - if (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT && - td->td_bitspersample == 32 && - tif->tif_postdecode == _TIFFSwab32BitData) - tif->tif_postdecode = _TIFFSwab16BitData; - else if ((td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT || - td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP) && - td->td_bitspersample == 64 && - tif->tif_postdecode == _TIFFSwab64BitData) - tif->tif_postdecode = _TIFFSwab32BitData; - break; - case TIFFTAG_IMAGEDEPTH: - 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_t)va_arg(ap, uint16_vap); - _TIFFsetLong8Array(tif, &td->td_subifd, - (uint64_t *)va_arg(ap, uint64_t *), - (uint32_t)td->td_nsubifd); - } - else - { - TIFFErrorExtR(tif, module, "%s: Sorry, cannot nest SubIFDs", - tif->tif_name); - status = 0; - } - break; - case TIFFTAG_YCBCRPOSITIONING: - td->td_ycbcrpositioning = (uint16_t)va_arg(ap, uint16_vap); - break; - case TIFFTAG_YCBCRSUBSAMPLING: - 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: - { - uint32_t i; - v = (td->td_samplesperpixel - td->td_extrasamples) > 1 ? 3 : 1; - for (i = 0; i < v; i++) - _TIFFsetShortArrayExt(tif, &td->td_transferfunction[i], - va_arg(ap, uint16_t *), - 1U << td->td_bitspersample); - break; - } - case TIFFTAG_REFERENCEBLACKWHITE: - /* XXX should check for null range */ - _TIFFsetFloatArrayExt(tif, &td->td_refblackwhite, - va_arg(ap, float *), 6); - break; - case TIFFTAG_INKNAMES: - { - v = (uint16_t)va_arg(ap, uint16_vap); - s = va_arg(ap, char *); - uint16_t ninksinstring; - ninksinstring = countInkNamesString(tif, v, s); - status = ninksinstring > 0; - if (ninksinstring > 0) - { - _TIFFsetNString(tif, &td->td_inknames, s, v); - td->td_inknameslen = v; - /* Set NumberOfInks to the value ninksinstring */ - if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS)) - { - if (td->td_numberofinks != ninksinstring) - { - TIFFErrorExtR( - tif, module, - "Warning %s; Tag %s:\n Value %" PRIu16 - " of NumberOfInks is different from the number of " - "inks %" PRIu16 - ".\n -> NumberOfInks value adapted to %" PRIu16 "", - tif->tif_name, fip->field_name, td->td_numberofinks, - ninksinstring, ninksinstring); - td->td_numberofinks = ninksinstring; - } - } - else - { - td->td_numberofinks = ninksinstring; - TIFFSetFieldBit(tif, FIELD_NUMBEROFINKS); - } - if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL)) - { - if (td->td_numberofinks != td->td_samplesperpixel) - { - TIFFErrorExtR(tif, module, - "Warning %s; Tag %s:\n Value %" PRIu16 - " of NumberOfInks is different from the " - "SamplesPerPixel value %" PRIu16 "", - tif->tif_name, fip->field_name, - td->td_numberofinks, - td->td_samplesperpixel); - } - } } } - break; - case TIFFTAG_NUMBEROFINKS: - v = (uint16_t)va_arg(ap, uint16_vap); - /* If InkNames already set also NumberOfInks is set accordingly and - * should be equal */ - if (TIFFFieldSet(tif, FIELD_INKNAMES)) - { - if (v != td->td_numberofinks) + td->td_samplesperpixel = (uint16) v; + break; + case TIFFTAG_ROWSPERSTRIP: + v32 = (uint32) va_arg(ap, uint32); + if (v32 == 0) + goto badvalue32; + td->td_rowsperstrip = v32; + if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { + td->td_tilelength = v32; + td->td_tilewidth = td->td_imagewidth; + } + break; + case TIFFTAG_MINSAMPLEVALUE: + td->td_minsamplevalue = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_MAXSAMPLEVALUE: + td->td_maxsamplevalue = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_SMINSAMPLEVALUE: + if (tif->tif_flags & TIFF_PERSAMPLE) + _TIFFsetDoubleArray(&td->td_sminsamplevalue, va_arg(ap, double*), td->td_samplesperpixel); + else + setDoubleArrayOneValue(&td->td_sminsamplevalue, va_arg(ap, double), td->td_samplesperpixel); + break; + case TIFFTAG_SMAXSAMPLEVALUE: + if (tif->tif_flags & TIFF_PERSAMPLE) + _TIFFsetDoubleArray(&td->td_smaxsamplevalue, va_arg(ap, double*), td->td_samplesperpixel); + else + setDoubleArrayOneValue(&td->td_smaxsamplevalue, va_arg(ap, double), td->td_samplesperpixel); + break; + case TIFFTAG_XRESOLUTION: + dblval = va_arg(ap, double); + if( dblval != dblval || dblval < 0 ) + goto badvaluedouble; + td->td_xresolution = _TIFFClampDoubleToFloat( dblval ); + break; + case TIFFTAG_YRESOLUTION: + dblval = va_arg(ap, double); + if( dblval != dblval || dblval < 0 ) + goto badvaluedouble; + td->td_yresolution = _TIFFClampDoubleToFloat( dblval ); + break; + case TIFFTAG_PLANARCONFIG: + v = (uint16) va_arg(ap, uint16_vap); + if (v != PLANARCONFIG_CONTIG && v != PLANARCONFIG_SEPARATE) + goto badvalue; + td->td_planarconfig = (uint16) v; + break; + case TIFFTAG_XPOSITION: + td->td_xposition = _TIFFClampDoubleToFloat( va_arg(ap, double) ); + break; + case TIFFTAG_YPOSITION: + td->td_yposition = _TIFFClampDoubleToFloat( va_arg(ap, double) ); + break; + case TIFFTAG_RESOLUTIONUNIT: + v = (uint16) va_arg(ap, uint16_vap); + if (v < RESUNIT_NONE || RESUNIT_CENTIMETER < v) + goto badvalue; + td->td_resolutionunit = (uint16) 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); + break; + case TIFFTAG_HALFTONEHINTS: + td->td_halftonehints[0] = (uint16) va_arg(ap, uint16_vap); + td->td_halftonehints[1] = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_COLORMAP: + v32 = (uint32)(1L<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); + 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); + if (td->td_extrasamples) { + uint16 sv = EXTRASAMPLE_ASSOCALPHA; + _TIFFsetShortArray(&td->td_sampleinfo, &sv, 1); + } + break; + case TIFFTAG_TILEWIDTH: + v32 = (uint32) va_arg(ap, uint32); + 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); + } + td->td_tilewidth = v32; + tif->tif_flags |= TIFF_ISTILED; + break; + case TIFFTAG_TILELENGTH: + v32 = (uint32) va_arg(ap, uint32); + 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); + } + td->td_tilelength = v32; + tif->tif_flags |= TIFF_ISTILED; + break; + case TIFFTAG_TILEDEPTH: + v32 = (uint32) va_arg(ap, uint32); + if (v32 == 0) + goto badvalue32; + td->td_tiledepth = v32; + break; + case TIFFTAG_DATATYPE: + v = (uint16) va_arg(ap, uint16_vap); + switch (v) { + case DATATYPE_VOID: v = SAMPLEFORMAT_VOID; break; + case DATATYPE_INT: v = SAMPLEFORMAT_INT; break; + case DATATYPE_UINT: v = SAMPLEFORMAT_UINT; break; + case DATATYPE_IEEEFP: v = SAMPLEFORMAT_IEEEFP;break; + default: goto badvalue; + } + td->td_sampleformat = (uint16) v; + break; + case TIFFTAG_SAMPLEFORMAT: + v = (uint16) va_arg(ap, uint16_vap); + if (v < SAMPLEFORMAT_UINT || SAMPLEFORMAT_COMPLEXIEEEFP < v) + goto badvalue; + td->td_sampleformat = (uint16) v; + + /* Try to fix up the SWAB function for complex data. */ + if( td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT + && td->td_bitspersample == 32 + && tif->tif_postdecode == _TIFFSwab32BitData ) + tif->tif_postdecode = _TIFFSwab16BitData; + else if( (td->td_sampleformat == SAMPLEFORMAT_COMPLEXINT + || td->td_sampleformat == SAMPLEFORMAT_COMPLEXIEEEFP) + && td->td_bitspersample == 64 + && tif->tif_postdecode == _TIFFSwab64BitData ) + tif->tif_postdecode = _TIFFSwab32BitData; + break; + case TIFFTAG_IMAGEDEPTH: + td->td_imagedepth = (uint32) va_arg(ap, uint32); + 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); + } else { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Sorry, cannot nest SubIFDs", + tif->tif_name); + status = 0; + } + break; + case TIFFTAG_YCBCRPOSITIONING: + td->td_ycbcrpositioning = (uint16) 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); + 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_bitspersample); + break; + case TIFFTAG_REFERENCEBLACKWHITE: + /* XXX should check for null range */ + _TIFFsetFloatArray(&td->td_refblackwhite, va_arg(ap, float*), 6); + break; + case TIFFTAG_INKNAMES: { - TIFFErrorExtR( - tif, module, - "Error %s; Tag %s:\n It is not possible to set the " - "value %" PRIu32 - " for NumberOfInks\n which is different from the " - "number of inks in the InkNames tag (%" PRIu16 ")", - tif->tif_name, fip->field_name, v, td->td_numberofinks); - /* Do not set / overwrite number of inks already set by - * InkNames case accordingly. */ - status = 0; - } - } - else - { - td->td_numberofinks = (uint16_t)v; - if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL)) - { - if (td->td_numberofinks != td->td_samplesperpixel) - { - TIFFErrorExtR(tif, module, - "Warning %s; Tag %s:\n Value %" PRIu32 - " of NumberOfInks is different from the " - "SamplesPerPixel value %" PRIu16 "", - tif->tif_name, fip->field_name, v, - td->td_samplesperpixel); - } - } - } - break; - case TIFFTAG_PERSAMPLE: - v = (uint16_t)va_arg(ap, uint16_vap); - if (v == PERSAMPLE_MULTI) - tif->tif_flags |= TIFF_PERSAMPLE; - else - tif->tif_flags &= ~TIFF_PERSAMPLE; - break; - default: - { - TIFFTagValue *tv; - int tv_size, iCustom; + uint16 ninksinstring; + v = (uint16) va_arg(ap, uint16_vap); + s = va_arg(ap, char*); + ninksinstring = countInkNamesString(tif, v, s); + status = ninksinstring > 0; + if(ninksinstring > 0 ) { + _TIFFsetNString(&td->td_inknames, s, v); + td->td_inknameslen = v; + /* Set NumberOfInks to the value ninksinstring */ + if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS)) + { + if (td->td_numberofinks != ninksinstring) { + TIFFErrorExt(tif->tif_clientdata, module, + "Warning %s; Tag %s:\n Value %u of NumberOfInks is different from the number of inks %u.\n -> NumberOfInks value adapted to %u", + tif->tif_name, fip->field_name, td->td_numberofinks, ninksinstring, ninksinstring); + td->td_numberofinks = ninksinstring; + } + } else { + td->td_numberofinks = ninksinstring; + TIFFSetFieldBit(tif, FIELD_NUMBEROFINKS); + } + if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL)) + { + if (td->td_numberofinks != td->td_samplesperpixel) { + TIFFErrorExt(tif->tif_clientdata, module, + "Warning %s; Tag %s:\n Value %u of NumberOfInks is different from the SamplesPerPixel value %u", + tif->tif_name, fip->field_name, td->td_numberofinks, td->td_samplesperpixel); + } + } + } + } + break; + case TIFFTAG_NUMBEROFINKS: + v = (uint16)va_arg(ap, uint16_vap); + /* If InkNames already set also NumberOfInks is set accordingly and should be equal */ + if (TIFFFieldSet(tif, FIELD_INKNAMES)) + { + if (v != td->td_numberofinks) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error %s; Tag %s:\n It is not possible to set the value %u for NumberOfInks\n which is different from the number of inks in the InkNames tag (%u)", + tif->tif_name, fip->field_name, v, td->td_numberofinks); + /* Do not set / overwrite number of inks already set by InkNames case accordingly. */ + status = 0; + } + } else { + td->td_numberofinks = (uint16)v; + if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL)) + { + if (td->td_numberofinks != td->td_samplesperpixel) { + TIFFErrorExt(tif->tif_clientdata, module, + "Warning %s; Tag %s:\n Value %u of NumberOfInks is different from the SamplesPerPixel value %u", + tif->tif_name, fip->field_name, v, td->td_samplesperpixel); + } + } + } + break; + case TIFFTAG_PERSAMPLE: + v = (uint16) va_arg(ap, uint16_vap); + if( v == PERSAMPLE_MULTI ) + tif->tif_flags |= TIFF_PERSAMPLE; + else + tif->tif_flags &= ~TIFF_PERSAMPLE; + break; + default: { + TIFFTagValue *tv; + int tv_size, iCustom; - /* - * This can happen if multiple images are open with different - * codecs which have private tags. The global tag information - * table may then have tags that are valid for one file but not - * the other. If the client tries to set a tag that is not valid - * for the image's codec then we'll arrive here. This - * happens, for example, when tiffcp is used to convert between - * compression schemes and codec-specific tags are blindly copied. - * - * This also happens when a FIELD_IGNORE tag is written. - */ - if (fip->field_bit == FIELD_IGNORE) - { - TIFFErrorExtR( - tif, module, - "%s: Ignored %stag \"%s\" (not supported by libtiff)", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", - fip->field_name); - status = 0; - break; - } - if (fip->field_bit != FIELD_CUSTOM) - { - TIFFErrorExtR( - tif, module, - "%s: Invalid %stag \"%s\" (not supported by codec)", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", - fip->field_name); - status = 0; - break; - } + /* + * This can happen if multiple images are open with different + * codecs which have private tags. The global tag information + * table may then have tags that are valid for one file but not + * the other. If the client tries to set a tag that is not valid + * for the image's codec then we'll arrive here. This + * happens, for example, when tiffcp is used to convert between + * compression schemes and codec-specific tags are blindly copied. + */ + if(fip->field_bit != FIELD_CUSTOM) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Invalid %stag \"%s\" (not supported by codec)", + tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", + fip->field_name); + status = 0; + break; + } - /* - * Find the existing entry for this custom value. - */ - tv = NULL; - for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++) - { - if (td->td_customValues[iCustom].info->field_tag == tag) - { - tv = td->td_customValues + iCustom; - if (tv->value != NULL) - { - _TIFFfreeExt(tif, tv->value); - tv->value = NULL; - } - break; - } - } + /* + * Find the existing entry for this custom value. + */ + tv = NULL; + for (iCustom = 0; iCustom < td->td_customValueCount; iCustom++) { + if (td->td_customValues[iCustom].info->field_tag == tag) { + tv = td->td_customValues + iCustom; + if (tv->value != NULL) { + _TIFFfree(tv->value); + tv->value = NULL; + } + break; + } + } - /* - * Grow the custom list if the entry was not found. - */ - if (tv == NULL) - { - TIFFTagValue *new_customValues; + /* + * Grow the custom list if the entry was not found. + */ + if(tv == NULL) { + TIFFTagValue *new_customValues; - td->td_customValueCount++; - new_customValues = (TIFFTagValue *)_TIFFreallocExt( - tif, td->td_customValues, - sizeof(TIFFTagValue) * td->td_customValueCount); - if (!new_customValues) - { - TIFFErrorExtR(tif, module, - "%s: Failed to allocate space for list of " - "custom values", - tif->tif_name); - status = 0; - goto end; - } + td->td_customValueCount++; + new_customValues = (TIFFTagValue *) + _TIFFrealloc(td->td_customValues, + sizeof(TIFFTagValue) * td->td_customValueCount); + if (!new_customValues) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Failed to allocate space for list of custom values", + tif->tif_name); + status = 0; + goto end; + } - td->td_customValues = new_customValues; + td->td_customValues = new_customValues; - tv = td->td_customValues + (td->td_customValueCount - 1); - tv->info = fip; - tv->value = NULL; - tv->count = 0; - } + tv = td->td_customValues + (td->td_customValueCount - 1); + tv->info = fip; + tv->value = NULL; + tv->count = 0; + } - /* - * Set custom value ... save a copy of the custom tag value. - */ - /*--: Rational2Double: For Rationals evaluate "set_field_type" to - * determine internal storage size. */ - tv_size = TIFFFieldSetGetSize(fip); - if (tv_size == 0) - { - status = 0; - TIFFErrorExtR(tif, module, "%s: Bad field type %d for \"%s\"", - tif->tif_name, fip->field_type, fip->field_name); - goto end; - } + /* + * Set custom value ... save a copy of the custom tag value. + */ + tv_size = _TIFFDataSize(fip->field_type); + /*--: Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size. */ + if (fip->field_type == TIFF_RATIONAL || fip->field_type == TIFF_SRATIONAL) { + tv_size = _TIFFSetGetFieldSize(fip->set_field_type); + } + if (tv_size == 0) { + status = 0; + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Bad field type %d for \"%s\"", + tif->tif_name, fip->field_type, + fip->field_name); + goto end; + } - if (fip->field_type == TIFF_ASCII) - { - uint32_t ma; - const char *mb; - if (fip->field_passcount) - { - assert(fip->field_writecount == TIFF_VARIABLE2); - ma = (uint32_t)va_arg(ap, uint32_t); - mb = (const char *)va_arg(ap, const char *); - } - else - { - mb = (const char *)va_arg(ap, const char *); - size_t len = strlen(mb) + 1; - if (len >= 0x80000000U) - { - status = 0; - TIFFErrorExtR(tif, module, - "%s: Too long string value for \"%s\". " - "Maximum supported is 2147483647 bytes", - tif->tif_name, fip->field_name); - goto end; - } - ma = (uint32_t)len; - } - tv->count = ma; - setByteArray(tif, &tv->value, mb, ma, 1); - } - else - { - if (fip->field_passcount) - { - if (fip->field_writecount == TIFF_VARIABLE2) - tv->count = (uint32_t)va_arg(ap, uint32_t); - else - tv->count = (int)va_arg(ap, int); - } - else if (fip->field_writecount == TIFF_VARIABLE || - fip->field_writecount == TIFF_VARIABLE2) - tv->count = 1; - else if (fip->field_writecount == TIFF_SPP) - tv->count = td->td_samplesperpixel; - else - tv->count = fip->field_writecount; + if (fip->field_type == TIFF_ASCII) + { + uint32 ma; + char* mb; + if (fip->field_passcount) + { + assert(fip->field_writecount==TIFF_VARIABLE2); + ma=(uint32)va_arg(ap,uint32); + mb=(char*)va_arg(ap,char*); + } + else + { + mb=(char*)va_arg(ap,char*); + ma=(uint32)(strlen(mb)+1); + } + tv->count=ma; + setByteArray(&tv->value,mb,ma,1); + } + else + { + if (fip->field_passcount) { + if (fip->field_writecount == TIFF_VARIABLE2) + tv->count = (uint32) va_arg(ap, uint32); + else + tv->count = (int) va_arg(ap, int); + } else if (fip->field_writecount == TIFF_VARIABLE + || fip->field_writecount == TIFF_VARIABLE2) + tv->count = 1; + else if (fip->field_writecount == TIFF_SPP) + tv->count = td->td_samplesperpixel; + else + tv->count = fip->field_writecount; - if (tv->count == 0) - { - status = 0; - TIFFErrorExtR(tif, module, - "%s: Null count for \"%s\" (type " - "%d, writecount %d, passcount %d)", - tif->tif_name, fip->field_name, - fip->field_type, fip->field_writecount, - fip->field_passcount); - goto end; - } + if (tv->count == 0) { + status = 0; + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Null count for \"%s\" (type " + "%d, writecount %d, passcount %d)", + tif->tif_name, + fip->field_name, + fip->field_type, + fip->field_writecount, + fip->field_passcount); + goto end; + } - tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size, - "custom tag binary object"); - if (!tv->value) - { - status = 0; - goto end; - } + tv->value = _TIFFCheckMalloc(tif, tv->count, tv_size, + "custom tag binary object"); + if (!tv->value) { + status = 0; + goto end; + } - if (fip->field_tag == TIFFTAG_DOTRANGE && - strcmp(fip->field_name, "DotRange") == 0) - { - /* TODO: This is an evil exception and should not have been - 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_t v2[2]; - v2[0] = (uint16_t)va_arg(ap, int); - v2[1] = (uint16_t)va_arg(ap, int); - _TIFFmemcpy(tv->value, &v2, 4); - } + if (fip->field_tag == TIFFTAG_DOTRANGE + && strcmp(fip->field_name,"DotRange") == 0) { + /* TODO: This is an evil exception and should not have been + 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); + _TIFFmemcpy(tv->value, v2, 4); + } - else if (fip->field_passcount || - fip->field_writecount == TIFF_VARIABLE || - fip->field_writecount == TIFF_VARIABLE2 || - fip->field_writecount == TIFF_SPP || tv->count > 1) - { - /*--: Rational2Double: For Rationals tv_size is set above to - * 4 or 8 according to fip->set_field_type! */ - _TIFFmemcpy(tv->value, va_arg(ap, void *), - tv->count * tv_size); - /* Test here for too big values for LONG8, SLONG8 in - * ClassicTIFF and delete custom field from custom list */ - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - if (tv->info->field_type == TIFF_LONG8) - { - uint64_t *pui64 = (uint64_t *)tv->value; - for (int i = 0; i < tv->count; i++) - { - if (pui64[i] > 0xffffffffu) - { - TIFFErrorExtR( - tif, module, - "%s: Bad LONG8 value %" PRIu64 - " at %d. array position for \"%s\" tag " - "%d in ClassicTIFF. Tag won't be " - "written to file", - tif->tif_name, pui64[i], i, - fip->field_name, tag); - goto badvalueifd8long8; - } - } - } - else if (tv->info->field_type == TIFF_SLONG8) - { - int64_t *pi64 = (int64_t *)tv->value; - for (int i = 0; i < tv->count; i++) - { - if (pi64[i] > 2147483647 || - pi64[i] < (-2147483647 - 1)) - { - TIFFErrorExtR( - tif, module, - "%s: Bad SLONG8 value %" PRIi64 - " at %d. array position for \"%s\" tag " - "%d in ClassicTIFF. Tag won't be " - "written to file", - tif->tif_name, pi64[i], i, - fip->field_name, tag); - goto badvalueifd8long8; - } - } - } - } - } - else - { - char *val = (char *)tv->value; - assert(tv->count == 1); + else if (fip->field_passcount + || fip->field_writecount == TIFF_VARIABLE + || fip->field_writecount == TIFF_VARIABLE2 + || fip->field_writecount == TIFF_SPP + || tv->count > 1) { + /*--: Rational2Double: For Rationals tv_size is set above to 4 or 8 according to fip->set_field_type! */ + _TIFFmemcpy(tv->value, va_arg(ap, void *), + tv->count * tv_size); + } else { + char *val = (char *)tv->value; + assert( tv->count == 1 ); - switch (fip->field_type) - { - case TIFF_BYTE: - case TIFF_UNDEFINED: - { - uint8_t v2 = (uint8_t)va_arg(ap, int); - _TIFFmemcpy(val, &v2, tv_size); - } - break; - case TIFF_SBYTE: - { - int8_t v2 = (int8_t)va_arg(ap, int); - _TIFFmemcpy(val, &v2, tv_size); - } - break; - case TIFF_SHORT: - { - uint16_t v2 = (uint16_t)va_arg(ap, int); - _TIFFmemcpy(val, &v2, tv_size); - } - break; - case TIFF_SSHORT: - { - int16_t v2 = (int16_t)va_arg(ap, int); - _TIFFmemcpy(val, &v2, tv_size); - } - break; - case TIFF_LONG: - case TIFF_IFD: - { - uint32_t v2 = va_arg(ap, uint32_t); - _TIFFmemcpy(val, &v2, tv_size); - } - break; - case TIFF_SLONG: - { - int32_t v2 = va_arg(ap, int32_t); - _TIFFmemcpy(val, &v2, tv_size); - } - break; - case TIFF_LONG8: - case TIFF_IFD8: - { - uint64_t v2 = va_arg(ap, uint64_t); - _TIFFmemcpy(val, &v2, tv_size); - /* Test here for too big values for ClassicTIFF and - * delete custom field from custom list */ - if (!(tif->tif_flags & TIFF_BIGTIFF) && - (v2 > 0xffffffffu)) - { - TIFFErrorExtR( - tif, module, - "%s: Bad LONG8 or IFD8 value %" PRIu64 - " for \"%s\" tag %d in ClassicTIFF. Tag " - "won't be written to file", - tif->tif_name, v2, fip->field_name, tag); - goto badvalueifd8long8; - } - } - break; - case TIFF_SLONG8: - { - int64_t v2 = va_arg(ap, int64_t); - _TIFFmemcpy(val, &v2, tv_size); - /* Test here for too big values for ClassicTIFF and - * delete custom field from custom list */ - if (!(tif->tif_flags & TIFF_BIGTIFF) && - ((v2 > 2147483647) || (v2 < (-2147483647 - 1)))) - { - TIFFErrorExtR( - tif, module, - "%s: Bad SLONG8 value %" PRIi64 - " for \"%s\" tag %d in ClassicTIFF. Tag " - "won't be written to file", - tif->tif_name, v2, fip->field_name, tag); - goto badvalueifd8long8; - } - } - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - /*-- Rational2Double: For Rationals tv_size is set - * above to 4 or 8 according to fip->set_field_type! - */ - { - if (tv_size == 8) - { - double v2 = va_arg(ap, double); - _TIFFmemcpy(val, &v2, tv_size); - } - else - { - /*-- default should be tv_size == 4 */ - float v3 = (float)va_arg(ap, double); - _TIFFmemcpy(val, &v3, tv_size); - /*-- ToDo: After Testing, this should be - * removed and tv_size==4 should be set as - * default. */ - if (tv_size != 4) - { - TIFFErrorExtR( - tif, module, - "Rational2Double: .set_field_type " - "in not 4 but %d", - tv_size); - } - } - } - break; - case TIFF_FLOAT: - { - float v2 = - _TIFFClampDoubleToFloat(va_arg(ap, double)); - _TIFFmemcpy(val, &v2, tv_size); - } - break; - case TIFF_DOUBLE: - { - double v2 = va_arg(ap, double); - _TIFFmemcpy(val, &v2, tv_size); - } - break; - default: - _TIFFmemset(val, 0, tv_size); - status = 0; - break; - } - } - } - } - } - if (status) - { - const TIFFField *fip2 = TIFFFieldWithTag(tif, tag); - if (fip2) - TIFFSetFieldBit(tif, fip2->field_bit); - tif->tif_flags |= TIFF_DIRTYDIRECT; - } + switch (fip->field_type) { + case TIFF_BYTE: + case TIFF_UNDEFINED: + { + uint8 v2 = (uint8)va_arg(ap, int); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + case TIFF_SBYTE: + { + int8 v2 = (int8)va_arg(ap, int); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + case TIFF_SHORT: + { + uint16 v2 = (uint16)va_arg(ap, int); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + case TIFF_SSHORT: + { + int16 v2 = (int16)va_arg(ap, int); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + case TIFF_LONG: + case TIFF_IFD: + { + uint32 v2 = va_arg(ap, uint32); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + case TIFF_SLONG: + { + int32 v2 = va_arg(ap, int32); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + case TIFF_LONG8: + case TIFF_IFD8: + { + uint64 v2 = va_arg(ap, uint64); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + case TIFF_SLONG8: + { + int64 v2 = va_arg(ap, int64); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + /*-- Rational2Double: For Rationals tv_size is set above to 4 or 8 according to fip->set_field_type! */ + { + if (tv_size == 8) { + double v2 = va_arg(ap, double); + _TIFFmemcpy(val, &v2, tv_size); + } else { + /*-- default should be tv_size == 4 */ + float v3 = (float)va_arg(ap, double); + _TIFFmemcpy(val, &v3, tv_size); + /*-- ToDo: After Testing, this should be removed and tv_size==4 should be set as default. */ + if (tv_size != 4) { + TIFFErrorExt(0,"TIFFLib: _TIFFVSetField()", "Rational2Double: .set_field_type in not 4 but %d", tv_size); + } + } + } + break; + case TIFF_FLOAT: + { + float v2 = _TIFFClampDoubleToFloat(va_arg(ap, double)); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + case TIFF_DOUBLE: + { + double v2 = va_arg(ap, double); + _TIFFmemcpy(val, &v2, tv_size); + } + break; + default: + _TIFFmemset(val, 0, tv_size); + status = 0; + break; + } + } + } + } + } + if (status) { + const TIFFField* fip2=TIFFFieldWithTag(tif,tag); + if (fip2) + TIFFSetFieldBit(tif, fip2->field_bit); + tif->tif_flags |= TIFF_DIRTYDIRECT; + } end: - va_end(ap); - return (status); + va_end(ap); + return (status); badvalue: -{ - const TIFFField *fip2 = TIFFFieldWithTag(tif, tag); - TIFFErrorExtR(tif, module, "%s: Bad value %" PRIu32 " for \"%s\" tag", - tif->tif_name, v, fip2 ? fip2->field_name : "Unknown"); - va_end(ap); -} - return (0); + { + const TIFFField* fip2=TIFFFieldWithTag(tif,tag); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Bad value %u for \"%s\" tag", + tif->tif_name, v, + fip2 ? fip2->field_name : "Unknown"); + va_end(ap); + } + return (0); badvalue32: -{ - const TIFFField *fip2 = TIFFFieldWithTag(tif, tag); - TIFFErrorExtR(tif, module, "%s: Bad value %" PRIu32 " for \"%s\" tag", - tif->tif_name, v32, fip2 ? fip2->field_name : "Unknown"); - va_end(ap); -} - return (0); + { + const TIFFField* fip2=TIFFFieldWithTag(tif,tag); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Bad value %u for \"%s\" tag", + tif->tif_name, v32, + fip2 ? fip2->field_name : "Unknown"); + va_end(ap); + } + return (0); badvaluedouble: -{ - const TIFFField *fip2 = TIFFFieldWithTag(tif, tag); - TIFFErrorExtR(tif, module, "%s: Bad value %f for \"%s\" tag", tif->tif_name, - dblval, fip2 ? fip2->field_name : "Unknown"); - va_end(ap); -} + { + const TIFFField* fip2=TIFFFieldWithTag(tif,tag); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Bad value %f for \"%s\" tag", + tif->tif_name, dblval, + fip2 ? fip2->field_name : "Unknown"); + va_end(ap); + } return (0); -badvalueifd8long8: -{ - /* Error message issued already above. */ - TIFFTagValue *tv2 = NULL; - int iCustom2, iC2; - /* Find the existing entry for this custom value. */ - for (iCustom2 = 0; iCustom2 < td->td_customValueCount; iCustom2++) - { - if (td->td_customValues[iCustom2].info->field_tag == tag) - { - tv2 = td->td_customValues + (iCustom2); - break; - } - } - if (tv2 != NULL) - { - /* Remove custom field from custom list */ - if (tv2->value != NULL) - { - _TIFFfreeExt(tif, tv2->value); - tv2->value = NULL; - } - /* Shorten list and close gap in customValues list. - * Re-allocation of td_customValues not necessary here. */ - td->td_customValueCount--; - for (iC2 = iCustom2; iC2 < td->td_customValueCount; iC2++) - { - td->td_customValues[iC2] = td->td_customValues[iC2 + 1]; - } - } - else - { - assert(0); - } - va_end(ap); } - return (0); -} /*-- _TIFFVSetField() --*/ /* * Return 1/0 according to whether or not @@ -1110,30 +838,29 @@ badvalueifd8long8: * has commenced, unless its value has no effect * on the format of the data that is written. */ -static int OkToChangeTag(TIFF *tif, uint32_t tag) +static int +OkToChangeTag(TIFF* tif, uint32 tag) { - const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); - if (!fip) - { /* unknown tag */ - TIFFErrorExtR(tif, "TIFFSetField", "%s: Unknown %stag %" PRIu32, - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); - return (0); - } - if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) && - !fip->field_oktochange) - { - /* - * Consult info table to see if tag can be changed - * after we've started writing. We only allow changes - * to those tags that don't/shouldn't affect the - * compression and/or format of the data. - */ - TIFFErrorExtR(tif, "TIFFSetField", - "%s: Cannot modify tag \"%s\" while writing", - tif->tif_name, fip->field_name); - return (0); - } - return (1); + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + if (!fip) { /* unknown tag */ + TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u", + tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag); + return (0); + } + if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) && + !fip->field_oktochange) { + /* + * Consult info table to see if tag can be changed + * after we've started writing. We only allow changes + * to those tags that don't/shouldn't affect the + * compression and/or format of the data. + */ + TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", + "%s: Cannot modify tag \"%s\" while writing", + tif->tif_name, fip->field_name); + return (0); + } + return (1); } /* @@ -1143,54 +870,54 @@ static int OkToChangeTag(TIFF *tif, uint32_t tag) * when/if the directory structure is * updated. */ -int TIFFSetField(TIFF *tif, uint32_t tag, ...) +int +TIFFSetField(TIFF* tif, uint32 tag, ...) { - va_list ap; - int status; + va_list ap; + int status; - va_start(ap, tag); - status = TIFFVSetField(tif, tag, ap); - va_end(ap); - return (status); + va_start(ap, tag); + status = TIFFVSetField(tif, tag, ap); + va_end(ap); + return (status); } /* * Clear the contents of the field in the internal structure. */ -int TIFFUnsetField(TIFF *tif, uint32_t tag) +int +TIFFUnsetField(TIFF* tif, uint32 tag) { - const TIFFField *fip = TIFFFieldWithTag(tif, tag); - TIFFDirectory *td = &tif->tif_dir; + const TIFFField *fip = TIFFFieldWithTag(tif, tag); + TIFFDirectory* td = &tif->tif_dir; - if (!fip) + if( !fip ) return 0; - if (fip->field_bit != FIELD_CUSTOM) + if( fip->field_bit != FIELD_CUSTOM ) TIFFClrFieldBit(tif, fip->field_bit); else { TIFFTagValue *tv = NULL; int i; - for (i = 0; i < td->td_customValueCount; i++) - { - + for (i = 0; i < td->td_customValueCount; i++) { + tv = td->td_customValues + i; - if (tv->info->field_tag == tag) + if( tv->info->field_tag == tag ) break; } - if (i < td->td_customValueCount) + if( i < td->td_customValueCount ) { - _TIFFfreeExt(tif, tv->value); - for (; i < td->td_customValueCount - 1; i++) - { - td->td_customValues[i] = td->td_customValues[i + 1]; + _TIFFfree(tv->value); + for( ; i < td->td_customValueCount-1; i++) { + td->td_customValues[i] = td->td_customValues[i+1]; } td->td_customValueCount--; } } - + tif->tif_flags |= TIFF_DIRTYDIRECT; return (1); @@ -1202,392 +929,374 @@ int TIFFUnsetField(TIFF *tif, uint32_t tag) * for building higher-level interfaces on * top of the library. */ -int TIFFVSetField(TIFF *tif, uint32_t tag, va_list ap) +int +TIFFVSetField(TIFF* tif, uint32 tag, va_list ap) { - return OkToChangeTag(tif, tag) - ? (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) - : 0; + return OkToChangeTag(tif, tag) ? + (*tif->tif_tagmethods.vsetfield)(tif, tag, ap) : 0; } -static int _TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap) +static int +_TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) { - TIFFDirectory *td = &tif->tif_dir; - int ret_val = 1; - 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; + TIFFDirectory* td = &tif->tif_dir; + int ret_val = 1; + uint32 standard_tag = tag; + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + if( fip == NULL ) /* cannot happen since TIFFGetField() already checks it */ + return 0; - /* - * We want to force the custom code to be used for custom - * fields even if the tag happens to match a well known - * one - important for reinterpreted handling of standard - * tag values in custom directories (i.e. EXIF) - */ - if (fip->field_bit == FIELD_CUSTOM) - { - standard_tag = 0; - } + /* + * We want to force the custom code to be used for custom + * fields even if the tag happens to match a well known + * one - important for reinterpreted handling of standard + * tag values in custom directories (i.e. EXIF) + */ + if (fip->field_bit == FIELD_CUSTOM) { + standard_tag = 0; + } + + switch (standard_tag) { + case TIFFTAG_SUBFILETYPE: + *va_arg(ap, uint32*) = td->td_subfiletype; + break; + case TIFFTAG_IMAGEWIDTH: + *va_arg(ap, uint32*) = td->td_imagewidth; + break; + case TIFFTAG_IMAGELENGTH: + *va_arg(ap, uint32*) = td->td_imagelength; + break; + case TIFFTAG_BITSPERSAMPLE: + *va_arg(ap, uint16*) = td->td_bitspersample; + break; + case TIFFTAG_COMPRESSION: + *va_arg(ap, uint16*) = td->td_compression; + break; + case TIFFTAG_PHOTOMETRIC: + *va_arg(ap, uint16*) = td->td_photometric; + break; + case TIFFTAG_THRESHHOLDING: + *va_arg(ap, uint16*) = td->td_threshholding; + break; + case TIFFTAG_FILLORDER: + *va_arg(ap, uint16*) = td->td_fillorder; + break; + case TIFFTAG_ORIENTATION: + *va_arg(ap, uint16*) = td->td_orientation; + break; + case TIFFTAG_SAMPLESPERPIXEL: + *va_arg(ap, uint16*) = td->td_samplesperpixel; + break; + case TIFFTAG_ROWSPERSTRIP: + *va_arg(ap, uint32*) = td->td_rowsperstrip; + break; + case TIFFTAG_MINSAMPLEVALUE: + *va_arg(ap, uint16*) = td->td_minsamplevalue; + break; + case TIFFTAG_MAXSAMPLEVALUE: + *va_arg(ap, uint16*) = td->td_maxsamplevalue; + break; + case TIFFTAG_SMINSAMPLEVALUE: + if (tif->tif_flags & TIFF_PERSAMPLE) + *va_arg(ap, double**) = td->td_sminsamplevalue; + else + { + /* libtiff historically treats this as a single value. */ + uint16 i; + double v = td->td_sminsamplevalue[0]; + for (i=1; i < td->td_samplesperpixel; ++i) + if( td->td_sminsamplevalue[i] < v ) + v = td->td_sminsamplevalue[i]; + *va_arg(ap, double*) = v; + } + break; + case TIFFTAG_SMAXSAMPLEVALUE: + if (tif->tif_flags & TIFF_PERSAMPLE) + *va_arg(ap, double**) = td->td_smaxsamplevalue; + else + { + /* libtiff historically treats this as a single value. */ + uint16 i; + double v = td->td_smaxsamplevalue[0]; + for (i=1; i < td->td_samplesperpixel; ++i) + if( td->td_smaxsamplevalue[i] > v ) + v = td->td_smaxsamplevalue[i]; + *va_arg(ap, double*) = v; + } + break; + case TIFFTAG_XRESOLUTION: + *va_arg(ap, float*) = td->td_xresolution; + break; + case TIFFTAG_YRESOLUTION: + *va_arg(ap, float*) = td->td_yresolution; + break; + case TIFFTAG_PLANARCONFIG: + *va_arg(ap, uint16*) = td->td_planarconfig; + break; + case TIFFTAG_XPOSITION: + *va_arg(ap, float*) = td->td_xposition; + break; + case TIFFTAG_YPOSITION: + *va_arg(ap, float*) = td->td_yposition; + break; + case TIFFTAG_RESOLUTIONUNIT: + *va_arg(ap, uint16*) = td->td_resolutionunit; + break; + case TIFFTAG_PAGENUMBER: + *va_arg(ap, uint16*) = td->td_pagenumber[0]; + *va_arg(ap, uint16*) = td->td_pagenumber[1]; + break; + case TIFFTAG_HALFTONEHINTS: + *va_arg(ap, uint16*) = td->td_halftonehints[0]; + *va_arg(ap, uint16*) = 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]; + break; + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_TILEOFFSETS: + _TIFFFillStriles( tif ); + *va_arg(ap, const uint64**) = td->td_stripoffset_p; + break; + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEBYTECOUNTS: + _TIFFFillStriles( tif ); + *va_arg(ap, const uint64**) = td->td_stripbytecount_p; + break; + case TIFFTAG_MATTEING: + *va_arg(ap, uint16*) = + (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; + break; + case TIFFTAG_TILEWIDTH: + *va_arg(ap, uint32*) = td->td_tilewidth; + break; + case TIFFTAG_TILELENGTH: + *va_arg(ap, uint32*) = td->td_tilelength; + break; + case TIFFTAG_TILEDEPTH: + *va_arg(ap, uint32*) = td->td_tiledepth; + break; + case TIFFTAG_DATATYPE: + switch (td->td_sampleformat) { + case SAMPLEFORMAT_UINT: + *va_arg(ap, uint16*) = DATATYPE_UINT; + break; + case SAMPLEFORMAT_INT: + *va_arg(ap, uint16*) = DATATYPE_INT; + break; + case SAMPLEFORMAT_IEEEFP: + *va_arg(ap, uint16*) = DATATYPE_IEEEFP; + break; + case SAMPLEFORMAT_VOID: + *va_arg(ap, uint16*) = DATATYPE_VOID; + break; + } + break; + case TIFFTAG_SAMPLEFORMAT: + *va_arg(ap, uint16*) = td->td_sampleformat; + break; + case TIFFTAG_IMAGEDEPTH: + *va_arg(ap, uint32*) = td->td_imagedepth; + break; + case TIFFTAG_SUBIFD: + *va_arg(ap, uint16*) = td->td_nsubifd; + *va_arg(ap, const uint64**) = td->td_subifd; + break; + case TIFFTAG_YCBCRPOSITIONING: + *va_arg(ap, uint16*) = td->td_ycbcrpositioning; + break; + case TIFFTAG_YCBCRSUBSAMPLING: + *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16*) = td->td_ycbcrsubsampling[1]; + break; + case TIFFTAG_TRANSFERFUNCTION: + *va_arg(ap, const uint16**) = 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]; + } else { + *va_arg(ap, const uint16**) = NULL; + *va_arg(ap, const uint16**) = NULL; + } + break; + case TIFFTAG_REFERENCEBLACKWHITE: + *va_arg(ap, const float**) = td->td_refblackwhite; + break; + case TIFFTAG_INKNAMES: + *va_arg(ap, const char**) = td->td_inknames; + break; + case TIFFTAG_NUMBEROFINKS: + *va_arg(ap, uint16 *) = td->td_numberofinks; + break; + default: + { + int i; - switch (standard_tag) - { - case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32_t *) = td->td_subfiletype; - break; - case TIFFTAG_IMAGEWIDTH: - *va_arg(ap, uint32_t *) = td->td_imagewidth; - break; - case TIFFTAG_IMAGELENGTH: - *va_arg(ap, uint32_t *) = td->td_imagelength; - break; - case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16_t *) = td->td_bitspersample; - break; - case TIFFTAG_COMPRESSION: - *va_arg(ap, uint16_t *) = td->td_compression; - break; - case TIFFTAG_PHOTOMETRIC: - *va_arg(ap, uint16_t *) = td->td_photometric; - break; - case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16_t *) = td->td_threshholding; - break; - case TIFFTAG_FILLORDER: - *va_arg(ap, uint16_t *) = td->td_fillorder; - break; - case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16_t *) = td->td_orientation; - break; - case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16_t *) = td->td_samplesperpixel; - break; - case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32_t *) = td->td_rowsperstrip; - break; - case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16_t *) = td->td_minsamplevalue; - break; - case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16_t *) = td->td_maxsamplevalue; - break; - case TIFFTAG_SMINSAMPLEVALUE: - if (tif->tif_flags & TIFF_PERSAMPLE) - *va_arg(ap, double **) = td->td_sminsamplevalue; - else - { - /* libtiff historically treats this as a single value. */ - uint16_t i; - double v = td->td_sminsamplevalue[0]; - for (i = 1; i < td->td_samplesperpixel; ++i) - if (td->td_sminsamplevalue[i] < v) - v = td->td_sminsamplevalue[i]; - *va_arg(ap, double *) = v; - } - break; - case TIFFTAG_SMAXSAMPLEVALUE: - if (tif->tif_flags & TIFF_PERSAMPLE) - *va_arg(ap, double **) = td->td_smaxsamplevalue; - else - { - /* libtiff historically treats this as a single value. */ - uint16_t i; - double v = td->td_smaxsamplevalue[0]; - for (i = 1; i < td->td_samplesperpixel; ++i) - if (td->td_smaxsamplevalue[i] > v) - v = td->td_smaxsamplevalue[i]; - *va_arg(ap, double *) = v; - } - break; - case TIFFTAG_XRESOLUTION: - *va_arg(ap, float *) = td->td_xresolution; - break; - case TIFFTAG_YRESOLUTION: - *va_arg(ap, float *) = td->td_yresolution; - break; - case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16_t *) = td->td_planarconfig; - break; - case TIFFTAG_XPOSITION: - *va_arg(ap, float *) = td->td_xposition; - break; - case TIFFTAG_YPOSITION: - *va_arg(ap, float *) = td->td_yposition; - break; - case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16_t *) = td->td_resolutionunit; - break; - case TIFFTAG_PAGENUMBER: - *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_t *) = td->td_halftonehints[0]; - *va_arg(ap, uint16_t *) = td->td_halftonehints[1]; - break; - case TIFFTAG_COLORMAP: - *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_t **) = td->td_stripoffset_p; - if (td->td_stripoffset_p == NULL) - ret_val = 0; - break; - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEBYTECOUNTS: - _TIFFFillStriles(tif); - *va_arg(ap, const uint64_t **) = td->td_stripbytecount_p; - if (td->td_stripbytecount_p == NULL) - ret_val = 0; - break; - case TIFFTAG_MATTEING: - *va_arg(ap, uint16_t *) = - (td->td_extrasamples == 1 && - td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); - break; - case TIFFTAG_EXTRASAMPLES: - *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_t *) = td->td_tilewidth; - break; - case TIFFTAG_TILELENGTH: - *va_arg(ap, uint32_t *) = td->td_tilelength; - break; - case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32_t *) = td->td_tiledepth; - break; - case TIFFTAG_DATATYPE: - switch (td->td_sampleformat) - { - case SAMPLEFORMAT_UINT: - *va_arg(ap, uint16_t *) = DATATYPE_UINT; - break; - case SAMPLEFORMAT_INT: - *va_arg(ap, uint16_t *) = DATATYPE_INT; - break; - case SAMPLEFORMAT_IEEEFP: - *va_arg(ap, uint16_t *) = DATATYPE_IEEEFP; - break; - case SAMPLEFORMAT_VOID: - *va_arg(ap, uint16_t *) = DATATYPE_VOID; - break; - } - break; - case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16_t *) = td->td_sampleformat; - break; - case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32_t *) = td->td_imagedepth; - break; - case TIFFTAG_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_t *) = td->td_ycbcrpositioning; - break; - case TIFFTAG_YCBCRSUBSAMPLING: - *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_t **) = td->td_transferfunction[0]; - if (td->td_samplesperpixel - td->td_extrasamples > 1) - { - *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_t **) = NULL; - *va_arg(ap, const uint16_t **) = NULL; - } - break; - case TIFFTAG_REFERENCEBLACKWHITE: - *va_arg(ap, const float **) = td->td_refblackwhite; - break; - case TIFFTAG_INKNAMES: - *va_arg(ap, const char **) = td->td_inknames; - break; - case TIFFTAG_NUMBEROFINKS: - *va_arg(ap, uint16_t *) = td->td_numberofinks; - break; - default: - { - int i; + /* + * This can happen if multiple images are open + * with different codecs which have private + * tags. The global tag information table may + * then have tags that are valid for one file + * but not the other. If the client tries to + * get a tag that is not valid for the image's + * codec then we'll arrive here. + */ + if( fip->field_bit != FIELD_CUSTOM ) + { + TIFFErrorExt(tif->tif_clientdata, "_TIFFVGetField", + "%s: Invalid %stag \"%s\" " + "(not supported by codec)", + tif->tif_name, + isPseudoTag(tag) ? "pseudo-" : "", + fip->field_name); + ret_val = 0; + break; + } - /* - * This can happen if multiple images are open - * with different codecs which have private - * tags. The global tag information table may - * then have tags that are valid for one file - * but not the other. If the client tries to - * get a tag that is not valid for the image's - * codec then we'll arrive here. - */ - if (fip->field_bit != FIELD_CUSTOM) - { - TIFFErrorExtR(tif, "_TIFFVGetField", - "%s: Invalid %stag \"%s\" " - "(not supported by codec)", - tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", - fip->field_name); - ret_val = 0; - break; - } + /* + * Do we have a custom value? + */ + ret_val = 0; + for (i = 0; i < td->td_customValueCount; i++) { + TIFFTagValue *tv = td->td_customValues + i; - /* - * Do we have a custom value? - */ - ret_val = 0; - for (i = 0; i < td->td_customValueCount; i++) - { - TIFFTagValue *tv = td->td_customValues + i; + if (tv->info->field_tag != tag) + continue; - if (tv->info->field_tag != tag) - continue; - - if (fip->field_passcount) - { - if (fip->field_readcount == TIFF_VARIABLE2) - *va_arg(ap, uint32_t *) = (uint32_t)tv->count; - else /* Assume TIFF_VARIABLE */ - *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 && - strcmp(fip->field_name, "DotRange") == 0) - { - /* TODO: This is an evil exception and should not have been - 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_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 || - fip->field_readcount == TIFF_VARIABLE || - fip->field_readcount == TIFF_VARIABLE2 || - fip->field_readcount == TIFF_SPP || tv->count > 1) - { - *va_arg(ap, void **) = tv->value; - ret_val = 1; - } - else - { - char *val = (char *)tv->value; - assert(tv->count == 1); - switch (fip->field_type) - { - case TIFF_BYTE: - case TIFF_UNDEFINED: - *va_arg(ap, uint8_t *) = *(uint8_t *)val; - ret_val = 1; - break; - case TIFF_SBYTE: - *va_arg(ap, int8_t *) = *(int8_t *)val; - ret_val = 1; - break; - case TIFF_SHORT: - *va_arg(ap, uint16_t *) = *(uint16_t *)val; - ret_val = 1; - break; - case TIFF_SSHORT: - *va_arg(ap, int16_t *) = *(int16_t *)val; - ret_val = 1; - break; - case TIFF_LONG: - case TIFF_IFD: - *va_arg(ap, uint32_t *) = *(uint32_t *)val; - ret_val = 1; - break; - case TIFF_SLONG: - *va_arg(ap, int32_t *) = *(int32_t *)val; - ret_val = 1; - break; - case TIFF_LONG8: - case TIFF_IFD8: - *va_arg(ap, uint64_t *) = *(uint64_t *)val; - ret_val = 1; - break; - case TIFF_SLONG8: - *va_arg(ap, int64_t *) = *(int64_t *)val; - ret_val = 1; - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - { - /*-- Rational2Double: For Rationals evaluate - * "set_field_type" to determine internal - * storage size and return value size. */ - int tv_size = TIFFFieldSetGetSize(fip); - if (tv_size == 8) - { - *va_arg(ap, double *) = *(double *)val; - ret_val = 1; - } - else - { - /*-- default should be tv_size == 4 */ - *va_arg(ap, float *) = *(float *)val; - ret_val = 1; - /*-- ToDo: After Testing, this should be - * removed and tv_size==4 should be set as - * default. */ - if (tv_size != 4) - { - TIFFErrorExtR( - tif, "_TIFFVGetField", - "Rational2Double: .set_field_type " - "in not 4 but %d", - tv_size); - } - } - } - break; - case TIFF_FLOAT: - *va_arg(ap, float *) = *(float *)val; - ret_val = 1; - break; - case TIFF_DOUBLE: - *va_arg(ap, double *) = *(double *)val; - ret_val = 1; - break; - default: - ret_val = 0; - break; - } - } - } - break; - } - } - } - return (ret_val); + if (fip->field_passcount) { + if (fip->field_readcount == TIFF_VARIABLE2) + *va_arg(ap, uint32*) = (uint32)tv->count; + else /* Assume TIFF_VARIABLE */ + *va_arg(ap, uint16*) = (uint16)tv->count; + *va_arg(ap, const void **) = tv->value; + ret_val = 1; + } else if (fip->field_tag == TIFFTAG_DOTRANGE + && strcmp(fip->field_name,"DotRange") == 0) { + /* TODO: This is an evil exception and should not have been + 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]; + ret_val = 1; + } else { + if (fip->field_type == TIFF_ASCII + || fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2 + || fip->field_readcount == TIFF_SPP + || tv->count > 1) { + *va_arg(ap, void **) = tv->value; + ret_val = 1; + } else { + char *val = (char *)tv->value; + assert( tv->count == 1 ); + switch (fip->field_type) { + case TIFF_BYTE: + case TIFF_UNDEFINED: + *va_arg(ap, uint8*) = + *(uint8 *)val; + ret_val = 1; + break; + case TIFF_SBYTE: + *va_arg(ap, int8*) = + *(int8 *)val; + ret_val = 1; + break; + case TIFF_SHORT: + *va_arg(ap, uint16*) = + *(uint16 *)val; + ret_val = 1; + break; + case TIFF_SSHORT: + *va_arg(ap, int16*) = + *(int16 *)val; + ret_val = 1; + break; + case TIFF_LONG: + case TIFF_IFD: + *va_arg(ap, uint32*) = + *(uint32 *)val; + ret_val = 1; + break; + case TIFF_SLONG: + *va_arg(ap, int32*) = + *(int32 *)val; + ret_val = 1; + break; + case TIFF_LONG8: + case TIFF_IFD8: + *va_arg(ap, uint64*) = + *(uint64 *)val; + ret_val = 1; + break; + case TIFF_SLONG8: + *va_arg(ap, int64*) = + *(int64 *)val; + ret_val = 1; + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + { + /*-- Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size and return value size. */ + int tv_size = _TIFFSetGetFieldSize(fip->set_field_type); + if (tv_size == 8) { + *va_arg(ap, double*) = *(double *)val; + ret_val = 1; + } else { + /*-- default should be tv_size == 4 */ + *va_arg(ap, float*) = *(float *)val; + ret_val = 1; + /*-- ToDo: After Testing, this should be removed and tv_size==4 should be set as default. */ + if (tv_size != 4) { + TIFFErrorExt(0,"TIFFLib: _TIFFVGetField()", "Rational2Double: .set_field_type in not 4 but %d", tv_size); + } + } + } + break; + case TIFF_FLOAT: + *va_arg(ap, float*) = + *(float *)val; + ret_val = 1; + break; + case TIFF_DOUBLE: + *va_arg(ap, double*) = + *(double *)val; + ret_val = 1; + break; + default: + ret_val = 0; + break; + } + } + } + break; + } + } + } + return(ret_val); } /* * Return the value of a field in the * internal directory structure. */ -int TIFFGetField(TIFF *tif, uint32_t tag, ...) +int +TIFFGetField(TIFF* tif, uint32 tag, ...) { - int status; - va_list ap; + int status; + va_list ap; - va_start(ap, tag); - status = TIFFVGetField(tif, tag, ap); - va_end(ap); - return (status); + va_start(ap, tag); + status = TIFFVGetField(tif, tag, ap); + va_end(ap); + return (status); } /* @@ -1596,75 +1305,74 @@ int TIFFGetField(TIFF *tif, uint32_t tag, ...) * for building higher-level interfaces on * top of the library. */ -int TIFFVGetField(TIFF *tif, uint32_t tag, va_list ap) +int +TIFFVGetField(TIFF* tif, uint32 tag, va_list ap) { - const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); - return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) - ? (*tif->tif_tagmethods.vgetfield)(tif, tag, ap) - : 0); + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + return (fip && (isPseudoTag(tag) || TIFFFieldSet(tif, fip->field_bit)) ? + (*tif->tif_tagmethods.vgetfield)(tif, tag, ap) : 0); } -#define CleanupField(member) \ - { \ - if (td->member) \ - { \ - _TIFFfreeExt(tif, td->member); \ - td->member = 0; \ - } \ - } +#define CleanupField(member) { \ + if (td->member) { \ + _TIFFfree(td->member); \ + td->member = 0; \ + } \ +} /* * Release storage associated with a directory. */ -void TIFFFreeDirectory(TIFF *tif) +void +TIFFFreeDirectory(TIFF* tif) { - TIFFDirectory *td = &tif->tif_dir; - int i; + TIFFDirectory *td = &tif->tif_dir; + int i; - _TIFFmemset(td->td_fieldsset, 0, sizeof(td->td_fieldsset)); - CleanupField(td_sminsamplevalue); - CleanupField(td_smaxsamplevalue); - CleanupField(td_colormap[0]); - CleanupField(td_colormap[1]); - CleanupField(td_colormap[2]); - CleanupField(td_sampleinfo); - CleanupField(td_subifd); - CleanupField(td_inknames); - CleanupField(td_refblackwhite); - CleanupField(td_transferfunction[0]); - CleanupField(td_transferfunction[1]); - CleanupField(td_transferfunction[2]); - CleanupField(td_stripoffset_p); - CleanupField(td_stripbytecount_p); - td->td_stripoffsetbyteallocsize = 0; - TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING); - TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING); + _TIFFmemset(td->td_fieldsset, 0, sizeof(td->td_fieldsset)); + CleanupField(td_sminsamplevalue); + CleanupField(td_smaxsamplevalue); + CleanupField(td_colormap[0]); + CleanupField(td_colormap[1]); + CleanupField(td_colormap[2]); + CleanupField(td_sampleinfo); + CleanupField(td_subifd); + CleanupField(td_inknames); + CleanupField(td_refblackwhite); + CleanupField(td_transferfunction[0]); + CleanupField(td_transferfunction[1]); + CleanupField(td_transferfunction[2]); + CleanupField(td_stripoffset_p); + CleanupField(td_stripbytecount_p); + td->td_stripoffsetbyteallocsize = 0; + TIFFClrFieldBit(tif, FIELD_YCBCRSUBSAMPLING); + TIFFClrFieldBit(tif, FIELD_YCBCRPOSITIONING); - /* Cleanup custom tag values */ - for (i = 0; i < td->td_customValueCount; i++) - { - if (td->td_customValues[i].value) - _TIFFfreeExt(tif, td->td_customValues[i].value); - } + /* Cleanup custom tag values */ + for( i = 0; i < td->td_customValueCount; i++ ) { + if (td->td_customValues[i].value) + _TIFFfree(td->td_customValues[i].value); + } - td->td_customValueCount = 0; - CleanupField(td_customValues); + td->td_customValueCount = 0; + CleanupField(td_customValues); - _TIFFmemset(&(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry)); - _TIFFmemset(&(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry)); + _TIFFmemset( &(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry)); + _TIFFmemset( &(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry)); } #undef CleanupField /* * Client Tag extension support (from Niles Ritter). */ -static TIFFExtendProc _TIFFextender = (TIFFExtendProc)NULL; +static TIFFExtendProc _TIFFextender = (TIFFExtendProc) NULL; -TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc extender) +TIFFExtendProc +TIFFSetTagExtender(TIFFExtendProc extender) { - TIFFExtendProc prev = _TIFFextender; - _TIFFextender = extender; - return (prev); + TIFFExtendProc prev = _TIFFextender; + _TIFFextender = extender; + return (prev); } /* @@ -1674,433 +1382,333 @@ TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc extender) * The newly created directory will not exist on the file till * TIFFWriteDirectory(), TIFFFlush() or TIFFClose() is called. */ -int TIFFCreateDirectory(TIFF *tif) +int +TIFFCreateDirectory(TIFF* tif) { - TIFFDefaultDirectory(tif); - tif->tif_diroff = 0; - tif->tif_nextdiroff = 0; - tif->tif_curoff = 0; - tif->tif_row = (uint32_t)-1; - tif->tif_curstrip = (uint32_t)-1; + TIFFDefaultDirectory(tif); + tif->tif_diroff = 0; + tif->tif_nextdiroff = 0; + tif->tif_curoff = 0; + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (uint32) -1; - return 0; + return 0; } -int TIFFCreateCustomDirectory(TIFF *tif, const TIFFFieldArray *infoarray) +int +TIFFCreateCustomDirectory(TIFF* tif, const TIFFFieldArray* infoarray) { - TIFFDefaultDirectory(tif); + TIFFDefaultDirectory(tif); - /* - * Reset the field definitions to match the application provided list. - * Hopefully TIFFDefaultDirectory() won't have done anything irreversible - * based on it's assumption this is an image directory. - */ - _TIFFSetupFields(tif, infoarray); + /* + * Reset the field definitions to match the application provided list. + * Hopefully TIFFDefaultDirectory() won't have done anything irreversable + * based on it's assumption this is an image directory. + */ + _TIFFSetupFields(tif, infoarray); - tif->tif_diroff = 0; - tif->tif_nextdiroff = 0; - tif->tif_curoff = 0; - tif->tif_row = (uint32_t)-1; - tif->tif_curstrip = (uint32_t)-1; - /* invalidate directory index */ - tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER; - /* invalidate IFD loop lists */ - _TIFFCleanupIFDOffsetAndNumberMaps(tif); - /* To be able to return from SubIFD or custom-IFD to main-IFD */ - tif->tif_setdirectory_force_absolute = TRUE; + tif->tif_diroff = 0; + tif->tif_nextdiroff = 0; + tif->tif_curoff = 0; + tif->tif_row = (uint32) -1; + tif->tif_curstrip = (uint32) -1; - return 0; + return 0; } -int TIFFCreateEXIFDirectory(TIFF *tif) +int +TIFFCreateEXIFDirectory(TIFF* tif) { - const TIFFFieldArray *exifFieldArray; - exifFieldArray = _TIFFGetExifFields(); - return TIFFCreateCustomDirectory(tif, exifFieldArray); + const TIFFFieldArray* exifFieldArray; + exifFieldArray = _TIFFGetExifFields(); + return TIFFCreateCustomDirectory(tif, exifFieldArray); } /* - * Creates the EXIF GPS custom directory + * Creates the EXIF GPS custom directory */ -int TIFFCreateGPSDirectory(TIFF *tif) +int +TIFFCreateGPSDirectory(TIFF* tif) { - const TIFFFieldArray *gpsFieldArray; - gpsFieldArray = _TIFFGetGpsFields(); - return TIFFCreateCustomDirectory(tif, gpsFieldArray); + const TIFFFieldArray* gpsFieldArray; + gpsFieldArray = _TIFFGetGpsFields(); + return TIFFCreateCustomDirectory(tif, gpsFieldArray); } /* * Setup a default directory structure. */ -int TIFFDefaultDirectory(TIFF *tif) +int +TIFFDefaultDirectory(TIFF* tif) { - register TIFFDirectory *td = &tif->tif_dir; - const TIFFFieldArray *tiffFieldArray; + register TIFFDirectory* td = &tif->tif_dir; + const TIFFFieldArray* tiffFieldArray; - tiffFieldArray = _TIFFGetFields(); - _TIFFSetupFields(tif, tiffFieldArray); + tiffFieldArray = _TIFFGetFields(); + _TIFFSetupFields(tif, tiffFieldArray); - _TIFFmemset(td, 0, sizeof(*td)); - td->td_fillorder = FILLORDER_MSB2LSB; - td->td_bitspersample = 1; - td->td_threshholding = THRESHHOLD_BILEVEL; - td->td_orientation = ORIENTATION_TOPLEFT; - td->td_samplesperpixel = 1; - td->td_rowsperstrip = (uint32_t)-1; - td->td_tilewidth = 0; - td->td_tilelength = 0; - td->td_tiledepth = 1; + _TIFFmemset(td, 0, sizeof (*td)); + td->td_fillorder = FILLORDER_MSB2LSB; + td->td_bitspersample = 1; + td->td_threshholding = THRESHHOLD_BILEVEL; + td->td_orientation = ORIENTATION_TOPLEFT; + td->td_samplesperpixel = 1; + td->td_rowsperstrip = (uint32) -1; + td->td_tilewidth = 0; + td->td_tilelength = 0; + td->td_tiledepth = 1; #ifdef STRIPBYTECOUNTSORTED_UNUSED - td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */ + td->td_stripbytecountsorted = 1; /* Our own arrays always sorted. */ #endif - td->td_resolutionunit = RESUNIT_INCH; - td->td_sampleformat = SAMPLEFORMAT_UINT; - td->td_imagedepth = 1; - td->td_ycbcrsubsampling[0] = 2; - td->td_ycbcrsubsampling[1] = 2; - td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; - tif->tif_postdecode = _TIFFNoPostDecode; - tif->tif_foundfield = NULL; - tif->tif_tagmethods.vsetfield = _TIFFVSetField; - tif->tif_tagmethods.vgetfield = _TIFFVGetField; - tif->tif_tagmethods.printdir = NULL; - /* additional default values */ - td->td_planarconfig = PLANARCONFIG_CONTIG; - td->td_compression = COMPRESSION_NONE; - td->td_subfiletype = 0; - td->td_minsamplevalue = 0; - /* td_bitspersample=1 is always set in TIFFDefaultDirectory(). - * Therefore, td_maxsamplevalue has to be re-calculated in - * TIFFGetFieldDefaulted(). */ - td->td_maxsamplevalue = 1; /* Default for td_bitspersample=1 */ - td->td_extrasamples = 0; - td->td_sampleinfo = NULL; + td->td_resolutionunit = RESUNIT_INCH; + td->td_sampleformat = SAMPLEFORMAT_UINT; + td->td_imagedepth = 1; + td->td_ycbcrsubsampling[0] = 2; + td->td_ycbcrsubsampling[1] = 2; + td->td_ycbcrpositioning = YCBCRPOSITION_CENTERED; + tif->tif_postdecode = _TIFFNoPostDecode; + tif->tif_foundfield = NULL; + tif->tif_tagmethods.vsetfield = _TIFFVSetField; + tif->tif_tagmethods.vgetfield = _TIFFVGetField; + tif->tif_tagmethods.printdir = NULL; + /* + * Give client code a chance to install their own + * tag extensions & methods, prior to compression overloads, + * but do some prior cleanup first. (http://trac.osgeo.org/gdal/ticket/5054) + */ + if (tif->tif_nfieldscompat > 0) { + uint32 i; - /* - * Give client code a chance to install their own - * tag extensions & methods, prior to compression overloads, - * but do some prior cleanup first. - * (http://trac.osgeo.org/gdal/ticket/5054) - */ - if (tif->tif_nfieldscompat > 0) - { - uint32_t i; + for (i = 0; i < tif->tif_nfieldscompat; i++) { + if (tif->tif_fieldscompat[i].allocated_size) + _TIFFfree(tif->tif_fieldscompat[i].fields); + } + _TIFFfree(tif->tif_fieldscompat); + tif->tif_nfieldscompat = 0; + tif->tif_fieldscompat = NULL; + } + if (_TIFFextender) + (*_TIFFextender)(tif); + (void) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + /* + * NB: The directory is marked dirty as a result of setting + * up the default compression scheme. However, this really + * isn't correct -- we want TIFF_DIRTYDIRECT to be set only + * if the user does something. We could just do the setup + * by hand, but it seems better to use the normal mechanism + * (i.e. TIFFSetField). + */ + tif->tif_flags &= ~TIFF_DIRTYDIRECT; - for (i = 0; i < tif->tif_nfieldscompat; i++) - { - if (tif->tif_fieldscompat[i].allocated_size) - _TIFFfreeExt(tif, tif->tif_fieldscompat[i].fields); - } - _TIFFfreeExt(tif, tif->tif_fieldscompat); - tif->tif_nfieldscompat = 0; - tif->tif_fieldscompat = NULL; - } - if (_TIFFextender) - (*_TIFFextender)(tif); - (void)TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - /* - * NB: The directory is marked dirty as a result of setting - * up the default compression scheme. However, this really - * isn't correct -- we want TIFF_DIRTYDIRECT to be set only - * if the user does something. We could just do the setup - * by hand, but it seems better to use the normal mechanism - * (i.e. TIFFSetField). - */ - tif->tif_flags &= ~TIFF_DIRTYDIRECT; + /* + * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19 + * we clear the ISTILED flag when setting up a new directory. + * Should we also be clearing stuff like INSUBIFD? + */ + tif->tif_flags &= ~TIFF_ISTILED; - /* - * As per http://bugzilla.remotesensing.org/show_bug.cgi?id=19 - * we clear the ISTILED flag when setting up a new directory. - * Should we also be clearing stuff like INSUBIFD? - */ - tif->tif_flags &= ~TIFF_ISTILED; - - return (1); + return (1); } -static int TIFFAdvanceDirectory(TIFF *tif, uint64_t *nextdiroff, uint64_t *off, - tdir_t *nextdirnum) +static int +TIFFAdvanceDirectory(TIFF* tif, uint64* nextdir, uint64* off) { - static const char module[] = "TIFFAdvanceDirectory"; - - /* Add this directory to the directory list, if not already in. */ - if (!_TIFFCheckDirNumberAndOffset(tif, *nextdirnum, *nextdiroff)) - { - TIFFErrorExtR(tif, module, - "Starting directory %u at offset 0x%" PRIx64 " (%" PRIu64 - ") might cause an IFD loop", - *nextdirnum, *nextdiroff, *nextdiroff); - *nextdiroff = 0; - *nextdirnum = 0; - return (0); - } - - if (isMapped(tif)) - { - uint64_t poff = *nextdiroff; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - tmsize_t poffa, poffb, poffc, poffd; - uint16_t dircount; - uint32_t nextdir32; - poffa = (tmsize_t)poff; - poffb = poffa + sizeof(uint16_t); - if (((uint64_t)poffa != poff) || (poffb < poffa) || - (poffb < (tmsize_t)sizeof(uint16_t)) || (poffb > tif->tif_size)) - { - TIFFErrorExtR(tif, module, "Error fetching directory count"); - *nextdiroff = 0; - return (0); - } - _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_t); - if ((poffc < poffb) || (poffc < dircount * 12) || (poffd < poffc) || - (poffd < (tmsize_t)sizeof(uint32_t)) || (poffd > tif->tif_size)) - { - TIFFErrorExtR(tif, module, "Error fetching directory link"); - return (0); - } - if (off != NULL) - *off = (uint64_t)poffc; - _TIFFmemcpy(&nextdir32, tif->tif_base + poffc, sizeof(uint32_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir32); - *nextdiroff = nextdir32; - } - else - { - tmsize_t poffa, poffb, poffc, poffd; - uint64_t dircount64; - uint16_t dircount16; - if (poff > (uint64_t)TIFF_TMSIZE_T_MAX - sizeof(uint64_t)) - { - TIFFErrorExtR(tif, module, "Error fetching directory count"); - return (0); - } - poffa = (tmsize_t)poff; - poffb = poffa + sizeof(uint64_t); - if (poffb > tif->tif_size) - { - TIFFErrorExtR(tif, module, "Error fetching directory count"); - return (0); - } - _TIFFmemcpy(&dircount64, tif->tif_base + poffa, sizeof(uint64_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&dircount64); - if (dircount64 > 0xFFFF) - { - TIFFErrorExtR(tif, module, - "Sanity check on directory count failed"); - return (0); - } - dircount16 = (uint16_t)dircount64; - if (poffb > TIFF_TMSIZE_T_MAX - (tmsize_t)(dircount16 * 20) - - (tmsize_t)sizeof(uint64_t)) - { - TIFFErrorExtR(tif, module, "Error fetching directory link"); - return (0); - } - poffc = poffb + dircount16 * 20; - poffd = poffc + sizeof(uint64_t); - if (poffd > tif->tif_size) - { - TIFFErrorExtR(tif, module, "Error fetching directory link"); - return (0); - } - if (off != NULL) - *off = (uint64_t)poffc; - _TIFFmemcpy(nextdiroff, tif->tif_base + poffc, sizeof(uint64_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(nextdiroff); - } - } - else - { - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - uint16_t dircount; - uint32_t nextdir32; - if (!SeekOK(tif, *nextdiroff) || - !ReadOK(tif, &dircount, sizeof(uint16_t))) - { - TIFFErrorExtR(tif, module, "%s: Error fetching directory count", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - if (off != NULL) - *off = TIFFSeekFile(tif, dircount * 12, SEEK_CUR); - else - (void)TIFFSeekFile(tif, dircount * 12, SEEK_CUR); - if (!ReadOK(tif, &nextdir32, sizeof(uint32_t))) - { - TIFFErrorExtR(tif, module, "%s: Error fetching directory link", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdir32); - *nextdiroff = nextdir32; - } - else - { - uint64_t dircount64; - uint16_t dircount16; - if (!SeekOK(tif, *nextdiroff) || - !ReadOK(tif, &dircount64, sizeof(uint64_t))) - { - TIFFErrorExtR(tif, module, "%s: Error fetching directory count", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&dircount64); - if (dircount64 > 0xFFFF) - { - TIFFErrorExtR(tif, module, "Error fetching directory count"); - return (0); - } - 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, nextdiroff, sizeof(uint64_t))) - { - TIFFErrorExtR(tif, module, "%s: Error fetching directory link", - tif->tif_name); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(nextdiroff); - } - } - if (*nextdiroff != 0) - { - (*nextdirnum)++; - /* Check next directory for IFD looping and if so, set it as last - * directory. */ - if (!_TIFFCheckDirNumberAndOffset(tif, *nextdirnum, *nextdiroff)) - { - TIFFWarningExtR( - tif, module, - "the next directory %u at offset 0x%" PRIx64 " (%" PRIu64 - ") might be an IFD loop. Treating directory %d as " - "last directory", - *nextdirnum, *nextdiroff, *nextdiroff, (int)(*nextdirnum) - 1); - *nextdiroff = 0; - (*nextdirnum)--; - } - } - return (1); + static const char module[] = "TIFFAdvanceDirectory"; + if (isMapped(tif)) + { + uint64 poff=*nextdir; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + tmsize_t poffa,poffb,poffc,poffd; + uint16 dircount; + uint32 nextdir32; + poffa=(tmsize_t)poff; + poffb=poffa+sizeof(uint16); + if (((uint64)poffa!=poff)||(poffbtif->tif_size)) + { + TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count"); + *nextdir=0; + return(0); + } + _TIFFmemcpy(&dircount,tif->tif_base+poffa,sizeof(uint16)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort(&dircount); + poffc=poffb+dircount*12; + poffd=poffc+sizeof(uint32); + if ((poffctif->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)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&nextdir32); + *nextdir=nextdir32; + } + else + { + tmsize_t poffa,poffb,poffc,poffd; + uint64 dircount64; + uint16 dircount16; + poffa=(tmsize_t)poff; + poffb=poffa+sizeof(uint64); + if (((uint64)poffa!=poff)||(poffbtif->tif_size)) + { + TIFFErrorExt(tif->tif_clientdata,module,"Error fetching directory count"); + return(0); + } + _TIFFmemcpy(&dircount64,tif->tif_base+poffa,sizeof(uint64)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFF) + { + TIFFErrorExt(tif->tif_clientdata,module,"Sanity check on directory count failed"); + return(0); + } + dircount16=(uint16)dircount64; + poffc=poffb+dircount16*20; + poffd=poffc+sizeof(uint64); + if ((poffctif->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)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(nextdir); + } + return(1); + } + else + { + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint16 dircount; + uint32 nextdir32; + if (!SeekOK(tif, *nextdir) || + !ReadOK(tif, &dircount, sizeof (uint16))) { + TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + if (off != NULL) + *off = TIFFSeekFile(tif, + dircount*12, SEEK_CUR); + else + (void) TIFFSeekFile(tif, + dircount*12, SEEK_CUR); + if (!ReadOK(tif, &nextdir32, sizeof (uint32))) { + TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory link", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextdir32); + *nextdir=nextdir32; + } + else + { + uint64 dircount64; + uint16 dircount16; + if (!SeekOK(tif, *nextdir) || + !ReadOK(tif, &dircount64, sizeof (uint64))) { + TIFFErrorExt(tif->tif_clientdata, module, "%s: Error fetching directory count", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFF) + { + TIFFErrorExt(tif->tif_clientdata, module, "Error fetching directory count"); + return(0); + } + dircount16 = (uint16)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))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Error fetching directory link", + tif->tif_name); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(nextdir); + } + return (1); + } } /* * Count the number of directories in a file. */ -tdir_t TIFFNumberOfDirectories(TIFF *tif) +uint16 +TIFFNumberOfDirectories(TIFF* tif) { - uint64_t nextdiroff; - tdir_t nextdirnum; - tdir_t n; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - nextdiroff = tif->tif_header.classic.tiff_diroff; - else - nextdiroff = tif->tif_header.big.tiff_diroff; - nextdirnum = 0; - n = 0; - while (nextdiroff != 0 && - TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum)) - { - ++n; - } - return (n); + static const char module[] = "TIFFNumberOfDirectories"; + uint64 nextdir; + uint16 n; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + nextdir = tif->tif_header.classic.tiff_diroff; + else + nextdir = tif->tif_header.big.tiff_diroff; + n = 0; + while (nextdir != 0 && TIFFAdvanceDirectory(tif, &nextdir, NULL)) + { + if (n != 65535) { + ++n; + } + else + { + TIFFErrorExt(tif->tif_clientdata, module, + "Directory count exceeded 65535 limit," + " giving up on counting."); + return (65535); + } + } + return (n); } /* * Set the n-th directory as the current directory. * NB: Directories are numbered starting at 0. */ -int TIFFSetDirectory(TIFF *tif, tdir_t dirn) +int +TIFFSetDirectory(TIFF* tif, uint16 dirn) { - uint64_t nextdiroff; - tdir_t nextdirnum = 0; - tdir_t n; + uint64 nextdir; + uint16 n; - if (tif->tif_setdirectory_force_absolute) - { - /* tif_setdirectory_force_absolute=1 will force parsing the main IFD - * chain from the beginning, thus IFD directory list needs to be cleared - * from possible SubIFD offsets. - */ - _TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */ - } - - /* Even faster path, if offset is available within IFD loop hash list. */ - if (!tif->tif_setdirectory_force_absolute && - _TIFFGetOffsetFromDirNumber(tif, dirn, &nextdiroff)) - { - /* Set parameters for following TIFFReadDirectory() below. */ - tif->tif_nextdiroff = nextdiroff; - tif->tif_curdir = dirn; - /* Reset to relative stepping */ - tif->tif_setdirectory_force_absolute = FALSE; - } - else - { - - /* Fast path when we just advance relative to the current directory: - * start at the current dir offset and continue to seek from there. - * Check special cases when relative is not allowed: - * - jump back from SubIFD or custom directory - * - right after TIFFWriteDirectory() jump back to that directory - * using TIFFSetDirectory() */ - const int relative = (dirn >= tif->tif_curdir) && - (tif->tif_diroff != 0) && - !tif->tif_setdirectory_force_absolute; - - if (relative) - { - nextdiroff = tif->tif_diroff; - dirn -= tif->tif_curdir; - nextdirnum = tif->tif_curdir; - } - else if (!(tif->tif_flags & TIFF_BIGTIFF)) - nextdiroff = tif->tif_header.classic.tiff_diroff; - else - nextdiroff = tif->tif_header.big.tiff_diroff; - - /* Reset to relative stepping */ - tif->tif_setdirectory_force_absolute = FALSE; - - for (n = dirn; n > 0 && nextdiroff != 0; n--) - if (!TIFFAdvanceDirectory(tif, &nextdiroff, NULL, &nextdirnum)) - return (0); - /* If the n-th directory could not be reached (does not exist), - * return here without touching anything further. */ - if (nextdiroff == 0 || n > 0) - return (0); - - tif->tif_nextdiroff = nextdiroff; - - /* Set curdir to the actual directory index. */ - if (relative) - tif->tif_curdir += dirn - n; - else - tif->tif_curdir = dirn - n; - } - - /* The -1 decrement is because TIFFReadDirectory will increment - * tif_curdir after successfully reading the directory. */ - if (tif->tif_curdir == 0) - tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER; - else - tif->tif_curdir--; - return (TIFFReadDirectory(tif)); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + nextdir = tif->tif_header.classic.tiff_diroff; + else + nextdir = tif->tif_header.big.tiff_diroff; + for (n = dirn; n > 0 && nextdir != 0; n--) + if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) + return (0); + tif->tif_nextdiroff = nextdir; + /* + * Set curdir to the actual directory index. The + * -1 is because TIFFReadDirectory will increment + * tif_curdir after successfully reading the directory. + */ + tif->tif_curdir = (dirn - n) - 1; + /* + * Reset tif_dirnumber counter and start new list of seen directories. + * We need this to prevent IFD loops. + */ + tif->tif_dirnumber = 0; + return (TIFFReadDirectory(tif)); } /* @@ -2109,200 +1717,140 @@ int TIFFSetDirectory(TIFF *tif, tdir_t dirn) * is used mainly to access directories linked with * the SubIFD tag (e.g. thumbnail images). */ -int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff) +int +TIFFSetSubDirectory(TIFF* tif, uint64 diroff) { - /* Match nextdiroff and curdir for consistent IFD-loop checking. - * Only with TIFFSetSubDirectory() the IFD list can be corrupted with - * invalid offsets within the main IFD tree. In the case of several subIFDs - * of a main image, there are two possibilities that are not even mutually - * exclusive. a.) The subIFD tag contains an array with all offsets of the - * subIFDs. b.) The SubIFDs are concatenated with their NextIFD parameters. - * (refer to - * https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf.) - */ - int retval; - uint32_t curdir = 0; - int8_t probablySubIFD = 0; - if (diroff == 0) - { - /* Special case to invalidate the tif_lastdiroff member. */ - tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER; - } - else - { - if (!_TIFFGetDirNumberFromOffset(tif, diroff, &curdir)) - { - /* Non-existing offsets might point to a SubIFD or invalid IFD.*/ - probablySubIFD = 1; - } - /* -1 because TIFFReadDirectory() will increment tif_curdir. */ - tif->tif_curdir = - curdir == 0 ? TIFF_NON_EXISTENT_DIR_NUMBER : curdir - 1; - } - - tif->tif_nextdiroff = diroff; - retval = TIFFReadDirectory(tif); - /* If failed, curdir was not incremented in TIFFReadDirectory(), so set it - * back, but leave it for diroff==0. */ - if (!retval && diroff != 0) - { - if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER) - tif->tif_curdir = 0; - else - tif->tif_curdir++; - } - if (retval && probablySubIFD) - { - /* Reset IFD list to start new one for SubIFD chain and also start - * SubIFD chain with tif_curdir=0. */ - _TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */ - tif->tif_curdir = 0; /* first directory of new chain */ - /* add this offset to new IFD list */ - _TIFFCheckDirNumberAndOffset(tif, tif->tif_curdir, diroff); - /* To be able to return from SubIFD or custom-IFD to main-IFD */ - tif->tif_setdirectory_force_absolute = TRUE; - } - return (retval); + tif->tif_nextdiroff = diroff; + /* + * Reset tif_dirnumber counter and start new list of seen directories. + * We need this to prevent IFD loops. + */ + tif->tif_dirnumber = 0; + return (TIFFReadDirectory(tif)); } /* * Return file offset of the current directory. */ -uint64_t TIFFCurrentDirOffset(TIFF *tif) { return (tif->tif_diroff); } +uint64 +TIFFCurrentDirOffset(TIFF* tif) +{ + return (tif->tif_diroff); +} /* * Return an indication of whether or not we are * at the last directory in the file. */ -int TIFFLastDirectory(TIFF *tif) { return (tif->tif_nextdiroff == 0); } +int +TIFFLastDirectory(TIFF* tif) +{ + return (tif->tif_nextdiroff == 0); +} /* * Unlink the specified directory from the directory chain. - * Note: First directory starts with number dirn=1. - * This is different to TIFFSetDirectory() where the first directory starts with - * zero. */ -int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn) +int +TIFFUnlinkDirectory(TIFF* tif, uint16 dirn) { - static const char module[] = "TIFFUnlinkDirectory"; - uint64_t nextdir; - tdir_t nextdirnum; - uint64_t off; - tdir_t n; + static const char module[] = "TIFFUnlinkDirectory"; + uint64 nextdir; + uint64 off; + uint16 n; - if (tif->tif_mode == O_RDONLY) - { - TIFFErrorExtR(tif, module, - "Can not unlink directory in read-only file"); - return (0); - } - if (dirn == 0) - { - TIFFErrorExtR(tif, module, - "For TIFFUnlinkDirectory() first directory starts with " - "number 1 and not 0"); - return (0); - } - /* - * Go to the directory before the one we want - * to unlink and nab the offset of the link - * field we'll need to patch. - */ - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - nextdir = tif->tif_header.classic.tiff_diroff; - off = 4; - } - else - { - nextdir = tif->tif_header.big.tiff_diroff; - off = 8; - } - nextdirnum = 0; /* First directory is dirn=0 */ - - for (n = dirn - 1; n > 0; n--) - { - if (nextdir == 0) - { - TIFFErrorExtR(tif, module, "Directory %u does not exist", dirn); - return (0); - } - if (!TIFFAdvanceDirectory(tif, &nextdir, &off, &nextdirnum)) - return (0); - } - /* - * Advance to the directory to be unlinked and fetch - * the offset of the directory that follows. - */ - if (!TIFFAdvanceDirectory(tif, &nextdir, NULL, &nextdirnum)) - return (0); - /* - * Go back and patch the link field of the preceding - * directory to point to the offset of the directory - * that follows. - */ - (void)TIFFSeekFile(tif, off, SEEK_SET); - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - 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_t))) - { - TIFFErrorExtR(tif, module, "Error writing directory link"); - return (0); - } - } - else - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&nextdir); - if (!WriteOK(tif, &nextdir, sizeof(uint64_t))) - { - TIFFErrorExtR(tif, module, "Error writing directory link"); - return (0); - } - } - - /* For dirn=1 (first directory) also update the libtiff internal - * base offset variables. */ - if (dirn == 1) - { - if (!(tif->tif_flags & TIFF_BIGTIFF)) - tif->tif_header.classic.tiff_diroff = (uint32_t)nextdir; - else - tif->tif_header.big.tiff_diroff = nextdir; - } - - /* - * Leave directory state setup safely. We don't have - * facilities for doing inserting and removing directories, - * so it's safest to just invalidate everything. This - * means that the caller can only append to the directory - * chain. - */ - (*tif->tif_cleanup)(tif); - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - { - _TIFFfreeExt(tif, tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawcc = 0; - tif->tif_rawdataoff = 0; - tif->tif_rawdataloaded = 0; - } - tif->tif_flags &= ~(TIFF_BEENWRITING | TIFF_BUFFERSETUP | TIFF_POSTENCODE | - TIFF_BUF4WRITE); - TIFFFreeDirectory(tif); - TIFFDefaultDirectory(tif); - tif->tif_diroff = 0; /* force link on next write */ - tif->tif_nextdiroff = 0; /* next write must be at end */ - tif->tif_lastdiroff = 0; /* will be updated on next link */ - tif->tif_curoff = 0; - tif->tif_row = (uint32_t)-1; - tif->tif_curstrip = (uint32_t)-1; - tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER; - _TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */ - return (1); + if (tif->tif_mode == O_RDONLY) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not unlink directory in read-only file"); + return (0); + } + /* + * Go to the directory before the one we want + * to unlink and nab the offset of the link + * field we'll need to patch. + */ + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + nextdir = tif->tif_header.classic.tiff_diroff; + off = 4; + } + else + { + nextdir = tif->tif_header.big.tiff_diroff; + off = 8; + } + for (n = dirn-1; n > 0; n--) { + if (nextdir == 0) { + TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn); + return (0); + } + if (!TIFFAdvanceDirectory(tif, &nextdir, &off)) + return (0); + } + /* + * Advance to the directory to be unlinked and fetch + * the offset of the directory that follows. + */ + if (!TIFFAdvanceDirectory(tif, &nextdir, NULL)) + return (0); + /* + * Go back and patch the link field of the preceding + * directory to point to the offset of the directory + * that follows. + */ + (void) TIFFSeekFile(tif, off, SEEK_SET); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 nextdir32; + nextdir32=(uint32)nextdir; + assert((uint64)nextdir32==nextdir); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextdir32); + if (!WriteOK(tif, &nextdir32, sizeof (uint32))) { + TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); + return (0); + } + } + else + { + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&nextdir); + if (!WriteOK(tif, &nextdir, sizeof (uint64))) { + TIFFErrorExt(tif->tif_clientdata, module, "Error writing directory link"); + return (0); + } + } + /* + * Leave directory state setup safely. We don't have + * facilities for doing inserting and removing directories, + * so it's safest to just invalidate everything. This + * means that the caller can only append to the directory + * chain. + */ + (*tif->tif_cleanup)(tif); + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawcc = 0; + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = 0; + } + tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP|TIFF_POSTENCODE|TIFF_BUF4WRITE); + TIFFFreeDirectory(tif); + TIFFDefaultDirectory(tif); + 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; + return (1); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dir.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dir.h index 9eaf22f8e..a7f7f537f 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dir.h +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dir.h @@ -2,28 +2,28 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFDIR_ -#define _TIFFDIR_ +#define _TIFFDIR_ #include "tiff.h" #include "tiffio.h" @@ -32,11 +32,10 @@ * ``Library-private'' Directory-related Definitions. */ -typedef struct -{ - const TIFFField *info; - int count; - void *value; +typedef struct { + const TIFFField *info; + int count; + void *value; } TIFFTagValue; /* @@ -50,91 +49,80 @@ typedef struct * BigTIFF, then it is placed in the offset field to save space. If so, * it is left-justified in the offset field. */ -typedef struct -{ - 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_t toff_short; - uint32_t toff_long; - uint64_t toff_long8; - } tdir_offset; /* either offset or the data itself if fits */ - uint8_t tdir_ignore; /* flag status to ignore tag when parsing tags in - tif_dirread.c */ +typedef struct { + uint16 tdir_tag; /* see below */ + uint16 tdir_type; /* data type; see below */ + uint64 tdir_count; /* number of items; length in spec */ + union { + uint16 toff_short; + uint32 toff_long; + uint64 toff_long8; + } tdir_offset; /* either offset or the data itself if fits */ + uint8 tdir_ignore; /* flag status to ignore tag when parsing tags in tif_dirread.c */ } TIFFDirEntry; /* * Internal format of a TIFF directory entry. */ -typedef struct -{ +typedef struct { #define FIELDSET_ITEMS 4 - /* bit vector of fields that are set */ - uint32_t td_fieldsset[FIELDSET_ITEMS]; + /* bit vector of fields that are set */ + uint32 td_fieldsset[FIELDSET_ITEMS]; - 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_t td_resolutionunit; - uint16_t td_planarconfig; - float td_xposition, td_yposition; - 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_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 - */ + uint32 td_imagewidth, td_imagelength, td_imagedepth; + uint32 td_tilewidth, td_tilelength, td_tiledepth; + uint32 td_subfiletype; + uint16 td_bitspersample; + uint16 td_sampleformat; + uint16 td_compression; + uint16 td_photometric; + uint16 td_threshholding; + uint16 td_fillorder; + uint16 td_orientation; + uint16 td_samplesperpixel; + uint32 td_rowsperstrip; + uint16 td_minsamplevalue, td_maxsamplevalue; + double* td_sminsamplevalue; + double* td_smaxsamplevalue; + float td_xresolution, td_yresolution; + uint16 td_resolutionunit; + uint16 td_planarconfig; + float td_xposition, td_yposition; + uint16 td_pagenumber[2]; + uint16* td_colormap[3]; + uint16 td_halftonehints[2]; + uint16 td_extrasamples; + uint16* td_sampleinfo; + /* even though the name is misleading, td_stripsperimage is the number + * of striles (=strips or tiles) per plane, and td_nstrips the total + * number of striles */ + uint32 td_stripsperimage; + uint32 td_nstrips; /* size of offset & bytecount arrays */ + uint64* td_stripoffset_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 */ #ifdef STRIPBYTECOUNTSORTED_UNUSED - int td_stripbytecountsorted; /* is the bytecount array sorted ascending? */ + 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_t td_nsubifd; - uint64_t *td_subifd; - /* YCbCr parameters */ - uint16_t td_ycbcrsubsampling[2]; - uint16_t td_ycbcrpositioning; - /* Colorimetry parameters */ - uint16_t *td_transferfunction[3]; - float *td_refblackwhite; - /* CMYK parameters */ - int td_inknameslen; - char *td_inknames; - uint16_t td_numberofinks; /* number of inks in InkNames string */ + TIFFDirEntry td_stripoffset_entry; /* for deferred loading */ + TIFFDirEntry td_stripbytecount_entry; /* for deferred loading */ + uint16 td_nsubifd; + uint64* td_subifd; + /* YCbCr parameters */ + uint16 td_ycbcrsubsampling[2]; + uint16 td_ycbcrpositioning; + /* Colorimetry parameters */ + uint16* td_transferfunction[3]; + float* td_refblackwhite; + /* CMYK parameters */ + int td_inknameslen; + char* td_inknames; + uint16 td_numberofinks; /* number of inks in InkNames string */ - int td_customValueCount; - TIFFTagValue *td_customValues; + int td_customValueCount; + TIFFTagValue *td_customValues; - unsigned char - td_deferstrilearraywriting; /* see TIFFDeferStrileArrayWriting() */ + unsigned char td_deferstrilearraywriting; /* see TIFFDeferStrileArrayWriting() */ } TIFFDirectory; /* @@ -148,49 +136,50 @@ typedef struct * Note that a bit *is* allocated for ignored tags; this is understood by the * directory reading logic which uses this fact to avoid special-case handling */ -#define FIELD_IGNORE 0 +#define FIELD_IGNORE 0 /* multi-item fields */ -#define FIELD_IMAGEDIMENSIONS 1 -#define FIELD_TILEDIMENSIONS 2 -#define FIELD_RESOLUTION 3 -#define FIELD_POSITION 4 +#define FIELD_IMAGEDIMENSIONS 1 +#define FIELD_TILEDIMENSIONS 2 +#define FIELD_RESOLUTION 3 +#define FIELD_POSITION 4 /* single-item fields */ -#define FIELD_SUBFILETYPE 5 -#define FIELD_BITSPERSAMPLE 6 -#define FIELD_COMPRESSION 7 -#define FIELD_PHOTOMETRIC 8 -#define FIELD_THRESHHOLDING 9 -#define FIELD_FILLORDER 10 -#define FIELD_ORIENTATION 15 -#define FIELD_SAMPLESPERPIXEL 16 -#define FIELD_ROWSPERSTRIP 17 -#define FIELD_MINSAMPLEVALUE 18 -#define FIELD_MAXSAMPLEVALUE 19 -#define FIELD_PLANARCONFIG 20 -#define FIELD_RESOLUTIONUNIT 22 -#define FIELD_PAGENUMBER 23 -#define FIELD_STRIPBYTECOUNTS 24 -#define FIELD_STRIPOFFSETS 25 -#define FIELD_COLORMAP 26 -#define FIELD_EXTRASAMPLES 31 -#define FIELD_SAMPLEFORMAT 32 -#define FIELD_SMINSAMPLEVALUE 33 -#define FIELD_SMAXSAMPLEVALUE 34 -#define FIELD_IMAGEDEPTH 35 -#define FIELD_TILEDEPTH 36 -#define FIELD_HALFTONEHINTS 37 -#define FIELD_YCBCRSUBSAMPLING 39 -#define FIELD_YCBCRPOSITIONING 40 -#define FIELD_REFBLACKWHITE 41 -#define FIELD_TRANSFERFUNCTION 44 -#define FIELD_INKNAMES 46 -#define FIELD_SUBIFD 49 -#define FIELD_NUMBEROFINKS 50 +#define FIELD_SUBFILETYPE 5 +#define FIELD_BITSPERSAMPLE 6 +#define FIELD_COMPRESSION 7 +#define FIELD_PHOTOMETRIC 8 +#define FIELD_THRESHHOLDING 9 +#define FIELD_FILLORDER 10 +#define FIELD_ORIENTATION 15 +#define FIELD_SAMPLESPERPIXEL 16 +#define FIELD_ROWSPERSTRIP 17 +#define FIELD_MINSAMPLEVALUE 18 +#define FIELD_MAXSAMPLEVALUE 19 +#define FIELD_PLANARCONFIG 20 +#define FIELD_RESOLUTIONUNIT 22 +#define FIELD_PAGENUMBER 23 +#define FIELD_STRIPBYTECOUNTS 24 +#define FIELD_STRIPOFFSETS 25 +#define FIELD_COLORMAP 26 +#define FIELD_EXTRASAMPLES 31 +#define FIELD_SAMPLEFORMAT 32 +#define FIELD_SMINSAMPLEVALUE 33 +#define FIELD_SMAXSAMPLEVALUE 34 +#define FIELD_IMAGEDEPTH 35 +#define FIELD_TILEDEPTH 36 +#define FIELD_HALFTONEHINTS 37 +#define FIELD_YCBCRSUBSAMPLING 39 +#define FIELD_YCBCRPOSITIONING 40 +#define FIELD_REFBLACKWHITE 41 +#define FIELD_TRANSFERFUNCTION 44 +#define FIELD_INKNAMES 46 +#define FIELD_SUBIFD 49 +#define FIELD_NUMBEROFINKS 50 /* FIELD_CUSTOM (see tiffio.h) 65 */ /* end of support for well-known tags; codec-private tags follow */ -#define FIELD_CODEC 66 /* base of codec-private tags */ +#define FIELD_CODEC 66 /* base of codec-private tags */ + /* * Pseudo-tags don't normally need field bits since they are not written to an @@ -200,141 +189,131 @@ typedef struct * or ``unset'' then it can do using internal state flags without polluting * the field bit space defined for real tags. */ -#define FIELD_PSEUDO 0 +#define FIELD_PSEUDO 0 -#define FIELD_LAST (32 * FIELDSET_ITEMS - 1) +#define FIELD_LAST (32*FIELDSET_ITEMS-1) -#define BITn(n) (((uint32_t)1L) << ((n)&0x1f)) -#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n) / 32]) -#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) -#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) -#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) +#define BITn(n) (((uint32)1L)<<((n)&0x1f)) +#define BITFIELDn(tif, n) ((tif)->tif_dir.td_fieldsset[(n)/32]) +#define TIFFFieldSet(tif, field) (BITFIELDn(tif, field) & BITn(field)) +#define TIFFSetFieldBit(tif, field) (BITFIELDn(tif, field) |= BITn(field)) +#define TIFFClrFieldBit(tif, field) (BITFIELDn(tif, field) &= ~BITn(field)) -#define FieldSet(fields, f) (fields[(f) / 32] & BITn(f)) -#define ResetFieldBit(fields, f) (fields[(f) / 32] &= ~BITn(f)) +#define FieldSet(fields, f) (fields[(f)/32] & BITn(f)) +#define ResetFieldBit(fields, f) (fields[(f)/32] &= ~BITn(f)) -typedef enum -{ - TIFF_SETGET_UNDEFINED = 0, - TIFF_SETGET_ASCII = 1, - TIFF_SETGET_UINT8 = 2, - TIFF_SETGET_SINT8 = 3, - TIFF_SETGET_UINT16 = 4, - TIFF_SETGET_SINT16 = 5, - TIFF_SETGET_UINT32 = 6, - TIFF_SETGET_SINT32 = 7, - TIFF_SETGET_UINT64 = 8, - TIFF_SETGET_SINT64 = 9, - TIFF_SETGET_FLOAT = 10, - TIFF_SETGET_DOUBLE = 11, - TIFF_SETGET_IFD8 = 12, - TIFF_SETGET_INT = 13, - TIFF_SETGET_UINT16_PAIR = 14, - TIFF_SETGET_C0_ASCII = 15, - TIFF_SETGET_C0_UINT8 = 16, - TIFF_SETGET_C0_SINT8 = 17, - TIFF_SETGET_C0_UINT16 = 18, - TIFF_SETGET_C0_SINT16 = 19, - TIFF_SETGET_C0_UINT32 = 20, - TIFF_SETGET_C0_SINT32 = 21, - TIFF_SETGET_C0_UINT64 = 22, - TIFF_SETGET_C0_SINT64 = 23, - TIFF_SETGET_C0_FLOAT = 24, - TIFF_SETGET_C0_DOUBLE = 25, - TIFF_SETGET_C0_IFD8 = 26, - TIFF_SETGET_C16_ASCII = 27, - TIFF_SETGET_C16_UINT8 = 28, - TIFF_SETGET_C16_SINT8 = 29, - TIFF_SETGET_C16_UINT16 = 30, - TIFF_SETGET_C16_SINT16 = 31, - TIFF_SETGET_C16_UINT32 = 32, - TIFF_SETGET_C16_SINT32 = 33, - TIFF_SETGET_C16_UINT64 = 34, - TIFF_SETGET_C16_SINT64 = 35, - TIFF_SETGET_C16_FLOAT = 36, - TIFF_SETGET_C16_DOUBLE = 37, - TIFF_SETGET_C16_IFD8 = 38, - TIFF_SETGET_C32_ASCII = 39, - TIFF_SETGET_C32_UINT8 = 40, - TIFF_SETGET_C32_SINT8 = 41, - TIFF_SETGET_C32_UINT16 = 42, - TIFF_SETGET_C32_SINT16 = 43, - TIFF_SETGET_C32_UINT32 = 44, - TIFF_SETGET_C32_SINT32 = 45, - TIFF_SETGET_C32_UINT64 = 46, - TIFF_SETGET_C32_SINT64 = 47, - TIFF_SETGET_C32_FLOAT = 48, - TIFF_SETGET_C32_DOUBLE = 49, - TIFF_SETGET_C32_IFD8 = 50, - TIFF_SETGET_OTHER = 51 +typedef enum { + TIFF_SETGET_UNDEFINED = 0, + TIFF_SETGET_ASCII = 1, + TIFF_SETGET_UINT8 = 2, + TIFF_SETGET_SINT8 = 3, + TIFF_SETGET_UINT16 = 4, + TIFF_SETGET_SINT16 = 5, + TIFF_SETGET_UINT32 = 6, + TIFF_SETGET_SINT32 = 7, + TIFF_SETGET_UINT64 = 8, + TIFF_SETGET_SINT64 = 9, + TIFF_SETGET_FLOAT = 10, + TIFF_SETGET_DOUBLE = 11, + TIFF_SETGET_IFD8 = 12, + TIFF_SETGET_INT = 13, + TIFF_SETGET_UINT16_PAIR = 14, + TIFF_SETGET_C0_ASCII = 15, + TIFF_SETGET_C0_UINT8 = 16, + TIFF_SETGET_C0_SINT8 = 17, + TIFF_SETGET_C0_UINT16 = 18, + TIFF_SETGET_C0_SINT16 = 19, + TIFF_SETGET_C0_UINT32 = 20, + TIFF_SETGET_C0_SINT32 = 21, + TIFF_SETGET_C0_UINT64 = 22, + TIFF_SETGET_C0_SINT64 = 23, + TIFF_SETGET_C0_FLOAT = 24, + TIFF_SETGET_C0_DOUBLE = 25, + TIFF_SETGET_C0_IFD8 = 26, + TIFF_SETGET_C16_ASCII = 27, + TIFF_SETGET_C16_UINT8 = 28, + TIFF_SETGET_C16_SINT8 = 29, + TIFF_SETGET_C16_UINT16 = 30, + TIFF_SETGET_C16_SINT16 = 31, + TIFF_SETGET_C16_UINT32 = 32, + TIFF_SETGET_C16_SINT32 = 33, + TIFF_SETGET_C16_UINT64 = 34, + TIFF_SETGET_C16_SINT64 = 35, + TIFF_SETGET_C16_FLOAT = 36, + TIFF_SETGET_C16_DOUBLE = 37, + TIFF_SETGET_C16_IFD8 = 38, + TIFF_SETGET_C32_ASCII = 39, + TIFF_SETGET_C32_UINT8 = 40, + TIFF_SETGET_C32_SINT8 = 41, + TIFF_SETGET_C32_UINT16 = 42, + TIFF_SETGET_C32_SINT16 = 43, + TIFF_SETGET_C32_UINT32 = 44, + TIFF_SETGET_C32_SINT32 = 45, + TIFF_SETGET_C32_UINT64 = 46, + TIFF_SETGET_C32_SINT64 = 47, + TIFF_SETGET_C32_FLOAT = 48, + TIFF_SETGET_C32_DOUBLE = 49, + TIFF_SETGET_C32_IFD8 = 50, + TIFF_SETGET_OTHER = 51 } TIFFSetGetFieldType; #if defined(__cplusplus) -extern "C" -{ +extern "C" { #endif - extern const TIFFFieldArray *_TIFFGetFields(void); - extern const TIFFFieldArray *_TIFFGetExifFields(void); - extern const TIFFFieldArray *_TIFFGetGpsFields(void); - extern void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *infoarray); - extern void _TIFFPrintFieldInfo(TIFF *, FILE *); +extern const TIFFFieldArray* _TIFFGetFields(void); +extern const TIFFFieldArray* _TIFFGetExifFields(void); +extern const TIFFFieldArray* _TIFFGetGpsFields(void); +extern void _TIFFSetupFields(TIFF* tif, const TIFFFieldArray* infoarray); +extern void _TIFFPrintFieldInfo(TIFF*, FILE*); - extern int _TIFFFillStriles(TIFF *); +extern int _TIFFFillStriles(TIFF*); - typedef enum - { - tfiatImage, - tfiatExif, - tfiatGps, /* EXIF-GPS fields array type */ - tfiatOther - } TIFFFieldArrayType; +typedef enum { + tfiatImage, + tfiatExif, + tfiatGps, /* EXIF-GPS fields array type */ + tfiatOther +} TIFFFieldArrayType; - struct _TIFFFieldArray - { - TIFFFieldArrayType type; /* array type, will be used to determine if IFD - is image and such */ - 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 _TIFFFieldArray { + TIFFFieldArrayType type; /* array type, will be used to determine if IFD is image and such */ + uint32 allocated_size; /* 0 if array is constant, other if modified by future definition extension support */ + uint32 count; /* number of elements in fields array */ + TIFFField* fields; /* actual field info */ +}; - struct _TIFFField - { - 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_t - field_anonymous; /* if true, this is a unknown / anonymous tag */ - TIFFSetGetFieldType - set_field_type; /* type to be passed to TIFFSetField */ - TIFFSetGetFieldType - get_field_type; /* type to be passed to TIFFGetField */ - unsigned short field_bit; /* bit in fieldsset bit vector */ - unsigned char field_oktochange; /* if true, can change while writing */ - unsigned char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ - TIFFFieldArray *field_subfields; /* if field points to child ifds, child - ifd field definition array */ - }; +struct _TIFFField { + uint32 field_tag; /* field's tag */ + short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ + short field_writecount; /* write count/TIFF_VARIABLE */ + TIFFDataType field_type; /* type of associated data */ + uint32 field_anonymous; /* if true, this is a unknown / anonymous tag */ + TIFFSetGetFieldType set_field_type; /* type to be passed to TIFFSetField */ + TIFFSetGetFieldType get_field_type; /* type to be passed to TIFFGetField */ + unsigned short field_bit; /* bit in fieldsset bit vector */ + unsigned char field_oktochange; /* if true, can change while writing */ + unsigned char field_passcount; /* if true, pass dir count on set */ + char* field_name; /* ASCII name */ + TIFFFieldArray* field_subfields; /* if field points to child ifds, child ifd field definition array */ +}; - extern int _TIFFMergeFields(TIFF *, const TIFFField[], uint32_t); - extern const TIFFField *_TIFFFindOrRegisterField(TIFF *, uint32_t, - TIFFDataType); - extern TIFFField *_TIFFCreateAnonField(TIFF *, uint32_t, TIFFDataType); - extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag); - extern int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn, - uint64_t diroff); - extern int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff, - tdir_t *dirn); - extern int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn, - uint64_t *diroff); - extern int _TIFFRemoveEntryFromDirectoryListByOffset(TIFF *tif, - uint64_t diroff); +extern int _TIFFMergeFields(TIFF*, const TIFFField[], uint32); +extern const TIFFField* _TIFFFindOrRegisterField(TIFF *, uint32, TIFFDataType); +extern TIFFField* _TIFFCreateAnonField(TIFF *, uint32, TIFFDataType); +extern int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag); #if defined(__cplusplus) } #endif #endif /* _TIFFDIR_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirinfo.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirinfo.c index bff7592a8..3eb22b8ba 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirinfo.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirinfo.c @@ -42,954 +42,873 @@ /* const object should be initialized */ #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4132) +#pragma warning( push ) +#pragma warning( disable : 4132 ) #endif static const TIFFFieldArray tiffFieldArray; static const TIFFFieldArray exifFieldArray; static const TIFFFieldArray gpsFieldArray; #ifdef _MSC_VER -#pragma warning(pop) +#pragma warning( pop ) #endif /*--: Rational2Double: -- - * The Rational2Double upgraded libtiff functionality allows the definition and - * achievement of true double-precision accuracy for TIFF tags of RATIONAL type - * and field_bit=FIELD_CUSTOM using the set_field_type = TIFF_SETGET_DOUBLE. + * The Rational2Double upgraded libtiff functionality allows the definition and achievement of true double-precision accuracy + * for TIFF tags of RATIONAL type and field_bit=FIELD_CUSTOM using the set_field_type = TIFF_SETGET_DOUBLE. * Unfortunately, that changes the old implemented interface for TIFFGetField(). - * In order to keep the old TIFFGetField() interface behavior those tags have to - * be redefined with set_field_type = TIFF_SETGET_FLOAT! + * In order to keep the old TIFFGetField() interface behavior those tags have to be redefined with set_field_type = TIFF_SETGET_FLOAT! * * Rational custom arrays are already defined as _Cxx_FLOAT, thus can stay. * */ -/* clang-format off */ /* for better readability of tag comments */ -static const TIFFField tiffFields[] = { - {TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL}, - {TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "OldSubfileType", NULL}, - {TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 0, 0, "ImageWidth", NULL}, - {TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 1, 0, "ImageLength", NULL}, - {TIFFTAG_BITSPERSAMPLE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_BITSPERSAMPLE, 0, 0, "BitsPerSample", NULL}, - {TIFFTAG_COMPRESSION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_COMPRESSION, 0, 0, "Compression", NULL}, - {TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PHOTOMETRIC, 0, 0, "PhotometricInterpretation", NULL}, - {TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_THRESHHOLDING, 1, 0, "Threshholding", NULL}, - {TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CellWidth", NULL}, - {TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CellLength", NULL}, - {TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_FILLORDER, 0, 0, "FillOrder", NULL}, - {TIFFTAG_DOCUMENTNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DocumentName", NULL}, - {TIFFTAG_IMAGEDESCRIPTION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageDescription", NULL}, - {TIFFTAG_MAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Make", NULL}, - {TIFFTAG_MODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Model", NULL}, - {TIFFTAG_STRIPOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "StripOffsets", NULL}, - {TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_ORIENTATION, 0, 0, "Orientation", NULL}, - {TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLESPERPIXEL, 0, 0, "SamplesPerPixel", NULL}, - {TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_ROWSPERSTRIP, 0, 0, "RowsPerStrip", NULL}, - {TIFFTAG_STRIPBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "StripByteCounts", NULL}, - {TIFFTAG_MINSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MINSAMPLEVALUE, 1, 0, "MinSampleValue", NULL}, - {TIFFTAG_MAXSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MAXSAMPLEVALUE, 1, 0, "MaxSampleValue", NULL}, - {TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "XResolution", NULL}, - {TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "YResolution", NULL}, - {TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PLANARCONFIG, 0, 0, "PlanarConfiguration", NULL}, - {TIFFTAG_PAGENAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PageName", NULL}, - {TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "XPosition", NULL}, - {TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "YPosition", NULL}, - {TIFFTAG_FREEOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeOffsets", NULL}, - {TIFFTAG_FREEBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeByteCounts", NULL}, - {TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseUnit", NULL}, - {TIFFTAG_GRAYRESPONSECURVE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseCurve", NULL}, - {TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTIONUNIT, 1, 0, "ResolutionUnit", NULL}, - {TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_PAGENUMBER, 1, 0, "PageNumber", NULL}, - {TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "ColorResponseUnit", NULL}, - {TIFFTAG_TRANSFERFUNCTION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_TRANSFERFUNCTION, 1, 0, "TransferFunction", NULL}, - {TIFFTAG_SOFTWARE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Software", NULL}, - {TIFFTAG_DATETIME, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTime", NULL}, - {TIFFTAG_ARTIST, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Artist", NULL}, - {TIFFTAG_HOSTCOMPUTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HostComputer", NULL}, - {TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhitePoint", NULL}, - {TIFFTAG_PRIMARYCHROMATICITIES, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PrimaryChromaticities", NULL}, - {TIFFTAG_COLORMAP, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_COLORMAP, 1, 0, "ColorMap", NULL}, - {TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_HALFTONEHINTS, 1, 0, "HalftoneHints", NULL}, - {TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileWidth", NULL}, - {TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileLength", NULL}, - {TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "TileOffsets", NULL}, - {TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "TileByteCounts", NULL}, - {TIFFTAG_SUBIFD, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_SUBIFD, 1, 1, "SubIFD", (TIFFFieldArray *)&tiffFieldArray}, - {TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InkSet", NULL}, - {TIFFTAG_INKNAMES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, TIFF_SETGET_UNDEFINED, FIELD_INKNAMES, 1, 1, "InkNames", NULL}, - {TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_NUMBEROFINKS, 1, 0, "NumberOfInks", NULL}, - {TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DotRange", NULL}, - {TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL}, - {TIFFTAG_EXTRASAMPLES, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 1, "ExtraSamples", NULL}, - {TIFFTAG_SAMPLEFORMAT, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "SampleFormat", NULL}, - {TIFFTAG_SMINSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMINSAMPLEVALUE, 1, 0, "SMinSampleValue", NULL}, - {TIFFTAG_SMAXSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMAXSAMPLEVALUE, 1, 0, "SMaxSampleValue", NULL}, - {TIFFTAG_CLIPPATH, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL}, - {TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL}, - {TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL}, - {TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YCbCrCoefficients", NULL}, - {TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_YCBCRSUBSAMPLING, 0, 0, "YCbCrSubsampling", NULL}, - {TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_YCBCRPOSITIONING, 0, 0, "YCbCrPositioning", NULL}, - {TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite", NULL}, - {TIFFTAG_XMLPACKET, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "XMLPacket", NULL}, - /* begin SGI tags */ - {TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 0, "Matteing", NULL}, - {TIFFTAG_DATATYPE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "DataType", NULL}, - {TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDEPTH, 0, 0, "ImageDepth", NULL}, - {TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDEPTH, 0, 0, "TileDepth", NULL}, - /* end SGI tags */ - /* begin Pixar tags */ - {TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL}, - {TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullLength", NULL}, - {TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL}, - {TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL}, - {TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL}, - {TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL}, - {TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL}, - {TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL}, - /* end Pixar tags */ - {TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "RichTIFFIPTC", NULL}, - {TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "Photoshop", NULL}, - /*--: EXIFIFD and GPSIFD specified as TIFF_LONG by Aware-Systems and not TIFF_IFD8 as in original LibTiff. However, for IFD-like tags, - * libtiff uses the data type TIFF_IFD8 in tiffFields[]-tag definition combined with a special handling procedure in order to write either - * a 32-bit value and the TIFF_IFD type-id into ClassicTIFF files or a 64-bit value and the TIFF_IFD8 type-id into BigTIFF files. */ - {TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EXIFIFDOffset", (TIFFFieldArray *)&exifFieldArray}, - {TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ICC Profile", NULL}, - {TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GPSIFDOffset", (TIFFFieldArray *)&gpsFieldArray}, - {TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL}, - {TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxSubAddress", NULL}, - {TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvTime", NULL}, - {TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxDcs", NULL}, - {TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "StoNits", NULL}, - {TIFFTAG_IMAGESOURCEDATA, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "Adobe Photoshop Document Data Block", NULL}, - {TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL}, - /* begin DNG tags */ - {TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DNGVersion", NULL}, - {TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DNGBackwardVersion", NULL}, - {TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "UniqueCameraModel", NULL}, - {TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LocalizedCameraModel", NULL}, - {TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPlaneColor", NULL}, - {TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CFALayout", NULL}, - {TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LinearizationTable", NULL}, - {TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BlackLevelRepeatDim", NULL}, - {TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "BlackLevel", NULL}, - {TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "BlackLevelDeltaH", NULL}, - {TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "BlackLevelDeltaV", NULL}, - {TIFFTAG_WHITELEVEL, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "WhiteLevel", NULL}, - {TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultScale", NULL}, - {TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BestQualityScale", NULL}, - {TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultCropOrigin", NULL}, - {TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultCropSize", NULL}, - {TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ColorMatrix1", NULL}, - {TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ColorMatrix2", NULL}, - {TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibration1", NULL}, - {TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibration2", NULL}, - {TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ReductionMatrix1", NULL}, - {TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ReductionMatrix2", NULL}, - {TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AnalogBalance", NULL}, - {TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotNeutral", NULL}, - {TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "AsShotWhiteXY", NULL}, - {TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineExposure", NULL}, - {TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineNoise", NULL}, - {TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineSharpness", NULL}, - {TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BayerGreenSplit", NULL}, - {TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LinearResponseLimit", NULL}, - {TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraSerialNumber", NULL}, - {TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensInfo", NULL}, - {TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ChromaBlurRadius", NULL}, - {TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "AntiAliasStrength", NULL}, - {TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShadowScale", NULL}, - {TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DNGPrivateData", NULL}, - {TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MakerNoteSafety", NULL}, - {TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant1", NULL}, - {TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant2", NULL}, - {TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RawDataUniqueID", NULL}, - {TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileName", NULL}, - {TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileData", NULL}, - {TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ActiveArea", NULL}, - {TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MaskedAreas", NULL}, - {TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotICCProfile", NULL}, - {TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotPreProfileMatrix", NULL}, - {TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CurrentICCProfile", NULL}, - {TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CurrentPreProfileMatrix", NULL}, - {TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL}, -#if 0 - /* begin DNG 1.2.0.0 tags */ - {TIFFTAG_COLORIMETRICREFERENCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorimetricReference", NULL}, - {TIFFTAG_CAMERACALIBRATIONSIGNATURE, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibrationSignature", NULL}, - {TIFFTAG_PROFILECALIBRATIONSIGNATURE, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileCalibrationSignature", NULL}, - {TIFFTAG_EXTRACAMERAPROFILES, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ExtraCameraProfiles", NULL}, - {TIFFTAG_ASSHOTPROFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AsShotProfileName", NULL}, - {TIFFTAG_NOISEREDUCTIONAPPLIED, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NoiseReductionApplied", NULL}, - {TIFFTAG_PROFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileName", NULL}, - {TIFFTAG_PROFILEHUESATMAPDIMS, 3, 3, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileHueSatMapDims", NULL}, - {TIFFTAG_PROFILEHUESATMAPDATA1, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData1", NULL}, - {TIFFTAG_PROFILEHUESATMAPDATA2, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData2", NULL}, - {TIFFTAG_PROFILETONECURVE, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileToneCurve", NULL}, - {TIFFTAG_PROFILEEMBEDPOLICY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileEmbedPolicy", NULL}, - {TIFFTAG_PROFILECOPYRIGHT, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileCopyright", NULL}, - {TIFFTAG_FORWARDMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ForwardMatrix1", NULL}, - {TIFFTAG_FORWARDMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ForwardMatrix2", NULL}, - {TIFFTAG_PREVIEWAPPLICATIONNAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "PreviewApplicationName", NULL}, - {TIFFTAG_PREVIEWAPPLICATIONVERSION, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "PreviewApplicationVersion", NULL}, - {TIFFTAG_PREVIEWSETTINGSNAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "PreviewSettingsName", NULL}, - {TIFFTAG_PREVIEWSETTINGSDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PreviewSettingsDigest", NULL}, - {TIFFTAG_PREVIEWCOLORSPACE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PreviewColorSpace", NULL}, - {TIFFTAG_PREVIEWDATETIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PreviewDateTime", NULL}, - {TIFFTAG_RAWIMAGEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RawImageDigest", NULL}, - {TIFFTAG_ORIGINALRAWFILEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalRawFileDigest", NULL}, - {TIFFTAG_SUBTILEBLOCKSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubTileBlockSize", NULL}, - {TIFFTAG_ROWINTERLEAVEFACTOR, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RowInterleaveFactor", NULL}, - {TIFFTAG_PROFILELOOKTABLEDIMS, 3, 3, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileLookTableDims", NULL}, - {TIFFTAG_PROFILELOOKTABLEDATA, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileLookTableData", NULL}, - /* begin DNG 1.3.0.0 tags */ - {TIFFTAG_OPCODELIST1, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OpcodeList1", NULL}, - {TIFFTAG_OPCODELIST2, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OpcodeList2", NULL}, - {TIFFTAG_OPCODELIST3, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OpcodeList3", NULL}, - {TIFFTAG_NOISEPROFILE, -1, -1, TIFF_DOUBLE, 0, TIFF_SETGET_C16_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "NoiseProfile", NULL}, - /* begin DNG 1.4.0.0 tags */ - {TIFFTAG_DEFAULTUSERCROP, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultUserCrop", NULL}, - {TIFFTAG_DEFAULTBLACKRENDER, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DefaultBlackRender", NULL}, - {TIFFTAG_BASELINEEXPOSUREOFFSET, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BaselineExposureOffset", NULL}, - {TIFFTAG_PROFILELOOKTABLEENCODING, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileLookTableEncoding", NULL}, - {TIFFTAG_PROFILEHUESATMAPENCODING, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileHueSatMapEncoding", NULL}, - {TIFFTAG_ORIGINALDEFAULTFINALSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalDefaultFinalSize", NULL}, - {TIFFTAG_ORIGINALBESTQUALITYFINALSIZE, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalBestQualityFinalSize", NULL}, - {TIFFTAG_ORIGINALDEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OriginalDefaultCropSize", NULL}, /* could also be rational */ - {TIFFTAG_NEWRAWIMAGEDIGEST, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "NewRawImageDigest", NULL}, - {TIFFTAG_RAWTOPREVIEWGAIN, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RawToPreviewGain", NULL}, - /* begin DNG 1.5.0.0 tags */ - {TIFFTAG_DEPTHFORMAT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthFormat", NULL}, - {TIFFTAG_DEPTHNEAR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthNear", NULL}, - {TIFFTAG_DEPTHFAR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthFar", NULL}, - {TIFFTAG_DEPTHUNITS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthUnits", NULL}, - {TIFFTAG_DEPTHMEASURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DepthMeasureType", NULL}, - {TIFFTAG_ENHANCEPARAMS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EnhanceParams", NULL}, - /* begin DNG 1.6.0.0 tags */ - {TIFFTAG_PROFILEGAINTABLEMAP, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileGainTableMap", NULL}, - {TIFFTAG_SEMANTICNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SemanticName", NULL}, - {TIFFTAG_SEMANTICINSTANCEID, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SemanticInstanceID", NULL}, - {TIFFTAG_MASKSUBAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaskSubArea", NULL}, - {TIFFTAG_RGBTABLES, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "RGBTables", NULL}, - {TIFFTAG_CALIBRATIONILLUMINANT3, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CalibrationIlluminant3", NULL}, - {TIFFTAG_COLORMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ColorMatrix3", NULL}, - {TIFFTAG_CAMERACALIBRATION3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CameraCalibration3", NULL}, - {TIFFTAG_REDUCTIONMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ReductionMatrix3", NULL}, - {TIFFTAG_PROFILEHUESATMAPDATA3, -1, -1, TIFF_FLOAT, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProfileHueSatMapData3", NULL}, - {TIFFTAG_FORWARDMATRIX3, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ForwardMatrix3", NULL}, - {TIFFTAG_ILLUMINANTDATA1, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "IlluminantData1", NULL}, - {TIFFTAG_ILLUMINANTDATA2, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "IlluminantData2", NULL}, - {TIFFTAG_ILLUMINANTDATA3, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "IlluminantData3", NULL}, - /* end DNG tags */ -#endif - /* begin TIFF/EP tags */ - {TIFFTAG_EP_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP CFARepeatPatternDim", NULL}, - {TIFFTAG_EP_CFAPATTERN, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP CFAPattern", NULL}, -#if 0 - /* TIFFTAG_EP_BATTERYLEVEL can be RATIONAL or ASCII. - * LibTiff defines it as ASCII and converts RATIONAL to an ASCII string. */ - {TIFFTAG_EP_BATTERYLEVEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP BatteryLevel", NULL}, - {TIFFTAG_EP_INTERLACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP Interlace", NULL}, - /* TIFFTAG_EP_IPTC_NAA and TIFFTAG_RICHTIFFIPTC share the same tag number (33723) - * LibTIFF type is UNDEFINED or BYTE, but often times incorrectly specified as LONG, because TIFF/EP (ISO/DIS 12234-2) specifies type LONG or ASCII. */ - {TIFFTAG_EP_TIMEZONEOFFSET, -1, -1, TIFF_SSHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP TimeZoneOffset", NULL}, - {TIFFTAG_EP_SELFTIMERMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SelfTimerMode", NULL}, - {TIFFTAG_EP_FLASHENERGY, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FlashEnergy", NULL}, - {TIFFTAG_EP_SPATIALFREQUENCYRESPONSE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SpatialFrequencyResponse", NULL}, - {TIFFTAG_EP_NOISE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP Noise", NULL}, - {TIFFTAG_EP_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP FocalPlaneXResolution", NULL}, - {TIFFTAG_EP_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP FocalPlaneYResolution", NULL}, - {TIFFTAG_EP_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP FocalPlaneResolutionUnit", NULL}, - {TIFFTAG_EP_IMAGENUMBER, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ImageNumber", NULL}, /* or SHORT */ - {TIFFTAG_EP_SECURITYCLASSIFICATION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SecurityClassification", NULL}, - {TIFFTAG_EP_IMAGEHISTORY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ImageHistory", NULL}, - {TIFFTAG_EP_EXPOSUREINDEX, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP ExposureIndex", NULL}, - {TIFFTAG_EP_STANDARDID, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP StandardId", NULL}, - {TIFFTAG_EP_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SensingMethod", NULL}, - /* TIFF/EP tags equivalent to EXIF tags, sometimes defined differently. */ - {TIFFTAG_EP_EXPOSURETIME, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP ExposureTime", NULL}, /*N=1 or 2 */ - {TIFFTAG_EP_FNUMBER, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FNumber", NULL}, - {TIFFTAG_EP_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ExposureProgram", NULL}, - {TIFFTAG_EP_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP SpectralSensitivity", NULL}, - {TIFFTAG_EP_ISOSPEEDRATINGS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ISOSpeedRatings", NULL}, - {TIFFTAG_EP_OECF, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP OptoelectricConversionFactor", NULL}, - {TIFFTAG_EP_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP DateTimeOriginal", NULL}, - {TIFFTAG_EP_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP CompressedBitsPerPixel", NULL}, - {TIFFTAG_EP_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ShutterSpeedValue", NULL}, - {TIFFTAG_EP_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP ApertureValue", NULL}, - {TIFFTAG_EP_BRIGHTNESSVALUE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP BrightnessValue", NULL}, - {TIFFTAG_EP_EXPOSUREBIASVALUE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP ExposureBiasValue", NULL}, /*N=1 or 2 */ - {TIFFTAG_EP_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP MaxApertureValue", NULL}, - {TIFFTAG_EP_SUBJECTDISTANCE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SubjectDistance", NULL}, - {TIFFTAG_EP_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP MeteringMode", NULL}, - {TIFFTAG_EP_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP LightSource", NULL}, - {TIFFTAG_EP_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EP Flash", NULL}, - {TIFFTAG_EP_FOCALLENGTH, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP FocalLength", NULL}, - {TIFFTAG_EP_SUBJECTLOCATION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "EP SubjectLocation", NULL}, - /* end TIFF/EP tags */ -#endif - /* begin TIFF/FX tags */ - {TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Indexed", NULL}, - {TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GlobalParametersIFD", NULL}, - {TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ProfileType", NULL}, - {TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FaxProfile", NULL}, - {TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CodingMethods", NULL}, - {TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "VersionYear", NULL}, - {TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ModeNumber", NULL}, - {TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "Decode", NULL}, - {TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ImageBaseColor", NULL}, - {TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "T82Options", NULL}, - {TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "StripRowCounts", NULL}, - {TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageLayer", NULL}, - /* end TIFF/FX tags */ - /* begin pseudo tags */ +static const TIFFField +tiffFields[] = { + { TIFFTAG_SUBFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "SubfileType", NULL }, + { TIFFTAG_OSUBFILETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_SUBFILETYPE, 1, 0, "OldSubfileType", NULL }, + { TIFFTAG_IMAGEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 0, 0, "ImageWidth", NULL }, + { TIFFTAG_IMAGELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDIMENSIONS, 1, 0, "ImageLength", NULL }, + { TIFFTAG_BITSPERSAMPLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_BITSPERSAMPLE, 0, 0, "BitsPerSample", NULL }, + { TIFFTAG_COMPRESSION, -1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_COMPRESSION, 0, 0, "Compression", NULL }, + { TIFFTAG_PHOTOMETRIC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PHOTOMETRIC, 0, 0, "PhotometricInterpretation", NULL }, + { TIFFTAG_THRESHHOLDING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_THRESHHOLDING, 1, 0, "Threshholding", NULL }, + { TIFFTAG_CELLWIDTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellWidth", NULL }, + { TIFFTAG_CELLLENGTH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "CellLength", NULL }, + { TIFFTAG_FILLORDER, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_FILLORDER, 0, 0, "FillOrder", NULL }, + { TIFFTAG_DOCUMENTNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DocumentName", NULL }, + { TIFFTAG_IMAGEDESCRIPTION, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageDescription", NULL }, + { TIFFTAG_MAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Make", NULL }, + { TIFFTAG_MODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Model", NULL }, + { TIFFTAG_STRIPOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "StripOffsets", NULL }, + { TIFFTAG_ORIENTATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_ORIENTATION, 0, 0, "Orientation", NULL }, + { TIFFTAG_SAMPLESPERPIXEL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLESPERPIXEL, 0, 0, "SamplesPerPixel", NULL }, + { TIFFTAG_ROWSPERSTRIP, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_ROWSPERSTRIP, 0, 0, "RowsPerStrip", NULL }, + { TIFFTAG_STRIPBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "StripByteCounts", NULL }, + { TIFFTAG_MINSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MINSAMPLEVALUE, 1, 0, "MinSampleValue", NULL }, + { TIFFTAG_MAXSAMPLEVALUE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_MAXSAMPLEVALUE, 1, 0, "MaxSampleValue", NULL }, + { TIFFTAG_XRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "XResolution", NULL }, + { TIFFTAG_YRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTION, 1, 0, "YResolution", NULL }, + { TIFFTAG_PLANARCONFIG, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_PLANARCONFIG, 0, 0, "PlanarConfiguration", NULL }, + { TIFFTAG_PAGENAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PageName", NULL }, + { TIFFTAG_XPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "XPosition", NULL }, + { TIFFTAG_YPOSITION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_POSITION, 1, 0, "YPosition", NULL }, + { TIFFTAG_FREEOFFSETS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeOffsets", NULL }, + { TIFFTAG_FREEBYTECOUNTS, -1, -1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 0, 0, "FreeByteCounts", NULL }, + { TIFFTAG_GRAYRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseUnit", NULL }, + { TIFFTAG_GRAYRESPONSECURVE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "GrayResponseCurve", NULL }, + { TIFFTAG_RESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_RESOLUTIONUNIT, 1, 0, "ResolutionUnit", NULL }, + { TIFFTAG_PAGENUMBER, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_PAGENUMBER, 1, 0, "PageNumber", NULL }, + { TIFFTAG_COLORRESPONSEUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_IGNORE, 1, 0, "ColorResponseUnit", NULL }, + { TIFFTAG_TRANSFERFUNCTION, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_TRANSFERFUNCTION, 1, 0, "TransferFunction", NULL }, + { TIFFTAG_SOFTWARE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Software", NULL }, + { TIFFTAG_DATETIME, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTime", NULL }, + { TIFFTAG_ARTIST, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Artist", NULL }, + { TIFFTAG_HOSTCOMPUTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HostComputer", NULL }, + { TIFFTAG_WHITEPOINT, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhitePoint", NULL }, + { TIFFTAG_PRIMARYCHROMATICITIES, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PrimaryChromaticities", NULL }, + { TIFFTAG_COLORMAP, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_COLORMAP, 1, 0, "ColorMap", NULL }, + { TIFFTAG_HALFTONEHINTS, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_HALFTONEHINTS, 1, 0, "HalftoneHints", NULL }, + { TIFFTAG_TILEWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileWidth", NULL }, + { TIFFTAG_TILELENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDIMENSIONS, 0, 0, "TileLength", NULL }, + { TIFFTAG_TILEOFFSETS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPOFFSETS, 0, 0, "TileOffsets", NULL }, + { TIFFTAG_TILEBYTECOUNTS, -1, 1, TIFF_LONG8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_STRIPBYTECOUNTS, 0, 0, "TileByteCounts", NULL }, + { TIFFTAG_SUBIFD, -1, -1, TIFF_IFD8, 0, TIFF_SETGET_C16_IFD8, TIFF_SETGET_UNDEFINED, FIELD_SUBIFD, 1, 1, "SubIFD", (TIFFFieldArray*) &tiffFieldArray }, + { TIFFTAG_INKSET, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InkSet", NULL }, + { TIFFTAG_INKNAMES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_C16_ASCII, TIFF_SETGET_UNDEFINED, FIELD_INKNAMES, 1, 1, "InkNames", NULL }, + { TIFFTAG_NUMBEROFINKS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_NUMBEROFINKS, 1, 0, "NumberOfInks", NULL }, + { TIFFTAG_DOTRANGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DotRange", NULL }, + { TIFFTAG_TARGETPRINTER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TargetPrinter", NULL }, + { TIFFTAG_EXTRASAMPLES, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 1, "ExtraSamples", NULL }, + { TIFFTAG_SAMPLEFORMAT, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "SampleFormat", NULL }, + { TIFFTAG_SMINSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMINSAMPLEVALUE, 1, 0, "SMinSampleValue", NULL }, + { TIFFTAG_SMAXSAMPLEVALUE, -2, -1, TIFF_ANY, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_SMAXSAMPLEVALUE, 1, 0, "SMaxSampleValue", NULL }, + { TIFFTAG_CLIPPATH, -1, -3, TIFF_BYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ClipPath", NULL }, + { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL }, + { TIFFTAG_XCLIPPATHUNITS, 1, 1, TIFF_SBYTE, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "XClipPathUnits", NULL }, + { TIFFTAG_YCLIPPATHUNITS, 1, 1, TIFF_SLONG, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YClipPathUnits", NULL }, + { TIFFTAG_YCBCRCOEFFICIENTS, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "YCbCrCoefficients", NULL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_UINT16_PAIR, TIFF_SETGET_UNDEFINED, FIELD_YCBCRSUBSAMPLING, 0, 0, "YCbCrSubsampling", NULL }, + { TIFFTAG_YCBCRPOSITIONING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_YCBCRPOSITIONING, 0, 0, "YCbCrPositioning", NULL }, + { TIFFTAG_REFERENCEBLACKWHITE, 6, 6, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_REFBLACKWHITE, 1, 0, "ReferenceBlackWhite", NULL }, + { TIFFTAG_XMLPACKET, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "XMLPacket", NULL }, + /* begin SGI tags */ + { TIFFTAG_MATTEING, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_EXTRASAMPLES, 0, 0, "Matteing", NULL }, + { TIFFTAG_DATATYPE, -2, -1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_SAMPLEFORMAT, 0, 0, "DataType", NULL }, + { TIFFTAG_IMAGEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_IMAGEDEPTH, 0, 0, "ImageDepth", NULL }, + { TIFFTAG_TILEDEPTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_TILEDEPTH, 0, 0, "TileDepth", NULL }, + /* end SGI tags */ + /* begin Pixar tags */ + { TIFFTAG_PIXAR_IMAGEFULLWIDTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullWidth", NULL }, + { TIFFTAG_PIXAR_IMAGEFULLLENGTH, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageFullLength", NULL }, + { TIFFTAG_PIXAR_TEXTUREFORMAT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureFormat", NULL }, + { TIFFTAG_PIXAR_WRAPMODES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TextureWrapModes", NULL }, + { TIFFTAG_PIXAR_FOVCOT, 1, 1, TIFF_FLOAT, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FieldOfViewCotangent", NULL }, + { TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToScreen", NULL }, + { TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA, 16, 16, TIFF_FLOAT, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MatrixWorldToCamera", NULL }, + { TIFFTAG_CFAREPEATPATTERNDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CFARepeatPatternDim", NULL }, + { TIFFTAG_CFAPATTERN, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CFAPattern" , NULL}, + { TIFFTAG_COPYRIGHT, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Copyright", NULL }, + /* end Pixar tags */ + { TIFFTAG_RICHTIFFIPTC, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "RichTIFFIPTC", NULL }, + { TIFFTAG_PHOTOSHOP, -3, -3, TIFF_BYTE, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Photoshop", NULL }, + /*--: EXIFIFD and GPSIFD specified as TIFF_LONG by Aware-Systems and not TIFF_IFD8 as in original LibTiff. + * However, for IFD-like tags, libtiff uses the data type TIFF_IFD8 in tiffFields[]-tag definition combined with + * a special handling procedure in order to write either a 32-bit value and the TIFF_IFD type-id into ClassicTIFF files + * or a 64-bit value and the TIFF_IFD8 type-id into BigTIFF files. */ + { TIFFTAG_EXIFIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "EXIFIFDOffset", (TIFFFieldArray*) &exifFieldArray }, + { TIFFTAG_ICCPROFILE, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ICC Profile", NULL }, + { TIFFTAG_GPSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GPSIFDOffset", (TIFFFieldArray*) &gpsFieldArray }, + { TIFFTAG_FAXRECVPARAMS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvParams", NULL }, + { TIFFTAG_FAXSUBADDRESS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxSubAddress", NULL }, + { TIFFTAG_FAXRECVTIME, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_CUSTOM, TRUE, FALSE, "FaxRecvTime", NULL }, + { TIFFTAG_FAXDCS, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_ASCII, FIELD_CUSTOM, TRUE, FALSE, "FaxDcs", NULL }, + { TIFFTAG_STONITS, 1, 1, TIFF_DOUBLE, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "StoNits", NULL }, + { TIFFTAG_INTEROPERABILITYIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "InteroperabilityIFDOffset", NULL }, + /* begin DNG tags */ + { TIFFTAG_DNGVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DNGVersion", NULL }, + { TIFFTAG_DNGBACKWARDVERSION, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DNGBackwardVersion", NULL }, + { TIFFTAG_UNIQUECAMERAMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "UniqueCameraModel", NULL }, + { TIFFTAG_LOCALIZEDCAMERAMODEL, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "LocalizedCameraModel", NULL }, + { TIFFTAG_CFAPLANECOLOR, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CFAPlaneColor", NULL }, + { TIFFTAG_CFALAYOUT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CFALayout", NULL }, + { TIFFTAG_LINEARIZATIONTABLE, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "LinearizationTable", NULL }, + { TIFFTAG_BLACKLEVELREPEATDIM, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BlackLevelRepeatDim", NULL }, + { TIFFTAG_BLACKLEVEL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevel", NULL }, + { TIFFTAG_BLACKLEVELDELTAH, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevelDeltaH", NULL }, + { TIFFTAG_BLACKLEVELDELTAV, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "BlackLevelDeltaV", NULL }, + { TIFFTAG_WHITELEVEL, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "WhiteLevel", NULL }, + { TIFFTAG_DEFAULTSCALE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultScale", NULL }, + { TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BestQualityScale", NULL }, + { TIFFTAG_DEFAULTCROPORIGIN, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropOrigin", NULL }, + { TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "DefaultCropSize", NULL }, + { TIFFTAG_COLORMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ColorMatrix1", NULL }, + { TIFFTAG_COLORMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ColorMatrix2", NULL }, + { TIFFTAG_CAMERACALIBRATION1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CameraCalibration1", NULL }, + { TIFFTAG_CAMERACALIBRATION2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CameraCalibration2", NULL }, + { TIFFTAG_REDUCTIONMATRIX1, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ReductionMatrix1", NULL }, + { TIFFTAG_REDUCTIONMATRIX2, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ReductionMatrix2", NULL }, + { TIFFTAG_ANALOGBALANCE, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AnalogBalance", NULL }, + { TIFFTAG_ASSHOTNEUTRAL, -1, -1, TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotNeutral", NULL }, + { TIFFTAG_ASSHOTWHITEXY, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AsShotWhiteXY", NULL }, + { TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineExposure", NULL }, + { TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineNoise", NULL }, + { TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BaselineSharpness", NULL }, + { TIFFTAG_BAYERGREENSPLIT, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "BayerGreenSplit", NULL }, + { TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LinearResponseLimit", NULL }, + { TIFFTAG_CAMERASERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraSerialNumber", NULL }, + { TIFFTAG_LENSINFO, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "LensInfo", NULL }, + { TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ChromaBlurRadius", NULL }, + { TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "AntiAliasStrength", NULL }, + { TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ShadowScale", NULL }, + { TIFFTAG_DNGPRIVATEDATA, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "DNGPrivateData", NULL }, + { TIFFTAG_MAKERNOTESAFETY, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "MakerNoteSafety", NULL }, + { TIFFTAG_CALIBRATIONILLUMINANT1, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CalibrationIlluminant1", NULL }, + { TIFFTAG_CALIBRATIONILLUMINANT2, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CalibrationIlluminant2", NULL }, + { TIFFTAG_RAWDATAUNIQUEID, 16, 16, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "RawDataUniqueID", NULL }, + { TIFFTAG_ORIGINALRAWFILENAME, -1, -1, TIFF_BYTE, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OriginalRawFileName", NULL }, + { TIFFTAG_ORIGINALRAWFILEDATA, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "OriginalRawFileData", NULL }, + { TIFFTAG_ACTIVEAREA, 4, 4, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ActiveArea", NULL }, + { TIFFTAG_MASKEDAREAS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "MaskedAreas", NULL }, + { TIFFTAG_ASSHOTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotICCProfile", NULL }, + { TIFFTAG_ASSHOTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "AsShotPreProfileMatrix", NULL }, + { TIFFTAG_CURRENTICCPROFILE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentICCProfile", NULL }, + { TIFFTAG_CURRENTPREPROFILEMATRIX, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "CurrentPreProfileMatrix", NULL }, + { TIFFTAG_PERSAMPLE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_UNDEFINED, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "PerSample", NULL}, + /* end DNG tags */ + /* begin TIFF/FX tags */ + { TIFFTAG_INDEXED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Indexed", NULL }, + { TIFFTAG_GLOBALPARAMETERSIFD, 1, 1, TIFF_IFD8, 0, TIFF_SETGET_IFD8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "GlobalParametersIFD", NULL }, + { TIFFTAG_PROFILETYPE, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ProfileType", NULL }, + { TIFFTAG_FAXPROFILE, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "FaxProfile", NULL }, + { TIFFTAG_CODINGMETHODS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "CodingMethods", NULL }, + { TIFFTAG_VERSIONYEAR, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "VersionYear", NULL }, + { TIFFTAG_MODENUMBER, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ModeNumber", NULL }, + { TIFFTAG_DECODE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Decode", NULL }, + { TIFFTAG_IMAGEBASECOLOR, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "ImageBaseColor", NULL }, + { TIFFTAG_T82OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "T82Options", NULL }, + { TIFFTAG_STRIPROWCOUNTS, -1, -1, TIFF_LONG, 0, TIFF_SETGET_C16_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "StripRowCounts", NULL }, + { TIFFTAG_IMAGELAYER, 2, 2, TIFF_LONG, 0, TIFF_SETGET_C0_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "ImageLayer", NULL }, + /* end TIFF/FX tags */ + /* begin pseudo tags */ }; /* * EXIF tags (Version 2.31, July 2016 plus version 2.32 May 2019) */ -static const TIFFField exifFields[] = { - {EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL}, - {EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL}, - {EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureProgram", NULL}, - {EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpectralSensitivity", NULL}, - /* After EXIF 2.2.1 ISOSpeedRatings is named PhotographicSensitivity. In addition, while "Count=Any", only 1 count should be used. */ - {EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ISOSpeedRatings", NULL}, - {EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OptoelectricConversionFactor", NULL}, - {EXIFTAG_SENSITIVITYTYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensitivityType", NULL}, - {EXIFTAG_STANDARDOUTPUTSENSITIVITY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "StandardOutputSensitivity", NULL}, - {EXIFTAG_RECOMMENDEDEXPOSUREINDEX, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RecommendedExposureIndex", NULL}, - {EXIFTAG_ISOSPEED, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeed", NULL}, - {EXIFTAG_ISOSPEEDLATITUDEYYY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudeyyy", NULL}, - {EXIFTAG_ISOSPEEDLATITUDEZZZ, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudezzz", NULL}, - {EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExifVersion", NULL}, - {EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeOriginal", NULL}, - {EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeDigitized", NULL}, - {EXIFTAG_OFFSETTIME, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTime", NULL}, - {EXIFTAG_OFFSETTIMEORIGINAL, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeOriginal", NULL}, - {EXIFTAG_OFFSETTIMEDIGITIZED, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeDigitized", NULL}, - {EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ComponentsConfiguration", NULL}, - {EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL}, - {EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL}, - {EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL}, - {EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL}, - {EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL}, - {EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL}, - /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance! - * However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values, - * which are not treated within LibTiff!! */ - {EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL}, - {EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeteringMode", NULL}, - {EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LightSource", NULL}, - {EXIFTAG_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Flash", NULL}, - {EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLength", NULL}, - {EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SubjectArea", NULL}, - {EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MakerNote", NULL}, - {EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "UserComment", NULL}, - {EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTime", NULL}, - {EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeOriginal", NULL}, - {EXIFTAG_SUBSECTIMEDIGITIZED, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeDigitized", NULL}, - {EXIFTAG_TEMPERATURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Temperature", NULL}, - {EXIFTAG_HUMIDITY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Humidity", NULL}, - {EXIFTAG_PRESSURE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Pressure", NULL}, - {EXIFTAG_WATERDEPTH, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WaterDepth", NULL}, - {EXIFTAG_ACCELERATION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Acceleration", NULL}, - {EXIFTAG_CAMERAELEVATIONANGLE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraElevationAngle", NULL}, - {EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashpixVersion", NULL}, - {EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorSpace", NULL}, - {EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelXDimension", NULL}, - {EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelYDimension", NULL}, - {EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RelatedSoundFile", NULL}, - {EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL}, - {EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SpatialFrequencyResponse", NULL}, - {EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL}, - {EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL}, - {EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneResolutionUnit", NULL}, - {EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectLocation", NULL}, - {EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL}, - {EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensingMethod", NULL}, - {EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FileSource", NULL}, - {EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneType", NULL}, - {EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPattern", NULL}, - {EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CustomRendered", NULL}, - {EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureMode", NULL}, - {EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhiteBalance", NULL}, - {EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL}, - {EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLengthIn35mmFilm", NULL}, - {EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneCaptureType", NULL}, - {EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GainControl", NULL}, - {EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Contrast", NULL}, - {EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Saturation", NULL}, - {EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Sharpness", NULL}, - {EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DeviceSettingDescription", NULL}, - {EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistanceRange", NULL}, - {EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL}, - {EXIFTAG_CAMERAOWNERNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraOwnerName", NULL}, - {EXIFTAG_BODYSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BodySerialNumber", NULL}, - {EXIFTAG_LENSSPECIFICATION, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSpecification", NULL}, - {EXIFTAG_LENSMAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensMake", NULL}, - {EXIFTAG_LENSMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensModel", NULL}, - {EXIFTAG_LENSSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSerialNumber", NULL}, - {EXIFTAG_GAMMA, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Gamma", NULL}, - {EXIFTAG_COMPOSITEIMAGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompositeImage", NULL}, - {EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SourceImageNumberOfCompositeImage", NULL}, - {EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, - "SourceExposureTimesOfCompositeImage", NULL}}; +static const TIFFField +exifFields[] = { + { EXIFTAG_EXPOSURETIME, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureTime", NULL }, + { EXIFTAG_FNUMBER, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FNumber", NULL }, + { EXIFTAG_EXPOSUREPROGRAM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureProgram", NULL }, + { EXIFTAG_SPECTRALSENSITIVITY, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpectralSensitivity", NULL }, + { EXIFTAG_ISOSPEEDRATINGS, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ISOSpeedRatings", NULL }, + { EXIFTAG_OECF, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "OptoelectricConversionFactor", NULL }, + { EXIFTAG_SENSITIVITYTYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensitivityType", NULL }, + { EXIFTAG_STANDARDOUTPUTSENSITIVITY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "StandardOutputSensitivity", NULL }, + { EXIFTAG_RECOMMENDEDEXPOSUREINDEX, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RecommendedExposureIndex", NULL }, + { EXIFTAG_ISOSPEED, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeed", NULL }, + { EXIFTAG_ISOSPEEDLATITUDEYYY, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudeyyy", NULL }, + { EXIFTAG_ISOSPEEDLATITUDEZZZ, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ISOSpeedLatitudezzz", NULL }, + { EXIFTAG_EXIFVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExifVersion", NULL }, + { EXIFTAG_DATETIMEORIGINAL, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeOriginal", NULL }, + { EXIFTAG_DATETIMEDIGITIZED, 20, 20, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateTimeDigitized", NULL }, + { EXIFTAG_OFFSETTIME, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTime", NULL }, + { EXIFTAG_OFFSETTIMEORIGINAL, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeOriginal", NULL }, + { EXIFTAG_OFFSETTIMEDIGITIZED, 7, 7, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "OffsetTimeDigitized", NULL }, + { EXIFTAG_COMPONENTSCONFIGURATION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ComponentsConfiguration", NULL }, + { EXIFTAG_COMPRESSEDBITSPERPIXEL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompressedBitsPerPixel", NULL }, + { EXIFTAG_SHUTTERSPEEDVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ShutterSpeedValue", NULL }, + { EXIFTAG_APERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ApertureValue", NULL }, + { EXIFTAG_BRIGHTNESSVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BrightnessValue", NULL }, + { EXIFTAG_EXPOSUREBIASVALUE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureBiasValue", NULL }, + { EXIFTAG_MAXAPERTUREVALUE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MaxApertureValue", NULL }, + /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance! + * However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values, + * which are not treated within LibTiff!! */ + { EXIFTAG_SUBJECTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistance", NULL }, + { EXIFTAG_METERINGMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeteringMode", NULL }, + { EXIFTAG_LIGHTSOURCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LightSource", NULL }, + { EXIFTAG_FLASH, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Flash", NULL }, + { EXIFTAG_FOCALLENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLength", NULL }, + { EXIFTAG_SUBJECTAREA, -1, -1, TIFF_SHORT, 0, TIFF_SETGET_C16_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SubjectArea", NULL }, + { EXIFTAG_MAKERNOTE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "MakerNote", NULL }, + { EXIFTAG_USERCOMMENT, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "UserComment", NULL }, + { EXIFTAG_SUBSECTIME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTime", NULL }, + { EXIFTAG_SUBSECTIMEORIGINAL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeOriginal", NULL }, + { EXIFTAG_SUBSECTIMEDIGITIZED, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubSecTimeDigitized", NULL }, + { EXIFTAG_TEMPERATURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Temperature", NULL }, + { EXIFTAG_HUMIDITY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Humidity", NULL }, + { EXIFTAG_PRESSURE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Pressure", NULL }, + { EXIFTAG_WATERDEPTH, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WaterDepth", NULL }, + { EXIFTAG_ACCELERATION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Acceleration", NULL }, + { EXIFTAG_CAMERAELEVATIONANGLE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraElevationAngle", NULL }, + { EXIFTAG_FLASHPIXVERSION, 4, 4, TIFF_UNDEFINED, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashpixVersion", NULL }, + { EXIFTAG_COLORSPACE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ColorSpace", NULL }, + { EXIFTAG_PIXELXDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelXDimension", NULL }, + { EXIFTAG_PIXELYDIMENSION, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "PixelYDimension", NULL }, + { EXIFTAG_RELATEDSOUNDFILE, 13, 13, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "RelatedSoundFile", NULL }, + { EXIFTAG_FLASHENERGY, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FlashEnergy", NULL }, + { EXIFTAG_SPATIALFREQUENCYRESPONSE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SpatialFrequencyResponse", NULL }, + { EXIFTAG_FOCALPLANEXRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneXResolution", NULL }, + { EXIFTAG_FOCALPLANEYRESOLUTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneYResolution", NULL }, + { EXIFTAG_FOCALPLANERESOLUTIONUNIT, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalPlaneResolutionUnit", NULL }, + { EXIFTAG_SUBJECTLOCATION, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectLocation", NULL }, + { EXIFTAG_EXPOSUREINDEX, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureIndex", NULL }, + { EXIFTAG_SENSINGMETHOD, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SensingMethod", NULL }, + { EXIFTAG_FILESOURCE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FileSource", NULL }, + { EXIFTAG_SCENETYPE, 1, 1, TIFF_UNDEFINED, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneType", NULL }, + { EXIFTAG_CFAPATTERN, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "CFAPattern", NULL }, + { EXIFTAG_CUSTOMRENDERED, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CustomRendered", NULL }, + { EXIFTAG_EXPOSUREMODE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ExposureMode", NULL }, + { EXIFTAG_WHITEBALANCE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "WhiteBalance", NULL }, + { EXIFTAG_DIGITALZOOMRATIO, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DigitalZoomRatio", NULL }, + { EXIFTAG_FOCALLENGTHIN35MMFILM, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "FocalLengthIn35mmFilm", NULL }, + { EXIFTAG_SCENECAPTURETYPE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SceneCaptureType", NULL }, + { EXIFTAG_GAINCONTROL, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "GainControl", NULL }, + { EXIFTAG_CONTRAST, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Contrast", NULL }, + { EXIFTAG_SATURATION, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Saturation", NULL }, + { EXIFTAG_SHARPNESS, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Sharpness", NULL }, + { EXIFTAG_DEVICESETTINGDESCRIPTION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "DeviceSettingDescription", NULL }, + { EXIFTAG_SUBJECTDISTANCERANGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SubjectDistanceRange", NULL }, + { EXIFTAG_IMAGEUNIQUEID, 33, 33, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImageUniqueID", NULL }, + { EXIFTAG_CAMERAOWNERNAME, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CameraOwnerName", NULL }, + { EXIFTAG_BODYSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "BodySerialNumber", NULL }, + { EXIFTAG_LENSSPECIFICATION, 4, 4, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSpecification", NULL }, + { EXIFTAG_LENSMAKE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensMake", NULL }, + { EXIFTAG_LENSMODEL, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensModel", NULL }, + { EXIFTAG_LENSSERIALNUMBER, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LensSerialNumber", NULL }, + { EXIFTAG_GAMMA, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Gamma", NULL }, + { EXIFTAG_COMPOSITEIMAGE, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "CompositeImage", NULL }, + { EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE, 2, 2, TIFF_SHORT, 0, TIFF_SETGET_C0_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SourceImageNumberOfCompositeImage", NULL }, + { EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "SourceExposureTimesOfCompositeImage", NULL } +}; /* - * EXIF-GPS tags (Version 2.31, July 2016; nothing changed for version 2.32 May - * 2019) + * EXIF-GPS tags (Version 2.31, July 2016; nothing changed for version 2.32 May 2019) */ -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! - * In order to achieve double precision for GPS tags: Standard definitions for GPSTAG is kept to TIFF_SETGET_DOUBLE - * and TIFF_SETGET_C0_FLOAT is changed to TIFF_SETGET_C0_DOUBLE. - */ - {GPSTAG_VERSIONID, 4, 4, TIFF_BYTE, 0, TIFF_SETGET_C0_UINT8, TIFF_SETGET_UINT8, FIELD_CUSTOM, 1, 0, "VersionID", NULL}, - {GPSTAG_LATITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LatitudeRef", NULL}, - {GPSTAG_LATITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Latitude", NULL}, - {GPSTAG_LONGITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "LongitudeRef", NULL}, - {GPSTAG_LONGITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Longitude", NULL}, - {GPSTAG_ALTITUDEREF, 1, 1, TIFF_BYTE, 0, TIFF_SETGET_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "AltitudeRef", NULL}, - {GPSTAG_ALTITUDE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Altitude", NULL}, - {GPSTAG_TIMESTAMP, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TimeStamp", NULL}, - {GPSTAG_SATELLITES, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Satellites", NULL}, - {GPSTAG_STATUS, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Status", NULL}, - {GPSTAG_MEASUREMODE, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MeasureMode", NULL}, - {GPSTAG_DOP, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DOP", NULL}, - {GPSTAG_SPEEDREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "SpeedRef", NULL}, - {GPSTAG_SPEED, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Speed", NULL}, - {GPSTAG_TRACKREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "TrackRef", NULL}, - {GPSTAG_TRACK, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Track", NULL}, - {GPSTAG_IMGDIRECTIONREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImgDirectionRef", NULL}, - {GPSTAG_IMGDIRECTION, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "ImgDirection", NULL}, - {GPSTAG_MAPDATUM, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "MapDatum", NULL}, - {GPSTAG_DESTLATITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLatitudeRef", NULL}, - {GPSTAG_DESTLATITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLatitude", NULL}, - {GPSTAG_DESTLONGITUDEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLongitudeRef", NULL}, - {GPSTAG_DESTLONGITUDE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestLongitude", NULL}, - {GPSTAG_DESTBEARINGREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestBearingRef", NULL}, - {GPSTAG_DESTBEARING, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestBearing", NULL}, - {GPSTAG_DESTDISTANCEREF, 2, 2, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestDistanceRef", NULL}, - {GPSTAG_DESTDISTANCE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DestDistance", NULL}, - {GPSTAG_PROCESSINGMETHOD, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "ProcessingMethod", NULL}, - {GPSTAG_AREAINFORMATION, -1, -1, TIFF_UNDEFINED, 0, TIFF_SETGET_C16_UINT8, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 1, "AreaInformation", NULL}, - {GPSTAG_DATESTAMP, 11, 11, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "DateStamp", NULL}, - {GPSTAG_DIFFERENTIAL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Differential", NULL}, - {GPSTAG_GPSHPOSITIONINGERROR, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "HorizontalPositioningError", NULL}}; -/* clang-format on */ /* was off for better readability of tag comments */ +static 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! + * In order to achieve double precision for GPS tags: + * Standard definitions for GPSTAG is kept to TIFF_SETGET_DOUBLE + * and TIFF_SETGET_C0_FLOAT is changed to TIFF_SETGET_C0_DOUBLE. + */ + { GPSTAG_VERSIONID , 4, 4, TIFF_BYTE , 0, TIFF_SETGET_C0_UINT8 , TIFF_SETGET_UINT8 , FIELD_CUSTOM , 1, 0, "VersionID", NULL }, + { GPSTAG_LATITUDEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "LatitudeRef", NULL }, + { GPSTAG_LATITUDE , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Latitude", NULL }, + { GPSTAG_LONGITUDEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "LongitudeRef", NULL }, + { GPSTAG_LONGITUDE , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Longitude", NULL }, + { GPSTAG_ALTITUDEREF , 1, 1, TIFF_BYTE , 0, TIFF_SETGET_UINT8 , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "AltitudeRef", NULL }, + { GPSTAG_ALTITUDE , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Altitude", NULL }, + { GPSTAG_TIMESTAMP , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "TimeStamp", NULL }, + { GPSTAG_SATELLITES , -1, -1, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Satellites", NULL }, + { GPSTAG_STATUS , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Status", NULL }, + { GPSTAG_MEASUREMODE , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "MeasureMode", NULL }, + { GPSTAG_DOP , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DOP", NULL }, + { GPSTAG_SPEEDREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "SpeedRef", NULL }, + { GPSTAG_SPEED , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Speed", NULL }, + { GPSTAG_TRACKREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "TrackRef", NULL }, + { GPSTAG_TRACK , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Track", NULL }, + { GPSTAG_IMGDIRECTIONREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "ImgDirectionRef", NULL }, + { GPSTAG_IMGDIRECTION , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "ImgDirection", NULL }, + { GPSTAG_MAPDATUM , -1, -1, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "MapDatum", NULL }, + { GPSTAG_DESTLATITUDEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestLatitudeRef", NULL }, + { GPSTAG_DESTLATITUDE , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestLatitude", NULL }, + { GPSTAG_DESTLONGITUDEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestLongitudeRef", NULL }, + { GPSTAG_DESTLONGITUDE , 3, 3, TIFF_RATIONAL , 0, TIFF_SETGET_C0_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestLongitude", NULL }, + { GPSTAG_DESTBEARINGREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestBearingRef", NULL }, + { GPSTAG_DESTBEARING , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestBearing", NULL }, + { GPSTAG_DESTDISTANCEREF , 2, 2, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestDistanceRef", NULL }, + { GPSTAG_DESTDISTANCE , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DestDistance", NULL }, + { GPSTAG_PROCESSINGMETHOD , -1, -1, TIFF_UNDEFINED , 0, TIFF_SETGET_C16_UINT8 , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 1, "ProcessingMethod", NULL }, + { GPSTAG_AREAINFORMATION , -1, -1, TIFF_UNDEFINED , 0, TIFF_SETGET_C16_UINT8 , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 1, "AreaInformation", NULL }, + { GPSTAG_DATESTAMP , 11, 11, TIFF_ASCII , 0, TIFF_SETGET_ASCII , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "DateStamp", NULL }, + { GPSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, TIFF_SETGET_UINT16 , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "Differential", NULL }, + { GPSTAG_GPSHPOSITIONINGERROR , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE , TIFF_SETGET_UNDEFINED , FIELD_CUSTOM , 1, 0, "HorizontalPositioningError", NULL } +}; -static const TIFFFieldArray tiffFieldArray = { - tfiatImage, 0, TIFFArrayCount(tiffFields), (TIFFField *)tiffFields}; -static const TIFFFieldArray exifFieldArray = { - tfiatExif, 0, TIFFArrayCount(exifFields), (TIFFField *)exifFields}; -static const TIFFFieldArray gpsFieldArray = { - tfiatGps, 0, TIFFArrayCount(gpsFields), (TIFFField *)gpsFields}; +static const TIFFFieldArray +tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), (TIFFField*) tiffFields }; +static const TIFFFieldArray +exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields), (TIFFField*) exifFields }; +static const TIFFFieldArray +gpsFieldArray = { tfiatGps, 0, TIFFArrayCount(gpsFields), (TIFFField*) gpsFields }; /* * We have our own local lfind() equivalent to avoid subtle differences - * in types passed to lfind() on different systems. + * in types passed to lfind() on different systems. */ -static void *td_lfind(const void *key, const void *base, size_t *nmemb, - size_t size, int (*compar)(const void *, const void *)) +static void * +td_lfind(const void *key, const void *base, size_t *nmemb, size_t size, + int(*compar)(const void *, const void *)) { char *element, *end; end = (char *)base + *nmemb * size; for (element = (char *)base; element < end; element += size) - if (!compar(key, element)) /* key found */ + if (!compar(key, element)) /* key found */ return element; return NULL; } -const TIFFFieldArray *_TIFFGetFields(void) { return (&tiffFieldArray); } - -const TIFFFieldArray *_TIFFGetExifFields(void) { return (&exifFieldArray); } - -const TIFFFieldArray *_TIFFGetGpsFields(void) { return (&gpsFieldArray); } - -void _TIFFSetupFields(TIFF *tif, const TIFFFieldArray *fieldarray) +const TIFFFieldArray* +_TIFFGetFields(void) { - if (tif->tif_fields && tif->tif_nfields > 0) - { - uint32_t i; + return(&tiffFieldArray); +} - for (i = 0; i < tif->tif_nfields; i++) - { - TIFFField *fld = tif->tif_fields[i]; - if (fld->field_name != NULL) - { - if (fld->field_bit == FIELD_CUSTOM && TIFFFieldIsAnonymous(fld)) - { - _TIFFfreeExt(tif, fld->field_name); - /* caution: tif_fields[i] must not be the beginning of a - * fields-array. Otherwise the following tags are also freed - * with the first free(). - */ - _TIFFfreeExt(tif, fld); +const TIFFFieldArray* +_TIFFGetExifFields(void) +{ + return(&exifFieldArray); +} + +const TIFFFieldArray* +_TIFFGetGpsFields(void) +{ + return(&gpsFieldArray); +} + +void +_TIFFSetupFields(TIFF* tif, const TIFFFieldArray* fieldarray) +{ + if (tif->tif_fields && tif->tif_nfields > 0) { + uint32 i; + + for (i = 0; i < tif->tif_nfields; i++) { + TIFFField *fld = tif->tif_fields[i]; + if (fld->field_name != NULL) { + if (fld->field_bit == FIELD_CUSTOM && + TIFFFieldIsAnonymous(fld)) { + _TIFFfree(fld->field_name); + /* catuion: tif_fields[i] must not be the beginning of a fields-array. + * Otherwise the following tags are also freed with the first free(). + */ + _TIFFfree(fld); + } + } + } + + _TIFFfree(tif->tif_fields); + tif->tif_fields = NULL; + tif->tif_nfields = 0; + } + if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count)) { + TIFFErrorExt(tif->tif_clientdata, "_TIFFSetupFields", + "Setting up field info failed"); + } +} + +static int +tagCompare(const void* a, const void* b) +{ + const TIFFField* ta = *(const TIFFField**) a; + const TIFFField* tb = *(const TIFFField**) b; + /* NB: be careful of return values for 16-bit platforms */ + if (ta->field_tag != tb->field_tag) + return (int)ta->field_tag - (int)tb->field_tag; + else + return (ta->field_type == TIFF_ANY) ? + 0 : ((int)tb->field_type - (int)ta->field_type); +} + +static int +tagNameCompare(const void* a, const void* b) +{ + const TIFFField* ta = *(const TIFFField**) a; + const TIFFField* tb = *(const TIFFField**) b; + int ret = strcmp(ta->field_name, tb->field_name); + + if (ret) + return ret; + else + return (ta->field_type == TIFF_ANY) ? + 0 : ((int)tb->field_type - (int)ta->field_type); +} + +int +_TIFFMergeFields(TIFF* tif, const TIFFField info[], uint32 n) +{ + static const char module[] = "_TIFFMergeFields"; + static const char reason[] = "for fields array"; + /* TIFFField** tp; */ + uint32 i; + + tif->tif_foundfield = NULL; + + if (tif->tif_fields && tif->tif_nfields > 0) { + tif->tif_fields = (TIFFField**) + _TIFFCheckRealloc(tif, tif->tif_fields, + (tif->tif_nfields + n), + sizeof(TIFFField *), reason); + } else { + tif->tif_fields = (TIFFField **) + _TIFFCheckMalloc(tif, n, sizeof(TIFFField *), + reason); + } + if (!tif->tif_fields) { + TIFFErrorExt(tif->tif_clientdata, module, + "Failed to allocate fields array"); + return 0; + } + + /* tp = tif->tif_fields + tif->tif_nfields; */ + for (i = 0; i < n; i++) { + const TIFFField *fip = + TIFFFindField(tif, info[i].field_tag, TIFF_ANY); + + /* only add definitions that aren't already present */ + if (!fip) { + tif->tif_fields[tif->tif_nfields] = (TIFFField *) (info+i); + tif->tif_nfields++; } - } - } + } - _TIFFfreeExt(tif, tif->tif_fields); - tif->tif_fields = NULL; - tif->tif_nfields = 0; - } - if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count)) - { - TIFFErrorExtR(tif, "_TIFFSetupFields", "Setting up field info failed"); - } + /* Sort the field info by tag number */ + qsort(tif->tif_fields, tif->tif_nfields, + sizeof(TIFFField *), tagCompare); + + return n; } -static int tagCompare(const void *a, const void *b) +void +_TIFFPrintFieldInfo(TIFF* tif, FILE* fd) { - const TIFFField *ta = *(const TIFFField **)a; - const TIFFField *tb = *(const TIFFField **)b; - /* NB: be careful of return values for 16-bit platforms */ - if (ta->field_tag != tb->field_tag) - return (int)ta->field_tag - (int)tb->field_tag; - else - return (ta->field_type == TIFF_ANY) - ? 0 - : ((int)tb->field_type - (int)ta->field_type); -} + uint32 i; -static int tagNameCompare(const void *a, const void *b) -{ - const TIFFField *ta = *(const TIFFField **)a; - const TIFFField *tb = *(const TIFFField **)b; - int ret = strcmp(ta->field_name, tb->field_name); - - if (ret) - return ret; - else - return (ta->field_type == TIFF_ANY) - ? 0 - : ((int)tb->field_type - (int)ta->field_type); -} - -int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32_t n) -{ - static const char module[] = "_TIFFMergeFields"; - static const char reason[] = "for fields array"; - /* TIFFField** tp; */ - uint32_t i; - - tif->tif_foundfield = NULL; - - if (tif->tif_fields && tif->tif_nfields > 0) - { - tif->tif_fields = (TIFFField **)_TIFFCheckRealloc( - tif, tif->tif_fields, (tif->tif_nfields + n), sizeof(TIFFField *), - reason); - } - else - { - tif->tif_fields = - (TIFFField **)_TIFFCheckMalloc(tif, n, sizeof(TIFFField *), reason); - } - if (!tif->tif_fields) - { - TIFFErrorExtR(tif, module, "Failed to allocate fields array"); - return 0; - } - - /* tp = tif->tif_fields + tif->tif_nfields; */ - for (i = 0; i < n; i++) - { - const TIFFField *fip = TIFFFindField(tif, info[i].field_tag, TIFF_ANY); - - /* only add definitions that aren't already present */ - if (!fip) - { - tif->tif_fields[tif->tif_nfields] = (TIFFField *)(info + i); - tif->tif_nfields++; - } - } - - /* Sort the field info by tag number */ - qsort(tif->tif_fields, tif->tif_nfields, sizeof(TIFFField *), tagCompare); - - return n; -} - -void _TIFFPrintFieldInfo(TIFF *tif, FILE *fd) -{ - uint32_t i; - - fprintf(fd, "%s: \n", tif->tif_name); - for (i = 0; i < tif->tif_nfields; i++) - { - const TIFFField *fip = tif->tif_fields[i]; - fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n", - (int)i, (unsigned long)fip->field_tag, fip->field_readcount, - fip->field_writecount, fip->field_type, fip->field_bit, - fip->field_oktochange ? "TRUE" : "FALSE", - fip->field_passcount ? "TRUE" : "FALSE", fip->field_name); - } + fprintf(fd, "%s: \n", tif->tif_name); + for (i = 0; i < tif->tif_nfields; i++) { + const TIFFField* fip = tif->tif_fields[i]; + fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n" + , (int)i + , (unsigned long) fip->field_tag + , fip->field_readcount, fip->field_writecount + , fip->field_type + , fip->field_bit + , fip->field_oktochange ? "TRUE" : "FALSE" + , fip->field_passcount ? "TRUE" : "FALSE" + , fip->field_name + ); + } } /* * Return size of TIFFDataType within TIFF-file in bytes */ -int TIFFDataWidth(TIFFDataType type) +int +TIFFDataWidth(TIFFDataType type) { - switch (type) - { - case 0: /* nothing */ - case TIFF_BYTE: - case TIFF_ASCII: - case TIFF_SBYTE: - case TIFF_UNDEFINED: - return 1; - case TIFF_SHORT: - case TIFF_SSHORT: - return 2; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - case TIFF_IFD: - return 4; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_DOUBLE: - case TIFF_LONG8: - case TIFF_SLONG8: - case TIFF_IFD8: - return 8; - default: - return 0; /* will return 0 for unknown types */ - } + switch(type) + { + case 0: /* nothing */ + case TIFF_BYTE: + case TIFF_ASCII: + case TIFF_SBYTE: + case TIFF_UNDEFINED: + return 1; + case TIFF_SHORT: + case TIFF_SSHORT: + return 2; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + case TIFF_IFD: + return 4; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_DOUBLE: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_IFD8: + return 8; + default: + return 0; /* will return 0 for unknown types */ + } } /* - * Return internal storage size of TIFFSetGetFieldType in bytes. - * TIFFSetField() and TIFFGetField() have to provide the parameter accordingly. - * Replaces internal functions _TIFFDataSize() and _TIFFSetGetFieldSize() - * with now extern available function TIFFFieldSetGetSize(). + * Return size of TIFFDataType in bytes. + * + * XXX: We need a separate function to determine the space needed + * to store the value. For TIFF_RATIONAL values TIFFDataWidth() returns 8, + * but we use 4-byte float to represent rationals. */ -int TIFFFieldSetGetSize(const TIFFField *fip) +int +_TIFFDataSize(TIFFDataType type) { - /* - * TIFFSetField() and TIFFGetField() must provide the parameter accordingly - * to the definition of "set_field_type" of the tag definition in - * dir_info.c. This function returns the data size for that purpose. - * - * Furthermore, this data size is also used for the internal storage, - * even for TIFF_RATIONAL values for FIELD_CUSTOM, which are stored - * internally as 4-byte float, but some of them should be stored internally - * as 8-byte double, depending on the "set_field_type" _FLOAT_ or _DOUBLE_. - */ - if (fip == NULL) - return 0; - - switch (fip->set_field_type) - { - case TIFF_SETGET_UNDEFINED: - case TIFF_SETGET_ASCII: - case TIFF_SETGET_C0_ASCII: - case TIFF_SETGET_C16_ASCII: - case TIFF_SETGET_C32_ASCII: - case TIFF_SETGET_OTHER: - return 1; - case TIFF_SETGET_UINT8: - case TIFF_SETGET_SINT8: - case TIFF_SETGET_C0_UINT8: - case TIFF_SETGET_C0_SINT8: - case TIFF_SETGET_C16_UINT8: - case TIFF_SETGET_C16_SINT8: - case TIFF_SETGET_C32_UINT8: - case TIFF_SETGET_C32_SINT8: - return 1; - case TIFF_SETGET_UINT16: - case TIFF_SETGET_SINT16: - case TIFF_SETGET_C0_UINT16: - case TIFF_SETGET_C0_SINT16: - case TIFF_SETGET_C16_UINT16: - case TIFF_SETGET_C16_SINT16: - case TIFF_SETGET_C32_UINT16: - case TIFF_SETGET_C32_SINT16: - return 2; - case TIFF_SETGET_INT: - case TIFF_SETGET_UINT32: - case TIFF_SETGET_SINT32: - case TIFF_SETGET_FLOAT: - case TIFF_SETGET_UINT16_PAIR: - case TIFF_SETGET_C0_UINT32: - case TIFF_SETGET_C0_SINT32: - case TIFF_SETGET_C0_FLOAT: - case TIFF_SETGET_C16_UINT32: - case TIFF_SETGET_C16_SINT32: - case TIFF_SETGET_C16_FLOAT: - case TIFF_SETGET_C32_UINT32: - case TIFF_SETGET_C32_SINT32: - case TIFF_SETGET_C32_FLOAT: - return 4; - case TIFF_SETGET_UINT64: - case TIFF_SETGET_SINT64: - case TIFF_SETGET_DOUBLE: - case TIFF_SETGET_IFD8: - case TIFF_SETGET_C0_UINT64: - case TIFF_SETGET_C0_SINT64: - case TIFF_SETGET_C0_DOUBLE: - case TIFF_SETGET_C0_IFD8: - case TIFF_SETGET_C16_UINT64: - case TIFF_SETGET_C16_SINT64: - case TIFF_SETGET_C16_DOUBLE: - case TIFF_SETGET_C16_IFD8: - case TIFF_SETGET_C32_UINT64: - case TIFF_SETGET_C32_SINT64: - case TIFF_SETGET_C32_DOUBLE: - case TIFF_SETGET_C32_IFD8: - return 8; - default: - return 0; - } -} /*-- TIFFFieldSetGetSize() --- */ + switch (type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_ASCII: + case TIFF_UNDEFINED: + return 1; + case TIFF_SHORT: + case TIFF_SSHORT: + return 2; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + case TIFF_IFD: + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + return 4; + case TIFF_DOUBLE: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_IFD8: + return 8; + default: + return 0; + } +} /* - * Return size of count parameter of TIFFSetField() and TIFFGetField() - * and also if it is required: 0=none, 2=uint16_t, 4=uint32_t + * Rational2Double: + * Return size of TIFFSetGetFieldType for internal storage in bytes. + * + * XXX: TIFF_RATIONAL values for FIELD_CUSTOM are stored internally as 4-byte float. + * However, some of them should be stored internally as 8-byte double. + * This is now managed by the SetGetField of the tag-definition! */ -int TIFFFieldSetGetCountSize(const TIFFField *fip) +int +_TIFFSetGetFieldSize(TIFFSetGetFieldType setgettype) { - if (fip == NULL) - return 0; + switch (setgettype) + { + case TIFF_SETGET_UNDEFINED: + case TIFF_SETGET_ASCII: + case TIFF_SETGET_C0_ASCII: + case TIFF_SETGET_C16_ASCII: + case TIFF_SETGET_C32_ASCII: + case TIFF_SETGET_OTHER: + return 1; + case TIFF_SETGET_UINT8: + case TIFF_SETGET_SINT8: + case TIFF_SETGET_C0_UINT8: + case TIFF_SETGET_C0_SINT8: + case TIFF_SETGET_C16_UINT8: + case TIFF_SETGET_C16_SINT8: + case TIFF_SETGET_C32_UINT8: + case TIFF_SETGET_C32_SINT8: + return 1; + case TIFF_SETGET_UINT16: + case TIFF_SETGET_SINT16: + case TIFF_SETGET_C0_UINT16: + case TIFF_SETGET_C0_SINT16: + case TIFF_SETGET_C16_UINT16: + case TIFF_SETGET_C16_SINT16: + case TIFF_SETGET_C32_UINT16: + case TIFF_SETGET_C32_SINT16: + return 2; + case TIFF_SETGET_INT: + case TIFF_SETGET_UINT32: + case TIFF_SETGET_SINT32: + case TIFF_SETGET_FLOAT: + case TIFF_SETGET_UINT16_PAIR: + case TIFF_SETGET_C0_UINT32: + case TIFF_SETGET_C0_SINT32: + case TIFF_SETGET_C0_FLOAT: + case TIFF_SETGET_C16_UINT32: + case TIFF_SETGET_C16_SINT32: + case TIFF_SETGET_C16_FLOAT: + case TIFF_SETGET_C32_UINT32: + case TIFF_SETGET_C32_SINT32: + case TIFF_SETGET_C32_FLOAT: + return 4; + case TIFF_SETGET_UINT64: + case TIFF_SETGET_SINT64: + case TIFF_SETGET_DOUBLE: + case TIFF_SETGET_IFD8: + case TIFF_SETGET_C0_UINT64: + case TIFF_SETGET_C0_SINT64: + case TIFF_SETGET_C0_DOUBLE: + case TIFF_SETGET_C0_IFD8: + case TIFF_SETGET_C16_UINT64: + case TIFF_SETGET_C16_SINT64: + case TIFF_SETGET_C16_DOUBLE: + case TIFF_SETGET_C16_IFD8: + case TIFF_SETGET_C32_UINT64: + case TIFF_SETGET_C32_SINT64: + case TIFF_SETGET_C32_DOUBLE: + case TIFF_SETGET_C32_IFD8: + return 8; + default: + return 0; + } +} /*-- _TIFFSetGetFieldSize --- */ - switch (fip->set_field_type) - { - case TIFF_SETGET_C16_ASCII: - case TIFF_SETGET_C16_UINT8: - case TIFF_SETGET_C16_SINT8: - case TIFF_SETGET_C16_UINT16: - case TIFF_SETGET_C16_SINT16: - case TIFF_SETGET_C16_UINT32: - case TIFF_SETGET_C16_SINT32: - case TIFF_SETGET_C16_FLOAT: - case TIFF_SETGET_C16_UINT64: - case TIFF_SETGET_C16_SINT64: - case TIFF_SETGET_C16_DOUBLE: - case TIFF_SETGET_C16_IFD8: - return 2; - case TIFF_SETGET_C32_ASCII: - case TIFF_SETGET_C32_UINT8: - case TIFF_SETGET_C32_SINT8: - case TIFF_SETGET_C32_UINT16: - case TIFF_SETGET_C32_SINT16: - case TIFF_SETGET_C32_UINT32: - case TIFF_SETGET_C32_SINT32: - case TIFF_SETGET_C32_FLOAT: - case TIFF_SETGET_C32_UINT64: - case TIFF_SETGET_C32_SINT64: - case TIFF_SETGET_C32_DOUBLE: - case TIFF_SETGET_C32_IFD8: - return 4; - default: - return 0; - } -} /*-- TIFFFieldSetGetCountSize() --- */ -const TIFFField *TIFFFindField(TIFF *tif, uint32_t tag, TIFFDataType dt) +const TIFFField* +TIFFFindField(TIFF* tif, uint32 tag, TIFFDataType dt) { - TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; - TIFFField *pkey = &key; - const TIFFField **ret; - if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag && - (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) - return tif->tif_foundfield; + TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; + TIFFField* pkey = &key; + const TIFFField **ret; + if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag && + (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) + return tif->tif_foundfield; - /* If we are invoked with no field information, then just return. */ - if (!tif->tif_fields) - return NULL; + /* If we are invoked with no field information, then just return. */ + if (!tif->tif_fields) + return NULL; - /* NB: use sorted search (e.g. binary search) */ + /* NB: use sorted search (e.g. binary search) */ - key.field_tag = tag; - key.field_type = dt; + key.field_tag = tag; + key.field_type = dt; - ret = (const TIFFField **)bsearch(&pkey, tif->tif_fields, tif->tif_nfields, - sizeof(TIFFField *), tagCompare); - return tif->tif_foundfield = (ret ? *ret : NULL); + ret = (const TIFFField **) bsearch(&pkey, tif->tif_fields, + tif->tif_nfields, + sizeof(TIFFField *), tagCompare); + return tif->tif_foundfield = (ret ? *ret : NULL); } -static const TIFFField *_TIFFFindFieldByName(TIFF *tif, const char *field_name, - TIFFDataType dt) +static const TIFFField* +_TIFFFindFieldByName(TIFF* tif, const char *field_name, TIFFDataType dt) { - TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; - TIFFField *pkey = &key; - const TIFFField **ret; - if (tif->tif_foundfield && - streq(tif->tif_foundfield->field_name, field_name) && - (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) - return (tif->tif_foundfield); + TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL}; + TIFFField* pkey = &key; + const TIFFField **ret; + if (tif->tif_foundfield + && streq(tif->tif_foundfield->field_name, field_name) + && (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type)) + return (tif->tif_foundfield); - /* If we are invoked with no field information, then just return. */ - if (!tif->tif_fields) - return NULL; + /* If we are invoked with no field information, then just return. */ + if (!tif->tif_fields) + return NULL; - /* NB: use linear search since list is sorted by key#, not name */ + /* NB: use linear search since list is sorted by key#, not name */ - key.field_name = (char *)field_name; - key.field_type = dt; + key.field_name = (char *)field_name; + key.field_type = dt; - ret = - (const TIFFField **)td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields, - sizeof(TIFFField *), tagNameCompare); + ret = (const TIFFField **) + td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields, + sizeof(TIFFField *), tagNameCompare); - return tif->tif_foundfield = (ret ? *ret : NULL); + return tif->tif_foundfield = (ret ? *ret : NULL); } -const TIFFField *TIFFFieldWithTag(TIFF *tif, uint32_t tag) +const TIFFField* +TIFFFieldWithTag(TIFF* tif, uint32 tag) { - const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY); - if (!fip) - { - TIFFWarningExtR(tif, "TIFFFieldWithTag", "Warning, unknown tag 0x%x", - (unsigned int)tag); - } - return (fip); + const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY); + if (!fip) { + TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag", + "Internal error, unknown tag 0x%x", + (unsigned int) tag); + } + return (fip); } -const TIFFField *TIFFFieldWithName(TIFF *tif, const char *field_name) +const TIFFField* +TIFFFieldWithName(TIFF* tif, const char *field_name) { - const TIFFField *fip = _TIFFFindFieldByName(tif, field_name, TIFF_ANY); - if (!fip) - { - TIFFWarningExtR(tif, "TIFFFieldWithName", "Warning, unknown tag %s", - field_name); - } - return (fip); + const TIFFField* fip = + _TIFFFindFieldByName(tif, field_name, TIFF_ANY); + if (!fip) { + TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName", + "Internal error, unknown tag %s", field_name); + } + return (fip); } -uint32_t TIFFFieldTag(const TIFFField *fip) { return fip->field_tag; } - -const char *TIFFFieldName(const TIFFField *fip) { return fip->field_name; } - -TIFFDataType TIFFFieldDataType(const TIFFField *fip) { return fip->field_type; } - -int TIFFFieldPassCount(const TIFFField *fip) { return fip->field_passcount; } - -int TIFFFieldReadCount(const TIFFField *fip) { return fip->field_readcount; } - -int TIFFFieldWriteCount(const TIFFField *fip) { return fip->field_writecount; } - -int TIFFFieldIsAnonymous(const TIFFField *fip) { return fip->field_anonymous; } - -const TIFFField *_TIFFFindOrRegisterField(TIFF *tif, uint32_t tag, - TIFFDataType dt) - +uint32 +TIFFFieldTag(const TIFFField* fip) { - const TIFFField *fld; - - fld = TIFFFindField(tif, tag, dt); - if (fld == NULL) - { - fld = _TIFFCreateAnonField(tif, tag, dt); - if (!_TIFFMergeFields(tif, fld, 1)) - return NULL; - } - - return fld; + return fip->field_tag; } -TIFFField *_TIFFCreateAnonField(TIFF *tif, uint32_t tag, - TIFFDataType field_type) +const char * +TIFFFieldName(const TIFFField* fip) { - TIFFField *fld; - (void)tif; + return fip->field_name; +} - fld = (TIFFField *)_TIFFmallocExt(tif, sizeof(TIFFField)); - if (fld == NULL) - return NULL; - _TIFFmemset(fld, 0, sizeof(TIFFField)); +TIFFDataType +TIFFFieldDataType(const TIFFField* fip) +{ + return fip->field_type; +} - fld->field_tag = tag; - fld->field_readcount = TIFF_VARIABLE2; - fld->field_writecount = TIFF_VARIABLE2; - fld->field_type = field_type; - fld->field_anonymous = - 1; /* indicate that this is an anonymous / unknown tag */ - switch (field_type) - { - case TIFF_BYTE: - case TIFF_UNDEFINED: - fld->set_field_type = TIFF_SETGET_C32_UINT8; - fld->get_field_type = TIFF_SETGET_C32_UINT8; - break; - case TIFF_ASCII: - fld->set_field_type = TIFF_SETGET_C32_ASCII; - fld->get_field_type = TIFF_SETGET_C32_ASCII; - break; - case TIFF_SHORT: - fld->set_field_type = TIFF_SETGET_C32_UINT16; - fld->get_field_type = TIFF_SETGET_C32_UINT16; - break; - case TIFF_LONG: - fld->set_field_type = TIFF_SETGET_C32_UINT32; - fld->get_field_type = TIFF_SETGET_C32_UINT32; - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - fld->set_field_type = TIFF_SETGET_C32_FLOAT; - fld->get_field_type = TIFF_SETGET_C32_FLOAT; - break; - case TIFF_SBYTE: - fld->set_field_type = TIFF_SETGET_C32_SINT8; - fld->get_field_type = TIFF_SETGET_C32_SINT8; - break; - case TIFF_SSHORT: - fld->set_field_type = TIFF_SETGET_C32_SINT16; - fld->get_field_type = TIFF_SETGET_C32_SINT16; - break; - case TIFF_SLONG: - fld->set_field_type = TIFF_SETGET_C32_SINT32; - fld->get_field_type = TIFF_SETGET_C32_SINT32; - break; - case TIFF_DOUBLE: - fld->set_field_type = TIFF_SETGET_C32_DOUBLE; - fld->get_field_type = TIFF_SETGET_C32_DOUBLE; - break; - case TIFF_IFD: - case TIFF_IFD8: - fld->set_field_type = TIFF_SETGET_C32_IFD8; - fld->get_field_type = TIFF_SETGET_C32_IFD8; - break; - case TIFF_LONG8: - fld->set_field_type = TIFF_SETGET_C32_UINT64; - fld->get_field_type = TIFF_SETGET_C32_UINT64; - break; - case TIFF_SLONG8: - fld->set_field_type = TIFF_SETGET_C32_SINT64; - fld->get_field_type = TIFF_SETGET_C32_SINT64; - break; - default: - fld->set_field_type = TIFF_SETGET_UNDEFINED; - fld->get_field_type = TIFF_SETGET_UNDEFINED; - break; - } - fld->field_bit = FIELD_CUSTOM; - fld->field_oktochange = TRUE; - fld->field_passcount = TRUE; - fld->field_name = (char *)_TIFFmallocExt(tif, 32); - if (fld->field_name == NULL) - { - _TIFFfreeExt(tif, fld); - return NULL; - } - fld->field_subfields = NULL; +int +TIFFFieldPassCount(const TIFFField* fip) +{ + return fip->field_passcount; +} - /* - * note that this name is a special sign to TIFFClose() and - * _TIFFSetupFields() to free the field - * Update: - * This special sign is replaced by fld->field_anonymous flag. - */ - (void)snprintf(fld->field_name, 32, "Tag %d", (int)tag); +int +TIFFFieldReadCount(const TIFFField* fip) +{ + return fip->field_readcount; +} - return fld; +int +TIFFFieldWriteCount(const TIFFField* fip) +{ + return fip->field_writecount; +} + +int +TIFFFieldIsAnonymous(const TIFFField *fip) +{ + return fip->field_anonymous; +} + +const TIFFField* +_TIFFFindOrRegisterField(TIFF *tif, uint32 tag, TIFFDataType dt) + +{ + const TIFFField *fld; + + fld = TIFFFindField(tif, tag, dt); + if (fld == NULL) { + fld = _TIFFCreateAnonField(tif, tag, dt); + if (!_TIFFMergeFields(tif, fld, 1)) + return NULL; + } + + return fld; +} + +TIFFField* +_TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type) +{ + TIFFField *fld; + (void) tif; + + fld = (TIFFField *) _TIFFmalloc(sizeof (TIFFField)); + if (fld == NULL) + return NULL; + _TIFFmemset(fld, 0, sizeof(TIFFField)); + + fld->field_tag = tag; + fld->field_readcount = TIFF_VARIABLE2; + fld->field_writecount = TIFF_VARIABLE2; + fld->field_type = field_type; + fld->field_anonymous = 1; /* indicate that this is an anonymous / unknown tag */ + switch (field_type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + fld->set_field_type = TIFF_SETGET_C32_UINT8; + fld->get_field_type = TIFF_SETGET_C32_UINT8; + break; + case TIFF_ASCII: + fld->set_field_type = TIFF_SETGET_C32_ASCII; + fld->get_field_type = TIFF_SETGET_C32_ASCII; + break; + case TIFF_SHORT: + fld->set_field_type = TIFF_SETGET_C32_UINT16; + fld->get_field_type = TIFF_SETGET_C32_UINT16; + break; + case TIFF_LONG: + fld->set_field_type = TIFF_SETGET_C32_UINT32; + fld->get_field_type = TIFF_SETGET_C32_UINT32; + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + fld->set_field_type = TIFF_SETGET_C32_FLOAT; + fld->get_field_type = TIFF_SETGET_C32_FLOAT; + break; + case TIFF_SBYTE: + fld->set_field_type = TIFF_SETGET_C32_SINT8; + fld->get_field_type = TIFF_SETGET_C32_SINT8; + break; + case TIFF_SSHORT: + fld->set_field_type = TIFF_SETGET_C32_SINT16; + fld->get_field_type = TIFF_SETGET_C32_SINT16; + break; + case TIFF_SLONG: + fld->set_field_type = TIFF_SETGET_C32_SINT32; + fld->get_field_type = TIFF_SETGET_C32_SINT32; + break; + case TIFF_DOUBLE: + fld->set_field_type = TIFF_SETGET_C32_DOUBLE; + fld->get_field_type = TIFF_SETGET_C32_DOUBLE; + break; + case TIFF_IFD: + case TIFF_IFD8: + fld->set_field_type = TIFF_SETGET_C32_IFD8; + fld->get_field_type = TIFF_SETGET_C32_IFD8; + break; + case TIFF_LONG8: + fld->set_field_type = TIFF_SETGET_C32_UINT64; + fld->get_field_type = TIFF_SETGET_C32_UINT64; + break; + case TIFF_SLONG8: + fld->set_field_type = TIFF_SETGET_C32_SINT64; + fld->get_field_type = TIFF_SETGET_C32_SINT64; + break; + default: + fld->set_field_type = TIFF_SETGET_UNDEFINED; + fld->get_field_type = TIFF_SETGET_UNDEFINED; + break; + } + fld->field_bit = FIELD_CUSTOM; + fld->field_oktochange = TRUE; + fld->field_passcount = TRUE; + fld->field_name = (char *) _TIFFmalloc(32); + if (fld->field_name == NULL) { + _TIFFfree(fld); + return NULL; + } + fld->field_subfields = NULL; + + /* + * note that this name is a special sign to TIFFClose() and + * _TIFFSetupFields() to free the field + * Update: + * This special sign is replaced by fld->field_anonymous flag. + */ + (void) snprintf(fld->field_name, 32, "Tag %d", (int) tag); + + return fld; } /**************************************************************************** @@ -999,353 +918,355 @@ TIFFField *_TIFFCreateAnonField(TIFF *tif, uint32_t tag, * libtiff versions. ****************************************************************************/ -static TIFFSetGetFieldType _TIFFSetGetType(TIFFDataType type, short count, - unsigned char passcount) +static TIFFSetGetFieldType +_TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount) { - if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0) - return TIFF_SETGET_ASCII; + if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0) + return TIFF_SETGET_ASCII; - else if (count == 1 && passcount == 0) - { - switch (type) - { - case TIFF_BYTE: - case TIFF_UNDEFINED: - return TIFF_SETGET_UINT8; - case TIFF_ASCII: - return TIFF_SETGET_ASCII; - case TIFF_SHORT: - return TIFF_SETGET_UINT16; - case TIFF_LONG: - return TIFF_SETGET_UINT32; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - return TIFF_SETGET_FLOAT; - case TIFF_SBYTE: - return TIFF_SETGET_SINT8; - case TIFF_SSHORT: - return TIFF_SETGET_SINT16; - case TIFF_SLONG: - return TIFF_SETGET_SINT32; - case TIFF_DOUBLE: - return TIFF_SETGET_DOUBLE; - case TIFF_IFD: - case TIFF_IFD8: - return TIFF_SETGET_IFD8; - case TIFF_LONG8: - return TIFF_SETGET_UINT64; - case TIFF_SLONG8: - return TIFF_SETGET_SINT64; - default: - return TIFF_SETGET_UNDEFINED; - } - } + else if (count == 1 && passcount == 0) { + switch (type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + return TIFF_SETGET_UINT8; + case TIFF_ASCII: + return TIFF_SETGET_ASCII; + case TIFF_SHORT: + return TIFF_SETGET_UINT16; + case TIFF_LONG: + return TIFF_SETGET_UINT32; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + return TIFF_SETGET_FLOAT; + case TIFF_SBYTE: + return TIFF_SETGET_SINT8; + case TIFF_SSHORT: + return TIFF_SETGET_SINT16; + case TIFF_SLONG: + return TIFF_SETGET_SINT32; + case TIFF_DOUBLE: + return TIFF_SETGET_DOUBLE; + case TIFF_IFD: + case TIFF_IFD8: + return TIFF_SETGET_IFD8; + case TIFF_LONG8: + return TIFF_SETGET_UINT64; + case TIFF_SLONG8: + return TIFF_SETGET_SINT64; + default: + return TIFF_SETGET_UNDEFINED; + } + } - else if (count >= 1 && passcount == 0) - { - switch (type) - { - case TIFF_BYTE: - case TIFF_UNDEFINED: - return TIFF_SETGET_C0_UINT8; - case TIFF_ASCII: - return TIFF_SETGET_C0_ASCII; - case TIFF_SHORT: - return TIFF_SETGET_C0_UINT16; - case TIFF_LONG: - return TIFF_SETGET_C0_UINT32; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - return TIFF_SETGET_C0_FLOAT; - case TIFF_SBYTE: - return TIFF_SETGET_C0_SINT8; - case TIFF_SSHORT: - return TIFF_SETGET_C0_SINT16; - case TIFF_SLONG: - return TIFF_SETGET_C0_SINT32; - case TIFF_DOUBLE: - return TIFF_SETGET_C0_DOUBLE; - case TIFF_IFD: - case TIFF_IFD8: - return TIFF_SETGET_C0_IFD8; - case TIFF_LONG8: - return TIFF_SETGET_C0_UINT64; - case TIFF_SLONG8: - return TIFF_SETGET_C0_SINT64; - default: - return TIFF_SETGET_UNDEFINED; - } - } + else if (count >= 1 && passcount == 0) { + switch (type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + return TIFF_SETGET_C0_UINT8; + case TIFF_ASCII: + return TIFF_SETGET_C0_ASCII; + case TIFF_SHORT: + return TIFF_SETGET_C0_UINT16; + case TIFF_LONG: + return TIFF_SETGET_C0_UINT32; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + return TIFF_SETGET_C0_FLOAT; + case TIFF_SBYTE: + return TIFF_SETGET_C0_SINT8; + case TIFF_SSHORT: + return TIFF_SETGET_C0_SINT16; + case TIFF_SLONG: + return TIFF_SETGET_C0_SINT32; + case TIFF_DOUBLE: + return TIFF_SETGET_C0_DOUBLE; + case TIFF_IFD: + case TIFF_IFD8: + return TIFF_SETGET_C0_IFD8; + case TIFF_LONG8: + return TIFF_SETGET_C0_UINT64; + case TIFF_SLONG8: + return TIFF_SETGET_C0_SINT64; + default: + return TIFF_SETGET_UNDEFINED; + } + } - else if (count == TIFF_VARIABLE && passcount == 1) - { - switch (type) - { - case TIFF_BYTE: - case TIFF_UNDEFINED: - return TIFF_SETGET_C16_UINT8; - case TIFF_ASCII: - return TIFF_SETGET_C16_ASCII; - case TIFF_SHORT: - return TIFF_SETGET_C16_UINT16; - case TIFF_LONG: - return TIFF_SETGET_C16_UINT32; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - return TIFF_SETGET_C16_FLOAT; - case TIFF_SBYTE: - return TIFF_SETGET_C16_SINT8; - case TIFF_SSHORT: - return TIFF_SETGET_C16_SINT16; - case TIFF_SLONG: - return TIFF_SETGET_C16_SINT32; - case TIFF_DOUBLE: - return TIFF_SETGET_C16_DOUBLE; - case TIFF_IFD: - case TIFF_IFD8: - return TIFF_SETGET_C16_IFD8; - case TIFF_LONG8: - return TIFF_SETGET_C16_UINT64; - case TIFF_SLONG8: - return TIFF_SETGET_C16_SINT64; - default: - return TIFF_SETGET_UNDEFINED; - } - } + else if (count == TIFF_VARIABLE && passcount == 1) { + switch (type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + return TIFF_SETGET_C16_UINT8; + case TIFF_ASCII: + return TIFF_SETGET_C16_ASCII; + case TIFF_SHORT: + return TIFF_SETGET_C16_UINT16; + case TIFF_LONG: + return TIFF_SETGET_C16_UINT32; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + return TIFF_SETGET_C16_FLOAT; + case TIFF_SBYTE: + return TIFF_SETGET_C16_SINT8; + case TIFF_SSHORT: + return TIFF_SETGET_C16_SINT16; + case TIFF_SLONG: + return TIFF_SETGET_C16_SINT32; + case TIFF_DOUBLE: + return TIFF_SETGET_C16_DOUBLE; + case TIFF_IFD: + case TIFF_IFD8: + return TIFF_SETGET_C16_IFD8; + case TIFF_LONG8: + return TIFF_SETGET_C16_UINT64; + case TIFF_SLONG8: + return TIFF_SETGET_C16_SINT64; + default: + return TIFF_SETGET_UNDEFINED; + } + } - else if (count == TIFF_VARIABLE2 && passcount == 1) - { - switch (type) - { - case TIFF_BYTE: - case TIFF_UNDEFINED: - return TIFF_SETGET_C32_UINT8; - case TIFF_ASCII: - return TIFF_SETGET_C32_ASCII; - case TIFF_SHORT: - return TIFF_SETGET_C32_UINT16; - case TIFF_LONG: - return TIFF_SETGET_C32_UINT32; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - return TIFF_SETGET_C32_FLOAT; - case TIFF_SBYTE: - return TIFF_SETGET_C32_SINT8; - case TIFF_SSHORT: - return TIFF_SETGET_C32_SINT16; - case TIFF_SLONG: - return TIFF_SETGET_C32_SINT32; - case TIFF_DOUBLE: - return TIFF_SETGET_C32_DOUBLE; - case TIFF_IFD: - case TIFF_IFD8: - return TIFF_SETGET_C32_IFD8; - case TIFF_LONG8: - return TIFF_SETGET_C32_UINT64; - case TIFF_SLONG8: - return TIFF_SETGET_C32_SINT64; - default: - return TIFF_SETGET_UNDEFINED; - } - } + else if (count == TIFF_VARIABLE2 && passcount == 1) { + switch (type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: + return TIFF_SETGET_C32_UINT8; + case TIFF_ASCII: + return TIFF_SETGET_C32_ASCII; + case TIFF_SHORT: + return TIFF_SETGET_C32_UINT16; + case TIFF_LONG: + return TIFF_SETGET_C32_UINT32; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + return TIFF_SETGET_C32_FLOAT; + case TIFF_SBYTE: + return TIFF_SETGET_C32_SINT8; + case TIFF_SSHORT: + return TIFF_SETGET_C32_SINT16; + case TIFF_SLONG: + return TIFF_SETGET_C32_SINT32; + case TIFF_DOUBLE: + return TIFF_SETGET_C32_DOUBLE; + case TIFF_IFD: + case TIFF_IFD8: + return TIFF_SETGET_C32_IFD8; + case TIFF_LONG8: + return TIFF_SETGET_C32_UINT64; + case TIFF_SLONG8: + return TIFF_SETGET_C32_SINT64; + default: + return TIFF_SETGET_UNDEFINED; + } + } - return TIFF_SETGET_UNDEFINED; + return TIFF_SETGET_UNDEFINED; } -int TIFFMergeFieldInfo(TIFF *tif, const TIFFFieldInfo info[], uint32_t n) +int +TIFFMergeFieldInfo(TIFF* tif, const TIFFFieldInfo info[], uint32 n) { - static const char module[] = "TIFFMergeFieldInfo"; - static const char reason[] = "for fields array"; - TIFFField *tp; - size_t nfields; - uint32_t i; + static const char module[] = "TIFFMergeFieldInfo"; + static const char reason[] = "for fields array"; + TIFFField *tp; + size_t nfields; + uint32 i; - if (tif->tif_nfieldscompat > 0) - { - tif->tif_fieldscompat = (TIFFFieldArray *)_TIFFCheckRealloc( - tif, tif->tif_fieldscompat, tif->tif_nfieldscompat + 1, - sizeof(TIFFFieldArray), reason); - } - else - { - tif->tif_fieldscompat = (TIFFFieldArray *)_TIFFCheckMalloc( - tif, 1, sizeof(TIFFFieldArray), reason); - } - if (!tif->tif_fieldscompat) - { - TIFFErrorExtR(tif, module, "Failed to allocate fields array"); - return -1; - } - nfields = tif->tif_nfieldscompat++; + if (tif->tif_nfieldscompat > 0) { + tif->tif_fieldscompat = (TIFFFieldArray *) + _TIFFCheckRealloc(tif, tif->tif_fieldscompat, + tif->tif_nfieldscompat + 1, + sizeof(TIFFFieldArray), reason); + } else { + tif->tif_fieldscompat = (TIFFFieldArray *) + _TIFFCheckMalloc(tif, 1, sizeof(TIFFFieldArray), + reason); + } + if (!tif->tif_fieldscompat) { + TIFFErrorExt(tif->tif_clientdata, module, + "Failed to allocate fields array"); + return -1; + } + nfields = tif->tif_nfieldscompat++; - tif->tif_fieldscompat[nfields].type = tfiatOther; - tif->tif_fieldscompat[nfields].allocated_size = n; - tif->tif_fieldscompat[nfields].count = n; - tif->tif_fieldscompat[nfields].fields = - (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField), reason); - if (!tif->tif_fieldscompat[nfields].fields) - { - TIFFErrorExtR(tif, module, "Failed to allocate fields array"); - return -1; - } + tif->tif_fieldscompat[nfields].type = tfiatOther; + tif->tif_fieldscompat[nfields].allocated_size = n; + tif->tif_fieldscompat[nfields].count = n; + tif->tif_fieldscompat[nfields].fields = + (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField), + reason); + if (!tif->tif_fieldscompat[nfields].fields) { + TIFFErrorExt(tif->tif_clientdata, module, + "Failed to allocate fields array"); + return -1; + } - tp = tif->tif_fieldscompat[nfields].fields; - for (i = 0; i < n; i++) - { - tp->field_tag = info[i].field_tag; - tp->field_readcount = info[i].field_readcount; - tp->field_writecount = info[i].field_writecount; - tp->field_type = info[i].field_type; - tp->field_anonymous = 0; - tp->set_field_type = - _TIFFSetGetType(info[i].field_type, info[i].field_readcount, - info[i].field_passcount); - tp->get_field_type = - _TIFFSetGetType(info[i].field_type, info[i].field_readcount, - info[i].field_passcount); - tp->field_bit = info[i].field_bit; - tp->field_oktochange = info[i].field_oktochange; - tp->field_passcount = info[i].field_passcount; - if (info[i].field_name == NULL) - { - TIFFErrorExtR(tif, module, - "Field_name of %d.th allocation tag %d is NULL", i, - info[i].field_tag); - return -1; - } - tp->field_name = info[i].field_name; - tp->field_subfields = NULL; - tp++; - } + tp = tif->tif_fieldscompat[nfields].fields; + for (i = 0; i < n; i++) { + tp->field_tag = info[i].field_tag; + tp->field_readcount = info[i].field_readcount; + tp->field_writecount = info[i].field_writecount; + tp->field_type = info[i].field_type; + tp->field_anonymous = 0; + tp->set_field_type = + _TIFFSetGetType(info[i].field_type, + info[i].field_readcount, + info[i].field_passcount); + tp->get_field_type = + _TIFFSetGetType(info[i].field_type, + info[i].field_readcount, + info[i].field_passcount); + tp->field_bit = info[i].field_bit; + tp->field_oktochange = info[i].field_oktochange; + tp->field_passcount = info[i].field_passcount; + if (info[i].field_name == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, + "Field_name of %d.th allocation tag %d is NULL", i, info[i].field_tag); + return -1; + } + tp->field_name = info[i].field_name; + tp->field_subfields = NULL; + tp++; + } - if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n)) - { - TIFFErrorExtR(tif, module, "Setting up field info failed"); - return -1; - } + if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Setting up field info failed"); + return -1; + } - return 0; + return 0; } -int _TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag) +int +_TIFFCheckFieldIsValidForCodec(TIFF *tif, ttag_t tag) { - /* Filter out non-codec specific tags */ - switch (tag) - { - /* Shared tags */ - case TIFFTAG_PREDICTOR: - /* JPEG tags */ - case TIFFTAG_JPEGTABLES: - /* OJPEG tags */ - case TIFFTAG_JPEGIFOFFSET: - case TIFFTAG_JPEGIFBYTECOUNT: - case TIFFTAG_JPEGQTABLES: - case TIFFTAG_JPEGDCTABLES: - case TIFFTAG_JPEGACTABLES: - case TIFFTAG_JPEGPROC: - case TIFFTAG_JPEGRESTARTINTERVAL: - /* CCITT* */ - case TIFFTAG_BADFAXLINES: - case TIFFTAG_CLEANFAXDATA: - case TIFFTAG_CONSECUTIVEBADFAXLINES: - case TIFFTAG_GROUP3OPTIONS: - case TIFFTAG_GROUP4OPTIONS: - /* LERC */ - case TIFFTAG_LERC_PARAMETERS: - break; - default: - return 1; - } - if (!TIFFIsCODECConfigured(tif->tif_dir.td_compression)) - { - return 0; - } - /* Check if codec specific tags are allowed for the current - * compression scheme (codec) */ - switch (tif->tif_dir.td_compression) - { - case COMPRESSION_LZW: - if (tag == TIFFTAG_PREDICTOR) - return 1; - break; - case COMPRESSION_PACKBITS: - /* No codec-specific tags */ - break; - case COMPRESSION_THUNDERSCAN: - /* No codec-specific tags */ - break; - case COMPRESSION_NEXT: - /* No codec-specific tags */ - break; - case COMPRESSION_JPEG: - if (tag == TIFFTAG_JPEGTABLES) - return 1; - break; - case COMPRESSION_OJPEG: - switch (tag) - { - case TIFFTAG_JPEGIFOFFSET: - case TIFFTAG_JPEGIFBYTECOUNT: - case TIFFTAG_JPEGQTABLES: - case TIFFTAG_JPEGDCTABLES: - case TIFFTAG_JPEGACTABLES: - case TIFFTAG_JPEGPROC: - case TIFFTAG_JPEGRESTARTINTERVAL: - return 1; - } - break; - case COMPRESSION_CCITTRLE: - case COMPRESSION_CCITTRLEW: - case COMPRESSION_CCITTFAX3: - case COMPRESSION_CCITTFAX4: - switch (tag) - { - case TIFFTAG_BADFAXLINES: - case TIFFTAG_CLEANFAXDATA: - case TIFFTAG_CONSECUTIVEBADFAXLINES: - return 1; - case TIFFTAG_GROUP3OPTIONS: - if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3) - return 1; - break; - case TIFFTAG_GROUP4OPTIONS: - if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) - return 1; - break; - } - break; - case COMPRESSION_JBIG: - /* No codec-specific tags */ - break; - case COMPRESSION_DEFLATE: - case COMPRESSION_ADOBE_DEFLATE: - if (tag == TIFFTAG_PREDICTOR) - return 1; - break; - case COMPRESSION_PIXARLOG: - if (tag == TIFFTAG_PREDICTOR) - return 1; - break; - case COMPRESSION_SGILOG: - case COMPRESSION_SGILOG24: - /* No codec-specific tags */ - break; - case COMPRESSION_LZMA: - if (tag == TIFFTAG_PREDICTOR) - return 1; - break; - case COMPRESSION_ZSTD: - if (tag == TIFFTAG_PREDICTOR) - return 1; - break; - case COMPRESSION_LERC: - if (tag == TIFFTAG_LERC_PARAMETERS) - return 1; - break; - } - return 0; + /* Filter out non-codec specific tags */ + switch (tag) { + /* Shared tags */ + case TIFFTAG_PREDICTOR: + /* JPEG tags */ + case TIFFTAG_JPEGTABLES: + /* OJPEG tags */ + case TIFFTAG_JPEGIFOFFSET: + case TIFFTAG_JPEGIFBYTECOUNT: + case TIFFTAG_JPEGQTABLES: + case TIFFTAG_JPEGDCTABLES: + case TIFFTAG_JPEGACTABLES: + case TIFFTAG_JPEGPROC: + case TIFFTAG_JPEGRESTARTINTERVAL: + /* CCITT* */ + case TIFFTAG_BADFAXLINES: + case TIFFTAG_CLEANFAXDATA: + case TIFFTAG_CONSECUTIVEBADFAXLINES: + case TIFFTAG_GROUP3OPTIONS: + case TIFFTAG_GROUP4OPTIONS: + /* LERC */ + case TIFFTAG_LERC_PARAMETERS: + break; + default: + return 1; + } + if( !TIFFIsCODECConfigured(tif->tif_dir.td_compression) ) { + return 0; + } + /* Check if codec specific tags are allowed for the current + * compression scheme (codec) */ + switch (tif->tif_dir.td_compression) { + case COMPRESSION_LZW: + if (tag == TIFFTAG_PREDICTOR) + return 1; + break; + case COMPRESSION_PACKBITS: + /* No codec-specific tags */ + break; + case COMPRESSION_THUNDERSCAN: + /* No codec-specific tags */ + break; + case COMPRESSION_NEXT: + /* No codec-specific tags */ + break; + case COMPRESSION_JPEG: + if (tag == TIFFTAG_JPEGTABLES) + return 1; + break; + case COMPRESSION_OJPEG: + switch (tag) { + case TIFFTAG_JPEGIFOFFSET: + case TIFFTAG_JPEGIFBYTECOUNT: + case TIFFTAG_JPEGQTABLES: + case TIFFTAG_JPEGDCTABLES: + case TIFFTAG_JPEGACTABLES: + case TIFFTAG_JPEGPROC: + case TIFFTAG_JPEGRESTARTINTERVAL: + return 1; + } + break; + case COMPRESSION_CCITTRLE: + case COMPRESSION_CCITTRLEW: + case COMPRESSION_CCITTFAX3: + case COMPRESSION_CCITTFAX4: + switch (tag) { + case TIFFTAG_BADFAXLINES: + case TIFFTAG_CLEANFAXDATA: + case TIFFTAG_CONSECUTIVEBADFAXLINES: + return 1; + case TIFFTAG_GROUP3OPTIONS: + if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3) + return 1; + break; + case TIFFTAG_GROUP4OPTIONS: + if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) + return 1; + break; + } + break; + case COMPRESSION_JBIG: + /* No codec-specific tags */ + break; + case COMPRESSION_DEFLATE: + case COMPRESSION_ADOBE_DEFLATE: + if (tag == TIFFTAG_PREDICTOR) + return 1; + break; + case COMPRESSION_PIXARLOG: + if (tag == TIFFTAG_PREDICTOR) + return 1; + break; + case COMPRESSION_SGILOG: + case COMPRESSION_SGILOG24: + /* No codec-specific tags */ + break; + case COMPRESSION_LZMA: + if (tag == TIFFTAG_PREDICTOR) + return 1; + break; + case COMPRESSION_ZSTD: + if (tag == TIFFTAG_PREDICTOR) + return 1; + break; + case COMPRESSION_LERC: + if (tag == TIFFTAG_LERC_PARAMETERS) + return 1; + break; + } + return 0; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirread.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirread.c index 2c49dc6aa..fa39ca9d7 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirread.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirread.c @@ -34,3993 +34,3471 @@ * TIFFReadDirectory, so as to eliminate current possibly repetitive lookup. */ -#include "tiffconf.h" #include "tiffiop.h" #include -#include #include -#include -#define FAILED_FII ((uint32_t)-1) +#define FAILED_FII ((uint32) -1) + +/* + * Largest 64-bit signed integer value. + */ +#define TIFF_INT64_MAX ((int64)(TIFF_UINT64_MAX >> 1)) #ifdef HAVE_IEEEFP -#define TIFFCvtIEEEFloatToNative(tif, n, fp) -#define TIFFCvtIEEEDoubleToNative(tif, n, dp) +# define TIFFCvtIEEEFloatToNative(tif, n, fp) +# define TIFFCvtIEEEDoubleToNative(tif, n, dp) #else -extern void TIFFCvtIEEEFloatToNative(TIFF *, uint32_t, float *); -extern void TIFFCvtIEEEDoubleToNative(TIFF *, uint32_t, double *); +extern void TIFFCvtIEEEFloatToNative(TIFF*, uint32, float*); +extern void TIFFCvtIEEEDoubleToNative(TIFF*, uint32, double*); #endif -enum TIFFReadDirEntryErr -{ - TIFFReadDirEntryErrOk = 0, - TIFFReadDirEntryErrCount = 1, - TIFFReadDirEntryErrType = 2, - TIFFReadDirEntryErrIo = 3, - TIFFReadDirEntryErrRange = 4, - TIFFReadDirEntryErrPsdif = 5, - TIFFReadDirEntryErrSizesan = 6, - TIFFReadDirEntryErrAlloc = 7, +enum TIFFReadDirEntryErr { + TIFFReadDirEntryErrOk = 0, + TIFFReadDirEntryErrCount = 1, + TIFFReadDirEntryErrType = 2, + TIFFReadDirEntryErrIo = 3, + TIFFReadDirEntryErrRange = 4, + TIFFReadDirEntryErrPsdif = 5, + TIFFReadDirEntryErrSizesan = 6, + TIFFReadDirEntryErrAlloc = 7, }; -static enum TIFFReadDirEntryErr -TIFFReadDirEntryByte(TIFF *tif, TIFFDirEntry *direntry, uint8_t *value); -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySbyte(TIFF *tif, TIFFDirEntry *direntry, int8_t *value); -static enum TIFFReadDirEntryErr -TIFFReadDirEntryShort(TIFF *tif, TIFFDirEntry *direntry, uint16_t *value); -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySshort(TIFF *tif, TIFFDirEntry *direntry, int16_t *value); -static enum TIFFReadDirEntryErr -TIFFReadDirEntryLong(TIFF *tif, TIFFDirEntry *direntry, uint32_t *value); -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySlong(TIFF *tif, TIFFDirEntry *direntry, int32_t *value); -static enum TIFFReadDirEntryErr -TIFFReadDirEntryLong8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value); -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySlong8(TIFF *tif, TIFFDirEntry *direntry, int64_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_t *value); +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 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_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_t **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 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 -TIFFReadDirEntryPersampleShort(TIFF *tif, TIFFDirEntry *direntry, - uint16_t *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 TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value); #if 0 -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckedRationalDirect(TIFF *tif, TIFFDirEntry *direntry, - TIFFRational_t *value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFDirEntry* direntry, double* value); #endif -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 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 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 -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 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 -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 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 -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 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 -TIFFReadDirEntryCheckRangeSlongLong(uint32_t value); -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongLong8(uint64_t value); -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongSlong8(int64_t 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 -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 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 -TIFFReadDirEntryCheckRangeSlong8Long8(uint64_t value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong(uint32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongLong8(uint64 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlongSlong8(int64 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 enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Sshort(int16 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong(int32 value); +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLong8Slong8(int64 value); -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 enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value); -static int EstimateStripByteCounts(TIFF *tif, TIFFDirEntry *dir, - uint16_t dircount); -static void MissingRequired(TIFF *, const char *); -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_t nstrips, - uint64_t **lpp); -static int TIFFFetchSubjectDistance(TIFF *, TIFFDirEntry *); -static void ChopUpSingleUncompressedStrip(TIFF *); -static void TryChopUpUncompressedBigTiff(TIFF *); -static uint64_t TIFFReadUInt64(const uint8_t *value); -static int _TIFFGetMaxColorChannels(uint16_t photometric); +static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest); +static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, const char* module, const char* tagname, int recover); -static int _TIFFFillStrilesInternal(TIFF *tif, int loadStripByteCount); +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 int EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 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 TIFFFetchNormalTag(TIFF*, TIFFDirEntry*, int recover); +static int TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** 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 int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount ); typedef union _UInt64Aligned_t { - double d; - uint64_t l; - uint32_t i[2]; - uint16_t s[4]; - uint8_t c[8]; + double d; + uint64 l; + uint32 i[2]; + uint16 s[4]; + uint8 c[8]; } UInt64Aligned_t; /* - Unaligned safe copy of a uint64_t value from an octet array. + Unaligned safe copy of a uint64 value from an octet array. */ -static uint64_t TIFFReadUInt64(const uint8_t *value) +static uint64 TIFFReadUInt64(const uint8 *value) { - UInt64Aligned_t result; + UInt64Aligned_t result; - result.c[0] = value[0]; - result.c[1] = value[1]; - result.c[2] = value[2]; - result.c[3] = value[3]; - result.c[4] = value[4]; - result.c[5] = value[5]; - result.c[6] = value[6]; - result.c[7] = value[7]; + result.c[0]=value[0]; + result.c[1]=value[1]; + result.c[2]=value[2]; + result.c[3]=value[3]; + result.c[4]=value[4]; + result.c[5]=value[5]; + result.c[6]=value[6]; + result.c[7]=value[7]; - return result.l; + return result.l; } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryByte(TIFF *tif, TIFFDirEntry *direntry, uint8_t *value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value) { - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_UNDEFINED: /* Support to read TIFF_UNDEFINED with - field_readcount==1 */ - TIFFReadDirEntryCheckedByte(tif, direntry, value); - return (TIFFReadDirEntryErrOk); - case TIFF_SBYTE: - { - int8_t m; - TIFFReadDirEntryCheckedSbyte(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeByteSbyte(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - { - uint16_t m; - TIFFReadDirEntryCheckedShort(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeByteShort(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - { - int16_t m; - TIFFReadDirEntryCheckedSshort(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeByteSshort(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeByteLong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - { - int32_t m; - TIFFReadDirEntryCheckedSlong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeByteSlong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - { - uint64_t m; - err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeByteLong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - { - int64_t m; - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeByteSlong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint8_t)m; - return (TIFFReadDirEntryErrOk); - } - default: - return (TIFFReadDirEntryErrType); - } + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_UNDEFINED: /* Support to read TIFF_UNDEFINED with field_readcount==1 */ + TIFFReadDirEntryCheckedByte(tif,direntry,value); + return(TIFFReadDirEntryErrOk); + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteSbyte(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteShort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteSshort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteLong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeByteSlong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeByteLong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeByteSlong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint8)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } } -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySbyte(TIFF *tif, TIFFDirEntry *direntry, int8_t *value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) { - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_UNDEFINED: /* Support to read TIFF_UNDEFINED with - field_readcount==1 */ - { - uint8_t m; - TIFFReadDirEntryCheckedByte(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeSbyteByte(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - { - TIFFReadDirEntryCheckedSbyte(tif, direntry, value); - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - { - uint16_t m; - TIFFReadDirEntryCheckedShort(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeSbyteShort(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - { - int16_t m; - TIFFReadDirEntryCheckedSshort(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeSbyteSshort(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeSbyteLong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - { - int32_t m; - TIFFReadDirEntryCheckedSlong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeSbyteSlong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - { - uint64_t m; - err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeSbyteLong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int8_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - { - int64_t m; - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeSbyteSlong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int8_t)m; - return (TIFFReadDirEntryErrOk); - } - default: - return (TIFFReadDirEntryErrType); - } -} /*-- TIFFReadDirEntrySbyte() --*/ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeShortSbyte(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + TIFFReadDirEntryCheckedShort(tif,direntry,value); + return(TIFFReadDirEntryErrOk); + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeShortSshort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeShortLong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeShortSlong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeShortLong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeShortSlong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint16)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } +} -static enum TIFFReadDirEntryErr -TIFFReadDirEntryShort(TIFF *tif, TIFFDirEntry *direntry, uint16_t *value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value) { - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t m; - TIFFReadDirEntryCheckedByte(tif, direntry, &m); - *value = (uint16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - { - int8_t m; - TIFFReadDirEntryCheckedSbyte(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeShortSbyte(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - TIFFReadDirEntryCheckedShort(tif, direntry, value); - return (TIFFReadDirEntryErrOk); - case TIFF_SSHORT: - { - int16_t m; - TIFFReadDirEntryCheckedSshort(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeShortSshort(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeShortLong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - { - int32_t m; - TIFFReadDirEntryCheckedSlong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeShortSlong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - { - uint64_t m; - err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeShortLong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - { - int64_t m; - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeShortSlong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint16_t)m; - return (TIFFReadDirEntryErrOk); - } - default: - return (TIFFReadDirEntryErrType); - } -} /*-- TIFFReadDirEntryShort() --*/ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLongSbyte(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLongSshort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + TIFFReadDirEntryCheckedLong(tif,direntry,value); + return(TIFFReadDirEntryErrOk); + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLongSlong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeLongLong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeLongSlong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint32)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } +} -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySshort(TIFF *tif, TIFFDirEntry *direntry, int16_t *value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) { - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t m; - TIFFReadDirEntryCheckedByte(tif, direntry, &m); - *value = (int16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - { - int8_t m; - TIFFReadDirEntryCheckedSbyte(tif, direntry, &m); - *value = (int16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - { - uint16_t m; - TIFFReadDirEntryCheckedShort(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeSshortShort(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - TIFFReadDirEntryCheckedSshort(tif, direntry, value); - return (TIFFReadDirEntryErrOk); - case TIFF_LONG: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeSshortLong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - { - int32_t m; - TIFFReadDirEntryCheckedSlong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeSshortSlong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - { - uint64_t m; - err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeSshortLong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int16_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - { - int64_t m; - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeSshortSlong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int16_t)m; - return (TIFFReadDirEntryErrOk); - } - default: - return (TIFFReadDirEntryErrType); - } -} /*-- TIFFReadDirEntrySshort() --*/ + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLong8Sbyte(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLong8Sshort(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + err=TIFFReadDirEntryCheckRangeLong8Slong(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + err=TIFFReadDirEntryCheckedLong8(tif,direntry,value); + return(err); + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + err=TIFFReadDirEntryCheckRangeLong8Slong8(m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } +} -static enum TIFFReadDirEntryErr -TIFFReadDirEntryLong(TIFF *tif, TIFFDirEntry *direntry, uint32_t *value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryFloat(TIFF* tif, TIFFDirEntry* direntry, float* value) { - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t m; - TIFFReadDirEntryCheckedByte(tif, direntry, &m); - *value = (uint32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - { - int8_t m; - TIFFReadDirEntryCheckedSbyte(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeLongSbyte(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - { - uint16_t m; - TIFFReadDirEntryCheckedShort(tif, direntry, &m); - *value = (uint32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - { - int16_t m; - TIFFReadDirEntryCheckedSshort(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeLongSshort(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG: - TIFFReadDirEntryCheckedLong(tif, direntry, value); - return (TIFFReadDirEntryErrOk); - case TIFF_SLONG: - { - int32_t m; - TIFFReadDirEntryCheckedSlong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeLongSlong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - { - uint64_t m; - err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeLongLong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - { - int64_t m; - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeLongSlong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint32_t)m; - return (TIFFReadDirEntryErrOk); - } - default: - return (TIFFReadDirEntryErrType); - } -} /*-- TIFFReadDirEntryLong() --*/ - -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySlong(TIFF *tif, TIFFDirEntry *direntry, int32_t *value) -{ - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t m; - TIFFReadDirEntryCheckedByte(tif, direntry, &m); - *value = (int32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - { - int8_t m; - TIFFReadDirEntryCheckedSbyte(tif, direntry, &m); - *value = (int32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - { - uint16_t m; - TIFFReadDirEntryCheckedShort(tif, direntry, &m); - *value = (int32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - { - int16_t m; - TIFFReadDirEntryCheckedSshort(tif, direntry, &m); - *value = (int32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeSlongLong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - TIFFReadDirEntryCheckedSlong(tif, direntry, value); - return (TIFFReadDirEntryErrOk); - case TIFF_LONG8: - { - uint64_t m; - err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeSlongLong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int32_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - { - int64_t m; - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeSlongSlong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int32_t)m; - return (TIFFReadDirEntryErrOk); - } - default: - return (TIFFReadDirEntryErrType); - } -} /*-- TIFFReadDirEntrySlong() --*/ - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryLong8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value) -{ - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t m; - TIFFReadDirEntryCheckedByte(tif, direntry, &m); - *value = (uint64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - { - int8_t m; - TIFFReadDirEntryCheckedSbyte(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeLong8Sbyte(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - { - uint16_t m; - TIFFReadDirEntryCheckedShort(tif, direntry, &m); - *value = (uint64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - { - int16_t m; - TIFFReadDirEntryCheckedSshort(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeLong8Sshort(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - *value = (uint64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - { - int32_t m; - TIFFReadDirEntryCheckedSlong(tif, direntry, &m); - err = TIFFReadDirEntryCheckRangeLong8Slong(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - err = TIFFReadDirEntryCheckedLong8(tif, direntry, value); - return (err); - case TIFF_SLONG8: - { - int64_t m; - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeLong8Slong8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (uint64_t)m; - return (TIFFReadDirEntryErrOk); - } - default: - return (TIFFReadDirEntryErrType); - } -} /*-- TIFFReadDirEntryLong8() --*/ - -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySlong8(TIFF *tif, TIFFDirEntry *direntry, int64_t *value) -{ - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t m; - TIFFReadDirEntryCheckedByte(tif, direntry, &m); - *value = (int64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - { - int8_t m; - TIFFReadDirEntryCheckedSbyte(tif, direntry, &m); - *value = (int64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - { - uint16_t m; - TIFFReadDirEntryCheckedShort(tif, direntry, &m); - *value = (int64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - { - int16_t m; - TIFFReadDirEntryCheckedSshort(tif, direntry, &m); - *value = (int64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - *value = (int64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - { - int32_t m; - TIFFReadDirEntryCheckedSlong(tif, direntry, &m); - *value = (int64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - { - uint64_t m; - err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - err = TIFFReadDirEntryCheckRangeSlong8Long8(m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (int64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, value); - return (err); - default: - return (TIFFReadDirEntryErrType); - } -} /*-- TIFFReadDirEntrySlong8() --*/ - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryFloat(TIFF *tif, TIFFDirEntry *direntry, float *value) -{ - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t m; - TIFFReadDirEntryCheckedByte(tif, direntry, &m); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - { - int8_t m; - TIFFReadDirEntryCheckedSbyte(tif, direntry, &m); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - { - uint16_t m; - TIFFReadDirEntryCheckedShort(tif, direntry, &m); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - { - int16_t m; - TIFFReadDirEntryCheckedSshort(tif, direntry, &m); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - { - int32_t m; - TIFFReadDirEntryCheckedSlong(tif, direntry, &m); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - { - uint64_t m; - err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); #if defined(__WIN32__) && (_MSC_VER < 1500) - /* - * XXX: MSVC 6.0 does not support conversion - * of 64-bit integers into floating point - * values. - */ - *value = _TIFFUInt64ToFloat(m); + /* + * XXX: MSVC 6.0 does not support conversion + * of 64-bit integers into floating point + * values. + */ + *value = _TIFFUInt64ToFloat(m); #else - *value = (float)m; + *value=(float)m; #endif - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - { - int64_t m; - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_RATIONAL: - { - double m; - err = TIFFReadDirEntryCheckedRational(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SRATIONAL: - { - double m; - err = TIFFReadDirEntryCheckedSrational(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_FLOAT: - TIFFReadDirEntryCheckedFloat(tif, direntry, value); - return (TIFFReadDirEntryErrOk); - case TIFF_DOUBLE: - { - double m; - err = TIFFReadDirEntryCheckedDouble(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - if ((m > FLT_MAX) || (m < -FLT_MAX)) - return (TIFFReadDirEntryErrRange); - *value = (float)m; - return (TIFFReadDirEntryErrOk); - } - default: - return (TIFFReadDirEntryErrType); - } + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_RATIONAL: + { + double m; + err=TIFFReadDirEntryCheckedRational(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SRATIONAL: + { + double m; + err=TIFFReadDirEntryCheckedSrational(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_FLOAT: + TIFFReadDirEntryCheckedFloat(tif,direntry,value); + return(TIFFReadDirEntryErrOk); + case TIFF_DOUBLE: + { + double m; + err=TIFFReadDirEntryCheckedDouble(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + if ((m > FLT_MAX) || (m < -FLT_MAX)) + return(TIFFReadDirEntryErrRange); + *value=(float)m; + return(TIFFReadDirEntryErrOk); + } + default: + return(TIFFReadDirEntryErrType); + } } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryDouble(TIFF *tif, TIFFDirEntry *direntry, double *value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryDouble(TIFF* tif, TIFFDirEntry* direntry, double* value) { - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t m; - TIFFReadDirEntryCheckedByte(tif, direntry, &m); - *value = (double)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - { - int8_t m; - TIFFReadDirEntryCheckedSbyte(tif, direntry, &m); - *value = (double)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SHORT: - { - uint16_t m; - TIFFReadDirEntryCheckedShort(tif, direntry, &m); - *value = (double)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - { - int16_t m; - TIFFReadDirEntryCheckedSshort(tif, direntry, &m); - *value = (double)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - *value = (double)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - { - int32_t m; - TIFFReadDirEntryCheckedSlong(tif, direntry, &m); - *value = (double)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - { - uint64_t m; - err = TIFFReadDirEntryCheckedLong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8 m; + TIFFReadDirEntryCheckedByte(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SBYTE: + { + int8 m; + TIFFReadDirEntryCheckedSbyte(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SHORT: + { + uint16 m; + TIFFReadDirEntryCheckedShort(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + { + int16 m; + TIFFReadDirEntryCheckedSshort(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + { + int32 m; + TIFFReadDirEntryCheckedSlong(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + { + uint64 m; + err=TIFFReadDirEntryCheckedLong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); #if defined(__WIN32__) && (_MSC_VER < 1500) - /* - * XXX: MSVC 6.0 does not support conversion - * of 64-bit integers into floating point - * values. - */ - *value = _TIFFUInt64ToDouble(m); + /* + * XXX: MSVC 6.0 does not support conversion + * of 64-bit integers into floating point + * values. + */ + *value = _TIFFUInt64ToDouble(m); #else - *value = (double)m; + *value = (double)m; #endif - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - { - int64_t m; - err = TIFFReadDirEntryCheckedSlong8(tif, direntry, &m); - if (err != TIFFReadDirEntryErrOk) - return (err); - *value = (double)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_RATIONAL: - err = TIFFReadDirEntryCheckedRational(tif, direntry, value); - return (err); - case TIFF_SRATIONAL: - err = TIFFReadDirEntryCheckedSrational(tif, direntry, value); - return (err); - case TIFF_FLOAT: - { - float m; - TIFFReadDirEntryCheckedFloat(tif, direntry, &m); - *value = (double)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_DOUBLE: - err = TIFFReadDirEntryCheckedDouble(tif, direntry, value); - return (err); - default: - return (TIFFReadDirEntryErrType); - } + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + { + int64 m; + err=TIFFReadDirEntryCheckedSlong8(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_RATIONAL: + err=TIFFReadDirEntryCheckedRational(tif,direntry,value); + return(err); + case TIFF_SRATIONAL: + err=TIFFReadDirEntryCheckedSrational(tif,direntry,value); + return(err); + case TIFF_FLOAT: + { + float m; + TIFFReadDirEntryCheckedFloat(tif,direntry,&m); + *value=(double)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_DOUBLE: + err=TIFFReadDirEntryCheckedDouble(tif,direntry,value); + return(err); + default: + return(TIFFReadDirEntryErrType); + } } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryIfd8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryIfd8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) { - enum TIFFReadDirEntryErr err; - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - switch (direntry->tdir_type) - { - case TIFF_LONG: - case TIFF_IFD: - { - uint32_t m; - TIFFReadDirEntryCheckedLong(tif, direntry, &m); - *value = (uint64_t)m; - return (TIFFReadDirEntryErrOk); - } - case TIFF_LONG8: - case TIFF_IFD8: - err = TIFFReadDirEntryCheckedLong8(tif, direntry, value); - return (err); - default: - return (TIFFReadDirEntryErrType); - } + enum TIFFReadDirEntryErr err; + if (direntry->tdir_count!=1) + return(TIFFReadDirEntryErrCount); + switch (direntry->tdir_type) + { + case TIFF_LONG: + case TIFF_IFD: + { + uint32 m; + TIFFReadDirEntryCheckedLong(tif,direntry,&m); + *value=(uint64)m; + return(TIFFReadDirEntryErrOk); + } + case TIFF_LONG8: + case TIFF_IFD8: + err=TIFFReadDirEntryCheckedLong8(tif,direntry,value); + return(err); + default: + return(TIFFReadDirEntryErrType); + } } + #define INITIAL_THRESHOLD (1024 * 1024) #define THRESHOLD_MULTIPLIER 10 -#define MAX_THRESHOLD \ - (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * \ - INITIAL_THRESHOLD) +#define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD) -static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc(TIFF *tif, - uint64_t offset, - tmsize_t size, - void **pdest) +static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc( + TIFF* tif, uint64 offset, tmsize_t size, void** pdest) { #if SIZEOF_SIZE_T == 8 - tmsize_t threshold = INITIAL_THRESHOLD; + tmsize_t threshold = INITIAL_THRESHOLD; #endif - tmsize_t already_read = 0; + tmsize_t already_read = 0; - assert(!isMapped(tif)); + assert( !isMapped(tif) ); - if (!SeekOK(tif, offset)) - return (TIFFReadDirEntryErrIo); + if (!SeekOK(tif,offset)) + return(TIFFReadDirEntryErrIo); - /* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc */ - /* so as to avoid allocating too much memory in case the file is too */ - /* short. We could ask for the file size, but this might be */ - /* expensive with some I/O layers (think of reading a gzipped file) */ - /* Restrict to 64 bit processes, so as to avoid reallocs() */ - /* on 32 bit processes where virtual memory is scarce. */ - while (already_read < size) - { - void *new_dest; - tmsize_t bytes_read; - tmsize_t to_read = size - already_read; + /* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc */ + /* so as to avoid allocating too much memory in case the file is too */ + /* short. We could ask for the file size, but this might be */ + /* expensive with some I/O layers (think of reading a gzipped file) */ + /* Restrict to 64 bit processes, so as to avoid reallocs() */ + /* on 32 bit processes where virtual memory is scarce. */ + while( already_read < size ) + { + void* new_dest; + tmsize_t bytes_read; + tmsize_t to_read = size - already_read; #if SIZEOF_SIZE_T == 8 - if (to_read >= threshold && threshold < MAX_THRESHOLD) - { - to_read = threshold; - threshold *= THRESHOLD_MULTIPLIER; - } + if( to_read >= threshold && threshold < MAX_THRESHOLD ) + { + to_read = threshold; + threshold *= THRESHOLD_MULTIPLIER; + } #endif - new_dest = - (uint8_t *)_TIFFreallocExt(tif, *pdest, already_read + to_read); - if (new_dest == NULL) - { - TIFFErrorExtR(tif, tif->tif_name, - "Failed to allocate memory for %s " - "(%" TIFF_SSIZE_FORMAT - " elements of %" TIFF_SSIZE_FORMAT " bytes each)", - "TIFFReadDirEntryArray", (tmsize_t)1, - already_read + to_read); - return TIFFReadDirEntryErrAlloc; - } - *pdest = new_dest; + new_dest = (uint8*) _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)", + "TIFFReadDirEntryArray", + (long) 1, (long) (already_read + to_read)); + return TIFFReadDirEntryErrAlloc; + } + *pdest = new_dest; - bytes_read = TIFFReadFile(tif, (char *)*pdest + already_read, to_read); - already_read += bytes_read; - if (bytes_read != to_read) - { - return TIFFReadDirEntryErrIo; + bytes_read = TIFFReadFile(tif, + (char*)*pdest + already_read, to_read); + already_read += bytes_read; + if (bytes_read != to_read) { + return TIFFReadDirEntryErrIo; + } } - } - return TIFFReadDirEntryErrOk; + return TIFFReadDirEntryErrOk; } -/* Caution: if raising that value, make sure int32 / uint32 overflows can't - * occur elsewhere */ -#define MAX_SIZE_TAG_DATA 2147483647U - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryArrayWithLimit(TIFF *tif, TIFFDirEntry *direntry, - uint32_t *count, uint32_t desttypesize, - void **value, uint64_t maxcount) +static enum TIFFReadDirEntryErr TIFFReadDirEntryArrayWithLimit( + TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, + void** value, uint64 maxcount) { - int typesize; - uint32_t datasize; - void *data; - uint64_t target_count64; - int original_datasize_clamped; - typesize = TIFFDataWidth(direntry->tdir_type); + int typesize; + uint32 datasize; + void* data; + uint64 target_count64; + int original_datasize_clamped; + typesize=TIFFDataWidth(direntry->tdir_type); - target_count64 = - (direntry->tdir_count > maxcount) ? maxcount : direntry->tdir_count; + target_count64 = (direntry->tdir_count > maxcount) ? + maxcount : direntry->tdir_count; - if ((target_count64 == 0) || (typesize == 0)) - { - *value = 0; - return (TIFFReadDirEntryErrOk); - } - (void)desttypesize; + if ((target_count64==0)||(typesize==0)) + { + *value=0; + return(TIFFReadDirEntryErrOk); + } + (void) desttypesize; - /* We just want to know if the original tag size is more than 4 bytes - * (classic TIFF) or 8 bytes (BigTIFF) - */ - original_datasize_clamped = - ((direntry->tdir_count > 10) ? 10 : (int)direntry->tdir_count) * - typesize; + /* We just want to know if the original tag size is more than 4 bytes + * (classic TIFF) or 8 bytes (BigTIFF) + */ + original_datasize_clamped = + ((direntry->tdir_count > 10) ? 10 : (int)direntry->tdir_count) * typesize; - /* - * As a sanity check, make sure we have no more than a 2GB tag array - * 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_t)(MAX_SIZE_TAG_DATA / typesize) < target_count64) - return (TIFFReadDirEntryErrSizesan); - if ((uint64_t)(MAX_SIZE_TAG_DATA / desttypesize) < target_count64) - return (TIFFReadDirEntryErrSizesan); + /* + * As a sanity check, make sure we have no more than a 2GB tag array + * 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) 0); + *count=(uint32)target_count64; + datasize=(*count)*typesize; + assert((tmsize_t)datasize>0); - if (isMapped(tif) && datasize > (uint64_t)tif->tif_size) - return TIFFReadDirEntryErrIo; + if( isMapped(tif) && datasize > (uint64)tif->tif_size ) + return TIFFReadDirEntryErrIo; - if (!isMapped(tif) && (((tif->tif_flags & TIFF_BIGTIFF) && datasize > 8) || - (!(tif->tif_flags & TIFF_BIGTIFF) && datasize > 4))) - { - data = NULL; - } - else - { - data = _TIFFCheckMalloc(tif, *count, typesize, "ReadDirEntryArray"); - if (data == 0) - return (TIFFReadDirEntryErrAlloc); - } - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - /* 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_t offset = direntry->tdir_offset.toff_long; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&offset); - if (isMapped(tif)) - err = TIFFReadDirEntryData(tif, (uint64_t)offset, - (tmsize_t)datasize, data); - else - err = TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset, - (tmsize_t)datasize, &data); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, data); - return (err); - } - } - } - else - { - /* 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_t offset = direntry->tdir_offset.toff_long8; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&offset); - if (isMapped(tif)) - err = TIFFReadDirEntryData(tif, (uint64_t)offset, - (tmsize_t)datasize, data); - else - err = TIFFReadDirEntryDataAndRealloc(tif, (uint64_t)offset, - (tmsize_t)datasize, &data); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, data); - return (err); - } - } - } - *value = data; - return (TIFFReadDirEntryErrOk); + if( !isMapped(tif) && + (((tif->tif_flags&TIFF_BIGTIFF) && datasize > 8) || + (!(tif->tif_flags&TIFF_BIGTIFF) && datasize > 4)) ) + { + data = NULL; + } + else + { + data=_TIFFCheckMalloc(tif, *count, typesize, "ReadDirEntryArray"); + if (data==0) + return(TIFFReadDirEntryErrAlloc); + } + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (original_datasize_clamped<=4) + _TIFFmemcpy(data,&direntry->tdir_offset,datasize); + else + { + enum TIFFReadDirEntryErr err; + uint32 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); + else + err=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + } + } + else + { + if (original_datasize_clamped<=8) + _TIFFmemcpy(data,&direntry->tdir_offset,datasize); + else + { + enum TIFFReadDirEntryErr err; + uint64 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); + else + err=TIFFReadDirEntryDataAndRealloc(tif,(uint64)offset,(tmsize_t)datasize,&data); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + } + } + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryArray(TIFF *tif, TIFFDirEntry *direntry, uint32_t *count, - uint32_t desttypesize, void **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryArray(TIFF* tif, TIFFDirEntry* direntry, uint32* count, uint32 desttypesize, void** value) { - return TIFFReadDirEntryArrayWithLimit(tif, direntry, count, desttypesize, - value, ~((uint64_t)0)); + return TIFFReadDirEntryArrayWithLimit(tif, direntry, count, + desttypesize, value, ~((uint64)0)); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryByteArray(TIFF *tif, TIFFDirEntry *direntry, uint8_t **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryByteArray(TIFF* tif, TIFFDirEntry* direntry, uint8** value) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - uint8_t *data; - switch (direntry->tdir_type) - { - case TIFF_ASCII: - case TIFF_UNDEFINED: - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 1, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_ASCII: - case TIFF_UNDEFINED: - case TIFF_BYTE: - *value = (uint8_t *)origdata; - return (TIFFReadDirEntryErrOk); - case TIFF_SBYTE: - { - int8_t *m; - uint32_t n; - m = (int8_t *)origdata; - for (n = 0; n < count; n++) - { - err = TIFFReadDirEntryCheckRangeByteSbyte(*m); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, origdata); - return (err); - } - m++; - } - *value = (uint8_t *)origdata; - return (TIFFReadDirEntryErrOk); - } - } - data = (uint8_t *)_TIFFmallocExt(tif, count); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_SHORT: - { - uint16_t *ma; - uint8_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); - err = TIFFReadDirEntryCheckRangeByteShort(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint8_t)(*ma++); - } - } - break; - case TIFF_SSHORT: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeByteSshort(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint8_t)(*ma++); - } - } - break; - case TIFF_LONG: - { - uint32_t *ma; - uint8_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); - err = TIFFReadDirEntryCheckRangeByteLong(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint8_t)(*ma++); - } - } - break; - case TIFF_SLONG: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeByteSlong(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint8_t)(*ma++); - } - } - break; - case TIFF_LONG8: - { - uint64_t *ma; - uint8_t *mb; - uint32_t n; - ma = (uint64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(ma); - err = TIFFReadDirEntryCheckRangeByteLong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint8_t)(*ma++); - } - } - break; - case TIFF_SLONG8: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeByteSlong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint8_t)(*ma++); - } - } - break; - } - _TIFFfreeExt(tif, origdata); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, data); - return (err); - } - *value = data; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + uint8* data; + switch (direntry->tdir_type) + { + case TIFF_ASCII: + case TIFF_UNDEFINED: + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,1,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_ASCII: + case TIFF_UNDEFINED: + case TIFF_BYTE: + *value=(uint8*)origdata; + return(TIFFReadDirEntryErrOk); + case TIFF_SBYTE: + { + int8* m; + uint32 n; + m=(int8*)origdata; + for (n=0; ntdir_type) + { + case TIFF_SHORT: + { + uint16* ma; + uint8* mb; + uint32 n; + ma=(uint16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + err=TIFFReadDirEntryCheckRangeByteShort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + uint8* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + err=TIFFReadDirEntryCheckRangeByteSshort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + uint8* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + err=TIFFReadDirEntryCheckRangeByteLong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + uint8* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeByteSlong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + uint8* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeByteLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + uint8* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeByteSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint8)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySbyteArray(TIFF *tif, TIFFDirEntry *direntry, int8_t **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySbyteArray(TIFF* tif, TIFFDirEntry* direntry, int8** value) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - int8_t *data; - switch (direntry->tdir_type) - { - case TIFF_UNDEFINED: - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 1, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_UNDEFINED: - case TIFF_BYTE: - { - uint8_t *m; - uint32_t n; - m = (uint8_t *)origdata; - for (n = 0; n < count; n++) - { - err = TIFFReadDirEntryCheckRangeSbyteByte(*m); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, origdata); - return (err); - } - m++; - } - *value = (int8_t *)origdata; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SBYTE: - *value = (int8_t *)origdata; - return (TIFFReadDirEntryErrOk); - } - data = (int8_t *)_TIFFmallocExt(tif, count); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_SHORT: - { - uint16_t *ma; - int8_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); - err = TIFFReadDirEntryCheckRangeSbyteShort(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int8_t)(*ma++); - } - } - break; - case TIFF_SSHORT: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeSbyteSshort(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int8_t)(*ma++); - } - } - break; - case TIFF_LONG: - { - uint32_t *ma; - int8_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); - err = TIFFReadDirEntryCheckRangeSbyteLong(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int8_t)(*ma++); - } - } - break; - case TIFF_SLONG: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeSbyteSlong(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int8_t)(*ma++); - } - } - break; - case TIFF_LONG8: - { - uint64_t *ma; - int8_t *mb; - uint32_t n; - ma = (uint64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(ma); - err = TIFFReadDirEntryCheckRangeSbyteLong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int8_t)(*ma++); - } - } - break; - case TIFF_SLONG8: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeSbyteSlong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int8_t)(*ma++); - } - } - break; - } - _TIFFfreeExt(tif, origdata); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, data); - return (err); - } - *value = data; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + int8* data; + switch (direntry->tdir_type) + { + case TIFF_UNDEFINED: + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,1,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_UNDEFINED: + case TIFF_BYTE: + { + uint8* m; + uint32 n; + m=(uint8*)origdata; + for (n=0; ntdir_type) + { + case TIFF_SHORT: + { + uint16* ma; + int8* mb; + uint32 n; + ma=(uint16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + err=TIFFReadDirEntryCheckRangeSbyteShort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + int8* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + err=TIFFReadDirEntryCheckRangeSbyteSshort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + int8* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + err=TIFFReadDirEntryCheckRangeSbyteLong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + int8* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeSbyteSlong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + int8* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeSbyteLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + int8* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeSbyteSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int8)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryShortArray(TIFF *tif, TIFFDirEntry *direntry, uint16_t **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryShortArray(TIFF* tif, TIFFDirEntry* direntry, uint16** value) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - uint16_t *data; - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 2, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_SHORT: - *value = (uint16_t *)origdata; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfShort(*value, count); - return (TIFFReadDirEntryErrOk); - case TIFF_SSHORT: - { - int16_t *m; - uint32_t n; - m = (int16_t *)origdata; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)m); - err = TIFFReadDirEntryCheckRangeShortSshort(*m); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, origdata); - return (err); - } - m++; - } - *value = (uint16_t *)origdata; - return (TIFFReadDirEntryErrOk); - } - } - data = (uint16_t *)_TIFFmallocExt(tif, count * 2); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t *ma; - uint16_t *mb; - uint32_t n; - ma = (uint8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (uint16_t)(*ma++); - } - break; - case TIFF_SBYTE: - { - 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_t)(*ma++); - } - } - break; - case TIFF_LONG: - { - uint32_t *ma; - uint16_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); - err = TIFFReadDirEntryCheckRangeShortLong(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint16_t)(*ma++); - } - } - break; - case TIFF_SLONG: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeShortSlong(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint16_t)(*ma++); - } - } - break; - case TIFF_LONG8: - { - uint64_t *ma; - uint16_t *mb; - uint32_t n; - ma = (uint64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(ma); - err = TIFFReadDirEntryCheckRangeShortLong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint16_t)(*ma++); - } - } - break; - case TIFF_SLONG8: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeShortSlong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint16_t)(*ma++); - } - } - break; - } - _TIFFfreeExt(tif, origdata); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, data); - return (err); - } - *value = data; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + uint16* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,2,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_SHORT: + *value=(uint16*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfShort(*value,count); + return(TIFFReadDirEntryErrOk); + case TIFF_SSHORT: + { + int16* m; + uint32 n; + m=(int16*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)m); + err=TIFFReadDirEntryCheckRangeShortSshort(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(uint16*)origdata; + return(TIFFReadDirEntryErrOk); + } + } + data=(uint16*)_TIFFmalloc(count*2); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + uint16* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + err=TIFFReadDirEntryCheckRangeShortLong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint16)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + uint16* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeShortSlong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint16)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + uint16* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeShortLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint16)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + uint16* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeShortSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint16)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySshortArray(TIFF *tif, TIFFDirEntry *direntry, int16_t **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySshortArray(TIFF* tif, TIFFDirEntry* direntry, int16** value) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - int16_t *data; - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 2, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_SHORT: - { - uint16_t *m; - uint32_t n; - m = (uint16_t *)origdata; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(m); - err = TIFFReadDirEntryCheckRangeSshortShort(*m); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, origdata); - return (err); - } - m++; - } - *value = (int16_t *)origdata; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SSHORT: - *value = (int16_t *)origdata; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfShort((uint16_t *)(*value), count); - return (TIFFReadDirEntryErrOk); - } - data = (int16_t *)_TIFFmallocExt(tif, count * 2); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t *ma; - int16_t *mb; - uint32_t n; - ma = (uint8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (int16_t)(*ma++); - } - break; - case TIFF_SBYTE: - { - int8_t *ma; - int16_t *mb; - uint32_t n; - ma = (int8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (int16_t)(*ma++); - } - break; - case TIFF_LONG: - { - uint32_t *ma; - int16_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); - err = TIFFReadDirEntryCheckRangeSshortLong(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int16_t)(*ma++); - } - } - break; - case TIFF_SLONG: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeSshortSlong(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int16_t)(*ma++); - } - } - break; - case TIFF_LONG8: - { - uint64_t *ma; - int16_t *mb; - uint32_t n; - ma = (uint64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(ma); - err = TIFFReadDirEntryCheckRangeSshortLong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int16_t)(*ma++); - } - } - break; - case TIFF_SLONG8: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeSshortSlong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int16_t)(*ma++); - } - } - break; - } - _TIFFfreeExt(tif, origdata); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, data); - return (err); - } - *value = data; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + int16* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,2,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_SHORT: + { + uint16* m; + uint32 n; + m=(uint16*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(m); + err=TIFFReadDirEntryCheckRangeSshortShort(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(int16*)origdata; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SSHORT: + *value=(int16*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfShort((uint16*)(*value),count); + return(TIFFReadDirEntryErrOk); + } + data=(int16*)_TIFFmalloc(count*2); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + int16* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + err=TIFFReadDirEntryCheckRangeSshortLong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int16)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + int16* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeSshortSlong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int16)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + int16* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeSshortLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int16)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + int16* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeSshortSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int16)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryLongArray(TIFF *tif, TIFFDirEntry *direntry, uint32_t **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLongArray(TIFF* tif, TIFFDirEntry* direntry, uint32** value) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - uint32_t *data; - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_LONG: - *value = (uint32_t *)origdata; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong(*value, count); - return (TIFFReadDirEntryErrOk); - case TIFF_SLONG: - { - int32_t *m; - uint32_t n; - m = (int32_t *)origdata; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong((uint32_t *)m); - err = TIFFReadDirEntryCheckRangeLongSlong(*m); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, origdata); - return (err); - } - m++; - } - *value = (uint32_t *)origdata; - return (TIFFReadDirEntryErrOk); - } - } - data = (uint32_t *)_TIFFmallocExt(tif, count * 4); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t *ma; - uint32_t *mb; - uint32_t n; - ma = (uint8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (uint32_t)(*ma++); - } - break; - case TIFF_SBYTE: - { - 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_t)(*ma++); - } - } - break; - case TIFF_SHORT: - { - 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_t)(*ma++); - } - } - break; - case TIFF_SSHORT: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeLongSshort(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint32_t)(*ma++); - } - } - break; - case TIFF_LONG8: - { - uint64_t *ma; - uint32_t *mb; - uint32_t n; - ma = (uint64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(ma); - err = TIFFReadDirEntryCheckRangeLongLong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint32_t)(*ma++); - } - } - break; - case TIFF_SLONG8: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeLongSlong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint32_t)(*ma++); - } - } - break; - } - _TIFFfreeExt(tif, origdata); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, data); - return (err); - } - *value = data; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + uint32* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,4,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG: + *value=(uint32*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(*value,count); + return(TIFFReadDirEntryErrOk); + case TIFF_SLONG: + { + int32* m; + uint32 n; + m=(int32*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)m); + err=TIFFReadDirEntryCheckRangeLongSlong(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(uint32*)origdata; + return(TIFFReadDirEntryErrOk); + } + } + data=(uint32*)_TIFFmalloc(count*4); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + uint32* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(uint32)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + uint32* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + err=TIFFReadDirEntryCheckRangeLongSshort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint32)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + uint32* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeLongLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint32)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + uint32* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeLongSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint32)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySlongArray(TIFF *tif, TIFFDirEntry *direntry, int32_t **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlongArray(TIFF* tif, TIFFDirEntry* direntry, int32** value) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - int32_t *data; - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_LONG: - { - uint32_t *m; - uint32_t n; - m = (uint32_t *)origdata; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong((uint32_t *)m); - err = TIFFReadDirEntryCheckRangeSlongLong(*m); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, origdata); - return (err); - } - m++; - } - *value = (int32_t *)origdata; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG: - *value = (int32_t *)origdata; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong((uint32_t *)(*value), count); - return (TIFFReadDirEntryErrOk); - } - data = (int32_t *)_TIFFmallocExt(tif, count * 4); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t *ma; - int32_t *mb; - uint32_t n; - ma = (uint8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (int32_t)(*ma++); - } - break; - case TIFF_SBYTE: - { - int8_t *ma; - int32_t *mb; - uint32_t n; - ma = (int8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (int32_t)(*ma++); - } - break; - case TIFF_SHORT: - { - 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_t)(*ma++); - } - } - break; - case TIFF_SSHORT: - { - 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_t *)ma); - *mb++ = (int32_t)(*ma++); - } - } - break; - case TIFF_LONG8: - { - uint64_t *ma; - int32_t *mb; - uint32_t n; - ma = (uint64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(ma); - err = TIFFReadDirEntryCheckRangeSlongLong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int32_t)(*ma++); - } - } - break; - case TIFF_SLONG8: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeSlongSlong8(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (int32_t)(*ma++); - } - } - break; - } - _TIFFfreeExt(tif, origdata); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, data); - return (err); - } - *value = data; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + int32* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,4,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG: + { + uint32* m; + uint32 n; + m=(uint32*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)m); + err=TIFFReadDirEntryCheckRangeSlongLong(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(int32*)origdata; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG: + *value=(int32*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)(*value),count); + return(TIFFReadDirEntryErrOk); + } + data=(int32*)_TIFFmalloc(count*4); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + int32* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(int32)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + int32* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + *mb++=(int32)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + int32* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); + err=TIFFReadDirEntryCheckRangeSlongLong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int32)(*ma++); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + int32* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + err=TIFFReadDirEntryCheckRangeSlongSlong8(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(int32)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryLong8ArrayWithLimit(TIFF *tif, TIFFDirEntry *direntry, - uint64_t **value, uint64_t maxcount) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8ArrayWithLimit( + TIFF* tif, TIFFDirEntry* direntry, uint64** value, uint64 maxcount) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - uint64_t *data; - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArrayWithLimit(tif, direntry, &count, 8, &origdata, - maxcount); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_LONG8: - *value = (uint64_t *)origdata; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong8(*value, count); - return (TIFFReadDirEntryErrOk); - case TIFF_SLONG8: - { - int64_t *m; - uint32_t n; - m = (int64_t *)origdata; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)m); - err = TIFFReadDirEntryCheckRangeLong8Slong8(*m); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, origdata); - return (err); - } - m++; - } - *value = (uint64_t *)origdata; - return (TIFFReadDirEntryErrOk); - } - } - data = (uint64_t *)_TIFFmallocExt(tif, count * 8); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t *ma; - uint64_t *mb; - uint32_t n; - ma = (uint8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (uint64_t)(*ma++); - } - break; - case TIFF_SBYTE: - { - 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_t)(*ma++); - } - } - break; - case TIFF_SHORT: - { - 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_t)(*ma++); - } - } - break; - case TIFF_SSHORT: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeLong8Sshort(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint64_t)(*ma++); - } - } - break; - case TIFF_LONG: - { - 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_t)(*ma++); - } - } - break; - case TIFF_SLONG: - { - 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_t *)ma); - err = TIFFReadDirEntryCheckRangeLong8Slong(*ma); - if (err != TIFFReadDirEntryErrOk) - break; - *mb++ = (uint64_t)(*ma++); - } - } - break; - } - _TIFFfreeExt(tif, origdata); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, data); - return (err); - } - *value = data; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + uint64* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArrayWithLimit(tif,direntry,&count,8,&origdata,maxcount); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG8: + *value=(uint64*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8(*value,count); + return(TIFFReadDirEntryErrOk); + case TIFF_SLONG8: + { + int64* m; + uint32 n; + m=(int64*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)m); + err=TIFFReadDirEntryCheckRangeLong8Slong8(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(uint64*)origdata; + return(TIFFReadDirEntryErrOk); + } + } + data=(uint64*)_TIFFmalloc(count*8); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + uint64* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(uint64)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + uint64* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + err=TIFFReadDirEntryCheckRangeLong8Sshort(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint64)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + uint64* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(uint64)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + uint64* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + err=TIFFReadDirEntryCheckRangeLong8Slong(*ma); + if (err!=TIFFReadDirEntryErrOk) + break; + *mb++=(uint64)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(data); + return(err); + } + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryLong8Array(TIFF *tif, TIFFDirEntry *direntry, uint64_t **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryLong8Array(TIFF* tif, TIFFDirEntry* direntry, uint64** value) { - return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value, - ~((uint64_t)0)); + return TIFFReadDirEntryLong8ArrayWithLimit(tif, direntry, value, ~((uint64)0)); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntrySlong8Array(TIFF *tif, TIFFDirEntry *direntry, int64_t **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntrySlong8Array(TIFF* tif, TIFFDirEntry* direntry, int64** value) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - int64_t *data; - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_LONG8: - { - uint64_t *m; - uint32_t n; - m = (uint64_t *)origdata; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(m); - err = TIFFReadDirEntryCheckRangeSlong8Long8(*m); - if (err != TIFFReadDirEntryErrOk) - { - _TIFFfreeExt(tif, origdata); - return (err); - } - m++; - } - *value = (int64_t *)origdata; - return (TIFFReadDirEntryErrOk); - } - case TIFF_SLONG8: - *value = (int64_t *)origdata; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64_t *)(*value), count); - return (TIFFReadDirEntryErrOk); - } - data = (int64_t *)_TIFFmallocExt(tif, count * 8); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t *ma; - int64_t *mb; - uint32_t n; - ma = (uint8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (int64_t)(*ma++); - } - break; - case TIFF_SBYTE: - { - int8_t *ma; - int64_t *mb; - uint32_t n; - ma = (int8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (int64_t)(*ma++); - } - break; - case TIFF_SHORT: - { - 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_t)(*ma++); - } - } - break; - case TIFF_SSHORT: - { - 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_t *)ma); - *mb++ = (int64_t)(*ma++); - } - } - break; - case TIFF_LONG: - { - 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_t)(*ma++); - } - } - break; - case TIFF_SLONG: - { - 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_t *)ma); - *mb++ = (int64_t)(*ma++); - } - } - break; - } - _TIFFfreeExt(tif, origdata); - *value = data; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + int64* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,8,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG8: + { + uint64* m; + uint32 n; + m=(uint64*)origdata; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(m); + err=TIFFReadDirEntryCheckRangeSlong8Long8(*m); + if (err!=TIFFReadDirEntryErrOk) + { + _TIFFfree(origdata); + return(err); + } + m++; + } + *value=(int64*)origdata; + return(TIFFReadDirEntryErrOk); + } + case TIFF_SLONG8: + *value=(int64*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8((uint64*)(*value),count); + return(TIFFReadDirEntryErrOk); + } + data=(int64*)_TIFFmalloc(count*8); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + int64* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(int64)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + int64* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + *mb++=(int64)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + int64* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(int64)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + int64* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + *mb++=(int64)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryFloatArray(TIFF *tif, TIFFDirEntry *direntry, float **value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryFloatArray(TIFF* tif, TIFFDirEntry* direntry, float** value) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - float *data; - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - case TIFF_DOUBLE: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 4, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_FLOAT: - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong((uint32_t *)origdata, count); - TIFFCvtIEEEDoubleToNative(tif, count, (float *)origdata); - *value = (float *)origdata; - return (TIFFReadDirEntryErrOk); - } - data = (float *)_TIFFmallocExt(tif, count * sizeof(float)); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t *ma; - float *mb; - uint32_t n; - ma = (uint8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (float)(*ma++); - } - break; - case TIFF_SBYTE: - { - int8_t *ma; - float *mb; - uint32_t n; - ma = (int8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (float)(*ma++); - } - break; - case TIFF_SHORT: - { - uint16_t *ma; - float *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++ = (float)(*ma++); - } - } - break; - case TIFF_SSHORT: - { - int16_t *ma; - float *mb; - uint32_t n; - ma = (int16_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)ma); - *mb++ = (float)(*ma++); - } - } - break; - case TIFF_LONG: - { - uint32_t *ma; - float *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++ = (float)(*ma++); - } - } - break; - case TIFF_SLONG: - { - int32_t *ma; - float *mb; - uint32_t n; - ma = (int32_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong((uint32_t *)ma); - *mb++ = (float)(*ma++); - } - } - break; - case TIFF_LONG8: - { - uint64_t *ma; - float *mb; - uint32_t n; - ma = (uint64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(ma); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + float* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + case TIFF_DOUBLE: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,4,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_FLOAT: + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)origdata,count); + TIFFCvtIEEEDoubleToNative(tif,count,(float*)origdata); + *value=(float*)origdata; + return(TIFFReadDirEntryErrOk); + } + data=(float*)_TIFFmalloc(count*sizeof(float)); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + float* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + float* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + float* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + float* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + float* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); #if defined(__WIN32__) && (_MSC_VER < 1500) - /* - * XXX: MSVC 6.0 does not support - * conversion of 64-bit integers into - * floating point values. - */ - *mb++ = _TIFFUInt64ToFloat(*ma++); + /* + * XXX: MSVC 6.0 does not support + * conversion of 64-bit integers into + * floating point values. + */ + *mb++ = _TIFFUInt64ToFloat(*ma++); #else - *mb++ = (float)(*ma++); + *mb++ = (float)(*ma++); #endif - } - } - break; - case TIFF_SLONG8: - { - int64_t *ma; - float *mb; - uint32_t n; - ma = (int64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)ma); - *mb++ = (float)(*ma++); - } - } - break; - case TIFF_RATIONAL: - { - uint32_t *ma; - uint32_t maa; - uint32_t mab; - float *mb; - uint32_t n; - ma = (uint32_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(ma); - maa = *ma++; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(ma); - mab = *ma++; - if (mab == 0) - *mb++ = 0.0; - else - *mb++ = (float)maa / (float)mab; - } - } - break; - case TIFF_SRATIONAL: - { - uint32_t *ma; - int32_t maa; - uint32_t mab; - float *mb; - 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_t *)ma; - ma++; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(ma); - mab = *ma++; - if (mab == 0) - *mb++ = 0.0; - else - *mb++ = (float)maa / (float)mab; - } - } - break; - case TIFF_DOUBLE: - { - double *ma; - float *mb; - uint32_t n; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64_t *)origdata, count); - TIFFCvtIEEEDoubleToNative(tif, count, (double *)origdata); - ma = (double *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - double val = *ma++; - if (val > FLT_MAX) - val = FLT_MAX; - else if (val < -FLT_MAX) - val = -FLT_MAX; - *mb++ = (float)val; - } - } - break; - } - _TIFFfreeExt(tif, origdata); - *value = data; - return (TIFFReadDirEntryErrOk); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + float* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + *mb++=(float)(*ma++); + } + } + break; + case TIFF_RATIONAL: + { + uint32* ma; + uint32 maa; + uint32 mab; + float* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + maa=*ma++; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + mab=*ma++; + if (mab==0) + *mb++=0.0; + else + *mb++=(float)maa/(float)mab; + } + } + break; + case TIFF_SRATIONAL: + { + uint32* ma; + int32 maa; + uint32 mab; + float* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + maa=*(int32*)ma; + ma++; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + mab=*ma++; + if (mab==0) + *mb++=0.0; + else + *mb++=(float)maa/(float)mab; + } + } + break; + case TIFF_DOUBLE: + { + double* ma; + float* mb; + uint32 n; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8((uint64*)origdata,count); + TIFFCvtIEEEDoubleToNative(tif,count,(double*)origdata); + ma=(double*)origdata; + mb=data; + for (n=0; n FLT_MAX ) + val = FLT_MAX; + else if( val < -FLT_MAX ) + val = -FLT_MAX; + *mb++=(float)val; + } + } + break; + } + _TIFFfree(origdata); + *value=data; + return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryDoubleArray(TIFF *tif, TIFFDirEntry *direntry, double **value) +TIFFReadDirEntryDoubleArray(TIFF* tif, TIFFDirEntry* direntry, double** value) { - enum TIFFReadDirEntryErr err; - uint32_t count; - void *origdata; - double *data; - switch (direntry->tdir_type) - { - case TIFF_BYTE: - case TIFF_SBYTE: - case TIFF_SHORT: - case TIFF_SSHORT: - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_LONG8: - case TIFF_SLONG8: - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - case TIFF_DOUBLE: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_DOUBLE: - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64_t *)origdata, count); - TIFFCvtIEEEDoubleToNative(tif, count, (double *)origdata); - *value = (double *)origdata; - return (TIFFReadDirEntryErrOk); - } - data = (double *)_TIFFmallocExt(tif, count * sizeof(double)); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_BYTE: - { - uint8_t *ma; - double *mb; - uint32_t n; - ma = (uint8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (double)(*ma++); - } - break; - case TIFF_SBYTE: - { - int8_t *ma; - double *mb; - uint32_t n; - ma = (int8_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (double)(*ma++); - } - break; - case TIFF_SHORT: - { - uint16_t *ma; - double *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++ = (double)(*ma++); - } - } - break; - case TIFF_SSHORT: - { - int16_t *ma; - double *mb; - uint32_t n; - ma = (int16_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)ma); - *mb++ = (double)(*ma++); - } - } - break; - case TIFF_LONG: - { - uint32_t *ma; - double *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++ = (double)(*ma++); - } - } - break; - case TIFF_SLONG: - { - int32_t *ma; - double *mb; - uint32_t n; - ma = (int32_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong((uint32_t *)ma); - *mb++ = (double)(*ma++); - } - } - break; - case TIFF_LONG8: - { - uint64_t *ma; - double *mb; - uint32_t n; - ma = (uint64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(ma); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + double* data; + switch (direntry->tdir_type) + { + case TIFF_BYTE: + case TIFF_SBYTE: + case TIFF_SHORT: + case TIFF_SSHORT: + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + case TIFF_DOUBLE: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,8,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_DOUBLE: + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8((uint64*)origdata,count); + TIFFCvtIEEEDoubleToNative(tif,count,(double*)origdata); + *value=(double*)origdata; + return(TIFFReadDirEntryErrOk); + } + data=(double*)_TIFFmalloc(count*sizeof(double)); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_BYTE: + { + uint8* ma; + double* mb; + uint32 n; + ma=(uint8*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort(ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_SSHORT: + { + int16* ma; + double* mb; + uint32 n; + ma=(int16*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_LONG: + { + uint32* ma; + double* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_SLONG: + { + int32* ma; + double* mb; + uint32 n; + ma=(int32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_LONG8: + { + uint64* ma; + double* mb; + uint32 n; + ma=(uint64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8(ma); #if defined(__WIN32__) && (_MSC_VER < 1500) - /* - * XXX: MSVC 6.0 does not support - * conversion of 64-bit integers into - * floating point values. - */ - *mb++ = _TIFFUInt64ToDouble(*ma++); + /* + * XXX: MSVC 6.0 does not support + * conversion of 64-bit integers into + * floating point values. + */ + *mb++ = _TIFFUInt64ToDouble(*ma++); #else - *mb++ = (double)(*ma++); + *mb++ = (double)(*ma++); #endif - } - } - break; - case TIFF_SLONG8: - { - int64_t *ma; - double *mb; - uint32_t n; - ma = (int64_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)ma); - *mb++ = (double)(*ma++); - } - } - break; - case TIFF_RATIONAL: - { - uint32_t *ma; - uint32_t maa; - uint32_t mab; - double *mb; - uint32_t n; - ma = (uint32_t *)origdata; - mb = data; - for (n = 0; n < count; n++) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(ma); - maa = *ma++; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(ma); - mab = *ma++; - if (mab == 0) - *mb++ = 0.0; - else - *mb++ = (double)maa / (double)mab; - } - } - break; - case TIFF_SRATIONAL: - { - uint32_t *ma; - int32_t maa; - uint32_t mab; - double *mb; - 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_t *)ma; - ma++; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(ma); - mab = *ma++; - if (mab == 0) - *mb++ = 0.0; - else - *mb++ = (double)maa / (double)mab; - } - } - break; - case TIFF_FLOAT: - { - float *ma; - double *mb; - uint32_t n; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong((uint32_t *)origdata, count); - TIFFCvtIEEEFloatToNative(tif, count, (float *)origdata); - ma = (float *)origdata; - mb = data; - for (n = 0; n < count; n++) - *mb++ = (double)(*ma++); - } - break; - } - _TIFFfreeExt(tif, origdata); - *value = data; - return (TIFFReadDirEntryErrOk); + } + } + break; + case TIFF_SLONG8: + { + int64* ma; + double* mb; + uint32 n; + ma=(int64*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + *mb++=(double)(*ma++); + } + } + break; + case TIFF_RATIONAL: + { + uint32* ma; + uint32 maa; + uint32 mab; + double* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + maa=*ma++; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + mab=*ma++; + if (mab==0) + *mb++=0.0; + else + *mb++=(double)maa/(double)mab; + } + } + break; + case TIFF_SRATIONAL: + { + uint32* ma; + int32 maa; + uint32 mab; + double* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + maa=*(int32*)ma; + ma++; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + mab=*ma++; + if (mab==0) + *mb++=0.0; + else + *mb++=(double)maa/(double)mab; + } + } + break; + case TIFF_FLOAT: + { + float* ma; + double* mb; + uint32 n; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)origdata,count); + TIFFCvtIEEEFloatToNative(tif,count,(float*)origdata); + ma=(float*)origdata; + mb=data; + for (n=0; ntdir_type) - { - case TIFF_LONG: - case TIFF_LONG8: - case TIFF_IFD: - case TIFF_IFD8: - break; - default: - return (TIFFReadDirEntryErrType); - } - err = TIFFReadDirEntryArray(tif, direntry, &count, 8, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - *value = 0; - return (err); - } - switch (direntry->tdir_type) - { - case TIFF_LONG8: - case TIFF_IFD8: - *value = (uint64_t *)origdata; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong8(*value, count); - return (TIFFReadDirEntryErrOk); - } - data = (uint64_t *)_TIFFmallocExt(tif, count * 8); - if (data == 0) - { - _TIFFfreeExt(tif, origdata); - return (TIFFReadDirEntryErrAlloc); - } - switch (direntry->tdir_type) - { - case TIFF_LONG: - case TIFF_IFD: - { - 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_t)(*ma++); - } - } - break; - } - _TIFFfreeExt(tif, origdata); - *value = data; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint32 count; + void* origdata; + uint64* data; + switch (direntry->tdir_type) + { + case TIFF_LONG: + case TIFF_LONG8: + case TIFF_IFD: + case TIFF_IFD8: + break; + default: + return(TIFFReadDirEntryErrType); + } + err=TIFFReadDirEntryArray(tif,direntry,&count,8,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + *value=0; + return(err); + } + switch (direntry->tdir_type) + { + case TIFF_LONG8: + case TIFF_IFD8: + *value=(uint64*)origdata; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8(*value,count); + return(TIFFReadDirEntryErrOk); + } + data=(uint64*)_TIFFmalloc(count*8); + if (data==0) + { + _TIFFfree(origdata); + return(TIFFReadDirEntryErrAlloc); + } + switch (direntry->tdir_type) + { + case TIFF_LONG: + case TIFF_IFD: + { + uint32* ma; + uint64* mb; + uint32 n; + ma=(uint32*)origdata; + mb=data; + for (n=0; ntif_flags&TIFF_SWAB) + TIFFSwabLong(ma); + *mb++=(uint64)(*ma++); + } + } + break; + } + _TIFFfree(origdata); + *value=data; + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr -TIFFReadDirEntryPersampleShort(TIFF *tif, TIFFDirEntry *direntry, - uint16_t *value) +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) { - enum TIFFReadDirEntryErr err; - 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) - return (err); - na = m; - nb = tif->tif_dir.td_samplesperpixel; - *value = *na++; - nb--; - while (nb > 0) - { - if (*na++ != *value) - { - err = TIFFReadDirEntryErrPsdif; - break; - } - nb--; - } - _TIFFfreeExt(tif, m); - return (err); -} - -static void TIFFReadDirEntryCheckedByte(TIFF *tif, TIFFDirEntry *direntry, - uint8_t *value) -{ - (void)tif; - *value = *(uint8_t *)(&direntry->tdir_offset); -} - -static void TIFFReadDirEntryCheckedSbyte(TIFF *tif, TIFFDirEntry *direntry, - int8_t *value) -{ - (void)tif; - *value = *(int8_t *)(&direntry->tdir_offset); -} - -static void TIFFReadDirEntryCheckedShort(TIFF *tif, TIFFDirEntry *direntry, - uint16_t *value) -{ - *value = direntry->tdir_offset.toff_short; - /* *value=*(uint16_t*)(&direntry->tdir_offset); */ - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(value); -} - -static void TIFFReadDirEntryCheckedSshort(TIFF *tif, TIFFDirEntry *direntry, - int16_t *value) -{ - *value = *(int16_t *)(&direntry->tdir_offset); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)value); -} - -static void TIFFReadDirEntryCheckedLong(TIFF *tif, TIFFDirEntry *direntry, - uint32_t *value) -{ - *value = *(uint32_t *)(&direntry->tdir_offset); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(value); -} - -static void TIFFReadDirEntryCheckedSlong(TIFF *tif, TIFFDirEntry *direntry, - int32_t *value) -{ - *value = *(int32_t *)(&direntry->tdir_offset); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong((uint32_t *)value); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckedLong8(TIFF *tif, TIFFDirEntry *direntry, uint64_t *value) -{ - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - enum TIFFReadDirEntryErr err; - uint32_t offset = direntry->tdir_offset.toff_long; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&offset); - err = TIFFReadDirEntryData(tif, offset, 8, value); - if (err != TIFFReadDirEntryErrOk) - return (err); - } - else - *value = direntry->tdir_offset.toff_long8; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(value); - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckedSlong8(TIFF *tif, TIFFDirEntry *direntry, int64_t *value) -{ - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - enum TIFFReadDirEntryErr err; - uint32_t offset = direntry->tdir_offset.toff_long; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&offset); - err = TIFFReadDirEntryData(tif, offset, 8, value); - if (err != TIFFReadDirEntryErrOk) - return (err); - } - else - *value = *(int64_t *)(&direntry->tdir_offset); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)value); - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckedRational(TIFF *tif, TIFFDirEntry *direntry, - double *value) -{ - UInt64Aligned_t m; - - assert(sizeof(double) == 8); - assert(sizeof(uint64_t) == 8); - assert(sizeof(uint32_t) == 4); - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - enum TIFFReadDirEntryErr err; - uint32_t offset = direntry->tdir_offset.toff_long; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&offset); - err = TIFFReadDirEntryData(tif, offset, 8, m.i); - if (err != TIFFReadDirEntryErrOk) - return (err); - } - else - m.l = direntry->tdir_offset.toff_long8; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong(m.i, 2); - /* 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 (m.i[0] == 0 || m.i[1] == 0) - *value = 0.0; - else - *value = (double)m.i[0] / (double)m.i[1]; - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckedSrational(TIFF *tif, TIFFDirEntry *direntry, - double *value) -{ - UInt64Aligned_t m; - assert(sizeof(double) == 8); - 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_t offset = direntry->tdir_offset.toff_long; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&offset); - err = TIFFReadDirEntryData(tif, offset, 8, m.i); - if (err != TIFFReadDirEntryErrOk) - return (err); - } - else - m.l = direntry->tdir_offset.toff_long8; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong(m.i, 2); - /* 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_t)m.i[0] == 0 || m.i[1] == 0) - *value = 0.0; - else - *value = (double)((int32_t)m.i[0]) / (double)m.i[1]; - return (TIFFReadDirEntryErrOk); + enum TIFFReadDirEntryErr err; + uint16* m; + uint16* na; + uint16 nb; + if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel) + return(TIFFReadDirEntryErrCount); + err=TIFFReadDirEntryShortArray(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk || m == NULL) + return(err); + na=m; + nb=tif->tif_dir.td_samplesperpixel; + *value=*na++; + nb--; + while (nb>0) + { + if (*na++!=*value) + { + err=TIFFReadDirEntryErrPsdif; + break; + } + nb--; + } + _TIFFfree(m); + return(err); } #if 0 -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckedRationalDirect(TIFF *tif, TIFFDirEntry *direntry, - TIFFRational_t *value) -{ /*--: SetGetRATIONAL_directly:_CustomTag: Read rational (and signed rationals) - directly --*/ - UInt64Aligned_t m; - - assert(sizeof(double) == 8); - assert(sizeof(uint64_t) == 8); - assert(sizeof(uint32_t) == 4); - - if (direntry->tdir_count != 1) - return (TIFFReadDirEntryErrCount); - - if (direntry->tdir_type != TIFF_RATIONAL && - direntry->tdir_type != TIFF_SRATIONAL) - return (TIFFReadDirEntryErrType); - - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - enum TIFFReadDirEntryErr err; - uint32_t offset = direntry->tdir_offset.toff_long; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&offset); - err = TIFFReadDirEntryData(tif, offset, 8, m.i); - if (err != TIFFReadDirEntryErrOk) - return (err); - } - else - { - m.l = direntry->tdir_offset.toff_long8; - } - - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong(m.i, 2); - - value->uNum = m.i[0]; - value->uDenom = m.i[1]; - return (TIFFReadDirEntryErrOk); -} /*-- TIFFReadDirEntryCheckedRationalDirect() --*/ +static enum TIFFReadDirEntryErr TIFFReadDirEntryPersampleDouble(TIFF* tif, TIFFDirEntry* direntry, double* value) +{ + enum TIFFReadDirEntryErr err; + double* m; + double* na; + uint16 nb; + if (direntry->tdir_count<(uint64)tif->tif_dir.td_samplesperpixel) + return(TIFFReadDirEntryErrCount); + err=TIFFReadDirEntryDoubleArray(tif,direntry,&m); + if (err!=TIFFReadDirEntryErrOk) + return(err); + na=m; + nb=tif->tif_dir.td_samplesperpixel; + *value=*na++; + nb--; + while (nb>0) + { + if (*na++!=*value) + { + err=TIFFReadDirEntryErrPsdif; + break; + } + nb--; + } + _TIFFfree(m); + return(err); +} #endif -static void TIFFReadDirEntryCheckedFloat(TIFF *tif, TIFFDirEntry *direntry, - float *value) +static void TIFFReadDirEntryCheckedByte(TIFF* tif, TIFFDirEntry* direntry, uint8* value) { - union - { - float f; - uint32_t i; - } float_union; - assert(sizeof(float) == 4); - assert(sizeof(uint32_t) == 4); - assert(sizeof(float_union) == 4); - float_union.i = *(uint32_t *)(&direntry->tdir_offset); - *value = float_union.f; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong((uint32_t *)value); + (void) tif; + *value=*(uint8*)(&direntry->tdir_offset); +} + +static void TIFFReadDirEntryCheckedSbyte(TIFF* tif, TIFFDirEntry* direntry, int8* value) +{ + (void) tif; + *value=*(int8*)(&direntry->tdir_offset); +} + +static void TIFFReadDirEntryCheckedShort(TIFF* tif, TIFFDirEntry* direntry, uint16* value) +{ + *value = direntry->tdir_offset.toff_short; + /* *value=*(uint16*)(&direntry->tdir_offset); */ + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort(value); +} + +static void TIFFReadDirEntryCheckedSshort(TIFF* tif, TIFFDirEntry* direntry, int16* value) +{ + *value=*(int16*)(&direntry->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)value); +} + +static void TIFFReadDirEntryCheckedLong(TIFF* tif, TIFFDirEntry* direntry, uint32* value) +{ + *value=*(uint32*)(&direntry->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(value); +} + +static void TIFFReadDirEntryCheckedSlong(TIFF* tif, TIFFDirEntry* direntry, int32* value) +{ + *value=*(int32*)(&direntry->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)value); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedLong8(TIFF* tif, TIFFDirEntry* direntry, uint64* value) +{ + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,value); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + *value = direntry->tdir_offset.toff_long8; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(value); + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSlong8(TIFF* tif, TIFFDirEntry* direntry, int64* value) +{ + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,value); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + *value=*(int64*)(&direntry->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)value); + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedRational(TIFF* tif, TIFFDirEntry* direntry, double* value) +{ + UInt64Aligned_t m; + + assert(sizeof(double)==8); + assert(sizeof(uint64)==8); + assert(sizeof(uint32)==4); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,m.i); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + m.l = direntry->tdir_offset.toff_long8; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(m.i,2); + /* 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 (m.i[0]==0 || m.i[1]==0) + *value=0.0; + else + *value=(double)m.i[0]/(double)m.i[1]; + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedSrational(TIFF* tif, TIFFDirEntry* direntry, double* value) +{ + UInt64Aligned_t m; + assert(sizeof(double)==8); + assert(sizeof(uint64)==8); + assert(sizeof(int32)==4); + assert(sizeof(uint32)==4); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,m.i); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + m.l=direntry->tdir_offset.toff_long8; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(m.i,2); + /* 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) + *value=0.0; + else + *value=(double)((int32)m.i[0])/(double)m.i[1]; + return(TIFFReadDirEntryErrOk); +} + +static void TIFFReadDirEntryCheckedFloat(TIFF* tif, TIFFDirEntry* direntry, float* value) +{ + union + { + float f; + uint32 i; + } float_union; + assert(sizeof(float)==4); + assert(sizeof(uint32)==4); + assert(sizeof(float_union)==4); + float_union.i=*(uint32*)(&direntry->tdir_offset); + *value=float_union.f; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)value); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckedDouble(TIFF* tif, TIFFDirEntry* direntry, double* value) +{ + assert(sizeof(double)==8); + assert(sizeof(uint64)==8); + assert(sizeof(UInt64Aligned_t)==8); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + enum TIFFReadDirEntryErr err; + uint32 offset = direntry->tdir_offset.toff_long; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,value); + if (err!=TIFFReadDirEntryErrOk) + return(err); + } + else + { + UInt64Aligned_t uint64_union; + uint64_union.l=direntry->tdir_offset.toff_long8; + *value=uint64_union.d; + } + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)value); + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSbyte(int8 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteShort(uint16 value) +{ + if (value>0xFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSshort(int16 value) +{ + if ((value<0)||(value>0xFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong(uint32 value) +{ + if (value>0xFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong(int32 value) +{ + if ((value<0)||(value>0xFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteLong8(uint64 value) +{ + if (value>0xFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeByteSlong8(int64 value) +{ + if ((value<0)||(value>0xFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteByte(uint8 value) +{ + if (value>0x7F) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteShort(uint16 value) +{ + if (value>0x7F) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSshort(int16 value) +{ + if ((value<-0x80)||(value>0x7F)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong(uint32 value) +{ + if (value>0x7F) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong(int32 value) +{ + if ((value<-0x80)||(value>0x7F)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteLong8(uint64 value) +{ + if (value>0x7F) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSbyteSlong8(int64 value) +{ + if ((value<-0x80)||(value>0x7F)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSbyte(int8 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSshort(int16 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong(uint32 value) +{ + if (value>0xFFFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong(int32 value) +{ + if ((value<0)||(value>0xFFFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortLong8(uint64 value) +{ + if (value>0xFFFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeShortSlong8(int64 value) +{ + if ((value<0)||(value>0xFFFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortShort(uint16 value) +{ + if (value>0x7FFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong(uint32 value) +{ + if (value>0x7FFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong(int32 value) +{ + if ((value<-0x8000)||(value>0x7FFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortLong8(uint64 value) +{ + if (value>0x7FFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeSshortSlong8(int64 value) +{ + if ((value<-0x8000)||(value>0x7FFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSbyte(int8 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSshort(int16 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); +} + +static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value) +{ + if (value<0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckedDouble(TIFF *tif, TIFFDirEntry *direntry, double *value) +TIFFReadDirEntryCheckRangeLongLong8(uint64 value) { - assert(sizeof(double) == 8); - assert(sizeof(uint64_t) == 8); - assert(sizeof(UInt64Aligned_t) == 8); - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - enum TIFFReadDirEntryErr err; - uint32_t offset = direntry->tdir_offset.toff_long; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&offset); - err = TIFFReadDirEntryData(tif, offset, 8, value); - if (err != TIFFReadDirEntryErrOk) - return (err); - } - else - { - UInt64Aligned_t uint64_union; - uint64_union.l = direntry->tdir_offset.toff_long8; - *value = uint64_union.d; - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)value); - return (TIFFReadDirEntryErrOk); + if (value > (uint64)(TIFF_UINT32_MAX)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeByteSbyte(int8_t value) +TIFFReadDirEntryCheckRangeLongSlong8(int64 value) { - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); + if ((value < 0) || (value > (int64) TIFF_UINT32_MAX)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeByteShort(uint16_t value) +TIFFReadDirEntryCheckRangeSlongLong(uint32 value) { - if (value > 0xFF) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeByteSshort(int16_t value) -{ - if ((value < 0) || (value > 0xFF)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeByteLong(uint32_t value) -{ - if (value > 0xFF) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeByteSlong(int32_t value) -{ - if ((value < 0) || (value > 0xFF)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeByteLong8(uint64_t value) -{ - if (value > 0xFF) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeByteSlong8(int64_t value) -{ - if ((value < 0) || (value > 0xFF)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSbyteByte(uint8_t value) -{ - if (value > 0x7F) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSbyteShort(uint16_t value) -{ - if (value > 0x7F) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSbyteSshort(int16_t value) -{ - if ((value < -0x80) || (value > 0x7F)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSbyteLong(uint32_t value) -{ - if (value > 0x7F) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSbyteSlong(int32_t value) -{ - if ((value < -0x80) || (value > 0x7F)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSbyteLong8(uint64_t value) -{ - if (value > 0x7F) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSbyteSlong8(int64_t value) -{ - if ((value < -0x80) || (value > 0x7F)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeShortSbyte(int8_t value) -{ - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeShortSshort(int16_t value) -{ - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeShortLong(uint32_t value) -{ - if (value > 0xFFFF) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeShortSlong(int32_t value) -{ - if ((value < 0) || (value > 0xFFFF)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeShortLong8(uint64_t value) -{ - if (value > 0xFFFF) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeShortSlong8(int64_t value) -{ - if ((value < 0) || (value > 0xFFFF)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSshortShort(uint16_t value) -{ - if (value > 0x7FFF) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSshortLong(uint32_t value) -{ - if (value > 0x7FFF) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSshortSlong(int32_t value) -{ - if ((value < -0x8000) || (value > 0x7FFF)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSshortLong8(uint64_t value) -{ - if (value > 0x7FFF) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSshortSlong8(int64_t value) -{ - if ((value < -0x8000) || (value > 0x7FFF)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLongSbyte(int8_t value) -{ - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLongSshort(int16_t value) -{ - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLongSlong(int32_t value) -{ - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLongLong8(uint64_t value) -{ - if (value > UINT32_MAX) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLongSlong8(int64_t value) -{ - if ((value < 0) || (value > (int64_t)UINT32_MAX)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); -} - -static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongLong(uint32_t value) -{ - if (value > 0x7FFFFFFFUL) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); + if (value > 0x7FFFFFFFUL) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } /* Check that the 8-byte unsigned value can fit in a 4-byte unsigned range */ static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongLong8(uint64_t value) +TIFFReadDirEntryCheckRangeSlongLong8(uint64 value) { - if (value > 0x7FFFFFFF) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); + if (value > 0x7FFFFFFF) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } /* Check that the 8-byte signed value can fit in a 4-byte signed range */ static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlongSlong8(int64_t value) +TIFFReadDirEntryCheckRangeSlongSlong8(int64 value) { - if ((value < 0 - ((int64_t)0x7FFFFFFF + 1)) || (value > 0x7FFFFFFF)) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); + if ((value < 0-((int64) 0x7FFFFFFF+1)) || (value > 0x7FFFFFFF)) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Sbyte(int8_t value) +TIFFReadDirEntryCheckRangeLong8Sbyte(int8 value) { - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); + if (value < 0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Sshort(int16_t value) +TIFFReadDirEntryCheckRangeLong8Sshort(int16 value) { - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); + if (value < 0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Slong(int32_t value) +TIFFReadDirEntryCheckRangeLong8Slong(int32 value) { - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); + if (value < 0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeLong8Slong8(int64_t value) +TIFFReadDirEntryCheckRangeLong8Slong8(int64 value) { - if (value < 0) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); + if (value < 0) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } static enum TIFFReadDirEntryErr -TIFFReadDirEntryCheckRangeSlong8Long8(uint64_t value) +TIFFReadDirEntryCheckRangeSlong8Long8(uint64 value) { - if (value > INT64_MAX) - return (TIFFReadDirEntryErrRange); - else - return (TIFFReadDirEntryErrOk); + if (value > TIFF_INT64_MAX) + return(TIFFReadDirEntryErrRange); + else + return(TIFFReadDirEntryErrOk); } -static enum TIFFReadDirEntryErr TIFFReadDirEntryData(TIFF *tif, uint64_t offset, - tmsize_t size, void *dest) +static enum TIFFReadDirEntryErr +TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest) { - assert(size > 0); - if (!isMapped(tif)) - { - if (!SeekOK(tif, offset)) - return (TIFFReadDirEntryErrIo); - if (!ReadOK(tif, dest, size)) - return (TIFFReadDirEntryErrIo); - } - else - { - size_t ma, mb; - ma = (size_t)offset; - if ((uint64_t)ma != offset || ma > (~(size_t)0) - (size_t)size) - { - return TIFFReadDirEntryErrIo; - } - mb = ma + size; - if (mb > (uint64_t)tif->tif_size) - return (TIFFReadDirEntryErrIo); - _TIFFmemcpy(dest, tif->tif_base + ma, size); - } - return (TIFFReadDirEntryErrOk); + assert(size>0); + if (!isMapped(tif)) { + if (!SeekOK(tif,offset)) + return(TIFFReadDirEntryErrIo); + if (!ReadOK(tif,dest,size)) + return(TIFFReadDirEntryErrIo); + } else { + size_t ma,mb; + ma=(size_t)offset; + if( (uint64)ma!=offset || + ma > (~(size_t)0) - (size_t)size ) + { + return TIFFReadDirEntryErrIo; + } + mb=ma+size; + if (mb > (uint64)tif->tif_size) + return(TIFFReadDirEntryErrIo); + _TIFFmemcpy(dest,tif->tif_base+ma,size); + } + return(TIFFReadDirEntryErrOk); } -static void TIFFReadDirEntryOutputErr(TIFF *tif, enum TIFFReadDirEntryErr err, - const char *module, const char *tagname, - int recover) +static void TIFFReadDirEntryOutputErr(TIFF* tif, enum TIFFReadDirEntryErr err, const char* module, const char* tagname, int recover) { - if (!recover) - { - switch (err) - { - case TIFFReadDirEntryErrCount: - TIFFErrorExtR(tif, module, "Incorrect count for \"%s\"", - tagname); - break; - case TIFFReadDirEntryErrType: - TIFFErrorExtR(tif, module, "Incompatible type for \"%s\"", - tagname); - break; - case TIFFReadDirEntryErrIo: - TIFFErrorExtR(tif, module, "IO error during reading of \"%s\"", - tagname); - break; - case TIFFReadDirEntryErrRange: - TIFFErrorExtR(tif, module, "Incorrect value for \"%s\"", - tagname); - break; - case TIFFReadDirEntryErrPsdif: - TIFFErrorExtR( - tif, module, - "Cannot handle different values per sample for \"%s\"", - tagname); - break; - case TIFFReadDirEntryErrSizesan: - TIFFErrorExtR(tif, module, - "Sanity check on size of \"%s\" value failed", - tagname); - break; - case TIFFReadDirEntryErrAlloc: - TIFFErrorExtR(tif, module, "Out of memory reading of \"%s\"", - tagname); - break; - default: - assert(0); /* we should never get here */ - break; - } - } - else - { - switch (err) - { - case TIFFReadDirEntryErrCount: - TIFFWarningExtR(tif, module, - "Incorrect count for \"%s\"; tag ignored", - tagname); - break; - case TIFFReadDirEntryErrType: - TIFFWarningExtR(tif, module, - "Incompatible type for \"%s\"; tag ignored", - tagname); - break; - case TIFFReadDirEntryErrIo: - TIFFWarningExtR( - tif, module, - "IO error during reading of \"%s\"; tag ignored", tagname); - break; - case TIFFReadDirEntryErrRange: - TIFFWarningExtR(tif, module, - "Incorrect value for \"%s\"; tag ignored", - tagname); - break; - case TIFFReadDirEntryErrPsdif: - TIFFWarningExtR(tif, module, - "Cannot handle different values per sample for " - "\"%s\"; tag ignored", - tagname); - break; - case TIFFReadDirEntryErrSizesan: - TIFFWarningExtR( - tif, module, - "Sanity check on size of \"%s\" value failed; tag ignored", - tagname); - break; - case TIFFReadDirEntryErrAlloc: - TIFFWarningExtR(tif, module, - "Out of memory reading of \"%s\"; tag ignored", - tagname); - break; - default: - assert(0); /* we should never get here */ - break; - } - } + if (!recover) { + switch (err) { + case TIFFReadDirEntryErrCount: + TIFFErrorExt(tif->tif_clientdata, module, + "Incorrect count for \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrType: + TIFFErrorExt(tif->tif_clientdata, module, + "Incompatible type for \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrIo: + TIFFErrorExt(tif->tif_clientdata, module, + "IO error during reading of \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrRange: + TIFFErrorExt(tif->tif_clientdata, module, + "Incorrect value for \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrPsdif: + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle different values per sample for \"%s\"", + tagname); + break; + case TIFFReadDirEntryErrSizesan: + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on size of \"%s\" value failed", + tagname); + break; + case TIFFReadDirEntryErrAlloc: + TIFFErrorExt(tif->tif_clientdata, module, + "Out of memory reading of \"%s\"", + tagname); + break; + default: + assert(0); /* we should never get here */ + break; + } + } else { + switch (err) { + case TIFFReadDirEntryErrCount: + TIFFWarningExt(tif->tif_clientdata, module, + "Incorrect count for \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrType: + TIFFWarningExt(tif->tif_clientdata, module, + "Incompatible type for \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrIo: + TIFFWarningExt(tif->tif_clientdata, module, + "IO error during reading of \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrRange: + TIFFWarningExt(tif->tif_clientdata, module, + "Incorrect value for \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrPsdif: + TIFFWarningExt(tif->tif_clientdata, module, + "Cannot handle different values per sample for \"%s\"; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrSizesan: + TIFFWarningExt(tif->tif_clientdata, module, + "Sanity check on size of \"%s\" value failed; tag ignored", + tagname); + break; + case TIFFReadDirEntryErrAlloc: + TIFFWarningExt(tif->tif_clientdata, module, + "Out of memory reading of \"%s\"; tag ignored", + tagname); + break; + default: + assert(0); /* we should never get here */ + break; + } + } } /* @@ -4028,1709 +3506,1259 @@ static void TIFFReadDirEntryOutputErr(TIFF *tif, enum TIFFReadDirEntryErr err, * type. 0 is returned if photometric type isn't supported or no default value * is defined by the specification. */ -static int _TIFFGetMaxColorChannels(uint16_t photometric) +static int _TIFFGetMaxColorChannels( uint16 photometric ) { - switch (photometric) - { - case PHOTOMETRIC_PALETTE: - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: + switch (photometric) { + case PHOTOMETRIC_PALETTE: + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: return 1; - case PHOTOMETRIC_YCBCR: - case PHOTOMETRIC_RGB: - case PHOTOMETRIC_CIELAB: - case PHOTOMETRIC_LOGLUV: - case PHOTOMETRIC_ITULAB: - case PHOTOMETRIC_ICCLAB: + case PHOTOMETRIC_YCBCR: + case PHOTOMETRIC_RGB: + case PHOTOMETRIC_CIELAB: + case PHOTOMETRIC_LOGLUV: + case PHOTOMETRIC_ITULAB: + case PHOTOMETRIC_ICCLAB: return 3; - case PHOTOMETRIC_SEPARATED: - case PHOTOMETRIC_MASK: + case PHOTOMETRIC_SEPARATED: + case PHOTOMETRIC_MASK: return 4; - case PHOTOMETRIC_LOGL: - case PHOTOMETRIC_CFA: - default: + case PHOTOMETRIC_LOGL: + case PHOTOMETRIC_CFA: + default: return 0; } } -static int ByteCountLooksBad(TIFF *tif) +static int ByteCountLooksBad(TIFF* tif) { /* - * Assume we have wrong StripByteCount value (in case - * of single strip) in following cases: - * - it is equal to zero along with StripOffset; - * - it is larger than file itself (in case of uncompressed - * image); - * - it is smaller than the size of the bytes per row - * multiplied on the number of rows. The last case should - * not be checked in the case of writing new image, - * because we may do not know the exact strip size - * until the whole image will be written and directory - * dumped out. - */ - uint64_t bytecount = TIFFGetStrileByteCount(tif, 0); - uint64_t offset = TIFFGetStrileOffset(tif, 0); - uint64_t filesize; + * Assume we have wrong StripByteCount value (in case + * of single strip) in following cases: + * - it is equal to zero along with StripOffset; + * - it is larger than file itself (in case of uncompressed + * image); + * - it is smaller than the size of the bytes per row + * multiplied on the number of rows. The last case should + * not be checked in the case of writing new image, + * because we may do not know the exact strip size + * until the whole image will be written and directory + * dumped out. + */ + uint64 bytecount = TIFFGetStrileByteCount(tif, 0); + uint64 offset = TIFFGetStrileOffset(tif, 0); + uint64 filesize; - if (offset == 0) + if( offset == 0 ) return 0; if (bytecount == 0) return 1; - if (tif->tif_dir.td_compression != COMPRESSION_NONE) + if ( tif->tif_dir.td_compression != COMPRESSION_NONE ) return 0; filesize = TIFFGetFileSize(tif); - if (offset <= filesize && bytecount > filesize - offset) + if( offset <= filesize && bytecount > filesize - offset ) return 1; - if (tif->tif_mode == O_RDONLY) + if( tif->tif_mode == O_RDONLY ) { - uint64_t scanlinesize = TIFFScanlineSize64(tif); - if (tif->tif_dir.td_imagelength > 0 && - scanlinesize > UINT64_MAX / tif->tif_dir.td_imagelength) + uint64 scanlinesize = TIFFScanlineSize64(tif); + if( tif->tif_dir.td_imagelength > 0 && + scanlinesize > TIFF_UINT64_MAX / tif->tif_dir.td_imagelength ) { return 1; } - if (bytecount < scanlinesize * tif->tif_dir.td_imagelength) + if( bytecount < scanlinesize * tif->tif_dir.td_imagelength) return 1; } return 0; } + /* * Read the next TIFF directory from a file and convert it to the internal * format. We read directories sequentially. */ -int TIFFReadDirectory(TIFF *tif) +int +TIFFReadDirectory(TIFF* tif) { - static const char module[] = "TIFFReadDirectory"; - TIFFDirEntry *dir; - uint16_t dircount; - TIFFDirEntry *dp; - uint16_t di; - const TIFFField *fip; - uint32_t fii = FAILED_FII; - toff_t nextdiroff; + static const char module[] = "TIFFReadDirectory"; + TIFFDirEntry* dir; + uint16 dircount; + TIFFDirEntry* dp; + uint16 di; + const TIFFField* fip; + uint32 fii=FAILED_FII; + toff_t nextdiroff; int bitspersample_read = FALSE; - int color_channels; + int color_channels; - if (tif->tif_nextdiroff == 0) - { - /* In this special case, tif_diroff needs also to be set to 0. - * This is behind the last IFD, thus no checking or reading necessary. - */ - tif->tif_diroff = tif->tif_nextdiroff; - return 0; - } + tif->tif_diroff=tif->tif_nextdiroff; + if (!TIFFCheckDirOffset(tif,tif->tif_nextdiroff)) + return 0; /* last offset or bad offset (IFD looping) */ + (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */ + tif->tif_curdir++; + nextdiroff = tif->tif_nextdiroff; + dircount=TIFFFetchDirectory(tif,nextdiroff,&dir,&tif->tif_nextdiroff); + if (!dircount) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Failed to read directory at offset " TIFF_UINT64_FORMAT,nextdiroff); + return 0; + } + TIFFReadDirectoryCheckOrder(tif,dir,dircount); - nextdiroff = tif->tif_nextdiroff; - /* tif_curdir++ and tif_nextdiroff should only be updated after SUCCESSFUL - * reading of the directory. Otherwise, invalid IFD offsets could corrupt - * the IFD list. */ - if (!_TIFFCheckDirNumberAndOffset(tif, - tif->tif_curdir == - TIFF_NON_EXISTENT_DIR_NUMBER - ? 0 - : tif->tif_curdir + 1, - nextdiroff)) - { - return 0; /* bad offset (IFD looping or more than TIFF_MAX_DIR_COUNT - IFDs) */ - } - dircount = TIFFFetchDirectory(tif, nextdiroff, &dir, &tif->tif_nextdiroff); - if (!dircount) - { - TIFFErrorExtR(tif, module, - "Failed to read directory at offset %" PRIu64, - nextdiroff); - return 0; - } - /* Set global values after a valid directory has been fetched. - * tif_diroff is already set to nextdiroff in TIFFFetchDirectory() in the - * beginning. */ - if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER) - tif->tif_curdir = 0; - else - tif->tif_curdir++; - (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */ - - TIFFReadDirectoryCheckOrder(tif, dir, dircount); - - /* - * Mark duplicates of any tag to be ignored (bugzilla 1994) - * to avoid certain pathological problems. - */ - { - TIFFDirEntry *ma; - uint16_t mb; - for (ma = dir, mb = 0; mb < dircount; ma++, mb++) - { - TIFFDirEntry *na; - uint16_t nb; - for (na = ma + 1, nb = mb + 1; nb < dircount; na++, nb++) - { - if (ma->tdir_tag == na->tdir_tag) - { - na->tdir_ignore = TRUE; - } - } - } - } - - tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ - tif->tif_flags &= ~TIFF_BUF4WRITE; /* reset before new dir */ - tif->tif_flags &= ~TIFF_CHOPPEDUPARRAYS; - - /* free any old stuff and reinit */ - TIFFFreeDirectory(tif); - TIFFDefaultDirectory(tif); - /* - * Electronic Arts writes gray-scale TIFF files - * without a PlanarConfiguration directory entry. - * Thus we setup a default value here, even though - * the TIFF spec says there is no default value. - * After PlanarConfiguration is preset in TIFFDefaultDirectory() - * the following setting is not needed, but does not harm either. - */ - TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - /* - * Setup default value and then make a pass over - * the fields to check type and tag information, - * and to extract info required to size data - * structures. A second pass is made afterwards - * to read in everything not taken in the first pass. - * But we must process the Compression tag first - * in order to merge in codec-private tag definitions (otherwise - * we may get complaints about unknown tags). However, the - * Compression tag may be dependent on the SamplesPerPixel - * tag value because older TIFF specs permitted Compression - * to be written as a SamplesPerPixel-count tag entry. - * Thus if we don't first figure out the correct SamplesPerPixel - * tag value then we may end up ignoring the Compression tag - * value because it has an incorrect count value (if the - * true value of SamplesPerPixel is not 1). - */ - dp = - TIFFReadDirectoryFindEntry(tif, dir, dircount, TIFFTAG_SAMPLESPERPIXEL); - if (dp) - { - if (!TIFFFetchNormalTag(tif, dp, 0)) - goto bad; - dp->tdir_ignore = TRUE; - } - dp = TIFFReadDirectoryFindEntry(tif, dir, dircount, TIFFTAG_COMPRESSION); - if (dp) - { /* - * The 5.0 spec says the Compression tag has one value, while - * earlier specs say it has one value per sample. Because of - * this, we accept the tag if one value is supplied with either - * count. + * Mark duplicates of any tag to be ignored (bugzilla 1994) + * to avoid certain pathological problems. */ - uint16_t value; - enum TIFFReadDirEntryErr err; - err = TIFFReadDirEntryShort(tif, dp, &value); - if (err == TIFFReadDirEntryErrCount) - err = TIFFReadDirEntryPersampleShort(tif, dp, &value); - if (err != TIFFReadDirEntryErrOk) - { - TIFFReadDirEntryOutputErr(tif, err, module, "Compression", 0); - goto bad; - } - if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, value)) - goto bad; - dp->tdir_ignore = TRUE; - } - else - { - if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE)) - goto bad; - } - /* - * First real pass over the directory. - */ - for (di = 0, dp = dir; di < dircount; di++, dp++) - { - if (!dp->tdir_ignore) - { - TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii); - if (fii == FAILED_FII) - { - TIFFWarningExtR(tif, module, - "Unknown field with tag %" PRIu16 " (0x%" PRIx16 - ") encountered", - dp->tdir_tag, dp->tdir_tag); - /* the following knowingly leaks the - anonymous field structure */ - if (!_TIFFMergeFields( - tif, - _TIFFCreateAnonField(tif, dp->tdir_tag, - (TIFFDataType)dp->tdir_type), - 1)) - { - TIFFWarningExtR( - tif, module, - "Registering anonymous field with tag %" PRIu16 - " (0x%" PRIx16 ") failed", - dp->tdir_tag, dp->tdir_tag); - dp->tdir_ignore = TRUE; - } - else - { - TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii); - assert(fii != FAILED_FII); - } - } - } - if (!dp->tdir_ignore) - { - fip = tif->tif_fields[fii]; - if (fip->field_bit == FIELD_IGNORE) - dp->tdir_ignore = TRUE; - else - { - switch (dp->tdir_tag) - { - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEOFFSETS: - case TIFFTAG_TILEBYTECOUNTS: - TIFFSetFieldBit(tif, fip->field_bit); - break; - case TIFFTAG_IMAGEWIDTH: - case TIFFTAG_IMAGELENGTH: - case TIFFTAG_IMAGEDEPTH: - case TIFFTAG_TILELENGTH: - case TIFFTAG_TILEWIDTH: - case TIFFTAG_TILEDEPTH: - case TIFFTAG_PLANARCONFIG: - case TIFFTAG_ROWSPERSTRIP: - case TIFFTAG_EXTRASAMPLES: - if (!TIFFFetchNormalTag(tif, dp, 0)) - goto bad; - dp->tdir_ignore = TRUE; - break; - default: - if (!_TIFFCheckFieldIsValidForCodec(tif, dp->tdir_tag)) - dp->tdir_ignore = TRUE; - break; - } - } - } - } - /* - * XXX: OJPEG hack. - * If a) compression is OJPEG, b) planarconfig tag says it's separate, - * c) strip offsets/bytecounts tag are both present and - * d) both contain exactly one value, then we consistently find - * that the buggy implementation of the buggy compression scheme - * matches contig planarconfig best. So we 'fix-up' the tag here - */ - if ((tif->tif_dir.td_compression == COMPRESSION_OJPEG) && - (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE)) - { - if (!_TIFFFillStriles(tif)) - goto bad; - dp = TIFFReadDirectoryFindEntry(tif, dir, dircount, - TIFFTAG_STRIPOFFSETS); - if ((dp != 0) && (dp->tdir_count == 1)) - { - dp = TIFFReadDirectoryFindEntry(tif, dir, dircount, - TIFFTAG_STRIPBYTECOUNTS); - if ((dp != 0) && (dp->tdir_count == 1)) - { - tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG; - TIFFWarningExtR(tif, module, - "Planarconfig tag value assumed incorrect, " - "assuming data is contig instead of chunky"); - } - } - } - /* - * Allocate directory structure and setup defaults. - */ - if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) - { - MissingRequired(tif, "ImageLength"); - goto bad; - } + { + TIFFDirEntry* ma; + uint16 mb; + for (ma=dir, mb=0; mbtdir_tag == na->tdir_tag) { + na->tdir_ignore = TRUE; + } + } + } + } + + tif->tif_flags &= ~TIFF_BEENWRITING; /* reset before new dir */ + tif->tif_flags &= ~TIFF_BUF4WRITE; /* reset before new dir */ + tif->tif_flags &= ~TIFF_CHOPPEDUPARRAYS; - /* - * Second pass: extract other information. - */ - for (di = 0, dp = dir; di < dircount; di++, dp++) - { - if (!dp->tdir_ignore) - { - switch (dp->tdir_tag) - { - case TIFFTAG_MINSAMPLEVALUE: - case TIFFTAG_MAXSAMPLEVALUE: - case TIFFTAG_BITSPERSAMPLE: - case TIFFTAG_DATATYPE: - case TIFFTAG_SAMPLEFORMAT: - /* - * The MinSampleValue, MaxSampleValue, BitsPerSample - * DataType and SampleFormat tags are supposed to be - * written as one value/sample, but some vendors - * incorrectly write one value only -- so we accept - * that as well (yuck). Other vendors write correct - * value for NumberOfSamples, but incorrect one for - * BitsPerSample and friends, and we will read this - * too. - */ - { - uint16_t value; - enum TIFFReadDirEntryErr err; - err = TIFFReadDirEntryShort(tif, dp, &value); - if (err == TIFFReadDirEntryErrCount) - err = - TIFFReadDirEntryPersampleShort(tif, dp, &value); - if (err != TIFFReadDirEntryErrOk) - { - fip = TIFFFieldWithTag(tif, dp->tdir_tag); - TIFFReadDirEntryOutputErr( - tif, err, module, - fip ? fip->field_name : "unknown tagname", 0); - goto bad; - } - if (!TIFFSetField(tif, dp->tdir_tag, value)) - goto bad; - if (dp->tdir_tag == TIFFTAG_BITSPERSAMPLE) - bitspersample_read = TRUE; - } - break; - case TIFFTAG_SMINSAMPLEVALUE: - case TIFFTAG_SMAXSAMPLEVALUE: - { + /* free any old stuff and reinit */ + TIFFFreeDirectory(tif); + TIFFDefaultDirectory(tif); + /* + * Electronic Arts writes gray-scale TIFF files + * without a PlanarConfiguration directory entry. + * Thus we setup a default value here, even though + * the TIFF spec says there is no default value. + */ + TIFFSetField(tif,TIFFTAG_PLANARCONFIG,PLANARCONFIG_CONTIG); + /* + * Setup default value and then make a pass over + * the fields to check type and tag information, + * and to extract info required to size data + * structures. A second pass is made afterwards + * to read in everything not taken in the first pass. + * But we must process the Compression tag first + * in order to merge in codec-private tag definitions (otherwise + * we may get complaints about unknown tags). However, the + * Compression tag may be dependent on the SamplesPerPixel + * tag value because older TIFF specs permitted Compression + * to be written as a SamplesPerPixel-count tag entry. + * Thus if we don't first figure out the correct SamplesPerPixel + * tag value then we may end up ignoring the Compression tag + * value because it has an incorrect count value (if the + * true value of SamplesPerPixel is not 1). + */ + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_SAMPLESPERPIXEL); + if (dp) + { + if (!TIFFFetchNormalTag(tif,dp,0)) + goto bad; + dp->tdir_ignore = TRUE; + } + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_COMPRESSION); + if (dp) + { + /* + * The 5.0 spec says the Compression tag has one value, while + * earlier specs say it has one value per sample. Because of + * this, we accept the tag if one value is supplied with either + * count. + */ + uint16 value; + enum TIFFReadDirEntryErr err; + err=TIFFReadDirEntryShort(tif,dp,&value); + if (err==TIFFReadDirEntryErrCount) + err=TIFFReadDirEntryPersampleShort(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + TIFFReadDirEntryOutputErr(tif,err,module,"Compression",0); + goto bad; + } + if (!TIFFSetField(tif,TIFFTAG_COMPRESSION,value)) + goto bad; + dp->tdir_ignore = TRUE; + } + else + { + if (!TIFFSetField(tif,TIFFTAG_COMPRESSION,COMPRESSION_NONE)) + goto bad; + } + /* + * First real pass over the directory. + */ + for (di=0, dp=dir; ditdir_ignore) + { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + if (fii == FAILED_FII) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Unknown field with tag %d (0x%x) encountered", + dp->tdir_tag,dp->tdir_tag); + /* the following knowingly leaks the + anonymous field structure */ + 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", + dp->tdir_tag, + dp->tdir_tag); + dp->tdir_ignore = TRUE; + } else { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + assert(fii != FAILED_FII); + } + } + } + if (!dp->tdir_ignore) + { + fip=tif->tif_fields[fii]; + if (fip->field_bit==FIELD_IGNORE) + dp->tdir_ignore = TRUE; + else + { + switch (dp->tdir_tag) + { + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEOFFSETS: + case TIFFTAG_TILEBYTECOUNTS: + TIFFSetFieldBit(tif,fip->field_bit); + break; + case TIFFTAG_IMAGEWIDTH: + case TIFFTAG_IMAGELENGTH: + case TIFFTAG_IMAGEDEPTH: + case TIFFTAG_TILELENGTH: + case TIFFTAG_TILEWIDTH: + case TIFFTAG_TILEDEPTH: + case TIFFTAG_PLANARCONFIG: + case TIFFTAG_ROWSPERSTRIP: + case TIFFTAG_EXTRASAMPLES: + if (!TIFFFetchNormalTag(tif,dp,0)) + goto bad; + dp->tdir_ignore = TRUE; + break; + default: + if( !_TIFFCheckFieldIsValidForCodec(tif, dp->tdir_tag) ) + dp->tdir_ignore = TRUE; + break; + } + } + } + } + /* + * XXX: OJPEG hack. + * If a) compression is OJPEG, b) planarconfig tag says it's separate, + * c) strip offsets/bytecounts tag are both present and + * d) both contain exactly one value, then we consistently find + * that the buggy implementation of the buggy compression scheme + * matches contig planarconfig best. So we 'fix-up' the tag here + */ + if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG)&& + (tif->tif_dir.td_planarconfig==PLANARCONFIG_SEPARATE)) + { + if (!_TIFFFillStriles(tif)) + goto bad; + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount,TIFFTAG_STRIPOFFSETS); + if ((dp!=0)&&(dp->tdir_count==1)) + { + dp=TIFFReadDirectoryFindEntry(tif,dir,dircount, + TIFFTAG_STRIPBYTECOUNTS); + if ((dp!=0)&&(dp->tdir_count==1)) + { + tif->tif_dir.td_planarconfig=PLANARCONFIG_CONTIG; + TIFFWarningExt(tif->tif_clientdata,module, + "Planarconfig tag value assumed incorrect, " + "assuming data is contig instead of chunky"); + } + } + } + /* + * Allocate directory structure and setup defaults. + */ + if (!TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) + { + MissingRequired(tif,"ImageLength"); + goto bad; + } - double *data = NULL; - enum TIFFReadDirEntryErr err; - uint32_t saved_flags; - int m; - if (dp->tdir_count != - (uint64_t)tif->tif_dir.td_samplesperpixel) - err = TIFFReadDirEntryErrCount; - else - err = TIFFReadDirEntryDoubleArray(tif, dp, &data); - if (err != TIFFReadDirEntryErrOk) - { - fip = TIFFFieldWithTag(tif, dp->tdir_tag); - TIFFReadDirEntryOutputErr( - tif, err, module, - fip ? fip->field_name : "unknown tagname", 0); - goto bad; - } - saved_flags = tif->tif_flags; - tif->tif_flags |= TIFF_PERSAMPLE; - m = TIFFSetField(tif, dp->tdir_tag, data); - tif->tif_flags = saved_flags; - _TIFFfreeExt(tif, data); - if (!m) - goto bad; - } - break; - case TIFFTAG_STRIPOFFSETS: - case TIFFTAG_TILEOFFSETS: - switch (dp->tdir_type) - { - case TIFF_SHORT: - case TIFF_LONG: - case TIFF_LONG8: - break; - default: - /* Warn except if directory typically created with - * TIFFDeferStrileArrayWriting() */ - if (!(tif->tif_mode == O_RDWR && - dp->tdir_count == 0 && dp->tdir_type == 0 && - dp->tdir_offset.toff_long8 == 0)) - { - fip = TIFFFieldWithTag(tif, dp->tdir_tag); - TIFFWarningExtR( - tif, module, "Invalid data type for tag %s", - fip ? fip->field_name : "unknown tagname"); - } - break; - } - _TIFFmemcpy(&(tif->tif_dir.td_stripoffset_entry), dp, - sizeof(TIFFDirEntry)); - break; - case TIFFTAG_STRIPBYTECOUNTS: - case TIFFTAG_TILEBYTECOUNTS: - switch (dp->tdir_type) - { - case TIFF_SHORT: - case TIFF_LONG: - case TIFF_LONG8: - break; - default: - /* Warn except if directory typically created with - * TIFFDeferStrileArrayWriting() */ - if (!(tif->tif_mode == O_RDWR && - dp->tdir_count == 0 && dp->tdir_type == 0 && - dp->tdir_offset.toff_long8 == 0)) - { - fip = TIFFFieldWithTag(tif, dp->tdir_tag); - TIFFWarningExtR( - tif, module, "Invalid data type for tag %s", - fip ? fip->field_name : "unknown tagname"); - } - break; - } - _TIFFmemcpy(&(tif->tif_dir.td_stripbytecount_entry), dp, - sizeof(TIFFDirEntry)); - break; - case TIFFTAG_COLORMAP: - case TIFFTAG_TRANSFERFUNCTION: - { - enum TIFFReadDirEntryErr err; - 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 */ - /* values greater than the default one (1), which may cause - */ - /* crashes in user code */ - if (!bitspersample_read) - { - fip = TIFFFieldWithTag(tif, dp->tdir_tag); - TIFFWarningExtR( - tif, module, - "Ignoring %s since BitsPerSample tag not found", - fip ? fip->field_name : "unknown tagname"); - continue; - } - /* ColorMap or TransferFunction for high bit */ - /* depths do not make much sense and could be */ - /* used as a denial of service vector */ - if (tif->tif_dir.td_bitspersample > 24) - { - fip = TIFFFieldWithTag(tif, dp->tdir_tag); - TIFFWarningExtR( - tif, module, - "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_t)countpersample)) - { - countrequired = countpersample; - incrementpersample = 0; - } - else - { - countrequired = 3 * countpersample; - incrementpersample = countpersample; - } - if (dp->tdir_count != (uint64_t)countrequired) - err = TIFFReadDirEntryErrCount; - else - err = TIFFReadDirEntryShortArray(tif, dp, &value); - if (err != TIFFReadDirEntryErrOk) - { - fip = TIFFFieldWithTag(tif, dp->tdir_tag); - TIFFReadDirEntryOutputErr( - tif, err, module, - fip ? fip->field_name : "unknown tagname", 1); - } - else - { - TIFFSetField(tif, dp->tdir_tag, value, - value + incrementpersample, - value + 2 * incrementpersample); - _TIFFfreeExt(tif, value); - } - } - break; - /* BEGIN REV 4.0 COMPATIBILITY */ - case TIFFTAG_OSUBFILETYPE: - { - uint16_t valueo; - uint32_t value; - if (TIFFReadDirEntryShort(tif, dp, &valueo) == - TIFFReadDirEntryErrOk) - { - switch (valueo) - { - case OFILETYPE_REDUCEDIMAGE: - value = FILETYPE_REDUCEDIMAGE; - break; - case OFILETYPE_PAGE: - value = FILETYPE_PAGE; - break; - default: - value = 0; - break; - } - if (value != 0) - TIFFSetField(tif, TIFFTAG_SUBFILETYPE, value); - } - } - break; - /* END REV 4.0 COMPATIBILITY */ -#if 0 - case TIFFTAG_EP_BATTERYLEVEL: - /* TIFFTAG_EP_BATTERYLEVEL can be RATIONAL or ASCII. - * LibTiff defines it as ASCII and converts RATIONAL to an - * ASCII string. */ - switch (dp->tdir_type) - { - case TIFF_RATIONAL: - { - /* Read rational and convert to ASCII*/ - enum TIFFReadDirEntryErr err; - TIFFRational_t rValue; - err = TIFFReadDirEntryCheckedRationalDirect( - tif, dp, &rValue); - if (err != TIFFReadDirEntryErrOk) - { - fip = TIFFFieldWithTag(tif, dp->tdir_tag); - TIFFReadDirEntryOutputErr( - tif, err, module, - fip ? fip->field_name : "unknown tagname", - 1); - } - else - { - char szAux[32]; - snprintf(szAux, sizeof(szAux) - 1, "%d/%d", - rValue.uNum, rValue.uDenom); - TIFFSetField(tif, dp->tdir_tag, szAux); - } - } - break; - case TIFF_ASCII: - (void)TIFFFetchNormalTag(tif, dp, TRUE); - break; - default: - fip = TIFFFieldWithTag(tif, dp->tdir_tag); - TIFFWarningExtR(tif, module, - "Invalid data type for tag %s. " - "ASCII or RATIONAL expected", - fip ? fip->field_name - : "unknown tagname"); - break; - } - break; -#endif - default: - (void)TIFFFetchNormalTag(tif, dp, TRUE); - break; - } - } /* -- if (!dp->tdir_ignore) */ - } /* -- for-loop -- */ + /* + * Second pass: extract other information. + */ + for (di=0, dp=dir; ditdir_ignore) { + switch (dp->tdir_tag) + { + case TIFFTAG_MINSAMPLEVALUE: + case TIFFTAG_MAXSAMPLEVALUE: + case TIFFTAG_BITSPERSAMPLE: + case TIFFTAG_DATATYPE: + case TIFFTAG_SAMPLEFORMAT: + /* + * The MinSampleValue, MaxSampleValue, BitsPerSample + * DataType and SampleFormat tags are supposed to be + * written as one value/sample, but some vendors + * incorrectly write one value only -- so we accept + * that as well (yuck). Other vendors write correct + * value for NumberOfSamples, but incorrect one for + * BitsPerSample and friends, and we will read this + * too. + */ + { + uint16 value; + enum TIFFReadDirEntryErr err; + err=TIFFReadDirEntryShort(tif,dp,&value); + if (err==TIFFReadDirEntryErrCount) + err=TIFFReadDirEntryPersampleShort(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); + goto bad; + } + if (!TIFFSetField(tif,dp->tdir_tag,value)) + goto bad; + if( dp->tdir_tag == TIFFTAG_BITSPERSAMPLE ) + bitspersample_read = TRUE; + } + break; + case TIFFTAG_SMINSAMPLEVALUE: + case TIFFTAG_SMAXSAMPLEVALUE: + { - /* - * OJPEG hack: - * - If a) compression is OJPEG, and b) photometric tag is missing, - * then we consistently find that photometric should be YCbCr - * - If a) compression is OJPEG, and b) photometric tag says it's RGB, - * then we consistently find that the buggy implementation of the - * buggy compression scheme matches photometric YCbCr instead. - * - If a) compression is OJPEG, and b) bitspersample tag is missing, - * then we consistently find bitspersample should be 8. - * - If a) compression is OJPEG, b) samplesperpixel tag is missing, - * and c) photometric is RGB or YCbCr, then we consistently find - * samplesperpixel should be 3 - * - If a) compression is OJPEG, b) samplesperpixel tag is missing, - * and c) photometric is MINISWHITE or MINISBLACK, then we consistently - * find samplesperpixel should be 3 - */ - if (tif->tif_dir.td_compression == COMPRESSION_OJPEG) - { - if (!TIFFFieldSet(tif, FIELD_PHOTOMETRIC)) - { - TIFFWarningExtR( - tif, module, - "Photometric tag is missing, assuming data is YCbCr"); - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR)) - goto bad; - } - else if (tif->tif_dir.td_photometric == PHOTOMETRIC_RGB) - { - tif->tif_dir.td_photometric = PHOTOMETRIC_YCBCR; - TIFFWarningExtR(tif, module, - "Photometric tag value assumed incorrect, " - "assuming data is YCbCr instead of RGB"); - } - if (!TIFFFieldSet(tif, FIELD_BITSPERSAMPLE)) - { - TIFFWarningExtR( - tif, module, - "BitsPerSample tag is missing, assuming 8 bits per sample"); - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) - goto bad; - } - if (!TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL)) - { - if (tif->tif_dir.td_photometric == PHOTOMETRIC_RGB) - { - TIFFWarningExtR(tif, module, - "SamplesPerPixel tag is missing, " - "assuming correct SamplesPerPixel value is 3"); - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3)) - goto bad; - } - if (tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR) - { - TIFFWarningExtR(tif, module, - "SamplesPerPixel tag is missing, " - "applying correct SamplesPerPixel value of 3"); - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3)) - goto bad; - } - else if ((tif->tif_dir.td_photometric == PHOTOMETRIC_MINISWHITE) || - (tif->tif_dir.td_photometric == PHOTOMETRIC_MINISBLACK)) - { - /* - * SamplesPerPixel tag is missing, but is not required - * by spec. Assume correct SamplesPerPixel value of 1. - */ - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1)) - goto bad; - } - } - } + double *data = NULL; + enum TIFFReadDirEntryErr err; + uint32 saved_flags; + int m; + if (dp->tdir_count != (uint64)tif->tif_dir.td_samplesperpixel) + err = TIFFReadDirEntryErrCount; + else + err = TIFFReadDirEntryDoubleArray(tif, dp, &data); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); + goto bad; + } + saved_flags = tif->tif_flags; + tif->tif_flags |= TIFF_PERSAMPLE; + m = TIFFSetField(tif,dp->tdir_tag,data); + tif->tif_flags = saved_flags; + _TIFFfree(data); + if (!m) + goto bad; + } + break; + case TIFFTAG_STRIPOFFSETS: + case TIFFTAG_TILEOFFSETS: + switch( dp->tdir_type ) + { + case TIFF_SHORT: + case TIFF_LONG: + case TIFF_LONG8: + break; + default: + /* Warn except if directory typically created with TIFFDeferStrileArrayWriting() */ + if( !(tif->tif_mode == O_RDWR && + dp->tdir_count == 0 && + dp->tdir_type == 0 && + dp->tdir_offset.toff_long8 == 0) ) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFWarningExt(tif->tif_clientdata,module, + "Invalid data type for tag %s", + fip ? fip->field_name : "unknown tagname"); + } + break; + } + _TIFFmemcpy( &(tif->tif_dir.td_stripoffset_entry), + dp, sizeof(TIFFDirEntry) ); + break; + case TIFFTAG_STRIPBYTECOUNTS: + case TIFFTAG_TILEBYTECOUNTS: + switch( dp->tdir_type ) + { + case TIFF_SHORT: + case TIFF_LONG: + case TIFF_LONG8: + break; + default: + /* Warn except if directory typically created with TIFFDeferStrileArrayWriting() */ + if( !(tif->tif_mode == O_RDWR && + dp->tdir_count == 0 && + dp->tdir_type == 0 && + dp->tdir_offset.toff_long8 == 0) ) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFWarningExt(tif->tif_clientdata,module, + "Invalid data type for tag %s", + fip ? fip->field_name : "unknown tagname"); + } + break; + } + _TIFFmemcpy( &(tif->tif_dir.td_stripbytecount_entry), + dp, sizeof(TIFFDirEntry) ); + break; + case TIFFTAG_COLORMAP: + case TIFFTAG_TRANSFERFUNCTION: + { + enum TIFFReadDirEntryErr err; + uint32 countpersample; + uint32 countrequired; + uint32 incrementpersample; + uint16* 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 */ + /* values greater than the default one (1), which may cause */ + /* crashes in user code */ + if( !bitspersample_read ) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFWarningExt(tif->tif_clientdata,module, + "Ignoring %s since BitsPerSample tag not found", + fip ? fip->field_name : "unknown tagname"); + continue; + } + /* ColorMap or TransferFunction for high bit */ + /* depths do not make much sense and could be */ + /* used as a denial of service vector */ + if (tif->tif_dir.td_bitspersample > 24) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFWarningExt(tif->tif_clientdata,module, + "Ignoring %s because BitsPerSample=%d>24", + fip ? fip->field_name : "unknown tagname", + tif->tif_dir.td_bitspersample); + continue; + } + countpersample=(1U<tif_dir.td_bitspersample); + if ((dp->tdir_tag==TIFFTAG_TRANSFERFUNCTION)&&(dp->tdir_count==(uint64)countpersample)) + { + countrequired=countpersample; + incrementpersample=0; + } + else + { + countrequired=3*countpersample; + incrementpersample=countpersample; + } + if (dp->tdir_count!=(uint64)countrequired) + err=TIFFReadDirEntryErrCount; + else + err=TIFFReadDirEntryShortArray(tif,dp,&value); + if (err!=TIFFReadDirEntryErrOk) + { + fip = TIFFFieldWithTag(tif,dp->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",1); + } + else + { + TIFFSetField(tif,dp->tdir_tag,value,value+incrementpersample,value+2*incrementpersample); + _TIFFfree(value); + } + } + break; +/* BEGIN REV 4.0 COMPATIBILITY */ + case TIFFTAG_OSUBFILETYPE: + { + uint16 valueo; + uint32 value; + if (TIFFReadDirEntryShort(tif,dp,&valueo)==TIFFReadDirEntryErrOk) + { + switch (valueo) + { + case OFILETYPE_REDUCEDIMAGE: value=FILETYPE_REDUCEDIMAGE; break; + case OFILETYPE_PAGE: value=FILETYPE_PAGE; break; + default: value=0; break; + } + if (value!=0) + TIFFSetField(tif,TIFFTAG_SUBFILETYPE,value); + } + } + break; +/* END REV 4.0 COMPATIBILITY */ + default: + (void) TIFFFetchNormalTag(tif, dp, TRUE); + break; + } + } /* -- if (!dp->tdir_ignore) */ + } /* -- for-loop -- */ - /* - * Setup appropriate structures (by strip or by tile) - * We do that only after the above OJPEG hack which alters SamplesPerPixel - * and thus influences the number of strips in the separate planarconfig. - */ - if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) - { - tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif); - tif->tif_dir.td_tilewidth = tif->tif_dir.td_imagewidth; - tif->tif_dir.td_tilelength = tif->tif_dir.td_rowsperstrip; - tif->tif_dir.td_tiledepth = tif->tif_dir.td_imagedepth; - tif->tif_flags &= ~TIFF_ISTILED; - } - else - { - tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif); - tif->tif_flags |= TIFF_ISTILED; - } - if (!tif->tif_dir.td_nstrips) - { - TIFFErrorExtR(tif, module, "Cannot handle zero number of %s", - isTiled(tif) ? "tiles" : "strips"); - goto bad; - } - tif->tif_dir.td_stripsperimage = tif->tif_dir.td_nstrips; - if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE) - tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel; - if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) - { + /* + * OJPEG hack: + * - If a) compression is OJPEG, and b) photometric tag is missing, + * then we consistently find that photometric should be YCbCr + * - If a) compression is OJPEG, and b) photometric tag says it's RGB, + * then we consistently find that the buggy implementation of the + * buggy compression scheme matches photometric YCbCr instead. + * - If a) compression is OJPEG, and b) bitspersample tag is missing, + * then we consistently find bitspersample should be 8. + * - If a) compression is OJPEG, b) samplesperpixel tag is missing, + * and c) photometric is RGB or YCbCr, then we consistently find + * samplesperpixel should be 3 + * - If a) compression is OJPEG, b) samplesperpixel tag is missing, + * and c) photometric is MINISWHITE or MINISBLACK, then we consistently + * find samplesperpixel should be 3 + */ + if (tif->tif_dir.td_compression==COMPRESSION_OJPEG) + { + if (!TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Photometric tag is missing, assuming data is YCbCr"); + if (!TIFFSetField(tif,TIFFTAG_PHOTOMETRIC,PHOTOMETRIC_YCBCR)) + goto bad; + } + else if (tif->tif_dir.td_photometric==PHOTOMETRIC_RGB) + { + tif->tif_dir.td_photometric=PHOTOMETRIC_YCBCR; + TIFFWarningExt(tif->tif_clientdata, module, + "Photometric tag value assumed incorrect, " + "assuming data is YCbCr instead of RGB"); + } + if (!TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) + { + TIFFWarningExt(tif->tif_clientdata,module, + "BitsPerSample tag is missing, assuming 8 bits per sample"); + if (!TIFFSetField(tif,TIFFTAG_BITSPERSAMPLE,8)) + goto bad; + } + if (!TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) + { + if (tif->tif_dir.td_photometric==PHOTOMETRIC_RGB) + { + TIFFWarningExt(tif->tif_clientdata,module, + "SamplesPerPixel tag is missing, " + "assuming correct SamplesPerPixel value is 3"); + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) + goto bad; + } + if (tif->tif_dir.td_photometric==PHOTOMETRIC_YCBCR) + { + TIFFWarningExt(tif->tif_clientdata,module, + "SamplesPerPixel tag is missing, " + "applying correct SamplesPerPixel value of 3"); + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,3)) + goto bad; + } + else if ((tif->tif_dir.td_photometric==PHOTOMETRIC_MINISWHITE) + || (tif->tif_dir.td_photometric==PHOTOMETRIC_MINISBLACK)) + { + /* + * SamplesPerPixel tag is missing, but is not required + * by spec. Assume correct SamplesPerPixel value of 1. + */ + if (!TIFFSetField(tif,TIFFTAG_SAMPLESPERPIXEL,1)) + goto bad; + } + } + } + + /* + * Setup appropriate structures (by strip or by tile) + * We do that only after the above OJPEG hack which alters SamplesPerPixel + * and thus influences the number of strips in the separate planarconfig. + */ + if (!TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) { + tif->tif_dir.td_nstrips = TIFFNumberOfStrips(tif); + tif->tif_dir.td_tilewidth = tif->tif_dir.td_imagewidth; + tif->tif_dir.td_tilelength = tif->tif_dir.td_rowsperstrip; + tif->tif_dir.td_tiledepth = tif->tif_dir.td_imagedepth; + tif->tif_flags &= ~TIFF_ISTILED; + } else { + tif->tif_dir.td_nstrips = TIFFNumberOfTiles(tif); + tif->tif_flags |= TIFF_ISTILED; + } + if (!tif->tif_dir.td_nstrips) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle zero number of %s", + isTiled(tif) ? "tiles" : "strips"); + goto bad; + } + tif->tif_dir.td_stripsperimage = tif->tif_dir.td_nstrips; + if (tif->tif_dir.td_planarconfig == PLANARCONFIG_SEPARATE) + tif->tif_dir.td_stripsperimage /= tif->tif_dir.td_samplesperpixel; + if (!TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) { #ifdef OJPEG_SUPPORT - if ((tif->tif_dir.td_compression == COMPRESSION_OJPEG) && - (isTiled(tif) == 0) && (tif->tif_dir.td_nstrips == 1)) - { - /* - * XXX: OJPEG hack. - * If a) compression is OJPEG, b) it's not a tiled TIFF, - * and c) the number of strips is 1, - * then we tolerate the absence of stripoffsets tag, - * because, presumably, all required data is in the - * JpegInterchangeFormat stream. - */ - TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); - } - else + if ((tif->tif_dir.td_compression==COMPRESSION_OJPEG) && + (isTiled(tif)==0) && + (tif->tif_dir.td_nstrips==1)) { + /* + * XXX: OJPEG hack. + * If a) compression is OJPEG, b) it's not a tiled TIFF, + * and c) the number of strips is 1, + * then we tolerate the absence of stripoffsets tag, + * because, presumably, all required data is in the + * JpegInterchangeFormat stream. + */ + TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); + } else #endif { - MissingRequired(tif, isTiled(tif) ? "TileOffsets" : "StripOffsets"); - goto bad; - } - } + MissingRequired(tif, + isTiled(tif) ? "TileOffsets" : "StripOffsets"); + goto bad; + } + } - if (tif->tif_mode == O_RDWR && - tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 && - tif->tif_dir.td_stripoffset_entry.tdir_count == 0 && - tif->tif_dir.td_stripoffset_entry.tdir_type == 0 && - tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0) - { - /* Directory typically created with TIFFDeferStrileArrayWriting() */ - TIFFSetupStrips(tif); - } - else if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD)) - { - if (tif->tif_dir.td_stripoffset_entry.tdir_tag != 0) + if( tif->tif_mode == O_RDWR && + tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 && + tif->tif_dir.td_stripoffset_entry.tdir_count == 0 && + tif->tif_dir.td_stripoffset_entry.tdir_type == 0 && + tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0 ) { - if (!TIFFFetchStripThing(tif, &(tif->tif_dir.td_stripoffset_entry), - tif->tif_dir.td_nstrips, - &tif->tif_dir.td_stripoffset_p)) + /* Directory typically created with TIFFDeferStrileArrayWriting() */ + TIFFSetupStrips(tif); + } + else if( !(tif->tif_flags&TIFF_DEFERSTRILELOAD) ) + { + if( tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 ) { - goto bad; + if (!TIFFFetchStripThing(tif,&(tif->tif_dir.td_stripoffset_entry), + tif->tif_dir.td_nstrips, + &tif->tif_dir.td_stripoffset_p)) + { + goto bad; + } + } + if( tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 ) + { + if (!TIFFFetchStripThing(tif,&(tif->tif_dir.td_stripbytecount_entry), + tif->tif_dir.td_nstrips, + &tif->tif_dir.td_stripbytecount_p)) + { + goto bad; + } } } - if (tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0) - { - if (!TIFFFetchStripThing( - tif, &(tif->tif_dir.td_stripbytecount_entry), - tif->tif_dir.td_nstrips, &tif->tif_dir.td_stripbytecount_p)) - { - goto bad; - } - } - } - /* - * Make sure all non-color channels are extrasamples. - * If it's not the case, define them as such. - */ - color_channels = _TIFFGetMaxColorChannels(tif->tif_dir.td_photometric); - if (color_channels && - tif->tif_dir.td_samplesperpixel - tif->tif_dir.td_extrasamples > - color_channels) - { - uint16_t old_extrasamples; - uint16_t *new_sampleinfo; + /* + * Make sure all non-color channels are extrasamples. + * If it's not the case, define them as such. + */ + 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; - TIFFWarningExtR( - tif, module, - "Sum of Photometric type-related " - "color channels and ExtraSamples doesn't match SamplesPerPixel. " - "Defining non-color channels as ExtraSamples."); + 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_t)(tif->tif_dir.td_samplesperpixel - color_channels); + old_extrasamples = tif->tif_dir.td_extrasamples; + tif->tif_dir.td_extrasamples = (uint16) (tif->tif_dir.td_samplesperpixel - color_channels); - // sampleinfo should contain information relative to these new extra - // samples - new_sampleinfo = (uint16_t *)_TIFFcallocExt( - tif, tif->tif_dir.td_extrasamples, sizeof(uint16_t)); - if (!new_sampleinfo) - { - TIFFErrorExtR(tif, module, - "Failed to allocate memory for " - "temporary new sampleinfo array " - "(%" PRIu16 " 16 bit elements)", - tif->tif_dir.td_extrasamples); - goto bad; + // sampleinfo should contain information relative to these new extra samples + new_sampleinfo = (uint16*) _TIFFcalloc(tif->tif_dir.td_extrasamples, sizeof(uint16)); + if (!new_sampleinfo) { + TIFFErrorExt(tif->tif_clientdata, module, "Failed to allocate memory for " + "temporary new sampleinfo array (%d 16 bit elements)", + tif->tif_dir.td_extrasamples); + goto bad; + } + + if (old_extrasamples > 0) + memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo, old_extrasamples * sizeof(uint16)); + _TIFFsetShortArray(&tif->tif_dir.td_sampleinfo, new_sampleinfo, tif->tif_dir.td_extrasamples); + _TIFFfree(new_sampleinfo); } - if (old_extrasamples > 0) - memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo, - old_extrasamples * sizeof(uint16_t)); - _TIFFsetShortArrayExt(tif, &tif->tif_dir.td_sampleinfo, new_sampleinfo, - tif->tif_dir.td_extrasamples); - _TIFFfreeExt(tif, new_sampleinfo); - } + /* + * Verify Palette image has a Colormap. + */ + if (tif->tif_dir.td_photometric == PHOTOMETRIC_PALETTE && + !TIFFFieldSet(tif, FIELD_COLORMAP)) { + if ( tif->tif_dir.td_bitspersample>=8 && tif->tif_dir.td_samplesperpixel==3) + tif->tif_dir.td_photometric = PHOTOMETRIC_RGB; + else if (tif->tif_dir.td_bitspersample>=8) + tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK; + else { + MissingRequired(tif, "Colormap"); + goto bad; + } + } + /* + * OJPEG hack: + * We do no further messing with strip/tile offsets/bytecounts in OJPEG + * TIFFs + */ + if (tif->tif_dir.td_compression!=COMPRESSION_OJPEG) + { + /* + * Attempt to deal with a missing StripByteCounts tag. + */ + if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) { + /* + * Some manufacturers violate the spec by not giving + * the size of the strips. In this case, assume there + * is one uncompressed strip of data. + */ + 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)) { + MissingRequired(tif, "StripByteCounts"); + goto bad; + } + TIFFWarningExt(tif->tif_clientdata, module, + "TIFF directory is missing required " + "\"StripByteCounts\" field, calculating from imagelength"); + if (EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; - /* - * Verify Palette image has a Colormap. - */ - if (tif->tif_dir.td_photometric == PHOTOMETRIC_PALETTE && - !TIFFFieldSet(tif, FIELD_COLORMAP)) - { - if (tif->tif_dir.td_bitspersample >= 8 && - tif->tif_dir.td_samplesperpixel == 3) - tif->tif_dir.td_photometric = PHOTOMETRIC_RGB; - else if (tif->tif_dir.td_bitspersample >= 8) - tif->tif_dir.td_photometric = PHOTOMETRIC_MINISBLACK; - else - { - MissingRequired(tif, "Colormap"); - goto bad; - } - } - /* - * OJPEG hack: - * We do no further messing with strip/tile offsets/bytecounts in OJPEG - * TIFFs - */ - if (tif->tif_dir.td_compression != COMPRESSION_OJPEG) - { - /* - * Attempt to deal with a missing StripByteCounts tag. - */ - if (!TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) - { - /* - * Some manufacturers violate the spec by not giving - * the size of the strips. In this case, assume there - * is one uncompressed strip of data. - */ - 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_t)tif->tif_dir.td_samplesperpixel)) - { - MissingRequired(tif, "StripByteCounts"); - goto bad; - } - TIFFWarningExtR( - tif, module, - "TIFF directory is missing required " - "\"StripByteCounts\" field, calculating from imagelength"); - if (EstimateStripByteCounts(tif, dir, dircount) < 0) - goto bad; - } - else if (tif->tif_dir.td_nstrips == 1 && - !(tif->tif_flags & TIFF_ISTILED) && ByteCountLooksBad(tif)) - { - /* - * XXX: Plexus (and others) sometimes give a value of - * zero for a tag when they don't know what the - * correct value is! Try and handle the simple case - * of estimating the size of a one strip image. - */ - TIFFWarningExtR(tif, module, - "Bogus \"StripByteCounts\" field, ignoring and " - "calculating from imagelength"); - if (EstimateStripByteCounts(tif, dir, dircount) < 0) - goto bad; - } - else if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) && - tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG && - tif->tif_dir.td_nstrips > 2 && - tif->tif_dir.td_compression == COMPRESSION_NONE && - TIFFGetStrileByteCount(tif, 0) != - TIFFGetStrileByteCount(tif, 1) && - TIFFGetStrileByteCount(tif, 0) != 0 && - TIFFGetStrileByteCount(tif, 1) != 0) - { - /* - * XXX: Some vendors fill StripByteCount array with - * absolutely wrong values (it can be equal to - * StripOffset array, for example). Catch this case - * here. - * - * We avoid this check if deferring strile loading - * as it would always force us to load the strip/tile - * information. - */ - TIFFWarningExtR(tif, module, - "Wrong \"StripByteCounts\" field, ignoring and " - "calculating from imagelength"); - if (EstimateStripByteCounts(tif, dir, dircount) < 0) - goto bad; - } - } - if (dir) - { - _TIFFfreeExt(tif, dir); - dir = NULL; - } - if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) - { - if (tif->tif_dir.td_bitspersample >= 16) - tif->tif_dir.td_maxsamplevalue = 0xFFFF; - else - tif->tif_dir.td_maxsamplevalue = - (uint16_t)((1L << tif->tif_dir.td_bitspersample) - 1); - } + } else if (tif->tif_dir.td_nstrips == 1 + && !(tif->tif_flags&TIFF_ISTILED) + && ByteCountLooksBad(tif)) { + /* + * XXX: Plexus (and others) sometimes give a value of + * zero for a tag when they don't know what the + * correct value is! Try and handle the simple case + * of estimating the size of a one strip image. + */ + TIFFWarningExt(tif->tif_clientdata, module, + "Bogus \"StripByteCounts\" field, ignoring and calculating from imagelength"); + if(EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; + + } else if (!(tif->tif_flags&TIFF_DEFERSTRILELOAD) + && tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG + && tif->tif_dir.td_nstrips > 2 + && tif->tif_dir.td_compression == COMPRESSION_NONE + && TIFFGetStrileByteCount(tif, 0) != TIFFGetStrileByteCount(tif, 1) + && TIFFGetStrileByteCount(tif, 0) != 0 + && TIFFGetStrileByteCount(tif, 1) != 0 ) { + /* + * XXX: Some vendors fill StripByteCount array with + * absolutely wrong values (it can be equal to + * StripOffset array, for example). Catch this case + * here. + * + * We avoid this check if deferring strile loading + * as it would always force us to load the strip/tile + * information. + */ + TIFFWarningExt(tif->tif_clientdata, module, + "Wrong \"StripByteCounts\" field, ignoring and calculating from imagelength"); + if (EstimateStripByteCounts(tif, dir, dircount) < 0) + goto bad; + } + } + if (dir) + { + _TIFFfree(dir); + dir=NULL; + } + if (!TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) + { + if (tif->tif_dir.td_bitspersample>=16) + tif->tif_dir.td_maxsamplevalue=0xFFFF; + else + tif->tif_dir.td_maxsamplevalue = (uint16)((1L<tif_dir.td_bitspersample)-1); + } #ifdef STRIPBYTECOUNTSORTED_UNUSED - /* - * XXX: We can optimize checking for the strip bounds using the sorted - * bytecounts array. See also comments for TIFFAppendToStrip() - * function in tif_write.c. - */ - if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) && tif->tif_dir.td_nstrips > 1) - { - uint32_t strip; + /* + * XXX: We can optimize checking for the strip bounds using the sorted + * bytecounts array. See also comments for TIFFAppendToStrip() + * function in tif_write.c. + */ + if (!(tif->tif_flags&TIFF_DEFERSTRILELOAD) && tif->tif_dir.td_nstrips > 1) { + uint32 strip; - tif->tif_dir.td_stripbytecountsorted = 1; - for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) - { - if (TIFFGetStrileOffset(tif, strip - 1) > - TIFFGetStrileOffset(tif, strip)) - { - tif->tif_dir.td_stripbytecountsorted = 0; - break; - } - } - } + tif->tif_dir.td_stripbytecountsorted = 1; + for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { + if (TIFFGetStrileOffset(tif, strip - 1) > + TIFFGetStrileOffset(tif, strip)) { + tif->tif_dir.td_stripbytecountsorted = 0; + break; + } + } + } #endif - /* - * An opportunity for compression mode dependent tag fixup - */ - (*tif->tif_fixuptags)(tif); + /* + * An opportunity for compression mode dependent tag fixup + */ + (*tif->tif_fixuptags)(tif); - /* - * Some manufacturers make life difficult by writing - * large amounts of uncompressed data as a single strip. - * This is contrary to the recommendations of the spec. - * The following makes an attempt at breaking such images - * into strips closer to the recommended 8k bytes. A - * side effect, however, is that the RowsPerStrip tag - * value may be changed. - */ - if ((tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) && - (tif->tif_dir.td_nstrips == 1) && - (tif->tif_dir.td_compression == COMPRESSION_NONE) && - ((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP)) - { - ChopUpSingleUncompressedStrip(tif); - } - - /* There are also uncompressed striped files with strips larger than */ - /* 2 GB, which make them unfriendly with a lot of code. If possible, */ - /* try to expose smaller "virtual" strips. */ - if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG && - tif->tif_dir.td_compression == COMPRESSION_NONE && - (tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == TIFF_STRIPCHOP && - TIFFStripSize64(tif) > 0x7FFFFFFFUL) - { - TryChopUpUncompressedBigTiff(tif); - } - - /* - * Clear the dirty directory flag. - */ - tif->tif_flags &= ~TIFF_DIRTYDIRECT; - tif->tif_flags &= ~TIFF_DIRTYSTRIP; - - /* - * Reinitialize i/o since we are starting on a new directory. - */ - 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); - if (!tif->tif_scanlinesize) - { - TIFFErrorExtR(tif, module, "Cannot handle zero scanline size"); - return (0); - } - - if (isTiled(tif)) - { - tif->tif_tilesize = TIFFTileSize(tif); - if (!tif->tif_tilesize) + /* + * Some manufacturers make life difficult by writing + * large amounts of uncompressed data as a single strip. + * This is contrary to the recommendations of the spec. + * The following makes an attempt at breaking such images + * into strips closer to the recommended 8k bytes. A + * side effect, however, is that the RowsPerStrip tag + * value may be changed. + */ + if ((tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG)&& + (tif->tif_dir.td_nstrips==1)&& + (tif->tif_dir.td_compression==COMPRESSION_NONE)&& + ((tif->tif_flags&(TIFF_STRIPCHOP|TIFF_ISTILED))==TIFF_STRIPCHOP)) { - TIFFErrorExtR(tif, module, "Cannot handle zero tile size"); - return (0); + ChopUpSingleUncompressedStrip(tif); } - } - else - { - if (!TIFFStripSize(tif)) + + /* There are also uncompressed striped files with strips larger than */ + /* 2 GB, which make them unfriendly with a lot of code. If possible, */ + /* try to expose smaller "virtual" strips. */ + if( tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG && + tif->tif_dir.td_compression == COMPRESSION_NONE && + (tif->tif_flags&(TIFF_STRIPCHOP|TIFF_ISTILED)) == TIFF_STRIPCHOP && + TIFFStripSize64(tif) > 0x7FFFFFFFUL ) { - TIFFErrorExtR(tif, module, "Cannot handle zero strip size"); - return (0); + TryChopUpUncompressedBigTiff(tif); } - } - return (1); + + /* + * Clear the dirty directory flag. + */ + tif->tif_flags &= ~TIFF_DIRTYDIRECT; + tif->tif_flags &= ~TIFF_DIRTYSTRIP; + + /* + * 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_tilesize = (tmsize_t) -1; + + tif->tif_scanlinesize = TIFFScanlineSize(tif); + if (!tif->tif_scanlinesize) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle zero scanline size"); + return (0); + } + + if (isTiled(tif)) { + tif->tif_tilesize = TIFFTileSize(tif); + if (!tif->tif_tilesize) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle zero tile size"); + return (0); + } + } else { + if (!TIFFStripSize(tif)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot handle zero strip size"); + return (0); + } + } + return (1); bad: - if (dir) - _TIFFfreeExt(tif, dir); - return (0); + if (dir) + _TIFFfree(dir); + return (0); } -static void TIFFReadDirectoryCheckOrder(TIFF *tif, TIFFDirEntry *dir, - uint16_t dircount) +static void +TIFFReadDirectoryCheckOrder(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) { - static const char module[] = "TIFFReadDirectoryCheckOrder"; - uint32_t m; - uint16_t n; - TIFFDirEntry *o; - m = 0; - for (n = 0, o = dir; n < dircount; n++, o++) - { - if (o->tdir_tag < m) - { - TIFFWarningExtR(tif, module, - "Invalid TIFF directory; tags are not sorted in " - "ascending order"); - break; - } - m = o->tdir_tag + 1; - } + static const char module[] = "TIFFReadDirectoryCheckOrder"; + uint32 m; + uint16 n; + TIFFDirEntry* o; + m=0; + for (n=0, o=dir; ntdir_tagtif_clientdata,module, + "Invalid TIFF directory; tags are not sorted in ascending order"); + break; + } + m=o->tdir_tag+1; + } } -static TIFFDirEntry *TIFFReadDirectoryFindEntry(TIFF *tif, TIFFDirEntry *dir, - uint16_t dircount, - uint16_t tagid) +static TIFFDirEntry* +TIFFReadDirectoryFindEntry(TIFF* tif, TIFFDirEntry* dir, uint16 dircount, uint16 tagid) { - TIFFDirEntry *m; - uint16_t n; - (void)tif; - for (m = dir, n = 0; n < dircount; m++, n++) - { - if (m->tdir_tag == tagid) - return (m); - } - return (0); + TIFFDirEntry* m; + uint16 n; + (void) tif; + for (m=dir, n=0; ntdir_tag==tagid) + return(m); + } + return(0); } -static void TIFFReadDirectoryFindFieldInfo(TIFF *tif, uint16_t tagid, - uint32_t *fii) +static void +TIFFReadDirectoryFindFieldInfo(TIFF* tif, uint16 tagid, uint32* fii) { - int32_t ma, mb, mc; - ma = -1; - mc = (int32_t)tif->tif_nfields; - while (1) - { - if (ma + 1 == mc) - { - *fii = FAILED_FII; - return; - } - mb = (ma + mc) / 2; - if (tif->tif_fields[mb]->field_tag == (uint32_t)tagid) - break; - if (tif->tif_fields[mb]->field_tag < (uint32_t)tagid) - ma = mb; - else - mc = mb; - } - while (1) - { - if (mb == 0) - break; - if (tif->tif_fields[mb - 1]->field_tag != (uint32_t)tagid) - break; - mb--; - } - *fii = mb; + int32 ma,mb,mc; + ma=-1; + mc=(int32)tif->tif_nfields; + while (1) + { + if (ma+1==mc) + { + *fii = FAILED_FII; + return; + } + mb=(ma+mc)/2; + if (tif->tif_fields[mb]->field_tag==(uint32)tagid) + break; + if (tif->tif_fields[mb]->field_tag<(uint32)tagid) + ma=mb; + else + mc=mb; + } + while (1) + { + if (mb==0) + break; + if (tif->tif_fields[mb-1]->field_tag!=(uint32)tagid) + break; + mb--; + } + *fii=mb; } /* * Read custom directory from the arbitrary offset. * The code is very similar to TIFFReadDirectory(). */ -int TIFFReadCustomDirectory(TIFF *tif, toff_t diroff, - const TIFFFieldArray *infoarray) +int +TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, + const TIFFFieldArray* infoarray) { - static const char module[] = "TIFFReadCustomDirectory"; - TIFFDirEntry *dir; - uint16_t dircount; - TIFFDirEntry *dp; - uint16_t di; - const TIFFField *fip; - uint32_t fii; - (*tif->tif_cleanup)(tif); /* cleanup any previous compression state */ - _TIFFSetupFields(tif, infoarray); - dircount = TIFFFetchDirectory(tif, diroff, &dir, NULL); - if (!dircount) - { - TIFFErrorExtR(tif, module, - "Failed to read custom directory at offset %" PRIu64, - diroff); - return 0; - } - TIFFFreeDirectory(tif); - _TIFFmemset(&tif->tif_dir, 0, sizeof(TIFFDirectory)); - TIFFReadDirectoryCheckOrder(tif, dir, dircount); - for (di = 0, dp = dir; di < dircount; di++, dp++) - { - TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii); - if (fii == FAILED_FII) - { - TIFFWarningExtR(tif, module, - "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)) - { - TIFFWarningExtR(tif, module, - "Registering anonymous field with tag %" PRIu16 - " (0x%" PRIx16 ") failed", - dp->tdir_tag, dp->tdir_tag); - dp->tdir_ignore = TRUE; - } - else - { - TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii); - assert(fii != FAILED_FII); - } - } - if (!dp->tdir_ignore) - { - fip = tif->tif_fields[fii]; - if (fip->field_bit == FIELD_IGNORE) - dp->tdir_ignore = TRUE; - else - { - /* check data type */ - while ((fip->field_type != TIFF_ANY) && - (fip->field_type != dp->tdir_type)) - { - fii++; - if ((fii == tif->tif_nfields) || - (tif->tif_fields[fii]->field_tag != - (uint32_t)dp->tdir_tag)) - { - fii = 0xFFFF; - break; - } - fip = tif->tif_fields[fii]; - } - if (fii == 0xFFFF) - { - TIFFWarningExtR(tif, module, - "Wrong data type %" PRIu16 - " for \"%s\"; tag ignored", - dp->tdir_type, fip->field_name); - dp->tdir_ignore = TRUE; - } - else - { - /* check count if known in advance */ - if ((fip->field_readcount != TIFF_VARIABLE) && - (fip->field_readcount != TIFF_VARIABLE2)) - { - uint32_t expected; - if (fip->field_readcount == TIFF_SPP) - expected = - (uint32_t)tif->tif_dir.td_samplesperpixel; - else - expected = (uint32_t)fip->field_readcount; - if (!CheckDirCount(tif, dp, expected)) - dp->tdir_ignore = TRUE; - } - } - } - if (!dp->tdir_ignore) - { - switch (dp->tdir_tag) - { - case EXIFTAG_SUBJECTDISTANCE: - if (!TIFFFieldIsAnonymous(fip)) - { - /* should only be called on a Exif directory */ - /* when exifFields[] is active */ - (void)TIFFFetchSubjectDistance(tif, dp); - } - else - { - (void)TIFFFetchNormalTag(tif, dp, TRUE); - } - break; - default: - (void)TIFFFetchNormalTag(tif, dp, TRUE); - break; - } - } /*-- if (!dp->tdir_ignore) */ - } - } - /* To be able to return from SubIFD or custom-IFD to main-IFD */ - tif->tif_setdirectory_force_absolute = TRUE; - if (dir) - _TIFFfreeExt(tif, dir); - return 1; + static const char module[] = "TIFFReadCustomDirectory"; + TIFFDirEntry* dir; + uint16 dircount; + TIFFDirEntry* dp; + uint16 di; + const TIFFField* fip; + uint32 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); + return 0; + } + TIFFFreeDirectory(tif); + _TIFFmemset(&tif->tif_dir, 0, sizeof(TIFFDirectory)); + TIFFReadDirectoryCheckOrder(tif,dir,dircount); + for (di=0, dp=dir; ditdir_tag,&fii); + if (fii == FAILED_FII) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Unknown field with tag %d (0x%x) 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", + dp->tdir_tag, dp->tdir_tag); + dp->tdir_ignore = TRUE; + } else { + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + assert( fii != FAILED_FII ); + } + } + if (!dp->tdir_ignore) + { + fip=tif->tif_fields[fii]; + if (fip->field_bit==FIELD_IGNORE) + dp->tdir_ignore = TRUE; + else + { + /* check data type */ + while ((fip->field_type!=TIFF_ANY)&&(fip->field_type!=dp->tdir_type)) + { + fii++; + if ((fii==tif->tif_nfields)|| + (tif->tif_fields[fii]->field_tag!=(uint32)dp->tdir_tag)) + { + fii=0xFFFF; + break; + } + fip=tif->tif_fields[fii]; + } + if (fii==0xFFFF) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Wrong data type %d for \"%s\"; tag ignored", + dp->tdir_type,fip->field_name); + dp->tdir_ignore = TRUE; + } + else + { + /* check count if known in advance */ + if ((fip->field_readcount!=TIFF_VARIABLE)&& + (fip->field_readcount!=TIFF_VARIABLE2)) + { + uint32 expected; + if (fip->field_readcount==TIFF_SPP) + expected=(uint32)tif->tif_dir.td_samplesperpixel; + else + expected=(uint32)fip->field_readcount; + if (!CheckDirCount(tif,dp,expected)) + dp->tdir_ignore = TRUE; + } + } + } + if (!dp->tdir_ignore) { + switch (dp->tdir_tag) + { + case EXIFTAG_SUBJECTDISTANCE: + (void)TIFFFetchSubjectDistance(tif, dp); + break; + default: + (void)TIFFFetchNormalTag(tif, dp, TRUE); + break; + } + } /*-- if (!dp->tdir_ignore) */ + } + } + if (dir) + _TIFFfree(dir); + return 1; } /* * EXIF is important special case of custom IFD, so we have a special * function to read it. */ -int TIFFReadEXIFDirectory(TIFF *tif, toff_t diroff) +int +TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff) { - const TIFFFieldArray *exifFieldArray; - exifFieldArray = _TIFFGetExifFields(); - return TIFFReadCustomDirectory(tif, diroff, exifFieldArray); + const TIFFFieldArray* exifFieldArray; + exifFieldArray = _TIFFGetExifFields(); + return TIFFReadCustomDirectory(tif, diroff, exifFieldArray); } /* *--: EXIF-GPS custom directory reading as another special case of custom IFD. */ -int TIFFReadGPSDirectory(TIFF *tif, toff_t diroff) +int +TIFFReadGPSDirectory(TIFF* tif, toff_t diroff) { - const TIFFFieldArray *gpsFieldArray; - gpsFieldArray = _TIFFGetGpsFields(); - return TIFFReadCustomDirectory(tif, diroff, gpsFieldArray); + const TIFFFieldArray* gpsFieldArray; + gpsFieldArray = _TIFFGetGpsFields(); + return TIFFReadCustomDirectory(tif, diroff, gpsFieldArray); } -static int EstimateStripByteCounts(TIFF *tif, TIFFDirEntry *dir, - uint16_t dircount) +static int +EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16 dircount) { - static const char module[] = "EstimateStripByteCounts"; + static const char module[] = "EstimateStripByteCounts"; - TIFFDirEntry *dp; - TIFFDirectory *td = &tif->tif_dir; - uint32_t strip; + TIFFDirEntry *dp; + TIFFDirectory *td = &tif->tif_dir; + uint32 strip; /* Do not try to load stripbytecount as we will compute it */ - if (!_TIFFFillStrilesInternal(tif, 0)) - return -1; - - if (td->td_stripbytecount_p) - _TIFFfreeExt(tif, td->td_stripbytecount_p); - 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_t space; - uint64_t filesize; - uint16_t n; - filesize = TIFFGetFileSize(tif); - if (!(tif->tif_flags & TIFF_BIGTIFF)) - space = sizeof(TIFFHeaderClassic) + 2 + dircount * 12 + 4; - else - space = sizeof(TIFFHeaderBig) + 8 + dircount * 20 + 8; - /* calculate amount of space used by indirect values */ - for (dp = dir, n = dircount; n > 0; n--, dp++) - { - uint32_t typewidth; - uint64_t datasize; - typewidth = TIFFDataWidth((TIFFDataType)dp->tdir_type); - if (typewidth == 0) - { - TIFFErrorExtR( - tif, module, - "Cannot determine size of unknown tag type %" PRIu16, - dp->tdir_type); - return -1; - } - if (dp->tdir_count > UINT64_MAX / typewidth) - return -1; - datasize = (uint64_t)typewidth * dp->tdir_count; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - if (datasize <= 4) - datasize = 0; - } - else - { - if (datasize <= 8) - datasize = 0; - } - if (space > UINT64_MAX - datasize) - return -1; - space += datasize; - } - if (filesize < space) - /* we should perhaps return in error ? */ - space = filesize; - else - space = filesize - space; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - space /= td->td_samplesperpixel; - for (strip = 0; strip < td->td_nstrips; strip++) - td->td_stripbytecount_p[strip] = space; - /* - * This gross hack handles the case were the offset to - * the last strip is past the place where we think the strip - * should begin. Since a strip of data must be contiguous, - * it's safe to assume that we've overestimated the amount - * of data in the strip and trim this number back accordingly. - */ - strip--; - if (td->td_stripoffset_p[strip] > - UINT64_MAX - td->td_stripbytecount_p[strip]) + if( !_TIFFFillStrilesInternal( tif, 0 ) ) return -1; - if (td->td_stripoffset_p[strip] + td->td_stripbytecount_p[strip] > - filesize) - { - if (td->td_stripoffset_p[strip] >= filesize) - { - /* Not sure what we should in that case... */ - td->td_stripbytecount_p[strip] = 0; - } - else - { - td->td_stripbytecount_p[strip] = - filesize - td->td_stripoffset_p[strip]; - } - } - } - else if (isTiled(tif)) - { - uint64_t bytespertile = TIFFTileSize64(tif); - for (strip = 0; strip < td->td_nstrips; strip++) - td->td_stripbytecount_p[strip] = bytespertile; - } - else - { - 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 > UINT64_MAX / rowbytes) - return -1; - td->td_stripbytecount_p[strip] = rowbytes * rowsperstrip; - } - } - TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); - if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) - td->td_rowsperstrip = td->td_imagelength; - return 1; + if (td->td_stripbytecount_p) + _TIFFfree(td->td_stripbytecount_p); + td->td_stripbytecount_p = (uint64*) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + "for \"StripByteCounts\" array"); + if( td->td_stripbytecount_p == NULL ) + return -1; + + if (td->td_compression != COMPRESSION_NONE) { + uint64 space; + uint64 filesize; + uint16 n; + filesize = TIFFGetFileSize(tif); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + space=sizeof(TIFFHeaderClassic)+2+dircount*12+4; + else + space=sizeof(TIFFHeaderBig)+8+dircount*20+8; + /* calculate amount of space used by indirect values */ + for (dp = dir, n = dircount; n > 0; n--, dp++) + { + uint32 typewidth; + uint64 datasize; + typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type); + if (typewidth == 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot determine size of unknown tag type %d", + dp->tdir_type); + return -1; + } + if( dp->tdir_count > TIFF_UINT64_MAX / typewidth ) + return -1; + datasize=(uint64)typewidth*dp->tdir_count; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (datasize<=4) + datasize=0; + } + else + { + if (datasize<=8) + datasize=0; + } + if( space > TIFF_UINT64_MAX - datasize ) + return -1; + space+=datasize; + } + if( filesize < space ) + /* we should perhaps return in error ? */ + space = filesize; + else + space = filesize - space; + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + space /= td->td_samplesperpixel; + for (strip = 0; strip < td->td_nstrips; strip++) + td->td_stripbytecount_p[strip] = space; + /* + * This gross hack handles the case were the offset to + * the last strip is past the place where we think the strip + * should begin. Since a strip of data must be contiguous, + * it's safe to assume that we've overestimated the amount + * 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]) + return -1; + if (td->td_stripoffset_p[strip]+td->td_stripbytecount_p[strip] > filesize) { + if( td->td_stripoffset_p[strip] >= filesize ) { + /* Not sure what we should in that case... */ + td->td_stripbytecount_p[strip] = 0; + } else { + td->td_stripbytecount_p[strip] = filesize - td->td_stripoffset_p[strip]; + } + } + } else if (isTiled(tif)) { + uint64 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; + for (strip = 0; strip < td->td_nstrips; strip++) + { + if( rowbytes > 0 && rowsperstrip > TIFF_UINT64_MAX / rowbytes ) + return -1; + td->td_stripbytecount_p[strip] = rowbytes * rowsperstrip; + } + } + TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); + if (!TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) + td->td_rowsperstrip = td->td_imagelength; + return 1; } -static void MissingRequired(TIFF *tif, const char *tagname) +static void +MissingRequired(TIFF* tif, const char* tagname) { - static const char module[] = "MissingRequired"; + static const char module[] = "MissingRequired"; - TIFFErrorExtR(tif, module, - "TIFF directory is missing required \"%s\" field", tagname); -} - -static unsigned long hashFuncOffsetToNumber(const void *elt) -{ - const TIFFOffsetAndDirNumber *offsetAndDirNumber = - (const TIFFOffsetAndDirNumber *)elt; - const uint32_t hash = (uint32_t)(offsetAndDirNumber->offset >> 32) ^ - ((uint32_t)offsetAndDirNumber->offset & 0xFFFFFFFFU); - return hash; -} - -static bool equalFuncOffsetToNumber(const void *elt1, const void *elt2) -{ - const TIFFOffsetAndDirNumber *offsetAndDirNumber1 = - (const TIFFOffsetAndDirNumber *)elt1; - const TIFFOffsetAndDirNumber *offsetAndDirNumber2 = - (const TIFFOffsetAndDirNumber *)elt2; - return offsetAndDirNumber1->offset == offsetAndDirNumber2->offset; -} - -static unsigned long hashFuncNumberToOffset(const void *elt) -{ - const TIFFOffsetAndDirNumber *offsetAndDirNumber = - (const TIFFOffsetAndDirNumber *)elt; - return offsetAndDirNumber->dirNumber; -} - -static bool equalFuncNumberToOffset(const void *elt1, const void *elt2) -{ - const TIFFOffsetAndDirNumber *offsetAndDirNumber1 = - (const TIFFOffsetAndDirNumber *)elt1; - const TIFFOffsetAndDirNumber *offsetAndDirNumber2 = - (const TIFFOffsetAndDirNumber *)elt2; - return offsetAndDirNumber1->dirNumber == offsetAndDirNumber2->dirNumber; + TIFFErrorExt(tif->tif_clientdata, module, + "TIFF directory is missing required \"%s\" field", + tagname); } /* - * Check the directory number and offset against the list of already seen - * directory numbers and offsets. This is a trick to prevent IFD looping. - * The one can create TIFF file with looped directory pointers. We will - * maintain a list of already seen directories and check every IFD offset - * and its IFD number against that list. However, the offset of an IFD number - * can change - e.g. when writing updates to file. - * Returns 1 if all is ok; 0 if last directory or IFD loop is encountered, - * or an error has occurred. + * Check the directory offset against the list of already seen directory + * offsets. This is a trick to prevent IFD looping. The one can create TIFF + * file with looped directory pointers. We will maintain a list of already + * seen directories and check every IFD offset against that list. */ -int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn, uint64_t diroff) +static int +TIFFCheckDirOffset(TIFF* tif, uint64 diroff) { - if (diroff == 0) /* no more directories */ - return 0; + uint16 n; - if (tif->tif_map_dir_offset_to_number == NULL) - { - tif->tif_map_dir_offset_to_number = TIFFHashSetNew( - hashFuncOffsetToNumber, equalFuncOffsetToNumber, free); - if (tif->tif_map_dir_offset_to_number == NULL) - { - TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset", - "Not enough memory"); - return 1; - } - } + if (diroff == 0) /* no more directories */ + return 0; + if (tif->tif_dirnumber == 65535) { + TIFFErrorExt(tif->tif_clientdata, "TIFFCheckDirOffset", + "Cannot handle more than 65535 TIFF directories"); + return 0; + } - if (tif->tif_map_dir_number_to_offset == NULL) - { - /* No free callback for this map, as it shares the same items as - * tif->tif_map_dir_offset_to_number. */ - tif->tif_map_dir_number_to_offset = TIFFHashSetNew( - hashFuncNumberToOffset, equalFuncNumberToOffset, NULL); - if (tif->tif_map_dir_number_to_offset == NULL) - { - TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset", - "Not enough memory"); - return 1; - } - } + for (n = 0; n < tif->tif_dirnumber && tif->tif_dirlist; n++) { + if (tif->tif_dirlist[n] == diroff) + return 0; + } - /* Check if offset is already in the list: - * - yes: check, if offset is at the same IFD number - if not, it is an IFD - * loop - * - no: add to list or update offset at that IFD number - */ - TIFFOffsetAndDirNumber entry; - entry.offset = diroff; - entry.dirNumber = dirn; + tif->tif_dirnumber++; - TIFFOffsetAndDirNumber *foundEntry = - (TIFFOffsetAndDirNumber *)TIFFHashSetLookup( - tif->tif_map_dir_offset_to_number, &entry); - if (foundEntry) - { - if (foundEntry->dirNumber == dirn) - { - return 1; - } - else - { - TIFFWarningExtR(tif, "_TIFFCheckDirNumberAndOffset", - "TIFF directory %d has IFD looping to directory %u " - "at offset 0x%" PRIx64 " (%" PRIu64 ")", - (int)dirn - 1, foundEntry->dirNumber, diroff, - diroff); - return 0; - } - } + if (tif->tif_dirlist == NULL || tif->tif_dirnumber > tif->tif_dirlistsize) { + uint64* new_dirlist; - /* Check if offset of an IFD has been changed and update offset of that IFD - * number. */ - foundEntry = (TIFFOffsetAndDirNumber *)TIFFHashSetLookup( - tif->tif_map_dir_number_to_offset, &entry); - if (foundEntry) - { - if (foundEntry->offset != diroff) - { - TIFFOffsetAndDirNumber entryOld; - entryOld.offset = foundEntry->offset; - entryOld.dirNumber = dirn; - /* We must remove first from tif_map_dir_number_to_offset as the */ - /* entry is owned (and thus freed) by */ - /* tif_map_dir_offset_to_number */ - TIFFOffsetAndDirNumber *foundEntryOld = - (TIFFOffsetAndDirNumber *)TIFFHashSetLookup( - tif->tif_map_dir_number_to_offset, &entryOld); - if (foundEntryOld) - { - TIFFHashSetRemove(tif->tif_map_dir_number_to_offset, - foundEntryOld); - } - foundEntryOld = (TIFFOffsetAndDirNumber *)TIFFHashSetLookup( - tif->tif_map_dir_offset_to_number, &entryOld); - if (foundEntryOld) - { - TIFFHashSetRemove(tif->tif_map_dir_offset_to_number, - foundEntryOld); - } + /* + * 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"); + if (!new_dirlist) + return 0; + if( tif->tif_dirnumber >= 32768 ) + tif->tif_dirlistsize = 65535; + else + tif->tif_dirlistsize = 2 * tif->tif_dirnumber; + tif->tif_dirlist = new_dirlist; + } - TIFFOffsetAndDirNumber *entryPtr = (TIFFOffsetAndDirNumber *)malloc( - sizeof(TIFFOffsetAndDirNumber)); - if (entryPtr == NULL) - { - return 0; - } + tif->tif_dirlist[tif->tif_dirnumber - 1] = diroff; - /* Add IFD offset and dirn to IFD directory list */ - *entryPtr = entry; - - if (!TIFFHashSetInsert(tif->tif_map_dir_offset_to_number, entryPtr)) - { - TIFFErrorExtR( - tif, "_TIFFCheckDirNumberAndOffset", - "Insertion in tif_map_dir_offset_to_number failed"); - return 0; - } - if (!TIFFHashSetInsert(tif->tif_map_dir_number_to_offset, entryPtr)) - { - TIFFErrorExtR( - tif, "_TIFFCheckDirNumberAndOffset", - "Insertion in tif_map_dir_number_to_offset failed"); - return 0; - } - } - return 1; - } - - /* Arbitrary (hopefully big enough) limit */ - if (TIFFHashSetSize(tif->tif_map_dir_offset_to_number) >= - TIFF_MAX_DIR_COUNT) - { - TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset", - "Cannot handle more than %u TIFF directories", - TIFF_MAX_DIR_COUNT); - return 0; - } - - TIFFOffsetAndDirNumber *entryPtr = - (TIFFOffsetAndDirNumber *)malloc(sizeof(TIFFOffsetAndDirNumber)); - if (entryPtr == NULL) - { - TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset", - "malloc(sizeof(TIFFOffsetAndDirNumber)) failed"); - return 0; - } - - /* Add IFD offset and dirn to IFD directory list */ - *entryPtr = entry; - - if (!TIFFHashSetInsert(tif->tif_map_dir_offset_to_number, entryPtr)) - { - TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset", - "Insertion in tif_map_dir_offset_to_number failed"); - return 0; - } - if (!TIFFHashSetInsert(tif->tif_map_dir_number_to_offset, entryPtr)) - { - TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset", - "Insertion in tif_map_dir_number_to_offset failed"); - return 0; - } - - return 1; -} /* --- _TIFFCheckDirNumberAndOffset() ---*/ - -/* - * Retrieve the matching IFD directory number of a given IFD offset - * from the list of directories already seen. - * Returns 1 if the offset was in the list and the directory number - * can be returned. - * Otherwise returns 0 or if an error occurred. - */ -int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff, tdir_t *dirn) -{ - if (diroff == 0) /* no more directories */ - return 0; - - /* Check if offset is already in the list and return matching directory - * number. Otherwise update IFD list using TIFFNumberOfDirectories() and - * search again in IFD list. - */ - if (tif->tif_map_dir_offset_to_number == NULL) - return 0; - TIFFOffsetAndDirNumber entry; - entry.offset = diroff; - entry.dirNumber = 0; /* not used */ - - TIFFOffsetAndDirNumber *foundEntry = - (TIFFOffsetAndDirNumber *)TIFFHashSetLookup( - tif->tif_map_dir_offset_to_number, &entry); - if (foundEntry) - { - *dirn = foundEntry->dirNumber; - return 1; - } - - /* This updates the directory list for all main-IFDs in the file. */ - TIFFNumberOfDirectories(tif); - - foundEntry = (TIFFOffsetAndDirNumber *)TIFFHashSetLookup( - tif->tif_map_dir_offset_to_number, &entry); - if (foundEntry) - { - *dirn = foundEntry->dirNumber; - return 1; - } - - return 0; -} /*--- _TIFFGetDirNumberFromOffset() ---*/ - -/* - * Retrieve the matching IFD directory offset of a given IFD number - * from the list of directories already seen. - * Returns 1 if the offset was in the list of already seen IFDs and the - * directory offset can be returned. The directory list is not updated. - * Otherwise returns 0 or if an error occurred. - */ -int _TIFFGetOffsetFromDirNumber(TIFF *tif, tdir_t dirn, uint64_t *diroff) -{ - - if (tif->tif_map_dir_number_to_offset == NULL) - return 0; - TIFFOffsetAndDirNumber entry; - entry.offset = 0; /* not used */ - entry.dirNumber = dirn; - - TIFFOffsetAndDirNumber *foundEntry = - (TIFFOffsetAndDirNumber *)TIFFHashSetLookup( - tif->tif_map_dir_number_to_offset, &entry); - if (foundEntry) - { - *diroff = foundEntry->offset; - return 1; - } - - return 0; -} /*--- _TIFFGetOffsetFromDirNumber() ---*/ - -/* - * Remove an entry from the directory list of already seen directories - * by directory offset. - * If an entry is to be removed from the list, it is also okay if the entry - * is not in the list or the list does not exist. - */ -int _TIFFRemoveEntryFromDirectoryListByOffset(TIFF *tif, uint64_t diroff) -{ - if (tif->tif_map_dir_offset_to_number == NULL) - return 1; - - TIFFOffsetAndDirNumber entryOld; - entryOld.offset = diroff; - entryOld.dirNumber = 0; - /* We must remove first from tif_map_dir_number_to_offset as the - * entry is owned (and thus freed) by tif_map_dir_offset_to_number. - * However, we need firstly to find the directory number from offset. */ - - TIFFOffsetAndDirNumber *foundEntryOldOff = - (TIFFOffsetAndDirNumber *)TIFFHashSetLookup( - tif->tif_map_dir_offset_to_number, &entryOld); - if (foundEntryOldOff) - { - entryOld.dirNumber = foundEntryOldOff->dirNumber; - if (tif->tif_map_dir_number_to_offset != NULL) - { - TIFFOffsetAndDirNumber *foundEntryOldDir = - (TIFFOffsetAndDirNumber *)TIFFHashSetLookup( - tif->tif_map_dir_number_to_offset, &entryOld); - if (foundEntryOldDir) - { - TIFFHashSetRemove(tif->tif_map_dir_number_to_offset, - foundEntryOldDir); - TIFFHashSetRemove(tif->tif_map_dir_offset_to_number, - foundEntryOldOff); - return 1; - } - } - else - { - TIFFErrorExtR(tif, "_TIFFRemoveEntryFromDirectoryListByOffset", - "Unexpectedly tif_map_dir_number_to_offset is " - "missing but tif_map_dir_offset_to_number exists."); - return 0; - } - } - return 1; -} /*--- _TIFFRemoveEntryFromDirectoryListByOffset() ---*/ + return 1; +} /* * Check the count field of a directory entry against a known value. The * caller is expected to skip/ignore the tag if there is a mismatch. */ -static int CheckDirCount(TIFF *tif, TIFFDirEntry *dir, uint32_t count) +static int +CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32 count) { - if ((uint64_t)count > dir->tdir_count) - { - const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag); - TIFFWarningExtR(tif, tif->tif_name, - "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_t)count < dir->tdir_count) - { - const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag); - TIFFWarningExtR(tif, tif->tif_name, - "incorrect count for field \"%s\" (%" PRIu64 - ", expecting %" PRIu32 "); tag trimmed", - fip ? fip->field_name : "unknown tagname", - dir->tdir_count, count); - dir->tdir_count = count; - return (1); - } - return (1); + if ((uint64)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", + fip ? fip->field_name : "unknown tagname", + dir->tdir_count, count); + return (0); + } else if ((uint64)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", + fip ? fip->field_name : "unknown tagname", + dir->tdir_count, count); + dir->tdir_count = count; + return (1); + } + return (1); } /* @@ -5738,1546 +4766,1139 @@ static int CheckDirCount(TIFF *tif, TIFFDirEntry *dir, uint32_t count) * nextdiroff variable has been specified, read it too. Function returns a * number of fields in the directory or 0 if failed. */ -static uint16_t TIFFFetchDirectory(TIFF *tif, uint64_t diroff, - TIFFDirEntry **pdir, uint64_t *nextdiroff) +static uint16 +TIFFFetchDirectory(TIFF* tif, uint64 diroff, TIFFDirEntry** pdir, + uint64 *nextdiroff) { - static const char module[] = "TIFFFetchDirectory"; + static const char module[] = "TIFFFetchDirectory"; - void *origdir; - uint16_t dircount16; - uint32_t dirsize; - TIFFDirEntry *dir; - uint8_t *ma; - TIFFDirEntry *mb; - uint16_t n; + void* origdir; + uint16 dircount16; + uint32 dirsize; + TIFFDirEntry* dir; + uint8* ma; + TIFFDirEntry* mb; + uint16 n; - assert(pdir); + assert(pdir); - tif->tif_diroff = diroff; - if (nextdiroff) - *nextdiroff = 0; - if (!isMapped(tif)) - { - if (!SeekOK(tif, tif->tif_diroff)) - { - TIFFErrorExtR(tif, module, - "%s: Seek error accessing TIFF directory", - tif->tif_name); - return 0; - } - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - if (!ReadOK(tif, &dircount16, sizeof(uint16_t))) - { - TIFFErrorExtR(tif, module, - "%s: Can not read TIFF directory count", - tif->tif_name); - return 0; - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount16); - if (dircount16 > 4096) - { - TIFFErrorExtR(tif, module, - "Sanity check on directory count failed, this is " - "probably not a valid IFD offset"); - return 0; - } - dirsize = 12; - } - else - { - uint64_t dircount64; - if (!ReadOK(tif, &dircount64, sizeof(uint64_t))) - { - TIFFErrorExtR(tif, module, - "%s: Can not read TIFF directory count", - tif->tif_name); - return 0; - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&dircount64); - if (dircount64 > 4096) - { - TIFFErrorExtR(tif, module, - "Sanity check on directory count failed, this is " - "probably not a valid IFD offset"); - return 0; - } - dircount16 = (uint16_t)dircount64; - dirsize = 20; - } - origdir = _TIFFCheckMalloc(tif, dircount16, dirsize, - "to read TIFF directory"); - if (origdir == NULL) - return 0; - if (!ReadOK(tif, origdir, (tmsize_t)(dircount16 * dirsize))) - { - TIFFErrorExtR(tif, module, "%.100s: Can not read TIFF directory", - tif->tif_name); - _TIFFfreeExt(tif, origdir); - return 0; - } - /* - * Read offset to next directory for sequential scans if - * needed. - */ - if (nextdiroff) - { - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - 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_t))) - *nextdiroff = 0; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(nextdiroff); - } - } - } - else - { - tmsize_t m; - tmsize_t off; - if (tif->tif_diroff > (uint64_t)INT64_MAX) - { - TIFFErrorExtR(tif, module, "Can not read TIFF directory count"); - return (0); - } - off = (tmsize_t)tif->tif_diroff; + tif->tif_diroff = diroff; + if (nextdiroff) + *nextdiroff = 0; + if (!isMapped(tif)) { + if (!SeekOK(tif, tif->tif_diroff)) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Seek error accessing TIFF directory", + tif->tif_name); + return 0; + } + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (!ReadOK(tif, &dircount16, sizeof (uint16))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory count", + tif->tif_name); + return 0; + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount16); + if (dircount16>4096) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, this is probably not a valid IFD offset"); + return 0; + } + dirsize = 12; + } else { + uint64 dircount64; + if (!ReadOK(tif, &dircount64, sizeof (uint64))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory count", + tif->tif_name); + return 0; + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>4096) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, this is probably not a valid IFD offset"); + return 0; + } + dircount16 = (uint16)dircount64; + dirsize = 20; + } + origdir = _TIFFCheckMalloc(tif, dircount16, + dirsize, "to read TIFF directory"); + if (origdir == NULL) + return 0; + if (!ReadOK(tif, origdir, (tmsize_t)(dircount16*dirsize))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%.100s: Can not read TIFF directory", + tif->tif_name); + _TIFFfree(origdir); + return 0; + } + /* + * Read offset to next directory for sequential scans if + * needed. + */ + if (nextdiroff) + { + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 nextdiroff32; + if (!ReadOK(tif, &nextdiroff32, sizeof(uint32))) + nextdiroff32 = 0; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&nextdiroff32); + *nextdiroff=nextdiroff32; + } else { + if (!ReadOK(tif, nextdiroff, sizeof(uint64))) + *nextdiroff = 0; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(nextdiroff); + } + } + } else { + tmsize_t m; + tmsize_t off; + if (tif->tif_diroff > (uint64)TIFF_INT64_MAX) + { + TIFFErrorExt(tif->tif_clientdata,module,"Can not read TIFF directory count"); + return(0); + } + off = (tmsize_t) tif->tif_diroff; - /* - * Check for integer overflow when validating the dir_off, - * otherwise a very high offset may cause an OOB read and - * crash the client. Make two comparisons instead of - * - * off + sizeof(uint16_t) > tif->tif_size - * - * to avoid overflow. - */ - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - m = off + sizeof(uint16_t); - if ((m < off) || (m < (tmsize_t)sizeof(uint16_t)) || - (m > tif->tif_size)) - { - TIFFErrorExtR(tif, module, "Can not read TIFF directory count"); - return 0; - } - else - { - _TIFFmemcpy(&dircount16, tif->tif_base + off, sizeof(uint16_t)); - } - off += sizeof(uint16_t); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount16); - if (dircount16 > 4096) - { - TIFFErrorExtR(tif, module, - "Sanity check on directory count failed, this is " - "probably not a valid IFD offset"); - return 0; - } - dirsize = 12; - } - else - { - uint64_t dircount64; - m = off + sizeof(uint64_t); - if ((m < off) || (m < (tmsize_t)sizeof(uint64_t)) || - (m > tif->tif_size)) - { - TIFFErrorExtR(tif, module, "Can not read TIFF directory count"); - return 0; - } - else - { - _TIFFmemcpy(&dircount64, tif->tif_base + off, sizeof(uint64_t)); - } - off += sizeof(uint64_t); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&dircount64); - if (dircount64 > 4096) - { - TIFFErrorExtR(tif, module, - "Sanity check on directory count failed, this is " - "probably not a valid IFD offset"); - return 0; - } - dircount16 = (uint16_t)dircount64; - dirsize = 20; - } - if (dircount16 == 0) - { - TIFFErrorExtR(tif, module, - "Sanity check on directory count failed, zero tag " - "directories not supported"); - return 0; - } - origdir = _TIFFCheckMalloc(tif, dircount16, dirsize, - "to read TIFF directory"); - if (origdir == NULL) - return 0; - m = off + dircount16 * dirsize; - if ((m < off) || (m < (tmsize_t)(dircount16 * dirsize)) || - (m > tif->tif_size)) - { - TIFFErrorExtR(tif, module, "Can not read TIFF directory"); - _TIFFfreeExt(tif, origdir); - return 0; - } - else - { - _TIFFmemcpy(origdir, tif->tif_base + off, dircount16 * dirsize); - } - if (nextdiroff) - { - off += dircount16 * dirsize; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - 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_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextdiroff32); - *nextdiroff = nextdiroff32; - } - else - { - 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_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(nextdiroff); - } - } - } - dir = (TIFFDirEntry *)_TIFFCheckMalloc( - tif, dircount16, sizeof(TIFFDirEntry), "to read TIFF directory"); - if (dir == 0) - { - _TIFFfreeExt(tif, origdir); - return 0; - } - ma = (uint8_t *)origdir; - mb = dir; - for (n = 0; n < dircount16; n++) - { - mb->tdir_ignore = FALSE; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)ma); - mb->tdir_tag = *(uint16_t *)ma; - ma += sizeof(uint16_t); - if (tif->tif_flags & TIFF_SWAB) - 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_t *)ma); - mb->tdir_count = (uint64_t)(*(uint32_t *)ma); - ma += sizeof(uint32_t); - mb->tdir_offset.toff_long8 = 0; - *(uint32_t *)(&mb->tdir_offset) = *(uint32_t *)ma; - ma += sizeof(uint32_t); - } - else - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)ma); - mb->tdir_count = TIFFReadUInt64(ma); - ma += sizeof(uint64_t); - mb->tdir_offset.toff_long8 = TIFFReadUInt64(ma); - ma += sizeof(uint64_t); - } - mb++; - } - _TIFFfreeExt(tif, origdir); - *pdir = dir; - return dircount16; + /* + * Check for integer overflow when validating the dir_off, + * 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 + * + * to avoid overflow. + */ + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + m=off+sizeof(uint16); + if ((mtif->tif_size)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not read TIFF directory count"); + return 0; + } else { + _TIFFmemcpy(&dircount16, tif->tif_base + off, + sizeof(uint16)); + } + off += sizeof (uint16); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount16); + if (dircount16>4096) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, this is probably not a valid IFD offset"); + return 0; + } + dirsize = 12; + } + else + { + uint64 dircount64; + m=off+sizeof(uint64); + if ((mtif->tif_size)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not read TIFF directory count"); + return 0; + } else { + _TIFFmemcpy(&dircount64, tif->tif_base + off, + sizeof(uint64)); + } + off += sizeof (uint64); + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>4096) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, this is probably not a valid IFD offset"); + return 0; + } + dircount16 = (uint16)dircount64; + dirsize = 20; + } + if (dircount16 == 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on directory count failed, zero tag directories not supported"); + return 0; + } + origdir = _TIFFCheckMalloc(tif, dircount16, + dirsize, + "to read TIFF directory"); + if (origdir == NULL) + return 0; + m=off+dircount16*dirsize; + if ((mtif->tif_size)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not read TIFF directory"); + _TIFFfree(origdir); + return 0; + } else { + _TIFFmemcpy(origdir, tif->tif_base + off, + dircount16 * dirsize); + } + if (nextdiroff) { + off += dircount16 * dirsize; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 nextdiroff32; + m=off+sizeof(uint32); + if ((mtif->tif_size)) + nextdiroff32 = 0; + else + _TIFFmemcpy(&nextdiroff32, tif->tif_base + off, + sizeof (uint32)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&nextdiroff32); + *nextdiroff = nextdiroff32; + } + else + { + m=off+sizeof(uint64); + if ((mtif->tif_size)) + *nextdiroff = 0; + else + _TIFFmemcpy(nextdiroff, tif->tif_base + off, + sizeof (uint64)); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(nextdiroff); + } + } + } + dir = (TIFFDirEntry*)_TIFFCheckMalloc(tif, dircount16, + sizeof(TIFFDirEntry), + "to read TIFF directory"); + if (dir==0) + { + _TIFFfree(origdir); + return 0; + } + ma=(uint8*)origdir; + mb=dir; + for (n=0; ntdir_ignore = FALSE; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + mb->tdir_tag=*(uint16*)ma; + ma+=sizeof(uint16); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)ma); + mb->tdir_type=*(uint16*)ma; + ma+=sizeof(uint16); + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)ma); + mb->tdir_count=(uint64)(*(uint32*)ma); + ma+=sizeof(uint32); + mb->tdir_offset.toff_long8=0; + *(uint32*)(&mb->tdir_offset)=*(uint32*)ma; + ma+=sizeof(uint32); + } + else + { + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)ma); + mb->tdir_count=TIFFReadUInt64(ma); + ma+=sizeof(uint64); + mb->tdir_offset.toff_long8=TIFFReadUInt64(ma); + ma+=sizeof(uint64); + } + mb++; + } + _TIFFfree(origdir); + *pdir = dir; + return dircount16; } /* * Fetch a tag that is not handled by special case code. */ -static int TIFFFetchNormalTag(TIFF *tif, TIFFDirEntry *dp, int recover) +static int +TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover) { - static const char module[] = "TIFFFetchNormalTag"; - enum TIFFReadDirEntryErr err; - uint32_t fii; - const TIFFField *fip = NULL; - TIFFReadDirectoryFindFieldInfo(tif, dp->tdir_tag, &fii); - if (fii == FAILED_FII) - { - TIFFErrorExtR(tif, "TIFFFetchNormalTag", - "No definition found for tag %" PRIu16, dp->tdir_tag); - return 0; - } - fip = tif->tif_fields[fii]; - assert(fip != NULL); /* should not happen */ - assert(fip->set_field_type != - TIFF_SETGET_OTHER); /* if so, we shouldn't arrive here but deal with - this in specialized code */ - assert(fip->set_field_type != - TIFF_SETGET_INT); /* if so, we shouldn't arrive here as this is only - the case for pseudo-tags */ - err = TIFFReadDirEntryErrOk; - switch (fip->set_field_type) - { - case TIFF_SETGET_UNDEFINED: - TIFFErrorExtR( - tif, "TIFFFetchNormalTag", - "Defined set_field_type of custom tag %u (%s) is " - "TIFF_SETGET_UNDEFINED and thus tag is not read from file", - fip->field_tag, fip->field_name); - break; - case TIFF_SETGET_ASCII: + static const char module[] = "TIFFFetchNormalTag"; + enum TIFFReadDirEntryErr err; + uint32 fii; + const TIFFField* fip = NULL; + TIFFReadDirectoryFindFieldInfo(tif,dp->tdir_tag,&fii); + if( fii == FAILED_FII ) { - uint8_t *data; - assert(fip->field_passcount == 0); - err = TIFFReadDirEntryByteArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - size_t mb = 0; - int n; - if (data != NULL) - { - if (dp->tdir_count > 0 && data[dp->tdir_count - 1] == 0) - { - /* optimization: if data is known to be 0 terminated, we - * can use strlen() */ - mb = strlen((const char *)data); - } - else - { - /* general case. equivalent to non-portable */ - /* mb = strnlen((const char*)data, - * (uint32_t)dp->tdir_count); */ - uint8_t *ma = data; - while (mb < (uint32_t)dp->tdir_count) - { - if (*ma == 0) - break; - ma++; - mb++; - } - } - } - if (mb + 1 < (uint32_t)dp->tdir_count) - TIFFWarningExtR( - tif, 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_t)dp->tdir_count) - { - uint8_t *o; - TIFFWarningExtR( - tif, module, - "ASCII value for tag \"%s\" does not end in null byte", - fip->field_name); - /* TIFFReadDirEntryArrayWithLimit() ensures this can't be - * larger than MAX_SIZE_TAG_DATA */ - assert((uint32_t)dp->tdir_count + 1 == dp->tdir_count + 1); - o = _TIFFmallocExt(tif, (uint32_t)dp->tdir_count + 1); - if (o == NULL) - { - if (data != NULL) - _TIFFfreeExt(tif, data); - return (0); - } - if (dp->tdir_count > 0) - { - _TIFFmemcpy(o, data, (uint32_t)dp->tdir_count); - } - o[(uint32_t)dp->tdir_count] = 0; - if (data != 0) - _TIFFfreeExt(tif, data); - data = o; - } - n = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!n) - return (0); - } + TIFFErrorExt(tif->tif_clientdata, "TIFFFetchNormalTag", + "No definition found for tag %d", + dp->tdir_tag); + return 0; } - break; - case TIFF_SETGET_UINT8: - { - uint8_t data = 0; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntryByte(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_SINT8: - { - int8_t data = 0; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntrySbyte(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_UINT16: - { - uint16_t data; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntryShort(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_SINT16: - { - int16_t data; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntrySshort(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_UINT32: - { - uint32_t data; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntryLong(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_SINT32: - { - int32_t data; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntrySlong(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_UINT64: - { - uint64_t data; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntryLong8(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_SINT64: - { - int64_t data; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntrySlong8(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_FLOAT: - { - float data; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntryFloat(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_DOUBLE: - { - double data; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntryDouble(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_IFD8: - { - uint64_t data; - assert(fip->field_readcount == 1); - assert(fip->field_passcount == 0); - err = TIFFReadDirEntryIfd8(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - if (!TIFFSetField(tif, dp->tdir_tag, data)) - return (0); - } - } - break; - case TIFF_SETGET_UINT16_PAIR: - { - uint16_t *data; - assert(fip->field_readcount == 2); - assert(fip->field_passcount == 0); - if (dp->tdir_count != 2) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected 2, " - "got %" PRIu64, - fip->field_name, dp->tdir_count); - return (0); - } - err = TIFFReadDirEntryShortArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - assert(data); /* avoid CLang static Analyzer false positive */ - m = TIFFSetField(tif, dp->tdir_tag, data[0], data[1]); - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C0_UINT8: - { - uint8_t *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntryByteArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C0_SINT8: - { - int8_t *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntrySbyteArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C0_UINT16: - { - uint16_t *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntryShortArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C0_SINT16: - { - int16_t *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntrySshortArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C0_UINT32: - { - uint32_t *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntryLongArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C0_SINT32: - { - int32_t *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntrySlongArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C0_UINT64: - { - uint64_t *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntryLong8Array(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C0_SINT64: - { - int64_t *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntrySlong8Array(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C0_FLOAT: - { - float *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntryFloatArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - /*--: Rational2Double: Extend for Double Arrays and Rational-Arrays read - * into Double-Arrays. */ - case TIFF_SETGET_C0_DOUBLE: - { - double *data; - assert(fip->field_readcount >= 1); - assert(fip->field_passcount == 0); - if (dp->tdir_count != (uint64_t)fip->field_readcount) - { - TIFFWarningExtR(tif, module, - "incorrect count for field \"%s\", expected " - "%d, got %" PRIu64, - fip->field_name, (int)fip->field_readcount, - dp->tdir_count); - return (0); - } - else - { - err = TIFFReadDirEntryDoubleArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_ASCII: - { - uint8_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntryByteArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - if (data != 0 && dp->tdir_count > 0 && - data[dp->tdir_count - 1] != '\0') - { - TIFFWarningExtR( - tif, 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_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_UINT8: - { - uint8_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntryByteArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_SINT8: - { - int8_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntrySbyteArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_UINT16: - { - uint16_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntryShortArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_SINT16: - { - int16_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntrySshortArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_UINT32: - { - uint32_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntryLongArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_SINT32: - { - int32_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntrySlongArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_UINT64: - { - uint64_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntryLong8Array(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_SINT64: - { - int64_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntrySlong8Array(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_FLOAT: - { - float *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntryFloatArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_DOUBLE: - { - double *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntryDoubleArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C16_IFD8: - { - uint64_t *data; - assert(fip->field_readcount == TIFF_VARIABLE); - assert(fip->field_passcount == 1); - if (dp->tdir_count > 0xFFFF) - err = TIFFReadDirEntryErrCount; - else - { - err = TIFFReadDirEntryIfd8Array(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, - (uint16_t)(dp->tdir_count), data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - } - break; - case TIFF_SETGET_C32_ASCII: - { - uint8_t *data; - assert(fip->field_readcount == TIFF_VARIABLE2); - assert(fip->field_passcount == 1); - err = TIFFReadDirEntryByteArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - if (data != 0 && dp->tdir_count > 0 && - data[dp->tdir_count - 1] != '\0') - { - TIFFWarningExtR(tif, 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_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_UINT8: - { - uint8_t *data; - uint32_t count = 0; - assert(fip->field_readcount == TIFF_VARIABLE2); - assert(fip->field_passcount == 1); - if (fip->field_tag == TIFFTAG_RICHTIFFIPTC && - dp->tdir_type == TIFF_LONG) - { - /* Adobe's software (wrongly) writes RichTIFFIPTC tag with - * data type LONG instead of UNDEFINED. Work around this - * frequently found issue */ - void *origdata; - err = TIFFReadDirEntryArray(tif, dp, &count, 4, &origdata); - if ((err != TIFFReadDirEntryErrOk) || (origdata == 0)) - { - data = NULL; - } - else - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong((uint32_t *)origdata, count); - data = (uint8_t *)origdata; - count = (uint32_t)(count * 4); - } - } - else - { - err = TIFFReadDirEntryByteArray(tif, dp, &data); - count = (uint32_t)(dp->tdir_count); - } - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, count, data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_SINT8: - { - 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_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_UINT16: - { - 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_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_SINT16: - { - 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_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_UINT32: - { - 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_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_SINT32: - { - 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_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_UINT64: - { - 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_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_SINT64: - { - 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_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_FLOAT: - { - float *data; - assert(fip->field_readcount == TIFF_VARIABLE2); - assert(fip->field_passcount == 1); - err = TIFFReadDirEntryFloatArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_DOUBLE: - { - double *data; - assert(fip->field_readcount == TIFF_VARIABLE2); - assert(fip->field_passcount == 1); - err = TIFFReadDirEntryDoubleArray(tif, dp, &data); - if (err == TIFFReadDirEntryErrOk) - { - int m; - m = TIFFSetField(tif, dp->tdir_tag, (uint32_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - case TIFF_SETGET_C32_IFD8: - { - 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_t)(dp->tdir_count), - data); - if (data != 0) - _TIFFfreeExt(tif, data); - if (!m) - return (0); - } - } - break; - default: - assert(0); /* we should never get here */ - break; - } - if (err != TIFFReadDirEntryErrOk) - { - TIFFReadDirEntryOutputErr(tif, err, module, fip->field_name, recover); - return (0); - } - return (1); + fip=tif->tif_fields[fii]; + assert(fip != NULL); /* should not happen */ + assert(fip->set_field_type!=TIFF_SETGET_OTHER); /* if so, we shouldn't arrive here but deal with this in specialized code */ + assert(fip->set_field_type!=TIFF_SETGET_INT); /* if so, we shouldn't arrive here as this is only the case for pseudo-tags */ + err=TIFFReadDirEntryErrOk; + switch (fip->set_field_type) + { + case TIFF_SETGET_UNDEFINED: + break; + case TIFF_SETGET_ASCII: + { + uint8* data; + assert(fip->field_passcount==0); + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + uint32 mb = 0; + int n; + if (data != NULL) + { + uint8* ma = data; + while (mb<(uint32)dp->tdir_count) + { + if (*ma==0) + break; + ma++; + mb++; + } + } + if (mb+1<(uint32)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) + { + uint8* 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) + o=NULL; + else + o=_TIFFmalloc((uint32)dp->tdir_count+1); + if (o==NULL) + { + if (data!=NULL) + _TIFFfree(data); + return(0); + } + if (dp->tdir_count > 0 ) + _TIFFmemcpy(o,data,(uint32)dp->tdir_count); + o[(uint32)dp->tdir_count]=0; + if (data!=0) + _TIFFfree(data); + data=o; + } + n=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!n) + return(0); + } + } + break; + case TIFF_SETGET_UINT8: + { + uint8 data=0; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryByte(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_UINT16: + { + uint16 data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryShort(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_UINT32: + { + uint32 data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryLong(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_UINT64: + { + uint64 data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryLong8(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_FLOAT: + { + float data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryFloat(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_DOUBLE: + { + double data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryDouble(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_IFD8: + { + uint64 data; + assert(fip->field_readcount==1); + assert(fip->field_passcount==0); + err=TIFFReadDirEntryIfd8(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + if (!TIFFSetField(tif,dp->tdir_tag,data)) + return(0); + } + } + break; + case TIFF_SETGET_UINT16_PAIR: + { + uint16* 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); + return(0); + } + err=TIFFReadDirEntryShortArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + assert(data); /* avoid CLang static Analyzer false positive */ + m=TIFFSetField(tif,dp->tdir_tag,data[0],data[1]); + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C0_UINT8: + { + uint8* data; + assert(fip->field_readcount>=1); + assert(fip->field_passcount==0); + if (dp->tdir_count!=(uint64)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); + return 0; + } + else + { + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C0_UINT16: + { + uint16* data; + assert(fip->field_readcount>=1); + assert(fip->field_passcount==0); + if (dp->tdir_count!=(uint64)fip->field_readcount) + /* corrupt file */; + else + { + err=TIFFReadDirEntryShortArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C0_UINT32: + { + uint32* data; + assert(fip->field_readcount>=1); + assert(fip->field_passcount==0); + if (dp->tdir_count!=(uint64)fip->field_readcount) + /* corrupt file */; + else + { + err=TIFFReadDirEntryLongArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C0_FLOAT: + { + float* data; + assert(fip->field_readcount>=1); + assert(fip->field_passcount==0); + if (dp->tdir_count!=(uint64)fip->field_readcount) + /* corrupt file */; + else + { + err=TIFFReadDirEntryFloatArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + /*--: Rational2Double: Extend for Double Arrays and Rational-Arrays read into Double-Arrays. */ + case TIFF_SETGET_C0_DOUBLE: + { + double* data; + assert(fip->field_readcount>=1); + assert(fip->field_passcount==0); + if (dp->tdir_count!=(uint64)fip->field_readcount) + /* corrupt file */; + else + { + err=TIFFReadDirEntryDoubleArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_ASCII: + { + uint8* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + if( data != 0 && dp->tdir_count > 0 && data[dp->tdir_count-1] != '\0' ) + { + 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_UINT8: + { + uint8* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_UINT16: + { + uint16* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryShortArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_UINT32: + { + uint32* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryLongArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_UINT64: + { + uint64* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryLong8Array(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_FLOAT: + { + float* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryFloatArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_DOUBLE: + { + double* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryDoubleArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C16_IFD8: + { + uint64* data; + assert(fip->field_readcount==TIFF_VARIABLE); + assert(fip->field_passcount==1); + if (dp->tdir_count>0xFFFF) + err=TIFFReadDirEntryErrCount; + else + { + err=TIFFReadDirEntryIfd8Array(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + } + break; + case TIFF_SETGET_C32_ASCII: + { + uint8* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryByteArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + if( data != 0 && dp->tdir_count > 0 && data[dp->tdir_count-1] != '\0' ) + { + 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_UINT8: + { + uint8* data; + uint32 count = 0; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + if( fip->field_tag == TIFFTAG_RICHTIFFIPTC && + dp->tdir_type == TIFF_LONG ) + { + /* Adobe's software (wrongly) writes RichTIFFIPTC tag with + * data type LONG instead of UNDEFINED. Work around this + * frequently found issue */ + void* origdata; + err=TIFFReadDirEntryArray(tif,dp,&count,4,&origdata); + if ((err!=TIFFReadDirEntryErrOk)||(origdata==0)) + { + data = NULL; + } + else + { + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)origdata,count); + data = (uint8*)origdata; + count = (uint32)(count * 4); + } + } + else + { + err=TIFFReadDirEntryByteArray(tif,dp,&data); + count = (uint32)(dp->tdir_count); + } + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,count,data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_SINT8: + { + int8* 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_UINT16: + { + uint16* 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_SINT16: + { + int16* 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_UINT32: + { + uint32* 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_SINT32: + { + int32* 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_UINT64: + { + uint64* 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_SINT64: + { + int64* 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_FLOAT: + { + float* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryFloatArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_DOUBLE: + { + double* data; + assert(fip->field_readcount==TIFF_VARIABLE2); + assert(fip->field_passcount==1); + err=TIFFReadDirEntryDoubleArray(tif,dp,&data); + if (err==TIFFReadDirEntryErrOk) + { + int m; + m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + case TIFF_SETGET_C32_IFD8: + { + uint64* 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); + if (data!=0) + _TIFFfree(data); + if (!m) + return(0); + } + } + break; + default: + assert(0); /* we should never get here */ + break; + } + if (err!=TIFFReadDirEntryErrOk) + { + TIFFReadDirEntryOutputErr(tif,err,module,fip->field_name,recover); + return(0); + } + return(1); } /* * Fetch a set of offsets or lengths. * While this routine says "strips", in fact it's also used for tiles. */ -static int TIFFFetchStripThing(TIFF *tif, TIFFDirEntry *dir, uint32_t nstrips, - uint64_t **lpp) +static int +TIFFFetchStripThing(TIFF* tif, TIFFDirEntry* dir, uint32 nstrips, uint64** lpp) { - static const char module[] = "TIFFFetchStripThing"; - enum TIFFReadDirEntryErr err; - uint64_t *data; - err = TIFFReadDirEntryLong8ArrayWithLimit(tif, dir, &data, nstrips); - if (err != TIFFReadDirEntryErrOk) - { - const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag); - TIFFReadDirEntryOutputErr(tif, err, module, - fip ? fip->field_name : "unknown tagname", 0); - return (0); - } - if (dir->tdir_count < (uint64_t)nstrips) - { - uint64_t *resizeddata; - const TIFFField *fip = TIFFFieldWithTag(tif, dir->tdir_tag); - const char *pszMax = getenv("LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT"); - uint32_t max_nstrips = 1000000; - if (pszMax) - max_nstrips = (uint32_t)atoi(pszMax); - TIFFReadDirEntryOutputErr(tif, TIFFReadDirEntryErrCount, module, - fip ? fip->field_name : "unknown tagname", - (nstrips <= max_nstrips)); + static const char module[] = "TIFFFetchStripThing"; + enum TIFFReadDirEntryErr err; + uint64* data; + err=TIFFReadDirEntryLong8ArrayWithLimit(tif,dir,&data,nstrips); + if (err!=TIFFReadDirEntryErrOk) + { + const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag); + TIFFReadDirEntryOutputErr(tif,err,module,fip ? fip->field_name : "unknown tagname",0); + return(0); + } + if (dir->tdir_count<(uint64)nstrips) + { + uint64* resizeddata; + const TIFFField* fip = TIFFFieldWithTag(tif,dir->tdir_tag); + const char* pszMax = getenv("LIBTIFF_STRILE_ARRAY_MAX_RESIZE_COUNT"); + uint32 max_nstrips = 1000000; + if( pszMax ) + max_nstrips = (uint32) atoi(pszMax); + TIFFReadDirEntryOutputErr(tif,TIFFReadDirEntryErrCount, + module, + fip ? fip->field_name : "unknown tagname", + ( nstrips <= max_nstrips ) ); - if (nstrips > max_nstrips) - { - _TIFFfreeExt(tif, data); - return (0); - } + if( nstrips > max_nstrips ) + { + _TIFFfree(data); + return(0); + } - resizeddata = (uint64_t *)_TIFFCheckMalloc( - tif, nstrips, sizeof(uint64_t), "for strip array"); - if (resizeddata == 0) - { - _TIFFfreeExt(tif, data); - return (0); - } - if (dir->tdir_count) - _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)); - _TIFFfreeExt(tif, data); - data = resizeddata; - } - *lpp = data; - return (1); + resizeddata=(uint64*)_TIFFCheckMalloc(tif,nstrips,sizeof(uint64),"for strip array"); + if (resizeddata==0) { + _TIFFfree(data); + return(0); + } + if (dir->tdir_count) + _TIFFmemcpy(resizeddata,data,(uint32)dir->tdir_count*sizeof(uint64)); + _TIFFmemset(resizeddata+(uint32)dir->tdir_count,0,(nstrips-(uint32)dir->tdir_count)*sizeof(uint64)); + _TIFFfree(data); + data=resizeddata; + } + *lpp=data; + return(1); } /* * Fetch and set the SubjectDistance EXIF tag. */ -static int TIFFFetchSubjectDistance(TIFF *tif, TIFFDirEntry *dir) +static int +TIFFFetchSubjectDistance(TIFF* tif, TIFFDirEntry* dir) { - static const char module[] = "TIFFFetchSubjectDistance"; - enum TIFFReadDirEntryErr err; - UInt64Aligned_t m; - m.l = 0; - assert(sizeof(double) == 8); - assert(sizeof(uint64_t) == 8); - assert(sizeof(uint32_t) == 4); - if (dir->tdir_count != 1) - err = TIFFReadDirEntryErrCount; - else if (dir->tdir_type != TIFF_RATIONAL) - err = TIFFReadDirEntryErrType; - else - { - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - uint32_t offset; - offset = *(uint32_t *)(&dir->tdir_offset); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&offset); - err = TIFFReadDirEntryData(tif, offset, 8, m.i); - } - else - { - m.l = dir->tdir_offset.toff_long8; - err = TIFFReadDirEntryErrOk; - } - } - if (err == TIFFReadDirEntryErrOk) - { - double n; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong(m.i, 2); - if (m.i[0] == 0) - n = 0.0; - else if (m.i[0] == 0xFFFFFFFF || m.i[1] == 0) - /* - * XXX: Numerator 0xFFFFFFFF means that we have infinite - * distance. Indicate that with a negative floating point - * SubjectDistance value. - */ - n = -1.0; - else - n = (double)m.i[0] / (double)m.i[1]; - return (TIFFSetField(tif, dir->tdir_tag, n)); - } - else - { - TIFFReadDirEntryOutputErr(tif, err, module, "SubjectDistance", TRUE); - return (0); - } + static const char module[] = "TIFFFetchSubjectDistance"; + enum TIFFReadDirEntryErr err; + UInt64Aligned_t m; + m.l=0; + assert(sizeof(double)==8); + assert(sizeof(uint64)==8); + assert(sizeof(uint32)==4); + if (dir->tdir_count!=1) + err=TIFFReadDirEntryErrCount; + else if (dir->tdir_type!=TIFF_RATIONAL) + err=TIFFReadDirEntryErrType; + else + { + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 offset; + offset=*(uint32*)(&dir->tdir_offset); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&offset); + err=TIFFReadDirEntryData(tif,offset,8,m.i); + } + else + { + m.l=dir->tdir_offset.toff_long8; + err=TIFFReadDirEntryErrOk; + } + } + if (err==TIFFReadDirEntryErrOk) + { + double n; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(m.i,2); + if (m.i[0]==0) + n=0.0; + else if (m.i[0]==0xFFFFFFFF || m.i[1]==0) + /* + * XXX: Numerator 0xFFFFFFFF means that we have infinite + * distance. Indicate that with a negative floating point + * SubjectDistance value. + */ + n=-1.0; + else + n=(double)m.i[0]/(double)m.i[1]; + return(TIFFSetField(tif,dir->tdir_tag,n)); + } + else + { + TIFFReadDirEntryOutputErr(tif,err,module,"SubjectDistance",TRUE); + return(0); + } } -static void allocChoppedUpStripArrays(TIFF *tif, uint32_t nstrips, - uint64_t stripbytes, - uint32_t rowsperstrip) +static void allocChoppedUpStripArrays(TIFF* tif, uint32 nstrips, + uint64 stripbytes, uint32 rowsperstrip) { TIFFDirectory *td = &tif->tif_dir; - uint64_t bytecount; - uint64_t offset; - uint64_t last_offset; - uint64_t last_bytecount; - uint32_t i; - uint64_t *newcounts; - uint64_t *newoffsets; + uint64 bytecount; + uint64 offset; + uint64 last_offset; + uint64 last_bytecount; + uint32 i; + uint64 *newcounts; + uint64 *newoffsets; offset = TIFFGetStrileOffset(tif, 0); - last_offset = TIFFGetStrileOffset(tif, td->td_nstrips - 1); - last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips - 1); - if (last_offset > UINT64_MAX - last_bytecount || - last_offset + last_bytecount < offset) + last_offset = TIFFGetStrileOffset(tif, td->td_nstrips-1); + last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips-1); + if( last_offset > TIFF_UINT64_MAX - last_bytecount || + last_offset + last_bytecount < offset ) { return; } bytecount = last_offset + last_bytecount - offset; - 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) - { + newcounts = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), + "for chopped \"StripByteCounts\" array"); + newoffsets = (uint64*) _TIFFCheckMalloc(tif, nstrips, sizeof (uint64), + "for chopped \"StripOffsets\" array"); + if (newcounts == NULL || newoffsets == NULL) { /* - * Unable to allocate new strip information, give up and use - * the original one strip information. - */ + * Unable to allocate new strip information, give up and use + * the original one strip information. + */ if (newcounts != NULL) - _TIFFfreeExt(tif, newcounts); + _TIFFfree(newcounts); if (newoffsets != NULL) - _TIFFfreeExt(tif, newoffsets); + _TIFFfree(newoffsets); return; } @@ -7301,8 +5922,8 @@ static void allocChoppedUpStripArrays(TIFF *tif, uint32_t nstrips, td->td_stripsperimage = td->td_nstrips = nstrips; TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - _TIFFfreeExt(tif, td->td_stripbytecount_p); - _TIFFfreeExt(tif, td->td_stripoffset_p); + _TIFFfree(td->td_stripbytecount_p); + _TIFFfree(td->td_stripoffset_p); td->td_stripbytecount_p = newcounts; td->td_stripoffset_p = newoffsets; #ifdef STRIPBYTECOUNTSORTED_UNUSED @@ -7311,140 +5932,140 @@ static void allocChoppedUpStripArrays(TIFF *tif, uint32_t nstrips, tif->tif_flags |= TIFF_CHOPPEDUPARRAYS; } + /* * Replace a single strip (tile) of uncompressed data by multiple strips * (tiles), each approximately STRIP_SIZE_DEFAULT bytes. This is useful for * dealing with large images or for dealing with machines with a limited * amount memory. */ -static void ChopUpSingleUncompressedStrip(TIFF *tif) +static void +ChopUpSingleUncompressedStrip(TIFF* tif) { - register TIFFDirectory *td = &tif->tif_dir; - uint64_t bytecount; - uint64_t offset; - uint32_t rowblock; - uint64_t rowblockbytes; - uint64_t stripbytes; - uint32_t nstrips; - uint32_t rowsperstrip; + register TIFFDirectory *td = &tif->tif_dir; + uint64 bytecount; + uint64 offset; + uint32 rowblock; + uint64 rowblockbytes; + uint64 stripbytes; + uint32 nstrips; + uint32 rowsperstrip; - bytecount = TIFFGetStrileByteCount(tif, 0); - /* On a newly created file, just re-opened to be filled, we */ - /* don't want strip chop to trigger as it is going to cause issues */ - /* later ( StripOffsets and StripByteCounts improperly filled) . */ - if (bytecount == 0 && tif->tif_mode != O_RDONLY) - return; - offset = TIFFGetStrileByteCount(tif, 0); - assert(td->td_planarconfig == PLANARCONFIG_CONTIG); - if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif))) - rowblock = td->td_ycbcrsubsampling[1]; - else - rowblock = 1; - rowblockbytes = TIFFVTileSize64(tif, rowblock); - /* - * Make the rows hold at least one scanline, but fill specified amount - * of data if possible. - */ - if (rowblockbytes > STRIP_SIZE_DEFAULT) - { - stripbytes = rowblockbytes; - rowsperstrip = rowblock; - } - else if (rowblockbytes > 0) - { - uint32_t rowblocksperstrip; - rowblocksperstrip = (uint32_t)(STRIP_SIZE_DEFAULT / rowblockbytes); - rowsperstrip = rowblocksperstrip * rowblock; - stripbytes = rowblocksperstrip * rowblockbytes; - } - else - return; + bytecount = TIFFGetStrileByteCount(tif, 0); + /* On a newly created file, just re-opened to be filled, we */ + /* don't want strip chop to trigger as it is going to cause issues */ + /* later ( StripOffsets and StripByteCounts improperly filled) . */ + if( bytecount == 0 && tif->tif_mode != O_RDONLY ) + return; + offset = TIFFGetStrileByteCount(tif, 0); + assert(td->td_planarconfig == PLANARCONFIG_CONTIG); + if ((td->td_photometric == PHOTOMETRIC_YCBCR)&& + (!isUpSampled(tif))) + rowblock = td->td_ycbcrsubsampling[1]; + else + rowblock = 1; + rowblockbytes = TIFFVTileSize64(tif, rowblock); + /* + * Make the rows hold at least one scanline, but fill specified amount + * of data if possible. + */ + if (rowblockbytes > STRIP_SIZE_DEFAULT) { + stripbytes = rowblockbytes; + rowsperstrip = rowblock; + } else if (rowblockbytes > 0 ) { + uint32 rowblocksperstrip; + rowblocksperstrip = (uint32) (STRIP_SIZE_DEFAULT / rowblockbytes); + rowsperstrip = rowblocksperstrip * rowblock; + stripbytes = rowblocksperstrip * rowblockbytes; + } + else + return; - /* - * never increase the number of rows per strip - */ - if (rowsperstrip >= td->td_rowsperstrip) - return; - nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip); - if (nstrips == 0) - return; + /* + * never increase the number of rows per strip + */ + if (rowsperstrip >= td->td_rowsperstrip) + return; + nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip); + if( nstrips == 0 ) + return; - /* If we are going to allocate a lot of memory, make sure that the */ - /* file is as big as needed */ - if (tif->tif_mode == O_RDONLY && nstrips > 1000000 && - (offset >= TIFFGetFileSize(tif) || - stripbytes > (TIFFGetFileSize(tif) - offset) / (nstrips - 1))) - { - return; - } + /* If we are going to allocate a lot of memory, make sure that the */ + /* file is as big as needed */ + if( tif->tif_mode == O_RDONLY && + nstrips > 1000000 && + (offset >= TIFFGetFileSize(tif) || + stripbytes > (TIFFGetFileSize(tif) - offset) / (nstrips - 1)) ) + { + return; + } - allocChoppedUpStripArrays(tif, nstrips, stripbytes, rowsperstrip); + allocChoppedUpStripArrays(tif, nstrips, stripbytes, rowsperstrip); } + /* * Replace a file with contiguous strips > 2 GB of uncompressed data by * multiple smaller strips. This is useful for * dealing with large images or for dealing with machines with a limited * amount memory. */ -static void TryChopUpUncompressedBigTiff(TIFF *tif) +static void TryChopUpUncompressedBigTiff( TIFF* tif ) { TIFFDirectory *td = &tif->tif_dir; - uint32_t rowblock; - uint64_t rowblockbytes; - uint32_t i; - uint64_t stripsize; - uint32_t rowblocksperstrip; - uint32_t rowsperstrip; - uint64_t stripbytes; - uint32_t nstrips; + uint32 rowblock; + uint64 rowblockbytes; + uint32 i; + uint64 stripsize; + uint32 rowblocksperstrip; + uint32 rowsperstrip; + uint64 stripbytes; + uint32 nstrips; stripsize = TIFFStripSize64(tif); - assert(tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG); - assert(tif->tif_dir.td_compression == COMPRESSION_NONE); - assert((tif->tif_flags & (TIFF_STRIPCHOP | TIFF_ISTILED)) == - TIFF_STRIPCHOP); - assert(stripsize > 0x7FFFFFFFUL); + assert( tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG ); + assert( tif->tif_dir.td_compression == COMPRESSION_NONE ); + assert( (tif->tif_flags&(TIFF_STRIPCHOP|TIFF_ISTILED)) == TIFF_STRIPCHOP ); + assert( stripsize > 0x7FFFFFFFUL ); /* On a newly created file, just re-opened to be filled, we */ /* don't want strip chop to trigger as it is going to cause issues */ /* later ( StripOffsets and StripByteCounts improperly filled) . */ - if (TIFFGetStrileByteCount(tif, 0) == 0 && tif->tif_mode != O_RDONLY) + if( TIFFGetStrileByteCount(tif, 0) == 0 && tif->tif_mode != O_RDONLY ) return; - if ((td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif))) + if ((td->td_photometric == PHOTOMETRIC_YCBCR)&& + (!isUpSampled(tif))) rowblock = td->td_ycbcrsubsampling[1]; else rowblock = 1; rowblockbytes = TIFFVStripSize64(tif, rowblock); - if (rowblockbytes == 0 || rowblockbytes > 0x7FFFFFFFUL) + if( rowblockbytes == 0 || rowblockbytes > 0x7FFFFFFFUL ) { /* In case of file with gigantic width */ return; } /* Check that the strips are contiguous and of the expected size */ - for (i = 0; i < td->td_nstrips; i++) + for( i = 0; i < td->td_nstrips; i++ ) { - if (i == td->td_nstrips - 1) + if( i == td->td_nstrips - 1 ) { - if (TIFFGetStrileByteCount(tif, i) < - TIFFVStripSize64(tif, - td->td_imagelength - i * td->td_rowsperstrip)) + if( TIFFGetStrileByteCount(tif, i) < TIFFVStripSize64( + tif, td->td_imagelength - i * td->td_rowsperstrip ) ) { return; } } else { - if (TIFFGetStrileByteCount(tif, i) != stripsize) + if( TIFFGetStrileByteCount(tif, i) != stripsize ) { return; } - if (i > 0 && TIFFGetStrileOffset(tif, i) != - TIFFGetStrileOffset(tif, i - 1) + - TIFFGetStrileByteCount(tif, i - 1)) + if( i > 0 && TIFFGetStrileOffset(tif, i) != + TIFFGetStrileOffset(tif, i-1) + TIFFGetStrileByteCount(tif, i-1) ) { return; } @@ -7452,26 +6073,27 @@ static void TryChopUpUncompressedBigTiff(TIFF *tif) } /* Aim for 512 MB strips (that will still be manageable by 32 bit builds */ - rowblocksperstrip = (uint32_t)(512 * 1024 * 1024 / rowblockbytes); - if (rowblocksperstrip == 0) + rowblocksperstrip = (uint32) (512 * 1024 * 1024 / rowblockbytes); + if( rowblocksperstrip == 0 ) rowblocksperstrip = 1; rowsperstrip = rowblocksperstrip * rowblock; stripbytes = rowblocksperstrip * rowblockbytes; - assert(stripbytes <= 0x7FFFFFFFUL); + assert( stripbytes <= 0x7FFFFFFFUL ); nstrips = TIFFhowmany_32(td->td_imagelength, rowsperstrip); - if (nstrips == 0) + if( nstrips == 0 ) return; /* If we are going to allocate a lot of memory, make sure that the */ /* file is as big as needed */ - if (tif->tif_mode == O_RDONLY && nstrips > 1000000) + if( tif->tif_mode == O_RDONLY && + nstrips > 1000000 ) { - 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) + uint64 last_offset = TIFFGetStrileOffset(tif, td->td_nstrips-1); + uint64 filesize = TIFFGetFileSize(tif); + uint64 last_bytecount = TIFFGetStrileByteCount(tif, td->td_nstrips-1); + if( last_offset > filesize || + last_bytecount > filesize - last_offset ) { return; } @@ -7480,8 +6102,9 @@ static void TryChopUpUncompressedBigTiff(TIFF *tif) allocChoppedUpStripArrays(tif, nstrips, stripbytes, rowsperstrip); } + TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static uint64_t _TIFFUnsanitizedAddUInt64AndInt(uint64_t a, int b) +static uint64 _TIFFUnsanitizedAddUInt64AndInt(uint64 a, int b) { return a + b; } @@ -7490,8 +6113,9 @@ static uint64_t _TIFFUnsanitizedAddUInt64AndInt(uint64_t a, int b) * strip/tile of number strile. Also fetch the neighbouring values using a * 4096 byte page size. */ -static int _TIFFPartialReadStripArray(TIFF *tif, TIFFDirEntry *dirent, - int strile, uint64_t *panVals) +static +int _TIFFPartialReadStripArray( TIFF* tif, TIFFDirEntry* dirent, + int strile, uint64* panVals ) { static const char module[] = "_TIFFPartialReadStripArray"; #define IO_CACHE_PAGE_SIZE 4096 @@ -7499,88 +6123,89 @@ static int _TIFFPartialReadStripArray(TIFF *tif, TIFFDirEntry *dirent, size_t sizeofval; const int bSwab = (tif->tif_flags & TIFF_SWAB) != 0; int sizeofvalint; - uint64_t nBaseOffset; - uint64_t nOffset; - uint64_t nOffsetStartPage; - uint64_t nOffsetEndPage; + uint64 nBaseOffset; + uint64 nOffset; + uint64 nOffsetStartPage; + uint64 nOffsetEndPage; tmsize_t nToRead; tmsize_t nRead; - uint64_t nLastStripOffset; + uint64 nLastStripOffset; int iStartBefore; int i; - const uint32_t arraySize = tif->tif_dir.td_stripoffsetbyteallocsize; + const uint32 arraySize = tif->tif_dir.td_stripoffsetbyteallocsize; unsigned char buffer[2 * IO_CACHE_PAGE_SIZE]; - assert(dirent->tdir_count > 4); + assert( dirent->tdir_count > 4 ); - if (dirent->tdir_type == TIFF_SHORT) + if( dirent->tdir_type == TIFF_SHORT ) { - sizeofval = sizeof(uint16_t); + sizeofval = sizeof(uint16); } - else if (dirent->tdir_type == TIFF_LONG) + else if( dirent->tdir_type == TIFF_LONG ) { - sizeofval = sizeof(uint32_t); + sizeofval = sizeof(uint32); } - else if (dirent->tdir_type == TIFF_LONG8) + else if( dirent->tdir_type == TIFF_LONG8 ) { - sizeofval = sizeof(uint64_t); + sizeofval = sizeof(uint64); } - else if (dirent->tdir_type == TIFF_SLONG8) + 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_t); + sizeofval = sizeof(int64); } else { - TIFFErrorExtR(tif, module, - "Invalid type for [Strip|Tile][Offset/ByteCount] tag"); + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid type for [Strip|Tile][Offset/ByteCount] tag"); panVals[strile] = 0; return 0; } sizeofvalint = (int)(sizeofval); - if (tif->tif_flags & TIFF_BIGTIFF) + if( tif->tif_flags&TIFF_BIGTIFF ) { - uint64_t offset = dirent->tdir_offset.toff_long8; - if (bSwab) + uint64 offset = dirent->tdir_offset.toff_long8; + if( bSwab ) TIFFSwabLong8(&offset); nBaseOffset = offset; } else { - uint32_t offset = dirent->tdir_offset.toff_long; - if (bSwab) + uint32 offset = dirent->tdir_offset.toff_long; + if( bSwab ) TIFFSwabLong(&offset); nBaseOffset = offset; } /* To avoid later unsigned integer overflows */ - if (nBaseOffset > (uint64_t)INT64_MAX) + if( nBaseOffset > (uint64)TIFF_INT64_MAX ) { - TIFFErrorExtR(tif, module, "Cannot read offset/size for strile %d", - strile); + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot read offset/size for strile %d", strile); panVals[strile] = 0; return 0; } nOffset = nBaseOffset + sizeofval * strile; - nOffsetStartPage = (nOffset / IO_CACHE_PAGE_SIZE) * IO_CACHE_PAGE_SIZE; + nOffsetStartPage = + (nOffset / IO_CACHE_PAGE_SIZE) * IO_CACHE_PAGE_SIZE; nOffsetEndPage = nOffsetStartPage + IO_CACHE_PAGE_SIZE; - if (nOffset + sizeofval > nOffsetEndPage) + if( nOffset + sizeofval > nOffsetEndPage ) nOffsetEndPage += IO_CACHE_PAGE_SIZE; #undef IO_CACHE_PAGE_SIZE nLastStripOffset = nBaseOffset + arraySize * sizeofval; - if (nLastStripOffset < nOffsetEndPage) + if( nLastStripOffset < nOffsetEndPage ) nOffsetEndPage = nLastStripOffset; - if (nOffsetStartPage >= nOffsetEndPage) + if( nOffsetStartPage >= nOffsetEndPage ) { - TIFFErrorExtR(tif, module, "Cannot read offset/size for strile %d", - strile); + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot read offset/size for strile %d", strile); panVals[strile] = 0; return 0; } - if (!SeekOK(tif, nOffsetStartPage)) + if (!SeekOK(tif,nOffsetStartPage)) { panVals[strile] = 0; return 0; @@ -7588,160 +6213,159 @@ static int _TIFFPartialReadStripArray(TIFF *tif, TIFFDirEntry *dirent, nToRead = (tmsize_t)(nOffsetEndPage - nOffsetStartPage); nRead = TIFFReadFile(tif, buffer, nToRead); - if (nRead < nToRead) + if( nRead < nToRead ) { - TIFFErrorExtR(tif, module, - "Cannot read offset/size for strile around ~%d", strile); + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot read offset/size for strile around ~%d", strile); return 0; } iStartBefore = -(int)((nOffset - nOffsetStartPage) / sizeofval); - if (strile + iStartBefore < 0) + if( strile + iStartBefore < 0 ) iStartBefore = -strile; - for (i = iStartBefore; - (uint32_t)(strile + i) < arraySize && - _TIFFUnsanitizedAddUInt64AndInt(nOffset, (i + 1) * sizeofvalint) <= - nOffsetEndPage; - ++i) + for( i = iStartBefore; + (uint32)(strile + i) < arraySize && + _TIFFUnsanitizedAddUInt64AndInt(nOffset, (i + 1) * sizeofvalint) <= nOffsetEndPage; + ++i ) { - if (dirent->tdir_type == TIFF_SHORT) + if( dirent->tdir_type == TIFF_SHORT ) { - uint16_t val; + uint16 val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); - if (bSwab) + if( bSwab ) TIFFSwabShort(&val); panVals[strile + i] = val; } - else if (dirent->tdir_type == TIFF_LONG) + else if( dirent->tdir_type == TIFF_LONG ) { - uint32_t val; + uint32 val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); - if (bSwab) + if( bSwab ) TIFFSwabLong(&val); panVals[strile + i] = val; } - else if (dirent->tdir_type == TIFF_LONG8) + else if( dirent->tdir_type == TIFF_LONG8 ) { - uint64_t val; + uint64 val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); - if (bSwab) + if( bSwab ) TIFFSwabLong8(&val); panVals[strile + i] = val; } else /* if( dirent->tdir_type == TIFF_SLONG8 ) */ { /* Non conformant data type */ - int64_t val; + int64 val; memcpy(&val, buffer + (nOffset - nOffsetStartPage) + i * sizeofvalint, sizeof(val)); - if (bSwab) - TIFFSwabLong8((uint64_t *)&val); - panVals[strile + i] = (uint64_t)val; + if( bSwab ) + TIFFSwabLong8((uint64*) &val); + panVals[strile + i] = (uint64) val; } } return 1; } -static int _TIFFFetchStrileValue(TIFF *tif, uint32_t strile, - TIFFDirEntry *dirent, uint64_t **parray) +static int _TIFFFetchStrileValue(TIFF* tif, + uint32 strile, + TIFFDirEntry* dirent, + uint64** parray) { static const char module[] = "_TIFFFetchStrileValue"; TIFFDirectory *td = &tif->tif_dir; - if (strile >= dirent->tdir_count) + if( strile >= dirent->tdir_count ) { return 0; } - if (strile >= td->td_stripoffsetbyteallocsize) + if( strile >= td->td_stripoffsetbyteallocsize ) { - uint32_t nStripArrayAllocBefore = td->td_stripoffsetbyteallocsize; - uint32_t nStripArrayAllocNew; - uint64_t nArraySize64; + uint32 nStripArrayAllocBefore = td->td_stripoffsetbyteallocsize; + uint32 nStripArrayAllocNew; + uint64 nArraySize64; size_t nArraySize; - uint64_t *offsetArray; - uint64_t *bytecountArray; + uint64* offsetArray; + uint64* bytecountArray; - if (strile > 1000000) + if( strile > 1000000 ) { - uint64_t filesize = TIFFGetFileSize(tif); + uint64 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_t)) + if( strile > filesize / sizeof(uint32) ) { - TIFFErrorExtR(tif, module, "File too short"); + TIFFErrorExt(tif->tif_clientdata, module, "File too short"); return 0; } } - if (td->td_stripoffsetbyteallocsize == 0 && - td->td_nstrips < 1024 * 1024) + if( td->td_stripoffsetbyteallocsize == 0 && + td->td_nstrips < 1024 * 1024 ) { nStripArrayAllocNew = td->td_nstrips; } else { -#define TIFF_MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define TIFF_MIN(a, b) (((a) < (b)) ? (a) : (b)) - nStripArrayAllocNew = TIFF_MAX(strile + 1, 1024U * 512U); - if (nStripArrayAllocNew < 0xFFFFFFFFU / 2) +#define TIFF_MAX(a,b) (((a)>(b)) ? (a) : (b)) +#define TIFF_MIN(a,b) (((a)<(b)) ? (a) : (b)) + nStripArrayAllocNew = TIFF_MAX(strile + 1, 1024U * 512U ); + if( nStripArrayAllocNew < 0xFFFFFFFFU / 2 ) nStripArrayAllocNew *= 2; nStripArrayAllocNew = TIFF_MIN(nStripArrayAllocNew, td->td_nstrips); } - assert(strile < nStripArrayAllocNew); - nArraySize64 = (uint64_t)sizeof(uint64_t) * nStripArrayAllocNew; + assert( strile < nStripArrayAllocNew ); + nArraySize64 = (uint64)sizeof(uint64) * nStripArrayAllocNew; nArraySize = (size_t)(nArraySize64); #if SIZEOF_SIZE_T == 4 - if (nArraySize != nArraySize64) + if( nArraySize != nArraySize64 ) { - TIFFErrorExtR(tif, module, - "Cannot allocate strip offset and bytecount arrays"); + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate strip offset and bytecount arrays"); return 0; } #endif - offsetArray = (uint64_t *)(_TIFFreallocExt(tif, td->td_stripoffset_p, - nArraySize)); - bytecountArray = (uint64_t *)(_TIFFreallocExt( - tif, td->td_stripbytecount_p, nArraySize)); - if (offsetArray) + offsetArray = (uint64*)( + _TIFFrealloc( td->td_stripoffset_p, nArraySize ) ); + bytecountArray = (uint64*)( + _TIFFrealloc( td->td_stripbytecount_p, nArraySize ) ); + if( offsetArray ) td->td_stripoffset_p = offsetArray; - if (bytecountArray) + if( bytecountArray ) td->td_stripbytecount_p = bytecountArray; - if (offsetArray && bytecountArray) + if( offsetArray && bytecountArray ) { td->td_stripoffsetbyteallocsize = nStripArrayAllocNew; /* Initialize new entries to ~0 / -1 */ - /* coverity[overrun-buffer-arg] */ - memset(td->td_stripoffset_p + nStripArrayAllocBefore, 0xFF, - (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * - sizeof(uint64_t)); - /* coverity[overrun-buffer-arg] */ - memset(td->td_stripbytecount_p + nStripArrayAllocBefore, 0xFF, - (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * - sizeof(uint64_t)); + memset(td->td_stripoffset_p + nStripArrayAllocBefore, + 0xFF, + (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64) ); + memset(td->td_stripbytecount_p + nStripArrayAllocBefore, + 0xFF, + (td->td_stripoffsetbyteallocsize - nStripArrayAllocBefore) * sizeof(uint64) ); } else { - TIFFErrorExtR(tif, module, - "Cannot allocate strip offset and bytecount arrays"); - _TIFFfreeExt(tif, td->td_stripoffset_p); + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate strip offset and bytecount arrays"); + _TIFFfree(td->td_stripoffset_p); td->td_stripoffset_p = NULL; - _TIFFfreeExt(tif, td->td_stripbytecount_p); + _TIFFfree(td->td_stripbytecount_p); td->td_stripbytecount_p = NULL; td->td_stripoffsetbyteallocsize = 0; } } - if (*parray == NULL || strile >= td->td_stripoffsetbyteallocsize) + if( *parray == NULL || strile >= td->td_stripoffsetbyteallocsize ) return 0; - if (~((*parray)[strile]) == 0) + if( ~((*parray)[strile]) == 0 ) { - if (!_TIFFPartialReadStripArray(tif, dirent, strile, *parray)) + if( !_TIFFPartialReadStripArray( tif, dirent, strile, *parray ) ) { (*parray)[strile] = 0; return 0; @@ -7751,25 +6375,24 @@ static int _TIFFFetchStrileValue(TIFF *tif, uint32_t strile, return 1; } -static uint64_t _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32_t strile, - TIFFDirEntry *dirent, - uint64_t **parray, - int *pbErr) +static uint64 _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32 strile, + TIFFDirEntry* dirent, + uint64** parray, + int *pbErr) { TIFFDirectory *td = &tif->tif_dir; - if (pbErr) + if( pbErr ) *pbErr = 0; - if ((tif->tif_flags & TIFF_DEFERSTRILELOAD) && - !(tif->tif_flags & TIFF_CHOPPEDUPARRAYS)) + if( (tif->tif_flags&TIFF_DEFERSTRILELOAD) && !(tif->tif_flags&TIFF_CHOPPEDUPARRAYS) ) { - if (!(tif->tif_flags & TIFF_LAZYSTRILELOAD) || + if( !(tif->tif_flags&TIFF_LAZYSTRILELOAD) || /* If the values may fit in the toff_long/toff_long8 member */ /* then use _TIFFFillStriles to simplify _TIFFFetchStrileValue */ - dirent->tdir_count <= 4) + dirent->tdir_count <= 4 ) { - if (!_TIFFFillStriles(tif)) + if( !_TIFFFillStriles(tif) ) { - if (pbErr) + if( pbErr ) *pbErr = 1; /* Do not return, as we want this function to always */ /* return the same value if called several times with */ @@ -7778,74 +6401,73 @@ static uint64_t _TIFFGetStrileOffsetOrByteCountValue(TIFF *tif, uint32_t strile, } else { - if (!_TIFFFetchStrileValue(tif, strile, dirent, parray)) - { - if (pbErr) + if( !_TIFFFetchStrileValue(tif, strile, dirent, parray) ) + { + if( pbErr ) *pbErr = 1; - return 0; - } + return 0; + } } } - if (*parray == NULL || strile >= td->td_nstrips) + if( *parray == NULL || strile >= td->td_nstrips ) { - if (pbErr) + if( pbErr ) *pbErr = 1; return 0; } return (*parray)[strile]; } -/* Return the value of the TileOffsets/StripOffsets array for the specified - * tile/strile */ -uint64_t TIFFGetStrileOffset(TIFF *tif, uint32_t strile) +/* Return the value of the TileOffsets/StripOffsets array for the specified tile/strile */ +uint64 TIFFGetStrileOffset(TIFF *tif, uint32 strile) { return TIFFGetStrileOffsetWithErr(tif, strile, NULL); } -/* Return the value of the TileOffsets/StripOffsets array for the specified - * tile/strile */ -uint64_t TIFFGetStrileOffsetWithErr(TIFF *tif, uint32_t strile, int *pbErr) +/* Return the value of the TileOffsets/StripOffsets array for the specified tile/strile */ +uint64 TIFFGetStrileOffsetWithErr(TIFF *tif, uint32 strile, int *pbErr) { TIFFDirectory *td = &tif->tif_dir; return _TIFFGetStrileOffsetOrByteCountValue(tif, strile, - &(td->td_stripoffset_entry), - &(td->td_stripoffset_p), pbErr); + &(td->td_stripoffset_entry), + &(td->td_stripoffset_p), pbErr); } -/* Return the value of the TileByteCounts/StripByteCounts array for the - * specified tile/strile */ -uint64_t TIFFGetStrileByteCount(TIFF *tif, uint32_t strile) +/* Return the value of the TileByteCounts/StripByteCounts array for the specified tile/strile */ +uint64 TIFFGetStrileByteCount(TIFF *tif, uint32 strile) { return TIFFGetStrileByteCountWithErr(tif, strile, NULL); } -/* Return the value of the TileByteCounts/StripByteCounts array for the - * specified tile/strile */ -uint64_t TIFFGetStrileByteCountWithErr(TIFF *tif, uint32_t strile, int *pbErr) +/* Return the value of the TileByteCounts/StripByteCounts array for the specified tile/strile */ +uint64 TIFFGetStrileByteCountWithErr(TIFF *tif, uint32 strile, int *pbErr) { TIFFDirectory *td = &tif->tif_dir; - return _TIFFGetStrileOffsetOrByteCountValue( - tif, strile, &(td->td_stripbytecount_entry), &(td->td_stripbytecount_p), - pbErr); + return _TIFFGetStrileOffsetOrByteCountValue(tif, strile, + &(td->td_stripbytecount_entry), + &(td->td_stripbytecount_p), pbErr); } -int _TIFFFillStriles(TIFF *tif) { return _TIFFFillStrilesInternal(tif, 1); } -static int _TIFFFillStrilesInternal(TIFF *tif, int loadStripByteCount) +int _TIFFFillStriles( TIFF *tif ) +{ + return _TIFFFillStrilesInternal( tif, 1 ); +} + +static int _TIFFFillStrilesInternal( TIFF *tif, int loadStripByteCount ) { register TIFFDirectory *td = &tif->tif_dir; int return_value = 1; /* Do not do anything if TIFF_DEFERSTRILELOAD is not set */ - if (!(tif->tif_flags & TIFF_DEFERSTRILELOAD) || - (tif->tif_flags & TIFF_CHOPPEDUPARRAYS) != 0) + if( !(tif->tif_flags&TIFF_DEFERSTRILELOAD) || (tif->tif_flags&TIFF_CHOPPEDUPARRAYS) != 0 ) return 1; - if (tif->tif_flags & TIFF_LAZYSTRILELOAD) + if( tif->tif_flags&TIFF_LAZYSTRILELOAD ) { /* In case of lazy loading, reload completely the arrays */ - _TIFFfreeExt(tif, td->td_stripoffset_p); - _TIFFfreeExt(tif, td->td_stripbytecount_p); + _TIFFfree(td->td_stripoffset_p); + _TIFFfree(td->td_stripbytecount_p); td->td_stripoffset_p = NULL; td->td_stripbytecount_p = NULL; td->td_stripoffsetbyteallocsize = 0; @@ -7853,46 +6475,53 @@ static int _TIFFFillStrilesInternal(TIFF *tif, int loadStripByteCount) } /* If stripoffset array is already loaded, exit with success */ - if (td->td_stripoffset_p != NULL) - return 1; + if( td->td_stripoffset_p != NULL ) + return 1; /* If tdir_count was canceled, then we already got there, but in error */ - if (td->td_stripoffset_entry.tdir_count == 0) - return 0; + if( td->td_stripoffset_entry.tdir_count == 0 ) + return 0; - if (!TIFFFetchStripThing(tif, &(td->td_stripoffset_entry), td->td_nstrips, - &td->td_stripoffset_p)) + if (!TIFFFetchStripThing(tif,&(td->td_stripoffset_entry), + td->td_nstrips,&td->td_stripoffset_p)) { - return_value = 0; + return_value = 0; } if (loadStripByteCount && - !TIFFFetchStripThing(tif, &(td->td_stripbytecount_entry), - td->td_nstrips, &td->td_stripbytecount_p)) + !TIFFFetchStripThing(tif,&(td->td_stripbytecount_entry), + td->td_nstrips,&td->td_stripbytecount_p)) { - return_value = 0; + return_value = 0; } - _TIFFmemset(&(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry)); - _TIFFmemset(&(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry)); + _TIFFmemset( &(td->td_stripoffset_entry), 0, sizeof(TIFFDirEntry)); + _TIFFmemset( &(td->td_stripbytecount_entry), 0, sizeof(TIFFDirEntry)); #ifdef STRIPBYTECOUNTSORTED_UNUSED - if (tif->tif_dir.td_nstrips > 1 && return_value == 1) - { - uint32_t strip; + if (tif->tif_dir.td_nstrips > 1 && return_value == 1 ) { + uint32 strip; - tif->tif_dir.td_stripbytecountsorted = 1; - for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) - { - if (tif->tif_dir.td_stripoffset_p[strip - 1] > - tif->tif_dir.td_stripoffset_p[strip]) - { - tif->tif_dir.td_stripbytecountsorted = 0; - break; + tif->tif_dir.td_stripbytecountsorted = 1; + for (strip = 1; strip < tif->tif_dir.td_nstrips; strip++) { + if (tif->tif_dir.td_stripoffset_p[strip - 1] > + tif->tif_dir.td_stripoffset_p[strip]) { + tif->tif_dir.td_stripbytecountsorted = 0; + break; + } } - } } #endif return return_value; } + + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirwrite.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirwrite.c index d8844bbd8..8743a3e3b 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirwrite.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dirwrite.c @@ -28,203 +28,161 @@ * Directory Write Support Routines. */ #include "tiffiop.h" -#include /*--: for Rational2Double */ -#include /*--: for Rational2Double */ +#include /*--: for Rational2Double */ +#include /*--: for Rational2Double */ #ifdef HAVE_IEEEFP #define TIFFCvtNativeToIEEEFloat(tif, n, fp) #define TIFFCvtNativeToIEEEDouble(tif, n, dp) #else -extern void TIFFCvtNativeToIEEEFloat(TIFF *tif, uint32_t n, float *fp); -extern void TIFFCvtNativeToIEEEDouble(TIFF *tif, uint32_t n, double *dp); +extern void TIFFCvtNativeToIEEEFloat(TIFF* tif, uint32 n, float* fp); +extern void TIFFCvtNativeToIEEEDouble(TIFF* tif, uint32 n, double* dp); #endif -static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, - uint64_t *pdiroff); +static int TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff); -static int TIFFWriteDirectoryTagSampleformatArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - double *value); +static int TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); +#if 0 +static int TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +#endif -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); -static int TIFFWriteDirectoryTagByteArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint8_t *value); -static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, int8_t *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); -static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, int16_t *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); -static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, int32_t *value); -static int TIFFWriteDirectoryTagLong8Array(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint64_t *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); -static int TIFFWriteDirectoryTagFloatArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, float *value); -static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, double *value); -static int TIFFWriteDirectoryTagIfdArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint32_t *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); -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 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); +#ifdef notdef +static int TIFFWriteDirectoryTagByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +#endif +static int TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +#if 0 +static int TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +#endif +#ifdef notdef +static int TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value); +#endif +static int TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value); +#if 0 +static int TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 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); +#ifdef notdef +static int TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value); +#endif +static int TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value); +#if 0 +static int TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 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); +#if 0 +static int TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value); +#endif +#ifdef notdef +static int TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +#endif +static int TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); +#if 0 +static int TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +#endif +#ifdef notdef +static int TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); +#endif +static int TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +#ifdef notdef +static int TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 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); +#ifdef notdef +static int TIFFWriteDirectoryTagFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +#endif +static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +#if 0 +static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +#endif +#ifdef notdef +static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +#endif +static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value); +#if 0 +static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value); +#endif +static int TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value); +#ifdef notdef +static int TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* 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); +#ifdef notdef +static int TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* 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 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); -static int TIFFWriteDirectoryTagCheckedByteArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - uint8_t *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); -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); -static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - int32_t *value); -static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - uint64_t *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); +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); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedByte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value); +#endif +static int TIFFWriteDirectoryTagCheckedByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 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); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 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); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value); +#endif +static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value); +#endif +static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 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); -/*--: Rational2Double: New functions to support true double-precision for custom - * rational tag types. */ -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); +/*--: 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); +#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 -static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - float *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); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value); +#endif +static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value); +#ifdef notdef +static int TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 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 TIFFWriteDirectoryTagData(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint16_t datatype, uint32_t count, - uint32_t datalength, void *data); +static int TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void* data); -static int TIFFLinkDirectory(TIFF *); +static int TIFFLinkDirectory(TIFF*); /* * Write the contents of the current directory @@ -232,9 +190,10 @@ static int TIFFLinkDirectory(TIFF *); * handle overwriting a directory with auxiliary * storage that's been changed. */ -int TIFFWriteDirectory(TIFF *tif) +int +TIFFWriteDirectory(TIFF* tif) { - return TIFFWriteDirectorySec(tif, TRUE, TRUE, NULL); + return TIFFWriteDirectorySec(tif,TRUE,TRUE,NULL); } /* @@ -262,17 +221,19 @@ int TIFFWriteDirectory(TIFF *tif) * * Returns 1 in case of success, 0 otherwise. */ -int TIFFDeferStrileArrayWriting(TIFF *tif) +int TIFFDeferStrileArrayWriting(TIFF* tif) { static const char module[] = "TIFFDeferStrileArrayWriting"; if (tif->tif_mode == O_RDONLY) { - TIFFErrorExtR(tif, tif->tif_name, "File opened in read-only mode"); + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "File opened in read-only mode"); return 0; } - if (tif->tif_diroff != 0) + if( tif->tif_diroff != 0 ) { - TIFFErrorExtR(tif, module, "Directory has already been written"); + TIFFErrorExt(tif->tif_clientdata, module, + "Directory has already been written"); return 0; } @@ -286,430 +247,359 @@ int TIFFDeferStrileArrayWriting(TIFF *tif) * written again. This will make a partially written TIFF file * readable before it is successfully completed/closed. */ -int TIFFCheckpointDirectory(TIFF *tif) +int +TIFFCheckpointDirectory(TIFF* tif) { - int rc; - /* Setup the strips arrays, if they haven't already been. */ - if (tif->tif_dir.td_stripoffset_p == NULL) - (void)TIFFSetupStrips(tif); - rc = TIFFWriteDirectorySec(tif, TRUE, FALSE, NULL); - (void)TIFFSetWriteOffset(tif, TIFFSeekFile(tif, 0, SEEK_END)); - return rc; + int rc; + /* Setup the strips arrays, if they haven't already been. */ + if (tif->tif_dir.td_stripoffset_p == NULL) + (void) TIFFSetupStrips(tif); + rc = TIFFWriteDirectorySec(tif,TRUE,FALSE,NULL); + (void) TIFFSetWriteOffset(tif, TIFFSeekFile(tif, 0, SEEK_END)); + return rc; } -int TIFFWriteCustomDirectory(TIFF *tif, uint64_t *pdiroff) +int +TIFFWriteCustomDirectory(TIFF* tif, uint64* pdiroff) { - return TIFFWriteDirectorySec(tif, FALSE, FALSE, pdiroff); + return TIFFWriteDirectorySec(tif,FALSE,FALSE,pdiroff); } /* * Similar to TIFFWriteDirectory(), but if the directory has already * been written once, it is relocated to the end of the file, in case it * has changed in size. Note that this will result in the loss of the - * previously used directory space. - */ -int TIFFRewriteDirectory(TIFF *tif) + * previously used directory space. + */ +int +TIFFRewriteDirectory( TIFF *tif ) { - static const char module[] = "TIFFRewriteDirectory"; + static const char module[] = "TIFFRewriteDirectory"; - /* We don't need to do anything special if it hasn't been written. */ - if (tif->tif_diroff == 0) - return TIFFWriteDirectory(tif); + /* We don't need to do anything special if it hasn't been written. */ + if( tif->tif_diroff == 0 ) + return TIFFWriteDirectory( tif ); - /* - * Find and zero the pointer to this directory, so that TIFFLinkDirectory - * will cause it to be added after this directories current pre-link. - */ - uint64_t torewritediroff = tif->tif_diroff; + /* + * Find and zero the pointer to this directory, so that TIFFLinkDirectory + * will cause it to be added after this directories current pre-link. + */ - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - if (tif->tif_header.classic.tiff_diroff == tif->tif_diroff) - { - tif->tif_header.classic.tiff_diroff = 0; - tif->tif_diroff = 0; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + if (tif->tif_header.classic.tiff_diroff == tif->tif_diroff) + { + tif->tif_header.classic.tiff_diroff = 0; + tif->tif_diroff = 0; - TIFFSeekFile(tif, 4, SEEK_SET); - if (!WriteOK(tif, &(tif->tif_header.classic.tiff_diroff), 4)) - { - TIFFErrorExtR(tif, tif->tif_name, "Error updating TIFF header"); - return (0); - } - } - else if (tif->tif_diroff > 0xFFFFFFFFU) - { - TIFFErrorExtR(tif, module, - "tif->tif_diroff exceeds 32 bit range allowed for " - "Classic TIFF"); - return (0); - } - else - { - uint32_t nextdir; - nextdir = tif->tif_header.classic.tiff_diroff; - while (1) - { - uint16_t dircount; - uint32_t nextnextdir; + TIFFSeekFile(tif,4,SEEK_SET); + if (!WriteOK(tif, &(tif->tif_header.classic.tiff_diroff),4)) + { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Error updating TIFF header"); + return (0); + } + } + else + { + uint32 nextdir; + nextdir = tif->tif_header.classic.tiff_diroff; + while(1) { + uint16 dircount; + uint32 nextnextdir; - if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, 2)) - { - TIFFErrorExtR(tif, module, - "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - (void)TIFFSeekFile(tif, nextdir + 2 + dircount * 12, SEEK_SET); - if (!ReadOK(tif, &nextnextdir, 4)) - { - TIFFErrorExtR(tif, module, "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextnextdir); - if (nextnextdir == tif->tif_diroff) - { - uint32_t m; - m = 0; - (void)TIFFSeekFile(tif, nextdir + 2 + dircount * 12, - SEEK_SET); - if (!WriteOK(tif, &m, 4)) - { - TIFFErrorExtR(tif, module, - "Error writing directory link"); - return (0); - } - tif->tif_diroff = 0; - /* Force a full-traversal to reach the zeroed pointer */ - tif->tif_lastdiroff = 0; - break; - } - nextdir = nextnextdir; - } - } - /* Remove skipped offset from IFD loop directory list. */ - _TIFFRemoveEntryFromDirectoryListByOffset(tif, torewritediroff); - } - else - { - if (tif->tif_header.big.tiff_diroff == tif->tif_diroff) - { - tif->tif_header.big.tiff_diroff = 0; - tif->tif_diroff = 0; + if (!SeekOK(tif, nextdir) || + !ReadOK(tif, &dircount, 2)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + (void) TIFFSeekFile(tif, + nextdir+2+dircount*12, SEEK_SET); + if (!ReadOK(tif, &nextnextdir, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory link"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextnextdir); + if (nextnextdir==tif->tif_diroff) + { + uint32 m; + m=0; + (void) TIFFSeekFile(tif, + nextdir+2+dircount*12, SEEK_SET); + if (!WriteOK(tif, &m, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + tif->tif_diroff=0; + break; + } + nextdir=nextnextdir; + } + } + } + else + { + if (tif->tif_header.big.tiff_diroff == tif->tif_diroff) + { + tif->tif_header.big.tiff_diroff = 0; + tif->tif_diroff = 0; - TIFFSeekFile(tif, 8, SEEK_SET); - if (!WriteOK(tif, &(tif->tif_header.big.tiff_diroff), 8)) - { - TIFFErrorExtR(tif, tif->tif_name, "Error updating TIFF header"); - return (0); - } - } - else - { - uint64_t nextdir; - nextdir = tif->tif_header.big.tiff_diroff; - while (1) - { - uint64_t dircount64; - uint16_t dircount; - uint64_t nextnextdir; + TIFFSeekFile(tif,8,SEEK_SET); + if (!WriteOK(tif, &(tif->tif_header.big.tiff_diroff),8)) + { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Error updating TIFF header"); + return (0); + } + } + else + { + uint64 nextdir; + nextdir = tif->tif_header.big.tiff_diroff; + while(1) { + uint64 dircount64; + uint16 dircount; + uint64 nextnextdir; - if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount64, 8)) - { - TIFFErrorExtR(tif, module, - "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&dircount64); - if (dircount64 > 0xFFFF) - { - TIFFErrorExtR(tif, module, - "Sanity check on tag count failed, likely " - "corrupt TIFF"); - return (0); - } - dircount = (uint16_t)dircount64; - (void)TIFFSeekFile(tif, nextdir + 8 + dircount * 20, SEEK_SET); - if (!ReadOK(tif, &nextnextdir, 8)) - { - TIFFErrorExtR(tif, module, "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&nextnextdir); - if (nextnextdir == tif->tif_diroff) - { - uint64_t m; - m = 0; - (void)TIFFSeekFile(tif, nextdir + 8 + dircount * 20, - SEEK_SET); - if (!WriteOK(tif, &m, 8)) - { - TIFFErrorExtR(tif, module, - "Error writing directory link"); - return (0); - } - tif->tif_diroff = 0; - /* Force a full-traversal to reach the zeroed pointer */ - tif->tif_lastdiroff = 0; - break; - } - nextdir = nextnextdir; - } - } - /* Remove skipped offset from IFD loop directory list. */ - _TIFFRemoveEntryFromDirectoryListByOffset(tif, torewritediroff); - } + if (!SeekOK(tif, nextdir) || + !ReadOK(tif, &dircount64, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFFULL) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on tag count failed, likely corrupt TIFF"); + return (0); + } + dircount=(uint16)dircount64; + (void) TIFFSeekFile(tif, + nextdir+8+dircount*20, SEEK_SET); + if (!ReadOK(tif, &nextnextdir, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory link"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&nextnextdir); + if (nextnextdir==tif->tif_diroff) + { + uint64 m; + m=0; + (void) TIFFSeekFile(tif, + nextdir+8+dircount*20, SEEK_SET); + if (!WriteOK(tif, &m, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + tif->tif_diroff=0; + break; + } + nextdir=nextnextdir; + } + } + } - /* - * Now use TIFFWriteDirectory() normally. - */ + /* + * Now use TIFFWriteDirectory() normally. + */ - return TIFFWriteDirectory(tif); + return TIFFWriteDirectory( tif ); } -static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, - uint64_t *pdiroff) +static int +TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64* pdiroff) { - static const char module[] = "TIFFWriteDirectorySec"; - uint32_t ndir; - TIFFDirEntry *dir; - uint32_t dirsize; - void *dirmem; - uint32_t m; - if (tif->tif_mode == O_RDONLY) - return (1); + static const char module[] = "TIFFWriteDirectorySec"; + uint32 ndir; + TIFFDirEntry* dir; + uint32 dirsize; + void* dirmem; + uint32 m; + if (tif->tif_mode == O_RDONLY) + return (1); - _TIFFFillStriles(tif); - - /* - * Clear write state so that subsequent images with - * different characteristics get the right buffers - * setup for them. - */ - if (imagedone) - { - if (tif->tif_flags & TIFF_POSTENCODE) - { - tif->tif_flags &= ~TIFF_POSTENCODE; - if (!(*tif->tif_postencode)(tif)) - { - TIFFErrorExtR(tif, module, - "Error post-encoding before directory write"); - return (0); - } - } - (*tif->tif_close)(tif); /* shutdown encoder */ - /* - * Flush any data that might have been written - * by the compression close+cleanup routines. But - * be careful not to write stuff if we didn't add data - * in the previous steps as the "rawcc" data may well be - * a previously read tile/strip in mixed read/write mode. - */ - if (tif->tif_rawcc > 0 && (tif->tif_flags & TIFF_BEENWRITING) != 0) - { - if (!TIFFFlushData1(tif)) - { - TIFFErrorExtR(tif, module, - "Error flushing data before directory write"); - return (0); - } - } - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - { - _TIFFfreeExt(tif, tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawcc = 0; - tif->tif_rawdatasize = 0; - tif->tif_rawdataoff = 0; - tif->tif_rawdataloaded = 0; - } - tif->tif_flags &= ~(TIFF_BEENWRITING | TIFF_BUFFERSETUP); - } - - if (TIFFFieldSet(tif, FIELD_COMPRESSION) && - (tif->tif_dir.td_compression == COMPRESSION_DEFLATE)) - { - TIFFWarningExtR(tif, module, - "Creating TIFF with legacy Deflate codec identifier, " - "COMPRESSION_ADOBE_DEFLATE is more widely supported"); - } - dir = NULL; - dirmem = NULL; - dirsize = 0; - while (1) - { - ndir = 0; - if (isimage) - { - if (TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) - { - if (!TIFFWriteDirectoryTagShortLong(tif, &ndir, dir, - TIFFTAG_IMAGEWIDTH, - tif->tif_dir.td_imagewidth)) - goto bad; - if (!TIFFWriteDirectoryTagShortLong( - tif, &ndir, dir, TIFFTAG_IMAGELENGTH, - tif->tif_dir.td_imagelength)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) - { - if (!TIFFWriteDirectoryTagShortLong(tif, &ndir, dir, - TIFFTAG_TILEWIDTH, - tif->tif_dir.td_tilewidth)) - goto bad; - if (!TIFFWriteDirectoryTagShortLong(tif, &ndir, dir, - TIFFTAG_TILELENGTH, - tif->tif_dir.td_tilelength)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_RESOLUTION)) - { - if (!TIFFWriteDirectoryTagRational(tif, &ndir, dir, - TIFFTAG_XRESOLUTION, - tif->tif_dir.td_xresolution)) - goto bad; - if (!TIFFWriteDirectoryTagRational(tif, &ndir, dir, - TIFFTAG_YRESOLUTION, - tif->tif_dir.td_yresolution)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_POSITION)) - { - if (!TIFFWriteDirectoryTagRational(tif, &ndir, dir, - TIFFTAG_XPOSITION, - tif->tif_dir.td_xposition)) - goto bad; - if (!TIFFWriteDirectoryTagRational(tif, &ndir, dir, - TIFFTAG_YPOSITION, - tif->tif_dir.td_yposition)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_SUBFILETYPE)) - { - if (!TIFFWriteDirectoryTagLong(tif, &ndir, dir, - TIFFTAG_SUBFILETYPE, - tif->tif_dir.td_subfiletype)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_BITSPERSAMPLE)) - { - if (!TIFFWriteDirectoryTagShortPerSample( - tif, &ndir, dir, TIFFTAG_BITSPERSAMPLE, - tif->tif_dir.td_bitspersample)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_COMPRESSION)) - { - if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, - TIFFTAG_COMPRESSION, - tif->tif_dir.td_compression)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_PHOTOMETRIC)) - { - if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, - TIFFTAG_PHOTOMETRIC, - tif->tif_dir.td_photometric)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_THRESHHOLDING)) - { - if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, - TIFFTAG_THRESHHOLDING, - tif->tif_dir.td_threshholding)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_FILLORDER)) - { - if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, - TIFFTAG_FILLORDER, - tif->tif_dir.td_fillorder)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_ORIENTATION)) - { - if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, - TIFFTAG_ORIENTATION, - tif->tif_dir.td_orientation)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL)) - { - if (!TIFFWriteDirectoryTagShort( - tif, &ndir, dir, TIFFTAG_SAMPLESPERPIXEL, - tif->tif_dir.td_samplesperpixel)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) - { - if (!TIFFWriteDirectoryTagShortLong( - tif, &ndir, dir, TIFFTAG_ROWSPERSTRIP, - tif->tif_dir.td_rowsperstrip)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_MINSAMPLEVALUE)) - { - if (!TIFFWriteDirectoryTagShortPerSample( - tif, &ndir, dir, TIFFTAG_MINSAMPLEVALUE, - tif->tif_dir.td_minsamplevalue)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_MAXSAMPLEVALUE)) - { - if (!TIFFWriteDirectoryTagShortPerSample( - tif, &ndir, dir, TIFFTAG_MAXSAMPLEVALUE, - tif->tif_dir.td_maxsamplevalue)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_PLANARCONFIG)) - { - if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, - TIFFTAG_PLANARCONFIG, - tif->tif_dir.td_planarconfig)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_RESOLUTIONUNIT)) - { - if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, - TIFFTAG_RESOLUTIONUNIT, - tif->tif_dir.td_resolutionunit)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_PAGENUMBER)) - { - if (!TIFFWriteDirectoryTagShortArray( - tif, &ndir, dir, TIFFTAG_PAGENUMBER, 2, - &tif->tif_dir.td_pagenumber[0])) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_STRIPBYTECOUNTS)) - { - if (!isTiled(tif)) - { - if (!TIFFWriteDirectoryTagLongLong8Array( - tif, &ndir, dir, TIFFTAG_STRIPBYTECOUNTS, - tif->tif_dir.td_nstrips, - tif->tif_dir.td_stripbytecount_p)) - goto bad; - } - else - { - if (!TIFFWriteDirectoryTagLongLong8Array( - tif, &ndir, dir, TIFFTAG_TILEBYTECOUNTS, - tif->tif_dir.td_nstrips, - tif->tif_dir.td_stripbytecount_p)) - goto bad; - } - } - if (TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) - { - if (!isTiled(tif)) - { + _TIFFFillStriles( tif ); + + /* + * Clear write state so that subsequent images with + * different characteristics get the right buffers + * setup for them. + */ + if (imagedone) + { + if (tif->tif_flags & TIFF_POSTENCODE) + { + tif->tif_flags &= ~TIFF_POSTENCODE; + if (!(*tif->tif_postencode)(tif)) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Error post-encoding before directory write"); + return (0); + } + } + (*tif->tif_close)(tif); /* shutdown encoder */ + /* + * Flush any data that might have been written + * by the compression close+cleanup routines. But + * be careful not to write stuff if we didn't add data + * in the previous steps as the "rawcc" data may well be + * a previously read tile/strip in mixed read/write mode. + */ + if (tif->tif_rawcc > 0 + && (tif->tif_flags & TIFF_BEENWRITING) != 0 ) + { + if( !TIFFFlushData1(tif) ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Error flushing data before directory write"); + return (0); + } + } + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) + { + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawcc = 0; + tif->tif_rawdatasize = 0; + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = 0; + } + tif->tif_flags &= ~(TIFF_BEENWRITING|TIFF_BUFFERSETUP); + } + dir=NULL; + dirmem=NULL; + dirsize=0; + while (1) + { + ndir=0; + if (isimage) + { + if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) + { + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_IMAGEWIDTH,tif->tif_dir.td_imagewidth)) + goto bad; + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_IMAGELENGTH,tif->tif_dir.td_imagelength)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) + { + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_TILEWIDTH,tif->tif_dir.td_tilewidth)) + goto bad; + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_TILELENGTH,tif->tif_dir.td_tilelength)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_RESOLUTION)) + { + if (!TIFFWriteDirectoryTagRational(tif,&ndir,dir,TIFFTAG_XRESOLUTION,tif->tif_dir.td_xresolution)) + goto bad; + if (!TIFFWriteDirectoryTagRational(tif,&ndir,dir,TIFFTAG_YRESOLUTION,tif->tif_dir.td_yresolution)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_POSITION)) + { + if (!TIFFWriteDirectoryTagRational(tif,&ndir,dir,TIFFTAG_XPOSITION,tif->tif_dir.td_xposition)) + goto bad; + if (!TIFFWriteDirectoryTagRational(tif,&ndir,dir,TIFFTAG_YPOSITION,tif->tif_dir.td_yposition)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) + { + if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,TIFFTAG_SUBFILETYPE,tif->tif_dir.td_subfiletype)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE)) + { + if (!TIFFWriteDirectoryTagShortPerSample(tif,&ndir,dir,TIFFTAG_BITSPERSAMPLE,tif->tif_dir.td_bitspersample)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_COMPRESSION)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_COMPRESSION,tif->tif_dir.td_compression)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_PHOTOMETRIC,tif->tif_dir.td_photometric)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_THRESHHOLDING,tif->tif_dir.td_threshholding)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_FILLORDER)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_FILLORDER,tif->tif_dir.td_fillorder)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_ORIENTATION)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_ORIENTATION,tif->tif_dir.td_orientation)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_SAMPLESPERPIXEL,tif->tif_dir.td_samplesperpixel)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) + { + if (!TIFFWriteDirectoryTagShortLong(tif,&ndir,dir,TIFFTAG_ROWSPERSTRIP,tif->tif_dir.td_rowsperstrip)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) + { + if (!TIFFWriteDirectoryTagShortPerSample(tif,&ndir,dir,TIFFTAG_MINSAMPLEVALUE,tif->tif_dir.td_minsamplevalue)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) + { + if (!TIFFWriteDirectoryTagShortPerSample(tif,&ndir,dir,TIFFTAG_MAXSAMPLEVALUE,tif->tif_dir.td_maxsamplevalue)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_PLANARCONFIG,tif->tif_dir.td_planarconfig)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_RESOLUTIONUNIT,tif->tif_dir.td_resolutionunit)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) + { + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_PAGENUMBER,2,&tif->tif_dir.td_pagenumber[0])) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_STRIPBYTECOUNTS)) + { + if (!isTiled(tif)) + { + if (!TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_STRIPBYTECOUNTS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripbytecount_p)) + goto bad; + } + else + { + if (!TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_TILEBYTECOUNTS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripbytecount_p)) + goto bad; + } + } + if (TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) + { + if (!isTiled(tif)) + { /* td_stripoffset_p might be NULL in an odd OJPEG case. See * tif_dirread.c around line 3634. * XXX: OJPEG hack. @@ -720,1108 +610,1179 @@ static int TIFFWriteDirectorySec(TIFF *tif, int isimage, int imagedone, * JpegInterchangeFormat stream. * We can get here when using tiffset on such a file. * See http://bugzilla.maptools.org/show_bug.cgi?id=2500 - */ + */ if (tif->tif_dir.td_stripoffset_p != NULL && - !TIFFWriteDirectoryTagLongLong8Array( - tif, &ndir, dir, TIFFTAG_STRIPOFFSETS, - tif->tif_dir.td_nstrips, - tif->tif_dir.td_stripoffset_p)) + !TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_STRIPOFFSETS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripoffset_p)) goto bad; - } - else - { - if (!TIFFWriteDirectoryTagLongLong8Array( - tif, &ndir, dir, TIFFTAG_TILEOFFSETS, - tif->tif_dir.td_nstrips, - tif->tif_dir.td_stripoffset_p)) - goto bad; - } - } - if (TIFFFieldSet(tif, FIELD_COLORMAP)) - { - if (!TIFFWriteDirectoryTagColormap(tif, &ndir, dir)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_EXTRASAMPLES)) - { - if (tif->tif_dir.td_extrasamples) - { - uint16_t na; - uint16_t *nb; - TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &na, &nb); - if (!TIFFWriteDirectoryTagShortArray( - tif, &ndir, dir, TIFFTAG_EXTRASAMPLES, na, nb)) - goto bad; - } - } - if (TIFFFieldSet(tif, FIELD_SAMPLEFORMAT)) - { - if (!TIFFWriteDirectoryTagShortPerSample( - tif, &ndir, dir, TIFFTAG_SAMPLEFORMAT, - tif->tif_dir.td_sampleformat)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_SMINSAMPLEVALUE)) - { - if (!TIFFWriteDirectoryTagSampleformatArray( - tif, &ndir, dir, TIFFTAG_SMINSAMPLEVALUE, - tif->tif_dir.td_samplesperpixel, - tif->tif_dir.td_sminsamplevalue)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_SMAXSAMPLEVALUE)) - { - if (!TIFFWriteDirectoryTagSampleformatArray( - tif, &ndir, dir, TIFFTAG_SMAXSAMPLEVALUE, - tif->tif_dir.td_samplesperpixel, - tif->tif_dir.td_smaxsamplevalue)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_IMAGEDEPTH)) - { - if (!TIFFWriteDirectoryTagLong(tif, &ndir, dir, - TIFFTAG_IMAGEDEPTH, - tif->tif_dir.td_imagedepth)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_TILEDEPTH)) - { - if (!TIFFWriteDirectoryTagLong(tif, &ndir, dir, - TIFFTAG_TILEDEPTH, - tif->tif_dir.td_tiledepth)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_HALFTONEHINTS)) - { - if (!TIFFWriteDirectoryTagShortArray( - tif, &ndir, dir, TIFFTAG_HALFTONEHINTS, 2, - &tif->tif_dir.td_halftonehints[0])) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_YCBCRSUBSAMPLING)) - { - if (!TIFFWriteDirectoryTagShortArray( - tif, &ndir, dir, TIFFTAG_YCBCRSUBSAMPLING, 2, - &tif->tif_dir.td_ycbcrsubsampling[0])) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_YCBCRPOSITIONING)) - { - if (!TIFFWriteDirectoryTagShort( - tif, &ndir, dir, TIFFTAG_YCBCRPOSITIONING, - tif->tif_dir.td_ycbcrpositioning)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_REFBLACKWHITE)) - { - if (!TIFFWriteDirectoryTagRationalArray( - tif, &ndir, dir, TIFFTAG_REFERENCEBLACKWHITE, 6, - tif->tif_dir.td_refblackwhite)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_TRANSFERFUNCTION)) - { - if (!TIFFWriteDirectoryTagTransferfunction(tif, &ndir, dir)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_INKNAMES)) - { - if (!TIFFWriteDirectoryTagAscii( - tif, &ndir, dir, TIFFTAG_INKNAMES, - tif->tif_dir.td_inknameslen, tif->tif_dir.td_inknames)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS)) - { - if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, - TIFFTAG_NUMBEROFINKS, - tif->tif_dir.td_numberofinks)) - goto bad; - } - if (TIFFFieldSet(tif, FIELD_SUBIFD)) - { - if (!TIFFWriteDirectoryTagSubifd(tif, &ndir, dir)) - goto bad; - } - { - uint32_t n; - for (n = 0; n < tif->tif_nfields; n++) - { - const TIFFField *o; - o = tif->tif_fields[n]; - if ((o->field_bit >= FIELD_CODEC) && - (TIFFFieldSet(tif, o->field_bit))) - { - switch (o->get_field_type) - { - case TIFF_SETGET_ASCII: - { - 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_t)(strlen(pb)); - if (!TIFFWriteDirectoryTagAscii( - tif, &ndir, dir, (uint16_t)o->field_tag, - pa, pb)) + } + else + { + if (!TIFFWriteDirectoryTagLongLong8Array(tif,&ndir,dir,TIFFTAG_TILEOFFSETS,tif->tif_dir.td_nstrips,tif->tif_dir.td_stripoffset_p)) + goto bad; + } + } + if (TIFFFieldSet(tif,FIELD_COLORMAP)) + { + if (!TIFFWriteDirectoryTagColormap(tif,&ndir,dir)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES)) + { + if (tif->tif_dir.td_extrasamples) + { + uint16 na; + uint16* nb; + TIFFGetFieldDefaulted(tif,TIFFTAG_EXTRASAMPLES,&na,&nb); + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_EXTRASAMPLES,na,nb)) + goto bad; + } + } + if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) + { + if (!TIFFWriteDirectoryTagShortPerSample(tif,&ndir,dir,TIFFTAG_SAMPLEFORMAT,tif->tif_dir.td_sampleformat)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) + { + if (!TIFFWriteDirectoryTagSampleformatArray(tif,&ndir,dir,TIFFTAG_SMINSAMPLEVALUE,tif->tif_dir.td_samplesperpixel,tif->tif_dir.td_sminsamplevalue)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) + { + if (!TIFFWriteDirectoryTagSampleformatArray(tif,&ndir,dir,TIFFTAG_SMAXSAMPLEVALUE,tif->tif_dir.td_samplesperpixel,tif->tif_dir.td_smaxsamplevalue)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) + { + if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,TIFFTAG_IMAGEDEPTH,tif->tif_dir.td_imagedepth)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) + { + if (!TIFFWriteDirectoryTagLong(tif,&ndir,dir,TIFFTAG_TILEDEPTH,tif->tif_dir.td_tiledepth)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) + { + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_HALFTONEHINTS,2,&tif->tif_dir.td_halftonehints[0])) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) + { + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,TIFFTAG_YCBCRSUBSAMPLING,2,&tif->tif_dir.td_ycbcrsubsampling[0])) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) + { + if (!TIFFWriteDirectoryTagShort(tif,&ndir,dir,TIFFTAG_YCBCRPOSITIONING,tif->tif_dir.td_ycbcrpositioning)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) + { + if (!TIFFWriteDirectoryTagRationalArray(tif,&ndir,dir,TIFFTAG_REFERENCEBLACKWHITE,6,tif->tif_dir.td_refblackwhite)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) + { + if (!TIFFWriteDirectoryTagTransferfunction(tif,&ndir,dir)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_INKNAMES)) + { + if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,TIFFTAG_INKNAMES,tif->tif_dir.td_inknameslen,tif->tif_dir.td_inknames)) + goto bad; + } + if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS)) + { + if (!TIFFWriteDirectoryTagShort(tif, &ndir, dir, TIFFTAG_NUMBEROFINKS, tif->tif_dir.td_numberofinks)) + goto bad; + } + if (TIFFFieldSet(tif,FIELD_SUBIFD)) + { + if (!TIFFWriteDirectoryTagSubifd(tif,&ndir,dir)) + goto bad; + } + { + uint32 n; + for (n=0; ntif_nfields; n++) { + const TIFFField* o; + o = tif->tif_fields[n]; + if ((o->field_bit>=FIELD_CODEC)&&(TIFFFieldSet(tif,o->field_bit))) + { + switch (o->get_field_type) + { + case TIFF_SETGET_ASCII: + { + uint32 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)) + goto bad; + } + break; + case TIFF_SETGET_UINT16: + { + uint16 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)) + goto bad; + } + break; + case TIFF_SETGET_UINT32: + { + uint32 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)) + goto bad; + } + break; + case TIFF_SETGET_C32_UINT8: + { + uint32 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)) + goto bad; + } + break; + default: + TIFFErrorExt(tif->tif_clientdata,module, + "Cannot write tag %d (%s)", + TIFFFieldTag(o), + o->field_name ? o->field_name : "unknown"); + goto bad; + } + } + } + } + } + for (m=0; m<(uint32)(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; + switch (tif->tif_dir.td_customValues[m].info->field_type) + { + case TIFF_ASCII: + if (!TIFFWriteDirectoryTagAscii(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_UNDEFINED: + if (!TIFFWriteDirectoryTagUndefinedArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_BYTE: + if (!TIFFWriteDirectoryTagByteArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SBYTE: + if (!TIFFWriteDirectoryTagSbyteArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SHORT: + if (!TIFFWriteDirectoryTagShortArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SSHORT: + if (!TIFFWriteDirectoryTagSshortArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_LONG: + if (!TIFFWriteDirectoryTagLongArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SLONG: + if (!TIFFWriteDirectoryTagSlongArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_LONG8: + if (!TIFFWriteDirectoryTagLong8Array(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_SLONG8: + if (!TIFFWriteDirectoryTagSlong8Array(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_RATIONAL: + { + /*-- Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size. */ + int tv_size; + tv_size = _TIFFSetGetFieldSize(tif->tif_dir.td_customValues[m].info->set_field_type); + if (tv_size == 8) { + if (!TIFFWriteDirectoryTagRationalDoubleArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + } else { + /*-- default should be tv_size == 4 */ + if (!TIFFWriteDirectoryTagRationalArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + /*-- ToDo: After Testing, this should be removed and tv_size==4 should be set as default. */ + if (tv_size != 4) { + TIFFErrorExt(0,"TIFFLib: _TIFFWriteDirectorySec()", "Rational2Double: .set_field_type in not 4 but %d", tv_size); + } + } + } + break; + case TIFF_SRATIONAL: + { + /*-- Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size. */ + int tv_size; + tv_size = _TIFFSetGetFieldSize(tif->tif_dir.td_customValues[m].info->set_field_type); + if (tv_size == 8) { + if (!TIFFWriteDirectoryTagSrationalDoubleArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + } else { + /*-- default should be tv_size == 4 */ + if (!TIFFWriteDirectoryTagSrationalArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + /*-- ToDo: After Testing, this should be removed and tv_size==4 should be set as default. */ + if (tv_size != 4) { + TIFFErrorExt(0,"TIFFLib: _TIFFWriteDirectorySec()", "Rational2Double: .set_field_type in not 4 but %d", tv_size); + } + } + } + break; + case TIFF_FLOAT: + if (!TIFFWriteDirectoryTagFloatArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_DOUBLE: + if (!TIFFWriteDirectoryTagDoubleArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_IFD: + if (!TIFFWriteDirectoryTagIfdArray(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + case TIFF_IFD8: + if (!TIFFWriteDirectoryTagIfdIfd8Array(tif,&ndir,dir,tag,count,tif->tif_dir.td_customValues[m].value)) + goto bad; + break; + default: + assert(0); /* we should never get here */ + break; + } + } + if (dir!=NULL) + break; + dir=_TIFFmalloc(ndir*sizeof(TIFFDirEntry)); + if (dir==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + goto bad; + } + if (isimage) + { + if ((tif->tif_diroff==0)&&(!TIFFLinkDirectory(tif))) + goto bad; + } + else + tif->tif_diroff=(TIFFSeekFile(tif,0,SEEK_END)+1)&(~((toff_t)1)); + if (pdiroff!=NULL) + *pdiroff=tif->tif_diroff; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + dirsize=2+ndir*12+4; + else + 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_dataofftif_diroff)||(tif->tif_dataoff<(uint64)dirsize)) + { + TIFFErrorExt(tif->tif_clientdata,module,"Maximum TIFF file size exceeded"); + goto bad; + } + if (tif->tif_dataoff&1) + tif->tif_dataoff++; + if (isimage) + tif->tif_curdir++; + } + if (isimage) + { + if (TIFFFieldSet(tif,FIELD_SUBIFD)&&(tif->tif_subifdoff==0)) + { + uint32 na; + TIFFDirEntry* nb; + for (na=0, nb=dir; ; na++, nb++) + { + if( na == ndir ) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Cannot find SubIFD tag"); goto bad; - } - break; - case TIFF_SETGET_UINT16: - { - 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_t)o->field_tag, - p)) - goto bad; - } - break; - case TIFF_SETGET_UINT32: - { - 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_t)o->field_tag, - p)) - goto bad; - } - break; - case TIFF_SETGET_C32_UINT8: - { - 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_t)o->field_tag, - pa, pb)) - goto bad; - } - break; - default: - TIFFErrorExtR( - tif, module, - "Cannot write tag %" PRIu32 " (%s)", - TIFFFieldTag(o), - o->field_name ? o->field_name : "unknown"); - goto bad; - } - } - } - } - } - for (m = 0; m < (uint32_t)(tif->tif_dir.td_customValueCount); m++) - { - 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: - if (!TIFFWriteDirectoryTagAscii( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_UNDEFINED: - if (!TIFFWriteDirectoryTagUndefinedArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_BYTE: - if (!TIFFWriteDirectoryTagByteArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_SBYTE: - if (!TIFFWriteDirectoryTagSbyteArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_SHORT: - if (!TIFFWriteDirectoryTagShortArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_SSHORT: - if (!TIFFWriteDirectoryTagSshortArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_LONG: - if (!TIFFWriteDirectoryTagLongArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_SLONG: - if (!TIFFWriteDirectoryTagSlongArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_LONG8: - if (!TIFFWriteDirectoryTagLong8Array( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_SLONG8: - if (!TIFFWriteDirectoryTagSlong8Array( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_RATIONAL: - { - /*-- Rational2Double: For Rationals evaluate - * "set_field_type" to determine internal storage size. */ - int tv_size; - tv_size = TIFFFieldSetGetSize( - tif->tif_dir.td_customValues[m].info); - if (tv_size == 8) - { - if (!TIFFWriteDirectoryTagRationalDoubleArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - } - else - { - /*-- default should be tv_size == 4 */ - if (!TIFFWriteDirectoryTagRationalArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - /*-- ToDo: After Testing, this should be removed and - * tv_size==4 should be set as default. */ - if (tv_size != 4) - { - TIFFErrorExtR(tif, - "TIFFLib: _TIFFWriteDirectorySec()", - "Rational2Double: .set_field_type is " - "not 4 but %d", - tv_size); - } - } - } - break; - case TIFF_SRATIONAL: - { - /*-- Rational2Double: For Rationals evaluate - * "set_field_type" to determine internal storage size. */ - int tv_size; - tv_size = TIFFFieldSetGetSize( - tif->tif_dir.td_customValues[m].info); - if (tv_size == 8) - { - if (!TIFFWriteDirectoryTagSrationalDoubleArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - } - else - { - /*-- default should be tv_size == 4 */ - if (!TIFFWriteDirectoryTagSrationalArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - /*-- ToDo: After Testing, this should be removed and - * tv_size==4 should be set as default. */ - if (tv_size != 4) - { - TIFFErrorExtR(tif, - "TIFFLib: _TIFFWriteDirectorySec()", - "Rational2Double: .set_field_type is " - "not 4 but %d", - tv_size); - } - } - } - break; - case TIFF_FLOAT: - if (!TIFFWriteDirectoryTagFloatArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_DOUBLE: - if (!TIFFWriteDirectoryTagDoubleArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_IFD: - if (!TIFFWriteDirectoryTagIfdArray( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - case TIFF_IFD8: - if (!TIFFWriteDirectoryTagIfdIfd8Array( - tif, &ndir, dir, tag, count, - tif->tif_dir.td_customValues[m].value)) - goto bad; - break; - default: - assert(0); /* we should never get here */ - break; - } - } - if (dir != NULL) - break; - dir = _TIFFmallocExt(tif, ndir * sizeof(TIFFDirEntry)); - if (dir == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - goto bad; - } - if (isimage) - { - if ((tif->tif_diroff == 0) && (!TIFFLinkDirectory(tif))) - goto bad; - } - else - tif->tif_diroff = - (TIFFSeekFile(tif, 0, SEEK_END) + 1) & (~((toff_t)1)); - if (pdiroff != NULL) - *pdiroff = tif->tif_diroff; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - dirsize = 2 + ndir * 12 + 4; - else - dirsize = 8 + ndir * 20 + 8; - tif->tif_dataoff = tif->tif_diroff + dirsize; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - tif->tif_dataoff = (uint32_t)tif->tif_dataoff; - if ((tif->tif_dataoff < tif->tif_diroff) || - (tif->tif_dataoff < (uint64_t)dirsize)) - { - TIFFErrorExtR(tif, module, "Maximum TIFF file size exceeded"); - goto bad; - } - if (tif->tif_dataoff & 1) - tif->tif_dataoff++; - if (isimage) - { - if (tif->tif_curdir == TIFF_NON_EXISTENT_DIR_NUMBER) - tif->tif_curdir = 0; - else - tif->tif_curdir++; - } - } - if (isimage) - { - if (TIFFFieldSet(tif, FIELD_SUBIFD) && (tif->tif_subifdoff == 0)) - { - uint32_t na; - TIFFDirEntry *nb; - for (na = 0, nb = dir;; na++, nb++) - { - if (na == ndir) - { - TIFFErrorExtR(tif, module, "Cannot find SubIFD tag"); - goto bad; - } - if (nb->tdir_tag == TIFFTAG_SUBIFD) - break; - } - if (!(tif->tif_flags & TIFF_BIGTIFF)) - tif->tif_subifdoff = tif->tif_diroff + 2 + na * 12 + 8; - else - tif->tif_subifdoff = tif->tif_diroff + 8 + na * 20 + 12; - } - } - dirmem = _TIFFmallocExt(tif, dirsize); - if (dirmem == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - goto bad; - } - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - uint8_t *n; - uint32_t nTmp; - TIFFDirEntry *o; - n = dirmem; - *(uint16_t *)n = (uint16_t)ndir; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)n); - n += 2; - o = dir; - for (m = 0; m < ndir; m++) - { - *(uint16_t *)n = o->tdir_tag; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)n); - n += 2; - *(uint16_t *)n = o->tdir_type; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)n); - n += 2; - nTmp = (uint32_t)o->tdir_count; - _TIFFmemcpy(n, &nTmp, 4); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong((uint32_t *)n); - n += 4; - /* This is correct. The data has been */ - /* swabbed previously in TIFFWriteDirectoryTagData */ - _TIFFmemcpy(n, &o->tdir_offset, 4); - n += 4; - o++; - } - nTmp = (uint32_t)tif->tif_nextdiroff; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nTmp); - _TIFFmemcpy(n, &nTmp, 4); - } - else - { - uint8_t *n; - TIFFDirEntry *o; - n = dirmem; - *(uint64_t *)n = ndir; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)n); - n += 8; - o = dir; - for (m = 0; m < ndir; m++) - { - *(uint16_t *)n = o->tdir_tag; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)n); - n += 2; - *(uint16_t *)n = o->tdir_type; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)n); - n += 2; - _TIFFmemcpy(n, &o->tdir_count, 8); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)n); - n += 8; - _TIFFmemcpy(n, &o->tdir_offset, 8); - n += 8; - o++; - } - _TIFFmemcpy(n, &tif->tif_nextdiroff, 8); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)n); - } - _TIFFfreeExt(tif, dir); - dir = NULL; - if (!SeekOK(tif, tif->tif_diroff)) - { - TIFFErrorExtR(tif, module, "IO error writing directory"); - goto bad; - } - if (!WriteOK(tif, dirmem, (tmsize_t)dirsize)) - { - TIFFErrorExtR(tif, module, "IO error writing directory"); - goto bad; - } - _TIFFfreeExt(tif, dirmem); - if (imagedone) - { - TIFFFreeDirectory(tif); - tif->tif_flags &= ~TIFF_DIRTYDIRECT; - tif->tif_flags &= ~TIFF_DIRTYSTRIP; - (*tif->tif_cleanup)(tif); - /* - * Reset directory-related state for subsequent - * directories. - */ - TIFFCreateDirectory(tif); - } - return (1); + } + if (nb->tdir_tag==TIFFTAG_SUBIFD) + break; + } + if (!(tif->tif_flags&TIFF_BIGTIFF)) + tif->tif_subifdoff=tif->tif_diroff+2+na*12+8; + else + tif->tif_subifdoff=tif->tif_diroff+8+na*20+12; + } + } + dirmem=_TIFFmalloc(dirsize); + if (dirmem==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + goto bad; + } + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint8* n; + uint32 nTmp; + TIFFDirEntry* o; + n=dirmem; + *(uint16*)n=(uint16)ndir; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + o=dir; + for (m=0; mtdir_tag; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + *(uint16*)n=o->tdir_type; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + nTmp = (uint32)o->tdir_count; + _TIFFmemcpy(n,&nTmp,4); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)n); + n+=4; + /* This is correct. The data has been */ + /* swabbed previously in TIFFWriteDirectoryTagData */ + _TIFFmemcpy(n,&o->tdir_offset,4); + n+=4; + o++; + } + nTmp = (uint32)tif->tif_nextdiroff; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&nTmp); + _TIFFmemcpy(n,&nTmp,4); + } + else + { + uint8* n; + TIFFDirEntry* o; + n=dirmem; + *(uint64*)n=ndir; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)n); + n+=8; + o=dir; + for (m=0; mtdir_tag; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + *(uint16*)n=o->tdir_type; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)n); + n+=2; + _TIFFmemcpy(n,&o->tdir_count,8); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)n); + n+=8; + _TIFFmemcpy(n,&o->tdir_offset,8); + n+=8; + o++; + } + _TIFFmemcpy(n,&tif->tif_nextdiroff,8); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8((uint64*)n); + } + _TIFFfree(dir); + dir=NULL; + if (!SeekOK(tif,tif->tif_diroff)) + { + TIFFErrorExt(tif->tif_clientdata,module,"IO error writing directory"); + goto bad; + } + if (!WriteOK(tif,dirmem,(tmsize_t)dirsize)) + { + TIFFErrorExt(tif->tif_clientdata,module,"IO error writing directory"); + goto bad; + } + _TIFFfree(dirmem); + if (imagedone) + { + TIFFFreeDirectory(tif); + tif->tif_flags &= ~TIFF_DIRTYDIRECT; + tif->tif_flags &= ~TIFF_DIRTYSTRIP; + (*tif->tif_cleanup)(tif); + /* + * Reset directory-related state for subsequent + * directories. + */ + TIFFCreateDirectory(tif); + } + return(1); bad: - if (dir != NULL) - _TIFFfreeExt(tif, dir); - if (dirmem != NULL) - _TIFFfreeExt(tif, dirmem); - return (0); + if (dir!=NULL) + _TIFFfree(dir); + if (dirmem!=NULL) + _TIFFfree(dirmem); + return(0); } -static int8_t TIFFClampDoubleToInt8(double val) +static int8 TIFFClampDoubleToInt8( double val ) { - if (val > 127) + if( val > 127 ) return 127; - if (val < -128 || val != val) + if( val < -128 || val != val ) return -128; - return (int8_t)val; + return (int8)val; } -static int16_t TIFFClampDoubleToInt16(double val) +static int16 TIFFClampDoubleToInt16( double val ) { - if (val > 32767) + if( val > 32767 ) return 32767; - if (val < -32768 || val != val) + if( val < -32768 || val != val ) return -32768; - return (int16_t)val; + return (int16)val; } -static int32_t TIFFClampDoubleToInt32(double val) +static int32 TIFFClampDoubleToInt32( double val ) { - if (val > 0x7FFFFFFF) + if( val > 0x7FFFFFFF ) return 0x7FFFFFFF; - if (val < -0x7FFFFFFF - 1 || val != val) - return -0x7FFFFFFF - 1; - return (int32_t)val; + if( val < -0x7FFFFFFF-1 || val != val ) + return -0x7FFFFFFF-1; + return (int32)val; } -static uint8_t TIFFClampDoubleToUInt8(double val) +static uint8 TIFFClampDoubleToUInt8( double val ) { - if (val < 0) + if( val < 0 ) return 0; - if (val > 255 || val != val) + if( val > 255 || val != val ) return 255; - return (uint8_t)val; + return (uint8)val; } -static uint16_t TIFFClampDoubleToUInt16(double val) +static uint16 TIFFClampDoubleToUInt16( double val ) { - if (val < 0) + if( val < 0 ) return 0; - if (val > 65535 || val != val) + if( val > 65535 || val != val ) return 65535; - return (uint16_t)val; + return (uint16)val; } -static uint32_t TIFFClampDoubleToUInt32(double val) +static uint32 TIFFClampDoubleToUInt32( double val ) { - if (val < 0) + if( val < 0 ) return 0; - if (val > 0xFFFFFFFFU || val != val) + if( val > 0xFFFFFFFFU || val != val ) return 0xFFFFFFFFU; - return (uint32_t)val; + return (uint32)val; } -static int TIFFWriteDirectoryTagSampleformatArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - double *value) +static int +TIFFWriteDirectoryTagSampleformatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) { - static const char module[] = "TIFFWriteDirectoryTagSampleformatArray"; - void *conv; - uint32_t i; - int ok; - conv = _TIFFmallocExt(tif, count * sizeof(double)); - if (conv == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } + static const char module[] = "TIFFWriteDirectoryTagSampleformatArray"; + void* conv; + uint32 i; + int ok; + conv = _TIFFmalloc(count*sizeof(double)); + if (conv == NULL) + { + TIFFErrorExt(tif->tif_clientdata, module, "Out of memory"); + return (0); + } - switch (tif->tif_dir.td_sampleformat) - { - case SAMPLEFORMAT_IEEEFP: - if (tif->tif_dir.td_bitspersample <= 32) - { - for (i = 0; i < count; ++i) - ((float *)conv)[i] = _TIFFClampDoubleToFloat(value[i]); - ok = TIFFWriteDirectoryTagFloatArray(tif, ndir, dir, tag, count, - (float *)conv); - } - else - { - ok = TIFFWriteDirectoryTagDoubleArray(tif, ndir, dir, tag, - count, value); - } - break; - case SAMPLEFORMAT_INT: - if (tif->tif_dir.td_bitspersample <= 8) - { - for (i = 0; i < count; ++i) - ((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_t *)conv)[i] = TIFFClampDoubleToInt16(value[i]); - ok = TIFFWriteDirectoryTagSshortArray(tif, ndir, dir, tag, - count, (int16_t *)conv); - } - else - { - for (i = 0; i < count; ++i) - ((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_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_t *)conv)[i] = TIFFClampDoubleToUInt16(value[i]); - ok = TIFFWriteDirectoryTagShortArray(tif, ndir, dir, tag, count, - (uint16_t *)conv); - } - else - { - for (i = 0; i < count; ++i) - ((uint32_t *)conv)[i] = TIFFClampDoubleToUInt32(value[i]); - ok = TIFFWriteDirectoryTagLongArray(tif, ndir, dir, tag, count, - (uint32_t *)conv); - } - break; - default: - ok = 0; - } + switch (tif->tif_dir.td_sampleformat) + { + case SAMPLEFORMAT_IEEEFP: + if (tif->tif_dir.td_bitspersample<=32) + { + for (i = 0; i < count; ++i) + ((float*)conv)[i] = _TIFFClampDoubleToFloat(value[i]); + ok = TIFFWriteDirectoryTagFloatArray(tif,ndir,dir,tag,count,(float*)conv); + } + else + { + ok = TIFFWriteDirectoryTagDoubleArray(tif,ndir,dir,tag,count,value); + } + break; + case SAMPLEFORMAT_INT: + 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); + } + 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); + } + else + { + for (i = 0; i < count; ++i) + ((int32*)conv)[i] = TIFFClampDoubleToInt32(value[i]); + ok = TIFFWriteDirectoryTagSlongArray(tif,ndir,dir,tag,count,(int32*)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); + } + 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); + } + else + { + for (i = 0; i < count; ++i) + ((uint32*)conv)[i] = TIFFClampDoubleToUInt32(value[i]); + ok = TIFFWriteDirectoryTagLongArray(tif,ndir,dir,tag,count,(uint32*)conv); + } + break; + default: + ok = 0; + } - _TIFFfreeExt(tif, conv); - return (ok); + _TIFFfree(conv); + return (ok); } -static int TIFFWriteDirectoryTagAscii(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, char *value) +#if 0 +static int +TIFFWriteDirectoryTagSampleformatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return ( - TIFFWriteDirectoryTagCheckedAscii(tif, ndir, dir, tag, count, value)); + switch (tif->tif_dir.td_sampleformat) + { + case SAMPLEFORMAT_IEEEFP: + if (tif->tif_dir.td_bitspersample<=32) + return(TIFFWriteDirectoryTagFloatPerSample(tif,ndir,dir,tag,(float)value)); + else + 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)); + else if (tif->tif_dir.td_bitspersample<=16) + return(TIFFWriteDirectoryTagSshortPerSample(tif,ndir,dir,tag,(int16)value)); + else + return(TIFFWriteDirectoryTagSlongPerSample(tif,ndir,dir,tag,(int32)value)); + case SAMPLEFORMAT_UINT: + if (tif->tif_dir.td_bitspersample<=8) + return(TIFFWriteDirectoryTagBytePerSample(tif,ndir,dir,tag,(uint8)value)); + else if (tif->tif_dir.td_bitspersample<=16) + return(TIFFWriteDirectoryTagShortPerSample(tif,ndir,dir,tag,(uint16)value)); + else + return(TIFFWriteDirectoryTagLongPerSample(tif,ndir,dir,tag,(uint32)value)); + default: + return(1); + } +} +#endif + +static int +TIFFWriteDirectoryTagAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedAscii(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagUndefinedArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint8_t *value) +static int +TIFFWriteDirectoryTagUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedUndefinedArray(tif, ndir, dir, tag, - count, value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedUndefinedArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagByteArray(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) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedByteArray(tif, ndir, dir, tag, count, - value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedByte(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagByteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedByteArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagSbyteArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, int8_t *value) +#if 0 +static int +TIFFWriteDirectoryTagBytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint8 value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedSbyteArray(tif, ndir, dir, tag, count, - value)); + static const char module[] = "TIFFWriteDirectoryTagBytePerSample"; + uint8* m; + uint8* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint8)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedByteArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +#ifdef notdef +static int +TIFFWriteDirectoryTagSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSbyte(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagSbyteArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int8* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSbyteArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagShort(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint16_t value) +#if 0 +static int +TIFFWriteDirectoryTagSbytePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedShort(tif, ndir, dir, tag, value)); + static const char module[] = "TIFFWriteDirectoryTagSbytePerSample"; + int8* m; + int8* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int8)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedSbyteArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +static int +TIFFWriteDirectoryTagShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,value)); } -static int TIFFWriteDirectoryTagShortArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint16_t *value) +static int +TIFFWriteDirectoryTagShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedShortArray(tif, ndir, dir, tag, count, - value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagShortPerSample(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint16_t value) +static int +TIFFWriteDirectoryTagShortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) { - static const char module[] = "TIFFWriteDirectoryTagShortPerSample"; - uint16_t *m; - uint16_t *na; - uint16_t nb; - int o; - if (dir == NULL) - { - (*ndir)++; - return (1); - } - m = _TIFFmallocExt(tif, tif->tif_dir.td_samplesperpixel * sizeof(uint16_t)); - if (m == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - for (na = m, nb = 0; nb < tif->tif_dir.td_samplesperpixel; na++, nb++) - *na = value; - o = TIFFWriteDirectoryTagCheckedShortArray( - tif, ndir, dir, tag, tif->tif_dir.td_samplesperpixel, m); - _TIFFfreeExt(tif, m); - return (o); + static const char module[] = "TIFFWriteDirectoryTagShortPerSample"; + uint16* m; + uint16* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint16)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); } -static int TIFFWriteDirectoryTagSshortArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, int16_t *value) +#ifdef notdef +static int +TIFFWriteDirectoryTagSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedSshortArray(tif, ndir, dir, tag, count, - value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSshort(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagSshortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int16* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSshortArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagLong(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t value) +#if 0 +static int +TIFFWriteDirectoryTagSshortPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedLong(tif, ndir, dir, tag, value)); + static const char module[] = "TIFFWriteDirectoryTagSshortPerSample"; + int16* m; + int16* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int16)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedSshortArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +static int +TIFFWriteDirectoryTagLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedLong(tif,ndir,dir,tag,value)); } -static int TIFFWriteDirectoryTagLongArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint32_t *value) +static int +TIFFWriteDirectoryTagLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedLongArray(tif, ndir, dir, tag, count, - value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagSlongArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, int32_t *value) +#if 0 +static int +TIFFWriteDirectoryTagLongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedSlongArray(tif, ndir, dir, tag, count, - value)); + static const char module[] = "TIFFWriteDirectoryTagLongPerSample"; + uint32* m; + uint32* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(uint32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +#ifdef notdef +static int +TIFFWriteDirectoryTagSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSlong(tif,ndir,dir,tag,value)); +} +#endif + +static int +TIFFWriteDirectoryTagSlongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int32* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSlongArray(tif,ndir,dir,tag,count,value)); } -/************************************************************************/ -/* TIFFWriteDirectoryTagLong8Array() */ -/* */ -/* Write either Long8 or Long array depending on file type. */ -/************************************************************************/ -static int TIFFWriteDirectoryTagLong8Array(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint64_t *value) +#if 0 +static int +TIFFWriteDirectoryTagSlongPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) { - static const char module[] = "TIFFWriteDirectoryTagLong8Array"; - uint64_t *ma; - uint32_t mb; - uint32_t *p; - uint32_t *q; - int o; + static const char module[] = "TIFFWriteDirectoryTagSlongPerSample"; + int32* m; + int32* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(int32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedSlongArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif - /* is this just a counting pass? */ - if (dir == NULL) - { - (*ndir)++; - return (1); - } +#ifdef notdef +static int +TIFFWriteDirectoryTagLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedLong8(tif,ndir,dir,tag,value)); +} +#endif - /* We always write Long8 for BigTIFF, no checking needed. */ - if (tif->tif_flags & TIFF_BIGTIFF) - return (TIFFWriteDirectoryTagCheckedLong8Array(tif, ndir, dir, tag, - count, value)); - - /* - ** For classic tiff we want to verify everything is in range for long - ** and convert to long format. - */ - p = _TIFFmallocExt(tif, count * sizeof(uint32_t)); - if (p == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - - for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++) - { - if (*ma > 0xFFFFFFFF) - { - TIFFErrorExtR(tif, module, - "Attempt to write unsigned long value %" PRIu64 - " larger than 0xFFFFFFFF for tag %d in Classic TIFF " - "file. TIFF file writing aborted", - *ma, tag); - _TIFFfreeExt(tif, p); - return (0); - } - *q = (uint32_t)(*ma); - } - - o = TIFFWriteDirectoryTagCheckedLongArray(tif, ndir, dir, tag, count, p); - _TIFFfreeExt(tif, p); - - return (o); +static int +TIFFWriteDirectoryTagLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedLong8Array(tif,ndir,dir,tag,count,value)); } -/************************************************************************/ -/* TIFFWriteDirectoryTagSlong8Array() */ -/* */ -/* Write either SLong8 or SLong array depending on file type. */ -/************************************************************************/ -static int TIFFWriteDirectoryTagSlong8Array(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, int64_t *value) +#ifdef notdef +static int +TIFFWriteDirectoryTagSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) { - static const char module[] = "TIFFWriteDirectoryTagSlong8Array"; - int64_t *ma; - uint32_t mb; - int32_t *p; - int32_t *q; - int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSlong8(tif,ndir,dir,tag,value)); +} +#endif - /* is this just a counting pass? */ - if (dir == NULL) - { - (*ndir)++; - return (1); - } - /* We always write SLong8 for BigTIFF, no checking needed. */ - if (tif->tif_flags & TIFF_BIGTIFF) - return (TIFFWriteDirectoryTagCheckedSlong8Array(tif, ndir, dir, tag, - count, value)); - - /* - ** For classic tiff we want to verify everything is in range for signed-long - ** and convert to signed-long format. - */ - p = _TIFFmallocExt(tif, count * sizeof(uint32_t)); - if (p == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - - for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++) - { - if (*ma > (2147483647)) - { - TIFFErrorExtR(tif, module, - "Attempt to write signed long value %" PRIi64 - " larger than 0x7FFFFFFF (2147483647) for tag %d in " - "Classic TIFF file. TIFF writing to file aborted", - *ma, tag); - _TIFFfreeExt(tif, p); - return (0); - } - else if (*ma < (-2147483647 - 1)) - { - TIFFErrorExtR(tif, module, - "Attempt to write signed long value %" PRIi64 - " smaller than 0x80000000 (-2147483648) for tag %d " - "in Classic TIFF file. TIFF writing to file aborted", - *ma, tag); - _TIFFfreeExt(tif, p); - return (0); - } - *q = (int32_t)(*ma); - } - - o = TIFFWriteDirectoryTagCheckedSlongArray(tif, ndir, dir, tag, count, p); - _TIFFfreeExt(tif, p); - - return (o); +static int +TIFFWriteDirectoryTagSlong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, int64* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSlong8Array(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagRational(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - double value) +static int +TIFFWriteDirectoryTagRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedRational(tif, ndir, dir, tag, value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedRational(tif,ndir,dir,tag,value)); } -static int TIFFWriteDirectoryTagRationalArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, float *value) +static int +TIFFWriteDirectoryTagRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedRationalArray(tif, ndir, dir, tag, - count, value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedRationalArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagSrationalArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, float *value) +static int +TIFFWriteDirectoryTagSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedSrationalArray(tif, ndir, dir, tag, - count, value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSrationalArray(tif,ndir,dir,tag,count,value)); } /*-- Rational2Double: additional write functions */ -static int TIFFWriteDirectoryTagRationalDoubleArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, - uint32_t count, - double *value) +static int +TIFFWriteDirectoryTagRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedRationalDoubleArray(tif, ndir, dir, tag, - count, value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedRationalDoubleArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagSrationalDoubleArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, - uint32_t count, - double *value) +static int +TIFFWriteDirectoryTagSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedSrationalDoubleArray( - tif, ndir, dir, tag, count, value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedSrationalDoubleArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagFloatArray(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) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedFloatArray(tif, ndir, dir, tag, count, - value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedFloat(tif,ndir,dir,tag,value)); +} +#endif + +static int TIFFWriteDirectoryTagFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedFloatArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagDoubleArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, double *value) +#if 0 +static int TIFFWriteDirectoryTagFloatPerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedDoubleArray(tif, ndir, dir, tag, count, - value)); + static const char module[] = "TIFFWriteDirectoryTagFloatPerSample"; + float* m; + float* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(float)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedFloatArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +#ifdef notdef +static int TIFFWriteDirectoryTagDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedDouble(tif,ndir,dir,tag,value)); +} +#endif + +static int TIFFWriteDirectoryTagDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedDoubleArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagIfdArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint32_t *value) +#if 0 +static int TIFFWriteDirectoryTagDoublePerSample(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - return (TIFFWriteDirectoryTagCheckedIfdArray(tif, ndir, dir, tag, count, - value)); + static const char module[] = "TIFFWriteDirectoryTagDoublePerSample"; + double* m; + double* na; + uint16 nb; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + m=_TIFFmalloc(tif->tif_dir.td_samplesperpixel*sizeof(double)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=m, nb=0; nbtif_dir.td_samplesperpixel; na++, nb++) + *na=value; + o=TIFFWriteDirectoryTagCheckedDoubleArray(tif,ndir,dir,tag,tif->tif_dir.td_samplesperpixel,m); + _TIFFfree(m); + return(o); +} +#endif + +static int +TIFFWriteDirectoryTagIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,tag,count,value)); } -static int TIFFWriteDirectoryTagShortLong(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t value) +#ifdef notdef +static int +TIFFWriteDirectoryTagIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) { - if (dir == NULL) - { - (*ndir)++; - return (1); - } - if (value <= 0xFFFF) - return (TIFFWriteDirectoryTagCheckedShort(tif, ndir, dir, tag, - (uint16_t)value)); - else - return (TIFFWriteDirectoryTagCheckedLong(tif, ndir, dir, tag, value)); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + return(TIFFWriteDirectoryTagCheckedIfd8Array(tif,ndir,dir,tag,count,value)); +} +#endif + +static int +TIFFWriteDirectoryTagShortLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) +{ + if (dir==NULL) + { + (*ndir)++; + return(1); + } + if (value<=0xFFFF) + return(TIFFWriteDirectoryTagCheckedShort(tif,ndir,dir,tag,(uint16)value)); + else + return(TIFFWriteDirectoryTagCheckedLong(tif,ndir,dir,tag,value)); } -static int _WriteAsType(TIFF *tif, uint64_t strile_size, - uint64_t uncompressed_threshold) +static int _WriteAsType(TIFF* tif, uint64 strile_size, uint64 uncompressed_threshold) { - const uint16_t compression = tif->tif_dir.td_compression; - if (compression == COMPRESSION_NONE) + const uint16 compression = tif->tif_dir.td_compression; + if ( compression == COMPRESSION_NONE ) { return strile_size > uncompressed_threshold; } - else if (compression == COMPRESSION_JPEG || - compression == COMPRESSION_LZW || - compression == COMPRESSION_ADOBE_DEFLATE || - compression == COMPRESSION_DEFLATE || - compression == COMPRESSION_LZMA || - compression == COMPRESSION_LERC || - compression == COMPRESSION_ZSTD || - compression == COMPRESSION_WEBP || compression == COMPRESSION_JXL) + else if ( compression == COMPRESSION_JPEG || + compression == COMPRESSION_LZW || + compression == COMPRESSION_ADOBE_DEFLATE || + compression == COMPRESSION_LZMA || + compression == COMPRESSION_LERC || + compression == COMPRESSION_ZSTD || + compression == COMPRESSION_WEBP ) { /* For a few select compression types, we assume that in the worst */ /* case the compressed size will be 10 times the uncompressed size */ @@ -1831,12 +1792,12 @@ static int _WriteAsType(TIFF *tif, uint64_t strile_size, return 1; } -static int WriteAsLong8(TIFF *tif, uint64_t strile_size) +static int WriteAsLong8(TIFF* tif, uint64 strile_size) { return _WriteAsType(tif, strile_size, 0xFFFFFFFFU); } -static int WriteAsLong4(TIFF *tif, uint64_t strile_size) +static int WriteAsLong4(TIFF* tif, uint64 strile_size) { return _WriteAsType(tif, strile_size, 0xFFFFU); } @@ -1848,128 +1809,121 @@ static int WriteAsLong4(TIFF *tif, uint64_t strile_size) /* on strile size and Classic/BigTIFF mode. */ /************************************************************************/ -static int TIFFWriteDirectoryTagLongLong8Array(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint64_t *value) +static int +TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) { static const char module[] = "TIFFWriteDirectoryTagLongLong8Array"; int o; int write_aslong4; /* is this just a counting pass? */ - if (dir == NULL) + if (dir==NULL) { (*ndir)++; - return (1); + return(1); } - if (tif->tif_dir.td_deferstrilearraywriting) + if( tif->tif_dir.td_deferstrilearraywriting ) { - return TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_NOTYPE, 0, 0, - NULL); + return TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_NOTYPE, 0, 0, NULL); } - if (tif->tif_flags & TIFF_BIGTIFF) + if( tif->tif_flags&TIFF_BIGTIFF ) { int write_aslong8 = 1; /* In the case of ByteCounts array, we may be able to write them on */ /* LONG if the strip/tilesize is not too big. */ - /* Also do that for count > 1 in the case someone would want to create - */ + /* Also do that for count > 1 in the case someone would want to create */ /* a single-strip file with a growing height, in which case using */ /* LONG8 will be safer. */ - if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS) + if( count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS ) { write_aslong8 = WriteAsLong8(tif, TIFFStripSize64(tif)); } - else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS) + else if( count > 1 && tag == TIFFTAG_TILEBYTECOUNTS ) { write_aslong8 = WriteAsLong8(tif, TIFFTileSize64(tif)); } - if (write_aslong8) + if( write_aslong8 ) { - return TIFFWriteDirectoryTagCheckedLong8Array(tif, ndir, dir, tag, - count, value); + return TIFFWriteDirectoryTagCheckedLong8Array(tif,ndir,dir, + tag,count,value); } } write_aslong4 = 1; - if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS) + if( count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS ) { write_aslong4 = WriteAsLong4(tif, TIFFStripSize64(tif)); } - else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS) + else if( count > 1 && tag == TIFFTAG_TILEBYTECOUNTS ) { write_aslong4 = WriteAsLong4(tif, TIFFTileSize64(tif)); } - if (write_aslong4) + if( write_aslong4 ) { /* ** For classic tiff we want to verify everything is in range for LONG ** and convert to long format. */ - uint32_t *p = _TIFFmallocExt(tif, count * sizeof(uint32_t)); - uint32_t *q; - uint64_t *ma; - uint32_t mb; + uint32* p = _TIFFmalloc(count*sizeof(uint32)); + uint32* q; + uint64* ma; + uint32 mb; - if (p == NULL) + if (p==NULL) { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); } - for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++) + for (q=p, ma=value, mb=0; mb 0xFFFFFFFF) + if (*ma>0xFFFFFFFFULL) { - TIFFErrorExtR(tif, module, - "Attempt to write value larger than 0xFFFFFFFF " - "in LONG array."); - _TIFFfreeExt(tif, p); - return (0); + TIFFErrorExt(tif->tif_clientdata,module, + "Attempt to write value larger than 0xFFFFFFFF in LONG array."); + _TIFFfree(p); + return(0); } - *q = (uint32_t)(*ma); + *q= (uint32)(*ma); } - o = TIFFWriteDirectoryTagCheckedLongArray(tif, ndir, dir, tag, count, - p); - _TIFFfreeExt(tif, p); + o=TIFFWriteDirectoryTagCheckedLongArray(tif,ndir,dir,tag,count,p); + _TIFFfree(p); } else { - uint16_t *p = _TIFFmallocExt(tif, count * sizeof(uint16_t)); - uint16_t *q; - uint64_t *ma; - uint32_t mb; + uint16* p = _TIFFmalloc(count*sizeof(uint16)); + uint16* q; + uint64* ma; + uint32 mb; - if (p == NULL) + if (p==NULL) { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); } - for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++) + for (q=p, ma=value, mb=0; mb 0xFFFF) + if (*ma>0xFFFFULL) { /* Should not happen normally given the check we did before */ - TIFFErrorExtR(tif, module, - "Attempt to write value larger than 0xFFFF in " - "SHORT array."); - _TIFFfreeExt(tif, p); - return (0); + TIFFErrorExt(tif->tif_clientdata,module, + "Attempt to write value larger than 0xFFFF in SHORT array."); + _TIFFfree(p); + return(0); } - *q = (uint16_t)(*ma); + *q= (uint16)(*ma); } - o = TIFFWriteDirectoryTagCheckedShortArray(tif, ndir, dir, tag, count, - p); - _TIFFfreeExt(tif, p); + o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,tag,count,p); + _TIFFfree(p); } - return (o); + return(o); } /************************************************************************/ @@ -1978,555 +1932,784 @@ static int TIFFWriteDirectoryTagLongLong8Array(TIFF *tif, uint32_t *ndir, /* Write either IFD8 or IFD array depending on file type. */ /************************************************************************/ -static int TIFFWriteDirectoryTagIfdIfd8Array(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint64_t *value) +static int +TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) { static const char module[] = "TIFFWriteDirectoryTagIfdIfd8Array"; - uint64_t *ma; - uint32_t mb; - uint32_t *p; - uint32_t *q; + uint64* ma; + uint32 mb; + uint32* p; + uint32* q; int o; /* is this just a counting pass? */ - if (dir == NULL) + if (dir==NULL) { (*ndir)++; - return (1); + return(1); } /* We always write IFD8 for BigTIFF, no checking needed. */ - if (tif->tif_flags & TIFF_BIGTIFF) - return TIFFWriteDirectoryTagCheckedIfd8Array(tif, ndir, dir, tag, count, - value); + if( tif->tif_flags&TIFF_BIGTIFF ) + return TIFFWriteDirectoryTagCheckedIfd8Array(tif,ndir,dir, + tag,count,value); /* ** For classic tiff we want to verify everything is in range for IFD ** and convert to long format. */ - p = _TIFFmallocExt(tif, count * sizeof(uint32_t)); - if (p == NULL) + p = _TIFFmalloc(count*sizeof(uint32)); + if (p==NULL) { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); } - for (q = p, ma = value, mb = 0; mb < count; ma++, mb++, q++) + for (q=p, ma=value, mb=0; mb 0xFFFFFFFF) + if (*ma>0xFFFFFFFFULL) { - TIFFErrorExtR(tif, module, - "Attempt to write value larger than 0xFFFFFFFF in " - "Classic TIFF file."); - _TIFFfreeExt(tif, p); - return (0); + TIFFErrorExt(tif->tif_clientdata,module, + "Attempt to write value larger than 0xFFFFFFFF in Classic TIFF file."); + _TIFFfree(p); + return(0); } - *q = (uint32_t)(*ma); + *q= (uint32)(*ma); } - o = TIFFWriteDirectoryTagCheckedIfdArray(tif, ndir, dir, tag, count, p); - _TIFFfreeExt(tif, p); + o=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,tag,count,p); + _TIFFfree(p); - return (o); + return(o); } -static int TIFFWriteDirectoryTagColormap(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir) +#ifdef notdef +static int +TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) { - static const char module[] = "TIFFWriteDirectoryTagColormap"; - uint32_t m; - uint16_t *n; - int o; - if (dir == NULL) - { - (*ndir)++; - return (1); - } - m = (1 << tif->tif_dir.td_bitspersample); - n = _TIFFmallocExt(tif, 3 * m * sizeof(uint16_t)); - if (n == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - _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); - _TIFFfreeExt(tif, n); - return (o); + static const char module[] = "TIFFWriteDirectoryTagShortLongLong8Array"; + uint64* ma; + uint32 mb; + uint8 n; + int o; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + n=0; + for (ma=value, mb=0; mb0xFFFFULL)) + n=1; + if ((n==1)&&(*ma>0xFFFFFFFFULL)) + { + n=2; + break; + } + } + if (n==0) + { + uint16* p; + uint16* q; + p=_TIFFmalloc(count*sizeof(uint16)); + if (p==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (ma=value, mb=0, q=p; mbtif_clientdata,module,"Out of memory"); + return(0); + } + for (ma=value, mb=0, q=p; mbtif_dir.td_bitspersample); + n=_TIFFmalloc(3*m*sizeof(uint16)); + 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)); + o=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,TIFFTAG_COLORMAP,3*m,n); + _TIFFfree(n); + return(o); } -static int TIFFWriteDirectoryTagTransferfunction(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir) +static int +TIFFWriteDirectoryTagTransferfunction(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) { - static const char module[] = "TIFFWriteDirectoryTagTransferfunction"; - uint32_t m; - uint16_t n; - uint16_t *o; - int p; - if (dir == NULL) - { - (*ndir)++; - return (1); - } - /* TIFFTAG_TRANSFERFUNCTION expects (1 or 3) pointer to arrays with - * (1 << BitsPerSample) * uint16_t values. - */ - m = (1 << tif->tif_dir.td_bitspersample); - /* clang-format off */ - n = (tif->tif_dir.td_samplesperpixel - tif->tif_dir.td_extrasamples) > 1 ? 3 : 1; - /* clang-format on */ - - /* Check for proper number of transferfunctions */ - for (int i = 0; i < n; i++) - { - if (tif->tif_dir.td_transferfunction[i] == NULL) - { - TIFFWarningExtR( - tif, module, - "Too few TransferFunctions provided. Tag not written to file"); - return (1); /* Not an error; only tag is not written. */ - } - } - /* - * Check if the table can be written as a single column, - * or if it must be written as 3 columns. Note that we - * write a 3-column tag if there are 2 samples/pixel and - * a single column of data won't suffice--hmm. - */ - if (n == 3) - { - if (!_TIFFmemcmp(tif->tif_dir.td_transferfunction[0], - tif->tif_dir.td_transferfunction[2], - m * sizeof(uint16_t)) && - !_TIFFmemcmp(tif->tif_dir.td_transferfunction[0], - tif->tif_dir.td_transferfunction[1], - m * sizeof(uint16_t))) - n = 1; - } - o = _TIFFmallocExt(tif, n * m * sizeof(uint16_t)); - if (o == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - _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_t)); - if (n > 2) - _TIFFmemcpy(&o[2 * m], tif->tif_dir.td_transferfunction[2], - m * sizeof(uint16_t)); - p = TIFFWriteDirectoryTagCheckedShortArray( - tif, ndir, dir, TIFFTAG_TRANSFERFUNCTION, n * m, o); - _TIFFfreeExt(tif, o); - return (p); + static const char module[] = "TIFFWriteDirectoryTagTransferfunction"; + uint32 m; + uint16 n; + uint16* o; + int p; + if (dir==NULL) + { + (*ndir)++; + return(1); + } + /* TIFFTAG_TRANSFERFUNCTION expects (1 or 3) pointer to arrays with + * (1 << BitsPerSample) * uint16 values. + */ + m=(1<tif_dir.td_bitspersample); + n=(tif->tif_dir.td_samplesperpixel-tif->tif_dir.td_extrasamples) > 1 ? 3 : 1; + /* Check for proper number of transferfunctions */ + for (p=0; ptif_dir.td_transferfunction[p] == NULL) + { + TIFFWarningExt(tif->tif_clientdata,module, + "Too few TransferFunctions provided. Tag not written to file"); + return (1); /* Not an error; only tag is not written. */ + } + } + /* + * Check if the table can be written as a single column, + * or if it must be written as 3 columns. Note that we + * write a 3-column tag if there are 2 samples/pixel and + * a single column of data won't suffice--hmm. + */ + if (n==3) + { + if (!_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[1],m*sizeof(uint16))) + n=1; + } + o=_TIFFmalloc(n*m*sizeof(uint16)); + 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)); + if (n>1) + _TIFFmemcpy(&o[m],tif->tif_dir.td_transferfunction[1],m*sizeof(uint16)); + if (n>2) + _TIFFmemcpy(&o[2*m],tif->tif_dir.td_transferfunction[2],m*sizeof(uint16)); + p=TIFFWriteDirectoryTagCheckedShortArray(tif,ndir,dir,TIFFTAG_TRANSFERFUNCTION,n*m,o); + _TIFFfree(o); + return(p); } -static int TIFFWriteDirectoryTagSubifd(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir) +static int +TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir) { - static const char module[] = "TIFFWriteDirectoryTagSubifd"; - uint64_t m; - int n; - if (tif->tif_dir.td_nsubifd == 0) - return (1); - if (dir == NULL) - { - (*ndir)++; - return (1); - } - m = tif->tif_dataoff; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - uint32_t *o; - uint64_t *pa; - uint32_t *pb; - uint16_t p; - o = _TIFFmallocExt(tif, tif->tif_dir.td_nsubifd * sizeof(uint32_t)); - if (o == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - pa = tif->tif_dir.td_subifd; - pb = o; - for (p = 0; p < tif->tif_dir.td_nsubifd; p++) - { - assert(pa != 0); + static const char module[] = "TIFFWriteDirectoryTagSubifd"; + uint64 m; + int n; + if (tif->tif_dir.td_nsubifd==0) + return(1); + if (dir==NULL) + { + (*ndir)++; + return(1); + } + 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)); + if (o==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + pa=tif->tif_dir.td_subifd; + pb=o; + for (p=0; p < tif->tif_dir.td_nsubifd; p++) + { + assert(pa != 0); - /* Could happen if an classicTIFF has a SubIFD of type LONG8 (which - * is illegal) */ - if (*pa > 0xFFFFFFFFUL) - { - TIFFErrorExtR(tif, module, "Illegal value for SubIFD tag"); - _TIFFfreeExt(tif, o); - return (0); - } - *pb++ = (uint32_t)(*pa++); - } - n = TIFFWriteDirectoryTagCheckedIfdArray(tif, ndir, dir, TIFFTAG_SUBIFD, - tif->tif_dir.td_nsubifd, o); - _TIFFfreeExt(tif, o); - } - else - n = TIFFWriteDirectoryTagCheckedIfd8Array( - tif, ndir, dir, TIFFTAG_SUBIFD, tif->tif_dir.td_nsubifd, - tif->tif_dir.td_subifd); - if (!n) - return (0); - /* - * Total hack: if this directory includes a SubIFD - * tag then force the next directories to be - * written as ``sub directories'' of this one. This - * is used to write things like thumbnails and - * image masks that one wants to keep out of the - * normal directory linkage access mechanism. - */ - tif->tif_flags |= TIFF_INSUBIFD; - tif->tif_nsubifd = tif->tif_dir.td_nsubifd; - if (tif->tif_dir.td_nsubifd == 1) - tif->tif_subifdoff = 0; - else - tif->tif_subifdoff = m; - return (1); + /* Could happen if an classicTIFF has a SubIFD of type LONG8 (which is illegal) */ + if( *pa > 0xFFFFFFFFULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Illegal value for SubIFD tag"); + _TIFFfree(o); + return(0); + } + *pb++=(uint32)(*pa++); + } + n=TIFFWriteDirectoryTagCheckedIfdArray(tif,ndir,dir,TIFFTAG_SUBIFD,tif->tif_dir.td_nsubifd,o); + _TIFFfree(o); + } + else + n=TIFFWriteDirectoryTagCheckedIfd8Array(tif,ndir,dir,TIFFTAG_SUBIFD,tif->tif_dir.td_nsubifd,tif->tif_dir.td_subifd); + if (!n) + return(0); + /* + * Total hack: if this directory includes a SubIFD + * tag then force the next directories to be + * written as ``sub directories'' of this one. This + * is used to write things like thumbnails and + * image masks that one wants to keep out of the + * normal directory linkage access mechanism. + */ + tif->tif_flags|=TIFF_INSUBIFD; + tif->tif_nsubifd=tif->tif_dir.td_nsubifd; + if (tif->tif_dir.td_nsubifd==1) + tif->tif_subifdoff=0; + else + tif->tif_subifdoff=m; + return(1); } -static int TIFFWriteDirectoryTagCheckedAscii(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, char *value) +static int +TIFFWriteDirectoryTagCheckedAscii(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, char* value) { - assert(sizeof(char) == 1); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_ASCII, count, - count, value)); + assert(sizeof(char)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_ASCII,count,count,value)); } -static int TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, - uint32_t count, - uint8_t *value) +static int +TIFFWriteDirectoryTagCheckedUndefinedArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint8* value) { - assert(sizeof(uint8_t) == 1); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_UNDEFINED, - count, count, value)); + assert(sizeof(uint8)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_UNDEFINED,count,count,value)); } -static int TIFFWriteDirectoryTagCheckedByteArray(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) { - assert(sizeof(uint8_t) == 1); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_BYTE, count, - count, value)); + assert(sizeof(uint8)==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) +{ + assert(sizeof(uint8)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_BYTE,count,count,value)); } -static int TIFFWriteDirectoryTagCheckedSbyteArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - int8_t *value) +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedSbyte(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int8 value) { - assert(sizeof(int8_t) == 1); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SBYTE, count, - count, value)); + assert(sizeof(int8)==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) +{ + assert(sizeof(int8)==1); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SBYTE,count,count,value)); } -static int TIFFWriteDirectoryTagCheckedShort(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint16_t value) +static int +TIFFWriteDirectoryTagCheckedShort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 value) { - uint16_t m; - assert(sizeof(uint16_t) == 2); - m = value; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&m); - return ( - TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SHORT, 1, 2, &m)); + uint16 m; + assert(sizeof(uint16)==2); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SHORT,1,2,&m)); } -static int TIFFWriteDirectoryTagCheckedShortArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - uint16_t *value) +static int +TIFFWriteDirectoryTagCheckedShortArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint16* value) { - assert(count < 0x80000000); - 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)); + assert(count<0x80000000); + assert(sizeof(uint16)==2); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfShort(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SHORT,count,count*2,value)); } -static int TIFFWriteDirectoryTagCheckedSshortArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - int16_t *value) +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedSshort(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int16 value) { - assert(count < 0x80000000); - assert(sizeof(int16_t) == 2); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfShort((uint16_t *)value, count); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SSHORT, count, - count * 2, value)); + int16 m; + assert(sizeof(int16)==2); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort((uint16*)(&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) +{ + assert(count<0x80000000); + assert(sizeof(int16)==2); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfShort((uint16*)value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SSHORT,count,count*2,value)); } -static int TIFFWriteDirectoryTagCheckedLong(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t value) +static int +TIFFWriteDirectoryTagCheckedLong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 value) { - uint32_t m; - assert(sizeof(uint32_t) == 4); - m = value; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&m); - return ( - TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_LONG, 1, 4, &m)); + uint32 m; + assert(sizeof(uint32)==4); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG,1,4,&m)); } -static int TIFFWriteDirectoryTagCheckedLongArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - uint32_t *value) +static int +TIFFWriteDirectoryTagCheckedLongArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) { - assert(count < 0x40000000); - 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)); + assert(count<0x40000000); + assert(sizeof(uint32)==4); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG,count,count*4,value)); } -static int TIFFWriteDirectoryTagCheckedSlongArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - int32_t *value) +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedSlong(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int32 value) { - assert(count < 0x40000000); - assert(sizeof(int32_t) == 4); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong((uint32_t *)value, count); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SLONG, count, - count * 4, value)); + int32 m; + assert(sizeof(int32)==4); + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong((uint32*)(&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) +{ + assert(count<0x40000000); + assert(sizeof(int32)==4); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG,count,count*4,value)); } -static int TIFFWriteDirectoryTagCheckedLong8Array(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - uint64_t *value) +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedLong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint64 value) { - assert(count < 0x20000000); - assert(sizeof(uint64_t) == 8); - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - TIFFErrorExtR(tif, "TIFFWriteDirectoryTagCheckedLong8Array", - "LONG8 not allowed for ClassicTIFF"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong8(value, count); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_LONG8, count, - count * 8, value)); + uint64 m; + assert(sizeof(uint64)==8); + if( !(tif->tif_flags&TIFF_BIGTIFF) ) { + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8","LONG8 not allowed for ClassicTIFF"); + return(0); + } + m=value; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,1,8,&m)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) +{ + assert(count<0x20000000); + assert(sizeof(uint64)==8); + if( !(tif->tif_flags&TIFF_BIGTIFF) ) { + TIFFErrorExt(tif->tif_clientdata,"TIFFWriteDirectoryTagCheckedLong8Array","LONG8 not allowed for ClassicTIFF"); + return(0); + } + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_LONG8,count,count*8,value)); } -static int TIFFWriteDirectoryTagCheckedSlong8Array(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - int64_t *value) +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedSlong8(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, int64 value) { - assert(count < 0x20000000); - assert(sizeof(int64_t) == 8); - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - TIFFErrorExtR(tif, "TIFFWriteDirectoryTagCheckedSlong8Array", - "SLONG8 not allowed for ClassicTIFF"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong8((uint64_t *)value, count); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SLONG8, count, - count * 8, value)); + int64 m; + assert(sizeof(int64)==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)); + 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) +{ + assert(count<0x20000000); + assert(sizeof(int64)==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); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SLONG8,count,count*8,value)); } -static int TIFFWriteDirectoryTagCheckedRational(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - double value) +static int +TIFFWriteDirectoryTagCheckedRational(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) { - static const char module[] = "TIFFWriteDirectoryTagCheckedRational"; - uint32_t m[2]; - assert(sizeof(uint32_t) == 4); - if (value < 0) - { - TIFFErrorExtR(tif, module, "Negative value is illegal"); - return 0; - } - else if (value != value) - { - TIFFErrorExtR(tif, module, "Not-a-number value is illegal"); - return 0; - } - /*--Rational2Double: New function also used for non-custom rational tags. - * However, could be omitted here, because - * TIFFWriteDirectoryTagCheckedRational() is not used by code for custom - * tags, only by code for named-tiff-tags like FIELD_RESOLUTION and - * FIELD_POSITION */ - else - { - DoubleToRational(value, &m[0], &m[1]); - } + static const char module[] = "TIFFWriteDirectoryTagCheckedRational"; + uint32 m[2]; + assert(sizeof(uint32)==4); + if (value < 0) + { + TIFFErrorExt(tif->tif_clientdata, module, "Negative value is illegal"); + return 0; + } + else if (value != value) + { + TIFFErrorExt(tif->tif_clientdata, module, "Not-a-number value is illegal"); + return 0; + } +#ifdef not_def + else if (value==0.0) + { + m[0]=0; + m[1]=1; + } + else if (value <= 0xFFFFFFFFU && value==(double)(uint32)value) + { + m[0]=(uint32)value; + m[1]=1; + } + else if (value<1.0) + { + m[0]=(uint32)(value*0xFFFFFFFF); + m[1]=0xFFFFFFFF; + } + else + { + m[0]=0xFFFFFFFF; + m[1]=(uint32)(0xFFFFFFFF/value); + } +#else + /*--Rational2Double: New function also used for non-custom rational tags. + * However, could be omitted here, because TIFFWriteDirectoryTagCheckedRational() is not used by code for custom tags, + * only by code for named-tiff-tags like FIELD_RESOLUTION and FIELD_POSITION */ + else { + DoubleToRational(value, &m[0], &m[1]); + } +#endif - if (tif->tif_flags & TIFF_SWAB) - { - TIFFSwabLong(&m[0]); - TIFFSwabLong(&m[1]); - } - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_RATIONAL, 1, 8, - &m[0])); + if (tif->tif_flags&TIFF_SWAB) + { + TIFFSwabLong(&m[0]); + TIFFSwabLong(&m[1]); + } + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_RATIONAL,1,8,&m[0])); } -static int TIFFWriteDirectoryTagCheckedRationalArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, - uint32_t count, - float *value) +static int +TIFFWriteDirectoryTagCheckedRationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) { - static const char module[] = "TIFFWriteDirectoryTagCheckedRationalArray"; - uint32_t *m; - float *na; - uint32_t *nb; - uint32_t nc; - int o; - assert(sizeof(uint32_t) == 4); - m = _TIFFmallocExt(tif, count * 2 * sizeof(uint32_t)); - if (m == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - for (na = value, nb = m, nc = 0; nc < count; na++, nb += 2, nc++) - { - DoubleToRational(*na, &nb[0], &nb[1]); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong(m, count * 2); - o = TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_RATIONAL, count, - count * 8, &m[0]); - _TIFFfreeExt(tif, m); - return (o); + static const char module[] = "TIFFWriteDirectoryTagCheckedRationalArray"; + uint32* m; + float* na; + uint32* nb; + uint32 nc; + int o; + assert(sizeof(uint32)==4); + m=_TIFFmalloc(count*2*sizeof(uint32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=value, nb=m, nc=0; nc= 0 && *na <= (float)0xFFFFFFFFU && + *na==(float)(uint32)(*na)) + { + nb[0]=(uint32)(*na); + nb[1]=1; + } + else if (*na<1.0) + { + nb[0]=(uint32)((double)(*na)*0xFFFFFFFF); + nb[1]=0xFFFFFFFF; + } + else + { + nb[0]=0xFFFFFFFF; + nb[1]=(uint32)((double)0xFFFFFFFF/(*na)); + } +#else + /*-- Rational2Double: Also for float precision accuracy is sometimes enhanced --*/ + DoubleToRational(*na, &nb[0], &nb[1]); +#endif + } + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(m,count*2); + o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_RATIONAL,count,count*8,&m[0]); + _TIFFfree(m); + return(o); } -static int TIFFWriteDirectoryTagCheckedSrationalArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, - uint32_t count, - float *value) +static int +TIFFWriteDirectoryTagCheckedSrationalArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) { - static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalArray"; - int32_t *m; - float *na; - int32_t *nb; - uint32_t nc; - int o; - assert(sizeof(int32_t) == 4); - m = _TIFFmallocExt(tif, count * 2 * sizeof(int32_t)); - if (m == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - for (na = value, nb = m, nc = 0; nc < count; na++, nb += 2, nc++) - { - DoubleToSrational(*na, &nb[0], &nb[1]); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong((uint32_t *)m, count * 2); - o = TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SRATIONAL, count, - count * 8, &m[0]); - _TIFFfreeExt(tif, m); - return (o); + static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalArray"; + int32* m; + float* na; + int32* nb; + uint32 nc; + int o; + assert(sizeof(int32)==4); + m=_TIFFmalloc(count*2*sizeof(int32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=value, nb=m, nc=0; nc-1.0) + { + nb[0]=-(int32)((double)(-*na)*0x7FFFFFFF); + nb[1]=0x7FFFFFFF; + } + else + { + nb[0]=-0x7FFFFFFF; + nb[1]=(int32)((double)0x7FFFFFFF/(-*na)); + } + } + else + { + if (*na==(int32)(*na)) + { + nb[0]=(int32)(*na); + nb[1]=1; + } + else if (*na<1.0) + { + nb[0]=(int32)((double)(*na)*0x7FFFFFFF); + nb[1]=0x7FFFFFFF; + } + else + { + nb[0]=0x7FFFFFFF; + nb[1]=(int32)((double)0x7FFFFFFF/(*na)); + } + } +#else + /*-- Rational2Double: Also for float precision accuracy is sometimes enhanced --*/ + DoubleToSrational(*na, &nb[0], &nb[1]); +#endif + } + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)m,count*2); + o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SRATIONAL,count,count*8,&m[0]); + _TIFFfree(m); + return(o); } /*-- Rational2Double: additional write functions for double arrays */ static int -TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, double *value) +TIFFWriteDirectoryTagCheckedRationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) { - static const char module[] = - "TIFFWriteDirectoryTagCheckedRationalDoubleArray"; - uint32_t *m; - double *na; - uint32_t *nb; - uint32_t nc; - int o; - assert(sizeof(uint32_t) == 4); - m = _TIFFmallocExt(tif, count * 2 * sizeof(uint32_t)); - if (m == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - for (na = value, nb = m, nc = 0; nc < count; na++, nb += 2, nc++) - { - DoubleToRational(*na, &nb[0], &nb[1]); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong(m, count * 2); - o = TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_RATIONAL, count, - count * 8, &m[0]); - _TIFFfreeExt(tif, m); - return (o); + static const char module[] = "TIFFWriteDirectoryTagCheckedRationalDoubleArray"; + uint32* m; + double* na; + uint32* nb; + uint32 nc; + int o; + assert(sizeof(uint32)==4); + m=_TIFFmalloc(count*2*sizeof(uint32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=value, nb=m, nc=0; nctif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong(m,count*2); + o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_RATIONAL,count,count*8,&m[0]); + _TIFFfree(m); + return(o); } /*-- TIFFWriteDirectoryTagCheckedRationalDoubleArray() ------- */ -static int TIFFWriteDirectoryTagCheckedSrationalDoubleArray( - TIFF *tif, uint32_t *ndir, TIFFDirEntry *dir, uint16_t tag, uint32_t count, - double *value) +static int +TIFFWriteDirectoryTagCheckedSrationalDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) { - static const char module[] = - "TIFFWriteDirectoryTagCheckedSrationalDoubleArray"; - int32_t *m; - double *na; - int32_t *nb; - uint32_t nc; - int o; - assert(sizeof(int32_t) == 4); - m = _TIFFmallocExt(tif, count * 2 * sizeof(int32_t)); - if (m == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - for (na = value, nb = m, nc = 0; nc < count; na++, nb += 2, nc++) - { - DoubleToSrational(*na, &nb[0], &nb[1]); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong((uint32_t *)m, count * 2); - o = TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_SRATIONAL, count, - count * 8, &m[0]); - _TIFFfreeExt(tif, m); - return (o); + static const char module[] = "TIFFWriteDirectoryTagCheckedSrationalDoubleArray"; + int32* m; + double* na; + int32* nb; + uint32 nc; + int o; + assert(sizeof(int32)==4); + m=_TIFFmalloc(count*2*sizeof(int32)); + if (m==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + for (na=value, nb=m, nc=0; nctif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong((uint32*)m,count*2); + o=TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_SRATIONAL,count,count*8,&m[0]); + _TIFFfree(m); + return(o); } /*--- TIFFWriteDirectoryTagCheckedSrationalDoubleArray() -------- */ -/** ----- Rational2Double: Double To Rational Conversion ----------------------------------------------------------- -* There is a mathematical theorem to convert real numbers into a rational -(integer fraction) number. -* This is called "continuous fraction" which uses the Euclidean algorithm to -find the greatest common divisor (GCD). -* (ref. e.g. https://de.wikipedia.org/wiki/Kettenbruch or -https://en.wikipedia.org/wiki/Continued_fraction +#if 0 +static +void DoubleToRational_direct(double value, unsigned long *num, unsigned long *denom) +{ + /*--- OLD Code for debugging and comparison ---- */ + /* code merged from TIFFWriteDirectoryTagCheckedRationalArray() and TIFFWriteDirectoryTagCheckedRational() */ + + /* First check for zero and also check for negative numbers (which are illegal for RATIONAL) + * and also check for "not-a-number". In each case just set this to zero to support also rational-arrays. + */ + if (value<=0.0 || value != value) + { + *num=0; + *denom=1; + } + else if (value <= 0xFFFFFFFFU && (value==(double)(uint32)(value))) /* check for integer values */ + { + *num=(uint32)(value); + *denom=1; + } + else if (value<1.0) + { + *num = (uint32)((value) * (double)0xFFFFFFFFU); + *denom=0xFFFFFFFFU; + } + else + { + *num=0xFFFFFFFFU; + *denom=(uint32)((double)0xFFFFFFFFU/(value)); + } +} /*-- DoubleToRational_direct() -------------- */ +#endif + +#if 0 +static +void DoubleToSrational_direct(double value, long *num, long *denom) +{ + /*--- OLD Code for debugging and comparison -- SIGNED-version ----*/ + /* code was amended from original TIFFWriteDirectoryTagCheckedSrationalArray() */ + + /* First check for zero and also check for negative numbers (which are illegal for RATIONAL) + * and also check for "not-a-number". In each case just set this to zero to support also rational-arrays. + */ + if (value<0.0) + { + if (value==(int32)(value)) + { + *num=(int32)(value); + *denom=1; + } + else if (value>-1.0) + { + *num=-(int32)((-value) * (double)0x7FFFFFFF); + *denom=0x7FFFFFFF; + } + else + { + *num=-0x7FFFFFFF; + *denom=(int32)((double)0x7FFFFFFF / (-value)); + } + } + else + { + if (value==(int32)(value)) + { + *num=(int32)(value); + *denom=1; + } + else if (value<1.0) + { + *num=(int32)((value) *(double)0x7FFFFFFF); + *denom=0x7FFFFFFF; + } + else + { + *num=0x7FFFFFFF; + *denom=(int32)((double)0x7FFFFFFF / (value)); + } + } +} /*-- DoubleToSrational_direct() --------------*/ +#endif + +//#define DOUBLE2RAT_DEBUGOUTPUT +/** ----- Rational2Double: Double To Rational Conversion ---------------------------------------------------------- +* There is a mathematical theorem to convert real numbers into a rational (integer fraction) number. +* This is called "continuous fraction" which uses the Euclidean algorithm to find the greatest common divisor (GCD). +* (ref. e.g. https://de.wikipedia.org/wiki/Kettenbruch or https://en.wikipedia.org/wiki/Continued_fraction * https://en.wikipedia.org/wiki/Euclidean_algorithm) * The following functions implement the -* - ToRationalEuclideanGCD() auxiliary function which mainly -implements euclidean GCD -* - DoubleToRational() conversion function for un-signed -rationals +* - ToRationalEuclideanGCD() auxiliary function which mainly implements euclidean GCD +* - DoubleToRational() conversion function for un-signed rationals * - DoubleToSrational() conversion function for signed rationals ------------------------------------------------------------------------------------------------------------------*/ @@ -2534,627 +2717,583 @@ rationals * Calculates the rational fractional of a double input value * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ -static void ToRationalEuclideanGCD(double value, int blnUseSignedRange, - int blnUseSmallRange, uint64_t *ullNum, - uint64_t *ullDenom) +static +void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmallRange, unsigned long long *ullNum, unsigned long long *ullDenom) { - /* Internally, the integer variables can be bigger than the external ones, - * as long as the result will fit into the external variable size. - */ - uint64_t numSum[3] = {0, 1, 0}, denomSum[3] = {1, 0, 0}; - uint64_t aux, bigNum, bigDenom; - uint64_t returnLimit; - int i; - uint64_t nMax; - double fMax; - unsigned long maxDenom; - /*-- nMax and fMax defines the initial accuracy of the starting fractional, - * or better, the highest used integer numbers used within the starting - * fractional (bigNum/bigDenom). There are two approaches, which can - * accidentally lead to different accuracies just depending on the value. - * Therefore, blnUseSmallRange steers this behavior. - * For long long nMax = ((9223372036854775807-1)/2); for long nMax = - * ((2147483647-1)/2); - */ - if (blnUseSmallRange) - { - nMax = (uint64_t)((2147483647 - 1) / 2); /* for ULONG range */ - } - else - { - nMax = ((9223372036854775807 - 1) / 2); /* for ULLONG range */ - } - fMax = (double)nMax; + /* 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; + int i; + unsigned long long nMax; + double fMax; + unsigned long maxDenom; + /*-- nMax and fMax defines the initial accuracy of the starting fractional, + * or better, the highest used integer numbers used within the starting fractional (bigNum/bigDenom). + * There are two approaches, which can accidentally lead to different accuracies just depending on the value. + * Therefore, blnUseSmallRange steers this behavior. + * 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 */ + } + else { + nMax = ((9223372036854775807 - 1) / 2); /* for ULLONG range */ + } + fMax = (double)nMax; - /*-- For the Euclidean GCD define the denominator range, so that it stays - * within size of unsigned long variables. maxDenom should be LONG_MAX for - * negative values and ULONG_MAX for positive ones. Also the final returned - * value of ullNum and ullDenom is limited according to signed- or - * unsigned-range. - */ - if (blnUseSignedRange) - { - maxDenom = 2147483647UL; /*LONG_MAX = 0x7FFFFFFFUL*/ - returnLimit = maxDenom; - } - else - { - maxDenom = 0xFFFFFFFFUL; /*ULONG_MAX = 0xFFFFFFFFUL*/ - returnLimit = maxDenom; - } + /*-- For the Euclidean GCD define the denominator range, so that it stays within size of unsigned long variables. + * maxDenom should be LONG_MAX for negative values and ULONG_MAX for positive ones. + * Also the final returned value of ullNum and ullDenom is limited according to signed- or unsigned-range. + */ + if (blnUseSignedRange) { + maxDenom = 2147483647UL; /*LONG_MAX = 0x7FFFFFFFUL*/ + returnLimit = maxDenom; + } + else { + maxDenom = 0xFFFFFFFFUL; /*ULONG_MAX = 0xFFFFFFFFUL*/ + returnLimit = maxDenom; + } - /*-- First generate a rational fraction (bigNum/bigDenom) which represents - *the value 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_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; - while ((value != floor(value)) && (value < fMax) && (bigDenom < nMax)) - { - bigDenom <<= 1; - value *= 2; - } - bigNum = (uint64_t)value; + /*-- 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. + * 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, + * and stop with enlargement of fraction when the double-value of it reaches an integer number without fractional part. + */ + bigDenom = 1; + while ((value != floor(value)) && (value < fMax) && (bigDenom < nMax)) { + bigDenom <<= 1; + value *= 2; + } + bigNum = (unsigned long long)value; - /*-- Start Euclidean algorithm to find the greatest common divisor (GCD) -- - */ + /*-- 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) - { - break; - } - val = bigNum / bigDenom; + for (i = 0; i < MAX_ITERATIONS; i++) { + /* if bigDenom is not zero, calculate integer part of fraction. */ + if (bigDenom == 0) { + val = 0; + break; + } + else { + val = bigNum / bigDenom; + } - /* Set bigDenom to reminder of bigNum/bigDenom and bigNum to previous - * denominator bigDenom. */ - aux = bigNum; - bigNum = bigDenom; - bigDenom = aux % bigDenom; + /* Set bigDenom to reminder of bigNum/bigDenom and bigNum to previous denominator bigDenom. */ + aux = bigNum; + bigNum = bigDenom; + bigDenom = aux % bigDenom; - /* calculate next denominator and check for its given maximum */ - aux = val; - if (denomSum[1] * val + denomSum[0] >= maxDenom) - { - aux = (maxDenom - denomSum[0]) / denomSum[1]; - if (aux * 2 >= val || denomSum[1] >= maxDenom) - i = (MAX_ITERATIONS + - 1); /* exit but execute rest of for-loop */ - else - break; - } - /* calculate next numerator to numSum2 and save previous one to numSum0; - * numSum1 just copy of numSum2. */ - numSum[2] = aux * numSum[1] + numSum[0]; - numSum[0] = numSum[1]; - numSum[1] = numSum[2]; - /* calculate next denominator to denomSum2 and save previous one to - * denomSum0; denomSum1 just copy of denomSum2. */ - denomSum[2] = aux * denomSum[1] + denomSum[0]; - denomSum[0] = denomSum[1]; - denomSum[1] = denomSum[2]; - } + /* calculate next denominator and check for its given maximum */ + aux = val; + if (denomSum[1] * val + denomSum[0] >= maxDenom) { + aux = (maxDenom - denomSum[0]) / denomSum[1]; + if (aux * 2 >= val || denomSum[1] >= maxDenom) + i = (MAX_ITERATIONS + 1); /* exit but execute rest of for-loop */ + else + break; + } + /* calculate next numerator to numSum2 and save previous one to numSum0; numSum1 just copy of numSum2. */ + numSum[2] = aux * numSum[1] + numSum[0]; + numSum[0] = numSum[1]; + numSum[1] = numSum[2]; + /* calculate next denominator to denomSum2 and save previous one to denomSum0; denomSum1 just copy of denomSum2. */ + denomSum[2] = aux * denomSum[1] + denomSum[0]; + denomSum[0] = denomSum[1]; + denomSum[1] = denomSum[2]; + } - /*-- Check and adapt for final variable size and return values; reduces - * internal accuracy; denominator is kept in ULONG-range with maxDenom -- */ - while (numSum[1] > returnLimit || denomSum[1] > returnLimit) - { - numSum[1] = numSum[1] / 2; - denomSum[1] = denomSum[1] / 2; - } + /*-- Check and adapt for final variable size and return values; reduces internal accuracy; denominator is kept in ULONG-range with maxDenom -- */ + while (numSum[1] > returnLimit || denomSum[1] > returnLimit) { + numSum[1] = numSum[1] / 2; + denomSum[1] = denomSum[1] / 2; + } - /* return values */ - *ullNum = numSum[1]; - *ullDenom = denomSum[1]; + /* return values */ + *ullNum = numSum[1]; + *ullDenom = denomSum[1]; + +} /*-- ToRationalEuclideanGCD() -------------- */ -} /*-- ToRationalEuclideanGCD() -------------- */ /**---- DoubleToRational() ----------------------------------------------- * Calculates the rational fractional of a double input value * for UN-SIGNED rationals, * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ -static void DoubleToRational(double value, uint32_t *num, uint32_t *denom) +static +void DoubleToRational(double value, uint32 *num, uint32 *denom) { - /*---- UN-SIGNED RATIONAL ---- */ - double dblDiff, dblDiff2; - uint64_t ullNum, ullDenom, ullNum2, ullDenom2; + /*---- UN-SIGNED RATIONAL ---- */ + double dblDiff, dblDiff2; + unsigned long long ullNum, ullDenom, ullNum2, ullDenom2; - /*-- Check for negative values. If so it is an error. */ - /* Test written that way to catch NaN */ - if (!(value >= 0)) - { - *num = *denom = 0; - TIFFErrorExt(0, "TIFFLib: DoubleToRational()", - " Negative Value for Unsigned Rational given."); - return; - } + /*-- Check for negative values. If so it is an error. */ + /* Test written that way to catch NaN */ + if (!(value >= 0)) { + *num = *denom = 0; + TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Negative Value for Unsigned Rational given."); + return; + } - /*-- Check for too big numbers (> ULONG_MAX) -- */ - if (value > 0xFFFFFFFFUL) - { - *num = 0xFFFFFFFFU; - *denom = 0; - return; - } - /*-- Check for easy integer numbers -- */ - if (value == (uint32_t)(value)) - { - *num = (uint32_t)value; - *denom = 1; - return; - } - /*-- Check for too small numbers for "unsigned long" type rationals -- */ - if (value < 1.0 / (double)0xFFFFFFFFUL) - { - *num = 0; - *denom = 0xFFFFFFFFU; - return; - } + /*-- Check for too big numbers (> ULONG_MAX) -- */ + if (value > 0xFFFFFFFFUL) { + *num = 0xFFFFFFFFU; + *denom = 0; + return; + } + /*-- Check for easy integer numbers -- */ + if (value == (uint32)(value)) { + *num = (uint32)value; + *denom = 1; + return; + } + /*-- Check for too small numbers for "unsigned long" type rationals -- */ + if (value < 1.0 / (double)0xFFFFFFFFUL) { + *num = 0; + *denom = 0xFFFFFFFFU; + return; + } - /*-- There are two approaches using the Euclidean algorithm, - * which can accidentally lead to different accuracies just depending on - * the value. Try both and define which one was better. - */ - ToRationalEuclideanGCD(value, FALSE, FALSE, &ullNum, &ullDenom); - ToRationalEuclideanGCD(value, FALSE, TRUE, &ullNum2, &ullDenom2); - /*-- Double-Check, that returned values fit into ULONG :*/ - if (ullNum > 0xFFFFFFFFUL || ullDenom > 0xFFFFFFFFUL || - ullNum2 > 0xFFFFFFFFUL || ullDenom2 > 0xFFFFFFFFUL) - { - 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); - } + /*-- There are two approaches using the Euclidean algorithm, + * which can accidentally lead to different accuracies just depending on the value. + * Try both and define which one was better. + */ + ToRationalEuclideanGCD(value, FALSE, FALSE, &ullNum, &ullDenom); + ToRationalEuclideanGCD(value, FALSE, TRUE, &ullNum2, &ullDenom2); + /*-- Double-Check, that returned values fit into ULONG :*/ + if (ullNum > 0xFFFFFFFFULL || ullDenom > 0xFFFFFFFFULL || ullNum2 > 0xFFFFFFFFULL || ullDenom2 > 0xFFFFFFFFULL) { +#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 + assert(0); + } - /* Check, which one has higher accuracy and take that. */ - dblDiff = fabs(value - ((double)ullNum / (double)ullDenom)); - dblDiff2 = fabs(value - ((double)ullNum2 / (double)ullDenom2)); - if (dblDiff < dblDiff2) - { - *num = (uint32_t)ullNum; - *denom = (uint32_t)ullDenom; - } - else - { - *num = (uint32_t)ullNum2; - *denom = (uint32_t)ullDenom2; - } -} /*-- DoubleToRational() -------------- */ + /* Check, which one has higher accuracy and take that. */ + dblDiff = fabs(value - ((double)ullNum / (double)ullDenom)); + dblDiff2 = fabs(value - ((double)ullNum2 / (double)ullDenom2)); + if (dblDiff < dblDiff2) { + *num = (uint32)ullNum; + *denom = (uint32)ullDenom; + } + else { + *num = (uint32)ullNum2; + *denom = (uint32)ullDenom2; + } +} /*-- DoubleToRational() -------------- */ /**---- DoubleToSrational() ----------------------------------------------- * Calculates the rational fractional of a double input value * for SIGNED rationals, * using the Euclidean algorithm to find the greatest common divisor (GCD) ------------------------------------------------------------------------*/ -static void DoubleToSrational(double value, int32_t *num, int32_t *denom) +static +void DoubleToSrational(double value, int32 *num, int32 *denom) { - /*---- SIGNED RATIONAL ----*/ - int neg = 1; - double dblDiff, dblDiff2; - uint64_t ullNum, ullDenom, ullNum2, ullDenom2; + /*---- SIGNED RATIONAL ----*/ + int neg = 1; + double dblDiff, dblDiff2; + unsigned long long 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; - } + /*-- 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; } - /*-- Check for too big numbers (> LONG_MAX) -- */ - if (value > 0x7FFFFFFFL) - { - *num = 0x7FFFFFFFL; - *denom = 0; - return; - } - /*-- Check for easy numbers -- */ - if (value == (int32_t)(value)) - { - *num = (int32_t)(neg * value); - *denom = 1; - return; - } - /*-- Check for too small numbers for "long" type rationals -- */ - if (value < 1.0 / (double)0x7FFFFFFFL) - { - *num = 0; - *denom = 0x7FFFFFFFL; - return; - } + /*-- Check for too big numbers (> LONG_MAX) -- */ + if (value > 0x7FFFFFFFL) { + *num = 0x7FFFFFFFL; + *denom = 0; + return; + } + /*-- Check for easy numbers -- */ + if (value == (int32)(value)) { + *num = (int32)(neg * value); + *denom = 1; + return; + } + /*-- Check for too small numbers for "long" type rationals -- */ + if (value < 1.0 / (double)0x7FFFFFFFL) { + *num = 0; + *denom = 0x7FFFFFFFL; + return; + } - /*-- There are two approaches using the Euclidean algorithm, - * which can accidentally lead to different accuracies just depending on - * the value. Try both and define which one was better. Furthermore, set - * behavior of ToRationalEuclideanGCD() to the range of signed-long. - */ - ToRationalEuclideanGCD(value, TRUE, FALSE, &ullNum, &ullDenom); - ToRationalEuclideanGCD(value, TRUE, TRUE, &ullNum2, &ullDenom2); - /*-- Double-Check, that returned values fit into LONG :*/ - if (ullNum > 0x7FFFFFFFL || ullDenom > 0x7FFFFFFFL || - ullNum2 > 0x7FFFFFFFL || ullDenom2 > 0x7FFFFFFFL) - { - 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); - } + /*-- There are two approaches using the Euclidean algorithm, + * which can accidentally lead to different accuracies just depending on the value. + * Try both and define which one was better. + * Furthermore, set behavior of ToRationalEuclideanGCD() to the range of signed-long. + */ + ToRationalEuclideanGCD(value, TRUE, FALSE, &ullNum, &ullDenom); + 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 + assert(0); + } - /* Check, which one has higher accuracy and take that. */ - dblDiff = fabs(value - ((double)ullNum / (double)ullDenom)); - dblDiff2 = fabs(value - ((double)ullNum2 / (double)ullDenom2)); - if (dblDiff < dblDiff2) - { - *num = (int32_t)(neg * (long)ullNum); - *denom = (int32_t)ullDenom; - } - else - { - *num = (int32_t)(neg * (long)ullNum2); - *denom = (int32_t)ullDenom2; - } -} /*-- DoubleToSrational() --------------*/ + /* Check, which one has higher accuracy and take that. */ + 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; + } + else { + *num = (int32)(neg * (long)ullNum2); + *denom = (int32)ullDenom2; + } +} /*-- DoubleToSrational() --------------*/ -static int TIFFWriteDirectoryTagCheckedFloatArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - float *value) + + + + +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedFloat(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, float value) { - assert(count < 0x40000000); - assert(sizeof(float) == 4); - TIFFCvtNativeToIEEEFloat(tif, count, &value); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfFloat(value, count); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_FLOAT, count, - count * 4, value)); + float m; + assert(sizeof(float)==4); + m=value; + TIFFCvtNativeToIEEEFloat(tif,1,&m); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabFloat(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_FLOAT,1,4,&m)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedFloatArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, float* value) +{ + assert(count<0x40000000); + assert(sizeof(float)==4); + TIFFCvtNativeToIEEEFloat(tif,count,&value); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfFloat(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_FLOAT,count,count*4,value)); } -static int TIFFWriteDirectoryTagCheckedDoubleArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - double *value) +#ifdef notdef +static int +TIFFWriteDirectoryTagCheckedDouble(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, double value) { - assert(count < 0x20000000); - assert(sizeof(double) == 8); - TIFFCvtNativeToIEEEDouble(tif, count, &value); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfDouble(value, count); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_DOUBLE, count, - count * 8, value)); + double m; + assert(sizeof(double)==8); + m=value; + TIFFCvtNativeToIEEEDouble(tif,1,&m); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabDouble(&m); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_DOUBLE,1,8,&m)); +} +#endif + +static int +TIFFWriteDirectoryTagCheckedDoubleArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, double* value) +{ + assert(count<0x20000000); + assert(sizeof(double)==8); + TIFFCvtNativeToIEEEDouble(tif,count,&value); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfDouble(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_DOUBLE,count,count*8,value)); } -static int TIFFWriteDirectoryTagCheckedIfdArray(TIFF *tif, uint32_t *ndir, - TIFFDirEntry *dir, uint16_t tag, - uint32_t count, uint32_t *value) +static int +TIFFWriteDirectoryTagCheckedIfdArray(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint32* value) { - assert(count < 0x40000000); - 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)); + assert(count<0x40000000); + assert(sizeof(uint32)==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_t *ndir, - TIFFDirEntry *dir, - uint16_t tag, uint32_t count, - uint64_t *value) +static int +TIFFWriteDirectoryTagCheckedIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint32 count, uint64* value) { - assert(count < 0x20000000); - assert(sizeof(uint64_t) == 8); - assert(tif->tif_flags & TIFF_BIGTIFF); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfLong8(value, count); - return (TIFFWriteDirectoryTagData(tif, ndir, dir, tag, TIFF_IFD8, count, - count * 8, value)); + assert(count<0x20000000); + assert(sizeof(uint64)==8); + assert(tif->tif_flags&TIFF_BIGTIFF); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabArrayOfLong8(value,count); + return(TIFFWriteDirectoryTagData(tif,ndir,dir,tag,TIFF_IFD8,count,count*8,value)); } -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 +TIFFWriteDirectoryTagData(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, uint16 tag, uint16 datatype, uint32 count, uint32 datalength, void* data) { - static const char module[] = "TIFFWriteDirectoryTagData"; - uint32_t m; - m = 0; - while (m < (*ndir)) - { - assert(dir[m].tdir_tag != tag); - if (dir[m].tdir_tag > tag) - break; - m++; - } - if (m < (*ndir)) - { - uint32_t n; - for (n = *ndir; n > m; n--) - dir[n] = dir[n - 1]; - } - dir[m].tdir_tag = tag; - dir[m].tdir_type = datatype; - dir[m].tdir_count = count; - dir[m].tdir_offset.toff_long8 = 0; - if (datalength <= ((tif->tif_flags & TIFF_BIGTIFF) ? 0x8U : 0x4U)) - { - if (data && datalength) + static const char module[] = "TIFFWriteDirectoryTagData"; + uint32 m; + m=0; + while (m<(*ndir)) + { + assert(dir[m].tdir_tag!=tag); + if (dir[m].tdir_tag>tag) + break; + m++; + } + if (m<(*ndir)) + { + uint32 n; + for (n=*ndir; n>m; n--) + dir[n]=dir[n-1]; + } + dir[m].tdir_tag=tag; + dir[m].tdir_type=datatype; + dir[m].tdir_count=count; + dir[m].tdir_offset.toff_long8 = 0; + if (datalength<=((tif->tif_flags&TIFF_BIGTIFF)?0x8U:0x4U)) { - _TIFFmemcpy(&dir[m].tdir_offset, data, datalength); + if( data && datalength ) + { + _TIFFmemcpy(&dir[m].tdir_offset,data,datalength); + } } - } - else - { - uint64_t na, nb; - na = tif->tif_dataoff; - nb = na + datalength; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - nb = (uint32_t)nb; - if ((nb < na) || (nb < datalength)) - { - TIFFErrorExtR(tif, module, "Maximum TIFF file size exceeded"); - return (0); - } - if (!SeekOK(tif, na)) - { - TIFFErrorExtR(tif, module, "IO error writing tag data"); - return (0); - } - if (datalength >= 0x80000000UL) - { - TIFFErrorExtR(tif, module, - "libtiff does not allow writing more than 2147483647 " - "bytes in a tag"); - return (0); - } - if (!WriteOK(tif, data, (tmsize_t)datalength)) - { - TIFFErrorExtR(tif, module, "IO error writing tag data"); - return (0); - } - tif->tif_dataoff = nb; - if (tif->tif_dataoff & 1) - tif->tif_dataoff++; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - uint32_t o; - o = (uint32_t)na; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&o); - _TIFFmemcpy(&dir[m].tdir_offset, &o, 4); - } - else - { - dir[m].tdir_offset.toff_long8 = na; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&dir[m].tdir_offset.toff_long8); - } - } - (*ndir)++; - return (1); + else + { + uint64 na,nb; + na=tif->tif_dataoff; + nb=na+datalength; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + nb=(uint32)nb; + if ((nbtif_clientdata,module,"Maximum TIFF file size exceeded"); + return(0); + } + if (!SeekOK(tif,na)) + { + TIFFErrorExt(tif->tif_clientdata,module,"IO error writing tag data"); + return(0); + } + assert(datalength<0x80000000UL); + if (!WriteOK(tif,data,(tmsize_t)datalength)) + { + TIFFErrorExt(tif->tif_clientdata,module,"IO error writing tag data"); + return(0); + } + tif->tif_dataoff=nb; + if (tif->tif_dataoff&1) + tif->tif_dataoff++; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 o; + o=(uint32)na; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong(&o); + _TIFFmemcpy(&dir[m].tdir_offset,&o,4); + } + else + { + dir[m].tdir_offset.toff_long8 = na; + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8(&dir[m].tdir_offset.toff_long8); + } + } + (*ndir)++; + return(1); } /* * Link the current directory into the directory chain for the file. */ -static int TIFFLinkDirectory(TIFF *tif) +static int +TIFFLinkDirectory(TIFF* tif) { - static const char module[] = "TIFFLinkDirectory"; + static const char module[] = "TIFFLinkDirectory"; - tif->tif_diroff = (TIFFSeekFile(tif, 0, SEEK_END) + 1) & (~((toff_t)1)); + tif->tif_diroff = (TIFFSeekFile(tif,0,SEEK_END)+1) & (~((toff_t)1)); - /* - * Handle SubIFDs - */ - if (tif->tif_flags & TIFF_INSUBIFD) - { - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - 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); - if (!WriteOK(tif, &m, 4)) - { - TIFFErrorExtR(tif, module, - "Error writing SubIFD directory link"); - return (0); - } - /* - * Advance to the next SubIFD or, if this is - * the last one configured, revert back to the - * normal directory linkage. - */ - if (--tif->tif_nsubifd) - tif->tif_subifdoff += 4; - else - tif->tif_flags &= ~TIFF_INSUBIFD; - return (1); - } - else - { - uint64_t m; - m = tif->tif_diroff; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&m); - (void)TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); - if (!WriteOK(tif, &m, 8)) - { - TIFFErrorExtR(tif, module, - "Error writing SubIFD directory link"); - return (0); - } - /* - * Advance to the next SubIFD or, if this is - * the last one configured, revert back to the - * normal directory linkage. - */ - if (--tif->tif_nsubifd) - tif->tif_subifdoff += 8; - else - tif->tif_flags &= ~TIFF_INSUBIFD; - return (1); - } - } + /* + * Handle SubIFDs + */ + if (tif->tif_flags & TIFF_INSUBIFD) + { + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 m; + m = (uint32)tif->tif_diroff; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&m); + (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); + if (!WriteOK(tif, &m, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing SubIFD directory link"); + return (0); + } + /* + * Advance to the next SubIFD or, if this is + * the last one configured, revert back to the + * normal directory linkage. + */ + if (--tif->tif_nsubifd) + tif->tif_subifdoff += 4; + else + tif->tif_flags &= ~TIFF_INSUBIFD; + return (1); + } + else + { + uint64 m; + m = tif->tif_diroff; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&m); + (void) TIFFSeekFile(tif, tif->tif_subifdoff, SEEK_SET); + if (!WriteOK(tif, &m, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing SubIFD directory link"); + return (0); + } + /* + * Advance to the next SubIFD or, if this is + * the last one configured, revert back to the + * normal directory linkage. + */ + if (--tif->tif_nsubifd) + tif->tif_subifdoff += 8; + else + tif->tif_flags &= ~TIFF_INSUBIFD; + return (1); + } + } - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - 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_t)tif->tif_diroff; - tif->tif_lastdiroff = tif->tif_diroff; - (void)TIFFSeekFile(tif, 4, SEEK_SET); - if (!WriteOK(tif, &m, 4)) - { - TIFFErrorExtR(tif, tif->tif_name, "Error writing TIFF header"); - return (0); - } - return (1); - } - /* - * Not the first directory, search to the last and append. - */ - if (tif->tif_lastdiroff != 0) - { - nextdir = (uint32_t)tif->tif_lastdiroff; - } - else - { - nextdir = tif->tif_header.classic.tiff_diroff; - } + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + uint32 m; + uint32 nextdir; + m = (uint32)(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; + (void) TIFFSeekFile(tif,4, SEEK_SET); + if (!WriteOK(tif, &m, 4)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Error writing TIFF header"); + return (0); + } + return (1); + } + /* + * Not the first directory, search to the last and append. + */ + nextdir = tif->tif_header.classic.tiff_diroff; + while(1) { + uint16 dircount; + uint32 nextnextdir; - while (1) - { - uint16_t dircount; - uint32_t nextnextdir; + if (!SeekOK(tif, nextdir) || + !ReadOK(tif, &dircount, 2)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&dircount); + (void) TIFFSeekFile(tif, + nextdir+2+dircount*12, SEEK_SET); + if (!ReadOK(tif, &nextnextdir, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory link"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&nextnextdir); + if (nextnextdir==0) + { + (void) TIFFSeekFile(tif, + nextdir+2+dircount*12, SEEK_SET); + if (!WriteOK(tif, &m, 4)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + break; + } + nextdir=nextnextdir; + } + } + else + { + uint64 m; + uint64 nextdir; + m = tif->tif_diroff; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&m); + if (tif->tif_header.big.tiff_diroff == 0) { + /* + * First directory, overwrite offset in header. + */ + tif->tif_header.big.tiff_diroff = tif->tif_diroff; + (void) TIFFSeekFile(tif,8, SEEK_SET); + if (!WriteOK(tif, &m, 8)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Error writing TIFF header"); + return (0); + } + return (1); + } + /* + * Not the first directory, search to the last and append. + */ + nextdir = tif->tif_header.big.tiff_diroff; + while(1) { + uint64 dircount64; + uint16 dircount; + uint64 nextnextdir; - if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount, 2)) - { - TIFFErrorExtR(tif, module, "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&dircount); - (void)TIFFSeekFile(tif, nextdir + 2 + dircount * 12, SEEK_SET); - if (!ReadOK(tif, &nextnextdir, 4)) - { - TIFFErrorExtR(tif, module, "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&nextnextdir); - if (nextnextdir == 0) - { - (void)TIFFSeekFile(tif, nextdir + 2 + dircount * 12, SEEK_SET); - if (!WriteOK(tif, &m, 4)) - { - TIFFErrorExtR(tif, module, "Error writing directory link"); - return (0); - } - tif->tif_lastdiroff = tif->tif_diroff; - break; - } - nextdir = nextnextdir; - } - } - else - { - uint64_t m; - uint64_t nextdir; - m = tif->tif_diroff; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&m); - if (tif->tif_header.big.tiff_diroff == 0) - { - /* - * First directory, overwrite offset in header. - */ - tif->tif_header.big.tiff_diroff = tif->tif_diroff; - tif->tif_lastdiroff = tif->tif_diroff; - (void)TIFFSeekFile(tif, 8, SEEK_SET); - if (!WriteOK(tif, &m, 8)) - { - TIFFErrorExtR(tif, tif->tif_name, "Error writing TIFF header"); - return (0); - } - return (1); - } - /* - * Not the first directory, search to the last and append. - */ - if (tif->tif_lastdiroff != 0) - { - nextdir = tif->tif_lastdiroff; - } - else - { - nextdir = tif->tif_header.big.tiff_diroff; - } - while (1) - { - uint64_t dircount64; - uint16_t dircount; - uint64_t nextnextdir; - - if (!SeekOK(tif, nextdir) || !ReadOK(tif, &dircount64, 8)) - { - TIFFErrorExtR(tif, module, "Error fetching directory count"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&dircount64); - if (dircount64 > 0xFFFF) - { - TIFFErrorExtR( - tif, module, - "Sanity check on tag count failed, likely corrupt TIFF"); - return (0); - } - dircount = (uint16_t)dircount64; - (void)TIFFSeekFile(tif, nextdir + 8 + dircount * 20, SEEK_SET); - if (!ReadOK(tif, &nextnextdir, 8)) - { - TIFFErrorExtR(tif, module, "Error fetching directory link"); - return (0); - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&nextnextdir); - if (nextnextdir == 0) - { - (void)TIFFSeekFile(tif, nextdir + 8 + dircount * 20, SEEK_SET); - if (!WriteOK(tif, &m, 8)) - { - TIFFErrorExtR(tif, module, "Error writing directory link"); - return (0); - } - tif->tif_lastdiroff = tif->tif_diroff; - break; - } - nextdir = nextnextdir; - } - } - return (1); + if (!SeekOK(tif, nextdir) || + !ReadOK(tif, &dircount64, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory count"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFF) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sanity check on tag count failed, likely corrupt TIFF"); + return (0); + } + dircount=(uint16)dircount64; + (void) TIFFSeekFile(tif, + nextdir+8+dircount*20, SEEK_SET); + if (!ReadOK(tif, &nextnextdir, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error fetching directory link"); + return (0); + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong8(&nextnextdir); + if (nextnextdir==0) + { + (void) TIFFSeekFile(tif, + nextdir+8+dircount*20, SEEK_SET); + if (!WriteOK(tif, &m, 8)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); + return (0); + } + break; + } + nextdir=nextnextdir; + } + } + return (1); } /************************************************************************/ @@ -3170,186 +3309,183 @@ static int TIFFLinkDirectory(TIFF *tif) /* Returns zero on failure, and one on success. */ /************************************************************************/ -int _TIFFRewriteField(TIFF *tif, uint16_t tag, TIFFDataType in_datatype, - tmsize_t count, void *data) +int +_TIFFRewriteField(TIFF* tif, uint16 tag, TIFFDataType in_datatype, + tmsize_t count, void* data) { static const char module[] = "TIFFResetField"; /* const TIFFField* fip = NULL; */ - uint16_t dircount; + uint16 dircount; tmsize_t dirsize; - 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_t read_offset; - uint8_t *buf_to_write = NULL; + uint8 direntry_raw[20]; + uint16 entry_tag = 0; + uint16 entry_type = 0; + uint64 entry_count = 0; + uint64 entry_offset = 0; + int value_in_entry = 0; + uint64 read_offset; + uint8 *buf_to_write = NULL; TIFFDataType datatype; - /* -------------------------------------------------------------------- */ - /* Find field definition. */ - /* -------------------------------------------------------------------- */ - /*fip =*/TIFFFindField(tif, tag, TIFF_ANY); +/* -------------------------------------------------------------------- */ +/* Find field definition. */ +/* -------------------------------------------------------------------- */ + /*fip =*/ TIFFFindField(tif, tag, TIFF_ANY); - /* -------------------------------------------------------------------- */ - /* Do some checking this is a straight forward case. */ - /* -------------------------------------------------------------------- */ - if (isMapped(tif)) +/* -------------------------------------------------------------------- */ +/* Do some checking this is a straight forward case. */ +/* -------------------------------------------------------------------- */ + if( isMapped(tif) ) { - TIFFErrorExtR( - tif, module, - "Memory mapped files not currently supported for this operation."); + TIFFErrorExt( tif->tif_clientdata, module, + "Memory mapped files not currently supported for this operation." ); return 0; } - if (tif->tif_diroff == 0) + if( tif->tif_diroff == 0 ) { - TIFFErrorExtR( - tif, module, - "Attempt to reset field on directory not already on disk."); + TIFFErrorExt( tif->tif_clientdata, module, + "Attempt to reset field on directory not already on disk." ); return 0; } - /* -------------------------------------------------------------------- */ - /* Read the directory entry count. */ - /* -------------------------------------------------------------------- */ - if (!SeekOK(tif, tif->tif_diroff)) - { - TIFFErrorExtR(tif, module, "%s: Seek error accessing TIFF directory", - tif->tif_name); +/* -------------------------------------------------------------------- */ +/* Read the directory entry count. */ +/* -------------------------------------------------------------------- */ + if (!SeekOK(tif, tif->tif_diroff)) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Seek error accessing TIFF directory", + tif->tif_name); return 0; } read_offset = tif->tif_diroff; - if (!(tif->tif_flags & TIFF_BIGTIFF)) + if (!(tif->tif_flags&TIFF_BIGTIFF)) { - if (!ReadOK(tif, &dircount, sizeof(uint16_t))) - { - TIFFErrorExtR(tif, module, "%s: Can not read TIFF directory count", - tif->tif_name); + if (!ReadOK(tif, &dircount, sizeof (uint16))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory count", + tif->tif_name); return 0; } if (tif->tif_flags & TIFF_SWAB) TIFFSwabShort(&dircount); dirsize = 12; read_offset += 2; - } - else - { - uint64_t dircount64; - if (!ReadOK(tif, &dircount64, sizeof(uint64_t))) - { - TIFFErrorExtR(tif, module, "%s: Can not read TIFF directory count", - tif->tif_name); + } else { + uint64 dircount64; + if (!ReadOK(tif, &dircount64, sizeof (uint64))) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory count", + tif->tif_name); return 0; } if (tif->tif_flags & TIFF_SWAB) TIFFSwabLong8(&dircount64); - dircount = (uint16_t)dircount64; + dircount = (uint16)dircount64; dirsize = 20; read_offset += 8; } - /* -------------------------------------------------------------------- */ - /* Read through directory to find target tag. */ - /* -------------------------------------------------------------------- */ - while (dircount > 0) +/* -------------------------------------------------------------------- */ +/* Read through directory to find target tag. */ +/* -------------------------------------------------------------------- */ + while( dircount > 0 ) { - if (!ReadOK(tif, direntry_raw, dirsize)) - { - TIFFErrorExtR(tif, module, "%s: Can not read TIFF directory entry.", - tif->tif_name); + if (!ReadOK(tif, direntry_raw, dirsize)) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not read TIFF directory entry.", + tif->tif_name); return 0; } - memcpy(&entry_tag, direntry_raw + 0, sizeof(uint16_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&entry_tag); + memcpy( &entry_tag, direntry_raw + 0, sizeof(uint16) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort( &entry_tag ); - if (entry_tag == tag) + if( entry_tag == tag ) break; read_offset += dirsize; } - if (entry_tag != tag) + if( entry_tag != tag ) { - TIFFErrorExtR(tif, module, "%s: Could not find tag %" PRIu16 ".", - tif->tif_name, tag); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Could not find tag %d.", + tif->tif_name, tag ); return 0; } - /* -------------------------------------------------------------------- */ - /* Extract the type, count and offset for this entry. */ - /* -------------------------------------------------------------------- */ - memcpy(&entry_type, direntry_raw + 2, sizeof(uint16_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&entry_type); +/* -------------------------------------------------------------------- */ +/* Extract the type, count and offset for this entry. */ +/* -------------------------------------------------------------------- */ + memcpy( &entry_type, direntry_raw + 2, sizeof(uint16) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort( &entry_type ); - if (!(tif->tif_flags & TIFF_BIGTIFF)) + if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32_t value; - - memcpy(&value, direntry_raw + 4, sizeof(uint32_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&value); + uint32 value; + + memcpy( &value, direntry_raw + 4, sizeof(uint32) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong( &value ); entry_count = value; - memcpy(&value, direntry_raw + 8, sizeof(uint32_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&value); + memcpy( &value, direntry_raw + 8, sizeof(uint32) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong( &value ); entry_offset = value; } else { - memcpy(&entry_count, direntry_raw + 4, sizeof(uint64_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&entry_count); + memcpy( &entry_count, direntry_raw + 4, sizeof(uint64) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8( &entry_count ); - memcpy(&entry_offset, direntry_raw + 12, sizeof(uint64_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8(&entry_offset); + memcpy( &entry_offset, direntry_raw + 12, sizeof(uint64) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8( &entry_offset ); } - /* -------------------------------------------------------------------- */ - /* When a dummy tag was written due to TIFFDeferStrileArrayWriting() */ - /* -------------------------------------------------------------------- */ - if (entry_offset == 0 && entry_count == 0 && entry_type == 0) +/* -------------------------------------------------------------------- */ +/* When a dummy tag was written due to TIFFDeferStrileArrayWriting() */ +/* -------------------------------------------------------------------- */ + if( entry_offset == 0 && entry_count == 0 && entry_type == 0 ) { - if (tag == TIFFTAG_TILEOFFSETS || tag == TIFFTAG_STRIPOFFSETS) + if( tag == TIFFTAG_TILEOFFSETS || tag == TIFFTAG_STRIPOFFSETS ) { - entry_type = - (tif->tif_flags & TIFF_BIGTIFF) ? TIFF_LONG8 : TIFF_LONG; + entry_type = (tif->tif_flags&TIFF_BIGTIFF) ? TIFF_LONG8 : TIFF_LONG; } else { int write_aslong8 = 1; - if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS) + if( count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS ) { write_aslong8 = WriteAsLong8(tif, TIFFStripSize64(tif)); } - else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS) + else if( count > 1 && tag == TIFFTAG_TILEBYTECOUNTS ) { write_aslong8 = WriteAsLong8(tif, TIFFTileSize64(tif)); } - if (write_aslong8) + if( write_aslong8 ) { entry_type = TIFF_LONG8; } else { int write_aslong4 = 1; - if (count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS) + if( count > 1 && tag == TIFFTAG_STRIPBYTECOUNTS ) { write_aslong4 = WriteAsLong4(tif, TIFFStripSize64(tif)); } - else if (count > 1 && tag == TIFFTAG_TILEBYTECOUNTS) + else if( count > 1 && tag == TIFFTAG_TILEBYTECOUNTS ) { write_aslong4 = WriteAsLong4(tif, TIFFTileSize64(tif)); } - if (write_aslong4) + if( write_aslong4 ) { entry_type = TIFF_LONG; } @@ -3361,120 +3497,123 @@ int _TIFFRewriteField(TIFF *tif, uint16_t tag, TIFFDataType in_datatype, } } - /* -------------------------------------------------------------------- */ - /* What data type do we want to write this as? */ - /* -------------------------------------------------------------------- */ - if (TIFFDataWidth(in_datatype) == 8 && !(tif->tif_flags & TIFF_BIGTIFF)) +/* -------------------------------------------------------------------- */ +/* What data type do we want to write this as? */ +/* -------------------------------------------------------------------- */ + if( TIFFDataWidth(in_datatype) == 8 && !(tif->tif_flags&TIFF_BIGTIFF) ) { - if (in_datatype == TIFF_LONG8) + if( in_datatype == TIFF_LONG8 ) datatype = entry_type == TIFF_SHORT ? TIFF_SHORT : TIFF_LONG; - else if (in_datatype == TIFF_SLONG8) + else if( in_datatype == TIFF_SLONG8 ) datatype = TIFF_SLONG; - else if (in_datatype == TIFF_IFD8) + else if( in_datatype == TIFF_IFD8 ) datatype = TIFF_IFD; else datatype = in_datatype; } else { - if (in_datatype == TIFF_LONG8 && + if( in_datatype == TIFF_LONG8 && (entry_type == TIFF_SHORT || entry_type == TIFF_LONG || - entry_type == TIFF_LONG8)) + entry_type == TIFF_LONG8 ) ) datatype = entry_type; - else if (in_datatype == TIFF_SLONG8 && - (entry_type == TIFF_SLONG || entry_type == TIFF_SLONG8)) + else if( in_datatype == TIFF_SLONG8 && + (entry_type == TIFF_SLONG || entry_type == TIFF_SLONG8 ) ) datatype = entry_type; - else if (in_datatype == TIFF_IFD8 && - (entry_type == TIFF_IFD || entry_type == TIFF_IFD8)) + else if( in_datatype == TIFF_IFD8 && + (entry_type == TIFF_IFD || entry_type == TIFF_IFD8 ) ) datatype = entry_type; else datatype = in_datatype; } - /* -------------------------------------------------------------------- */ - /* Prepare buffer of actual data to write. This includes */ - /* swabbing as needed. */ - /* -------------------------------------------------------------------- */ - buf_to_write = (uint8_t *)_TIFFCheckMalloc( - tif, count, TIFFDataWidth(datatype), "for field buffer."); +/* -------------------------------------------------------------------- */ +/* Prepare buffer of actual data to write. This includes */ +/* swabbing as needed. */ +/* -------------------------------------------------------------------- */ + buf_to_write = + (uint8 *)_TIFFCheckMalloc(tif, count, TIFFDataWidth(datatype), + "for field buffer."); if (!buf_to_write) return 0; - if (datatype == in_datatype) - memcpy(buf_to_write, data, count * TIFFDataWidth(datatype)); - else if (datatype == TIFF_SLONG && in_datatype == TIFF_SLONG8) + if( datatype == in_datatype ) + memcpy( buf_to_write, data, count * TIFFDataWidth(datatype) ); + else if( datatype == TIFF_SLONG && in_datatype == TIFF_SLONG8 ) { - tmsize_t i; + tmsize_t i; - for (i = 0; i < count; i++) + for( i = 0; i < count; 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]) + ((int32 *) buf_to_write)[i] = + (int32) ((int64 *) data)[i]; + if( (int64) ((int32 *) buf_to_write)[i] != ((int64 *) data)[i] ) { - _TIFFfreeExt(tif, buf_to_write); - TIFFErrorExtR(tif, module, - "Value exceeds 32bit range of output type."); + _TIFFfree( buf_to_write ); + TIFFErrorExt( tif->tif_clientdata, module, + "Value exceeds 32bit range of output type." ); return 0; } } } - else if ((datatype == TIFF_LONG && in_datatype == TIFF_LONG8) || - (datatype == TIFF_IFD && in_datatype == TIFF_IFD8)) + else if( (datatype == TIFF_LONG && in_datatype == TIFF_LONG8) + || (datatype == TIFF_IFD && in_datatype == TIFF_IFD8) ) { - tmsize_t i; + tmsize_t i; - for (i = 0; i < count; i++) + for( i = 0; i < count; 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]) + ((uint32 *) buf_to_write)[i] = + (uint32) ((uint64 *) data)[i]; + if( (uint64) ((uint32 *) buf_to_write)[i] != ((uint64 *) data)[i] ) { - _TIFFfreeExt(tif, buf_to_write); - TIFFErrorExtR(tif, module, - "Value exceeds 32bit range of output type."); + _TIFFfree( buf_to_write ); + TIFFErrorExt( tif->tif_clientdata, module, + "Value exceeds 32bit range of output type." ); return 0; } } } - else if (datatype == TIFF_SHORT && in_datatype == TIFF_LONG8) + else if( datatype == TIFF_SHORT && in_datatype == TIFF_LONG8 ) { - tmsize_t i; + tmsize_t i; - for (i = 0; i < count; i++) + for( i = 0; i < count; 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]) + ((uint16 *) buf_to_write)[i] = + (uint16) ((uint64 *) data)[i]; + if( (uint64) ((uint16 *) buf_to_write)[i] != ((uint64 *) data)[i] ) { - _TIFFfreeExt(tif, buf_to_write); - TIFFErrorExtR(tif, module, - "Value exceeds 16bit range of output type."); + _TIFFfree( buf_to_write ); + TIFFErrorExt( tif->tif_clientdata, module, + "Value exceeds 16bit range of output type." ); return 0; } } } else { - TIFFErrorExtR(tif, module, "Unhandled type conversion."); + TIFFErrorExt( tif->tif_clientdata, module, + "Unhandled type conversion." ); return 0; } - if (TIFFDataWidth(datatype) > 1 && (tif->tif_flags & TIFF_SWAB)) + if( TIFFDataWidth(datatype) > 1 && (tif->tif_flags&TIFF_SWAB) ) { - if (TIFFDataWidth(datatype) == 2) - TIFFSwabArrayOfShort((uint16_t *)buf_to_write, count); - else if (TIFFDataWidth(datatype) == 4) - TIFFSwabArrayOfLong((uint32_t *)buf_to_write, count); - else if (TIFFDataWidth(datatype) == 8) - TIFFSwabArrayOfLong8((uint64_t *)buf_to_write, count); + if( TIFFDataWidth(datatype) == 2 ) + TIFFSwabArrayOfShort( (uint16 *) buf_to_write, count ); + else if( TIFFDataWidth(datatype) == 4 ) + TIFFSwabArrayOfLong( (uint32 *) buf_to_write, count ); + else if( TIFFDataWidth(datatype) == 8 ) + TIFFSwabArrayOfLong8( (uint64 *) buf_to_write, count ); } - /* -------------------------------------------------------------------- */ - /* Is this a value that fits into the directory entry? */ - /* -------------------------------------------------------------------- */ - if (!(tif->tif_flags & TIFF_BIGTIFF)) +/* -------------------------------------------------------------------- */ +/* Is this a value that fits into the directory entry? */ +/* -------------------------------------------------------------------- */ + if (!(tif->tif_flags&TIFF_BIGTIFF)) { - if (TIFFDataWidth(datatype) * count <= 4) + if( TIFFDataWidth(datatype) * count <= 4 ) { entry_offset = read_offset + 8; value_in_entry = 1; @@ -3482,139 +3621,136 @@ int _TIFFRewriteField(TIFF *tif, uint16_t tag, TIFFDataType in_datatype, } else { - if (TIFFDataWidth(datatype) * count <= 8) + if( TIFFDataWidth(datatype) * count <= 8 ) { entry_offset = read_offset + 12; value_in_entry = 1; } } - if ((tag == TIFFTAG_TILEOFFSETS || tag == TIFFTAG_STRIPOFFSETS) && + if( (tag == TIFFTAG_TILEOFFSETS || tag == TIFFTAG_STRIPOFFSETS) && tif->tif_dir.td_stripoffset_entry.tdir_count == 0 && tif->tif_dir.td_stripoffset_entry.tdir_type == 0 && - tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0) + tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 ) { tif->tif_dir.td_stripoffset_entry.tdir_type = datatype; tif->tif_dir.td_stripoffset_entry.tdir_count = count; } - else if ((tag == TIFFTAG_TILEBYTECOUNTS || - tag == TIFFTAG_STRIPBYTECOUNTS) && - tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0) + else if( (tag == TIFFTAG_TILEBYTECOUNTS || tag == TIFFTAG_STRIPBYTECOUNTS) && + tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0 ) { tif->tif_dir.td_stripbytecount_entry.tdir_type = datatype; tif->tif_dir.td_stripbytecount_entry.tdir_count = count; } - /* -------------------------------------------------------------------- */ - /* If the tag type, and count match, then we just write it out */ - /* over the old values without altering the directory entry at */ - /* all. */ - /* -------------------------------------------------------------------- */ - if (entry_count == (uint64_t)count && entry_type == (uint16_t)datatype) +/* -------------------------------------------------------------------- */ +/* If the tag type, and count match, then we just write it out */ +/* over the old values without altering the directory entry at */ +/* all. */ +/* -------------------------------------------------------------------- */ + if( entry_count == (uint64)count && entry_type == (uint16) datatype ) { - if (!SeekOK(tif, entry_offset)) - { - _TIFFfreeExt(tif, buf_to_write); - TIFFErrorExtR(tif, module, - "%s: Seek error accessing TIFF directory", - tif->tif_name); + if (!SeekOK(tif, entry_offset)) { + _TIFFfree( buf_to_write ); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Seek error accessing TIFF directory", + tif->tif_name); return 0; } - if (!WriteOK(tif, buf_to_write, count * TIFFDataWidth(datatype))) - { - _TIFFfreeExt(tif, buf_to_write); - TIFFErrorExtR(tif, module, "Error writing directory link"); + if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) { + _TIFFfree( buf_to_write ); + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); return (0); } - _TIFFfreeExt(tif, buf_to_write); + _TIFFfree( buf_to_write ); return 1; } - /* -------------------------------------------------------------------- */ - /* Otherwise, we write the new tag data at the end of the file. */ - /* -------------------------------------------------------------------- */ - if (!value_in_entry) +/* -------------------------------------------------------------------- */ +/* Otherwise, we write the new tag data at the end of the file. */ +/* -------------------------------------------------------------------- */ + if( !value_in_entry ) { - entry_offset = TIFFSeekFile(tif, 0, SEEK_END); - - if (!WriteOK(tif, buf_to_write, count * TIFFDataWidth(datatype))) - { - _TIFFfreeExt(tif, buf_to_write); - TIFFErrorExtR(tif, module, "Error writing directory link"); + entry_offset = TIFFSeekFile(tif,0,SEEK_END); + + if (!WriteOK(tif, buf_to_write, count*TIFFDataWidth(datatype))) { + _TIFFfree( buf_to_write ); + TIFFErrorExt(tif->tif_clientdata, module, + "Error writing directory link"); return (0); } } else { - if (count * TIFFDataWidth(datatype) == 4) - { - uint32_t value; - memcpy(&value, buf_to_write, count * TIFFDataWidth(datatype)); - entry_offset = value; - } - else - { - memcpy(&entry_offset, buf_to_write, - count * TIFFDataWidth(datatype)); - } + memcpy( &entry_offset, buf_to_write, count*TIFFDataWidth(datatype)); } - _TIFFfreeExt(tif, buf_to_write); + _TIFFfree( buf_to_write ); buf_to_write = 0; - /* -------------------------------------------------------------------- */ - /* Adjust the directory entry. */ - /* -------------------------------------------------------------------- */ +/* -------------------------------------------------------------------- */ +/* Adjust the directory entry. */ +/* -------------------------------------------------------------------- */ entry_type = datatype; - entry_count = (uint64_t)count; - memcpy(direntry_raw + 2, &entry_type, sizeof(uint16_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort((uint16_t *)(direntry_raw + 2)); + entry_count = (uint64)count; + memcpy( direntry_raw + 2, &entry_type, sizeof(uint16) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabShort( (uint16 *) (direntry_raw + 2) ); - if (!(tif->tif_flags & TIFF_BIGTIFF)) + if (!(tif->tif_flags&TIFF_BIGTIFF)) { - uint32_t value; + uint32 value; - value = (uint32_t)entry_count; - memcpy(direntry_raw + 4, &value, sizeof(uint32_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong((uint32_t *)(direntry_raw + 4)); + value = (uint32) entry_count; + memcpy( direntry_raw + 4, &value, sizeof(uint32) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong( (uint32 *) (direntry_raw + 4) ); - value = (uint32_t)entry_offset; - memcpy(direntry_raw + 8, &value, sizeof(uint32_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong((uint32_t *)(direntry_raw + 8)); + value = (uint32) entry_offset; + memcpy( direntry_raw + 8, &value, sizeof(uint32) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong( (uint32 *) (direntry_raw + 8) ); } else { - memcpy(direntry_raw + 4, &entry_count, sizeof(uint64_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)(direntry_raw + 4)); + memcpy( direntry_raw + 4, &entry_count, sizeof(uint64) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8( (uint64 *) (direntry_raw + 4) ); - memcpy(direntry_raw + 12, &entry_offset, sizeof(uint64_t)); - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong8((uint64_t *)(direntry_raw + 12)); + memcpy( direntry_raw + 12, &entry_offset, sizeof(uint64) ); + if (tif->tif_flags&TIFF_SWAB) + TIFFSwabLong8( (uint64 *) (direntry_raw + 12) ); } - /* -------------------------------------------------------------------- */ - /* Write the directory entry out to disk. */ - /* -------------------------------------------------------------------- */ - if (!SeekOK(tif, read_offset)) - { - TIFFErrorExtR(tif, module, "%s: Seek error accessing TIFF directory", - tif->tif_name); +/* -------------------------------------------------------------------- */ +/* Write the directory entry out to disk. */ +/* -------------------------------------------------------------------- */ + if (!SeekOK(tif, read_offset )) { + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Seek error accessing TIFF directory", + tif->tif_name); return 0; } - if (!WriteOK(tif, direntry_raw, dirsize)) + if (!WriteOK(tif, direntry_raw,dirsize)) { - TIFFErrorExtR(tif, module, "%s: Can not write TIFF directory entry.", - tif->tif_name); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: Can not write TIFF directory entry.", + tif->tif_name); return 0; } - + return 1; } +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dumpmode.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dumpmode.c index 267d5d2d7..4a0b07f50 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dumpmode.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_dumpmode.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -29,94 +29,113 @@ */ #include "tiffiop.h" -static int DumpFixupTags(TIFF *tif) +static int +DumpFixupTags(TIFF* tif) { - (void)tif; - return (1); + (void) tif; + return (1); } /* * Encode a hunk of pixels. */ -static int DumpModeEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s) +static int +DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s) { - (void)s; - while (cc > 0) - { - tmsize_t n; + (void) s; + while (cc > 0) { + tmsize_t n; - n = cc; - if (tif->tif_rawcc + n > tif->tif_rawdatasize) - n = tif->tif_rawdatasize - tif->tif_rawcc; + n = cc; + if (tif->tif_rawcc + n > tif->tif_rawdatasize) + n = tif->tif_rawdatasize - tif->tif_rawcc; - assert(n > 0); + assert( n > 0 ); - /* - * Avoid copy if client has setup raw - * data buffer to avoid extra copy. - */ - if (tif->tif_rawcp != pp) - _TIFFmemcpy(tif->tif_rawcp, pp, n); - tif->tif_rawcp += n; - tif->tif_rawcc += n; - pp += n; - cc -= n; - if (tif->tif_rawcc >= tif->tif_rawdatasize && !TIFFFlushData1(tif)) - return (0); - } - return (1); + /* + * Avoid copy if client has setup raw + * data buffer to avoid extra copy. + */ + if (tif->tif_rawcp != pp) + _TIFFmemcpy(tif->tif_rawcp, pp, n); + tif->tif_rawcp += n; + tif->tif_rawcc += n; + pp += n; + cc -= n; + if (tif->tif_rawcc >= tif->tif_rawdatasize && + !TIFFFlushData1(tif)) + return (0); + } + return (1); } /* * Decode a hunk of pixels. */ -static int DumpModeDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s) +static int +DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - static const char module[] = "DumpModeDecode"; - (void)s; - if (tif->tif_rawcc < cc) - { - TIFFErrorExtR(tif, module, - "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); - } - /* - * Avoid copy if client has setup raw - * data buffer to avoid extra copy. - */ - if (tif->tif_rawcp != buf) - _TIFFmemcpy(buf, tif->tif_rawcp, cc); - tif->tif_rawcp += cc; - tif->tif_rawcc -= cc; - return (1); + 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 + return (0); + } + /* + * Avoid copy if client has setup raw + * data buffer to avoid extra copy. + */ + if (tif->tif_rawcp != buf) + _TIFFmemcpy(buf, tif->tif_rawcp, cc); + tif->tif_rawcp += cc; + tif->tif_rawcc -= cc; + return (1); } /* * Seek forwards nrows in the current strip. */ -static int DumpModeSeek(TIFF *tif, uint32_t nrows) +static int +DumpModeSeek(TIFF* tif, uint32 nrows) { - tif->tif_rawcp += nrows * tif->tif_scanlinesize; - tif->tif_rawcc -= nrows * tif->tif_scanlinesize; - return (1); + tif->tif_rawcp += nrows * tif->tif_scanlinesize; + tif->tif_rawcc -= nrows * tif->tif_scanlinesize; + return (1); } /* * Initialize dump mode. */ -int TIFFInitDumpMode(TIFF *tif, int scheme) +int +TIFFInitDumpMode(TIFF* tif, int scheme) { - (void)scheme; - tif->tif_fixuptags = DumpFixupTags; - tif->tif_decoderow = DumpModeDecode; - tif->tif_decodestrip = DumpModeDecode; - tif->tif_decodetile = DumpModeDecode; - tif->tif_encoderow = DumpModeEncode; - tif->tif_encodestrip = DumpModeEncode; - tif->tif_encodetile = DumpModeEncode; - tif->tif_seek = DumpModeSeek; - return (1); + (void) scheme; + tif->tif_fixuptags = DumpFixupTags; + tif->tif_decoderow = DumpModeDecode; + tif->tif_decodestrip = DumpModeDecode; + tif->tif_decodetile = DumpModeDecode; + tif->tif_encoderow = DumpModeEncode; + tif->tif_encodestrip = DumpModeEncode; + tif->tif_encodetile = DumpModeEncode; + tif->tif_seek = DumpModeSeek; + return (1); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_error.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_error.c index ac0b9c373..651168f7d 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_error.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_error.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -29,104 +29,58 @@ TIFFErrorHandlerExt _TIFFerrorHandlerExt = NULL; -TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler) +TIFFErrorHandler +TIFFSetErrorHandler(TIFFErrorHandler handler) { - TIFFErrorHandler prev = _TIFFerrorHandler; - _TIFFerrorHandler = handler; - return (prev); + TIFFErrorHandler prev = _TIFFerrorHandler; + _TIFFerrorHandler = handler; + return (prev); } -TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler) +TIFFErrorHandlerExt +TIFFSetErrorHandlerExt(TIFFErrorHandlerExt handler) { - TIFFErrorHandlerExt prev = _TIFFerrorHandlerExt; - _TIFFerrorHandlerExt = handler; - return (prev); + TIFFErrorHandlerExt prev = _TIFFerrorHandlerExt; + _TIFFerrorHandlerExt = handler; + return (prev); } -void TIFFError(const char *module, const char *fmt, ...) +void +TIFFError(const char* module, const char* fmt, ...) { - va_list ap; - if (_TIFFerrorHandler) - { - va_start(ap, fmt); - (*_TIFFerrorHandler)(module, fmt, ap); - va_end(ap); - } - if (_TIFFerrorHandlerExt) - { - va_start(ap, fmt); - (*_TIFFerrorHandlerExt)(0, module, fmt, ap); - va_end(ap); - } + va_list ap; + if (_TIFFerrorHandler) { + va_start(ap, fmt); + (*_TIFFerrorHandler)(module, fmt, ap); + va_end(ap); + } + if (_TIFFerrorHandlerExt) { + va_start(ap, fmt); + (*_TIFFerrorHandlerExt)(0, module, fmt, ap); + va_end(ap); + } } -void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt, ...) +void +TIFFErrorExt(thandle_t fd, const char* module, const char* fmt, ...) { - va_list ap; - if (_TIFFerrorHandler) - { - va_start(ap, fmt); - (*_TIFFerrorHandler)(module, fmt, ap); - va_end(ap); - } - if (_TIFFerrorHandlerExt) - { - va_start(ap, fmt); - (*_TIFFerrorHandlerExt)(fd, module, fmt, ap); - va_end(ap); - } + va_list ap; + if (_TIFFerrorHandler) { + va_start(ap, fmt); + (*_TIFFerrorHandler)(module, fmt, ap); + va_end(ap); + } + if (_TIFFerrorHandlerExt) { + va_start(ap, fmt); + (*_TIFFerrorHandlerExt)(fd, module, fmt, ap); + va_end(ap); + } } -void _TIFFErrorEarly(TIFFOpenOptions *opts, thandle_t clientdata, - const char *module, const char *fmt, ...) -{ - va_list ap; - if (opts && opts->errorhandler) - { - va_start(ap, fmt); - int stop = opts->errorhandler(NULL, opts->errorhandler_user_data, - module, fmt, ap); - va_end(ap); - if (stop) - return; - } - if (_TIFFerrorHandler) - { - va_start(ap, fmt); - (*_TIFFerrorHandler)(module, fmt, ap); - va_end(ap); - } - if (_TIFFerrorHandlerExt) - { - va_start(ap, fmt); - (*_TIFFerrorHandlerExt)(clientdata, module, fmt, ap); - va_end(ap); - } -} - -void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt, ...) -{ - va_list ap; - if (tif && tif->tif_errorhandler) - { - va_start(ap, fmt); - int stop = (*tif->tif_errorhandler)( - tif, tif->tif_errorhandler_user_data, module, fmt, ap); - va_end(ap); - if (stop) - return; - } - if (_TIFFerrorHandler) - { - va_start(ap, fmt); - (*_TIFFerrorHandler)(module, fmt, ap); - va_end(ap); - } - if (_TIFFerrorHandlerExt) - { - va_start(ap, fmt); - (*_TIFFerrorHandlerExt)(tif ? tif->tif_clientdata : NULL, module, fmt, - ap); - va_end(ap); - } -} +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_extension.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_extension.c index 1a09e987a..87d3cfcbc 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_extension.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_extension.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -26,26 +26,26 @@ * TIFF Library. * * Various routines support external extension of the tag set, and other - * application extension capabilities. + * application extension capabilities. */ #include "tiffiop.h" -int TIFFGetTagListCount(TIFF *tif) +int TIFFGetTagListCount( TIFF *tif ) { - TIFFDirectory *td = &tif->tif_dir; - + TIFFDirectory* td = &tif->tif_dir; + return td->td_customValueCount; } -uint32_t TIFFGetTagListEntry(TIFF *tif, int tag_index) +uint32 TIFFGetTagListEntry( TIFF *tif, int tag_index ) { - TIFFDirectory *td = &tif->tif_dir; + TIFFDirectory* td = &tif->tif_dir; - if (tag_index < 0 || tag_index >= td->td_customValueCount) - return (uint32_t)(-1); + if( tag_index < 0 || tag_index >= td->td_customValueCount ) + return (uint32)(-1); else return td->td_customValues[tag_index].info->field_tag; } @@ -55,27 +55,27 @@ uint32_t TIFFGetTagListEntry(TIFF *tif, int tag_index) ** structure to application code without giving access to the private ** TIFF structure. */ -TIFFTagMethods *TIFFAccessTagMethods(TIFF *tif) +TIFFTagMethods *TIFFAccessTagMethods( TIFF *tif ) { return &(tif->tif_tagmethods); } -void *TIFFGetClientInfo(TIFF *tif, const char *name) +void *TIFFGetClientInfo( TIFF *tif, const char *name ) { TIFFClientInfoLink *psLink = tif->tif_clientinfo; - while (psLink != NULL && strcmp(psLink->name, name) != 0) + while( psLink != NULL && strcmp(psLink->name,name) != 0 ) psLink = psLink->next; - if (psLink != NULL) + if( psLink != NULL ) return psLink->data; else return NULL; } -void TIFFSetClientInfo(TIFF *tif, void *data, const char *name) +void TIFFSetClientInfo( TIFF *tif, void *data, const char *name ) { TIFFClientInfoLink *psLink = tif->tif_clientinfo; @@ -84,10 +84,10 @@ void TIFFSetClientInfo(TIFF *tif, void *data, const char *name) ** Do we have an existing link with this name? If so, just ** set it. */ - while (psLink != NULL && strcmp(psLink->name, name) != 0) + while( psLink != NULL && strcmp(psLink->name,name) != 0 ) psLink = psLink->next; - if (psLink != NULL) + if( psLink != NULL ) { psLink->data = data; return; @@ -97,14 +97,20 @@ void TIFFSetClientInfo(TIFF *tif, void *data, const char *name) ** Create a new link. */ - psLink = - (TIFFClientInfoLink *)_TIFFmallocExt(tif, sizeof(TIFFClientInfoLink)); - assert(psLink != NULL); + psLink = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink)); + assert (psLink != NULL); psLink->next = tif->tif_clientinfo; - psLink->name = (char *)_TIFFmallocExt(tif, (tmsize_t)(strlen(name) + 1)); - assert(psLink->name != NULL); + psLink->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1)); + assert (psLink->name != NULL); strcpy(psLink->name, name); psLink->data = data; tif->tif_clientinfo = psLink; } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_fax3.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_fax3.c index a3c645cb6..9ab5b26ad 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_fax3.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_fax3.c @@ -2,23 +2,23 @@ * Copyright (c) 1990-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -37,7 +37,7 @@ * Copyright (C) 1990, 1995 Frank D. Cringle. */ #include "tif_fax3.h" -#define G3CODES +#define G3CODES #include "t4.h" #include @@ -45,57 +45,51 @@ * Compression+decompression state blocks are * derived from this ``base state'' block. */ -typedef struct -{ - int rw_mode; /* O_RDONLY for decode, else encode */ - int mode; /* operating mode */ - tmsize_t rowbytes; /* bytes in a decoded scanline */ - uint32_t rowpixels; /* pixels in a scanline */ +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 */ - uint16_t cleanfaxdata; /* CleanFaxData tag */ - uint32_t badfaxrun; /* BadFaxRun tag */ - uint32_t badfaxlines; /* BadFaxLines tag */ - uint32_t groupoptions; /* Group 3/4 options tag */ + uint16 cleanfaxdata; /* CleanFaxData tag */ + uint32 badfaxrun; /* BadFaxRun tag */ + uint32 badfaxlines; /* BadFaxLines tag */ + uint32 groupoptions; /* Group 3/4 options tag */ - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFPrintMethod printdir; /* super-class method */ + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ + TIFFPrintMethod printdir; /* super-class method */ } Fax3BaseState; -#define Fax3State(tif) ((Fax3BaseState *)(tif)->tif_data) +#define Fax3State(tif) ((Fax3BaseState*) (tif)->tif_data) -typedef enum -{ - G3_1D, - G3_2D -} Ttag; -typedef struct -{ - Fax3BaseState b; +typedef enum { G3_1D, G3_2D } Ttag; +typedef struct { + Fax3BaseState b; - /* Decoder state info */ - const unsigned char *bitmap; /* bit reversal table */ - 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_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 */ + /* Decoder state info */ + const unsigned char* bitmap; /* bit reversal table */ + uint32 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 */ - /* Encoder state info */ - Ttag tag; /* encoding state */ - unsigned char *refline; /* reference line for 2d decoding */ - int k; /* #rows left that can be 2d encoded */ - int maxk; /* max #rows that can be 2d encoded */ + /* Encoder state info */ + Ttag tag; /* encoding state */ + unsigned char* refline; /* reference line for 2d decoding */ + int k; /* #rows left that can be 2d encoded */ + int maxk; /* max #rows that can be 2d encoded */ - int line; + int line; } Fax3CodecState; -#define DecoderState(tif) ((Fax3CodecState *)Fax3State(tif)) -#define EncoderState(tif) ((Fax3CodecState *)Fax3State(tif)) +#define DecoderState(tif) ((Fax3CodecState*) Fax3State(tif)) +#define EncoderState(tif) ((Fax3CodecState*) Fax3State(tif)) #define is2DEncoding(sp) (sp->b.groupoptions & GROUP3OPT_2DENCODING) -#define isAligned(p, t) ((((size_t)(p)) & (sizeof(t) - 1)) == 0) +#define isAligned(p,t) ((((size_t)(p)) & (sizeof (t)-1)) == 0) /* * Group 3 and Group 4 Decoding. @@ -105,81 +99,76 @@ typedef struct * These macros glue the TIFF library state to * the state expected by Frank's decoder. */ -#define DECLARE_STATE(tif, sp, mod) \ - static const char module[] = mod; \ - Fax3CodecState *sp = DecoderState(tif); \ - int a0; /* reference element */ \ - int lastx = sp->b.rowpixels; /* last element in row */ \ - 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_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_t \ - *pb /* next run in reference line */ /* \ - * Load any state that may be \ - * changed during decoding. \ - */ -#define CACHE_STATE(tif, sp) \ - do \ - { \ - BitAcc = sp->data; \ - BitsAvail = sp->bit; \ - EOLcnt = sp->EOLcnt; \ - cp = (unsigned char *)tif->tif_rawcp; \ - ep = cp + tif->tif_rawcc; \ - } while (0) +#define DECLARE_STATE(tif, sp, mod) \ + static const char module[] = mod; \ + Fax3CodecState* sp = DecoderState(tif); \ + int a0; /* reference element */ \ + int lastx = sp->b.rowpixels; /* last element in row */ \ + uint32 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 */ \ + 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 */\ +/* + * Load any state that may be changed during decoding. + */ +#define CACHE_STATE(tif, sp) do { \ + BitAcc = sp->data; \ + BitsAvail = sp->bit; \ + EOLcnt = sp->EOLcnt; \ + cp = (unsigned char*) tif->tif_rawcp; \ + ep = cp + tif->tif_rawcc; \ +} while (0) /* * Save state possibly changed during decoding. */ -#define UNCACHE_STATE(tif, sp) \ - do \ - { \ - sp->bit = BitsAvail; \ - sp->data = BitAcc; \ - sp->EOLcnt = EOLcnt; \ - tif->tif_rawcc -= (tmsize_t)((uint8_t *)cp - tif->tif_rawcp); \ - tif->tif_rawcp = (uint8_t *)cp; \ - } while (0) +#define UNCACHE_STATE(tif, sp) do { \ + sp->bit = BitsAvail; \ + sp->data = BitAcc; \ + sp->EOLcnt = EOLcnt; \ + tif->tif_rawcc -= (tmsize_t)((uint8*) cp - tif->tif_rawcp); \ + tif->tif_rawcp = (uint8*) cp; \ +} while (0) /* * Setup state for decoding a strip. */ -static int Fax3PreDecode(TIFF *tif, uint16_t s) +static int +Fax3PreDecode(TIFF* tif, uint16 s) { - Fax3CodecState *sp = DecoderState(tif); + Fax3CodecState* sp = DecoderState(tif); - (void)s; - assert(sp != NULL); - sp->bit = 0; /* force initial read */ - sp->data = 0; - sp->EOLcnt = 0; /* force initial scan for EOL */ - /* - * Decoder assumes lsb-to-msb bit order. Note that we select - * this here rather than in Fax3SetupState so that viewers can - * hold the image open, fiddle with the FillOrder tag value, - * and then re-decode the image. Otherwise they'd need to close - * and open the image to get the state reset. - */ - sp->bitmap = - TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB); - sp->curruns = sp->runs; - if (sp->refruns) - { /* init reference line to white */ - sp->refruns = sp->runs + sp->nruns; - sp->refruns[0] = (uint32_t)sp->b.rowpixels; - sp->refruns[1] = 0; - } - sp->line = 0; - return (1); + (void) s; + assert(sp != NULL); + sp->bit = 0; /* force initial read */ + sp->data = 0; + sp->EOLcnt = 0; /* force initial scan for EOL */ + /* + * Decoder assumes lsb-to-msb bit order. Note that we select + * this here rather than in Fax3SetupState so that viewers can + * hold the image open, fiddle with the FillOrder tag value, + * and then re-decode the image. Otherwise they'd need to close + * and open the image to get the state reset. + */ + sp->bitmap = + TIFFGetBitRevTable(tif->tif_dir.td_fillorder != FILLORDER_LSB2MSB); + 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[1] = 0; + } + sp->line = 0; + return (1); } /* @@ -188,53 +177,49 @@ static int Fax3PreDecode(TIFF *tif, uint16_t s) * overriding the definitions used by the decoder. */ -static void Fax3Unexpected(const char *module, TIFF *tif, uint32_t line, - uint32_t a0) +static void +Fax3Unexpected(const char* module, TIFF* tif, uint32 line, uint32 a0) { - TIFFErrorExtR(tif, 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); + TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %u of %s %u (x %u)", + line, isTiled(tif) ? "tile" : "strip", + (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), + a0); } -#define unexpected(table, a0) Fax3Unexpected(module, tif, sp->line, a0) +#define unexpected(table, a0) Fax3Unexpected(module, tif, sp->line, a0) -static void Fax3Extension(const char *module, TIFF *tif, uint32_t line, - uint32_t a0) +static void +Fax3Extension(const char* module, TIFF* tif, uint32 line, uint32 a0) { - TIFFErrorExtR(tif, module, - "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); + TIFFErrorExt(tif->tif_clientdata, module, + "Uncompressed data (not supported) at line %u of %s %u (x %u)", + line, isTiled(tif) ? "tile" : "strip", + (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), + a0); } -#define extension(a0) Fax3Extension(module, tif, sp->line, a0) +#define extension(a0) Fax3Extension(module, tif, sp->line, a0) -static void Fax3BadLength(const char *module, TIFF *tif, uint32_t line, - uint32_t a0, uint32_t lastx) +static void +Fax3BadLength(const char* module, TIFF* tif, uint32 line, uint32 a0, uint32 lastx) { - TIFFWarningExtR(tif, 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), a0, - lastx); + TIFFWarningExt(tif->tif_clientdata, module, "%s at line %u of %s %u (got %u, expected %u)", + a0 < lastx ? "Premature EOL" : "Line length mismatch", + line, isTiled(tif) ? "tile" : "strip", + (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), + a0, lastx); } -#define badlength(a0, lastx) Fax3BadLength(module, tif, sp->line, a0, lastx) +#define badlength(a0,lastx) Fax3BadLength(module, tif, sp->line, a0, lastx) -static void Fax3PrematureEOF(const char *module, TIFF *tif, uint32_t line, - uint32_t a0) +static void +Fax3PrematureEOF(const char* module, TIFF* tif, uint32 line, uint32 a0) { - TIFFWarningExtR(tif, 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); + TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %u of %s %u (x %u)", + line, isTiled(tif) ? "tile" : "strip", + (isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip), + a0); } -#define prematureEOF(a0) Fax3PrematureEOF(module, tif, sp->line, a0) +#define prematureEOF(a0) Fax3PrematureEOF(module, tif, sp->line, a0) -#define Nop +#define Nop /** * Decode the requested amount of G3 1D-encoded data. @@ -243,240 +228,275 @@ static void Fax3PrematureEOF(const char *module, TIFF *tif, uint32_t line, * @param s number of planes (ignored) * @returns 1 for success, -1 in case of error */ -static int Fax3Decode1D(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) +static int +Fax3Decode1D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { - DECLARE_STATE(tif, sp, "Fax3Decode1D"); - (void)s; - if (occ % sp->b.rowbytes) - { - TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read"); - return (-1); - } - CACHE_STATE(tif, sp); - thisrun = sp->curruns; - while (occ > 0) - { - a0 = 0; - RunLength = 0; - pa = thisrun; + DECLARE_STATE(tif, sp, "Fax3Decode1D"); + (void) s; + if (occ % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (-1); + } + CACHE_STATE(tif, sp); + thisrun = sp->curruns; + while (occ > 0) { + a0 = 0; + RunLength = 0; + pa = thisrun; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %" PRIu32 "\n", tif->tif_row); - fflush(stdout); + printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %d\n", tif->tif_row); + fflush(stdout); #endif - SYNC_EOL(EOF1D); - EXPAND1D(EOF1Da); - (*sp->fill)(buf, thisrun, pa, lastx); - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - sp->line++; - continue; - EOF1D: /* premature EOF */ - CLEANUP_RUNS(); - EOF1Da: /* premature EOF */ - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); + SYNC_EOL(EOF1D); + EXPAND1D(EOF1Da); + (*sp->fill)(buf, thisrun, pa, lastx); + buf += sp->b.rowbytes; + occ -= sp->b.rowbytes; + sp->line++; + continue; + EOF1D: /* premature EOF */ + CLEANUP_RUNS(); + EOF1Da: /* premature EOF */ + (*sp->fill)(buf, thisrun, pa, lastx); + UNCACHE_STATE(tif, sp); + return (-1); + } + UNCACHE_STATE(tif, sp); + return (1); } -#define SWAP(t, a, b) \ - { \ - t x; \ - x = (a); \ - (a) = (b); \ - (b) = x; \ - } +#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } /* * Decode the requested amount of G3 2D-encoded data. */ -static int Fax3Decode2D(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) +static int +Fax3Decode2D(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { - DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); - int is1D; /* current line is 1d/2d-encoded */ - (void)s; - if (occ % sp->b.rowbytes) - { - TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read"); - return (-1); - } - CACHE_STATE(tif, sp); - while (occ > 0) - { - a0 = 0; - RunLength = 0; - pa = thisrun = sp->curruns; + DECLARE_STATE_2D(tif, sp, "Fax3Decode2D"); + int is1D; /* current line is 1d/2d-encoded */ + (void) s; + if (occ % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (-1); + } + CACHE_STATE(tif, sp); + while (occ > 0) { + a0 = 0; + RunLength = 0; + pa = thisrun = sp->curruns; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d EOLcnt = %d", BitAcc, - BitsAvail, EOLcnt); + printf("\nBitAcc=%08X, BitsAvail = %d EOLcnt = %d", + BitAcc, BitsAvail, EOLcnt); #endif - SYNC_EOL(EOF2D); - NeedBits8(1, EOF2D); - is1D = GetBits(1); /* 1D/2D-encoding tag bit */ - ClrBits(1); + SYNC_EOL(EOF2D); + NeedBits8(1, EOF2D); + is1D = GetBits(1); /* 1D/2D-encoding tag bit */ + ClrBits(1); #ifdef FAX3_DEBUG - printf(" %s\n-------------------- %" PRIu32 "\n", is1D ? "1D" : "2D", - tif->tif_row); - fflush(stdout); + printf(" %s\n-------------------- %d\n", + is1D ? "1D" : "2D", tif->tif_row); + fflush(stdout); #endif - pb = sp->refruns; - b1 = *pb++; - if (is1D) - EXPAND1D(EOF2Da); - else - EXPAND2D(EOF2Da); - (*sp->fill)(buf, thisrun, pa, lastx); - if (pa < thisrun + sp->nruns) - { - SETVALUE(0); /* imaginary change for reference */ - } - SWAP(uint32_t *, sp->curruns, sp->refruns); - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - sp->line++; - continue; - EOF2D: /* premature EOF */ - CLEANUP_RUNS(); - EOF2Da: /* premature EOF */ - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); + pb = sp->refruns; + b1 = *pb++; + if (is1D) + EXPAND1D(EOF2Da); + else + EXPAND2D(EOF2Da); + (*sp->fill)(buf, thisrun, pa, lastx); + if (pa < thisrun + sp->nruns) { + SETVALUE(0); /* imaginary change for reference */ + } + SWAP(uint32*, sp->curruns, sp->refruns); + buf += sp->b.rowbytes; + occ -= sp->b.rowbytes; + sp->line++; + continue; + EOF2D: /* premature EOF */ + CLEANUP_RUNS(); + EOF2Da: /* premature EOF */ + (*sp->fill)(buf, thisrun, pa, lastx); + UNCACHE_STATE(tif, sp); + return (-1); + } + UNCACHE_STATE(tif, sp); + return (1); } #undef SWAP -#define FILL(n, cp) \ - for (int32_t ifill = 0; ifill < (n); ++ifill) \ - { \ - (cp)[ifill] = 0xff; \ - } \ - (cp) += (n); - -#define ZERO(n, cp) \ - for (int32_t izero = 0; izero < (n); ++izero) \ - { \ - (cp)[izero] = 0; \ - } \ - (cp) += (n); +/* + * 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: ; \ + } +#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 /* * Bit-fill a row according to the white/black * runs generated during G3/G4 decoding. */ -void _TIFFFax3fillruns(unsigned char *buf, uint32_t *runs, uint32_t *erun, - uint32_t lastx) +void +_TIFFFax3fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) { - static const unsigned char _fillmasks[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, - 0xf8, 0xfc, 0xfe, 0xff}; - unsigned char *cp; - uint32_t x, bx, run; - int32_t n, nw; - int64_t *lp; + 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; - if ((erun - runs) & 1) - *erun++ = 0; - x = 0; - for (; runs < erun; runs += 2) - { - run = runs[0]; - if (x + run > lastx || run > lastx) - run = runs[0] = (uint32_t)(lastx - x); - if (run) - { - cp = buf + (x >> 3); - bx = x & 7; - if (run > 8 - bx) - { - if (bx) - { /* align to byte boundary */ - *cp++ &= 0xff << (8 - bx); - run -= 8 - bx; - } - if ((n = run >> 3) != 0) - { /* multiple bytes to fill */ - if ((n / sizeof(int64_t)) > 1) - { - /* - * Align to int64_tword boundary and fill. - */ - for (; n && !isAligned(cp, int64_t); n--) - *cp++ = 0x00; - lp = (int64_t *)cp; - nw = (int32_t)(n / sizeof(int64_t)); - n -= nw * sizeof(int64_t); - do - { - *lp++ = 0L; - } while (--nw); - cp = (unsigned char *)lp; - } - ZERO(n, cp); - run &= 7; - } - if (run) - cp[0] &= 0xff >> run; - } - else - cp[0] &= ~(_fillmasks[run] >> bx); - x += runs[0]; - } - run = runs[1]; - if (x + run > lastx || run > lastx) - run = runs[1] = lastx - x; - if (run) - { - cp = buf + (x >> 3); - bx = x & 7; - if (run > 8 - bx) - { - if (bx) - { /* align to byte boundary */ - *cp++ |= 0xff >> bx; - run -= 8 - bx; - } - if ((n = run >> 3) != 0) - { /* multiple bytes to fill */ - if ((n / sizeof(int64_t)) > 1) - { - /* - * Align to int64_t boundary and fill. - */ - for (; n && !isAligned(cp, int64_t); n--) - *cp++ = 0xff; - lp = (int64_t *)cp; - nw = (int32_t)(n / sizeof(int64_t)); - n -= nw * sizeof(int64_t); - do - { - *lp++ = -1L; - } while (--nw); - cp = (unsigned char *)lp; - } - FILL(n, cp); - run &= 7; - } - /* Explicit 0xff masking to make icc -check=conversions happy */ - if (run) - cp[0] = (unsigned char)((cp[0] | (0xff00 >> run)) & 0xff); - } - else - cp[0] |= _fillmasks[run] >> bx; - x += runs[1]; - } - } - assert(x == lastx); + if ((erun-runs)&1) + *erun++ = 0; + x = 0; + for (; runs < erun; runs += 2) { + run = runs[0]; + if (x+run > lastx || run > lastx ) + run = runs[0] = (uint32) (lastx - x); + if (run) { + cp = buf + (x>>3); + bx = x&7; + if (run > 8-bx) { + if (bx) { /* align to byte boundary */ + *cp++ &= 0xff << (8-bx); + run -= 8-bx; + } + if( (n = run >> 3) != 0 ) { /* multiple bytes to fill */ + if ((n/sizeof (long)) > 1) { + /* + * Align to longword boundary and fill. + */ + for (; n && !isAligned(cp, long); n--) + *cp++ = 0x00; + lp = (long*) cp; + nw = (int32)(n / sizeof (long)); + n -= nw * sizeof (long); + do { + *lp++ = 0L; + } while (--nw); + cp = (unsigned char*) lp; + } + ZERO(n, cp); + run &= 7; + } + if (run) + cp[0] &= 0xff >> run; + } else + cp[0] &= ~(_fillmasks[run]>>bx); + x += runs[0]; + } + run = runs[1]; + if (x+run > lastx || run > lastx ) + run = runs[1] = lastx - x; + if (run) { + cp = buf + (x>>3); + bx = x&7; + if (run > 8-bx) { + if (bx) { /* align to byte boundary */ + *cp++ |= 0xff >> bx; + run -= 8-bx; + } + if( (n = run>>3) != 0 ) { /* multiple bytes to fill */ + if ((n/sizeof (long)) > 1) { + /* + * Align to longword boundary and fill. + */ + for (; n && !isAligned(cp, long); n--) + *cp++ = 0xff; + lp = (long*) cp; + nw = (int32)(n / sizeof (long)); + n -= nw * sizeof (long); + do { + *lp++ = -1L; + } while (--nw); + cp = (unsigned char*) lp; + } + FILL(n, cp); + run &= 7; + } + /* Explicit 0xff masking to make icc -check=conversions happy */ + if (run) + cp[0] = (unsigned char)((cp[0] | (0xff00 >> run))&0xff); + } else + cp[0] |= _fillmasks[run]>>bx; + x += runs[1]; + } + } + assert(x == lastx); } -#undef ZERO -#undef FILL +#undef ZERO +#undef FILL -static int Fax3FixupTags(TIFF *tif) +static int +Fax3FixupTags(TIFF* tif) { - (void)tif; - return (1); + (void) tif; + return (1); } /* @@ -486,188 +506,175 @@ static int Fax3FixupTags(TIFF *tif) * or not decoding or encoding is being done and whether * 1D- or 2D-encoded data is involved. */ -static int Fax3SetupState(TIFF *tif) +static int +Fax3SetupState(TIFF* tif) { - static const char module[] = "Fax3SetupState"; - TIFFDirectory *td = &tif->tif_dir; - Fax3BaseState *sp = Fax3State(tif); - int needsRefLine; - Fax3CodecState *dsp = (Fax3CodecState *)Fax3State(tif); - tmsize_t rowbytes; - uint32_t rowpixels; + static const char module[] = "Fax3SetupState"; + TIFFDirectory* td = &tif->tif_dir; + Fax3BaseState* sp = Fax3State(tif); + int needsRefLine; + Fax3CodecState* dsp = (Fax3CodecState*) Fax3State(tif); + tmsize_t rowbytes; + uint32 rowpixels; - if (td->td_bitspersample != 1) - { - TIFFErrorExtR(tif, module, - "Bits/sample must be 1 for Group 3/4 encoding/decoding"); - return (0); - } - /* - * Calculate the scanline/tile widths. - */ - if (isTiled(tif)) - { - rowbytes = TIFFTileRowSize(tif); - rowpixels = td->td_tilewidth; - } - else - { - rowbytes = TIFFScanlineSize(tif); - rowpixels = td->td_imagewidth; - } - if ((int64_t)rowbytes < ((int64_t)rowpixels + 7) / 8) - { - TIFFErrorExtR(tif, module, - "Inconsistent number of bytes per row : rowbytes=%" PRId64 - " rowpixels=%" PRIu32, - (int64_t)rowbytes, rowpixels); - return (0); - } - sp->rowbytes = rowbytes; - sp->rowpixels = rowpixels; - /* - * Allocate any additional space required for decoding/encoding. - */ - needsRefLine = ((sp->groupoptions & GROUP3OPT_2DENCODING) || - td->td_compression == COMPRESSION_CCITTFAX4); + if (td->td_bitspersample != 1) { + TIFFErrorExt(tif->tif_clientdata, module, + "Bits/sample must be 1 for Group 3/4 encoding/decoding"); + return (0); + } + /* + * Calculate the scanline/tile widths. + */ + if (isTiled(tif)) { + rowbytes = TIFFTileRowSize(tif); + rowpixels = td->td_tilewidth; + } else { + rowbytes = TIFFScanlineSize(tif); + rowpixels = td->td_imagewidth; + } + if ((uint64)rowbytes < ((uint64)rowpixels + 7) / 8) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Inconsistent number of bytes per row : rowbytes=%lu rowpixels=%lu", + (unsigned long)(rowbytes), (unsigned long)(rowpixels)); + return (0); + } + sp->rowbytes = rowbytes; + sp->rowpixels = rowpixels; + /* + * Allocate any additional space required for decoding/encoding. + */ + needsRefLine = ( + (sp->groupoptions & GROUP3OPT_2DENCODING) || + td->td_compression == COMPRESSION_CCITTFAX4 + ); - /* - Assure that allocation computations do not overflow. + /* + Assure that allocation computations do not overflow. + + TIFFroundup and TIFFSafeMultiply return zero on integer overflow + */ + dsp->runs=(uint32*) NULL; + dsp->nruns = TIFFroundup_32(rowpixels,32); + if (needsRefLine) { + dsp->nruns = TIFFSafeMultiply(uint32,dsp->nruns,2); + } + if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32,dsp->nruns,2) == 0)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Row pixels integer overflow (rowpixels %u)", + rowpixels); + return (0); + } + dsp->runs = (uint32*) _TIFFCheckMalloc(tif, + TIFFSafeMultiply(uint32,dsp->nruns,2), + sizeof (uint32), + "for Group 3/4 run arrays"); + if (dsp->runs == NULL) + return (0); + memset( dsp->runs, 0, TIFFSafeMultiply(uint32,dsp->nruns,2)*sizeof(uint32)); + dsp->curruns = dsp->runs; + if (needsRefLine) + dsp->refruns = dsp->runs + dsp->nruns; + else + dsp->refruns = NULL; + if (td->td_compression == COMPRESSION_CCITTFAX3 + && is2DEncoding(dsp)) { /* NB: default is 1D routine */ + tif->tif_decoderow = Fax3Decode2D; + tif->tif_decodestrip = Fax3Decode2D; + tif->tif_decodetile = Fax3Decode2D; + } - TIFFroundup and TIFFSafeMultiply return zero on integer overflow - */ - dsp->runs = (uint32_t *)NULL; - dsp->nruns = TIFFroundup_32(rowpixels + 1, 32); - if (needsRefLine) - { - dsp->nruns = TIFFSafeMultiply(uint32_t, dsp->nruns, 2); - } - if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32_t, dsp->nruns, 2) == 0)) - { - TIFFErrorExtR(tif, tif->tif_name, - "Row pixels integer overflow (rowpixels %" PRIu32 ")", - rowpixels); - return (0); - } - 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_t, dsp->nruns, 2) * sizeof(uint32_t)); - dsp->curruns = dsp->runs; - if (needsRefLine) - dsp->refruns = dsp->runs + dsp->nruns; - else - dsp->refruns = NULL; - if (td->td_compression == COMPRESSION_CCITTFAX3 && is2DEncoding(dsp)) - { /* NB: default is 1D routine */ - tif->tif_decoderow = Fax3Decode2D; - tif->tif_decodestrip = Fax3Decode2D; - tif->tif_decodetile = Fax3Decode2D; - } + if (needsRefLine) { /* 2d encoding */ + Fax3CodecState* esp = EncoderState(tif); + /* + * 2d encoding requires a scanline + * buffer for the ``reference line''; the + * scanline against which delta encoding + * is referenced. The reference line must + * be initialized to be ``white'' (done elsewhere). + */ + esp->refline = (unsigned char*) _TIFFmalloc(rowbytes); + if (esp->refline == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, + "No space for Group 3/4 reference line"); + return (0); + } + } else /* 1d encoding */ + EncoderState(tif)->refline = NULL; - if (needsRefLine) - { /* 2d encoding */ - Fax3CodecState *esp = EncoderState(tif); - /* - * 2d encoding requires a scanline - * buffer for the ``reference line''; the - * scanline against which delta encoding - * is referenced. The reference line must - * be initialized to be ``white'' (done elsewhere). - */ - esp->refline = (unsigned char *)_TIFFmallocExt(tif, rowbytes); - if (esp->refline == NULL) - { - TIFFErrorExtR(tif, module, "No space for Group 3/4 reference line"); - return (0); - } - } - else /* 1d encoding */ - EncoderState(tif)->refline = NULL; - - return (1); + return (1); } /* * CCITT Group 3 FAX Encoding. */ -#define Fax3FlushBits(tif, sp) \ - { \ - if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ - { \ - if (!TIFFFlushData1(tif)) \ - return 0; \ - } \ - *(tif)->tif_rawcp++ = (uint8_t)(sp)->data; \ - (tif)->tif_rawcc++; \ - (sp)->data = 0, (sp)->bit = 8; \ - } -#define _FlushBits(tif) \ - { \ - if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) \ - { \ - if (!TIFFFlushData1(tif)) \ - return 0; \ - } \ - *(tif)->tif_rawcp++ = (uint8_t)data; \ - (tif)->tif_rawcc++; \ - data = 0, bit = 8; \ - } -static const int _msbmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, - 0x1f, 0x3f, 0x7f, 0xff}; -#define _PutBits(tif, bits, length) \ - { \ - while (length > bit) \ - { \ - data |= bits >> (length - bit); \ - length -= bit; \ - _FlushBits(tif); \ - } \ - assert(length < 9); \ - data |= (bits & _msbmask[length]) << (bit - length); \ - bit -= length; \ - if (bit == 0) \ - _FlushBits(tif); \ - } - +#define Fax3FlushBits(tif, sp) { \ + if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) { \ + if( !TIFFFlushData1(tif) ) \ + return 0; \ + } \ + *(tif)->tif_rawcp++ = (uint8) (sp)->data; \ + (tif)->tif_rawcc++; \ + (sp)->data = 0, (sp)->bit = 8; \ +} +#define _FlushBits(tif) { \ + if ((tif)->tif_rawcc >= (tif)->tif_rawdatasize) { \ + if( !TIFFFlushData1(tif) ) \ + return 0; \ + } \ + *(tif)->tif_rawcp++ = (uint8) data; \ + (tif)->tif_rawcc++; \ + data = 0, bit = 8; \ +} +static const int _msbmask[9] = + { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff }; +#define _PutBits(tif, bits, length) { \ + while (length > bit) { \ + data |= bits >> (length - bit); \ + length -= bit; \ + _FlushBits(tif); \ + } \ + assert( length < 9 ); \ + data |= (bits & _msbmask[length]) << (bit - length); \ + bit -= length; \ + if (bit == 0) \ + _FlushBits(tif); \ +} + /* * Write a variable-length bit-value to * the output stream. Values are * assumed to be at most 16 bits. */ -static int Fax3PutBits(TIFF *tif, unsigned int bits, unsigned int length) +static int +Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length) { - Fax3CodecState *sp = EncoderState(tif); - unsigned int bit = sp->bit; - int data = sp->data; + Fax3CodecState* sp = EncoderState(tif); + unsigned int bit = sp->bit; + int data = sp->data; - _PutBits(tif, bits, length); + _PutBits(tif, bits, length); - sp->data = data; - sp->bit = bit; - return 1; + sp->data = data; + sp->bit = bit; + return 1; } /* * Write a code to the output stream. */ -#define putcode(tif, te) Fax3PutBits(tif, (te)->code, (te)->length) +#define putcode(tif, te) Fax3PutBits(tif, (te)->code, (te)->length) #ifdef FAX3_DEBUG -#define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B") -#define DEBUG_PRINT(what, len) \ - { \ - int t; \ - 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'); \ - } +#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); \ + for (t = length-1; t >= 0; t--) \ + putchar(code & (1<bit; - int data = sp->data; - unsigned int code, length; + Fax3CodecState* sp = EncoderState(tif); + unsigned int bit = sp->bit; + int data = sp->data; + unsigned int code, length; - while (span >= 2624) - { - const tableentry *te = &tab[63 + (2560 >> 6)]; - code = te->code; - length = te->length; + while (span >= 2624) { + const tableentry* te = &tab[63 + (2560>>6)]; + code = te->code; + length = te->length; #ifdef FAX3_DEBUG - DEBUG_PRINT("MakeUp", te->runlen); + DEBUG_PRINT("MakeUp", te->runlen); #endif - _PutBits(tif, code, length); - span -= te->runlen; - } - if (span >= 64) - { - const tableentry *te = &tab[63 + (span >> 6)]; - assert(te->runlen == 64 * (span >> 6)); - code = te->code; - length = te->length; + _PutBits(tif, code, length); + span -= te->runlen; + } + if (span >= 64) { + const tableentry* te = &tab[63 + (span>>6)]; + assert(te->runlen == 64*(span>>6)); + code = te->code; + length = te->length; #ifdef FAX3_DEBUG - DEBUG_PRINT("MakeUp", te->runlen); + DEBUG_PRINT("MakeUp", te->runlen); #endif - _PutBits(tif, code, length); - span -= te->runlen; - } - code = tab[span].code; - length = tab[span].length; + _PutBits(tif, code, length); + span -= te->runlen; + } + code = tab[span].code; + length = tab[span].length; #ifdef FAX3_DEBUG - DEBUG_PRINT(" Term", tab[span].runlen); + DEBUG_PRINT(" Term", tab[span].runlen); #endif - _PutBits(tif, code, length); + _PutBits(tif, code, length); - sp->data = data; - sp->bit = bit; + sp->data = data; + sp->bit = bit; - return 1; + return 1; } /* @@ -725,266 +731,260 @@ static int putspan(TIFF *tif, int32_t span, const tableentry *tab) * here. We also handle writing the tag bit for the next * scanline when doing 2d encoding. */ -static int Fax3PutEOL(TIFF *tif) +static int +Fax3PutEOL(TIFF* tif) { - Fax3CodecState *sp = EncoderState(tif); - unsigned int bit = sp->bit; - int data = sp->data; - unsigned int code, length, tparm; + Fax3CodecState* sp = EncoderState(tif); + unsigned int bit = sp->bit; + int data = sp->data; + unsigned int code, length, tparm; - if (sp->b.groupoptions & GROUP3OPT_FILLBITS) - { - /* - * Force bit alignment so EOL will terminate on - * a byte boundary. That is, force the bit alignment - * to 16-12 = 4 before putting out the EOL code. - */ - int align = 8 - 4; - if (align != sp->bit) - { - if (align > sp->bit) - align = sp->bit + (8 - align); - else - align = sp->bit - align; - tparm = align; - _PutBits(tif, 0, tparm); - } - } - code = EOL; - length = 12; - if (is2DEncoding(sp)) - { - code = (code << 1) | (sp->tag == G3_1D); - length++; - } - _PutBits(tif, code, length); + if (sp->b.groupoptions & GROUP3OPT_FILLBITS) { + /* + * Force bit alignment so EOL will terminate on + * a byte boundary. That is, force the bit alignment + * to 16-12 = 4 before putting out the EOL code. + */ + int align = 8 - 4; + if (align != sp->bit) { + if (align > sp->bit) + align = sp->bit + (8 - align); + else + align = sp->bit - align; + tparm=align; + _PutBits(tif, 0, tparm); + } + } + code = EOL; + length = 12; + if (is2DEncoding(sp)) { + code = (code<<1) | (sp->tag == G3_1D); + length++; + } + _PutBits(tif, code, length); - sp->data = data; - sp->bit = bit; + sp->data = data; + sp->bit = bit; - return 1; + return 1; } /* * Reset encoding state at the start of a strip. */ -static int Fax3PreEncode(TIFF *tif, uint16_t s) +static int +Fax3PreEncode(TIFF* tif, uint16 s) { - Fax3CodecState *sp = EncoderState(tif); + Fax3CodecState* sp = EncoderState(tif); - (void)s; - assert(sp != NULL); - sp->bit = 8; - sp->data = 0; - sp->tag = G3_1D; - /* - * This is necessary for Group 4; otherwise it isn't - * needed because the first scanline of each strip ends - * up being copied into the refline. - */ - if (sp->refline) - _TIFFmemset(sp->refline, 0x00, sp->b.rowbytes); - if (is2DEncoding(sp)) - { - float res = tif->tif_dir.td_yresolution; - /* - * The CCITT spec says that when doing 2d encoding, you - * should only do it on K consecutive scanlines, where K - * depends on the resolution of the image being encoded - * (2 for <= 200 lpi, 4 for > 200 lpi). Since the directory - * code initializes td_yresolution to 0, this code will - * select a K of 2 unless the YResolution tag is set - * appropriately. (Note also that we fudge a little here - * and use 150 lpi to avoid problems with units conversion.) - */ - if (tif->tif_dir.td_resolutionunit == RESUNIT_CENTIMETER) - res *= 2.54f; /* convert to inches */ - sp->maxk = (res > 150 ? 4 : 2); - sp->k = sp->maxk - 1; - } - else - sp->k = sp->maxk = 0; - sp->line = 0; - return (1); + (void) s; + assert(sp != NULL); + sp->bit = 8; + sp->data = 0; + sp->tag = G3_1D; + /* + * This is necessary for Group 4; otherwise it isn't + * needed because the first scanline of each strip ends + * up being copied into the refline. + */ + if (sp->refline) + _TIFFmemset(sp->refline, 0x00, sp->b.rowbytes); + if (is2DEncoding(sp)) { + float res = tif->tif_dir.td_yresolution; + /* + * The CCITT spec says that when doing 2d encoding, you + * should only do it on K consecutive scanlines, where K + * depends on the resolution of the image being encoded + * (2 for <= 200 lpi, 4 for > 200 lpi). Since the directory + * code initializes td_yresolution to 0, this code will + * select a K of 2 unless the YResolution tag is set + * appropriately. (Note also that we fudge a little here + * and use 150 lpi to avoid problems with units conversion.) + */ + if (tif->tif_dir.td_resolutionunit == RESUNIT_CENTIMETER) + res *= 2.54f; /* convert to inches */ + sp->maxk = (res > 150 ? 4 : 2); + sp->k = sp->maxk-1; + } else + sp->k = sp->maxk = 0; + sp->line = 0; + return (1); } static const unsigned char zeroruns[256] = { - 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0f */ - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x1f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 - 0x2f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 - 0x3f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 - 0x4f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 - 0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x6f */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x7f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 - 0x8f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 - 0x9f */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 - 0xaf */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 - 0xbf */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xc0 - 0xcf */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0xd0 - 0xdf */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0xe0 - 0xef */ + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 8, /* 0xf0 - 0xff */ }; +/* + * 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. */ -static inline int32_t find0span(unsigned char *bp, int32_t bs, int32_t be) +inline static int32 +find0span(unsigned char* bp, int32 bs, int32 be) { - int32_t bits = be - bs; - int32_t n, span; + int32 bits = be - bs; + int32 n, span; - bp += bs >> 3; - /* - * Check partial byte on lhs. - */ - if (bits > 0 && (n = (bs & 7)) != 0) - { - span = zeroruns[(*bp << n) & 0xff]; - if (span > 8 - n) /* table value too generous */ - span = 8 - n; - if (span > bits) /* constrain span to bit range */ - span = bits; - if (n + span < 8) /* doesn't extend to edge of byte */ - return (span); - bits -= span; - bp++; - } - else - span = 0; - if (bits >= (int32_t)(2 * 8 * sizeof(int64_t))) - { - int64_t *lp; - /* - * Align to int64_t boundary and check int64_t words. - */ - while (!isAligned(bp, int64_t)) - { - if (*bp != 0x00) - return (span + zeroruns[*bp]); - span += 8; - bits -= 8; - bp++; - } - 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; - } - /* - * Scan full bytes for all 0's. - */ - while (bits >= 8) - { - if (*bp != 0x00) /* end of run */ - return (span + zeroruns[*bp]); - span += 8; - bits -= 8; - bp++; - } - /* - * Check partial byte on rhs. - */ - if (bits > 0) - { - n = zeroruns[*bp]; - span += (n > bits ? bits : n); - } - return (span); + bp += bs>>3; + /* + * Check partial byte on lhs. + */ + if (bits > 0 && (n = (bs & 7)) != 0) { + span = zeroruns[(*bp << n) & 0xff]; + if (span > 8-n) /* table value too generous */ + span = 8-n; + if (span > bits) /* constrain span to bit range */ + span = bits; + if (n+span < 8) /* doesn't extend to edge of byte */ + return (span); + bits -= span; + bp++; + } else + span = 0; + if (bits >= (int32)(2 * 8 * sizeof(long))) { + long* lp; + /* + * Align to longword boundary and check longwords. + */ + while (!isAligned(bp, long)) { + 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++; + } + bp = (unsigned char*) lp; + } + /* + * Scan full bytes for all 0's. + */ + while (bits >= 8) { + if (*bp != 0x00) /* end of run */ + return (span + zeroruns[*bp]); + span += 8; + bits -= 8; + bp++; + } + /* + * Check partial byte on rhs. + */ + if (bits > 0) { + n = zeroruns[*bp]; + span += (n > bits ? bits : n); + } + return (span); } -static inline int32_t find1span(unsigned char *bp, int32_t bs, int32_t be) +inline static int32 +find1span(unsigned char* bp, int32 bs, int32 be) { - int32_t bits = be - bs; - int32_t n, span; + int32 bits = be - bs; + int32 n, span; - bp += bs >> 3; - /* - * Check partial byte on lhs. - */ - if (bits > 0 && (n = (bs & 7)) != 0) - { - span = oneruns[(*bp << n) & 0xff]; - if (span > 8 - n) /* table value too generous */ - span = 8 - n; - if (span > bits) /* constrain span to bit range */ - span = bits; - if (n + span < 8) /* doesn't extend to edge of byte */ - return (span); - bits -= span; - bp++; - } - else - span = 0; - if (bits >= (int32_t)(2 * 8 * sizeof(int64_t))) - { - int64_t *lp; - /* - * Align to int64_t boundary and check int64_t words. - */ - while (!isAligned(bp, int64_t)) - { - if (*bp != 0xff) - return (span + oneruns[*bp]); - span += 8; - bits -= 8; - bp++; - } - 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; - } - /* - * Scan full bytes for all 1's. - */ - while (bits >= 8) - { - if (*bp != 0xff) /* end of run */ - return (span + oneruns[*bp]); - span += 8; - bits -= 8; - bp++; - } - /* - * Check partial byte on rhs. - */ - if (bits > 0) - { - n = oneruns[*bp]; - span += (n > bits ? bits : n); - } - return (span); + bp += bs>>3; + /* + * Check partial byte on lhs. + */ + if (bits > 0 && (n = (bs & 7)) != 0) { + span = oneruns[(*bp << n) & 0xff]; + if (span > 8-n) /* table value too generous */ + span = 8-n; + if (span > bits) /* constrain span to bit range */ + span = bits; + if (n+span < 8) /* doesn't extend to edge of byte */ + return (span); + bits -= span; + bp++; + } else + span = 0; + if (bits >= (int32)(2 * 8 * sizeof(long))) { + long* lp; + /* + * Align to longword boundary and check longwords. + */ + while (!isAligned(bp, long)) { + 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++; + } + bp = (unsigned char*) lp; + } + /* + * Scan full bytes for all 1's. + */ + while (bits >= 8) { + if (*bp != 0xff) /* end of run */ + return (span + oneruns[*bp]); + span += 8; + bits -= 8; + bp++; + } + /* + * Check partial byte on rhs. + */ + if (bits > 0) { + n = oneruns[*bp]; + span += (n > bits ? bits : n); + } + return (span); } /* @@ -993,501 +993,474 @@ static inline int32_t find1span(unsigned char *bp, int32_t bs, int32_t be) * color. The end, be, is returned if no such bit * exists. */ -#define finddiff(_cp, _bs, _be, _color) \ - (_bs + (_color ? find1span(_cp, _bs, _be) : find0span(_cp, _bs, _be))) +#define finddiff(_cp, _bs, _be, _color) \ + (_bs + (_color ? find1span(_cp,_bs,_be) : find0span(_cp,_bs,_be))) /* * Like finddiff, but also check the starting bit * against the end in case start > end. */ -#define finddiff2(_cp, _bs, _be, _color) \ - (_bs < _be ? finddiff(_cp, _bs, _be, _color) : _be) +#define finddiff2(_cp, _bs, _be, _color) \ + (_bs < _be ? finddiff(_cp,_bs,_be,_color) : _be) /* * 1d-encode a row of pixels. The encoding is * a sequence of all-white or all-black spans * of pixels encoded with Huffman codes. */ -static int Fax3Encode1DRow(TIFF *tif, unsigned char *bp, uint32_t bits) +static int +Fax3Encode1DRow(TIFF* tif, unsigned char* bp, uint32 bits) { - Fax3CodecState *sp = EncoderState(tif); - int32_t span; - uint32_t bs = 0; + Fax3CodecState* sp = EncoderState(tif); + int32 span; + uint32 bs = 0; - for (;;) - { - span = find0span(bp, bs, bits); /* white span */ - if (!putspan(tif, span, TIFFFaxWhiteCodes)) - return 0; - bs += span; - if (bs >= bits) - break; - span = find1span(bp, bs, bits); /* black span */ - if (!putspan(tif, span, TIFFFaxBlackCodes)) - return 0; - bs += span; - if (bs >= bits) - break; - } - if (sp->b.mode & (FAXMODE_BYTEALIGN | FAXMODE_WORDALIGN)) - { - if (sp->bit != 8) /* byte-align */ - Fax3FlushBits(tif, sp); - if ((sp->b.mode & FAXMODE_WORDALIGN) && - !isAligned(tif->tif_rawcp, uint16_t)) - Fax3FlushBits(tif, sp); - } - return (1); + for (;;) { + span = find0span(bp, bs, bits); /* white span */ + if( !putspan(tif, span, TIFFFaxWhiteCodes) ) + return 0; + bs += span; + if (bs >= bits) + break; + span = find1span(bp, bs, bits); /* black span */ + if( !putspan(tif, span, TIFFFaxBlackCodes) ) + return 0; + bs += span; + if (bs >= bits) + break; + } + if (sp->b.mode & (FAXMODE_BYTEALIGN|FAXMODE_WORDALIGN)) { + if (sp->bit != 8) /* byte-align */ + Fax3FlushBits(tif, sp); + if ((sp->b.mode&FAXMODE_WORDALIGN) && + !isAligned(tif->tif_rawcp, uint16)) + Fax3FlushBits(tif, sp); + } + return (1); } -static const tableentry horizcode = {3, 0x1, 0}; /* 001 */ -static const tableentry passcode = {4, 0x1, 0}; /* 0001 */ +static const tableentry horizcode = + { 3, 0x1, 0 }; /* 001 */ +static const tableentry passcode = + { 4, 0x1, 0 }; /* 0001 */ static const tableentry vcodes[7] = { - {7, 0x03, 0}, /* 0000 011 */ - {6, 0x03, 0}, /* 0000 11 */ - {3, 0x03, 0}, /* 011 */ - {1, 0x1, 0}, /* 1 */ - {3, 0x2, 0}, /* 010 */ - {6, 0x02, 0}, /* 0000 10 */ - {7, 0x02, 0} /* 0000 010 */ + { 7, 0x03, 0 }, /* 0000 011 */ + { 6, 0x03, 0 }, /* 0000 11 */ + { 3, 0x03, 0 }, /* 011 */ + { 1, 0x1, 0 }, /* 1 */ + { 3, 0x2, 0 }, /* 010 */ + { 6, 0x02, 0 }, /* 0000 10 */ + { 7, 0x02, 0 } /* 0000 010 */ }; /* * 2d-encode a row of pixels. Consult the CCITT * documentation for the algorithm. */ -static int Fax3Encode2DRow(TIFF *tif, unsigned char *bp, unsigned char *rp, - uint32_t bits) +static int +Fax3Encode2DRow(TIFF* tif, unsigned char* bp, unsigned char* rp, uint32 bits) { -#define PIXEL(buf, ix) ((((buf)[(ix) >> 3]) >> (7 - ((ix)&7))) & 1) - 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; +#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; - 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_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)) - return 0; - if (a0 + a1 == 0 || PIXEL(bp, a0) == 0) - { - if (!putspan(tif, a1 - a0, TIFFFaxWhiteCodes)) - return 0; - if (!putspan(tif, a2 - a1, TIFFFaxBlackCodes)) - return 0; - } - else - { - if (!putspan(tif, a1 - a0, TIFFFaxBlackCodes)) - return 0; - if (!putspan(tif, a2 - a1, TIFFFaxWhiteCodes)) - return 0; - } - a0 = a2; - } - else - { /* vertical mode */ - if (!putcode(tif, &vcodes[d + 3])) - return 0; - a0 = a1; - } - } - else - { /* pass mode */ - if (!putcode(tif, &passcode)) - return 0; - a0 = b2; - } - if (a0 >= bits) - break; - a1 = finddiff(bp, a0, bits, PIXEL(bp, a0)); - b1 = finddiff(rp, a0, bits, !PIXEL(bp, a0)); - b1 = finddiff(rp, b1, bits, PIXEL(bp, a0)); - } - return (1); + 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; + if (!(-3 <= d && d <= 3)) { /* horizontal mode */ + a2 = finddiff2(bp, a1, bits, PIXEL(bp,a1)); + if( !putcode(tif, &horizcode) ) + return 0; + if (a0+a1 == 0 || PIXEL(bp, a0) == 0) { + if( !putspan(tif, a1-a0, TIFFFaxWhiteCodes) ) + return 0; + if( !putspan(tif, a2-a1, TIFFFaxBlackCodes) ) + return 0; + } else { + if( !putspan(tif, a1-a0, TIFFFaxBlackCodes) ) + return 0; + if( !putspan(tif, a2-a1, TIFFFaxWhiteCodes) ) + return 0; + } + a0 = a2; + } else { /* vertical mode */ + if( !putcode(tif, &vcodes[d+3]) ) + return 0; + a0 = a1; + } + } else { /* pass mode */ + if( !putcode(tif, &passcode) ) + return 0; + a0 = b2; + } + if (a0 >= bits) + break; + a1 = finddiff(bp, a0, bits, PIXEL(bp,a0)); + b1 = finddiff(rp, a0, bits, !PIXEL(bp,a0)); + b1 = finddiff(rp, b1, bits, PIXEL(bp,a0)); + } + return (1); #undef PIXEL } /* * Encode a buffer of pixels. */ -static int Fax3Encode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +Fax3Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "Fax3Encode"; - Fax3CodecState *sp = EncoderState(tif); - (void)s; - if (cc % sp->b.rowbytes) - { - TIFFErrorExtR(tif, module, "Fractional scanlines cannot be written"); - return (0); - } - while (cc > 0) - { - if ((sp->b.mode & FAXMODE_NOEOL) == 0) - { - if (!Fax3PutEOL(tif)) - return 0; - } - if (is2DEncoding(sp)) - { - if (sp->tag == G3_1D) - { - if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) - return (0); - sp->tag = G3_2D; - } - else - { - if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) - return (0); - sp->k--; - } - if (sp->k == 0) - { - sp->tag = G3_1D; - sp->k = sp->maxk - 1; - } - else - _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); - } - else - { - if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) - return (0); - } - bp += sp->b.rowbytes; - cc -= sp->b.rowbytes; - } - return (1); + static const char module[] = "Fax3Encode"; + Fax3CodecState* sp = EncoderState(tif); + (void) s; + if (cc % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be written"); + return (0); + } + while (cc > 0) { + if ((sp->b.mode & FAXMODE_NOEOL) == 0) + { + if( !Fax3PutEOL(tif) ) + return 0; + } + if (is2DEncoding(sp)) { + if (sp->tag == G3_1D) { + if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) + return (0); + sp->tag = G3_2D; + } else { + if (!Fax3Encode2DRow(tif, bp, sp->refline, + sp->b.rowpixels)) + return (0); + sp->k--; + } + if (sp->k == 0) { + sp->tag = G3_1D; + sp->k = sp->maxk-1; + } else + _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); + } else { + if (!Fax3Encode1DRow(tif, bp, sp->b.rowpixels)) + return (0); + } + bp += sp->b.rowbytes; + cc -= sp->b.rowbytes; + } + return (1); } -static int Fax3PostEncode(TIFF *tif) +static int +Fax3PostEncode(TIFF* tif) { - Fax3CodecState *sp = EncoderState(tif); + Fax3CodecState* sp = EncoderState(tif); - if (sp->bit != 8) - Fax3FlushBits(tif, sp); - return (1); + if (sp->bit != 8) + Fax3FlushBits(tif, sp); + return (1); } -static int _Fax3Close(TIFF *tif) +static int +_Fax3Close(TIFF* tif) { - if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0 && tif->tif_rawcp) - { - Fax3CodecState *sp = EncoderState(tif); - unsigned int code = EOL; - unsigned int length = 12; - int i; + if ((Fax3State(tif)->mode & FAXMODE_NORTC) == 0 && tif->tif_rawcp) { + Fax3CodecState* sp = EncoderState(tif); + unsigned int code = EOL; + unsigned int length = 12; + int i; - if (is2DEncoding(sp)) - { - code = (code << 1) | (sp->tag == G3_1D); - length++; - } - for (i = 0; i < 6; i++) - Fax3PutBits(tif, code, length); - Fax3FlushBits(tif, sp); - } - return 1; + if (is2DEncoding(sp)) { + code = (code<<1) | (sp->tag == G3_1D); + length++; + } + for (i = 0; i < 6; i++) + Fax3PutBits(tif, code, length); + Fax3FlushBits(tif, sp); + } + return 1; } -static void Fax3Close(TIFF *tif) { _Fax3Close(tif); } - -static void Fax3Cleanup(TIFF *tif) +static void +Fax3Close(TIFF* tif) { - Fax3CodecState *sp = DecoderState(tif); - - assert(sp != 0); - - tif->tif_tagmethods.vgetfield = sp->b.vgetparent; - tif->tif_tagmethods.vsetfield = sp->b.vsetparent; - tif->tif_tagmethods.printdir = sp->b.printdir; - - if (sp->runs) - _TIFFfreeExt(tif, sp->runs); - if (sp->refline) - _TIFFfreeExt(tif, sp->refline); - - _TIFFfreeExt(tif, tif->tif_data); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); + _Fax3Close(tif); } -#define FIELD_BADFAXLINES (FIELD_CODEC + 0) -#define FIELD_CLEANFAXDATA (FIELD_CODEC + 1) -#define FIELD_BADFAXRUN (FIELD_CODEC + 2) +static void +Fax3Cleanup(TIFF* tif) +{ + Fax3CodecState* sp = DecoderState(tif); + + assert(sp != 0); -#define FIELD_OPTIONS (FIELD_CODEC + 7) + tif->tif_tagmethods.vgetfield = sp->b.vgetparent; + tif->tif_tagmethods.vsetfield = sp->b.vsetparent; + tif->tif_tagmethods.printdir = sp->b.printdir; + + if (sp->runs) + _TIFFfree(sp->runs); + if (sp->refline) + _TIFFfree(sp->refline); + + _TIFFfree(tif->tif_data); + tif->tif_data = NULL; + + _TIFFSetDefaultCompressionState(tif); +} + +#define FIELD_BADFAXLINES (FIELD_CODEC+0) +#define FIELD_CLEANFAXDATA (FIELD_CODEC+1) +#define FIELD_BADFAXRUN (FIELD_CODEC+2) + +#define FIELD_OPTIONS (FIELD_CODEC+7) static const TIFFField faxFields[] = { - {TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, - FIELD_PSEUDO, FALSE, FALSE, "FaxMode", NULL}, - {TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, 0, TIFF_SETGET_OTHER, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "FaxFillFunc", NULL}, - {TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, - TIFF_SETGET_UINT32, FIELD_BADFAXLINES, TRUE, FALSE, "BadFaxLines", NULL}, - {TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, - TIFF_SETGET_UINT16, FIELD_CLEANFAXDATA, TRUE, FALSE, "CleanFaxData", NULL}, - {TIFFTAG_CONSECUTIVEBADFAXLINES, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, - TIFF_SETGET_UINT32, FIELD_BADFAXRUN, TRUE, FALSE, "ConsecutiveBadFaxLines", - NULL}}; + { TIFFTAG_FAXMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "FaxMode", NULL }, + { TIFFTAG_FAXFILLFUNC, 0, 0, TIFF_ANY, 0, TIFF_SETGET_OTHER, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "FaxFillFunc", NULL }, + { TIFFTAG_BADFAXLINES, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_BADFAXLINES, TRUE, FALSE, "BadFaxLines", NULL }, + { TIFFTAG_CLEANFAXDATA, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UINT16, FIELD_CLEANFAXDATA, TRUE, FALSE, "CleanFaxData", NULL }, + { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_BADFAXRUN, TRUE, FALSE, "ConsecutiveBadFaxLines", NULL }}; static const TIFFField fax3Fields[] = { - {TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, - TIFF_SETGET_UINT32, FIELD_OPTIONS, FALSE, FALSE, "Group3Options", NULL}, + { TIFFTAG_GROUP3OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_OPTIONS, FALSE, FALSE, "Group3Options", NULL }, }; static const TIFFField fax4Fields[] = { - {TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, - TIFF_SETGET_UINT32, FIELD_OPTIONS, FALSE, FALSE, "Group4Options", NULL}, + { TIFFTAG_GROUP4OPTIONS, 1, 1, TIFF_LONG, 0, TIFF_SETGET_UINT32, TIFF_SETGET_UINT32, FIELD_OPTIONS, FALSE, FALSE, "Group4Options", NULL }, }; -static int Fax3VSetField(TIFF *tif, uint32_t tag, va_list ap) +static int +Fax3VSetField(TIFF* tif, uint32 tag, va_list ap) { - Fax3BaseState *sp = Fax3State(tif); - const TIFFField *fip; + Fax3BaseState* sp = Fax3State(tif); + const TIFFField* fip; - assert(sp != 0); - assert(sp->vsetparent != 0); + assert(sp != 0); + assert(sp->vsetparent != 0); - switch (tag) - { - case TIFFTAG_FAXMODE: - sp->mode = (int)va_arg(ap, int); - return 1; /* NB: pseudo tag */ - case TIFFTAG_FAXFILLFUNC: - DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc); - return 1; /* NB: pseudo tag */ - case TIFFTAG_GROUP3OPTIONS: - /* XXX: avoid reading options if compression mismatches. */ - if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX3) - 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_t)va_arg(ap, uint32_t); - break; - case TIFFTAG_BADFAXLINES: - sp->badfaxlines = (uint32_t)va_arg(ap, uint32_t); - break; - case TIFFTAG_CLEANFAXDATA: - sp->cleanfaxdata = (uint16_t)va_arg(ap, uint16_vap); - break; - case TIFFTAG_CONSECUTIVEBADFAXLINES: - sp->badfaxrun = (uint32_t)va_arg(ap, uint32_t); - break; - default: - return (*sp->vsetparent)(tif, tag, ap); - } + switch (tag) { + case TIFFTAG_FAXMODE: + sp->mode = (int) va_arg(ap, int); + return 1; /* NB: pseudo tag */ + case TIFFTAG_FAXFILLFUNC: + DecoderState(tif)->fill = va_arg(ap, TIFFFaxFillFunc); + return 1; /* NB: pseudo tag */ + 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); + 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); + break; + case TIFFTAG_BADFAXLINES: + sp->badfaxlines = (uint32) va_arg(ap, uint32); + break; + case TIFFTAG_CLEANFAXDATA: + sp->cleanfaxdata = (uint16) va_arg(ap, uint16_vap); + break; + case TIFFTAG_CONSECUTIVEBADFAXLINES: + sp->badfaxrun = (uint32) va_arg(ap, uint32); + break; + default: + return (*sp->vsetparent)(tif, tag, ap); + } + + if ((fip = TIFFFieldWithTag(tif, tag)) != NULL) + TIFFSetFieldBit(tif, fip->field_bit); + else + return 0; - if ((fip = TIFFFieldWithTag(tif, tag)) != NULL) - TIFFSetFieldBit(tif, fip->field_bit); - else - return 0; - - tif->tif_flags |= TIFF_DIRTYDIRECT; - return 1; + tif->tif_flags |= TIFF_DIRTYDIRECT; + return 1; } -static int Fax3VGetField(TIFF *tif, uint32_t tag, va_list ap) +static int +Fax3VGetField(TIFF* tif, uint32 tag, va_list ap) { - Fax3BaseState *sp = Fax3State(tif); + Fax3BaseState* sp = Fax3State(tif); - assert(sp != 0); + assert(sp != 0); - switch (tag) - { - case TIFFTAG_FAXMODE: - *va_arg(ap, int *) = sp->mode; - break; - case TIFFTAG_FAXFILLFUNC: - *va_arg(ap, TIFFFaxFillFunc *) = DecoderState(tif)->fill; - break; - case TIFFTAG_GROUP3OPTIONS: - case TIFFTAG_GROUP4OPTIONS: - *va_arg(ap, uint32_t *) = sp->groupoptions; - break; - case TIFFTAG_BADFAXLINES: - *va_arg(ap, uint32_t *) = sp->badfaxlines; - break; - case TIFFTAG_CLEANFAXDATA: - *va_arg(ap, uint16_t *) = sp->cleanfaxdata; - break; - case TIFFTAG_CONSECUTIVEBADFAXLINES: - *va_arg(ap, uint32_t *) = sp->badfaxrun; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); + switch (tag) { + case TIFFTAG_FAXMODE: + *va_arg(ap, int*) = sp->mode; + break; + case TIFFTAG_FAXFILLFUNC: + *va_arg(ap, TIFFFaxFillFunc*) = DecoderState(tif)->fill; + break; + case TIFFTAG_GROUP3OPTIONS: + case TIFFTAG_GROUP4OPTIONS: + *va_arg(ap, uint32*) = sp->groupoptions; + break; + case TIFFTAG_BADFAXLINES: + *va_arg(ap, uint32*) = sp->badfaxlines; + break; + case TIFFTAG_CLEANFAXDATA: + *va_arg(ap, uint16*) = sp->cleanfaxdata; + break; + case TIFFTAG_CONSECUTIVEBADFAXLINES: + *va_arg(ap, uint32*) = sp->badfaxrun; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return (1); } -static void Fax3PrintDir(TIFF *tif, FILE *fd, long flags) +static void +Fax3PrintDir(TIFF* tif, FILE* fd, long flags) { - Fax3BaseState *sp = Fax3State(tif); + Fax3BaseState* sp = Fax3State(tif); - assert(sp != 0); + assert(sp != 0); - (void)flags; - if (TIFFFieldSet(tif, FIELD_OPTIONS)) - { - const char *sep = " "; - if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) - { - fprintf(fd, " Group 4 Options:"); - if (sp->groupoptions & GROUP4OPT_UNCOMPRESSED) - fprintf(fd, "%suncompressed data", sep); - } - else - { + (void) flags; + if (TIFFFieldSet(tif,FIELD_OPTIONS)) { + const char* sep = " "; + if (tif->tif_dir.td_compression == COMPRESSION_CCITTFAX4) { + fprintf(fd, " Group 4 Options:"); + if (sp->groupoptions & GROUP4OPT_UNCOMPRESSED) + fprintf(fd, "%suncompressed data", sep); + } else { - fprintf(fd, " Group 3 Options:"); - if (sp->groupoptions & GROUP3OPT_2DENCODING) - { - fprintf(fd, "%s2-d encoding", sep); - sep = "+"; - } - if (sp->groupoptions & GROUP3OPT_FILLBITS) - { - fprintf(fd, "%sEOL padding", sep); - sep = "+"; - } - if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED) - fprintf(fd, "%suncompressed data", sep); - } - fprintf(fd, " (%" PRIu32 " = 0x%" PRIx32 ")\n", sp->groupoptions, - sp->groupoptions); - } - if (TIFFFieldSet(tif, FIELD_CLEANFAXDATA)) - { - fprintf(fd, " Fax Data:"); - switch (sp->cleanfaxdata) - { - case CLEANFAXDATA_CLEAN: - fprintf(fd, " clean"); - break; - case CLEANFAXDATA_REGENERATED: - fprintf(fd, " receiver regenerated"); - break; - case CLEANFAXDATA_UNCLEAN: - fprintf(fd, " uncorrected errors"); - break; - } - fprintf(fd, " (%" PRIu16 " = 0x%" PRIx16 ")\n", sp->cleanfaxdata, - sp->cleanfaxdata); - } - if (TIFFFieldSet(tif, FIELD_BADFAXLINES)) - fprintf(fd, " Bad Fax Lines: %" PRIu32 "\n", sp->badfaxlines); - if (TIFFFieldSet(tif, FIELD_BADFAXRUN)) - fprintf(fd, " Consecutive Bad Fax Lines: %" PRIu32 "\n", - sp->badfaxrun); - if (sp->printdir) - (*sp->printdir)(tif, fd, flags); + fprintf(fd, " Group 3 Options:"); + if (sp->groupoptions & GROUP3OPT_2DENCODING) { + fprintf(fd, "%s2-d encoding", sep); + sep = "+"; + } + if (sp->groupoptions & GROUP3OPT_FILLBITS) { + fprintf(fd, "%sEOL padding", sep); + sep = "+"; + } + if (sp->groupoptions & GROUP3OPT_UNCOMPRESSED) + fprintf(fd, "%suncompressed data", sep); + } + fprintf(fd, " (%lu = 0x%lx)\n", + (unsigned long) sp->groupoptions, + (unsigned long) sp->groupoptions); + } + if (TIFFFieldSet(tif,FIELD_CLEANFAXDATA)) { + fprintf(fd, " Fax Data:"); + switch (sp->cleanfaxdata) { + case CLEANFAXDATA_CLEAN: + fprintf(fd, " clean"); + break; + case CLEANFAXDATA_REGENERATED: + fprintf(fd, " receiver regenerated"); + break; + case CLEANFAXDATA_UNCLEAN: + fprintf(fd, " uncorrected errors"); + break; + } + fprintf(fd, " (%u = 0x%x)\n", + sp->cleanfaxdata, sp->cleanfaxdata); + } + if (TIFFFieldSet(tif,FIELD_BADFAXLINES)) + fprintf(fd, " Bad Fax Lines: %lu\n", + (unsigned long) sp->badfaxlines); + if (TIFFFieldSet(tif,FIELD_BADFAXRUN)) + fprintf(fd, " Consecutive Bad Fax Lines: %lu\n", + (unsigned long) sp->badfaxrun); + if (sp->printdir) + (*sp->printdir)(tif, fd, flags); } -static int InitCCITTFax3(TIFF *tif) +static int +InitCCITTFax3(TIFF* tif) { - static const char module[] = "InitCCITTFax3"; - Fax3BaseState *sp; + static const char module[] = "InitCCITTFax3"; + Fax3BaseState* sp; - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, faxFields, TIFFArrayCount(faxFields))) - { - TIFFErrorExtR(tif, "InitCCITTFax3", - "Merging common CCITT Fax codec-specific tags failed"); - return 0; - } + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, faxFields, TIFFArrayCount(faxFields))) { + TIFFErrorExt(tif->tif_clientdata, "InitCCITTFax3", + "Merging common CCITT Fax codec-specific tags failed"); + return 0; + } - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(Fax3CodecState)); + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) + _TIFFmalloc(sizeof (Fax3CodecState)); - if (tif->tif_data == NULL) - { - TIFFErrorExtR(tif, module, "No space for state block"); - return (0); - } - _TIFFmemset(tif->tif_data, 0, sizeof(Fax3CodecState)); + if (tif->tif_data == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, + "No space for state block"); + return (0); + } + _TIFFmemset(tif->tif_data, 0, sizeof (Fax3CodecState)); - sp = Fax3State(tif); - sp->rw_mode = tif->tif_mode; + sp = Fax3State(tif); + sp->rw_mode = tif->tif_mode; - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = Fax3VGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = Fax3VSetField; /* hook for codec tags */ - sp->printdir = tif->tif_tagmethods.printdir; - tif->tif_tagmethods.printdir = Fax3PrintDir; /* hook for codec tags */ - sp->groupoptions = 0; + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = Fax3VGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = Fax3VSetField; /* hook for codec tags */ + sp->printdir = tif->tif_tagmethods.printdir; + tif->tif_tagmethods.printdir = Fax3PrintDir; /* hook for codec tags */ + sp->groupoptions = 0; - if (sp->rw_mode == O_RDONLY) /* FIXME: improve for in place update */ - tif->tif_flags |= TIFF_NOBITREV; /* decoder does bit reversal */ - DecoderState(tif)->runs = NULL; - TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns); - EncoderState(tif)->refline = NULL; + if (sp->rw_mode == O_RDONLY) /* FIXME: improve for in place update */ + tif->tif_flags |= TIFF_NOBITREV; /* decoder does bit reversal */ + DecoderState(tif)->runs = NULL; + TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, _TIFFFax3fillruns); + EncoderState(tif)->refline = NULL; - /* - * Install codec methods. - */ - tif->tif_fixuptags = Fax3FixupTags; - tif->tif_setupdecode = Fax3SetupState; - tif->tif_predecode = Fax3PreDecode; - tif->tif_decoderow = Fax3Decode1D; - tif->tif_decodestrip = Fax3Decode1D; - tif->tif_decodetile = Fax3Decode1D; - tif->tif_setupencode = Fax3SetupState; - tif->tif_preencode = Fax3PreEncode; - tif->tif_postencode = Fax3PostEncode; - tif->tif_encoderow = Fax3Encode; - tif->tif_encodestrip = Fax3Encode; - tif->tif_encodetile = Fax3Encode; - tif->tif_close = Fax3Close; - tif->tif_cleanup = Fax3Cleanup; + /* + * Install codec methods. + */ + tif->tif_fixuptags = Fax3FixupTags; + tif->tif_setupdecode = Fax3SetupState; + tif->tif_predecode = Fax3PreDecode; + tif->tif_decoderow = Fax3Decode1D; + tif->tif_decodestrip = Fax3Decode1D; + tif->tif_decodetile = Fax3Decode1D; + tif->tif_setupencode = Fax3SetupState; + tif->tif_preencode = Fax3PreEncode; + tif->tif_postencode = Fax3PostEncode; + tif->tif_encoderow = Fax3Encode; + tif->tif_encodestrip = Fax3Encode; + tif->tif_encodetile = Fax3Encode; + tif->tif_close = Fax3Close; + tif->tif_cleanup = Fax3Cleanup; - return (1); + return (1); } -int TIFFInitCCITTFax3(TIFF *tif, int scheme) +int +TIFFInitCCITTFax3(TIFF* tif, int scheme) { - (void)scheme; - if (InitCCITTFax3(tif)) - { - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, fax3Fields, TIFFArrayCount(fax3Fields))) - { - TIFFErrorExtR(tif, "TIFFInitCCITTFax3", - "Merging CCITT Fax 3 codec-specific tags failed"); - return 0; - } + (void) scheme; + if (InitCCITTFax3(tif)) { + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, fax3Fields, + TIFFArrayCount(fax3Fields))) { + TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax3", + "Merging CCITT Fax 3 codec-specific tags failed"); + return 0; + } - /* - * The default format is Class/F-style w/o RTC. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF); - } - else - return 01; + /* + * The default format is Class/F-style w/o RTC. + */ + return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_CLASSF); + } else + return 01; } /* @@ -1495,146 +1468,138 @@ int TIFFInitCCITTFax3(TIFF *tif, int scheme) * Compression Scheme Support. */ -#define SWAP(t, a, b) \ - { \ - t x; \ - x = (a); \ - (a) = (b); \ - (b) = x; \ - } +#define SWAP(t,a,b) { t x; x = (a); (a) = (b); (b) = x; } /* * Decode the requested amount of G4-encoded data. */ -static int Fax4Decode(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) +static int +Fax4Decode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { - DECLARE_STATE_2D(tif, sp, "Fax4Decode"); - (void)s; - if (occ % sp->b.rowbytes) - { - TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read"); - return (-1); - } - CACHE_STATE(tif, sp); - while (occ > 0) - { - a0 = 0; - RunLength = 0; - pa = thisrun = sp->curruns; - pb = sp->refruns; - b1 = *pb++; + DECLARE_STATE_2D(tif, sp, "Fax4Decode"); + (void) s; + if (occ % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (-1); + } + CACHE_STATE(tif, sp); + while (occ > 0) { + a0 = 0; + RunLength = 0; + pa = thisrun = sp->curruns; + pb = sp->refruns; + b1 = *pb++; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %d\n", tif->tif_row); - fflush(stdout); + printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %d\n", tif->tif_row); + fflush(stdout); #endif - EXPAND2D(EOFG4); - if (EOLcnt) - goto EOFG4; - if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ - { - TIFFErrorExtR(tif, module, - "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_t *, sp->curruns, sp->refruns); - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - sp->line++; - continue; - EOFG4: - NeedBits16(13, BADG4); - BADG4: + EXPAND2D(EOFG4); + if (EOLcnt) + goto EOFG4; + 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); + return -1; + } + (*sp->fill)(buf, thisrun, pa, lastx); + SETVALUE(0); /* imaginary change for reference */ + SWAP(uint32*, sp->curruns, sp->refruns); + buf += sp->b.rowbytes; + occ -= sp->b.rowbytes; + sp->line++; + continue; + EOFG4: + NeedBits16( 13, BADG4 ); + BADG4: #ifdef FAX3_DEBUG - if (GetBits(13) != 0x1001) - fputs("Bad EOFB\n", stderr); -#endif - ClrBits(13); - if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */ - { - TIFFErrorExtR(tif, module, - "Buffer overrun detected : %" TIFF_SSIZE_FORMAT - " bytes available, %d bits needed", - occ, lastx); - return -1; - } - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (sp->line ? 1 : -1); /* don't error on badly-terminated strips */ - } - UNCACHE_STATE(tif, sp); - return (1); + if( GetBits(13) != 0x1001 ) + fputs( "Bad EOFB\n", stderr ); +#endif + ClrBits( 13 ); + 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); + return -1; + } + (*sp->fill)(buf, thisrun, pa, lastx); + UNCACHE_STATE(tif, sp); + return ( sp->line ? 1 : -1); /* don't error on badly-terminated strips */ + } + UNCACHE_STATE(tif, sp); + return (1); } -#undef SWAP +#undef SWAP /* * Encode the requested amount of data. */ -static int Fax4Encode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +Fax4Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "Fax4Encode"; - Fax3CodecState *sp = EncoderState(tif); - (void)s; - if (cc % sp->b.rowbytes) - { - TIFFErrorExtR(tif, module, "Fractional scanlines cannot be written"); - return (0); - } - while (cc > 0) - { - if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) - return (0); - _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); - bp += sp->b.rowbytes; - cc -= sp->b.rowbytes; - } - return (1); + static const char module[] = "Fax4Encode"; + Fax3CodecState *sp = EncoderState(tif); + (void) s; + if (cc % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be written"); + return (0); + } + while (cc > 0) { + if (!Fax3Encode2DRow(tif, bp, sp->refline, sp->b.rowpixels)) + return (0); + _TIFFmemcpy(sp->refline, bp, sp->b.rowbytes); + bp += sp->b.rowbytes; + cc -= sp->b.rowbytes; + } + return (1); } -static int Fax4PostEncode(TIFF *tif) +static int +Fax4PostEncode(TIFF* tif) { - Fax3CodecState *sp = EncoderState(tif); + Fax3CodecState *sp = EncoderState(tif); - /* terminate strip w/ EOFB */ - Fax3PutBits(tif, EOL, 12); - Fax3PutBits(tif, EOL, 12); - if (sp->bit != 8) - Fax3FlushBits(tif, sp); - return (1); + /* terminate strip w/ EOFB */ + Fax3PutBits(tif, EOL, 12); + Fax3PutBits(tif, EOL, 12); + if (sp->bit != 8) + Fax3FlushBits(tif, sp); + return (1); } -int TIFFInitCCITTFax4(TIFF *tif, int scheme) +int +TIFFInitCCITTFax4(TIFF* tif, int scheme) { - (void)scheme; - if (InitCCITTFax3(tif)) - { /* reuse G3 support */ - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, fax4Fields, TIFFArrayCount(fax4Fields))) - { - TIFFErrorExtR(tif, "TIFFInitCCITTFax4", - "Merging CCITT Fax 4 codec-specific tags failed"); - return 0; - } + (void) scheme; + if (InitCCITTFax3(tif)) { /* reuse G3 support */ + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, fax4Fields, + TIFFArrayCount(fax4Fields))) { + TIFFErrorExt(tif->tif_clientdata, "TIFFInitCCITTFax4", + "Merging CCITT Fax 4 codec-specific tags failed"); + return 0; + } - tif->tif_decoderow = Fax4Decode; - tif->tif_decodestrip = Fax4Decode; - tif->tif_decodetile = Fax4Decode; - tif->tif_encoderow = Fax4Encode; - tif->tif_encodestrip = Fax4Encode; - tif->tif_encodetile = Fax4Encode; - tif->tif_postencode = Fax4PostEncode; - /* - * Suppress RTC at the end of each strip. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC); - } - else - return (0); + tif->tif_decoderow = Fax4Decode; + tif->tif_decodestrip = Fax4Decode; + tif->tif_decodetile = Fax4Decode; + tif->tif_encoderow = Fax4Encode; + tif->tif_encodestrip = Fax4Encode; + tif->tif_encodetile = Fax4Encode; + tif->tif_postencode = Fax4PostEncode; + /* + * Suppress RTC at the end of each strip. + */ + return TIFFSetField(tif, TIFFTAG_FAXMODE, FAXMODE_NORTC); + } else + return (0); } /* @@ -1645,91 +1610,95 @@ int TIFFInitCCITTFax4(TIFF *tif, int scheme) /* * Decode the requested amount of RLE-encoded data. */ -static int Fax3DecodeRLE(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) +static int +Fax3DecodeRLE(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { - DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); - int mode = sp->b.mode; - (void)s; - if (occ % sp->b.rowbytes) - { - TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read"); - return (-1); - } - CACHE_STATE(tif, sp); - thisrun = sp->curruns; - while (occ > 0) - { - a0 = 0; - RunLength = 0; - pa = thisrun; + DECLARE_STATE(tif, sp, "Fax3DecodeRLE"); + int mode = sp->b.mode; + (void) s; + if (occ % sp->b.rowbytes) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (-1); + } + CACHE_STATE(tif, sp); + thisrun = sp->curruns; + while (occ > 0) { + a0 = 0; + RunLength = 0; + pa = thisrun; #ifdef FAX3_DEBUG - printf("\nBitAcc=%08" PRIX32 ", BitsAvail = %d\n", BitAcc, BitsAvail); - printf("-------------------- %" PRIu32 "\n", tif->tif_row); - fflush(stdout); + printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail); + printf("-------------------- %d\n", tif->tif_row); + fflush(stdout); #endif - EXPAND1D(EOFRLE); - (*sp->fill)(buf, thisrun, pa, lastx); - /* - * Cleanup at the end of the row. - */ - if (mode & FAXMODE_BYTEALIGN) - { - int n = BitsAvail - (BitsAvail & ~7); - ClrBits(n); - } - else if (mode & FAXMODE_WORDALIGN) - { - int n = BitsAvail - (BitsAvail & ~15); - ClrBits(n); - if (BitsAvail == 0 && !isAligned(cp, uint16_t)) - cp++; - } - buf += sp->b.rowbytes; - occ -= sp->b.rowbytes; - sp->line++; - continue; - EOFRLE: /* premature EOF */ - (*sp->fill)(buf, thisrun, pa, lastx); - UNCACHE_STATE(tif, sp); - return (-1); - } - UNCACHE_STATE(tif, sp); - return (1); + EXPAND1D(EOFRLE); + (*sp->fill)(buf, thisrun, pa, lastx); + /* + * Cleanup at the end of the row. + */ + if (mode & FAXMODE_BYTEALIGN) { + int n = BitsAvail - (BitsAvail &~ 7); + ClrBits(n); + } else if (mode & FAXMODE_WORDALIGN) { + int n = BitsAvail - (BitsAvail &~ 15); + ClrBits(n); + if (BitsAvail == 0 && !isAligned(cp, uint16)) + cp++; + } + buf += sp->b.rowbytes; + occ -= sp->b.rowbytes; + sp->line++; + continue; + EOFRLE: /* premature EOF */ + (*sp->fill)(buf, thisrun, pa, lastx); + UNCACHE_STATE(tif, sp); + return (-1); + } + UNCACHE_STATE(tif, sp); + return (1); } -int TIFFInitCCITTRLE(TIFF *tif, int scheme) +int +TIFFInitCCITTRLE(TIFF* tif, int scheme) { - (void)scheme; - if (InitCCITTFax3(tif)) - { /* reuse G3 support */ - tif->tif_decoderow = Fax3DecodeRLE; - tif->tif_decodestrip = Fax3DecodeRLE; - tif->tif_decodetile = Fax3DecodeRLE; - /* - * Suppress RTC+EOLs when encoding and byte-align data. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, - FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_BYTEALIGN); - } - else - return (0); + (void) scheme; + if (InitCCITTFax3(tif)) { /* reuse G3 support */ + tif->tif_decoderow = Fax3DecodeRLE; + tif->tif_decodestrip = Fax3DecodeRLE; + tif->tif_decodetile = Fax3DecodeRLE; + /* + * Suppress RTC+EOLs when encoding and byte-align data. + */ + return TIFFSetField(tif, TIFFTAG_FAXMODE, + FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_BYTEALIGN); + } else + return (0); } -int TIFFInitCCITTRLEW(TIFF *tif, int scheme) +int +TIFFInitCCITTRLEW(TIFF* tif, int scheme) { - (void)scheme; - if (InitCCITTFax3(tif)) - { /* reuse G3 support */ - tif->tif_decoderow = Fax3DecodeRLE; - tif->tif_decodestrip = Fax3DecodeRLE; - tif->tif_decodetile = Fax3DecodeRLE; - /* - * Suppress RTC+EOLs when encoding and word-align data. - */ - return TIFFSetField(tif, TIFFTAG_FAXMODE, - FAXMODE_NORTC | FAXMODE_NOEOL | FAXMODE_WORDALIGN); - } - else - return (0); + (void) scheme; + if (InitCCITTFax3(tif)) { /* reuse G3 support */ + tif->tif_decoderow = Fax3DecodeRLE; + tif->tif_decodestrip = Fax3DecodeRLE; + tif->tif_decodetile = Fax3DecodeRLE; + /* + * Suppress RTC+EOLs when encoding and word-align data. + */ + return TIFFSetField(tif, TIFFTAG_FAXMODE, + FAXMODE_NORTC|FAXMODE_NOEOL|FAXMODE_WORDALIGN); + } else + return (0); } #endif /* CCITT_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_fax3.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_fax3.h index e095009bb..701716cc1 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_fax3.h +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_fax3.h @@ -2,28 +2,28 @@ * Copyright (c) 1990-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _FAX3_ -#define _FAX3_ +#define _FAX3_ /* * TIFF Library. * @@ -41,7 +41,7 @@ * The routine must have the type signature given below; * for example: * - * fillruns(unsigned char* buf, uint32_t* runs, uint32_t* erun, uint32_t lastx) + * fillruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 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,47 +50,41 @@ * 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_t *, uint32_t *, - uint32_t); +typedef void (*TIFFFaxFillFunc)(unsigned char*, uint32*, uint32*, uint32); /* * The default run filler; made external for other decoders. */ #if defined(__cplusplus) -extern "C" -{ +extern "C" { #endif - extern void _TIFFFax3fillruns(unsigned char *, uint32_t *, uint32_t *, - uint32_t); +extern void _TIFFFax3fillruns(unsigned char*, uint32*, uint32*, uint32); #if defined(__cplusplus) } #endif -/* finite state machine codes */ -#define S_Null 0 -#define S_Pass 1 -#define S_Horiz 2 -#define S_V0 3 -#define S_VR 4 -#define S_VL 5 -#define S_Ext 6 -#define S_TermW 7 -#define S_TermB 8 -#define S_MakeUpW 9 -#define S_MakeUpB 10 -#define S_MakeUp 11 -#define S_EOL 12 -/* WARNING: do not change the layout of this structure as the HylaFAX software - */ -/* really depends on it. See http://bugzilla.maptools.org/show_bug.cgi?id=2636 - */ -typedef struct -{ /* state table entry */ - unsigned char State; /* see above */ - unsigned char Width; /* width of code in bits */ - uint32_t Param; /* unsigned 32-bit run length in bits (holds on 16 bit - actually, but cannot be changed. See above warning) */ +/* finite state machine codes */ +#define S_Null 0 +#define S_Pass 1 +#define S_Horiz 2 +#define S_V0 3 +#define S_VR 4 +#define S_VL 5 +#define S_Ext 6 +#define S_TermW 7 +#define S_TermB 8 +#define S_MakeUpW 9 +#define S_MakeUpB 10 +#define S_MakeUp 11 +#define S_EOL 12 + +/* WARNING: do not change the layout of this structure as the HylaFAX software */ +/* really depends on it. See http://bugzilla.maptools.org/show_bug.cgi?id=2636 */ +typedef struct { /* state table entry */ + unsigned char State; /* see above */ + unsigned char Width; /* width of code in bits */ + uint32 Param; /* unsigned 32-bit run length in bits (holds on 16 bit actually, but cannot be changed. See above warning) */ } TIFFFaxTabEnt; extern const TIFFFaxTabEnt TIFFFaxMainTable[]; @@ -114,7 +108,7 @@ extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; */ #ifndef EndOfData -#define EndOfData() (cp >= ep) +#define EndOfData() (cp >= ep) #endif /* * Need <=8 or <=16 bits of input data. Unlike viewfax we @@ -140,143 +134,121 @@ extern const TIFFFaxTabEnt TIFFFaxBlackTable[]; * otherwise we should get the right answer. */ #ifndef NeedBits8 -#define NeedBits8(n, eoflab) \ - do \ - { \ - if (BitsAvail < (n)) \ - { \ - if (EndOfData()) \ - { \ - if (BitsAvail == 0) /* no valid bits */ \ - goto eoflab; \ - BitsAvail = (n); /* pad with zeros */ \ - } \ - else \ - { \ - BitAcc |= ((uint32_t)bitmap[*cp++]) << BitsAvail; \ - BitsAvail += 8; \ - } \ - } \ - } while (0) +#define NeedBits8(n,eoflab) do { \ + if (BitsAvail < (n)) { \ + if (EndOfData()) { \ + if (BitsAvail == 0) /* no valid bits */ \ + goto eoflab; \ + BitsAvail = (n); /* pad with zeros */ \ + } else { \ + BitAcc |= ((uint32) bitmap[*cp++])<>= (n); \ - } while (0) +#define GetBits(n) (BitAcc & ((1<<(n))-1)) +#define ClrBits(n) do { \ + BitsAvail -= (n); \ + BitAcc >>= (n); \ +} while (0) #ifdef FAX3_DEBUG -static const char *StateNames[] = { - "Null ", "Pass ", "Horiz ", "V0 ", "VR ", "VL ", "Ext ", - "TermW ", "TermB ", "MakeUpW", "MakeUpB", "MakeUp ", "EOL ", +static const char* StateNames[] = { + "Null ", + "Pass ", + "Horiz ", + "V0 ", + "VR ", + "VL ", + "Ext ", + "TermW ", + "TermB ", + "MakeUpW", + "MakeUpB", + "MakeUp ", + "EOL ", }; #define DEBUG_SHOW putchar(BitAcc & (1 << t) ? '1' : '0') -#define LOOKUP8(wid, tab, eoflab) \ - do \ - { \ - int t; \ - NeedBits8(wid, eoflab); \ - TabEnt = tab + GetBits(wid); \ - printf("%08lX/%d: %s%5d\t", (long)BitAcc, BitsAvail, \ - StateNames[TabEnt->State], TabEnt->Param); \ - for (t = 0; t < TabEnt->Width; t++) \ - DEBUG_SHOW; \ - putchar('\n'); \ - fflush(stdout); \ - ClrBits(TabEnt->Width); \ - } while (0) -#define LOOKUP16(wid, tab, eoflab) \ - do \ - { \ - int t; \ - NeedBits16(wid, eoflab); \ - TabEnt = tab + GetBits(wid); \ - printf("%08lX/%d: %s%5d\t", (long)BitAcc, BitsAvail, \ - StateNames[TabEnt->State], TabEnt->Param); \ - for (t = 0; t < TabEnt->Width; t++) \ - DEBUG_SHOW; \ - putchar('\n'); \ - fflush(stdout); \ - ClrBits(TabEnt->Width); \ - } while (0) +#define LOOKUP8(wid,tab,eoflab) do { \ + int t; \ + NeedBits8(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ + StateNames[TabEnt->State], TabEnt->Param); \ + for (t = 0; t < TabEnt->Width; t++) \ + DEBUG_SHOW; \ + putchar('\n'); \ + fflush(stdout); \ + ClrBits(TabEnt->Width); \ +} while (0) +#define LOOKUP16(wid,tab,eoflab) do { \ + int t; \ + NeedBits16(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + printf("%08lX/%d: %s%5d\t", (long) BitAcc, BitsAvail, \ + StateNames[TabEnt->State], TabEnt->Param); \ + for (t = 0; t < TabEnt->Width; t++) \ + DEBUG_SHOW; \ + putchar('\n'); \ + fflush(stdout); \ + ClrBits(TabEnt->Width); \ +} while (0) -#define SETVALUE(x) \ - do \ - { \ - *pa++ = RunLength + (x); \ - printf("SETVALUE: %d\t%d\n", RunLength + (x), a0); \ - a0 += x; \ - RunLength = 0; \ - } while (0) +#define SETVALUE(x) do { \ + *pa++ = RunLength + (x); \ + printf("SETVALUE: %d\t%d\n", RunLength + (x), a0); \ + a0 += x; \ + RunLength = 0; \ +} while (0) #else -#define LOOKUP8(wid, tab, eoflab) \ - do \ - { \ - NeedBits8(wid, eoflab); \ - TabEnt = tab + GetBits(wid); \ - ClrBits(TabEnt->Width); \ - } while (0) -#define LOOKUP16(wid, tab, eoflab) \ - do \ - { \ - NeedBits16(wid, eoflab); \ - TabEnt = tab + GetBits(wid); \ - ClrBits(TabEnt->Width); \ - } while (0) +#define LOOKUP8(wid,tab,eoflab) do { \ + NeedBits8(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + ClrBits(TabEnt->Width); \ +} while (0) +#define LOOKUP16(wid,tab,eoflab) do { \ + NeedBits16(wid,eoflab); \ + TabEnt = tab + GetBits(wid); \ + ClrBits(TabEnt->Width); \ +} while (0) /* * Append a run to the run length array for the * current row and reset decoding state. */ -#define SETVALUE(x) \ - do \ - { \ - if (pa >= thisrun + sp->nruns) \ - { \ - TIFFErrorExtR(tif, module, "Buffer overflow at line %u of %s %u", \ - sp->line, isTiled(tif) ? "tile" : "strip", \ - isTiled(tif) ? tif->tif_curtile \ - : tif->tif_curstrip); \ - return (-1); \ - } \ - *pa++ = RunLength + (x); \ - a0 += (x); \ - RunLength = 0; \ - } while (0) +#define SETVALUE(x) do { \ + if (pa >= thisrun + sp->nruns) { \ + TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \ + sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \ + return (-1); \ + } \ + *pa++ = RunLength + (x); \ + a0 += (x); \ + RunLength = 0; \ +} while (0) #endif /* @@ -289,62 +261,51 @@ static const char *StateNames[] = { * is non-zero then we still need to scan for the final flag * bit that is part of the EOL code. */ -#define SYNC_EOL(eoflab) \ - do \ - { \ - if (EOLcnt == 0) \ - { \ - for (;;) \ - { \ - NeedBits16(11, eoflab); \ - if (GetBits(11) == 0) \ - break; \ - ClrBits(1); \ - } \ - } \ - for (;;) \ - { \ - NeedBits8(8, eoflab); \ - if (GetBits(8)) \ - break; \ - ClrBits(8); \ - } \ - while (GetBits(1) == 0) \ - ClrBits(1); \ - ClrBits(1); /* EOL bit */ \ - EOLcnt = 0; /* reset EOL counter/flag */ \ - } while (0) +#define SYNC_EOL(eoflab) do { \ + if (EOLcnt == 0) { \ + for (;;) { \ + NeedBits16(11,eoflab); \ + if (GetBits(11) == 0) \ + break; \ + ClrBits(1); \ + } \ + } \ + for (;;) { \ + NeedBits8(8,eoflab); \ + if (GetBits(8)) \ + break; \ + ClrBits(8); \ + } \ + while (GetBits(1) == 0) \ + ClrBits(1); \ + ClrBits(1); /* EOL bit */ \ + EOLcnt = 0; /* reset EOL counter/flag */ \ +} while (0) /* * Cleanup the array of runs after decoding a row. * We adjust final runs to insure the user buffer is not * overwritten and/or undecoded area is white filled. */ -#define CLEANUP_RUNS() \ - do \ - { \ - if (RunLength) \ - SETVALUE(0); \ - if (a0 != lastx) \ - { \ - badlength(a0, lastx); \ - while (a0 > lastx && pa > thisrun) \ - a0 -= *--pa; \ - if (a0 < lastx) \ - { \ - if (a0 < 0) \ - a0 = 0; \ - if ((pa - thisrun) & 1) \ - SETVALUE(0); \ - SETVALUE(lastx - a0); \ - } \ - else if (a0 > lastx) \ - { \ - SETVALUE(lastx); \ - SETVALUE(0); \ - } \ - } \ - } while (0) +#define CLEANUP_RUNS() do { \ + if (RunLength) \ + SETVALUE(0); \ + if (a0 != lastx) { \ + badlength(a0, lastx); \ + while (a0 > lastx && pa > thisrun) \ + a0 -= *--pa; \ + if (a0 < lastx) { \ + if (a0 < 0) \ + a0 = 0; \ + if ((pa-thisrun)&1) \ + SETVALUE(0); \ + SETVALUE(lastx - a0); \ + } else if (a0 > lastx) { \ + SETVALUE(lastx); \ + SETVALUE(0); \ + } \ + } \ +} while (0) /* * Decode a line of 1D-encoded data. @@ -358,291 +319,249 @@ static const char *StateNames[] = { * the original code depended on the input data being zero-padded to * insure the decoder recognized an EOL before running out of data. */ -#define EXPAND1D(eoflab) \ - do \ - { \ - for (;;) \ - { \ - for (;;) \ - { \ - LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \ - switch (TabEnt->State) \ - { \ - case S_EOL: \ - EOLcnt = 1; \ - goto done1d; \ - case S_TermW: \ - SETVALUE(TabEnt->Param); \ - goto doneWhite1d; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - unexpected("WhiteTable", a0); \ - goto done1d; \ - } \ - } \ - doneWhite1d: \ - if (a0 >= lastx) \ - goto done1d; \ - for (;;) \ - { \ - LOOKUP16(13, TIFFFaxBlackTable, eof1d); \ - switch (TabEnt->State) \ - { \ - case S_EOL: \ - EOLcnt = 1; \ - goto done1d; \ - case S_TermB: \ - SETVALUE(TabEnt->Param); \ - goto doneBlack1d; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - unexpected("BlackTable", a0); \ - goto done1d; \ - } \ - } \ - doneBlack1d: \ - if (a0 >= lastx) \ - goto done1d; \ - if (*(pa - 1) == 0 && *(pa - 2) == 0) \ - pa -= 2; \ - } \ - eof1d: \ - prematureEOF(a0); \ - CLEANUP_RUNS(); \ - goto eoflab; \ - done1d: \ - CLEANUP_RUNS(); \ - } while (0) +#define EXPAND1D(eoflab) do { \ + for (;;) { \ + for (;;) { \ + LOOKUP16(12, TIFFFaxWhiteTable, eof1d); \ + switch (TabEnt->State) { \ + case S_EOL: \ + EOLcnt = 1; \ + goto done1d; \ + case S_TermW: \ + SETVALUE(TabEnt->Param); \ + goto doneWhite1d; \ + case S_MakeUpW: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + unexpected("WhiteTable", a0); \ + goto done1d; \ + } \ + } \ + doneWhite1d: \ + if (a0 >= lastx) \ + goto done1d; \ + for (;;) { \ + LOOKUP16(13, TIFFFaxBlackTable, eof1d); \ + switch (TabEnt->State) { \ + case S_EOL: \ + EOLcnt = 1; \ + goto done1d; \ + case S_TermB: \ + SETVALUE(TabEnt->Param); \ + goto doneBlack1d; \ + case S_MakeUpB: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + unexpected("BlackTable", a0); \ + goto done1d; \ + } \ + } \ + doneBlack1d: \ + if (a0 >= lastx) \ + goto done1d; \ + if( *(pa-1) == 0 && *(pa-2) == 0 ) \ + pa -= 2; \ + } \ +eof1d: \ + prematureEOF(a0); \ + CLEANUP_RUNS(); \ + goto eoflab; \ +done1d: \ + CLEANUP_RUNS(); \ +} while (0) /* * Update the value of b1 using the array * of runs for the reference line. */ -#define CHECK_b1 \ - do \ - { \ - if (pa != thisrun) \ - while (b1 <= a0 && b1 < lastx) \ - { \ - if (pb + 1 >= sp->refruns + sp->nruns) \ - { \ - TIFFErrorExtR( \ - tif, module, "Buffer overflow at line %u of %s %u", \ - sp->line, isTiled(tif) ? "tile" : "strip", \ - isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \ - return (-1); \ - } \ - b1 += pb[0] + pb[1]; \ - pb += 2; \ - } \ - } while (0) +#define CHECK_b1 do { \ + if (pa != thisrun) while (b1 <= a0 && b1 < lastx) { \ + if( pb + 1 >= sp->refruns + sp->nruns) { \ + TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \ + sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \ + return (-1); \ + } \ + b1 += pb[0] + pb[1]; \ + pb += 2; \ + } \ +} while (0) /* * Expand a row of 2D-encoded data. */ -#define EXPAND2D(eoflab) \ - do \ - { \ - while (a0 < lastx) \ - { \ - if (pa >= thisrun + sp->nruns) \ - { \ - TIFFErrorExtR( \ - tif, module, "Buffer overflow at line %u of %s %u", \ - sp->line, isTiled(tif) ? "tile" : "strip", \ - isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \ - return (-1); \ - } \ - LOOKUP8(7, TIFFFaxMainTable, eof2d); \ - switch (TabEnt->State) \ - { \ - case S_Pass: \ - CHECK_b1; \ - if (pb + 1 >= sp->refruns + sp->nruns) \ - { \ - TIFFErrorExtR(tif, module, \ - "Buffer overflow at line %u of %s %u", \ - sp->line, \ - isTiled(tif) ? "tile" : "strip", \ - isTiled(tif) ? tif->tif_curtile \ - : tif->tif_curstrip); \ - return (-1); \ - } \ - b1 += *pb++; \ - RunLength += b1 - a0; \ - a0 = b1; \ - b1 += *pb++; \ - break; \ - case S_Horiz: \ - if ((pa - thisrun) & 1) \ - { \ - for (;;) \ - { /* black first */ \ - LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ - switch (TabEnt->State) \ - { \ - case S_TermB: \ - SETVALUE(TabEnt->Param); \ - goto doneWhite2da; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badBlack2d; \ - } \ - } \ - doneWhite2da:; \ - for (;;) \ - { /* then white */ \ - LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ - switch (TabEnt->State) \ - { \ - case S_TermW: \ - SETVALUE(TabEnt->Param); \ - goto doneBlack2da; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badWhite2d; \ - } \ - } \ - doneBlack2da:; \ - } \ - else \ - { \ - for (;;) \ - { /* white first */ \ - LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ - switch (TabEnt->State) \ - { \ - case S_TermW: \ - SETVALUE(TabEnt->Param); \ - goto doneWhite2db; \ - case S_MakeUpW: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badWhite2d; \ - } \ - } \ - doneWhite2db:; \ - for (;;) \ - { /* then black */ \ - LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ - switch (TabEnt->State) \ - { \ - case S_TermB: \ - SETVALUE(TabEnt->Param); \ - goto doneBlack2db; \ - case S_MakeUpB: \ - case S_MakeUp: \ - a0 += TabEnt->Param; \ - RunLength += TabEnt->Param; \ - break; \ - default: \ - goto badBlack2d; \ - } \ - } \ - doneBlack2db:; \ - } \ - CHECK_b1; \ - break; \ - case S_V0: \ - CHECK_b1; \ - SETVALUE(b1 - a0); \ - if (pb >= sp->refruns + sp->nruns) \ - { \ - TIFFErrorExtR(tif, module, \ - "Buffer overflow at line %u of %s %u", \ - sp->line, \ - isTiled(tif) ? "tile" : "strip", \ - isTiled(tif) ? tif->tif_curtile \ - : tif->tif_curstrip); \ - return (-1); \ - } \ - b1 += *pb++; \ - break; \ - case S_VR: \ - CHECK_b1; \ - SETVALUE(b1 - a0 + TabEnt->Param); \ - if (pb >= sp->refruns + sp->nruns) \ - { \ - TIFFErrorExtR(tif, module, \ - "Buffer overflow at line %u of %s %u", \ - sp->line, \ - isTiled(tif) ? "tile" : "strip", \ - isTiled(tif) ? tif->tif_curtile \ - : tif->tif_curstrip); \ - return (-1); \ - } \ - b1 += *pb++; \ - break; \ - case S_VL: \ - CHECK_b1; \ - if (b1 < (int)(a0 + TabEnt->Param)) \ - { \ - unexpected("VL", a0); \ - goto eol2d; \ - } \ - SETVALUE(b1 - a0 - TabEnt->Param); \ - b1 -= *--pb; \ - break; \ - case S_Ext: \ - *pa++ = lastx - a0; \ - extension(a0); \ - goto eol2d; \ - case S_EOL: \ - *pa++ = lastx - a0; \ - NeedBits8(4, eof2d); \ - if (GetBits(4)) \ - unexpected("EOL", a0); \ - ClrBits(4); \ - EOLcnt = 1; \ - goto eol2d; \ - default: \ - badMain2d: \ - unexpected("MainTable", a0); \ - goto eol2d; \ - badBlack2d: \ - unexpected("BlackTable", a0); \ - goto eol2d; \ - badWhite2d: \ - unexpected("WhiteTable", a0); \ - goto eol2d; \ - eof2d: \ - prematureEOF(a0); \ - CLEANUP_RUNS(); \ - goto eoflab; \ - } \ - } \ - if (RunLength) \ - { \ - if (RunLength + a0 < lastx) \ - { \ - /* expect a final V0 */ \ - NeedBits8(1, eof2d); \ - if (!GetBits(1)) \ - goto badMain2d; \ - ClrBits(1); \ - } \ - SETVALUE(0); \ - } \ - eol2d: \ - CLEANUP_RUNS(); \ - } while (0) +#define EXPAND2D(eoflab) do { \ + while (a0 < lastx) { \ + if (pa >= thisrun + sp->nruns) { \ + TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \ + sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \ + return (-1); \ + } \ + LOOKUP8(7, TIFFFaxMainTable, eof2d); \ + switch (TabEnt->State) { \ + case S_Pass: \ + CHECK_b1; \ + if( pb + 1 >= sp->refruns + sp->nruns) { \ + TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \ + sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \ + return (-1); \ + } \ + b1 += *pb++; \ + RunLength += b1 - a0; \ + a0 = b1; \ + b1 += *pb++; \ + break; \ + case S_Horiz: \ + if ((pa-thisrun)&1) { \ + for (;;) { /* black first */ \ + LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ + switch (TabEnt->State) { \ + case S_TermB: \ + SETVALUE(TabEnt->Param); \ + goto doneWhite2da; \ + case S_MakeUpB: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + goto badBlack2d; \ + } \ + } \ + doneWhite2da:; \ + for (;;) { /* then white */ \ + LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ + switch (TabEnt->State) { \ + case S_TermW: \ + SETVALUE(TabEnt->Param); \ + goto doneBlack2da; \ + case S_MakeUpW: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + goto badWhite2d; \ + } \ + } \ + doneBlack2da:; \ + } else { \ + for (;;) { /* white first */ \ + LOOKUP16(12, TIFFFaxWhiteTable, eof2d); \ + switch (TabEnt->State) { \ + case S_TermW: \ + SETVALUE(TabEnt->Param); \ + goto doneWhite2db; \ + case S_MakeUpW: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + goto badWhite2d; \ + } \ + } \ + doneWhite2db:; \ + for (;;) { /* then black */ \ + LOOKUP16(13, TIFFFaxBlackTable, eof2d); \ + switch (TabEnt->State) { \ + case S_TermB: \ + SETVALUE(TabEnt->Param); \ + goto doneBlack2db; \ + case S_MakeUpB: \ + case S_MakeUp: \ + a0 += TabEnt->Param; \ + RunLength += TabEnt->Param; \ + break; \ + default: \ + goto badBlack2d; \ + } \ + } \ + doneBlack2db:; \ + } \ + CHECK_b1; \ + break; \ + case S_V0: \ + CHECK_b1; \ + SETVALUE(b1 - a0); \ + if( pb >= sp->refruns + sp->nruns) { \ + TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \ + sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \ + return (-1); \ + } \ + b1 += *pb++; \ + break; \ + case S_VR: \ + CHECK_b1; \ + SETVALUE(b1 - a0 + TabEnt->Param); \ + if( pb >= sp->refruns + sp->nruns) { \ + TIFFErrorExt(tif->tif_clientdata, module, "Buffer overflow at line %u of %s %u", \ + sp->line, isTiled(tif) ? "tile" : "strip", isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip); \ + return (-1); \ + } \ + b1 += *pb++; \ + break; \ + case S_VL: \ + CHECK_b1; \ + if (b1 < (int) (a0 + TabEnt->Param)) { \ + unexpected("VL", a0); \ + goto eol2d; \ + } \ + SETVALUE(b1 - a0 - TabEnt->Param); \ + b1 -= *--pb; \ + break; \ + case S_Ext: \ + *pa++ = lastx - a0; \ + extension(a0); \ + goto eol2d; \ + case S_EOL: \ + *pa++ = lastx - a0; \ + NeedBits8(4,eof2d); \ + if (GetBits(4)) \ + unexpected("EOL", a0); \ + ClrBits(4); \ + EOLcnt = 1; \ + goto eol2d; \ + default: \ + badMain2d: \ + unexpected("MainTable", a0); \ + goto eol2d; \ + badBlack2d: \ + unexpected("BlackTable", a0); \ + goto eol2d; \ + badWhite2d: \ + unexpected("WhiteTable", a0); \ + goto eol2d; \ + eof2d: \ + prematureEOF(a0); \ + CLEANUP_RUNS(); \ + goto eoflab; \ + } \ + } \ + if (RunLength) { \ + if (RunLength + a0 < lastx) { \ + /* expect a final V0 */ \ + NeedBits8(1,eof2d); \ + if (!GetBits(1)) \ + goto badMain2d; \ + ClrBits(1); \ + } \ + SETVALUE(0); \ + } \ +eol2d: \ + CLEANUP_RUNS(); \ +} while (0) #endif /* _FAX3_ */ +/* vim: set ts=8 sts=4 sw=4 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_flush.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_flush.c index ff9c1e247..f7fa2072a 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_flush.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_flush.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -27,28 +27,30 @@ */ #include "tiffiop.h" -int TIFFFlush(TIFF *tif) +int +TIFFFlush(TIFF* tif) { - if (tif->tif_mode == O_RDONLY) + if( tif->tif_mode == O_RDONLY ) return 1; if (!TIFFFlushData(tif)) return (0); - - /* In update (r+) mode we try to detect the case where - only the strip/tile map has been altered, and we try to - rewrite only that portion of the directory without + + /* In update (r+) mode we try to detect the case where + only the strip/tile map has been altered, and we try to + rewrite only that portion of the directory without making any other changes */ - - if ((tif->tif_flags & TIFF_DIRTYSTRIP) && - !(tif->tif_flags & TIFF_DIRTYDIRECT) && tif->tif_mode == O_RDWR) + + if( (tif->tif_flags & TIFF_DIRTYSTRIP) + && !(tif->tif_flags & TIFF_DIRTYDIRECT) + && tif->tif_mode == O_RDWR ) { - if (TIFFForceStrileArrayWriting(tif)) + if( TIFFForceStrileArrayWriting(tif) ) return 1; } - if ((tif->tif_flags & (TIFF_DIRTYDIRECT | TIFF_DIRTYSTRIP)) && - !TIFFRewriteDirectory(tif)) + if ((tif->tif_flags & (TIFF_DIRTYDIRECT|TIFF_DIRTYSTRIP)) + && !TIFFRewriteDirectory(tif)) return (0); return (1); @@ -73,43 +75,45 @@ int TIFFFlush(TIFF *tif) * * Returns 1 in case of success, 0 otherwise. */ -int TIFFForceStrileArrayWriting(TIFF *tif) +int TIFFForceStrileArrayWriting(TIFF* tif) { static const char module[] = "TIFFForceStrileArrayWriting"; const int isTiled = TIFFIsTiled(tif); if (tif->tif_mode == O_RDONLY) { - TIFFErrorExtR(tif, tif->tif_name, "File opened in read-only mode"); + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "File opened in read-only mode"); return 0; } - if (tif->tif_diroff == 0) + if( tif->tif_diroff == 0 ) { - TIFFErrorExtR(tif, module, "Directory has not yet been written"); + TIFFErrorExt(tif->tif_clientdata, module, + "Directory has not yet been written"); return 0; } - if ((tif->tif_flags & TIFF_DIRTYDIRECT) != 0) + if( (tif->tif_flags & TIFF_DIRTYDIRECT) != 0 ) { - TIFFErrorExtR(tif, module, - "Directory has changes other than the strile arrays. " - "TIFFRewriteDirectory() should be called instead"); + TIFFErrorExt(tif->tif_clientdata, module, + "Directory has changes other than the strile arrays. " + "TIFFRewriteDirectory() should be called instead"); return 0; } - if (!(tif->tif_flags & TIFF_DIRTYSTRIP)) + if( !(tif->tif_flags & TIFF_DIRTYSTRIP) ) { - if (!(tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 && - tif->tif_dir.td_stripoffset_entry.tdir_count == 0 && - tif->tif_dir.td_stripoffset_entry.tdir_type == 0 && - tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0)) + if( !(tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 && + tif->tif_dir.td_stripoffset_entry.tdir_count == 0 && + tif->tif_dir.td_stripoffset_entry.tdir_type == 0 && + tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0) ) { - TIFFErrorExtR(tif, module, - "Function not called together with " - "TIFFDeferStrileArrayWriting()"); + TIFFErrorExt(tif->tif_clientdata, module, + "Function not called together with " + "TIFFDeferStrileArrayWriting()"); return 0; } @@ -117,14 +121,18 @@ int TIFFForceStrileArrayWriting(TIFF *tif) return 0; } - if (_TIFFRewriteField(tif, - isTiled ? TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS, - TIFF_LONG8, tif->tif_dir.td_nstrips, - tif->tif_dir.td_stripoffset_p) && - _TIFFRewriteField( - tif, isTiled ? TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS, - TIFF_LONG8, tif->tif_dir.td_nstrips, - tif->tif_dir.td_stripbytecount_p)) + if( _TIFFRewriteField( tif, + isTiled ? TIFFTAG_TILEOFFSETS : + TIFFTAG_STRIPOFFSETS, + TIFF_LONG8, + tif->tif_dir.td_nstrips, + tif->tif_dir.td_stripoffset_p ) + && _TIFFRewriteField( tif, + isTiled ? TIFFTAG_TILEBYTECOUNTS : + TIFFTAG_STRIPBYTECOUNTS, + TIFF_LONG8, + tif->tif_dir.td_nstrips, + tif->tif_dir.td_stripbytecount_p ) ) { tif->tif_flags &= ~TIFF_DIRTYSTRIP; tif->tif_flags &= ~TIFF_BEENWRITING; @@ -141,17 +149,26 @@ int TIFFForceStrileArrayWriting(TIFF *tif) * is not set, so that TIFFFlush() will proceed to write out the directory. * The documentation says returning 1 is an error indicator, but not having * been writing isn't exactly a an error. Hopefully this doesn't cause - * problems for other people. + * problems for other people. */ -int TIFFFlushData(TIFF *tif) +int +TIFFFlushData(TIFF* tif) { - if ((tif->tif_flags & TIFF_BEENWRITING) == 0) - return (1); - if (tif->tif_flags & TIFF_POSTENCODE) - { - tif->tif_flags &= ~TIFF_POSTENCODE; - if (!(*tif->tif_postencode)(tif)) - return (0); - } - return (TIFFFlushData1(tif)); + if ((tif->tif_flags & TIFF_BEENWRITING) == 0) + return (1); + if (tif->tif_flags & TIFF_POSTENCODE) { + tif->tif_flags &= ~TIFF_POSTENCODE; + if (!(*tif->tif_postencode)(tif)) + return (0); + } + return (TIFFFlushData1(tif)); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_getimage.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_getimage.c index 41f7dfd77..2b6682d22 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_getimage.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_getimage.c @@ -2,23 +2,23 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -28,50 +28,41 @@ * Read and return a packed RGBA image. */ #include "tiffiop.h" -#include #include +#include -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 *); +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 PickContigCase(TIFFRGBAImage*); +static int PickSeparateCase(TIFFRGBAImage*); -static int BuildMapUaToAa(TIFFRGBAImage *img); -static int BuildMapBitdepth16To8(TIFFRGBAImage *img); +static int BuildMapUaToAa(TIFFRGBAImage* img); +static int BuildMapBitdepth16To8(TIFFRGBAImage* img); static const char photoTag[] = "PhotometricInterpretation"; -/* +/* * Helper constants used in Orientation tag handling */ #define FLIP_VERTICALLY 0x01 #define FLIP_HORIZONTALLY 0x02 -#define EMSG_BUF_SIZE 1024 - /* * Color conversion constants. We will define display types here. */ static const TIFFDisplay display_sRGB = { - {/* XYZ -> luminance matrix */ - {3.2410F, -1.5374F, -0.4986F}, - {-0.9692F, 1.8760F, 0.0416F}, - {0.0556F, -0.2040F, 1.0570F}}, - 100.0F, - 100.0F, - 100.0F, /* Light o/p for reference white */ - 255, - 255, - 255, /* Pixel values for ref. white */ - 1.0F, - 1.0F, - 1.0F, /* Residual light o/p for black pixel */ - 2.4F, - 2.4F, - 2.4F, /* Gamma values for the three guns */ + { /* XYZ -> luminance matrix */ + { 3.2410F, -1.5374F, -0.4986F }, + { -0.9692F, 1.8760F, 0.0416F }, + { 0.0556F, -0.2040F, 1.0570F } + }, + 100.0F, 100.0F, 100.0F, /* Light o/p for reference white */ + 255, 255, 255, /* Pixel values for ref. white */ + 1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel */ + 2.4F, 2.4F, 2.4F, /* Gamma values for the three guns */ }; /* @@ -80,525 +71,443 @@ static const TIFFDisplay display_sRGB = { * be handled. If 0 is returned, emsg contains the reason * why it is being rejected. */ -int TIFFRGBAImageOK(TIFF *tif, char emsg[EMSG_BUF_SIZE]) +int +TIFFRGBAImageOK(TIFF* tif, char emsg[1024]) { - TIFFDirectory *td = &tif->tif_dir; - uint16_t photometric; - int colorchannels; + TIFFDirectory* td = &tif->tif_dir; + uint16 photometric; + int colorchannels; - if (!tif->tif_decodestatus) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, requested compression method is not configured"); - return (0); - } - switch (td->td_bitspersample) - { - case 1: - case 2: - case 4: - case 8: - case 16: - break; - default: - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle images with %" PRIu16 - "-bit samples", - td->td_bitspersample); - return (0); - } - if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP) - { - snprintf( - emsg, EMSG_BUF_SIZE, - "Sorry, can not handle images with IEEE floating-point samples"); - return (0); - } - colorchannels = td->td_samplesperpixel - td->td_extrasamples; - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) - { - switch (colorchannels) - { - case 1: - photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - photometric = PHOTOMETRIC_RGB; - break; - default: - snprintf(emsg, EMSG_BUF_SIZE, "Missing needed %s tag", - photoTag); + if (!tif->tif_decodestatus) { + sprintf(emsg, "Sorry, requested compression method is not configured"); + return (0); + } + switch (td->td_bitspersample) { + case 1: + case 2: + case 4: + case 8: + case 16: + break; + default: + sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + td->td_bitspersample); + return (0); + } + if (td->td_sampleformat == SAMPLEFORMAT_IEEEFP) { + sprintf(emsg, "Sorry, can not handle images with IEEE floating-point samples"); return (0); } - } - switch (photometric) - { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_PALETTE: - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - td->td_samplesperpixel != 1 && td->td_bitspersample < 8) - { - snprintf( - emsg, EMSG_BUF_SIZE, - "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); - return (0); - } - /* - * We should likely validate that any extra samples are either - * to be ignored, or are alpha, and if alpha we should try to use - * them. But for now we won't bother with this. - */ - break; - case PHOTOMETRIC_YCBCR: - /* - * TODO: if at all meaningful and useful, make more complete - * support check here, or better still, refactor to let supporting - * code decide whether there is support and what meaningful - * error to return - */ - break; - case PHOTOMETRIC_RGB: - if (colorchannels < 3) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle RGB image with %s=%d", - "Color channels", colorchannels); - return (0); - } - break; - case PHOTOMETRIC_SEPARATED: - { - uint16_t inkset; - TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); - if (inkset != INKSET_CMYK) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle separated image with %s=%d", - "InkSet", inkset); - return 0; - } - if (td->td_samplesperpixel < 4) - { - snprintf( - emsg, EMSG_BUF_SIZE, - "Sorry, can not handle separated image with %s=%" PRIu16, - "Samples/pixel", td->td_samplesperpixel); - return 0; - } - break; - } - case PHOTOMETRIC_LOGL: - if (td->td_compression != COMPRESSION_SGILOG) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, LogL data must have %s=%d", "Compression", - COMPRESSION_SGILOG); - return (0); - } - break; - case PHOTOMETRIC_LOGLUV: - if (td->td_compression != COMPRESSION_SGILOG && - td->td_compression != COMPRESSION_SGILOG24) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, LogLuv data must have %s=%d or %d", - "Compression", COMPRESSION_SGILOG, - COMPRESSION_SGILOG24); - return (0); - } - if (td->td_planarconfig != PLANARCONFIG_CONTIG) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle LogLuv images with %s=%" PRIu16, - "Planarconfiguration", td->td_planarconfig); - return (0); - } - if (td->td_samplesperpixel != 3 || colorchannels != 3) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle image with %s=%" PRIu16 - ", %s=%d", - "Samples/pixel", td->td_samplesperpixel, - "colorchannels", colorchannels); - return 0; - } - break; - case PHOTOMETRIC_CIELAB: - if (td->td_samplesperpixel != 3 || colorchannels != 3 || - (td->td_bitspersample != 8 && td->td_bitspersample != 16)) - { - snprintf(emsg, EMSG_BUF_SIZE, - "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); - return 0; - } - break; - default: - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle image with %s=%" PRIu16, photoTag, - photometric); - return (0); - } - return (1); + colorchannels = td->td_samplesperpixel - td->td_extrasamples; + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) { + switch (colorchannels) { + case 1: + photometric = PHOTOMETRIC_MINISBLACK; + break; + case 3: + photometric = PHOTOMETRIC_RGB; + break; + default: + sprintf(emsg, "Missing needed %s tag", photoTag); + return (0); + } + } + switch (photometric) { + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_PALETTE: + if (td->td_planarconfig == PLANARCONFIG_CONTIG + && 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", + photoTag, photometric, + "Samples/pixel", td->td_samplesperpixel, + td->td_bitspersample); + return (0); + } + /* + * We should likely validate that any extra samples are either + * to be ignored, or are alpha, and if alpha we should try to use + * them. But for now we won't bother with this. + */ + break; + case PHOTOMETRIC_YCBCR: + /* + * TODO: if at all meaningful and useful, make more complete + * support check here, or better still, refactor to let supporting + * code decide whether there is support and what meaningful + * error to return + */ + break; + case PHOTOMETRIC_RGB: + if (colorchannels < 3) { + sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", + "Color channels", colorchannels); + return (0); + } + break; + case PHOTOMETRIC_SEPARATED: + { + uint16 inkset; + TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); + if (inkset != INKSET_CMYK) { + sprintf(emsg, + "Sorry, can not handle separated image with %s=%d", + "InkSet", inkset); + return 0; + } + if (td->td_samplesperpixel < 4) { + sprintf(emsg, + "Sorry, can not handle separated image with %s=%d", + "Samples/pixel", td->td_samplesperpixel); + return 0; + } + break; + } + case PHOTOMETRIC_LOGL: + if (td->td_compression != COMPRESSION_SGILOG) { + sprintf(emsg, "Sorry, LogL data must have %s=%d", + "Compression", COMPRESSION_SGILOG); + return (0); + } + break; + case PHOTOMETRIC_LOGLUV: + if (td->td_compression != COMPRESSION_SGILOG && + td->td_compression != COMPRESSION_SGILOG24) { + sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", + "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); + return (0); + } + if (td->td_planarconfig != PLANARCONFIG_CONTIG) { + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + "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", + "Samples/pixel", td->td_samplesperpixel, + "colorchannels", colorchannels); + return 0; + } + break; + 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", + "Samples/pixel", td->td_samplesperpixel, + "colorchannels", colorchannels, + "Bits/sample", td->td_bitspersample); + return 0; + } + break; + default: + sprintf(emsg, "Sorry, can not handle image with %s=%d", + photoTag, photometric); + return (0); + } + return (1); } -void TIFFRGBAImageEnd(TIFFRGBAImage *img) +void +TIFFRGBAImageEnd(TIFFRGBAImage* img) { - if (img->Map) - { - _TIFFfreeExt(img->tif, img->Map); - img->Map = NULL; - } - if (img->BWmap) - { - _TIFFfreeExt(img->tif, img->BWmap); - img->BWmap = NULL; - } - if (img->PALmap) - { - _TIFFfreeExt(img->tif, img->PALmap); - img->PALmap = NULL; - } - if (img->ycbcr) - { - _TIFFfreeExt(img->tif, img->ycbcr); - img->ycbcr = NULL; - } - if (img->cielab) - { - _TIFFfreeExt(img->tif, img->cielab); - img->cielab = NULL; - } - if (img->UaToAa) - { - _TIFFfreeExt(img->tif, img->UaToAa); - img->UaToAa = NULL; - } - if (img->Bitdepth16To8) - { - _TIFFfreeExt(img->tif, img->Bitdepth16To8); - img->Bitdepth16To8 = NULL; - } + if (img->Map) { + _TIFFfree(img->Map); + img->Map = NULL; + } + if (img->BWmap) { + _TIFFfree(img->BWmap); + img->BWmap = NULL; + } + if (img->PALmap) { + _TIFFfree(img->PALmap); + img->PALmap = NULL; + } + if (img->ycbcr) { + _TIFFfree(img->ycbcr); + img->ycbcr = NULL; + } + if (img->cielab) { + _TIFFfree(img->cielab); + img->cielab = NULL; + } + if (img->UaToAa) { + _TIFFfree(img->UaToAa); + img->UaToAa = NULL; + } + if (img->Bitdepth16To8) { + _TIFFfree(img->Bitdepth16To8); + img->Bitdepth16To8 = NULL; + } - if (img->redcmap) - { - _TIFFfreeExt(img->tif, img->redcmap); - _TIFFfreeExt(img->tif, img->greencmap); - _TIFFfreeExt(img->tif, img->bluecmap); - img->redcmap = img->greencmap = img->bluecmap = NULL; - } + if( img->redcmap ) { + _TIFFfree( img->redcmap ); + _TIFFfree( img->greencmap ); + _TIFFfree( img->bluecmap ); + img->redcmap = img->greencmap = img->bluecmap = NULL; + } } -static int isCCITTCompression(TIFF *tif) +static int +isCCITTCompression(TIFF* tif) { - uint16_t compress; + uint16 compress; TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); return (compress == COMPRESSION_CCITTFAX3 || - compress == COMPRESSION_CCITTFAX4 || - compress == COMPRESSION_CCITTRLE || - compress == COMPRESSION_CCITTRLEW); + compress == COMPRESSION_CCITTFAX4 || + compress == COMPRESSION_CCITTRLE || + compress == COMPRESSION_CCITTRLEW); } -int TIFFRGBAImageBegin(TIFFRGBAImage *img, TIFF *tif, int stop, - char emsg[EMSG_BUF_SIZE]) +int +TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024]) { - uint16_t *sampleinfo; - uint16_t extrasamples; - uint16_t planarconfig; - uint16_t compress; - int colorchannels; - uint16_t *red_orig, *green_orig, *blue_orig; - int n_color; + uint16* sampleinfo; + uint16 extrasamples; + uint16 planarconfig; + uint16 compress; + int colorchannels; + uint16 *red_orig, *green_orig, *blue_orig; + int n_color; + + if( !TIFFRGBAImageOK(tif, emsg) ) + return 0; - if (!TIFFRGBAImageOK(tif, emsg)) - return 0; + /* Initialize to normal values */ + img->row_offset = 0; + img->col_offset = 0; + img->redcmap = NULL; + img->greencmap = NULL; + img->bluecmap = NULL; + img->Map = NULL; + img->BWmap = NULL; + img->PALmap = NULL; + img->ycbcr = NULL; + img->cielab = NULL; + img->UaToAa = NULL; + img->Bitdepth16To8 = NULL; + img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */ - /* Initialize to normal values */ - img->row_offset = 0; - img->col_offset = 0; - img->redcmap = NULL; - img->greencmap = NULL; - img->bluecmap = NULL; - img->Map = NULL; - img->BWmap = NULL; - img->PALmap = NULL; - img->ycbcr = NULL; - img->cielab = NULL; - img->UaToAa = NULL; - img->Bitdepth16To8 = NULL; - img->req_orientation = ORIENTATION_BOTLEFT; /* It is the default */ - - img->tif = tif; - img->stoponerr = stop; - TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample); - switch (img->bitspersample) - { - case 1: - case 2: - case 4: - case 8: - case 16: - break; - default: - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle images with %" PRIu16 - "-bit samples", - img->bitspersample); - goto fail_return; - } - img->alpha = 0; - TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel); - TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples, - &sampleinfo); - if (extrasamples >= 1) - { - switch (sampleinfo[0]) - { - case EXTRASAMPLE_UNSPECIFIED: /* Workaround for some images without - */ - if (img->samplesperpixel > - 3) /* correct info about alpha channel */ - img->alpha = EXTRASAMPLE_ASSOCALPHA; - break; - case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */ - case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */ - img->alpha = sampleinfo[0]; - break; - } - } + img->tif = tif; + img->stoponerr = stop; + TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &img->bitspersample); + switch (img->bitspersample) { + case 1: + case 2: + case 4: + case 8: + case 16: + break; + default: + sprintf(emsg, "Sorry, can not handle images with %d-bit samples", + img->bitspersample); + goto fail_return; + } + img->alpha = 0; + TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &img->samplesperpixel); + TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, + &extrasamples, &sampleinfo); + if (extrasamples >= 1) + { + switch (sampleinfo[0]) { + case EXTRASAMPLE_UNSPECIFIED: /* Workaround for some images without */ + if (img->samplesperpixel > 3) /* correct info about alpha channel */ + img->alpha = EXTRASAMPLE_ASSOCALPHA; + break; + case EXTRASAMPLE_ASSOCALPHA: /* data is pre-multiplied */ + case EXTRASAMPLE_UNASSALPHA: /* data is not pre-multiplied */ + img->alpha = sampleinfo[0]; + break; + } + } #ifdef DEFAULT_EXTRASAMPLE_AS_ALPHA - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) - img->photometric = PHOTOMETRIC_MINISWHITE; + if( !TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) + img->photometric = PHOTOMETRIC_MINISWHITE; - if (extrasamples == 0 && img->samplesperpixel == 4 && - img->photometric == PHOTOMETRIC_RGB) - { - img->alpha = EXTRASAMPLE_ASSOCALPHA; - extrasamples = 1; - } + if( extrasamples == 0 + && img->samplesperpixel == 4 + && img->photometric == PHOTOMETRIC_RGB ) + { + img->alpha = EXTRASAMPLE_ASSOCALPHA; + extrasamples = 1; + } #endif - colorchannels = img->samplesperpixel - extrasamples; - TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress); - TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig); - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) - { - switch (colorchannels) - { - case 1: - if (isCCITTCompression(tif)) - img->photometric = PHOTOMETRIC_MINISWHITE; - else - img->photometric = PHOTOMETRIC_MINISBLACK; - break; - case 3: - img->photometric = PHOTOMETRIC_RGB; - break; - default: - snprintf(emsg, EMSG_BUF_SIZE, "Missing needed %s tag", - photoTag); - goto fail_return; - } - } - switch (img->photometric) - { - case PHOTOMETRIC_PALETTE: - if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &red_orig, &green_orig, - &blue_orig)) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Missing required \"Colormap\" tag"); - goto fail_return; - } + colorchannels = img->samplesperpixel - extrasamples; + TIFFGetFieldDefaulted(tif, TIFFTAG_COMPRESSION, &compress); + TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfig); + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &img->photometric)) { + switch (colorchannels) { + case 1: + if (isCCITTCompression(tif)) + img->photometric = PHOTOMETRIC_MINISWHITE; + else + img->photometric = PHOTOMETRIC_MINISBLACK; + break; + case 3: + img->photometric = PHOTOMETRIC_RGB; + break; + default: + sprintf(emsg, "Missing needed %s tag", photoTag); + goto fail_return; + } + } + switch (img->photometric) { + case PHOTOMETRIC_PALETTE: + if (!TIFFGetField(tif, TIFFTAG_COLORMAP, + &red_orig, &green_orig, &blue_orig)) { + sprintf(emsg, "Missing required \"Colormap\" tag"); + goto fail_return; + } - /* copy the colormaps so we can modify them */ - n_color = (1U << img->bitspersample); - img->redcmap = - (uint16_t *)_TIFFmallocExt(tif, sizeof(uint16_t) * n_color); - img->greencmap = - (uint16_t *)_TIFFmallocExt(tif, sizeof(uint16_t) * n_color); - img->bluecmap = - (uint16_t *)_TIFFmallocExt(tif, sizeof(uint16_t) * n_color); - if (!img->redcmap || !img->greencmap || !img->bluecmap) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Out of memory for colormap copy"); - goto fail_return; - } + /* 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); + if( !img->redcmap || !img->greencmap || !img->bluecmap ) { + sprintf(emsg, "Out of memory for colormap copy"); + goto fail_return; + } - _TIFFmemcpy(img->redcmap, red_orig, n_color * 2); - _TIFFmemcpy(img->greencmap, green_orig, n_color * 2); - _TIFFmemcpy(img->bluecmap, blue_orig, n_color * 2); + _TIFFmemcpy( img->redcmap, red_orig, n_color * 2 ); + _TIFFmemcpy( img->greencmap, green_orig, n_color * 2 ); + _TIFFmemcpy( img->bluecmap, blue_orig, n_color * 2 ); - /* fall through... */ - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - if (planarconfig == PLANARCONFIG_CONTIG && - img->samplesperpixel != 1 && img->bitspersample < 8) - { - snprintf( - emsg, EMSG_BUF_SIZE, - "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); - goto fail_return; - } - break; - case PHOTOMETRIC_YCBCR: - /* It would probably be nice to have a reality check here. */ - if (planarconfig == PLANARCONFIG_CONTIG) - /* can rely on libjpeg to convert to RGB */ - /* XXX should restore current state on exit */ - switch (compress) - { - case COMPRESSION_JPEG: - /* - * TODO: when complete tests verify complete - * desubsampling and YCbCr handling, remove use of - * TIFFTAG_JPEGCOLORMODE in favor of tif_getimage.c - * native handling - */ - TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, - JPEGCOLORMODE_RGB); - img->photometric = PHOTOMETRIC_RGB; - break; - default: - /* do nothing */; - break; - } - /* - * TODO: if at all meaningful and useful, make more complete - * support check here, or better still, refactor to let supporting - * code decide whether there is support and what meaningful - * error to return - */ - break; - case PHOTOMETRIC_RGB: - if (colorchannels < 3) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle RGB image with %s=%d", - "Color channels", colorchannels); - goto fail_return; - } - break; - case PHOTOMETRIC_SEPARATED: - { - uint16_t inkset; - TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); - if (inkset != INKSET_CMYK) - { - snprintf( - emsg, EMSG_BUF_SIZE, - "Sorry, can not handle separated image with %s=%" PRIu16, - "InkSet", inkset); - goto fail_return; - } - if (img->samplesperpixel < 4) - { - snprintf( - emsg, EMSG_BUF_SIZE, - "Sorry, can not handle separated image with %s=%" PRIu16, - "Samples/pixel", img->samplesperpixel); - goto fail_return; - } - } - break; - case PHOTOMETRIC_LOGL: - if (compress != COMPRESSION_SGILOG) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, LogL data must have %s=%d", "Compression", - COMPRESSION_SGILOG); - goto fail_return; - } - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */ - img->bitspersample = 8; - break; - case PHOTOMETRIC_LOGLUV: - if (compress != COMPRESSION_SGILOG && - compress != COMPRESSION_SGILOG24) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, LogLuv data must have %s=%d or %d", - "Compression", COMPRESSION_SGILOG, - COMPRESSION_SGILOG24); - goto fail_return; - } - if (planarconfig != PLANARCONFIG_CONTIG) - { - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle LogLuv images with %s=%" PRIu16, - "Planarconfiguration", planarconfig); - return (0); - } - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - img->photometric = PHOTOMETRIC_RGB; /* little white lie */ - img->bitspersample = 8; - break; - case PHOTOMETRIC_CIELAB: - break; - default: - snprintf(emsg, EMSG_BUF_SIZE, - "Sorry, can not handle image with %s=%" PRIu16, photoTag, - img->photometric); - goto fail_return; - } - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height); - TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation); - img->isContig = - !(planarconfig == PLANARCONFIG_SEPARATE && img->samplesperpixel > 1); - if (img->isContig) - { - if (!PickContigCase(img)) - { - snprintf(emsg, EMSG_BUF_SIZE, "Sorry, can not handle image"); - goto fail_return; - } - } - else - { - if (!PickSeparateCase(img)) - { - snprintf(emsg, EMSG_BUF_SIZE, "Sorry, can not handle image"); - goto fail_return; - } - } - return 1; + /* fall through... */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + if (planarconfig == PLANARCONFIG_CONTIG + && img->samplesperpixel != 1 + && img->bitspersample < 8 ) { + sprintf(emsg, + "Sorry, can not handle contiguous data with %s=%d, " + "and %s=%d and Bits/Sample=%d", + photoTag, img->photometric, + "Samples/pixel", img->samplesperpixel, + img->bitspersample); + goto fail_return; + } + break; + case PHOTOMETRIC_YCBCR: + /* It would probably be nice to have a reality check here. */ + if (planarconfig == PLANARCONFIG_CONTIG) + /* can rely on libjpeg to convert to RGB */ + /* XXX should restore current state on exit */ + switch (compress) { + case COMPRESSION_JPEG: + /* + * TODO: when complete tests verify complete desubsampling + * and YCbCr handling, remove use of TIFFTAG_JPEGCOLORMODE in + * favor of tif_getimage.c native handling + */ + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + img->photometric = PHOTOMETRIC_RGB; + break; + default: + /* do nothing */; + break; + } + /* + * TODO: if at all meaningful and useful, make more complete + * support check here, or better still, refactor to let supporting + * code decide whether there is support and what meaningful + * error to return + */ + break; + case PHOTOMETRIC_RGB: + if (colorchannels < 3) { + sprintf(emsg, "Sorry, can not handle RGB image with %s=%d", + "Color channels", colorchannels); + goto fail_return; + } + break; + case PHOTOMETRIC_SEPARATED: + { + uint16 inkset; + TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset); + if (inkset != INKSET_CMYK) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "InkSet", inkset); + goto fail_return; + } + if (img->samplesperpixel < 4) { + sprintf(emsg, "Sorry, can not handle separated image with %s=%d", + "Samples/pixel", img->samplesperpixel); + goto fail_return; + } + } + break; + case PHOTOMETRIC_LOGL: + if (compress != COMPRESSION_SGILOG) { + sprintf(emsg, "Sorry, LogL data must have %s=%d", + "Compression", COMPRESSION_SGILOG); + goto fail_return; + } + TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); + img->photometric = PHOTOMETRIC_MINISBLACK; /* little white lie */ + img->bitspersample = 8; + break; + case PHOTOMETRIC_LOGLUV: + if (compress != COMPRESSION_SGILOG && compress != COMPRESSION_SGILOG24) { + sprintf(emsg, "Sorry, LogLuv data must have %s=%d or %d", + "Compression", COMPRESSION_SGILOG, COMPRESSION_SGILOG24); + goto fail_return; + } + if (planarconfig != PLANARCONFIG_CONTIG) { + sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d", + "Planarconfiguration", planarconfig); + return (0); + } + TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); + img->photometric = PHOTOMETRIC_RGB; /* little white lie */ + img->bitspersample = 8; + break; + case PHOTOMETRIC_CIELAB: + break; + default: + sprintf(emsg, "Sorry, can not handle image with %s=%d", + photoTag, img->photometric); + goto fail_return; + } + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &img->width); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &img->height); + TIFFGetFieldDefaulted(tif, TIFFTAG_ORIENTATION, &img->orientation); + img->isContig = + !(planarconfig == PLANARCONFIG_SEPARATE && img->samplesperpixel > 1); + if (img->isContig) { + if (!PickContigCase(img)) { + sprintf(emsg, "Sorry, can not handle image"); + goto fail_return; + } + } else { + if (!PickSeparateCase(img)) { + sprintf(emsg, "Sorry, can not handle image"); + goto fail_return; + } + } + return 1; -fail_return: - TIFFRGBAImageEnd(img); - return 0; + fail_return: + TIFFRGBAImageEnd( img ); + return 0; } -int TIFFRGBAImageGet(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, - uint32_t h) +int +TIFFRGBAImageGet(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { - if (img->get == NULL) - { - TIFFErrorExtR(img->tif, TIFFFileName(img->tif), - "No \"get\" routine setup"); - return (0); - } - if (img->put.any == NULL) - { - TIFFErrorExtR( - img->tif, TIFFFileName(img->tif), - "No \"put\" routine setupl; probably can not handle image format"); - return (0); + if (img->get == NULL) { + TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No \"get\" routine setup"); + return (0); + } + if (img->put.any == NULL) { + TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), + "No \"put\" routine setupl; probably can not handle image format"); + return (0); } return (*img->get)(img, raster, w, h); } @@ -607,25 +516,24 @@ int TIFFRGBAImageGet(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, * Read the specified image into an ABGR-format rastertaking in account * specified orientation. */ -int TIFFReadRGBAImageOriented(TIFF *tif, uint32_t rwidth, uint32_t rheight, - uint32_t *raster, int orientation, int stop) +int +TIFFReadRGBAImageOriented(TIFF* tif, + uint32 rwidth, uint32 rheight, uint32* raster, + int orientation, int stop) { - char emsg[EMSG_BUF_SIZE] = ""; + char emsg[1024] = ""; TIFFRGBAImage img; int ok; - if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg)) - { - 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); - TIFFRGBAImageEnd(&img); - } - else - { - TIFFErrorExtR(tif, TIFFFileName(tif), "%s", emsg); - ok = 0; + if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg)) { + img.req_orientation = (uint16)orientation; + /* XXX verify rwidth and rheight against width and height */ + ok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth, + rwidth, img.height); + TIFFRGBAImageEnd(&img); + } else { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); + ok = 0; } return (ok); } @@ -634,72 +542,73 @@ int TIFFReadRGBAImageOriented(TIFF *tif, uint32_t rwidth, uint32_t rheight, * Read the specified image into an ABGR-format raster. Use bottom left * origin for raster by default. */ -int TIFFReadRGBAImage(TIFF *tif, uint32_t rwidth, uint32_t rheight, - uint32_t *raster, int stop) +int +TIFFReadRGBAImage(TIFF* tif, + uint32 rwidth, uint32 rheight, uint32* raster, int stop) { - return TIFFReadRGBAImageOriented(tif, rwidth, rheight, raster, - ORIENTATION_BOTLEFT, stop); + return TIFFReadRGBAImageOriented(tif, rwidth, rheight, raster, + ORIENTATION_BOTLEFT, stop); } -static int setorientation(TIFFRGBAImage *img) +static int +setorientation(TIFFRGBAImage* img) { - switch (img->orientation) - { - case ORIENTATION_TOPLEFT: - case ORIENTATION_LEFTTOP: - if (img->req_orientation == ORIENTATION_TOPRIGHT || - img->req_orientation == ORIENTATION_RIGHTTOP) - return FLIP_HORIZONTALLY; - else if (img->req_orientation == ORIENTATION_BOTRIGHT || - img->req_orientation == ORIENTATION_RIGHTBOT) - return FLIP_HORIZONTALLY | FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_BOTLEFT || - img->req_orientation == ORIENTATION_LEFTBOT) - return FLIP_VERTICALLY; - else - return 0; - case ORIENTATION_TOPRIGHT: - case ORIENTATION_RIGHTTOP: - if (img->req_orientation == ORIENTATION_TOPLEFT || - img->req_orientation == ORIENTATION_LEFTTOP) - return FLIP_HORIZONTALLY; - else if (img->req_orientation == ORIENTATION_BOTRIGHT || - img->req_orientation == ORIENTATION_RIGHTBOT) - return FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_BOTLEFT || - img->req_orientation == ORIENTATION_LEFTBOT) - return FLIP_HORIZONTALLY | FLIP_VERTICALLY; - else - return 0; - case ORIENTATION_BOTRIGHT: - case ORIENTATION_RIGHTBOT: - if (img->req_orientation == ORIENTATION_TOPLEFT || - img->req_orientation == ORIENTATION_LEFTTOP) - return FLIP_HORIZONTALLY | FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_TOPRIGHT || - img->req_orientation == ORIENTATION_RIGHTTOP) - return FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_BOTLEFT || - img->req_orientation == ORIENTATION_LEFTBOT) - return FLIP_HORIZONTALLY; - else - return 0; - case ORIENTATION_BOTLEFT: - case ORIENTATION_LEFTBOT: - if (img->req_orientation == ORIENTATION_TOPLEFT || - img->req_orientation == ORIENTATION_LEFTTOP) - return FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_TOPRIGHT || - img->req_orientation == ORIENTATION_RIGHTTOP) - return FLIP_HORIZONTALLY | FLIP_VERTICALLY; - else if (img->req_orientation == ORIENTATION_BOTRIGHT || - img->req_orientation == ORIENTATION_RIGHTBOT) - return FLIP_HORIZONTALLY; - else - return 0; - default: /* NOTREACHED */ - return 0; - } + switch (img->orientation) { + case ORIENTATION_TOPLEFT: + case ORIENTATION_LEFTTOP: + if (img->req_orientation == ORIENTATION_TOPRIGHT || + img->req_orientation == ORIENTATION_RIGHTTOP) + return FLIP_HORIZONTALLY; + else if (img->req_orientation == ORIENTATION_BOTRIGHT || + img->req_orientation == ORIENTATION_RIGHTBOT) + return FLIP_HORIZONTALLY | FLIP_VERTICALLY; + else if (img->req_orientation == ORIENTATION_BOTLEFT || + img->req_orientation == ORIENTATION_LEFTBOT) + return FLIP_VERTICALLY; + else + return 0; + case ORIENTATION_TOPRIGHT: + case ORIENTATION_RIGHTTOP: + if (img->req_orientation == ORIENTATION_TOPLEFT || + img->req_orientation == ORIENTATION_LEFTTOP) + return FLIP_HORIZONTALLY; + else if (img->req_orientation == ORIENTATION_BOTRIGHT || + img->req_orientation == ORIENTATION_RIGHTBOT) + return FLIP_VERTICALLY; + else if (img->req_orientation == ORIENTATION_BOTLEFT || + img->req_orientation == ORIENTATION_LEFTBOT) + return FLIP_HORIZONTALLY | FLIP_VERTICALLY; + else + return 0; + case ORIENTATION_BOTRIGHT: + case ORIENTATION_RIGHTBOT: + if (img->req_orientation == ORIENTATION_TOPLEFT || + img->req_orientation == ORIENTATION_LEFTTOP) + return FLIP_HORIZONTALLY | FLIP_VERTICALLY; + else if (img->req_orientation == ORIENTATION_TOPRIGHT || + img->req_orientation == ORIENTATION_RIGHTTOP) + return FLIP_VERTICALLY; + else if (img->req_orientation == ORIENTATION_BOTLEFT || + img->req_orientation == ORIENTATION_LEFTBOT) + return FLIP_HORIZONTALLY; + else + return 0; + case ORIENTATION_BOTLEFT: + case ORIENTATION_LEFTBOT: + if (img->req_orientation == ORIENTATION_TOPLEFT || + img->req_orientation == ORIENTATION_LEFTTOP) + return FLIP_VERTICALLY; + else if (img->req_orientation == ORIENTATION_TOPRIGHT || + img->req_orientation == ORIENTATION_RIGHTTOP) + return FLIP_HORIZONTALLY | FLIP_VERTICALLY; + else if (img->req_orientation == ORIENTATION_BOTRIGHT || + img->req_orientation == ORIENTATION_RIGHTBOT) + return FLIP_HORIZONTALLY; + else + return 0; + default: /* NOTREACHED */ + return 0; + } } /* @@ -707,29 +616,28 @@ static int setorientation(TIFFRGBAImage *img) * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 - */ -static int gtTileContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, - uint32_t h) + */ +static int +gtTileContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { - TIFF *tif = img->tif; + TIFF* tif = img->tif; tileContigRoutine put = img->put.contig; - uint32_t col, row, y, rowstoread; + uint32 col, row, y, rowstoread; tmsize_t pos; - uint32_t tw, th; - unsigned char *buf = NULL; - int32_t fromskew, toskew; - uint32_t nrow; + uint32 tw, th; + unsigned char* buf = NULL; + int32 fromskew, toskew; + uint32 nrow; int ret = 1, flip; - uint32_t this_tw, tocol; - int32_t this_toskew, leftmost_toskew; - int32_t leftmost_fromskew; - uint32_t leftmost_tw; + uint32 this_tw, tocol; + int32 this_toskew, leftmost_toskew; + int32 leftmost_fromskew; + uint32 leftmost_tw; tmsize_t bufsize; bufsize = TIFFTileSize(tif); - if (bufsize == 0) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "%s", "No space for tile buffer"); + if (bufsize == 0) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "No space for tile buffer"); return (0); } @@ -737,29 +645,23 @@ static int gtTileContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); flip = setorientation(img); - if (flip & FLIP_VERTICALLY) - { - if ((tw + w) > INT_MAX) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "%s", - "unsupported tile size (too wide)"); + if (flip & FLIP_VERTICALLY) { + if ((tw + w) > INT_MAX) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)"); return (0); } y = h - 1; - toskew = -(int32_t)(tw + w); + toskew = -(int32)(tw + w); } - else - { - if (tw > (INT_MAX + w)) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "%s", - "unsupported tile size (too wide)"); + else { + if (tw > (INT_MAX + w)) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)"); return (0); } y = 0; - toskew = -(int32_t)(tw - w); + toskew = -(int32)(tw - w); } - + /* * Leftmost tile is clipped on left side if col_offset > 0. */ @@ -769,69 +671,62 @@ static int gtTileContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, for (row = 0; ret != 0 && row < h; row += nrow) { rowstoread = th - (row + img->row_offset) % th; - nrow = (row + rowstoread > h ? h - row : rowstoread); - fromskew = leftmost_fromskew; - this_tw = leftmost_tw; - this_toskew = leftmost_toskew; - tocol = 0; - col = img->col_offset; - while (tocol < w) + nrow = (row + rowstoread > h ? h - row : rowstoread); + fromskew = leftmost_fromskew; + this_tw = leftmost_tw; + this_toskew = leftmost_toskew; + tocol = 0; + col = img->col_offset; + while (tocol < w) { - if (_TIFFReadTileAndAllocBuffer(tif, (void **)&buf, bufsize, col, - row + img->row_offset, 0, - 0) == (tmsize_t)(-1) && + if (_TIFFReadTileAndAllocBuffer(tif, (void**) &buf, bufsize, col, + row+img->row_offset, 0, 0)==(tmsize_t)(-1) && (buf == NULL || img->stoponerr)) { ret = 0; break; } - pos = ((row + img->row_offset) % th) * TIFFTileRowSize(tif) + - ((tmsize_t)fromskew * img->samplesperpixel); - if (tocol + this_tw > w) - { - /* - * Rightmost tile is clipped on right side. - */ - fromskew = tw - (w - tocol); - this_tw = tw - fromskew; - this_toskew = toskew + fromskew; - } - tmsize_t roffset = (tmsize_t)y * w + tocol; - (*put)(img, raster + roffset, tocol, y, this_tw, nrow, fromskew, - this_toskew, buf + pos); - tocol += this_tw; - col += this_tw; - /* - * After the leftmost tile, tiles are no longer clipped on left - * side. - */ - fromskew = 0; - this_tw = tw; - this_toskew = toskew; - } + pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif) + \ + ((tmsize_t) fromskew * img->samplesperpixel); + if (tocol + this_tw > w) + { + /* + * Rightmost tile is clipped on right side. + */ + fromskew = tw - (w - tocol); + this_tw = tw - fromskew; + this_toskew = toskew + fromskew; + } + (*put)(img, raster+y*w+tocol, tocol, y, this_tw, nrow, fromskew, this_toskew, buf + pos); + tocol += this_tw; + col += this_tw; + /* + * After the leftmost tile, tiles are no longer clipped on left side. + */ + fromskew = 0; + this_tw = tw; + this_toskew = toskew; + } - y += ((flip & FLIP_VERTICALLY) ? -(int32_t)nrow : (int32_t)nrow); + y += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow); } - _TIFFfreeExt(img->tif, buf); + _TIFFfree(buf); - if (flip & FLIP_HORIZONTALLY) - { - uint32_t line; + if (flip & FLIP_HORIZONTALLY) { + uint32 line; - for (line = 0; line < h; line++) - { - uint32_t *left = raster + (line * w); - uint32_t *right = left + w - 1; - - while (left < right) - { - uint32_t temp = *left; - *left = *right; - *right = temp; - left++; - right--; - } - } + for (line = 0; line < h; line++) { + uint32 *left = raster + (line * w); + uint32 *right = left + w - 1; + + while ( left < right ) { + uint32 temp = *left; + *left = *right; + *right = temp; + left++; + right--; + } + } } return (ret); @@ -842,203 +737,188 @@ static int gtTileContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, * SamplesPerPixel > 1 * PlanarConfiguration separated * We assume that all such images are RGB. - */ -static int gtTileSeparate(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, - uint32_t h) + */ +static int +gtTileSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { - TIFF *tif = img->tif; - tileSeparateRoutine put = img->put.separate; - uint32_t col, row, y, rowstoread; - tmsize_t pos; - uint32_t tw, th; - unsigned char *buf = NULL; - unsigned char *p0 = NULL; - unsigned char *p1 = NULL; - unsigned char *p2 = NULL; - unsigned char *pa = NULL; - tmsize_t tilesize; - tmsize_t bufsize; - int32_t fromskew, toskew; - int alpha = img->alpha; - uint32_t nrow; - int ret = 1, flip; - uint16_t colorchannels; - uint32_t this_tw, tocol; - int32_t this_toskew, leftmost_toskew; - int32_t leftmost_fromskew; - uint32_t leftmost_tw; + TIFF* tif = img->tif; + tileSeparateRoutine put = img->put.separate; + uint32 col, row, y, rowstoread; + tmsize_t pos; + uint32 tw, th; + unsigned char* buf = NULL; + unsigned char* p0 = NULL; + unsigned char* p1 = NULL; + unsigned char* p2 = NULL; + unsigned char* pa = NULL; + tmsize_t tilesize; + tmsize_t bufsize; + int32 fromskew, toskew; + int alpha = img->alpha; + uint32 nrow; + int ret = 1, flip; + uint16 colorchannels; + uint32 this_tw, tocol; + int32 this_toskew, leftmost_toskew; + int32 leftmost_fromskew; + uint32 leftmost_tw; - tilesize = TIFFTileSize(tif); - bufsize = - _TIFFMultiplySSize(tif, alpha ? 4 : 3, tilesize, "gtTileSeparate"); - if (bufsize == 0) - { - return (0); - } + tilesize = TIFFTileSize(tif); + bufsize = _TIFFMultiplySSize(tif, alpha?4:3,tilesize, "gtTileSeparate"); + if (bufsize == 0) { + return (0); + } - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) - { - if ((tw + w) > INT_MAX) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "%s", - "unsupported tile size (too wide)"); + flip = setorientation(img); + if (flip & FLIP_VERTICALLY) { + if ((tw + w) > INT_MAX) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)"); return (0); } - y = h - 1; - toskew = -(int32_t)(tw + w); - } - else - { - if (tw > (INT_MAX + w)) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "%s", - "unsupported tile size (too wide)"); + y = h - 1; + toskew = -(int32)(tw + w); + } + else { + if (tw > (INT_MAX + w)) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", "unsupported tile size (too wide)"); return (0); } - y = 0; - toskew = -(int32_t)(tw - w); - } + y = 0; + toskew = -(int32)(tw - w); + } - switch (img->photometric) - { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_PALETTE: + switch( img->photometric ) + { + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_PALETTE: colorchannels = 1; break; - default: + default: colorchannels = 3; break; - } - - /* - * Leftmost tile is clipped on left side if col_offset > 0. - */ - leftmost_fromskew = img->col_offset % tw; - leftmost_tw = tw - leftmost_fromskew; - leftmost_toskew = toskew + leftmost_fromskew; - for (row = 0; ret != 0 && row < h; row += nrow) - { - rowstoread = th - (row + img->row_offset) % th; - nrow = (row + rowstoread > h ? h - row : rowstoread); - fromskew = leftmost_fromskew; - this_tw = leftmost_tw; - this_toskew = leftmost_toskew; - tocol = 0; - col = img->col_offset; - while (tocol < w) - { - if (buf == NULL) - { - if (_TIFFReadTileAndAllocBuffer(tif, (void **)&buf, bufsize, - col, row + img->row_offset, 0, - 0) == (tmsize_t)(-1) && - (buf == NULL || img->stoponerr)) - { - ret = 0; - break; - } - p0 = buf; - if (colorchannels == 1) - { - p2 = p1 = p0; - pa = (alpha ? (p0 + 3 * tilesize) : NULL); - } - else - { - p1 = p0 + tilesize; - p2 = p1 + tilesize; - pa = (alpha ? (p2 + tilesize) : NULL); - } - } - else if (TIFFReadTile(tif, p0, col, row + img->row_offset, 0, 0) == - (tmsize_t)(-1) && - img->stoponerr) - { - ret = 0; - break; - } - if (colorchannels > 1 && - TIFFReadTile(tif, p1, col, row + img->row_offset, 0, 1) == - (tmsize_t)(-1) && - img->stoponerr) - { - ret = 0; - break; - } - if (colorchannels > 1 && - TIFFReadTile(tif, p2, col, row + img->row_offset, 0, 2) == - (tmsize_t)(-1) && - img->stoponerr) - { - ret = 0; - break; - } - if (alpha && - TIFFReadTile(tif, pa, col, row + img->row_offset, 0, - colorchannels) == (tmsize_t)(-1) && - img->stoponerr) - { - ret = 0; - break; - } - - pos = ((row + img->row_offset) % th) * TIFFTileRowSize(tif) + - ((tmsize_t)fromskew * img->samplesperpixel); - if (tocol + this_tw > w) - { - /* - * Rightmost tile is clipped on right side. - */ - fromskew = tw - (w - tocol); - this_tw = tw - fromskew; - this_toskew = toskew + fromskew; - } - tmsize_t roffset = (tmsize_t)y * w + tocol; - (*put)(img, raster + roffset, tocol, y, this_tw, nrow, fromskew, - this_toskew, p0 + pos, p1 + pos, p2 + pos, - (alpha ? (pa + pos) : NULL)); - tocol += this_tw; - col += this_tw; - /* - * After the leftmost tile, tiles are no longer clipped on left - * side. - */ - fromskew = 0; - this_tw = tw; - this_toskew = toskew; } - y += ((flip & FLIP_VERTICALLY) ? -(int32_t)nrow : (int32_t)nrow); - } + /* + * Leftmost tile is clipped on left side if col_offset > 0. + */ + leftmost_fromskew = img->col_offset % tw; + leftmost_tw = tw - leftmost_fromskew; + leftmost_toskew = toskew + leftmost_fromskew; + for (row = 0; ret != 0 && row < h; row += nrow) + { + rowstoread = th - (row + img->row_offset) % th; + nrow = (row + rowstoread > h ? h - row : rowstoread); + fromskew = leftmost_fromskew; + this_tw = leftmost_tw; + this_toskew = leftmost_toskew; + tocol = 0; + col = img->col_offset; + while (tocol < w) + { + if( buf == NULL ) + { + if (_TIFFReadTileAndAllocBuffer( + tif, (void**) &buf, bufsize, col, + row+img->row_offset,0,0)==(tmsize_t)(-1) + && (buf == NULL || img->stoponerr)) + { + ret = 0; + break; + } + p0 = buf; + if( colorchannels == 1 ) + { + p2 = p1 = p0; + pa = (alpha?(p0+3*tilesize):NULL); + } + else + { + p1 = p0 + tilesize; + p2 = p1 + tilesize; + pa = (alpha?(p2+tilesize):NULL); + } + } + else if (TIFFReadTile(tif, p0, col, + row+img->row_offset,0,0)==(tmsize_t)(-1) && img->stoponerr) + { + ret = 0; + break; + } + if (colorchannels > 1 + && TIFFReadTile(tif, p1, col, + row+img->row_offset,0,1) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (colorchannels > 1 + && TIFFReadTile(tif, p2, col, + row+img->row_offset,0,2) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (alpha + && TIFFReadTile(tif,pa,col, + row+img->row_offset,0,colorchannels) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } - if (flip & FLIP_HORIZONTALLY) - { - uint32_t line; + pos = ((row+img->row_offset) % th) * TIFFTileRowSize(tif) + \ + ((tmsize_t) fromskew * img->samplesperpixel); + if (tocol + this_tw > w) + { + /* + * Rightmost tile is clipped on right side. + */ + fromskew = tw - (w - tocol); + this_tw = tw - fromskew; + this_toskew = toskew + fromskew; + } + (*put)(img, raster+y*w+tocol, tocol, y, this_tw, nrow, fromskew, this_toskew, \ + p0 + pos, p1 + pos, p2 + pos, (alpha?(pa+pos):NULL)); + tocol += this_tw; + col += this_tw; + /* + * After the leftmost tile, tiles are no longer clipped on left side. + */ + fromskew = 0; + this_tw = tw; + this_toskew = toskew; + } - for (line = 0; line < h; line++) - { - uint32_t *left = raster + (line * w); - uint32_t *right = left + w - 1; + y += ((flip & FLIP_VERTICALLY) ?-(int32) nrow : (int32) nrow); + } - while (left < right) - { - uint32_t temp = *left; - *left = *right; - *right = temp; - left++; - right--; - } - } - } + if (flip & FLIP_HORIZONTALLY) { + uint32 line; - _TIFFfreeExt(img->tif, buf); - return (ret); + for (line = 0; line < h; line++) { + uint32 *left = raster + (line * w); + uint32 *right = left + w - 1; + + while ( left < right ) { + uint32 temp = *left; + *left = *right; + *right = temp; + left++; + right--; + } + } + } + + _TIFFfree(buf); + return (ret); } /* @@ -1046,110 +926,98 @@ static int gtTileSeparate(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, * PlanarConfiguration contiguous if SamplesPerPixel > 1 * or * SamplesPerPixel == 1 - */ -static int gtStripContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, - uint32_t h) + */ +static int +gtStripContig(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 h) { - TIFF *tif = img->tif; - tileContigRoutine put = img->put.contig; - uint32_t row, y, nrow, nrowsub, rowstoread; - tmsize_t pos; - unsigned char *buf = NULL; - uint32_t rowsperstrip; - uint16_t subsamplinghor, subsamplingver; - uint32_t imagewidth = img->width; - tmsize_t scanline; - int32_t fromskew, toskew; - int ret = 1, flip; - tmsize_t maxstripsize; + TIFF* tif = img->tif; + tileContigRoutine put = img->put.contig; + uint32 row, y, nrow, nrowsub, rowstoread; + tmsize_t pos; + unsigned char* buf = NULL; + uint32 rowsperstrip; + uint16 subsamplinghor,subsamplingver; + uint32 imagewidth = img->width; + tmsize_t scanline; + int32 fromskew, toskew; + int ret = 1, flip; + tmsize_t maxstripsize; - TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, - &subsamplingver); - if (subsamplingver == 0) - { - TIFFErrorExtR(tif, TIFFFileName(tif), - "Invalid vertical YCbCr subsampling"); - return (0); - } + TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, &subsamplingver); + if( subsamplingver == 0 ) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Invalid vertical YCbCr subsampling"); + return (0); + } + + maxstripsize = TIFFStripSize(tif); - maxstripsize = TIFFStripSize(tif); + flip = setorientation(img); + if (flip & FLIP_VERTICALLY) { + if ( w > INT_MAX ) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Width overflow"); + return (0); + } + y = h - 1; + toskew = -(int32)(w + w); + } else { + y = 0; + toskew = -(int32)(w - w); + } - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) - { - if (w > INT_MAX) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "Width overflow"); - return (0); - } - y = h - 1; - toskew = -(int32_t)(w + w); - } - else - { - y = 0; - toskew = -(int32_t)(w - w); - } + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + scanline = TIFFScanlineSize(tif); + fromskew = (w < imagewidth ? imagewidth - w : 0); + for (row = 0; row < h; row += nrow) + { + uint32 temp; + rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; + nrow = (row + rowstoread > h ? h - row : rowstoread); + nrowsub = nrow; + if ((nrowsub%subsamplingver)!=0) + nrowsub+=subsamplingver-nrowsub%subsamplingver; + temp = (row + img->row_offset)%rowsperstrip + nrowsub; + if( scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline) ) + { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in gtStripContig"); + return 0; + } + if (_TIFFReadEncodedStripAndAllocBuffer(tif, + TIFFComputeStrip(tif,row+img->row_offset, 0), + (void**)(&buf), + maxstripsize, + temp * scanline)==(tmsize_t)(-1) + && (buf == NULL || img->stoponerr)) + { + ret = 0; + break; + } - scanline = TIFFScanlineSize(tif); - fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += nrow) - { - uint32_t temp; - rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; - nrow = (row + rowstoread > h ? h - row : rowstoread); - nrowsub = nrow; - if ((nrowsub % subsamplingver) != 0) - nrowsub += subsamplingver - nrowsub % subsamplingver; - temp = (row + img->row_offset) % rowsperstrip + nrowsub; - if (scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline)) - { - TIFFErrorExtR(tif, TIFFFileName(tif), - "Integer overflow in gtStripContig"); - return 0; - } - if (_TIFFReadEncodedStripAndAllocBuffer( - tif, TIFFComputeStrip(tif, row + img->row_offset, 0), - (void **)(&buf), maxstripsize, - temp * scanline) == (tmsize_t)(-1) && - (buf == NULL || img->stoponerr)) - { - ret = 0; - break; - } + 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); + } - pos = ((row + img->row_offset) % rowsperstrip) * scanline + - ((tmsize_t)img->col_offset * img->samplesperpixel); - tmsize_t roffset = (tmsize_t)y * w; - (*put)(img, raster + roffset, 0, y, w, nrow, fromskew, toskew, - buf + pos); - y += ((flip & FLIP_VERTICALLY) ? -(int32_t)nrow : (int32_t)nrow); - } + if (flip & FLIP_HORIZONTALLY) { + uint32 line; - if (flip & FLIP_HORIZONTALLY) - { - uint32_t line; + for (line = 0; line < h; line++) { + uint32 *left = raster + (line * w); + uint32 *right = left + w - 1; - for (line = 0; line < h; line++) - { - uint32_t *left = raster + (line * w); - uint32_t *right = left + w - 1; + while ( left < right ) { + uint32 temp = *left; + *left = *right; + *right = temp; + left++; + right--; + } + } + } - while (left < right) - { - uint32_t temp = *left; - *left = *right; - *right = temp; - left++; - right--; - } - } - } - - _TIFFfreeExt(img->tif, buf); - return (ret); + _TIFFfree(buf); + return (ret); } /* @@ -1158,167 +1026,157 @@ static int gtStripContig(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, * PlanarConfiguration separated * We assume that all such images are RGB. */ -static int gtStripSeparate(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, - uint32_t h) +static int +gtStripSeparate(TIFFRGBAImage* img, uint32* raster, uint32 w, uint32 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_t row, y, nrow, rowstoread; - tmsize_t pos; - tmsize_t scanline; - uint32_t rowsperstrip, offset_row; - uint32_t imagewidth = img->width; - tmsize_t stripsize; - tmsize_t bufsize; - int32_t fromskew, toskew; - int alpha = img->alpha; - int ret = 1, flip; - uint16_t colorchannels; + 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; + tmsize_t pos; + tmsize_t scanline; + uint32 rowsperstrip, offset_row; + uint32 imagewidth = img->width; + tmsize_t stripsize; + tmsize_t bufsize; + int32 fromskew, toskew; + int alpha = img->alpha; + int ret = 1, flip; + uint16 colorchannels; - stripsize = TIFFStripSize(tif); - bufsize = - _TIFFMultiplySSize(tif, alpha ? 4 : 3, stripsize, "gtStripSeparate"); - if (bufsize == 0) - { - return (0); - } + stripsize = TIFFStripSize(tif); + bufsize = _TIFFMultiplySSize(tif,alpha?4:3,stripsize, "gtStripSeparate"); + if (bufsize == 0) { + return (0); + } - flip = setorientation(img); - if (flip & FLIP_VERTICALLY) - { - if (w > INT_MAX) + flip = setorientation(img); + if (flip & FLIP_VERTICALLY) { + if ( w > INT_MAX ) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Width overflow"); + return (0); + } + y = h - 1; + toskew = -(int32)(w + w); + } + else { + y = 0; + toskew = -(int32)(w - w); + } + + switch( img->photometric ) { - TIFFErrorExtR(tif, TIFFFileName(tif), "Width overflow"); - return (0); - } - y = h - 1; - toskew = -(int32_t)(w + w); - } - else - { - y = 0; - toskew = -(int32_t)(w - w); - } - - switch (img->photometric) - { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_PALETTE: + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_PALETTE: colorchannels = 1; break; - default: + default: colorchannels = 3; break; - } - - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - scanline = TIFFScanlineSize(tif); - fromskew = (w < imagewidth ? imagewidth - w : 0); - for (row = 0; row < h; row += nrow) - { - uint32_t temp; - rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; - nrow = (row + rowstoread > h ? h - row : rowstoread); - offset_row = row + img->row_offset; - temp = (row + img->row_offset) % rowsperstrip + nrow; - if (scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline)) - { - TIFFErrorExtR(tif, TIFFFileName(tif), - "Integer overflow in gtStripSeparate"); - return 0; - } - if (buf == NULL) - { - if (_TIFFReadEncodedStripAndAllocBuffer( - tif, TIFFComputeStrip(tif, offset_row, 0), (void **)&buf, - bufsize, temp * scanline) == (tmsize_t)(-1) && - (buf == NULL || img->stoponerr)) - { - ret = 0; - break; - } - p0 = buf; - if (colorchannels == 1) - { - p2 = p1 = p0; - pa = (alpha ? (p0 + 3 * stripsize) : NULL); - } - else - { - p1 = p0 + stripsize; - p2 = p1 + stripsize; - pa = (alpha ? (p2 + stripsize) : NULL); - } - } - else if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0), - p0, temp * scanline) == (tmsize_t)(-1) && - img->stoponerr) - { - ret = 0; - break; - } - if (colorchannels > 1 && - TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), p1, - temp * scanline) == (tmsize_t)(-1) && - img->stoponerr) - { - ret = 0; - break; - } - if (colorchannels > 1 && - TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), p2, - temp * scanline) == (tmsize_t)(-1) && - img->stoponerr) - { - ret = 0; - break; - } - if (alpha) - { - if (TIFFReadEncodedStrip( - tif, TIFFComputeStrip(tif, offset_row, colorchannels), pa, - temp * scanline) == (tmsize_t)(-1) && - img->stoponerr) - { - ret = 0; - break; - } } - pos = ((row + img->row_offset) % rowsperstrip) * scanline + - ((tmsize_t)img->col_offset * img->samplesperpixel); - tmsize_t roffset = (tmsize_t)y * w; - (*put)(img, raster + roffset, 0, y, w, nrow, fromskew, toskew, p0 + pos, - p1 + pos, p2 + pos, (alpha ? (pa + pos) : NULL)); - y += ((flip & FLIP_VERTICALLY) ? -(int32_t)nrow : (int32_t)nrow); - } + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + scanline = TIFFScanlineSize(tif); + fromskew = (w < imagewidth ? imagewidth - w : 0); + for (row = 0; row < h; row += nrow) + { + uint32 temp; + rowstoread = rowsperstrip - (row + img->row_offset) % rowsperstrip; + nrow = (row + rowstoread > h ? h - row : rowstoread); + offset_row = row + img->row_offset; + temp = (row + img->row_offset)%rowsperstrip + nrow; + if( scanline > 0 && temp > (size_t)(TIFF_TMSIZE_T_MAX / scanline) ) + { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "Integer overflow in gtStripSeparate"); + return 0; + } + if( buf == NULL ) + { + if (_TIFFReadEncodedStripAndAllocBuffer( + tif, TIFFComputeStrip(tif, offset_row, 0), + (void**) &buf, bufsize, + temp * scanline)==(tmsize_t)(-1) + && (buf == NULL || img->stoponerr)) + { + ret = 0; + break; + } + p0 = buf; + if( colorchannels == 1 ) + { + p2 = p1 = p0; + pa = (alpha?(p0+3*stripsize):NULL); + } + else + { + p1 = p0 + stripsize; + p2 = p1 + stripsize; + pa = (alpha?(p2+stripsize):NULL); + } + } + else if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 0), + p0, temp * scanline)==(tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (colorchannels > 1 + && TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 1), + p1, temp * scanline) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (colorchannels > 1 + && TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, 2), + p2, temp * scanline) == (tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + if (alpha) + { + if (TIFFReadEncodedStrip(tif, TIFFComputeStrip(tif, offset_row, colorchannels), + pa, temp * scanline)==(tmsize_t)(-1) + && img->stoponerr) + { + ret = 0; + break; + } + } - if (flip & FLIP_HORIZONTALLY) - { - uint32_t line; + pos = ((row + img->row_offset) % rowsperstrip) * scanline + \ + ((tmsize_t) img->col_offset * img->samplesperpixel); + (*put)(img, raster+y*w, 0, y, w, nrow, fromskew, toskew, p0 + pos, p1 + pos, + p2 + pos, (alpha?(pa+pos):NULL)); + y += ((flip & FLIP_VERTICALLY) ? -(int32) nrow : (int32) nrow); + } - for (line = 0; line < h; line++) - { - uint32_t *left = raster + (line * w); - uint32_t *right = left + w - 1; + if (flip & FLIP_HORIZONTALLY) { + uint32 line; - while (left < right) - { - uint32_t temp = *left; - *left = *right; - *right = temp; - left++; - right--; - } - } - } + for (line = 0; line < h; line++) { + uint32 *left = raster + (line * w); + uint32 *right = left + w - 1; - _TIFFfreeExt(img->tif, buf); - return (ret); + while ( left < right ) { + uint32 temp = *left; + *left = *right; + *right = temp; + left++; + right--; + } + } + } + + _TIFFfree(buf); + return (ret); } /* @@ -1331,139 +1189,98 @@ static int gtStripSeparate(TIFFRGBAImage *img, uint32_t *raster, uint32_t w, * PickSeparateCase analyze the parameters and select * the appropriate "get" and "put" routine to use. */ -#define REPEAT8(op) \ - REPEAT4(op); \ - REPEAT4(op) -#define REPEAT4(op) \ - REPEAT2(op); \ - REPEAT2(op) -#define REPEAT2(op) \ - op; \ - op -#define CASE8(x, op) \ - switch (x) \ - { \ - case 7: \ - op; /*-fallthrough*/ \ - case 6: \ - op; /*-fallthrough*/ \ - case 5: \ - op; /*-fallthrough*/ \ - case 4: \ - op; /*-fallthrough*/ \ - case 3: \ - op; /*-fallthrough*/ \ - case 2: \ - op; /*-fallthrough*/ \ - case 1: \ - op; \ +#define REPEAT8(op) REPEAT4(op); REPEAT4(op) +#define REPEAT4(op) REPEAT2(op); REPEAT2(op) +#define REPEAT2(op) op; op +#define CASE8(x,op) \ + switch (x) { \ + case 7: op; /*-fallthrough*/ \ + case 6: op; /*-fallthrough*/ \ + case 5: op; /*-fallthrough*/ \ + case 4: op; /*-fallthrough*/ \ + case 3: op; /*-fallthrough*/ \ + case 2: op; /*-fallthrough*/ \ + case 1: op; \ } -#define CASE4(x, op) \ - switch (x) \ - { \ - case 3: \ - op; /*-fallthrough*/ \ - case 2: \ - op; /*-fallthrough*/ \ - case 1: \ - op; \ - } -#define NOP +#define CASE4(x,op) switch (x) { case 3: op; /*-fallthrough*/ case 2: op; /*-fallthrough*/ case 1: op; } +#define NOP -#define UNROLL8(w, op1, op2) \ - { \ - uint32_t _x; \ - for (_x = w; _x >= 8; _x -= 8) \ - { \ - op1; \ - REPEAT8(op2); \ - } \ - if (_x > 0) \ - { \ - op1; \ - CASE8(_x, op2); \ - } \ - } -#define UNROLL4(w, op1, op2) \ - { \ - uint32_t _x; \ - for (_x = w; _x >= 4; _x -= 4) \ - { \ - op1; \ - REPEAT4(op2); \ - } \ - if (_x > 0) \ - { \ - op1; \ - CASE4(_x, op2); \ - } \ - } -#define UNROLL2(w, op1, op2) \ - { \ - uint32_t _x; \ - for (_x = w; _x >= 2; _x -= 2) \ - { \ - op1; \ - REPEAT2(op2); \ - } \ - if (_x) \ - { \ - op1; \ - op2; \ - } \ - } +#define UNROLL8(w, op1, op2) { \ + uint32 _x; \ + for (_x = w; _x >= 8; _x -= 8) { \ + op1; \ + REPEAT8(op2); \ + } \ + if (_x > 0) { \ + op1; \ + CASE8(_x,op2); \ + } \ +} +#define UNROLL4(w, op1, op2) { \ + uint32 _x; \ + for (_x = w; _x >= 4; _x -= 4) { \ + op1; \ + REPEAT4(op2); \ + } \ + if (_x > 0) { \ + op1; \ + CASE4(_x,op2); \ + } \ +} +#define UNROLL2(w, op1, op2) { \ + uint32 _x; \ + for (_x = w; _x >= 2; _x -= 2) { \ + op1; \ + REPEAT2(op2); \ + } \ + if (_x) { \ + op1; \ + op2; \ + } \ +} + +#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 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_t)0xffL) << 24) -#define PACK(r, g, b) \ - ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | A1) -#define PACK4(r, g, b, a) \ - ((uint32_t)(r) | ((uint32_t)(g) << 8) | ((uint32_t)(b) << 16) | \ - ((uint32_t)(a) << 24)) -#define W2B(v) (((v) >> 8) & 0xff) +#define A1 (((uint32)0xffL)<<24) +#define PACK(r,g,b) \ + ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|A1) +#define PACK4(r,g,b,a) \ + ((uint32)(r)|((uint32)(g)<<8)|((uint32)(b)<<16)|((uint32)(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_t)W2B(r) | ((uint32_t)W2B(g) << 8) | ((uint32_t)W2B(b) << 16) | A1) -#define PACKW4(r, g, b, a) \ - ((uint32_t)W2B(r) | ((uint32_t)W2B(g) << 8) | ((uint32_t)W2B(b) << 16) | \ - ((uint32_t)W2B(a) << 24)) +#define PACKW(r,g,b) \ + ((uint32)W2B(r)|((uint32)W2B(g)<<8)|((uint32)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)) -#define DECLAREContigPutFunc(name) \ - static void name(TIFFRGBAImage *img, uint32_t *cp, uint32_t x, uint32_t y, \ - uint32_t w, uint32_t h, int32_t fromskew, int32_t toskew, \ - unsigned char *pp) +#define DECLAREContigPutFunc(name) \ +static void name(\ + TIFFRGBAImage* img, \ + uint32* cp, \ + uint32 x, uint32 y, \ + uint32 w, uint32 h, \ + int32 fromskew, int32 toskew, \ + unsigned char* pp \ +) /* * 8-bit palette => colormap/RGB */ DECLAREContigPutFunc(put8bitcmaptile) { - uint32_t **PALmap = img->PALmap; + uint32** PALmap = img->PALmap; int samplesperpixel = img->samplesperpixel; - (void)y; - for (; h > 0; --h) - { - for (x = w; x > 0; --x) + (void) y; + for( ; h > 0; --h) { + for (x = w; x > 0; --x) { - *cp++ = PALmap[*pp][0]; + *cp++ = PALmap[*pp][0]; pp += samplesperpixel; } - cp += toskew; - pp += fromskew; + cp += toskew; + pp += fromskew; } } @@ -1472,17 +1289,15 @@ DECLAREContigPutFunc(put8bitcmaptile) */ DECLAREContigPutFunc(put4bitcmaptile) { - uint32_t **PALmap = img->PALmap; + uint32** PALmap = img->PALmap; - (void)x; - (void)y; + (void) x; (void) y; fromskew /= 2; - for (; h > 0; --h) - { - uint32_t *bw; - UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; + for( ; h > 0; --h) { + uint32* bw; + UNROLL2(w, bw = PALmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; } } @@ -1491,17 +1306,15 @@ DECLAREContigPutFunc(put4bitcmaptile) */ DECLAREContigPutFunc(put2bitcmaptile) { - uint32_t **PALmap = img->PALmap; + uint32** PALmap = img->PALmap; - (void)x; - (void)y; + (void) x; (void) y; fromskew /= 4; - for (; h > 0; --h) - { - uint32_t *bw; - UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; + for( ; h > 0; --h) { + uint32* bw; + UNROLL4(w, bw = PALmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; } } @@ -1510,17 +1323,15 @@ DECLAREContigPutFunc(put2bitcmaptile) */ DECLAREContigPutFunc(put1bitcmaptile) { - uint32_t **PALmap = img->PALmap; + uint32** PALmap = img->PALmap; - (void)x; - (void)y; + (void) x; (void) y; fromskew /= 8; - for (; h > 0; --h) - { - uint32_t *bw; - UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; + for( ; h > 0; --h) { + uint32* bw; + UNROLL8(w, bw = PALmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; } } @@ -1530,18 +1341,17 @@ DECLAREContigPutFunc(put1bitcmaptile) DECLAREContigPutFunc(putgreytile) { int samplesperpixel = img->samplesperpixel; - uint32_t **BWmap = img->BWmap; + uint32** BWmap = img->BWmap; - (void)y; - for (; h > 0; --h) - { - for (x = w; x > 0; --x) + (void) y; + for( ; h > 0; --h) { + for (x = w; x > 0; --x) { - *cp++ = BWmap[*pp][0]; + *cp++ = BWmap[*pp][0]; pp += samplesperpixel; } - cp += toskew; - pp += fromskew; + cp += toskew; + pp += fromskew; } } @@ -1551,18 +1361,17 @@ DECLAREContigPutFunc(putgreytile) DECLAREContigPutFunc(putagreytile) { int samplesperpixel = img->samplesperpixel; - uint32_t **BWmap = img->BWmap; + uint32** BWmap = img->BWmap; - (void)y; - for (; h > 0; --h) - { - for (x = w; x > 0; --x) + (void) y; + for( ; h > 0; --h) { + for (x = w; x > 0; --x) { - *cp++ = BWmap[*pp][0] & ((uint32_t) * (pp + 1) << 24 | ~A1); + *cp++ = BWmap[*pp][0] & ((uint32)*(pp+1) << 24 | ~A1); pp += samplesperpixel; } - cp += toskew; - pp += fromskew; + cp += toskew; + pp += fromskew; } } @@ -1572,23 +1381,22 @@ DECLAREContigPutFunc(putagreytile) DECLAREContigPutFunc(put16bitbwtile) { int samplesperpixel = img->samplesperpixel; - uint32_t **BWmap = img->BWmap; + uint32** BWmap = img->BWmap; - (void)y; - for (; h > 0; --h) - { - uint16_t *wp = (uint16_t *)pp; + (void) y; + for( ; h > 0; --h) { + uint16 *wp = (uint16 *) pp; - for (x = w; x > 0; --x) + for (x = w; x > 0; --x) { /* use high order byte of 16bit value */ - *cp++ = BWmap[*wp >> 8][0]; + *cp++ = BWmap[*wp >> 8][0]; pp += 2 * samplesperpixel; wp += samplesperpixel; } - cp += toskew; - pp += fromskew; + cp += toskew; + pp += fromskew; } } @@ -1597,17 +1405,15 @@ DECLAREContigPutFunc(put16bitbwtile) */ DECLAREContigPutFunc(put1bitbwtile) { - uint32_t **BWmap = img->BWmap; + uint32** BWmap = img->BWmap; - (void)x; - (void)y; + (void) x; (void) y; fromskew /= 8; - for (; h > 0; --h) - { - uint32_t *bw; - UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; + for( ; h > 0; --h) { + uint32* bw; + UNROLL8(w, bw = BWmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; } } @@ -1616,17 +1422,15 @@ DECLAREContigPutFunc(put1bitbwtile) */ DECLAREContigPutFunc(put2bitbwtile) { - uint32_t **BWmap = img->BWmap; + uint32** BWmap = img->BWmap; - (void)x; - (void)y; + (void) x; (void) y; fromskew /= 4; - for (; h > 0; --h) - { - uint32_t *bw; - UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; + for( ; h > 0; --h) { + uint32* bw; + UNROLL4(w, bw = BWmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; } } @@ -1635,17 +1439,15 @@ DECLAREContigPutFunc(put2bitbwtile) */ DECLAREContigPutFunc(put4bitbwtile) { - uint32_t **BWmap = img->BWmap; + uint32** BWmap = img->BWmap; - (void)x; - (void)y; + (void) x; (void) y; fromskew /= 2; - for (; h > 0; --h) - { - uint32_t *bw; - UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++); - cp += toskew; - pp += fromskew; + for( ; h > 0; --h) { + uint32* bw; + UNROLL2(w, bw = BWmap[*pp++], *cp++ = *bw++); + cp += toskew; + pp += fromskew; } } @@ -1656,15 +1458,14 @@ DECLAREContigPutFunc(putRGBcontig8bittile) { int samplesperpixel = img->samplesperpixel; - (void)x; - (void)y; + (void) x; (void) y; fromskew *= samplesperpixel; - for (; h > 0; --h) - { - UNROLL8(w, NOP, *cp++ = PACK(pp[0], pp[1], pp[2]); - pp += samplesperpixel); - cp += toskew; - pp += fromskew; + for( ; h > 0; --h) { + UNROLL8(w, NOP, + *cp++ = PACK(pp[0], pp[1], pp[2]); + pp += samplesperpixel); + cp += toskew; + pp += fromskew; } } @@ -1676,15 +1477,14 @@ DECLAREContigPutFunc(putRGBAAcontig8bittile) { int samplesperpixel = img->samplesperpixel; - (void)x; - (void)y; + (void) x; (void) y; fromskew *= samplesperpixel; - for (; h > 0; --h) - { - UNROLL8(w, NOP, *cp++ = PACK4(pp[0], pp[1], pp[2], pp[3]); - pp += samplesperpixel); - cp += toskew; - pp += fromskew; + for( ; h > 0; --h) { + UNROLL8(w, NOP, + *cp++ = PACK4(pp[0], pp[1], pp[2], pp[3]); + pp += samplesperpixel); + cp += toskew; + pp += fromskew; } } @@ -1694,26 +1494,24 @@ DECLAREContigPutFunc(putRGBAAcontig8bittile) */ DECLAREContigPutFunc(putRGBUAcontig8bittile) { - int samplesperpixel = img->samplesperpixel; - (void)y; - fromskew *= samplesperpixel; - for (; h > 0; --h) - { - 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); - r = m[pp[0]]; - g = m[pp[1]]; - b = m[pp[2]]; - *cp++ = PACK4(r, g, b, a); - pp += samplesperpixel; - } - cp += toskew; - pp += fromskew; - } + int samplesperpixel = img->samplesperpixel; + (void) y; + fromskew *= samplesperpixel; + for( ; h > 0; --h) { + uint32 r, g, b, a; + uint8* m; + for (x = w; x > 0; --x) { + a = pp[3]; + m = img->UaToAa+((size_t) a<<8); + r = m[pp[0]]; + g = m[pp[1]]; + b = m[pp[2]]; + *cp++ = PACK4(r,g,b,a); + pp += samplesperpixel; + } + cp += toskew; + pp += fromskew; + } } /* @@ -1721,21 +1519,20 @@ DECLAREContigPutFunc(putRGBUAcontig8bittile) */ DECLAREContigPutFunc(putRGBcontig16bittile) { - int samplesperpixel = img->samplesperpixel; - uint16_t *wp = (uint16_t *)pp; - (void)y; - fromskew *= samplesperpixel; - for (; h > 0; --h) - { - for (x = w; x > 0; --x) - { - *cp++ = PACK(img->Bitdepth16To8[wp[0]], img->Bitdepth16To8[wp[1]], - img->Bitdepth16To8[wp[2]]); - wp += samplesperpixel; - } - cp += toskew; - wp += fromskew; - } + int samplesperpixel = img->samplesperpixel; + uint16 *wp = (uint16 *)pp; + (void) y; + fromskew *= samplesperpixel; + for( ; h > 0; --h) { + for (x = w; x > 0; --x) { + *cp++ = PACK(img->Bitdepth16To8[wp[0]], + img->Bitdepth16To8[wp[1]], + img->Bitdepth16To8[wp[2]]); + wp += samplesperpixel; + } + cp += toskew; + wp += fromskew; + } } /* @@ -1744,21 +1541,21 @@ DECLAREContigPutFunc(putRGBcontig16bittile) */ DECLAREContigPutFunc(putRGBAAcontig16bittile) { - int samplesperpixel = img->samplesperpixel; - uint16_t *wp = (uint16_t *)pp; - (void)y; - fromskew *= samplesperpixel; - for (; h > 0; --h) - { - for (x = w; x > 0; --x) - { - *cp++ = PACK4(img->Bitdepth16To8[wp[0]], img->Bitdepth16To8[wp[1]], - img->Bitdepth16To8[wp[2]], img->Bitdepth16To8[wp[3]]); - wp += samplesperpixel; - } - cp += toskew; - wp += fromskew; - } + int samplesperpixel = img->samplesperpixel; + uint16 *wp = (uint16 *)pp; + (void) y; + fromskew *= samplesperpixel; + for( ; h > 0; --h) { + for (x = w; x > 0; --x) { + *cp++ = PACK4(img->Bitdepth16To8[wp[0]], + img->Bitdepth16To8[wp[1]], + img->Bitdepth16To8[wp[2]], + img->Bitdepth16To8[wp[3]]); + wp += samplesperpixel; + } + cp += toskew; + wp += fromskew; + } } /* @@ -1767,27 +1564,25 @@ DECLAREContigPutFunc(putRGBAAcontig16bittile) */ DECLAREContigPutFunc(putRGBUAcontig16bittile) { - int samplesperpixel = img->samplesperpixel; - uint16_t *wp = (uint16_t *)pp; - (void)y; - fromskew *= samplesperpixel; - for (; h > 0; --h) - { - 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); - r = m[img->Bitdepth16To8[wp[0]]]; - g = m[img->Bitdepth16To8[wp[1]]]; - b = m[img->Bitdepth16To8[wp[2]]]; - *cp++ = PACK4(r, g, b, a); - wp += samplesperpixel; - } - cp += toskew; - wp += fromskew; - } + int samplesperpixel = img->samplesperpixel; + uint16 *wp = (uint16 *)pp; + (void) y; + fromskew *= samplesperpixel; + for( ; h > 0; --h) { + uint32 r,g,b,a; + uint8* m; + for (x = w; x > 0; --x) { + a = img->Bitdepth16To8[wp[3]]; + m = img->UaToAa+((size_t) a<<8); + r = m[img->Bitdepth16To8[wp[0]]]; + g = m[img->Bitdepth16To8[wp[1]]]; + b = m[img->Bitdepth16To8[wp[2]]]; + *cp++ = PACK4(r,g,b,a); + wp += samplesperpixel; + } + cp += toskew; + wp += fromskew; + } } /* @@ -1798,18 +1593,20 @@ DECLAREContigPutFunc(putRGBUAcontig16bittile) DECLAREContigPutFunc(putRGBcontig8bitCMYKtile) { int samplesperpixel = img->samplesperpixel; - uint16_t r, g, b, k; + uint16 r, g, b, k; - (void)x; - (void)y; + (void) x; (void) y; fromskew *= samplesperpixel; - for (; h > 0; --h) - { - UNROLL8(w, NOP, k = 255 - pp[3]; r = (k * (255 - pp[0])) / 255; - g = (k * (255 - pp[1])) / 255; b = (k * (255 - pp[2])) / 255; - *cp++ = PACK(r, g, b); pp += samplesperpixel); - cp += toskew; - pp += fromskew; + for( ; h > 0; --h) { + UNROLL8(w, NOP, + k = 255 - pp[3]; + r = (k*(255-pp[0]))/255; + g = (k*(255-pp[1]))/255; + b = (k*(255-pp[2]))/255; + *cp++ = PACK(r, g, b); + pp += samplesperpixel); + cp += toskew; + pp += fromskew; } } @@ -1821,47 +1618,45 @@ DECLAREContigPutFunc(putRGBcontig8bitCMYKtile) DECLAREContigPutFunc(putRGBcontig8bitCMYKMaptile) { int samplesperpixel = img->samplesperpixel; - TIFFRGBValue *Map = img->Map; - uint16_t r, g, b, k; + TIFFRGBValue* Map = img->Map; + uint16 r, g, b, k; - (void)y; + (void) y; fromskew *= samplesperpixel; - for (; h > 0; --h) - { - for (x = w; x > 0; --x) - { - k = 255 - pp[3]; - r = (k * (255 - pp[0])) / 255; - g = (k * (255 - pp[1])) / 255; - b = (k * (255 - pp[2])) / 255; - *cp++ = PACK(Map[r], Map[g], Map[b]); - pp += samplesperpixel; - } - pp += fromskew; - cp += toskew; + for( ; h > 0; --h) { + for (x = w; x > 0; --x) { + k = 255 - pp[3]; + r = (k*(255-pp[0]))/255; + g = (k*(255-pp[1]))/255; + b = (k*(255-pp[2]))/255; + *cp++ = PACK(Map[r], Map[g], Map[b]); + pp += samplesperpixel; + } + pp += fromskew; + cp += toskew; } } -#define DECLARESepPutFunc(name) \ - static void name(TIFFRGBAImage *img, 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) +#define DECLARESepPutFunc(name) \ +static void name(\ + TIFFRGBAImage* img,\ + uint32* cp,\ + uint32 x, uint32 y, \ + uint32 w, uint32 h,\ + int32 fromskew, int32 toskew,\ + unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a\ +) /* * 8-bit unpacked samples => RGB */ DECLARESepPutFunc(putRGBseparate8bittile) { - (void)img; - (void)x; - (void)y; - (void)a; - for (; h > 0; --h) - { - UNROLL8(w, NOP, *cp++ = PACK(*r++, *g++, *b++)); - SKEW(r, g, b, fromskew); - cp += toskew; + (void) img; (void) x; (void) y; (void) a; + for( ; h > 0; --h) { + UNROLL8(w, NOP, *cp++ = PACK(*r++, *g++, *b++)); + SKEW(r, g, b, fromskew); + cp += toskew; } } @@ -1870,15 +1665,12 @@ DECLARESepPutFunc(putRGBseparate8bittile) */ DECLARESepPutFunc(putRGBAAseparate8bittile) { - (void)img; - (void)x; - (void)y; - for (; h > 0; --h) - { - UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++)); - SKEW4(r, g, b, a, fromskew); - cp += toskew; - } + (void) img; (void) x; (void) y; + for( ; h > 0; --h) { + UNROLL8(w, NOP, *cp++ = PACK4(*r++, *g++, *b++, *a++)); + SKEW4(r, g, b, a, fromskew); + cp += toskew; + } } /* @@ -1886,22 +1678,19 @@ DECLARESepPutFunc(putRGBAAseparate8bittile) */ DECLARESepPutFunc(putCMYKseparate8bittile) { - (void)img; - (void)y; - for (; h > 0; --h) - { - uint32_t rv, gv, bv, kv; - for (x = w; x > 0; --x) - { - kv = 255 - *a++; - rv = (kv * (255 - *r++)) / 255; - gv = (kv * (255 - *g++)) / 255; - bv = (kv * (255 - *b++)) / 255; - *cp++ = PACK4(rv, gv, bv, 255); - } - SKEW4(r, g, b, a, fromskew); - cp += toskew; - } + (void) img; (void) y; + for( ; h > 0; --h) { + uint32 rv, gv, bv, kv; + for (x = w; x > 0; --x) { + kv = 255 - *a++; + rv = (kv*(255-*r++))/255; + gv = (kv*(255-*g++))/255; + bv = (kv*(255-*b++))/255; + *cp++ = PACK4(rv,gv,bv,255); + } + SKEW4(r, g, b, a, fromskew); + cp += toskew; + } } /* @@ -1909,24 +1698,21 @@ DECLARESepPutFunc(putCMYKseparate8bittile) */ DECLARESepPutFunc(putRGBUAseparate8bittile) { - (void)img; - (void)y; - for (; h > 0; --h) - { - uint32_t rv, gv, bv, av; - uint8_t *m; - for (x = w; x > 0; --x) - { - av = *a++; - m = img->UaToAa + ((size_t)av << 8); - rv = m[*r++]; - gv = m[*g++]; - bv = m[*b++]; - *cp++ = PACK4(rv, gv, bv, av); - } - SKEW4(r, g, b, a, fromskew); - cp += toskew; - } + (void) img; (void) y; + for( ; h > 0; --h) { + uint32 rv, gv, bv, av; + uint8* m; + for (x = w; x > 0; --x) { + av = *a++; + m = img->UaToAa+((size_t) av<<8); + rv = m[*r++]; + gv = m[*g++]; + bv = m[*b++]; + *cp++ = PACK4(rv,gv,bv,av); + } + SKEW4(r, g, b, a, fromskew); + cp += toskew; + } } /* @@ -1934,20 +1720,18 @@ DECLARESepPutFunc(putRGBUAseparate8bittile) */ DECLARESepPutFunc(putRGBseparate16bittile) { - 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++) - *cp++ = PACK(img->Bitdepth16To8[*wr++], img->Bitdepth16To8[*wg++], - img->Bitdepth16To8[*wb++]); - SKEW(wr, wg, wb, fromskew); - cp += toskew; - } + uint16 *wr = (uint16*) r; + uint16 *wg = (uint16*) g; + uint16 *wb = (uint16*) b; + (void) img; (void) y; (void) a; + for( ; h > 0; --h) { + for (x = 0; x < w; x++) + *cp++ = PACK(img->Bitdepth16To8[*wr++], + img->Bitdepth16To8[*wg++], + img->Bitdepth16To8[*wb++]); + SKEW(wr, wg, wb, fromskew); + cp += toskew; + } } /* @@ -1955,20 +1739,20 @@ DECLARESepPutFunc(putRGBseparate16bittile) */ DECLARESepPutFunc(putRGBAAseparate16bittile) { - 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++) - *cp++ = PACK4(img->Bitdepth16To8[*wr++], img->Bitdepth16To8[*wg++], - img->Bitdepth16To8[*wb++], img->Bitdepth16To8[*wa++]); - SKEW4(wr, wg, wb, wa, fromskew); - cp += toskew; - } + uint16 *wr = (uint16*) r; + uint16 *wg = (uint16*) g; + uint16 *wb = (uint16*) b; + uint16 *wa = (uint16*) a; + (void) img; (void) y; + for( ; h > 0; --h) { + for (x = 0; x < w; x++) + *cp++ = PACK4(img->Bitdepth16To8[*wr++], + img->Bitdepth16To8[*wg++], + img->Bitdepth16To8[*wb++], + img->Bitdepth16To8[*wa++]); + SKEW4(wr, wg, wb, wa, fromskew); + cp += toskew; + } } /* @@ -1976,123 +1760,168 @@ DECLARESepPutFunc(putRGBAAseparate16bittile) */ DECLARESepPutFunc(putRGBUAseparate16bittile) { - 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_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); - r2 = m[img->Bitdepth16To8[*wr++]]; - g2 = m[img->Bitdepth16To8[*wg++]]; - b2 = m[img->Bitdepth16To8[*wb++]]; - *cp++ = PACK4(r2, g2, b2, a2); - } - SKEW4(wr, wg, wb, wa, fromskew); - cp += toskew; - } + uint16 *wr = (uint16*) r; + uint16 *wg = (uint16*) g; + uint16 *wb = (uint16*) b; + uint16 *wa = (uint16*) a; + (void) img; (void) y; + for( ; h > 0; --h) { + uint32 r2,g2,b2,a2; + uint8* m; + for (x = w; x > 0; --x) { + a2 = img->Bitdepth16To8[*wa++]; + m = img->UaToAa+((size_t) a2<<8); + r2 = m[img->Bitdepth16To8[*wr++]]; + g2 = m[img->Bitdepth16To8[*wg++]]; + b2 = m[img->Bitdepth16To8[*wb++]]; + *cp++ = PACK4(r2,g2,b2,a2); + } + SKEW4(wr, wg, wb, wa, fromskew); + cp += toskew; + } } /* * 8-bit packed CIE L*a*b 1976 samples => RGB */ -DECLAREContigPutFunc(putcontig8bitCIELab8) +DECLAREContigPutFunc(putcontig8bitCIELab) { - float X, Y, Z; - uint32_t r, g, b; - (void)y; - fromskew *= 3; - for (; h > 0; --h) - { - for (x = w; x > 0; --x) - { - TIFFCIELabToXYZ(img->cielab, (unsigned char)pp[0], - (signed char)pp[1], (signed char)pp[2], &X, &Y, &Z); - TIFFXYZToRGB(img->cielab, X, Y, Z, &r, &g, &b); - *cp++ = PACK(r, g, b); - pp += 3; - } - cp += toskew; - pp += fromskew; - } -} - -/* - * 16-bit packed CIE L*a*b 1976 samples => RGB - */ -DECLAREContigPutFunc(putcontig8bitCIELab16) -{ - float X, Y, Z; - uint32_t r, g, b; - uint16_t *wp = (uint16_t *)pp; - (void)y; - fromskew *= 3; - for (; h > 0; --h) - { - for (x = w; x > 0; --x) - { - TIFFCIELab16ToXYZ(img->cielab, (uint16_t)wp[0], (int16_t)wp[1], - (int16_t)wp[2], &X, &Y, &Z); - TIFFXYZToRGB(img->cielab, X, Y, Z, &r, &g, &b); - *cp++ = PACK(r, g, b); - wp += 3; - } - cp += toskew; - wp += fromskew; - } + float X, Y, Z; + uint32 r, g, b; + (void) y; + fromskew *= 3; + for( ; h > 0; --h) { + for (x = w; x > 0; --x) { + TIFFCIELabToXYZ(img->cielab, + (unsigned char)pp[0], + (signed char)pp[1], + (signed char)pp[2], + &X, &Y, &Z); + TIFFXYZToRGB(img->cielab, X, Y, Z, &r, &g, &b); + *cp++ = PACK(r, g, b); + pp += 3; + } + cp += toskew; + pp += fromskew; + } } /* * YCbCr -> RGB conversion and packing routines. */ -#define YCbCrtoRGB(dst, Y) \ - { \ - uint32_t r, g, b; \ - TIFFYCbCrtoRGB(img->ycbcr, (Y), Cb, Cr, &r, &g, &b); \ - dst = PACK(r, g, b); \ +#define YCbCrtoRGB(dst, Y) { \ + uint32 r, g, b; \ + TIFFYCbCrtoRGB(img->ycbcr, (Y), Cb, Cr, &r, &g, &b); \ + dst = PACK(r, g, b); \ +} + +/* + * 8-bit packed YCbCr samples => RGB + * This function is generic for different sampling sizes, + * and can handle blocks sizes that aren't multiples of the + * sampling size. However, it is substantially less optimized + * than the specific sampling cases. It is used as a fallback + * for difficult blocks. + */ +#ifdef notdef +static void putcontig8bitYCbCrGenericTile( + TIFFRGBAImage* img, + uint32* cp, + uint32 x, uint32 y, + uint32 w, uint32 h, + int32 fromskew, int32 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; + int group_size = v_group * h_group + 2; + + (void) y; + fromskew = (fromskew * group_size) / h_group; + + for( yy = 0; yy < h; yy++ ) + { + unsigned char *pp_line; + int y_line_group = yy / v_group; + int y_remainder = yy - y_line_group * v_group; + + pp_line = pp + v_line_group * + + + for( xx = 0; xx < w; xx++ ) + { + Cb = pp + } } + for (; h >= 4; h -= 4) { + x = w>>2; + do { + Cb = pp[16]; + Cr = pp[17]; + + YCbCrtoRGB(cp [0], pp[ 0]); + YCbCrtoRGB(cp [1], pp[ 1]); + YCbCrtoRGB(cp [2], pp[ 2]); + YCbCrtoRGB(cp [3], pp[ 3]); + YCbCrtoRGB(cp1[0], pp[ 4]); + YCbCrtoRGB(cp1[1], pp[ 5]); + YCbCrtoRGB(cp1[2], pp[ 6]); + YCbCrtoRGB(cp1[3], pp[ 7]); + YCbCrtoRGB(cp2[0], pp[ 8]); + YCbCrtoRGB(cp2[1], pp[ 9]); + YCbCrtoRGB(cp2[2], pp[10]); + YCbCrtoRGB(cp2[3], pp[11]); + YCbCrtoRGB(cp3[0], pp[12]); + YCbCrtoRGB(cp3[1], pp[13]); + YCbCrtoRGB(cp3[2], pp[14]); + YCbCrtoRGB(cp3[3], pp[15]); + + cp += 4, cp1 += 4, cp2 += 4, cp3 += 4; + pp += 18; + } while (--x); + cp += incr, cp1 += incr, cp2 += incr, cp3 += incr; + pp += fromskew; + } +} +#endif /* * 8-bit packed YCbCr samples w/ 4,4 subsampling => RGB */ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) { - 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; + uint32* cp1 = cp+w+toskew; + uint32* cp2 = cp1+w+toskew; + uint32* cp3 = cp2+w+toskew; + int32 incr = 3*w+4*toskew; - (void)y; + (void) y; /* adjust fromskew */ - fromskew = (fromskew / 4) * (4 * 2 + 2); - if ((h & 3) == 0 && (w & 3) == 0) - { - for (; h >= 4; h -= 4) - { - x = w >> 2; - do - { - int32_t Cb = pp[16]; - int32_t Cr = pp[17]; + fromskew = (fromskew / 4) * (4*2+2); + if ((h & 3) == 0 && (w & 3) == 0) { + for (; h >= 4; h -= 4) { + x = w>>2; + do { + int32 Cb = pp[16]; + int32 Cr = pp[17]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); - YCbCrtoRGB(cp[2], pp[2]); - YCbCrtoRGB(cp[3], pp[3]); - YCbCrtoRGB(cp1[0], pp[4]); - YCbCrtoRGB(cp1[1], pp[5]); - YCbCrtoRGB(cp1[2], pp[6]); - YCbCrtoRGB(cp1[3], pp[7]); - YCbCrtoRGB(cp2[0], pp[8]); - YCbCrtoRGB(cp2[1], pp[9]); + YCbCrtoRGB(cp [0], pp[ 0]); + YCbCrtoRGB(cp [1], pp[ 1]); + YCbCrtoRGB(cp [2], pp[ 2]); + YCbCrtoRGB(cp [3], pp[ 3]); + YCbCrtoRGB(cp1[0], pp[ 4]); + YCbCrtoRGB(cp1[1], pp[ 5]); + YCbCrtoRGB(cp1[2], pp[ 6]); + YCbCrtoRGB(cp1[3], pp[ 7]); + YCbCrtoRGB(cp2[0], pp[ 8]); + YCbCrtoRGB(cp2[1], pp[ 9]); YCbCrtoRGB(cp2[2], pp[10]); YCbCrtoRGB(cp2[3], pp[11]); YCbCrtoRGB(cp3[0], pp[12]); @@ -2112,80 +1941,47 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) cp3 += incr; pp += fromskew; } - } - else - { - while (h > 0) - { - for (x = w; x > 0;) - { - int32_t Cb = pp[16]; - int32_t Cr = pp[17]; - switch (x) - { - default: - switch (h) - { - default: - YCbCrtoRGB(cp3[3], pp[15]); /* FALLTHROUGH */ - case 3: - YCbCrtoRGB(cp2[3], pp[11]); /* FALLTHROUGH */ - case 2: - YCbCrtoRGB(cp1[3], pp[7]); /* FALLTHROUGH */ - case 1: - YCbCrtoRGB(cp[3], pp[3]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 3: - switch (h) - { - default: - YCbCrtoRGB(cp3[2], pp[14]); /* FALLTHROUGH */ - case 3: - YCbCrtoRGB(cp2[2], pp[10]); /* FALLTHROUGH */ - case 2: - YCbCrtoRGB(cp1[2], pp[6]); /* FALLTHROUGH */ - case 1: - YCbCrtoRGB(cp[2], pp[2]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 2: - switch (h) - { - default: - YCbCrtoRGB(cp3[1], pp[13]); /* FALLTHROUGH */ - case 3: - YCbCrtoRGB(cp2[1], pp[9]); /* FALLTHROUGH */ - case 2: - YCbCrtoRGB(cp1[1], pp[5]); /* FALLTHROUGH */ - case 1: - YCbCrtoRGB(cp[1], pp[1]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 1: - switch (h) - { - default: - YCbCrtoRGB(cp3[0], pp[12]); /* FALLTHROUGH */ - case 3: - YCbCrtoRGB(cp2[0], pp[8]); /* FALLTHROUGH */ - case 2: - YCbCrtoRGB(cp1[0], pp[4]); /* FALLTHROUGH */ - case 1: - YCbCrtoRGB(cp[0], pp[0]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ + } else { + while (h > 0) { + for (x = w; x > 0;) { + int32 Cb = pp[16]; + int32 Cr = pp[17]; + switch (x) { + default: + switch (h) { + default: YCbCrtoRGB(cp3[3], pp[15]); /* FALLTHROUGH */ + case 3: YCbCrtoRGB(cp2[3], pp[11]); /* FALLTHROUGH */ + case 2: YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 3: + switch (h) { + default: YCbCrtoRGB(cp3[2], pp[14]); /* FALLTHROUGH */ + case 3: YCbCrtoRGB(cp2[2], pp[10]); /* FALLTHROUGH */ + case 2: YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 2: + switch (h) { + default: YCbCrtoRGB(cp3[1], pp[13]); /* FALLTHROUGH */ + case 3: YCbCrtoRGB(cp2[1], pp[ 9]); /* FALLTHROUGH */ + case 2: YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 1: + switch (h) { + default: YCbCrtoRGB(cp3[0], pp[12]); /* FALLTHROUGH */ + case 3: YCbCrtoRGB(cp2[0], pp[ 8]); /* FALLTHROUGH */ + case 2: YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ } - if (x < 4) - { - cp += x; - cp1 += x; - cp2 += x; - cp3 += x; + if (x < 4) { + cp += x; cp1 += x; cp2 += x; cp3 += x; x = 0; } - else - { - cp += 4; - cp1 += 4; - cp2 += 4; - cp3 += 4; + else { + cp += 4; cp1 += 4; cp2 += 4; cp3 += 4; x -= 4; } pp += 18; @@ -2207,30 +2003,27 @@ DECLAREContigPutFunc(putcontig8bitYCbCr44tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) { - uint32_t *cp1 = cp + w + toskew; - int32_t incr = 2 * toskew + w; + uint32* cp1 = cp+w+toskew; + int32 incr = 2*toskew+w; - (void)y; - fromskew = (fromskew / 4) * (4 * 2 + 2); - if ((w & 3) == 0 && (h & 1) == 0) - { - for (; h >= 2; h -= 2) - { - x = w >> 2; - do - { - int32_t Cb = pp[8]; - int32_t Cr = pp[9]; - - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); - YCbCrtoRGB(cp[2], pp[2]); - YCbCrtoRGB(cp[3], pp[3]); + (void) y; + fromskew = (fromskew / 4) * (4*2+2); + if ((w & 3) == 0 && (h & 1) == 0) { + for (; h >= 2; h -= 2) { + x = w>>2; + do { + int32 Cb = pp[8]; + int32 Cr = pp[9]; + + YCbCrtoRGB(cp [0], pp[0]); + YCbCrtoRGB(cp [1], pp[1]); + YCbCrtoRGB(cp [2], pp[2]); + YCbCrtoRGB(cp [3], pp[3]); YCbCrtoRGB(cp1[0], pp[4]); YCbCrtoRGB(cp1[1], pp[5]); YCbCrtoRGB(cp1[2], pp[6]); YCbCrtoRGB(cp1[3], pp[7]); - + cp += 4; cp1 += 4; pp += 10; @@ -2239,60 +2032,39 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) cp1 += incr; pp += fromskew; } - } - else - { - while (h > 0) - { - for (x = w; x > 0;) - { - int32_t Cb = pp[8]; - int32_t Cr = pp[9]; - switch (x) - { - default: - switch (h) - { - default: - YCbCrtoRGB(cp1[3], pp[7]); /* FALLTHROUGH */ - case 1: - YCbCrtoRGB(cp[3], pp[3]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 3: - switch (h) - { - default: - YCbCrtoRGB(cp1[2], pp[6]); /* FALLTHROUGH */ - case 1: - YCbCrtoRGB(cp[2], pp[2]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 2: - switch (h) - { - default: - YCbCrtoRGB(cp1[1], pp[5]); /* FALLTHROUGH */ - case 1: - YCbCrtoRGB(cp[1], pp[1]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ - case 1: - switch (h) - { - default: - YCbCrtoRGB(cp1[0], pp[4]); /* FALLTHROUGH */ - case 1: - YCbCrtoRGB(cp[0], pp[0]); /* FALLTHROUGH */ - } /* FALLTHROUGH */ + } else { + while (h > 0) { + for (x = w; x > 0;) { + int32 Cb = pp[8]; + int32 Cr = pp[9]; + switch (x) { + default: + switch (h) { + default: YCbCrtoRGB(cp1[3], pp[ 7]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [3], pp[ 3]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 3: + switch (h) { + default: YCbCrtoRGB(cp1[2], pp[ 6]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [2], pp[ 2]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 2: + switch (h) { + default: YCbCrtoRGB(cp1[1], pp[ 5]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [1], pp[ 1]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ + case 1: + switch (h) { + default: YCbCrtoRGB(cp1[0], pp[ 4]); /* FALLTHROUGH */ + case 1: YCbCrtoRGB(cp [0], pp[ 0]); /* FALLTHROUGH */ + } /* FALLTHROUGH */ } - if (x < 4) - { - cp += x; - cp1 += x; + if (x < 4) { + cp += x; cp1 += x; x = 0; } - else - { - cp += 4; - cp1 += 4; + else { + cp += 4; cp1 += 4; x -= 4; } pp += 10; @@ -2312,50 +2084,44 @@ DECLAREContigPutFunc(putcontig8bitYCbCr42tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) { - (void)y; - fromskew = (fromskew / 4) * (4 * 1 + 2); - do - { - x = w >> 2; - while (x > 0) + (void) y; + fromskew = (fromskew / 4) * (4*1+2); + do { + x = w>>2; + while(x>0) { + int32 Cb = pp[4]; + int32 Cr = pp[5]; + + YCbCrtoRGB(cp [0], pp[0]); + YCbCrtoRGB(cp [1], pp[1]); + YCbCrtoRGB(cp [2], pp[2]); + YCbCrtoRGB(cp [3], pp[3]); + + cp += 4; + pp += 6; + x--; + } + + if( (w&3) != 0 ) { - int32_t Cb = pp[4]; - int32_t Cr = pp[5]; + int32 Cb = pp[4]; + int32 Cr = pp[5]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); - YCbCrtoRGB(cp[2], pp[2]); - YCbCrtoRGB(cp[3], pp[3]); - - cp += 4; - pp += 6; - x--; - } - - if ((w & 3) != 0) - { - int32_t Cb = pp[4]; - int32_t Cr = pp[5]; - - switch ((w & 3)) - { - case 3: - YCbCrtoRGB(cp[2], pp[2]); /*-fallthrough*/ - case 2: - YCbCrtoRGB(cp[1], pp[1]); /*-fallthrough*/ - case 1: - YCbCrtoRGB(cp[0], pp[0]); /*-fallthrough*/ - case 0: - break; + switch( (w&3) ) { + case 3: YCbCrtoRGB(cp [2], pp[2]); /*-fallthrough*/ + case 2: YCbCrtoRGB(cp [1], pp[1]); /*-fallthrough*/ + case 1: YCbCrtoRGB(cp [0], pp[0]); /*-fallthrough*/ + case 0: break; } - cp += (w & 3); + cp += (w&3); pp += 6; } - cp += toskew; - pp += fromskew; + cp += toskew; + pp += fromskew; } while (--h); + } /* @@ -2363,63 +2129,57 @@ DECLAREContigPutFunc(putcontig8bitYCbCr41tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) { - 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_t Cb = pp[4]; - uint32_t Cr = pp[5]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); - YCbCrtoRGB(cp2[0], pp[2]); - YCbCrtoRGB(cp2[1], pp[3]); - cp += 2; - cp2 += 2; - pp += 6; - x -= 2; - } - if (x == 1) - { - uint32_t Cb = pp[4]; - uint32_t Cr = pp[5]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp2[0], pp[2]); - cp++; - cp2++; - pp += 6; - } - cp += incr; - cp2 += incr; - pp += fromskew; - h -= 2; - } - if (h == 1) - { - x = w; - while (x >= 2) - { - uint32_t Cb = pp[4]; - uint32_t Cr = pp[5]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); - cp += 2; - cp2 += 2; - pp += 6; - x -= 2; - } - if (x == 1) - { - uint32_t Cb = pp[4]; - uint32_t Cr = pp[5]; - YCbCrtoRGB(cp[0], pp[0]); - } - } + uint32* cp2; + int32 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]; + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp[1], pp[1]); + YCbCrtoRGB(cp2[0], pp[2]); + YCbCrtoRGB(cp2[1], pp[3]); + cp += 2; + cp2 += 2; + pp += 6; + x -= 2; + } + if (x==1) { + uint32 Cb = pp[4]; + uint32 Cr = pp[5]; + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp2[0], pp[2]); + cp ++ ; + cp2 ++ ; + pp += 6; + } + cp += incr; + cp2 += incr; + pp += fromskew; + h-=2; + } + if (h==1) { + x = w; + while (x>=2) { + uint32 Cb = pp[4]; + uint32 Cr = pp[5]; + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp[1], pp[1]); + cp += 2; + cp2 += 2; + pp += 6; + x -= 2; + } + if (x==1) { + uint32 Cb = pp[4]; + uint32 Cr = pp[5]; + YCbCrtoRGB(cp[0], pp[0]); + } + } } /* @@ -2427,38 +2187,36 @@ DECLAREContigPutFunc(putcontig8bitYCbCr22tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) { - (void)y; - fromskew = (fromskew / 2) * (2 * 1 + 2); - do - { - x = w >> 1; - while (x > 0) - { - int32_t Cb = pp[2]; - int32_t Cr = pp[3]; + (void) y; + fromskew = (fromskew / 2) * (2*1+2); + do { + x = w>>1; + while(x>0) { + int32 Cb = pp[2]; + int32 Cr = pp[3]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp[1], pp[1]); + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp[1], pp[1]); - cp += 2; - pp += 4; - x--; - } + cp += 2; + pp += 4; + x --; + } - if ((w & 1) != 0) - { - int32_t Cb = pp[2]; - int32_t Cr = pp[3]; + if( (w&1) != 0 ) + { + int32 Cb = pp[2]; + int32 Cr = pp[3]; - YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp[0], pp[0]); - cp += 1; - pp += 4; - } + cp += 1; + pp += 4; + } - cp += toskew; - pp += fromskew; - } while (--h); + cp += toskew; + pp += fromskew; + } while (--h); } /* @@ -2466,41 +2224,37 @@ DECLAREContigPutFunc(putcontig8bitYCbCr21tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr12tile) { - 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_t Cb = pp[2]; - uint32_t Cr = pp[3]; - YCbCrtoRGB(cp[0], pp[0]); - YCbCrtoRGB(cp2[0], pp[1]); - cp++; - cp2++; - pp += 4; - } while (--x); - cp += incr; - cp2 += incr; - pp += fromskew; - h -= 2; - } - if (h == 1) - { - x = w; - do - { - uint32_t Cb = pp[2]; - uint32_t Cr = pp[3]; - YCbCrtoRGB(cp[0], pp[0]); - cp++; - pp += 4; - } while (--x); - } + uint32* cp2; + int32 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]; + YCbCrtoRGB(cp[0], pp[0]); + YCbCrtoRGB(cp2[0], pp[1]); + cp ++; + cp2 ++; + pp += 4; + } while (--x); + cp += incr; + cp2 += incr; + pp += fromskew; + h-=2; + } + if (h==1) { + x = w; + do { + uint32 Cb = pp[2]; + uint32 Cr = pp[3]; + YCbCrtoRGB(cp[0], pp[0]); + cp ++; + pp += 4; + } while (--x); + } } /* @@ -2508,23 +2262,21 @@ DECLAREContigPutFunc(putcontig8bitYCbCr12tile) */ DECLAREContigPutFunc(putcontig8bitYCbCr11tile) { - (void)y; - fromskew = (fromskew / 1) * (1 * 1 + 2); - do - { - x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */ - do - { - int32_t Cb = pp[1]; - int32_t Cr = pp[2]; + (void) y; + fromskew = (fromskew / 1) * (1 * 1 + 2); + do { + x = w; /* was x = w>>1; patched 2000/09/25 warmerda@home.com */ + do { + int32 Cb = pp[1]; + int32 Cr = pp[2]; - YCbCrtoRGB(*cp++, pp[0]); + YCbCrtoRGB(*cp++, pp[0]); - pp += 3; - } while (--x); - cp += toskew; - pp += fromskew; - } while (--h); + pp += 3; + } while (--x); + cp += toskew; + pp += fromskew; + } while (--h); } /* @@ -2532,22 +2284,19 @@ DECLAREContigPutFunc(putcontig8bitYCbCr11tile) */ DECLARESepPutFunc(putseparate8bitYCbCr11tile) { - (void)y; - (void)a; - /* TODO: naming of input vars is still off, change obfuscating declaration - * inside define, or resolve obfuscation */ - for (; h > 0; --h) - { - x = w; - do - { - uint32_t dr, dg, db; - TIFFYCbCrtoRGB(img->ycbcr, *r++, *g++, *b++, &dr, &dg, &db); - *cp++ = PACK(dr, dg, db); - } while (--x); - SKEW(r, g, b, fromskew); - cp += toskew; - } + (void) y; + (void) a; + /* TODO: naming of input vars is still off, change obfuscating declaration inside define, or resolve obfuscation */ + for( ; h > 0; --h) { + x = w; + do { + uint32 dr, dg, db; + TIFFYCbCrtoRGB(img->ycbcr,*r++,*g++,*b++,&dr,&dg,&db); + *cp++ = PACK(dr,dg,db); + } while (--x); + SKEW(r, g, b, fromskew); + cp += toskew; + } } #undef YCbCrtoRGB @@ -2556,100 +2305,97 @@ static int isInRefBlackWhiteRange(float f) return f > (float)(-0x7FFFFFFF + 128) && f < (float)0x7FFFFFFF; } -static int initYCbCrConversion(TIFFRGBAImage *img) +static int +initYCbCrConversion(TIFFRGBAImage* img) { - static const char module[] = "initYCbCrConversion"; + static const char module[] = "initYCbCrConversion"; - float *luma, *refBlackWhite; + float *luma, *refBlackWhite; - if (img->ycbcr == NULL) - { - img->ycbcr = (TIFFYCbCrToRGB *)_TIFFmallocExt( - img->tif, TIFFroundup_32(sizeof(TIFFYCbCrToRGB), sizeof(long)) + - 4 * 256 * sizeof(TIFFRGBValue) + - 2 * 256 * sizeof(int) + 3 * 256 * sizeof(int32_t)); - if (img->ycbcr == NULL) + if (img->ycbcr == NULL) { + img->ycbcr = (TIFFYCbCrToRGB*) _TIFFmalloc( + TIFFroundup_32(sizeof (TIFFYCbCrToRGB), sizeof (long)) + + 4*256*sizeof (TIFFRGBValue) + + 2*256*sizeof (int) + + 3*256*sizeof (int32) + ); + if (img->ycbcr == NULL) { + TIFFErrorExt(img->tif->tif_clientdata, module, + "No space for YCbCr->RGB conversion state"); + return (0); + } + } + + TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma); + TIFFGetFieldDefaulted(img->tif, TIFFTAG_REFERENCEBLACKWHITE, + &refBlackWhite); + + /* Do some validation to avoid later issues. Detect NaN for now */ + /* and also if lumaGreen is zero since we divide by it later */ + if( luma[0] != luma[0] || + luma[1] != luma[1] || + luma[1] == 0.0 || + luma[2] != luma[2] ) { - TIFFErrorExtR(img->tif, module, - "No space for YCbCr->RGB conversion state"); + TIFFErrorExt(img->tif->tif_clientdata, module, + "Invalid values for YCbCrCoefficients tag"); return (0); } - } - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma); - TIFFGetFieldDefaulted(img->tif, TIFFTAG_REFERENCEBLACKWHITE, - &refBlackWhite); + if( !isInRefBlackWhiteRange(refBlackWhite[0]) || + !isInRefBlackWhiteRange(refBlackWhite[1]) || + !isInRefBlackWhiteRange(refBlackWhite[2]) || + !isInRefBlackWhiteRange(refBlackWhite[3]) || + !isInRefBlackWhiteRange(refBlackWhite[4]) || + !isInRefBlackWhiteRange(refBlackWhite[5]) ) + { + TIFFErrorExt(img->tif->tif_clientdata, module, + "Invalid values for ReferenceBlackWhite tag"); + return (0); + } - /* Do some validation to avoid later issues. Detect NaN for now */ - /* and also if lumaGreen is zero since we divide by it later */ - if (luma[0] != luma[0] || luma[1] != luma[1] || luma[1] == 0.0 || - luma[2] != luma[2]) - { - TIFFErrorExtR(img->tif, module, - "Invalid values for YCbCrCoefficients tag"); - return (0); - } - - if (!isInRefBlackWhiteRange(refBlackWhite[0]) || - !isInRefBlackWhiteRange(refBlackWhite[1]) || - !isInRefBlackWhiteRange(refBlackWhite[2]) || - !isInRefBlackWhiteRange(refBlackWhite[3]) || - !isInRefBlackWhiteRange(refBlackWhite[4]) || - !isInRefBlackWhiteRange(refBlackWhite[5])) - { - TIFFErrorExtR(img->tif, module, - "Invalid values for ReferenceBlackWhite tag"); - return (0); - } - - if (TIFFYCbCrToRGBInit(img->ycbcr, luma, refBlackWhite) < 0) - return (0); - return (1); + if (TIFFYCbCrToRGBInit(img->ycbcr, luma, refBlackWhite) < 0) + return(0); + return (1); } -static tileContigRoutine initCIELabConversion(TIFFRGBAImage *img) +static tileContigRoutine +initCIELabConversion(TIFFRGBAImage* img) { - static const char module[] = "initCIELabConversion"; + static const char module[] = "initCIELabConversion"; - float *whitePoint; - float refWhite[3]; + float *whitePoint; + float refWhite[3]; - TIFFGetFieldDefaulted(img->tif, TIFFTAG_WHITEPOINT, &whitePoint); - if (whitePoint[1] == 0.0f) - { - TIFFErrorExtR(img->tif, module, "Invalid value for WhitePoint tag."); - return NULL; - } - - if (!img->cielab) - { - img->cielab = (TIFFCIELabToRGB *)_TIFFmallocExt( - img->tif, sizeof(TIFFCIELabToRGB)); - if (!img->cielab) - { - TIFFErrorExtR(img->tif, module, - "No space for CIE L*a*b*->RGB conversion state."); - return NULL; + TIFFGetFieldDefaulted(img->tif, TIFFTAG_WHITEPOINT, &whitePoint); + if (whitePoint[1] == 0.0f ) { + TIFFErrorExt(img->tif->tif_clientdata, module, + "Invalid value for WhitePoint tag."); + return NULL; } - } - refWhite[1] = 100.0F; - refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1]; - refWhite[2] = - (1.0F - whitePoint[0] - whitePoint[1]) / whitePoint[1] * refWhite[1]; - if (TIFFCIELabToRGBInit(img->cielab, &display_sRGB, refWhite) < 0) - { - TIFFErrorExtR(img->tif, module, - "Failed to initialize CIE L*a*b*->RGB conversion state."); - _TIFFfreeExt(img->tif, img->cielab); - return NULL; - } + if (!img->cielab) { + img->cielab = (TIFFCIELabToRGB *) + _TIFFmalloc(sizeof(TIFFCIELabToRGB)); + if (!img->cielab) { + TIFFErrorExt(img->tif->tif_clientdata, module, + "No space for CIE L*a*b*->RGB conversion state."); + return NULL; + } + } - if (img->bitspersample == 8) - return putcontig8bitCIELab8; - else if (img->bitspersample == 16) - return putcontig8bitCIELab16; - return NULL; + refWhite[1] = 100.0F; + refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1]; + refWhite[2] = (1.0F - whitePoint[0] - whitePoint[1]) + / whitePoint[1] * refWhite[1]; + if (TIFFCIELabToRGBInit(img->cielab, &display_sRGB, refWhite) < 0) { + TIFFErrorExt(img->tif->tif_clientdata, module, + "Failed to initialize CIE L*a*b*->RGB conversion state."); + _TIFFfree(img->cielab); + return NULL; + } + + return putcontig8bitCIELab; } /* @@ -2659,62 +2405,56 @@ static tileContigRoutine initCIELabConversion(TIFFRGBAImage *img) * pixel values simply by indexing into the table with one * number. */ -static int makebwmap(TIFFRGBAImage *img) +static int +makebwmap(TIFFRGBAImage* img) { - TIFFRGBValue *Map = img->Map; + TIFFRGBValue* Map = img->Map; int bitspersample = img->bitspersample; int nsamples = 8 / bitspersample; int i; - uint32_t *p; + uint32* p; - if (nsamples == 0) + if( nsamples == 0 ) nsamples = 1; - img->BWmap = (uint32_t **)_TIFFmallocExt( - img->tif, - 256 * sizeof(uint32_t *) + (256 * nsamples * sizeof(uint32_t))); - if (img->BWmap == NULL) - { - TIFFErrorExtR(img->tif, TIFFFileName(img->tif), - "No space for B&W mapping table"); - return (0); + img->BWmap = (uint32**) _TIFFmalloc( + 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); + if (img->BWmap == NULL) { + TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "No space for B&W mapping table"); + return (0); } - p = (uint32_t *)(img->BWmap + 256); - for (i = 0; i < 256; i++) - { - TIFFRGBValue c; - img->BWmap[i] = p; - switch (bitspersample) - { -#define GREY(x) \ - c = Map[x]; \ - *p++ = PACK(c, c, c); - case 1: - GREY(i >> 7); - GREY((i >> 6) & 1); - GREY((i >> 5) & 1); - GREY((i >> 4) & 1); - GREY((i >> 3) & 1); - GREY((i >> 2) & 1); - GREY((i >> 1) & 1); - GREY(i & 1); - break; - case 2: - GREY(i >> 6); - GREY((i >> 4) & 3); - GREY((i >> 2) & 3); - GREY(i & 3); - break; - case 4: - GREY(i >> 4); - GREY(i & 0xf); - break; - case 8: - case 16: - GREY(i); - break; - } -#undef GREY + p = (uint32*)(img->BWmap + 256); + for (i = 0; i < 256; i++) { + TIFFRGBValue c; + img->BWmap[i] = p; + switch (bitspersample) { +#define GREY(x) c = Map[x]; *p++ = PACK(c,c,c); + case 1: + GREY(i>>7); + GREY((i>>6)&1); + GREY((i>>5)&1); + GREY((i>>4)&1); + GREY((i>>3)&1); + GREY((i>>2)&1); + GREY((i>>1)&1); + GREY(i&1); + break; + case 2: + GREY(i>>6); + GREY((i>>4)&3); + GREY((i>>2)&3); + GREY(i&3); + break; + case 4: + GREY(i>>4); + GREY(i&0xf); + break; + case 8: + case 16: + GREY(i); + break; + } +#undef GREY } return (1); } @@ -2723,79 +2463,75 @@ static int makebwmap(TIFFRGBAImage *img) * Construct a mapping table to convert from the range * of the data samples to [0,255] --for display. This * process also handles inverting B&W images when needed. - */ -static int setupMap(TIFFRGBAImage *img) + */ +static int +setupMap(TIFFRGBAImage* img) { - int32_t x, range; - - range = (int32_t)((1L << img->bitspersample) - 1); + int32 x, range; + range = (int32)((1L<bitspersample)-1); + /* treat 16 bit the same as eight bit */ - if (img->bitspersample == 16) - range = (int32_t)255; + if( img->bitspersample == 16 ) + range = (int32) 255; - img->Map = (TIFFRGBValue *)_TIFFmallocExt( - img->tif, (range + 1) * sizeof(TIFFRGBValue)); - if (img->Map == NULL) - { - TIFFErrorExtR(img->tif, TIFFFileName(img->tif), - "No space for photometric conversion table"); - return (0); + img->Map = (TIFFRGBValue*) _TIFFmalloc((range+1) * sizeof (TIFFRGBValue)); + if (img->Map == NULL) { + TIFFErrorExt(img->tif->tif_clientdata, TIFFFileName(img->tif), + "No space for photometric conversion table"); + return (0); } - if (img->photometric == PHOTOMETRIC_MINISWHITE) - { - for (x = 0; x <= range; x++) - img->Map[x] = (TIFFRGBValue)(((range - x) * 255) / range); - } - else - { - for (x = 0; x <= range; x++) - img->Map[x] = (TIFFRGBValue)((x * 255) / range); + if (img->photometric == PHOTOMETRIC_MINISWHITE) { + for (x = 0; x <= range; x++) + img->Map[x] = (TIFFRGBValue) (((range - x) * 255) / range); + } else { + for (x = 0; x <= range; x++) + img->Map[x] = (TIFFRGBValue) ((x * 255) / range); } if (img->bitspersample <= 16 && - (img->photometric == PHOTOMETRIC_MINISBLACK || - img->photometric == PHOTOMETRIC_MINISWHITE)) - { - /* - * Use photometric mapping table to construct - * unpacking tables for samples <= 8 bits. - */ - if (!makebwmap(img)) - return (0); - /* no longer need Map, free it */ - _TIFFfreeExt(img->tif, img->Map); - img->Map = NULL; + (img->photometric == PHOTOMETRIC_MINISBLACK || + img->photometric == PHOTOMETRIC_MINISWHITE)) { + /* + * Use photometric mapping table to construct + * unpacking tables for samples <= 8 bits. + */ + if (!makebwmap(img)) + return (0); + /* no longer need Map, free it */ + _TIFFfree(img->Map); + img->Map = NULL; } return (1); } -static int checkcmap(TIFFRGBAImage *img) +static int +checkcmap(TIFFRGBAImage* img) { - uint16_t *r = img->redcmap; - uint16_t *g = img->greencmap; - uint16_t *b = img->bluecmap; - long n = 1L << img->bitspersample; + uint16* r = img->redcmap; + uint16* g = img->greencmap; + uint16* b = img->bluecmap; + long n = 1L<bitspersample; while (n-- > 0) - if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) - return (16); + if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) + return (16); return (8); } -static void cvtcmap(TIFFRGBAImage *img) +static void +cvtcmap(TIFFRGBAImage* img) { - uint16_t *r = img->redcmap; - uint16_t *g = img->greencmap; - uint16_t *b = img->bluecmap; + uint16* r = img->redcmap; + uint16* g = img->greencmap; + uint16* b = img->bluecmap; long i; - for (i = (1L << img->bitspersample) - 1; i >= 0; i--) - { -#define CVT(x) ((uint16_t)((x) >> 8)) - r[i] = CVT(r[i]); - g[i] = CVT(g[i]); - b[i] = CVT(b[i]); -#undef CVT + for (i = (1L<bitspersample)-1; i >= 0; i--) { +#define CVT(x) ((uint16)((x)>>8)) + r[i] = CVT(r[i]); + g[i] = CVT(g[i]); + b[i] = CVT(b[i]); +#undef CVT } } @@ -2806,100 +2542,93 @@ static void cvtcmap(TIFFRGBAImage *img) * pixel values simply by indexing into the table with one * number. */ -static int makecmap(TIFFRGBAImage *img) +static int +makecmap(TIFFRGBAImage* img) { int bitspersample = img->bitspersample; int nsamples = 8 / bitspersample; - uint16_t *r = img->redcmap; - uint16_t *g = img->greencmap; - uint16_t *b = img->bluecmap; - uint32_t *p; + uint16* r = img->redcmap; + uint16* g = img->greencmap; + uint16* b = img->bluecmap; + uint32 *p; int i; - img->PALmap = (uint32_t **)_TIFFmallocExt( - img->tif, - 256 * sizeof(uint32_t *) + (256 * nsamples * sizeof(uint32_t))); - if (img->PALmap == NULL) - { - TIFFErrorExtR(img->tif, TIFFFileName(img->tif), - "No space for Palette mapping table"); - return (0); - } - p = (uint32_t *)(img->PALmap + 256); - for (i = 0; i < 256; i++) - { - TIFFRGBValue c; - img->PALmap[i] = p; -#define CMAP(x) \ - c = (TIFFRGBValue)x; \ - *p++ = PACK(r[c] & 0xff, g[c] & 0xff, b[c] & 0xff); - switch (bitspersample) - { - case 1: - CMAP(i >> 7); - CMAP((i >> 6) & 1); - CMAP((i >> 5) & 1); - CMAP((i >> 4) & 1); - CMAP((i >> 3) & 1); - CMAP((i >> 2) & 1); - CMAP((i >> 1) & 1); - CMAP(i & 1); - break; - case 2: - CMAP(i >> 6); - CMAP((i >> 4) & 3); - CMAP((i >> 2) & 3); - CMAP(i & 3); - break; - case 4: - CMAP(i >> 4); - CMAP(i & 0xf); - break; - case 8: - CMAP(i); - break; - } + img->PALmap = (uint32**) _TIFFmalloc( + 256*sizeof (uint32 *)+(256*nsamples*sizeof(uint32))); + 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); + for (i = 0; i < 256; i++) { + TIFFRGBValue c; + img->PALmap[i] = p; +#define CMAP(x) c = (TIFFRGBValue) x; *p++ = PACK(r[c]&0xff, g[c]&0xff, b[c]&0xff); + switch (bitspersample) { + case 1: + CMAP(i>>7); + CMAP((i>>6)&1); + CMAP((i>>5)&1); + CMAP((i>>4)&1); + CMAP((i>>3)&1); + CMAP((i>>2)&1); + CMAP((i>>1)&1); + CMAP(i&1); + break; + case 2: + CMAP(i>>6); + CMAP((i>>4)&3); + CMAP((i>>2)&3); + CMAP(i&3); + break; + case 4: + CMAP(i>>4); + CMAP(i&0xf); + break; + case 8: + CMAP(i); + break; + } #undef CMAP } return (1); } -/* +/* * Construct any mapping table used * by the associated put routine. */ -static int buildMap(TIFFRGBAImage *img) +static int +buildMap(TIFFRGBAImage* img) { - switch (img->photometric) - { - case PHOTOMETRIC_RGB: - case PHOTOMETRIC_YCBCR: - case PHOTOMETRIC_SEPARATED: - if (img->bitspersample == 8) - break; - /* fall through... */ - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_MINISWHITE: - if (!setupMap(img)) - return (0); - break; - case PHOTOMETRIC_PALETTE: - /* - * Convert 16-bit colormap to 8-bit (unless it looks - * like an old-style 8-bit colormap). - */ - if (checkcmap(img) == 16) - cvtcmap(img); - else - TIFFWarningExtR(img->tif, TIFFFileName(img->tif), - "Assuming 8-bit colormap"); - /* - * Use mapping table and colormap to construct - * unpacking tables for samples < 8 bits. - */ - if (img->bitspersample <= 8 && !makecmap(img)) - return (0); - break; + switch (img->photometric) { + case PHOTOMETRIC_RGB: + case PHOTOMETRIC_YCBCR: + case PHOTOMETRIC_SEPARATED: + if (img->bitspersample == 8) + break; + /* fall through... */ + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_MINISWHITE: + if (!setupMap(img)) + return (0); + break; + case PHOTOMETRIC_PALETTE: + /* + * Convert 16-bit colormap to 8-bit (unless it looks + * like an old-style 8-bit colormap). + */ + if (checkcmap(img) == 16) + cvtcmap(img); + else + TIFFWarningExt(img->tif->tif_clientdata, TIFFFileName(img->tif), "Assuming 8-bit colormap"); + /* + * Use mapping table and colormap to construct + * unpacking tables for samples < 8 bits. + */ + if (img->bitspersample <= 8 && !makecmap(img)) + return (0); + break; } return (1); } @@ -2907,162 +2636,153 @@ static int buildMap(TIFFRGBAImage *img) /* * Select the appropriate conversion routine for packed data. */ -static int PickContigCase(TIFFRGBAImage *img) +static int +PickContigCase(TIFFRGBAImage* img) { - img->get = TIFFIsTiled(img->tif) ? gtTileContig : gtStripContig; - img->put.contig = NULL; - switch (img->photometric) - { - case PHOTOMETRIC_RGB: - switch (img->bitspersample) - { - case 8: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA && - img->samplesperpixel >= 4) - img->put.contig = putRGBAAcontig8bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA && - img->samplesperpixel >= 4) - { - if (BuildMapUaToAa(img)) - img->put.contig = putRGBUAcontig8bittile; - } - else if (img->samplesperpixel >= 3) - img->put.contig = putRGBcontig8bittile; - break; - case 16: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA && - img->samplesperpixel >= 4) - { - if (BuildMapBitdepth16To8(img)) - img->put.contig = putRGBAAcontig16bittile; - } - else if (img->alpha == EXTRASAMPLE_UNASSALPHA && - img->samplesperpixel >= 4) - { - if (BuildMapBitdepth16To8(img) && BuildMapUaToAa(img)) - img->put.contig = putRGBUAcontig16bittile; - } - else if (img->samplesperpixel >= 3) - { - if (BuildMapBitdepth16To8(img)) - img->put.contig = putRGBcontig16bittile; - } - break; - } - break; - case PHOTOMETRIC_SEPARATED: - if (img->samplesperpixel >= 4 && buildMap(img)) - { - if (img->bitspersample == 8) - { - if (!img->Map) - img->put.contig = putRGBcontig8bitCMYKtile; - else - img->put.contig = putRGBcontig8bitCMYKMaptile; - } - } - break; - case PHOTOMETRIC_PALETTE: - if (buildMap(img)) - { - switch (img->bitspersample) - { - case 8: - img->put.contig = put8bitcmaptile; - break; - case 4: - img->put.contig = put4bitcmaptile; - break; - case 2: - img->put.contig = put2bitcmaptile; - break; - case 1: - img->put.contig = put1bitcmaptile; - break; - } - } - break; - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - if (buildMap(img)) - { - switch (img->bitspersample) - { - case 16: - img->put.contig = put16bitbwtile; - break; - case 8: - if (img->alpha && img->samplesperpixel == 2) - img->put.contig = putagreytile; - else - img->put.contig = putgreytile; - break; - case 4: - img->put.contig = put4bitbwtile; - break; - case 2: - img->put.contig = put2bitbwtile; - break; - case 1: - img->put.contig = put1bitbwtile; - break; - } - } - break; - case PHOTOMETRIC_YCBCR: - if ((img->bitspersample == 8) && (img->samplesperpixel == 3)) - { - if (initYCbCrConversion(img) != 0) - { - /* - * The 6.0 spec says that subsampling must be - * one of 1, 2, or 4, and that vertical subsampling - * must always be <= horizontal subsampling; so - * there are only a few possibilities and we just - * enumerate the cases. - * Joris: added support for the [1,2] case, nonetheless, to - * accommodate some OJPEG files - */ - uint16_t SubsamplingHor; - uint16_t SubsamplingVer; - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, - &SubsamplingHor, &SubsamplingVer); - switch ((SubsamplingHor << 4) | SubsamplingVer) - { - case 0x44: - img->put.contig = putcontig8bitYCbCr44tile; - break; - case 0x42: - img->put.contig = putcontig8bitYCbCr42tile; - break; - case 0x41: - img->put.contig = putcontig8bitYCbCr41tile; - break; - case 0x22: - img->put.contig = putcontig8bitYCbCr22tile; - break; - case 0x21: - img->put.contig = putcontig8bitYCbCr21tile; - break; - case 0x12: - img->put.contig = putcontig8bitYCbCr12tile; - break; - case 0x11: - img->put.contig = putcontig8bitYCbCr11tile; - break; - } - } - } - break; - case PHOTOMETRIC_CIELAB: - if (img->samplesperpixel == 3 && buildMap(img)) - { - if (img->bitspersample == 8 || img->bitspersample == 16) - img->put.contig = initCIELabConversion(img); - break; - } - } - return ((img->get != NULL) && (img->put.contig != NULL)); + img->get = TIFFIsTiled(img->tif) ? gtTileContig : gtStripContig; + img->put.contig = NULL; + switch (img->photometric) { + case PHOTOMETRIC_RGB: + switch (img->bitspersample) { + case 8: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA && + img->samplesperpixel >= 4) + img->put.contig = putRGBAAcontig8bittile; + else if (img->alpha == EXTRASAMPLE_UNASSALPHA && + img->samplesperpixel >= 4) + { + if (BuildMapUaToAa(img)) + img->put.contig = putRGBUAcontig8bittile; + } + else if( img->samplesperpixel >= 3 ) + img->put.contig = putRGBcontig8bittile; + break; + case 16: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA && + img->samplesperpixel >=4 ) + { + if (BuildMapBitdepth16To8(img)) + img->put.contig = putRGBAAcontig16bittile; + } + else if (img->alpha == EXTRASAMPLE_UNASSALPHA && + img->samplesperpixel >=4 ) + { + if (BuildMapBitdepth16To8(img) && + BuildMapUaToAa(img)) + img->put.contig = putRGBUAcontig16bittile; + } + else if( img->samplesperpixel >=3 ) + { + if (BuildMapBitdepth16To8(img)) + img->put.contig = putRGBcontig16bittile; + } + break; + } + break; + case PHOTOMETRIC_SEPARATED: + if (img->samplesperpixel >=4 && buildMap(img)) { + if (img->bitspersample == 8) { + if (!img->Map) + img->put.contig = putRGBcontig8bitCMYKtile; + else + img->put.contig = putRGBcontig8bitCMYKMaptile; + } + } + break; + case PHOTOMETRIC_PALETTE: + if (buildMap(img)) { + switch (img->bitspersample) { + case 8: + img->put.contig = put8bitcmaptile; + break; + case 4: + img->put.contig = put4bitcmaptile; + break; + case 2: + img->put.contig = put2bitcmaptile; + break; + case 1: + img->put.contig = put1bitcmaptile; + break; + } + } + break; + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + if (buildMap(img)) { + switch (img->bitspersample) { + case 16: + img->put.contig = put16bitbwtile; + break; + case 8: + if (img->alpha && img->samplesperpixel == 2) + img->put.contig = putagreytile; + else + img->put.contig = putgreytile; + break; + case 4: + img->put.contig = put4bitbwtile; + break; + case 2: + img->put.contig = put2bitbwtile; + break; + case 1: + img->put.contig = put1bitbwtile; + break; + } + } + break; + case PHOTOMETRIC_YCBCR: + if ((img->bitspersample==8) && (img->samplesperpixel==3)) + { + if (initYCbCrConversion(img)!=0) + { + /* + * The 6.0 spec says that subsampling must be + * one of 1, 2, or 4, and that vertical subsampling + * must always be <= horizontal subsampling; so + * there are only a few possibilities and we just + * enumerate the cases. + * Joris: added support for the [1,2] case, nonetheless, to accommodate + * some OJPEG files + */ + uint16 SubsamplingHor; + uint16 SubsamplingVer; + TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &SubsamplingHor, &SubsamplingVer); + switch ((SubsamplingHor<<4)|SubsamplingVer) { + case 0x44: + img->put.contig = putcontig8bitYCbCr44tile; + break; + case 0x42: + img->put.contig = putcontig8bitYCbCr42tile; + break; + case 0x41: + img->put.contig = putcontig8bitYCbCr41tile; + break; + case 0x22: + img->put.contig = putcontig8bitYCbCr22tile; + break; + case 0x21: + img->put.contig = putcontig8bitYCbCr21tile; + break; + case 0x12: + img->put.contig = putcontig8bitYCbCr12tile; + break; + case 0x11: + img->put.contig = putcontig8bitYCbCr11tile; + break; + } + } + } + break; + case PHOTOMETRIC_CIELAB: + if (img->samplesperpixel == 3 && buildMap(img)) { + if (img->bitspersample == 8) + img->put.contig = initCIELabConversion(img); + break; + } + } + return ((img->get!=NULL) && (img->put.contig!=NULL)); } /* @@ -3071,118 +2791,117 @@ static int PickContigCase(TIFFRGBAImage *img) * NB: we assume that unpacked single channel data is directed * to the "packed routines. */ -static int PickSeparateCase(TIFFRGBAImage *img) +static int +PickSeparateCase(TIFFRGBAImage* img) { - img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate; - img->put.separate = NULL; - switch (img->photometric) - { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - /* greyscale images processed pretty much as RGB by gtTileSeparate - */ - case PHOTOMETRIC_RGB: - switch (img->bitspersample) - { - case 8: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - img->put.separate = putRGBAAseparate8bittile; - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - { - if (BuildMapUaToAa(img)) - img->put.separate = putRGBUAseparate8bittile; - } - else - img->put.separate = putRGBseparate8bittile; - break; - case 16: - if (img->alpha == EXTRASAMPLE_ASSOCALPHA) - { - if (BuildMapBitdepth16To8(img)) - img->put.separate = putRGBAAseparate16bittile; - } - else if (img->alpha == EXTRASAMPLE_UNASSALPHA) - { - if (BuildMapBitdepth16To8(img) && BuildMapUaToAa(img)) - img->put.separate = putRGBUAseparate16bittile; - } - else - { - if (BuildMapBitdepth16To8(img)) - img->put.separate = putRGBseparate16bittile; - } - break; - } - break; - case PHOTOMETRIC_SEPARATED: - if (img->bitspersample == 8 && img->samplesperpixel == 4) - { - img->alpha = - 1; // Not alpha, but seems like the only way to get 4th band - img->put.separate = putCMYKseparate8bittile; - } - break; - case PHOTOMETRIC_YCBCR: - if ((img->bitspersample == 8) && (img->samplesperpixel == 3)) - { - if (initYCbCrConversion(img) != 0) - { - uint16_t hs, vs; - TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, - &hs, &vs); - switch ((hs << 4) | vs) - { - case 0x11: - img->put.separate = putseparate8bitYCbCr11tile; - break; - /* TODO: add other cases here */ - } - } - } - break; - } - return ((img->get != NULL) && (img->put.separate != NULL)); + img->get = TIFFIsTiled(img->tif) ? gtTileSeparate : gtStripSeparate; + img->put.separate = NULL; + switch (img->photometric) { + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + /* greyscale images processed pretty much as RGB by gtTileSeparate */ + case PHOTOMETRIC_RGB: + switch (img->bitspersample) { + case 8: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + img->put.separate = putRGBAAseparate8bittile; + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + { + if (BuildMapUaToAa(img)) + img->put.separate = putRGBUAseparate8bittile; + } + else + img->put.separate = putRGBseparate8bittile; + break; + case 16: + if (img->alpha == EXTRASAMPLE_ASSOCALPHA) + { + if (BuildMapBitdepth16To8(img)) + img->put.separate = putRGBAAseparate16bittile; + } + else if (img->alpha == EXTRASAMPLE_UNASSALPHA) + { + if (BuildMapBitdepth16To8(img) && + BuildMapUaToAa(img)) + img->put.separate = putRGBUAseparate16bittile; + } + else + { + if (BuildMapBitdepth16To8(img)) + img->put.separate = putRGBseparate16bittile; + } + break; + } + break; + case PHOTOMETRIC_SEPARATED: + if (img->bitspersample == 8 && img->samplesperpixel == 4) + { + img->alpha = 1; // Not alpha, but seems like the only way to get 4th band + img->put.separate = putCMYKseparate8bittile; + } + break; + case PHOTOMETRIC_YCBCR: + if ((img->bitspersample==8) && (img->samplesperpixel==3)) + { + if (initYCbCrConversion(img)!=0) + { + uint16 hs, vs; + TIFFGetFieldDefaulted(img->tif, TIFFTAG_YCBCRSUBSAMPLING, &hs, &vs); + switch ((hs<<4)|vs) { + case 0x11: + img->put.separate = putseparate8bitYCbCr11tile; + break; + /* TODO: add other cases here */ + } + } + } + break; + } + return ((img->get!=NULL) && (img->put.separate!=NULL)); } -static int BuildMapUaToAa(TIFFRGBAImage *img) +static int +BuildMapUaToAa(TIFFRGBAImage* img) { - static const char module[] = "BuildMapUaToAa"; - uint8_t *m; - uint16_t na, nv; - assert(img->UaToAa == NULL); - img->UaToAa = _TIFFmallocExt(img->tif, 65536); - if (img->UaToAa == NULL) - { - TIFFErrorExtR(img->tif, module, "Out of memory"); - return (0); - } - m = img->UaToAa; - for (na = 0; na < 256; na++) - { - for (nv = 0; nv < 256; nv++) - *m++ = (uint8_t)((nv * na + 127) / 255); - } - return (1); + static const char module[]="BuildMapUaToAa"; + uint8* m; + uint16 na,nv; + assert(img->UaToAa==NULL); + img->UaToAa=_TIFFmalloc(65536); + if (img->UaToAa==NULL) + { + TIFFErrorExt(img->tif->tif_clientdata,module,"Out of memory"); + return(0); + } + m=img->UaToAa; + for (na=0; na<256; na++) + { + for (nv=0; nv<256; nv++) + *m++=(uint8)((nv*na+127)/255); + } + return(1); } -static int BuildMapBitdepth16To8(TIFFRGBAImage *img) +static int +BuildMapBitdepth16To8(TIFFRGBAImage* img) { - static const char module[] = "BuildMapBitdepth16To8"; - uint8_t *m; - uint32_t n; - assert(img->Bitdepth16To8 == NULL); - img->Bitdepth16To8 = _TIFFmallocExt(img->tif, 65536); - if (img->Bitdepth16To8 == NULL) - { - TIFFErrorExtR(img->tif, module, "Out of memory"); - return (0); - } - m = img->Bitdepth16To8; - for (n = 0; n < 65536; n++) - *m++ = (uint8_t)((n + 128) / 257); - return (1); + static const char module[]="BuildMapBitdepth16To8"; + uint8* m; + uint32 n; + assert(img->Bitdepth16To8==NULL); + img->Bitdepth16To8=_TIFFmalloc(65536); + if (img->Bitdepth16To8==NULL) + { + TIFFErrorExt(img->tif->tif_clientdata,module,"Out of memory"); + return(0); + } + m=img->Bitdepth16To8; + for (n=0; n<65536; n++) + *m++=(uint8)((n+128)/257); + return(1); } + /* * Read a whole strip off data from the file, and convert to RGBA form. * If this is the last strip, then it will only contain the portion of @@ -3190,59 +2909,56 @@ static int BuildMapBitdepth16To8(TIFFRGBAImage *img) * organized in bottom to top form. */ -int TIFFReadRGBAStrip(TIFF *tif, uint32_t row, uint32_t *raster) + +int +TIFFReadRGBAStrip(TIFF* tif, uint32 row, uint32 * raster ) { - return TIFFReadRGBAStripExt(tif, row, raster, 0); + return TIFFReadRGBAStripExt(tif, row, raster, 0 ); } -int TIFFReadRGBAStripExt(TIFF *tif, uint32_t row, uint32_t *raster, - int stop_on_error) +int +TIFFReadRGBAStripExt(TIFF* tif, uint32 row, uint32 * raster, int stop_on_error) { - char emsg[EMSG_BUF_SIZE] = ""; + char emsg[1024] = ""; TIFFRGBAImage img; - int ok; - uint32_t rowsperstrip, rows_to_read; + int ok; + uint32 rowsperstrip, rows_to_read; - if (TIFFIsTiled(tif)) + if( TIFFIsTiled( tif ) ) { - TIFFErrorExtR(tif, TIFFFileName(tif), - "Can't use TIFFReadRGBAStrip() with tiled file."); - return (0); + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), + "Can't use TIFFReadRGBAStrip() with tiled file."); + return (0); } - + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - if ((row % rowsperstrip) != 0) + if( (row % rowsperstrip) != 0 ) { - TIFFErrorExtR( - tif, TIFFFileName(tif), - "Row passed to TIFFReadRGBAStrip() must be first in a strip."); - return (0); + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), + "Row passed to TIFFReadRGBAStrip() must be first in a strip."); + return (0); } - if (TIFFRGBAImageOK(tif, emsg) && - TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) - { + if (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) { img.row_offset = row; img.col_offset = 0; - if (row + rowsperstrip > img.height) + if( row + rowsperstrip > img.height ) rows_to_read = img.height - row; else rows_to_read = rowsperstrip; - - ok = TIFFRGBAImageGet(&img, raster, img.width, rows_to_read); - - TIFFRGBAImageEnd(&img); + + ok = TIFFRGBAImageGet(&img, raster, img.width, rows_to_read ); + + TIFFRGBAImageEnd(&img); + } else { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); + ok = 0; } - else - { - TIFFErrorExtR(tif, TIFFFileName(tif), "%s", emsg); - ok = 0; - } - + return (ok); } @@ -3252,53 +2968,54 @@ int TIFFReadRGBAStripExt(TIFF *tif, uint32_t row, uint32_t *raster, * and may include zeroed areas if the tile extends off the image. */ -int TIFFReadRGBATile(TIFF *tif, uint32_t col, uint32_t row, uint32_t *raster) +int +TIFFReadRGBATile(TIFF* tif, uint32 col, uint32 row, uint32 * raster) { - return TIFFReadRGBATileExt(tif, col, row, raster, 0); + return TIFFReadRGBATileExt(tif, col, row, raster, 0 ); } -int TIFFReadRGBATileExt(TIFF *tif, uint32_t col, uint32_t row, uint32_t *raster, - int stop_on_error) + +int +TIFFReadRGBATileExt(TIFF* tif, uint32 col, uint32 row, uint32 * raster, int stop_on_error ) { - char emsg[EMSG_BUF_SIZE] = ""; + char emsg[1024] = ""; TIFFRGBAImage img; - int ok; - uint32_t tile_xsize, tile_ysize; - uint32_t read_xsize, read_ysize; - uint32_t i_row; + int ok; + uint32 tile_xsize, tile_ysize; + uint32 read_xsize, read_ysize; + uint32 i_row; /* * Verify that our request is legal - on a tile file, and on a * tile boundary. */ - - if (!TIFFIsTiled(tif)) + + if( !TIFFIsTiled( tif ) ) { - TIFFErrorExtR(tif, TIFFFileName(tif), - "Can't use TIFFReadRGBATile() with striped file."); - return (0); + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), + "Can't use TIFFReadRGBATile() with striped file."); + return (0); } - + TIFFGetFieldDefaulted(tif, TIFFTAG_TILEWIDTH, &tile_xsize); TIFFGetFieldDefaulted(tif, TIFFTAG_TILELENGTH, &tile_ysize); - if ((col % tile_xsize) != 0 || (row % tile_ysize) != 0) + if( (col % tile_xsize) != 0 || (row % tile_ysize) != 0 ) { - TIFFErrorExtR(tif, TIFFFileName(tif), - "Row/col passed to TIFFReadRGBATile() must be top" - "left corner of a tile."); - return (0); + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), + "Row/col passed to TIFFReadRGBATile() must be top" + "left corner of a tile."); + return (0); } /* * Setup the RGBA reader. */ - - if (!TIFFRGBAImageOK(tif, emsg) || - !TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "%s", emsg); - return (0); + + if (!TIFFRGBAImageOK(tif, emsg) + || !TIFFRGBAImageBegin(&img, tif, stop_on_error, emsg)) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), "%s", emsg); + return( 0 ); } /* @@ -3308,12 +3025,12 @@ int TIFFReadRGBATileExt(TIFF *tif, uint32_t col, uint32_t row, uint32_t *raster, * a full tile configuration afterwards. */ - if (row + tile_ysize > img.height) + if( row + tile_ysize > img.height ) read_ysize = img.height - row; else read_ysize = tile_ysize; - - if (col + tile_xsize > img.width) + + if( col + tile_xsize > img.width ) read_xsize = img.width - col; else read_xsize = tile_xsize; @@ -3321,12 +3038,12 @@ int TIFFReadRGBATileExt(TIFF *tif, uint32_t col, uint32_t row, uint32_t *raster, /* * Read the chunk of imagery. */ - + img.row_offset = row; img.col_offset = col; - ok = TIFFRGBAImageGet(&img, raster, read_xsize, read_ysize); - + ok = TIFFRGBAImageGet(&img, raster, read_xsize, read_ysize ); + TIFFRGBAImageEnd(&img); /* @@ -3334,27 +3051,33 @@ int TIFFReadRGBATileExt(TIFF *tif, uint32_t col, uint32_t row, uint32_t *raster, * shifting the data around as if a full tile of data is being returned. * * This is all the more complicated because the image is organized in - * bottom to top format. + * bottom to top format. */ - if (read_xsize == tile_xsize && read_ysize == tile_ysize) - return (ok); + if( read_xsize == tile_xsize && read_ysize == tile_ysize ) + return( ok ); - for (i_row = 0; i_row < read_ysize; i_row++) - { - memmove(raster + (size_t)(tile_ysize - i_row - 1) * tile_xsize, - raster + (size_t)(read_ysize - i_row - 1) * read_xsize, - read_xsize * sizeof(uint32_t)); - _TIFFmemset(raster + (size_t)(tile_ysize - i_row - 1) * tile_xsize + - read_xsize, - 0, sizeof(uint32_t) * (tile_xsize - read_xsize)); + for( i_row = 0; i_row < read_ysize; i_row++ ) { + memmove( raster + (size_t)(tile_ysize - i_row - 1) * tile_xsize, + raster + (size_t)(read_ysize - i_row - 1) * read_xsize, + read_xsize * sizeof(uint32) ); + _TIFFmemset( raster + (size_t)(tile_ysize - i_row - 1) * tile_xsize+read_xsize, + 0, sizeof(uint32) * (tile_xsize - read_xsize) ); } - for (i_row = read_ysize; i_row < tile_ysize; i_row++) - { - _TIFFmemset(raster + (size_t)(tile_ysize - i_row - 1) * tile_xsize, 0, - sizeof(uint32_t) * tile_xsize); + for( i_row = read_ysize; i_row < tile_ysize; i_row++ ) { + _TIFFmemset( raster + (size_t)(tile_ysize - i_row - 1) * tile_xsize, + 0, sizeof(uint32) * tile_xsize ); } return (ok); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_hash_set.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_hash_set.c deleted file mode 100644 index 9792c63f4..000000000 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_hash_set.c +++ /dev/null @@ -1,603 +0,0 @@ -/********************************************************************** - * - * Name: tif_hash_set.c - * Purpose: Hash set functions. - * Author: Even Rouault, - * - ********************************************************************** - * Copyright (c) 2008-2009, Even Rouault - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - ****************************************************************************/ - -#include "tif_config.h" - -#include "tif_hash_set.h" - -#include -#include -#include -#include -#include - -/** List element structure. */ -typedef struct _TIFFList TIFFList; - -/** List element structure. */ -struct _TIFFList -{ - /*! Pointer to the data object. Should be allocated and freed by the - * caller. - * */ - void *pData; - /*! Pointer to the next element in list. NULL, if current element is the - * last one. - */ - struct _TIFFList *psNext; -}; - -struct _TIFFHashSet -{ - TIFFHashSetHashFunc fnHashFunc; - TIFFHashSetEqualFunc fnEqualFunc; - TIFFHashSetFreeEltFunc fnFreeEltFunc; - TIFFList **tabList; - int nSize; - int nIndiceAllocatedSize; - int nAllocatedSize; - TIFFList *psRecyclingList; - int nRecyclingListSize; - bool bRehash; -#ifdef HASH_DEBUG - int nCollisions; -#endif -}; - -static const int anPrimes[] = { - 53, 97, 193, 389, 769, 1543, 3079, - 6151, 12289, 24593, 49157, 98317, 196613, 393241, - 786433, 1572869, 3145739, 6291469, 12582917, 25165843, 50331653, - 100663319, 201326611, 402653189, 805306457, 1610612741}; - -/************************************************************************/ -/* TIFFHashSetHashPointer() */ -/************************************************************************/ - -/** - * Hash function for an arbitrary pointer - * - * @param elt the arbitrary pointer to hash - * - * @return the hash value of the pointer - */ - -static unsigned long TIFFHashSetHashPointer(const void *elt) -{ - return (unsigned long)(uintptr_t)((void *)(elt)); -} - -/************************************************************************/ -/* TIFFHashSetEqualPointer() */ -/************************************************************************/ - -/** - * Equality function for arbitrary pointers - * - * @param elt1 the first arbitrary pointer to compare - * @param elt2 the second arbitrary pointer to compare - * - * @return true if the pointers are equal - */ - -static bool TIFFHashSetEqualPointer(const void *elt1, const void *elt2) -{ - return elt1 == elt2; -} - -/************************************************************************/ -/* TIFFHashSetNew() */ -/************************************************************************/ - -/** - * Creates a new hash set - * - * The hash function must return a hash value for the elements to insert. - * If fnHashFunc is NULL, TIFFHashSetHashPointer will be used. - * - * The equal function must return if two elements are equal. - * If fnEqualFunc is NULL, TIFFHashSetEqualPointer will be used. - * - * The free function is used to free elements inserted in the hash set, - * when the hash set is destroyed, when elements are removed or replaced. - * If fnFreeEltFunc is NULL, elements inserted into the hash set will not be - * freed. - * - * @param fnHashFunc hash function. May be NULL. - * @param fnEqualFunc equal function. May be NULL. - * @param fnFreeEltFunc element free function. May be NULL. - * - * @return a new hash set - */ - -TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc, - TIFFHashSetEqualFunc fnEqualFunc, - TIFFHashSetFreeEltFunc fnFreeEltFunc) -{ - TIFFHashSet *set = (TIFFHashSet *)malloc(sizeof(TIFFHashSet)); - if (set == NULL) - return NULL; - set->fnHashFunc = fnHashFunc ? fnHashFunc : TIFFHashSetHashPointer; - set->fnEqualFunc = fnEqualFunc ? fnEqualFunc : TIFFHashSetEqualPointer; - set->fnFreeEltFunc = fnFreeEltFunc; - set->nSize = 0; - set->tabList = (TIFFList **)(calloc(sizeof(TIFFList *), 53)); - if (set->tabList == NULL) - { - free(set); - return NULL; - } - set->nIndiceAllocatedSize = 0; - set->nAllocatedSize = 53; - set->psRecyclingList = NULL; - set->nRecyclingListSize = 0; - set->bRehash = false; -#ifdef HASH_DEBUG - set->nCollisions = 0; -#endif - return set; -} - -/************************************************************************/ -/* TIFFHashSetSize() */ -/************************************************************************/ - -/** - * Returns the number of elements inserted in the hash set - * - * Note: this is not the internal size of the hash set - * - * @param set the hash set - * - * @return the number of elements in the hash set - */ - -int TIFFHashSetSize(const TIFFHashSet *set) -{ - assert(set != NULL); - return set->nSize; -} - -/************************************************************************/ -/* TIFFHashSetGetNewListElt() */ -/************************************************************************/ - -static TIFFList *TIFFHashSetGetNewListElt(TIFFHashSet *set) -{ - if (set->psRecyclingList) - { - TIFFList *psRet = set->psRecyclingList; - psRet->pData = NULL; - set->nRecyclingListSize--; - set->psRecyclingList = psRet->psNext; - return psRet; - } - - return (TIFFList *)malloc(sizeof(TIFFList)); -} - -/************************************************************************/ -/* TIFFHashSetReturnListElt() */ -/************************************************************************/ - -static void TIFFHashSetReturnListElt(TIFFHashSet *set, TIFFList *psList) -{ - if (set->nRecyclingListSize < 128) - { - psList->psNext = set->psRecyclingList; - set->psRecyclingList = psList; - set->nRecyclingListSize++; - } - else - { - free(psList); - } -} - -/************************************************************************/ -/* TIFFHashSetClearInternal() */ -/************************************************************************/ - -static void TIFFHashSetClearInternal(TIFFHashSet *set, bool bFinalize) -{ - assert(set != NULL); - for (int i = 0; i < set->nAllocatedSize; i++) - { - TIFFList *cur = set->tabList[i]; - while (cur) - { - if (set->fnFreeEltFunc) - set->fnFreeEltFunc(cur->pData); - TIFFList *psNext = cur->psNext; - if (bFinalize) - free(cur); - else - TIFFHashSetReturnListElt(set, cur); - cur = psNext; - } - set->tabList[i] = NULL; - } - set->bRehash = false; -} - -/************************************************************************/ -/* TIFFListDestroy() */ -/************************************************************************/ - -/** - * Destroy a list. Caller responsible for freeing data objects contained in - * list elements. - * - * @param psList pointer to list head. - * - */ - -static void TIFFListDestroy(TIFFList *psList) -{ - TIFFList *psCurrent = psList; - - while (psCurrent) - { - TIFFList *const psNext = psCurrent->psNext; - free(psCurrent); - psCurrent = psNext; - } -} - -/************************************************************************/ -/* TIFFHashSetDestroy() */ -/************************************************************************/ - -/** - * Destroys an allocated hash set. - * - * This function also frees the elements if a free function was - * provided at the creation of the hash set. - * - * @param set the hash set - */ - -void TIFFHashSetDestroy(TIFFHashSet *set) -{ - if (set) - { - TIFFHashSetClearInternal(set, true); - free(set->tabList); - TIFFListDestroy(set->psRecyclingList); - free(set); - } -} - -#ifdef notused -/************************************************************************/ -/* TIFFHashSetClear() */ -/************************************************************************/ - -/** - * Clear all elements from a hash set. - * - * This function also frees the elements if a free function was - * provided at the creation of the hash set. - * - * @param set the hash set - */ - -void TIFFHashSetClear(TIFFHashSet *set) -{ - TIFFHashSetClearInternal(set, false); - set->nIndiceAllocatedSize = 0; - set->nAllocatedSize = 53; -#ifdef HASH_DEBUG - set->nCollisions = 0; -#endif - set->nSize = 0; -} - -/************************************************************************/ -/* TIFFHashSetForeach() */ -/************************************************************************/ - -/** - * Walk through the hash set and runs the provided function on all the - * elements - * - * This function is provided the user_data argument of TIFFHashSetForeach. - * It must return true to go on the walk through the hash set, or FALSE to - * make it stop. - * - * Note : the structure of the hash set must *NOT* be modified during the - * walk. - * - * @param set the hash set. - * @param fnIterFunc the function called on each element. - * @param user_data the user data provided to the function. - */ - -void TIFFHashSetForeach(TIFFHashSet *set, TIFFHashSetIterEltFunc fnIterFunc, - void *user_data) -{ - assert(set != NULL); - if (!fnIterFunc) - return; - - for (int i = 0; i < set->nAllocatedSize; i++) - { - TIFFList *cur = set->tabList[i]; - while (cur) - { - if (!fnIterFunc(cur->pData, user_data)) - return; - - cur = cur->psNext; - } - } -} -#endif - -/************************************************************************/ -/* TIFFHashSetRehash() */ -/************************************************************************/ - -static bool TIFFHashSetRehash(TIFFHashSet *set) -{ - int nNewAllocatedSize = anPrimes[set->nIndiceAllocatedSize]; - TIFFList **newTabList = - (TIFFList **)(calloc(sizeof(TIFFList *), nNewAllocatedSize)); - if (newTabList == NULL) - return false; -#ifdef HASH_DEBUG - TIFFDebug("TIFFHASH", - "hashSet=%p, nSize=%d, nCollisions=%d, " - "fCollisionRate=%.02f", - set, set->nSize, set->nCollisions, - set->nCollisions * 100.0 / set->nSize); - set->nCollisions = 0; -#endif - for (int i = 0; i < set->nAllocatedSize; i++) - { - TIFFList *cur = set->tabList[i]; - while (cur) - { - const unsigned long nNewHashVal = - set->fnHashFunc(cur->pData) % nNewAllocatedSize; -#ifdef HASH_DEBUG - if (newTabList[nNewHashVal]) - set->nCollisions++; -#endif - TIFFList *psNext = cur->psNext; - cur->psNext = newTabList[nNewHashVal]; - newTabList[nNewHashVal] = cur; - cur = psNext; - } - } - free(set->tabList); - set->tabList = newTabList; - set->nAllocatedSize = nNewAllocatedSize; - set->bRehash = false; - return true; -} - -/************************************************************************/ -/* TIFFHashSetFindPtr() */ -/************************************************************************/ - -static void **TIFFHashSetFindPtr(TIFFHashSet *set, const void *elt) -{ - const unsigned long nHashVal = set->fnHashFunc(elt) % set->nAllocatedSize; - TIFFList *cur = set->tabList[nHashVal]; - while (cur) - { - if (set->fnEqualFunc(cur->pData, elt)) - return &cur->pData; - cur = cur->psNext; - } - return NULL; -} - -/************************************************************************/ -/* TIFFHashSetInsert() */ -/************************************************************************/ - -/** - * Inserts an element into a hash set. - * - * If the element was already inserted in the hash set, the previous - * element is replaced by the new element. If a free function was provided, - * it is used to free the previously inserted element - * - * @param set the hash set - * @param elt the new element to insert in the hash set - * - * @return true if success. If false is returned, elt has not been inserted, - * but TIFFHashSetInsert() will have run the free function if provided. - */ - -bool TIFFHashSetInsert(TIFFHashSet *set, void *elt) -{ - assert(set != NULL); - void **pElt = TIFFHashSetFindPtr(set, elt); - if (pElt) - { - if (set->fnFreeEltFunc) - set->fnFreeEltFunc(*pElt); - - *pElt = elt; - return true; - } - - if (set->nSize >= 2 * set->nAllocatedSize / 3 || - (set->bRehash && set->nIndiceAllocatedSize > 0 && - set->nSize <= set->nAllocatedSize / 2)) - { - set->nIndiceAllocatedSize++; - if (!TIFFHashSetRehash(set)) - { - set->nIndiceAllocatedSize--; - if (set->fnFreeEltFunc) - set->fnFreeEltFunc(elt); - return false; - } - } - - const unsigned long nHashVal = set->fnHashFunc(elt) % set->nAllocatedSize; -#ifdef HASH_DEBUG - if (set->tabList[nHashVal]) - set->nCollisions++; -#endif - - TIFFList *new_elt = TIFFHashSetGetNewListElt(set); - if (new_elt == NULL) - { - if (set->fnFreeEltFunc) - set->fnFreeEltFunc(elt); - return false; - } - new_elt->pData = elt; - new_elt->psNext = set->tabList[nHashVal]; - set->tabList[nHashVal] = new_elt; - set->nSize++; - - return true; -} - -/************************************************************************/ -/* TIFFHashSetLookup() */ -/************************************************************************/ - -/** - * Returns the element found in the hash set corresponding to the element to - * look up The element must not be modified. - * - * @param set the hash set - * @param elt the element to look up in the hash set - * - * @return the element found in the hash set or NULL - */ - -void *TIFFHashSetLookup(TIFFHashSet *set, const void *elt) -{ - assert(set != NULL); - void **pElt = TIFFHashSetFindPtr(set, elt); - if (pElt) - return *pElt; - - return NULL; -} - -/************************************************************************/ -/* TIFFHashSetRemoveInternal() */ -/************************************************************************/ - -static bool TIFFHashSetRemoveInternal(TIFFHashSet *set, const void *elt, - bool bDeferRehash) -{ - assert(set != NULL); - if (set->nIndiceAllocatedSize > 0 && set->nSize <= set->nAllocatedSize / 2) - { - set->nIndiceAllocatedSize--; - if (bDeferRehash) - set->bRehash = true; - else - { - if (!TIFFHashSetRehash(set)) - { - set->nIndiceAllocatedSize++; - return false; - } - } - } - - int nHashVal = (int)(set->fnHashFunc(elt) % set->nAllocatedSize); - TIFFList *cur = set->tabList[nHashVal]; - TIFFList *prev = NULL; - while (cur) - { - if (set->fnEqualFunc(cur->pData, elt)) - { - if (prev) - prev->psNext = cur->psNext; - else - set->tabList[nHashVal] = cur->psNext; - - if (set->fnFreeEltFunc) - set->fnFreeEltFunc(cur->pData); - - TIFFHashSetReturnListElt(set, cur); -#ifdef HASH_DEBUG - if (set->tabList[nHashVal]) - set->nCollisions--; -#endif - set->nSize--; - return true; - } - prev = cur; - cur = cur->psNext; - } - return false; -} - -/************************************************************************/ -/* TIFFHashSetRemove() */ -/************************************************************************/ - -/** - * Removes an element from a hash set - * - * @param set the hash set - * @param elt the new element to remove from the hash set - * - * @return true if the element was in the hash set - */ - -bool TIFFHashSetRemove(TIFFHashSet *set, const void *elt) -{ - return TIFFHashSetRemoveInternal(set, elt, false); -} - -#ifdef notused -/************************************************************************/ -/* TIFFHashSetRemoveDeferRehash() */ -/************************************************************************/ - -/** - * Removes an element from a hash set. - * - * This will defer potential rehashing of the set to later calls to - * TIFFHashSetInsert() or TIFFHashSetRemove(). - * - * @param set the hash set - * @param elt the new element to remove from the hash set - * - * @return true if the element was in the hash set - */ - -bool TIFFHashSetRemoveDeferRehash(TIFFHashSet *set, const void *elt) -{ - return TIFFHashSetRemoveInternal(set, elt, true); -} -#endif diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_hash_set.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_hash_set.h deleted file mode 100644 index f60e2c675..000000000 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_hash_set.h +++ /dev/null @@ -1,100 +0,0 @@ -/********************************************************************** - * $Id$ - * - * Name: tif_hash_set.h - * Project: TIFF - Common Portability Library - * Purpose: Hash set functions. - * Author: Even Rouault, - * - ********************************************************************** - * Copyright (c) 2008-2009, Even Rouault - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - ****************************************************************************/ - -#ifndef TIFF_HASH_SET_H_INCLUDED -#define TIFF_HASH_SET_H_INCLUDED - -#include - -/** - * \file tif_hash_set.h - * - * Hash set implementation. - * - * An hash set is a data structure that holds elements that are unique - * according to a comparison function. Operations on the hash set, such as - * insertion, removal or lookup, are supposed to be fast if an efficient - * "hash" function is provided. - */ - -#ifdef __cplusplus -extern "C" -{ -#endif - - /* Types */ - - /** Opaque type for a hash set */ - typedef struct _TIFFHashSet TIFFHashSet; - - /** TIFFHashSetHashFunc */ - typedef unsigned long (*TIFFHashSetHashFunc)(const void *elt); - - /** TIFFHashSetEqualFunc */ - typedef bool (*TIFFHashSetEqualFunc)(const void *elt1, const void *elt2); - - /** TIFFHashSetFreeEltFunc */ - typedef void (*TIFFHashSetFreeEltFunc)(void *elt); - - /* Functions */ - - TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc, - TIFFHashSetEqualFunc fnEqualFunc, - TIFFHashSetFreeEltFunc fnFreeEltFunc); - - void TIFFHashSetDestroy(TIFFHashSet *set); - - int TIFFHashSetSize(const TIFFHashSet *set); - -#ifdef notused - void TIFFHashSetClear(TIFFHashSet *set); - - /** TIFFHashSetIterEltFunc */ - typedef int (*TIFFHashSetIterEltFunc)(void *elt, void *user_data); - - void TIFFHashSetForeach(TIFFHashSet *set, TIFFHashSetIterEltFunc fnIterFunc, - void *user_data); -#endif - - bool TIFFHashSetInsert(TIFFHashSet *set, void *elt); - - void *TIFFHashSetLookup(TIFFHashSet *set, const void *elt); - - bool TIFFHashSetRemove(TIFFHashSet *set, const void *elt); - -#ifdef notused - bool TIFFHashSetRemoveDeferRehash(TIFFHashSet *set, const void *elt); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* TIFF_HASH_SET_H_INCLUDED */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jbig.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jbig.c index 7e455ad1c..9095dd4a4 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jbig.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jbig.c @@ -35,197 +35,209 @@ #ifdef JBIG_SUPPORT #include "jbig.h" -static int JBIGSetupDecode(TIFF *tif) +static int JBIGSetupDecode(TIFF* tif) { - if (TIFFNumberOfStrips(tif) != 1) - { - TIFFErrorExtR(tif, "JBIG", - "Multistrip images not supported in decoder"); - return 0; - } + if (TIFFNumberOfStrips(tif) != 1) + { + TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in decoder"); + return 0; + } - return 1; + return 1; } -static int JBIGDecode(TIFF *tif, uint8_t *buffer, tmsize_t size, uint16_t s) +static int JBIGDecode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) { - struct jbg_dec_state decoder; - int decodeStatus = 0; - unsigned char *pImage = NULL; - unsigned long decodedSize; - (void)s; + struct jbg_dec_state decoder; + int decodeStatus = 0; + unsigned char* pImage = NULL; + unsigned long decodedSize; + (void) s; - if (isFillOrder(tif, tif->tif_dir.td_fillorder)) - { - TIFFReverseBits(tif->tif_rawcp, tif->tif_rawcc); - } + if (isFillOrder(tif, tif->tif_dir.td_fillorder)) + { + TIFFReverseBits(tif->tif_rawcp, tif->tif_rawcc); + } - jbg_dec_init(&decoder); + jbg_dec_init(&decoder); #if defined(HAVE_JBG_NEWLEN) - jbg_newlen(tif->tif_rawcp, (size_t)tif->tif_rawcc); - /* - * I do not check the return status of jbg_newlen because even if this - * function fails it does not necessarily mean that decoding the image - * will fail. It is generally only needed for received fax images - * that do not contain the actual length of the image in the BIE - * header. I do not log when an error occurs because that will cause - * problems when converting JBIG encoded TIFF's to - * PostScript. As long as the actual image length is contained in the - * BIE header jbg_dec_in should succeed. - */ + jbg_newlen(tif->tif_rawcp, (size_t)tif->tif_rawcc); + /* + * I do not check the return status of jbg_newlen because even if this + * function fails it does not necessarily mean that decoding the image + * will fail. It is generally only needed for received fax images + * that do not contain the actual length of the image in the BIE + * header. I do not log when an error occurs because that will cause + * problems when converting JBIG encoded TIFF's to + * PostScript. As long as the actual image length is contained in the + * BIE header jbg_dec_in should succeed. + */ #endif /* HAVE_JBG_NEWLEN */ - decodeStatus = jbg_dec_in(&decoder, (unsigned char *)tif->tif_rawcp, - (size_t)tif->tif_rawcc, NULL); - if (JBG_EOK != decodeStatus) - { - /* - * XXX: JBG_EN constant was defined in pre-2.0 releases of the - * JBIG-KIT. Since the 2.0 the error reporting functions were - * changed. We will handle both cases here. - */ - TIFFErrorExtR(tif, "JBIG", "Error (%d) decoding: %s", decodeStatus, + decodeStatus = jbg_dec_in(&decoder, (unsigned char*)tif->tif_rawcp, + (size_t)tif->tif_rawcc, NULL); + if (JBG_EOK != decodeStatus) + { + /* + * XXX: JBG_EN constant was defined in pre-2.0 releases of the + * JBIG-KIT. Since the 2.0 the error reporting functions were + * changed. We will handle both cases here. + */ + TIFFErrorExt(tif->tif_clientdata, + "JBIG", "Error (%d) decoding: %s", + decodeStatus, #if defined(JBG_EN) - jbg_strerror(decodeStatus, JBG_EN) + jbg_strerror(decodeStatus, JBG_EN) #else - jbg_strerror(decodeStatus) + jbg_strerror(decodeStatus) #endif - ); - jbg_dec_free(&decoder); - return 0; - } + ); + jbg_dec_free(&decoder); + return 0; + } - decodedSize = jbg_dec_getsize(&decoder); - if ((tmsize_t)decodedSize < size) - { - TIFFWarningExtR(tif, "JBIG", - "Only decoded %lu bytes, whereas %" TIFF_SSIZE_FORMAT - " requested", - decodedSize, size); - } - else if ((tmsize_t)decodedSize > size) - { - TIFFErrorExtR(tif, "JBIG", - "Decoded %lu bytes, whereas %" TIFF_SSIZE_FORMAT - " were requested", - decodedSize, size); - jbg_dec_free(&decoder); - return 0; - } - pImage = jbg_dec_getimage(&decoder, 0); - _TIFFmemcpy(buffer, pImage, decodedSize); - jbg_dec_free(&decoder); + decodedSize = jbg_dec_getsize(&decoder); + if( (tmsize_t)decodedSize < size ) + { + TIFFWarningExt(tif->tif_clientdata, "JBIG", + "Only decoded %lu bytes, whereas %lu requested", + decodedSize, (unsigned long)size); + } + else if( (tmsize_t)decodedSize > size ) + { + TIFFErrorExt(tif->tif_clientdata, "JBIG", + "Decoded %lu bytes, whereas %lu were requested", + decodedSize, (unsigned long)size); + jbg_dec_free(&decoder); + return 0; + } + pImage = jbg_dec_getimage(&decoder, 0); + _TIFFmemcpy(buffer, pImage, decodedSize); + jbg_dec_free(&decoder); - tif->tif_rawcp += tif->tif_rawcc; - tif->tif_rawcc = 0; + tif->tif_rawcp += tif->tif_rawcc; + tif->tif_rawcc = 0; - return 1; + return 1; } -static int JBIGSetupEncode(TIFF *tif) +static int JBIGSetupEncode(TIFF* tif) { - if (TIFFNumberOfStrips(tif) != 1) - { - TIFFErrorExtR(tif, "JBIG", - "Multistrip images not supported in encoder"); - return 0; - } + if (TIFFNumberOfStrips(tif) != 1) + { + TIFFErrorExt(tif->tif_clientdata, "JBIG", "Multistrip images not supported in encoder"); + return 0; + } - return 1; + return 1; } -static int JBIGCopyEncodedData(TIFF *tif, unsigned char *pp, size_t cc, - uint16_t s) +static int JBIGCopyEncodedData(TIFF* tif, unsigned char* pp, size_t cc, uint16 s) { - (void)s; - while (cc > 0) - { - tmsize_t n = (tmsize_t)cc; + (void) s; + while (cc > 0) + { + tmsize_t n = (tmsize_t)cc; - if (tif->tif_rawcc + n > tif->tif_rawdatasize) - { - n = tif->tif_rawdatasize - tif->tif_rawcc; - } + if (tif->tif_rawcc + n > tif->tif_rawdatasize) + { + n = tif->tif_rawdatasize - tif->tif_rawcc; + } - assert(n > 0); - _TIFFmemcpy(tif->tif_rawcp, pp, n); - tif->tif_rawcp += n; - tif->tif_rawcc += n; - pp += n; - cc -= (size_t)n; - if (tif->tif_rawcc >= tif->tif_rawdatasize && !TIFFFlushData1(tif)) - { - return (-1); - } - } + assert(n > 0); + _TIFFmemcpy(tif->tif_rawcp, pp, n); + tif->tif_rawcp += n; + tif->tif_rawcc += n; + pp += n; + cc -= (size_t)n; + if (tif->tif_rawcc >= tif->tif_rawdatasize && + !TIFFFlushData1(tif)) + { + return (-1); + } + } - return (1); + return (1); } -static void JBIGOutputBie(unsigned char *buffer, size_t len, void *userData) +static void JBIGOutputBie(unsigned char* buffer, size_t len, void* userData) { - TIFF *tif = (TIFF *)userData; + TIFF* tif = (TIFF*)userData; - if (isFillOrder(tif, tif->tif_dir.td_fillorder)) - { - TIFFReverseBits(buffer, (tmsize_t)len); - } + if (isFillOrder(tif, tif->tif_dir.td_fillorder)) + { + TIFFReverseBits(buffer, (tmsize_t)len); + } - JBIGCopyEncodedData(tif, buffer, len, 0); + JBIGCopyEncodedData(tif, buffer, len, 0); } -static int JBIGEncode(TIFF *tif, uint8_t *buffer, tmsize_t size, uint16_t s) +static int JBIGEncode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) { - TIFFDirectory *dir = &tif->tif_dir; - struct jbg_enc_state encoder; + TIFFDirectory* dir = &tif->tif_dir; + struct jbg_enc_state encoder; - (void)size, (void)s; + (void) size, (void) s; - jbg_enc_init(&encoder, dir->td_imagewidth, dir->td_imagelength, 1, &buffer, - JBIGOutputBie, tif); - /* - * jbg_enc_out does the "real" encoding. As data is encoded, - * JBIGOutputBie is called, which writes the data to the directory. - */ - jbg_enc_out(&encoder); - jbg_enc_free(&encoder); + jbg_enc_init(&encoder, + dir->td_imagewidth, + dir->td_imagelength, + 1, + &buffer, + JBIGOutputBie, + tif); + /* + * jbg_enc_out does the "real" encoding. As data is encoded, + * JBIGOutputBie is called, which writes the data to the directory. + */ + jbg_enc_out(&encoder); + jbg_enc_free(&encoder); - return 1; + return 1; } -int TIFFInitJBIG(TIFF *tif, int scheme) +int TIFFInitJBIG(TIFF* tif, int scheme) { - (void)scheme; - assert(scheme == COMPRESSION_JBIG); + (void)scheme; + assert(scheme == COMPRESSION_JBIG); - /* - * These flags are set so the JBIG Codec can control when to reverse - * bits and when not to and to allow the jbig decoder and bit reverser - * to write to memory when necessary. - */ - tif->tif_flags |= TIFF_NOBITREV; - tif->tif_flags &= ~TIFF_MAPPED; - /* We may have read from a previous IFD and thus set TIFF_BUFFERMMAP and - * cleared TIFF_MYBUFFER. It is necessary to restore them to their initial - * value to be consistent with the state of a non-memory mapped file. - */ - if (tif->tif_flags & TIFF_BUFFERMMAP) - { - tif->tif_rawdata = NULL; - tif->tif_rawdatasize = 0; - tif->tif_flags &= ~TIFF_BUFFERMMAP; - tif->tif_flags |= TIFF_MYBUFFER; - } + /* + * These flags are set so the JBIG Codec can control when to reverse + * bits and when not to and to allow the jbig decoder and bit reverser + * to write to memory when necessary. + */ + tif->tif_flags |= TIFF_NOBITREV; + tif->tif_flags &= ~TIFF_MAPPED; + /* We may have read from a previous IFD and thus set TIFF_BUFFERMMAP and + * cleared TIFF_MYBUFFER. It is necessary to restore them to their initial + * value to be consistent with the state of a non-memory mapped file. + */ + if (tif->tif_flags&TIFF_BUFFERMMAP) { + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + tif->tif_flags &= ~TIFF_BUFFERMMAP; + tif->tif_flags |= TIFF_MYBUFFER; + } - /* Setup the function pointers for encode, decode, and cleanup. */ - tif->tif_setupdecode = JBIGSetupDecode; - tif->tif_decodestrip = JBIGDecode; + /* Setup the function pointers for encode, decode, and cleanup. */ + tif->tif_setupdecode = JBIGSetupDecode; + tif->tif_decodestrip = JBIGDecode; - tif->tif_setupencode = JBIGSetupEncode; - tif->tif_encodestrip = JBIGEncode; + tif->tif_setupencode = JBIGSetupEncode; + tif->tif_encodestrip = JBIGEncode; - return 1; + return 1; } #endif /* JBIG_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jpeg.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jpeg.c index 250144f21..6711137a9 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jpeg.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jpeg.c @@ -2,23 +2,23 @@ * Copyright (c) 1994-1997 Sam Leffler * Copyright (c) 1994-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -44,34 +44,10 @@ */ #include -/* Settings that are independent of libjpeg ABI. Used when reinitializing the */ -/* JPEGState from libjpegs 8 bit to libjpeg 12 bits, which have potentially */ -/* different ABI */ -typedef struct -{ - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFPrintMethod printdir; /* super-class method */ - TIFFStripMethod defsparent; /* super-class method */ - TIFFTileMethod deftparent; /* super-class method */ - - /* pseudo-tag fields */ - void *jpegtables; /* JPEGTables tag value, or NULL */ - 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 */ - - int ycbcrsampling_fetched; - int max_allowed_scan_number; - int has_warned_about_progressive_mode; -} JPEGOtherSettings; - -int TIFFFillStrip(TIFF *tif, uint32_t strip); -int TIFFFillTile(TIFF *tif, uint32_t tile); -int TIFFReInitJPEG_12(TIFF *tif, const JPEGOtherSettings *otherSettings, - int scheme, int is_encode); -int TIFFJPEGIsFullStripRequired_12(TIFF *tif); +int TIFFFillStrip(TIFF* tif, uint32 strip); +int TIFFFillTile(TIFF* tif, uint32 tile); +int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode ); +int TIFFJPEGIsFullStripRequired_12(TIFF* tif); /* We undefine FAR to avoid conflict with JPEG definition */ @@ -86,7 +62,7 @@ int TIFFJPEGIsFullStripRequired_12(TIFF *tif); a conflicting typedef given the headers which are included. */ #if defined(__BORLANDC__) || defined(__MINGW32__) -#define XMD_H 1 +# define XMD_H 1 #endif /* @@ -104,63 +80,24 @@ int TIFFJPEGIsFullStripRequired_12(TIFF *tif); /* Define "boolean" as unsigned char, not int, per Windows custom. */ #if defined(__WIN32__) && !defined(__MINGW32__) -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +# ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ + typedef unsigned char boolean; +# endif +# define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ #endif -#include "jerror.h" #include "jpeglib.h" +#include "jerror.h" -/* Do optional compile-time version check */ -#if defined(EXPECTED_JPEG_LIB_VERSION) && !defined(LIBJPEG_12_PATH) -#if EXPECTED_JPEG_LIB_VERSION != JPEG_LIB_VERSION -#error EXPECTED_JPEG_LIB_VERSION != JPEG_LIB_VERSION -#endif -#endif - -/* +/* * Do we want to do special processing suitable for when JSAMPLE is a - * 16bit value? + * 16bit value? */ -/* HAVE_JPEGTURBO_DUAL_MODE_8_12 is defined for libjpeg-turbo >= 2.2 which - * adds a dual-mode 8/12 bit API in the same library. - */ - -#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) -#define JPEG_DUAL_MODE_8_12 -/* Start by undefining BITS_IN_JSAMPLE which is always set to 8 in libjpeg-turbo - * >= 2.2 Cf - * https://github.com/libjpeg-turbo/libjpeg-turbo/commit/8b9bc4b9635a2a047fb23ebe70c9acd728d3f99b - */ -#undef BITS_IN_JSAMPLE -/* libjpeg-turbo >= 2.2 adds J12xxxx datatypes for the 12-bit mode. */ -#if defined(FROM_TIF_JPEG_12) -#define BITS_IN_JSAMPLE 12 -#define TIFF_JSAMPLE J12SAMPLE -#define TIFF_JSAMPARRAY J12SAMPARRAY -#define TIFF_JSAMPIMAGE J12SAMPIMAGE -#define TIFF_JSAMPROW J12SAMPROW -#else -#define BITS_IN_JSAMPLE 8 -#define TIFF_JSAMPLE JSAMPLE -#define TIFF_JSAMPARRAY JSAMPARRAY -#define TIFF_JSAMPIMAGE JSAMPIMAGE -#define TIFF_JSAMPROW JSAMPROW -#endif -#else -#define TIFF_JSAMPLE JSAMPLE -#define TIFF_JSAMPARRAY JSAMPARRAY -#define TIFF_JSAMPIMAGE JSAMPIMAGE -#define TIFF_JSAMPROW JSAMPROW -#endif - #if defined(JPEG_LIB_MK1) -#define JPEG_LIB_MK1_OR_12BIT 1 +# define JPEG_LIB_MK1_OR_12BIT 1 #elif BITS_IN_JSAMPLE == 12 -#define JPEG_LIB_MK1_OR_12BIT 1 +# define JPEG_LIB_MK1_OR_12BIT 1 #endif /* @@ -178,9 +115,9 @@ typedef unsigned char boolean; * On some machines it may be worthwhile to use _setjmp or sigsetjmp * in place of plain setjmp. These macros will make it easier. */ -#define SETJMP(jbuf) setjmp(jbuf) -#define LONGJMP(jbuf, code) longjmp(jbuf, code) -#define JMP_BUF jmp_buf +#define SETJMP(jbuf) setjmp(jbuf) +#define LONGJMP(jbuf,code) longjmp(jbuf,code) +#define JMP_BUF jmp_buf typedef struct jpeg_destination_mgr jpeg_destination_mgr; typedef struct jpeg_source_mgr jpeg_source_mgr; @@ -199,60 +136,68 @@ typedef struct jpeg_error_mgr jpeg_error_mgr; * so we can safely cast JPEGState* -> jpeg_xxx_struct* * and vice versa! */ -typedef struct -{ - union - { - struct jpeg_compress_struct c; - struct jpeg_decompress_struct d; - struct jpeg_common_struct comm; - } cinfo; /* NB: must be first */ - int cinfo_initialized; +typedef struct { + union { + struct jpeg_compress_struct c; + struct jpeg_decompress_struct d; + struct jpeg_common_struct comm; + } cinfo; /* NB: must be first */ + int cinfo_initialized; - jpeg_error_mgr err; /* libjpeg error manager */ - JMP_BUF exit_jmpbuf; /* for catching libjpeg failures */ + jpeg_error_mgr err; /* libjpeg error manager */ + JMP_BUF exit_jmpbuf; /* for catching libjpeg failures */ + + struct jpeg_progress_mgr progress; + /* + * The following two members could be a union, but + * they're small enough that it's not worth the effort. + */ + jpeg_destination_mgr dest; /* data dest for compression */ + 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; + tmsize_t bytesperline; /* decompressed bytes per scanline */ + /* pointers to intermediate buffers when processing downsampled data */ + JSAMPARRAY ds_buffer[MAX_COMPONENTS]; + int scancount; /* number of "scanlines" accumulated */ + int samplesperclump; - struct jpeg_progress_mgr progress; - /* - * The following two members could be a union, but - * they're small enough that it's not worth the effort. - */ - jpeg_destination_mgr dest; /* data dest for compression */ - jpeg_source_mgr src; /* data source for decompression */ - /* private state */ - TIFF *tif; /* back link needed by some code */ - 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 */ - TIFF_JSAMPARRAY ds_buffer[MAX_COMPONENTS]; - int scancount; /* number of "scanlines" accumulated */ - int samplesperclump; + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ + TIFFPrintMethod printdir; /* super-class method */ + TIFFStripMethod defsparent; /* super-class method */ + TIFFTileMethod deftparent; /* super-class method */ + /* pseudo-tag fields */ + void* jpegtables; /* JPEGTables tag value, or NULL */ + uint32 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 */ - JPEGOtherSettings otherSettings; + int ycbcrsampling_fetched; + int max_allowed_scan_number; } JPEGState; -#define JState(tif) ((JPEGState *)(tif)->tif_data) +#define JState(tif) ((JPEGState*)(tif)->tif_data) -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_t *buf, tmsize_t cc, uint16_t s); +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 JPEGInitializeLibJPEG(TIFF * tif, int decode ); +static int DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s); -#define FIELD_JPEGTABLES (FIELD_CODEC + 0) +#define FIELD_JPEGTABLES (FIELD_CODEC+0) static const TIFFField jpegFields[] = { - {TIFFTAG_JPEGTABLES, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, - TIFF_SETGET_C32_UINT8, FIELD_JPEGTABLES, FALSE, TRUE, "JPEGTables", NULL}, - {TIFFTAG_JPEGQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL}, - {TIFFTAG_JPEGCOLORMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL}, - {TIFFTAG_JPEGTABLESMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL}}; + { TIFFTAG_JPEGTABLES, -3, -3, TIFF_UNDEFINED, 0, TIFF_SETGET_C32_UINT8, TIFF_SETGET_C32_UINT8, FIELD_JPEGTABLES, FALSE, TRUE, "JPEGTables", NULL }, + { TIFFTAG_JPEGQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL }, + { TIFFTAG_JPEGCOLORMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL }, + { TIFFTAG_JPEGTABLESMODE, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL } +}; /* * libjpeg interface layer. @@ -268,16 +213,16 @@ static const TIFFField jpegFields[] = { * IJG routines from jerror.c). These are used for both * compression and decompression. */ -static void TIFFjpeg_error_exit(j_common_ptr cinfo) +static void +TIFFjpeg_error_exit(j_common_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; /* NB: cinfo assumed first */ - char buffer[JMSG_LENGTH_MAX]; + JPEGState *sp = (JPEGState *) cinfo; /* NB: cinfo assumed first */ + char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, buffer); - TIFFErrorExtR(sp->tif, "JPEGLib", "%s", - buffer); /* display the error message */ - jpeg_abort(cinfo); /* clean up libjpeg state */ - LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */ + (*cinfo->err->format_message) (cinfo, buffer); + TIFFErrorExt(sp->tif->tif_clientdata, "JPEGLib", "%s", buffer); /* display the error message */ + jpeg_abort(cinfo); /* clean up libjpeg state */ + LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */ } /* @@ -285,216 +230,203 @@ static void TIFFjpeg_error_exit(j_common_ptr cinfo) * since error_exit does its own thing and trace_level * is never set > 0. */ -static void TIFFjpeg_output_message(j_common_ptr cinfo) +static void +TIFFjpeg_output_message(j_common_ptr cinfo) { - char buffer[JMSG_LENGTH_MAX]; + char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, buffer); - TIFFWarningExtR(((JPEGState *)cinfo)->tif, "JPEGLib", "%s", buffer); + (*cinfo->err->format_message) (cinfo, buffer); + TIFFWarningExt(((JPEGState *) cinfo)->tif->tif_clientdata, "JPEGLib", "%s", buffer); } /* Avoid the risk of denial-of-service on crafted JPEGs with an insane */ /* number of scans. */ -/* See - * http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf - */ -static void TIFFjpeg_progress_monitor(j_common_ptr cinfo) +/* See http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf */ +static void +TIFFjpeg_progress_monitor(j_common_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; /* NB: cinfo assumed first */ + JPEGState *sp = (JPEGState *) cinfo; /* NB: cinfo assumed first */ if (cinfo->is_decompressor) { - const int scan_no = ((j_decompress_ptr)cinfo)->input_scan_number; - if (scan_no >= sp->otherSettings.max_allowed_scan_number) + const int scan_no = + ((j_decompress_ptr)cinfo)->input_scan_number; + if (scan_no >= sp->max_allowed_scan_number) { - TIFFErrorExtR( - ((JPEGState *)cinfo)->tif, "TIFFjpeg_progress_monitor", - "Scan number %d exceeds maximum scans (%d). This limit " - "can be raised through the " - "LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER " - "environment variable.", - scan_no, sp->otherSettings.max_allowed_scan_number); + TIFFErrorExt(((JPEGState *) cinfo)->tif->tif_clientdata, + "TIFFjpeg_progress_monitor", + "Scan number %d exceeds maximum scans (%d). This limit " + "can be raised through the LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER " + "environment variable.", + scan_no, sp->max_allowed_scan_number); - jpeg_abort(cinfo); /* clean up libjpeg state */ - LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */ + jpeg_abort(cinfo); /* clean up libjpeg state */ + LONGJMP(sp->exit_jmpbuf, 1); /* return to libtiff caller */ } } } + /* * Interface routines. This layer of routines exists * primarily to limit side-effects from using setjmp. * Also, normal/error returns are converted into return * values per libtiff practice. */ -#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op)) -#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op), 1)) +#define CALLJPEG(sp, fail, op) (SETJMP((sp)->exit_jmpbuf) ? (fail) : (op)) +#define CALLVJPEG(sp, op) CALLJPEG(sp, 0, ((op),1)) -static int TIFFjpeg_create_compress(JPEGState *sp) +static int +TIFFjpeg_create_compress(JPEGState* sp) { - /* initialize JPEG error handling */ - sp->cinfo.c.err = jpeg_std_error(&sp->err); - sp->err.error_exit = TIFFjpeg_error_exit; - sp->err.output_message = TIFFjpeg_output_message; + /* initialize JPEG error handling */ + sp->cinfo.c.err = jpeg_std_error(&sp->err); + sp->err.error_exit = TIFFjpeg_error_exit; + sp->err.output_message = TIFFjpeg_output_message; - /* set client_data to avoid UMR warning from tools like Purify */ - sp->cinfo.c.client_data = NULL; + /* set client_data to avoid UMR warning from tools like Purify */ + sp->cinfo.c.client_data = NULL; - return CALLVJPEG(sp, jpeg_create_compress(&sp->cinfo.c)); + return CALLVJPEG(sp, jpeg_create_compress(&sp->cinfo.c)); } -static int TIFFjpeg_create_decompress(JPEGState *sp) +static int +TIFFjpeg_create_decompress(JPEGState* sp) { - /* initialize JPEG error handling */ - sp->cinfo.d.err = jpeg_std_error(&sp->err); - sp->err.error_exit = TIFFjpeg_error_exit; - sp->err.output_message = TIFFjpeg_output_message; + /* initialize JPEG error handling */ + sp->cinfo.d.err = jpeg_std_error(&sp->err); + sp->err.error_exit = TIFFjpeg_error_exit; + sp->err.output_message = TIFFjpeg_output_message; - /* set client_data to avoid UMR warning from tools like Purify */ - sp->cinfo.d.client_data = NULL; + /* set client_data to avoid UMR warning from tools like Purify */ + sp->cinfo.d.client_data = NULL; - return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d)); + return CALLVJPEG(sp, jpeg_create_decompress(&sp->cinfo.d)); } -static int TIFFjpeg_set_defaults(JPEGState *sp) +static int +TIFFjpeg_set_defaults(JPEGState* sp) { - return CALLVJPEG(sp, jpeg_set_defaults(&sp->cinfo.c)); + return CALLVJPEG(sp, jpeg_set_defaults(&sp->cinfo.c)); } -static int TIFFjpeg_set_colorspace(JPEGState *sp, J_COLOR_SPACE colorspace) +static int +TIFFjpeg_set_colorspace(JPEGState* sp, J_COLOR_SPACE colorspace) { - return CALLVJPEG(sp, jpeg_set_colorspace(&sp->cinfo.c, colorspace)); + return CALLVJPEG(sp, jpeg_set_colorspace(&sp->cinfo.c, colorspace)); } -static int TIFFjpeg_set_quality(JPEGState *sp, int quality, - boolean force_baseline) +static int +TIFFjpeg_set_quality(JPEGState* sp, int quality, boolean force_baseline) { - return CALLVJPEG(sp, - jpeg_set_quality(&sp->cinfo.c, quality, force_baseline)); + return CALLVJPEG(sp, + jpeg_set_quality(&sp->cinfo.c, quality, force_baseline)); } -static int TIFFjpeg_suppress_tables(JPEGState *sp, boolean suppress) +static int +TIFFjpeg_suppress_tables(JPEGState* sp, boolean suppress) { - return CALLVJPEG(sp, jpeg_suppress_tables(&sp->cinfo.c, suppress)); + return CALLVJPEG(sp, jpeg_suppress_tables(&sp->cinfo.c, suppress)); } -static int TIFFjpeg_start_compress(JPEGState *sp, boolean write_all_tables) +static int +TIFFjpeg_start_compress(JPEGState* sp, boolean write_all_tables) { - return CALLVJPEG(sp, jpeg_start_compress(&sp->cinfo.c, write_all_tables)); + return CALLVJPEG(sp, + jpeg_start_compress(&sp->cinfo.c, write_all_tables)); } -static int TIFFjpeg_write_scanlines(JPEGState *sp, TIFF_JSAMPARRAY scanlines, - int num_lines) +static int +TIFFjpeg_write_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int num_lines) { -#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) && BITS_IN_JSAMPLE == 12 - return CALLJPEG(sp, -1, - (int)jpeg12_write_scanlines(&sp->cinfo.c, scanlines, - (JDIMENSION)num_lines)); -#else - return CALLJPEG(sp, -1, - (int)jpeg_write_scanlines(&sp->cinfo.c, scanlines, - (JDIMENSION)num_lines)); -#endif + return CALLJPEG(sp, -1, (int) jpeg_write_scanlines(&sp->cinfo.c, + scanlines, (JDIMENSION) num_lines)); } -static int TIFFjpeg_write_raw_data(JPEGState *sp, TIFF_JSAMPIMAGE data, - int num_lines) +static int +TIFFjpeg_write_raw_data(JPEGState* sp, JSAMPIMAGE data, int num_lines) { -#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) && BITS_IN_JSAMPLE == 12 - return CALLJPEG( - sp, -1, - (int)jpeg12_write_raw_data(&sp->cinfo.c, data, (JDIMENSION)num_lines)); -#else - return CALLJPEG( - sp, -1, - (int)jpeg_write_raw_data(&sp->cinfo.c, data, (JDIMENSION)num_lines)); -#endif + return CALLJPEG(sp, -1, (int) jpeg_write_raw_data(&sp->cinfo.c, + data, (JDIMENSION) num_lines)); } -static int TIFFjpeg_finish_compress(JPEGState *sp) +static int +TIFFjpeg_finish_compress(JPEGState* sp) { - return CALLVJPEG(sp, jpeg_finish_compress(&sp->cinfo.c)); + return CALLVJPEG(sp, jpeg_finish_compress(&sp->cinfo.c)); } -static int TIFFjpeg_write_tables(JPEGState *sp) +static int +TIFFjpeg_write_tables(JPEGState* sp) { - return CALLVJPEG(sp, jpeg_write_tables(&sp->cinfo.c)); + return CALLVJPEG(sp, jpeg_write_tables(&sp->cinfo.c)); } -static int TIFFjpeg_read_header(JPEGState *sp, boolean require_image) +static int +TIFFjpeg_read_header(JPEGState* sp, boolean require_image) { - return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image)); + return CALLJPEG(sp, -1, jpeg_read_header(&sp->cinfo.d, require_image)); } -static int TIFFjpeg_has_multiple_scans(JPEGState *sp) +static int +TIFFjpeg_has_multiple_scans(JPEGState* sp) { - return CALLJPEG(sp, 0, jpeg_has_multiple_scans(&sp->cinfo.d)); + return CALLJPEG(sp, 0, jpeg_has_multiple_scans(&sp->cinfo.d)); } -static int TIFFjpeg_start_decompress(JPEGState *sp) +static int +TIFFjpeg_start_decompress(JPEGState* sp) { - const char *sz_max_allowed_scan_number; - /* progress monitor */ - sp->cinfo.d.progress = &sp->progress; - sp->progress.progress_monitor = TIFFjpeg_progress_monitor; - sp->otherSettings.max_allowed_scan_number = 100; - sz_max_allowed_scan_number = getenv("LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER"); - if (sz_max_allowed_scan_number) - sp->otherSettings.max_allowed_scan_number = - atoi(sz_max_allowed_scan_number); + const char* sz_max_allowed_scan_number; + /* progress monitor */ + sp->cinfo.d.progress = &sp->progress; + sp->progress.progress_monitor = TIFFjpeg_progress_monitor; + sp->max_allowed_scan_number = 100; + sz_max_allowed_scan_number = getenv("LIBTIFF_JPEG_MAX_ALLOWED_SCAN_NUMBER"); + if( sz_max_allowed_scan_number ) + sp->max_allowed_scan_number = atoi(sz_max_allowed_scan_number); - return CALLVJPEG(sp, jpeg_start_decompress(&sp->cinfo.d)); + return CALLVJPEG(sp, jpeg_start_decompress(&sp->cinfo.d)); } -static int TIFFjpeg_read_scanlines(JPEGState *sp, TIFF_JSAMPARRAY scanlines, - int max_lines) +static int +TIFFjpeg_read_scanlines(JPEGState* sp, JSAMPARRAY scanlines, int max_lines) { -#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) && BITS_IN_JSAMPLE == 12 - return CALLJPEG(sp, -1, - (int)jpeg12_read_scanlines(&sp->cinfo.d, scanlines, - (JDIMENSION)max_lines)); -#else - return CALLJPEG(sp, -1, - (int)jpeg_read_scanlines(&sp->cinfo.d, scanlines, - (JDIMENSION)max_lines)); -#endif + return CALLJPEG(sp, -1, (int) jpeg_read_scanlines(&sp->cinfo.d, + scanlines, (JDIMENSION) max_lines)); } -static int TIFFjpeg_read_raw_data(JPEGState *sp, TIFF_JSAMPIMAGE data, - int max_lines) +static int +TIFFjpeg_read_raw_data(JPEGState* sp, JSAMPIMAGE data, int max_lines) { -#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) && BITS_IN_JSAMPLE == 12 - return CALLJPEG( - sp, -1, - (int)jpeg12_read_raw_data(&sp->cinfo.d, data, (JDIMENSION)max_lines)); -#else - return CALLJPEG( - sp, -1, - (int)jpeg_read_raw_data(&sp->cinfo.d, data, (JDIMENSION)max_lines)); -#endif + return CALLJPEG(sp, -1, (int) jpeg_read_raw_data(&sp->cinfo.d, + data, (JDIMENSION) max_lines)); } -static int TIFFjpeg_finish_decompress(JPEGState *sp) +static int +TIFFjpeg_finish_decompress(JPEGState* sp) { - return CALLJPEG(sp, -1, (int)jpeg_finish_decompress(&sp->cinfo.d)); + return CALLJPEG(sp, -1, (int) jpeg_finish_decompress(&sp->cinfo.d)); } -static int TIFFjpeg_abort(JPEGState *sp) +static int +TIFFjpeg_abort(JPEGState* sp) { - return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm)); + return CALLVJPEG(sp, jpeg_abort(&sp->cinfo.comm)); } -static int TIFFjpeg_destroy(JPEGState *sp) +static int +TIFFjpeg_destroy(JPEGState* sp) { - return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm)); + return CALLVJPEG(sp, jpeg_destroy(&sp->cinfo.comm)); } -static JSAMPARRAY TIFFjpeg_alloc_sarray(JPEGState *sp, int pool_id, - JDIMENSION samplesperrow, - JDIMENSION numrows) +static JSAMPARRAY +TIFFjpeg_alloc_sarray(JPEGState* sp, int pool_id, + JDIMENSION samplesperrow, JDIMENSION numrows) { - return CALLJPEG(sp, (JSAMPARRAY)NULL, - (*sp->cinfo.comm.mem->alloc_sarray)( - &sp->cinfo.comm, pool_id, samplesperrow, numrows)); + return CALLJPEG(sp, (JSAMPARRAY) NULL, + (*sp->cinfo.comm.mem->alloc_sarray) + (&sp->cinfo.comm, pool_id, samplesperrow, numrows)); } /* @@ -503,128 +435,130 @@ static JSAMPARRAY TIFFjpeg_alloc_sarray(JPEGState *sp, int pool_id, * libtiff output buffer. */ -static void std_init_destination(j_compress_ptr cinfo) +static void +std_init_destination(j_compress_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; - TIFF *tif = sp->tif; + JPEGState* sp = (JPEGState*) cinfo; + TIFF* tif = sp->tif; - sp->dest.next_output_byte = (JOCTET *)tif->tif_rawdata; - sp->dest.free_in_buffer = (size_t)tif->tif_rawdatasize; + sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; + sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; } -static boolean std_empty_output_buffer(j_compress_ptr cinfo) +static boolean +std_empty_output_buffer(j_compress_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; - TIFF *tif = sp->tif; + JPEGState* sp = (JPEGState*) cinfo; + TIFF* tif = sp->tif; - /* the entire buffer has been filled */ - tif->tif_rawcc = tif->tif_rawdatasize; + /* the entire buffer has been filled */ + tif->tif_rawcc = tif->tif_rawdatasize; #ifdef IPPJ_HUFF - /* - * The Intel IPP performance library does not necessarily fill up - * the whole output buffer on each pass, so only dump out the parts - * that have been filled. - * http://trac.osgeo.org/gdal/wiki/JpegIPP - */ - if (sp->dest.free_in_buffer >= 0) - { - tif->tif_rawcc = tif->tif_rawdatasize - sp->dest.free_in_buffer; - } + /* + * The Intel IPP performance library does not necessarily fill up + * the whole output buffer on each pass, so only dump out the parts + * that have been filled. + * http://trac.osgeo.org/gdal/wiki/JpegIPP + */ + if ( sp->dest.free_in_buffer >= 0 ) { + tif->tif_rawcc = tif->tif_rawdatasize - sp->dest.free_in_buffer; + } #endif - if (!TIFFFlushData1(tif)) - return FALSE; - sp->dest.next_output_byte = (JOCTET *)tif->tif_rawdata; - sp->dest.free_in_buffer = (size_t)tif->tif_rawdatasize; + if( !TIFFFlushData1(tif) ) + return FALSE; + sp->dest.next_output_byte = (JOCTET*) tif->tif_rawdata; + sp->dest.free_in_buffer = (size_t) tif->tif_rawdatasize; - return (TRUE); + return (TRUE); } -static void std_term_destination(j_compress_ptr cinfo) +static void +std_term_destination(j_compress_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; - TIFF *tif = sp->tif; + JPEGState* sp = (JPEGState*) cinfo; + TIFF* tif = sp->tif; - 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 */ + tif->tif_rawcp = (uint8*) 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 */ } -static void TIFFjpeg_data_dest(JPEGState *sp, TIFF *tif) +static void +TIFFjpeg_data_dest(JPEGState* sp, TIFF* tif) { - (void)tif; - sp->cinfo.c.dest = &sp->dest; - sp->dest.init_destination = std_init_destination; - sp->dest.empty_output_buffer = std_empty_output_buffer; - sp->dest.term_destination = std_term_destination; + (void) tif; + sp->cinfo.c.dest = &sp->dest; + sp->dest.init_destination = std_init_destination; + sp->dest.empty_output_buffer = std_empty_output_buffer; + sp->dest.term_destination = std_term_destination; } /* * Alternate destination manager for outputting to JPEGTables field. */ -static void tables_init_destination(j_compress_ptr cinfo) +static void +tables_init_destination(j_compress_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; + JPEGState* sp = (JPEGState*) cinfo; - /* while building, otherSettings.jpegtables_length is allocated buffer size - */ - sp->dest.next_output_byte = (JOCTET *)sp->otherSettings.jpegtables; - sp->dest.free_in_buffer = (size_t)sp->otherSettings.jpegtables_length; + /* while building, jpegtables_length is allocated buffer size */ + sp->dest.next_output_byte = (JOCTET*) sp->jpegtables; + sp->dest.free_in_buffer = (size_t) sp->jpegtables_length; } -static boolean tables_empty_output_buffer(j_compress_ptr cinfo) +static boolean +tables_empty_output_buffer(j_compress_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; - void *newbuf; + JPEGState* sp = (JPEGState*) cinfo; + void* newbuf; - /* the entire buffer has been filled; enlarge it by 1000 bytes */ - newbuf = - _TIFFreallocExt(sp->tif, (void *)sp->otherSettings.jpegtables, - (tmsize_t)(sp->otherSettings.jpegtables_length + 1000)); - if (newbuf == NULL) - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 100); - sp->dest.next_output_byte = - (JOCTET *)newbuf + sp->otherSettings.jpegtables_length; - sp->dest.free_in_buffer = (size_t)1000; - sp->otherSettings.jpegtables = newbuf; - sp->otherSettings.jpegtables_length += 1000; - return (TRUE); + /* the entire buffer has been filled; enlarge it by 1000 bytes */ + newbuf = _TIFFrealloc((void*) sp->jpegtables, + (tmsize_t) (sp->jpegtables_length + 1000)); + if (newbuf == NULL) + ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 100); + sp->dest.next_output_byte = (JOCTET*) newbuf + sp->jpegtables_length; + sp->dest.free_in_buffer = (size_t) 1000; + sp->jpegtables = newbuf; + sp->jpegtables_length += 1000; + return (TRUE); } -static void tables_term_destination(j_compress_ptr cinfo) +static void +tables_term_destination(j_compress_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; + JPEGState* sp = (JPEGState*) cinfo; - /* set tables length to number of bytes actually emitted */ - sp->otherSettings.jpegtables_length -= (uint32_t)sp->dest.free_in_buffer; + /* set tables length to number of bytes actually emitted */ + sp->jpegtables_length -= (uint32) sp->dest.free_in_buffer; } -static int TIFFjpeg_tables_dest(JPEGState *sp, TIFF *tif) +static int +TIFFjpeg_tables_dest(JPEGState* sp, TIFF* tif) { - (void)tif; - /* - * Allocate a working buffer for building tables. - * Initial size is 1000 bytes, which is usually adequate. - */ - if (sp->otherSettings.jpegtables) - _TIFFfreeExt(tif, sp->otherSettings.jpegtables); - sp->otherSettings.jpegtables_length = 1000; - sp->otherSettings.jpegtables = (void *)_TIFFmallocExt( - tif, (tmsize_t)sp->otherSettings.jpegtables_length); - if (sp->otherSettings.jpegtables == NULL) - { - sp->otherSettings.jpegtables_length = 0; - TIFFErrorExtR(sp->tif, "TIFFjpeg_tables_dest", - "No space for JPEGTables"); - return (0); - } - sp->cinfo.c.dest = &sp->dest; - sp->dest.init_destination = tables_init_destination; - sp->dest.empty_output_buffer = tables_empty_output_buffer; - sp->dest.term_destination = tables_term_destination; - return (1); + (void) tif; + /* + * Allocate a working buffer for building tables. + * Initial size is 1000 bytes, which is usually adequate. + */ + if (sp->jpegtables) + _TIFFfree(sp->jpegtables); + sp->jpegtables_length = 1000; + sp->jpegtables = (void*) _TIFFmalloc((tmsize_t) sp->jpegtables_length); + if (sp->jpegtables == NULL) { + sp->jpegtables_length = 0; + TIFFErrorExt(sp->tif->tif_clientdata, "TIFFjpeg_tables_dest", "No space for JPEGTables"); + return (0); + } + sp->cinfo.c.dest = &sp->dest; + sp->dest.init_destination = tables_init_destination; + sp->dest.empty_output_buffer = tables_empty_output_buffer; + sp->dest.term_destination = tables_term_destination; + return (1); } /* @@ -632,86 +566,86 @@ static int TIFFjpeg_tables_dest(JPEGState *sp, TIFF *tif) * These routines supply compressed data to libjpeg. */ -static void std_init_source(j_decompress_ptr cinfo) +static void +std_init_source(j_decompress_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; - TIFF *tif = sp->tif; + JPEGState* sp = (JPEGState*) cinfo; + TIFF* tif = sp->tif; - sp->src.next_input_byte = (const JOCTET *)tif->tif_rawdata; - sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc; + sp->src.next_input_byte = (const JOCTET*) tif->tif_rawdata; + sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; } -static boolean std_fill_input_buffer(j_decompress_ptr cinfo) +static boolean +std_fill_input_buffer(j_decompress_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; - static const JOCTET dummy_EOI[2] = {0xFF, JPEG_EOI}; + JPEGState* sp = (JPEGState* ) cinfo; + static const JOCTET dummy_EOI[2] = { 0xFF, JPEG_EOI }; #ifdef IPPJ_HUFF - /* - * The Intel IPP performance library does not necessarily read the whole - * input buffer in one pass, so it is possible to get here with data - * yet to read. - * - * We just return without doing anything, until the entire buffer has - * been read. - * http://trac.osgeo.org/gdal/wiki/JpegIPP - */ - if (sp->src.bytes_in_buffer > 0) - { - return (TRUE); - } + /* + * The Intel IPP performance library does not necessarily read the whole + * input buffer in one pass, so it is possible to get here with data + * yet to read. + * + * We just return without doing anything, until the entire buffer has + * been read. + * http://trac.osgeo.org/gdal/wiki/JpegIPP + */ + if( sp->src.bytes_in_buffer > 0 ) { + return (TRUE); + } #endif - /* - * Normally the whole strip/tile is read and so we don't need to do - * a fill. In the case of CHUNKY_STRIP_READ_SUPPORT we might not have - * all the data, but the rawdata is refreshed between scanlines and - * we push this into the io machinery in JPEGDecode(). - * http://trac.osgeo.org/gdal/ticket/3894 - */ - - WARNMS(cinfo, JWRN_JPEG_EOF); - /* insert a fake EOI marker */ - sp->src.next_input_byte = dummy_EOI; - sp->src.bytes_in_buffer = 2; - return (TRUE); + /* + * Normally the whole strip/tile is read and so we don't need to do + * a fill. In the case of CHUNKY_STRIP_READ_SUPPORT we might not have + * all the data, but the rawdata is refreshed between scanlines and + * we push this into the io machinery in JPEGDecode(). + * http://trac.osgeo.org/gdal/ticket/3894 + */ + + WARNMS(cinfo, JWRN_JPEG_EOF); + /* insert a fake EOI marker */ + sp->src.next_input_byte = dummy_EOI; + sp->src.bytes_in_buffer = 2; + return (TRUE); } -static void std_skip_input_data(j_decompress_ptr cinfo, long num_bytes) +static void +std_skip_input_data(j_decompress_ptr cinfo, long num_bytes) { - JPEGState *sp = (JPEGState *)cinfo; + JPEGState* sp = (JPEGState*) cinfo; - if (num_bytes > 0) - { - if ((size_t)num_bytes > sp->src.bytes_in_buffer) - { - /* oops, buffer overrun */ - (void)std_fill_input_buffer(cinfo); - } - else - { - sp->src.next_input_byte += (size_t)num_bytes; - sp->src.bytes_in_buffer -= (size_t)num_bytes; - } - } + if (num_bytes > 0) { + if ((size_t)num_bytes > sp->src.bytes_in_buffer) { + /* oops, buffer overrun */ + (void) std_fill_input_buffer(cinfo); + } else { + sp->src.next_input_byte += (size_t) num_bytes; + sp->src.bytes_in_buffer -= (size_t) num_bytes; + } + } } -static void std_term_source(j_decompress_ptr cinfo) +static void +std_term_source(j_decompress_ptr cinfo) { - /* No work necessary here */ - (void)cinfo; + /* No work necessary here */ + (void) cinfo; } -static void TIFFjpeg_data_src(JPEGState *sp) +static void +TIFFjpeg_data_src(JPEGState* sp) { - sp->cinfo.d.src = &sp->src; - sp->src.init_source = std_init_source; - sp->src.fill_input_buffer = std_fill_input_buffer; - sp->src.skip_input_data = std_skip_input_data; - sp->src.resync_to_restart = jpeg_resync_to_restart; - sp->src.term_source = std_term_source; - sp->src.bytes_in_buffer = 0; /* for safety */ - sp->src.next_input_byte = NULL; + sp->cinfo.d.src = &sp->src; + sp->src.init_source = std_init_source; + sp->src.fill_input_buffer = std_fill_input_buffer; + sp->src.skip_input_data = std_skip_input_data; + sp->src.resync_to_restart = jpeg_resync_to_restart; + sp->src.term_source = std_term_source; + sp->src.bytes_in_buffer = 0; /* for safety */ + sp->src.next_input_byte = NULL; } /* @@ -719,18 +653,20 @@ static void TIFFjpeg_data_src(JPEGState *sp) * We can share all the code except for the init routine. */ -static void tables_init_source(j_decompress_ptr cinfo) +static void +tables_init_source(j_decompress_ptr cinfo) { - JPEGState *sp = (JPEGState *)cinfo; + JPEGState* sp = (JPEGState*) cinfo; - sp->src.next_input_byte = (const JOCTET *)sp->otherSettings.jpegtables; - sp->src.bytes_in_buffer = (size_t)sp->otherSettings.jpegtables_length; + sp->src.next_input_byte = (const JOCTET*) sp->jpegtables; + sp->src.bytes_in_buffer = (size_t) sp->jpegtables_length; } -static void TIFFjpeg_tables_src(JPEGState *sp) +static void +TIFFjpeg_tables_src(JPEGState* sp) { - TIFFjpeg_data_src(sp); - sp->src.init_source = tables_init_source; + TIFFjpeg_data_src(sp); + sp->src.init_source = tables_init_source; } /* @@ -740,29 +676,32 @@ static void TIFFjpeg_tables_src(JPEGState *sp) * when done with strip/tile. * This is also a handy place to compute samplesperclump, bytesperline. */ -static int alloc_downsampled_buffers(TIFF *tif, jpeg_component_info *comp_info, - int num_components) +static int +alloc_downsampled_buffers(TIFF* tif, jpeg_component_info* comp_info, + int num_components) { - JPEGState *sp = JState(tif); - int ci; - jpeg_component_info *compptr; - TIFF_JSAMPARRAY buf; - int samples_per_clump = 0; + JPEGState* sp = JState(tif); + int ci; + jpeg_component_info* compptr; + JSAMPARRAY buf; + int samples_per_clump = 0; - for (ci = 0, compptr = comp_info; ci < num_components; ci++, compptr++) - { - samples_per_clump += compptr->h_samp_factor * compptr->v_samp_factor; - buf = (TIFF_JSAMPARRAY)TIFFjpeg_alloc_sarray( - sp, JPOOL_IMAGE, compptr->width_in_blocks * DCTSIZE, - (JDIMENSION)(compptr->v_samp_factor * DCTSIZE)); - if (buf == NULL) - return (0); - sp->ds_buffer[ci] = buf; - } - sp->samplesperclump = samples_per_clump; - return (1); + for (ci = 0, compptr = comp_info; ci < num_components; + ci++, compptr++) { + samples_per_clump += compptr->h_samp_factor * + compptr->v_samp_factor; + buf = TIFFjpeg_alloc_sarray(sp, JPOOL_IMAGE, + compptr->width_in_blocks * DCTSIZE, + (JDIMENSION) (compptr->v_samp_factor*DCTSIZE)); + if (buf == NULL) + return (0); + sp->ds_buffer[ci] = buf; + } + sp->samplesperclump = samples_per_clump; + return (1); } + /* * JPEG Decoding. */ @@ -783,367 +722,331 @@ static int alloc_downsampled_buffers(TIFF *tif, jpeg_component_info *comp_info, #define JPEG_MARKER_COM 0xFE struct JPEGFixupTagsSubsamplingData { - TIFF *tif; - void *buffer; - uint32_t buffersize; - uint8_t *buffercurrentbyte; - uint32_t bufferbytesleft; - uint64_t fileoffset; - uint64_t filebytesleft; - uint8_t filepositioned; + TIFF* tif; + void* buffer; + uint32 buffersize; + uint8* buffercurrentbyte; + uint32 bufferbytesleft; + uint64 fileoffset; + uint64 filebytesleft; + uint8 filepositioned; }; -static void JPEGFixupTagsSubsampling(TIFF *tif); -static int -JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData *data); -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); +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); #endif -static int JPEGFixupTags(TIFF *tif) +static int +JPEGFixupTags(TIFF* tif) { #ifdef CHECK_JPEG_YCBCR_SUBSAMPLING - JPEGState *sp = JState(tif); - if ((tif->tif_dir.td_photometric == PHOTOMETRIC_YCBCR) && - (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) && - (tif->tif_dir.td_samplesperpixel == 3) && - !sp->otherSettings.ycbcrsampling_fetched) - JPEGFixupTagsSubsampling(tif); + JPEGState* sp = JState(tif); + if ((tif->tif_dir.td_photometric==PHOTOMETRIC_YCBCR)&& + (tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG)&& + (tif->tif_dir.td_samplesperpixel==3) && + !sp->ycbcrsampling_fetched) + JPEGFixupTagsSubsampling(tif); #endif - - return (1); + + return(1); } #ifdef CHECK_JPEG_YCBCR_SUBSAMPLING -static void JPEGFixupTagsSubsampling(TIFF *tif) +static void +JPEGFixupTagsSubsampling(TIFF* tif) { - /* - * Some JPEG-in-TIFF produces do not emit the YCBCRSUBSAMPLING values in - * the TIFF tags, but still use non-default (2,2) values within the jpeg - * data stream itself. In order for TIFF applications to work properly - * - for instance to get the strip buffer size right - it is imperative - * that the subsampling be available before we start reading the image - * data normally. This function will attempt to analyze the first strip in - * order to get the sampling values from the jpeg data stream. - * - * Note that JPEGPreDeocode() will produce a fairly loud warning when the - * discovered sampling does not match the default sampling (2,2) or whatever - * was actually in the tiff tags. - * - * See the bug in bugzilla for details: - * - * http://bugzilla.remotesensing.org/show_bug.cgi?id=168 - * - * Frank Warmerdam, July 2002 - * Joris Van Damme, May 2007 - */ - static const char module[] = "JPEGFixupTagsSubsampling"; - struct JPEGFixupTagsSubsamplingData m; - uint64_t fileoffset = TIFFGetStrileOffset(tif, 0); + /* + * Some JPEG-in-TIFF produces do not emit the YCBCRSUBSAMPLING values in + * the TIFF tags, but still use non-default (2,2) values within the jpeg + * data stream itself. In order for TIFF applications to work properly + * - for instance to get the strip buffer size right - it is imperative + * that the subsampling be available before we start reading the image + * data normally. This function will attempt to analyze the first strip in + * order to get the sampling values from the jpeg data stream. + * + * Note that JPEGPreDeocode() will produce a fairly loud warning when the + * discovered sampling does not match the default sampling (2,2) or whatever + * was actually in the tiff tags. + * + * See the bug in bugzilla for details: + * + * http://bugzilla.remotesensing.org/show_bug.cgi?id=168 + * + * Frank Warmerdam, July 2002 + * Joris Van Damme, May 2007 + */ + static const char module[] = "JPEGFixupTagsSubsampling"; + struct JPEGFixupTagsSubsamplingData m; + uint64 fileoffset = TIFFGetStrileOffset(tif, 0); - if (fileoffset == 0) - { - /* Do not even try to check if the first strip/tile does not - yet exist, as occurs when GDAL has created a new NULL file - for instance. */ - return; - } + if( fileoffset == 0 ) + { + /* Do not even try to check if the first strip/tile does not + yet exist, as occurs when GDAL has created a new NULL file + for instance. */ + return; + } - m.tif = tif; - m.buffersize = 2048; - m.buffer = _TIFFmallocExt(tif, m.buffersize); - if (m.buffer == NULL) - { - TIFFWarningExtR(tif, module, - "Unable to allocate memory for auto-correcting of " - "subsampling values; auto-correcting skipped"); - return; - } - m.buffercurrentbyte = NULL; - m.bufferbytesleft = 0; - m.fileoffset = fileoffset; - m.filepositioned = 0; - m.filebytesleft = TIFFGetStrileByteCount(tif, 0); - if (!JPEGFixupTagsSubsamplingSec(&m)) - TIFFWarningExtR( - tif, module, - "Unable to auto-correct subsampling values, likely corrupt JPEG " - "compressed data in first strip/tile; auto-correcting skipped"); - _TIFFfreeExt(tif, m.buffer); + m.tif=tif; + m.buffersize=2048; + m.buffer=_TIFFmalloc(m.buffersize); + if (m.buffer==NULL) + { + TIFFWarningExt(tif->tif_clientdata,module, + "Unable to allocate memory for auto-correcting of subsampling values; auto-correcting skipped"); + return; + } + m.buffercurrentbyte=NULL; + m.bufferbytesleft=0; + m.fileoffset=fileoffset; + m.filepositioned=0; + m.filebytesleft=TIFFGetStrileByteCount(tif, 0); + if (!JPEGFixupTagsSubsamplingSec(&m)) + TIFFWarningExt(tif->tif_clientdata,module, + "Unable to auto-correct subsampling values, likely corrupt JPEG compressed data in first strip/tile; auto-correcting skipped"); + _TIFFfree(m.buffer); } static int -JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData *data) +JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data) { - static const char module[] = "JPEGFixupTagsSubsamplingSec"; - uint8_t m; - while (1) - { - while (1) - { - if (!JPEGFixupTagsSubsamplingReadByte(data, &m)) - return (0); - if (m == 255) - break; - } - while (1) - { - if (!JPEGFixupTagsSubsamplingReadByte(data, &m)) - return (0); - if (m != 255) - break; - } - switch (m) - { - case JPEG_MARKER_SOI: - /* this type of marker has no data and should be skipped */ - break; - case JPEG_MARKER_COM: - case JPEG_MARKER_APP0: - case JPEG_MARKER_APP0 + 1: - case JPEG_MARKER_APP0 + 2: - case JPEG_MARKER_APP0 + 3: - case JPEG_MARKER_APP0 + 4: - case JPEG_MARKER_APP0 + 5: - case JPEG_MARKER_APP0 + 6: - case JPEG_MARKER_APP0 + 7: - case JPEG_MARKER_APP0 + 8: - case JPEG_MARKER_APP0 + 9: - case JPEG_MARKER_APP0 + 10: - case JPEG_MARKER_APP0 + 11: - case JPEG_MARKER_APP0 + 12: - case JPEG_MARKER_APP0 + 13: - case JPEG_MARKER_APP0 + 14: - case JPEG_MARKER_APP0 + 15: - case JPEG_MARKER_DQT: - case JPEG_MARKER_SOS: - case JPEG_MARKER_DHT: - case JPEG_MARKER_DRI: - /* this type of marker has data, but it has no use to us and - * should be skipped */ - { - uint16_t n; - if (!JPEGFixupTagsSubsamplingReadWord(data, &n)) - return (0); - if (n < 2) - return (0); - n -= 2; - if (n > 0) - JPEGFixupTagsSubsamplingSkip(data, n); - } - break; - case JPEG_MARKER_SOF0: /* Baseline sequential Huffman */ - case JPEG_MARKER_SOF1: /* Extended sequential Huffman */ - case JPEG_MARKER_SOF2: /* Progressive Huffman: normally not allowed - by TechNote, but that doesn't hurt - supporting it */ - case JPEG_MARKER_SOF9: /* Extended sequential arithmetic */ - case JPEG_MARKER_SOF10: /* Progressive arithmetic: normally not - allowed by TechNote, but that doesn't - hurt supporting it */ - /* this marker contains the subsampling factors we're scanning - * for */ - { - uint16_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) - return (0); - JPEGFixupTagsSubsamplingSkip(data, 7); - if (!JPEGFixupTagsSubsamplingReadByte(data, &p)) - return (0); - ph = (p >> 4); - pv = (p & 15); - JPEGFixupTagsSubsamplingSkip(data, 1); - for (o = 1; o < data->tif->tif_dir.td_samplesperpixel; o++) - { - JPEGFixupTagsSubsamplingSkip(data, 1); - if (!JPEGFixupTagsSubsamplingReadByte(data, &p)) - return (0); - if (p != 0x11) - { - TIFFWarningExtR(data->tif, module, - "Subsampling values inside JPEG " - "compressed data " - "have no TIFF equivalent, " - "auto-correction of TIFF " - "subsampling values failed"); - return (1); - } - JPEGFixupTagsSubsamplingSkip(data, 1); - } - if (((ph != 1) && (ph != 2) && (ph != 4)) || - ((pv != 1) && (pv != 2) && (pv != 4))) - { - TIFFWarningExtR(data->tif, module, - "Subsampling values inside JPEG " - "compressed data have no TIFF " - "equivalent, auto-correction of TIFF " - "subsampling values failed"); - return (1); - } - if ((ph != data->tif->tif_dir.td_ycbcrsubsampling[0]) || - (pv != data->tif->tif_dir.td_ycbcrsubsampling[1])) - { - TIFFWarningExtR( - data->tif, module, - "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; - } - } - return (1); - default: - return (0); - } - } + static const char module[] = "JPEGFixupTagsSubsamplingSec"; + uint8 m; + while (1) + { + while (1) + { + if (!JPEGFixupTagsSubsamplingReadByte(data,&m)) + return(0); + if (m==255) + break; + } + while (1) + { + if (!JPEGFixupTagsSubsamplingReadByte(data,&m)) + return(0); + if (m!=255) + break; + } + switch (m) + { + case JPEG_MARKER_SOI: + /* this type of marker has no data and should be skipped */ + break; + case JPEG_MARKER_COM: + case JPEG_MARKER_APP0: + case JPEG_MARKER_APP0+1: + case JPEG_MARKER_APP0+2: + case JPEG_MARKER_APP0+3: + case JPEG_MARKER_APP0+4: + case JPEG_MARKER_APP0+5: + case JPEG_MARKER_APP0+6: + case JPEG_MARKER_APP0+7: + case JPEG_MARKER_APP0+8: + case JPEG_MARKER_APP0+9: + case JPEG_MARKER_APP0+10: + case JPEG_MARKER_APP0+11: + case JPEG_MARKER_APP0+12: + case JPEG_MARKER_APP0+13: + case JPEG_MARKER_APP0+14: + case JPEG_MARKER_APP0+15: + case JPEG_MARKER_DQT: + case JPEG_MARKER_SOS: + case JPEG_MARKER_DHT: + case JPEG_MARKER_DRI: + /* this type of marker has data, but it has no use to us and should be skipped */ + { + uint16 n; + if (!JPEGFixupTagsSubsamplingReadWord(data,&n)) + return(0); + if (n<2) + return(0); + n-=2; + if (n>0) + JPEGFixupTagsSubsamplingSkip(data,n); + } + break; + case JPEG_MARKER_SOF0: /* Baseline sequential Huffman */ + case JPEG_MARKER_SOF1: /* Extended sequential Huffman */ + case JPEG_MARKER_SOF2: /* Progressive Huffman: normally not allowed by TechNote, but that doesn't hurt supporting it */ + case JPEG_MARKER_SOF9: /* Extended sequential arithmetic */ + case JPEG_MARKER_SOF10: /* Progressive arithmetic: normally not allowed by TechNote, but that doesn't hurt supporting it */ + /* this marker contains the subsampling factors we're scanning for */ + { + uint16 n; + uint16 o; + uint8 p; + uint8 ph,pv; + if (!JPEGFixupTagsSubsamplingReadWord(data,&n)) + return(0); + if (n!=8+data->tif->tif_dir.td_samplesperpixel*3) + return(0); + JPEGFixupTagsSubsamplingSkip(data,7); + if (!JPEGFixupTagsSubsamplingReadByte(data,&p)) + return(0); + ph=(p>>4); + pv=(p&15); + JPEGFixupTagsSubsamplingSkip(data,1); + for (o=1; otif->tif_dir.td_samplesperpixel; o++) + { + JPEGFixupTagsSubsamplingSkip(data,1); + if (!JPEGFixupTagsSubsamplingReadByte(data,&p)) + return(0); + if (p!=0x11) + { + TIFFWarningExt(data->tif->tif_clientdata,module, + "Subsampling values inside JPEG compressed data have no TIFF equivalent, auto-correction of TIFF subsampling values failed"); + return(1); + } + JPEGFixupTagsSubsamplingSkip(data,1); + } + if (((ph!=1)&&(ph!=2)&&(ph!=4))||((pv!=1)&&(pv!=2)&&(pv!=4))) + { + TIFFWarningExt(data->tif->tif_clientdata,module, + "Subsampling values inside JPEG compressed data have no TIFF equivalent, auto-correction of TIFF subsampling values failed"); + return(1); + } + 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); + data->tif->tif_dir.td_ycbcrsubsampling[0]=ph; + data->tif->tif_dir.td_ycbcrsubsampling[1]=pv; + } + } + return(1); + default: + return(0); + } + } } static int -JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData *data, - uint8_t *result) +JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result) { - if (data->bufferbytesleft == 0) - { - uint32_t m; - if (data->filebytesleft == 0) - return (0); - if (!data->filepositioned) - { - if (TIFFSeekFile(data->tif, data->fileoffset, SEEK_SET) == - (toff_t)-1) - { - return 0; - } - data->filepositioned = 1; - } - m = data->buffersize; - 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); - data->buffercurrentbyte = data->buffer; - data->bufferbytesleft = m; - data->fileoffset += m; - data->filebytesleft -= m; - } - *result = *data->buffercurrentbyte; - data->buffercurrentbyte++; - data->bufferbytesleft--; - return (1); + if (data->bufferbytesleft==0) + { + uint32 m; + if (data->filebytesleft==0) + return(0); + if (!data->filepositioned) + { + if (TIFFSeekFile(data->tif,data->fileoffset,SEEK_SET) == (toff_t)-1) + { + return 0; + } + data->filepositioned=1; + } + m=data->buffersize; + if ((uint64)m>data->filebytesleft) + m=(uint32)data->filebytesleft; + assert(m<0x80000000UL); + if (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m) + return(0); + data->buffercurrentbyte=data->buffer; + data->bufferbytesleft=m; + data->fileoffset+=m; + data->filebytesleft-=m; + } + *result=*data->buffercurrentbyte; + data->buffercurrentbyte++; + data->bufferbytesleft--; + return(1); } static int -JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData *data, - uint16_t *result) +JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result) { - uint8_t ma; - uint8_t mb; - if (!JPEGFixupTagsSubsamplingReadByte(data, &ma)) - return (0); - if (!JPEGFixupTagsSubsamplingReadByte(data, &mb)) - return (0); - *result = (ma << 8) | mb; - return (1); + uint8 ma; + uint8 mb; + if (!JPEGFixupTagsSubsamplingReadByte(data,&ma)) + return(0); + if (!JPEGFixupTagsSubsamplingReadByte(data,&mb)) + return(0); + *result=(ma<<8)|mb; + return(1); } static void -JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData *data, - uint16_t skiplength) +JPEGFixupTagsSubsamplingSkip(struct JPEGFixupTagsSubsamplingData* data, uint16 skiplength) { - if ((uint32_t)skiplength <= data->bufferbytesleft) - { - data->buffercurrentbyte += skiplength; - data->bufferbytesleft -= skiplength; - } - else - { - uint16_t m; - m = (uint16_t)(skiplength - data->bufferbytesleft); - if (m <= data->filebytesleft) - { - data->bufferbytesleft = 0; - data->fileoffset += m; - data->filebytesleft -= m; - data->filepositioned = 0; - } - else - { - data->bufferbytesleft = 0; - data->filebytesleft = 0; - } - } + if ((uint32)skiplength<=data->bufferbytesleft) + { + data->buffercurrentbyte+=skiplength; + data->bufferbytesleft-=skiplength; + } + else + { + uint16 m; + m=(uint16)(skiplength-data->bufferbytesleft); + if (m<=data->filebytesleft) + { + data->bufferbytesleft=0; + data->fileoffset+=m; + data->filebytesleft-=m; + data->filepositioned=0; + } + else + { + data->bufferbytesleft=0; + data->filebytesleft=0; + } + } } #endif -static int JPEGSetupDecode(TIFF *tif) -{ - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; -#if defined(JPEG_DUAL_MODE_8_12) && !defined(FROM_TIF_JPEG_12) - if (tif->tif_dir.td_bitspersample == 12) - { - /* We pass a pointer to a copy of otherSettings, since */ - /* TIFFReInitJPEG_12() will clear sp */ - JPEGOtherSettings savedOtherSettings = sp->otherSettings; - return TIFFReInitJPEG_12(tif, &savedOtherSettings, COMPRESSION_JPEG, 0); - } +static int +JPEGSetupDecode(TIFF* tif) +{ + JPEGState* sp = JState(tif); + TIFFDirectory *td = &tif->tif_dir; + +#if defined(JPEG_DUAL_MODE_8_12) && !defined(TIFFInitJPEG) + if( tif->tif_dir.td_bitspersample == 12 ) + return TIFFReInitJPEG_12( tif, COMPRESSION_JPEG, 0 ); #endif - JPEGInitializeLibJPEG(tif, TRUE); + JPEGInitializeLibJPEG( tif, TRUE ); - assert(sp != NULL); - assert(sp->cinfo.comm.is_decompressor); + assert(sp != NULL); + assert(sp->cinfo.comm.is_decompressor); - /* Read JPEGTables if it is present */ - if (TIFFFieldSet(tif, FIELD_JPEGTABLES)) - { - TIFFjpeg_tables_src(sp); - if (TIFFjpeg_read_header(sp, FALSE) != JPEG_HEADER_TABLES_ONLY) - { - TIFFErrorExtR(tif, "JPEGSetupDecode", "Bogus JPEGTables field"); - return (0); - } - } + /* Read JPEGTables if it is present */ + if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) { + TIFFjpeg_tables_src(sp); + if(TIFFjpeg_read_header(sp,FALSE) != JPEG_HEADER_TABLES_ONLY) { + TIFFErrorExt(tif->tif_clientdata, "JPEGSetupDecode", "Bogus JPEGTables field"); + return (0); + } + } - /* Grab parameters that are same for all strips/tiles */ - sp->photometric = td->td_photometric; - switch (sp->photometric) - { - case PHOTOMETRIC_YCBCR: - sp->h_sampling = td->td_ycbcrsubsampling[0]; - sp->v_sampling = td->td_ycbcrsubsampling[1]; - break; - default: - /* TIFF 6.0 forbids subsampling of all other color spaces */ - sp->h_sampling = 1; - sp->v_sampling = 1; - break; - } + /* Grab parameters that are same for all strips/tiles */ + sp->photometric = td->td_photometric; + switch (sp->photometric) { + case PHOTOMETRIC_YCBCR: + sp->h_sampling = td->td_ycbcrsubsampling[0]; + sp->v_sampling = td->td_ycbcrsubsampling[1]; + break; + default: + /* TIFF 6.0 forbids subsampling of all other color spaces */ + sp->h_sampling = 1; + sp->v_sampling = 1; + break; + } - /* Set up for reading normal data */ - TIFFjpeg_data_src(sp); - tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */ - return (1); + /* Set up for reading normal data */ + TIFFjpeg_data_src(sp); + tif->tif_postdecode = _TIFFNoPostDecode; /* override byte swapping */ + return (1); } /* Returns 1 if the full strip should be read, even when doing scanline per */ @@ -1153,14 +1056,14 @@ static int JPEGSetupDecode(TIFF *tif) /* Only reads tif->tif_dir.td_bitspersample, tif->tif_rawdata and */ /* tif->tif_rawcc members. */ /* Can be called independently of the usual setup/predecode/decode states */ -int TIFFJPEGIsFullStripRequired(TIFF *tif) +int TIFFJPEGIsFullStripRequired(TIFF* tif) { int ret; JPEGState state; -#if defined(JPEG_DUAL_MODE_8_12) && !defined(FROM_TIF_JPEG_12) - if (tif->tif_dir.td_bitspersample == 12) - return TIFFJPEGIsFullStripRequired_12(tif); +#if defined(JPEG_DUAL_MODE_8_12) && !defined(TIFFJPEGIsFullStripRequired) + if( tif->tif_dir.td_bitspersample == 12 ) + return TIFFJPEGIsFullStripRequired_12( tif ); #endif memset(&state, 0, sizeof(JPEGState)); @@ -1185,271 +1088,233 @@ int TIFFJPEGIsFullStripRequired(TIFF *tif) /* * Set up for decoding a strip or tile. */ -/*ARGSUSED*/ static int JPEGPreDecode(TIFF *tif, uint16_t s) +/*ARGSUSED*/ static int +JPEGPreDecode(TIFF* tif, uint16 s) { - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "JPEGPreDecode"; - uint32_t segment_width, segment_height; - int downsampled_output; - int ci; + JPEGState *sp = JState(tif); + TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "JPEGPreDecode"; + uint32 segment_width, segment_height; + int downsampled_output; + int ci; - assert(sp != NULL); + assert(sp != NULL); + + if (sp->cinfo.comm.is_decompressor == 0) + { + tif->tif_setupdecode( tif ); + } + + assert(sp->cinfo.comm.is_decompressor); + /* + * Reset decoder state from any previous strip/tile, + * in case application didn't read the whole strip. + */ + if (!TIFFjpeg_abort(sp)) + return (0); + /* + * Read the header for this strip/tile. + */ + + if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) + return (0); - if (sp->cinfo.comm.is_decompressor == 0) - { - tif->tif_setupdecode(tif); - } + tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcc = sp->src.bytes_in_buffer; - assert(sp->cinfo.comm.is_decompressor); - /* - * Reset decoder state from any previous strip/tile, - * in case application didn't read the whole strip. - */ - if (!TIFFjpeg_abort(sp)) - return (0); - /* - * Read the header for this strip/tile. - */ - - if (TIFFjpeg_read_header(sp, TRUE) != JPEG_HEADER_OK) - return (0); - - tif->tif_rawcp = (uint8_t *)sp->src.next_input_byte; - tif->tif_rawcc = sp->src.bytes_in_buffer; - - /* - * Check image parameters and set decompression parameters. - */ - if (isTiled(tif)) - { - segment_width = td->td_tilewidth; - segment_height = td->td_tilelength; - sp->bytesperline = TIFFTileRowSize(tif); - } - else - { - segment_width = td->td_imagewidth; - segment_height = td->td_imagelength - tif->tif_row; - if (segment_height > td->td_rowsperstrip) - segment_height = td->td_rowsperstrip; - sp->bytesperline = TIFFScanlineSize(tif); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) - { - /* - * For PC 2, scale down the expected strip/tile size - * to match a downsampled component - */ - segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); - segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); - } - if (sp->cinfo.d.image_width < segment_width || - sp->cinfo.d.image_height < segment_height) - { - TIFFWarningExtR(tif, module, - "Improper JPEG strip/tile size, " - "expected %" PRIu32 "x%" PRIu32 ", got %ux%u", - segment_width, segment_height, sp->cinfo.d.image_width, - sp->cinfo.d.image_height); - } - if (sp->cinfo.d.image_width == segment_width && - sp->cinfo.d.image_height > segment_height && - tif->tif_row + segment_height == td->td_imagelength && !isTiled(tif)) - { - /* Some files have a last strip, that should be truncated, */ - /* but their JPEG codestream has still the maximum strip */ - /* height. Warn about this as this is non compliant, but */ - /* we can safely recover from that. */ - TIFFWarningExtR(tif, module, - "JPEG strip size exceeds expected dimensions," - " expected %" PRIu32 "x%" PRIu32 ", got %ux%u", - segment_width, segment_height, sp->cinfo.d.image_width, - sp->cinfo.d.image_height); - } - else if (sp->cinfo.d.image_width > segment_width || - sp->cinfo.d.image_height > segment_height) - { - /* - * This case could be dangerous, if the strip or tile size has - * been reported as less than the amount of data jpeg will - * return, some potential security issues arise. Catch this - * case and error out. - */ - TIFFErrorExtR(tif, module, - "JPEG strip/tile size exceeds expected dimensions," - " expected %" PRIu32 "x%" PRIu32 ", got %ux%u", - segment_width, segment_height, sp->cinfo.d.image_width, - sp->cinfo.d.image_height); - return (0); - } - if (sp->cinfo.d.num_components != - (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel - : 1)) - { - TIFFErrorExtR(tif, module, "Improper JPEG component count"); - return (0); - } + /* + * Check image parameters and set decompression parameters. + */ + if (isTiled(tif)) { + segment_width = td->td_tilewidth; + segment_height = td->td_tilelength; + sp->bytesperline = TIFFTileRowSize(tif); + } else { + segment_width = td->td_imagewidth; + segment_height = td->td_imagelength - tif->tif_row; + if (segment_height > td->td_rowsperstrip) + segment_height = td->td_rowsperstrip; + sp->bytesperline = TIFFScanlineSize(tif); + } + if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) { + /* + * For PC 2, scale down the expected strip/tile size + * to match a downsampled component + */ + segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); + segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); + } + if (sp->cinfo.d.image_width < segment_width || + sp->cinfo.d.image_height < segment_height) { + TIFFWarningExt(tif->tif_clientdata, module, + "Improper JPEG strip/tile size, " + "expected %dx%d, got %dx%d", + segment_width, segment_height, + sp->cinfo.d.image_width, + sp->cinfo.d.image_height); + } + if( sp->cinfo.d.image_width == segment_width && + sp->cinfo.d.image_height > segment_height && + tif->tif_row + segment_height == td->td_imagelength && + !isTiled(tif) ) { + /* Some files have a last strip, that should be truncated, */ + /* but their JPEG codestream has still the maximum strip */ + /* height. Warn about this as this is non compliant, but */ + /* we can safely recover from that. */ + TIFFWarningExt(tif->tif_clientdata, module, + "JPEG strip size exceeds expected dimensions," + " expected %dx%d, got %dx%d", + segment_width, segment_height, + sp->cinfo.d.image_width, sp->cinfo.d.image_height); + } + else if (sp->cinfo.d.image_width > segment_width || + sp->cinfo.d.image_height > segment_height) { + /* + * This case could be dangerous, if the strip or tile size has + * been reported as less than the amount of data jpeg will + * return, some potential security issues arise. Catch this + * case and error out. + */ + TIFFErrorExt(tif->tif_clientdata, module, + "JPEG strip/tile size exceeds expected dimensions," + " expected %dx%d, got %dx%d", + segment_width, segment_height, + sp->cinfo.d.image_width, sp->cinfo.d.image_height); + return (0); + } + if (sp->cinfo.d.num_components != + (td->td_planarconfig == PLANARCONFIG_CONTIG ? + td->td_samplesperpixel : 1)) { + TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG component count"); + return (0); + } #ifdef JPEG_LIB_MK1 - if (12 != td->td_bitspersample && 8 != td->td_bitspersample) - { - TIFFErrorExtR(tif, module, "Improper JPEG data precision"); - return (0); - } - sp->cinfo.d.data_precision = td->td_bitspersample; - sp->cinfo.d.bits_in_jsample = td->td_bitspersample; + if (12 != td->td_bitspersample && 8 != td->td_bitspersample) { + TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG data precision"); + return (0); + } + sp->cinfo.d.data_precision = td->td_bitspersample; + sp->cinfo.d.bits_in_jsample = td->td_bitspersample; #else - if (sp->cinfo.d.data_precision != td->td_bitspersample) - { - TIFFErrorExtR(tif, module, "Improper JPEG data precision"); - return (0); - } + if (sp->cinfo.d.data_precision != td->td_bitspersample) { + TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG data precision"); + return (0); + } #endif - if (sp->cinfo.d.progressive_mode && - !sp->otherSettings.has_warned_about_progressive_mode) - { - TIFFWarningExtR(tif, module, - "The JPEG strip/tile is encoded with progressive mode, " - "which is normally not legal for JPEG-in-TIFF.\n" - "libtiff should be able to decode it, but it might " - "cause compatibility issues with other readers"); - sp->otherSettings.has_warned_about_progressive_mode = TRUE; - } - - /* In some cases, libjpeg needs to allocate a lot of memory */ - /* http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf - */ - if (TIFFjpeg_has_multiple_scans(sp)) - { - /* In this case libjpeg will need to allocate memory or backing */ - /* store for all coefficients */ - /* See call to jinit_d_coef_controller() from master_selection() */ - /* in libjpeg */ - - /* 1 MB for regular libjpeg usage */ - toff_t nRequiredMemory = 1024 * 1024; - - for (ci = 0; ci < sp->cinfo.d.num_components; ci++) + /* In some cases, libjpeg needs to allocate a lot of memory */ + /* http://www.libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf */ + if( TIFFjpeg_has_multiple_scans(sp) ) { - const jpeg_component_info *compptr = &(sp->cinfo.d.comp_info[ci]); - if (compptr->h_samp_factor > 0 && compptr->v_samp_factor > 0) + /* In this case libjpeg will need to allocate memory or backing */ + /* store for all coefficients */ + /* See call to jinit_d_coef_controller() from master_selection() */ + /* in libjpeg */ + + /* 1 MB for regular libjpeg usage */ + toff_t nRequiredMemory = 1024 * 1024; + + for (ci = 0; ci < sp->cinfo.d.num_components; ci++) { + const jpeg_component_info *compptr = &(sp->cinfo.d.comp_info[ci]); + if( compptr->h_samp_factor > 0 && compptr->v_samp_factor > 0 ) + { + nRequiredMemory += (toff_t)( + ((compptr->width_in_blocks + compptr->h_samp_factor - 1) / compptr->h_samp_factor)) * + ((compptr->height_in_blocks + compptr->v_samp_factor - 1) / compptr->v_samp_factor) * + sizeof(JBLOCK); + } + } + + if( sp->cinfo.d.mem->max_memory_to_use > 0 && + nRequiredMemory > (toff_t)(sp->cinfo.d.mem->max_memory_to_use) && + getenv("LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC") == NULL ) { - nRequiredMemory += - (toff_t)(((compptr->width_in_blocks + - compptr->h_samp_factor - 1) / - compptr->h_samp_factor)) * - ((compptr->height_in_blocks + compptr->v_samp_factor - 1) / - compptr->v_samp_factor) * - sizeof(JBLOCK); + 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. " + "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)); + return 0; } } - if (sp->cinfo.d.mem->max_memory_to_use > 0 && - nRequiredMemory > (toff_t)(sp->cinfo.d.mem->max_memory_to_use) && - getenv("LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC") == NULL) - { - TIFFErrorExtR( - tif, module, - "Reading this image would require libjpeg to allocate " - "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 '%" PRIu64 "M'", - nRequiredMemory, sp->cinfo.d.mem->max_memory_to_use, - (nRequiredMemory + 1000000u - 1u) / 1000000u); - return 0; - } - } - - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - { - /* Component 0 should have expected sampling factors */ - if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || - sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) - { - TIFFErrorExtR(tif, module, - "Improper JPEG sampling factors %d,%d\n" - "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); - return (0); - } - /* Rest should have sampling factors 1,1 */ - for (ci = 1; ci < sp->cinfo.d.num_components; ci++) - { - if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 || - sp->cinfo.d.comp_info[ci].v_samp_factor != 1) - { - TIFFErrorExtR(tif, module, "Improper JPEG sampling factors"); - return (0); - } - } - } - else - { - /* PC 2's single component should have sampling factors 1,1 */ - if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 || - sp->cinfo.d.comp_info[0].v_samp_factor != 1) - { - TIFFErrorExtR(tif, module, "Improper JPEG sampling factors"); - return (0); - } - } - downsampled_output = FALSE; - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - sp->photometric == PHOTOMETRIC_YCBCR && - sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB) - { - /* Convert YCbCr to RGB */ - sp->cinfo.d.jpeg_color_space = JCS_YCbCr; - sp->cinfo.d.out_color_space = JCS_RGB; - } - else - { - /* Suppress colorspace handling */ - sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; - sp->cinfo.d.out_color_space = JCS_UNKNOWN; - if (td->td_planarconfig == PLANARCONFIG_CONTIG && - (sp->h_sampling != 1 || sp->v_sampling != 1)) - downsampled_output = TRUE; - /* XXX what about up-sampling? */ - } - if (downsampled_output) - { - /* Need to use raw-data interface to libjpeg */ - sp->cinfo.d.raw_data_out = TRUE; + if (td->td_planarconfig == PLANARCONFIG_CONTIG) { + /* Component 0 should have expected sampling factors */ + if (sp->cinfo.d.comp_info[0].h_samp_factor != sp->h_sampling || + sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) { + TIFFErrorExt(tif->tif_clientdata, module, + "Improper JPEG sampling factors %d,%d\n" + "Apparently should be %d,%d.", + sp->cinfo.d.comp_info[0].h_samp_factor, + sp->cinfo.d.comp_info[0].v_samp_factor, + sp->h_sampling, sp->v_sampling); + return (0); + } + /* Rest should have sampling factors 1,1 */ + for (ci = 1; ci < sp->cinfo.d.num_components; ci++) { + if (sp->cinfo.d.comp_info[ci].h_samp_factor != 1 || + sp->cinfo.d.comp_info[ci].v_samp_factor != 1) { + TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG sampling factors"); + return (0); + } + } + } else { + /* PC 2's single component should have sampling factors 1,1 */ + if (sp->cinfo.d.comp_info[0].h_samp_factor != 1 || + sp->cinfo.d.comp_info[0].v_samp_factor != 1) { + TIFFErrorExt(tif->tif_clientdata, module, "Improper JPEG sampling factors"); + return (0); + } + } + downsampled_output = FALSE; + if (td->td_planarconfig == PLANARCONFIG_CONTIG && + sp->photometric == PHOTOMETRIC_YCBCR && + sp->jpegcolormode == JPEGCOLORMODE_RGB) { + /* Convert YCbCr to RGB */ + sp->cinfo.d.jpeg_color_space = JCS_YCbCr; + sp->cinfo.d.out_color_space = JCS_RGB; + } else { + /* Suppress colorspace handling */ + sp->cinfo.d.jpeg_color_space = JCS_UNKNOWN; + sp->cinfo.d.out_color_space = JCS_UNKNOWN; + if (td->td_planarconfig == PLANARCONFIG_CONTIG && + (sp->h_sampling != 1 || sp->v_sampling != 1)) + downsampled_output = TRUE; + /* XXX what about up-sampling? */ + } + if (downsampled_output) { + /* Need to use raw-data interface to libjpeg */ + sp->cinfo.d.raw_data_out = TRUE; #if JPEG_LIB_VERSION >= 70 - sp->cinfo.d.do_fancy_upsampling = FALSE; + sp->cinfo.d.do_fancy_upsampling = FALSE; #endif /* JPEG_LIB_VERSION >= 70 */ - tif->tif_decoderow = DecodeRowError; - tif->tif_decodestrip = JPEGDecodeRaw; - tif->tif_decodetile = JPEGDecodeRaw; - } - else - { - /* Use normal interface to libjpeg */ - sp->cinfo.d.raw_data_out = FALSE; - tif->tif_decoderow = JPEGDecode; - tif->tif_decodestrip = JPEGDecode; - tif->tif_decodetile = JPEGDecode; - } - /* Start JPEG decompressor */ - if (!TIFFjpeg_start_decompress(sp)) - return (0); - /* Allocate downsampled-data buffers if needed */ - if (downsampled_output) - { - if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info, - sp->cinfo.d.num_components)) - return (0); - sp->scancount = DCTSIZE; /* mark buffer empty */ - } - return (1); + tif->tif_decoderow = DecodeRowError; + tif->tif_decodestrip = JPEGDecodeRaw; + tif->tif_decodetile = JPEGDecodeRaw; + } else { + /* Use normal interface to libjpeg */ + sp->cinfo.d.raw_data_out = FALSE; + tif->tif_decoderow = JPEGDecode; + tif->tif_decodestrip = JPEGDecode; + tif->tif_decodetile = JPEGDecode; + } + /* Start JPEG decompressor */ + if (!TIFFjpeg_start_decompress(sp)) + return (0); + /* Allocate downsampled-data buffers if needed */ + if (downsampled_output) { + if (!alloc_downsampled_buffers(tif, sp->cinfo.d.comp_info, + sp->cinfo.d.num_components)) + return (0); + sp->scancount = DCTSIZE; /* mark buffer empty */ + } + return (1); } /* @@ -1457,179 +1322,177 @@ int TIFFJPEGIsFullStripRequired(TIFF *tif) * "Standard" case: returned data is not downsampled. */ #if !JPEG_LIB_MK1_OR_12BIT -static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s) +static int +JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - JPEGState *sp = JState(tif); - tmsize_t nrows; - (void)s; + JPEGState *sp = JState(tif); + tmsize_t nrows; + (void) s; - /* - ** Update available information, buffer may have been refilled - ** between decode requests - */ - sp->src.next_input_byte = (const JOCTET *)tif->tif_rawcp; - sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc; + /* + ** Update available information, buffer may have been refilled + ** between decode requests + */ + sp->src.next_input_byte = (const JOCTET*) tif->tif_rawcp; + sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; - if (sp->bytesperline == 0) - return 0; + if( sp->bytesperline == 0 ) + return 0; + + nrows = cc / sp->bytesperline; + if (cc % sp->bytesperline) + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + "fractional scanline not read"); - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarningExtR(tif, tif->tif_name, "fractional scanline not read"); + if( nrows > (tmsize_t) sp->cinfo.d.image_height ) + nrows = sp->cinfo.d.image_height; - if (nrows > (tmsize_t)sp->cinfo.d.image_height) - nrows = sp->cinfo.d.image_height; - - /* data is expected to be read in multiples of a scanline */ - if (nrows) - { - do + /* data is expected to be read in multiples of a scanline */ + if (nrows) { - /* - * In the libjpeg6b-9a 8bit case. We read directly into - * the TIFF buffer. - */ - JSAMPROW bufptr = (JSAMPROW)buf; + do + { + /* + * In the libjpeg6b-9a 8bit case. We read directly into + * the TIFF buffer. + */ + JSAMPROW bufptr = (JSAMPROW)buf; - if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1) - return (0); + if (TIFFjpeg_read_scanlines(sp, &bufptr, 1) != 1) + return (0); - ++tif->tif_row; - buf += sp->bytesperline; - cc -= sp->bytesperline; - } while (--nrows > 0); - } + ++tif->tif_row; + buf += sp->bytesperline; + cc -= sp->bytesperline; + } while (--nrows > 0); + } - /* Update information on consumed data */ - 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. */ - return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height || - TIFFjpeg_finish_decompress(sp); + /* Update information on consumed data */ + tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcc = sp->src.bytes_in_buffer; + + /* Close down the decompressor if we've finished the strip or tile. */ + return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height + || TIFFjpeg_finish_decompress(sp); } #endif /* !JPEG_LIB_MK1_OR_12BIT */ #if JPEG_LIB_MK1_OR_12BIT -/*ARGSUSED*/ static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, - uint16_t s) +/*ARGSUSED*/ static int +JPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - JPEGState *sp = JState(tif); - tmsize_t nrows; - (void)s; - - /* - ** Update available information, buffer may have been refilled - ** between decode requests - */ - sp->src.next_input_byte = (const JOCTET *)tif->tif_rawcp; - sp->src.bytes_in_buffer = (size_t)tif->tif_rawcc; - - if (sp->bytesperline == 0) - return 0; - - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarningExtR(tif, tif->tif_name, "fractional scanline not read"); - - if (nrows > (tmsize_t)sp->cinfo.d.image_height) - nrows = sp->cinfo.d.image_height; - - /* data is expected to be read in multiples of a scanline */ - if (nrows) - { - TIFF_JSAMPROW line_work_buf = NULL; + JPEGState *sp = JState(tif); + tmsize_t nrows; + (void) s; /* - * For 6B, only use temporary buffer for 12 bit imagery. - * For Mk1 always use it. - */ - if (sp->cinfo.d.data_precision == 12) + ** Update available information, buffer may have been refilled + ** between decode requests + */ + sp->src.next_input_byte = (const JOCTET*) tif->tif_rawcp; + sp->src.bytes_in_buffer = (size_t) tif->tif_rawcc; + + if( sp->bytesperline == 0 ) + return 0; + + nrows = cc / sp->bytesperline; + if (cc % sp->bytesperline) + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + "fractional scanline not read"); + + if( nrows > (tmsize_t) sp->cinfo.d.image_height ) + nrows = sp->cinfo.d.image_height; + + /* data is expected to be read in multiples of a scanline */ + if (nrows) { - line_work_buf = (TIFF_JSAMPROW)_TIFFmallocExt( - tif, sizeof(short) * sp->cinfo.d.output_width * - sp->cinfo.d.num_components); + JSAMPROW line_work_buf = NULL; + + /* + * For 6B, only use temporary buffer for 12 bit imagery. + * For Mk1 always use it. + */ + if( sp->cinfo.d.data_precision == 12 ) + { + line_work_buf = (JSAMPROW) + _TIFFmalloc(sizeof(short) * sp->cinfo.d.output_width + * sp->cinfo.d.num_components ); + } + + do + { + if( line_work_buf != NULL ) + { + /* + * In the MK1 case, we always read into a 16bit + * buffer, and then pack down to 12bit or 8bit. + * In 6B case we only read into 16 bit buffer + * for 12bit data, which we need to repack. + */ + if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1) + return (0); + + if( sp->cinfo.d.data_precision == 12 ) + { + int value_pairs = (sp->cinfo.d.output_width + * sp->cinfo.d.num_components) / 2; + int iPair; + + for( iPair = 0; iPair < value_pairs; iPair++ ) + { + unsigned char *out_ptr = + ((unsigned char *) buf) + iPair * 3; + JSAMPLE *in_ptr = line_work_buf + iPair * 2; + + out_ptr[0] = (unsigned char)((in_ptr[0] & 0xff0) >> 4); + out_ptr[1] = (unsigned char)(((in_ptr[0] & 0xf) << 4) + | ((in_ptr[1] & 0xf00) >> 8)); + out_ptr[2] = (unsigned char)(((in_ptr[1] & 0xff) >> 0)); + } + } + else if( sp->cinfo.d.data_precision == 8 ) + { + int value_count = (sp->cinfo.d.output_width + * sp->cinfo.d.num_components); + int iValue; + + for( iValue = 0; iValue < value_count; iValue++ ) + { + ((unsigned char *) buf)[iValue] = + line_work_buf[iValue] & 0xff; + } + } + } + + ++tif->tif_row; + buf += sp->bytesperline; + cc -= sp->bytesperline; + } while (--nrows > 0); + + if( line_work_buf != NULL ) + _TIFFfree( line_work_buf ); } - do - { - if (line_work_buf != NULL) - { - /* - * In the MK1 case, we always read into a 16bit - * buffer, and then pack down to 12bit or 8bit. - * In 6B case we only read into 16 bit buffer - * for 12bit data, which we need to repack. - */ - if (TIFFjpeg_read_scanlines(sp, &line_work_buf, 1) != 1) - return (0); - - if (sp->cinfo.d.data_precision == 12) - { - int value_pairs = (sp->cinfo.d.output_width * - sp->cinfo.d.num_components) / - 2; - int iPair; - - for (iPair = 0; iPair < value_pairs; iPair++) - { - unsigned char *out_ptr = - ((unsigned char *)buf) + iPair * 3; - TIFF_JSAMPLE *in_ptr = line_work_buf + iPair * 2; - - out_ptr[0] = (unsigned char)((in_ptr[0] & 0xff0) >> 4); - out_ptr[1] = - (unsigned char)(((in_ptr[0] & 0xf) << 4) | - ((in_ptr[1] & 0xf00) >> 8)); - out_ptr[2] = (unsigned char)(((in_ptr[1] & 0xff) >> 0)); - } - } - else if (sp->cinfo.d.data_precision == 8) - { - int value_count = - (sp->cinfo.d.output_width * sp->cinfo.d.num_components); - int iValue; - - for (iValue = 0; iValue < value_count; iValue++) - { - ((unsigned char *)buf)[iValue] = - line_work_buf[iValue] & 0xff; - } - } - } - - ++tif->tif_row; - buf += sp->bytesperline; - cc -= sp->bytesperline; - } while (--nrows > 0); - - if (line_work_buf != NULL) - _TIFFfreeExt(tif, line_work_buf); - } - - /* Update information on consumed data */ - 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. */ - return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height || - TIFFjpeg_finish_decompress(sp); + /* Update information on consumed data */ + tif->tif_rawcp = (uint8*) sp->src.next_input_byte; + tif->tif_rawcc = sp->src.bytes_in_buffer; + + /* Close down the decompressor if we've finished the strip or tile. */ + return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height + || TIFFjpeg_finish_decompress(sp); } #endif /* JPEG_LIB_MK1_OR_12BIT */ -/*ARGSUSED*/ static int DecodeRowError(TIFF *tif, uint8_t *buf, tmsize_t cc, - uint16_t s) +/*ARGSUSED*/ static int +DecodeRowError(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - (void)buf; - (void)cc; - (void)s; + (void) buf; + (void) cc; + (void) s; - TIFFErrorExtR( - tif, "TIFFReadScanline", - "scanline oriented access is not supported for downsampled JPEG " - "compressed images, consider enabling TIFFTAG_JPEGCOLORMODE as " - "JPEGCOLORMODE_RGB."); + TIFFErrorExt(tif->tif_clientdata, "TIFFReadScanline", + "scanline oriented access is not supported for downsampled JPEG compressed images, consider enabling TIFF_JPEGCOLORMODE as JPEGCOLORMODE_RGB." ); return 0; } @@ -1637,1079 +1500,926 @@ static int JPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s) * Decode a chunk of pixels. * Returned data is downsampled per sampling factors. */ -/*ARGSUSED*/ static int JPEGDecodeRaw(TIFF *tif, uint8_t *buf, tmsize_t cc, - uint16_t s) +/*ARGSUSED*/ static int +JPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - JPEGState *sp = JState(tif); - tmsize_t nrows; - TIFFDirectory *td = &tif->tif_dir; - (void)s; + JPEGState *sp = JState(tif); + tmsize_t nrows; + TIFFDirectory *td = &tif->tif_dir; + (void) s; - nrows = sp->cinfo.d.image_height; - /* 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_t)nrows > td->td_imagelength - tif->tif_row && !isTiled(tif)) - nrows = td->td_imagelength - tif->tif_row; + nrows = sp->cinfo.d.image_height; + /* 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) ) + nrows = td->td_imagelength - tif->tif_row; + + /* data is expected to be read in multiples of a scanline */ + if ( nrows != 0 ) { + + /* Cb,Cr both have sampling factors 1, so this is correct */ + JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; + int samples_per_clump = sp->samplesperclump; #if defined(JPEG_LIB_MK1_OR_12BIT) - unsigned short *tmpbuf = NULL; + unsigned short* tmpbuf = _TIFFmalloc(sizeof(unsigned short) * + sp->cinfo.d.output_width * + sp->cinfo.d.num_components); + if(tmpbuf==NULL) { + TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", + "Out of memory"); + return 0; + } #endif - /* data is expected to be read in multiples of a scanline */ - if (nrows != 0) - { + do { + jpeg_component_info *compptr; + int ci, clumpoffset; - /* Cb,Cr both have sampling factors 1, so this is correct */ - JDIMENSION clumps_per_line = sp->cinfo.d.comp_info[1].downsampled_width; - int samples_per_clump = sp->samplesperclump; + if( cc < sp->bytesperline ) { + TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", + "application buffer not large enough for all data."); + return 0; + } + /* Reload downsampled-data buffer if needed */ + if (sp->scancount >= DCTSIZE) { + int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE; + if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n) + return (0); + sp->scancount = 0; + } + /* + * Fastest way to unseparate data is to make one pass + * over the scanline for each row of each component. + */ + clumpoffset = 0; /* first sample in clump */ + for (ci = 0, compptr = sp->cinfo.d.comp_info; + ci < sp->cinfo.d.num_components; + ci++, compptr++) { + int hsamp = compptr->h_samp_factor; + int vsamp = compptr->v_samp_factor; + int ypos; + + for (ypos = 0; ypos < vsamp; ypos++) { + JSAMPLE *inptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; + JDIMENSION nclump; #if defined(JPEG_LIB_MK1_OR_12BIT) - tmpbuf = _TIFFmallocExt(tif, sizeof(unsigned short) * - sp->cinfo.d.output_width * - sp->cinfo.d.num_components); - if (tmpbuf == NULL) - { - TIFFErrorExtR(tif, "JPEGDecodeRaw", "Out of memory"); - return 0; - } -#endif - - do - { - jpeg_component_info *compptr; - int ci, clumpoffset; - - if (cc < sp->bytesperline) - { - TIFFErrorExtR( - tif, "JPEGDecodeRaw", - "application buffer not large enough for all data."); - goto error; - } - - /* Reload downsampled-data buffer if needed */ - if (sp->scancount >= DCTSIZE) - { - int n = sp->cinfo.d.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_read_raw_data(sp, sp->ds_buffer, n) != n) - goto error; - sp->scancount = 0; - } - /* - * Fastest way to unseparate data is to make one pass - * over the scanline for each row of each component. - */ - clumpoffset = 0; /* first sample in clump */ - for (ci = 0, compptr = sp->cinfo.d.comp_info; - ci < sp->cinfo.d.num_components; ci++, compptr++) - { - int hsamp = compptr->h_samp_factor; - int vsamp = compptr->v_samp_factor; - int ypos; - - for (ypos = 0; ypos < vsamp; ypos++) - { - TIFF_JSAMPLE *inptr = - sp->ds_buffer[ci][sp->scancount * vsamp + ypos]; - JDIMENSION nclump; -#if defined(JPEG_LIB_MK1_OR_12BIT) - TIFF_JSAMPLE *outptr = (TIFF_JSAMPLE *)tmpbuf + clumpoffset; + JSAMPLE *outptr = (JSAMPLE*)tmpbuf + clumpoffset; #else - TIFF_JSAMPLE *outptr = (TIFF_JSAMPLE *)buf + clumpoffset; - if (cc < (tmsize_t)(clumpoffset + - (tmsize_t)samples_per_clump * - (clumps_per_line - 1) + - hsamp)) - { - TIFFErrorExtR( - tif, "JPEGDecodeRaw", - "application buffer not large enough for all data, " - "possible subsampling issue"); - goto error; - } + JSAMPLE *outptr = (JSAMPLE*)buf + clumpoffset; + if (cc < (tmsize_t)(clumpoffset + (tmsize_t)samples_per_clump*(clumps_per_line-1) + hsamp)) { + TIFFErrorExt(tif->tif_clientdata, "JPEGDecodeRaw", + "application buffer not large enough for all data, possible subsampling issue"); + return 0; + } #endif - if (hsamp == 1) - { - /* fast path for at least Cb and Cr */ - for (nclump = clumps_per_line; nclump-- > 0;) - { - outptr[0] = *inptr++; - outptr += samples_per_clump; - } - } - else - { - int xpos; + if (hsamp == 1) { + /* fast path for at least Cb and Cr */ + for (nclump = clumps_per_line; nclump-- > 0; ) { + outptr[0] = *inptr++; + outptr += samples_per_clump; + } + } else { + int xpos; - /* general case */ - for (nclump = clumps_per_line; nclump-- > 0;) - { - for (xpos = 0; xpos < hsamp; xpos++) - outptr[xpos] = *inptr++; - outptr += samples_per_clump; - } - } - clumpoffset += hsamp; - } - } + /* general case */ + for (nclump = clumps_per_line; nclump-- > 0; ) { + for (xpos = 0; xpos < hsamp; xpos++) + outptr[xpos] = *inptr++; + outptr += samples_per_clump; + } + } + clumpoffset += hsamp; + } + } #if defined(JPEG_LIB_MK1_OR_12BIT) - { - if (sp->cinfo.d.data_precision == 8) - { - int i = 0; - int len = - sp->cinfo.d.output_width * sp->cinfo.d.num_components; - for (i = 0; i < len; i++) - { - ((unsigned char *)buf)[i] = tmpbuf[i] & 0xff; - } - } - else - { /* 12-bit */ - int value_pairs = (sp->cinfo.d.output_width * - sp->cinfo.d.num_components) / - 2; - int iPair; - for (iPair = 0; iPair < value_pairs; iPair++) - { - unsigned char *out_ptr = - ((unsigned char *)buf) + iPair * 3; - JSAMPLE *in_ptr = (JSAMPLE *)(tmpbuf + iPair * 2); - out_ptr[0] = (unsigned char)((in_ptr[0] & 0xff0) >> 4); - out_ptr[1] = - (unsigned char)(((in_ptr[0] & 0xf) << 4) | - ((in_ptr[1] & 0xf00) >> 8)); - out_ptr[2] = (unsigned char)(((in_ptr[1] & 0xff) >> 0)); - } - } - } + { + if (sp->cinfo.d.data_precision == 8) + { + int i=0; + int len = sp->cinfo.d.output_width * sp->cinfo.d.num_components; + for (i=0; icinfo.d.output_width + * sp->cinfo.d.num_components) / 2; + int iPair; + for( iPair = 0; iPair < value_pairs; iPair++ ) + { + unsigned char *out_ptr = ((unsigned char *) buf) + iPair * 3; + JSAMPLE *in_ptr = (JSAMPLE *) (tmpbuf + iPair * 2); + out_ptr[0] = (unsigned char)((in_ptr[0] & 0xff0) >> 4); + out_ptr[1] = (unsigned char)(((in_ptr[0] & 0xf) << 4) + | ((in_ptr[1] & 0xf00) >> 8)); + out_ptr[2] = (unsigned char)(((in_ptr[1] & 0xff) >> 0)); + } + } + } #endif - sp->scancount++; - tif->tif_row += sp->v_sampling; + sp->scancount ++; + tif->tif_row += sp->v_sampling; - buf += sp->bytesperline; - cc -= sp->bytesperline; + buf += sp->bytesperline; + cc -= sp->bytesperline; - nrows -= sp->v_sampling; - } while (nrows > 0); + nrows -= sp->v_sampling; + } while (nrows > 0); #if defined(JPEG_LIB_MK1_OR_12BIT) - _TIFFfreeExt(tif, tmpbuf); + _TIFFfree(tmpbuf); #endif - } - /* Close down the decompressor if done. */ - return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height || - TIFFjpeg_finish_decompress(sp); + } -error: -#if defined(JPEG_LIB_MK1_OR_12BIT) - _TIFFfreeExt(tif, tmpbuf); -#endif - return 0; + /* Close down the decompressor if done. */ + return sp->cinfo.d.output_scanline < sp->cinfo.d.output_height + || TIFFjpeg_finish_decompress(sp); } + /* * JPEG Encoding. */ -static void unsuppress_quant_table(JPEGState *sp, int tblno) +static void +unsuppress_quant_table (JPEGState* sp, int tblno) { - JQUANT_TBL *qtbl; + JQUANT_TBL* qtbl; - if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) - qtbl->sent_table = FALSE; + if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) + qtbl->sent_table = FALSE; } -static void suppress_quant_table(JPEGState *sp, int tblno) +static void +suppress_quant_table (JPEGState* sp, int tblno) { - JQUANT_TBL *qtbl; + JQUANT_TBL* qtbl; - if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) - qtbl->sent_table = TRUE; + if ((qtbl = sp->cinfo.c.quant_tbl_ptrs[tblno]) != NULL) + qtbl->sent_table = TRUE; } -static void unsuppress_huff_table(JPEGState *sp, int tblno) +static void +unsuppress_huff_table (JPEGState* sp, int tblno) { - JHUFF_TBL *htbl; + JHUFF_TBL* htbl; - if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) - htbl->sent_table = FALSE; - if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) - htbl->sent_table = FALSE; + if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) + htbl->sent_table = FALSE; + if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) + htbl->sent_table = FALSE; } -static void suppress_huff_table(JPEGState *sp, int tblno) +static void +suppress_huff_table (JPEGState* sp, int tblno) { - JHUFF_TBL *htbl; + JHUFF_TBL* htbl; - if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) - htbl->sent_table = TRUE; - if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) - htbl->sent_table = TRUE; + if ((htbl = sp->cinfo.c.dc_huff_tbl_ptrs[tblno]) != NULL) + htbl->sent_table = TRUE; + if ((htbl = sp->cinfo.c.ac_huff_tbl_ptrs[tblno]) != NULL) + htbl->sent_table = TRUE; } -static int prepare_JPEGTables(TIFF *tif) +static int +prepare_JPEGTables(TIFF* tif) { - JPEGState *sp = JState(tif); + JPEGState* sp = JState(tif); - /* Initialize quant tables for current quality setting */ - if (!TIFFjpeg_set_quality(sp, sp->otherSettings.jpegquality, FALSE)) - return (0); - /* Mark only the tables we want for output */ - /* NB: chrominance tables are currently used only with YCbCr */ - if (!TIFFjpeg_suppress_tables(sp, TRUE)) - return (0); - if (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_QUANT) - { - unsuppress_quant_table(sp, 0); - if (sp->photometric == PHOTOMETRIC_YCBCR) - unsuppress_quant_table(sp, 1); - } - if (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_HUFF) - { - unsuppress_huff_table(sp, 0); - if (sp->photometric == PHOTOMETRIC_YCBCR) - unsuppress_huff_table(sp, 1); - } - /* Direct libjpeg output into otherSettings.jpegtables */ - if (!TIFFjpeg_tables_dest(sp, tif)) - return (0); - /* Emit tables-only datastream */ - if (!TIFFjpeg_write_tables(sp)) - return (0); + /* Initialize quant tables for current quality setting */ + if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) + return (0); + /* Mark only the tables we want for output */ + /* NB: chrominance tables are currently used only with YCbCr */ + if (!TIFFjpeg_suppress_tables(sp, TRUE)) + return (0); + if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) { + unsuppress_quant_table(sp, 0); + if (sp->photometric == PHOTOMETRIC_YCBCR) + unsuppress_quant_table(sp, 1); + } + if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) { + unsuppress_huff_table(sp, 0); + if (sp->photometric == PHOTOMETRIC_YCBCR) + unsuppress_huff_table(sp, 1); + } + /* Direct libjpeg output into jpegtables */ + if (!TIFFjpeg_tables_dest(sp, tif)) + return (0); + /* Emit tables-only datastream */ + if (!TIFFjpeg_write_tables(sp)) + return (0); - return (1); + return (1); } -#if defined(JPEG_LIB_VERSION_MAJOR) && \ - (JPEG_LIB_VERSION_MAJOR > 9 || \ - (JPEG_LIB_VERSION_MAJOR == 9 && JPEG_LIB_VERSION_MINOR >= 4)) -/* This is a modified version of std_huff_tables() from jcparam.c - * in libjpeg-9d because it no longer initializes default Huffman - * tables in jpeg_set_defaults(). */ -static void TIFF_std_huff_tables(j_compress_ptr cinfo) +static int +JPEGSetupEncode(TIFF* tif) { + JPEGState* sp = JState(tif); + TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "JPEGSetupEncode"; - if (cinfo->dc_huff_tbl_ptrs[0] == NULL) - { - (void)jpeg_std_huff_table((j_common_ptr)cinfo, TRUE, 0); - } - if (cinfo->ac_huff_tbl_ptrs[0] == NULL) - { - (void)jpeg_std_huff_table((j_common_ptr)cinfo, FALSE, 0); - } - if (cinfo->dc_huff_tbl_ptrs[1] == NULL) - { - (void)jpeg_std_huff_table((j_common_ptr)cinfo, TRUE, 1); - } - if (cinfo->ac_huff_tbl_ptrs[1] == NULL) - { - (void)jpeg_std_huff_table((j_common_ptr)cinfo, FALSE, 1); - } -} +#if defined(JPEG_DUAL_MODE_8_12) && !defined(TIFFInitJPEG) + if( tif->tif_dir.td_bitspersample == 12 ) + return TIFFReInitJPEG_12( tif, COMPRESSION_JPEG, 1 ); #endif -static int JPEGSetupEncode(TIFF *tif) -{ - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "JPEGSetupEncode"; + JPEGInitializeLibJPEG( tif, FALSE ); -#if defined(JPEG_DUAL_MODE_8_12) && !defined(FROM_TIF_JPEG_12) - if (tif->tif_dir.td_bitspersample == 12) - { - /* We pass a pointer to a copy of otherSettings, since */ - /* TIFFReInitJPEG_12() will clear sp */ - JPEGOtherSettings savedOtherSettings = sp->otherSettings; - return TIFFReInitJPEG_12(tif, &savedOtherSettings, COMPRESSION_JPEG, 1); - } -#endif + assert(sp != NULL); + assert(!sp->cinfo.comm.is_decompressor); - JPEGInitializeLibJPEG(tif, FALSE); + sp->photometric = td->td_photometric; - assert(sp != NULL); - assert(!sp->cinfo.comm.is_decompressor); - - sp->photometric = td->td_photometric; - - /* - * Initialize all JPEG parameters to default values. - * Note that jpeg_set_defaults needs legal values for - * in_color_space and input_components. - */ - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - { - sp->cinfo.c.input_components = td->td_samplesperpixel; - if (sp->photometric == PHOTOMETRIC_YCBCR) - { - if (sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB) - { - sp->cinfo.c.in_color_space = JCS_RGB; - } - else - { - sp->cinfo.c.in_color_space = JCS_YCbCr; - } - } - else - { - if ((td->td_photometric == PHOTOMETRIC_MINISWHITE || - td->td_photometric == PHOTOMETRIC_MINISBLACK) && - td->td_samplesperpixel == 1) - sp->cinfo.c.in_color_space = JCS_GRAYSCALE; - else if (td->td_photometric == PHOTOMETRIC_RGB && - td->td_samplesperpixel == 3) - sp->cinfo.c.in_color_space = JCS_RGB; - else if (td->td_photometric == PHOTOMETRIC_SEPARATED && - td->td_samplesperpixel == 4) - sp->cinfo.c.in_color_space = JCS_CMYK; - else - sp->cinfo.c.in_color_space = JCS_UNKNOWN; - } - } - else - { - sp->cinfo.c.input_components = 1; - sp->cinfo.c.in_color_space = JCS_UNKNOWN; - } - if (!TIFFjpeg_set_defaults(sp)) - return (0); - - /* mozjpeg by default enables progressive JPEG, which is illegal in - * JPEG-in-TIFF */ - /* So explicitly disable it. */ - if (sp->cinfo.c.num_scans != 0 && - (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_HUFF) != 0) - { - /* it has been found that mozjpeg could create corrupt strips/tiles */ - /* in non optimize_coding mode. */ - TIFFWarningExtR( - tif, module, - "mozjpeg library likely detected. Disable emission of " - "Huffman tables in JpegTables tag, and use optimize_coding " - "to avoid potential issues"); - sp->otherSettings.jpegtablesmode &= ~JPEGTABLESMODE_HUFF; - } - sp->cinfo.c.num_scans = 0; - sp->cinfo.c.scan_info = NULL; - - /* Set per-file parameters */ - switch (sp->photometric) - { - case PHOTOMETRIC_YCBCR: - sp->h_sampling = td->td_ycbcrsubsampling[0]; - sp->v_sampling = td->td_ycbcrsubsampling[1]; - if (sp->h_sampling == 0 || sp->v_sampling == 0) - { - TIFFErrorExtR(tif, module, - "Invalig horizontal/vertical sampling value"); - return (0); - } - if (td->td_bitspersample > 16) - { - TIFFErrorExtR(tif, module, - "BitsPerSample %" PRIu16 " not allowed for JPEG", - td->td_bitspersample); - return (0); - } - - /* - * A ReferenceBlackWhite field *must* be present since the - * default value is inappropriate for YCbCr. Fill in the - * proper value if application didn't set it. - */ - { - float *ref; - if (!TIFFGetField(tif, TIFFTAG_REFERENCEBLACKWHITE, &ref)) + /* + * Initialize all JPEG parameters to default values. + * Note that jpeg_set_defaults needs legal values for + * in_color_space and input_components. + */ + if (td->td_planarconfig == PLANARCONFIG_CONTIG) { + sp->cinfo.c.input_components = td->td_samplesperpixel; + if (sp->photometric == PHOTOMETRIC_YCBCR) { + if (sp->jpegcolormode == JPEGCOLORMODE_RGB) { + sp->cinfo.c.in_color_space = JCS_RGB; + } else { + sp->cinfo.c.in_color_space = JCS_YCbCr; + } + } else { + if ((td->td_photometric == PHOTOMETRIC_MINISWHITE || td->td_photometric == PHOTOMETRIC_MINISBLACK) && td->td_samplesperpixel == 1) + sp->cinfo.c.in_color_space = JCS_GRAYSCALE; + else if (td->td_photometric == PHOTOMETRIC_RGB && td->td_samplesperpixel == 3) + sp->cinfo.c.in_color_space = JCS_RGB; + else if (td->td_photometric == PHOTOMETRIC_SEPARATED && td->td_samplesperpixel == 4) + sp->cinfo.c.in_color_space = JCS_CMYK; + else + sp->cinfo.c.in_color_space = JCS_UNKNOWN; + } + } else { + sp->cinfo.c.input_components = 1; + sp->cinfo.c.in_color_space = JCS_UNKNOWN; + } + if (!TIFFjpeg_set_defaults(sp)) + return (0); + /* Set per-file parameters */ + switch (sp->photometric) { + case PHOTOMETRIC_YCBCR: + sp->h_sampling = td->td_ycbcrsubsampling[0]; + sp->v_sampling = td->td_ycbcrsubsampling[1]; + if( sp->h_sampling == 0 || sp->v_sampling == 0 ) { - float refbw[6]; - long top = 1L << td->td_bitspersample; - refbw[0] = 0; - refbw[1] = (float)(top - 1L); - refbw[2] = (float)(top >> 1); - refbw[3] = refbw[1]; - refbw[4] = refbw[2]; - refbw[5] = refbw[1]; - TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, refbw); + TIFFErrorExt(tif->tif_clientdata, module, + "Invalig horizontal/vertical sampling value"); + return (0); + } + if( td->td_bitspersample > 16 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "BitsPerSample %d not allowed for JPEG", + td->td_bitspersample); + return (0); } - } - break; - case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */ - case PHOTOMETRIC_MASK: - TIFFErrorExtR(tif, module, - "PhotometricInterpretation %" PRIu16 - " not allowed for JPEG", - sp->photometric); - return (0); - default: - /* TIFF 6.0 forbids subsampling of all other color spaces */ - sp->h_sampling = 1; - sp->v_sampling = 1; - break; - } - /* Verify miscellaneous parameters */ + /* + * A ReferenceBlackWhite field *must* be present since the + * default value is inappropriate for YCbCr. Fill in the + * proper value if application didn't set it. + */ + { + float *ref; + if (!TIFFGetField(tif, TIFFTAG_REFERENCEBLACKWHITE, + &ref)) { + float refbw[6]; + long top = 1L << td->td_bitspersample; + refbw[0] = 0; + refbw[1] = (float)(top-1L); + refbw[2] = (float)(top>>1); + refbw[3] = refbw[1]; + refbw[4] = refbw[2]; + refbw[5] = refbw[1]; + TIFFSetField(tif, TIFFTAG_REFERENCEBLACKWHITE, + refbw); + } + } + break; + case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */ + case PHOTOMETRIC_MASK: + TIFFErrorExt(tif->tif_clientdata, module, + "PhotometricInterpretation %d not allowed for JPEG", + (int) sp->photometric); + return (0); + default: + /* TIFF 6.0 forbids subsampling of all other color spaces */ + sp->h_sampling = 1; + sp->v_sampling = 1; + break; + } - /* - * This would need work if libtiff ever supports different - * depths for different components, or if libjpeg ever supports - * run-time selection of depth. Neither is imminent. - */ + /* Verify miscellaneous parameters */ + + /* + * This would need work if libtiff ever supports different + * depths for different components, or if libjpeg ever supports + * run-time selection of depth. Neither is imminent. + */ #ifdef JPEG_LIB_MK1 - /* BITS_IN_JSAMPLE now permits 8 and 12 --- dgilbert */ - if (td->td_bitspersample != 8 && td->td_bitspersample != 12) + /* BITS_IN_JSAMPLE now permits 8 and 12 --- dgilbert */ + if (td->td_bitspersample != 8 && td->td_bitspersample != 12) #else - if (td->td_bitspersample != BITS_IN_JSAMPLE) + if (td->td_bitspersample != BITS_IN_JSAMPLE ) #endif - { - TIFFErrorExtR(tif, module, - "BitsPerSample %" PRIu16 " not allowed for JPEG", - td->td_bitspersample); - return (0); - } - sp->cinfo.c.data_precision = td->td_bitspersample; + { + TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %d not allowed for JPEG", + (int) td->td_bitspersample); + return (0); + } + sp->cinfo.c.data_precision = td->td_bitspersample; #ifdef JPEG_LIB_MK1 - sp->cinfo.c.bits_in_jsample = td->td_bitspersample; + sp->cinfo.c.bits_in_jsample = td->td_bitspersample; #endif - if (isTiled(tif)) - { - if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) - { - TIFFErrorExtR(tif, module, - "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) - { - TIFFErrorExtR(tif, module, - "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) - { - TIFFErrorExtR(tif, module, - "RowsPerStrip must be multiple of %" PRIu32 - " for JPEG", - (uint32_t)(sp->v_sampling * DCTSIZE)); - return (0); - } - } + 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); + 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); + 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); + return (0); + } + } - /* Create a JPEGTables field if appropriate */ - if (sp->otherSettings.jpegtablesmode & - (JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF)) - { - if (sp->otherSettings.jpegtables == NULL || - memcmp(sp->otherSettings.jpegtables, "\0\0\0\0\0\0\0\0\0", 8) == 0) - { -#if defined(JPEG_LIB_VERSION_MAJOR) && \ - (JPEG_LIB_VERSION_MAJOR > 9 || \ - (JPEG_LIB_VERSION_MAJOR == 9 && JPEG_LIB_VERSION_MINOR >= 4)) - if ((sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_HUFF) != 0 && - (sp->cinfo.c.dc_huff_tbl_ptrs[0] == NULL || - sp->cinfo.c.dc_huff_tbl_ptrs[1] == NULL || - sp->cinfo.c.ac_huff_tbl_ptrs[0] == NULL || - sp->cinfo.c.ac_huff_tbl_ptrs[1] == NULL)) - { - /* libjpeg-9d no longer initializes default Huffman tables in */ - /* jpeg_set_defaults() */ - TIFF_std_huff_tables(&sp->cinfo.c); - } -#endif + /* Create a JPEGTables field if appropriate */ + if (sp->jpegtablesmode & (JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF)) { + if( sp->jpegtables == NULL + || memcmp(sp->jpegtables,"\0\0\0\0\0\0\0\0\0",8) == 0 ) + { + if (!prepare_JPEGTables(tif)) + return (0); + /* Mark the field present */ + /* Can't use TIFFSetField since BEENWRITING is already set! */ + tif->tif_flags |= TIFF_DIRTYDIRECT; + TIFFSetFieldBit(tif, FIELD_JPEGTABLES); + } + } else { + /* We do not support application-supplied JPEGTables, */ + /* so mark the field not present */ + TIFFClrFieldBit(tif, FIELD_JPEGTABLES); + } - if (!prepare_JPEGTables(tif)) - return (0); - /* Mark the field present */ - /* Can't use TIFFSetField since BEENWRITING is already set! */ - tif->tif_flags |= TIFF_DIRTYDIRECT; - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); - } - } - else - { - /* We do not support application-supplied JPEGTables, */ - /* so mark the field not present */ - TIFFClrFieldBit(tif, FIELD_JPEGTABLES); - } + /* Direct libjpeg output to libtiff's output buffer */ + TIFFjpeg_data_dest(sp, tif); - /* Direct libjpeg output to libtiff's output buffer */ - TIFFjpeg_data_dest(sp, tif); - - return (1); + return (1); } /* * Set encoding state at the start of a strip or tile. */ -static int JPEGPreEncode(TIFF *tif, uint16_t s) +static int +JPEGPreEncode(TIFF* tif, uint16 s) { - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; - static const char module[] = "JPEGPreEncode"; - uint32_t segment_width, segment_height; - int downsampled_input; + JPEGState *sp = JState(tif); + TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "JPEGPreEncode"; + uint32 segment_width, segment_height; + int downsampled_input; - assert(sp != NULL); + assert(sp != NULL); + + if (sp->cinfo.comm.is_decompressor == 1) + { + tif->tif_setupencode( tif ); + } + + assert(!sp->cinfo.comm.is_decompressor); + /* + * Set encoding parameters for this strip/tile. + */ + if (isTiled(tif)) { + segment_width = td->td_tilewidth; + segment_height = td->td_tilelength; + sp->bytesperline = TIFFTileRowSize(tif); + } else { + segment_width = td->td_imagewidth; + segment_height = td->td_imagelength - tif->tif_row; + if (segment_height > td->td_rowsperstrip) + segment_height = td->td_rowsperstrip; + sp->bytesperline = TIFFScanlineSize(tif); + } + if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) { + /* for PC 2, scale down the strip/tile size + * to match a downsampled component + */ + segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); + segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); + } + if (segment_width > 65535 || segment_height > 65535) { + TIFFErrorExt(tif->tif_clientdata, module, "Strip/tile too large for JPEG"); + return (0); + } + sp->cinfo.c.image_width = segment_width; + sp->cinfo.c.image_height = segment_height; + downsampled_input = FALSE; + if (td->td_planarconfig == PLANARCONFIG_CONTIG) { + sp->cinfo.c.input_components = td->td_samplesperpixel; + if (sp->photometric == PHOTOMETRIC_YCBCR) { + if (sp->jpegcolormode != JPEGCOLORMODE_RGB) { + if (sp->h_sampling != 1 || sp->v_sampling != 1) + downsampled_input = TRUE; + } + if (!TIFFjpeg_set_colorspace(sp, JCS_YCbCr)) + return (0); + /* + * Set Y sampling factors; + * we assume jpeg_set_colorspace() set the rest to 1 + */ + sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; + sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; + } else { + if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space)) + return (0); + /* jpeg_set_colorspace set all sampling factors to 1 */ + } + } else { + if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) + return (0); + sp->cinfo.c.comp_info[0].component_id = s; + /* jpeg_set_colorspace() set sampling factors to 1 */ + if (sp->photometric == PHOTOMETRIC_YCBCR && s > 0) { + sp->cinfo.c.comp_info[0].quant_tbl_no = 1; + sp->cinfo.c.comp_info[0].dc_tbl_no = 1; + sp->cinfo.c.comp_info[0].ac_tbl_no = 1; + } + } + /* ensure libjpeg won't write any extraneous markers */ + sp->cinfo.c.write_JFIF_header = FALSE; + sp->cinfo.c.write_Adobe_marker = FALSE; + /* set up table handling correctly */ + /* calling TIFFjpeg_set_quality() causes quantization tables to be flagged */ + /* as being to be emitted, which we don't want in the JPEGTABLESMODE_QUANT */ + /* mode, so we must manually suppress them. However TIFFjpeg_set_quality() */ + /* should really be called when dealing with files with directories with */ + /* mixed qualities. see http://trac.osgeo.org/gdal/ticket/3539 */ + if (!TIFFjpeg_set_quality(sp, sp->jpegquality, FALSE)) + return (0); + if (sp->jpegtablesmode & JPEGTABLESMODE_QUANT) { + suppress_quant_table(sp, 0); + suppress_quant_table(sp, 1); + } + else { + unsuppress_quant_table(sp, 0); + unsuppress_quant_table(sp, 1); + } + if (sp->jpegtablesmode & JPEGTABLESMODE_HUFF) + { + /* Explicit suppression is only needed if we did not go through the */ + /* prepare_JPEGTables() code path, which may be the case if updating */ + /* an existing file */ + suppress_huff_table(sp, 0); + suppress_huff_table(sp, 1); + sp->cinfo.c.optimize_coding = FALSE; + } + else + sp->cinfo.c.optimize_coding = TRUE; + if (downsampled_input) { + /* Need to use raw-data interface to libjpeg */ + sp->cinfo.c.raw_data_in = TRUE; + tif->tif_encoderow = JPEGEncodeRaw; + tif->tif_encodestrip = JPEGEncodeRaw; + tif->tif_encodetile = JPEGEncodeRaw; + } else { + /* Use normal interface to libjpeg */ + sp->cinfo.c.raw_data_in = FALSE; + tif->tif_encoderow = JPEGEncode; + tif->tif_encodestrip = JPEGEncode; + tif->tif_encodetile = JPEGEncode; + } + /* Start JPEG compressor */ + if (!TIFFjpeg_start_compress(sp, FALSE)) + return (0); + /* Allocate downsampled-data buffers if needed */ + if (downsampled_input) { + if (!alloc_downsampled_buffers(tif, sp->cinfo.c.comp_info, + sp->cinfo.c.num_components)) + return (0); + } + sp->scancount = 0; - if (sp->cinfo.comm.is_decompressor == 1) - { - tif->tif_setupencode(tif); - } - - assert(!sp->cinfo.comm.is_decompressor); - /* - * Set encoding parameters for this strip/tile. - */ - if (isTiled(tif)) - { - segment_width = td->td_tilewidth; - segment_height = td->td_tilelength; - sp->bytesperline = TIFFTileRowSize(tif); - } - else - { - segment_width = td->td_imagewidth; - segment_height = td->td_imagelength - tif->tif_row; - if (segment_height > td->td_rowsperstrip) - segment_height = td->td_rowsperstrip; - sp->bytesperline = TIFFScanlineSize(tif); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE && s > 0) - { - /* for PC 2, scale down the strip/tile size - * to match a downsampled component - */ - segment_width = TIFFhowmany_32(segment_width, sp->h_sampling); - segment_height = TIFFhowmany_32(segment_height, sp->v_sampling); - } - if (segment_width > 65535 || segment_height > 65535) - { - TIFFErrorExtR(tif, module, "Strip/tile too large for JPEG"); - return (0); - } - sp->cinfo.c.image_width = segment_width; - sp->cinfo.c.image_height = segment_height; - downsampled_input = FALSE; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - { - sp->cinfo.c.input_components = td->td_samplesperpixel; - if (sp->photometric == PHOTOMETRIC_YCBCR) - { - if (sp->otherSettings.jpegcolormode != JPEGCOLORMODE_RGB) - { - if (sp->h_sampling != 1 || sp->v_sampling != 1) - downsampled_input = TRUE; - } - if (!TIFFjpeg_set_colorspace(sp, JCS_YCbCr)) - return (0); - /* - * Set Y sampling factors; - * we assume jpeg_set_colorspace() set the rest to 1 - */ - sp->cinfo.c.comp_info[0].h_samp_factor = sp->h_sampling; - sp->cinfo.c.comp_info[0].v_samp_factor = sp->v_sampling; - } - else - { - if (!TIFFjpeg_set_colorspace(sp, sp->cinfo.c.in_color_space)) - return (0); - /* jpeg_set_colorspace set all sampling factors to 1 */ - } - } - else - { - if (!TIFFjpeg_set_colorspace(sp, JCS_UNKNOWN)) - return (0); - sp->cinfo.c.comp_info[0].component_id = s; - /* jpeg_set_colorspace() set sampling factors to 1 */ - if (sp->photometric == PHOTOMETRIC_YCBCR && s > 0) - { - sp->cinfo.c.comp_info[0].quant_tbl_no = 1; - sp->cinfo.c.comp_info[0].dc_tbl_no = 1; - sp->cinfo.c.comp_info[0].ac_tbl_no = 1; - } - } - /* ensure libjpeg won't write any extraneous markers */ - sp->cinfo.c.write_JFIF_header = FALSE; - sp->cinfo.c.write_Adobe_marker = FALSE; - /* set up table handling correctly */ - /* calling TIFFjpeg_set_quality() causes quantization tables to be flagged - */ - /* as being to be emitted, which we don't want in the JPEGTABLESMODE_QUANT - */ - /* mode, so we must manually suppress them. However TIFFjpeg_set_quality() - */ - /* should really be called when dealing with files with directories with */ - /* mixed qualities. see http://trac.osgeo.org/gdal/ticket/3539 */ - if (!TIFFjpeg_set_quality(sp, sp->otherSettings.jpegquality, FALSE)) - return (0); - if (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_QUANT) - { - suppress_quant_table(sp, 0); - suppress_quant_table(sp, 1); - } - else - { - unsuppress_quant_table(sp, 0); - unsuppress_quant_table(sp, 1); - } - if (sp->otherSettings.jpegtablesmode & JPEGTABLESMODE_HUFF) - { - /* Explicit suppression is only needed if we did not go through the */ - /* prepare_JPEGTables() code path, which may be the case if updating */ - /* an existing file */ - suppress_huff_table(sp, 0); - suppress_huff_table(sp, 1); - sp->cinfo.c.optimize_coding = FALSE; - } - else - sp->cinfo.c.optimize_coding = TRUE; - if (downsampled_input) - { - /* Need to use raw-data interface to libjpeg */ - sp->cinfo.c.raw_data_in = TRUE; - tif->tif_encoderow = JPEGEncodeRaw; - tif->tif_encodestrip = JPEGEncodeRaw; - tif->tif_encodetile = JPEGEncodeRaw; - } - else - { - /* Use normal interface to libjpeg */ - sp->cinfo.c.raw_data_in = FALSE; - tif->tif_encoderow = JPEGEncode; - tif->tif_encodestrip = JPEGEncode; - tif->tif_encodetile = JPEGEncode; - } - /* Start JPEG compressor */ - if (!TIFFjpeg_start_compress(sp, FALSE)) - return (0); - /* Allocate downsampled-data buffers if needed */ - if (downsampled_input) - { - if (!alloc_downsampled_buffers(tif, sp->cinfo.c.comp_info, - sp->cinfo.c.num_components)) - return (0); - } - sp->scancount = 0; - - return (1); + return (1); } /* * Encode a chunk of pixels. * "Standard" case: incoming data is not downsampled. */ -static int JPEGEncode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s) +static int +JPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - JPEGState *sp = JState(tif); - tmsize_t nrows; - TIFF_JSAMPROW bufptr[1]; - short *line16 = NULL; - int line16_count = 0; + JPEGState *sp = JState(tif); + tmsize_t nrows; + JSAMPROW bufptr[1]; + short *line16 = NULL; + int line16_count = 0; - (void)s; - assert(sp != NULL); - /* data is expected to be supplied in multiples of a scanline */ - nrows = cc / sp->bytesperline; - if (cc % sp->bytesperline) - TIFFWarningExtR(tif, tif->tif_name, "fractional scanline discarded"); + (void) s; + assert(sp != NULL); + /* data is expected to be supplied in multiples of a scanline */ + nrows = cc / sp->bytesperline; + if (cc % sp->bytesperline) + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, + "fractional scanline discarded"); - /* The last strip will be limited to image size */ - if (!isTiled(tif) && tif->tif_row + nrows > tif->tif_dir.td_imagelength) - nrows = tif->tif_dir.td_imagelength - tif->tif_row; + /* The last strip will be limited to image size */ + if( !isTiled(tif) && tif->tif_row+nrows > tif->tif_dir.td_imagelength ) + nrows = tif->tif_dir.td_imagelength - tif->tif_row; - if (sp->cinfo.c.data_precision == 12) - { - line16_count = (int)((sp->bytesperline * 2) / 3); - line16 = (short *)_TIFFmallocExt(tif, sizeof(short) * line16_count); - if (!line16) + if( sp->cinfo.c.data_precision == 12 ) { - TIFFErrorExtR(tif, "JPEGEncode", "Failed to allocate memory"); - - return 0; - } - } - - while (nrows-- > 0) - { - - if (sp->cinfo.c.data_precision == 12) - { - - int value_pairs = line16_count / 2; - int iPair; - - bufptr[0] = (TIFF_JSAMPROW)line16; - - for (iPair = 0; iPair < value_pairs; iPair++) + line16_count = (int)((sp->bytesperline * 2) / 3); + line16 = (short *) _TIFFmalloc(sizeof(short) * line16_count); + if (!line16) { - unsigned char *in_ptr = ((unsigned char *)buf) + iPair * 3; - TIFF_JSAMPLE *out_ptr = (TIFF_JSAMPLE *)(line16 + iPair * 2); + TIFFErrorExt(tif->tif_clientdata, + "JPEGEncode", + "Failed to allocate memory"); - out_ptr[0] = (in_ptr[0] << 4) | ((in_ptr[1] & 0xf0) >> 4); - out_ptr[1] = ((in_ptr[1] & 0x0f) << 8) | in_ptr[2]; + return 0; } } - else + + while (nrows-- > 0) { + + if( sp->cinfo.c.data_precision == 12 ) + { + + int value_pairs = line16_count / 2; + int iPair; + + bufptr[0] = (JSAMPROW) line16; + + for( iPair = 0; iPair < value_pairs; iPair++ ) + { + unsigned char *in_ptr = + ((unsigned char *) buf) + iPair * 3; + JSAMPLE *out_ptr = (JSAMPLE *) (line16 + iPair * 2); + + out_ptr[0] = (in_ptr[0] << 4) | ((in_ptr[1] & 0xf0) >> 4); + out_ptr[1] = ((in_ptr[1] & 0x0f) << 8) | in_ptr[2]; + } + } + else + { + bufptr[0] = (JSAMPROW) buf; + } + if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1) + return (0); + if (nrows > 0) + tif->tif_row++; + buf += sp->bytesperline; + } + + if( sp->cinfo.c.data_precision == 12 ) { - bufptr[0] = (TIFF_JSAMPROW)buf; + _TIFFfree( line16 ); } - if (TIFFjpeg_write_scanlines(sp, bufptr, 1) != 1) - return (0); - if (nrows > 0) - tif->tif_row++; - buf += sp->bytesperline; - } - - if (sp->cinfo.c.data_precision == 12) - { - _TIFFfreeExt(tif, line16); - } - - return (1); + + return (1); } /* * Encode a chunk of pixels. * Incoming data is expected to be downsampled per sampling factors. */ -static int JPEGEncodeRaw(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s) +static int +JPEGEncodeRaw(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - JPEGState *sp = JState(tif); - TIFF_JSAMPLE *inptr; - TIFF_JSAMPLE *outptr; - tmsize_t nrows; - JDIMENSION clumps_per_line, nclump; - int clumpoffset, ci, xpos, ypos; - jpeg_component_info *compptr; - int samples_per_clump = sp->samplesperclump; - tmsize_t bytesperclumpline; + JPEGState *sp = JState(tif); + JSAMPLE* inptr; + JSAMPLE* outptr; + tmsize_t nrows; + JDIMENSION clumps_per_line, nclump; + int clumpoffset, ci, xpos, ypos; + jpeg_component_info* compptr; + int samples_per_clump = sp->samplesperclump; + tmsize_t bytesperclumpline; - (void)s; - assert(sp != NULL); - /* data is expected to be supplied in multiples of a clumpline */ - /* a clumpline is equivalent to v_sampling desubsampled scanlines */ - /* TODO: the following calculation of bytesperclumpline, should substitute - * calculation of sp->bytesperline, except that it is per v_sampling lines - */ - bytesperclumpline = - ((((tmsize_t)sp->cinfo.c.image_width + sp->h_sampling - 1) / - sp->h_sampling) * - ((tmsize_t)sp->h_sampling * sp->v_sampling + 2) * - sp->cinfo.c.data_precision + - 7) / - 8; + (void) s; + assert(sp != NULL); + /* data is expected to be supplied in multiples of a clumpline */ + /* a clumpline is equivalent to v_sampling desubsampled scanlines */ + /* TODO: the following calculation of bytesperclumpline, should substitute calculation of sp->bytesperline, except that it is per v_sampling lines */ + bytesperclumpline = ((((tmsize_t)sp->cinfo.c.image_width+sp->h_sampling-1)/sp->h_sampling) + *((tmsize_t)sp->h_sampling*sp->v_sampling+2)*sp->cinfo.c.data_precision+7) + /8; - nrows = (cc / bytesperclumpline) * sp->v_sampling; - if (cc % bytesperclumpline) - TIFFWarningExtR(tif, tif->tif_name, "fractional scanline discarded"); + nrows = ( cc / bytesperclumpline ) * sp->v_sampling; + if (cc % bytesperclumpline) + TIFFWarningExt(tif->tif_clientdata, tif->tif_name, "fractional scanline discarded"); - /* Cb,Cr both have sampling factors 1, so this is correct */ - clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width; + /* Cb,Cr both have sampling factors 1, so this is correct */ + clumps_per_line = sp->cinfo.c.comp_info[1].downsampled_width; - while (nrows > 0) - { - /* - * Fastest way to separate the data is to make one pass - * over the scanline for each row of each component. - */ - clumpoffset = 0; /* first sample in clump */ - for (ci = 0, compptr = sp->cinfo.c.comp_info; - ci < sp->cinfo.c.num_components; ci++, compptr++) - { - int hsamp = compptr->h_samp_factor; - int vsamp = compptr->v_samp_factor; - int padding = (int)(compptr->width_in_blocks * DCTSIZE - - clumps_per_line * hsamp); - for (ypos = 0; ypos < vsamp; ypos++) - { - inptr = ((TIFF_JSAMPLE *)buf) + clumpoffset; - outptr = sp->ds_buffer[ci][sp->scancount * vsamp + ypos]; - if (hsamp == 1) - { - /* fast path for at least Cb and Cr */ - for (nclump = clumps_per_line; nclump-- > 0;) - { - *outptr++ = inptr[0]; - inptr += samples_per_clump; - } - } - else - { - /* general case */ - for (nclump = clumps_per_line; nclump-- > 0;) - { - for (xpos = 0; xpos < hsamp; xpos++) - *outptr++ = inptr[xpos]; - inptr += samples_per_clump; - } - } - /* pad each scanline as needed */ - for (xpos = 0; xpos < padding; xpos++) - { - *outptr = outptr[-1]; - outptr++; - } - clumpoffset += hsamp; - } - } - sp->scancount++; - if (sp->scancount >= DCTSIZE) - { - int n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) - return (0); - sp->scancount = 0; - } - tif->tif_row += sp->v_sampling; - buf += bytesperclumpline; - nrows -= sp->v_sampling; - } - return (1); + while (nrows > 0) { + /* + * Fastest way to separate the data is to make one pass + * over the scanline for each row of each component. + */ + clumpoffset = 0; /* first sample in clump */ + for (ci = 0, compptr = sp->cinfo.c.comp_info; + ci < sp->cinfo.c.num_components; + ci++, compptr++) { + int hsamp = compptr->h_samp_factor; + int vsamp = compptr->v_samp_factor; + int padding = (int) (compptr->width_in_blocks * DCTSIZE - + clumps_per_line * hsamp); + for (ypos = 0; ypos < vsamp; ypos++) { + inptr = ((JSAMPLE*) buf) + clumpoffset; + outptr = sp->ds_buffer[ci][sp->scancount*vsamp + ypos]; + if (hsamp == 1) { + /* fast path for at least Cb and Cr */ + for (nclump = clumps_per_line; nclump-- > 0; ) { + *outptr++ = inptr[0]; + inptr += samples_per_clump; + } + } else { + /* general case */ + for (nclump = clumps_per_line; nclump-- > 0; ) { + for (xpos = 0; xpos < hsamp; xpos++) + *outptr++ = inptr[xpos]; + inptr += samples_per_clump; + } + } + /* pad each scanline as needed */ + for (xpos = 0; xpos < padding; xpos++) { + *outptr = outptr[-1]; + outptr++; + } + clumpoffset += hsamp; + } + } + sp->scancount++; + if (sp->scancount >= DCTSIZE) { + int n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; + if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) + return (0); + sp->scancount = 0; + } + tif->tif_row += sp->v_sampling; + buf += bytesperclumpline; + nrows -= sp->v_sampling; + } + return (1); } /* * Finish up at the end of a strip or tile. */ -static int JPEGPostEncode(TIFF *tif) +static int +JPEGPostEncode(TIFF* tif) { - JPEGState *sp = JState(tif); + JPEGState *sp = JState(tif); - if (sp->scancount > 0) - { - /* - * Need to emit a partial bufferload of downsampled data. - * Pad the data vertically. - */ - int ci, ypos, n; - jpeg_component_info *compptr; + if (sp->scancount > 0) { + /* + * Need to emit a partial bufferload of downsampled data. + * Pad the data vertically. + */ + int ci, ypos, n; + jpeg_component_info* compptr; - for (ci = 0, compptr = sp->cinfo.c.comp_info; - ci < sp->cinfo.c.num_components; ci++, compptr++) - { - int vsamp = compptr->v_samp_factor; - tmsize_t row_width = - compptr->width_in_blocks * DCTSIZE * sizeof(JSAMPLE); - for (ypos = sp->scancount * vsamp; ypos < DCTSIZE * vsamp; ypos++) - { - _TIFFmemcpy((void *)sp->ds_buffer[ci][ypos], - (void *)sp->ds_buffer[ci][ypos - 1], row_width); - } - } - n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; - if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) - return (0); - } + for (ci = 0, compptr = sp->cinfo.c.comp_info; + ci < sp->cinfo.c.num_components; + ci++, compptr++) { + int vsamp = compptr->v_samp_factor; + tmsize_t row_width = compptr->width_in_blocks * DCTSIZE + * sizeof(JSAMPLE); + for (ypos = sp->scancount * vsamp; + ypos < DCTSIZE * vsamp; ypos++) { + _TIFFmemcpy((void*)sp->ds_buffer[ci][ypos], + (void*)sp->ds_buffer[ci][ypos-1], + row_width); - return (TIFFjpeg_finish_compress(JState(tif))); + } + } + n = sp->cinfo.c.max_v_samp_factor * DCTSIZE; + if (TIFFjpeg_write_raw_data(sp, sp->ds_buffer, n) != n) + return (0); + } + + return (TIFFjpeg_finish_compress(JState(tif))); } -static void JPEGCleanup(TIFF *tif) +static void +JPEGCleanup(TIFF* tif) { - JPEGState *sp = JState(tif); + JPEGState *sp = JState(tif); + + assert(sp != 0); - assert(sp != 0); + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; + tif->tif_tagmethods.printdir = sp->printdir; + if( sp->cinfo_initialized ) + TIFFjpeg_destroy(sp); /* release libjpeg resources */ + if (sp->jpegtables) /* tag value */ + _TIFFfree(sp->jpegtables); + _TIFFfree(tif->tif_data); /* release local state */ + tif->tif_data = NULL; - tif->tif_tagmethods.vgetfield = sp->otherSettings.vgetparent; - tif->tif_tagmethods.vsetfield = sp->otherSettings.vsetparent; - tif->tif_tagmethods.printdir = sp->otherSettings.printdir; - if (sp->cinfo_initialized) - TIFFjpeg_destroy(sp); /* release libjpeg resources */ - if (sp->otherSettings.jpegtables) /* tag value */ - _TIFFfreeExt(tif, sp->otherSettings.jpegtables); - _TIFFfreeExt(tif, tif->tif_data); /* release local state */ - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); + _TIFFSetDefaultCompressionState(tif); } -static void JPEGResetUpsampled(TIFF *tif) +static void +JPEGResetUpsampled( TIFF* tif ) { - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; + JPEGState* sp = JState(tif); + TIFFDirectory* td = &tif->tif_dir; - /* - * Mark whether returned data is up-sampled or not so TIFFStripSize - * and TIFFTileSize return values that reflect the true amount of - * data. - */ - tif->tif_flags &= ~TIFF_UPSAMPLED; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - { - if (td->td_photometric == PHOTOMETRIC_YCBCR && - sp->otherSettings.jpegcolormode == JPEGCOLORMODE_RGB) - { - tif->tif_flags |= TIFF_UPSAMPLED; - } - else - { + /* + * Mark whether returned data is up-sampled or not so TIFFStripSize + * and TIFFTileSize return values that reflect the true amount of + * data. + */ + tif->tif_flags &= ~TIFF_UPSAMPLED; + if (td->td_planarconfig == PLANARCONFIG_CONTIG) { + if (td->td_photometric == PHOTOMETRIC_YCBCR && + sp->jpegcolormode == JPEGCOLORMODE_RGB) { + tif->tif_flags |= TIFF_UPSAMPLED; + } else { #ifdef notdef - if (td->td_ycbcrsubsampling[0] != 1 || - td->td_ycbcrsubsampling[1] != 1) - ; /* XXX what about up-sampling? */ + if (td->td_ycbcrsubsampling[0] != 1 || + td->td_ycbcrsubsampling[1] != 1) + ; /* XXX what about up-sampling? */ #endif - } - } + } + } - /* - * Must recalculate cached tile size in case sampling state changed. - * Should we really be doing this now if image size isn't set? - */ - if (tif->tif_tilesize > 0) - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1); - if (tif->tif_scanlinesize > 0) - tif->tif_scanlinesize = TIFFScanlineSize(tif); + /* + * Must recalculate cached tile size in case sampling state changed. + * Should we really be doing this now if image size isn't set? + */ + if( tif->tif_tilesize > 0 ) + tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1); + if( tif->tif_scanlinesize > 0 ) + tif->tif_scanlinesize = TIFFScanlineSize(tif); } -static int JPEGVSetField(TIFF *tif, uint32_t tag, va_list ap) +static int +JPEGVSetField(TIFF* tif, uint32 tag, va_list ap) { - JPEGState *sp = JState(tif); - const TIFFField *fip; - uint32_t v32; + JPEGState* sp = JState(tif); + const TIFFField* fip; + uint32 v32; - assert(sp != NULL); + assert(sp != NULL); - switch (tag) - { - case TIFFTAG_JPEGTABLES: - v32 = (uint32_t)va_arg(ap, uint32_t); - if (v32 == 0) - { - /* XXX */ - return (0); - } - _TIFFsetByteArrayExt(tif, &sp->otherSettings.jpegtables, - va_arg(ap, void *), v32); - sp->otherSettings.jpegtables_length = v32; - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); - break; - case TIFFTAG_JPEGQUALITY: - sp->otherSettings.jpegquality = (int)va_arg(ap, int); - return (1); /* pseudo tag */ - case TIFFTAG_JPEGCOLORMODE: - sp->otherSettings.jpegcolormode = (int)va_arg(ap, int); - JPEGResetUpsampled(tif); - return (1); /* pseudo tag */ - case TIFFTAG_PHOTOMETRIC: - { - int ret_value = (*sp->otherSettings.vsetparent)(tif, tag, ap); - JPEGResetUpsampled(tif); - return ret_value; - } - case TIFFTAG_JPEGTABLESMODE: - sp->otherSettings.jpegtablesmode = (int)va_arg(ap, int); - return (1); /* pseudo tag */ - case TIFFTAG_YCBCRSUBSAMPLING: - /* mark the fact that we have a real ycbcrsubsampling! */ - sp->otherSettings.ycbcrsampling_fetched = 1; - /* should we be recomputing upsampling info here? */ - return (*sp->otherSettings.vsetparent)(tif, tag, ap); - default: - return (*sp->otherSettings.vsetparent)(tif, tag, ap); - } + switch (tag) { + case TIFFTAG_JPEGTABLES: + v32 = (uint32) va_arg(ap, uint32); + if (v32 == 0) { + /* XXX */ + return (0); + } + _TIFFsetByteArray(&sp->jpegtables, va_arg(ap, void*), v32); + sp->jpegtables_length = v32; + TIFFSetFieldBit(tif, FIELD_JPEGTABLES); + break; + case TIFFTAG_JPEGQUALITY: + sp->jpegquality = (int) va_arg(ap, int); + return (1); /* pseudo tag */ + case TIFFTAG_JPEGCOLORMODE: + sp->jpegcolormode = (int) va_arg(ap, int); + JPEGResetUpsampled( tif ); + return (1); /* pseudo tag */ + case TIFFTAG_PHOTOMETRIC: + { + int ret_value = (*sp->vsetparent)(tif, tag, ap); + JPEGResetUpsampled( tif ); + return ret_value; + } + case TIFFTAG_JPEGTABLESMODE: + sp->jpegtablesmode = (int) va_arg(ap, int); + return (1); /* pseudo tag */ + case TIFFTAG_YCBCRSUBSAMPLING: + /* mark the fact that we have a real ycbcrsubsampling! */ + sp->ycbcrsampling_fetched = 1; + /* should we be recomputing upsampling info here? */ + return (*sp->vsetparent)(tif, tag, ap); + default: + return (*sp->vsetparent)(tif, tag, ap); + } - if ((fip = TIFFFieldWithTag(tif, tag)) != NULL) - { - TIFFSetFieldBit(tif, fip->field_bit); - } - else - { - return (0); - } + if ((fip = TIFFFieldWithTag(tif, tag)) != NULL) { + TIFFSetFieldBit(tif, fip->field_bit); + } else { + return (0); + } - tif->tif_flags |= TIFF_DIRTYDIRECT; - return (1); + tif->tif_flags |= TIFF_DIRTYDIRECT; + return (1); } -static int JPEGVGetField(TIFF *tif, uint32_t tag, va_list ap) +static int +JPEGVGetField(TIFF* tif, uint32 tag, va_list ap) { - JPEGState *sp = JState(tif); + JPEGState* sp = JState(tif); - assert(sp != NULL); + assert(sp != NULL); - switch (tag) - { - case TIFFTAG_JPEGTABLES: - *va_arg(ap, uint32_t *) = sp->otherSettings.jpegtables_length; - *va_arg(ap, const void **) = sp->otherSettings.jpegtables; - break; - case TIFFTAG_JPEGQUALITY: - *va_arg(ap, int *) = sp->otherSettings.jpegquality; - break; - case TIFFTAG_JPEGCOLORMODE: - *va_arg(ap, int *) = sp->otherSettings.jpegcolormode; - break; - case TIFFTAG_JPEGTABLESMODE: - *va_arg(ap, int *) = sp->otherSettings.jpegtablesmode; - break; - default: - return (*sp->otherSettings.vgetparent)(tif, tag, ap); - } - return (1); + switch (tag) { + case TIFFTAG_JPEGTABLES: + *va_arg(ap, uint32*) = sp->jpegtables_length; + *va_arg(ap, const void**) = sp->jpegtables; + break; + case TIFFTAG_JPEGQUALITY: + *va_arg(ap, int*) = sp->jpegquality; + break; + case TIFFTAG_JPEGCOLORMODE: + *va_arg(ap, int*) = sp->jpegcolormode; + break; + case TIFFTAG_JPEGTABLESMODE: + *va_arg(ap, int*) = sp->jpegtablesmode; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return (1); } -static void JPEGPrintDir(TIFF *tif, FILE *fd, long flags) +static void +JPEGPrintDir(TIFF* tif, FILE* fd, long flags) { - JPEGState *sp = JState(tif); + JPEGState* sp = JState(tif); - assert(sp != NULL); - (void)flags; + assert(sp != NULL); + (void) flags; - if (sp != NULL) - { - if (TIFFFieldSet(tif, FIELD_JPEGTABLES)) - fprintf(fd, " JPEG Tables: (%" PRIu32 " bytes)\n", - sp->otherSettings.jpegtables_length); - if (sp->otherSettings.printdir) - (*sp->otherSettings.printdir)(tif, fd, flags); - } + if( sp != NULL ) { + if (TIFFFieldSet(tif,FIELD_JPEGTABLES)) + fprintf(fd, " JPEG Tables: (%lu bytes)\n", + (unsigned long) sp->jpegtables_length); + if (sp->printdir) + (*sp->printdir)(tif, fd, flags); + } } -static uint32_t JPEGDefaultStripSize(TIFF *tif, uint32_t s) +static uint32 +JPEGDefaultStripSize(TIFF* tif, uint32 s) { - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; + JPEGState* sp = JState(tif); + TIFFDirectory *td = &tif->tif_dir; - s = (*sp->otherSettings.defsparent)(tif, s); - if (s < td->td_imagelength) - s = TIFFroundup_32(s, td->td_ycbcrsubsampling[1] * DCTSIZE); - return (s); + s = (*sp->defsparent)(tif, s); + if (s < td->td_imagelength) + s = TIFFroundup_32(s, td->td_ycbcrsubsampling[1] * DCTSIZE); + return (s); } -static void JPEGDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th) +static void +JPEGDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) { - JPEGState *sp = JState(tif); - TIFFDirectory *td = &tif->tif_dir; + JPEGState* sp = JState(tif); + TIFFDirectory *td = &tif->tif_dir; - (*sp->otherSettings.deftparent)(tif, tw, th); - *tw = TIFFroundup_32(*tw, td->td_ycbcrsubsampling[0] * DCTSIZE); - *th = TIFFroundup_32(*th, td->td_ycbcrsubsampling[1] * DCTSIZE); + (*sp->deftparent)(tif, tw, th); + *tw = TIFFroundup_32(*tw, td->td_ycbcrsubsampling[0] * DCTSIZE); + *th = TIFFroundup_32(*th, td->td_ycbcrsubsampling[1] * DCTSIZE); } /* * The JPEG library initialized used to be done in TIFFInitJPEG(), but * now that we allow a TIFF file to be opened in update mode it is necessary * to have some way of deciding whether compression or decompression is - * desired other than looking at tif->tif_mode. We accomplish this by + * desired other than looking at tif->tif_mode. We accomplish this by * examining {TILE/STRIP}BYTECOUNTS to see if there is a non-zero entry. - * If so, we assume decompression is desired. + * If so, we assume decompression is desired. * * This is tricky, because TIFFInitJPEG() is called while the directory is * being read, and generally speaking the BYTECOUNTS tag won't have been read * at that point. So we try to defer jpeg library initialization till we * do have that tag ... basically any access that might require the compressor - * or decompressor that occurs after the reading of the directory. + * or decompressor that occurs after the reading of the directory. * * In an ideal world compressors or decompressors would be setup * at the point where a single tile or strip was accessed (for read or write) @@ -2719,16 +2429,16 @@ static void JPEGDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th) * NFW, Feb 3rd, 2003. */ -static int JPEGInitializeLibJPEG(TIFF *tif, int decompress) +static int JPEGInitializeLibJPEG( TIFF * tif, int decompress ) { - JPEGState *sp = JState(tif); + JPEGState* sp = JState(tif); - if (sp->cinfo_initialized) + if(sp->cinfo_initialized) { - if (!decompress && sp->cinfo.comm.is_decompressor) - TIFFjpeg_destroy(sp); - else if (decompress && !sp->cinfo.comm.is_decompressor) - TIFFjpeg_destroy(sp); + if( !decompress && sp->cinfo.comm.is_decompressor ) + TIFFjpeg_destroy( sp ); + else if( decompress && !sp->cinfo.comm.is_decompressor ) + TIFFjpeg_destroy( sp ); else return 1; @@ -2738,36 +2448,29 @@ static int JPEGInitializeLibJPEG(TIFF *tif, int decompress) /* * Initialize libjpeg. */ - if (decompress) - { + if ( decompress ) { if (!TIFFjpeg_create_decompress(sp)) return (0); - } - else - { + } else { if (!TIFFjpeg_create_compress(sp)) return (0); #ifndef TIFF_JPEG_MAX_MEMORY_TO_USE #define TIFF_JPEG_MAX_MEMORY_TO_USE (10 * 1024 * 1024) #endif /* libjpeg turbo 1.5.2 honours max_memory_to_use, but has no backing */ - /* store implementation, so better not set max_memory_to_use ourselves. - */ + /* store implementation, so better not set max_memory_to_use ourselves. */ /* See https://github.com/libjpeg-turbo/libjpeg-turbo/issues/162 */ - if (sp->cinfo.c.mem->max_memory_to_use > 0) + if( sp->cinfo.c.mem->max_memory_to_use > 0 ) { /* This is to address bug related in ticket GDAL #1795. */ if (getenv("JPEGMEM") == NULL) { - /* Increase the max memory usable. This helps when creating - * files */ + /* Increase the max memory usable. This helps when creating files */ /* with "big" tile, without using libjpeg temporary files. */ /* For example a 512x512 tile with 3 bands */ /* requires 1.5 MB which is above libjpeg 1MB default */ - if (sp->cinfo.c.mem->max_memory_to_use < - TIFF_JPEG_MAX_MEMORY_TO_USE) - sp->cinfo.c.mem->max_memory_to_use = - TIFF_JPEG_MAX_MEMORY_TO_USE; + if( sp->cinfo.c.mem->max_memory_to_use < TIFF_JPEG_MAX_MEMORY_TO_USE ) + sp->cinfo.c.mem->max_memory_to_use = TIFF_JPEG_MAX_MEMORY_TO_USE; } } } @@ -2777,124 +2480,124 @@ static int JPEGInitializeLibJPEG(TIFF *tif, int decompress) return 1; } -/* Common to tif_jpeg.c and tif_jpeg_12.c */ -static void TIFFInitJPEGCommon(TIFF *tif) +int +TIFFInitJPEG(TIFF* tif, int scheme) { - JPEGState *sp; + JPEGState* sp; - sp = JState(tif); - sp->tif = tif; /* back link */ + (void)scheme; + assert(scheme == COMPRESSION_JPEG); - /* Default values for codec-specific fields */ - sp->otherSettings.jpegtables = NULL; - sp->otherSettings.jpegtables_length = 0; - sp->otherSettings.jpegquality = 75; /* Default IJG quality */ - sp->otherSettings.jpegcolormode = JPEGCOLORMODE_RAW; - sp->otherSettings.jpegtablesmode = - JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF; - sp->otherSettings.ycbcrsampling_fetched = 0; + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, jpegFields, TIFFArrayCount(jpegFields))) { + TIFFErrorExt(tif->tif_clientdata, + "TIFFInitJPEG", + "Merging JPEG codec-specific tags failed"); + return 0; + } - tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */ - tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */ - tif->tif_tagmethods.printdir = JPEGPrintDir; /* hook for codec tags */ + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (JPEGState)); - /* - * Install codec methods. - */ - tif->tif_fixuptags = JPEGFixupTags; - tif->tif_setupdecode = JPEGSetupDecode; - tif->tif_predecode = JPEGPreDecode; - tif->tif_decoderow = JPEGDecode; - tif->tif_decodestrip = JPEGDecode; - tif->tif_decodetile = JPEGDecode; - tif->tif_setupencode = JPEGSetupEncode; - tif->tif_preencode = JPEGPreEncode; - tif->tif_postencode = JPEGPostEncode; - tif->tif_encoderow = JPEGEncode; - tif->tif_encodestrip = JPEGEncode; - tif->tif_encodetile = JPEGEncode; - tif->tif_cleanup = JPEGCleanup; + if (tif->tif_data == NULL) { + TIFFErrorExt(tif->tif_clientdata, + "TIFFInitJPEG", "No space for JPEG state block"); + return 0; + } + _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState)); - tif->tif_defstripsize = JPEGDefaultStripSize; - tif->tif_deftilesize = JPEGDefaultTileSize; - tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ - sp->cinfo_initialized = FALSE; -} + sp = JState(tif); + sp->tif = tif; /* back link */ -int TIFFInitJPEG(TIFF *tif, int scheme) -{ - JPEGState *sp; + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */ + sp->printdir = tif->tif_tagmethods.printdir; + tif->tif_tagmethods.printdir = JPEGPrintDir; /* hook for codec tags */ - (void)scheme; - assert(scheme == COMPRESSION_JPEG); + /* Default values for codec-specific fields */ + sp->jpegtables = NULL; + sp->jpegtables_length = 0; + sp->jpegquality = 75; /* Default IJG quality */ + sp->jpegcolormode = JPEGCOLORMODE_RAW; + sp->jpegtablesmode = JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF; + sp->ycbcrsampling_fetched = 0; - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, jpegFields, TIFFArrayCount(jpegFields))) - { - TIFFErrorExtR(tif, "TIFFInitJPEG", - "Merging JPEG codec-specific tags failed"); - return 0; - } + /* + * Install codec methods. + */ + tif->tif_fixuptags = JPEGFixupTags; + tif->tif_setupdecode = JPEGSetupDecode; + tif->tif_predecode = JPEGPreDecode; + tif->tif_decoderow = JPEGDecode; + tif->tif_decodestrip = JPEGDecode; + tif->tif_decodetile = JPEGDecode; + tif->tif_setupencode = JPEGSetupEncode; + tif->tif_preencode = JPEGPreEncode; + tif->tif_postencode = JPEGPostEncode; + tif->tif_encoderow = JPEGEncode; + tif->tif_encodestrip = JPEGEncode; + tif->tif_encodetile = JPEGEncode; + tif->tif_cleanup = JPEGCleanup; + sp->defsparent = tif->tif_defstripsize; + tif->tif_defstripsize = JPEGDefaultStripSize; + sp->deftparent = tif->tif_deftilesize; + tif->tif_deftilesize = JPEGDefaultTileSize; + tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(JPEGState)); + sp->cinfo_initialized = FALSE; - if (tif->tif_data == NULL) - { - TIFFErrorExtR(tif, "TIFFInitJPEG", "No space for JPEG state block"); - return 0; - } - _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState)); - - sp = JState(tif); - /* - * Override parent get/set field methods. - */ - sp->otherSettings.vgetparent = tif->tif_tagmethods.vgetfield; - sp->otherSettings.vsetparent = tif->tif_tagmethods.vsetfield; - sp->otherSettings.printdir = tif->tif_tagmethods.printdir; - - sp->otherSettings.defsparent = tif->tif_defstripsize; - sp->otherSettings.deftparent = tif->tif_deftilesize; - - TIFFInitJPEGCommon(tif); - - /* - ** Create a JPEGTables field if no directory has yet been created. - ** We do this just to ensure that sufficient space is reserved for - ** the JPEGTables field. It will be properly created the right - ** size later. - */ - if (tif->tif_diroff == 0) - { -#define SIZE_OF_JPEGTABLES 2000 - /* - The following line assumes incorrectly that all JPEG-in-TIFF files will - have a JPEGTABLES tag generated and causes null-filled JPEGTABLES tags - to be written when the JPEG data is placed with TIFFWriteRawStrip. The - field bit should be set, anyway, later when actual JPEGTABLES header is - generated, so removing it here hopefully is harmless. - TIFFSetFieldBit(tif, FIELD_JPEGTABLES); + /* + ** Create a JPEGTables field if no directory has yet been created. + ** We do this just to ensure that sufficient space is reserved for + ** the JPEGTables field. It will be properly created the right + ** size later. */ - sp->otherSettings.jpegtables_length = SIZE_OF_JPEGTABLES; - sp->otherSettings.jpegtables = - (void *)_TIFFmallocExt(tif, sp->otherSettings.jpegtables_length); - if (sp->otherSettings.jpegtables) + if( tif->tif_diroff == 0 ) { - _TIFFmemset(sp->otherSettings.jpegtables, 0, SIZE_OF_JPEGTABLES); - } - else - { - TIFFErrorExtR(tif, "TIFFInitJPEG", - "Failed to allocate memory for JPEG tables"); - return 0; - } +#define SIZE_OF_JPEGTABLES 2000 +/* +The following line assumes incorrectly that all JPEG-in-TIFF files will have +a JPEGTABLES tag generated and causes null-filled JPEGTABLES tags to be written +when the JPEG data is placed with TIFFWriteRawStrip. The field bit should be +set, anyway, later when actual JPEGTABLES header is generated, so removing it +here hopefully is harmless. + TIFFSetFieldBit(tif, FIELD_JPEGTABLES); +*/ + sp->jpegtables_length = SIZE_OF_JPEGTABLES; + sp->jpegtables = (void *) _TIFFmalloc(sp->jpegtables_length); + if (sp->jpegtables) + { + _TIFFmemset(sp->jpegtables, 0, SIZE_OF_JPEGTABLES); + } + else + { + TIFFErrorExt(tif->tif_clientdata, + "TIFFInitJPEG", + "Failed to allocate memory for JPEG tables"); + return 0; + } #undef SIZE_OF_JPEGTABLES - } - return 1; + } + + return 1; } #endif /* JPEG_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jpeg_12.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jpeg_12.c index 406e1cfc3..b458c2589 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jpeg_12.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_jpeg_12.c @@ -1,63 +1,69 @@ #include "tiffiop.h" -#if defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) -#define JPEG_DUAL_MODE_8_12 -#endif - #if defined(JPEG_DUAL_MODE_8_12) -#define FROM_TIF_JPEG_12 +# define TIFFInitJPEG TIFFInitJPEG_12 +# define TIFFJPEGIsFullStripRequired TIFFJPEGIsFullStripRequired_12 -#ifdef TIFFInitJPEG -#undef TIFFInitJPEG -#endif -#define TIFFInitJPEG TIFFInitJPEG_12 +int +TIFFInitJPEG_12(TIFF* tif, int scheme); -#ifdef TIFFJPEGIsFullStripRequired -#undef TIFFJPEGIsFullStripRequired -#endif -#define TIFFJPEGIsFullStripRequired TIFFJPEGIsFullStripRequired_12 +# include LIBJPEG_12_PATH -int TIFFInitJPEG_12(TIFF *tif, int scheme); +# include "tif_jpeg.c" -#if !defined(HAVE_JPEGTURBO_DUAL_MODE_8_12) -#include LIBJPEG_12_PATH -#endif +int TIFFReInitJPEG_12( TIFF *tif, int scheme, int is_encode ) -#include "tif_jpeg.c" - -int TIFFReInitJPEG_12(TIFF *tif, const JPEGOtherSettings *otherSettings, - int scheme, int is_encode) { - JPEGState *sp; - uint8_t *new_tif_data; + JPEGState* sp; - (void)scheme; assert(scheme == COMPRESSION_JPEG); - new_tif_data = - (uint8_t *)_TIFFreallocExt(tif, tif->tif_data, sizeof(JPEGState)); - - if (new_tif_data == NULL) - { - TIFFErrorExtR(tif, "TIFFReInitJPEG_12", - "No space for JPEG state block"); - return 0; - } - - tif->tif_data = new_tif_data; - _TIFFmemset(tif->tif_data, 0, sizeof(JPEGState)); - - TIFFInitJPEGCommon(tif); - sp = JState(tif); - sp->otherSettings = *otherSettings; + sp->tif = tif; /* back link */ - if (is_encode) + /* + * Override parent get/set field methods. + */ + tif->tif_tagmethods.vgetfield = JPEGVGetField; /* hook for codec tags */ + tif->tif_tagmethods.vsetfield = JPEGVSetField; /* hook for codec tags */ + tif->tif_tagmethods.printdir = JPEGPrintDir; /* hook for codec tags */ + + /* + * Install codec methods. + */ + tif->tif_fixuptags = JPEGFixupTags; + tif->tif_setupdecode = JPEGSetupDecode; + tif->tif_predecode = JPEGPreDecode; + tif->tif_decoderow = JPEGDecode; + tif->tif_decodestrip = JPEGDecode; + tif->tif_decodetile = JPEGDecode; + tif->tif_setupencode = JPEGSetupEncode; + tif->tif_preencode = JPEGPreEncode; + tif->tif_postencode = JPEGPostEncode; + tif->tif_encoderow = JPEGEncode; + tif->tif_encodestrip = JPEGEncode; + tif->tif_encodetile = JPEGEncode; + tif->tif_cleanup = JPEGCleanup; + tif->tif_defstripsize = JPEGDefaultStripSize; + tif->tif_deftilesize = JPEGDefaultTileSize; + tif->tif_flags |= TIFF_NOBITREV; /* no bit reversal, please */ + + sp->cinfo_initialized = FALSE; + + if( is_encode ) return JPEGSetupEncode(tif); else return JPEGSetupDecode(tif); } #endif /* defined(JPEG_DUAL_MODE_8_12) */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lerc.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lerc.c deleted file mode 100644 index 4f357a601..000000000 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lerc.c +++ /dev/null @@ -1,1206 +0,0 @@ -/* - * Copyright (c) 2018, Even Rouault - * Author: - * - * 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 - -#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; - } - - TIFFErrorExtR( - tif, 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) - { - TIFFErrorExtR(tif, module, "Too large uncompressed strip/tile"); - _TIFFfreeExt(tif, sp->uncompressed_buffer); - sp->uncompressed_buffer = 0; - sp->uncompressed_alloc = 0; - return 0; - } - - if (sp->uncompressed_alloc < new_alloc) - { - _TIFFfreeExt(tif, sp->uncompressed_buffer); - sp->uncompressed_buffer = _TIFFmallocExt(tif, new_alloc); - if (!sp->uncompressed_buffer) - { - TIFFErrorExtR(tif, module, "Cannot allocate buffer"); - _TIFFfreeExt(tif, 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 = - _TIFFreallocExt(tif, sp->mask_buffer, mask_size); - if (mask_buffer == NULL) - { - TIFFErrorExtR(tif, module, "Cannot allocate buffer"); - sp->mask_size = 0; - _TIFFfreeExt(tif, 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) - { - _TIFFfreeExt(tif, sp->compressed_buffer); - sp->compressed_buffer = _TIFFmallocExt(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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)) - { - TIFFErrorExtR(tif, 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 - TIFFErrorExtR(tif, module, "ZSTD support missing"); - return 0; -#endif - } - else if (sp->additional_compression != LERC_ADD_COMPRESSION_NONE) - { - TIFFErrorExtR(tif, module, "Unhandled additional compression"); - return 0; - } - - lerc_ret = - lerc_getBlobInfo(lerc_data, lerc_data_size, infoArray, NULL, 8, 0); - if (lerc_ret != 0) - { - TIFFErrorExtR(tif, 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) - { - TIFFWarningExtR(tif, module, - "Unexpected version number: %d. Expected: %d", - infoArray[0], sp->lerc_version); - } - if (infoArray[1] != (unsigned)lerc_data_type) - { - TIFFErrorExtR(tif, module, "Unexpected dataType: %d. Expected: %d", - infoArray[1], lerc_data_type); - return 0; - } - if (infoArray[2] != (unsigned)ndims) - { - TIFFErrorExtR(tif, module, "Unexpected nDim: %d. Expected: %d", - infoArray[2], ndims); - return 0; - } - if (infoArray[3] != sp->segment_width) - { - TIFFErrorExtR(tif, module, "Unexpected nCols: %d. Expected: %du", - infoArray[3], sp->segment_width); - return 0; - } - if (infoArray[4] != sp->segment_height) - { - TIFFErrorExtR(tif, module, "Unexpected nRows: %d. Expected: %u", - infoArray[4], sp->segment_height); - return 0; - } - if (infoArray[5] != 1) - { - TIFFErrorExtR(tif, module, "Unexpected nBands: %d. Expected: %d", - infoArray[5], 1); - return 0; - } - if (infoArray[7] != lerc_data_size) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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 WORDS_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) - { - TIFFErrorExtR(tif, module, "Uncompressed buffer not allocated"); - return 0; - } - - if ((uint64_t)sp->uncompressed_offset + (uint64_t)occ > - sp->uncompressed_size) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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 ) - { - TIFFErrorExtR(tif, module, - "lerc_computeCompressedSize() failed"); - return 0; - } -#else - numBytes = sp->uncompressed_alloc; -#endif - - if (sp->compressed_size < numBytes) - { - _TIFFfreeExt(tif, sp->compressed_buffer); - sp->compressed_buffer = _TIFFmallocExt(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, module, "Cannot allocate compressor"); - return 0; - } - } - - /* Should not happen normally */ - if (libdeflate_zlib_compress_bound( - sp->libdeflate_enc, numBytesWritten) > sp->uncompressed_alloc) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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)) - { - TIFFErrorExtR(tif, 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 - TIFFErrorExtR(tif, module, "ZSTD support missing"); - return 0; -#endif - } - else if (sp->additional_compression != LERC_ADD_COMPRESSION_NONE) - { - TIFFErrorExtR(tif, 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; - - _TIFFfreeExt(tif, sp->uncompressed_buffer); - _TIFFfreeExt(tif, sp->compressed_buffer); - _TIFFfreeExt(tif, 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 - - _TIFFfreeExt(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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) - { - TIFFErrorExtR(tif, 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()) - { - TIFFWarningExtR(tif, 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) - { - TIFFErrorExtR( - tif, 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))) - { - TIFFErrorExtR(tif, 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 *)_TIFFcallocExt(tif, 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: - TIFFErrorExtR(tif, module, "No space for LERC state block"); - return 0; -} -#endif /* LERC_SUPPORT */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_luv.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_luv.c index 021756d5d..3bd02e88e 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_luv.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_luv.c @@ -2,23 +2,23 @@ * Copyright (c) 1997 Greg Ward Larson * Copyright (c) 1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler, Greg Larson 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, Greg Larson and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER, GREG LARSON OR SILICON GRAPHICS BE LIABLE * FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -34,7 +34,7 @@ * LogLuv image support uses the TIFF library to store 16 or 10-bit * log luminance values with 8 bits each of u and v or a 14-bit index. * - * The codec can take as input and produce as output 32-bit IEEE float values + * The codec can take as input and produce as output 32-bit IEEE float values * as well as 16-bit integer values. A 16-bit luminance is interpreted * as a sign bit followed by a 15-bit integer that is converted * to and from a linear magnitude using the transformation: @@ -145,9 +145,9 @@ * quantization errors into noise. */ -#include #include #include +#include /* * State block for each open TIFF @@ -155,23 +155,22 @@ */ typedef struct logLuvState LogLuvState; -struct logLuvState -{ - int encoder_state; /* 1 if encoder correctly initialized */ - int user_datafmt; /* user data format */ - int encode_meth; /* encoding method */ - int pixel_size; /* bytes per pixel */ +struct logLuvState { + int encoder_state; /* 1 if encoder correctly initialized */ + int user_datafmt; /* user data format */ + int encode_meth; /* encoding method */ + int pixel_size; /* bytes per pixel */ - uint8_t *tbuf; /* translation buffer */ - tmsize_t tbuflen; /* buffer length */ - void (*tfunc)(LogLuvState *, uint8_t *, tmsize_t); + uint8* tbuf; /* translation buffer */ + tmsize_t tbuflen; /* buffer length */ + void (*tfunc)(LogLuvState*, uint8*, tmsize_t); - TIFFVSetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ + TIFFVSetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ }; -#define DecoderState(tif) ((LogLuvState *)(tif)->tif_data) -#define EncoderState(tif) ((LogLuvState *)(tif)->tif_data) +#define DecoderState(tif) ((LogLuvState*) (tif)->tif_data) +#define EncoderState(tif) ((LogLuvState*) (tif)->tif_data) #define SGILOGDATAFMT_UNKNOWN -1 @@ -180,207 +179,214 @@ struct logLuvState /* * Decode a string of 16-bit gray pixels. */ -static int LogL16Decode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) +static int +LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - static const char module[] = "LogL16Decode"; - LogLuvState *sp = DecoderState(tif); - int shft; - tmsize_t i; - tmsize_t npixels; - unsigned char *bp; - int16_t *tp; - int16_t b; - tmsize_t cc; - int rc; + static const char module[] = "LogL16Decode"; + LogLuvState* sp = DecoderState(tif); + int shft; + tmsize_t i; + tmsize_t npixels; + unsigned char* bp; + int16* tp; + int16 b; + tmsize_t cc; + int rc; - (void)s; - assert(s == 0); - assert(sp != NULL); + (void)s; + assert(s == 0); + assert(sp != NULL); - npixels = occ / sp->pixel_size; + npixels = occ / sp->pixel_size; - if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16_t *)op; - else - { - if (sp->tbuflen < npixels) - { - TIFFErrorExtR(tif, module, "Translation buffer too short"); - return (0); - } - tp = (int16_t *)sp->tbuf; - } - _TIFFmemset((void *)tp, 0, npixels * sizeof(tp[0])); + if (sp->user_datafmt == SGILOGDATAFMT_16BIT) + tp = (int16*) op; + else { + if(sp->tbuflen < npixels) { + TIFFErrorExt(tif->tif_clientdata, module, + "Translation buffer too short"); + return (0); + } + tp = (int16*) sp->tbuf; + } + _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); - bp = (unsigned char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - /* get each byte string */ - for (shft = 8; shft >= 0; shft -= 8) - { - for (i = 0; i < npixels && cc > 0;) - { - if (*bp >= 128) - { /* run */ - if (cc < 2) - break; - rc = *bp++ + (2 - 128); - 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_t)*bp++ << shft; - } - } - if (i != npixels) - { - TIFFErrorExtR(tif, module, - "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_t *)bp; - tif->tif_rawcc = cc; - return (1); + bp = (unsigned char*) tif->tif_rawcp; + cc = tif->tif_rawcc; + /* get each byte string */ + for (shft = 8; shft >= 0; shft -=8) { + for (i = 0; i < npixels && cc > 0; ) { + if (*bp >= 128) { /* run */ + if( cc < 2 ) + break; + rc = *bp++ + (2-128); + b = (int16)(*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; + } + } + 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; + tif->tif_rawcc = cc; + return (0); + } + } + (*sp->tfunc)(sp, op, npixels); + tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcc = cc; + return (1); } /* * Decode a string of 24-bit pixels. */ -static int LogLuvDecode24(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) +static int +LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - static const char module[] = "LogLuvDecode24"; - LogLuvState *sp = DecoderState(tif); - tmsize_t cc; - tmsize_t i; - tmsize_t npixels; - unsigned char *bp; - uint32_t *tp; + static const char module[] = "LogLuvDecode24"; + LogLuvState* sp = DecoderState(tif); + tmsize_t cc; + tmsize_t i; + tmsize_t npixels; + unsigned char* bp; + uint32* tp; - (void)s; - assert(s == 0); - assert(sp != NULL); + (void)s; + assert(s == 0); + assert(sp != NULL); - npixels = occ / sp->pixel_size; + npixels = occ / sp->pixel_size; - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32_t *)op; - else - { - if (sp->tbuflen < npixels) - { - TIFFErrorExtR(tif, module, "Translation buffer too short"); - return (0); - } - tp = (uint32_t *)sp->tbuf; - } - /* copy to array of uint32_t */ - bp = (unsigned char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - for (i = 0; i < npixels && cc >= 3; i++) - { - tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2]; - bp += 3; - cc -= 3; - } - tif->tif_rawcp = (uint8_t *)bp; - tif->tif_rawcc = cc; - if (i != npixels) - { - TIFFErrorExtR(tif, module, - "Not enough data at row %" PRIu32 - " (short %" TIFF_SSIZE_FORMAT " pixels)", - tif->tif_row, npixels - i); - return (0); - } - (*sp->tfunc)(sp, op, npixels); - return (1); + if (sp->user_datafmt == SGILOGDATAFMT_RAW) + tp = (uint32 *)op; + else { + if(sp->tbuflen < npixels) { + TIFFErrorExt(tif->tif_clientdata, module, + "Translation buffer too short"); + return (0); + } + tp = (uint32 *) sp->tbuf; + } + /* copy to array of uint32 */ + bp = (unsigned char*) tif->tif_rawcp; + cc = tif->tif_rawcc; + for (i = 0; i < npixels && cc >= 3; i++) { + tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2]; + bp += 3; + cc -= 3; + } + tif->tif_rawcp = (uint8*) 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 + return (0); + } + (*sp->tfunc)(sp, op, npixels); + return (1); } /* * Decode a string of 32-bit pixels. */ -static int LogLuvDecode32(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) +static int +LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - static const char module[] = "LogLuvDecode32"; - LogLuvState *sp; - int shft; - tmsize_t i; - tmsize_t npixels; - unsigned char *bp; - uint32_t *tp; - uint32_t b; - tmsize_t cc; - int rc; + static const char module[] = "LogLuvDecode32"; + LogLuvState* sp; + int shft; + tmsize_t i; + tmsize_t npixels; + unsigned char* bp; + uint32* tp; + uint32 b; + tmsize_t cc; + int rc; - (void)s; - assert(s == 0); - sp = DecoderState(tif); - assert(sp != NULL); + (void)s; + assert(s == 0); + sp = DecoderState(tif); + assert(sp != NULL); - npixels = occ / sp->pixel_size; + npixels = occ / sp->pixel_size; - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32_t *)op; - else - { - if (sp->tbuflen < npixels) - { - TIFFErrorExtR(tif, module, "Translation buffer too short"); - return (0); - } - tp = (uint32_t *)sp->tbuf; - } - _TIFFmemset((void *)tp, 0, npixels * sizeof(tp[0])); + if (sp->user_datafmt == SGILOGDATAFMT_RAW) + tp = (uint32*) op; + else { + if(sp->tbuflen < npixels) { + TIFFErrorExt(tif->tif_clientdata, module, + "Translation buffer too short"); + return (0); + } + tp = (uint32*) sp->tbuf; + } + _TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0])); - bp = (unsigned char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - /* get each byte string */ - for (shft = 24; shft >= 0; shft -= 8) - { - for (i = 0; i < npixels && cc > 0;) - { - if (*bp >= 128) - { /* run */ - if (cc < 2) - break; - rc = *bp++ + (2 - 128); - 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_t)*bp++ << shft; - } - } - if (i != npixels) - { - TIFFErrorExtR(tif, module, - "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_t *)bp; - tif->tif_rawcc = cc; - return (1); + bp = (unsigned char*) tif->tif_rawcp; + cc = tif->tif_rawcc; + /* get each byte string */ + for (shft = 24; shft >= 0; shft -=8) { + for (i = 0; i < npixels && cc > 0; ) { + if (*bp >= 128) { /* run */ + if( cc < 2 ) + break; + rc = *bp++ + (2-128); + b = (uint32)*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; + } + } + 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; + tif->tif_rawcc = cc; + return (0); + } + } + (*sp->tfunc)(sp, op, npixels); + tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcc = cc; + return (1); } /* @@ -388,20 +394,20 @@ static int LogLuvDecode32(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) * maintain synchrony with the encode algorithm, which * is row by row. */ -static int LogLuvDecodeStrip(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +LogLuvDecodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tmsize_t rowlen = TIFFScanlineSize(tif); + tmsize_t rowlen = TIFFScanlineSize(tif); - if (rowlen == 0) - return 0; + if (rowlen == 0) + return 0; - assert(cc % rowlen == 0); - while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) - { - bp += rowlen; - cc -= rowlen; - } - return (cc == 0); + assert(cc%rowlen == 0); + while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) { + bp += rowlen; + cc -= rowlen; + } + return (cc == 0); } /* @@ -409,342 +415,314 @@ static int LogLuvDecodeStrip(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) * maintain synchrony with the encode algorithm, which * is row by row. */ -static int LogLuvDecodeTile(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +LogLuvDecodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tmsize_t rowlen = TIFFTileRowSize(tif); + tmsize_t rowlen = TIFFTileRowSize(tif); - if (rowlen == 0) - return 0; + if (rowlen == 0) + return 0; - assert(cc % rowlen == 0); - while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) - { - bp += rowlen; - cc -= rowlen; - } - return (cc == 0); + assert(cc%rowlen == 0); + while (cc && (*tif->tif_decoderow)(tif, bp, rowlen, s)) { + bp += rowlen; + cc -= rowlen; + } + return (cc == 0); } /* * Encode a row of 16-bit pixels. */ -static int LogL16Encode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "LogL16Encode"; - LogLuvState *sp = EncoderState(tif); - int shft; - tmsize_t i; - tmsize_t j; - tmsize_t npixels; - uint8_t *op; - int16_t *tp; - int16_t b; - tmsize_t occ; - int rc = 0, mask; - tmsize_t beg; + static const char module[] = "LogL16Encode"; + LogLuvState* sp = EncoderState(tif); + int shft; + tmsize_t i; + tmsize_t j; + tmsize_t npixels; + uint8* op; + int16* tp; + int16 b; + tmsize_t occ; + int rc=0, mask; + tmsize_t beg; - (void)s; - assert(s == 0); - assert(sp != NULL); - npixels = cc / sp->pixel_size; + (void)s; + assert(s == 0); + assert(sp != NULL); + npixels = cc / sp->pixel_size; - if (sp->user_datafmt == SGILOGDATAFMT_16BIT) - tp = (int16_t *)bp; - else - { - tp = (int16_t *)sp->tbuf; - if (sp->tbuflen < npixels) - { - TIFFErrorExtR(tif, module, "Translation buffer too short"); - return (0); - } - (*sp->tfunc)(sp, bp, npixels); - } - /* compress each byte string */ - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - for (shft = 8; shft >= 0; shft -= 8) - { - for (i = 0; i < npixels; i += rc) - { - if (occ < 4) - { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (0); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - mask = 0xff << shft; /* find next run */ - for (beg = i; beg < npixels; beg += rc) - { - b = (int16_t)(tp[beg] & mask); - rc = 1; - while (rc < 127 + 2 && beg + rc < npixels && - (tp[beg + rc] & mask) == b) - rc++; - if (rc >= MINRUN) - break; /* long enough */ - } - if (beg - i > 1 && beg - i < MINRUN) - { - b = (int16_t)(tp[i] & mask); /*check short run */ - j = i + 1; - while ((tp[j++] & mask) == b) - if (j == beg) - { - *op++ = (uint8_t)(128 - 2 + j - i); - *op++ = (uint8_t)(b >> shft); - occ -= 2; - i = beg; - break; - } - } - while (i < beg) - { /* write out non-run */ - if ((j = beg - i) > 127) - j = 127; - if (occ < j + 3) - { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (0); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - *op++ = (uint8_t)j; - occ--; - while (j--) - { - *op++ = (uint8_t)(tp[i++] >> shft & 0xff); - occ--; - } - } - if (rc >= MINRUN) - { /* write out run */ - *op++ = (uint8_t)(128 - 2 + rc); - *op++ = (uint8_t)(tp[beg] >> shft & 0xff); - occ -= 2; - } - else - rc = 0; - } - } - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (sp->user_datafmt == SGILOGDATAFMT_16BIT) + tp = (int16*) bp; + else { + tp = (int16*) sp->tbuf; + if(sp->tbuflen < npixels) { + TIFFErrorExt(tif->tif_clientdata, module, + "Translation buffer too short"); + return (0); + } + (*sp->tfunc)(sp, bp, npixels); + } + /* compress each byte string */ + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + for (shft = 8; shft >= 0; shft -=8) { + for (i = 0; i < npixels; i += rc) { + if (occ < 4) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (!TIFFFlushData1(tif)) + return (0); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + } + mask = 0xff << shft; /* find next run */ + for (beg = i; beg < npixels; beg += rc) { + b = (int16) (tp[beg] & mask); + rc = 1; + while (rc < 127+2 && beg+rc < npixels && + (tp[beg+rc] & mask) == b) + rc++; + if (rc >= MINRUN) + break; /* long enough */ + } + if (beg-i > 1 && beg-i < MINRUN) { + b = (int16) (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); + occ -= 2; + i = beg; + break; + } + } + while (i < beg) { /* write out non-run */ + if ((j = beg-i) > 127) j = 127; + if (occ < j+3) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (!TIFFFlushData1(tif)) + return (0); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + } + *op++ = (uint8) j; occ--; + while (j--) { + *op++ = (uint8) (tp[i++] >> shft & 0xff); + occ--; + } + } + if (rc >= MINRUN) { /* write out run */ + *op++ = (uint8) (128-2+rc); + *op++ = (uint8) (tp[beg] >> shft & 0xff); + occ -= 2; + } else + rc = 0; + } + } + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; - return (1); + return (1); } /* * Encode a row of 24-bit pixels. */ -static int LogLuvEncode24(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "LogLuvEncode24"; - LogLuvState *sp = EncoderState(tif); - tmsize_t i; - tmsize_t npixels; - tmsize_t occ; - uint8_t *op; - uint32_t *tp; + static const char module[] = "LogLuvEncode24"; + LogLuvState* sp = EncoderState(tif); + tmsize_t i; + tmsize_t npixels; + tmsize_t occ; + uint8* op; + uint32* tp; - (void)s; - assert(s == 0); - assert(sp != NULL); - npixels = cc / sp->pixel_size; + (void)s; + assert(s == 0); + assert(sp != NULL); + npixels = cc / sp->pixel_size; - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32_t *)bp; - else - { - tp = (uint32_t *)sp->tbuf; - if (sp->tbuflen < npixels) - { - TIFFErrorExtR(tif, module, "Translation buffer too short"); - return (0); - } - (*sp->tfunc)(sp, bp, npixels); - } - /* write out encoded pixels */ - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - for (i = npixels; i--;) - { - if (occ < 3) - { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (0); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - *op++ = (uint8_t)(*tp >> 16); - *op++ = (uint8_t)(*tp >> 8 & 0xff); - *op++ = (uint8_t)(*tp++ & 0xff); - occ -= 3; - } - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (sp->user_datafmt == SGILOGDATAFMT_RAW) + tp = (uint32*) bp; + else { + tp = (uint32*) sp->tbuf; + if(sp->tbuflen < npixels) { + TIFFErrorExt(tif->tif_clientdata, module, + "Translation buffer too short"); + return (0); + } + (*sp->tfunc)(sp, bp, npixels); + } + /* write out encoded pixels */ + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + for (i = npixels; i--; ) { + if (occ < 3) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (!TIFFFlushData1(tif)) + return (0); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + } + *op++ = (uint8)(*tp >> 16); + *op++ = (uint8)(*tp >> 8 & 0xff); + *op++ = (uint8)(*tp++ & 0xff); + occ -= 3; + } + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; - return (1); + return (1); } /* * Encode a row of 32-bit pixels. */ -static int LogLuvEncode32(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "LogLuvEncode32"; - LogLuvState *sp = EncoderState(tif); - int shft; - tmsize_t i; - tmsize_t j; - tmsize_t npixels; - uint8_t *op; - uint32_t *tp; - uint32_t b; - tmsize_t occ; - int rc = 0; - tmsize_t beg; + static const char module[] = "LogLuvEncode32"; + LogLuvState* sp = EncoderState(tif); + int shft; + tmsize_t i; + tmsize_t j; + tmsize_t npixels; + uint8* op; + uint32* tp; + uint32 b; + tmsize_t occ; + int rc=0, mask; + tmsize_t beg; - (void)s; - assert(s == 0); - assert(sp != NULL); + (void)s; + assert(s == 0); + assert(sp != NULL); - npixels = cc / sp->pixel_size; + npixels = cc / sp->pixel_size; - if (sp->user_datafmt == SGILOGDATAFMT_RAW) - tp = (uint32_t *)bp; - else - { - tp = (uint32_t *)sp->tbuf; - if (sp->tbuflen < npixels) - { - TIFFErrorExtR(tif, module, "Translation buffer too short"); - return (0); - } - (*sp->tfunc)(sp, bp, npixels); - } - /* compress each byte string */ - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - for (shft = 24; shft >= 0; shft -= 8) - { - const uint32_t mask = 0xffU << shft; /* find next run */ - for (i = 0; i < npixels; i += rc) - { - if (occ < 4) - { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (0); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - for (beg = i; beg < npixels; beg += rc) - { - b = tp[beg] & mask; - rc = 1; - while (rc < 127 + 2 && beg + rc < npixels && - (tp[beg + rc] & mask) == b) - rc++; - if (rc >= MINRUN) - break; /* long enough */ - } - if (beg - i > 1 && beg - i < MINRUN) - { - b = tp[i] & mask; /* check short run */ - j = i + 1; - while ((tp[j++] & mask) == b) - if (j == beg) - { - *op++ = (uint8_t)(128 - 2 + j - i); - *op++ = (uint8_t)(b >> shft); - occ -= 2; - i = beg; - break; - } - } - while (i < beg) - { /* write out non-run */ - if ((j = beg - i) > 127) - j = 127; - if (occ < j + 3) - { - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; - if (!TIFFFlushData1(tif)) - return (0); - op = tif->tif_rawcp; - occ = tif->tif_rawdatasize - tif->tif_rawcc; - } - *op++ = (uint8_t)j; - occ--; - while (j--) - { - *op++ = (uint8_t)(tp[i++] >> shft & 0xff); - occ--; - } - } - if (rc >= MINRUN) - { /* write out run */ - *op++ = (uint8_t)(128 - 2 + rc); - *op++ = (uint8_t)(tp[beg] >> shft & 0xff); - occ -= 2; - } - else - rc = 0; - } - } - tif->tif_rawcp = op; - tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (sp->user_datafmt == SGILOGDATAFMT_RAW) + tp = (uint32*) bp; + else { + tp = (uint32*) sp->tbuf; + if(sp->tbuflen < npixels) { + TIFFErrorExt(tif->tif_clientdata, module, + "Translation buffer too short"); + return (0); + } + (*sp->tfunc)(sp, bp, npixels); + } + /* compress each byte string */ + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + for (shft = 24; shft >= 0; shft -=8) { + for (i = 0; i < npixels; i += rc) { + if (occ < 4) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (!TIFFFlushData1(tif)) + return (0); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + } + mask = 0xff << shft; /* find next run */ + for (beg = i; beg < npixels; beg += rc) { + b = tp[beg] & mask; + rc = 1; + while (rc < 127+2 && beg+rc < npixels && + (tp[beg+rc] & mask) == b) + rc++; + if (rc >= MINRUN) + break; /* long enough */ + } + if (beg-i > 1 && beg-i < MINRUN) { + b = 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); + occ -= 2; + i = beg; + break; + } + } + while (i < beg) { /* write out non-run */ + if ((j = beg-i) > 127) j = 127; + if (occ < j+3) { + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; + if (!TIFFFlushData1(tif)) + return (0); + op = tif->tif_rawcp; + occ = tif->tif_rawdatasize - tif->tif_rawcc; + } + *op++ = (uint8) j; occ--; + while (j--) { + *op++ = (uint8)(tp[i++] >> shft & 0xff); + occ--; + } + } + if (rc >= MINRUN) { /* write out run */ + *op++ = (uint8) (128-2+rc); + *op++ = (uint8)(tp[beg] >> shft & 0xff); + occ -= 2; + } else + rc = 0; + } + } + tif->tif_rawcp = op; + tif->tif_rawcc = tif->tif_rawdatasize - occ; - return (1); + return (1); } /* * Encode a strip of pixels. We break it into rows to * avoid encoding runs across row boundaries. */ -static int LogLuvEncodeStrip(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +LogLuvEncodeStrip(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tmsize_t rowlen = TIFFScanlineSize(tif); + tmsize_t rowlen = TIFFScanlineSize(tif); - if (rowlen == 0) - return 0; + if (rowlen == 0) + return 0; - assert(cc % rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) - { - bp += rowlen; - cc -= rowlen; - } - return (cc == 0); + assert(cc%rowlen == 0); + while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) { + bp += rowlen; + cc -= rowlen; + } + return (cc == 0); } /* * Encode a tile of pixels. We break it into rows to * avoid encoding runs across row boundaries. */ -static int LogLuvEncodeTile(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +LogLuvEncodeTile(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tmsize_t rowlen = TIFFTileRowSize(tif); + tmsize_t rowlen = TIFFTileRowSize(tif); - if (rowlen == 0) - return 0; + if (rowlen == 0) + return 0; - assert(cc % rowlen == 0); - while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) - { - bp += rowlen; - cc -= rowlen; - } - return (cc == 0); + assert(cc%rowlen == 0); + while (cc && (*tif->tif_encoderow)(tif, bp, rowlen, s) == 1) { + bp += rowlen; + cc -= rowlen; + } + return (cc == 0); } /* @@ -754,192 +732,190 @@ static int LogLuvEncodeTile(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) #include "uvcode.h" #ifndef UVSCALE -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. +#define U_NEU 0.210526316 +#define V_NEU 0.473684211 +#define UVSCALE 410. #endif -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 +#ifndef M_LN2 +#define M_LN2 0.69314718055994530942 #endif #ifndef M_PI -#define M_PI 3.14159265358979323846 +#define M_PI 3.14159265358979323846 #endif #undef log2 /* Conflict with C'99 function */ -#define log2(x) ((1. / M_LN2) * log(x)) -#undef exp2 /* Conflict with C'99 function */ -#define exp2(x) exp(M_LN2 *(x)) +#define log2(x) ((1./M_LN2)*log(x)) +#undef exp2 /* Conflict with C'99 function */ +#define exp2(x) exp(M_LN2*(x)) static int tiff_itrunc(double x, int m) { - if (m == SGILOGENCODE_NODITHER) + if( m == SGILOGENCODE_NODITHER ) return (int)x; /* Silence CoverityScan warning about bad crypto function */ /* coverity[dont_call] */ - return (int)(x + rand() * (1. / RAND_MAX) - .5); + return (int)(x + rand()*(1./RAND_MAX) - .5); } #if !LOGLUV_PUBLIC static #endif - double - LogL16toY(int p16) /* compute luminance from 16-bit LogL */ +double +LogL16toY(int p16) /* compute luminance from 16-bit LogL */ { - int Le = p16 & 0x7fff; - double Y; + int Le = p16 & 0x7fff; + double Y; - if (!Le) - return (0.); - Y = exp(M_LN2 / 256. * (Le + .5) - M_LN2 * 64.); - return (!(p16 & 0x8000) ? Y : -Y); + if (!Le) + return (0.); + Y = exp(M_LN2/256.*(Le+.5) - M_LN2*64.); + return (!(p16 & 0x8000) ? Y : -Y); } #if !LOGLUV_PUBLIC static #endif - int - LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */ +int +LogL16fromY(double Y, int em) /* get 16-bit LogL from Y */ { - if (Y >= 1.8371976e19) - return (0x7fff); - if (Y <= -1.8371976e19) - return (0xffff); - if (Y > 5.4136769e-20) - return tiff_itrunc(256. * (log2(Y) + 64.), em); - if (Y < -5.4136769e-20) - return (~0x7fff | tiff_itrunc(256. * (log2(-Y) + 64.), em)); - return (0); + if (Y >= 1.8371976e19) + return (0x7fff); + if (Y <= -1.8371976e19) + return (0xffff); + if (Y > 5.4136769e-20) + return tiff_itrunc(256.*(log2(Y) + 64.), em); + if (Y < -5.4136769e-20) + return (~0x7fff | tiff_itrunc(256.*(log2(-Y) + 64.), em)); + return (0); } -static void L16toY(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +L16toY(LogLuvState* sp, uint8* op, tmsize_t n) { - int16_t *l16 = (int16_t *)sp->tbuf; - float *yp = (float *)op; + int16* l16 = (int16*) sp->tbuf; + float* yp = (float*) op; - while (n-- > 0) - *yp++ = (float)LogL16toY(*l16++); + while (n-- > 0) + *yp++ = (float)LogL16toY(*l16++); } -static void L16toGry(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +L16toGry(LogLuvState* sp, uint8* op, tmsize_t n) { - int16_t *l16 = (int16_t *)sp->tbuf; - uint8_t *gp = (uint8_t *)op; + int16* l16 = (int16*) sp->tbuf; + uint8* gp = (uint8*) op; - while (n-- > 0) - { - double Y = LogL16toY(*l16++); - *gp++ = (uint8_t)((Y <= 0.) ? 0 - : (Y >= 1.) ? 255 - : (int)(256. * sqrt(Y))); - } + while (n-- > 0) { + double Y = LogL16toY(*l16++); + *gp++ = (uint8) ((Y <= 0.) ? 0 : (Y >= 1.) ? 255 : (int)(256.*sqrt(Y))); + } } -static void L16fromY(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +L16fromY(LogLuvState* sp, uint8* op, tmsize_t n) { - int16_t *l16 = (int16_t *)sp->tbuf; - float *yp = (float *)op; + int16* l16 = (int16*) sp->tbuf; + float* yp = (float*) op; - while (n-- > 0) - *l16++ = (int16_t)(LogL16fromY(*yp++, sp->encode_meth)); + while (n-- > 0) + *l16++ = (int16) (LogL16fromY(*yp++, sp->encode_meth)); } #if !LOGLUV_PUBLIC static #endif - void - XYZtoRGB24(float *xyz, uint8_t *rgb) +void +XYZtoRGB24(float xyz[3], uint8 rgb[3]) { - double r, g, b; - /* assume CCIR-709 primaries */ - r = 2.690 * xyz[0] + -1.276 * xyz[1] + -0.414 * xyz[2]; - g = -1.022 * xyz[0] + 1.978 * xyz[1] + 0.044 * xyz[2]; - 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_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))); + double r, g, b; + /* assume CCIR-709 primaries */ + r = 2.690*xyz[0] + -1.276*xyz[1] + -0.414*xyz[2]; + g = -1.022*xyz[0] + 1.978*xyz[1] + 0.044*xyz[2]; + 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))); } #if !LOGLUV_PUBLIC static #endif - double - LogL10toY(int p10) /* compute luminance from 10-bit LogL */ +double +LogL10toY(int p10) /* compute luminance from 10-bit LogL */ { - if (p10 == 0) - return (0.); - return (exp(M_LN2 / 64. * (p10 + .5) - M_LN2 * 12.)); + if (p10 == 0) + return (0.); + return (exp(M_LN2/64.*(p10+.5) - M_LN2*12.)); } #if !LOGLUV_PUBLIC static #endif - int - LogL10fromY(double Y, int em) /* get 10-bit LogL from Y */ +int +LogL10fromY(double Y, int em) /* get 10-bit LogL from Y */ { - if (Y >= 15.742) - return (0x3ff); - else if (Y <= .00024283) - return (0); - else - return tiff_itrunc(64. * (log2(Y) + 12.), em); + if (Y >= 15.742) + return (0x3ff); + else if (Y <= .00024283) + return (0); + else + return tiff_itrunc(64.*(log2(Y) + 12.), em); } -#define NANGLES 100 -#define uv2ang(u, v) \ - ((NANGLES * .499999999 / M_PI) * atan2((v)-V_NEU, (u)-U_NEU) + .5 * NANGLES) +#define NANGLES 100 +#define uv2ang(u, v) ( (NANGLES*.499999999/M_PI) \ + * atan2((v)-V_NEU,(u)-U_NEU) + .5*NANGLES ) -static int oog_encode(double u, double v) /* encode out-of-gamut chroma */ +static int +oog_encode(double u, double v) /* encode out-of-gamut chroma */ { - static int oog_table[NANGLES]; - static int initialized = 0; - register int i; + static int oog_table[NANGLES]; + static int initialized = 0; + register int i; - if (!initialized) - { /* set up perimeter table */ - double eps[NANGLES], ua, va, ang, epsa; - int ui, vi, ustep; - for (i = NANGLES; i--;) - eps[i] = 2.; - for (vi = UV_NVS; vi--;) - { - va = UV_VSTART + (vi + .5) * UV_SQSIZ; - ustep = uv_row[vi].nus - 1; - if (vi == UV_NVS - 1 || vi == 0 || ustep <= 0) - ustep = 1; - for (ui = uv_row[vi].nus - 1; ui >= 0; ui -= ustep) - { - ua = uv_row[vi].ustart + (ui + .5) * UV_SQSIZ; - ang = uv2ang(ua, va); - i = (int)ang; - epsa = fabs(ang - (i + .5)); - if (epsa < eps[i]) - { - oog_table[i] = uv_row[vi].ncum + ui; - eps[i] = epsa; - } - } - } - for (i = NANGLES; i--;) /* fill any holes */ - if (eps[i] > 1.5) - { - int i1, i2; - for (i1 = 1; i1 < NANGLES / 2; i1++) - if (eps[(i + i1) % NANGLES] < 1.5) - break; - for (i2 = 1; i2 < NANGLES / 2; i2++) - if (eps[(i + NANGLES - i2) % NANGLES] < 1.5) - break; - if (i1 < i2) - oog_table[i] = oog_table[(i + i1) % NANGLES]; - else - oog_table[i] = oog_table[(i + NANGLES - i2) % NANGLES]; - } - initialized = 1; - } - i = (int)uv2ang(u, v); /* look up hue angle */ - return (oog_table[i]); + if (!initialized) { /* set up perimeter table */ + double eps[NANGLES], ua, va, ang, epsa; + int ui, vi, ustep; + for (i = NANGLES; i--; ) + eps[i] = 2.; + for (vi = UV_NVS; vi--; ) { + va = UV_VSTART + (vi+.5)*UV_SQSIZ; + ustep = uv_row[vi].nus-1; + if (vi == UV_NVS-1 || vi == 0 || ustep <= 0) + ustep = 1; + for (ui = uv_row[vi].nus-1; ui >= 0; ui -= ustep) { + ua = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ; + ang = uv2ang(ua, va); + i = (int) ang; + epsa = fabs(ang - (i+.5)); + if (epsa < eps[i]) { + oog_table[i] = uv_row[vi].ncum + ui; + eps[i] = epsa; + } + } + } + for (i = NANGLES; i--; ) /* fill any holes */ + if (eps[i] > 1.5) { + int i1, i2; + for (i1 = 1; i1 < NANGLES/2; i1++) + if (eps[(i+i1)%NANGLES] < 1.5) + break; + for (i2 = 1; i2 < NANGLES/2; i2++) + if (eps[(i+NANGLES-i2)%NANGLES] < 1.5) + break; + if (i1 < i2) + oog_table[i] = + oog_table[(i+i1)%NANGLES]; + else + oog_table[i] = + oog_table[(i+NANGLES-i2)%NANGLES]; + } + initialized = 1; + } + i = (int) uv2ang(u, v); /* look up hue angle */ + return (oog_table[i]); } #undef uv2ang @@ -948,891 +924,847 @@ static int oog_encode(double u, double v) /* encode out-of-gamut chroma */ #if !LOGLUV_PUBLIC static #endif - int - uv_encode(double u, double v, int em) /* encode (u',v') coordinates */ +int +uv_encode(double u, double v, int em) /* encode (u',v') coordinates */ { - register int vi, ui; + register int vi, ui; - /* check for NaN */ - if (u != u || v != v) - { - u = U_NEU; - v = V_NEU; - } + if (v < UV_VSTART) + return oog_encode(u, v); + vi = tiff_itrunc((v - UV_VSTART)*(1./UV_SQSIZ), em); + if (vi >= UV_NVS) + return oog_encode(u, v); + if (u < uv_row[vi].ustart) + return oog_encode(u, v); + ui = tiff_itrunc((u - uv_row[vi].ustart)*(1./UV_SQSIZ), em); + if (ui >= uv_row[vi].nus) + return oog_encode(u, v); - if (v < UV_VSTART) - return oog_encode(u, v); - vi = tiff_itrunc((v - UV_VSTART) * (1. / UV_SQSIZ), em); - if (vi >= UV_NVS) - return oog_encode(u, v); - if (u < uv_row[vi].ustart) - return oog_encode(u, v); - ui = tiff_itrunc((u - uv_row[vi].ustart) * (1. / UV_SQSIZ), em); - if (ui >= uv_row[vi].nus) - return oog_encode(u, v); - - return (uv_row[vi].ncum + ui); + return (uv_row[vi].ncum + ui); } #if !LOGLUV_PUBLIC static #endif - int - uv_decode(double *up, double *vp, int c) /* decode (u',v') index */ +int +uv_decode(double *up, double *vp, int c) /* decode (u',v') index */ { - int upper, lower; - register int ui, vi; + int upper, lower; + register int ui, vi; - if (c < 0 || c >= UV_NDIVS) - return (-1); - lower = 0; /* binary search */ - upper = UV_NVS; - while (upper - lower > 1) - { - vi = (lower + upper) >> 1; - ui = c - uv_row[vi].ncum; - if (ui > 0) - lower = vi; - else if (ui < 0) - upper = vi; - else - { - lower = vi; - break; - } - } - vi = lower; - ui = c - uv_row[vi].ncum; - *up = uv_row[vi].ustart + (ui + .5) * UV_SQSIZ; - *vp = UV_VSTART + (vi + .5) * UV_SQSIZ; - return (0); + if (c < 0 || c >= UV_NDIVS) + return (-1); + lower = 0; /* binary search */ + upper = UV_NVS; + while (upper - lower > 1) { + vi = (lower + upper) >> 1; + ui = c - uv_row[vi].ncum; + if (ui > 0) + lower = vi; + else if (ui < 0) + upper = vi; + else { + lower = vi; + break; + } + } + vi = lower; + ui = c - uv_row[vi].ncum; + *up = uv_row[vi].ustart + (ui+.5)*UV_SQSIZ; + *vp = UV_VSTART + (vi+.5)*UV_SQSIZ; + return (0); } #if !LOGLUV_PUBLIC static #endif - void - LogLuv24toXYZ(uint32_t p, float *XYZ) +void +LogLuv24toXYZ(uint32 p, float XYZ[3]) { - int Ce; - double L, u, v, s, x, y; - /* decode luminance */ - L = LogL10toY(p >> 14 & 0x3ff); - if (L <= 0.) - { - XYZ[0] = XYZ[1] = XYZ[2] = 0.; - return; - } - /* decode color */ - Ce = p & 0x3fff; - if (uv_decode(&u, &v, Ce) < 0) - { - u = U_NEU; - v = V_NEU; - } - s = 1. / (6. * u - 16. * v + 12.); - x = 9. * u * s; - y = 4. * v * s; - /* convert to XYZ */ - XYZ[0] = (float)(x / y * L); - XYZ[1] = (float)L; - XYZ[2] = (float)((1. - x - y) / y * L); + int Ce; + double L, u, v, s, x, y; + /* decode luminance */ + L = LogL10toY(p>>14 & 0x3ff); + if (L <= 0.) { + XYZ[0] = XYZ[1] = XYZ[2] = 0.; + return; + } + /* decode color */ + Ce = p & 0x3fff; + if (uv_decode(&u, &v, Ce) < 0) { + u = U_NEU; v = V_NEU; + } + s = 1./(6.*u - 16.*v + 12.); + x = 9.*u * s; + y = 4.*v * s; + /* convert to XYZ */ + XYZ[0] = (float)(x/y * L); + XYZ[1] = (float)L; + XYZ[2] = (float)((1.-x-y)/y * L); } #if !LOGLUV_PUBLIC static #endif - uint32_t - LogLuv24fromXYZ(float *XYZ, int em) +uint32 +LogLuv24fromXYZ(float XYZ[3], int em) { - int Le, Ce; - double u, v, s; - /* encode luminance */ - Le = LogL10fromY(XYZ[1], em); - /* encode color */ - s = XYZ[0] + 15. * XYZ[1] + 3. * XYZ[2]; - if (!Le || s <= 0.) - { - u = U_NEU; - v = V_NEU; - } - else - { - u = 4. * XYZ[0] / s; - v = 9. * XYZ[1] / s; - } - Ce = uv_encode(u, v, em); - if (Ce < 0) /* never happens */ - Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); - /* combine encodings */ - return (Le << 14 | Ce); + int Le, Ce; + double u, v, s; + /* encode luminance */ + Le = LogL10fromY(XYZ[1], em); + /* encode color */ + s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2]; + if (!Le || s <= 0.) { + u = U_NEU; + v = V_NEU; + } else { + u = 4.*XYZ[0] / s; + v = 9.*XYZ[1] / s; + } + Ce = uv_encode(u, v, em); + if (Ce < 0) /* never happens */ + Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); + /* combine encodings */ + return (Le << 14 | Ce); } -static void Luv24toXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv24toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - float *xyz = (float *)op; + uint32* luv = (uint32*) sp->tbuf; + float* xyz = (float*) op; - while (n-- > 0) - { - LogLuv24toXYZ(*luv, xyz); - xyz += 3; - luv++; - } + while (n-- > 0) { + LogLuv24toXYZ(*luv, xyz); + xyz += 3; + luv++; + } } -static void Luv24toLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv24toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - int16_t *luv3 = (int16_t *)op; + uint32* luv = (uint32*) sp->tbuf; + int16* luv3 = (int16*) op; - while (n-- > 0) - { - double u, v; + while (n-- > 0) { + double u, v; - *luv3++ = (int16_t)((*luv >> 12 & 0xffd) + 13314); - if (uv_decode(&u, &v, *luv & 0x3fff) < 0) - { - u = U_NEU; - v = V_NEU; - } - *luv3++ = (int16_t)(u * (1L << 15)); - *luv3++ = (int16_t)(v * (1L << 15)); - luv++; - } + *luv3++ = (int16)((*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)); + luv++; + } } -static void Luv24toRGB(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv24toRGB(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - uint8_t *rgb = (uint8_t *)op; + uint32* luv = (uint32*) sp->tbuf; + uint8* rgb = (uint8*) op; - while (n-- > 0) - { - float xyz[3]; + while (n-- > 0) { + float xyz[3]; - LogLuv24toXYZ(*luv++, xyz); - XYZtoRGB24(xyz, rgb); - rgb += 3; - } + LogLuv24toXYZ(*luv++, xyz); + XYZtoRGB24(xyz, rgb); + rgb += 3; + } } -static void Luv24fromXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv24fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - float *xyz = (float *)op; + uint32* luv = (uint32*) sp->tbuf; + float* xyz = (float*) op; - while (n-- > 0) - { - *luv++ = LogLuv24fromXYZ(xyz, sp->encode_meth); - xyz += 3; - } + while (n-- > 0) { + *luv++ = LogLuv24fromXYZ(xyz, sp->encode_meth); + xyz += 3; + } } -static void Luv24fromLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv24fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - int16_t *luv3 = (int16_t *)op; + uint32* luv = (uint32*) sp->tbuf; + int16* luv3 = (int16*) op; - while (n-- > 0) - { - int Le, Ce; + while (n-- > 0) { + int Le, Ce; - if (luv3[0] <= 0) - Le = 0; - else if (luv3[0] >= (1 << 12) + 3314) - Le = (1 << 10) - 1; - else if (sp->encode_meth == SGILOGENCODE_NODITHER) - Le = (luv3[0] - 3314) >> 2; - else - Le = tiff_itrunc(.25 * (luv3[0] - 3314.), sp->encode_meth); + if (luv3[0] <= 0) + Le = 0; + else if (luv3[0] >= (1<<12)+3314) + Le = (1<<10) - 1; + else if (sp->encode_meth == SGILOGENCODE_NODITHER) + Le = (luv3[0]-3314) >> 2; + else + Le = tiff_itrunc(.25*(luv3[0]-3314.), sp->encode_meth); - Ce = uv_encode((luv3[1] + .5) / (1 << 15), (luv3[2] + .5) / (1 << 15), - sp->encode_meth); - if (Ce < 0) /* never happens */ - Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); - *luv++ = (uint32_t)Le << 14 | Ce; - luv3 += 3; - } + Ce = uv_encode((luv3[1]+.5)/(1<<15), (luv3[2]+.5)/(1<<15), + sp->encode_meth); + if (Ce < 0) /* never happens */ + Ce = uv_encode(U_NEU, V_NEU, SGILOGENCODE_NODITHER); + *luv++ = (uint32)Le << 14 | Ce; + luv3 += 3; + } } #if !LOGLUV_PUBLIC static #endif - void - LogLuv32toXYZ(uint32_t p, float *XYZ) +void +LogLuv32toXYZ(uint32 p, float XYZ[3]) { - double L, u, v, s, x, y; - /* decode luminance */ - L = LogL16toY((int)p >> 16); - if (L <= 0.) - { - XYZ[0] = XYZ[1] = XYZ[2] = 0.; - return; - } - /* decode color */ - u = 1. / UVSCALE * ((p >> 8 & 0xff) + .5); - v = 1. / UVSCALE * ((p & 0xff) + .5); - s = 1. / (6. * u - 16. * v + 12.); - x = 9. * u * s; - y = 4. * v * s; - /* convert to XYZ */ - XYZ[0] = (float)(x / y * L); - XYZ[1] = (float)L; - XYZ[2] = (float)((1. - x - y) / y * L); + double L, u, v, s, x, y; + /* decode luminance */ + L = LogL16toY((int)p >> 16); + if (L <= 0.) { + XYZ[0] = XYZ[1] = XYZ[2] = 0.; + return; + } + /* decode color */ + u = 1./UVSCALE * ((p>>8 & 0xff) + .5); + v = 1./UVSCALE * ((p & 0xff) + .5); + s = 1./(6.*u - 16.*v + 12.); + x = 9.*u * s; + y = 4.*v * s; + /* convert to XYZ */ + XYZ[0] = (float)(x/y * L); + XYZ[1] = (float)L; + XYZ[2] = (float)((1.-x-y)/y * L); } #if !LOGLUV_PUBLIC static #endif - uint32_t - LogLuv32fromXYZ(float *XYZ, int em) +uint32 +LogLuv32fromXYZ(float XYZ[3], int em) { - unsigned int Le, ue, ve; - double u, v, s; - /* encode luminance */ - Le = (unsigned int)LogL16fromY(XYZ[1], em); - /* encode color */ - s = XYZ[0] + 15. * XYZ[1] + 3. * XYZ[2]; - if (!Le || s <= 0.) - { - u = U_NEU; - v = V_NEU; - } - else - { - u = 4. * XYZ[0] / s; - v = 9. * XYZ[1] / s; - } - if (u <= 0.) - ue = 0; - else - ue = tiff_itrunc(UVSCALE * u, em); - if (ue > 255) - ue = 255; - if (v <= 0.) - ve = 0; - else - ve = tiff_itrunc(UVSCALE * v, em); - if (ve > 255) - ve = 255; - /* combine encodings */ - return (Le << 16 | ue << 8 | ve); + unsigned int Le, ue, ve; + double u, v, s; + /* encode luminance */ + Le = (unsigned int)LogL16fromY(XYZ[1], em); + /* encode color */ + s = XYZ[0] + 15.*XYZ[1] + 3.*XYZ[2]; + if (!Le || s <= 0.) { + u = U_NEU; + v = V_NEU; + } else { + u = 4.*XYZ[0] / s; + v = 9.*XYZ[1] / s; + } + if (u <= 0.) ue = 0; + else ue = tiff_itrunc(UVSCALE*u, em); + if (ue > 255) ue = 255; + if (v <= 0.) ve = 0; + else ve = tiff_itrunc(UVSCALE*v, em); + if (ve > 255) ve = 255; + /* combine encodings */ + return (Le << 16 | ue << 8 | ve); } -static void Luv32toXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv32toXYZ(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - float *xyz = (float *)op; + uint32* luv = (uint32*) sp->tbuf; + float* xyz = (float*) op; - while (n-- > 0) - { - LogLuv32toXYZ(*luv++, xyz); - xyz += 3; - } + while (n-- > 0) { + LogLuv32toXYZ(*luv++, xyz); + xyz += 3; + } } -static void Luv32toLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv32toLuv48(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - int16_t *luv3 = (int16_t *)op; + uint32* luv = (uint32*) sp->tbuf; + int16* luv3 = (int16*) op; - while (n-- > 0) - { - double u, v; + while (n-- > 0) { + double u, v; - *luv3++ = (int16_t)(*luv >> 16); - u = 1. / UVSCALE * ((*luv >> 8 & 0xff) + .5); - v = 1. / UVSCALE * ((*luv & 0xff) + .5); - *luv3++ = (int16_t)(u * (1L << 15)); - *luv3++ = (int16_t)(v * (1L << 15)); - luv++; - } + *luv3++ = (int16)(*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)); + luv++; + } } -static void Luv32toRGB(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv32toRGB(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - uint8_t *rgb = (uint8_t *)op; + uint32* luv = (uint32*) sp->tbuf; + uint8* rgb = (uint8*) op; - while (n-- > 0) - { - float xyz[3]; + while (n-- > 0) { + float xyz[3]; - LogLuv32toXYZ(*luv++, xyz); - XYZtoRGB24(xyz, rgb); - rgb += 3; - } + LogLuv32toXYZ(*luv++, xyz); + XYZtoRGB24(xyz, rgb); + rgb += 3; + } } -static void Luv32fromXYZ(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv32fromXYZ(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - float *xyz = (float *)op; + uint32* luv = (uint32*) sp->tbuf; + float* xyz = (float*) op; - while (n-- > 0) - { - *luv++ = LogLuv32fromXYZ(xyz, sp->encode_meth); - xyz += 3; - } + while (n-- > 0) { + *luv++ = LogLuv32fromXYZ(xyz, sp->encode_meth); + xyz += 3; + } } -static void Luv32fromLuv48(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +Luv32fromLuv48(LogLuvState* sp, uint8* op, tmsize_t n) { - uint32_t *luv = (uint32_t *)sp->tbuf; - int16_t *luv3 = (int16_t *)op; + uint32* luv = (uint32*) sp->tbuf; + int16* luv3 = (int16*) op; - if (sp->encode_meth == SGILOGENCODE_NODITHER) - { - while (n-- > 0) - { - *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_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; - } + 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); + 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); + luv3 += 3; + } } -static void _logLuvNop(LogLuvState *sp, uint8_t *op, tmsize_t n) +static void +_logLuvNop(LogLuvState* sp, uint8* op, tmsize_t n) { - (void)sp; - (void)op; - (void)n; + (void) sp; (void) op; (void) n; } -static int LogL16GuessDataFmt(TIFFDirectory *td) +static int +LogL16GuessDataFmt(TIFFDirectory *td) { -#define PACK(s, b, f) (((b) << 6) | ((s) << 3) | (f)) - switch ( - PACK(td->td_samplesperpixel, td->td_bitspersample, td->td_sampleformat)) - { - case PACK(1, 32, SAMPLEFORMAT_IEEEFP): - return (SGILOGDATAFMT_FLOAT); - case PACK(1, 16, SAMPLEFORMAT_VOID): - case PACK(1, 16, SAMPLEFORMAT_INT): - case PACK(1, 16, SAMPLEFORMAT_UINT): - return (SGILOGDATAFMT_16BIT); - case PACK(1, 8, SAMPLEFORMAT_VOID): - case PACK(1, 8, SAMPLEFORMAT_UINT): - return (SGILOGDATAFMT_8BIT); - } +#define PACK(s,b,f) (((b)<<6)|((s)<<3)|(f)) + switch (PACK(td->td_samplesperpixel, td->td_bitspersample, td->td_sampleformat)) { + case PACK(1, 32, SAMPLEFORMAT_IEEEFP): + return (SGILOGDATAFMT_FLOAT); + case PACK(1, 16, SAMPLEFORMAT_VOID): + case PACK(1, 16, SAMPLEFORMAT_INT): + case PACK(1, 16, SAMPLEFORMAT_UINT): + return (SGILOGDATAFMT_16BIT); + case PACK(1, 8, SAMPLEFORMAT_VOID): + case PACK(1, 8, SAMPLEFORMAT_UINT): + return (SGILOGDATAFMT_8BIT); + } #undef PACK - return (SGILOGDATAFMT_UNKNOWN); + return (SGILOGDATAFMT_UNKNOWN); } -static tmsize_t multiply_ms(tmsize_t m1, tmsize_t m2) +static tmsize_t +multiply_ms(tmsize_t m1, tmsize_t m2) { - return _TIFFMultiplySSize(NULL, m1, m2, NULL); + return _TIFFMultiplySSize(NULL, m1, m2, NULL); } -static int LogL16InitState(TIFF *tif) +static int +LogL16InitState(TIFF* tif) { - static const char module[] = "LogL16InitState"; - TIFFDirectory *td = &tif->tif_dir; - LogLuvState *sp = DecoderState(tif); + static const char module[] = "LogL16InitState"; + TIFFDirectory *td = &tif->tif_dir; + LogLuvState* sp = DecoderState(tif); - assert(sp != NULL); - assert(td->td_photometric == PHOTOMETRIC_LOGL); + assert(sp != NULL); + assert(td->td_photometric == PHOTOMETRIC_LOGL); - if (td->td_samplesperpixel != 1) - { - TIFFErrorExtR(tif, module, - "Sorry, can not handle LogL image with %s=%" PRIu16, - "Samples/pixel", td->td_samplesperpixel); - return 0; - } + if( td->td_samplesperpixel != 1 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Sorry, can not handle LogL image with %s=%d", + "Samples/pixel", td->td_samplesperpixel); + return 0; + } - /* for some reason, we can't do this in TIFFInitLogL16 */ - if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) - sp->user_datafmt = LogL16GuessDataFmt(td); - switch (sp->user_datafmt) - { - case SGILOGDATAFMT_FLOAT: - sp->pixel_size = sizeof(float); - break; - case SGILOGDATAFMT_16BIT: - sp->pixel_size = sizeof(int16_t); - break; - case SGILOGDATAFMT_8BIT: - sp->pixel_size = sizeof(uint8_t); - break; - default: - TIFFErrorExtR(tif, module, - "No support for converting user data format to LogL"); - return (0); - } - if (isTiled(tif)) - sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength); - else if (td->td_rowsperstrip < td->td_imagelength) - 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_t)) == 0 || - (sp->tbuf = (uint8_t *)_TIFFmallocExt( - tif, sp->tbuflen * sizeof(int16_t))) == NULL) - { - TIFFErrorExtR(tif, module, "No space for SGILog translation buffer"); - return (0); - } - return (1); + /* for some reason, we can't do this in TIFFInitLogL16 */ + if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) + sp->user_datafmt = LogL16GuessDataFmt(td); + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->pixel_size = sizeof (float); + break; + case SGILOGDATAFMT_16BIT: + sp->pixel_size = sizeof (int16); + break; + case SGILOGDATAFMT_8BIT: + sp->pixel_size = sizeof (uint8); + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "No support for converting user data format to LogL"); + return (0); + } + if( isTiled(tif) ) + sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength); + else if( td->td_rowsperstrip < td->td_imagelength ) + 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) { + TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); + return (0); + } + return (1); } -static int LogLuvGuessDataFmt(TIFFDirectory *td) +static int +LogLuvGuessDataFmt(TIFFDirectory *td) { - int guess; + int guess; - /* - * If the user didn't tell us their datafmt, - * take our best guess from the bitspersample. - */ -#define PACK(a, b) (((a) << 3) | (b)) - switch (PACK(td->td_bitspersample, td->td_sampleformat)) - { - case PACK(32, SAMPLEFORMAT_IEEEFP): - guess = SGILOGDATAFMT_FLOAT; - break; - case PACK(32, SAMPLEFORMAT_VOID): - case PACK(32, SAMPLEFORMAT_UINT): - case PACK(32, SAMPLEFORMAT_INT): - guess = SGILOGDATAFMT_RAW; - break; - case PACK(16, SAMPLEFORMAT_VOID): - case PACK(16, SAMPLEFORMAT_INT): - case PACK(16, SAMPLEFORMAT_UINT): - guess = SGILOGDATAFMT_16BIT; - break; - case PACK(8, SAMPLEFORMAT_VOID): - case PACK(8, SAMPLEFORMAT_UINT): - guess = SGILOGDATAFMT_8BIT; - break; - default: - guess = SGILOGDATAFMT_UNKNOWN; - break; + /* + * If the user didn't tell us their datafmt, + * take our best guess from the bitspersample. + */ +#define PACK(a,b) (((a)<<3)|(b)) + switch (PACK(td->td_bitspersample, td->td_sampleformat)) { + case PACK(32, SAMPLEFORMAT_IEEEFP): + guess = SGILOGDATAFMT_FLOAT; + break; + case PACK(32, SAMPLEFORMAT_VOID): + case PACK(32, SAMPLEFORMAT_UINT): + case PACK(32, SAMPLEFORMAT_INT): + guess = SGILOGDATAFMT_RAW; + break; + case PACK(16, SAMPLEFORMAT_VOID): + case PACK(16, SAMPLEFORMAT_INT): + case PACK(16, SAMPLEFORMAT_UINT): + guess = SGILOGDATAFMT_16BIT; + break; + case PACK( 8, SAMPLEFORMAT_VOID): + case PACK( 8, SAMPLEFORMAT_UINT): + guess = SGILOGDATAFMT_8BIT; + break; + default: + guess = SGILOGDATAFMT_UNKNOWN; + break; #undef PACK - } - /* - * Double-check samples per pixel. - */ - switch (td->td_samplesperpixel) - { - case 1: - if (guess != SGILOGDATAFMT_RAW) - guess = SGILOGDATAFMT_UNKNOWN; - break; - case 3: - if (guess == SGILOGDATAFMT_RAW) - guess = SGILOGDATAFMT_UNKNOWN; - break; - default: - guess = SGILOGDATAFMT_UNKNOWN; - break; - } - return (guess); + } + /* + * Double-check samples per pixel. + */ + switch (td->td_samplesperpixel) { + case 1: + if (guess != SGILOGDATAFMT_RAW) + guess = SGILOGDATAFMT_UNKNOWN; + break; + case 3: + if (guess == SGILOGDATAFMT_RAW) + guess = SGILOGDATAFMT_UNKNOWN; + break; + default: + guess = SGILOGDATAFMT_UNKNOWN; + break; + } + return (guess); } -static int LogLuvInitState(TIFF *tif) +static int +LogLuvInitState(TIFF* tif) { - static const char module[] = "LogLuvInitState"; - TIFFDirectory *td = &tif->tif_dir; - LogLuvState *sp = DecoderState(tif); + static const char module[] = "LogLuvInitState"; + TIFFDirectory* td = &tif->tif_dir; + LogLuvState* sp = DecoderState(tif); - assert(sp != NULL); - assert(td->td_photometric == PHOTOMETRIC_LOGLUV); + assert(sp != NULL); + assert(td->td_photometric == PHOTOMETRIC_LOGLUV); - /* for some reason, we can't do this in TIFFInitLogLuv */ - if (td->td_planarconfig != PLANARCONFIG_CONTIG) - { - TIFFErrorExtR(tif, module, - "SGILog compression cannot handle non-contiguous data"); - return (0); - } - if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) - sp->user_datafmt = LogLuvGuessDataFmt(td); - switch (sp->user_datafmt) - { - case SGILOGDATAFMT_FLOAT: - sp->pixel_size = 3 * sizeof(float); - break; - case SGILOGDATAFMT_16BIT: - sp->pixel_size = 3 * sizeof(int16_t); - break; - case SGILOGDATAFMT_RAW: - sp->pixel_size = sizeof(uint32_t); - break; - case SGILOGDATAFMT_8BIT: - sp->pixel_size = 3 * sizeof(uint8_t); - break; - default: - TIFFErrorExtR( - tif, module, - "No support for converting user data format to LogLuv"); - return (0); - } - if (isTiled(tif)) - sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength); - else if (td->td_rowsperstrip < td->td_imagelength) - 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_t)) == 0 || - (sp->tbuf = (uint8_t *)_TIFFmallocExt( - tif, sp->tbuflen * sizeof(uint32_t))) == NULL) - { - TIFFErrorExtR(tif, module, "No space for SGILog translation buffer"); - return (0); - } - return (1); + /* for some reason, we can't do this in TIFFInitLogLuv */ + if (td->td_planarconfig != PLANARCONFIG_CONTIG) { + TIFFErrorExt(tif->tif_clientdata, module, + "SGILog compression cannot handle non-contiguous data"); + return (0); + } + if (sp->user_datafmt == SGILOGDATAFMT_UNKNOWN) + sp->user_datafmt = LogLuvGuessDataFmt(td); + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->pixel_size = 3*sizeof (float); + break; + case SGILOGDATAFMT_16BIT: + sp->pixel_size = 3*sizeof (int16); + break; + case SGILOGDATAFMT_RAW: + sp->pixel_size = sizeof (uint32); + break; + case SGILOGDATAFMT_8BIT: + sp->pixel_size = 3*sizeof (uint8); + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "No support for converting user data format to LogLuv"); + return (0); + } + if( isTiled(tif) ) + sp->tbuflen = multiply_ms(td->td_tilewidth, td->td_tilelength); + else if( td->td_rowsperstrip < td->td_imagelength ) + 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) { + TIFFErrorExt(tif->tif_clientdata, module, "No space for SGILog translation buffer"); + return (0); + } + return (1); } -static int LogLuvFixupTags(TIFF *tif) +static int +LogLuvFixupTags(TIFF* tif) { - (void)tif; - return (1); + (void) tif; + return (1); } -static int LogLuvSetupDecode(TIFF *tif) +static int +LogLuvSetupDecode(TIFF* tif) { - static const char module[] = "LogLuvSetupDecode"; - LogLuvState *sp = DecoderState(tif); - TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "LogLuvSetupDecode"; + LogLuvState* sp = DecoderState(tif); + TIFFDirectory* td = &tif->tif_dir; - tif->tif_postdecode = _TIFFNoPostDecode; - switch (td->td_photometric) - { - case PHOTOMETRIC_LOGLUV: - if (!LogLuvInitState(tif)) - break; - if (td->td_compression == COMPRESSION_SGILOG24) - { - tif->tif_decoderow = LogLuvDecode24; - switch (sp->user_datafmt) - { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv24toXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv24toLuv48; - break; - case SGILOGDATAFMT_8BIT: - sp->tfunc = Luv24toRGB; - break; - } - } - else - { - tif->tif_decoderow = LogLuvDecode32; - switch (sp->user_datafmt) - { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv32toXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv32toLuv48; - break; - case SGILOGDATAFMT_8BIT: - sp->tfunc = Luv32toRGB; - break; - } - } - return (1); - case PHOTOMETRIC_LOGL: - if (!LogL16InitState(tif)) - break; - tif->tif_decoderow = LogL16Decode; - switch (sp->user_datafmt) - { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = L16toY; - break; - case SGILOGDATAFMT_8BIT: - sp->tfunc = L16toGry; - break; - } - return (1); - default: - TIFFErrorExtR(tif, module, - "Inappropriate photometric interpretation %" PRIu16 - " for SGILog compression; %s", - td->td_photometric, "must be either LogLUV or LogL"); - break; - } - return (0); + tif->tif_postdecode = _TIFFNoPostDecode; + switch (td->td_photometric) { + case PHOTOMETRIC_LOGLUV: + if (!LogLuvInitState(tif)) + break; + if (td->td_compression == COMPRESSION_SGILOG24) { + tif->tif_decoderow = LogLuvDecode24; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = Luv24toXYZ; + break; + case SGILOGDATAFMT_16BIT: + sp->tfunc = Luv24toLuv48; + break; + case SGILOGDATAFMT_8BIT: + sp->tfunc = Luv24toRGB; + break; + } + } else { + tif->tif_decoderow = LogLuvDecode32; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = Luv32toXYZ; + break; + case SGILOGDATAFMT_16BIT: + sp->tfunc = Luv32toLuv48; + break; + case SGILOGDATAFMT_8BIT: + sp->tfunc = Luv32toRGB; + break; + } + } + return (1); + case PHOTOMETRIC_LOGL: + if (!LogL16InitState(tif)) + break; + tif->tif_decoderow = LogL16Decode; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = L16toY; + break; + case SGILOGDATAFMT_8BIT: + sp->tfunc = L16toGry; + break; + } + return (1); + default: + TIFFErrorExt(tif->tif_clientdata, module, + "Inappropriate photometric interpretation %d for SGILog compression; %s", + td->td_photometric, "must be either LogLUV or LogL"); + break; + } + return (0); } -static int LogLuvSetupEncode(TIFF *tif) +static int +LogLuvSetupEncode(TIFF* tif) { - static const char module[] = "LogLuvSetupEncode"; - LogLuvState *sp = EncoderState(tif); - TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "LogLuvSetupEncode"; + LogLuvState* sp = EncoderState(tif); + TIFFDirectory* td = &tif->tif_dir; - switch (td->td_photometric) - { - case PHOTOMETRIC_LOGLUV: - if (!LogLuvInitState(tif)) - return (0); - if (td->td_compression == COMPRESSION_SGILOG24) - { - tif->tif_encoderow = LogLuvEncode24; - switch (sp->user_datafmt) - { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv24fromXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv24fromLuv48; - break; - case SGILOGDATAFMT_RAW: - break; - default: - goto notsupported; - } - } - else - { - tif->tif_encoderow = LogLuvEncode32; - switch (sp->user_datafmt) - { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = Luv32fromXYZ; - break; - case SGILOGDATAFMT_16BIT: - sp->tfunc = Luv32fromLuv48; - break; - case SGILOGDATAFMT_RAW: - break; - default: - goto notsupported; - } - } - break; - case PHOTOMETRIC_LOGL: - if (!LogL16InitState(tif)) - return (0); - tif->tif_encoderow = LogL16Encode; - switch (sp->user_datafmt) - { - case SGILOGDATAFMT_FLOAT: - sp->tfunc = L16fromY; - break; - case SGILOGDATAFMT_16BIT: - break; - default: - goto notsupported; - } - break; - default: - TIFFErrorExtR(tif, module, - "Inappropriate photometric interpretation %" PRIu16 - " for SGILog compression; %s", - td->td_photometric, "must be either LogLUV or LogL"); - return (0); - } - sp->encoder_state = 1; - return (1); + switch (td->td_photometric) { + case PHOTOMETRIC_LOGLUV: + if (!LogLuvInitState(tif)) + return (0); + if (td->td_compression == COMPRESSION_SGILOG24) { + tif->tif_encoderow = LogLuvEncode24; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = Luv24fromXYZ; + break; + case SGILOGDATAFMT_16BIT: + sp->tfunc = Luv24fromLuv48; + break; + case SGILOGDATAFMT_RAW: + break; + default: + goto notsupported; + } + } else { + tif->tif_encoderow = LogLuvEncode32; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = Luv32fromXYZ; + break; + case SGILOGDATAFMT_16BIT: + sp->tfunc = Luv32fromLuv48; + break; + case SGILOGDATAFMT_RAW: + break; + default: + goto notsupported; + } + } + break; + case PHOTOMETRIC_LOGL: + if (!LogL16InitState(tif)) + return (0); + tif->tif_encoderow = LogL16Encode; + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + sp->tfunc = L16fromY; + break; + case SGILOGDATAFMT_16BIT: + break; + default: + goto notsupported; + } + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "Inappropriate photometric interpretation %d for SGILog compression; %s", + td->td_photometric, "must be either LogLUV or LogL"); + return (0); + } + sp->encoder_state = 1; + return (1); notsupported: - TIFFErrorExtR(tif, module, - "SGILog compression supported only for %s, or raw data", - td->td_photometric == PHOTOMETRIC_LOGL ? "Y, L" : "XYZ, Luv"); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, + "SGILog compression supported only for %s, or raw data", + td->td_photometric == PHOTOMETRIC_LOGL ? "Y, L" : "XYZ, Luv"); + return (0); } -static void LogLuvClose(TIFF *tif) +static void +LogLuvClose(TIFF* tif) { - LogLuvState *sp = (LogLuvState *)tif->tif_data; - TIFFDirectory *td = &tif->tif_dir; + LogLuvState* sp = (LogLuvState*) tif->tif_data; + TIFFDirectory *td = &tif->tif_dir; - assert(sp != 0); - /* - * For consistency, we always want to write out the same - * bitspersample and sampleformat for our TIFF file, - * regardless of the data format being used by the application. - * Since this routine is called after tags have been set but - * before they have been recorded in the file, we reset them here. - * Note: this is really a nasty approach. See PixarLogClose - */ - if (sp->encoder_state) - { - /* See PixarLogClose. Might avoid issues with tags whose size depends - * on those below, but not completely sure this is enough. */ - td->td_samplesperpixel = - (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3; - td->td_bitspersample = 16; - td->td_sampleformat = SAMPLEFORMAT_INT; - } + assert(sp != 0); + /* + * For consistency, we always want to write out the same + * bitspersample and sampleformat for our TIFF file, + * regardless of the data format being used by the application. + * Since this routine is called after tags have been set but + * before they have been recorded in the file, we reset them here. + * Note: this is really a nasty approach. See PixarLogClose + */ + if( sp->encoder_state ) + { + /* See PixarLogClose. Might avoid issues with tags whose size depends + * on those below, but not completely sure this is enough. */ + td->td_samplesperpixel = + (td->td_photometric == PHOTOMETRIC_LOGL) ? 1 : 3; + td->td_bitspersample = 16; + td->td_sampleformat = SAMPLEFORMAT_INT; + } } -static void LogLuvCleanup(TIFF *tif) +static void +LogLuvCleanup(TIFF* tif) { - LogLuvState *sp = (LogLuvState *)tif->tif_data; + LogLuvState* sp = (LogLuvState *)tif->tif_data; - assert(sp != 0); + assert(sp != 0); - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; - if (sp->tbuf) - _TIFFfreeExt(tif, sp->tbuf); - _TIFFfreeExt(tif, sp); - tif->tif_data = NULL; + if (sp->tbuf) + _TIFFfree(sp->tbuf); + _TIFFfree(sp); + tif->tif_data = NULL; - _TIFFSetDefaultCompressionState(tif); + _TIFFSetDefaultCompressionState(tif); } -static int LogLuvVSetField(TIFF *tif, uint32_t tag, va_list ap) +static int +LogLuvVSetField(TIFF* tif, uint32 tag, va_list ap) { - static const char module[] = "LogLuvVSetField"; - LogLuvState *sp = DecoderState(tif); - int bps, fmt; + static const char module[] = "LogLuvVSetField"; + LogLuvState* sp = DecoderState(tif); + int bps, fmt; - switch (tag) - { - case TIFFTAG_SGILOGDATAFMT: - sp->user_datafmt = (int)va_arg(ap, int); - /* - * Tweak the TIFF header so that the rest of libtiff knows what - * size of data will be passed between app and library, and - * assume that the app knows what it is doing and is not - * confused by these header manipulations... - */ - switch (sp->user_datafmt) - { - case SGILOGDATAFMT_FLOAT: - bps = 32; - fmt = SAMPLEFORMAT_IEEEFP; - break; - case SGILOGDATAFMT_16BIT: - bps = 16; - fmt = SAMPLEFORMAT_INT; - break; - case SGILOGDATAFMT_RAW: - bps = 32; - fmt = SAMPLEFORMAT_UINT; - TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); - break; - case SGILOGDATAFMT_8BIT: - bps = 8; - fmt = SAMPLEFORMAT_UINT; - break; - default: - TIFFErrorExtR( - tif, tif->tif_name, - "Unknown data format %d for LogLuv compression", - sp->user_datafmt); - return (0); - } - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt); - /* - * Must recalculate sizes should bits/sample change. - */ - tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)-1; - tif->tif_scanlinesize = TIFFScanlineSize(tif); - return (1); - case TIFFTAG_SGILOGENCODE: - sp->encode_meth = (int)va_arg(ap, int); - if (sp->encode_meth != SGILOGENCODE_NODITHER && - sp->encode_meth != SGILOGENCODE_RANDITHER) - { - TIFFErrorExtR(tif, module, - "Unknown encoding %d for LogLuv compression", - sp->encode_meth); - return (0); - } - return (1); - default: - return (*sp->vsetparent)(tif, tag, ap); - } + switch (tag) { + case TIFFTAG_SGILOGDATAFMT: + sp->user_datafmt = (int) va_arg(ap, int); + /* + * Tweak the TIFF header so that the rest of libtiff knows what + * size of data will be passed between app and library, and + * assume that the app knows what it is doing and is not + * confused by these header manipulations... + */ + switch (sp->user_datafmt) { + case SGILOGDATAFMT_FLOAT: + bps = 32; + fmt = SAMPLEFORMAT_IEEEFP; + break; + case SGILOGDATAFMT_16BIT: + bps = 16; + fmt = SAMPLEFORMAT_INT; + break; + case SGILOGDATAFMT_RAW: + bps = 32; + fmt = SAMPLEFORMAT_UINT; + TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); + break; + case SGILOGDATAFMT_8BIT: + bps = 8; + fmt = SAMPLEFORMAT_UINT; + break; + default: + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "Unknown data format %d for LogLuv compression", + sp->user_datafmt); + return (0); + } + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps); + TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, fmt); + /* + * Must recalculate sizes should bits/sample change. + */ + tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t) -1; + tif->tif_scanlinesize = TIFFScanlineSize(tif); + return (1); + case TIFFTAG_SGILOGENCODE: + sp->encode_meth = (int) va_arg(ap, int); + if (sp->encode_meth != SGILOGENCODE_NODITHER && + sp->encode_meth != SGILOGENCODE_RANDITHER) { + TIFFErrorExt(tif->tif_clientdata, module, + "Unknown encoding %d for LogLuv compression", + sp->encode_meth); + return (0); + } + return (1); + default: + return (*sp->vsetparent)(tif, tag, ap); + } } -static int LogLuvVGetField(TIFF *tif, uint32_t tag, va_list ap) +static int +LogLuvVGetField(TIFF* tif, uint32 tag, va_list ap) { - LogLuvState *sp = (LogLuvState *)tif->tif_data; + LogLuvState *sp = (LogLuvState *)tif->tif_data; - switch (tag) - { - case TIFFTAG_SGILOGDATAFMT: - *va_arg(ap, int *) = sp->user_datafmt; - return (1); - default: - return (*sp->vgetparent)(tif, tag, ap); - } + switch (tag) { + case TIFFTAG_SGILOGDATAFMT: + *va_arg(ap, int*) = sp->user_datafmt; + return (1); + default: + return (*sp->vgetparent)(tif, tag, ap); + } } static const TIFFField LogLuvFields[] = { - {TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogDataFmt", NULL}, - {TIFFTAG_SGILOGENCODE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogEncode", NULL}}; + { TIFFTAG_SGILOGDATAFMT, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogDataFmt", NULL}, + { TIFFTAG_SGILOGENCODE, 0, 0, TIFF_SHORT, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "SGILogEncode", NULL} +}; -int TIFFInitSGILog(TIFF *tif, int scheme) +int +TIFFInitSGILog(TIFF* tif, int scheme) { - static const char module[] = "TIFFInitSGILog"; - LogLuvState *sp; + static const char module[] = "TIFFInitSGILog"; + LogLuvState* sp; - assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG); + assert(scheme == COMPRESSION_SGILOG24 || scheme == COMPRESSION_SGILOG); - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, LogLuvFields, TIFFArrayCount(LogLuvFields))) - { - TIFFErrorExtR(tif, module, "Merging SGILog codec-specific tags failed"); - return 0; - } + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, LogLuvFields, + TIFFArrayCount(LogLuvFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging SGILog codec-specific tags failed"); + return 0; + } - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LogLuvState)); - if (tif->tif_data == NULL) - goto bad; - sp = (LogLuvState *)tif->tif_data; - _TIFFmemset((void *)sp, 0, sizeof(*sp)); - sp->user_datafmt = SGILOGDATAFMT_UNKNOWN; - sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? SGILOGENCODE_RANDITHER - : SGILOGENCODE_NODITHER; - sp->tfunc = _logLuvNop; + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LogLuvState)); + if (tif->tif_data == NULL) + goto bad; + sp = (LogLuvState*) tif->tif_data; + _TIFFmemset((void*)sp, 0, sizeof (*sp)); + sp->user_datafmt = SGILOGDATAFMT_UNKNOWN; + sp->encode_meth = (scheme == COMPRESSION_SGILOG24) ? + SGILOGENCODE_RANDITHER : SGILOGENCODE_NODITHER; + sp->tfunc = _logLuvNop; - /* - * Install codec methods. - * NB: tif_decoderow & tif_encoderow are filled - * in at setup time. - */ - tif->tif_fixuptags = LogLuvFixupTags; - tif->tif_setupdecode = LogLuvSetupDecode; - tif->tif_decodestrip = LogLuvDecodeStrip; - tif->tif_decodetile = LogLuvDecodeTile; - tif->tif_setupencode = LogLuvSetupEncode; - tif->tif_encodestrip = LogLuvEncodeStrip; - tif->tif_encodetile = LogLuvEncodeTile; - tif->tif_close = LogLuvClose; - tif->tif_cleanup = LogLuvCleanup; + /* + * Install codec methods. + * NB: tif_decoderow & tif_encoderow are filled + * in at setup time. + */ + tif->tif_fixuptags = LogLuvFixupTags; + tif->tif_setupdecode = LogLuvSetupDecode; + tif->tif_decodestrip = LogLuvDecodeStrip; + tif->tif_decodetile = LogLuvDecodeTile; + tif->tif_setupencode = LogLuvSetupEncode; + tif->tif_encodestrip = LogLuvEncodeStrip; + tif->tif_encodetile = LogLuvEncodeTile; + tif->tif_close = LogLuvClose; + tif->tif_cleanup = LogLuvCleanup; - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = LogLuvVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = LogLuvVSetField; /* hook for codec tags */ + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = LogLuvVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = LogLuvVSetField; /* hook for codec tags */ - return (1); + return (1); bad: - TIFFErrorExtR(tif, module, "%s: No space for LogLuv state block", - tif->tif_name); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, + "%s: No space for LogLuv state block", tif->tif_name); + return (0); } #endif /* LOGLUV_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lzma.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lzma.c index 4cfd5e882..7b1539430 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lzma.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lzma.c @@ -33,488 +33,471 @@ * The codec is derived from ZLIB codec (tif_zip.c). */ -#include "lzma.h" #include "tif_predict.h" +#include "lzma.h" #include /* * State block for each open TIFF file using LZMA2 compression/decompression. */ -typedef struct -{ - TIFFPredictorState predict; - lzma_stream stream; - lzma_filter filters[LZMA_FILTERS_MAX + 1]; - lzma_options_delta opt_delta; /* delta filter options */ - lzma_options_lzma opt_lzma; /* LZMA2 filter options */ - int preset; /* compression level */ - lzma_check check; /* type of the integrity check */ - int state; /* state flags */ +typedef struct { + TIFFPredictorState predict; + lzma_stream stream; + lzma_filter filters[LZMA_FILTERS_MAX + 1]; + lzma_options_delta opt_delta; /* delta filter options */ + lzma_options_lzma opt_lzma; /* LZMA2 filter options */ + int preset; /* compression level */ + lzma_check check; /* type of the integrity check */ + int state; /* state flags */ #define LSTATE_INIT_DECODE 0x01 #define LSTATE_INIT_ENCODE 0x02 - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ } LZMAState; -#define LState(tif) ((LZMAState *)(tif)->tif_data) -#define DecoderState(tif) LState(tif) -#define EncoderState(tif) LState(tif) +#define LState(tif) ((LZMAState*) (tif)->tif_data) +#define DecoderState(tif) LState(tif) +#define EncoderState(tif) LState(tif) -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 int LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); +static int LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); -static const char *LZMAStrerror(lzma_ret ret) +static const char * +LZMAStrerror(lzma_ret ret) { - switch (ret) - { - case LZMA_OK: - return "operation completed successfully"; - case LZMA_STREAM_END: - return "end of stream was reached"; - case LZMA_NO_CHECK: - return "input stream has no integrity check"; - case LZMA_UNSUPPORTED_CHECK: - return "cannot calculate the integrity check"; - case LZMA_GET_CHECK: - return "integrity check type is now available"; - case LZMA_MEM_ERROR: - return "cannot allocate memory"; - case LZMA_MEMLIMIT_ERROR: - return "memory usage limit was reached"; - case LZMA_FORMAT_ERROR: - return "file format not recognized"; - case LZMA_OPTIONS_ERROR: - return "invalid or unsupported options"; - case LZMA_DATA_ERROR: - return "data is corrupt"; - case LZMA_BUF_ERROR: - return "no progress is possible (stream is truncated or corrupt)"; - case LZMA_PROG_ERROR: - return "programming error"; - default: - return "unidentified liblzma error"; - } + switch (ret) { + case LZMA_OK: + return "operation completed successfully"; + case LZMA_STREAM_END: + return "end of stream was reached"; + case LZMA_NO_CHECK: + return "input stream has no integrity check"; + case LZMA_UNSUPPORTED_CHECK: + return "cannot calculate the integrity check"; + case LZMA_GET_CHECK: + return "integrity check type is now available"; + case LZMA_MEM_ERROR: + return "cannot allocate memory"; + case LZMA_MEMLIMIT_ERROR: + return "memory usage limit was reached"; + case LZMA_FORMAT_ERROR: + return "file format not recognized"; + case LZMA_OPTIONS_ERROR: + return "invalid or unsupported options"; + case LZMA_DATA_ERROR: + return "data is corrupt"; + case LZMA_BUF_ERROR: + return "no progress is possible (stream is truncated or corrupt)"; + case LZMA_PROG_ERROR: + return "programming error"; + default: + return "unidentified liblzma error"; + } } -static int LZMAFixupTags(TIFF *tif) +static int +LZMAFixupTags(TIFF* tif) { - (void)tif; - return 1; + (void) tif; + return 1; } -static int LZMASetupDecode(TIFF *tif) +static int +LZMASetupDecode(TIFF* tif) { - LZMAState *sp = DecoderState(tif); + LZMAState* sp = DecoderState(tif); - assert(sp != NULL); + assert(sp != NULL); + + /* if we were last encoding, terminate this mode */ + if (sp->state & LSTATE_INIT_ENCODE) { + lzma_end(&sp->stream); + sp->state = 0; + } - /* if we were last encoding, terminate this mode */ - if (sp->state & LSTATE_INIT_ENCODE) - { - lzma_end(&sp->stream); - sp->state = 0; - } - - sp->state |= LSTATE_INIT_DECODE; - return 1; + sp->state |= LSTATE_INIT_DECODE; + return 1; } /* * Setup state for decoding a strip. */ -static int LZMAPreDecode(TIFF *tif, uint16_t s) +static int +LZMAPreDecode(TIFF* tif, uint16 s) { - static const char module[] = "LZMAPreDecode"; - LZMAState *sp = DecoderState(tif); - lzma_ret ret; + static const char module[] = "LZMAPreDecode"; + LZMAState* sp = DecoderState(tif); + lzma_ret ret; - (void)s; - assert(sp != NULL); + (void) s; + assert(sp != NULL); - if ((sp->state & LSTATE_INIT_DECODE) == 0) - tif->tif_setupdecode(tif); + if( (sp->state & LSTATE_INIT_DECODE) == 0 ) + tif->tif_setupdecode(tif); - sp->stream.next_in = tif->tif_rawdata; - sp->stream.avail_in = (size_t)tif->tif_rawcc; - if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc) - { - TIFFErrorExtR(tif, module, - "Liblzma cannot deal with buffers this size"); - return 0; - } + sp->stream.next_in = tif->tif_rawdata; + sp->stream.avail_in = (size_t) tif->tif_rawcc; + if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma cannot deal with buffers this size"); + return 0; + } - /* - * Disable memory limit when decoding. UINT64_MAX is a flag to disable - * the limit, we are passing (uint64_t)-1 which should be the same. - */ - ret = lzma_stream_decoder(&sp->stream, (uint64_t)-1, 0); - if (ret != LZMA_OK) - { - TIFFErrorExtR(tif, module, "Error initializing the stream decoder, %s", - LZMAStrerror(ret)); - return 0; - } - return 1; + /* + * Disable memory limit when decoding. UINT64_MAX is a flag to disable + * the limit, we are passing (uint64_t)-1 which should be the same. + */ + ret = lzma_stream_decoder(&sp->stream, (uint64_t)-1, 0); + if (ret != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error initializing the stream decoder, %s", + LZMAStrerror(ret)); + return 0; + } + return 1; } -static int LZMADecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) +static int +LZMADecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - static const char module[] = "LZMADecode"; - LZMAState *sp = DecoderState(tif); + static const char module[] = "LZMADecode"; + LZMAState* sp = DecoderState(tif); - (void)s; - assert(sp != NULL); - assert(sp->state == LSTATE_INIT_DECODE); + (void) s; + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_DECODE); - sp->stream.next_in = tif->tif_rawcp; - sp->stream.avail_in = (size_t)tif->tif_rawcc; + sp->stream.next_in = tif->tif_rawcp; + sp->stream.avail_in = (size_t) tif->tif_rawcc; - sp->stream.next_out = op; - sp->stream.avail_out = (size_t)occ; - if ((tmsize_t)sp->stream.avail_out != occ) - { - TIFFErrorExtR(tif, module, - "Liblzma cannot deal with buffers this size"); - return 0; - } + sp->stream.next_out = op; + sp->stream.avail_out = (size_t) occ; + if ((tmsize_t)sp->stream.avail_out != occ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma cannot deal with buffers this size"); + return 0; + } - do - { - /* - * Save the current stream state to properly recover from the - * decoding errors later. - */ - const uint8_t *next_in = sp->stream.next_in; - size_t avail_in = sp->stream.avail_in; + do { + /* + * Save the current stream state to properly recover from the + * decoding errors later. + */ + const uint8 *next_in = sp->stream.next_in; + size_t avail_in = sp->stream.avail_in; - lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN); - if (ret == LZMA_STREAM_END) - break; - if (ret == LZMA_MEMLIMIT_ERROR) - { - lzma_ret r = - lzma_stream_decoder(&sp->stream, lzma_memusage(&sp->stream), 0); - if (r != LZMA_OK) - { - TIFFErrorExtR(tif, module, - "Error initializing the stream decoder, %s", - LZMAStrerror(r)); - break; - } - sp->stream.next_in = next_in; - sp->stream.avail_in = avail_in; - continue; - } - if (ret != LZMA_OK) - { - TIFFErrorExtR(tif, module, - "Decoding error at scanline %" PRIu32 ", %s", - tif->tif_row, LZMAStrerror(ret)); - break; - } - } while (sp->stream.avail_out > 0); - if (sp->stream.avail_out != 0) - { - TIFFErrorExtR(tif, module, - "Not enough data at scanline %" PRIu32 - " (short %" TIFF_SIZE_FORMAT " bytes)", - tif->tif_row, sp->stream.avail_out); - return 0; - } + lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN); + if (ret == LZMA_STREAM_END) + break; + if (ret == LZMA_MEMLIMIT_ERROR) { + lzma_ret r = lzma_stream_decoder(&sp->stream, + lzma_memusage(&sp->stream), 0); + if (r != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error initializing the stream decoder, %s", + LZMAStrerror(r)); + break; + } + sp->stream.next_in = next_in; + sp->stream.avail_in = avail_in; + continue; + } + if (ret != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Decoding error at scanline %lu, %s", + (unsigned long) tif->tif_row, LZMAStrerror(ret)); + break; + } + } while (sp->stream.avail_out > 0); + if (sp->stream.avail_out != 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at scanline %lu (short %lu bytes)", + (unsigned long) tif->tif_row, (unsigned long) sp->stream.avail_out); + return 0; + } - tif->tif_rawcp = (uint8_t *)sp->stream.next_in; /* cast away const */ - tif->tif_rawcc = sp->stream.avail_in; - - return 1; + tif->tif_rawcp = (uint8 *)sp->stream.next_in; /* cast away const */ + tif->tif_rawcc = sp->stream.avail_in; + + return 1; } -static int LZMASetupEncode(TIFF *tif) +static int +LZMASetupEncode(TIFF* tif) { - LZMAState *sp = EncoderState(tif); + LZMAState* sp = EncoderState(tif); - assert(sp != NULL); - if (sp->state & LSTATE_INIT_DECODE) - { - lzma_end(&sp->stream); - sp->state = 0; - } + assert(sp != NULL); + if (sp->state & LSTATE_INIT_DECODE) { + lzma_end(&sp->stream); + sp->state = 0; + } - sp->state |= LSTATE_INIT_ENCODE; - return 1; + sp->state |= LSTATE_INIT_ENCODE; + return 1; } /* * Reset encoding state at the start of a strip. */ -static int LZMAPreEncode(TIFF *tif, uint16_t s) +static int +LZMAPreEncode(TIFF* tif, uint16 s) { - static const char module[] = "LZMAPreEncode"; - LZMAState *sp = EncoderState(tif); - lzma_ret ret; + static const char module[] = "LZMAPreEncode"; + LZMAState *sp = EncoderState(tif); + lzma_ret ret; - (void)s; - assert(sp != NULL); - if (sp->state != LSTATE_INIT_ENCODE) - tif->tif_setupencode(tif); + (void) s; + assert(sp != NULL); + if( sp->state != LSTATE_INIT_ENCODE ) + tif->tif_setupencode(tif); - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = (size_t)tif->tif_rawdatasize; - if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) - { - TIFFErrorExtR(tif, module, - "Liblzma cannot deal with buffers this size"); - return 0; - } - ret = lzma_stream_encoder(&sp->stream, sp->filters, sp->check); - if (ret != LZMA_OK) - { - TIFFErrorExtR(tif, module, "Error in lzma_stream_encoder(): %s", - LZMAStrerror(ret)); - return 0; - } - return 1; + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (size_t)tif->tif_rawdatasize; + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma cannot deal with buffers this size"); + return 0; + } + ret = lzma_stream_encoder(&sp->stream, sp->filters, sp->check); + if (ret != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in lzma_stream_encoder(): %s", LZMAStrerror(ret)); + return 0; + } + return 1; } /* * Encode a chunk of pixels. */ -static int LZMAEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +LZMAEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "LZMAEncode"; - LZMAState *sp = EncoderState(tif); + static const char module[] = "LZMAEncode"; + LZMAState *sp = EncoderState(tif); - assert(sp != NULL); - assert(sp->state == LSTATE_INIT_ENCODE); + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_ENCODE); - (void)s; - sp->stream.next_in = bp; - sp->stream.avail_in = (size_t)cc; - if ((tmsize_t)sp->stream.avail_in != cc) - { - TIFFErrorExtR(tif, module, - "Liblzma cannot deal with buffers this size"); - return 0; - } - do - { - lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN); - if (ret != LZMA_OK) - { - TIFFErrorExtR(tif, module, - "Encoding error at scanline %" PRIu32 ", %s", - tif->tif_row, LZMAStrerror(ret)); - return 0; - } - if (sp->stream.avail_out == 0) - { - tif->tif_rawcc = tif->tif_rawdatasize; - if (!TIFFFlushData1(tif)) - return 0; - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = - (size_t) - tif->tif_rawdatasize; /* this is a safe typecast, as check - is made already in LZMAPreEncode */ - } - } while (sp->stream.avail_in > 0); - return 1; + (void) s; + sp->stream.next_in = bp; + sp->stream.avail_in = (size_t) cc; + if ((tmsize_t)sp->stream.avail_in != cc) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma cannot deal with buffers this size"); + return 0; + } + do { + lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN); + if (ret != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Encoding error at scanline %lu, %s", + (unsigned long) tif->tif_row, LZMAStrerror(ret)); + return 0; + } + if (sp->stream.avail_out == 0) { + tif->tif_rawcc = tif->tif_rawdatasize; + if (!TIFFFlushData1(tif)) + return 0; + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in LZMAPreEncode */ + } + } while (sp->stream.avail_in > 0); + return 1; } /* * Finish off an encoded strip by flushing the last * string and tacking on an End Of Information code. */ -static int LZMAPostEncode(TIFF *tif) +static int +LZMAPostEncode(TIFF* tif) { - static const char module[] = "LZMAPostEncode"; - LZMAState *sp = EncoderState(tif); - lzma_ret ret; + static const char module[] = "LZMAPostEncode"; + LZMAState *sp = EncoderState(tif); + lzma_ret ret; - sp->stream.avail_in = 0; - do - { - ret = lzma_code(&sp->stream, LZMA_FINISH); - switch (ret) - { - case LZMA_STREAM_END: - case LZMA_OK: - if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) - { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; - if (!TIFFFlushData1(tif)) - return 0; - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = - (size_t) - tif->tif_rawdatasize; /* this is a safe typecast, as - check is made already in - ZIPPreEncode */ - } - break; - default: - TIFFErrorExtR(tif, module, "Liblzma error: %s", - LZMAStrerror(ret)); - return 0; - } - } while (ret != LZMA_STREAM_END); - return 1; + sp->stream.avail_in = 0; + do { + ret = lzma_code(&sp->stream, LZMA_FINISH); + switch (ret) { + case LZMA_STREAM_END: + case LZMA_OK: + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) { + tif->tif_rawcc = + tif->tif_rawdatasize - sp->stream.avail_out; + if (!TIFFFlushData1(tif)) + return 0; + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (size_t)tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in ZIPPreEncode */ + } + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, "Liblzma error: %s", + LZMAStrerror(ret)); + return 0; + } + } while (ret != LZMA_STREAM_END); + return 1; } -static void LZMACleanup(TIFF *tif) +static void +LZMACleanup(TIFF* tif) { - LZMAState *sp = LState(tif); + LZMAState* sp = LState(tif); - assert(sp != 0); + assert(sp != 0); - (void)TIFFPredictorCleanup(tif); + (void)TIFFPredictorCleanup(tif); - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; - if (sp->state) - { - lzma_end(&sp->stream); - sp->state = 0; - } - _TIFFfreeExt(tif, sp); - tif->tif_data = NULL; + if (sp->state) { + lzma_end(&sp->stream); + sp->state = 0; + } + _TIFFfree(sp); + tif->tif_data = NULL; - _TIFFSetDefaultCompressionState(tif); + _TIFFSetDefaultCompressionState(tif); } -static int LZMAVSetField(TIFF *tif, uint32_t tag, va_list ap) +static int +LZMAVSetField(TIFF* tif, uint32 tag, va_list ap) { - static const char module[] = "LZMAVSetField"; - LZMAState *sp = LState(tif); + static const char module[] = "LZMAVSetField"; + LZMAState* sp = LState(tif); - switch (tag) - { - case TIFFTAG_LZMAPRESET: - sp->preset = (int)va_arg(ap, int); - lzma_lzma_preset(&sp->opt_lzma, sp->preset); - if (sp->state & LSTATE_INIT_ENCODE) - { - lzma_ret ret = - lzma_stream_encoder(&sp->stream, sp->filters, sp->check); - if (ret != LZMA_OK) - { - TIFFErrorExtR(tif, module, "Liblzma error: %s", - LZMAStrerror(ret)); - } - } - return 1; - default: - return (*sp->vsetparent)(tif, tag, ap); - } - /*NOTREACHED*/ + switch (tag) { + case TIFFTAG_LZMAPRESET: + sp->preset = (int) va_arg(ap, int); + lzma_lzma_preset(&sp->opt_lzma, sp->preset); + if (sp->state & LSTATE_INIT_ENCODE) { + lzma_ret ret = lzma_stream_encoder(&sp->stream, + sp->filters, + sp->check); + if (ret != LZMA_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Liblzma error: %s", + LZMAStrerror(ret)); + } + } + return 1; + default: + return (*sp->vsetparent)(tif, tag, ap); + } + /*NOTREACHED*/ } -static int LZMAVGetField(TIFF *tif, uint32_t tag, va_list ap) +static int +LZMAVGetField(TIFF* tif, uint32 tag, va_list ap) { - LZMAState *sp = LState(tif); + LZMAState* sp = LState(tif); - switch (tag) - { - case TIFFTAG_LZMAPRESET: - *va_arg(ap, int *) = sp->preset; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return 1; + switch (tag) { + case TIFFTAG_LZMAPRESET: + *va_arg(ap, int*) = sp->preset; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return 1; } static const TIFFField lzmaFields[] = { - {TIFFTAG_LZMAPRESET, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, - "LZMA2 Compression Preset", NULL}, + { TIFFTAG_LZMAPRESET, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, TRUE, FALSE, "LZMA2 Compression Preset", NULL }, }; -int TIFFInitLZMA(TIFF *tif, int scheme) +int +TIFFInitLZMA(TIFF* tif, int scheme) { - static const char module[] = "TIFFInitLZMA"; - LZMAState *sp; - lzma_stream tmp_stream = LZMA_STREAM_INIT; + static const char module[] = "TIFFInitLZMA"; + LZMAState* sp; + lzma_stream tmp_stream = LZMA_STREAM_INIT; - (void)scheme; - assert(scheme == COMPRESSION_LZMA); + (void)scheme; + assert( scheme == COMPRESSION_LZMA ); - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, lzmaFields, TIFFArrayCount(lzmaFields))) - { - TIFFErrorExtR(tif, module, "Merging LZMA2 codec-specific tags failed"); - return 0; - } + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, lzmaFields, TIFFArrayCount(lzmaFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging LZMA2 codec-specific tags failed"); + return 0; + } - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LZMAState)); - if (tif->tif_data == NULL) - goto bad; - sp = LState(tif); - memcpy(&sp->stream, &tmp_stream, sizeof(lzma_stream)); + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZMAState)); + if (tif->tif_data == NULL) + goto bad; + sp = LState(tif); + memcpy(&sp->stream, &tmp_stream, sizeof(lzma_stream)); - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = LZMAVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = LZMAVSetField; /* hook for codec tags */ + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = LZMAVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = LZMAVSetField; /* hook for codec tags */ - /* Default values for codec-specific fields */ - sp->preset = LZMA_PRESET_DEFAULT; /* default comp. level */ - sp->check = LZMA_CHECK_NONE; - sp->state = 0; + /* Default values for codec-specific fields */ + sp->preset = LZMA_PRESET_DEFAULT; /* default comp. level */ + sp->check = LZMA_CHECK_NONE; + sp->state = 0; - /* Data filters. So far we are using delta and LZMA2 filters only. */ - sp->opt_delta.type = LZMA_DELTA_TYPE_BYTE; - /* - * The sample size in bytes seems to be reasonable distance for delta - * filter. - */ - sp->opt_delta.dist = (tif->tif_dir.td_bitspersample % 8) - ? 1 - : tif->tif_dir.td_bitspersample / 8; - sp->filters[0].id = LZMA_FILTER_DELTA; - sp->filters[0].options = &sp->opt_delta; + /* Data filters. So far we are using delta and LZMA2 filters only. */ + sp->opt_delta.type = LZMA_DELTA_TYPE_BYTE; + /* + * The sample size in bytes seems to be reasonable distance for delta + * filter. + */ + sp->opt_delta.dist = (tif->tif_dir.td_bitspersample % 8) ? + 1 : tif->tif_dir.td_bitspersample / 8; + sp->filters[0].id = LZMA_FILTER_DELTA; + sp->filters[0].options = &sp->opt_delta; - lzma_lzma_preset(&sp->opt_lzma, sp->preset); - sp->filters[1].id = LZMA_FILTER_LZMA2; - sp->filters[1].options = &sp->opt_lzma; + lzma_lzma_preset(&sp->opt_lzma, sp->preset); + sp->filters[1].id = LZMA_FILTER_LZMA2; + sp->filters[1].options = &sp->opt_lzma; - sp->filters[2].id = LZMA_VLI_UNKNOWN; - sp->filters[2].options = NULL; + sp->filters[2].id = LZMA_VLI_UNKNOWN; + sp->filters[2].options = NULL; - /* - * Install codec methods. - */ - tif->tif_fixuptags = LZMAFixupTags; - tif->tif_setupdecode = LZMASetupDecode; - tif->tif_predecode = LZMAPreDecode; - tif->tif_decoderow = LZMADecode; - tif->tif_decodestrip = LZMADecode; - tif->tif_decodetile = LZMADecode; - tif->tif_setupencode = LZMASetupEncode; - tif->tif_preencode = LZMAPreEncode; - tif->tif_postencode = LZMAPostEncode; - tif->tif_encoderow = LZMAEncode; - tif->tif_encodestrip = LZMAEncode; - tif->tif_encodetile = LZMAEncode; - tif->tif_cleanup = LZMACleanup; - /* - * Setup predictor setup. - */ - (void)TIFFPredictorInit(tif); - return 1; + /* + * Install codec methods. + */ + tif->tif_fixuptags = LZMAFixupTags; + tif->tif_setupdecode = LZMASetupDecode; + tif->tif_predecode = LZMAPreDecode; + tif->tif_decoderow = LZMADecode; + tif->tif_decodestrip = LZMADecode; + tif->tif_decodetile = LZMADecode; + tif->tif_setupencode = LZMASetupEncode; + tif->tif_preencode = LZMAPreEncode; + tif->tif_postencode = LZMAPostEncode; + tif->tif_encoderow = LZMAEncode; + tif->tif_encodestrip = LZMAEncode; + tif->tif_encodetile = LZMAEncode; + tif->tif_cleanup = LZMACleanup; + /* + * Setup predictor setup. + */ + (void) TIFFPredictorInit(tif); + return 1; bad: - TIFFErrorExtR(tif, module, "No space for LZMA2 state block"); - return 0; + TIFFErrorExt(tif->tif_clientdata, module, + "No space for LZMA2 state block"); + return 0; } #endif /* LZMA_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lzw.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lzw.c index d631fa104..b166b3817 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lzw.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_lzw.c @@ -1,32 +1,31 @@ /* * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * Copyright (c) 2022 Even Rouault * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include "tiffiop.h" #ifdef LZW_SUPPORT /* - * TIFF Library. + * TIFF Library. * Rev 5.0 Lempel-Ziv & Welch Compression Support * * This code is derived from the compress program whose code is @@ -37,13 +36,7 @@ */ #include "tif_predict.h" -#include #include -#include - -/* Select the plausible largest natural integer type for the architecture */ -#define SIZEOF_WORDTYPE SIZEOF_SIZE_T -typedef size_t WordType; /* * NB: The 5.0 spec describes a different algorithm than Aldus @@ -58,27 +51,34 @@ typedef size_t WordType; * * Future revisions to the TIFF spec are expected to "clarify this issue". */ -#define LZW_COMPAT /* include backwards compatibility code */ +#define LZW_COMPAT /* include backwards compatibility code */ +/* + * Each strip of data is supposed to be terminated by a CODE_EOI. + * If the following #define is included, the decoder will also + * check for end-of-strip w/o seeing this code. This makes the + * library more robust, but also slower. + */ +#define LZW_CHECKEOS /* include checks for strips w/o EOI code */ -#define MAXCODE(n) ((1L << (n)) - 1) +#define MAXCODE(n) ((1L<<(n))-1) /* * The TIFF spec specifies that encoded bit * strings range from 9 to 12 bits. */ -#define BITS_MIN 9 /* start with 9 bits */ -#define BITS_MAX 12 /* max of 12 bit strings */ +#define BITS_MIN 9 /* start with 9 bits */ +#define BITS_MAX 12 /* max of 12 bit strings */ /* predefined codes */ -#define CODE_CLEAR 256 /* code to clear string table */ -#define CODE_EOI 257 /* end-of-information code */ -#define CODE_FIRST 258 /* first free code entry */ -#define CODE_MAX MAXCODE(BITS_MAX) -#define HSIZE 9001L /* 91% occupancy */ -#define HSHIFT (13 - 8) +#define CODE_CLEAR 256 /* code to clear string table */ +#define CODE_EOI 257 /* end-of-information code */ +#define CODE_FIRST 258 /* first free code entry */ +#define CODE_MAX MAXCODE(BITS_MAX) +#define HSIZE 9001L /* 91% occupancy */ +#define HSHIFT (13-8) #ifdef LZW_COMPAT /* NB: +1024 is for compatibility with old files */ -#define CSIZE (MAXCODE(BITS_MAX) + 1024L) +#define CSIZE (MAXCODE(BITS_MAX)+1024L) #else -#define CSIZE (MAXCODE(BITS_MAX) + 1L) +#define CSIZE (MAXCODE(BITS_MAX)+1L) #endif /* @@ -86,936 +86,713 @@ typedef size_t WordType; * compression/decompression. Note that the predictor * state block must be first in this data structure. */ -typedef struct -{ - TIFFPredictorState predict; /* predictor super class */ +typedef struct { + TIFFPredictorState predict; /* predictor super class */ - unsigned short nbits; /* # of bits/code */ - unsigned short maxcode; /* maximum code for lzw_nbits */ - unsigned short free_ent; /* next free entry in hash table */ - WordType nextdata; /* next bits of i/o */ - long nextbits; /* # of valid bits in lzw_nextdata */ + unsigned short nbits; /* # of bits/code */ + unsigned short maxcode; /* maximum code for lzw_nbits */ + unsigned short free_ent; /* next free entry in hash table */ + unsigned long nextdata; /* next bits of i/o */ + long nextbits; /* # of valid bits in lzw_nextdata */ - int rw_mode; /* preserve rw_mode from init */ + int rw_mode; /* preserve rw_mode from init */ } LZWBaseState; -#define lzw_nbits base.nbits -#define lzw_maxcode base.maxcode -#define lzw_free_ent base.free_ent -#define lzw_nextdata base.nextdata -#define lzw_nextbits base.nextbits +#define lzw_nbits base.nbits +#define lzw_maxcode base.maxcode +#define lzw_free_ent base.free_ent +#define lzw_nextdata base.nextdata +#define lzw_nextbits base.nextbits /* * Encoding-specific state. */ -typedef uint16_t hcode_t; /* codes fit in 16 bits */ -typedef struct -{ - long hash; - hcode_t code; +typedef uint16 hcode_t; /* codes fit in 16 bits */ +typedef struct { + long hash; + hcode_t code; } hash_t; /* * Decoding-specific state. */ -typedef struct code_ent -{ - struct code_ent *next; - unsigned short length; /* string len, including this token */ - /* firstchar should be placed immediately before value in this structure */ - unsigned char firstchar; /* first token of string */ - unsigned char value; /* data value */ - bool repeated; +typedef struct code_ent { + struct code_ent *next; + unsigned short length; /* string len, including this token */ + unsigned char value; /* data value */ + unsigned char firstchar; /* first token of string */ } code_t; -typedef int (*decodeFunc)(TIFF *, uint8_t *, tmsize_t, uint16_t); +typedef int (*decodeFunc)(TIFF*, uint8*, tmsize_t, uint16); -typedef struct -{ - LZWBaseState base; +typedef struct { + LZWBaseState base; - /* Decoding specific data */ - long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ - tmsize_t dec_restart; /* restart count */ - 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 */ - decodeFunc dec_decode; /* regular or backwards compatible */ - code_t *dec_codep; /* current recognized code */ - code_t *dec_oldcodep; /* previously recognized code */ - code_t *dec_free_entp; /* next free entry */ - code_t *dec_maxcodep; /* max available entry */ - code_t *dec_codetab; /* kept separate for small machines */ - int read_error; /* whether a read error has occurred, and which should cause - further reads in the same strip/tile to be aborted */ + /* Decoding specific data */ + long dec_nbitsmask; /* lzw_nbits 1 bits, right adjusted */ + tmsize_t dec_restart; /* restart count */ +#ifdef LZW_CHECKEOS + uint64 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 */ + code_t* dec_codep; /* current recognized code */ + code_t* dec_oldcodep; /* previously recognized code */ + code_t* dec_free_entp; /* next free entry */ + code_t* dec_maxcodep; /* max available entry */ + code_t* dec_codetab; /* kept separate for small machines */ + int read_error; /* whether a read error has occured, and which should cause further reads in the same strip/tile to be aborted */ - /* Encoding specific data */ - int enc_oldcode; /* last code encountered */ - tmsize_t enc_checkpoint; /* point at which to clear table */ -#define CHECK_GAP 10000 /* enc_ratio check interval */ - tmsize_t enc_ratio; /* current compression ratio */ - tmsize_t enc_incount; /* (input) data bytes encoded */ - tmsize_t enc_outcount; /* encoded (output) bytes */ - uint8_t *enc_rawlimit; /* bound on tif_rawdata buffer */ - hash_t *enc_hashtab; /* kept separate for small machines */ + /* Encoding specific data */ + int enc_oldcode; /* last code encountered */ + tmsize_t enc_checkpoint; /* point at which to clear table */ +#define CHECK_GAP 10000 /* enc_ratio check interval */ + tmsize_t enc_ratio; /* current compression ratio */ + tmsize_t enc_incount; /* (input) data bytes encoded */ + tmsize_t enc_outcount; /* encoded (output) bytes */ + uint8* enc_rawlimit; /* bound on tif_rawdata buffer */ + hash_t* enc_hashtab; /* kept separate for small machines */ } LZWCodecState; -#define LZWState(tif) ((LZWBaseState *)(tif)->tif_data) -#define DecoderState(tif) ((LZWCodecState *)LZWState(tif)) -#define EncoderState(tif) ((LZWCodecState *)LZWState(tif)) +#define LZWState(tif) ((LZWBaseState*) (tif)->tif_data) +#define DecoderState(tif) ((LZWCodecState*) LZWState(tif)) +#define EncoderState(tif) ((LZWCodecState*) LZWState(tif)) -static int LZWDecode(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s); +static int LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); #ifdef LZW_COMPAT -static int LZWDecodeCompat(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s); +static int LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s); #endif -static void cl_hash(LZWCodecState *); +static void cl_hash(LZWCodecState*); /* * LZW Decoder. */ -static int LZWFixupTags(TIFF *tif) +#ifdef LZW_CHECKEOS +/* + * This check shouldn't be necessary because each + * strip is suppose to be terminated with CODE_EOI. + */ +#define NextCode(_tif, _sp, _bp, _code, _get) { \ + if ((_sp)->dec_bitsleft < (uint64)nbits) { \ + TIFFWarningExt(_tif->tif_clientdata, module, \ + "LZWDecode: Strip %d not terminated with EOI code", \ + _tif->tif_curstrip); \ + _code = CODE_EOI; \ + } else { \ + _get(_sp,_bp,_code); \ + (_sp)->dec_bitsleft -= nbits; \ + } \ +} +#else +#define NextCode(tif, sp, bp, code, get) get(sp, bp, code) +#endif + +static int +LZWFixupTags(TIFF* tif) { - (void)tif; - return (1); + (void) tif; + return (1); } -static int LZWSetupDecode(TIFF *tif) +static int +LZWSetupDecode(TIFF* tif) { - static const char module[] = "LZWSetupDecode"; - LZWCodecState *sp = DecoderState(tif); - int code; + static const char module[] = "LZWSetupDecode"; + LZWCodecState* sp = DecoderState(tif); + int code; - if (sp == NULL) - { - /* - * Allocate state block so tag methods have storage to record - * values. - */ - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LZWCodecState)); - if (tif->tif_data == NULL) - { - TIFFErrorExtR(tif, module, "No space for LZW state block"); - return (0); - } + if( sp == NULL ) + { + /* + * Allocate state block so tag methods have storage to record + * values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof(LZWCodecState)); + if (tif->tif_data == NULL) + { + TIFFErrorExt(tif->tif_clientdata, module, "No space for LZW state block"); + return (0); + } - sp = DecoderState(tif); - sp->dec_codetab = NULL; - sp->dec_decode = NULL; + sp = DecoderState(tif); + sp->dec_codetab = NULL; + sp->dec_decode = NULL; - /* - * Setup predictor setup. - */ - (void)TIFFPredictorInit(tif); - } + /* + * Setup predictor setup. + */ + (void) TIFFPredictorInit(tif); + } - if (sp->dec_codetab == NULL) - { - sp->dec_codetab = (code_t *)_TIFFmallocExt(tif, CSIZE * sizeof(code_t)); - if (sp->dec_codetab == NULL) - { - TIFFErrorExtR(tif, module, "No space for LZW code table"); - return (0); - } - /* - * Pre-load the table. - */ - code = 255; - do - { - sp->dec_codetab[code].firstchar = (unsigned char)code; - sp->dec_codetab[code].value = (unsigned char)code; - sp->dec_codetab[code].repeated = true; - sp->dec_codetab[code].length = 1; - sp->dec_codetab[code].next = NULL; - } while (code--); - /* - * Zero-out the unused entries */ - /* Silence false positive */ - /* coverity[overrun-buffer-arg] */ - memset(&sp->dec_codetab[CODE_CLEAR], 0, - (CODE_FIRST - CODE_CLEAR) * sizeof(code_t)); - } - return (1); + if (sp->dec_codetab == NULL) { + sp->dec_codetab = (code_t*)_TIFFmalloc(CSIZE*sizeof (code_t)); + if (sp->dec_codetab == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, + "No space for LZW code table"); + return (0); + } + /* + * Pre-load the table. + */ + code = 255; + do { + sp->dec_codetab[code].value = (unsigned char)code; + sp->dec_codetab[code].firstchar = (unsigned char)code; + sp->dec_codetab[code].length = 1; + sp->dec_codetab[code].next = NULL; + } while (code--); + /* + * Zero-out the unused entries + */ + /* Silence false positive */ + /* coverity[overrun-buffer-arg] */ + _TIFFmemset(&sp->dec_codetab[CODE_CLEAR], 0, + (CODE_FIRST - CODE_CLEAR) * sizeof (code_t)); + } + return (1); } /* * Setup state for decoding a strip. */ -static int LZWPreDecode(TIFF *tif, uint16_t s) +static int +LZWPreDecode(TIFF* tif, uint16 s) { - static const char module[] = "LZWPreDecode"; - LZWCodecState *sp = DecoderState(tif); + static const char module[] = "LZWPreDecode"; + LZWCodecState *sp = DecoderState(tif); - (void)s; - assert(sp != NULL); - if (sp->dec_codetab == NULL) - { - tif->tif_setupdecode(tif); - if (sp->dec_codetab == NULL) - return (0); - } + (void) s; + assert(sp != NULL); + if( sp->dec_codetab == NULL ) + { + tif->tif_setupdecode( tif ); + if( sp->dec_codetab == NULL ) + return (0); + } - /* - * Check for old bit-reversed codes. - */ - if (tif->tif_rawcc >= 2 && tif->tif_rawdata[0] == 0 && - (tif->tif_rawdata[1] & 0x1)) - { + /* + * Check for old bit-reversed codes. + */ + if (tif->tif_rawcc >= 2 && + tif->tif_rawdata[0] == 0 && (tif->tif_rawdata[1] & 0x1)) { #ifdef LZW_COMPAT - if (!sp->dec_decode) - { - TIFFWarningExtR(tif, module, "Old-style LZW codes, convert file"); - /* - * Override default decoding methods with - * ones that deal with the old coding. - * Otherwise the predictor versions set - * above will call the compatibility routines - * through the dec_decode method. - */ - tif->tif_decoderow = LZWDecodeCompat; - tif->tif_decodestrip = LZWDecodeCompat; - tif->tif_decodetile = LZWDecodeCompat; - /* - * If doing horizontal differencing, must - * re-setup the predictor logic since we - * switched the basic decoder methods... - */ - (*tif->tif_setupdecode)(tif); - sp->dec_decode = LZWDecodeCompat; - } - sp->lzw_maxcode = MAXCODE(BITS_MIN); -#else /* !LZW_COMPAT */ - if (!sp->dec_decode) - { - TIFFErrorExtR(tif, module, "Old-style LZW codes not supported"); - sp->dec_decode = LZWDecode; - } - return (0); -#endif /* !LZW_COMPAT */ - } - else - { - sp->lzw_maxcode = MAXCODE(BITS_MIN) - 1; - sp->dec_decode = LZWDecode; - } - sp->lzw_nbits = BITS_MIN; - sp->lzw_nextbits = 0; - sp->lzw_nextdata = 0; + if (!sp->dec_decode) { + sp->read_error = 1; + TIFFWarningExt(tif->tif_clientdata, module, + "Old-style LZW codes, convert file"); + /* + * Override default decoding methods with + * ones that deal with the old coding. + * Otherwise the predictor versions set + * above will call the compatibility routines + * through the dec_decode method. + */ + tif->tif_decoderow = LZWDecodeCompat; + tif->tif_decodestrip = LZWDecodeCompat; + tif->tif_decodetile = LZWDecodeCompat; + /* + * If doing horizontal differencing, must + * re-setup the predictor logic since we + * switched the basic decoder methods... + */ + (*tif->tif_setupdecode)(tif); + sp->dec_decode = LZWDecodeCompat; + } + sp->lzw_maxcode = MAXCODE(BITS_MIN); +#else /* !LZW_COMPAT */ + if (!sp->dec_decode) { + sp->read_error = 1; + TIFFErrorExt(tif->tif_clientdata, module, + "Old-style LZW codes not supported"); + sp->dec_decode = LZWDecode; + } + return (0); +#endif/* !LZW_COMPAT */ + } else { + sp->lzw_maxcode = MAXCODE(BITS_MIN)-1; + sp->dec_decode = LZWDecode; + } + sp->lzw_nbits = BITS_MIN; + sp->lzw_nextbits = 0; + sp->lzw_nextdata = 0; - sp->dec_restart = 0; - sp->dec_nbitsmask = MAXCODE(BITS_MIN); - sp->dec_bitsleft = 0; - sp->old_tif_rawcc = 0; - sp->dec_free_entp = sp->dec_codetab - 1; // + CODE_FIRST; - /* - * Zero entries that are not yet filled in. We do - * this to guard against bogus input data that causes - * us to index into undefined entries. If you can - * come up with a way to safely bounds-check input codes - * while decoding then you can remove this operation. - */ - sp->dec_oldcodep = &sp->dec_codetab[0]; - sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask - 1]; - sp->read_error = 0; - return (1); + sp->dec_restart = 0; + sp->dec_nbitsmask = MAXCODE(BITS_MIN); +#ifdef LZW_CHECKEOS + sp->dec_bitsleft = 0; + sp->old_tif_rawcc = 0; +#endif + sp->dec_free_entp = sp->dec_codetab + CODE_FIRST; + /* + * Zero entries that are not yet filled in. We do + * this to guard against bogus input data that causes + * us to index into undefined entries. If you can + * come up with a way to safely bounds-check input codes + * while decoding then you can remove this operation. + */ + _TIFFmemset(sp->dec_free_entp, 0, (CSIZE-CODE_FIRST)*sizeof (code_t)); + sp->dec_oldcodep = &sp->dec_codetab[-1]; + sp->dec_maxcodep = &sp->dec_codetab[sp->dec_nbitsmask-1]; + sp->read_error = 0; + return (1); } /* * Decode a "hunk of data". */ +#define GetNextCode(sp, bp, code) { \ + nextdata = (nextdata<<8) | *(bp)++; \ + nextbits += 8; \ + if (nextbits < nbits) { \ + nextdata = (nextdata<<8) | *(bp)++; \ + nextbits += 8; \ + } \ + code = (hcode_t)((nextdata >> (nextbits-nbits)) & nbitsmask); \ + nextbits -= nbits; \ +} -/* Get the next 32 or 64-bit from the input data */ -#ifdef WORDS_BIGENDIAN -#define GetNextData(nextdata, bp) memcpy(&nextdata, bp, sizeof(nextdata)) -#elif SIZEOF_WORDTYPE == 8 -#if defined(__GNUC__) && defined(__x86_64__) -#define GetNextData(nextdata, bp) \ - nextdata = __builtin_bswap64(*(uint64_t *)(bp)) -#elif defined(_M_X64) -#define GetNextData(nextdata, bp) nextdata = _byteswap_uint64(*(uint64_t *)(bp)) -#elif defined(__GNUC__) -#define GetNextData(nextdata, bp) \ - memcpy(&nextdata, bp, sizeof(nextdata)); \ - nextdata = __builtin_bswap64(nextdata) -#else -#define GetNextData(nextdata, bp) \ - nextdata = (((uint64_t)bp[0]) << 56) | (((uint64_t)bp[1]) << 48) | \ - (((uint64_t)bp[2]) << 40) | (((uint64_t)bp[3]) << 32) | \ - (((uint64_t)bp[4]) << 24) | (((uint64_t)bp[5]) << 16) | \ - (((uint64_t)bp[6]) << 8) | (((uint64_t)bp[7])) +static void +codeLoop(TIFF* tif, const char* module) +{ + TIFFErrorExt(tif->tif_clientdata, module, + "Bogus encoding, loop in the code table; scanline %d", + tif->tif_row); +} + +static int +LZWDecode(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) +{ + static const char module[] = "LZWDecode"; + LZWCodecState *sp = DecoderState(tif); + char *op = (char*) op0; + tmsize_t occ = occ0; + char *tp; + unsigned char *bp; + hcode_t code; + int len; + long nbits, nextbits, nbitsmask; + unsigned long nextdata; + code_t *codep, *free_entp, *maxcodep, *oldcodep; + + (void) s; + assert(sp != NULL); + assert(sp->dec_codetab != NULL); + + if (sp->read_error) { + return 0; + } + + /* + * Restart interrupted output operation. + */ + if (sp->dec_restart) { + tmsize_t residue; + + codep = sp->dec_codep; + residue = codep->length - sp->dec_restart; + if (residue > occ) { + /* + * Residue from previous decode is sufficient + * to satisfy decode request. Skip to the + * start of the decoded string, place decoded + * values in the output buffer, and return. + */ + sp->dec_restart += occ; + do { + codep = codep->next; + } while (--residue > occ && codep); + if (codep) { + tp = op + occ; + do { + *--tp = codep->value; + codep = codep->next; + } while (--occ && codep); + } + return (1); + } + /* + * Residue satisfies only part of the decode request. + */ + op += residue; + occ -= residue; + tp = op; + do { + int t; + --tp; + t = codep->value; + codep = codep->next; + *tp = (char)t; + } while (--residue && codep); + sp->dec_restart = 0; + } + + bp = (unsigned char *)tif->tif_rawcp; +#ifdef LZW_CHECKEOS + sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3); #endif -#elif SIZEOF_WORDTYPE == 4 -#if defined(__GNUC__) && defined(__i386__) -#define GetNextData(nextdata, bp) \ - nextdata = __builtin_bswap32(*(uint32_t *)(bp)) -#elif defined(_M_X86) -#define GetNextData(nextdata, bp) \ - nextdata = _byteswap_ulong(*(unsigned long *)(bp)) -#elif defined(__GNUC__) -#define GetNextData(nextdata, bp) \ - memcpy(&nextdata, bp, sizeof(nextdata)); \ - nextdata = __builtin_bswap32(nextdata) -#else -#define GetNextData(nextdata, bp) \ - nextdata = (((uint32_t)bp[0]) << 24) | (((uint32_t)bp[1]) << 16) | \ - (((uint32_t)bp[2]) << 8) | (((uint32_t)bp[3])) -#endif -#else -#error "Unhandled SIZEOF_WORDTYPE" + nbits = sp->lzw_nbits; + nextdata = sp->lzw_nextdata; + nextbits = sp->lzw_nextbits; + nbitsmask = sp->dec_nbitsmask; + oldcodep = sp->dec_oldcodep; + free_entp = sp->dec_free_entp; + maxcodep = sp->dec_maxcodep; + + while (occ > 0) { + NextCode(tif, sp, bp, code, GetNextCode); + if (code == CODE_EOI) + break; + if (code == CODE_CLEAR) { + do { + free_entp = sp->dec_codetab + CODE_FIRST; + _TIFFmemset(free_entp, 0, + (CSIZE - CODE_FIRST) * sizeof (code_t)); + nbits = BITS_MIN; + nbitsmask = MAXCODE(BITS_MIN); + maxcodep = sp->dec_codetab + nbitsmask-1; + NextCode(tif, sp, bp, code, GetNextCode); + } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */ + if (code == CODE_EOI) + break; + if (code > CODE_CLEAR) { + sp->read_error = 1; + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "LZWDecode: Corrupted LZW table at scanline %d", + tif->tif_row); + return (0); + } + *op++ = (char)code; + occ--; + oldcodep = sp->dec_codetab + code; + continue; + } + codep = sp->dec_codetab + code; + + /* + * Add the new entry to the code table. + */ + if (free_entp < &sp->dec_codetab[0] || + free_entp >= &sp->dec_codetab[CSIZE]) { + sp->read_error = 1; + TIFFErrorExt(tif->tif_clientdata, module, + "Corrupted LZW table at scanline %d", + tif->tif_row); + return (0); + } + + free_entp->next = oldcodep; + if (free_entp->next < &sp->dec_codetab[0] || + free_entp->next >= &sp->dec_codetab[CSIZE]) { + sp->read_error = 1; + TIFFErrorExt(tif->tif_clientdata, module, + "Corrupted LZW table at scanline %d", + tif->tif_row); + return (0); + } + free_entp->firstchar = free_entp->next->firstchar; + free_entp->length = free_entp->next->length+1; + free_entp->value = (codep < free_entp) ? + codep->firstchar : free_entp->firstchar; + if (++free_entp > maxcodep) { + if (++nbits > BITS_MAX) /* should not happen */ + nbits = BITS_MAX; + nbitsmask = MAXCODE(nbits); + maxcodep = sp->dec_codetab + nbitsmask-1; + } + oldcodep = codep; + if (code >= 256) { + /* + * Code maps to a string, copy string + * value to output (written in reverse). + */ + if(codep->length == 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Wrong length of decoded string: " + "data probably corrupted at scanline %d", + tif->tif_row); + return (0); + } + if (codep->length > occ) { + /* + * String is too long for decode buffer, + * locate portion that will fit, copy to + * the decode buffer, and setup restart + * logic for the next decoding call. + */ + sp->dec_codep = codep; + do { + codep = codep->next; + } while (codep && codep->length > occ); + if (codep) { + sp->dec_restart = occ; + tp = op + occ; + do { + *--tp = codep->value; + codep = codep->next; + } while (--occ && codep); + if (codep) + codeLoop(tif, module); + } + break; + } + len = codep->length; + tp = op + len; + do { + int t; + --tp; + t = codep->value; + codep = codep->next; + *tp = (char)t; + } while (codep && tp > op); + if (codep) { + codeLoop(tif, module); + break; + } + assert(occ >= len); + op += len; + occ -= len; + } else { + *op++ = (char)code; + occ--; + } + } + + tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp ); + tif->tif_rawcp = (uint8*) bp; +#ifdef LZW_CHECKEOS + sp->old_tif_rawcc = tif->tif_rawcc; #endif + sp->lzw_nbits = (unsigned short) nbits; + sp->lzw_nextdata = nextdata; + sp->lzw_nextbits = nextbits; + sp->dec_nbitsmask = nbitsmask; + sp->dec_oldcodep = oldcodep; + sp->dec_free_entp = free_entp; + sp->dec_maxcodep = maxcodep; -#define GetNextCodeLZW() \ - do \ - { \ - nextbits -= nbits; \ - if (nextbits < 0) \ - { \ - if (dec_bitsleft >= 8 * SIZEOF_WORDTYPE) \ - { \ - unsigned codetmp = (unsigned)(nextdata << (-nextbits)); \ - GetNextData(nextdata, bp); \ - bp += SIZEOF_WORDTYPE; \ - nextbits += 8 * SIZEOF_WORDTYPE; \ - dec_bitsleft -= 8 * SIZEOF_WORDTYPE; \ - code = (WordType)((codetmp | (nextdata >> nextbits)) & \ - nbitsmask); \ - break; \ - } \ - else \ - { \ - if (dec_bitsleft < 8) \ - { \ - goto no_eoi; \ - } \ - nextdata = (nextdata << 8) | *(bp)++; \ - nextbits += 8; \ - dec_bitsleft -= 8; \ - if (nextbits < 0) \ - { \ - if (dec_bitsleft < 8) \ - { \ - goto no_eoi; \ - } \ - nextdata = (nextdata << 8) | *(bp)++; \ - nextbits += 8; \ - dec_bitsleft -= 8; \ - } \ - } \ - } \ - code = (WordType)((nextdata >> nextbits) & nbitsmask); \ - } while (0) - -static int LZWDecode(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s) -{ - static const char module[] = "LZWDecode"; - LZWCodecState *sp = DecoderState(tif); - uint8_t *op = (uint8_t *)op0; - tmsize_t occ = occ0; - uint8_t *bp; - long nbits, nextbits, nbitsmask; - WordType nextdata; - code_t *free_entp, *maxcodep, *oldcodep; - - (void)s; - assert(sp != NULL); - assert(sp->dec_codetab != NULL); - - if (sp->read_error) - { - TIFFErrorExtR(tif, module, - "LZWDecode: Scanline %" PRIu32 " cannot be read due to " - "previous error", - tif->tif_row); - return 0; - } - - /* - * Restart interrupted output operation. - */ - if (sp->dec_restart) - { - tmsize_t residue; - - code_t *codep = sp->dec_codep; - residue = codep->length - sp->dec_restart; - if (residue > occ) - { - /* - * Residue from previous decode is sufficient - * to satisfy decode request. Skip to the - * start of the decoded string, place decoded - * values in the output buffer, and return. - */ - sp->dec_restart += occ; - do - { - codep = codep->next; - } while (--residue > occ && codep); - if (codep) - { - uint8_t *tp = op + occ; - do - { - *--tp = codep->value; - codep = codep->next; - } while (--occ && codep); - } - return (1); - } - /* - * Residue satisfies only part of the decode request. - */ - op += residue; - occ -= residue; - uint8_t *tp = op; - do - { - *--tp = codep->value; - codep = codep->next; - } while (--residue && codep); - sp->dec_restart = 0; - } - - bp = (uint8_t *)tif->tif_rawcp; - sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3); - uint64_t dec_bitsleft = sp->dec_bitsleft; - nbits = sp->lzw_nbits; - nextdata = sp->lzw_nextdata; - nextbits = sp->lzw_nextbits; - nbitsmask = sp->dec_nbitsmask; - oldcodep = sp->dec_oldcodep; - free_entp = sp->dec_free_entp; - maxcodep = sp->dec_maxcodep; - code_t *const dec_codetab = sp->dec_codetab; - code_t *codep; - - if (occ == 0) - { - goto after_loop; - } - -begin: -{ - WordType code; - GetNextCodeLZW(); - codep = dec_codetab + code; - if (code >= CODE_FIRST) - goto code_above_or_equal_to_258; - if (code < 256) - goto code_below_256; - if (code == CODE_EOI) - goto after_loop; - goto code_clear; - -code_below_256: -{ - if (codep > free_entp) - goto error_code; - free_entp->next = oldcodep; - free_entp->firstchar = oldcodep->firstchar; - free_entp->length = oldcodep->length + 1; - free_entp->value = (uint8_t)code; - free_entp->repeated = - (bool)(oldcodep->repeated & (oldcodep->value == code)); - if (++free_entp > maxcodep) - { - if (++nbits > BITS_MAX) /* should not happen for a conformant encoder */ - nbits = BITS_MAX; - nbitsmask = MAXCODE(nbits); - maxcodep = dec_codetab + nbitsmask - 1; - if (free_entp >= &dec_codetab[CSIZE]) - { - /* At that point, the next valid states are either EOI or a */ - /* CODE_CLEAR. If a regular code is read, at the next */ - /* attempt at registering a new entry, we will error out */ - /* due to setting free_entp before any valid code */ - free_entp = dec_codetab - 1; - } - } - oldcodep = codep; - *op++ = (uint8_t)code; - occ--; - if (occ == 0) - goto after_loop; - goto begin; -} - -code_above_or_equal_to_258: -{ - /* - * Add the new entry to the code table. - */ - - if (codep >= free_entp) - { - if (codep != free_entp) - goto error_code; - free_entp->value = oldcodep->firstchar; - } - else - { - free_entp->value = codep->firstchar; - } - free_entp->repeated = - (bool)(oldcodep->repeated & (oldcodep->value == free_entp->value)); - free_entp->next = oldcodep; - - free_entp->firstchar = oldcodep->firstchar; - free_entp->length = oldcodep->length + 1; - if (++free_entp > maxcodep) - { - if (++nbits > BITS_MAX) /* should not happen for a conformant encoder */ - nbits = BITS_MAX; - nbitsmask = MAXCODE(nbits); - maxcodep = dec_codetab + nbitsmask - 1; - if (free_entp >= &dec_codetab[CSIZE]) - { - /* At that point, the next valid states are either EOI or a */ - /* CODE_CLEAR. If a regular code is read, at the next */ - /* attempt at registering a new entry, we will error out */ - /* due to setting free_entp before any valid code */ - free_entp = dec_codetab - 1; - } - } - oldcodep = codep; - - /* - * Code maps to a string, copy string - * value to output (written in reverse). - */ - /* tiny bit faster on x86_64 to store in unsigned short than int */ - unsigned short len = codep->length; - - if (len < 3) /* equivalent to len == 2 given all other conditions */ - { - if (occ <= 2) - { - if (occ == 2) - { - memcpy(op, &(codep->firstchar), 2); - op += 2; - occ -= 2; - goto after_loop; - } - goto too_short_buffer; - } - - memcpy(op, &(codep->firstchar), 2); - op += 2; - occ -= 2; - goto begin; /* we can save the comparison occ > 0 */ - } - - if (len == 3) - { - if (occ <= 3) - { - if (occ == 3) - { - op[0] = codep->firstchar; - op[1] = codep->next->value; - op[2] = codep->value; - op += 3; - occ -= 3; - goto after_loop; - } - goto too_short_buffer; - } - - op[0] = codep->firstchar; - op[1] = codep->next->value; - op[2] = codep->value; - op += 3; - occ -= 3; - goto begin; /* we can save the comparison occ > 0 */ - } - - if (len > occ) - { - goto too_short_buffer; - } - - if (codep->repeated) - { - memset(op, codep->value, len); - op += len; - occ -= len; - if (occ == 0) - goto after_loop; - goto begin; - } - - uint8_t *tp = op + len; - - assert(len >= 4); - - *--tp = codep->value; - codep = codep->next; - *--tp = codep->value; - codep = codep->next; - *--tp = codep->value; - codep = codep->next; - *--tp = codep->value; - if (tp > op) - { - do - { - codep = codep->next; - *--tp = codep->value; - } while (tp > op); - } - - assert(occ >= len); - op += len; - occ -= len; - if (occ == 0) - goto after_loop; - goto begin; -} - -code_clear: -{ - free_entp = dec_codetab + CODE_FIRST; - nbits = BITS_MIN; - nbitsmask = MAXCODE(BITS_MIN); - maxcodep = dec_codetab + nbitsmask - 1; - do - { - GetNextCodeLZW(); - } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */ - if (code == CODE_EOI) - goto after_loop; - if (code > CODE_EOI) - { - goto error_code; - } - *op++ = (uint8_t)code; - occ--; - oldcodep = dec_codetab + code; - if (occ == 0) - goto after_loop; - goto begin; -} -} - -too_short_buffer: -{ - /* - * String is too long for decode buffer, - * locate portion that will fit, copy to - * the decode buffer, and setup restart - * logic for the next decoding call. - */ - sp->dec_codep = codep; - do - { - codep = codep->next; - } while (codep->length > occ); - - sp->dec_restart = occ; - uint8_t *tp = op + occ; - do - { - *--tp = codep->value; - codep = codep->next; - } while (--occ); -} - -after_loop: - tif->tif_rawcc -= (tmsize_t)((uint8_t *)bp - tif->tif_rawcp); - tif->tif_rawcp = (uint8_t *)bp; - sp->old_tif_rawcc = tif->tif_rawcc; - sp->dec_bitsleft = dec_bitsleft; - sp->lzw_nbits = (unsigned short)nbits; - sp->lzw_nextdata = nextdata; - sp->lzw_nextbits = nextbits; - sp->dec_nbitsmask = nbitsmask; - sp->dec_oldcodep = oldcodep; - sp->dec_free_entp = free_entp; - sp->dec_maxcodep = maxcodep; - - if (occ > 0) - { - TIFFErrorExtR(tif, module, - "Not enough data at scanline %" PRIu32 " (short %" PRIu64 - " bytes)", - tif->tif_row, (uint64_t)occ); - return (0); - } - return (1); - -no_eoi: - sp->read_error = 1; - TIFFErrorExtR(tif, module, - "LZWDecode: Strip %" PRIu32 " not terminated with EOI code", - tif->tif_curstrip); - return 0; -error_code: - sp->read_error = 1; - TIFFErrorExtR(tif, tif->tif_name, "Using code not yet in table"); - return 0; + if (occ > 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at scanline %d (short " TIFF_SSIZE_FORMAT " bytes)", + tif->tif_row, occ); + return (0); + } + return (1); } #ifdef LZW_COMPAT - -/* - * This check shouldn't be necessary because each - * strip is suppose to be terminated with CODE_EOI. - */ -#define NextCode(_tif, _sp, _bp, _code, _get, dec_bitsleft) \ - { \ - if (dec_bitsleft < (uint64_t)nbits) \ - { \ - TIFFWarningExtR(_tif, module, \ - "LZWDecode: Strip %" PRIu32 \ - " not terminated with EOI code", \ - _tif->tif_curstrip); \ - _code = CODE_EOI; \ - } \ - else \ - { \ - _get(_sp, _bp, _code); \ - dec_bitsleft -= nbits; \ - } \ - } - /* * Decode a "hunk of data" for old images. */ -#define GetNextCodeCompat(sp, bp, code) \ - { \ - nextdata |= (unsigned long)*(bp)++ << nextbits; \ - nextbits += 8; \ - if (nextbits < nbits) \ - { \ - nextdata |= (unsigned long)*(bp)++ << nextbits; \ - nextbits += 8; \ - } \ - code = (hcode_t)(nextdata & nbitsmask); \ - nextdata >>= nbits; \ - nextbits -= nbits; \ - } +#define GetNextCodeCompat(sp, bp, code) { \ + nextdata |= (unsigned long) *(bp)++ << nextbits; \ + nextbits += 8; \ + if (nextbits < nbits) { \ + nextdata |= (unsigned long) *(bp)++ << nextbits;\ + nextbits += 8; \ + } \ + code = (hcode_t)(nextdata & nbitsmask); \ + nextdata >>= nbits; \ + nextbits -= nbits; \ +} -static int LZWDecodeCompat(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s) +static int +LZWDecodeCompat(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) { - static const char module[] = "LZWDecodeCompat"; - LZWCodecState *sp = DecoderState(tif); - uint8_t *op = (uint8_t *)op0; - tmsize_t occ = occ0; - uint8_t *tp; - uint8_t *bp; - int code, nbits; - int len; - long nextbits, nbitsmask; - WordType nextdata; - code_t *codep, *free_entp, *maxcodep, *oldcodep; + static const char module[] = "LZWDecodeCompat"; + LZWCodecState *sp = DecoderState(tif); + char *op = (char*) op0; + tmsize_t occ = occ0; + char *tp; + unsigned char *bp; + int code, nbits; + int len; + long nextbits, nextdata, nbitsmask; + code_t *codep, *free_entp, *maxcodep, *oldcodep; - (void)s; - assert(sp != NULL); + (void) s; + assert(sp != NULL); - /* - * Restart interrupted output operation. - */ - if (sp->dec_restart) - { - tmsize_t residue; + /* + * Restart interrupted output operation. + */ + if (sp->dec_restart) { + tmsize_t residue; - codep = sp->dec_codep; - residue = codep->length - sp->dec_restart; - if (residue > occ) - { - /* - * Residue from previous decode is sufficient - * to satisfy decode request. Skip to the - * start of the decoded string, place decoded - * values in the output buffer, and return. - */ - sp->dec_restart += occ; - do - { - codep = codep->next; - } while (--residue > occ); - tp = op + occ; - do - { - *--tp = codep->value; - codep = codep->next; - } while (--occ); - return (1); - } - /* - * Residue satisfies only part of the decode request. - */ - op += residue; - occ -= residue; - tp = op; - do - { - *--tp = codep->value; - codep = codep->next; - } while (--residue); - sp->dec_restart = 0; - } + codep = sp->dec_codep; + residue = codep->length - sp->dec_restart; + if (residue > occ) { + /* + * Residue from previous decode is sufficient + * to satisfy decode request. Skip to the + * start of the decoded string, place decoded + * values in the output buffer, and return. + */ + sp->dec_restart += occ; + do { + codep = codep->next; + } while (--residue > occ); + tp = op + occ; + do { + *--tp = codep->value; + codep = codep->next; + } while (--occ); + return (1); + } + /* + * Residue satisfies only part of the decode request. + */ + op += residue; + occ -= residue; + tp = op; + do { + *--tp = codep->value; + codep = codep->next; + } while (--residue); + sp->dec_restart = 0; + } - bp = (uint8_t *)tif->tif_rawcp; + bp = (unsigned char *)tif->tif_rawcp; +#ifdef LZW_CHECKEOS + sp->dec_bitsleft += (((uint64)tif->tif_rawcc - sp->old_tif_rawcc) << 3); +#endif + nbits = sp->lzw_nbits; + nextdata = sp->lzw_nextdata; + nextbits = sp->lzw_nextbits; + nbitsmask = sp->dec_nbitsmask; + oldcodep = sp->dec_oldcodep; + free_entp = sp->dec_free_entp; + maxcodep = sp->dec_maxcodep; - sp->dec_bitsleft += (((uint64_t)tif->tif_rawcc - sp->old_tif_rawcc) << 3); - uint64_t dec_bitsleft = sp->dec_bitsleft; + while (occ > 0) { + NextCode(tif, sp, bp, code, GetNextCodeCompat); + if (code == CODE_EOI) + break; + if (code == CODE_CLEAR) { + do { + free_entp = sp->dec_codetab + CODE_FIRST; + _TIFFmemset(free_entp, 0, + (CSIZE - CODE_FIRST) * sizeof (code_t)); + nbits = BITS_MIN; + nbitsmask = MAXCODE(BITS_MIN); + maxcodep = sp->dec_codetab + nbitsmask; + NextCode(tif, sp, bp, code, GetNextCodeCompat); + } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */ + if (code == CODE_EOI) + break; + if (code > CODE_CLEAR) { + sp->read_error = 1; + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "LZWDecode: Corrupted LZW table at scanline %d", + tif->tif_row); + return (0); + } + *op++ = (char)code; + occ--; + oldcodep = sp->dec_codetab + code; + continue; + } + codep = sp->dec_codetab + code; - nbits = sp->lzw_nbits; - nextdata = sp->lzw_nextdata; - nextbits = sp->lzw_nextbits; - nbitsmask = sp->dec_nbitsmask; - oldcodep = sp->dec_oldcodep; - free_entp = sp->dec_free_entp; - maxcodep = sp->dec_maxcodep; + /* + * Add the new entry to the code table. + */ + if (free_entp < &sp->dec_codetab[0] || + free_entp >= &sp->dec_codetab[CSIZE]) { + sp->read_error = 1; + TIFFErrorExt(tif->tif_clientdata, module, + "Corrupted LZW table at scanline %d", tif->tif_row); + return (0); + } - while (occ > 0) - { - NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft); - if (code == CODE_EOI) - break; - if (code == CODE_CLEAR) - { - do - { - free_entp = sp->dec_codetab + CODE_FIRST; - _TIFFmemset(free_entp, 0, - (CSIZE - CODE_FIRST) * sizeof(code_t)); - nbits = BITS_MIN; - nbitsmask = MAXCODE(BITS_MIN); - maxcodep = sp->dec_codetab + nbitsmask; - NextCode(tif, sp, bp, code, GetNextCodeCompat, dec_bitsleft); - } while (code == CODE_CLEAR); /* consecutive CODE_CLEAR codes */ - if (code == CODE_EOI) - break; - if (code > CODE_CLEAR) - { - TIFFErrorExtR( - tif, tif->tif_name, - "LZWDecode: Corrupted LZW table at scanline %" PRIu32, - tif->tif_row); - return (0); - } - *op++ = (uint8_t)code; - occ--; - oldcodep = sp->dec_codetab + code; - continue; - } - codep = sp->dec_codetab + code; + free_entp->next = oldcodep; + if (free_entp->next < &sp->dec_codetab[0] || + free_entp->next >= &sp->dec_codetab[CSIZE]) { + sp->read_error = 1; + TIFFErrorExt(tif->tif_clientdata, module, + "Corrupted LZW table at scanline %d", tif->tif_row); + return (0); + } + free_entp->firstchar = free_entp->next->firstchar; + free_entp->length = free_entp->next->length+1; + free_entp->value = (codep < free_entp) ? + codep->firstchar : free_entp->firstchar; + if (++free_entp > maxcodep) { + if (++nbits > BITS_MAX) /* should not happen */ + nbits = BITS_MAX; + nbitsmask = MAXCODE(nbits); + maxcodep = sp->dec_codetab + nbitsmask; + } + oldcodep = codep; + if (code >= 256) { + /* + * Code maps to a string, copy string + * value to output (written in reverse). + */ + if(codep->length == 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Wrong length of decoded " + "string: data probably corrupted at scanline %d", + tif->tif_row); + return (0); + } + if (codep->length > occ) { + /* + * String is too long for decode buffer, + * locate portion that will fit, copy to + * the decode buffer, and setup restart + * logic for the next decoding call. + */ + sp->dec_codep = codep; + do { + codep = codep->next; + } while (codep->length > occ); + sp->dec_restart = occ; + tp = op + occ; + do { + *--tp = codep->value; + codep = codep->next; + } while (--occ); + break; + } + len = codep->length; + tp = op + len; + do { + int t; + --tp; + t = codep->value; + codep = codep->next; + *tp = (char)t; + } while (codep && tp > op); + assert(occ >= len); + op += len; + occ -= len; + } else { + *op++ = (char)code; + occ--; + } + } - /* - * Add the new entry to the code table. - */ - if (free_entp < &sp->dec_codetab[0] || - free_entp >= &sp->dec_codetab[CSIZE]) - { - TIFFErrorExtR(tif, module, - "Corrupted LZW table at scanline %" PRIu32, - tif->tif_row); - return (0); - } + tif->tif_rawcc -= (tmsize_t)( (uint8*) bp - tif->tif_rawcp ); + tif->tif_rawcp = (uint8*) bp; +#ifdef LZW_CHECKEOS + sp->old_tif_rawcc = tif->tif_rawcc; +#endif + sp->lzw_nbits = (unsigned short)nbits; + sp->lzw_nextdata = nextdata; + sp->lzw_nextbits = nextbits; + sp->dec_nbitsmask = nbitsmask; + sp->dec_oldcodep = oldcodep; + sp->dec_free_entp = free_entp; + sp->dec_maxcodep = maxcodep; - free_entp->next = oldcodep; - if (free_entp->next < &sp->dec_codetab[0] || - free_entp->next >= &sp->dec_codetab[CSIZE]) - { - TIFFErrorExtR(tif, module, - "Corrupted LZW table at scanline %" PRIu32, - tif->tif_row); - return (0); - } - free_entp->firstchar = free_entp->next->firstchar; - free_entp->length = free_entp->next->length + 1; - free_entp->value = - (codep < free_entp) ? codep->firstchar : free_entp->firstchar; - if (++free_entp > maxcodep) - { - if (++nbits > BITS_MAX) /* should not happen */ - nbits = BITS_MAX; - nbitsmask = MAXCODE(nbits); - maxcodep = sp->dec_codetab + nbitsmask; - } - oldcodep = codep; - if (code >= 256) - { - /* - * Code maps to a string, copy string - * value to output (written in reverse). - */ - if (codep->length == 0) - { - TIFFErrorExtR( - tif, module, - "Wrong length of decoded " - "string: data probably corrupted at scanline %" PRIu32, - tif->tif_row); - return (0); - } - if (codep->length > occ) - { - /* - * String is too long for decode buffer, - * locate portion that will fit, copy to - * the decode buffer, and setup restart - * logic for the next decoding call. - */ - sp->dec_codep = codep; - do - { - codep = codep->next; - } while (codep->length > occ); - sp->dec_restart = occ; - tp = op + occ; - do - { - *--tp = codep->value; - codep = codep->next; - } while (--occ); - break; - } - len = codep->length; - tp = op + len; - do - { - *--tp = codep->value; - codep = codep->next; - } while (codep && tp > op); - assert(occ >= len); - op += len; - occ -= len; - } - else - { - *op++ = (uint8_t)code; - occ--; - } - } - - tif->tif_rawcc -= (tmsize_t)((uint8_t *)bp - tif->tif_rawcp); - tif->tif_rawcp = (uint8_t *)bp; - - sp->old_tif_rawcc = tif->tif_rawcc; - sp->dec_bitsleft = dec_bitsleft; - - sp->lzw_nbits = (unsigned short)nbits; - sp->lzw_nextdata = nextdata; - sp->lzw_nextbits = nextbits; - sp->dec_nbitsmask = nbitsmask; - sp->dec_oldcodep = oldcodep; - sp->dec_free_entp = free_entp; - sp->dec_maxcodep = maxcodep; - - if (occ > 0) - { - TIFFErrorExtR(tif, module, - "Not enough data at scanline %" PRIu32 " (short %" PRIu64 - " bytes)", - tif->tif_row, (uint64_t)occ); - return (0); - } - return (1); + if (occ > 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at scanline %d (short " TIFF_SSIZE_FORMAT " bytes)", + tif->tif_row, occ); + return (0); + } + return (1); } #endif /* LZW_COMPAT */ @@ -1023,416 +800,393 @@ static int LZWDecodeCompat(TIFF *tif, uint8_t *op0, tmsize_t occ0, uint16_t s) * LZW Encoding. */ -static int LZWSetupEncode(TIFF *tif) +static int +LZWSetupEncode(TIFF* tif) { - static const char module[] = "LZWSetupEncode"; - LZWCodecState *sp = EncoderState(tif); + static const char module[] = "LZWSetupEncode"; + LZWCodecState* sp = EncoderState(tif); - assert(sp != NULL); - sp->enc_hashtab = (hash_t *)_TIFFmallocExt(tif, HSIZE * sizeof(hash_t)); - if (sp->enc_hashtab == NULL) - { - TIFFErrorExtR(tif, module, "No space for LZW hash table"); - return (0); - } - return (1); + assert(sp != NULL); + sp->enc_hashtab = (hash_t*) _TIFFmalloc(HSIZE*sizeof (hash_t)); + if (sp->enc_hashtab == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, + "No space for LZW hash table"); + return (0); + } + return (1); } /* * Reset encoding state at the start of a strip. */ -static int LZWPreEncode(TIFF *tif, uint16_t s) +static int +LZWPreEncode(TIFF* tif, uint16 s) { - LZWCodecState *sp = EncoderState(tif); + LZWCodecState *sp = EncoderState(tif); - (void)s; - assert(sp != NULL); + (void) s; + assert(sp != NULL); - if (sp->enc_hashtab == NULL) - { - tif->tif_setupencode(tif); - } + if( sp->enc_hashtab == NULL ) + { + tif->tif_setupencode( tif ); + } - sp->lzw_nbits = BITS_MIN; - sp->lzw_maxcode = MAXCODE(BITS_MIN); - sp->lzw_free_ent = CODE_FIRST; - sp->lzw_nextbits = 0; - sp->lzw_nextdata = 0; - sp->enc_checkpoint = CHECK_GAP; - sp->enc_ratio = 0; - sp->enc_incount = 0; - sp->enc_outcount = 0; - /* - * The 4 here insures there is space for 2 max-sized - * codes in LZWEncode and LZWPostDecode. - */ - sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize - 1 - 4; - cl_hash(sp); /* clear hash table */ - sp->enc_oldcode = (hcode_t)-1; /* generates CODE_CLEAR in LZWEncode */ - return (1); + sp->lzw_nbits = BITS_MIN; + sp->lzw_maxcode = MAXCODE(BITS_MIN); + sp->lzw_free_ent = CODE_FIRST; + sp->lzw_nextbits = 0; + sp->lzw_nextdata = 0; + sp->enc_checkpoint = CHECK_GAP; + sp->enc_ratio = 0; + sp->enc_incount = 0; + sp->enc_outcount = 0; + /* + * The 4 here insures there is space for 2 max-sized + * codes in LZWEncode and LZWPostDecode. + */ + sp->enc_rawlimit = tif->tif_rawdata + tif->tif_rawdatasize-1 - 4; + cl_hash(sp); /* clear hash table */ + sp->enc_oldcode = (hcode_t) -1; /* generates CODE_CLEAR in LZWEncode */ + return (1); } -#define CALCRATIO(sp, rat) \ - { \ - if (incount > 0x007fffff) \ - { /* NB: shift will overflow */ \ - rat = outcount >> 8; \ - rat = (rat == 0 ? 0x7fffffff : incount / rat); \ - } \ - else \ - rat = (incount << 8) / outcount; \ - } +#define CALCRATIO(sp, rat) { \ + if (incount > 0x007fffff) { /* NB: shift will overflow */\ + rat = outcount >> 8; \ + rat = (rat == 0 ? 0x7fffffff : incount/rat); \ + } else \ + rat = (incount<<8) / outcount; \ +} /* Explicit 0xff masking to make icc -check=conversions happy */ -#define PutNextCode(op, c) \ - { \ - nextdata = (nextdata << nbits) | c; \ - nextbits += nbits; \ - *op++ = (unsigned char)((nextdata >> (nextbits - 8)) & 0xff); \ - nextbits -= 8; \ - if (nextbits >= 8) \ - { \ - *op++ = (unsigned char)((nextdata >> (nextbits - 8)) & 0xff); \ - nextbits -= 8; \ - } \ - outcount += nbits; \ - } +#define PutNextCode(op, c) { \ + nextdata = (nextdata << nbits) | c; \ + nextbits += nbits; \ + *op++ = (unsigned char)((nextdata >> (nextbits-8))&0xff); \ + nextbits -= 8; \ + if (nextbits >= 8) { \ + *op++ = (unsigned char)((nextdata >> (nextbits-8))&0xff); \ + nextbits -= 8; \ + } \ + outcount += nbits; \ +} /* * Encode a chunk of pixels. * - * Uses an open addressing double hashing (no chaining) on the + * Uses an open addressing double hashing (no chaining) on the * prefix code/next character combination. We do a variant of * Knuth's algorithm D (vol. 3, sec. 6.4) along with G. Knott's * relatively-prime secondary probe. Here, the modular division - * first probe is gives way to a faster exclusive-or manipulation. + * first probe is gives way to a faster exclusive-or manipulation. * Also do block compression with an adaptive reset, whereby the * code table is cleared when the compression ratio decreases, * but after the table fills. The variable-length output codes * are re-sized at this point, and a CODE_CLEAR is generated - * for the decoder. + * for the decoder. */ -static int LZWEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +LZWEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - register LZWCodecState *sp = EncoderState(tif); - register long fcode; - register hash_t *hp; - register int h, c; - hcode_t ent; - long disp; - tmsize_t incount, outcount, checkpoint; - WordType nextdata; - long nextbits; - int free_ent, maxcode, nbits; - uint8_t *op; - uint8_t *limit; + register LZWCodecState *sp = EncoderState(tif); + register long fcode; + register hash_t *hp; + register int h, c; + hcode_t ent; + long disp; + tmsize_t incount, outcount, checkpoint; + unsigned long nextdata; + long nextbits; + int free_ent, maxcode, nbits; + uint8* op; + uint8* limit; - (void)s; - if (sp == NULL) - return (0); + (void) s; + if (sp == NULL) + return (0); - assert(sp->enc_hashtab != NULL); + assert(sp->enc_hashtab != NULL); - /* - * Load local state. - */ - incount = sp->enc_incount; - outcount = sp->enc_outcount; - checkpoint = sp->enc_checkpoint; - nextdata = sp->lzw_nextdata; - nextbits = sp->lzw_nextbits; - free_ent = sp->lzw_free_ent; - maxcode = sp->lzw_maxcode; - nbits = sp->lzw_nbits; - op = tif->tif_rawcp; - limit = sp->enc_rawlimit; - ent = (hcode_t)sp->enc_oldcode; + /* + * Load local state. + */ + incount = sp->enc_incount; + outcount = sp->enc_outcount; + checkpoint = sp->enc_checkpoint; + nextdata = sp->lzw_nextdata; + nextbits = sp->lzw_nextbits; + free_ent = sp->lzw_free_ent; + maxcode = sp->lzw_maxcode; + nbits = sp->lzw_nbits; + op = tif->tif_rawcp; + limit = sp->enc_rawlimit; + ent = (hcode_t)sp->enc_oldcode; - if (ent == (hcode_t)-1 && cc > 0) - { - /* - * NB: This is safe because it can only happen - * at the start of a strip where we know there - * is space in the data buffer. - */ - PutNextCode(op, CODE_CLEAR); - ent = *bp++; - cc--; - incount++; - } - while (cc > 0) - { - c = *bp++; - cc--; - incount++; - fcode = ((long)c << BITS_MAX) + ent; - h = (c << HSHIFT) ^ ent; /* xor hashing */ + if (ent == (hcode_t) -1 && cc > 0) { + /* + * NB: This is safe because it can only happen + * at the start of a strip where we know there + * is space in the data buffer. + */ + PutNextCode(op, CODE_CLEAR); + ent = *bp++; cc--; incount++; + } + while (cc > 0) { + c = *bp++; cc--; incount++; + fcode = ((long)c << BITS_MAX) + ent; + h = (c << HSHIFT) ^ ent; /* xor hashing */ #ifdef _WINDOWS - /* - * Check hash index for an overflow. - */ - if (h >= HSIZE) - h -= HSIZE; + /* + * Check hash index for an overflow. + */ + if (h >= HSIZE) + h -= HSIZE; #endif - hp = &sp->enc_hashtab[h]; - if (hp->hash == fcode) - { - ent = hp->code; - continue; - } - if (hp->hash >= 0) - { - /* - * Primary hash failed, check secondary hash. - */ - disp = HSIZE - h; - if (h == 0) - disp = 1; - do - { - /* - * Avoid pointer arithmetic because of - * wraparound problems with segments. - */ - if ((h -= disp) < 0) - h += HSIZE; - hp = &sp->enc_hashtab[h]; - if (hp->hash == fcode) - { - ent = hp->code; - goto hit; - } - } while (hp->hash >= 0); - } - /* - * New entry, emit code and add to table. - */ - /* - * Verify there is space in the buffer for the code - * and any potential Clear code that might be emitted - * below. The value of limit is setup so that there - * are at least 4 bytes free--room for 2 codes. - */ - if (op > limit) - { - tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); - if (!TIFFFlushData1(tif)) - return 0; - op = tif->tif_rawdata; - } - PutNextCode(op, ent); - ent = (hcode_t)c; - hp->code = (hcode_t)(free_ent++); - hp->hash = fcode; - if (free_ent == CODE_MAX - 1) - { - /* table is full, emit clear code and reset */ - cl_hash(sp); - sp->enc_ratio = 0; - incount = 0; - outcount = 0; - free_ent = CODE_FIRST; - PutNextCode(op, CODE_CLEAR); - nbits = BITS_MIN; - maxcode = MAXCODE(BITS_MIN); - } - else - { - /* - * If the next entry is going to be too big for - * the code size, then increase it, if possible. - */ - if (free_ent > maxcode) - { - nbits++; - assert(nbits <= BITS_MAX); - maxcode = (int)MAXCODE(nbits); - } - else if (incount >= checkpoint) - { - tmsize_t rat; - /* - * Check compression ratio and, if things seem - * to be slipping, clear the hash table and - * reset state. The compression ratio is a - * 24+8-bit fractional number. - */ - checkpoint = incount + CHECK_GAP; - CALCRATIO(sp, rat); - if (rat <= sp->enc_ratio) - { - cl_hash(sp); - sp->enc_ratio = 0; - incount = 0; - outcount = 0; - free_ent = CODE_FIRST; - PutNextCode(op, CODE_CLEAR); - nbits = BITS_MIN; - maxcode = MAXCODE(BITS_MIN); - } - else - sp->enc_ratio = rat; - } - } - hit:; - } + hp = &sp->enc_hashtab[h]; + if (hp->hash == fcode) { + ent = hp->code; + continue; + } + if (hp->hash >= 0) { + /* + * Primary hash failed, check secondary hash. + */ + disp = HSIZE - h; + if (h == 0) + disp = 1; + do { + /* + * Avoid pointer arithmetic because of + * wraparound problems with segments. + */ + if ((h -= disp) < 0) + h += HSIZE; + hp = &sp->enc_hashtab[h]; + if (hp->hash == fcode) { + ent = hp->code; + goto hit; + } + } while (hp->hash >= 0); + } + /* + * New entry, emit code and add to table. + */ + /* + * Verify there is space in the buffer for the code + * and any potential Clear code that might be emitted + * below. The value of limit is setup so that there + * are at least 4 bytes free--room for 2 codes. + */ + if (op > limit) { + tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); + if( !TIFFFlushData1(tif) ) + return 0; + op = tif->tif_rawdata; + } + PutNextCode(op, ent); + ent = (hcode_t)c; + hp->code = (hcode_t)(free_ent++); + hp->hash = fcode; + if (free_ent == CODE_MAX-1) { + /* table is full, emit clear code and reset */ + cl_hash(sp); + sp->enc_ratio = 0; + incount = 0; + outcount = 0; + free_ent = CODE_FIRST; + PutNextCode(op, CODE_CLEAR); + nbits = BITS_MIN; + maxcode = MAXCODE(BITS_MIN); + } else { + /* + * If the next entry is going to be too big for + * the code size, then increase it, if possible. + */ + if (free_ent > maxcode) { + nbits++; + assert(nbits <= BITS_MAX); + maxcode = (int) MAXCODE(nbits); + } else if (incount >= checkpoint) { + tmsize_t rat; + /* + * Check compression ratio and, if things seem + * to be slipping, clear the hash table and + * reset state. The compression ratio is a + * 24+8-bit fractional number. + */ + checkpoint = incount+CHECK_GAP; + CALCRATIO(sp, rat); + if (rat <= sp->enc_ratio) { + cl_hash(sp); + sp->enc_ratio = 0; + incount = 0; + outcount = 0; + free_ent = CODE_FIRST; + PutNextCode(op, CODE_CLEAR); + nbits = BITS_MIN; + maxcode = MAXCODE(BITS_MIN); + } else + sp->enc_ratio = rat; + } + } + hit: + ; + } - /* - * Restore global state. - */ - sp->enc_incount = incount; - sp->enc_outcount = outcount; - sp->enc_checkpoint = checkpoint; - sp->enc_oldcode = ent; - sp->lzw_nextdata = nextdata; - sp->lzw_nextbits = nextbits; - sp->lzw_free_ent = (unsigned short)free_ent; - sp->lzw_maxcode = (unsigned short)maxcode; - sp->lzw_nbits = (unsigned short)nbits; - tif->tif_rawcp = op; - return (1); + /* + * Restore global state. + */ + sp->enc_incount = incount; + sp->enc_outcount = outcount; + sp->enc_checkpoint = checkpoint; + sp->enc_oldcode = ent; + sp->lzw_nextdata = nextdata; + sp->lzw_nextbits = nextbits; + sp->lzw_free_ent = (unsigned short)free_ent; + sp->lzw_maxcode = (unsigned short)maxcode; + sp->lzw_nbits = (unsigned short)nbits; + tif->tif_rawcp = op; + return (1); } /* * Finish off an encoded strip by flushing the last * string and tacking on an End Of Information code. */ -static int LZWPostEncode(TIFF *tif) +static int +LZWPostEncode(TIFF* tif) { - register LZWCodecState *sp = EncoderState(tif); - uint8_t *op = tif->tif_rawcp; - long nextbits = sp->lzw_nextbits; - WordType nextdata = sp->lzw_nextdata; - tmsize_t outcount = sp->enc_outcount; - int nbits = sp->lzw_nbits; + register LZWCodecState *sp = EncoderState(tif); + uint8* op = tif->tif_rawcp; + long nextbits = sp->lzw_nextbits; + unsigned long nextdata = sp->lzw_nextdata; + tmsize_t outcount = sp->enc_outcount; + int nbits = sp->lzw_nbits; - if (op > sp->enc_rawlimit) - { - tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); - if (!TIFFFlushData1(tif)) - return 0; - op = tif->tif_rawdata; - } - if (sp->enc_oldcode != (hcode_t)-1) - { - int free_ent = sp->lzw_free_ent; + if (op > sp->enc_rawlimit) { + tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); + if( !TIFFFlushData1(tif) ) + return 0; + op = tif->tif_rawdata; + } + if (sp->enc_oldcode != (hcode_t) -1) { + int free_ent = sp->lzw_free_ent; - PutNextCode(op, sp->enc_oldcode); - sp->enc_oldcode = (hcode_t)-1; - free_ent++; + PutNextCode(op, sp->enc_oldcode); + sp->enc_oldcode = (hcode_t) -1; + free_ent ++; - if (free_ent == CODE_MAX - 1) - { - /* table is full, emit clear code and reset */ - outcount = 0; - PutNextCode(op, CODE_CLEAR); - nbits = BITS_MIN; - } - else - { - /* - * If the next entry is going to be too big for - * the code size, then increase it, if possible. - */ - if (free_ent > sp->lzw_maxcode) - { - nbits++; - assert(nbits <= BITS_MAX); - } - } - } - PutNextCode(op, CODE_EOI); - /* Explicit 0xff masking to make icc -check=conversions happy */ - if (nextbits > 0) - *op++ = (unsigned char)((nextdata << (8 - nextbits)) & 0xff); - tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); - (void)outcount; - return (1); + if (free_ent == CODE_MAX-1) { + /* table is full, emit clear code and reset */ + outcount = 0; + PutNextCode(op, CODE_CLEAR); + nbits = BITS_MIN; + } else { + /* + * If the next entry is going to be too big for + * the code size, then increase it, if possible. + */ + if (free_ent > sp->lzw_maxcode) { + nbits++; + assert(nbits <= BITS_MAX); + } + } + } + PutNextCode(op, CODE_EOI); + /* Explicit 0xff masking to make icc -check=conversions happy */ + if (nextbits > 0) + *op++ = (unsigned char)((nextdata << (8-nextbits))&0xff); + tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata); + return (1); } /* * Reset encoding hash table. */ -static void cl_hash(LZWCodecState *sp) +static void +cl_hash(LZWCodecState* sp) { - register hash_t *hp = &sp->enc_hashtab[HSIZE - 1]; - register long i = HSIZE - 8; + register hash_t *hp = &sp->enc_hashtab[HSIZE-1]; + register long i = HSIZE-8; - do - { - i -= 8; - hp[-7].hash = -1; - hp[-6].hash = -1; - hp[-5].hash = -1; - hp[-4].hash = -1; - hp[-3].hash = -1; - hp[-2].hash = -1; - hp[-1].hash = -1; - hp[0].hash = -1; - hp -= 8; - } while (i >= 0); - for (i += 8; i > 0; i--, hp--) - hp->hash = -1; + do { + i -= 8; + hp[-7].hash = -1; + hp[-6].hash = -1; + hp[-5].hash = -1; + hp[-4].hash = -1; + hp[-3].hash = -1; + hp[-2].hash = -1; + hp[-1].hash = -1; + hp[ 0].hash = -1; + hp -= 8; + } while (i >= 0); + for (i += 8; i > 0; i--, hp--) + hp->hash = -1; } -static void LZWCleanup(TIFF *tif) +static void +LZWCleanup(TIFF* tif) { - (void)TIFFPredictorCleanup(tif); + (void)TIFFPredictorCleanup(tif); - assert(tif->tif_data != 0); + assert(tif->tif_data != 0); - if (DecoderState(tif)->dec_codetab) - _TIFFfreeExt(tif, DecoderState(tif)->dec_codetab); + if (DecoderState(tif)->dec_codetab) + _TIFFfree(DecoderState(tif)->dec_codetab); - if (EncoderState(tif)->enc_hashtab) - _TIFFfreeExt(tif, EncoderState(tif)->enc_hashtab); + if (EncoderState(tif)->enc_hashtab) + _TIFFfree(EncoderState(tif)->enc_hashtab); - _TIFFfreeExt(tif, tif->tif_data); - tif->tif_data = NULL; + _TIFFfree(tif->tif_data); + tif->tif_data = NULL; - _TIFFSetDefaultCompressionState(tif); + _TIFFSetDefaultCompressionState(tif); } -int TIFFInitLZW(TIFF *tif, int scheme) +int +TIFFInitLZW(TIFF* tif, int scheme) { - static const char module[] = "TIFFInitLZW"; - (void)scheme; - assert(scheme == COMPRESSION_LZW); - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(LZWCodecState)); - if (tif->tif_data == NULL) - goto bad; - DecoderState(tif)->dec_codetab = NULL; - DecoderState(tif)->dec_decode = NULL; - EncoderState(tif)->enc_hashtab = NULL; - LZWState(tif)->rw_mode = tif->tif_mode; + static const char module[] = "TIFFInitLZW"; + (void)scheme; + assert(scheme == COMPRESSION_LZW); + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (LZWCodecState)); + if (tif->tif_data == NULL) + goto bad; + DecoderState(tif)->dec_codetab = NULL; + DecoderState(tif)->dec_decode = NULL; + EncoderState(tif)->enc_hashtab = NULL; + LZWState(tif)->rw_mode = tif->tif_mode; - /* - * Install codec methods. - */ - tif->tif_fixuptags = LZWFixupTags; - tif->tif_setupdecode = LZWSetupDecode; - tif->tif_predecode = LZWPreDecode; - tif->tif_decoderow = LZWDecode; - tif->tif_decodestrip = LZWDecode; - tif->tif_decodetile = LZWDecode; - tif->tif_setupencode = LZWSetupEncode; - tif->tif_preencode = LZWPreEncode; - tif->tif_postencode = LZWPostEncode; - tif->tif_encoderow = LZWEncode; - tif->tif_encodestrip = LZWEncode; - tif->tif_encodetile = LZWEncode; - tif->tif_cleanup = LZWCleanup; - /* - * Setup predictor setup. - */ - (void)TIFFPredictorInit(tif); - return (1); + /* + * Install codec methods. + */ + tif->tif_fixuptags = LZWFixupTags; + tif->tif_setupdecode = LZWSetupDecode; + tif->tif_predecode = LZWPreDecode; + tif->tif_decoderow = LZWDecode; + tif->tif_decodestrip = LZWDecode; + tif->tif_decodetile = LZWDecode; + tif->tif_setupencode = LZWSetupEncode; + tif->tif_preencode = LZWPreEncode; + tif->tif_postencode = LZWPostEncode; + tif->tif_encoderow = LZWEncode; + tif->tif_encodestrip = LZWEncode; + tif->tif_encodetile = LZWEncode; + tif->tif_cleanup = LZWCleanup; + /* + * Setup predictor setup. + */ + (void) TIFFPredictorInit(tif); + return (1); bad: - TIFFErrorExtR(tif, module, "No space for LZW state block"); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, + "No space for LZW state block"); + return (0); } /* @@ -1456,3 +1210,12 @@ bad: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #endif /* LZW_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_next.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_next.c index f000574ee..0ba61aed3 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_next.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_next.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -30,165 +30,158 @@ * NeXT 2-bit Grey Scale Compression Algorithm Support */ -#define SETPIXEL(op, v) \ - { \ - switch (npixels++ & 3) \ - { \ - case 0: \ - op[0] = (unsigned char)((v) << 6); \ - break; \ - case 1: \ - op[0] |= (v) << 4; \ - break; \ - case 2: \ - op[0] |= (v) << 2; \ - break; \ - case 3: \ - *op++ |= (v); \ - op_offset++; \ - break; \ - } \ - } +#define SETPIXEL(op, v) { \ + switch (npixels++ & 3) { \ + case 0: op[0] = (unsigned char) ((v) << 6); break; \ + case 1: op[0] |= (v) << 4; break; \ + case 2: op[0] |= (v) << 2; break; \ + case 3: *op++ |= (v); op_offset++; break; \ + } \ +} -#define LITERALROW 0x00 -#define LITERALSPAN 0x40 -#define WHITE ((1 << 2) - 1) +#define LITERALROW 0x00 +#define LITERALSPAN 0x40 +#define WHITE ((1<<2)-1) -static int NeXTDecode(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) +static int +NeXTDecode(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { - static const char module[] = "NeXTDecode"; - unsigned char *bp, *op; - tmsize_t cc; - uint8_t *row; - tmsize_t scanline, n; + static const char module[] = "NeXTDecode"; + unsigned char *bp, *op; + tmsize_t cc; + uint8* row; + tmsize_t scanline, n; - (void)s; - /* - * Each scanline is assumed to start off as all - * white (we assume a PhotometricInterpretation - * of ``min-is-black''). - */ - for (op = (unsigned char *)buf, cc = occ; cc-- > 0;) - *op++ = 0xff; + (void) s; + /* + * Each scanline is assumed to start off as all + * white (we assume a PhotometricInterpretation + * of ``min-is-black''). + */ + for (op = (unsigned char*) buf, cc = occ; cc-- > 0;) + *op++ = 0xff; - bp = (unsigned char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - scanline = tif->tif_scanlinesize; - if (occ % scanline) - { - TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read"); - return (0); - } - for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) - { - n = *bp++; - cc--; - switch (n) - { - case LITERALROW: - /* - * The entire scanline is given as literal values. - */ - if (cc < scanline) - goto bad; - _TIFFmemcpy(row, bp, scanline); - bp += scanline; - cc -= scanline; - break; - case LITERALSPAN: - { - tmsize_t off; - /* - * The scanline has a literal span that begins at some - * offset. - */ - if (cc < 4) - goto bad; - off = (bp[0] * 256) + bp[1]; - n = (bp[2] * 256) + bp[3]; - if (cc < 4 + n || off + n > scanline) - goto bad; - _TIFFmemcpy(row + off, bp + 4, n); - bp += 4 + n; - cc -= 4 + n; - break; - } - default: - { - uint32_t npixels = 0, grey; - tmsize_t op_offset = 0; - uint32_t imagewidth = tif->tif_dir.td_imagewidth; - if (isTiled(tif)) - imagewidth = tif->tif_dir.td_tilewidth; + bp = (unsigned char *)tif->tif_rawcp; + cc = tif->tif_rawcc; + scanline = tif->tif_scanlinesize; + if (occ % scanline) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (0); + } + for (row = buf; cc > 0 && occ > 0; occ -= scanline, row += scanline) { + n = *bp++; + cc--; + switch (n) { + case LITERALROW: + /* + * The entire scanline is given as literal values. + */ + if (cc < scanline) + goto bad; + _TIFFmemcpy(row, bp, scanline); + bp += scanline; + cc -= scanline; + break; + case LITERALSPAN: { + tmsize_t off; + /* + * The scanline has a literal span that begins at some + * offset. + */ + if( cc < 4 ) + goto bad; + off = (bp[0] * 256) + bp[1]; + n = (bp[2] * 256) + bp[3]; + if (cc < 4+n || off+n > scanline) + goto bad; + _TIFFmemcpy(row+off, bp+4, n); + bp += 4+n; + cc -= 4+n; + break; + } + default: { + uint32 npixels = 0, grey; + tmsize_t op_offset = 0; + uint32 imagewidth = tif->tif_dir.td_imagewidth; + if( isTiled(tif) ) + imagewidth = tif->tif_dir.td_tilewidth; - /* - * The scanline is composed of a sequence of constant - * color ``runs''. We shift into ``run mode'' and - * interpret bytes as codes of the form - * until we've filled the scanline. - */ - op = row; - for (;;) - { - grey = (uint32_t)((n >> 6) & 0x3); - n &= 0x3f; - /* - * Ensure the run does not exceed the scanline - * bounds, potentially resulting in a security - * issue. - */ - while (n-- > 0 && npixels < imagewidth && - op_offset < scanline) - SETPIXEL(op, grey); - if (npixels >= imagewidth) - break; - if (op_offset >= scanline) - { - TIFFErrorExtR(tif, module, - "Invalid data for scanline %" PRIu32, - tif->tif_row); - return (0); - } - if (cc == 0) - goto bad; - n = *bp++; - cc--; + /* + * The scanline is composed of a sequence of constant + * color ``runs''. We shift into ``run mode'' and + * interpret bytes as codes of the form + * until we've filled the scanline. + */ + op = row; + for (;;) { + grey = (uint32)((n>>6) & 0x3); + n &= 0x3f; + /* + * Ensure the run does not exceed the scanline + * bounds, potentially resulting in a security + * issue. + */ + while (n-- > 0 && npixels < imagewidth && op_offset < scanline) + SETPIXEL(op, grey); + if (npixels >= imagewidth) + break; + if (op_offset >= scanline ) { + TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %ld", + (long) tif->tif_row); + return (0); } - break; - } - } - } - tif->tif_rawcp = (uint8_t *)bp; - tif->tif_rawcc = cc; - return (1); + if (cc == 0) + goto bad; + n = *bp++; + cc--; + } + break; + } + } + } + tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcc = cc; + return (1); bad: - TIFFErrorExtR(tif, module, "Not enough data for scanline %" PRIu32, - tif->tif_row); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld", + (long) tif->tif_row); + return (0); } -static int NeXTPreDecode(TIFF *tif, uint16_t s) +static int +NeXTPreDecode(TIFF* tif, uint16 s) { - static const char module[] = "NeXTPreDecode"; - TIFFDirectory *td = &tif->tif_dir; - (void)s; + static const char module[] = "NeXTPreDecode"; + TIFFDirectory *td = &tif->tif_dir; + (void)s; - if (td->td_bitspersample != 2) - { - TIFFErrorExtR(tif, module, "Unsupported BitsPerSample = %" PRIu16, - td->td_bitspersample); - return (0); - } - return (1); + if( td->td_bitspersample != 2 ) + { + TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %d", + td->td_bitspersample); + return (0); + } + return (1); } - -int TIFFInitNeXT(TIFF *tif, int scheme) + +int +TIFFInitNeXT(TIFF* tif, int scheme) { - (void)scheme; - tif->tif_predecode = NeXTPreDecode; - tif->tif_decoderow = NeXTDecode; - tif->tif_decodestrip = NeXTDecode; - tif->tif_decodetile = NeXTDecode; - return (1); + (void) scheme; + tif->tif_predecode = NeXTPreDecode; + tif->tif_decoderow = NeXTDecode; + tif->tif_decodestrip = NeXTDecode; + tif->tif_decodetile = NeXTDecode; + return (1); } #endif /* NEXT_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_ojpeg.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_ojpeg.c index ea572091e..133d1f1c4 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_ojpeg.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_ojpeg.c @@ -43,83 +43,79 @@ /* What is what, and what is not? - This decoder starts with an input stream, that is essentially the - JpegInterchangeFormat stream, if any, followed by the strile data, if any. - This stream is read in OJPEGReadByte and related functions. + This decoder starts with an input stream, that is essentially the JpegInterchangeFormat + stream, if any, followed by the strile data, if any. This stream is read in + OJPEGReadByte and related functions. - It analyzes the start of this stream, until it encounters non-marker data, - i.e. compressed image data. Some of the header markers it sees have no actual - content, like the SOI marker, and APP/COM markers that really shouldn't even - be there. Some other markers do have content, and the valuable bits and - pieces of information in these markers are saved, checking all to verify that - the stream is more or less within expected bounds. This happens inside the - OJPEGReadHeaderInfoSecStreamXxx functions. - - Some OJPEG imagery contains no valid JPEG header markers. This situation is - picked up on if we've seen no SOF marker when we're at the start of the - compressed image data. In this case, the tables are read from JpegXxxTables - tags, and the other bits and pieces of information is initialized to its most - basic value. This is implemented in the OJPEGReadHeaderInfoSecTablesXxx + It analyzes the start of this stream, until it encounters non-marker data, i.e. + compressed image data. Some of the header markers it sees have no actual content, + like the SOI marker, and APP/COM markers that really shouldn't even be there. Some + other markers do have content, and the valuable bits and pieces of information + in these markers are saved, checking all to verify that the stream is more or + less within expected bounds. This happens inside the OJPEGReadHeaderInfoSecStreamXxx functions. - When this is complete, a good and valid JPEG header can be assembled, and - this is passed through to LibJpeg. When that's done, the remainder of the - input stream, i.e. the compressed image data, can be passed through - unchanged. This is done in OJPEGWriteStream functions. + Some OJPEG imagery contains no valid JPEG header markers. This situation is picked + up on if we've seen no SOF marker when we're at the start of the compressed image + data. In this case, the tables are read from JpegXxxTables tags, and the other + bits and pieces of information is initialized to its most basic value. This is + implemented in the OJPEGReadHeaderInfoSecTablesXxx functions. - LibTiff rightly expects to know the subsampling values before decompression. - Just like in new-style JPEG-in-TIFF, though, or even more so, actually, the - YCbCrsubsampling tag is notoriously unreliable. To correct these tag values - with the ones inside the JPEG stream, the first part of the input stream is - pre-scanned in OJPEGSubsamplingCorrect, making no note of any other data, - reporting no warnings or errors, up to the point where either these values - are read, or it's clear they aren't there. This means that some of the data - is read twice, but we feel speed in correcting these values is important - enough to warrant this sacrifice. Although there is currently no define or - other configuration mechanism to disable this behavior, the actual header - scanning is build to robustly respond with error report if it should - encounter an uncorrected mismatch of subsampling values. See + When this is complete, a good and valid JPEG header can be assembled, and this is + passed through to LibJpeg. When that's done, the remainder of the input stream, i.e. + the compressed image data, can be passed through unchanged. This is done in + OJPEGWriteStream functions. + + LibTiff rightly expects to know the subsampling values before decompression. Just like + in new-style JPEG-in-TIFF, though, or even more so, actually, the YCbCrsubsampling + tag is notoriously unreliable. To correct these tag values with the ones inside + the JPEG stream, the first part of the input stream is pre-scanned in + OJPEGSubsamplingCorrect, making no note of any other data, reporting no warnings + or errors, up to the point where either these values are read, or it's clear they + aren't there. This means that some of the data is read twice, but we feel speed + in correcting these values is important enough to warrant this sacrifice. Although + there is currently no define or other configuration mechanism to disable this behavior, + the actual header scanning is build to robustly respond with error report if it + should encounter an uncorrected mismatch of subsampling values. See OJPEGReadHeaderInfoSecStreamSof. - The restart interval and restart markers are the most tricky part... The - restart interval can be specified in a tag. It can also be set inside the - input JPEG stream. It can be used inside the input JPEG stream. If reading - from strile data, we've consistently discovered the need to insert restart - markers in between the different striles, as is also probably the most likely - interpretation of the original TIFF 6.0 specification. With all this setting - of interval, and actual use of markers that is not predictable at the time of - valid JPEG header assembly, the restart thing may turn out the Achilles heel - of this implementation. Fortunately, most OJPEG writer vendors succeed in - reading back what they write, which may be the reason why we've been able to - discover ways that seem to work. + The restart interval and restart markers are the most tricky part... The restart + interval can be specified in a tag. It can also be set inside the input JPEG stream. + It can be used inside the input JPEG stream. If reading from strile data, we've + consistently discovered the need to insert restart markers in between the different + striles, as is also probably the most likely interpretation of the original TIFF 6.0 + specification. With all this setting of interval, and actual use of markers that is not + predictable at the time of valid JPEG header assembly, the restart thing may turn + out the Achilles heel of this implementation. Fortunately, most OJPEG writer vendors + succeed in reading back what they write, which may be the reason why we've been able + to discover ways that seem to work. - Some special provision is made for planarconfig separate OJPEG files. These - seem to consistently contain header info, a SOS marker, a plane, SOS marker, - plane, SOS, and plane. This may or may not be a valid JPEG configuration, we - don't know and don't care. We want LibTiff to be able to access the planes - individually, without huge buffering inside LibJpeg, anyway. So we compose - headers to feed to LibJpeg, in this case, that allow us to pass a single - plane such that LibJpeg sees a valid single-channel JPEG stream. Locating - subsequent SOS markers, and thus subsequent planes, is done inside - OJPEGReadSecondarySos. + Some special provision is made for planarconfig separate OJPEG files. These seem + to consistently contain header info, a SOS marker, a plane, SOS marker, plane, SOS, + and plane. This may or may not be a valid JPEG configuration, we don't know and don't + care. We want LibTiff to be able to access the planes individually, without huge + buffering inside LibJpeg, anyway. So we compose headers to feed to LibJpeg, in this + case, that allow us to pass a single plane such that LibJpeg sees a valid + single-channel JPEG stream. Locating subsequent SOS markers, and thus subsequent + planes, is done inside OJPEGReadSecondarySos. - The benefit of the scheme is... that it works, basically. We know of no other - that does. It works without checking software tag, or otherwise going about - things in an OJPEG flavor specific manner. Instead, it is a single scheme, - that covers the cases with and without JpegInterchangeFormat, with and - without striles, with part of the header in JpegInterchangeFormat and - remainder in first strile, etc. It is forgiving and robust, may likely work - with OJPEG flavors we've not seen yet, and makes most out of the data. + The benefit of the scheme is... that it works, basically. We know of no other that + does. It works without checking software tag, or otherwise going about things in an + OJPEG flavor specific manner. Instead, it is a single scheme, that covers the cases + with and without JpegInterchangeFormat, with and without striles, with part of + the header in JpegInterchangeFormat and remainder in first strile, etc. It is forgiving + and robust, may likely work with OJPEG flavors we've not seen yet, and makes most out + of the data. - Another nice side-effect is that a complete JPEG single valid stream is build - if planarconfig is not separate (vast majority). We may one day use that to - build converters to JPEG, and/or to new-style JPEG compression inside TIFF. + Another nice side-effect is that a complete JPEG single valid stream is build if + planarconfig is not separate (vast majority). We may one day use that to build + converters to JPEG, and/or to new-style JPEG compression inside TIFF. - A disadvantage is the lack of random access to the individual striles. This - is the reason for much of the complicated restart-and-position stuff inside - OJPEGPreDecode. Applications would do well accessing all striles in order, as - this will result in a single sequential scan of the input stream, and no - restarting of LibJpeg decoding session. + A disadvantage is the lack of random access to the individual striles. This is the + reason for much of the complicated restart-and-position stuff inside OJPEGPreDecode. + Applications would do well accessing all striles in order, as this will result in + a single sequential scan of the input stream, and no restarting of LibJpeg decoding + session. */ #define WIN32_LEAN_AND_MEAN @@ -129,31 +125,30 @@ #ifdef OJPEG_SUPPORT /* Configuration defines here are: - * JPEG_ENCAP_EXTERNAL: The normal way to call libjpeg, uses longjump. In some - * environments, like eg LibTiffDelphi, this is not possible. For this reason, - * the actual calls to libjpeg, with longjump stuff, are encapsulated in - * dedicated functions. When JPEG_ENCAP_EXTERNAL is defined, these encapsulating - * functions are declared external to this unit, and can be defined elsewhere to - * use stuff other then longjump. The default mode, without JPEG_ENCAP_EXTERNAL, - * implements the call encapsulators here, internally, with normal longjump. - * SETJMP, LONGJMP, JMP_BUF: On some machines/environments a longjump equivalent - * is conveniently available, but still it may be worthwhile to use _setjmp or - * sigsetjmp in place of plain setjmp. These macros will make it easier. It is - * useless to fiddle with these if you define JPEG_ENCAP_EXTERNAL. OJPEG_BUFFER: - * Define the size of the desired buffer here. Should be small enough so as to - * guarantee instant processing, optimal streaming and optimal use of processor - * cache, but also big enough so as to not result in significant call overhead. - * It should be at least a few bytes to 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_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. + * JPEG_ENCAP_EXTERNAL: The normal way to call libjpeg, uses longjump. In some environments, + * like eg LibTiffDelphi, this is not possible. For this reason, the actual calls to + * libjpeg, with longjump stuff, are encapsulated in dedicated functions. When + * JPEG_ENCAP_EXTERNAL is defined, these encapsulating functions are declared external + * to this unit, and can be defined elsewhere to use stuff other then longjump. + * The default mode, without JPEG_ENCAP_EXTERNAL, implements the call encapsulators + * here, internally, with normal longjump. + * SETJMP, LONGJMP, JMP_BUF: On some machines/environments a longjump equivalent is + * conveniently available, but still it may be worthwhile to use _setjmp or sigsetjmp + * in place of plain setjmp. These macros will make it easier. It is useless + * to fiddle with these if you define JPEG_ENCAP_EXTERNAL. + * OJPEG_BUFFER: Define the size of the desired buffer here. Should be small enough so as to guarantee + * instant processing, optimal streaming and optimal use of processor cache, but also big + * enough so as to not result in significant call overhead. It should be at least a few + * bytes to accommodate some structures (this is verified in asserts), but it would not be + * sensible to make it this small anyway, and it should be at most 64K since it is indexed + * with uint16. We recommend 2K. + * EGYPTIANWALK: You could also define EGYPTIANWALK here, but it is not used anywhere and has + * absolutely no effect. That is why most people insist the EGYPTIANWALK is a bit silly. */ /* define LIBJPEG_ENCAP_EXTERNAL */ #define SETJMP(jbuf) setjmp(jbuf) -#define LONGJMP(jbuf, code) longjmp(jbuf, code) +#define LONGJMP(jbuf,code) longjmp(jbuf,code) #define JMP_BUF jmp_buf #define OJPEG_BUFFER 2048 /* define EGYPTIANWALK */ @@ -171,36 +166,22 @@ #define JPEG_MARKER_APP0 0xE0 #define JPEG_MARKER_COM 0xFE -#define FIELD_OJPEG_JPEGINTERCHANGEFORMAT (FIELD_CODEC + 0) -#define FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH (FIELD_CODEC + 1) -#define FIELD_OJPEG_JPEGQTABLES (FIELD_CODEC + 2) -#define FIELD_OJPEG_JPEGDCTABLES (FIELD_CODEC + 3) -#define FIELD_OJPEG_JPEGACTABLES (FIELD_CODEC + 4) -#define FIELD_OJPEG_JPEGPROC (FIELD_CODEC + 5) -#define FIELD_OJPEG_JPEGRESTARTINTERVAL (FIELD_CODEC + 6) +#define FIELD_OJPEG_JPEGINTERCHANGEFORMAT (FIELD_CODEC+0) +#define FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH (FIELD_CODEC+1) +#define FIELD_OJPEG_JPEGQTABLES (FIELD_CODEC+2) +#define FIELD_OJPEG_JPEGDCTABLES (FIELD_CODEC+3) +#define FIELD_OJPEG_JPEGACTABLES (FIELD_CODEC+4) +#define FIELD_OJPEG_JPEGPROC (FIELD_CODEC+5) +#define FIELD_OJPEG_JPEGRESTARTINTERVAL (FIELD_CODEC+6) static const TIFFField ojpegFields[] = { - {TIFFTAG_JPEGIFOFFSET, 1, 1, TIFF_LONG8, 0, TIFF_SETGET_UINT64, - TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGINTERCHANGEFORMAT, TRUE, FALSE, - "JpegInterchangeFormat", NULL}, - {TIFFTAG_JPEGIFBYTECOUNT, 1, 1, TIFF_LONG8, 0, TIFF_SETGET_UINT64, - TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH, TRUE, - FALSE, "JpegInterchangeFormatLength", NULL}, - {TIFFTAG_JPEGQTABLES, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_LONG8, 0, - TIFF_SETGET_C32_UINT64, TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGQTABLES, - FALSE, TRUE, "JpegQTables", NULL}, - {TIFFTAG_JPEGDCTABLES, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_LONG8, 0, - TIFF_SETGET_C32_UINT64, TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGDCTABLES, - FALSE, TRUE, "JpegDcTables", NULL}, - {TIFFTAG_JPEGACTABLES, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_LONG8, 0, - TIFF_SETGET_C32_UINT64, TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGACTABLES, - FALSE, TRUE, "JpegAcTables", NULL}, - {TIFFTAG_JPEGPROC, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, - TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGPROC, FALSE, FALSE, "JpegProc", - NULL}, - {TIFFTAG_JPEGRESTARTINTERVAL, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, - TIFF_SETGET_UNDEFINED, FIELD_OJPEG_JPEGRESTARTINTERVAL, FALSE, FALSE, - "JpegRestartInterval", NULL}, + {TIFFTAG_JPEGIFOFFSET,1,1,TIFF_LONG8,0,TIFF_SETGET_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGINTERCHANGEFORMAT,TRUE,FALSE,"JpegInterchangeFormat",NULL}, + {TIFFTAG_JPEGIFBYTECOUNT,1,1,TIFF_LONG8,0,TIFF_SETGET_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH,TRUE,FALSE,"JpegInterchangeFormatLength",NULL}, + {TIFFTAG_JPEGQTABLES,TIFF_VARIABLE2,TIFF_VARIABLE2,TIFF_LONG8,0,TIFF_SETGET_C32_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGQTABLES,FALSE,TRUE,"JpegQTables",NULL}, + {TIFFTAG_JPEGDCTABLES,TIFF_VARIABLE2,TIFF_VARIABLE2,TIFF_LONG8,0,TIFF_SETGET_C32_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGDCTABLES,FALSE,TRUE,"JpegDcTables",NULL}, + {TIFFTAG_JPEGACTABLES,TIFF_VARIABLE2,TIFF_VARIABLE2,TIFF_LONG8,0,TIFF_SETGET_C32_UINT64,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGACTABLES,FALSE,TRUE,"JpegAcTables",NULL}, + {TIFFTAG_JPEGPROC,1,1,TIFF_SHORT,0,TIFF_SETGET_UINT16,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGPROC,FALSE,FALSE,"JpegProc",NULL}, + {TIFFTAG_JPEGRESTARTINTERVAL,1,1,TIFF_SHORT,0,TIFF_SETGET_UINT16,TIFF_SETGET_UNDEFINED,FIELD_OJPEG_JPEGRESTARTINTERVAL,FALSE,FALSE,"JpegRestartInterval",NULL}, }; #ifndef LIBJPEG_ENCAP_EXTERNAL @@ -220,2596 +201,2405 @@ static const TIFFField ojpegFields[] = { a conflicting typedef given the headers which are included. */ #if defined(__BORLANDC__) || defined(__MINGW32__) -#define XMD_H 1 +# define XMD_H 1 #endif /* Define "boolean" as unsigned char, not int, per Windows custom. */ #if defined(__WIN32__) && !defined(__MINGW32__) -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +# ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ + typedef unsigned char boolean; +# endif +# define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ #endif -#include "jerror.h" #include "jpeglib.h" +#include "jerror.h" typedef struct jpeg_error_mgr jpeg_error_mgr; typedef struct jpeg_common_struct jpeg_common_struct; typedef struct jpeg_decompress_struct jpeg_decompress_struct; typedef struct jpeg_source_mgr jpeg_source_mgr; -typedef enum -{ - osibsNotSetYet, - osibsJpegInterchangeFormat, - osibsStrile, - osibsEof +typedef enum { + osibsNotSetYet, + osibsJpegInterchangeFormat, + osibsStrile, + osibsEof } OJPEGStateInBufferSource; -typedef enum -{ - ososSoi, - ososQTable0, - ososQTable1, - ososQTable2, - ososQTable3, - ososDcTable0, - ososDcTable1, - ososDcTable2, - ososDcTable3, - ososAcTable0, - ososAcTable1, - ososAcTable2, - ososAcTable3, - ososDri, - ososSof, - ososSos, - ososCompressed, - ososRst, - ososEoi +typedef enum { + ososSoi, + ososQTable0,ososQTable1,ososQTable2,ososQTable3, + ososDcTable0,ososDcTable1,ososDcTable2,ososDcTable3, + ososAcTable0,ososAcTable1,ososAcTable2,ososAcTable3, + ososDri, + ososSof, + ososSos, + ososCompressed, + ososRst, + ososEoi } OJPEGStateOutState; -typedef struct -{ - TIFF *tif; - int decoder_ok; - int error_in_raw_data_decoding; -#ifndef LIBJPEG_ENCAP_EXTERNAL - JMP_BUF exit_jmpbuf; -#endif - TIFFVGetMethod vgetparent; - TIFFVSetMethod vsetparent; - TIFFPrintMethod printdir; - 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_t log; - OJPEGStateInBufferSource in_buffer_source; - uint32_t in_buffer_next_strile; - uint64_t in_buffer_file_pos; - uint64_t in_buffer_file_togo; - } sos_end[3]; - 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_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_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_t out_buffer[OJPEG_BUFFER]; - uint8_t *skip_buffer; +typedef struct { + TIFF* tif; + int decoder_ok; + int error_in_raw_data_decoding; + #ifndef LIBJPEG_ENCAP_EXTERNAL + JMP_BUF exit_jmpbuf; + #endif + 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]; + struct { + uint8 log; + OJPEGStateInBufferSource in_buffer_source; + uint32 in_buffer_next_strile; + uint64 in_buffer_file_pos; + uint64 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; + 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 */ + 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]; + OJPEGStateOutState out_state; + uint8 out_buffer[OJPEG_BUFFER]; + uint8* skip_buffer; } OJPEGState; -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 OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap); +static int OJPEGVSetField(TIFF* tif, uint32 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_t s); -static int OJPEGPreDecodeSkipRaw(TIFF *tif); -static int OJPEGPreDecodeSkipScanlines(TIFF *tif); -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_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 int OJPEGFixupTags(TIFF* tif); +static int OJPEGSetupDecode(TIFF* tif); +static int OJPEGPreDecode(TIFF* tif, uint16 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 OJPEGSetupEncode(TIFF* tif); +static int OJPEGPreEncode(TIFF* tif, uint16 s); +static int OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 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_t s); -static int OJPEGWriteHeaderInfo(TIFF *tif); -static void OJPEGLibjpegSessionAbort(TIFF *tif); +static void OJPEGSubsamplingCorrect(TIFF* tif); +static int OJPEGReadHeaderInfo(TIFF* tif); +static int OJPEGReadSecondarySos(TIFF* tif, uint16 s); +static int OJPEGWriteHeaderInfo(TIFF* tif); +static void OJPEGLibjpegSessionAbort(TIFF* tif); -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_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 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 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_t *byte); -static int OJPEGReadBytePeek(OJPEGState *sp, uint8_t *byte); -static void OJPEGReadByteAdvance(OJPEGState *sp); -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 OJPEGReadBufferFill(OJPEGState* sp); +static int OJPEGReadByte(OJPEGState* sp, uint8* byte); +static int OJPEGReadBytePeek(OJPEGState* sp, uint8* 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_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); +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); #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_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_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); +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_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 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_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_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); +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_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 void jpeg_encap_unwind(TIFF* tif); #endif -static void OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct *cinfo); -static void OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct *cinfo); -static void OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct *cinfo); -static boolean -OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct *cinfo); +static void OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct* cinfo); +static void OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct* cinfo); +static void OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct* cinfo); +static boolean OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo); +static void OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct* cinfo, long num_bytes); +static boolean OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desired); +static void OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo); + +int +TIFFInitOJPEG(TIFF* tif, int scheme) +{ + static const char module[]="TIFFInitOJPEG"; + OJPEGState* sp; + + (void)scheme; + assert(scheme==COMPRESSION_OJPEG); + + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, ojpegFields, TIFFArrayCount(ojpegFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging Old JPEG codec-specific tags failed"); + return 0; + } + + /* state block */ + sp=_TIFFmalloc(sizeof(OJPEGState)); + if (sp==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"No space for OJPEG state block"); + return(0); + } + _TIFFmemset(sp,0,sizeof(OJPEGState)); + sp->tif=tif; + sp->jpeg_proc=1; + sp->subsampling_hor=2; + sp->subsampling_ver=2; + TIFFSetField(tif,TIFFTAG_YCBCRSUBSAMPLING,2,2); + /* tif codec methods */ + tif->tif_fixuptags=OJPEGFixupTags; + tif->tif_setupdecode=OJPEGSetupDecode; + tif->tif_predecode=OJPEGPreDecode; + tif->tif_postdecode=OJPEGPostDecode; + tif->tif_decoderow=OJPEGDecode; + tif->tif_decodestrip=OJPEGDecode; + tif->tif_decodetile=OJPEGDecode; + tif->tif_setupencode=OJPEGSetupEncode; + tif->tif_preencode=OJPEGPreEncode; + tif->tif_postencode=OJPEGPostEncode; + tif->tif_encoderow=OJPEGEncode; + tif->tif_encodestrip=OJPEGEncode; + tif->tif_encodetile=OJPEGEncode; + tif->tif_cleanup=OJPEGCleanup; + tif->tif_data=(uint8*)sp; + /* tif tag methods */ + sp->vgetparent=tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield=OJPEGVGetField; + sp->vsetparent=tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield=OJPEGVSetField; + sp->printdir=tif->tif_tagmethods.printdir; + tif->tif_tagmethods.printdir=OJPEGPrintDir; + /* Some OJPEG files don't have strip or tile offsets or bytecounts tags. + Some others do, but have totally meaningless or corrupt values + in these tags. In these cases, the JpegInterchangeFormat stream is + reliable. In any case, this decoder reads the compressed data itself, + from the most reliable locations, and we need to notify encapsulating + LibTiff not to read raw strips or tiles for us. */ + tif->tif_flags|=TIFF_NOREADRAW; + return(1); +} + +static int +OJPEGVGetField(TIFF* tif, uint32 tag, va_list ap) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + switch(tag) + { + case TIFFTAG_JPEGIFOFFSET: + *va_arg(ap,uint64*)=(uint64)sp->jpeg_interchange_format; + break; + case TIFFTAG_JPEGIFBYTECOUNT: + *va_arg(ap,uint64*)=(uint64)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; + break; + case TIFFTAG_JPEGQTABLES: + *va_arg(ap,uint32*)=(uint32)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,const void**)=(const void*)sp->dctable_offset; + break; + case TIFFTAG_JPEGACTABLES: + *va_arg(ap,uint32*)=(uint32)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; + break; + case TIFFTAG_JPEGRESTARTINTERVAL: + *va_arg(ap,uint16*)=sp->restart_interval; + break; + default: + return (*sp->vgetparent)(tif,tag,ap); + } + return (1); +} + +static int +OJPEGVSetField(TIFF* tif, uint32 tag, va_list ap) +{ + static const char module[]="OJPEGVSetField"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint32 ma; + uint64* mb; + uint32 n; + const TIFFField* fip; + + switch(tag) + { + case TIFFTAG_JPEGIFOFFSET: + sp->jpeg_interchange_format=(uint64)va_arg(ap,uint64); + break; + case TIFFTAG_JPEGIFBYTECOUNT: + sp->jpeg_interchange_format_length=(uint64)va_arg(ap,uint64); + 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); + 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); + if (ma!=0) + { + if (ma>3) + { + TIFFErrorExt(tif->tif_clientdata,module,"JpegQTables tag has incorrect count"); + return(0); + } + sp->qtable_offset_count=(uint8)ma; + mb=(uint64*)va_arg(ap,uint64*); + for (n=0; nqtable_offset[n]=mb[n]; + } + break; + case TIFFTAG_JPEGDCTABLES: + ma=(uint32)va_arg(ap,uint32); + if (ma!=0) + { + if (ma>3) + { + TIFFErrorExt(tif->tif_clientdata,module,"JpegDcTables tag has incorrect count"); + return(0); + } + sp->dctable_offset_count=(uint8)ma; + mb=(uint64*)va_arg(ap,uint64*); + for (n=0; ndctable_offset[n]=mb[n]; + } + break; + case TIFFTAG_JPEGACTABLES: + ma=(uint32)va_arg(ap,uint32); + if (ma!=0) + { + if (ma>3) + { + TIFFErrorExt(tif->tif_clientdata,module,"JpegAcTables tag has incorrect count"); + return(0); + } + sp->actable_offset_count=(uint8)ma; + mb=(uint64*)va_arg(ap,uint64*); + for (n=0; nactable_offset[n]=mb[n]; + } + break; + case TIFFTAG_JPEGPROC: + sp->jpeg_proc=(uint8)va_arg(ap,uint16_vap); + break; + case TIFFTAG_JPEGRESTARTINTERVAL: + sp->restart_interval=(uint16)va_arg(ap,uint16_vap); + break; + default: + return (*sp->vsetparent)(tif,tag,ap); + } + fip = TIFFFieldWithTag(tif,tag); + if( fip == NULL ) /* shouldn't happen */ + return(0); + TIFFSetFieldBit(tif,fip->field_bit); + tif->tif_flags|=TIFF_DIRTYDIRECT; + return(1); +} + static void -OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct *cinfo, - long num_bytes); -static boolean -OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct *cinfo, - int desired); -static void OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct *cinfo); - -int TIFFInitOJPEG(TIFF *tif, int scheme) +OJPEGPrintDir(TIFF* tif, FILE* fd, long flags) { - static const char module[] = "TIFFInitOJPEG"; - OJPEGState *sp; - - (void)scheme; - assert(scheme == COMPRESSION_OJPEG); - - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, ojpegFields, TIFFArrayCount(ojpegFields))) - { - TIFFErrorExtR(tif, module, - "Merging Old JPEG codec-specific tags failed"); - return 0; - } - - /* state block */ - sp = _TIFFmallocExt(tif, sizeof(OJPEGState)); - if (sp == NULL) - { - TIFFErrorExtR(tif, module, "No space for OJPEG state block"); - return (0); - } - _TIFFmemset(sp, 0, sizeof(OJPEGState)); - sp->tif = tif; - sp->jpeg_proc = 1; - sp->subsampling_hor = 2; - sp->subsampling_ver = 2; - TIFFSetField(tif, TIFFTAG_YCBCRSUBSAMPLING, 2, 2); - /* tif codec methods */ - tif->tif_fixuptags = OJPEGFixupTags; - tif->tif_setupdecode = OJPEGSetupDecode; - tif->tif_predecode = OJPEGPreDecode; - tif->tif_postdecode = OJPEGPostDecode; - tif->tif_decoderow = OJPEGDecode; - tif->tif_decodestrip = OJPEGDecode; - tif->tif_decodetile = OJPEGDecode; - tif->tif_setupencode = OJPEGSetupEncode; - tif->tif_preencode = OJPEGPreEncode; - tif->tif_postencode = OJPEGPostEncode; - tif->tif_encoderow = OJPEGEncode; - tif->tif_encodestrip = OJPEGEncode; - tif->tif_encodetile = OJPEGEncode; - tif->tif_cleanup = OJPEGCleanup; - tif->tif_data = (uint8_t *)sp; - /* tif tag methods */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = OJPEGVGetField; - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = OJPEGVSetField; - sp->printdir = tif->tif_tagmethods.printdir; - tif->tif_tagmethods.printdir = OJPEGPrintDir; - /* Some OJPEG files don't have strip or tile offsets or bytecounts tags. - Some others do, but have totally meaningless or corrupt values - in these tags. In these cases, the JpegInterchangeFormat stream is - reliable. In any case, this decoder reads the compressed data itself, - from the most reliable locations, and we need to notify encapsulating - LibTiff not to read raw strips or tiles for us. */ - tif->tif_flags |= TIFF_NOREADRAW; - return (1); + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 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); + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH)) + fprintf(fd," JpegInterchangeFormatLength: " TIFF_UINT64_FORMAT "\n",(TIFF_UINT64_T)sp->jpeg_interchange_format_length); + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGQTABLES)) + { + fprintf(fd," JpegQTables:"); + for (m=0; mqtable_offset_count; m++) + fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->qtable_offset[m]); + fprintf(fd,"\n"); + } + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGDCTABLES)) + { + fprintf(fd," JpegDcTables:"); + for (m=0; mdctable_offset_count; m++) + fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_UINT64_T)sp->dctable_offset[m]); + fprintf(fd,"\n"); + } + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGACTABLES)) + { + fprintf(fd," JpegAcTables:"); + for (m=0; mactable_offset_count; m++) + fprintf(fd," " TIFF_UINT64_FORMAT,(TIFF_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); + if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGRESTARTINTERVAL)) + fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval); + if (sp->printdir) + (*sp->printdir)(tif, fd, flags); } -static int OJPEGVGetField(TIFF *tif, uint32_t tag, va_list ap) +static int +OJPEGFixupTags(TIFF* tif) { - OJPEGState *sp = (OJPEGState *)tif->tif_data; - switch (tag) - { - case TIFFTAG_JPEGIFOFFSET: - *va_arg(ap, uint64_t *) = (uint64_t)sp->jpeg_interchange_format; - break; - case TIFFTAG_JPEGIFBYTECOUNT: - *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_t *) = (uint16_t)sp->subsampling_hor; - *va_arg(ap, uint16_t *) = (uint16_t)sp->subsampling_ver; - break; - case TIFFTAG_JPEGQTABLES: - *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_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_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_t *) = (uint16_t)sp->jpeg_proc; - break; - case TIFFTAG_JPEGRESTARTINTERVAL: - *va_arg(ap, uint16_t *) = sp->restart_interval; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); + (void) tif; + return(1); } -static int OJPEGVSetField(TIFF *tif, uint32_t tag, va_list ap) +static int +OJPEGSetupDecode(TIFF* tif) { - static const char module[] = "OJPEGVSetField"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint32_t ma; - uint64_t *mb; - uint32_t n; - const TIFFField *fip; - - switch (tag) - { - case TIFFTAG_JPEGIFOFFSET: - sp->jpeg_interchange_format = (uint64_t)va_arg(ap, uint64_t); - break; - case TIFFTAG_JPEGIFBYTECOUNT: - sp->jpeg_interchange_format_length = (uint64_t)va_arg(ap, uint64_t); - break; - case TIFFTAG_YCBCRSUBSAMPLING: - sp->subsampling_tag = 1; - 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_t)va_arg(ap, uint32_t); - if (ma != 0) - { - if (ma > 3) - { - TIFFErrorExtR(tif, module, - "JpegQTables tag has incorrect count"); - return (0); - } - 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_t)va_arg(ap, uint32_t); - if (ma != 0) - { - if (ma > 3) - { - TIFFErrorExtR(tif, module, - "JpegDcTables tag has incorrect count"); - return (0); - } - 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_t)va_arg(ap, uint32_t); - if (ma != 0) - { - if (ma > 3) - { - TIFFErrorExtR(tif, module, - "JpegAcTables tag has incorrect count"); - return (0); - } - 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_t)va_arg(ap, uint16_vap); - break; - case TIFFTAG_JPEGRESTARTINTERVAL: - sp->restart_interval = (uint16_t)va_arg(ap, uint16_vap); - break; - default: - return (*sp->vsetparent)(tif, tag, ap); - } - fip = TIFFFieldWithTag(tif, tag); - if (fip == NULL) /* shouldn't happen */ - return (0); - TIFFSetFieldBit(tif, fip->field_bit); - tif->tif_flags |= TIFF_DIRTYDIRECT; - return (1); + static const char module[]="OJPEGSetupDecode"; + TIFFWarningExt(tif->tif_clientdata,module,"Deprecated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software"); + return(1); } -static void OJPEGPrintDir(TIFF *tif, FILE *fd, long flags) +static int +OJPEGPreDecode(TIFF* tif, uint16 s) { - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint8_t m; - (void)flags; - assert(sp != NULL); - if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGINTERCHANGEFORMAT)) - fprintf(fd, " JpegInterchangeFormat: %" PRIu64 "\n", - (uint64_t)sp->jpeg_interchange_format); - if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGINTERCHANGEFORMATLENGTH)) - 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, " %" 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, " %" 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, " %" PRIu64, (uint64_t)sp->actable_offset[m]); - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGPROC)) - fprintf(fd, " JpegProc: %" PRIu8 "\n", sp->jpeg_proc); - if (TIFFFieldSet(tif, FIELD_OJPEG_JPEGRESTARTINTERVAL)) - fprintf(fd, " JpegRestartInterval: %" PRIu16 "\n", - sp->restart_interval); - if (sp->printdir) - (*sp->printdir)(tif, fd, flags); + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint32 m; + if (sp->subsamplingcorrect_done==0) + OJPEGSubsamplingCorrect(tif); + if (sp->readheader_done==0) + { + if (OJPEGReadHeaderInfo(tif)==0) + return(0); + } + if (sp->sos_end[s].log==0) + { + if (OJPEGReadSecondarySos(tif,s)==0) + return(0); + } + if (isTiled(tif)) + m=tif->tif_curtile; + else + m=tif->tif_curstrip; + if ((sp->writeheader_done!=0) && ((sp->write_cursample!=s) || (sp->write_curstrile>m))) + { + if (sp->libjpeg_session_active!=0) + OJPEGLibjpegSessionAbort(tif); + sp->writeheader_done=0; + } + if (sp->writeheader_done==0) + { + sp->plane_sample_offset=(uint8)s; + sp->write_cursample=s; + sp->write_curstrile=s*tif->tif_dir.td_stripsperimage; + if ((sp->in_buffer_file_pos_log==0) || + (sp->in_buffer_file_pos-sp->in_buffer_togo!=sp->sos_end[s].in_buffer_file_pos)) + { + sp->in_buffer_source=sp->sos_end[s].in_buffer_source; + sp->in_buffer_next_strile=sp->sos_end[s].in_buffer_next_strile; + sp->in_buffer_file_pos=sp->sos_end[s].in_buffer_file_pos; + sp->in_buffer_file_pos_log=0; + sp->in_buffer_file_togo=sp->sos_end[s].in_buffer_file_togo; + sp->in_buffer_togo=0; + sp->in_buffer_cur=0; + } + if (OJPEGWriteHeaderInfo(tif)==0) + return(0); + } + while (sp->write_curstrilelibjpeg_jpeg_query_style==0) + { + if (OJPEGPreDecodeSkipRaw(tif)==0) + return(0); + } + else + { + if (OJPEGPreDecodeSkipScanlines(tif)==0) + return(0); + } + sp->write_curstrile++; + } + sp->decoder_ok = 1; + return(1); } -static int OJPEGFixupTags(TIFF *tif) +static int +OJPEGPreDecodeSkipRaw(TIFF* tif) { - (void)tif; - return (1); + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint32 m; + m=sp->lines_per_strile; + if (sp->subsampling_convert_state!=0) + { + if (sp->subsampling_convert_clines-sp->subsampling_convert_state>=m) + { + sp->subsampling_convert_state+=m; + if (sp->subsampling_convert_state==sp->subsampling_convert_clines) + sp->subsampling_convert_state=0; + return(1); + } + m-=sp->subsampling_convert_clines-sp->subsampling_convert_state; + sp->subsampling_convert_state=0; + sp->error_in_raw_data_decoding=0; + } + while (m>=sp->subsampling_convert_clines) + { + if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0) + return(0); + m-=sp->subsampling_convert_clines; + } + if (m>0) + { + if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0) + return(0); + sp->subsampling_convert_state=m; + } + return(1); } -static int OJPEGSetupDecode(TIFF *tif) +static int +OJPEGPreDecodeSkipScanlines(TIFF* tif) { - static const char module[] = "OJPEGSetupDecode"; - TIFFWarningExtR(tif, module, - "Deprecated and troublesome old-style JPEG compression " - "mode, please convert to new-style JPEG compression and " - "notify vendor of writing software"); - return (1); + static const char module[]="OJPEGPreDecodeSkipScanlines"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint32 m; + if (sp->skip_buffer==NULL) + { + sp->skip_buffer=_TIFFmalloc(sp->bytes_per_line); + if (sp->skip_buffer==NULL) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + } + for (m=0; mlines_per_strile; m++) + { + if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&sp->skip_buffer,1)==0) + return(0); + } + return(1); } -static int OJPEGPreDecode(TIFF *tif, uint16_t s) +static int +OJPEGDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint32_t m; - if (sp->subsamplingcorrect_done == 0) - OJPEGSubsamplingCorrect(tif); - if (sp->readheader_done == 0) - { - if (OJPEGReadHeaderInfo(tif) == 0) - return (0); - } - if (sp->sos_end[s].log == 0) - { - if (OJPEGReadSecondarySos(tif, s) == 0) - return (0); - } - if (isTiled(tif)) - m = tif->tif_curtile; - else - m = tif->tif_curstrip; - if ((sp->writeheader_done != 0) && - ((sp->write_cursample != s) || (sp->write_curstrile > m))) - { - if (sp->libjpeg_session_active != 0) - OJPEGLibjpegSessionAbort(tif); - sp->writeheader_done = 0; - } - if (sp->writeheader_done == 0) - { - 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) || - (sp->in_buffer_file_pos - sp->in_buffer_togo != - sp->sos_end[s].in_buffer_file_pos)) + static const char module[]="OJPEGDecode"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + (void)s; + if( !sp->decoder_ok ) { - sp->in_buffer_source = sp->sos_end[s].in_buffer_source; - sp->in_buffer_next_strile = sp->sos_end[s].in_buffer_next_strile; - sp->in_buffer_file_pos = sp->sos_end[s].in_buffer_file_pos; - sp->in_buffer_file_pos_log = 0; - sp->in_buffer_file_togo = sp->sos_end[s].in_buffer_file_togo; - sp->in_buffer_togo = 0; - sp->in_buffer_cur = 0; + TIFFErrorExt(tif->tif_clientdata,module,"Cannot decode: decoder not correctly initialized"); + return 0; } - if (OJPEGWriteHeaderInfo(tif) == 0) - return (0); - } - while (sp->write_curstrile < m) - { - if (sp->libjpeg_jpeg_query_style == 0) + if( sp->error_in_raw_data_decoding ) { - if (OJPEGPreDecodeSkipRaw(tif) == 0) - return (0); + return 0; } - else - { - if (OJPEGPreDecodeSkipScanlines(tif) == 0) - return (0); - } - sp->write_curstrile++; - } - sp->decoder_ok = 1; - return (1); + if (sp->libjpeg_jpeg_query_style==0) + { + if (OJPEGDecodeRaw(tif,buf,cc)==0) + return(0); + } + else + { + if (OJPEGDecodeScanlines(tif,buf,cc)==0) + return(0); + } + return(1); } -static int OJPEGPreDecodeSkipRaw(TIFF *tif) +static int +OJPEGDecodeRaw(TIFF* tif, uint8* buf, tmsize_t cc) { - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint32_t m; - m = sp->lines_per_strile; - if (sp->subsampling_convert_state != 0) - { - if (sp->subsampling_convert_clines - sp->subsampling_convert_state >= m) - { - sp->subsampling_convert_state += m; - if (sp->subsampling_convert_state == sp->subsampling_convert_clines) - sp->subsampling_convert_state = 0; - return (1); - } - m -= sp->subsampling_convert_clines - sp->subsampling_convert_state; - sp->subsampling_convert_state = 0; - sp->error_in_raw_data_decoding = 0; - } - while (m >= sp->subsampling_convert_clines) - { - if (jpeg_read_raw_data_encap(sp, &(sp->libjpeg_jpeg_decompress_struct), - sp->subsampling_convert_ycbcrimage, - sp->subsampling_ver * 8) == 0) - return (0); - m -= sp->subsampling_convert_clines; - } - if (m > 0) - { - if (jpeg_read_raw_data_encap(sp, &(sp->libjpeg_jpeg_decompress_struct), - sp->subsampling_convert_ycbcrimage, - sp->subsampling_ver * 8) == 0) - return (0); - sp->subsampling_convert_state = m; - } - return (1); + static const char module[]="OJPEGDecodeRaw"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8* m; + tmsize_t n; + uint8* oy; + uint8* ocb; + uint8* ocr; + uint8* p; + uint32 q; + uint8* r; + uint8 sx,sy; + if (cc%sp->bytes_per_line!=0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read"); + return(0); + } + assert(cc>0); + m=buf; + n=cc; + do + { + if (sp->subsampling_convert_state==0) + { + if (jpeg_read_raw_data_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),sp->subsampling_convert_ycbcrimage,sp->subsampling_ver*8)==0) + { + sp->error_in_raw_data_decoding = 1; + return(0); + } + } + oy=sp->subsampling_convert_ybuf+sp->subsampling_convert_state*sp->subsampling_ver*sp->subsampling_convert_ylinelen; + ocb=sp->subsampling_convert_cbbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; + ocr=sp->subsampling_convert_crbuf+sp->subsampling_convert_state*sp->subsampling_convert_clinelen; + p=m; + for (q=0; qsubsampling_convert_clinelenout; q++) + { + r=oy; + for (sy=0; sysubsampling_ver; sy++) + { + for (sx=0; sxsubsampling_hor; sx++) + *p++=*r++; + r+=sp->subsampling_convert_ylinelen-sp->subsampling_hor; + } + oy+=sp->subsampling_hor; + *p++=*ocb++; + *p++=*ocr++; + } + sp->subsampling_convert_state++; + if (sp->subsampling_convert_state==sp->subsampling_convert_clines) + sp->subsampling_convert_state=0; + m+=sp->bytes_per_line; + n-=sp->bytes_per_line; + } while(n>0); + return(1); } -static int OJPEGPreDecodeSkipScanlines(TIFF *tif) +static int +OJPEGDecodeScanlines(TIFF* tif, uint8* buf, tmsize_t cc) { - static const char module[] = "OJPEGPreDecodeSkipScanlines"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint32_t m; - if (sp->skip_buffer == NULL) - { - sp->skip_buffer = _TIFFmallocExt(tif, sp->bytes_per_line); - if (sp->skip_buffer == NULL) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - } - for (m = 0; m < sp->lines_per_strile; m++) - { - if (jpeg_read_scanlines_encap(sp, &(sp->libjpeg_jpeg_decompress_struct), - &sp->skip_buffer, 1) == 0) - return (0); - } - return (1); + static const char module[]="OJPEGDecodeScanlines"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8* m; + tmsize_t n; + if (cc%sp->bytes_per_line!=0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Fractional scanline not read"); + return(0); + } + assert(cc>0); + m=buf; + n=cc; + do + { + if (jpeg_read_scanlines_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),&m,1)==0) + return(0); + m+=sp->bytes_per_line; + n-=sp->bytes_per_line; + } while(n>0); + return(1); } -static int OJPEGDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s) +static void +OJPEGPostDecode(TIFF* tif, uint8* buf, tmsize_t cc) { - static const char module[] = "OJPEGDecode"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - (void)s; - if (!sp->decoder_ok) - { - TIFFErrorExtR(tif, module, - "Cannot decode: decoder not correctly initialized"); - return 0; - } - if (sp->libjpeg_session_active == 0) - { - /* This should normally not happen, except that it does when */ - /* using TIFFReadScanline() which calls OJPEGPostDecode() for */ - /* each scanline, which assumes that a whole strile was read */ - /* and may thus incorrectly consider it has read the whole image, - * causing */ - /* OJPEGLibjpegSessionAbort() to be called prematurely. */ - /* Triggered by https://gitlab.com/libtiff/libtiff/-/issues/337 */ - TIFFErrorExtR(tif, module, - "Cannot decode: libjpeg_session_active == 0"); - return 0; - } - if (sp->error_in_raw_data_decoding) - { - return 0; - } - if (sp->libjpeg_jpeg_query_style == 0) - { - if (OJPEGDecodeRaw(tif, buf, cc) == 0) - return (0); - } - else - { - if (OJPEGDecodeScanlines(tif, buf, cc) == 0) - return (0); - } - return (1); + OJPEGState* sp=(OJPEGState*)tif->tif_data; + (void)buf; + (void)cc; + sp->write_curstrile++; + if (sp->write_curstrile%tif->tif_dir.td_stripsperimage==0) + { + assert(sp->libjpeg_session_active!=0); + OJPEGLibjpegSessionAbort(tif); + sp->writeheader_done=0; + } } -static int OJPEGDecodeRaw(TIFF *tif, uint8_t *buf, tmsize_t cc) +static int +OJPEGSetupEncode(TIFF* tif) { - static const char module[] = "OJPEGDecodeRaw"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint8_t *m; - tmsize_t n; - 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) - { - TIFFErrorExtR(tif, module, "Fractional scanline not read"); - return (0); - } - assert(cc > 0); - m = buf; - n = cc; - do - { - if (sp->subsampling_convert_state == 0) - { - if (jpeg_read_raw_data_encap(sp, - &(sp->libjpeg_jpeg_decompress_struct), - sp->subsampling_convert_ycbcrimage, - sp->subsampling_ver * 8) == 0) - { - sp->error_in_raw_data_decoding = 1; - return (0); - } - } - oy = sp->subsampling_convert_ybuf + - sp->subsampling_convert_state * sp->subsampling_ver * - sp->subsampling_convert_ylinelen; - ocb = sp->subsampling_convert_cbbuf + - sp->subsampling_convert_state * sp->subsampling_convert_clinelen; - ocr = sp->subsampling_convert_crbuf + - sp->subsampling_convert_state * sp->subsampling_convert_clinelen; - p = m; - for (q = 0; q < sp->subsampling_convert_clinelenout; q++) - { - r = oy; - for (sy = 0; sy < sp->subsampling_ver; sy++) - { - for (sx = 0; sx < sp->subsampling_hor; sx++) - *p++ = *r++; - r += sp->subsampling_convert_ylinelen - sp->subsampling_hor; - } - oy += sp->subsampling_hor; - *p++ = *ocb++; - *p++ = *ocr++; - } - sp->subsampling_convert_state++; - if (sp->subsampling_convert_state == sp->subsampling_convert_clines) - sp->subsampling_convert_state = 0; - m += sp->bytes_per_line; - n -= sp->bytes_per_line; - } while (n > 0); - return (1); + static const char module[]="OJPEGSetupEncode"; + TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); + return(0); } -static int OJPEGDecodeScanlines(TIFF *tif, uint8_t *buf, tmsize_t cc) +static int +OJPEGPreEncode(TIFF* tif, uint16 s) { - static const char module[] = "OJPEGDecodeScanlines"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint8_t *m; - tmsize_t n; - if (cc % sp->bytes_per_line != 0) - { - TIFFErrorExtR(tif, module, "Fractional scanline not read"); - return (0); - } - assert(cc > 0); - m = buf; - n = cc; - do - { - if (jpeg_read_scanlines_encap(sp, &(sp->libjpeg_jpeg_decompress_struct), - &m, 1) == 0) - return (0); - m += sp->bytes_per_line; - n -= sp->bytes_per_line; - } while (n > 0); - return (1); + static const char module[]="OJPEGPreEncode"; + (void)s; + TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); + return(0); } -static void OJPEGPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc) +static int +OJPEGEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - OJPEGState *sp = (OJPEGState *)tif->tif_data; - (void)buf; - (void)cc; - /* This function somehow incorrectly assumes that a whole strile was read, - */ - /* which is not true when TIFFReadScanline() is called, */ - /* and may thus incorrectly consider it has read the whole image, causing */ - /* OJPEGLibjpegSessionAbort() to be called prematurely. */ - /* So this logic should be fixed to take into account cc, or disable */ - /* the scan line reading interface. */ - /* Triggered by https://gitlab.com/libtiff/libtiff/-/issues/337 */ - sp->write_curstrile++; - if (sp->write_curstrile % tif->tif_dir.td_stripsperimage == 0) - { - assert(sp->libjpeg_session_active != 0); - OJPEGLibjpegSessionAbort(tif); - sp->writeheader_done = 0; - } + static const char module[]="OJPEGEncode"; + (void)buf; + (void)cc; + (void)s; + TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); + return(0); } -static int OJPEGSetupEncode(TIFF *tif) +static int +OJPEGPostEncode(TIFF* tif) { - static const char module[] = "OJPEGSetupEncode"; - TIFFErrorExtR( - tif, module, - "OJPEG encoding not supported; use new-style JPEG compression instead"); - return (0); + static const char module[]="OJPEGPostEncode"; + TIFFErrorExt(tif->tif_clientdata,module,"OJPEG encoding not supported; use new-style JPEG compression instead"); + return(0); } -static int OJPEGPreEncode(TIFF *tif, uint16_t s) +static void +OJPEGCleanup(TIFF* tif) { - static const char module[] = "OJPEGPreEncode"; - (void)s; - TIFFErrorExtR( - tif, module, - "OJPEG encoding not supported; use new-style JPEG compression instead"); - return (0); + OJPEGState* sp=(OJPEGState*)tif->tif_data; + if (sp!=0) + { + tif->tif_tagmethods.vgetfield=sp->vgetparent; + tif->tif_tagmethods.vsetfield=sp->vsetparent; + tif->tif_tagmethods.printdir=sp->printdir; + if (sp->qtable[0]!=0) + _TIFFfree(sp->qtable[0]); + if (sp->qtable[1]!=0) + _TIFFfree(sp->qtable[1]); + if (sp->qtable[2]!=0) + _TIFFfree(sp->qtable[2]); + if (sp->qtable[3]!=0) + _TIFFfree(sp->qtable[3]); + if (sp->dctable[0]!=0) + _TIFFfree(sp->dctable[0]); + if (sp->dctable[1]!=0) + _TIFFfree(sp->dctable[1]); + if (sp->dctable[2]!=0) + _TIFFfree(sp->dctable[2]); + if (sp->dctable[3]!=0) + _TIFFfree(sp->dctable[3]); + if (sp->actable[0]!=0) + _TIFFfree(sp->actable[0]); + if (sp->actable[1]!=0) + _TIFFfree(sp->actable[1]); + if (sp->actable[2]!=0) + _TIFFfree(sp->actable[2]); + if (sp->actable[3]!=0) + _TIFFfree(sp->actable[3]); + if (sp->libjpeg_session_active!=0) + OJPEGLibjpegSessionAbort(tif); + if (sp->subsampling_convert_ycbcrbuf!=0) + _TIFFfree(sp->subsampling_convert_ycbcrbuf); + if (sp->subsampling_convert_ycbcrimage!=0) + _TIFFfree(sp->subsampling_convert_ycbcrimage); + if (sp->skip_buffer!=0) + _TIFFfree(sp->skip_buffer); + _TIFFfree(sp); + tif->tif_data=NULL; + _TIFFSetDefaultCompressionState(tif); + } } -static int OJPEGEncode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s) +static void +OJPEGSubsamplingCorrect(TIFF* tif) { - static const char module[] = "OJPEGEncode"; - (void)buf; - (void)cc; - (void)s; - TIFFErrorExtR( - tif, module, - "OJPEG encoding not supported; use new-style JPEG compression instead"); - return (0); + static const char module[]="OJPEGSubsamplingCorrect"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 mh; + uint8 mv; + + assert(sp->subsamplingcorrect_done==0); + if ((tif->tif_dir.td_samplesperpixel!=3) || ((tif->tif_dir.td_photometric!=PHOTOMETRIC_YCBCR) && + (tif->tif_dir.td_photometric!=PHOTOMETRIC_ITULAB))) + { + if (sp->subsampling_tag!=0) + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag not appropriate for this Photometric and/or SamplesPerPixel"); + sp->subsampling_hor=1; + sp->subsampling_ver=1; + sp->subsampling_force_desubsampling_inside_decompression=0; + } + else + { + sp->subsamplingcorrect_done=1; + mh=sp->subsampling_hor; + mv=sp->subsampling_ver; + sp->subsamplingcorrect=1; + OJPEGReadHeaderInfoSec(tif); + if (sp->subsampling_force_desubsampling_inside_decompression!=0) + { + sp->subsampling_hor=1; + sp->subsampling_ver=1; + } + sp->subsamplingcorrect=0; + 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); + 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); + } + 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); + } + if (sp->subsampling_force_desubsampling_inside_decompression==0) + { + if (sp->subsampling_horsubsampling_ver) + TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver); + } + } + sp->subsamplingcorrect_done=1; } -static int OJPEGPostEncode(TIFF *tif) +static int +OJPEGReadHeaderInfo(TIFF* tif) { - static const char module[] = "OJPEGPostEncode"; - TIFFErrorExtR( - tif, module, - "OJPEG encoding not supported; use new-style JPEG compression instead"); - return (0); + static const char module[]="OJPEGReadHeaderInfo"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(sp->readheader_done==0); + sp->image_width=tif->tif_dir.td_imagewidth; + sp->image_length=tif->tif_dir.td_imagelength; + if (isTiled(tif)) + { + sp->strile_width=tif->tif_dir.td_tilewidth; + sp->strile_length=tif->tif_dir.td_tilelength; + sp->strile_length_total=((sp->image_length+sp->strile_length-1)/sp->strile_length)*sp->strile_length; + } + else + { + sp->strile_width=sp->image_width; + sp->strile_length=tif->tif_dir.td_rowsperstrip; + if( sp->strile_length == (uint32)-1 ) + sp->strile_length = sp->image_length; + sp->strile_length_total=sp->image_length; + } + if (tif->tif_dir.td_samplesperpixel==1) + { + sp->samples_per_pixel=1; + sp->plane_sample_offset=0; + sp->samples_per_pixel_per_plane=sp->samples_per_pixel; + sp->subsampling_hor=1; + sp->subsampling_ver=1; + } + else + { + if (tif->tif_dir.td_samplesperpixel!=3) + { + TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel); + return(0); + } + sp->samples_per_pixel=3; + sp->plane_sample_offset=0; + if (tif->tif_dir.td_planarconfig==PLANARCONFIG_CONTIG) + sp->samples_per_pixel_per_plane=3; + else + sp->samples_per_pixel_per_plane=1; + } + if (sp->strile_lengthimage_length) + { + if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) || + ((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4))) + { + TIFFErrorExt(tif->tif_clientdata,module,"Invalid subsampling values"); + return(0); + } + if (sp->strile_length%(sp->subsampling_ver*8)!=0) + { + 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))); + } + if (OJPEGReadHeaderInfoSec(tif)==0) + return(0); + sp->sos_end[0].log=1; + sp->sos_end[0].in_buffer_source=sp->in_buffer_source; + sp->sos_end[0].in_buffer_next_strile=sp->in_buffer_next_strile; + sp->sos_end[0].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; + sp->sos_end[0].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo; + sp->readheader_done=1; + return(1); } -static void OJPEGCleanup(TIFF *tif) +static int +OJPEGReadSecondarySos(TIFF* tif, uint16 s) { - OJPEGState *sp = (OJPEGState *)tif->tif_data; - if (sp != 0) - { - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - tif->tif_tagmethods.printdir = sp->printdir; - if (sp->qtable[0] != 0) - _TIFFfreeExt(tif, sp->qtable[0]); - if (sp->qtable[1] != 0) - _TIFFfreeExt(tif, sp->qtable[1]); - if (sp->qtable[2] != 0) - _TIFFfreeExt(tif, sp->qtable[2]); - if (sp->qtable[3] != 0) - _TIFFfreeExt(tif, sp->qtable[3]); - if (sp->dctable[0] != 0) - _TIFFfreeExt(tif, sp->dctable[0]); - if (sp->dctable[1] != 0) - _TIFFfreeExt(tif, sp->dctable[1]); - if (sp->dctable[2] != 0) - _TIFFfreeExt(tif, sp->dctable[2]); - if (sp->dctable[3] != 0) - _TIFFfreeExt(tif, sp->dctable[3]); - if (sp->actable[0] != 0) - _TIFFfreeExt(tif, sp->actable[0]); - if (sp->actable[1] != 0) - _TIFFfreeExt(tif, sp->actable[1]); - if (sp->actable[2] != 0) - _TIFFfreeExt(tif, sp->actable[2]); - if (sp->actable[3] != 0) - _TIFFfreeExt(tif, sp->actable[3]); - if (sp->libjpeg_session_active != 0) - OJPEGLibjpegSessionAbort(tif); - if (sp->subsampling_convert_ycbcrbuf != 0) - _TIFFfreeExt(tif, sp->subsampling_convert_ycbcrbuf); - if (sp->subsampling_convert_ycbcrimage != 0) - _TIFFfreeExt(tif, sp->subsampling_convert_ycbcrimage); - if (sp->skip_buffer != 0) - _TIFFfreeExt(tif, sp->skip_buffer); - _TIFFfreeExt(tif, sp); - tif->tif_data = NULL; - _TIFFSetDefaultCompressionState(tif); - } + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 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); + 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; + sp->in_buffer_next_strile=sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile; + sp->in_buffer_file_pos=sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos; + sp->in_buffer_file_pos_log=0; + sp->in_buffer_file_togo=sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo; + sp->in_buffer_togo=0; + sp->in_buffer_cur=0; + while(sp->plane_sample_offsetplane_sample_offset++; + if (OJPEGReadHeaderInfoSecStreamSos(tif)==0) + return(0); + sp->sos_end[sp->plane_sample_offset].log=1; + sp->sos_end[sp->plane_sample_offset].in_buffer_source=sp->in_buffer_source; + sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile=sp->in_buffer_next_strile; + sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos=sp->in_buffer_file_pos-sp->in_buffer_togo; + sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo=sp->in_buffer_file_togo+sp->in_buffer_togo; + } + return(1); } -static void OJPEGSubsamplingCorrect(TIFF *tif) +static int +OJPEGWriteHeaderInfo(TIFF* tif) { - static const char module[] = "OJPEGSubsamplingCorrect"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - 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) && - (tif->tif_dir.td_photometric != PHOTOMETRIC_ITULAB))) - { - if (sp->subsampling_tag != 0) - TIFFWarningExtR(tif, module, - "Subsampling tag not appropriate for this " - "Photometric and/or SamplesPerPixel"); - sp->subsampling_hor = 1; - sp->subsampling_ver = 1; - sp->subsampling_force_desubsampling_inside_decompression = 0; - } - else - { - sp->subsamplingcorrect_done = 1; - mh = sp->subsampling_hor; - mv = sp->subsampling_ver; - sp->subsamplingcorrect = 1; - OJPEGReadHeaderInfoSec(tif); - if (sp->subsampling_force_desubsampling_inside_decompression != 0) - { - sp->subsampling_hor = 1; - sp->subsampling_ver = 1; - } - sp->subsamplingcorrect = 0; - if (((sp->subsampling_hor != mh) || (sp->subsampling_ver != mv)) && - (sp->subsampling_force_desubsampling_inside_decompression == 0)) - { - if (sp->subsampling_tag == 0) - TIFFWarningExtR( - tif, 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 - TIFFWarningExtR( - tif, 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) - TIFFWarningExtR( - tif, 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 - TIFFWarningExtR( - tif, 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) - TIFFWarningExtR(tif, module, - "Subsampling values [%" PRIu8 ",%" PRIu8 - "] are not allowed in TIFF", - sp->subsampling_hor, sp->subsampling_ver); - } - } - sp->subsamplingcorrect_done = 1; -} - -static int OJPEGReadHeaderInfo(TIFF *tif) -{ - static const char module[] = "OJPEGReadHeaderInfo"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - assert(sp->readheader_done == 0); - sp->image_width = tif->tif_dir.td_imagewidth; - sp->image_length = tif->tif_dir.td_imagelength; - if (isTiled(tif)) - { - sp->strile_width = tif->tif_dir.td_tilewidth; - sp->strile_length = tif->tif_dir.td_tilelength; - sp->strile_length_total = - ((sp->image_length + sp->strile_length - 1) / sp->strile_length) * - sp->strile_length; - } - else - { - sp->strile_width = sp->image_width; - sp->strile_length = tif->tif_dir.td_rowsperstrip; - if (sp->strile_length == (uint32_t)-1) - sp->strile_length = sp->image_length; - sp->strile_length_total = sp->image_length; - } - if (tif->tif_dir.td_samplesperpixel == 1) - { - sp->samples_per_pixel = 1; - sp->plane_sample_offset = 0; - sp->samples_per_pixel_per_plane = sp->samples_per_pixel; - sp->subsampling_hor = 1; - sp->subsampling_ver = 1; - } - else - { - if (tif->tif_dir.td_samplesperpixel != 3) - { - TIFFErrorExtR(tif, module, - "SamplesPerPixel %" PRIu8 - " not supported for this compression scheme", - sp->samples_per_pixel); - return (0); - } - sp->samples_per_pixel = 3; - sp->plane_sample_offset = 0; - if (tif->tif_dir.td_planarconfig == PLANARCONFIG_CONTIG) - sp->samples_per_pixel_per_plane = 3; - else - sp->samples_per_pixel_per_plane = 1; - } - if (sp->strile_length < sp->image_length) - { - if (((sp->subsampling_hor != 1) && (sp->subsampling_hor != 2) && - (sp->subsampling_hor != 4)) || - ((sp->subsampling_ver != 1) && (sp->subsampling_ver != 2) && - (sp->subsampling_ver != 4))) - { - TIFFErrorExtR(tif, module, "Invalid subsampling values"); - return (0); - } - if (sp->strile_length % (sp->subsampling_ver * 8) != 0) - { - TIFFErrorExtR(tif, module, - "Incompatible vertical subsampling and image " - "strip/tile length"); - return (0); - } - 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); - sp->sos_end[0].log = 1; - sp->sos_end[0].in_buffer_source = sp->in_buffer_source; - sp->sos_end[0].in_buffer_next_strile = sp->in_buffer_next_strile; - sp->sos_end[0].in_buffer_file_pos = - sp->in_buffer_file_pos - sp->in_buffer_togo; - sp->sos_end[0].in_buffer_file_togo = - sp->in_buffer_file_togo + sp->in_buffer_togo; - sp->readheader_done = 1; - return (1); -} - -static int OJPEGReadSecondarySos(TIFF *tif, uint16_t s) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - 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_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; - sp->in_buffer_next_strile = - sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile; - sp->in_buffer_file_pos = - sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos; - sp->in_buffer_file_pos_log = 0; - sp->in_buffer_file_togo = - sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo; - sp->in_buffer_togo = 0; - sp->in_buffer_cur = 0; - while (sp->plane_sample_offset < s) - { - do - { - if (OJPEGReadByte(sp, &m) == 0) - return (0); - if (m == 255) - { - do - { - if (OJPEGReadByte(sp, &m) == 0) - return (0); - if (m != 255) - break; - } while (1); - if (m == JPEG_MARKER_SOS) - break; - } - } while (1); - sp->plane_sample_offset++; - if (OJPEGReadHeaderInfoSecStreamSos(tif) == 0) - return (0); - sp->sos_end[sp->plane_sample_offset].log = 1; - sp->sos_end[sp->plane_sample_offset].in_buffer_source = - sp->in_buffer_source; - sp->sos_end[sp->plane_sample_offset].in_buffer_next_strile = - sp->in_buffer_next_strile; - sp->sos_end[sp->plane_sample_offset].in_buffer_file_pos = - sp->in_buffer_file_pos - sp->in_buffer_togo; - sp->sos_end[sp->plane_sample_offset].in_buffer_file_togo = - sp->in_buffer_file_togo + sp->in_buffer_togo; - } - return (1); -} - -static int OJPEGWriteHeaderInfo(TIFF *tif) -{ - static const char module[] = "OJPEGWriteHeaderInfo"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint8_t **m; - uint32_t n; - /* if a previous attempt failed, don't try again */ - if (sp->libjpeg_session_active != 0) - return 0; - sp->out_state = ososSoi; - sp->restart_index = 0; - jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr)); - sp->libjpeg_jpeg_error_mgr.output_message = - OJPEGLibjpegJpegErrorMgrOutputMessage; - sp->libjpeg_jpeg_error_mgr.error_exit = OJPEGLibjpegJpegErrorMgrErrorExit; - sp->libjpeg_jpeg_decompress_struct.err = &(sp->libjpeg_jpeg_error_mgr); - sp->libjpeg_jpeg_decompress_struct.client_data = (void *)tif; - if (jpeg_create_decompress_encap( - sp, &(sp->libjpeg_jpeg_decompress_struct)) == 0) - return (0); - sp->libjpeg_session_active = 1; - sp->libjpeg_jpeg_source_mgr.bytes_in_buffer = 0; - sp->libjpeg_jpeg_source_mgr.init_source = - OJPEGLibjpegJpegSourceMgrInitSource; - sp->libjpeg_jpeg_source_mgr.fill_input_buffer = - OJPEGLibjpegJpegSourceMgrFillInputBuffer; - sp->libjpeg_jpeg_source_mgr.skip_input_data = - OJPEGLibjpegJpegSourceMgrSkipInputData; - sp->libjpeg_jpeg_source_mgr.resync_to_restart = - OJPEGLibjpegJpegSourceMgrResyncToRestart; - sp->libjpeg_jpeg_source_mgr.term_source = - OJPEGLibjpegJpegSourceMgrTermSource; - sp->libjpeg_jpeg_decompress_struct.src = &(sp->libjpeg_jpeg_source_mgr); - if (jpeg_read_header_encap(sp, &(sp->libjpeg_jpeg_decompress_struct), 1) == - 0) - return (0); - if ((sp->subsampling_force_desubsampling_inside_decompression == 0) && - (sp->samples_per_pixel_per_plane > 1)) - { - sp->libjpeg_jpeg_decompress_struct.raw_data_out = 1; + static const char module[]="OJPEGWriteHeaderInfo"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8** m; + uint32 n; + /* if a previous attempt failed, don't try again */ + if (sp->libjpeg_session_active != 0) + return 0; + sp->out_state=ososSoi; + sp->restart_index=0; + jpeg_std_error(&(sp->libjpeg_jpeg_error_mgr)); + sp->libjpeg_jpeg_error_mgr.output_message=OJPEGLibjpegJpegErrorMgrOutputMessage; + sp->libjpeg_jpeg_error_mgr.error_exit=OJPEGLibjpegJpegErrorMgrErrorExit; + sp->libjpeg_jpeg_decompress_struct.err=&(sp->libjpeg_jpeg_error_mgr); + sp->libjpeg_jpeg_decompress_struct.client_data=(void*)tif; + if (jpeg_create_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) + return(0); + sp->libjpeg_session_active=1; + sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=0; + sp->libjpeg_jpeg_source_mgr.init_source=OJPEGLibjpegJpegSourceMgrInitSource; + sp->libjpeg_jpeg_source_mgr.fill_input_buffer=OJPEGLibjpegJpegSourceMgrFillInputBuffer; + sp->libjpeg_jpeg_source_mgr.skip_input_data=OJPEGLibjpegJpegSourceMgrSkipInputData; + sp->libjpeg_jpeg_source_mgr.resync_to_restart=OJPEGLibjpegJpegSourceMgrResyncToRestart; + sp->libjpeg_jpeg_source_mgr.term_source=OJPEGLibjpegJpegSourceMgrTermSource; + sp->libjpeg_jpeg_decompress_struct.src=&(sp->libjpeg_jpeg_source_mgr); + if (jpeg_read_header_encap(sp,&(sp->libjpeg_jpeg_decompress_struct),1)==0) + return(0); + if ((sp->subsampling_force_desubsampling_inside_decompression==0) && (sp->samples_per_pixel_per_plane>1)) + { + sp->libjpeg_jpeg_decompress_struct.raw_data_out=1; #if JPEG_LIB_VERSION >= 70 - sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling = FALSE; + sp->libjpeg_jpeg_decompress_struct.do_fancy_upsampling=FALSE; #endif - sp->libjpeg_jpeg_query_style = 0; - if (sp->subsampling_convert_log == 0) - { - assert(sp->subsampling_convert_ycbcrbuf == 0); - assert(sp->subsampling_convert_ycbcrimage == 0); - /* Check for division by zero. */ - if (sp->subsampling_hor == 0 || sp->subsampling_ver == 0) - return (0); - sp->subsampling_convert_ylinelen = - ((sp->strile_width + sp->subsampling_hor * 8 - 1) / - (sp->subsampling_hor * 8) * sp->subsampling_hor * 8); - sp->subsampling_convert_ylines = sp->subsampling_ver * 8; - sp->subsampling_convert_clinelen = - sp->subsampling_convert_ylinelen / sp->subsampling_hor; - sp->subsampling_convert_clines = 8; - sp->subsampling_convert_ybuflen = sp->subsampling_convert_ylinelen * - sp->subsampling_convert_ylines; - sp->subsampling_convert_cbuflen = sp->subsampling_convert_clinelen * - sp->subsampling_convert_clines; - sp->subsampling_convert_ycbcrbuflen = - sp->subsampling_convert_ybuflen + - 2 * sp->subsampling_convert_cbuflen; - /* The calloc is not normally necessary, except in some edge/broken - * cases */ - /* for example for a tiled image of height 1 with a tile height of 1 - * and subsampling_hor=subsampling_ver=2 */ - /* In that case, libjpeg will only fill the 8 first lines of the 16 - * lines */ - /* See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16844 - */ - /* Even if this case is allowed (?), its handling is broken because - * OJPEGPreDecode() should also likely */ - /* reset subsampling_convert_state to 0 when changing tile. */ - sp->subsampling_convert_ycbcrbuf = - _TIFFcallocExt(tif, 1, sp->subsampling_convert_ycbcrbuflen); - if (sp->subsampling_convert_ycbcrbuf == 0) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - sp->subsampling_convert_ybuf = sp->subsampling_convert_ycbcrbuf; - 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 = _TIFFmallocExt( - tif, sp->subsampling_convert_ycbcrimagelen * sizeof(uint8_t *)); - if (sp->subsampling_convert_ycbcrimage == 0) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - m = sp->subsampling_convert_ycbcrimage; - *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++) - *m++ = sp->subsampling_convert_cbbuf + - n * sp->subsampling_convert_clinelen; - for (n = 0; n < sp->subsampling_convert_clines; n++) - *m++ = sp->subsampling_convert_crbuf + - n * sp->subsampling_convert_clinelen; - sp->subsampling_convert_clinelenout = - sp->strile_width / sp->subsampling_hor + - ((sp->strile_width % sp->subsampling_hor) != 0 ? 1 : 0); - sp->subsampling_convert_state = 0; - sp->error_in_raw_data_decoding = 0; - sp->bytes_per_line = - sp->subsampling_convert_clinelenout * - (sp->subsampling_ver * sp->subsampling_hor + 2); - sp->lines_per_strile = - sp->strile_length / sp->subsampling_ver + - ((sp->strile_length % sp->subsampling_ver) != 0 ? 1 : 0); - sp->subsampling_convert_log = 1; + sp->libjpeg_jpeg_query_style=0; + if (sp->subsampling_convert_log==0) + { + assert(sp->subsampling_convert_ycbcrbuf==0); + assert(sp->subsampling_convert_ycbcrimage==0); + sp->subsampling_convert_ylinelen=((sp->strile_width+sp->subsampling_hor*8-1)/(sp->subsampling_hor*8)*sp->subsampling_hor*8); + sp->subsampling_convert_ylines=sp->subsampling_ver*8; + sp->subsampling_convert_clinelen=sp->subsampling_convert_ylinelen/sp->subsampling_hor; + sp->subsampling_convert_clines=8; + sp->subsampling_convert_ybuflen=sp->subsampling_convert_ylinelen*sp->subsampling_convert_ylines; + sp->subsampling_convert_cbuflen=sp->subsampling_convert_clinelen*sp->subsampling_convert_clines; + sp->subsampling_convert_ycbcrbuflen=sp->subsampling_convert_ybuflen+2*sp->subsampling_convert_cbuflen; + /* The calloc is not normally necessary, except in some edge/broken cases */ + /* for example for a tiled image of height 1 with a tile height of 1 and subsampling_hor=subsampling_ver=2 */ + /* In that case, libjpeg will only fill the 8 first lines of the 16 lines */ + /* See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16844 */ + /* Even if this case is allowed (?), its handling is broken because OJPEGPreDecode() should also likely */ + /* reset subsampling_convert_state to 0 when changing tile. */ + sp->subsampling_convert_ycbcrbuf=_TIFFcalloc(1, sp->subsampling_convert_ycbcrbuflen); + if (sp->subsampling_convert_ycbcrbuf==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Out of memory"); + return(0); + } + sp->subsampling_convert_ybuf=sp->subsampling_convert_ycbcrbuf; + 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*)); + 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); + for (n=0; nsubsampling_convert_ylines; n++) + *m++=sp->subsampling_convert_ybuf+n*sp->subsampling_convert_ylinelen; + for (n=0; nsubsampling_convert_clines; n++) + *m++=sp->subsampling_convert_cbbuf+n*sp->subsampling_convert_clinelen; + for (n=0; nsubsampling_convert_clines; n++) + *m++=sp->subsampling_convert_crbuf+n*sp->subsampling_convert_clinelen; + sp->subsampling_convert_clinelenout=sp->strile_width/sp->subsampling_hor + ((sp->strile_width % sp->subsampling_hor) != 0 ? 1 : 0); + sp->subsampling_convert_state=0; + sp->error_in_raw_data_decoding=0; + sp->bytes_per_line=sp->subsampling_convert_clinelenout*(sp->subsampling_ver*sp->subsampling_hor+2); + sp->lines_per_strile=sp->strile_length/sp->subsampling_ver + ((sp->strile_length % sp->subsampling_ver) != 0 ? 1 : 0); + sp->subsampling_convert_log=1; + } + } + else + { + sp->libjpeg_jpeg_decompress_struct.jpeg_color_space=JCS_UNKNOWN; + sp->libjpeg_jpeg_decompress_struct.out_color_space=JCS_UNKNOWN; + sp->libjpeg_jpeg_query_style=1; + sp->bytes_per_line=sp->samples_per_pixel_per_plane*sp->strile_width; + sp->lines_per_strile=sp->strile_length; + } + if (jpeg_start_decompress_encap(sp,&(sp->libjpeg_jpeg_decompress_struct))==0) + 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", + sp->libjpeg_jpeg_decompress_struct.image_width, + sp->strile_width); + return 0; } - } - else - { - sp->libjpeg_jpeg_decompress_struct.jpeg_color_space = JCS_UNKNOWN; - sp->libjpeg_jpeg_decompress_struct.out_color_space = JCS_UNKNOWN; - sp->libjpeg_jpeg_query_style = 1; - sp->bytes_per_line = sp->samples_per_pixel_per_plane * sp->strile_width; - sp->lines_per_strile = sp->strile_length; - } - if (jpeg_start_decompress_encap(sp, - &(sp->libjpeg_jpeg_decompress_struct)) == 0) - return (0); - if (sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width) - { - TIFFErrorExtR(tif, module, - "jpeg_start_decompress() returned image_width = %u, " - "expected %" PRIu32, - sp->libjpeg_jpeg_decompress_struct.image_width, - sp->strile_width); - return 0; - } - if (sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor != - sp->subsampling_hor || - sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor != - sp->subsampling_ver) - { - TIFFErrorExtR(tif, module, - "jpeg_start_decompress() returned max_h_samp_factor = %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, sp->subsampling_ver); - return 0; - } - - sp->writeheader_done = 1; - return (1); -} - -static void OJPEGLibjpegSessionAbort(TIFF *tif) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - assert(sp->libjpeg_session_active != 0); - jpeg_destroy((jpeg_common_struct *)(&(sp->libjpeg_jpeg_decompress_struct))); - sp->libjpeg_session_active = 0; -} - -static int OJPEGReadHeaderInfoSec(TIFF *tif) -{ - static const char module[] = "OJPEGReadHeaderInfoSec"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - 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) - { - if (sp->jpeg_interchange_format >= sp->file_size) - { - sp->jpeg_interchange_format = 0; - sp->jpeg_interchange_format_length = 0; + if(sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor != sp->subsampling_hor || + 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", + sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor, + sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor, + sp->subsampling_hor, + sp->subsampling_ver); + return 0; } - else - { - if ((sp->jpeg_interchange_format_length == 0) || - (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; - } - } - sp->in_buffer_source = osibsNotSetYet; - sp->in_buffer_next_strile = 0; - sp->in_buffer_strile_count = tif->tif_dir.td_nstrips; - sp->in_buffer_file_togo = 0; - sp->in_buffer_togo = 0; - do - { - if (OJPEGReadBytePeek(sp, &m) == 0) - return (0); - if (m != 255) - break; - OJPEGReadByteAdvance(sp); - do - { - if (OJPEGReadByte(sp, &m) == 0) - return (0); - } while (m == 255); - switch (m) - { - case JPEG_MARKER_SOI: - /* this type of marker has no data, and should be skipped */ - break; - case JPEG_MARKER_COM: - case JPEG_MARKER_APP0: - case JPEG_MARKER_APP0 + 1: - case JPEG_MARKER_APP0 + 2: - case JPEG_MARKER_APP0 + 3: - case JPEG_MARKER_APP0 + 4: - case JPEG_MARKER_APP0 + 5: - case JPEG_MARKER_APP0 + 6: - case JPEG_MARKER_APP0 + 7: - case JPEG_MARKER_APP0 + 8: - case JPEG_MARKER_APP0 + 9: - case JPEG_MARKER_APP0 + 10: - case JPEG_MARKER_APP0 + 11: - case JPEG_MARKER_APP0 + 12: - case JPEG_MARKER_APP0 + 13: - case JPEG_MARKER_APP0 + 14: - case JPEG_MARKER_APP0 + 15: - /* this type of marker has data, but it has no use to us (and no - * place here) and should be skipped */ - if (OJPEGReadWord(sp, &n) == 0) - return (0); - if (n < 2) - { - if (sp->subsamplingcorrect == 0) - TIFFErrorExtR(tif, module, "Corrupt JPEG data"); - return (0); - } - if (n > 2) - OJPEGReadSkip(sp, n - 2); - break; - case JPEG_MARKER_DRI: - if (OJPEGReadHeaderInfoSecStreamDri(tif) == 0) - return (0); - break; - case JPEG_MARKER_DQT: - if (OJPEGReadHeaderInfoSecStreamDqt(tif) == 0) - return (0); - break; - case JPEG_MARKER_DHT: - if (OJPEGReadHeaderInfoSecStreamDht(tif) == 0) - return (0); - break; - case JPEG_MARKER_SOF0: - case JPEG_MARKER_SOF1: - case JPEG_MARKER_SOF3: - if (OJPEGReadHeaderInfoSecStreamSof(tif, m) == 0) - return (0); - if (sp->subsamplingcorrect != 0) - return (1); - break; - case JPEG_MARKER_SOS: - if (sp->subsamplingcorrect != 0) - return (1); - assert(sp->plane_sample_offset == 0); - if (OJPEGReadHeaderInfoSecStreamSos(tif) == 0) - return (0); - break; - default: - TIFFErrorExtR(tif, module, - "Unknown marker type %" PRIu8 " in JPEG data", m); - return (0); - } - } while (m != JPEG_MARKER_SOS); - if (sp->subsamplingcorrect) - return (1); - if (sp->sof_log == 0) - { - if (OJPEGReadHeaderInfoSecTablesQTable(tif) == 0) - return (0); - sp->sof_marker_id = JPEG_MARKER_SOF0; - for (o = 0; o < sp->samples_per_pixel; o++) - sp->sof_c[o] = o; - sp->sof_hv[0] = ((sp->subsampling_hor << 4) | sp->subsampling_ver); - for (o = 1; o < sp->samples_per_pixel; o++) - sp->sof_hv[o] = 17; - sp->sof_x = sp->strile_width; - sp->sof_y = sp->strile_length_total; - sp->sof_log = 1; - if (OJPEGReadHeaderInfoSecTablesDcTable(tif) == 0) - return (0); - if (OJPEGReadHeaderInfoSecTablesAcTable(tif) == 0) - return (0); - for (o = 1; o < sp->samples_per_pixel; o++) - sp->sos_cs[o] = o; - } - return (1); -} -static int OJPEGReadHeaderInfoSecStreamDri(TIFF *tif) -{ - /* This could easily cause trouble in some cases... but no such cases have - occurred so far */ - static const char module[] = "OJPEGReadHeaderInfoSecStreamDri"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint16_t m; - if (OJPEGReadWord(sp, &m) == 0) - return (0); - if (m != 4) - { - TIFFErrorExtR(tif, module, "Corrupt DRI marker in JPEG data"); - return (0); - } - if (OJPEGReadWord(sp, &m) == 0) - return (0); - sp->restart_interval = m; - return (1); -} - -static int 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_t m; - uint32_t na; - uint8_t *nb; - uint8_t o; - if (OJPEGReadWord(sp, &m) == 0) - return (0); - if (m <= 2) - { - if (sp->subsamplingcorrect == 0) - TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data"); - return (0); - } - if (sp->subsamplingcorrect != 0) - OJPEGReadSkip(sp, m - 2); - else - { - m -= 2; - do - { - if (m < 65) - { - TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data"); - return (0); - } - na = sizeof(uint32_t) + 69; - nb = _TIFFmallocExt(tif, na); - if (nb == 0) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (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) - { - _TIFFfreeExt(tif, nb); - return (0); - } - o = nb[sizeof(uint32_t) + 4] & 15; - if (3 < o) - { - TIFFErrorExtR(tif, module, "Corrupt DQT marker in JPEG data"); - _TIFFfreeExt(tif, nb); - return (0); - } - if (sp->qtable[o] != 0) - _TIFFfreeExt(tif, sp->qtable[o]); - sp->qtable[o] = nb; - m -= 65; - } while (m > 0); - } - return (1); -} - -static int OJPEGReadHeaderInfoSecStreamDht(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 */ - /* 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_t m; - uint32_t na; - uint8_t *nb; - uint8_t o; - if (OJPEGReadWord(sp, &m) == 0) - return (0); - if (m <= 2) - { - if (sp->subsamplingcorrect == 0) - TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data"); - return (0); - } - if (sp->subsamplingcorrect != 0) - { - OJPEGReadSkip(sp, m - 2); - } - else - { - na = sizeof(uint32_t) + 2 + m; - nb = _TIFFmallocExt(tif, na); - if (nb == 0) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (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) - { - _TIFFfreeExt(tif, nb); - return (0); - } - o = nb[sizeof(uint32_t) + 4]; - if ((o & 240) == 0) - { - if (3 < o) - { - TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data"); - _TIFFfreeExt(tif, nb); - return (0); - } - if (sp->dctable[o] != 0) - _TIFFfreeExt(tif, sp->dctable[o]); - sp->dctable[o] = nb; - } - else - { - if ((o & 240) != 16) - { - TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data"); - _TIFFfreeExt(tif, nb); - return (0); - } - o &= 15; - if (3 < o) - { - TIFFErrorExtR(tif, module, "Corrupt DHT marker in JPEG data"); - _TIFFfreeExt(tif, nb); - return (0); - } - if (sp->actable[o] != 0) - _TIFFfreeExt(tif, sp->actable[o]); - sp->actable[o] = nb; - } - } - return (1); -} - -static int 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_t m; - uint16_t n; - uint8_t o; - uint16_t p; - uint16_t q; - if (sp->sof_log != 0) - { - TIFFErrorExtR(tif, module, "Corrupt JPEG data"); - return (0); - } - if (sp->subsamplingcorrect == 0) - sp->sof_marker_id = marker_id; - /* Lf: data length */ - if (OJPEGReadWord(sp, &m) == 0) - return (0); - if (m < 11) - { - if (sp->subsamplingcorrect == 0) - TIFFErrorExtR(tif, module, "Corrupt SOF marker in JPEG data"); - return (0); - } - m -= 8; - if (m % 3 != 0) - { - if (sp->subsamplingcorrect == 0) - TIFFErrorExtR(tif, module, "Corrupt SOF marker in JPEG data"); - return (0); - } - n = m / 3; - if (sp->subsamplingcorrect == 0) - { - if (n != sp->samples_per_pixel) - { - TIFFErrorExtR( - tif, module, - "JPEG compressed data indicates unexpected number of samples"); - return (0); - } - } - /* P: Sample precision */ - if (OJPEGReadByte(sp, &o) == 0) - return (0); - if (o != 8) - { - if (sp->subsamplingcorrect == 0) - TIFFErrorExtR(tif, module, - "JPEG compressed data indicates unexpected number of " - "bits per sample"); - return (0); - } - /* Y: Number of lines, X: Number of samples per line */ - if (sp->subsamplingcorrect) - OJPEGReadSkip(sp, 4); - else - { - /* Y: Number of lines */ - if (OJPEGReadWord(sp, &p) == 0) - return (0); - if (((uint32_t)p < sp->image_length) && - ((uint32_t)p < sp->strile_length_total)) - { - TIFFErrorExtR(tif, module, - "JPEG compressed data indicates unexpected height"); - return (0); - } - sp->sof_y = p; - /* X: Number of samples per line */ - if (OJPEGReadWord(sp, &p) == 0) - return (0); - if (((uint32_t)p < sp->image_width) && ((uint32_t)p < sp->strile_width)) - { - TIFFErrorExtR(tif, module, - "JPEG compressed data indicates unexpected width"); - return (0); - } - if ((uint32_t)p > sp->strile_width) - { - TIFFErrorExtR(tif, module, - "JPEG compressed data image width exceeds expected " - "image width"); - return (0); - } - sp->sof_x = p; - } - /* Nf: Number of image components in frame */ - if (OJPEGReadByte(sp, &o) == 0) - return (0); - if (o != n) - { - if (sp->subsamplingcorrect == 0) - TIFFErrorExtR(tif, module, "Corrupt SOF marker in JPEG data"); - return (0); - } - /* per component stuff */ - /* TODO: double-check that flow implies that n cannot be as big as to make - * us overflow sof_c, sof_hv and sof_tq arrays */ - for (q = 0; q < n; q++) - { - /* C: Component identifier */ - if (OJPEGReadByte(sp, &o) == 0) - return (0); - if (sp->subsamplingcorrect == 0) - sp->sof_c[q] = o; - /* H: Horizontal sampling factor, and V: Vertical sampling factor */ - if (OJPEGReadByte(sp, &o) == 0) - return (0); - if (sp->subsamplingcorrect != 0) - { - if (q == 0) - { - sp->subsampling_hor = (o >> 4); - sp->subsampling_ver = (o & 15); - if (((sp->subsampling_hor != 1) && (sp->subsampling_hor != 2) && - (sp->subsampling_hor != 4)) || - ((sp->subsampling_ver != 1) && (sp->subsampling_ver != 2) && - (sp->subsampling_ver != 4))) - sp->subsampling_force_desubsampling_inside_decompression = - 1; - } - else - { - if (o != 17) - sp->subsampling_force_desubsampling_inside_decompression = - 1; - } - } - else - { - sp->sof_hv[q] = o; - if (sp->subsampling_force_desubsampling_inside_decompression == 0) - { - if (q == 0) - { - if (o != ((sp->subsampling_hor << 4) | sp->subsampling_ver)) - { - TIFFErrorExtR(tif, module, - "JPEG compressed data indicates " - "unexpected subsampling values"); - return (0); - } - } - else - { - if (o != 17) - { - TIFFErrorExtR(tif, module, - "JPEG compressed data indicates " - "unexpected subsampling values"); - return (0); - } - } - } - } - /* Tq: Quantization table destination selector */ - if (OJPEGReadByte(sp, &o) == 0) - return (0); - if (sp->subsamplingcorrect == 0) - sp->sof_tq[q] = o; - } - if (sp->subsamplingcorrect == 0) - sp->sof_log = 1; - return (1); -} - -static int 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_t m; - uint8_t n; - uint8_t o; - assert(sp->subsamplingcorrect == 0); - if (sp->sof_log == 0) - { - TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data"); - return (0); - } - /* Ls */ - if (OJPEGReadWord(sp, &m) == 0) - return (0); - if (m != 6 + sp->samples_per_pixel_per_plane * 2) - { - TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data"); - return (0); - } - /* Ns */ - if (OJPEGReadByte(sp, &n) == 0) - return (0); - if (n != sp->samples_per_pixel_per_plane) - { - TIFFErrorExtR(tif, module, "Corrupt SOS marker in JPEG data"); - return (0); - } - /* Cs, Td, and Ta */ - for (o = 0; o < sp->samples_per_pixel_per_plane; o++) - { - /* Cs */ - if (OJPEGReadByte(sp, &n) == 0) - return (0); - sp->sos_cs[sp->plane_sample_offset + o] = n; - /* Td and Ta */ - if (OJPEGReadByte(sp, &n) == 0) - return (0); - sp->sos_tda[sp->plane_sample_offset + o] = n; - } - /* skip Ss, Se, Ah, en Al -> no check, as per Tom Lane recommendation, as - * per LibJpeg source */ - OJPEGReadSkip(sp, 3); - return (1); -} - -static int OJPEGReadHeaderInfoSecTablesQTable(TIFF *tif) -{ - static const char module[] = "OJPEGReadHeaderInfoSecTablesQTable"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - uint8_t m; - uint8_t n; - uint32_t oa; - uint8_t *ob; - uint32_t p; - if (sp->qtable_offset[0] == 0) - { - TIFFErrorExtR(tif, module, "Missing JPEG tables"); - return (0); - } - sp->in_buffer_file_pos_log = 0; - for (m = 0; m < sp->samples_per_pixel; m++) - { - if ((sp->qtable_offset[m] != 0) && - ((m == 0) || (sp->qtable_offset[m] != sp->qtable_offset[m - 1]))) - { - for (n = 0; n < m - 1; n++) - { - if (sp->qtable_offset[m] == sp->qtable_offset[n]) - { - TIFFErrorExtR(tif, module, "Corrupt JpegQTables tag value"); - return (0); - } - } - oa = sizeof(uint32_t) + 69; - ob = _TIFFmallocExt(tif, oa); - if (ob == 0) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - *(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_t)TIFFReadFile(tif, &ob[sizeof(uint32_t) + 5], 64); - if (p != 64) - { - _TIFFfreeExt(tif, ob); - return (0); - } - if (sp->qtable[m] != 0) - _TIFFfreeExt(tif, sp->qtable[m]); - sp->qtable[m] = ob; - sp->sof_tq[m] = m; - } - else - sp->sof_tq[m] = sp->sof_tq[m - 1]; - } - return (1); -} - -static int OJPEGReadHeaderInfoSecTablesDcTable(TIFF *tif) -{ - static const char module[] = "OJPEGReadHeaderInfoSecTablesDcTable"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - 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) - { - TIFFErrorExtR(tif, module, "Missing JPEG tables"); - return (0); - } - sp->in_buffer_file_pos_log = 0; - for (m = 0; m < sp->samples_per_pixel; m++) - { - if ((sp->dctable_offset[m] != 0) && - ((m == 0) || (sp->dctable_offset[m] != sp->dctable_offset[m - 1]))) - { - for (n = 0; n < m - 1; n++) - { - if (sp->dctable_offset[m] == sp->dctable_offset[n]) - { - TIFFErrorExtR(tif, module, - "Corrupt JpegDcTables tag value"); - return (0); - } - } - TIFFSeekFile(tif, sp->dctable_offset[m], SEEK_SET); - 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_t) + 21 + q; - rb = _TIFFmallocExt(tif, ra); - if (rb == 0) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - *(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_t) + 5 + n] = o[n]; - p = (uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q); - if (p != q) - { - _TIFFfreeExt(tif, rb); - return (0); - } - if (sp->dctable[m] != 0) - _TIFFfreeExt(tif, sp->dctable[m]); - sp->dctable[m] = rb; - sp->sos_tda[m] = (m << 4); - } - else - sp->sos_tda[m] = sp->sos_tda[m - 1]; - } - return (1); -} - -static int OJPEGReadHeaderInfoSecTablesAcTable(TIFF *tif) -{ - static const char module[] = "OJPEGReadHeaderInfoSecTablesAcTable"; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - 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) - { - TIFFErrorExtR(tif, module, "Missing JPEG tables"); - return (0); - } - sp->in_buffer_file_pos_log = 0; - for (m = 0; m < sp->samples_per_pixel; m++) - { - if ((sp->actable_offset[m] != 0) && - ((m == 0) || (sp->actable_offset[m] != sp->actable_offset[m - 1]))) - { - for (n = 0; n < m - 1; n++) - { - if (sp->actable_offset[m] == sp->actable_offset[n]) - { - TIFFErrorExtR(tif, module, - "Corrupt JpegAcTables tag value"); - return (0); - } - } - TIFFSeekFile(tif, sp->actable_offset[m], SEEK_SET); - 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_t) + 21 + q; - rb = _TIFFmallocExt(tif, ra); - if (rb == 0) - { - TIFFErrorExtR(tif, module, "Out of memory"); - return (0); - } - *(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_t) + 5 + n] = o[n]; - p = (uint32_t)TIFFReadFile(tif, &(rb[sizeof(uint32_t) + 21]), q); - if (p != q) - { - _TIFFfreeExt(tif, rb); - return (0); - } - if (sp->actable[m] != 0) - _TIFFfreeExt(tif, sp->actable[m]); - sp->actable[m] = rb; - sp->sos_tda[m] = (sp->sos_tda[m] | m); - } - else - sp->sos_tda[m] = (sp->sos_tda[m] | (sp->sos_tda[m - 1] & 15)); - } - return (1); -} - -static int OJPEGReadBufferFill(OJPEGState *sp) -{ - 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 */ - do - { - if (sp->in_buffer_file_togo != 0) - { - if (sp->in_buffer_file_pos_log == 0) - { - TIFFSeekFile(sp->tif, sp->in_buffer_file_pos, SEEK_SET); - sp->in_buffer_file_pos_log = 1; - } - m = OJPEG_BUFFER; - 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_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; - sp->in_buffer_file_pos += m; - break; - } - sp->in_buffer_file_pos_log = 0; - switch (sp->in_buffer_source) - { - case osibsNotSetYet: - if (sp->jpeg_interchange_format != 0) - { - sp->in_buffer_file_pos = sp->jpeg_interchange_format; - sp->in_buffer_file_togo = - sp->jpeg_interchange_format_length; - } - sp->in_buffer_source = osibsJpegInterchangeFormat; - break; - case osibsJpegInterchangeFormat: - sp->in_buffer_source = osibsStrile; - break; - case osibsStrile: - if (sp->in_buffer_next_strile == sp->in_buffer_strile_count) - sp->in_buffer_source = osibsEof; - else - { - int err = 0; - sp->in_buffer_file_pos = TIFFGetStrileOffsetWithErr( - sp->tif, sp->in_buffer_next_strile, &err); - if (err) - return 0; - if (sp->in_buffer_file_pos != 0) - { - 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) - sp->in_buffer_file_pos = 0; - else if (bytecount == 0) - sp->in_buffer_file_togo = - sp->file_size - sp->in_buffer_file_pos; - else - { - 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 > - 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; - } - } - sp->in_buffer_next_strile++; - } - break; - default: - return (0); - } - } while (1); - return (1); -} - -static int OJPEGReadByte(OJPEGState *sp, uint8_t *byte) -{ - if (sp->in_buffer_togo == 0) - { - if (OJPEGReadBufferFill(sp) == 0) - return (0); - assert(sp->in_buffer_togo > 0); - } - *byte = *(sp->in_buffer_cur); - sp->in_buffer_cur++; - sp->in_buffer_togo--; - return (1); -} - -static int OJPEGReadBytePeek(OJPEGState *sp, uint8_t *byte) -{ - if (sp->in_buffer_togo == 0) - { - if (OJPEGReadBufferFill(sp) == 0) - return (0); - assert(sp->in_buffer_togo > 0); - } - *byte = *(sp->in_buffer_cur); - return (1); -} - -static void OJPEGReadByteAdvance(OJPEGState *sp) -{ - assert(sp->in_buffer_togo > 0); - sp->in_buffer_cur++; - sp->in_buffer_togo--; -} - -static int OJPEGReadWord(OJPEGState *sp, uint16_t *word) -{ - uint8_t m; - if (OJPEGReadByte(sp, &m) == 0) - return (0); - *word = (m << 8); - if (OJPEGReadByte(sp, &m) == 0) - return (0); - *word |= m; - return (1); -} - -static int OJPEGReadBlock(OJPEGState *sp, uint16_t len, void *mem) -{ - uint16_t mlen; - uint8_t *mmem; - uint16_t n; - assert(len > 0); - mlen = len; - mmem = mem; - do - { - if (sp->in_buffer_togo == 0) - { - if (OJPEGReadBufferFill(sp) == 0) - return (0); - assert(sp->in_buffer_togo > 0); - } - n = mlen; - if (n > sp->in_buffer_togo) - n = sp->in_buffer_togo; - _TIFFmemcpy(mmem, sp->in_buffer_cur, n); - sp->in_buffer_cur += n; - sp->in_buffer_togo -= n; - mlen -= n; - mmem += n; - } while (mlen > 0); - return (1); -} - -static void OJPEGReadSkip(OJPEGState *sp, uint16_t len) -{ - uint16_t m; - uint16_t n; - m = len; - n = m; - if (n > sp->in_buffer_togo) - n = sp->in_buffer_togo; - sp->in_buffer_cur += n; - sp->in_buffer_togo -= n; - m -= n; - if (m > 0) - { - assert(sp->in_buffer_togo == 0); - n = m; - 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; - /* we don't skip past jpeginterchangeformat/strile block... - * if that is asked from us, we're dealing with totally bazurk - * data anyway, and we've not seen this happening on any - * testfile, so we might as well likely cause some other - * meaningless error to be passed at some later time - */ - } -} - -static int OJPEGWriteStream(TIFF *tif, void **mem, uint32_t *len) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - *len = 0; - do - { - assert(sp->out_state <= ososEoi); - switch (sp->out_state) - { - case ososSoi: - OJPEGWriteStreamSoi(tif, mem, len); - break; - case ososQTable0: - OJPEGWriteStreamQTable(tif, 0, mem, len); - break; - case ososQTable1: - OJPEGWriteStreamQTable(tif, 1, mem, len); - break; - case ososQTable2: - OJPEGWriteStreamQTable(tif, 2, mem, len); - break; - case ososQTable3: - OJPEGWriteStreamQTable(tif, 3, mem, len); - break; - case ososDcTable0: - OJPEGWriteStreamDcTable(tif, 0, mem, len); - break; - case ososDcTable1: - OJPEGWriteStreamDcTable(tif, 1, mem, len); - break; - case ososDcTable2: - OJPEGWriteStreamDcTable(tif, 2, mem, len); - break; - case ososDcTable3: - OJPEGWriteStreamDcTable(tif, 3, mem, len); - break; - case ososAcTable0: - OJPEGWriteStreamAcTable(tif, 0, mem, len); - break; - case ososAcTable1: - OJPEGWriteStreamAcTable(tif, 1, mem, len); - break; - case ososAcTable2: - OJPEGWriteStreamAcTable(tif, 2, mem, len); - break; - case ososAcTable3: - OJPEGWriteStreamAcTable(tif, 3, mem, len); - break; - case ososDri: - OJPEGWriteStreamDri(tif, mem, len); - break; - case ososSof: - OJPEGWriteStreamSof(tif, mem, len); - break; - case ososSos: - OJPEGWriteStreamSos(tif, mem, len); - break; - case ososCompressed: - if (OJPEGWriteStreamCompressed(tif, mem, len) == 0) - return (0); - break; - case ososRst: - OJPEGWriteStreamRst(tif, mem, len); - break; - case ososEoi: - OJPEGWriteStreamEoi(tif, mem, len); - break; - } - } while (*len == 0); - return (1); -} - -static void OJPEGWriteStreamSoi(TIFF *tif, void **mem, uint32_t *len) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - assert(OJPEG_BUFFER >= 2); - sp->out_buffer[0] = 255; - sp->out_buffer[1] = JPEG_MARKER_SOI; - *len = 2; - *mem = (void *)sp->out_buffer; - sp->out_state++; -} - -static void 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_t)); - *len = *((uint32_t *)sp->qtable[table_index]) - sizeof(uint32_t); - } - sp->out_state++; -} - -static void 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_t)); - *len = *((uint32_t *)sp->dctable[table_index]) - sizeof(uint32_t); - } - sp->out_state++; -} - -static void 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_t)); - *len = *((uint32_t *)sp->actable[table_index]) - sizeof(uint32_t); - } - sp->out_state++; -} - -static void OJPEGWriteStreamDri(TIFF *tif, void **mem, uint32_t *len) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - assert(OJPEG_BUFFER >= 6); - if (sp->restart_interval != 0) - { - sp->out_buffer[0] = 255; - sp->out_buffer[1] = JPEG_MARKER_DRI; - sp->out_buffer[2] = 0; - sp->out_buffer[3] = 4; - sp->out_buffer[4] = (sp->restart_interval >> 8); - sp->out_buffer[5] = (sp->restart_interval & 255); - *len = 6; - *mem = (void *)sp->out_buffer; - } - sp->out_state++; -} - -static void OJPEGWriteStreamSof(TIFF *tif, void **mem, uint32_t *len) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - 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; - sp->out_buffer[1] = sp->sof_marker_id; - /* Lf */ - sp->out_buffer[2] = 0; - sp->out_buffer[3] = 8 + sp->samples_per_pixel_per_plane * 3; - /* P */ - sp->out_buffer[4] = 8; - /* Y */ - sp->out_buffer[5] = (uint8_t)(sp->sof_y >> 8); - sp->out_buffer[6] = (sp->sof_y & 255); - /* X */ - 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; - for (m = 0; m < sp->samples_per_pixel_per_plane; m++) - { - /* C */ - sp->out_buffer[10 + m * 3] = sp->sof_c[sp->plane_sample_offset + m]; - /* H and V */ - sp->out_buffer[10 + m * 3 + 1] = - sp->sof_hv[sp->plane_sample_offset + m]; - /* Tq */ - sp->out_buffer[10 + m * 3 + 2] = - sp->sof_tq[sp->plane_sample_offset + m]; - } - *len = 10 + sp->samples_per_pixel_per_plane * 3; - *mem = (void *)sp->out_buffer; - sp->out_state++; -} - -static void OJPEGWriteStreamSos(TIFF *tif, void **mem, uint32_t *len) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - 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; - sp->out_buffer[1] = JPEG_MARKER_SOS; - /* Ls */ - sp->out_buffer[2] = 0; - sp->out_buffer[3] = 6 + sp->samples_per_pixel_per_plane * 2; - /* Ns */ - sp->out_buffer[4] = sp->samples_per_pixel_per_plane; - for (m = 0; m < sp->samples_per_pixel_per_plane; m++) - { - /* Cs */ - sp->out_buffer[5 + m * 2] = sp->sos_cs[sp->plane_sample_offset + m]; - /* Td and Ta */ - sp->out_buffer[5 + m * 2 + 1] = - sp->sos_tda[sp->plane_sample_offset + m]; - } - /* Ss */ - sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2] = 0; - /* Se */ - sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2 + 1] = 63; - /* Ah and Al */ - sp->out_buffer[5 + sp->samples_per_pixel_per_plane * 2 + 2] = 0; - *len = 8 + sp->samples_per_pixel_per_plane * 2; - *mem = (void *)sp->out_buffer; - sp->out_state++; -} - -static int OJPEGWriteStreamCompressed(TIFF *tif, void **mem, uint32_t *len) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - if (sp->in_buffer_togo == 0) - { - if (OJPEGReadBufferFill(sp) == 0) - return (0); - assert(sp->in_buffer_togo > 0); - } - *len = sp->in_buffer_togo; - *mem = (void *)sp->in_buffer_cur; - sp->in_buffer_togo = 0; - if (sp->in_buffer_file_togo == 0) - { - switch (sp->in_buffer_source) - { - case osibsStrile: - if (sp->in_buffer_next_strile < sp->in_buffer_strile_count) - sp->out_state = ososRst; - else - sp->out_state = ososEoi; - break; - case osibsEof: - sp->out_state = ososEoi; - break; - default: - break; - } - } - return (1); -} - -static void OJPEGWriteStreamRst(TIFF *tif, void **mem, uint32_t *len) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - assert(OJPEG_BUFFER >= 2); - sp->out_buffer[0] = 255; - sp->out_buffer[1] = JPEG_MARKER_RST0 + sp->restart_index; - sp->restart_index++; - if (sp->restart_index == 8) - sp->restart_index = 0; - *len = 2; - *mem = (void *)sp->out_buffer; - sp->out_state = ososCompressed; -} - -static void OJPEGWriteStreamEoi(TIFF *tif, void **mem, uint32_t *len) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - assert(OJPEG_BUFFER >= 2); - sp->out_buffer[0] = 255; - sp->out_buffer[1] = JPEG_MARKER_EOI; - *len = 2; - *mem = (void *)sp->out_buffer; -} - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int jpeg_create_decompress_encap(OJPEGState *sp, - jpeg_decompress_struct *cinfo) -{ - if (SETJMP(sp->exit_jmpbuf)) - return 0; - else - { - jpeg_create_decompress(cinfo); - return 1; - } -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int jpeg_read_header_encap(OJPEGState *sp, jpeg_decompress_struct *cinfo, - uint8_t require_image) -{ - if (SETJMP(sp->exit_jmpbuf)) - return 0; - else - { - jpeg_read_header(cinfo, require_image); - return 1; - } -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int jpeg_start_decompress_encap(OJPEGState *sp, - jpeg_decompress_struct *cinfo) -{ - if (SETJMP(sp->exit_jmpbuf)) - return 0; - else - { - jpeg_start_decompress(cinfo); - return 1; - } -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int jpeg_read_scanlines_encap(OJPEGState *sp, - jpeg_decompress_struct *cinfo, - void *scanlines, uint32_t max_lines) -{ - if (SETJMP(sp->exit_jmpbuf)) - return 0; - else - { - jpeg_read_scanlines(cinfo, scanlines, max_lines); - return 1; - } -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static int jpeg_read_raw_data_encap(OJPEGState *sp, - jpeg_decompress_struct *cinfo, void *data, - uint32_t max_lines) -{ - if (SETJMP(sp->exit_jmpbuf)) - return 0; - else - { - jpeg_read_raw_data(cinfo, data, max_lines); - return 1; - } -} -#endif - -#ifndef LIBJPEG_ENCAP_EXTERNAL -static void jpeg_encap_unwind(TIFF *tif) -{ - OJPEGState *sp = (OJPEGState *)tif->tif_data; - LONGJMP(sp->exit_jmpbuf, 1); -} -#endif - -static void OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct *cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, buffer); - TIFFWarningExtR(((TIFF *)(cinfo->client_data)), "LibJpeg", "%s", buffer); -} - -static void OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct *cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - (*cinfo->err->format_message)(cinfo, buffer); - TIFFErrorExtR(((TIFF *)(cinfo->client_data)), "LibJpeg", "%s", buffer); - jpeg_encap_unwind((TIFF *)(cinfo->client_data)); -} - -static void OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct *cinfo) -{ - (void)cinfo; -} - -static boolean -OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct *cinfo) -{ - TIFF *tif = (TIFF *)cinfo->client_data; - OJPEGState *sp = (OJPEGState *)tif->tif_data; - void *mem = 0; - uint32_t len = 0U; - if (OJPEGWriteStream(tif, &mem, &len) == 0) - { - TIFFErrorExtR(tif, "LibJpeg", "Premature end of JPEG data"); - jpeg_encap_unwind(tif); - } - sp->libjpeg_jpeg_source_mgr.bytes_in_buffer = len; - sp->libjpeg_jpeg_source_mgr.next_input_byte = mem; - return (1); + sp->writeheader_done=1; + return(1); } static void -OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct *cinfo, - long num_bytes) +OJPEGLibjpegSessionAbort(TIFF* tif) { - TIFF *tif = (TIFF *)cinfo->client_data; - (void)num_bytes; - TIFFErrorExtR(tif, "LibJpeg", "Unexpected error"); - jpeg_encap_unwind(tif); + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(sp->libjpeg_session_active!=0); + jpeg_destroy((jpeg_common_struct*)(&(sp->libjpeg_jpeg_decompress_struct))); + sp->libjpeg_session_active=0; +} + +static int +OJPEGReadHeaderInfoSec(TIFF* tif) +{ + static const char module[]="OJPEGReadHeaderInfoSec"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + uint16 n; + uint8 o; + if (sp->file_size==0) + sp->file_size=TIFFGetFileSize(tif); + if (sp->jpeg_interchange_format!=0) + { + if (sp->jpeg_interchange_format>=sp->file_size) + { + sp->jpeg_interchange_format=0; + sp->jpeg_interchange_format_length=0; + } + else + { + if ((sp->jpeg_interchange_format_length==0) || + (sp->jpeg_interchange_format > TIFF_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; + } + } + sp->in_buffer_source=osibsNotSetYet; + sp->in_buffer_next_strile=0; + sp->in_buffer_strile_count=tif->tif_dir.td_nstrips; + sp->in_buffer_file_togo=0; + sp->in_buffer_togo=0; + do + { + if (OJPEGReadBytePeek(sp,&m)==0) + return(0); + if (m!=255) + break; + OJPEGReadByteAdvance(sp); + do + { + if (OJPEGReadByte(sp,&m)==0) + return(0); + } while(m==255); + switch(m) + { + case JPEG_MARKER_SOI: + /* this type of marker has no data, and should be skipped */ + break; + case JPEG_MARKER_COM: + case JPEG_MARKER_APP0: + case JPEG_MARKER_APP0+1: + case JPEG_MARKER_APP0+2: + case JPEG_MARKER_APP0+3: + case JPEG_MARKER_APP0+4: + case JPEG_MARKER_APP0+5: + case JPEG_MARKER_APP0+6: + case JPEG_MARKER_APP0+7: + case JPEG_MARKER_APP0+8: + case JPEG_MARKER_APP0+9: + case JPEG_MARKER_APP0+10: + case JPEG_MARKER_APP0+11: + case JPEG_MARKER_APP0+12: + case JPEG_MARKER_APP0+13: + case JPEG_MARKER_APP0+14: + case JPEG_MARKER_APP0+15: + /* this type of marker has data, but it has no use to us (and no place here) and should be skipped */ + if (OJPEGReadWord(sp,&n)==0) + return(0); + if (n<2) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data"); + return(0); + } + if (n>2) + OJPEGReadSkip(sp,n-2); + break; + case JPEG_MARKER_DRI: + if (OJPEGReadHeaderInfoSecStreamDri(tif)==0) + return(0); + break; + case JPEG_MARKER_DQT: + if (OJPEGReadHeaderInfoSecStreamDqt(tif)==0) + return(0); + break; + case JPEG_MARKER_DHT: + if (OJPEGReadHeaderInfoSecStreamDht(tif)==0) + return(0); + break; + case JPEG_MARKER_SOF0: + case JPEG_MARKER_SOF1: + case JPEG_MARKER_SOF3: + if (OJPEGReadHeaderInfoSecStreamSof(tif,m)==0) + return(0); + if (sp->subsamplingcorrect!=0) + return(1); + break; + case JPEG_MARKER_SOS: + if (sp->subsamplingcorrect!=0) + return(1); + assert(sp->plane_sample_offset==0); + if (OJPEGReadHeaderInfoSecStreamSos(tif)==0) + return(0); + break; + default: + TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %d in JPEG data",m); + return(0); + } + } while(m!=JPEG_MARKER_SOS); + if (sp->subsamplingcorrect) + return(1); + if (sp->sof_log==0) + { + if (OJPEGReadHeaderInfoSecTablesQTable(tif)==0) + return(0); + sp->sof_marker_id=JPEG_MARKER_SOF0; + for (o=0; osamples_per_pixel; o++) + sp->sof_c[o]=o; + sp->sof_hv[0]=((sp->subsampling_hor<<4)|sp->subsampling_ver); + for (o=1; osamples_per_pixel; o++) + sp->sof_hv[o]=17; + sp->sof_x=sp->strile_width; + sp->sof_y=sp->strile_length_total; + sp->sof_log=1; + if (OJPEGReadHeaderInfoSecTablesDcTable(tif)==0) + return(0); + if (OJPEGReadHeaderInfoSecTablesAcTable(tif)==0) + return(0); + for (o=1; osamples_per_pixel; o++) + sp->sos_cs[o]=o; + } + return(1); +} + +static int +OJPEGReadHeaderInfoSecStreamDri(TIFF* tif) +{ + /* This could easily cause trouble in some cases... but no such cases have + occurred so far */ + static const char module[]="OJPEGReadHeaderInfoSecStreamDri"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint16 m; + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m!=4) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DRI marker in JPEG data"); + return(0); + } + if (OJPEGReadWord(sp,&m)==0) + return(0); + sp->restart_interval=m; + return(1); +} + +static int +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; + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m<=2) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); + return(0); + } + if (sp->subsamplingcorrect!=0) + OJPEGReadSkip(sp,m-2); + else + { + m-=2; + do + { + if (m<65) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data"); + return(0); + } + na=sizeof(uint32)+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) { + _TIFFfree(nb); + return(0); + } + o=nb[sizeof(uint32)+4]&15; + if (3tif_clientdata,module,"Corrupt DQT marker in JPEG data"); + _TIFFfree(nb); + return(0); + } + if (sp->qtable[o]!=0) + _TIFFfree(sp->qtable[o]); + sp->qtable[o]=nb; + m-=65; + } while(m>0); + } + return(1); +} + +static int +OJPEGReadHeaderInfoSecStreamDht(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 */ + /* 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; + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m<=2) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data"); + return(0); + } + if (sp->subsamplingcorrect!=0) + { + OJPEGReadSkip(sp,m-2); + } + else + { + na=sizeof(uint32)+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) { + _TIFFfree(nb); + return(0); + } + o=nb[sizeof(uint32)+4]; + if ((o&240)==0) + { + if (3tif_clientdata,module,"Corrupt DHT marker in JPEG data"); + _TIFFfree(nb); + return(0); + } + if (sp->dctable[o]!=0) + _TIFFfree(sp->dctable[o]); + sp->dctable[o]=nb; + } + else + { + if ((o&240)!=16) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data"); + _TIFFfree(nb); + return(0); + } + o&=15; + if (3tif_clientdata,module,"Corrupt DHT marker in JPEG data"); + _TIFFfree(nb); + return(0); + } + if (sp->actable[o]!=0) + _TIFFfree(sp->actable[o]); + sp->actable[o]=nb; + } + } + return(1); +} + +static int +OJPEGReadHeaderInfoSecStreamSof(TIFF* tif, uint8 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; + if (sp->sof_log!=0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JPEG data"); + return(0); + } + if (sp->subsamplingcorrect==0) + sp->sof_marker_id=marker_id; + /* Lf: data length */ + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m<11) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data"); + return(0); + } + m-=8; + if (m%3!=0) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data"); + return(0); + } + n=m/3; + if (sp->subsamplingcorrect==0) + { + if (n!=sp->samples_per_pixel) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected number of samples"); + return(0); + } + } + /* P: Sample precision */ + if (OJPEGReadByte(sp,&o)==0) + return(0); + if (o!=8) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected number of bits per sample"); + return(0); + } + /* Y: Number of lines, X: Number of samples per line */ + if (sp->subsamplingcorrect) + OJPEGReadSkip(sp,4); + else + { + /* Y: Number of lines */ + if (OJPEGReadWord(sp,&p)==0) + return(0); + if (((uint32)pimage_length) && ((uint32)pstrile_length_total)) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected height"); + return(0); + } + sp->sof_y=p; + /* X: Number of samples per line */ + if (OJPEGReadWord(sp,&p)==0) + return(0); + if (((uint32)pimage_width) && ((uint32)pstrile_width)) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected width"); + return(0); + } + if ((uint32)p>sp->strile_width) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data image width exceeds expected image width"); + return(0); + } + sp->sof_x=p; + } + /* Nf: Number of image components in frame */ + if (OJPEGReadByte(sp,&o)==0) + return(0); + if (o!=n) + { + if (sp->subsamplingcorrect==0) + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOF marker in JPEG data"); + return(0); + } + /* per component stuff */ + /* TODO: double-check that flow implies that n cannot be as big as to make us overflow sof_c, sof_hv and sof_tq arrays */ + for (q=0; qsubsamplingcorrect==0) + sp->sof_c[q]=o; + /* H: Horizontal sampling factor, and V: Vertical sampling factor */ + if (OJPEGReadByte(sp,&o)==0) + return(0); + if (sp->subsamplingcorrect!=0) + { + if (q==0) + { + sp->subsampling_hor=(o>>4); + sp->subsampling_ver=(o&15); + if (((sp->subsampling_hor!=1) && (sp->subsampling_hor!=2) && (sp->subsampling_hor!=4)) || + ((sp->subsampling_ver!=1) && (sp->subsampling_ver!=2) && (sp->subsampling_ver!=4))) + sp->subsampling_force_desubsampling_inside_decompression=1; + } + else + { + if (o!=17) + sp->subsampling_force_desubsampling_inside_decompression=1; + } + } + else + { + sp->sof_hv[q]=o; + if (sp->subsampling_force_desubsampling_inside_decompression==0) + { + if (q==0) + { + if (o!=((sp->subsampling_hor<<4)|sp->subsampling_ver)) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected subsampling values"); + return(0); + } + } + else + { + if (o!=17) + { + TIFFErrorExt(tif->tif_clientdata,module,"JPEG compressed data indicates unexpected subsampling values"); + return(0); + } + } + } + } + /* Tq: Quantization table destination selector */ + if (OJPEGReadByte(sp,&o)==0) + return(0); + if (sp->subsamplingcorrect==0) + sp->sof_tq[q]=o; + } + if (sp->subsamplingcorrect==0) + sp->sof_log=1; + return(1); +} + +static int +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; + assert(sp->subsamplingcorrect==0); + if (sp->sof_log==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data"); + return(0); + } + /* Ls */ + if (OJPEGReadWord(sp,&m)==0) + return(0); + if (m!=6+sp->samples_per_pixel_per_plane*2) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data"); + return(0); + } + /* Ns */ + if (OJPEGReadByte(sp,&n)==0) + return(0); + if (n!=sp->samples_per_pixel_per_plane) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt SOS marker in JPEG data"); + return(0); + } + /* Cs, Td, and Ta */ + for (o=0; osamples_per_pixel_per_plane; o++) + { + /* Cs */ + if (OJPEGReadByte(sp,&n)==0) + return(0); + sp->sos_cs[sp->plane_sample_offset+o]=n; + /* Td and Ta */ + if (OJPEGReadByte(sp,&n)==0) + return(0); + sp->sos_tda[sp->plane_sample_offset+o]=n; + } + /* skip Ss, Se, Ah, en Al -> no check, as per Tom Lane recommendation, as per LibJpeg source */ + OJPEGReadSkip(sp,3); + return(1); +} + +static int +OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif) +{ + static const char module[]="OJPEGReadHeaderInfoSecTablesQTable"; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 m; + uint8 n; + uint32 oa; + uint8* ob; + uint32 p; + if (sp->qtable_offset[0]==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); + return(0); + } + sp->in_buffer_file_pos_log=0; + for (m=0; msamples_per_pixel; m++) + { + if ((sp->qtable_offset[m]!=0) && ((m==0) || (sp->qtable_offset[m]!=sp->qtable_offset[m-1]))) + { + for (n=0; nqtable_offset[m]==sp->qtable_offset[n]) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegQTables tag value"); + return(0); + } + } + oa=sizeof(uint32)+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; + TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET); + p=(uint32)TIFFReadFile(tif,&ob[sizeof(uint32)+5],64); + if (p!=64) + { + _TIFFfree(ob); + return(0); + } + if (sp->qtable[m]!=0) + _TIFFfree(sp->qtable[m]); + sp->qtable[m]=ob; + sp->sof_tq[m]=m; + } + else + sp->sof_tq[m]=sp->sof_tq[m-1]; + } + return(1); +} + +static int +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; + if (sp->dctable_offset[0]==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); + return(0); + } + sp->in_buffer_file_pos_log=0; + for (m=0; msamples_per_pixel; m++) + { + if ((sp->dctable_offset[m]!=0) && ((m==0) || (sp->dctable_offset[m]!=sp->dctable_offset[m-1]))) + { + for (n=0; ndctable_offset[m]==sp->dctable_offset[n]) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegDcTables tag value"); + return(0); + } + } + TIFFSeekFile(tif,sp->dctable_offset[m],SEEK_SET); + p=(uint32)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; + 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; + for (n=0; n<16; n++) + rb[sizeof(uint32)+5+n]=o[n]; + p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); + if (p!=q) + { + _TIFFfree(rb); + return(0); + } + if (sp->dctable[m]!=0) + _TIFFfree(sp->dctable[m]); + sp->dctable[m]=rb; + sp->sos_tda[m]=(m<<4); + } + else + sp->sos_tda[m]=sp->sos_tda[m-1]; + } + return(1); +} + +static int +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; + if (sp->actable_offset[0]==0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables"); + return(0); + } + sp->in_buffer_file_pos_log=0; + for (m=0; msamples_per_pixel; m++) + { + if ((sp->actable_offset[m]!=0) && ((m==0) || (sp->actable_offset[m]!=sp->actable_offset[m-1]))) + { + for (n=0; nactable_offset[m]==sp->actable_offset[n]) + { + TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegAcTables tag value"); + return(0); + } + } + TIFFSeekFile(tif,sp->actable_offset[m],SEEK_SET); + p=(uint32)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; + 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); + for (n=0; n<16; n++) + rb[sizeof(uint32)+5+n]=o[n]; + p=(uint32)TIFFReadFile(tif,&(rb[sizeof(uint32)+21]),q); + if (p!=q) + { + _TIFFfree(rb); + return(0); + } + if (sp->actable[m]!=0) + _TIFFfree(sp->actable[m]); + sp->actable[m]=rb; + sp->sos_tda[m]=(sp->sos_tda[m]|m); + } + else + sp->sos_tda[m]=(sp->sos_tda[m]|(sp->sos_tda[m-1]&15)); + } + return(1); +} + +static int +OJPEGReadBufferFill(OJPEGState* sp) +{ + uint16 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 */ + do + { + if (sp->in_buffer_file_togo!=0) + { + if (sp->in_buffer_file_pos_log==0) + { + TIFFSeekFile(sp->tif,sp->in_buffer_file_pos,SEEK_SET); + 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; + 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; + sp->in_buffer_togo=m; + sp->in_buffer_cur=sp->in_buffer; + sp->in_buffer_file_togo-=m; + sp->in_buffer_file_pos+=m; + break; + } + sp->in_buffer_file_pos_log=0; + switch(sp->in_buffer_source) + { + case osibsNotSetYet: + if (sp->jpeg_interchange_format!=0) + { + sp->in_buffer_file_pos=sp->jpeg_interchange_format; + sp->in_buffer_file_togo=sp->jpeg_interchange_format_length; + } + sp->in_buffer_source=osibsJpegInterchangeFormat; + break; + case osibsJpegInterchangeFormat: + sp->in_buffer_source=osibsStrile; + break; + case osibsStrile: + if (sp->in_buffer_next_strile==sp->in_buffer_strile_count) + sp->in_buffer_source=osibsEof; + else + { + int err = 0; + sp->in_buffer_file_pos=TIFFGetStrileOffsetWithErr(sp->tif, sp->in_buffer_next_strile, &err); + if( err ) + return 0; + if (sp->in_buffer_file_pos!=0) + { + uint64 bytecount = TIFFGetStrileByteCountWithErr(sp->tif, sp->in_buffer_next_strile, &err); + if( err ) + return 0; + if (sp->in_buffer_file_pos>=sp->file_size) + sp->in_buffer_file_pos=0; + else if (bytecount==0) + sp->in_buffer_file_togo=sp->file_size-sp->in_buffer_file_pos; + else + { + 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 || + 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; + } + } + sp->in_buffer_next_strile++; + } + break; + default: + return(0); + } + } while (1); + return(1); +} + +static int +OJPEGReadByte(OJPEGState* sp, uint8* byte) +{ + if (sp->in_buffer_togo==0) + { + if (OJPEGReadBufferFill(sp)==0) + return(0); + assert(sp->in_buffer_togo>0); + } + *byte=*(sp->in_buffer_cur); + sp->in_buffer_cur++; + sp->in_buffer_togo--; + return(1); +} + +static int +OJPEGReadBytePeek(OJPEGState* sp, uint8* byte) +{ + if (sp->in_buffer_togo==0) + { + if (OJPEGReadBufferFill(sp)==0) + return(0); + assert(sp->in_buffer_togo>0); + } + *byte=*(sp->in_buffer_cur); + return(1); +} + +static void +OJPEGReadByteAdvance(OJPEGState* sp) +{ + assert(sp->in_buffer_togo>0); + sp->in_buffer_cur++; + sp->in_buffer_togo--; +} + +static int +OJPEGReadWord(OJPEGState* sp, uint16* word) +{ + uint8 m; + if (OJPEGReadByte(sp,&m)==0) + return(0); + *word=(m<<8); + if (OJPEGReadByte(sp,&m)==0) + return(0); + *word|=m; + return(1); +} + +static int +OJPEGReadBlock(OJPEGState* sp, uint16 len, void* mem) +{ + uint16 mlen; + uint8* mmem; + uint16 n; + assert(len>0); + mlen=len; + mmem=mem; + do + { + if (sp->in_buffer_togo==0) + { + if (OJPEGReadBufferFill(sp)==0) + return(0); + assert(sp->in_buffer_togo>0); + } + n=mlen; + if (n>sp->in_buffer_togo) + n=sp->in_buffer_togo; + _TIFFmemcpy(mmem,sp->in_buffer_cur,n); + sp->in_buffer_cur+=n; + sp->in_buffer_togo-=n; + mlen-=n; + mmem+=n; + } while(mlen>0); + return(1); +} + +static void +OJPEGReadSkip(OJPEGState* sp, uint16 len) +{ + uint16 m; + uint16 n; + m=len; + n=m; + if (n>sp->in_buffer_togo) + n=sp->in_buffer_togo; + sp->in_buffer_cur+=n; + sp->in_buffer_togo-=n; + m-=n; + if (m>0) + { + assert(sp->in_buffer_togo==0); + n=m; + if ((uint64)n>sp->in_buffer_file_togo) + n=(uint16)sp->in_buffer_file_togo; + sp->in_buffer_file_pos+=n; + sp->in_buffer_file_togo-=n; + sp->in_buffer_file_pos_log=0; + /* we don't skip past jpeginterchangeformat/strile block... + * if that is asked from us, we're dealing with totally bazurk + * data anyway, and we've not seen this happening on any + * testfile, so we might as well likely cause some other + * meaningless error to be passed at some later time + */ + } +} + +static int +OJPEGWriteStream(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + *len=0; + do + { + assert(sp->out_state<=ososEoi); + switch(sp->out_state) + { + case ososSoi: + OJPEGWriteStreamSoi(tif,mem,len); + break; + case ososQTable0: + OJPEGWriteStreamQTable(tif,0,mem,len); + break; + case ososQTable1: + OJPEGWriteStreamQTable(tif,1,mem,len); + break; + case ososQTable2: + OJPEGWriteStreamQTable(tif,2,mem,len); + break; + case ososQTable3: + OJPEGWriteStreamQTable(tif,3,mem,len); + break; + case ososDcTable0: + OJPEGWriteStreamDcTable(tif,0,mem,len); + break; + case ososDcTable1: + OJPEGWriteStreamDcTable(tif,1,mem,len); + break; + case ososDcTable2: + OJPEGWriteStreamDcTable(tif,2,mem,len); + break; + case ososDcTable3: + OJPEGWriteStreamDcTable(tif,3,mem,len); + break; + case ososAcTable0: + OJPEGWriteStreamAcTable(tif,0,mem,len); + break; + case ososAcTable1: + OJPEGWriteStreamAcTable(tif,1,mem,len); + break; + case ososAcTable2: + OJPEGWriteStreamAcTable(tif,2,mem,len); + break; + case ososAcTable3: + OJPEGWriteStreamAcTable(tif,3,mem,len); + break; + case ososDri: + OJPEGWriteStreamDri(tif,mem,len); + break; + case ososSof: + OJPEGWriteStreamSof(tif,mem,len); + break; + case ososSos: + OJPEGWriteStreamSos(tif,mem,len); + break; + case ososCompressed: + if (OJPEGWriteStreamCompressed(tif,mem,len)==0) + return(0); + break; + case ososRst: + OJPEGWriteStreamRst(tif,mem,len); + break; + case ososEoi: + OJPEGWriteStreamEoi(tif,mem,len); + break; + } + } while (*len==0); + return(1); +} + +static void +OJPEGWriteStreamSoi(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(OJPEG_BUFFER>=2); + sp->out_buffer[0]=255; + sp->out_buffer[1]=JPEG_MARKER_SOI; + *len=2; + *mem=(void*)sp->out_buffer; + sp->out_state++; +} + +static void +OJPEGWriteStreamQTable(TIFF* tif, uint8 table_index, void** mem, uint32* 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); + } + sp->out_state++; +} + +static void +OJPEGWriteStreamDcTable(TIFF* tif, uint8 table_index, void** mem, uint32* 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); + } + sp->out_state++; +} + +static void +OJPEGWriteStreamAcTable(TIFF* tif, uint8 table_index, void** mem, uint32* 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); + } + sp->out_state++; +} + +static void +OJPEGWriteStreamDri(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(OJPEG_BUFFER>=6); + if (sp->restart_interval!=0) + { + sp->out_buffer[0]=255; + sp->out_buffer[1]=JPEG_MARKER_DRI; + sp->out_buffer[2]=0; + sp->out_buffer[3]=4; + sp->out_buffer[4]=(sp->restart_interval>>8); + sp->out_buffer[5]=(sp->restart_interval&255); + *len=6; + *mem=(void*)sp->out_buffer; + } + sp->out_state++; +} + +static void +OJPEGWriteStreamSof(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 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; + sp->out_buffer[1]=sp->sof_marker_id; + /* Lf */ + sp->out_buffer[2]=0; + sp->out_buffer[3]=8+sp->samples_per_pixel_per_plane*3; + /* P */ + sp->out_buffer[4]=8; + /* Y */ + sp->out_buffer[5]=(uint8)(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[8]=(sp->sof_x&255); + /* Nf */ + sp->out_buffer[9]=sp->samples_per_pixel_per_plane; + for (m=0; msamples_per_pixel_per_plane; m++) + { + /* C */ + sp->out_buffer[10+m*3]=sp->sof_c[sp->plane_sample_offset+m]; + /* H and V */ + sp->out_buffer[10+m*3+1]=sp->sof_hv[sp->plane_sample_offset+m]; + /* Tq */ + sp->out_buffer[10+m*3+2]=sp->sof_tq[sp->plane_sample_offset+m]; + } + *len=10+sp->samples_per_pixel_per_plane*3; + *mem=(void*)sp->out_buffer; + sp->out_state++; +} + +static void +OJPEGWriteStreamSos(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + uint8 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; + sp->out_buffer[1]=JPEG_MARKER_SOS; + /* Ls */ + sp->out_buffer[2]=0; + sp->out_buffer[3]=6+sp->samples_per_pixel_per_plane*2; + /* Ns */ + sp->out_buffer[4]=sp->samples_per_pixel_per_plane; + for (m=0; msamples_per_pixel_per_plane; m++) + { + /* Cs */ + sp->out_buffer[5+m*2]=sp->sos_cs[sp->plane_sample_offset+m]; + /* Td and Ta */ + sp->out_buffer[5+m*2+1]=sp->sos_tda[sp->plane_sample_offset+m]; + } + /* Ss */ + sp->out_buffer[5+sp->samples_per_pixel_per_plane*2]=0; + /* Se */ + sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+1]=63; + /* Ah and Al */ + sp->out_buffer[5+sp->samples_per_pixel_per_plane*2+2]=0; + *len=8+sp->samples_per_pixel_per_plane*2; + *mem=(void*)sp->out_buffer; + sp->out_state++; +} + +static int +OJPEGWriteStreamCompressed(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + if (sp->in_buffer_togo==0) + { + if (OJPEGReadBufferFill(sp)==0) + return(0); + assert(sp->in_buffer_togo>0); + } + *len=sp->in_buffer_togo; + *mem=(void*)sp->in_buffer_cur; + sp->in_buffer_togo=0; + if (sp->in_buffer_file_togo==0) + { + switch(sp->in_buffer_source) + { + case osibsStrile: + if (sp->in_buffer_next_strilein_buffer_strile_count) + sp->out_state=ososRst; + else + sp->out_state=ososEoi; + break; + case osibsEof: + sp->out_state=ososEoi; + break; + default: + break; + } + } + return(1); +} + +static void +OJPEGWriteStreamRst(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(OJPEG_BUFFER>=2); + sp->out_buffer[0]=255; + sp->out_buffer[1]=JPEG_MARKER_RST0+sp->restart_index; + sp->restart_index++; + if (sp->restart_index==8) + sp->restart_index=0; + *len=2; + *mem=(void*)sp->out_buffer; + sp->out_state=ososCompressed; +} + +static void +OJPEGWriteStreamEoi(TIFF* tif, void** mem, uint32* len) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + assert(OJPEG_BUFFER>=2); + sp->out_buffer[0]=255; + sp->out_buffer[1]=JPEG_MARKER_EOI; + *len=2; + *mem=(void*)sp->out_buffer; +} + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_create_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) +{ + if( SETJMP(sp->exit_jmpbuf) ) + return 0; + else { + jpeg_create_decompress(cinfo); + return 1; + } +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_read_header_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, uint8 require_image) +{ + if( SETJMP(sp->exit_jmpbuf) ) + return 0; + else { + jpeg_read_header(cinfo,require_image); + return 1; + } +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_start_decompress_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo) +{ + if( SETJMP(sp->exit_jmpbuf) ) + return 0; + else { + jpeg_start_decompress(cinfo); + return 1; + } +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_read_scanlines_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* scanlines, uint32 max_lines) +{ + if( SETJMP(sp->exit_jmpbuf) ) + return 0; + else { + jpeg_read_scanlines(cinfo,scanlines,max_lines); + return 1; + } +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static int +jpeg_read_raw_data_encap(OJPEGState* sp, jpeg_decompress_struct* cinfo, void* data, uint32 max_lines) +{ + if( SETJMP(sp->exit_jmpbuf) ) + return 0; + else { + jpeg_read_raw_data(cinfo,data,max_lines); + return 1; + } +} +#endif + +#ifndef LIBJPEG_ENCAP_EXTERNAL +static void +jpeg_encap_unwind(TIFF* tif) +{ + OJPEGState* sp=(OJPEGState*)tif->tif_data; + LONGJMP(sp->exit_jmpbuf,1); +} +#endif + +static void +OJPEGLibjpegJpegErrorMgrOutputMessage(jpeg_common_struct* cinfo) +{ + char buffer[JMSG_LENGTH_MAX]; + (*cinfo->err->format_message)(cinfo,buffer); + TIFFWarningExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg","%s",buffer); +} + +static void +OJPEGLibjpegJpegErrorMgrErrorExit(jpeg_common_struct* cinfo) +{ + char buffer[JMSG_LENGTH_MAX]; + (*cinfo->err->format_message)(cinfo,buffer); + TIFFErrorExt(((TIFF*)(cinfo->client_data))->tif_clientdata,"LibJpeg","%s",buffer); + jpeg_encap_unwind((TIFF*)(cinfo->client_data)); +} + +static void +OJPEGLibjpegJpegSourceMgrInitSource(jpeg_decompress_struct* cinfo) +{ + (void)cinfo; +} + +static boolean +OJPEGLibjpegJpegSourceMgrFillInputBuffer(jpeg_decompress_struct* cinfo) +{ + TIFF* tif=(TIFF*)cinfo->client_data; + OJPEGState* sp=(OJPEGState*)tif->tif_data; + void* mem=0; + uint32 len=0U; + if (OJPEGWriteStream(tif,&mem,&len)==0) + { + TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Premature end of JPEG data"); + jpeg_encap_unwind(tif); + } + sp->libjpeg_jpeg_source_mgr.bytes_in_buffer=len; + sp->libjpeg_jpeg_source_mgr.next_input_byte=mem; + return(1); +} + +static void +OJPEGLibjpegJpegSourceMgrSkipInputData(jpeg_decompress_struct* cinfo, long num_bytes) +{ + TIFF* tif=(TIFF*)cinfo->client_data; + (void)num_bytes; + TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Unexpected error"); + jpeg_encap_unwind(tif); } #ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4702) /* unreachable code */ +#pragma warning( push ) +#pragma warning( disable : 4702 ) /* unreachable code */ #endif static boolean -OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct *cinfo, - int desired) +OJPEGLibjpegJpegSourceMgrResyncToRestart(jpeg_decompress_struct* cinfo, int desired) { - TIFF *tif = (TIFF *)cinfo->client_data; - (void)desired; - TIFFErrorExtR(tif, "LibJpeg", "Unexpected error"); - jpeg_encap_unwind(tif); - return (0); + TIFF* tif=(TIFF*)cinfo->client_data; + (void)desired; + TIFFErrorExt(tif->tif_clientdata,"LibJpeg","Unexpected error"); + jpeg_encap_unwind(tif); + return(0); } #ifdef _MSC_VER -#pragma warning(pop) +#pragma warning( pop ) #endif -static void OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct *cinfo) +static void +OJPEGLibjpegJpegSourceMgrTermSource(jpeg_decompress_struct* cinfo) { - (void)cinfo; + (void)cinfo; } #endif + + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_open.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_open.c index 23fcf81c4..a0e31583a 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_open.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_open.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -26,626 +26,481 @@ * TIFF Library. */ #include "tiffiop.h" -#include /* * Dummy functions to fill the omitted client procedures. */ -static int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize) +static int +_tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize) { - (void)fd; - (void)pbase; - (void)psize; - return (0); + (void) fd; (void) pbase; (void) psize; + return (0); } -static void _tiffDummyUnmapProc(thandle_t fd, void *base, toff_t size) +static void +_tiffDummyUnmapProc(thandle_t fd, void* base, toff_t size) { - (void)fd; - (void)base; - (void)size; + (void) fd; (void) base; (void) size; } -int _TIFFgetMode(TIFFOpenOptions *opts, thandle_t clientdata, const char *mode, - const char *module) +int +_TIFFgetMode(const char* mode, const char* module) { - int m = -1; + int m = -1; - switch (mode[0]) - { - case 'r': - m = O_RDONLY; - if (mode[1] == '+') - m = O_RDWR; - break; - case 'w': - case 'a': - m = O_RDWR | O_CREAT; - if (mode[0] == 'w') - m |= O_TRUNC; - break; - default: - _TIFFErrorEarly(opts, clientdata, module, "\"%s\": Bad mode", mode); - break; - } - return (m); + switch (mode[0]) { + case 'r': + m = O_RDONLY; + if (mode[1] == '+') + m = O_RDWR; + break; + case 'w': + case 'a': + m = O_RDWR|O_CREAT; + if (mode[0] == 'w') + m |= O_TRUNC; + break; + default: + TIFFErrorExt(0, module, "\"%s\": Bad mode", mode); + break; + } + return (m); } -TIFFOpenOptions *TIFFOpenOptionsAlloc() +TIFF* +TIFFClientOpen( + const char* name, const char* mode, + thandle_t clientdata, + TIFFReadWriteProc readproc, + TIFFReadWriteProc writeproc, + TIFFSeekProc seekproc, + TIFFCloseProc closeproc, + TIFFSizeProc sizeproc, + TIFFMapFileProc mapproc, + TIFFUnmapFileProc unmapproc +) { - TIFFOpenOptions *opts = - (TIFFOpenOptions *)_TIFFcalloc(1, sizeof(TIFFOpenOptions)); - return opts; -} + static const char module[] = "TIFFClientOpen"; + TIFF *tif; + int m; + const char* cp; -void TIFFOpenOptionsFree(TIFFOpenOptions *opts) { _TIFFfree(opts); } + /* 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(tmsize_t)==sizeof(void*)); + { + union{ + uint8 a8[2]; + uint16 a16; + } n; + n.a8[0]=1; + n.a8[1]=0; + (void)n; + #ifdef WORDS_BIGENDIAN + assert(n.a16==256); + #else + assert(n.a16==1); + #endif + } -/** Define a limit in bytes for a single memory allocation done by libtiff. - * If max_single_mem_alloc is set to 0, no other limit that the underlying - * _TIFFmalloc() will be applied, which is the default. - */ -void TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts, - tmsize_t max_single_mem_alloc) -{ - opts->max_single_mem_alloc = max_single_mem_alloc; -} + m = _TIFFgetMode(mode, module); + if (m == -1) + goto bad2; + tif = (TIFF *)_TIFFmalloc((tmsize_t)(sizeof (TIFF) + strlen(name) + 1)); + if (tif == NULL) { + TIFFErrorExt(clientdata, module, "%s: Out of memory (TIFF structure)", name); + goto bad2; + } + _TIFFmemset(tif, 0, sizeof (*tif)); + 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_curoff = 0; + tif->tif_curstrip = (uint32) -1; /* invalid strip */ + tif->tif_row = (uint32) -1; /* read/write pre-increment */ + tif->tif_clientdata = clientdata; + if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) { + TIFFErrorExt(clientdata, module, + "One of the client procedures is NULL pointer."); + _TIFFfree(tif); + goto bad2; + } + tif->tif_readproc = readproc; + tif->tif_writeproc = writeproc; + tif->tif_seekproc = seekproc; + tif->tif_closeproc = closeproc; + tif->tif_sizeproc = sizeproc; + if (mapproc) + tif->tif_mapproc = mapproc; + else + tif->tif_mapproc = _tiffDummyMapProc; + if (unmapproc) + tif->tif_unmapproc = unmapproc; + else + tif->tif_unmapproc = _tiffDummyUnmapProc; + _TIFFSetDefaultCompressionState(tif); /* setup default state */ + /* + * Default is to return data MSB2LSB and enable the + * use of memory-mapped files and strip chopping when + * a file is opened read-only. + */ + tif->tif_flags = FILLORDER_MSB2LSB; + if (m == O_RDONLY ) + tif->tif_flags |= TIFF_MAPPED; -void TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts, - TIFFErrorHandlerExtR handler, - void *errorhandler_user_data) -{ - opts->errorhandler = handler; - opts->errorhandler_user_data = errorhandler_user_data; -} + #ifdef STRIPCHOP_DEFAULT + if (m == O_RDONLY || m == O_RDWR) + tif->tif_flags |= STRIPCHOP_DEFAULT; + #endif -void TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions *opts, - TIFFErrorHandlerExtR handler, - void *warnhandler_user_data) -{ - opts->warnhandler = handler; - opts->warnhandler_user_data = warnhandler_user_data; -} - -static void _TIFFEmitErrorAboveMaxSingleMemAlloc(TIFF *tif, - const char *pszFunction, - tmsize_t s) -{ - TIFFErrorExtR(tif, pszFunction, - "Memory allocation of %" PRIu64 - " bytes is beyond the %" PRIu64 - " byte limit defined in open options", - (uint64_t)s, (uint64_t)tif->tif_max_single_mem_alloc); -} - -/** malloc() version that takes into account memory-specific open options */ -void *_TIFFmallocExt(TIFF *tif, tmsize_t s) -{ - if (tif != NULL && tif->tif_max_single_mem_alloc > 0 && - s > tif->tif_max_single_mem_alloc) - { - _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFmallocExt", s); - return NULL; - } - return _TIFFmalloc(s); -} - -/** calloc() version that takes into account memory-specific open options */ -void *_TIFFcallocExt(TIFF *tif, tmsize_t nmemb, tmsize_t siz) -{ - if (tif != NULL && tif->tif_max_single_mem_alloc > 0) - { - if (nmemb <= 0 || siz <= 0 || nmemb > TIFF_TMSIZE_T_MAX / siz) - return NULL; - if (nmemb * siz > tif->tif_max_single_mem_alloc) - { - _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFcallocExt", - nmemb * siz); - return NULL; - } - } - return _TIFFcalloc(nmemb, siz); -} - -/** realloc() version that takes into account memory-specific open options */ -void *_TIFFreallocExt(TIFF *tif, void *p, tmsize_t s) -{ - if (tif != NULL && tif->tif_max_single_mem_alloc > 0 && - s > tif->tif_max_single_mem_alloc) - { - _TIFFEmitErrorAboveMaxSingleMemAlloc(tif, "_TIFFreallocExt", s); - return NULL; - } - return _TIFFrealloc(p, s); -} - -/** free() version that takes into account memory-specific open options */ -void _TIFFfreeExt(TIFF *tif, void *p) -{ - (void)tif; - _TIFFfree(p); -} - -TIFF *TIFFClientOpen(const char *name, const char *mode, thandle_t clientdata, - TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, - TIFFSeekProc seekproc, TIFFCloseProc closeproc, - TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, - TIFFUnmapFileProc unmapproc) -{ - return TIFFClientOpenExt(name, mode, clientdata, readproc, writeproc, - seekproc, closeproc, sizeproc, mapproc, unmapproc, - NULL); -} - -TIFF *TIFFClientOpenExt(const char *name, const char *mode, - thandle_t clientdata, TIFFReadWriteProc readproc, - TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, - TIFFCloseProc closeproc, TIFFSizeProc sizeproc, - TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc, - TIFFOpenOptions *opts) -{ - static const char module[] = "TIFFClientOpenExt"; - TIFF *tif; - int m; - const char *cp; - - /* 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_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); - { - union - { - uint8_t a8[2]; - uint16_t a16; - } n; - n.a8[0] = 1; - n.a8[1] = 0; - (void)n; -#ifdef WORDS_BIGENDIAN - assert(n.a16 == 256); -#else - assert(n.a16 == 1); -#endif - } - - m = _TIFFgetMode(opts, clientdata, mode, module); - if (m == -1) - goto bad2; - tmsize_t size_to_alloc = (tmsize_t)(sizeof(TIFF) + strlen(name) + 1); - if (opts && opts->max_single_mem_alloc > 0 && - size_to_alloc > opts->max_single_mem_alloc) - { - _TIFFErrorEarly(opts, clientdata, module, - "%s: Memory allocation of %" PRIu64 - " bytes is beyond the %" PRIu64 - " byte limit defined in open options", - name, (uint64_t)size_to_alloc, - (uint64_t)opts->max_single_mem_alloc); - goto bad2; - } - tif = (TIFF *)_TIFFmallocExt(NULL, size_to_alloc); - if (tif == NULL) - { - _TIFFErrorEarly(opts, clientdata, module, - "%s: Out of memory (TIFF structure)", name); - goto bad2; - } - _TIFFmemset(tif, 0, sizeof(*tif)); - tif->tif_name = (char *)tif + sizeof(TIFF); - strcpy(tif->tif_name, name); - tif->tif_mode = m & ~(O_CREAT | O_TRUNC); - tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER; /* non-existent directory */ - tif->tif_curoff = 0; - tif->tif_curstrip = (uint32_t)-1; /* invalid strip */ - tif->tif_row = (uint32_t)-1; /* read/write pre-increment */ - tif->tif_clientdata = clientdata; - tif->tif_readproc = readproc; - tif->tif_writeproc = writeproc; - tif->tif_seekproc = seekproc; - tif->tif_closeproc = closeproc; - tif->tif_sizeproc = sizeproc; - tif->tif_mapproc = mapproc ? mapproc : _tiffDummyMapProc; - tif->tif_unmapproc = unmapproc ? unmapproc : _tiffDummyUnmapProc; - if (opts) - { - tif->tif_errorhandler = opts->errorhandler; - tif->tif_errorhandler_user_data = opts->errorhandler_user_data; - tif->tif_warnhandler = opts->warnhandler; - tif->tif_warnhandler_user_data = opts->warnhandler_user_data; - tif->tif_max_single_mem_alloc = opts->max_single_mem_alloc; - } - - if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) - { - TIFFErrorExtR(tif, module, - "One of the client procedures is NULL pointer."); - _TIFFfreeExt(NULL, tif); - goto bad2; - } - - _TIFFSetDefaultCompressionState(tif); /* setup default state */ - /* - * Default is to return data MSB2LSB and enable the - * use of memory-mapped files and strip chopping when - * a file is opened read-only. - */ - tif->tif_flags = FILLORDER_MSB2LSB; - if (m == O_RDONLY) - tif->tif_flags |= TIFF_MAPPED; - -#ifdef STRIPCHOP_DEFAULT - if (m == O_RDONLY || m == O_RDWR) - tif->tif_flags |= STRIPCHOP_DEFAULT; -#endif - - /* - * Process library-specific flags in the open mode string. - * The following flags may be used to control intrinsic library - * behavior that may or may not be desirable (usually for - * compatibility with some application that claims to support - * TIFF but only supports some brain dead idea of what the - * vendor thinks TIFF is): - * - * 'l' use little-endian byte order for creating a file - * 'b' use big-endian byte order for creating a file - * 'L' read/write information using LSB2MSB bit order - * 'B' read/write information using MSB2LSB bit order - * 'H' read/write information using host bit order - * 'M' enable use of memory-mapped files when supported - * 'm' disable use of memory-mapped files - * 'C' enable strip chopping support when reading - * 'c' disable strip chopping support - * 'h' read TIFF header only, do not load the first IFD - * '4' ClassicTIFF for creating a file (default) - * '8' BigTIFF for creating a file - * 'D' enable use of deferred strip/tile offset/bytecount array loading. - * 'O' on-demand loading of values instead of whole array loading (implies - * D) - * - * The use of the 'l' and 'b' flags is strongly discouraged. - * These flags are provided solely because numerous vendors, - * typically on the PC, do not correctly support TIFF; they - * only support the Intel little-endian byte order. This - * support is not configured by default because it supports - * the violation of the TIFF spec that says that readers *MUST* - * support both byte orders. It is strongly recommended that - * you not use this feature except to deal with busted apps - * that write invalid TIFF. And even in those cases you should - * bang on the vendors to fix their software. - * - * The 'L', 'B', and 'H' flags are intended for applications - * that can optimize operations on data by using a particular - * bit order. By default the library returns data in MSB2LSB - * bit order for compatibility with older versions of this - * library. Returning data in the bit order of the native CPU - * makes the most sense but also requires applications to check - * the value of the FillOrder tag; something they probably do - * not do right now. - * - * The 'M' and 'm' flags are provided because some virtual memory - * systems exhibit poor behavior when large images are mapped. - * These options permit clients to control the use of memory-mapped - * files on a per-file basis. - * - * The 'C' and 'c' flags are provided because the library support - * for chopping up large strips into multiple smaller strips is not - * application-transparent and as such can cause problems. The 'c' - * option permits applications that only want to look at the tags, - * for example, to get the unadulterated TIFF tag information. - */ - for (cp = mode; *cp; cp++) - switch (*cp) - { - case 'b': -#ifndef WORDS_BIGENDIAN - if (m & O_CREAT) - tif->tif_flags |= TIFF_SWAB; -#endif - break; - case 'l': -#ifdef WORDS_BIGENDIAN - if ((m & O_CREAT)) - tif->tif_flags |= TIFF_SWAB; -#endif - break; - case 'B': - tif->tif_flags = - (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB; - break; - case 'L': - tif->tif_flags = - (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_LSB2MSB; - break; - case 'H': - TIFFWarningExtR(tif, name, - "H(ost) mode is deprecated. Since " - "libtiff 4.5.1, it is an alias of 'B' / " - "FILLORDER_MSB2LSB."); - tif->tif_flags = - (tif->tif_flags & ~TIFF_FILLORDER) | FILLORDER_MSB2LSB; - break; - case 'M': - if (m == O_RDONLY) - tif->tif_flags |= TIFF_MAPPED; - break; - case 'm': - if (m == O_RDONLY) - tif->tif_flags &= ~TIFF_MAPPED; - break; - case 'C': - if (m == O_RDONLY) - tif->tif_flags |= TIFF_STRIPCHOP; - break; - case 'c': - if (m == O_RDONLY) - tif->tif_flags &= ~TIFF_STRIPCHOP; - break; - case 'h': - tif->tif_flags |= TIFF_HEADERONLY; - break; - case '8': - if (m & O_CREAT) - tif->tif_flags |= TIFF_BIGTIFF; - break; - case 'D': - tif->tif_flags |= TIFF_DEFERSTRILELOAD; - break; - case 'O': - if (m == O_RDONLY) - tif->tif_flags |= - (TIFF_LAZYSTRILELOAD | TIFF_DEFERSTRILELOAD); - break; - } + /* + * Process library-specific flags in the open mode string. + * The following flags may be used to control intrinsic library + * behavior that may or may not be desirable (usually for + * compatibility with some application that claims to support + * TIFF but only supports some brain dead idea of what the + * vendor thinks TIFF is): + * + * 'l' use little-endian byte order for creating a file + * 'b' use big-endian byte order for creating a file + * 'L' read/write information using LSB2MSB bit order + * 'B' read/write information using MSB2LSB bit order + * 'H' read/write information using host bit order + * 'M' enable use of memory-mapped files when supported + * 'm' disable use of memory-mapped files + * 'C' enable strip chopping support when reading + * 'c' disable strip chopping support + * 'h' read TIFF header only, do not load the first IFD + * '4' ClassicTIFF for creating a file (default) + * '8' BigTIFF for creating a file + * 'D' enable use of deferred strip/tile offset/bytecount array loading. + * 'O' on-demand loading of values instead of whole array loading (implies D) + * + * The use of the 'l' and 'b' flags is strongly discouraged. + * These flags are provided solely because numerous vendors, + * typically on the PC, do not correctly support TIFF; they + * only support the Intel little-endian byte order. This + * support is not configured by default because it supports + * the violation of the TIFF spec that says that readers *MUST* + * support both byte orders. It is strongly recommended that + * you not use this feature except to deal with busted apps + * that write invalid TIFF. And even in those cases you should + * bang on the vendors to fix their software. + * + * The 'L', 'B', and 'H' flags are intended for applications + * that can optimize operations on data by using a particular + * bit order. By default the library returns data in MSB2LSB + * bit order for compatibility with older versions of this + * library. Returning data in the bit order of the native CPU + * makes the most sense but also requires applications to check + * the value of the FillOrder tag; something they probably do + * not do right now. + * + * The 'M' and 'm' flags are provided because some virtual memory + * systems exhibit poor behavior when large images are mapped. + * These options permit clients to control the use of memory-mapped + * files on a per-file basis. + * + * The 'C' and 'c' flags are provided because the library support + * for chopping up large strips into multiple smaller strips is not + * application-transparent and as such can cause problems. The 'c' + * option permits applications that only want to look at the tags, + * for example, to get the unadulterated TIFF tag information. + */ + for (cp = mode; *cp; cp++) + switch (*cp) { + case 'b': + #ifndef WORDS_BIGENDIAN + if (m&O_CREAT) + tif->tif_flags |= TIFF_SWAB; + #endif + break; + case 'l': + #ifdef WORDS_BIGENDIAN + if ((m&O_CREAT)) + tif->tif_flags |= TIFF_SWAB; + #endif + break; + case 'B': + tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | + FILLORDER_MSB2LSB; + break; + case 'L': + tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | + FILLORDER_LSB2MSB; + break; + case 'H': + tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) | + HOST_FILLORDER; + break; + case 'M': + if (m == O_RDONLY) + tif->tif_flags |= TIFF_MAPPED; + break; + case 'm': + if (m == O_RDONLY) + tif->tif_flags &= ~TIFF_MAPPED; + break; + case 'C': + if (m == O_RDONLY) + tif->tif_flags |= TIFF_STRIPCHOP; + break; + case 'c': + if (m == O_RDONLY) + tif->tif_flags &= ~TIFF_STRIPCHOP; + break; + case 'h': + tif->tif_flags |= TIFF_HEADERONLY; + break; + case '8': + if (m&O_CREAT) + tif->tif_flags |= TIFF_BIGTIFF; + break; + case 'D': + tif->tif_flags |= TIFF_DEFERSTRILELOAD; + break; + case 'O': + if( m == O_RDONLY ) + tif->tif_flags |= (TIFF_LAZYSTRILELOAD | TIFF_DEFERSTRILELOAD); + break; + } #ifdef DEFER_STRILE_LOAD - /* Compatibility with old DEFER_STRILE_LOAD compilation flag */ - /* Probably unneeded, since to the best of my knowledge (E. Rouault) */ - /* GDAL was the only user of this, and will now use the new 'D' flag */ - tif->tif_flags |= TIFF_DEFERSTRILELOAD; + /* Compatibility with old DEFER_STRILE_LOAD compilation flag */ + /* Probably unneeded, since to the best of my knowledge (E. Rouault) */ + /* GDAL was the only user of this, and will now use the new 'D' flag */ + tif->tif_flags |= TIFF_DEFERSTRILELOAD; #endif - /* - * Read in TIFF header. - */ - if ((m & O_TRUNC) || - !ReadOK(tif, &tif->tif_header, sizeof(TIFFHeaderClassic))) - { - if (tif->tif_mode == O_RDONLY) - { - TIFFErrorExtR(tif, name, "Cannot read TIFF header"); - goto bad; - } -/* - * Setup header and write. - */ -#ifdef WORDS_BIGENDIAN - tif->tif_header.common.tiff_magic = - (tif->tif_flags & TIFF_SWAB) ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN; -#else - tif->tif_header.common.tiff_magic = - (tif->tif_flags & TIFF_SWAB) ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN; -#endif - if (!(tif->tif_flags & TIFF_BIGTIFF)) - { - tif->tif_header.common.tiff_version = TIFF_VERSION_CLASSIC; - tif->tif_header.classic.tiff_diroff = 0; - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&tif->tif_header.common.tiff_version); - tif->tif_header_size = sizeof(TIFFHeaderClassic); - } - else - { - tif->tif_header.common.tiff_version = TIFF_VERSION_BIG; - tif->tif_header.big.tiff_offsetsize = 8; - tif->tif_header.big.tiff_unused = 0; - tif->tif_header.big.tiff_diroff = 0; - if (tif->tif_flags & TIFF_SWAB) - { - TIFFSwabShort(&tif->tif_header.common.tiff_version); - TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize); - } - tif->tif_header_size = sizeof(TIFFHeaderBig); - } - /* - * The doc for "fopen" for some STD_C_LIBs says that if you - * open a file for modify ("+"), then you must fseek (or - * fflush?) between any freads and fwrites. This is not - * necessary on most systems, but has been shown to be needed - * on Solaris. - */ - TIFFSeekFile(tif, 0, SEEK_SET); - if (!WriteOK(tif, &tif->tif_header, (tmsize_t)(tif->tif_header_size))) - { - TIFFErrorExtR(tif, name, "Error writing TIFF header"); - goto bad; - } - /* - * Setup the byte order handling. - */ - if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) - { -#ifndef WORDS_BIGENDIAN - tif->tif_flags |= TIFF_SWAB; -#endif - } - else - { -#ifdef WORDS_BIGENDIAN - tif->tif_flags |= TIFF_SWAB; -#endif - } - /* - * Setup default directory. - */ - if (!TIFFDefaultDirectory(tif)) - goto bad; - tif->tif_diroff = 0; - tif->tif_lastdiroff = 0; - tif->tif_setdirectory_force_absolute = FALSE; - return (tif); - } - /* - * Setup the byte order handling. - */ - if (tif->tif_header.common.tiff_magic != TIFF_BIGENDIAN && - tif->tif_header.common.tiff_magic != TIFF_LITTLEENDIAN -#if MDI_SUPPORT - && -#if HOST_BIGENDIAN - tif->tif_header.common.tiff_magic != MDI_BIGENDIAN -#else - tif->tif_header.common.tiff_magic != MDI_LITTLEENDIAN -#endif - ) - { - TIFFErrorExtR(tif, name, - "Not a TIFF or MDI file, bad magic number %" PRIu16 - " (0x%" PRIx16 ")", -#else - ) - { - TIFFErrorExtR(tif, name, - "Not a TIFF file, bad magic number %" PRIu16 - " (0x%" PRIx16 ")", -#endif - tif->tif_header.common.tiff_magic, - tif->tif_header.common.tiff_magic); - goto bad; - } - if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) - { -#ifndef WORDS_BIGENDIAN - tif->tif_flags |= TIFF_SWAB; -#endif - } - else - { -#ifdef WORDS_BIGENDIAN - tif->tif_flags |= TIFF_SWAB; -#endif - } - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabShort(&tif->tif_header.common.tiff_version); - if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC) && - (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG)) - { - TIFFErrorExtR(tif, name, - "Not a TIFF file, bad version number %" PRIu16 - " (0x%" PRIx16 ")", - tif->tif_header.common.tiff_version, - tif->tif_header.common.tiff_version); - goto bad; - } - if (tif->tif_header.common.tiff_version == TIFF_VERSION_CLASSIC) - { - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabLong(&tif->tif_header.classic.tiff_diroff); - tif->tif_header_size = sizeof(TIFFHeaderClassic); - } - else - { - if (!ReadOK(tif, - ((uint8_t *)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), - (sizeof(TIFFHeaderBig) - sizeof(TIFFHeaderClassic)))) - { - TIFFErrorExtR(tif, name, "Cannot read TIFF header"); - goto bad; - } - if (tif->tif_flags & TIFF_SWAB) - { - TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize); - TIFFSwabLong8(&tif->tif_header.big.tiff_diroff); - } - if (tif->tif_header.big.tiff_offsetsize != 8) - { - TIFFErrorExtR(tif, name, - "Not a TIFF file, bad BigTIFF offsetsize %" PRIu16 - " (0x%" PRIx16 ")", - tif->tif_header.big.tiff_offsetsize, - tif->tif_header.big.tiff_offsetsize); - goto bad; - } - if (tif->tif_header.big.tiff_unused != 0) - { - TIFFErrorExtR(tif, name, - "Not a TIFF file, bad BigTIFF unused %" PRIu16 - " (0x%" PRIx16 ")", - tif->tif_header.big.tiff_unused, - tif->tif_header.big.tiff_unused); - goto bad; - } - tif->tif_header_size = sizeof(TIFFHeaderBig); - tif->tif_flags |= TIFF_BIGTIFF; - } - tif->tif_flags |= TIFF_MYBUFFER; - tif->tif_rawcp = tif->tif_rawdata = 0; - tif->tif_rawdatasize = 0; - tif->tif_rawdataoff = 0; - tif->tif_rawdataloaded = 0; + /* + * Read in TIFF header. + */ + if ((m & O_TRUNC) || + !ReadOK(tif, &tif->tif_header, sizeof (TIFFHeaderClassic))) { + if (tif->tif_mode == O_RDONLY) { + TIFFErrorExt(tif->tif_clientdata, name, + "Cannot read TIFF header"); + goto bad; + } + /* + * Setup header and write. + */ + #ifdef WORDS_BIGENDIAN + tif->tif_header.common.tiff_magic = (tif->tif_flags & TIFF_SWAB) + ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN; + #else + tif->tif_header.common.tiff_magic = (tif->tif_flags & TIFF_SWAB) + ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN; + #endif + if (!(tif->tif_flags&TIFF_BIGTIFF)) + { + tif->tif_header.common.tiff_version = TIFF_VERSION_CLASSIC; + tif->tif_header.classic.tiff_diroff = 0; + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&tif->tif_header.common.tiff_version); + tif->tif_header_size = sizeof(TIFFHeaderClassic); + } + else + { + tif->tif_header.common.tiff_version = TIFF_VERSION_BIG; + tif->tif_header.big.tiff_offsetsize = 8; + tif->tif_header.big.tiff_unused = 0; + tif->tif_header.big.tiff_diroff = 0; + if (tif->tif_flags & TIFF_SWAB) + { + TIFFSwabShort(&tif->tif_header.common.tiff_version); + TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize); + } + tif->tif_header_size = sizeof (TIFFHeaderBig); + } + /* + * The doc for "fopen" for some STD_C_LIBs says that if you + * open a file for modify ("+"), then you must fseek (or + * fflush?) between any freads and fwrites. This is not + * necessary on most systems, but has been shown to be needed + * on Solaris. + */ + TIFFSeekFile( tif, 0, SEEK_SET ); + if (!WriteOK(tif, &tif->tif_header, (tmsize_t)(tif->tif_header_size))) { + TIFFErrorExt(tif->tif_clientdata, name, + "Error writing TIFF header"); + goto bad; + } + /* + * Setup the byte order handling. + */ + if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) { + #ifndef WORDS_BIGENDIAN + tif->tif_flags |= TIFF_SWAB; + #endif + } else { + #ifdef WORDS_BIGENDIAN + tif->tif_flags |= TIFF_SWAB; + #endif + } + /* + * Setup default directory. + */ + if (!TIFFDefaultDirectory(tif)) + goto bad; + tif->tif_diroff = 0; + tif->tif_dirlist = NULL; + tif->tif_dirlistsize = 0; + tif->tif_dirnumber = 0; + return (tif); + } + /* + * Setup the byte order handling. + */ + if (tif->tif_header.common.tiff_magic != TIFF_BIGENDIAN && + tif->tif_header.common.tiff_magic != TIFF_LITTLEENDIAN + #if MDI_SUPPORT + && + #if HOST_BIGENDIAN + tif->tif_header.common.tiff_magic != MDI_BIGENDIAN + #else + tif->tif_header.common.tiff_magic != MDI_LITTLEENDIAN + #endif + ) { + TIFFErrorExt(tif->tif_clientdata, name, + "Not a TIFF or MDI file, bad magic number %d (0x%x)", + #else + ) { + TIFFErrorExt(tif->tif_clientdata, name, + "Not a TIFF file, bad magic number %d (0x%x)", + #endif + tif->tif_header.common.tiff_magic, + tif->tif_header.common.tiff_magic); + goto bad; + } + if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) { + #ifndef WORDS_BIGENDIAN + tif->tif_flags |= TIFF_SWAB; + #endif + } else { + #ifdef WORDS_BIGENDIAN + tif->tif_flags |= TIFF_SWAB; + #endif + } + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabShort(&tif->tif_header.common.tiff_version); + 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)", + tif->tif_header.common.tiff_version, + tif->tif_header.common.tiff_version); + goto bad; + } + if (tif->tif_header.common.tiff_version == TIFF_VERSION_CLASSIC) + { + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabLong(&tif->tif_header.classic.tiff_diroff); + tif->tif_header_size = sizeof(TIFFHeaderClassic); + } + else + { + if (!ReadOK(tif, ((uint8*)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), (sizeof(TIFFHeaderBig)-sizeof(TIFFHeaderClassic)))) + { + TIFFErrorExt(tif->tif_clientdata, name, + "Cannot read TIFF header"); + goto bad; + } + if (tif->tif_flags & TIFF_SWAB) + { + TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize); + TIFFSwabLong8(&tif->tif_header.big.tiff_diroff); + } + if (tif->tif_header.big.tiff_offsetsize != 8) + { + TIFFErrorExt(tif->tif_clientdata, name, + "Not a TIFF file, bad BigTIFF offsetsize %d (0x%x)", + tif->tif_header.big.tiff_offsetsize, + tif->tif_header.big.tiff_offsetsize); + goto bad; + } + if (tif->tif_header.big.tiff_unused != 0) + { + TIFFErrorExt(tif->tif_clientdata, name, + "Not a TIFF file, bad BigTIFF unused %d (0x%x)", + tif->tif_header.big.tiff_unused, + tif->tif_header.big.tiff_unused); + goto bad; + } + tif->tif_header_size = sizeof(TIFFHeaderBig); + tif->tif_flags |= TIFF_BIGTIFF; + } + tif->tif_flags |= TIFF_MYBUFFER; + tif->tif_rawcp = tif->tif_rawdata = 0; + tif->tif_rawdatasize = 0; + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = 0; - switch (mode[0]) - { - case 'r': - if (!(tif->tif_flags & TIFF_BIGTIFF)) - tif->tif_nextdiroff = tif->tif_header.classic.tiff_diroff; - else - tif->tif_nextdiroff = tif->tif_header.big.tiff_diroff; - /* - * Try to use a memory-mapped file if the client - * has not explicitly suppressed usage with the - * 'm' flag in the open mode (see above). - */ - if (tif->tif_flags & TIFF_MAPPED) - { - toff_t n; - if (TIFFMapFileContents(tif, (void **)(&tif->tif_base), &n)) - { - tif->tif_size = (tmsize_t)n; - assert((toff_t)tif->tif_size == n); - } - else - tif->tif_flags &= ~TIFF_MAPPED; - } - /* - * Sometimes we do not want to read the first directory (for - * example, it may be broken) and want to proceed to other - * directories. I this case we use the TIFF_HEADERONLY flag to open - * file and return immediately after reading TIFF header. - */ - if (tif->tif_flags & TIFF_HEADERONLY) - return (tif); + switch (mode[0]) { + case 'r': + if (!(tif->tif_flags&TIFF_BIGTIFF)) + tif->tif_nextdiroff = tif->tif_header.classic.tiff_diroff; + else + tif->tif_nextdiroff = tif->tif_header.big.tiff_diroff; + /* + * Try to use a memory-mapped file if the client + * has not explicitly suppressed usage with the + * 'm' flag in the open mode (see above). + */ + if (tif->tif_flags & TIFF_MAPPED) + { + toff_t n; + if (TIFFMapFileContents(tif,(void**)(&tif->tif_base),&n)) + { + tif->tif_size=(tmsize_t)n; + assert((toff_t)tif->tif_size==n); + } + else + tif->tif_flags &= ~TIFF_MAPPED; + } + /* + * Sometimes we do not want to read the first directory (for example, + * it may be broken) and want to proceed to other directories. I this + * case we use the TIFF_HEADERONLY flag to open file and return + * immediately after reading TIFF header. + */ + if (tif->tif_flags & TIFF_HEADERONLY) + return (tif); - /* - * Setup initial directory. - */ - if (TIFFReadDirectory(tif)) - { - return (tif); - } - break; - case 'a': - /* - * New directories are automatically append - * to the end of the directory chain when they - * are written out (see TIFFWriteDirectory). - */ - if (!TIFFDefaultDirectory(tif)) - goto bad; - return (tif); - } + /* + * Setup initial directory. + */ + if (TIFFReadDirectory(tif)) { + tif->tif_rawcc = (tmsize_t)-1; + tif->tif_flags |= TIFF_BUFFERSETUP; + return (tif); + } + break; + case 'a': + /* + * New directories are automatically append + * to the end of the directory chain when they + * are written out (see TIFFWriteDirectory). + */ + if (!TIFFDefaultDirectory(tif)) + goto bad; + return (tif); + } bad: - tif->tif_mode = O_RDONLY; /* XXX avoid flush */ - TIFFCleanup(tif); + tif->tif_mode = O_RDONLY; /* XXX avoid flush */ + TIFFCleanup(tif); bad2: - return ((TIFF *)0); + return ((TIFF*)0); } /* @@ -655,154 +510,233 @@ bad2: /* * Return open file's name. */ -const char *TIFFFileName(TIFF *tif) { return (tif->tif_name); } +const char * +TIFFFileName(TIFF* tif) +{ + return (tif->tif_name); +} /* * Set the file name. */ -const char *TIFFSetFileName(TIFF *tif, const char *name) +const char * +TIFFSetFileName(TIFF* tif, const char *name) { - const char *old_name = tif->tif_name; - tif->tif_name = (char *)name; - return (old_name); + const char* old_name = tif->tif_name; + tif->tif_name = (char *)name; + return (old_name); } /* * Return open file's I/O descriptor. */ -int TIFFFileno(TIFF *tif) { return (tif->tif_fd); } +int +TIFFFileno(TIFF* tif) +{ + return (tif->tif_fd); +} /* * Set open file's I/O descriptor, and return previous value. */ -int TIFFSetFileno(TIFF *tif, int fd) +int +TIFFSetFileno(TIFF* tif, int fd) { - int old_fd = tif->tif_fd; - tif->tif_fd = fd; - return old_fd; + int old_fd = tif->tif_fd; + tif->tif_fd = fd; + return old_fd; } /* * Return open file's clientdata. */ -thandle_t TIFFClientdata(TIFF *tif) { return (tif->tif_clientdata); } +thandle_t +TIFFClientdata(TIFF* tif) +{ + return (tif->tif_clientdata); +} /* * Set open file's clientdata, and return previous value. */ -thandle_t TIFFSetClientdata(TIFF *tif, thandle_t newvalue) +thandle_t +TIFFSetClientdata(TIFF* tif, thandle_t newvalue) { - thandle_t m = tif->tif_clientdata; - tif->tif_clientdata = newvalue; - return m; + thandle_t m = tif->tif_clientdata; + tif->tif_clientdata = newvalue; + return m; } /* * Return read/write mode. */ -int TIFFGetMode(TIFF *tif) { return (tif->tif_mode); } +int +TIFFGetMode(TIFF* tif) +{ + return (tif->tif_mode); +} /* * Return read/write mode. */ -int TIFFSetMode(TIFF *tif, int mode) +int +TIFFSetMode(TIFF* tif, int mode) { - int old_mode = tif->tif_mode; - tif->tif_mode = mode; - return (old_mode); + int old_mode = tif->tif_mode; + tif->tif_mode = mode; + return (old_mode); } /* * Return nonzero if file is organized in * tiles; zero if organized as strips. */ -int TIFFIsTiled(TIFF *tif) { return (isTiled(tif)); } +int +TIFFIsTiled(TIFF* tif) +{ + return (isTiled(tif)); +} /* * Return current row being read/written. */ -uint32_t TIFFCurrentRow(TIFF *tif) { return (tif->tif_row); } +uint32 +TIFFCurrentRow(TIFF* tif) +{ + return (tif->tif_row); +} /* * Return index of the current directory. */ -tdir_t TIFFCurrentDirectory(TIFF *tif) { return (tif->tif_curdir); } +uint16 +TIFFCurrentDirectory(TIFF* tif) +{ + return (tif->tif_curdir); +} /* * Return current strip. */ -uint32_t TIFFCurrentStrip(TIFF *tif) { return (tif->tif_curstrip); } +uint32 +TIFFCurrentStrip(TIFF* tif) +{ + return (tif->tif_curstrip); +} /* * Return current tile. */ -uint32_t TIFFCurrentTile(TIFF *tif) { return (tif->tif_curtile); } +uint32 +TIFFCurrentTile(TIFF* tif) +{ + return (tif->tif_curtile); +} /* * Return nonzero if the file has byte-swapped data. */ -int TIFFIsByteSwapped(TIFF *tif) { return ((tif->tif_flags & TIFF_SWAB) != 0); } +int +TIFFIsByteSwapped(TIFF* tif) +{ + return ((tif->tif_flags & TIFF_SWAB) != 0); +} /* * Return nonzero if the data is returned up-sampled. */ -int TIFFIsUpSampled(TIFF *tif) { return (isUpSampled(tif)); } +int +TIFFIsUpSampled(TIFF* tif) +{ + return (isUpSampled(tif)); +} /* * Return nonzero if the data is returned in MSB-to-LSB bit order. */ -int TIFFIsMSB2LSB(TIFF *tif) { return (isFillOrder(tif, FILLORDER_MSB2LSB)); } +int +TIFFIsMSB2LSB(TIFF* tif) +{ + return (isFillOrder(tif, FILLORDER_MSB2LSB)); +} /* * Return nonzero if given file was written in big-endian order. */ -int TIFFIsBigEndian(TIFF *tif) +int +TIFFIsBigEndian(TIFF* tif) { - return (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN); -} - -/* - * Return nonzero if given file is BigTIFF style. - */ -int TIFFIsBigTIFF(TIFF *tif) -{ - return (tif->tif_header.common.tiff_version == TIFF_VERSION_BIG); + return (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN); } /* * Return pointer to file read method. */ -TIFFReadWriteProc TIFFGetReadProc(TIFF *tif) { return (tif->tif_readproc); } +TIFFReadWriteProc +TIFFGetReadProc(TIFF* tif) +{ + return (tif->tif_readproc); +} /* * Return pointer to file write method. */ -TIFFReadWriteProc TIFFGetWriteProc(TIFF *tif) { return (tif->tif_writeproc); } +TIFFReadWriteProc +TIFFGetWriteProc(TIFF* tif) +{ + return (tif->tif_writeproc); +} /* * Return pointer to file seek method. */ -TIFFSeekProc TIFFGetSeekProc(TIFF *tif) { return (tif->tif_seekproc); } +TIFFSeekProc +TIFFGetSeekProc(TIFF* tif) +{ + return (tif->tif_seekproc); +} /* * Return pointer to file close method. */ -TIFFCloseProc TIFFGetCloseProc(TIFF *tif) { return (tif->tif_closeproc); } +TIFFCloseProc +TIFFGetCloseProc(TIFF* tif) +{ + return (tif->tif_closeproc); +} /* * Return pointer to file size requesting method. */ -TIFFSizeProc TIFFGetSizeProc(TIFF *tif) { return (tif->tif_sizeproc); } +TIFFSizeProc +TIFFGetSizeProc(TIFF* tif) +{ + return (tif->tif_sizeproc); +} /* * Return pointer to memory mapping method. */ -TIFFMapFileProc TIFFGetMapFileProc(TIFF *tif) { return (tif->tif_mapproc); } +TIFFMapFileProc +TIFFGetMapFileProc(TIFF* tif) +{ + return (tif->tif_mapproc); +} /* * Return pointer to memory unmapping method. */ -TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *tif) +TIFFUnmapFileProc +TIFFGetUnmapFileProc(TIFF* tif) { - return (tif->tif_unmapproc); + return (tif->tif_unmapproc); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_packbits.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_packbits.c index 62849f8f3..a8f29e875 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_packbits.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_packbits.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -31,178 +31,157 @@ */ #include -static int PackBitsPreEncode(TIFF *tif, uint16_t s) +static int +PackBitsPreEncode(TIFF* tif, uint16 s) { - (void)s; + (void) s; - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(tmsize_t)); - if (tif->tif_data == NULL) - return (0); - /* - * Calculate the scanline/tile-width size in bytes. - */ - if (isTiled(tif)) - *(tmsize_t *)tif->tif_data = TIFFTileRowSize(tif); - else - *(tmsize_t *)tif->tif_data = TIFFScanlineSize(tif); - return (1); + tif->tif_data = (uint8*)_TIFFmalloc(sizeof(tmsize_t)); + if (tif->tif_data == NULL) + return (0); + /* + * Calculate the scanline/tile-width size in bytes. + */ + if (isTiled(tif)) + *(tmsize_t*)tif->tif_data = TIFFTileRowSize(tif); + else + *(tmsize_t*)tif->tif_data = TIFFScanlineSize(tif); + return (1); } -static int PackBitsPostEncode(TIFF *tif) +static int +PackBitsPostEncode(TIFF* tif) { - if (tif->tif_data) - _TIFFfreeExt(tif, tif->tif_data); - return (1); + if (tif->tif_data) + _TIFFfree(tif->tif_data); + return (1); } /* * Encode a run of pixels. */ -static int PackBitsEncode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s) +static int +PackBitsEncode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s) { - unsigned char *bp = (unsigned char *)buf; - uint8_t *op; - uint8_t *ep; - uint8_t *lastliteral; - long n, slop; - int b; - enum - { - BASE, - LITERAL, - RUN, - LITERAL_RUN - } state; + unsigned char* bp = (unsigned char*) buf; + uint8* op; + uint8* ep; + uint8* lastliteral; + long n, slop; + int b; + enum { BASE, LITERAL, RUN, LITERAL_RUN } state; - (void)s; - op = tif->tif_rawcp; - ep = tif->tif_rawdata + tif->tif_rawdatasize; - state = BASE; - lastliteral = 0; - while (cc > 0) - { - /* - * Find the longest string of identical bytes. - */ - b = *bp++; - cc--; - n = 1; - for (; cc > 0 && b == *bp; cc--, bp++) - n++; - again: - if (op + 2 >= ep) - { /* insure space for new data */ - /* - * Be careful about writing the last - * literal. Must write up to that point - * and then copy the remainder to the - * front of the buffer. - */ - if (state == LITERAL || state == LITERAL_RUN) - { - slop = (long)(op - lastliteral); - tif->tif_rawcc += (tmsize_t)(lastliteral - tif->tif_rawcp); - if (!TIFFFlushData1(tif)) - return (0); - op = tif->tif_rawcp; - while (slop-- > 0) - *op++ = *lastliteral++; - lastliteral = tif->tif_rawcp; - } - else - { - tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp); - if (!TIFFFlushData1(tif)) - return (0); - op = tif->tif_rawcp; - } - } - switch (state) - { - case BASE: /* initial state, set run/literal */ - if (n > 1) - { - state = RUN; - if (n > 128) - { - *op++ = (uint8_t)-127; - *op++ = (uint8_t)b; - n -= 128; - goto again; - } - *op++ = (uint8_t)(-(n - 1)); - *op++ = (uint8_t)b; - } - else - { - lastliteral = op; - *op++ = 0; - *op++ = (uint8_t)b; - state = LITERAL; - } - break; - case LITERAL: /* last object was literal string */ - if (n > 1) - { - state = LITERAL_RUN; - if (n > 128) - { - *op++ = (uint8_t)-127; - *op++ = (uint8_t)b; - n -= 128; - goto again; - } - *op++ = (uint8_t)(-(n - 1)); /* encode run */ - *op++ = (uint8_t)b; - } - else - { /* extend literal */ - if (++(*lastliteral) == 127) - state = BASE; - *op++ = (uint8_t)b; - } - break; - case RUN: /* last object was run */ - if (n > 1) - { - if (n > 128) - { - *op++ = (uint8_t)-127; - *op++ = (uint8_t)b; - n -= 128; - goto again; - } - *op++ = (uint8_t)(-(n - 1)); - *op++ = (uint8_t)b; - } - else - { - lastliteral = op; - *op++ = 0; - *op++ = (uint8_t)b; - state = LITERAL; - } - break; - case LITERAL_RUN: /* literal followed by a run */ - /* - * Check to see if previous run should - * be converted to a literal, in which - * case we convert literal-run-literal - * to a single literal. - */ - if (n == 1 && op[-2] == (uint8_t)-1 && *lastliteral < 126) - { - state = (((*lastliteral) += 2) == 127 ? BASE : LITERAL); - op[-2] = op[-1]; /* replicate */ - } - else - state = RUN; - goto again; - } - } - tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp); - tif->tif_rawcp = op; - return (1); + (void) s; + op = tif->tif_rawcp; + ep = tif->tif_rawdata + tif->tif_rawdatasize; + state = BASE; + lastliteral = 0; + while (cc > 0) { + /* + * Find the longest string of identical bytes. + */ + b = *bp++; + cc--; + n = 1; + for (; cc > 0 && b == *bp; cc--, bp++) + n++; + again: + if (op + 2 >= ep) { /* insure space for new data */ + /* + * Be careful about writing the last + * literal. Must write up to that point + * and then copy the remainder to the + * front of the buffer. + */ + if (state == LITERAL || state == LITERAL_RUN) { + slop = (long)(op - lastliteral); + tif->tif_rawcc += (tmsize_t)(lastliteral - tif->tif_rawcp); + if (!TIFFFlushData1(tif)) + return (0); + op = tif->tif_rawcp; + while (slop-- > 0) + *op++ = *lastliteral++; + lastliteral = tif->tif_rawcp; + } else { + tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp); + if (!TIFFFlushData1(tif)) + return (0); + op = tif->tif_rawcp; + } + } + switch (state) { + case BASE: /* initial state, set run/literal */ + if (n > 1) { + state = RUN; + if (n > 128) { + *op++ = (uint8) -127; + *op++ = (uint8) b; + n -= 128; + goto again; + } + *op++ = (uint8)(-(n-1)); + *op++ = (uint8) b; + } else { + lastliteral = op; + *op++ = 0; + *op++ = (uint8) b; + state = LITERAL; + } + break; + case LITERAL: /* last object was literal string */ + if (n > 1) { + state = LITERAL_RUN; + if (n > 128) { + *op++ = (uint8) -127; + *op++ = (uint8) b; + n -= 128; + goto again; + } + *op++ = (uint8)(-(n-1)); /* encode run */ + *op++ = (uint8) b; + } else { /* extend literal */ + if (++(*lastliteral) == 127) + state = BASE; + *op++ = (uint8) b; + } + break; + case RUN: /* last object was run */ + if (n > 1) { + if (n > 128) { + *op++ = (uint8) -127; + *op++ = (uint8) b; + n -= 128; + goto again; + } + *op++ = (uint8)(-(n-1)); + *op++ = (uint8) b; + } else { + lastliteral = op; + *op++ = 0; + *op++ = (uint8) b; + state = LITERAL; + } + break; + case LITERAL_RUN: /* literal followed by a run */ + /* + * Check to see if previous run should + * be converted to a literal, in which + * case we convert literal-run-literal + * to a single literal. + */ + if (n == 1 && op[-2] == (uint8) -1 && + *lastliteral < 126) { + state = (((*lastliteral) += 2) == 127 ? + BASE : LITERAL); + op[-2] = op[-1]; /* replicate */ + } else + state = RUN; + goto again; + } + } + tif->tif_rawcc += (tmsize_t)(op - tif->tif_rawcp); + tif->tif_rawcp = op; + return (1); } /* @@ -212,112 +191,119 @@ static int PackBitsEncode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s) * the decoder if data is read, for example, by scanlines * when it was encoded by strips. */ -static int PackBitsEncodeChunk(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +PackBitsEncodeChunk(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - tmsize_t rowsize = *(tmsize_t *)tif->tif_data; + tmsize_t rowsize = *(tmsize_t*)tif->tif_data; - while (cc > 0) - { - tmsize_t chunk = rowsize; + while (cc > 0) { + tmsize_t chunk = rowsize; + + if( cc < chunk ) + chunk = cc; - if (cc < chunk) - chunk = cc; - - if (PackBitsEncode(tif, bp, chunk, s) < 0) - return (-1); - bp += chunk; - cc -= chunk; - } - return (1); + if (PackBitsEncode(tif, bp, chunk, s) < 0) + return (-1); + bp += chunk; + cc -= chunk; + } + return (1); } -static int PackBitsDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) +static int +PackBitsDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - static const char module[] = "PackBitsDecode"; - int8_t *bp; - tmsize_t cc; - long n; - int b; + static const char module[] = "PackBitsDecode"; + char *bp; + tmsize_t cc; + long n; + int b; - (void)s; - bp = (int8_t *)tif->tif_rawcp; - cc = tif->tif_rawcc; - while (cc > 0 && occ > 0) - { - n = (long)*bp++; - cc--; - if (n < 0) - { /* replicate next byte -n+1 times */ - if (n == -128) /* nop */ - continue; - n = -n + 1; - if (occ < (tmsize_t)n) - { - TIFFWarningExtR(tif, module, - "Discarding %" TIFF_SSIZE_FORMAT - " bytes to avoid buffer overrun", - (tmsize_t)n - occ); - n = (long)occ; - } - if (cc == 0) - { - TIFFWarningExtR( - tif, module, - "Terminating PackBitsDecode due to lack of data."); - break; - } - occ -= n; - b = *bp++; - cc--; - while (n-- > 0) - *op++ = (uint8_t)b; - } - else - { /* copy next n+1 bytes literally */ - if (occ < (tmsize_t)(n + 1)) - { - TIFFWarningExtR(tif, module, - "Discarding %" TIFF_SSIZE_FORMAT - " bytes to avoid buffer overrun", - (tmsize_t)n - occ + 1); - n = (long)occ - 1; - } - if (cc < (tmsize_t)(n + 1)) - { - TIFFWarningExtR( - tif, module, - "Terminating PackBitsDecode due to lack of data."); - break; - } - _TIFFmemcpy(op, bp, ++n); - op += n; - occ -= n; - bp += n; - cc -= n; - } - } - tif->tif_rawcp = (uint8_t *)bp; - tif->tif_rawcc = cc; - if (occ > 0) - { - TIFFErrorExtR(tif, module, "Not enough data for scanline %" PRIu32, - tif->tif_row); - return (0); - } - return (1); + (void) s; + bp = (char*) tif->tif_rawcp; + cc = tif->tif_rawcc; + while (cc > 0 && occ > 0) { + n = (long) *bp++; + cc--; + /* + * Watch out for compilers that + * don't sign extend chars... + */ + if (n >= 128) + n -= 256; + if (n < 0) { /* replicate next byte -n+1 times */ + if (n == -128) /* nop */ + continue; + n = -n + 1; + if( occ < (tmsize_t)n ) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Discarding %lu bytes to avoid buffer overrun", + (unsigned long) ((tmsize_t)n - occ)); + n = (long)occ; + } + if( cc == 0 ) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Terminating PackBitsDecode due to lack of data."); + break; + } + occ -= n; + b = *bp++; + cc--; + while (n-- > 0) + *op++ = (uint8) b; + } else { /* copy next n+1 bytes literally */ + if (occ < (tmsize_t)(n + 1)) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Discarding %lu bytes to avoid buffer overrun", + (unsigned long) ((tmsize_t)n - occ + 1)); + n = (long)occ - 1; + } + if (cc < (tmsize_t) (n+1)) + { + TIFFWarningExt(tif->tif_clientdata, module, + "Terminating PackBitsDecode due to lack of data."); + break; + } + _TIFFmemcpy(op, bp, ++n); + op += n; occ -= n; + bp += n; cc -= n; + } + } + tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcc = cc; + if (occ > 0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data for scanline %lu", + (unsigned long) tif->tif_row); + return (0); + } + return (1); } -int TIFFInitPackBits(TIFF *tif, int scheme) +int +TIFFInitPackBits(TIFF* tif, int scheme) { - (void)scheme; - tif->tif_decoderow = PackBitsDecode; - tif->tif_decodestrip = PackBitsDecode; - tif->tif_decodetile = PackBitsDecode; - tif->tif_preencode = PackBitsPreEncode; - tif->tif_postencode = PackBitsPostEncode; - tif->tif_encoderow = PackBitsEncode; - tif->tif_encodestrip = PackBitsEncodeChunk; - tif->tif_encodetile = PackBitsEncodeChunk; - return (1); + (void) scheme; + tif->tif_decoderow = PackBitsDecode; + tif->tif_decodestrip = PackBitsDecode; + tif->tif_decodetile = PackBitsDecode; + tif->tif_preencode = PackBitsPreEncode; + tif->tif_postencode = PackBitsPostEncode; + tif->tif_encoderow = PackBitsEncode; + tif->tif_encodestrip = PackBitsEncodeChunk; + tif->tif_encodetile = PackBitsEncodeChunk; + return (1); } #endif /* PACKBITS_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_pixarlog.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_pixarlog.c index 5c0346b6e..f29120150 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_pixarlog.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_pixarlog.c @@ -2,23 +2,23 @@ * Copyright (c) 1996-1997 Sam Leffler * Copyright (c) 1996 Pixar * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Pixar, 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 Pixar, Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL PIXAR, SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,10 +32,10 @@ * Contributed by Dan McCoy. * * PixarLog film support uses the TIFF library to store companded - * 11 bit values into a tiff file, which are compressed using the - * zip compressor. + * 11 bit values into a tiff file, which are compressed using the + * zip compressor. * - * The codec can take as input and produce as output 32-bit IEEE float values + * The codec can take as input and produce as output 32-bit IEEE float values * as well as 16-bit or 8-bit unsigned integer values. * * On writing any of the above are converted into the internal @@ -49,7 +49,7 @@ * than the human eye can perceive with extra room to allow for * error introduced by further image computation. As with any quantized * color format, it is possible to perform image calculations which - * expose the quantization error. This format should certainly be less + * expose the quantization error. This format should certainly be less * susceptible to such errors than standard 8-bit encodings, but more * susceptible than straight 16-bit or 32-bit encodings. * @@ -90,429 +90,363 @@ #include "tif_predict.h" #include "zlib.h" -#include #include #include +#include /* Tables for converting to/from 11 bit coded values */ -#define TSIZE 2048 /* decode table size (11-bit tokens) */ -#define TSIZEP1 2049 /* Plus one for slop */ -#define ONE 1250 /* token value of 1.0 exactly */ -#define RATIO 1.004 /* nominal ratio for log part */ +#define TSIZE 2048 /* decode table size (11-bit tokens) */ +#define TSIZEP1 2049 /* Plus one for slop */ +#define ONE 1250 /* token value of 1.0 exactly */ +#define RATIO 1.004 /* nominal ratio for log part */ -#define CODE_MASK 0x7ff /* 11 bits. */ +#define CODE_MASK 0x7ff /* 11 bits. */ -static float Fltsize; -static float LogK1, LogK2; +static float Fltsize; +static float LogK1, LogK2; -#define REPEAT(n, op) \ - { \ - int i; \ - i = n; \ - do \ - { \ - i--; \ - op; \ - } while (i > 0); \ - } +#define REPEAT(n, op) { int i; i=n; do { i--; op; } while (i>0); } -static void horizontalAccumulateF(uint16_t *wp, int n, int stride, float *op, - float *ToLinearF) +static void +horizontalAccumulateF(uint16 *wp, int n, int stride, float *op, + float *ToLinearF) { - register unsigned int cr, cg, cb, ca, mask; - register float t0, t1, t2, t3; + register unsigned int cr, cg, cb, ca, mask; + register float t0, t1, t2, t3; - if (n >= stride) - { - mask = CODE_MASK; - if (stride == 3) - { - t0 = ToLinearF[cr = (wp[0] & mask)]; - t1 = ToLinearF[cg = (wp[1] & mask)]; - t2 = ToLinearF[cb = (wp[2] & mask)]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - n -= 3; - while (n > 0) - { - wp += 3; - op += 3; - n -= 3; - t0 = ToLinearF[(cr += wp[0]) & mask]; - t1 = ToLinearF[(cg += wp[1]) & mask]; - t2 = ToLinearF[(cb += wp[2]) & mask]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - } - } - else if (stride == 4) - { - t0 = ToLinearF[cr = (wp[0] & mask)]; - t1 = ToLinearF[cg = (wp[1] & mask)]; - t2 = ToLinearF[cb = (wp[2] & mask)]; - t3 = ToLinearF[ca = (wp[3] & mask)]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - n -= 4; - while (n > 0) - { - wp += 4; - op += 4; - n -= 4; - t0 = ToLinearF[(cr += wp[0]) & mask]; - t1 = ToLinearF[(cg += wp[1]) & mask]; - t2 = ToLinearF[(cb += wp[2]) & mask]; - t3 = ToLinearF[(ca += wp[3]) & mask]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - } - } - else - { - REPEAT(stride, *op = ToLinearF[*wp & mask]; wp++; op++) - n -= stride; - while (n > 0) - { - REPEAT(stride, wp[stride] += *wp; *op = ToLinearF[*wp & mask]; - wp++; op++) - n -= stride; - } - } + if (n >= stride) { + mask = CODE_MASK; + if (stride == 3) { + t0 = ToLinearF[cr = (wp[0] & mask)]; + t1 = ToLinearF[cg = (wp[1] & mask)]; + t2 = ToLinearF[cb = (wp[2] & mask)]; + op[0] = t0; + op[1] = t1; + op[2] = t2; + n -= 3; + while (n > 0) { + wp += 3; + op += 3; + n -= 3; + t0 = ToLinearF[(cr += wp[0]) & mask]; + t1 = ToLinearF[(cg += wp[1]) & mask]; + t2 = ToLinearF[(cb += wp[2]) & mask]; + op[0] = t0; + op[1] = t1; + op[2] = t2; + } + } else if (stride == 4) { + t0 = ToLinearF[cr = (wp[0] & mask)]; + t1 = ToLinearF[cg = (wp[1] & mask)]; + t2 = ToLinearF[cb = (wp[2] & mask)]; + t3 = ToLinearF[ca = (wp[3] & mask)]; + op[0] = t0; + op[1] = t1; + op[2] = t2; + op[3] = t3; + n -= 4; + while (n > 0) { + wp += 4; + op += 4; + n -= 4; + t0 = ToLinearF[(cr += wp[0]) & mask]; + t1 = ToLinearF[(cg += wp[1]) & mask]; + t2 = ToLinearF[(cb += wp[2]) & mask]; + t3 = ToLinearF[(ca += wp[3]) & mask]; + op[0] = t0; + op[1] = t1; + op[2] = t2; + op[3] = t3; + } + } else { + REPEAT(stride, *op = ToLinearF[*wp&mask]; wp++; op++) + n -= stride; + while (n > 0) { + REPEAT(stride, + wp[stride] += *wp; *op = ToLinearF[*wp&mask]; wp++; op++) + n -= stride; + } + } } } -static void horizontalAccumulate12(uint16_t *wp, int n, int stride, int16_t *op, - float *ToLinearF) +static void +horizontalAccumulate12(uint16 *wp, int n, int stride, int16 *op, + float *ToLinearF) { - register unsigned int cr, cg, cb, ca, mask; - register float t0, t1, t2, t3; + 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)(t) : 3071) +#define CLAMP12(t) (((t) < 3071) ? (uint16) (t) : 3071) - if (n >= stride) - { - mask = CODE_MASK; - if (stride == 3) - { - t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12; - t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12; - t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - n -= 3; - while (n > 0) - { - wp += 3; - op += 3; - n -= 3; - t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12; - t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12; - t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - } - } - else if (stride == 4) - { - t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12; - t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12; - t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12; - t3 = ToLinearF[ca = (wp[3] & mask)] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - op[3] = CLAMP12(t3); - n -= 4; - while (n > 0) - { - wp += 4; - op += 4; - n -= 4; - t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12; - t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12; - t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12; - t3 = ToLinearF[(ca += wp[3]) & mask] * SCALE12; - op[0] = CLAMP12(t0); - op[1] = CLAMP12(t1); - op[2] = CLAMP12(t2); - op[3] = CLAMP12(t3); - } - } - else - { - REPEAT(stride, t0 = ToLinearF[*wp & mask] * SCALE12; - *op = CLAMP12(t0); wp++; op++) - n -= stride; - while (n > 0) - { - REPEAT(stride, wp[stride] += *wp; - t0 = ToLinearF[wp[stride] & mask] * SCALE12; - *op = CLAMP12(t0); wp++; op++) - n -= stride; - } - } + if (n >= stride) { + mask = CODE_MASK; + if (stride == 3) { + t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12; + t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12; + t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12; + op[0] = CLAMP12(t0); + op[1] = CLAMP12(t1); + op[2] = CLAMP12(t2); + n -= 3; + while (n > 0) { + wp += 3; + op += 3; + n -= 3; + t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12; + t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12; + t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12; + op[0] = CLAMP12(t0); + op[1] = CLAMP12(t1); + op[2] = CLAMP12(t2); + } + } else if (stride == 4) { + t0 = ToLinearF[cr = (wp[0] & mask)] * SCALE12; + t1 = ToLinearF[cg = (wp[1] & mask)] * SCALE12; + t2 = ToLinearF[cb = (wp[2] & mask)] * SCALE12; + t3 = ToLinearF[ca = (wp[3] & mask)] * SCALE12; + op[0] = CLAMP12(t0); + op[1] = CLAMP12(t1); + op[2] = CLAMP12(t2); + op[3] = CLAMP12(t3); + n -= 4; + while (n > 0) { + wp += 4; + op += 4; + n -= 4; + t0 = ToLinearF[(cr += wp[0]) & mask] * SCALE12; + t1 = ToLinearF[(cg += wp[1]) & mask] * SCALE12; + t2 = ToLinearF[(cb += wp[2]) & mask] * SCALE12; + t3 = ToLinearF[(ca += wp[3]) & mask] * SCALE12; + op[0] = CLAMP12(t0); + op[1] = CLAMP12(t1); + op[2] = CLAMP12(t2); + op[3] = CLAMP12(t3); + } + } else { + REPEAT(stride, t0 = ToLinearF[*wp&mask] * SCALE12; + *op = CLAMP12(t0); wp++; op++) + n -= stride; + while (n > 0) { + REPEAT(stride, + wp[stride] += *wp; t0 = ToLinearF[wp[stride]&mask]*SCALE12; + *op = CLAMP12(t0); wp++; op++) + n -= stride; + } + } } } -static void horizontalAccumulate16(uint16_t *wp, int n, int stride, - uint16_t *op, uint16_t *ToLinear16) +static void +horizontalAccumulate16(uint16 *wp, int n, int stride, uint16 *op, + uint16 *ToLinear16) { - register unsigned int cr, cg, cb, ca, mask; + register unsigned int cr, cg, cb, ca, mask; - if (n >= stride) - { - mask = CODE_MASK; - if (stride == 3) - { - op[0] = ToLinear16[cr = (wp[0] & mask)]; - op[1] = ToLinear16[cg = (wp[1] & mask)]; - op[2] = ToLinear16[cb = (wp[2] & mask)]; - n -= 3; - while (n > 0) - { - wp += 3; - op += 3; - n -= 3; - op[0] = ToLinear16[(cr += wp[0]) & mask]; - op[1] = ToLinear16[(cg += wp[1]) & mask]; - op[2] = ToLinear16[(cb += wp[2]) & mask]; - } - } - else if (stride == 4) - { - op[0] = ToLinear16[cr = (wp[0] & mask)]; - op[1] = ToLinear16[cg = (wp[1] & mask)]; - op[2] = ToLinear16[cb = (wp[2] & mask)]; - op[3] = ToLinear16[ca = (wp[3] & mask)]; - n -= 4; - while (n > 0) - { - wp += 4; - op += 4; - n -= 4; - op[0] = ToLinear16[(cr += wp[0]) & mask]; - op[1] = ToLinear16[(cg += wp[1]) & mask]; - op[2] = ToLinear16[(cb += wp[2]) & mask]; - op[3] = ToLinear16[(ca += wp[3]) & mask]; - } - } - else - { - REPEAT(stride, *op = ToLinear16[*wp & mask]; wp++; op++) - n -= stride; - while (n > 0) - { - REPEAT(stride, wp[stride] += *wp; *op = ToLinear16[*wp & mask]; - wp++; op++) - n -= stride; - } - } + if (n >= stride) { + mask = CODE_MASK; + if (stride == 3) { + op[0] = ToLinear16[cr = (wp[0] & mask)]; + op[1] = ToLinear16[cg = (wp[1] & mask)]; + op[2] = ToLinear16[cb = (wp[2] & mask)]; + n -= 3; + while (n > 0) { + wp += 3; + op += 3; + n -= 3; + op[0] = ToLinear16[(cr += wp[0]) & mask]; + op[1] = ToLinear16[(cg += wp[1]) & mask]; + op[2] = ToLinear16[(cb += wp[2]) & mask]; + } + } else if (stride == 4) { + op[0] = ToLinear16[cr = (wp[0] & mask)]; + op[1] = ToLinear16[cg = (wp[1] & mask)]; + op[2] = ToLinear16[cb = (wp[2] & mask)]; + op[3] = ToLinear16[ca = (wp[3] & mask)]; + n -= 4; + while (n > 0) { + wp += 4; + op += 4; + n -= 4; + op[0] = ToLinear16[(cr += wp[0]) & mask]; + op[1] = ToLinear16[(cg += wp[1]) & mask]; + op[2] = ToLinear16[(cb += wp[2]) & mask]; + op[3] = ToLinear16[(ca += wp[3]) & mask]; + } + } else { + REPEAT(stride, *op = ToLinear16[*wp&mask]; wp++; op++) + n -= stride; + while (n > 0) { + REPEAT(stride, + wp[stride] += *wp; *op = ToLinear16[*wp&mask]; wp++; op++) + n -= stride; + } + } } } -/* +/* * Returns the log encoded 11-bit values with the horizontal * differencing undone. */ -static void horizontalAccumulate11(uint16_t *wp, int n, int stride, - uint16_t *op) +static void +horizontalAccumulate11(uint16 *wp, int n, int stride, uint16 *op) { register unsigned int cr, cg, cb, ca, mask; - if (n >= stride) - { - mask = CODE_MASK; - if (stride == 3) - { - op[0] = wp[0]; - op[1] = wp[1]; - op[2] = wp[2]; - cr = wp[0]; - cg = wp[1]; - cb = wp[2]; - n -= 3; - while (n > 0) - { - wp += 3; - op += 3; - n -= 3; - 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]; - op[2] = wp[2]; - op[3] = wp[3]; - cr = wp[0]; - cg = wp[1]; - cb = wp[2]; - ca = wp[3]; - n -= 4; - while (n > 0) - { - wp += 4; - op += 4; - n -= 4; - 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++) - n -= stride; - while (n > 0) - { - REPEAT(stride, wp[stride] += *wp; *op = *wp & mask; wp++; op++) - n -= stride; - } - } + if (n >= stride) { + mask = CODE_MASK; + if (stride == 3) { + op[0] = wp[0]; op[1] = wp[1]; op[2] = wp[2]; + cr = wp[0]; cg = wp[1]; cb = wp[2]; + n -= 3; + while (n > 0) { + 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); + } + } else if (stride == 4) { + op[0] = wp[0]; op[1] = wp[1]; + op[2] = wp[2]; op[3] = wp[3]; + cr = wp[0]; cg = wp[1]; cb = wp[2]; ca = wp[3]; + n -= 4; + while (n > 0) { + 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); + } + } else { + REPEAT(stride, *op = *wp&mask; wp++; op++) + n -= stride; + while (n > 0) { + REPEAT(stride, + wp[stride] += *wp; *op = *wp&mask; wp++; op++) + n -= stride; + } + } } } -static void horizontalAccumulate8(uint16_t *wp, int n, int stride, - unsigned char *op, unsigned char *ToLinear8) +static void +horizontalAccumulate8(uint16 *wp, int n, int stride, unsigned char *op, + unsigned char *ToLinear8) { - register unsigned int cr, cg, cb, ca, mask; + register unsigned int cr, cg, cb, ca, mask; - if (n >= stride) - { - mask = CODE_MASK; - if (stride == 3) - { - op[0] = ToLinear8[cr = (wp[0] & mask)]; - op[1] = ToLinear8[cg = (wp[1] & mask)]; - op[2] = ToLinear8[cb = (wp[2] & mask)]; - n -= 3; - while (n > 0) - { - n -= 3; - wp += 3; - op += 3; - op[0] = ToLinear8[(cr += wp[0]) & mask]; - op[1] = ToLinear8[(cg += wp[1]) & mask]; - op[2] = ToLinear8[(cb += wp[2]) & mask]; - } - } - else if (stride == 4) - { - op[0] = ToLinear8[cr = (wp[0] & mask)]; - op[1] = ToLinear8[cg = (wp[1] & mask)]; - op[2] = ToLinear8[cb = (wp[2] & mask)]; - op[3] = ToLinear8[ca = (wp[3] & mask)]; - n -= 4; - while (n > 0) - { - n -= 4; - wp += 4; - op += 4; - op[0] = ToLinear8[(cr += wp[0]) & mask]; - op[1] = ToLinear8[(cg += wp[1]) & mask]; - op[2] = ToLinear8[(cb += wp[2]) & mask]; - op[3] = ToLinear8[(ca += wp[3]) & mask]; - } - } - else - { - REPEAT(stride, *op = ToLinear8[*wp & mask]; wp++; op++) - n -= stride; - while (n > 0) - { - REPEAT(stride, wp[stride] += *wp; *op = ToLinear8[*wp & mask]; - wp++; op++) - n -= stride; - } - } + if (n >= stride) { + mask = CODE_MASK; + if (stride == 3) { + op[0] = ToLinear8[cr = (wp[0] & mask)]; + op[1] = ToLinear8[cg = (wp[1] & mask)]; + op[2] = ToLinear8[cb = (wp[2] & mask)]; + n -= 3; + while (n > 0) { + n -= 3; + wp += 3; + op += 3; + op[0] = ToLinear8[(cr += wp[0]) & mask]; + op[1] = ToLinear8[(cg += wp[1]) & mask]; + op[2] = ToLinear8[(cb += wp[2]) & mask]; + } + } else if (stride == 4) { + op[0] = ToLinear8[cr = (wp[0] & mask)]; + op[1] = ToLinear8[cg = (wp[1] & mask)]; + op[2] = ToLinear8[cb = (wp[2] & mask)]; + op[3] = ToLinear8[ca = (wp[3] & mask)]; + n -= 4; + while (n > 0) { + n -= 4; + wp += 4; + op += 4; + op[0] = ToLinear8[(cr += wp[0]) & mask]; + op[1] = ToLinear8[(cg += wp[1]) & mask]; + op[2] = ToLinear8[(cb += wp[2]) & mask]; + op[3] = ToLinear8[(ca += wp[3]) & mask]; + } + } else { + REPEAT(stride, *op = ToLinear8[*wp&mask]; wp++; op++) + n -= stride; + while (n > 0) { + REPEAT(stride, + wp[stride] += *wp; *op = ToLinear8[*wp&mask]; wp++; op++) + n -= stride; + } + } } } -static void 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; - if (n >= stride) - { - mask = CODE_MASK; - if (stride == 3) - { - op[0] = 0; - t1 = ToLinear8[cb = (wp[2] & mask)]; - t2 = ToLinear8[cg = (wp[1] & mask)]; - t3 = ToLinear8[cr = (wp[0] & mask)]; - op[1] = t1; - op[2] = t2; - op[3] = t3; - n -= 3; - while (n > 0) - { - n -= 3; - wp += 3; - op += 4; - op[0] = 0; - t1 = ToLinear8[(cb += wp[2]) & mask]; - t2 = ToLinear8[(cg += wp[1]) & mask]; - t3 = ToLinear8[(cr += wp[0]) & mask]; - op[1] = t1; - op[2] = t2; - op[3] = t3; - } - } - else if (stride == 4) - { - t0 = ToLinear8[ca = (wp[3] & mask)]; - t1 = ToLinear8[cb = (wp[2] & mask)]; - t2 = ToLinear8[cg = (wp[1] & mask)]; - t3 = ToLinear8[cr = (wp[0] & mask)]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - n -= 4; - while (n > 0) - { - n -= 4; - wp += 4; - op += 4; - t0 = ToLinear8[(ca += wp[3]) & mask]; - t1 = ToLinear8[(cb += wp[2]) & mask]; - t2 = ToLinear8[(cg += wp[1]) & mask]; - t3 = ToLinear8[(cr += wp[0]) & mask]; - op[0] = t0; - op[1] = t1; - op[2] = t2; - op[3] = t3; - } - } - else - { - REPEAT(stride, *op = ToLinear8[*wp & mask]; wp++; op++) - n -= stride; - while (n > 0) - { - REPEAT(stride, wp[stride] += *wp; *op = ToLinear8[*wp & mask]; - wp++; op++) - n -= stride; - } - } +static void +horizontalAccumulate8abgr(uint16 *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; + + if (n >= stride) { + mask = CODE_MASK; + if (stride == 3) { + op[0] = 0; + t1 = ToLinear8[cb = (wp[2] & mask)]; + t2 = ToLinear8[cg = (wp[1] & mask)]; + t3 = ToLinear8[cr = (wp[0] & mask)]; + op[1] = t1; + op[2] = t2; + op[3] = t3; + n -= 3; + while (n > 0) { + n -= 3; + wp += 3; + op += 4; + op[0] = 0; + t1 = ToLinear8[(cb += wp[2]) & mask]; + t2 = ToLinear8[(cg += wp[1]) & mask]; + t3 = ToLinear8[(cr += wp[0]) & mask]; + op[1] = t1; + op[2] = t2; + op[3] = t3; + } + } else if (stride == 4) { + t0 = ToLinear8[ca = (wp[3] & mask)]; + t1 = ToLinear8[cb = (wp[2] & mask)]; + t2 = ToLinear8[cg = (wp[1] & mask)]; + t3 = ToLinear8[cr = (wp[0] & mask)]; + op[0] = t0; + op[1] = t1; + op[2] = t2; + op[3] = t3; + n -= 4; + while (n > 0) { + n -= 4; + wp += 4; + op += 4; + t0 = ToLinear8[(ca += wp[3]) & mask]; + t1 = ToLinear8[(cb += wp[2]) & mask]; + t2 = ToLinear8[(cg += wp[1]) & mask]; + t3 = ToLinear8[(cr += wp[0]) & mask]; + op[0] = t0; + op[1] = t1; + op[2] = t2; + op[3] = t3; + } + } else { + REPEAT(stride, *op = ToLinear8[*wp&mask]; wp++; op++) + n -= stride; + while (n > 0) { + REPEAT(stride, + wp[stride] += *wp; *op = ToLinear8[*wp&mask]; wp++; op++) + n -= stride; + } + } } } @@ -520,121 +454,110 @@ static void horizontalAccumulate8abgr(uint16_t *wp, int n, int stride, * State block for each open TIFF * file using PixarLog compression/decompression. */ -typedef struct -{ - TIFFPredictorState predict; - z_stream stream; - tmsize_t tbuf_size; /* only set/used on reading for now */ - uint16_t *tbuf; - uint16_t stride; - int state; - int user_datafmt; - int quality; +typedef struct { + TIFFPredictorState predict; + z_stream stream; + tmsize_t tbuf_size; /* only set/used on reading for now */ + uint16 *tbuf; + uint16 stride; + int state; + int user_datafmt; + int quality; #define PLSTATE_INIT 1 - TIFFVSetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - - float *ToLinearF; - uint16_t *ToLinear16; - unsigned char *ToLinear8; - uint16_t *FromLT2; - uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16_t *From8; + TIFFVSetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ + float *ToLinearF; + uint16 *ToLinear16; + unsigned char *ToLinear8; + uint16 *FromLT2; + uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ + uint16 *From8; + } PixarLogState; -static int PixarLogMakeTables(TIFF *tif, PixarLogState *sp) +static int +PixarLogMakeTables(PixarLogState *sp) { - /* - * We make several tables here to convert between various external - * representations (float, 16-bit, and 8-bit) and the internal - * 11-bit companded representation. The 11-bit representation has two - * distinct regions. A linear bottom end up through .018316 in steps - * of about .000073, and a region of constant ratio up to about 25. - * These floating point numbers are stored in the main table ToLinearF. - * All other tables are derived from this one. The tables (and the - * ratios) are continuous at the internal seam. - */ +/* + * We make several tables here to convert between various external + * representations (float, 16-bit, and 8-bit) and the internal + * 11-bit companded representation. The 11-bit representation has two + * distinct regions. A linear bottom end up through .018316 in steps + * of about .000073, and a region of constant ratio up to about 25. + * These floating point numbers are stored in the main table ToLinearF. + * All other tables are derived from this one. The tables (and the + * ratios) are continuous at the internal seam. + */ - int nlin, lt2size; - int i, j; - double b, c, linstep, v; + int nlin, lt2size; + int i, j; + double b, c, linstep, v; float *ToLinearF; - uint16_t *ToLinear16; + uint16 *ToLinear16; unsigned char *ToLinear8; - uint16_t *FromLT2; - uint16_t *From14; /* Really for 16-bit data, but we shift down 2 */ - uint16_t *From8; + uint16 *FromLT2; + uint16 *From14; /* Really for 16-bit data, but we shift down 2 */ + uint16 *From8; - c = log(RATIO); - nlin = (int)(1. / c); /* nlin must be an integer */ - c = 1. / nlin; - b = exp(-c * ONE); /* multiplicative scale factor [b*exp(c*ONE) = 1] */ - linstep = b * c * exp(1.); + c = log(RATIO); + nlin = (int)(1./c); /* nlin must be an integer */ + c = 1./nlin; + b = exp(-c*ONE); /* multiplicative scale factor [b*exp(c*ONE) = 1] */ + linstep = b*c*exp(1.); - LogK1 = (float)(1. / c); /* if (v >= 2) token = k1*log(v*k2) */ - LogK2 = (float)(1. / b); - lt2size = (int)(2. / linstep) + 1; - FromLT2 = (uint16_t *)_TIFFmallocExt(tif, lt2size * sizeof(uint16_t)); - From14 = (uint16_t *)_TIFFmallocExt(tif, 16384 * sizeof(uint16_t)); - From8 = (uint16_t *)_TIFFmallocExt(tif, 256 * sizeof(uint16_t)); - ToLinearF = (float *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(float)); - ToLinear16 = (uint16_t *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(uint16_t)); - ToLinear8 = - (unsigned char *)_TIFFmallocExt(tif, TSIZEP1 * sizeof(unsigned char)); - if (FromLT2 == NULL || From14 == NULL || From8 == NULL || - ToLinearF == NULL || ToLinear16 == NULL || ToLinear8 == NULL) - { - if (FromLT2) - _TIFFfreeExt(tif, FromLT2); - if (From14) - _TIFFfreeExt(tif, From14); - if (From8) - _TIFFfreeExt(tif, From8); - if (ToLinearF) - _TIFFfreeExt(tif, ToLinearF); - if (ToLinear16) - _TIFFfreeExt(tif, ToLinear16); - if (ToLinear8) - _TIFFfreeExt(tif, ToLinear8); - sp->FromLT2 = NULL; - sp->From14 = NULL; - sp->From8 = NULL; - sp->ToLinearF = NULL; - sp->ToLinear16 = NULL; - sp->ToLinear8 = NULL; - return 0; + 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)); + ToLinearF = (float *)_TIFFmalloc(TSIZEP1 * sizeof(float)); + ToLinear16 = (uint16 *)_TIFFmalloc(TSIZEP1 * sizeof(uint16)); + ToLinear8 = (unsigned char *)_TIFFmalloc(TSIZEP1 * sizeof(unsigned char)); + if (FromLT2 == NULL || From14 == NULL || From8 == NULL || + ToLinearF == NULL || ToLinear16 == NULL || ToLinear8 == NULL) { + if (FromLT2) _TIFFfree(FromLT2); + if (From14) _TIFFfree(From14); + if (From8) _TIFFfree(From8); + if (ToLinearF) _TIFFfree(ToLinearF); + if (ToLinear16) _TIFFfree(ToLinear16); + if (ToLinear8) _TIFFfree(ToLinear8); + sp->FromLT2 = NULL; + sp->From14 = NULL; + sp->From8 = NULL; + sp->ToLinearF = NULL; + sp->ToLinear16 = NULL; + sp->ToLinear8 = NULL; + return 0; } j = 0; - for (i = 0; i < nlin; i++) - { - v = i * linstep; - ToLinearF[j++] = (float)v; + for (i = 0; i < nlin; i++) { + v = i * linstep; + ToLinearF[j++] = (float)v; } for (i = nlin; i < TSIZE; i++) - ToLinearF[j++] = (float)(b * exp(c * i)); + ToLinearF[j++] = (float)(b*exp(c*i)); ToLinearF[2048] = ToLinearF[2047]; - for (i = 0; i < TSIZEP1; i++) - { - v = ToLinearF[i] * 65535.0 + 0.5; - 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; + for (i = 0; i < TSIZEP1; i++) { + v = ToLinearF[i]*65535.0 + 0.5; + ToLinear16[i] = (v > 65535.0) ? 65535 : (uint16)v; + v = ToLinearF[i]*255.0 + 0.5; + ToLinear8[i] = (v > 255.0) ? 255 : (unsigned char)v; } j = 0; - for (i = 0; i < lt2size; i++) - { - if ((i * linstep) * (i * linstep) > ToLinearF[j] * ToLinearF[j + 1]) - j++; - FromLT2[i] = (uint16_t)j; + for (i = 0; i < lt2size; i++) { + if ((i*linstep)*(i*linstep) > ToLinearF[j]*ToLinearF[j+1]) + j++; + FromLT2[i] = (uint16)j; } /* @@ -643,22 +566,20 @@ static int PixarLogMakeTables(TIFF *tif, PixarLogState *sp) * saves a little table space. */ j = 0; - for (i = 0; i < 16384; i++) - { - while ((i / 16383.) * (i / 16383.) > ToLinearF[j] * ToLinearF[j + 1]) - j++; - From14[i] = (uint16_t)j; + for (i = 0; i < 16384; i++) { + while ((i/16383.)*(i/16383.) > ToLinearF[j]*ToLinearF[j+1]) + j++; + From14[i] = (uint16)j; } j = 0; - for (i = 0; i < 256; i++) - { - while ((i / 255.) * (i / 255.) > ToLinearF[j] * ToLinearF[j + 1]) - j++; - From8[i] = (uint16_t)j; + for (i = 0; i < 256; i++) { + while ((i/255.)*(i/255.) > ToLinearF[j]*ToLinearF[j+1]) + j++; + From8[i] = (uint16)j; } - Fltsize = (float)(lt2size / 2); + Fltsize = (float)(lt2size/2); sp->ToLinearF = ToLinearF; sp->ToLinear16 = ToLinear16; @@ -670,727 +591,622 @@ static int PixarLogMakeTables(TIFF *tif, PixarLogState *sp) return 1; } -#define DecoderState(tif) ((PixarLogState *)(tif)->tif_data) -#define EncoderState(tif) ((PixarLogState *)(tif)->tif_data) +#define DecoderState(tif) ((PixarLogState*) (tif)->tif_data) +#define EncoderState(tif) ((PixarLogState*) (tif)->tif_data) -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); +static int PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); +static int PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); -#define PIXARLOGDATAFMT_UNKNOWN -1 +#define PIXARLOGDATAFMT_UNKNOWN -1 -static int PixarLogGuessDataFmt(TIFFDirectory *td) +static int +PixarLogGuessDataFmt(TIFFDirectory *td) { - int guess = PIXARLOGDATAFMT_UNKNOWN; - int format = td->td_sampleformat; + int guess = PIXARLOGDATAFMT_UNKNOWN; + int format = td->td_sampleformat; - /* If the user didn't tell us his datafmt, - * take our best guess from the bitspersample. - */ - switch (td->td_bitspersample) - { - case 32: - if (format == SAMPLEFORMAT_IEEEFP) - guess = PIXARLOGDATAFMT_FLOAT; - break; - case 16: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) - guess = PIXARLOGDATAFMT_16BIT; - break; - case 12: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_INT) - guess = PIXARLOGDATAFMT_12BITPICIO; - break; - case 11: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) - guess = PIXARLOGDATAFMT_11BITLOG; - break; - case 8: - if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) - guess = PIXARLOGDATAFMT_8BIT; - break; - } + /* If the user didn't tell us his datafmt, + * take our best guess from the bitspersample. + */ + switch (td->td_bitspersample) { + case 32: + if (format == SAMPLEFORMAT_IEEEFP) + guess = PIXARLOGDATAFMT_FLOAT; + break; + case 16: + if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) + guess = PIXARLOGDATAFMT_16BIT; + break; + case 12: + if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_INT) + guess = PIXARLOGDATAFMT_12BITPICIO; + break; + case 11: + if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) + guess = PIXARLOGDATAFMT_11BITLOG; + break; + case 8: + if (format == SAMPLEFORMAT_VOID || format == SAMPLEFORMAT_UINT) + guess = PIXARLOGDATAFMT_8BIT; + break; + } - return guess; + return guess; } -static tmsize_t multiply_ms(tmsize_t m1, tmsize_t m2) +static tmsize_t +multiply_ms(tmsize_t m1, tmsize_t m2) { - return _TIFFMultiplySSize(NULL, m1, m2, NULL); + return _TIFFMultiplySSize(NULL, m1, m2, NULL); } -static tmsize_t add_ms(tmsize_t m1, tmsize_t m2) +static tmsize_t +add_ms(tmsize_t m1, tmsize_t m2) { - assert(m1 >= 0 && m2 >= 0); - /* if either input is zero, assume overflow already occurred */ - if (m1 == 0 || m2 == 0) - return 0; - else if (m1 > TIFF_TMSIZE_T_MAX - m2) - return 0; + assert(m1 >= 0 && m2 >= 0); + /* if either input is zero, assume overflow already occurred */ + if (m1 == 0 || m2 == 0) + return 0; + else if (m1 > TIFF_TMSIZE_T_MAX - m2) + return 0; - return m1 + m2; + return m1 + m2; } -static int PixarLogFixupTags(TIFF *tif) +static int +PixarLogFixupTags(TIFF* tif) { - (void)tif; - return (1); + (void) tif; + return (1); } -static int PixarLogSetupDecode(TIFF *tif) +static int +PixarLogSetupDecode(TIFF* tif) { - static const char module[] = "PixarLogSetupDecode"; - TIFFDirectory *td = &tif->tif_dir; - PixarLogState *sp = DecoderState(tif); - tmsize_t tbuf_size; - uint32_t strip_height; + static const char module[] = "PixarLogSetupDecode"; + TIFFDirectory *td = &tif->tif_dir; + PixarLogState* sp = DecoderState(tif); + tmsize_t tbuf_size; + uint32 strip_height; - assert(sp != NULL); + assert(sp != NULL); - /* This function can possibly be called several times by */ - /* PredictorSetupDecode() if this function succeeds but */ - /* PredictorSetup() fails */ - if ((sp->state & PLSTATE_INIT) != 0) - return 1; + /* This function can possibly be called several times by */ + /* PredictorSetupDecode() if this function succeeds but */ + /* PredictorSetup() fails */ + if( (sp->state & PLSTATE_INIT) != 0 ) + return 1; - strip_height = td->td_rowsperstrip; - if (strip_height > td->td_imagelength) - strip_height = td->td_imagelength; + strip_height = td->td_rowsperstrip; + if( strip_height > td->td_imagelength ) + strip_height = td->td_imagelength; - /* Make sure no byte swapping happens on the data - * after decompression. */ - tif->tif_postdecode = _TIFFNoPostDecode; + /* Make sure no byte swapping happens on the data + * after decompression. */ + tif->tif_postdecode = _TIFFNoPostDecode; - /* for some reason, we can't do this in TIFFInitPixarLog */ + /* for some reason, we can't do this in TIFFInitPixarLog */ - 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_t)); - /* add one more stride in case input ends mid-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_t *)_TIFFmallocExt(tif, tbuf_size); - if (sp->tbuf == NULL) - return (0); - sp->tbuf_size = tbuf_size; - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) - sp->user_datafmt = PixarLogGuessDataFmt(td); - if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) - { - _TIFFfreeExt(tif, sp->tbuf); - sp->tbuf = NULL; - sp->tbuf_size = 0; - TIFFErrorExtR(tif, module, - "PixarLog compression can't handle bits depth/data " - "format combination (depth: %" PRIu16 ")", - td->td_bitspersample); - return (0); - } + 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)); + /* add one more stride in case input ends mid-stride */ + tbuf_size = add_ms(tbuf_size, sizeof(uint16) * sp->stride); + if (tbuf_size == 0) + return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ + sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); + if (sp->tbuf == NULL) + return (0); + sp->tbuf_size = tbuf_size; + if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) + sp->user_datafmt = PixarLogGuessDataFmt(td); + if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) { + _TIFFfree(sp->tbuf); + sp->tbuf = NULL; + sp->tbuf_size = 0; + TIFFErrorExt(tif->tif_clientdata, module, + "PixarLog compression can't handle bits depth/data format combination (depth: %d)", + td->td_bitspersample); + return (0); + } - if (inflateInit(&sp->stream) != Z_OK) - { - _TIFFfreeExt(tif, sp->tbuf); - sp->tbuf = NULL; - sp->tbuf_size = 0; - TIFFErrorExtR(tif, module, "%s", - sp->stream.msg ? sp->stream.msg : "(null)"); - return (0); - } - else - { - sp->state |= PLSTATE_INIT; - return (1); - } + if (inflateInit(&sp->stream) != Z_OK) { + _TIFFfree(sp->tbuf); + sp->tbuf = NULL; + sp->tbuf_size = 0; + TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg ? sp->stream.msg : "(null)"); + return (0); + } else { + sp->state |= PLSTATE_INIT; + return (1); + } } /* * Setup state for decoding a strip. */ -static int PixarLogPreDecode(TIFF *tif, uint16_t s) +static int +PixarLogPreDecode(TIFF* tif, uint16 s) { - static const char module[] = "PixarLogPreDecode"; - PixarLogState *sp = DecoderState(tif); + static const char module[] = "PixarLogPreDecode"; + PixarLogState* sp = DecoderState(tif); - (void)s; - assert(sp != NULL); - sp->stream.next_in = tif->tif_rawdata; - assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised, - we need to simplify this code to reflect a ZLib that is likely updated - to deal with 8byte memory sizes, though this code will respond - appropriately even before we simplify it */ - sp->stream.avail_in = (uInt)tif->tif_rawcc; - if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc) - { - TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size"); - return (0); - } - return (inflateReset(&sp->stream) == Z_OK); + (void) s; + assert(sp != NULL); + sp->stream.next_in = tif->tif_rawdata; + assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + appropriately even before we simplify it */ + sp->stream.avail_in = (uInt) tif->tif_rawcc; + if ((tmsize_t)sp->stream.avail_in != tif->tif_rawcc) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } + return (inflateReset(&sp->stream) == Z_OK); } -static int PixarLogDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) +static int +PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - static const char module[] = "PixarLogDecode"; - TIFFDirectory *td = &tif->tif_dir; - PixarLogState *sp = DecoderState(tif); - tmsize_t i; - tmsize_t nsamples; - int llen; - uint16_t *up; + static const char module[] = "PixarLogDecode"; + TIFFDirectory *td = &tif->tif_dir; + PixarLogState* sp = DecoderState(tif); + tmsize_t i; + tmsize_t nsamples; + int llen; + uint16 *up; - switch (sp->user_datafmt) - { - case PIXARLOGDATAFMT_FLOAT: - nsamples = occ / sizeof(float); /* XXX float == 32 bits */ - break; - case PIXARLOGDATAFMT_16BIT: - case PIXARLOGDATAFMT_12BITPICIO: - case PIXARLOGDATAFMT_11BITLOG: - nsamples = occ / sizeof(uint16_t); /* XXX uint16_t == 16 bits */ - break; - case PIXARLOGDATAFMT_8BIT: - case PIXARLOGDATAFMT_8BITABGR: - nsamples = occ; - break; - default: - TIFFErrorExtR(tif, module, - "%" PRIu16 " bit input not supported in PixarLog", - td->td_bitspersample); - return 0; - } + switch (sp->user_datafmt) { + case PIXARLOGDATAFMT_FLOAT: + nsamples = occ / sizeof(float); /* XXX float == 32 bits */ + break; + case PIXARLOGDATAFMT_16BIT: + case PIXARLOGDATAFMT_12BITPICIO: + case PIXARLOGDATAFMT_11BITLOG: + nsamples = occ / sizeof(uint16); /* XXX uint16 == 16 bits */ + break; + case PIXARLOGDATAFMT_8BIT: + case PIXARLOGDATAFMT_8BITABGR: + nsamples = occ; + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "%d bit input not supported in PixarLog", + td->td_bitspersample); + return 0; + } - llen = sp->stride * td->td_imagewidth; + llen = sp->stride * td->td_imagewidth; - (void)s; - assert(sp != NULL); + (void) s; + assert(sp != NULL); - sp->stream.next_in = tif->tif_rawcp; - sp->stream.avail_in = (uInt)tif->tif_rawcc; + sp->stream.next_in = tif->tif_rawcp; + sp->stream.avail_in = (uInt) tif->tif_rawcc; - sp->stream.next_out = (unsigned char *)sp->tbuf; - assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised, - we need to simplify this code to reflect a ZLib that is likely updated - to deal with 8byte memory sizes, though this code will respond - appropriately even before we simplify it */ - sp->stream.avail_out = (uInt)(nsamples * sizeof(uint16_t)); - if (sp->stream.avail_out != nsamples * sizeof(uint16_t)) - { - TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size"); - return (0); - } - /* Check that we will not fill more than what was allocated */ - if ((tmsize_t)sp->stream.avail_out > sp->tbuf_size) - { - TIFFErrorExtR(tif, module, "sp->stream.avail_out > sp->tbuf_size"); - return (0); - } - do - { - int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); - if (state == Z_STREAM_END) - { - break; /* XXX */ - } - if (state == Z_DATA_ERROR) - { - TIFFErrorExtR( - tif, module, "Decoding error at scanline %" PRIu32 ", %s", - tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)"); - return (0); - } - if (state != Z_OK) - { - TIFFErrorExtR(tif, module, "ZLib error: %s", - sp->stream.msg ? sp->stream.msg : "(null)"); - return (0); - } - } while (sp->stream.avail_out > 0); + sp->stream.next_out = (unsigned char *) sp->tbuf; + assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + appropriately even before we simplify it */ + sp->stream.avail_out = (uInt) (nsamples * sizeof(uint16)); + if (sp->stream.avail_out != nsamples * sizeof(uint16)) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } + /* Check that we will not fill more than what was allocated */ + if ((tmsize_t)sp->stream.avail_out > sp->tbuf_size) + { + TIFFErrorExt(tif->tif_clientdata, module, "sp->stream.avail_out > sp->tbuf_size"); + return (0); + } + do { + int state = inflate(&sp->stream, Z_PARTIAL_FLUSH); + if (state == Z_STREAM_END) { + break; /* XXX */ + } + 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)"); + return (0); + } + if (state != Z_OK) { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + sp->stream.msg ? sp->stream.msg : "(null)"); + return (0); + } + } while (sp->stream.avail_out > 0); - /* hopefully, we got all the bytes we needed */ - if (sp->stream.avail_out != 0) - { - TIFFErrorExtR(tif, module, - "Not enough data at scanline %" PRIu32 - " (short %u bytes)", - tif->tif_row, sp->stream.avail_out); - return (0); - } + /* 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); + return (0); + } - tif->tif_rawcp = sp->stream.next_in; - tif->tif_rawcc = sp->stream.avail_in; + tif->tif_rawcp = sp->stream.next_in; + tif->tif_rawcc = sp->stream.avail_in; - up = sp->tbuf; - /* Swap bytes in the data if from a different endian machine. */ - if (tif->tif_flags & TIFF_SWAB) - TIFFSwabArrayOfShort(up, nsamples); + up = sp->tbuf; + /* Swap bytes in the data if from a different endian machine. */ + if (tif->tif_flags & TIFF_SWAB) + TIFFSwabArrayOfShort(up, nsamples); - /* - * if llen is not an exact multiple of nsamples, the decode operation - * may overflow the output buffer, so truncate it enough to prevent - * that but still salvage as much data as possible. - */ - if (nsamples % llen) - { - TIFFWarningExtR(tif, module, - "stride %d is not a multiple of sample count, " - "%" TIFF_SSIZE_FORMAT ", data truncated.", - llen, nsamples); - nsamples -= nsamples % llen; - } + /* + * if llen is not an exact multiple of nsamples, the decode operation + * may overflow the output buffer, so truncate it enough to prevent + * that but still salvage as much data as possible. + */ + if (nsamples % llen) { + TIFFWarningExt(tif->tif_clientdata, module, + "stride %lu is not a multiple of sample count, " + "%lu, data truncated.", (unsigned long) llen, (unsigned long) nsamples); + nsamples -= nsamples % llen; + } - for (i = 0; i < nsamples; i += llen, up += llen) - { - switch (sp->user_datafmt) - { - case PIXARLOGDATAFMT_FLOAT: - horizontalAccumulateF(up, llen, sp->stride, (float *)op, - sp->ToLinearF); - op += llen * sizeof(float); - break; - case PIXARLOGDATAFMT_16BIT: - horizontalAccumulate16(up, llen, sp->stride, (uint16_t *)op, - sp->ToLinear16); - op += llen * sizeof(uint16_t); - break; - case PIXARLOGDATAFMT_12BITPICIO: - horizontalAccumulate12(up, llen, sp->stride, (int16_t *)op, - sp->ToLinearF); - op += llen * sizeof(int16_t); - break; - case PIXARLOGDATAFMT_11BITLOG: - horizontalAccumulate11(up, llen, sp->stride, (uint16_t *)op); - op += llen * sizeof(uint16_t); - break; - case PIXARLOGDATAFMT_8BIT: - horizontalAccumulate8(up, llen, sp->stride, (unsigned char *)op, - sp->ToLinear8); - op += llen * sizeof(unsigned char); - break; - case PIXARLOGDATAFMT_8BITABGR: - horizontalAccumulate8abgr(up, llen, sp->stride, - (unsigned char *)op, sp->ToLinear8); - op += llen * sizeof(unsigned char); - break; - default: - TIFFErrorExtR(tif, module, "Unsupported bits/sample: %" PRIu16, - td->td_bitspersample); - return (0); - } - } + for (i = 0; i < nsamples; i += llen, up += llen) { + switch (sp->user_datafmt) { + case PIXARLOGDATAFMT_FLOAT: + horizontalAccumulateF(up, llen, sp->stride, + (float *)op, sp->ToLinearF); + op += llen * sizeof(float); + break; + case PIXARLOGDATAFMT_16BIT: + horizontalAccumulate16(up, llen, sp->stride, + (uint16 *)op, sp->ToLinear16); + op += llen * sizeof(uint16); + break; + case PIXARLOGDATAFMT_12BITPICIO: + horizontalAccumulate12(up, llen, sp->stride, + (int16 *)op, sp->ToLinearF); + op += llen * sizeof(int16); + break; + case PIXARLOGDATAFMT_11BITLOG: + horizontalAccumulate11(up, llen, sp->stride, + (uint16 *)op); + op += llen * sizeof(uint16); + break; + case PIXARLOGDATAFMT_8BIT: + horizontalAccumulate8(up, llen, sp->stride, + (unsigned char *)op, sp->ToLinear8); + op += llen * sizeof(unsigned char); + break; + case PIXARLOGDATAFMT_8BITABGR: + horizontalAccumulate8abgr(up, llen, sp->stride, + (unsigned char *)op, sp->ToLinear8); + op += llen * sizeof(unsigned char); + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "Unsupported bits/sample: %d", + td->td_bitspersample); + return (0); + } + } - return (1); + return (1); } -static int PixarLogSetupEncode(TIFF *tif) +static int +PixarLogSetupEncode(TIFF* tif) { - static const char module[] = "PixarLogSetupEncode"; - TIFFDirectory *td = &tif->tif_dir; - PixarLogState *sp = EncoderState(tif); - tmsize_t tbuf_size; + static const char module[] = "PixarLogSetupEncode"; + TIFFDirectory *td = &tif->tif_dir; + PixarLogState* sp = EncoderState(tif); + tmsize_t tbuf_size; - assert(sp != NULL); + assert(sp != NULL); - /* for some reason, we can't do this in TIFFInitPixarLog */ + /* for some reason, we can't do this in TIFFInitPixarLog */ - 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_t)); - if (tbuf_size == 0) - return (0); /* TODO: this is an error return without error report - through TIFFErrorExt */ - sp->tbuf = (uint16_t *)_TIFFmallocExt(tif, 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) - { - TIFFErrorExtR(tif, module, - "PixarLog compression can't handle %" PRIu16 - " bit linear encodings", - td->td_bitspersample); - return (0); - } + 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)); + if (tbuf_size == 0) + return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ + sp->tbuf = (uint16 *) _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); + return (0); + } - if (deflateInit(&sp->stream, sp->quality) != Z_OK) - { - TIFFErrorExtR(tif, module, "%s", - sp->stream.msg ? sp->stream.msg : "(null)"); - return (0); - } - else - { - sp->state |= PLSTATE_INIT; - return (1); - } + if (deflateInit(&sp->stream, sp->quality) != Z_OK) { + TIFFErrorExt(tif->tif_clientdata, module, "%s", sp->stream.msg ? sp->stream.msg : "(null)"); + return (0); + } else { + sp->state |= PLSTATE_INIT; + return (1); + } } /* * Reset encoding state at the start of a strip. */ -static int PixarLogPreEncode(TIFF *tif, uint16_t s) +static int +PixarLogPreEncode(TIFF* tif, uint16 s) { - static const char module[] = "PixarLogPreEncode"; - PixarLogState *sp = EncoderState(tif); + static const char module[] = "PixarLogPreEncode"; + PixarLogState *sp = EncoderState(tif); - (void)s; - assert(sp != NULL); - sp->stream.next_out = tif->tif_rawdata; - assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised, - we need to simplify this code to reflect a ZLib that is likely updated - to deal with 8byte memory sizes, though this code will respond - appropriately even before we simplify it */ - sp->stream.avail_out = (uInt)tif->tif_rawdatasize; - if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) - { - TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size"); - return (0); - } - return (deflateReset(&sp->stream) == Z_OK); + (void) s; + assert(sp != NULL); + sp->stream.next_out = tif->tif_rawdata; + assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + appropriately even before we simplify it */ + sp->stream.avail_out = (uInt)tif->tif_rawdatasize; + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) + { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); + return (0); + } + return (deflateReset(&sp->stream) == Z_OK); } -static void horizontalDifferenceF(float *ip, int n, int stride, uint16_t *wp, - uint16_t *FromLT2) +static void +horizontalDifferenceF(float *ip, int n, int stride, uint16 *wp, uint16 *FromLT2) { - int32_t r1, g1, b1, a1, r2, g2, b2, a2, mask; + int32 r1, g1, b1, a1, r2, g2, b2, a2, mask; float fltsize = Fltsize; -#define CLAMP(v) \ - ((v < (float)0.) ? 0 \ - : (v < (float)2.) ? FromLT2[(int)(v * fltsize)] \ - : (v > (float)24.2) ? 2047 \ - : LogK1 * log(v * LogK2) + 0.5) +#define CLAMP(v) ( (v<(float)0.) ? 0 \ + : (v<(float)2.) ? FromLT2[(int)(v*fltsize)] \ + : (v>(float)24.2) ? 2047 \ + : LogK1*log(v*LogK2) + 0.5 ) mask = CODE_MASK; - if (n >= stride) - { - if (stride == 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]); - n -= 3; - while (n > 0) - { - n -= 3; - wp += 3; - ip += 3; - 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_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_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_t)CLAMP(ip[0]); wp++; ip++) + 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]); + 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; + } + } 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]); + 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; + } + } else { + REPEAT(stride, wp[0] = (uint16) 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++; ip++) n -= stride; - while (n > 0) - { - REPEAT(stride, - wp[0] = (uint16_t)(((int32_t)CLAMP(ip[0]) - - (int32_t)CLAMP(ip[-stride])) & - mask); - wp++; ip++) - n -= stride; - } } + } } } -static void horizontalDifference16(unsigned short *ip, int n, int stride, - unsigned short *wp, uint16_t *From14) +static void +horizontalDifference16(unsigned short *ip, int n, int stride, + unsigned short *wp, uint16 *From14) { - register int r1, g1, b1, a1, r2, g2, b2, a2, mask; + register int r1, g1, b1, a1, r2, g2, b2, a2, mask; /* assumption is unsigned pixel values */ -#undef CLAMP -#define CLAMP(v) From14[(v) >> 2] +#undef CLAMP +#define CLAMP(v) From14[(v) >> 2] mask = CODE_MASK; - if (n >= stride) - { - if (stride == 3) - { - r2 = wp[0] = CLAMP(ip[0]); - g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); - n -= 3; - while (n > 0) - { - n -= 3; - wp += 3; - ip += 3; - 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]); - b2 = wp[2] = CLAMP(ip[2]); - a2 = wp[3] = CLAMP(ip[3]); - n -= 4; - while (n > 0) - { - n -= 4; - wp += 4; - ip += 4; - 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++) + if (n >= stride) { + if (stride == 3) { + r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); + b2 = wp[2] = CLAMP(ip[2]); + n -= 3; + while (n > 0) { + 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; + } + } else if (stride == 4) { + r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); + b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]); + n -= 4; + while (n > 0) { + 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; + } + } 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++; ip++) n -= stride; - while (n > 0) - { - REPEAT(stride, - wp[0] = (uint16_t)((CLAMP(ip[0]) - CLAMP(ip[-stride])) & - mask); - wp++; ip++) - n -= stride; - } } + } } } -static void 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; -#undef CLAMP -#define CLAMP(v) (From8[(v)]) +static void +horizontalDifference8(unsigned char *ip, int n, int stride, + unsigned short *wp, uint16 *From8) +{ + register int r1, g1, b1, a1, r2, g2, b2, a2, mask; + +#undef CLAMP +#define CLAMP(v) (From8[(v)]) mask = CODE_MASK; - if (n >= stride) - { - if (stride == 3) - { - r2 = wp[0] = CLAMP(ip[0]); - g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); - n -= 3; - while (n > 0) - { - n -= 3; - 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; - } - } - else if (stride == 4) - { - r2 = wp[0] = CLAMP(ip[0]); - g2 = wp[1] = CLAMP(ip[1]); - b2 = wp[2] = CLAMP(ip[2]); - a2 = wp[3] = CLAMP(ip[3]); - n -= 4; - while (n > 0) - { - n -= 4; - 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; - } - } - else - { - REPEAT(stride, wp[0] = CLAMP(ip[0]); wp++; ip++) + if (n >= stride) { + if (stride == 3) { + r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); + b2 = wp[2] = CLAMP(ip[2]); + 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; + wp += 3; + ip += 3; + } + } else if (stride == 4) { + r2 = wp[0] = CLAMP(ip[0]); g2 = wp[1] = CLAMP(ip[1]); + b2 = wp[2] = CLAMP(ip[2]); a2 = wp[3] = CLAMP(ip[3]); + 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; + wp += 4; + ip += 4; + } + } 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++; ip++) n -= stride; - while (n > 0) - { - REPEAT(stride, - wp[0] = (uint16_t)((CLAMP(ip[0]) - CLAMP(ip[-stride])) & - mask); - wp++; ip++) - n -= stride; - } } } + } } /* * Encode a chunk of pixels. */ -static int PixarLogEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +PixarLogEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "PixarLogEncode"; - TIFFDirectory *td = &tif->tif_dir; - PixarLogState *sp = EncoderState(tif); - tmsize_t i; - tmsize_t n; - int llen; - unsigned short *up; + static const char module[] = "PixarLogEncode"; + TIFFDirectory *td = &tif->tif_dir; + PixarLogState *sp = EncoderState(tif); + tmsize_t i; + tmsize_t n; + int llen; + unsigned short * up; - (void)s; + (void) s; - switch (sp->user_datafmt) + switch (sp->user_datafmt) { + case PIXARLOGDATAFMT_FLOAT: + n = cc / sizeof(float); /* XXX float == 32 bits */ + break; + case PIXARLOGDATAFMT_16BIT: + case PIXARLOGDATAFMT_12BITPICIO: + case PIXARLOGDATAFMT_11BITLOG: + n = cc / sizeof(uint16); /* XXX uint16 == 16 bits */ + break; + case PIXARLOGDATAFMT_8BIT: + case PIXARLOGDATAFMT_8BITABGR: + n = cc; + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "%d 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 */ + if( n > ((tmsize_t)td->td_rowsperstrip * llen) ) { - case PIXARLOGDATAFMT_FLOAT: - n = cc / sizeof(float); /* XXX float == 32 bits */ - break; - case PIXARLOGDATAFMT_16BIT: - case PIXARLOGDATAFMT_12BITPICIO: - case PIXARLOGDATAFMT_11BITLOG: - n = cc / sizeof(uint16_t); /* XXX uint16_t == 16 bits */ - break; - case PIXARLOGDATAFMT_8BIT: - case PIXARLOGDATAFMT_8BITABGR: - n = cc; - break; - default: - TIFFErrorExtR(tif, module, - "%" 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_t) of sp->tbuf */ - if (n > ((tmsize_t)td->td_rowsperstrip * llen)) - { - TIFFErrorExtR(tif, module, "Too many input bytes provided"); + TIFFErrorExt(tif->tif_clientdata, module, + "Too many input bytes provided"); return 0; } - for (i = 0, up = sp->tbuf; i < n; i += llen, up += llen) - { - switch (sp->user_datafmt) - { - case PIXARLOGDATAFMT_FLOAT: - horizontalDifferenceF((float *)bp, llen, sp->stride, up, - sp->FromLT2); - bp += llen * sizeof(float); - break; - case PIXARLOGDATAFMT_16BIT: - horizontalDifference16((uint16_t *)bp, llen, sp->stride, up, - sp->From14); - bp += llen * sizeof(uint16_t); - break; - case PIXARLOGDATAFMT_8BIT: - horizontalDifference8((unsigned char *)bp, llen, sp->stride, up, - sp->From8); - bp += llen * sizeof(unsigned char); - break; - default: - TIFFErrorExtR(tif, module, - "%" PRIu16 " bit input not supported in PixarLog", - td->td_bitspersample); - return 0; - } - } + for (i = 0, up = sp->tbuf; i < n; i += llen, up += llen) { + switch (sp->user_datafmt) { + case PIXARLOGDATAFMT_FLOAT: + horizontalDifferenceF((float *)bp, llen, + sp->stride, up, sp->FromLT2); + bp += llen * sizeof(float); + break; + case PIXARLOGDATAFMT_16BIT: + horizontalDifference16((uint16 *)bp, llen, + sp->stride, up, sp->From14); + bp += llen * sizeof(uint16); + break; + case PIXARLOGDATAFMT_8BIT: + horizontalDifference8((unsigned char *)bp, llen, + sp->stride, up, sp->From8); + bp += llen * sizeof(unsigned char); + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "%d bit input not supported in PixarLog", + td->td_bitspersample); + return 0; + } + } + + sp->stream.next_in = (unsigned char *) sp->tbuf; + assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + appropriately even before we simplify it */ + sp->stream.avail_in = (uInt) (n * sizeof(uint16)); + if ((sp->stream.avail_in / sizeof(uint16)) != (uInt) n) + { + TIFFErrorExt(tif->tif_clientdata, module, + "ZLib cannot deal with buffers this size"); + return (0); + } - sp->stream.next_in = (unsigned char *)sp->tbuf; - assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised, - we need to simplify this code to reflect a ZLib that is likely updated - to deal with 8byte memory sizes, though this code will respond - appropriately even before we simplify it */ - sp->stream.avail_in = (uInt)(n * sizeof(uint16_t)); - if ((sp->stream.avail_in / sizeof(uint16_t)) != (uInt)n) - { - TIFFErrorExtR(tif, module, "ZLib cannot deal with buffers this size"); - return (0); - } - - do - { - if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) - { - TIFFErrorExtR(tif, module, "Encoder error: %s", - sp->stream.msg ? sp->stream.msg : "(null)"); - return (0); - } - if (sp->stream.avail_out == 0) - { - tif->tif_rawcc = tif->tif_rawdatasize; - if (!TIFFFlushData1(tif)) - return 0; - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = - (uInt)tif - ->tif_rawdatasize; /* this is a safe typecast, as check is - made already in PixarLogPreEncode */ - } - } while (sp->stream.avail_in > 0); - return (1); + do { + if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { + TIFFErrorExt(tif->tif_clientdata, module, "Encoder error: %s", + sp->stream.msg ? sp->stream.msg : "(null)"); + return (0); + } + if (sp->stream.avail_out == 0) { + tif->tif_rawcc = tif->tif_rawdatasize; + if (!TIFFFlushData1(tif)) + return 0; + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in PixarLogPreEncode */ + } + } while (sp->stream.avail_in > 0); + return (1); } /* @@ -1398,273 +1214,267 @@ static int PixarLogEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) * string and tacking on an End Of Information code. */ -static int PixarLogPostEncode(TIFF *tif) +static int +PixarLogPostEncode(TIFF* tif) { - static const char module[] = "PixarLogPostEncode"; - PixarLogState *sp = EncoderState(tif); - int state; + static const char module[] = "PixarLogPostEncode"; + PixarLogState *sp = EncoderState(tif); + int state; - sp->stream.avail_in = 0; + sp->stream.avail_in = 0; - do - { - state = deflate(&sp->stream, Z_FINISH); - switch (state) - { - case Z_STREAM_END: - case Z_OK: - if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) - { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; - if (!TIFFFlushData1(tif)) - return 0; - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = - (uInt)tif->tif_rawdatasize; /* this is a safe typecast, - as check is made already - in PixarLogPreEncode */ - } - break; - default: - TIFFErrorExtR(tif, module, "ZLib error: %s", - sp->stream.msg ? sp->stream.msg : "(null)"); - return (0); + do { + state = deflate(&sp->stream, Z_FINISH); + switch (state) { + case Z_STREAM_END: + case Z_OK: + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) { + tif->tif_rawcc = + tif->tif_rawdatasize - sp->stream.avail_out; + if (!TIFFFlushData1(tif)) + return 0; + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (uInt) tif->tif_rawdatasize; /* this is a safe typecast, as check is made already in PixarLogPreEncode */ + } + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + sp->stream.msg ? sp->stream.msg : "(null)"); + return (0); + } + } while (state != Z_STREAM_END); + return (1); +} + +static void +PixarLogClose(TIFF* tif) +{ + PixarLogState* sp = (PixarLogState*) tif->tif_data; + TIFFDirectory *td = &tif->tif_dir; + + assert(sp != 0); + /* In a really sneaky (and really incorrect, and untruthful, and + * troublesome, and error-prone) maneuver that completely goes against + * the spirit of TIFF, and breaks TIFF, on close, we covertly + * modify both bitspersample and sampleformat in the directory to + * indicate 8-bit linear. This way, the decode "just works" even for + * readers that don't know about PixarLog, or how to set + * the PIXARLOGDATFMT pseudo-tag. + */ + + if (sp->state&PLSTATE_INIT) { + /* We test the state to avoid an issue such as in + * http://bugzilla.maptools.org/show_bug.cgi?id=2604 + * What appends in that case is that the bitspersample is 1 and + * a TransferFunction is set. The size of the TransferFunction + * depends on 1<td_bitspersample = 8; + td->td_sampleformat = SAMPLEFORMAT_UINT; } - } while (state != Z_STREAM_END); - return (1); } -static void PixarLogClose(TIFF *tif) +static void +PixarLogCleanup(TIFF* tif) { - PixarLogState *sp = (PixarLogState *)tif->tif_data; - TIFFDirectory *td = &tif->tif_dir; + PixarLogState* sp = (PixarLogState*) tif->tif_data; - assert(sp != 0); - /* In a really sneaky (and really incorrect, and untruthful, and - * troublesome, and error-prone) maneuver that completely goes against - * the spirit of TIFF, and breaks TIFF, on close, we covertly - * modify both bitspersample and sampleformat in the directory to - * indicate 8-bit linear. This way, the decode "just works" even for - * readers that don't know about PixarLog, or how to set - * the PIXARLOGDATFMT pseudo-tag. - */ + assert(sp != 0); - if (sp->state & PLSTATE_INIT) - { - /* We test the state to avoid an issue such as in - * http://bugzilla.maptools.org/show_bug.cgi?id=2604 - * What appends in that case is that the bitspersample is 1 and - * a TransferFunction is set. The size of the TransferFunction - * depends on 1<td_bitspersample = 8; - td->td_sampleformat = SAMPLEFORMAT_UINT; - } + (void)TIFFPredictorCleanup(tif); + + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; + + if (sp->FromLT2) _TIFFfree(sp->FromLT2); + if (sp->From14) _TIFFfree(sp->From14); + if (sp->From8) _TIFFfree(sp->From8); + if (sp->ToLinearF) _TIFFfree(sp->ToLinearF); + if (sp->ToLinear16) _TIFFfree(sp->ToLinear16); + if (sp->ToLinear8) _TIFFfree(sp->ToLinear8); + if (sp->state&PLSTATE_INIT) { + if (tif->tif_mode == O_RDONLY) + inflateEnd(&sp->stream); + else + deflateEnd(&sp->stream); + } + if (sp->tbuf) + _TIFFfree(sp->tbuf); + _TIFFfree(sp); + tif->tif_data = NULL; + + _TIFFSetDefaultCompressionState(tif); } -static void PixarLogCleanup(TIFF *tif) -{ - PixarLogState *sp = (PixarLogState *)tif->tif_data; - - assert(sp != 0); - - (void)TIFFPredictorCleanup(tif); - - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - - if (sp->FromLT2) - _TIFFfreeExt(tif, sp->FromLT2); - if (sp->From14) - _TIFFfreeExt(tif, sp->From14); - if (sp->From8) - _TIFFfreeExt(tif, sp->From8); - if (sp->ToLinearF) - _TIFFfreeExt(tif, sp->ToLinearF); - if (sp->ToLinear16) - _TIFFfreeExt(tif, sp->ToLinear16); - if (sp->ToLinear8) - _TIFFfreeExt(tif, sp->ToLinear8); - if (sp->state & PLSTATE_INIT) - { - if (tif->tif_mode == O_RDONLY) - inflateEnd(&sp->stream); - else - deflateEnd(&sp->stream); - } - if (sp->tbuf) - _TIFFfreeExt(tif, sp->tbuf); - _TIFFfreeExt(tif, sp); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -static int PixarLogVSetField(TIFF *tif, uint32_t tag, va_list ap) +static int +PixarLogVSetField(TIFF* tif, uint32 tag, va_list ap) { static const char module[] = "PixarLogVSetField"; PixarLogState *sp = (PixarLogState *)tif->tif_data; int result; - switch (tag) - { - case TIFFTAG_PIXARLOGQUALITY: - sp->quality = (int)va_arg(ap, int); - if (tif->tif_mode != O_RDONLY && (sp->state & PLSTATE_INIT)) - { - if (deflateParams(&sp->stream, sp->quality, - Z_DEFAULT_STRATEGY) != Z_OK) - { - TIFFErrorExtR(tif, module, "ZLib error: %s", - sp->stream.msg ? sp->stream.msg : "(null)"); - return (0); - } - } - return (1); - case TIFFTAG_PIXARLOGDATAFMT: - sp->user_datafmt = (int)va_arg(ap, int); - /* Tweak the TIFF header so that the rest of libtiff knows what - * size of data will be passed between app and library, and - * assume that the app knows what it is doing and is not - * confused by these header manipulations... - */ - switch (sp->user_datafmt) - { - case PIXARLOGDATAFMT_8BIT: - case PIXARLOGDATAFMT_8BITABGR: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case PIXARLOGDATAFMT_11BITLOG: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case PIXARLOGDATAFMT_12BITPICIO: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); - break; - case PIXARLOGDATAFMT_16BIT: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case PIXARLOGDATAFMT_FLOAT: - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 32); - TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, - SAMPLEFORMAT_IEEEFP); - break; - } - /* - * Must recalculate sizes should bits/sample change. - */ - tif->tif_tilesize = - isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1); - tif->tif_scanlinesize = TIFFScanlineSize(tif); - result = 1; /* NB: pseudo tag */ - break; - default: - result = (*sp->vsetparent)(tif, tag, ap); + switch (tag) { + case TIFFTAG_PIXARLOGQUALITY: + sp->quality = (int) va_arg(ap, int); + if (tif->tif_mode != O_RDONLY && (sp->state&PLSTATE_INIT)) { + if (deflateParams(&sp->stream, + sp->quality, Z_DEFAULT_STRATEGY) != Z_OK) { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + sp->stream.msg ? sp->stream.msg : "(null)"); + return (0); + } + } + return (1); + case TIFFTAG_PIXARLOGDATAFMT: + sp->user_datafmt = (int) va_arg(ap, int); + /* Tweak the TIFF header so that the rest of libtiff knows what + * size of data will be passed between app and library, and + * assume that the app knows what it is doing and is not + * confused by these header manipulations... + */ + switch (sp->user_datafmt) { + case PIXARLOGDATAFMT_8BIT: + case PIXARLOGDATAFMT_8BITABGR: + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); + break; + case PIXARLOGDATAFMT_11BITLOG: + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); + TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); + break; + case PIXARLOGDATAFMT_12BITPICIO: + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); + TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); + break; + case PIXARLOGDATAFMT_16BIT: + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 16); + TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); + break; + case PIXARLOGDATAFMT_FLOAT: + TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 32); + TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); + break; + } + /* + * Must recalculate sizes should bits/sample change. + */ + tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tmsize_t)(-1); + tif->tif_scanlinesize = TIFFScanlineSize(tif); + result = 1; /* NB: pseudo tag */ + break; + default: + result = (*sp->vsetparent)(tif, tag, ap); } return (result); } -static int PixarLogVGetField(TIFF *tif, uint32_t tag, va_list ap) +static int +PixarLogVGetField(TIFF* tif, uint32 tag, va_list ap) { PixarLogState *sp = (PixarLogState *)tif->tif_data; - switch (tag) - { - case TIFFTAG_PIXARLOGQUALITY: - *va_arg(ap, int *) = sp->quality; - break; - case TIFFTAG_PIXARLOGDATAFMT: - *va_arg(ap, int *) = sp->user_datafmt; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); + switch (tag) { + case TIFFTAG_PIXARLOGQUALITY: + *va_arg(ap, int*) = sp->quality; + break; + case TIFFTAG_PIXARLOGDATAFMT: + *va_arg(ap, int*) = sp->user_datafmt; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); } return (1); } static const TIFFField pixarlogFields[] = { - {TIFFTAG_PIXARLOGDATAFMT, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL}, - {TIFFTAG_PIXARLOGQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL}}; + {TIFFTAG_PIXARLOGDATAFMT, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL}, + {TIFFTAG_PIXARLOGQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, FALSE, FALSE, "", NULL} +}; -int TIFFInitPixarLog(TIFF *tif, int scheme) +int +TIFFInitPixarLog(TIFF* tif, int scheme) { - static const char module[] = "TIFFInitPixarLog"; + static const char module[] = "TIFFInitPixarLog"; - PixarLogState *sp; + PixarLogState* sp; - (void)scheme; - assert(scheme == COMPRESSION_PIXARLOG); + (void)scheme; + assert(scheme == COMPRESSION_PIXARLOG); - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, pixarlogFields, TIFFArrayCount(pixarlogFields))) - { - TIFFErrorExtR(tif, module, - "Merging PixarLog codec-specific tags failed"); - return 0; - } + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, pixarlogFields, + TIFFArrayCount(pixarlogFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging PixarLog codec-specific tags failed"); + return 0; + } - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(PixarLogState)); - if (tif->tif_data == NULL) - goto bad; - sp = (PixarLogState *)tif->tif_data; - _TIFFmemset(sp, 0, sizeof(*sp)); - sp->stream.data_type = Z_BINARY; - sp->user_datafmt = PIXARLOGDATAFMT_UNKNOWN; + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof (PixarLogState)); + if (tif->tif_data == NULL) + goto bad; + sp = (PixarLogState*) tif->tif_data; + _TIFFmemset(sp, 0, sizeof (*sp)); + sp->stream.data_type = Z_BINARY; + sp->user_datafmt = PIXARLOGDATAFMT_UNKNOWN; - /* - * Install codec methods. - */ - tif->tif_fixuptags = PixarLogFixupTags; - tif->tif_setupdecode = PixarLogSetupDecode; - tif->tif_predecode = PixarLogPreDecode; - tif->tif_decoderow = PixarLogDecode; - tif->tif_decodestrip = PixarLogDecode; - tif->tif_decodetile = PixarLogDecode; - tif->tif_setupencode = PixarLogSetupEncode; - tif->tif_preencode = PixarLogPreEncode; - tif->tif_postencode = PixarLogPostEncode; - tif->tif_encoderow = PixarLogEncode; - tif->tif_encodestrip = PixarLogEncode; - tif->tif_encodetile = PixarLogEncode; - tif->tif_close = PixarLogClose; - tif->tif_cleanup = PixarLogCleanup; + /* + * Install codec methods. + */ + tif->tif_fixuptags = PixarLogFixupTags; + tif->tif_setupdecode = PixarLogSetupDecode; + tif->tif_predecode = PixarLogPreDecode; + tif->tif_decoderow = PixarLogDecode; + tif->tif_decodestrip = PixarLogDecode; + tif->tif_decodetile = PixarLogDecode; + tif->tif_setupencode = PixarLogSetupEncode; + tif->tif_preencode = PixarLogPreEncode; + tif->tif_postencode = PixarLogPostEncode; + tif->tif_encoderow = PixarLogEncode; + tif->tif_encodestrip = PixarLogEncode; + tif->tif_encodetile = PixarLogEncode; + tif->tif_close = PixarLogClose; + tif->tif_cleanup = PixarLogCleanup; - /* Override SetField so we can handle our private pseudo-tag */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = PixarLogVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = PixarLogVSetField; /* hook for codec tags */ + /* Override SetField so we can handle our private pseudo-tag */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = PixarLogVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = PixarLogVSetField; /* hook for codec tags */ - /* Default values for codec-specific fields */ - sp->quality = Z_DEFAULT_COMPRESSION; /* default comp. level */ - sp->state = 0; + /* Default values for codec-specific fields */ + sp->quality = Z_DEFAULT_COMPRESSION; /* default comp. level */ + sp->state = 0; - /* we don't wish to use the predictor, - * the default is none, which predictor value 1 - */ - (void)TIFFPredictorInit(tif); + /* we don't wish to use the predictor, + * the default is none, which predictor value 1 + */ + (void) TIFFPredictorInit(tif); - /* - * build the companding tables - */ - PixarLogMakeTables(tif, sp); + /* + * build the companding tables + */ + PixarLogMakeTables(sp); - return (1); + return (1); bad: - TIFFErrorExtR(tif, module, "No space for PixarLog state block"); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, + "No space for PixarLog state block"); + return (0); } #endif /* PIXARLOG_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_predict.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_predict.c index 386b5fe82..c02339745 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_predict.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_predict.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -27,309 +27,246 @@ * * Predictor Tag Support (used by multiple codecs). */ -#include "tif_predict.h" #include "tiffiop.h" +#include "tif_predict.h" -#define PredictorState(tif) ((TIFFPredictorState *)(tif)->tif_data) +#define PredictorState(tif) ((TIFFPredictorState*) (tif)->tif_data) -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 horAcc64(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 swabHorAcc64(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 horDiff64(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 swabHorDiff64(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 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 PredictorSetup(TIFF *tif) +static int +PredictorSetup(TIFF* tif) { - static const char module[] = "PredictorSetup"; + static const char module[] = "PredictorSetup"; - TIFFPredictorState *sp = PredictorState(tif); - TIFFDirectory *td = &tif->tif_dir; + TIFFPredictorState* sp = PredictorState(tif); + TIFFDirectory* td = &tif->tif_dir; - switch (sp->predictor) /* no differencing */ - { - case PREDICTOR_NONE: - return 1; - case PREDICTOR_HORIZONTAL: - if (td->td_bitspersample != 8 && td->td_bitspersample != 16 && - td->td_bitspersample != 32 && td->td_bitspersample != 64) - { - TIFFErrorExtR(tif, module, - "Horizontal differencing \"Predictor\" not " - "supported with %" PRIu16 "-bit samples", - td->td_bitspersample); - return 0; - } - break; - case PREDICTOR_FLOATINGPOINT: - if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP) - { - TIFFErrorExtR( - tif, module, - "Floating point \"Predictor\" not supported with %" PRIu16 - " data format", - td->td_sampleformat); - return 0; - } - if (td->td_bitspersample != 16 && td->td_bitspersample != 24 && - td->td_bitspersample != 32 && td->td_bitspersample != 64) - { /* Should 64 be allowed? */ - TIFFErrorExtR( - tif, module, - "Floating point \"Predictor\" not supported with %" PRIu16 - "-bit samples", - td->td_bitspersample); - return 0; - } - break; - default: - TIFFErrorExtR(tif, module, "\"Predictor\" value %d not supported", - sp->predictor); - return 0; - } - sp->stride = - (td->td_planarconfig == PLANARCONFIG_CONTIG ? td->td_samplesperpixel - : 1); - /* - * Calculate the scanline/tile-width size in bytes. - */ - if (isTiled(tif)) - sp->rowsize = TIFFTileRowSize(tif); - else - sp->rowsize = TIFFScanlineSize(tif); - if (sp->rowsize == 0) - return 0; + switch (sp->predictor) /* no differencing */ + { + case PREDICTOR_NONE: + return 1; + case PREDICTOR_HORIZONTAL: + if (td->td_bitspersample != 8 + && td->td_bitspersample != 16 + && td->td_bitspersample != 32) { + TIFFErrorExt(tif->tif_clientdata, module, + "Horizontal differencing \"Predictor\" not supported with %d-bit samples", + td->td_bitspersample); + return 0; + } + break; + case PREDICTOR_FLOATINGPOINT: + if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP) { + TIFFErrorExt(tif->tif_clientdata, module, + "Floating point \"Predictor\" not supported with %d data format", + td->td_sampleformat); + return 0; + } + if (td->td_bitspersample != 16 + && td->td_bitspersample != 24 + && 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", + td->td_bitspersample); + return 0; + } + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "\"Predictor\" value %d not supported", + sp->predictor); + return 0; + } + sp->stride = (td->td_planarconfig == PLANARCONFIG_CONTIG ? + td->td_samplesperpixel : 1); + /* + * Calculate the scanline/tile-width size in bytes. + */ + if (isTiled(tif)) + sp->rowsize = TIFFTileRowSize(tif); + else + sp->rowsize = TIFFScanlineSize(tif); + if (sp->rowsize == 0) + return 0; - return 1; + return 1; } -static int PredictorSetupDecode(TIFF *tif) +static int +PredictorSetupDecode(TIFF* tif) { - TIFFPredictorState *sp = PredictorState(tif); - TIFFDirectory *td = &tif->tif_dir; + TIFFPredictorState* sp = PredictorState(tif); + TIFFDirectory* td = &tif->tif_dir; - /* Note: when PredictorSetup() fails, the effets of setupdecode() */ - /* will not be "canceled" so setupdecode() might be robust to */ - /* be called several times. */ - if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif)) - return 0; + /* Note: when PredictorSetup() fails, the effets of setupdecode() */ + /* will not be "canceled" so setupdecode() might be robust to */ + /* be called several times. */ + if (!(*sp->setupdecode)(tif) || !PredictorSetup(tif)) + return 0; - if (sp->predictor == 2) - { - switch (td->td_bitspersample) - { - case 8: - sp->decodepfunc = horAcc8; - break; - case 16: - sp->decodepfunc = horAcc16; - break; - case 32: - sp->decodepfunc = horAcc32; - break; - case 64: - sp->decodepfunc = horAcc64; - break; - } - /* - * Override default decoding method with one that does the - * predictor stuff. - */ - if (tif->tif_decoderow != PredictorDecodeRow) - { - sp->decoderow = tif->tif_decoderow; - tif->tif_decoderow = PredictorDecodeRow; - sp->decodestrip = tif->tif_decodestrip; - tif->tif_decodestrip = PredictorDecodeTile; - sp->decodetile = tif->tif_decodetile; - tif->tif_decodetile = PredictorDecodeTile; - } + if (sp->predictor == 2) { + switch (td->td_bitspersample) { + case 8: sp->decodepfunc = horAcc8; break; + case 16: sp->decodepfunc = horAcc16; break; + case 32: sp->decodepfunc = horAcc32; break; + } + /* + * Override default decoding method with one that does the + * predictor stuff. + */ + if( tif->tif_decoderow != PredictorDecodeRow ) + { + sp->decoderow = tif->tif_decoderow; + tif->tif_decoderow = PredictorDecodeRow; + sp->decodestrip = tif->tif_decodestrip; + tif->tif_decodestrip = PredictorDecodeTile; + sp->decodetile = tif->tif_decodetile; + tif->tif_decodetile = PredictorDecodeTile; + } - /* - * If the data is horizontally differenced 16-bit data that - * requires byte-swapping, then it must be byte swapped before - * the accumulation step. We do this with a special-purpose - * routine and override the normal post decoding logic that - * the library setup when the directory was read. - */ - if (tif->tif_flags & TIFF_SWAB) - { - if (sp->decodepfunc == horAcc16) - { - sp->decodepfunc = swabHorAcc16; - tif->tif_postdecode = _TIFFNoPostDecode; + /* + * If the data is horizontally differenced 16-bit data that + * requires byte-swapping, then it must be byte swapped before + * the accumulation step. We do this with a special-purpose + * routine and override the normal post decoding logic that + * the library setup when the directory was read. + */ + if (tif->tif_flags & TIFF_SWAB) { + if (sp->decodepfunc == horAcc16) { + sp->decodepfunc = swabHorAcc16; + tif->tif_postdecode = _TIFFNoPostDecode; + } else if (sp->decodepfunc == horAcc32) { + sp->decodepfunc = swabHorAcc32; + tif->tif_postdecode = _TIFFNoPostDecode; } - else if (sp->decodepfunc == horAcc32) - { - sp->decodepfunc = swabHorAcc32; - tif->tif_postdecode = _TIFFNoPostDecode; - } - else if (sp->decodepfunc == horAcc64) - { - sp->decodepfunc = swabHorAcc64; - tif->tif_postdecode = _TIFFNoPostDecode; - } - } - } + } + } - else if (sp->predictor == 3) - { - sp->decodepfunc = fpAcc; - /* - * Override default decoding method with one that does the - * predictor stuff. - */ - if (tif->tif_decoderow != PredictorDecodeRow) - { - sp->decoderow = tif->tif_decoderow; - tif->tif_decoderow = PredictorDecodeRow; - sp->decodestrip = tif->tif_decodestrip; - tif->tif_decodestrip = PredictorDecodeTile; - sp->decodetile = tif->tif_decodetile; - tif->tif_decodetile = PredictorDecodeTile; - } - /* - * The data should not be swapped outside of the floating - * point predictor, the accumulation routine should return - * byres in the native order. - */ - if (tif->tif_flags & TIFF_SWAB) - { - tif->tif_postdecode = _TIFFNoPostDecode; - } - /* - * Allocate buffer to keep the decoded bytes before - * rearranging in the right order - */ - } + else if (sp->predictor == 3) { + sp->decodepfunc = fpAcc; + /* + * Override default decoding method with one that does the + * predictor stuff. + */ + if( tif->tif_decoderow != PredictorDecodeRow ) + { + sp->decoderow = tif->tif_decoderow; + tif->tif_decoderow = PredictorDecodeRow; + sp->decodestrip = tif->tif_decodestrip; + tif->tif_decodestrip = PredictorDecodeTile; + sp->decodetile = tif->tif_decodetile; + tif->tif_decodetile = PredictorDecodeTile; + } + /* + * The data should not be swapped outside of the floating + * point predictor, the accumulation routine should return + * byres in the native order. + */ + if (tif->tif_flags & TIFF_SWAB) { + tif->tif_postdecode = _TIFFNoPostDecode; + } + /* + * Allocate buffer to keep the decoded bytes before + * rearranging in the right order + */ + } - return 1; + return 1; } -static int PredictorSetupEncode(TIFF *tif) +static int +PredictorSetupEncode(TIFF* tif) { - TIFFPredictorState *sp = PredictorState(tif); - TIFFDirectory *td = &tif->tif_dir; + TIFFPredictorState* sp = PredictorState(tif); + TIFFDirectory* td = &tif->tif_dir; - if (!(*sp->setupencode)(tif) || !PredictorSetup(tif)) - return 0; + if (!(*sp->setupencode)(tif) || !PredictorSetup(tif)) + return 0; - if (sp->predictor == 2) - { - switch (td->td_bitspersample) - { - case 8: - sp->encodepfunc = horDiff8; - break; - case 16: - sp->encodepfunc = horDiff16; - break; - case 32: - sp->encodepfunc = horDiff32; - break; - case 64: - sp->encodepfunc = horDiff64; - break; - } - /* - * Override default encoding method with one that does the - * predictor stuff. - */ - if (tif->tif_encoderow != PredictorEncodeRow) - { - sp->encoderow = tif->tif_encoderow; - tif->tif_encoderow = PredictorEncodeRow; - sp->encodestrip = tif->tif_encodestrip; - tif->tif_encodestrip = PredictorEncodeTile; - sp->encodetile = tif->tif_encodetile; - tif->tif_encodetile = PredictorEncodeTile; + if (sp->predictor == 2) { + switch (td->td_bitspersample) { + case 8: sp->encodepfunc = horDiff8; break; + case 16: sp->encodepfunc = horDiff16; break; + case 32: sp->encodepfunc = horDiff32; break; + } + /* + * Override default encoding method with one that does the + * predictor stuff. + */ + if( tif->tif_encoderow != PredictorEncodeRow ) + { + sp->encoderow = tif->tif_encoderow; + tif->tif_encoderow = PredictorEncodeRow; + sp->encodestrip = tif->tif_encodestrip; + tif->tif_encodestrip = PredictorEncodeTile; + sp->encodetile = tif->tif_encodetile; + tif->tif_encodetile = PredictorEncodeTile; + } + + /* + * If the data is horizontally differenced 16-bit data that + * requires byte-swapping, then it must be byte swapped after + * the differentiation step. We do this with a special-purpose + * routine and override the normal post decoding logic that + * the library setup when the directory was read. + */ + if (tif->tif_flags & TIFF_SWAB) { + if (sp->encodepfunc == horDiff16) { + sp->encodepfunc = swabHorDiff16; + tif->tif_postdecode = _TIFFNoPostDecode; + } else if (sp->encodepfunc == horDiff32) { + sp->encodepfunc = swabHorDiff32; + tif->tif_postdecode = _TIFFNoPostDecode; + } + } } - /* - * If the data is horizontally differenced 16-bit data that - * requires byte-swapping, then it must be byte swapped after - * the differentiation step. We do this with a special-purpose - * routine and override the normal post decoding logic that - * the library setup when the directory was read. - */ - if (tif->tif_flags & TIFF_SWAB) - { - if (sp->encodepfunc == horDiff16) - { - sp->encodepfunc = swabHorDiff16; - tif->tif_postdecode = _TIFFNoPostDecode; - } - else if (sp->encodepfunc == horDiff32) - { - sp->encodepfunc = swabHorDiff32; - tif->tif_postdecode = _TIFFNoPostDecode; - } - else if (sp->encodepfunc == horDiff64) - { - sp->encodepfunc = swabHorDiff64; - tif->tif_postdecode = _TIFFNoPostDecode; - } - } - } + else if (sp->predictor == 3) { + sp->encodepfunc = fpDiff; + /* + * Override default encoding method with one that does the + * predictor stuff. + */ + if( tif->tif_encoderow != PredictorEncodeRow ) + { + sp->encoderow = tif->tif_encoderow; + tif->tif_encoderow = PredictorEncodeRow; + sp->encodestrip = tif->tif_encodestrip; + tif->tif_encodestrip = PredictorEncodeTile; + sp->encodetile = tif->tif_encodetile; + tif->tif_encodetile = PredictorEncodeTile; + } + } - else if (sp->predictor == 3) - { - sp->encodepfunc = fpDiff; - /* - * Override default encoding method with one that does the - * predictor stuff. - */ - if (tif->tif_encoderow != PredictorEncodeRow) - { - sp->encoderow = tif->tif_encoderow; - tif->tif_encoderow = PredictorEncodeRow; - sp->encodestrip = tif->tif_encodestrip; - tif->tif_encodestrip = PredictorEncodeTile; - sp->encodetile = tif->tif_encodetile; - tif->tif_encodetile = PredictorEncodeTile; - } - } - - return 1; + return 1; } -#define REPEAT4(n, op) \ - switch (n) \ - { \ - default: \ - { \ - tmsize_t i; \ - for (i = n - 4; i > 0; i--) \ - { \ - op; \ - } \ - } /*-fallthrough*/ \ - case 4: \ - op; /*-fallthrough*/ \ - case 3: \ - op; /*-fallthrough*/ \ - case 2: \ - op; /*-fallthrough*/ \ - case 1: \ - op; /*-fallthrough*/ \ - case 0:; \ +#define REPEAT4(n, op) \ + switch (n) { \ + default: { \ + tmsize_t i; for (i = n-4; i > 0; i--) { op; } } /*-fallthrough*/ \ + case 4: op; /*-fallthrough*/ \ + case 3: op; /*-fallthrough*/ \ + case 2: op; /*-fallthrough*/ \ + case 1: op; /*-fallthrough*/ \ + case 0: ; \ } /* Remarks related to C standard compliance in all below functions : */ @@ -339,236 +276,196 @@ static int PredictorSetupEncode(TIFF *tif) /* as to make icc -check=conversions happy (not necessary by the standard) */ TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static int horAcc8(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +horAcc8(TIFF* tif, uint8* cp0, tmsize_t cc) { - tmsize_t stride = PredictorState(tif)->stride; + tmsize_t stride = PredictorState(tif)->stride; - unsigned char *cp = (unsigned char *)cp0; - if ((cc % stride) != 0) + unsigned char* cp = (unsigned char*) cp0; + if((cc%stride)!=0) { - TIFFErrorExtR(tif, "horAcc8", "%s", "(cc%stride)!=0"); + TIFFErrorExt(tif->tif_clientdata, "horAcc8", + "%s", "(cc%stride)!=0"); return 0; } - if (cc > stride) - { - /* - * Pipeline the most common cases. - */ - if (stride == 3) - { - unsigned int cr = cp[0]; - unsigned int cg = cp[1]; - unsigned int cb = cp[2]; - tmsize_t i = stride; - for (; i < cc; i += stride) - { - cp[i + 0] = (unsigned char)((cr += cp[i + 0]) & 0xff); - cp[i + 1] = (unsigned char)((cg += cp[i + 1]) & 0xff); - cp[i + 2] = (unsigned char)((cb += cp[i + 2]) & 0xff); - } - } - else if (stride == 4) - { - unsigned int cr = cp[0]; - unsigned int cg = cp[1]; - unsigned int cb = cp[2]; - unsigned int ca = cp[3]; - tmsize_t i = stride; - for (; i < cc; i += stride) - { - cp[i + 0] = (unsigned char)((cr += cp[i + 0]) & 0xff); - cp[i + 1] = (unsigned char)((cg += cp[i + 1]) & 0xff); - cp[i + 2] = (unsigned char)((cb += cp[i + 2]) & 0xff); - cp[i + 3] = (unsigned char)((ca += cp[i + 3]) & 0xff); - } - } - else - { - cc -= stride; - do - { - REPEAT4(stride, - cp[stride] = (unsigned char)((cp[stride] + *cp) & 0xff); - cp++) - cc -= stride; - } while (cc > 0); - } - } - return 1; + if (cc > stride) { + /* + * Pipeline the most common cases. + */ + if (stride == 3) { + unsigned int cr = cp[0]; + unsigned int cg = cp[1]; + unsigned int cb = cp[2]; + cc -= 3; + cp += 3; + while (cc>0) { + cp[0] = (unsigned char) ((cr += cp[0]) & 0xff); + cp[1] = (unsigned char) ((cg += cp[1]) & 0xff); + cp[2] = (unsigned char) ((cb += cp[2]) & 0xff); + cc -= 3; + cp += 3; + } + } else if (stride == 4) { + unsigned int cr = cp[0]; + unsigned int cg = cp[1]; + unsigned int cb = cp[2]; + unsigned int ca = cp[3]; + cc -= 4; + cp += 4; + while (cc>0) { + cp[0] = (unsigned char) ((cr += cp[0]) & 0xff); + cp[1] = (unsigned char) ((cg += cp[1]) & 0xff); + cp[2] = (unsigned char) ((cb += cp[2]) & 0xff); + cp[3] = (unsigned char) ((ca += cp[3]) & 0xff); + cc -= 4; + cp += 4; + } + } else { + cc -= stride; + do { + REPEAT4(stride, cp[stride] = + (unsigned char) ((cp[stride] + *cp) & 0xff); cp++) + cc -= stride; + } while (cc>0); + } + } + return 1; } -static int swabHorAcc16(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +swabHorAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) { - uint16_t *wp = (uint16_t *)cp0; - tmsize_t wc = cc / 2; + uint16* wp = (uint16*) cp0; + tmsize_t wc = cc / 2; - TIFFSwabArrayOfShort(wp, wc); - return horAcc16(tif, cp0, cc); + TIFFSwabArrayOfShort(wp, wc); + return horAcc16(tif, cp0, cc); } TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static int horAcc16(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +horAcc16(TIFF* tif, uint8* cp0, tmsize_t cc) { - tmsize_t stride = PredictorState(tif)->stride; - uint16_t *wp = (uint16_t *)cp0; - tmsize_t wc = cc / 2; + tmsize_t stride = PredictorState(tif)->stride; + uint16* wp = (uint16*) cp0; + tmsize_t wc = cc / 2; - if ((cc % (2 * stride)) != 0) + if((cc%(2*stride))!=0) { - TIFFErrorExtR(tif, "horAcc16", "%s", "cc%(2*stride))!=0"); + TIFFErrorExt(tif->tif_clientdata, "horAcc16", + "%s", "cc%(2*stride))!=0"); return 0; } - if (wc > stride) - { - wc -= stride; - do - { - REPEAT4(stride, wp[stride] = (uint16_t)(((unsigned int)wp[stride] + - (unsigned int)wp[0]) & - 0xffff); - wp++) - wc -= stride; - } while (wc > 0); - } - return 1; + if (wc > stride) { + wc -= stride; + do { + REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] + (unsigned int)wp[0]) & 0xffff); wp++) + wc -= stride; + } while (wc > 0); + } + return 1; } -static int swabHorAcc32(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +swabHorAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) { - uint32_t *wp = (uint32_t *)cp0; - tmsize_t wc = cc / 4; + uint32* wp = (uint32*) cp0; + tmsize_t wc = cc / 4; - TIFFSwabArrayOfLong(wp, wc); - return horAcc32(tif, cp0, cc); + TIFFSwabArrayOfLong(wp, wc); + return horAcc32(tif, cp0, cc); } TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static int horAcc32(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +horAcc32(TIFF* tif, uint8* cp0, tmsize_t cc) { - tmsize_t stride = PredictorState(tif)->stride; - uint32_t *wp = (uint32_t *)cp0; - tmsize_t wc = cc / 4; + tmsize_t stride = PredictorState(tif)->stride; + uint32* wp = (uint32*) cp0; + tmsize_t wc = cc / 4; - if ((cc % (4 * stride)) != 0) + if((cc%(4*stride))!=0) { - TIFFErrorExtR(tif, "horAcc32", "%s", "cc%(4*stride))!=0"); + TIFFErrorExt(tif->tif_clientdata, "horAcc32", + "%s", "cc%(4*stride))!=0"); return 0; } - if (wc > stride) - { - wc -= stride; - do - { - REPEAT4(stride, wp[stride] += wp[0]; wp++) - wc -= stride; - } while (wc > 0); - } - return 1; -} - -static int swabHorAcc64(TIFF *tif, uint8_t *cp0, tmsize_t cc) -{ - uint64_t *wp = (uint64_t *)cp0; - tmsize_t wc = cc / 8; - - TIFFSwabArrayOfLong8(wp, wc); - return horAcc64(tif, cp0, cc); -} - -TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static int horAcc64(TIFF *tif, uint8_t *cp0, tmsize_t cc) -{ - tmsize_t stride = PredictorState(tif)->stride; - uint64_t *wp = (uint64_t *)cp0; - tmsize_t wc = cc / 8; - - if ((cc % (8 * stride)) != 0) - { - TIFFErrorExtR(tif, "horAcc64", "%s", "cc%(8*stride))!=0"); - return 0; - } - - if (wc > stride) - { - wc -= stride; - do - { - REPEAT4(stride, wp[stride] += wp[0]; wp++) - wc -= stride; - } while (wc > 0); - } - return 1; + if (wc > stride) { + wc -= stride; + do { + REPEAT4(stride, wp[stride] += wp[0]; wp++) + wc -= stride; + } while (wc > 0); + } + return 1; } /* * Floating point predictor accumulation routine. */ -static int fpAcc(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +fpAcc(TIFF* tif, uint8* cp0, tmsize_t cc) { - tmsize_t stride = PredictorState(tif)->stride; - uint32_t bps = tif->tif_dir.td_bitspersample / 8; - tmsize_t wc = cc / bps; - tmsize_t count = cc; - uint8_t *cp = (uint8_t *)cp0; - uint8_t *tmp; + tmsize_t stride = PredictorState(tif)->stride; + uint32 bps = tif->tif_dir.td_bitspersample / 8; + tmsize_t wc = cc / bps; + tmsize_t count = cc; + uint8 *cp = (uint8 *) cp0; + uint8 *tmp; - if (cc % (bps * stride) != 0) + if(cc%(bps*stride)!=0) { - TIFFErrorExtR(tif, "fpAcc", "%s", "cc%(bps*stride))!=0"); + TIFFErrorExt(tif->tif_clientdata, "fpAcc", + "%s", "cc%(bps*stride))!=0"); return 0; } - tmp = (uint8_t *)_TIFFmallocExt(tif, cc); - if (!tmp) - return 0; + tmp = (uint8 *)_TIFFmalloc(cc); + if (!tmp) + return 0; - while (count > stride) - { - REPEAT4(stride, - cp[stride] = (unsigned char)((cp[stride] + cp[0]) & 0xff); - cp++) - count -= stride; - } + while (count > stride) { + REPEAT4(stride, cp[stride] = + (unsigned char) ((cp[stride] + cp[0]) & 0xff); cp++) + count -= stride; + } - _TIFFmemcpy(tmp, cp0, cc); - cp = (uint8_t *)cp0; - for (count = 0; count < wc; count++) - { - uint32_t byte; - for (byte = 0; byte < bps; byte++) - { -#if WORDS_BIGENDIAN - cp[bps * count + byte] = tmp[byte * wc + count]; -#else - cp[bps * count + byte] = tmp[(bps - byte - 1) * wc + count]; -#endif - } - } - _TIFFfreeExt(tif, tmp); + _TIFFmemcpy(tmp, cp0, cc); + cp = (uint8 *) cp0; + for (count = 0; count < wc; count++) { + uint32 byte; + for (byte = 0; byte < bps; byte++) { + #if WORDS_BIGENDIAN + cp[bps * count + byte] = tmp[byte * wc + count]; + #else + cp[bps * count + byte] = + tmp[(bps - byte - 1) * wc + count]; + #endif + } + } + _TIFFfree(tmp); return 1; } /* * Decode a scanline and apply the predictor routine. */ -static int PredictorDecodeRow(TIFF *tif, uint8_t *op0, tmsize_t occ0, - uint16_t s) +static int +PredictorDecodeRow(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) { - TIFFPredictorState *sp = PredictorState(tif); + TIFFPredictorState *sp = PredictorState(tif); - assert(sp != NULL); - assert(sp->decoderow != NULL); - assert(sp->decodepfunc != NULL); + assert(sp != NULL); + assert(sp->decoderow != NULL); + assert(sp->decodepfunc != NULL); - if ((*sp->decoderow)(tif, op0, occ0, s)) - { - return (*sp->decodepfunc)(tif, op0, occ0); - } - else - return 0; + if ((*sp->decoderow)(tif, op0, occ0, s)) { + return (*sp->decodepfunc)(tif, op0, occ0); + } else + return 0; } /* @@ -578,152 +475,123 @@ static int PredictorDecodeRow(TIFF *tif, uint8_t *op0, tmsize_t occ0, * been calculated at pre-decode time according to the * strip/tile dimensions. */ -static int PredictorDecodeTile(TIFF *tif, uint8_t *op0, tmsize_t occ0, - uint16_t s) +static int +PredictorDecodeTile(TIFF* tif, uint8* op0, tmsize_t occ0, uint16 s) { - TIFFPredictorState *sp = PredictorState(tif); + TIFFPredictorState *sp = PredictorState(tif); - assert(sp != NULL); - assert(sp->decodetile != NULL); + assert(sp != NULL); + assert(sp->decodetile != NULL); - if ((*sp->decodetile)(tif, op0, occ0, s)) - { - tmsize_t rowsize = sp->rowsize; - assert(rowsize > 0); - if ((occ0 % rowsize) != 0) + if ((*sp->decodetile)(tif, op0, occ0, s)) { + tmsize_t rowsize = sp->rowsize; + assert(rowsize > 0); + if((occ0%rowsize) !=0) { - TIFFErrorExtR(tif, "PredictorDecodeTile", "%s", - "occ0%rowsize != 0"); + TIFFErrorExt(tif->tif_clientdata, "PredictorDecodeTile", + "%s", "occ0%rowsize != 0"); return 0; } - assert(sp->decodepfunc != NULL); - while (occ0 > 0) - { - if (!(*sp->decodepfunc)(tif, op0, rowsize)) + assert(sp->decodepfunc != NULL); + while (occ0 > 0) { + if( !(*sp->decodepfunc)(tif, op0, rowsize) ) return 0; - occ0 -= rowsize; - op0 += rowsize; - } - return 1; - } - else - return 0; + occ0 -= rowsize; + op0 += rowsize; + } + return 1; + } else + return 0; } TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static int horDiff8(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +horDiff8(TIFF* tif, uint8* cp0, tmsize_t cc) { - TIFFPredictorState *sp = PredictorState(tif); - tmsize_t stride = sp->stride; - unsigned char *cp = (unsigned char *)cp0; + TIFFPredictorState* sp = PredictorState(tif); + tmsize_t stride = sp->stride; + unsigned char* cp = (unsigned char*) cp0; - if ((cc % stride) != 0) + if((cc%stride)!=0) { - TIFFErrorExtR(tif, "horDiff8", "%s", "(cc%stride)!=0"); + TIFFErrorExt(tif->tif_clientdata, "horDiff8", + "%s", "(cc%stride)!=0"); return 0; } - if (cc > stride) - { - cc -= stride; - /* - * Pipeline the most common cases. - */ - if (stride == 3) - { - unsigned int r1, g1, b1; - unsigned int r2 = cp[0]; - unsigned int g2 = cp[1]; - unsigned int b2 = cp[2]; - do - { - r1 = cp[3]; - cp[3] = (unsigned char)((r1 - r2) & 0xff); - r2 = r1; - g1 = cp[4]; - cp[4] = (unsigned char)((g1 - g2) & 0xff); - g2 = g1; - b1 = cp[5]; - cp[5] = (unsigned char)((b1 - b2) & 0xff); - b2 = b1; - cp += 3; - } while ((cc -= 3) > 0); - } - else if (stride == 4) - { - unsigned int r1, g1, b1, a1; - unsigned int r2 = cp[0]; - unsigned int g2 = cp[1]; - unsigned int b2 = cp[2]; - unsigned int a2 = cp[3]; - do - { - r1 = cp[4]; - cp[4] = (unsigned char)((r1 - r2) & 0xff); - r2 = r1; - g1 = cp[5]; - cp[5] = (unsigned char)((g1 - g2) & 0xff); - g2 = g1; - b1 = cp[6]; - cp[6] = (unsigned char)((b1 - b2) & 0xff); - b2 = b1; - a1 = cp[7]; - cp[7] = (unsigned char)((a1 - a2) & 0xff); - a2 = a1; - cp += 4; - } while ((cc -= 4) > 0); - } - else - { - cp += cc - 1; - do - { - REPEAT4(stride, - cp[stride] = - (unsigned char)((cp[stride] - cp[0]) & 0xff); - cp--) - } while ((cc -= stride) > 0); - } - } - return 1; + if (cc > stride) { + cc -= stride; + /* + * Pipeline the most common cases. + */ + if (stride == 3) { + unsigned int r1, g1, b1; + unsigned int r2 = cp[0]; + unsigned int g2 = cp[1]; + unsigned int b2 = cp[2]; + do { + r1 = cp[3]; cp[3] = (unsigned char)((r1-r2)&0xff); r2 = r1; + g1 = cp[4]; cp[4] = (unsigned char)((g1-g2)&0xff); g2 = g1; + b1 = cp[5]; cp[5] = (unsigned char)((b1-b2)&0xff); b2 = b1; + cp += 3; + } while ((cc -= 3) > 0); + } else if (stride == 4) { + unsigned int r1, g1, b1, a1; + unsigned int r2 = cp[0]; + unsigned int g2 = cp[1]; + unsigned int b2 = cp[2]; + unsigned int a2 = cp[3]; + do { + r1 = cp[4]; cp[4] = (unsigned char)((r1-r2)&0xff); r2 = r1; + g1 = cp[5]; cp[5] = (unsigned char)((g1-g2)&0xff); g2 = g1; + b1 = cp[6]; cp[6] = (unsigned char)((b1-b2)&0xff); b2 = b1; + a1 = cp[7]; cp[7] = (unsigned char)((a1-a2)&0xff); a2 = a1; + cp += 4; + } while ((cc -= 4) > 0); + } else { + cp += cc - 1; + do { + REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--) + } while ((cc -= stride) > 0); + } + } + return 1; } TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static int horDiff16(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +horDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) { - TIFFPredictorState *sp = PredictorState(tif); - tmsize_t stride = sp->stride; - uint16_t *wp = (uint16_t *)cp0; - tmsize_t wc = cc / 2; + TIFFPredictorState* sp = PredictorState(tif); + tmsize_t stride = sp->stride; + uint16 *wp = (uint16*) cp0; + tmsize_t wc = cc/2; - if ((cc % (2 * stride)) != 0) + if((cc%(2*stride))!=0) { - TIFFErrorExtR(tif, "horDiff8", "%s", "(cc%(2*stride))!=0"); + TIFFErrorExt(tif->tif_clientdata, "horDiff8", + "%s", "(cc%(2*stride))!=0"); return 0; } - if (wc > stride) - { - wc -= stride; - wp += wc - 1; - do - { - REPEAT4(stride, wp[stride] = (uint16_t)(((unsigned int)wp[stride] - - (unsigned int)wp[0]) & - 0xffff); - wp--) - wc -= stride; - } while (wc > 0); - } - return 1; + if (wc > stride) { + wc -= stride; + wp += wc - 1; + do { + REPEAT4(stride, wp[stride] = (uint16)(((unsigned int)wp[stride] - (unsigned int)wp[0]) & 0xffff); wp--) + wc -= stride; + } while (wc > 0); + } + return 1; } -static int swabHorDiff16(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +swabHorDiff16(TIFF* tif, uint8* cp0, tmsize_t cc) { - uint16_t *wp = (uint16_t *)cp0; + uint16* wp = (uint16*) cp0; tmsize_t wc = cc / 2; - if (!horDiff16(tif, cp0, cc)) + if( !horDiff16(tif, cp0, cc) ) return 0; TIFFSwabArrayOfShort(wp, wc); @@ -731,316 +599,281 @@ static int swabHorDiff16(TIFF *tif, uint8_t *cp0, tmsize_t cc) } TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static int horDiff32(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +horDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) { - TIFFPredictorState *sp = PredictorState(tif); - tmsize_t stride = sp->stride; - uint32_t *wp = (uint32_t *)cp0; - tmsize_t wc = cc / 4; + TIFFPredictorState* sp = PredictorState(tif); + tmsize_t stride = sp->stride; + uint32 *wp = (uint32*) cp0; + tmsize_t wc = cc/4; - if ((cc % (4 * stride)) != 0) + if((cc%(4*stride))!=0) { - TIFFErrorExtR(tif, "horDiff32", "%s", "(cc%(4*stride))!=0"); + TIFFErrorExt(tif->tif_clientdata, "horDiff32", + "%s", "(cc%(4*stride))!=0"); return 0; } - if (wc > stride) - { - wc -= stride; - wp += wc - 1; - do - { - REPEAT4(stride, wp[stride] -= wp[0]; wp--) - wc -= stride; - } while (wc > 0); - } - return 1; + if (wc > stride) { + wc -= stride; + wp += wc - 1; + do { + REPEAT4(stride, wp[stride] -= wp[0]; wp--) + wc -= stride; + } while (wc > 0); + } + return 1; } -static int swabHorDiff32(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +swabHorDiff32(TIFF* tif, uint8* cp0, tmsize_t cc) { - uint32_t *wp = (uint32_t *)cp0; + uint32* wp = (uint32*) cp0; tmsize_t wc = cc / 4; - if (!horDiff32(tif, cp0, cc)) + if( !horDiff32(tif, cp0, cc) ) return 0; TIFFSwabArrayOfLong(wp, wc); return 1; } -TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static int horDiff64(TIFF *tif, uint8_t *cp0, tmsize_t cc) -{ - TIFFPredictorState *sp = PredictorState(tif); - tmsize_t stride = sp->stride; - uint64_t *wp = (uint64_t *)cp0; - tmsize_t wc = cc / 8; - - if ((cc % (8 * stride)) != 0) - { - TIFFErrorExtR(tif, "horDiff64", "%s", "(cc%(8*stride))!=0"); - return 0; - } - - if (wc > stride) - { - wc -= stride; - wp += wc - 1; - do - { - REPEAT4(stride, wp[stride] -= wp[0]; wp--) - wc -= stride; - } while (wc > 0); - } - return 1; -} - -static int swabHorDiff64(TIFF *tif, uint8_t *cp0, tmsize_t cc) -{ - uint64_t *wp = (uint64_t *)cp0; - tmsize_t wc = cc / 8; - - if (!horDiff64(tif, cp0, cc)) - return 0; - - TIFFSwabArrayOfLong8(wp, wc); - return 1; -} - /* * Floating point predictor differencing routine. */ TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static int fpDiff(TIFF *tif, uint8_t *cp0, tmsize_t cc) +static int +fpDiff(TIFF* tif, uint8* cp0, tmsize_t cc) { - tmsize_t stride = PredictorState(tif)->stride; - uint32_t bps = tif->tif_dir.td_bitspersample / 8; - tmsize_t wc = cc / bps; - tmsize_t count; - uint8_t *cp = (uint8_t *)cp0; - uint8_t *tmp; + tmsize_t stride = PredictorState(tif)->stride; + uint32 bps = tif->tif_dir.td_bitspersample / 8; + tmsize_t wc = cc / bps; + tmsize_t count; + uint8 *cp = (uint8 *) cp0; + uint8 *tmp; - if ((cc % (bps * stride)) != 0) + if((cc%(bps*stride))!=0) { - TIFFErrorExtR(tif, "fpDiff", "%s", "(cc%(bps*stride))!=0"); + TIFFErrorExt(tif->tif_clientdata, "fpDiff", + "%s", "(cc%(bps*stride))!=0"); return 0; } - tmp = (uint8_t *)_TIFFmallocExt(tif, cc); - if (!tmp) - return 0; + tmp = (uint8 *)_TIFFmalloc(cc); + if (!tmp) + return 0; - _TIFFmemcpy(tmp, cp0, cc); - for (count = 0; count < wc; count++) - { - uint32_t byte; - for (byte = 0; byte < bps; byte++) - { -#if WORDS_BIGENDIAN - cp[byte * wc + count] = tmp[bps * count + byte]; -#else - cp[(bps - byte - 1) * wc + count] = tmp[bps * count + byte]; -#endif - } - } - _TIFFfreeExt(tif, tmp); + _TIFFmemcpy(tmp, cp0, cc); + for (count = 0; count < wc; count++) { + uint32 byte; + for (byte = 0; byte < bps; byte++) { + #if WORDS_BIGENDIAN + cp[byte * wc + count] = tmp[bps * count + byte]; + #else + cp[(bps - byte - 1) * wc + count] = + tmp[bps * count + byte]; + #endif + } + } + _TIFFfree(tmp); - 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--) + cp = (uint8 *) cp0; + cp += cc - stride - 1; + for (count = cc; count > stride; count -= stride) + REPEAT4(stride, cp[stride] = (unsigned char)((cp[stride] - cp[0])&0xff); cp--) return 1; } -static int PredictorEncodeRow(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +PredictorEncodeRow(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - TIFFPredictorState *sp = PredictorState(tif); + TIFFPredictorState *sp = PredictorState(tif); - assert(sp != NULL); - assert(sp->encodepfunc != NULL); - assert(sp->encoderow != NULL); + assert(sp != NULL); + assert(sp->encodepfunc != NULL); + assert(sp->encoderow != NULL); - /* XXX horizontal differencing alters user's data XXX */ - if (!(*sp->encodepfunc)(tif, bp, cc)) + /* XXX horizontal differencing alters user's data XXX */ + if( !(*sp->encodepfunc)(tif, bp, cc) ) return 0; - return (*sp->encoderow)(tif, bp, cc, s); + return (*sp->encoderow)(tif, bp, cc, s); } -static int PredictorEncodeTile(TIFF *tif, uint8_t *bp0, tmsize_t cc0, - uint16_t s) +static int +PredictorEncodeTile(TIFF* tif, uint8* bp0, tmsize_t cc0, uint16 s) { - static const char module[] = "PredictorEncodeTile"; - TIFFPredictorState *sp = PredictorState(tif); - uint8_t *working_copy; - tmsize_t cc = cc0, rowsize; - unsigned char *bp; - int result_code; + static const char module[] = "PredictorEncodeTile"; + TIFFPredictorState *sp = PredictorState(tif); + uint8 *working_copy; + tmsize_t cc = cc0, rowsize; + unsigned char* bp; + int result_code; - assert(sp != NULL); - assert(sp->encodepfunc != NULL); - assert(sp->encodetile != NULL); + assert(sp != NULL); + assert(sp->encodepfunc != NULL); + assert(sp->encodetile != NULL); - /* - * Do predictor manipulation in a working buffer to avoid altering - * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965 - */ - working_copy = (uint8_t *)_TIFFmallocExt(tif, cc0); - if (working_copy == NULL) + /* + * Do predictor manipulation in a working buffer to avoid altering + * the callers buffer. http://trac.osgeo.org/gdal/ticket/1965 + */ + working_copy = (uint8*) _TIFFmalloc(cc0); + if( working_copy == NULL ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Out of memory allocating " TIFF_SSIZE_FORMAT " byte temp buffer.", + cc0 ); + return 0; + } + memcpy( working_copy, bp0, cc0 ); + bp = working_copy; + + rowsize = sp->rowsize; + assert(rowsize > 0); + if((cc0%rowsize)!=0) { - TIFFErrorExtR(tif, module, - "Out of memory allocating %" PRId64 " byte temp buffer.", - (int64_t)cc0); + TIFFErrorExt(tif->tif_clientdata, "PredictorEncodeTile", + "%s", "(cc0%rowsize)!=0"); + _TIFFfree( working_copy ); return 0; } - memcpy(working_copy, bp0, cc0); - bp = working_copy; + while (cc > 0) { + (*sp->encodepfunc)(tif, bp, rowsize); + cc -= rowsize; + bp += rowsize; + } + result_code = (*sp->encodetile)(tif, working_copy, cc0, s); - rowsize = sp->rowsize; - assert(rowsize > 0); - if ((cc0 % rowsize) != 0) - { - TIFFErrorExtR(tif, "PredictorEncodeTile", "%s", "(cc0%rowsize)!=0"); - _TIFFfreeExt(tif, working_copy); - return 0; - } - while (cc > 0) - { - (*sp->encodepfunc)(tif, bp, rowsize); - cc -= rowsize; - bp += rowsize; - } - result_code = (*sp->encodetile)(tif, working_copy, cc0, s); + _TIFFfree( working_copy ); - _TIFFfreeExt(tif, working_copy); - - return result_code; + return result_code; } -#define FIELD_PREDICTOR (FIELD_CODEC + 0) /* XXX */ +#define FIELD_PREDICTOR (FIELD_CODEC+0) /* XXX */ static const TIFFField predictFields[] = { - {TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, - TIFF_SETGET_UINT16, FIELD_PREDICTOR, FALSE, FALSE, "Predictor", NULL}, + { TIFFTAG_PREDICTOR, 1, 1, TIFF_SHORT, 0, TIFF_SETGET_UINT16, TIFF_SETGET_UINT16, FIELD_PREDICTOR, FALSE, FALSE, "Predictor", NULL }, }; -static int PredictorVSetField(TIFF *tif, uint32_t tag, va_list ap) +static int +PredictorVSetField(TIFF* tif, uint32 tag, va_list ap) { - TIFFPredictorState *sp = PredictorState(tif); + TIFFPredictorState *sp = PredictorState(tif); - assert(sp != NULL); - assert(sp->vsetparent != NULL); + assert(sp != NULL); + assert(sp->vsetparent != NULL); - switch (tag) - { - case TIFFTAG_PREDICTOR: - sp->predictor = (uint16_t)va_arg(ap, uint16_vap); - TIFFSetFieldBit(tif, FIELD_PREDICTOR); - break; - default: - return (*sp->vsetparent)(tif, tag, ap); - } - tif->tif_flags |= TIFF_DIRTYDIRECT; - return 1; + switch (tag) { + case TIFFTAG_PREDICTOR: + sp->predictor = (uint16) va_arg(ap, uint16_vap); + TIFFSetFieldBit(tif, FIELD_PREDICTOR); + break; + default: + return (*sp->vsetparent)(tif, tag, ap); + } + tif->tif_flags |= TIFF_DIRTYDIRECT; + return 1; } -static int PredictorVGetField(TIFF *tif, uint32_t tag, va_list ap) +static int +PredictorVGetField(TIFF* tif, uint32 tag, va_list ap) { - TIFFPredictorState *sp = PredictorState(tif); + TIFFPredictorState *sp = PredictorState(tif); - assert(sp != NULL); - assert(sp->vgetparent != NULL); + assert(sp != NULL); + assert(sp->vgetparent != NULL); - switch (tag) - { - case TIFFTAG_PREDICTOR: - *va_arg(ap, uint16_t *) = (uint16_t)sp->predictor; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return 1; + switch (tag) { + case TIFFTAG_PREDICTOR: + *va_arg(ap, uint16*) = (uint16)sp->predictor; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return 1; } -static void PredictorPrintDir(TIFF *tif, FILE *fd, long flags) +static void +PredictorPrintDir(TIFF* tif, FILE* fd, long flags) { - TIFFPredictorState *sp = PredictorState(tif); + TIFFPredictorState* sp = PredictorState(tif); - (void)flags; - if (TIFFFieldSet(tif, FIELD_PREDICTOR)) - { - fprintf(fd, " Predictor: "); - switch (sp->predictor) - { - case 1: - fprintf(fd, "none "); - break; - case 2: - fprintf(fd, "horizontal differencing "); - break; - case 3: - fprintf(fd, "floating point predictor "); - break; - } - fprintf(fd, "%d (0x%x)\n", sp->predictor, sp->predictor); - } - if (sp->printdir) - (*sp->printdir)(tif, fd, flags); + (void) flags; + if (TIFFFieldSet(tif,FIELD_PREDICTOR)) { + fprintf(fd, " Predictor: "); + switch (sp->predictor) { + case 1: fprintf(fd, "none "); break; + case 2: fprintf(fd, "horizontal differencing "); break; + case 3: fprintf(fd, "floating point predictor "); break; + } + fprintf(fd, "%d (0x%x)\n", sp->predictor, sp->predictor); + } + if (sp->printdir) + (*sp->printdir)(tif, fd, flags); } -int TIFFPredictorInit(TIFF *tif) +int +TIFFPredictorInit(TIFF* tif) { - TIFFPredictorState *sp = PredictorState(tif); + TIFFPredictorState* sp = PredictorState(tif); - assert(sp != 0); + assert(sp != 0); - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, predictFields, TIFFArrayCount(predictFields))) - { - TIFFErrorExtR(tif, "TIFFPredictorInit", - "Merging Predictor codec-specific tags failed"); - return 0; - } + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, predictFields, + TIFFArrayCount(predictFields))) { + TIFFErrorExt(tif->tif_clientdata, "TIFFPredictorInit", + "Merging Predictor codec-specific tags failed"); + return 0; + } - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = - PredictorVGetField; /* hook for predictor tag */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = - PredictorVSetField; /* hook for predictor tag */ - sp->printdir = tif->tif_tagmethods.printdir; - tif->tif_tagmethods.printdir = - PredictorPrintDir; /* hook for predictor tag */ + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = + PredictorVGetField;/* hook for predictor tag */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = + PredictorVSetField;/* hook for predictor tag */ + sp->printdir = tif->tif_tagmethods.printdir; + tif->tif_tagmethods.printdir = + PredictorPrintDir; /* hook for predictor tag */ - sp->setupdecode = tif->tif_setupdecode; - tif->tif_setupdecode = PredictorSetupDecode; - sp->setupencode = tif->tif_setupencode; - tif->tif_setupencode = PredictorSetupEncode; + sp->setupdecode = tif->tif_setupdecode; + tif->tif_setupdecode = PredictorSetupDecode; + sp->setupencode = tif->tif_setupencode; + tif->tif_setupencode = PredictorSetupEncode; - sp->predictor = 1; /* default value */ - sp->encodepfunc = NULL; /* no predictor routine */ - sp->decodepfunc = NULL; /* no predictor routine */ - return 1; + sp->predictor = 1; /* default value */ + sp->encodepfunc = NULL; /* no predictor routine */ + sp->decodepfunc = NULL; /* no predictor routine */ + return 1; } -int TIFFPredictorCleanup(TIFF *tif) +int +TIFFPredictorCleanup(TIFF* tif) { - TIFFPredictorState *sp = PredictorState(tif); + TIFFPredictorState* sp = PredictorState(tif); - assert(sp != 0); + assert(sp != 0); - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - tif->tif_tagmethods.printdir = sp->printdir; - tif->tif_setupdecode = sp->setupdecode; - tif->tif_setupencode = sp->setupencode; + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; + tif->tif_tagmethods.printdir = sp->printdir; + tif->tif_setupdecode = sp->setupdecode; + tif->tif_setupencode = sp->setupencode; - return 1; + return 1; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_predict.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_predict.h index de7732835..a326b9b8f 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_predict.h +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_predict.h @@ -23,7 +23,7 @@ */ #ifndef _TIFFPREDICT_ -#define _TIFFPREDICT_ +#define _TIFFPREDICT_ #include "tiffio.h" #include "tiffiop.h" @@ -32,43 +32,50 @@ * ``Library-private'' Support for the Predictor Tag */ -typedef int (*TIFFEncodeDecodeMethod)(TIFF *tif, uint8_t *buf, tmsize_t size); +typedef int (*TIFFEncodeDecodeMethod)(TIFF* tif, uint8* buf, tmsize_t size); /* * Codecs that want to support the Predictor tag must place * this structure first in their private state block so that * the predictor code can cast tif_data to find its state. */ -typedef struct -{ - int predictor; /* predictor tag value */ - tmsize_t stride; /* sample stride over data */ - tmsize_t rowsize; /* tile/strip row size */ +typedef struct { + int predictor; /* predictor tag value */ + tmsize_t stride; /* sample stride over data */ + tmsize_t rowsize; /* tile/strip row size */ - TIFFCodeMethod encoderow; /* parent codec encode/decode row */ - TIFFCodeMethod encodestrip; /* parent codec encode/decode strip */ - TIFFCodeMethod encodetile; /* parent codec encode/decode tile */ - TIFFEncodeDecodeMethod encodepfunc; /* horizontal differencer */ + TIFFCodeMethod encoderow; /* parent codec encode/decode row */ + TIFFCodeMethod encodestrip; /* parent codec encode/decode strip */ + TIFFCodeMethod encodetile; /* parent codec encode/decode tile */ + TIFFEncodeDecodeMethod encodepfunc; /* horizontal differencer */ - TIFFCodeMethod decoderow; /* parent codec encode/decode row */ - TIFFCodeMethod decodestrip; /* parent codec encode/decode strip */ - TIFFCodeMethod decodetile; /* parent codec encode/decode tile */ - TIFFEncodeDecodeMethod decodepfunc; /* horizontal accumulator */ + TIFFCodeMethod decoderow; /* parent codec encode/decode row */ + TIFFCodeMethod decodestrip; /* parent codec encode/decode strip */ + TIFFCodeMethod decodetile; /* parent codec encode/decode tile */ + TIFFEncodeDecodeMethod decodepfunc; /* horizontal accumulator */ - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ - TIFFPrintMethod printdir; /* super-class method */ - TIFFBoolMethod setupdecode; /* super-class method */ - TIFFBoolMethod setupencode; /* super-class method */ + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ + TIFFPrintMethod printdir; /* super-class method */ + TIFFBoolMethod setupdecode; /* super-class method */ + TIFFBoolMethod setupencode; /* super-class method */ } TIFFPredictorState; #if defined(__cplusplus) -extern "C" -{ +extern "C" { #endif - extern int TIFFPredictorInit(TIFF *); - extern int TIFFPredictorCleanup(TIFF *); +extern int TIFFPredictorInit(TIFF*); +extern int TIFFPredictorCleanup(TIFF*); #if defined(__cplusplus) } #endif #endif /* _TIFFPREDICT_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_print.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_print.c index 2b7fd1765..4cce6cf26 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_print.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_print.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,724 +32,695 @@ #include -static void _TIFFprintAsciiBounded(FILE *fd, const char *cp, size_t max_chars); +static void +_TIFFprintAsciiBounded(FILE* fd, const char* cp, size_t max_chars); -static const char *const photoNames[] = { - "min-is-white", /* PHOTOMETRIC_MINISWHITE */ - "min-is-black", /* PHOTOMETRIC_MINISBLACK */ - "RGB color", /* PHOTOMETRIC_RGB */ - "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */ - "transparency mask", /* PHOTOMETRIC_MASK */ - "separated", /* PHOTOMETRIC_SEPARATED */ - "YCbCr", /* PHOTOMETRIC_YCBCR */ +static const char * const photoNames[] = { + "min-is-white", /* PHOTOMETRIC_MINISWHITE */ + "min-is-black", /* PHOTOMETRIC_MINISBLACK */ + "RGB color", /* PHOTOMETRIC_RGB */ + "palette color (RGB from colormap)", /* PHOTOMETRIC_PALETTE */ + "transparency mask", /* PHOTOMETRIC_MASK */ + "separated", /* PHOTOMETRIC_SEPARATED */ + "YCbCr", /* PHOTOMETRIC_YCBCR */ "7 (0x7)", - "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */ - "ICC L*a*b*", /* PHOTOMETRIC_ICCLAB */ - "ITU L*a*b*" /* PHOTOMETRIC_ITULAB */ + "CIE L*a*b*", /* PHOTOMETRIC_CIELAB */ + "ICC L*a*b*", /* PHOTOMETRIC_ICCLAB */ + "ITU L*a*b*" /* PHOTOMETRIC_ITULAB */ }; -#define NPHOTONAMES (sizeof(photoNames) / sizeof(photoNames[0])) +#define NPHOTONAMES (sizeof (photoNames) / sizeof (photoNames[0])) -static const char *const orientNames[] = { +static const char * const orientNames[] = { "0 (0x0)", - "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */ - "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */ - "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */ - "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */ - "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */ - "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */ - "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */ - "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */ + "row 0 top, col 0 lhs", /* ORIENTATION_TOPLEFT */ + "row 0 top, col 0 rhs", /* ORIENTATION_TOPRIGHT */ + "row 0 bottom, col 0 rhs", /* ORIENTATION_BOTRIGHT */ + "row 0 bottom, col 0 lhs", /* ORIENTATION_BOTLEFT */ + "row 0 lhs, col 0 top", /* ORIENTATION_LEFTTOP */ + "row 0 rhs, col 0 top", /* ORIENTATION_RIGHTTOP */ + "row 0 rhs, col 0 bottom", /* ORIENTATION_RIGHTBOT */ + "row 0 lhs, col 0 bottom", /* ORIENTATION_LEFTBOT */ }; -#define NORIENTNAMES (sizeof(orientNames) / sizeof(orientNames[0])) +#define NORIENTNAMES (sizeof (orientNames) / sizeof (orientNames[0])) -static const struct tagname +static void +_TIFFPrintField(FILE* fd, const TIFFField *fip, + uint32 value_count, void *raw_data) { - uint16_t tag; - const char *name; -} tagnames[] = { - {TIFFTAG_GDAL_METADATA, "GDAL Metadata"}, - {TIFFTAG_GDAL_NODATA, "GDAL NoDataValue"}, -}; -#define NTAGS (sizeof(tagnames) / sizeof(tagnames[0])) + uint32 j; + + fprintf(fd, " %s: ", fip->field_name); -static void _TIFFPrintField(FILE *fd, const TIFFField *fip, - uint32_t value_count, void *raw_data) -{ - uint32_t j; + for(j = 0; j < value_count; j++) { + if(fip->field_type == TIFF_BYTE) + fprintf(fd, "%u", ((uint8 *) raw_data)[j]); + else if(fip->field_type == TIFF_UNDEFINED) + fprintf(fd, "0x%x", + (unsigned int) ((unsigned char *) raw_data)[j]); + else if(fip->field_type == TIFF_SBYTE) + fprintf(fd, "%d", ((int8 *) raw_data)[j]); + else if(fip->field_type == TIFF_SHORT) + fprintf(fd, "%u", ((uint16 *) raw_data)[j]); + else if(fip->field_type == TIFF_SSHORT) + fprintf(fd, "%d", ((int16 *) raw_data)[j]); + else if(fip->field_type == TIFF_LONG) + fprintf(fd, "%lu", + (unsigned long)((uint32 *) raw_data)[j]); + else if(fip->field_type == TIFF_SLONG) + fprintf(fd, "%ld", (long)((int32 *) raw_data)[j]); + else if(fip->field_type == TIFF_IFD) + fprintf(fd, "0x%lx", + (unsigned long)((uint32 *) raw_data)[j]); + else if(fip->field_type == TIFF_RATIONAL + || fip->field_type == TIFF_SRATIONAL) { + int tv_size = _TIFFSetGetFieldSize(fip->set_field_type); + if(tv_size==8) + fprintf(fd, "%lf", ((double*)raw_data)[j]); + else + fprintf(fd, "%f", ((float *) raw_data)[j]); + } + else if(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 + 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 + 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 + 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]); + else if(fip->field_type == TIFF_ASCII) { + fprintf(fd, "%s", (char *) raw_data); + break; + } + else { + fprintf(fd, ""); + break; + } - /* Print a user-friendly name for tags of relatively common use, but */ - /* which aren't registered by libtiff itself. */ - const char *field_name = fip->field_name; - if (TIFFFieldIsAnonymous(fip)) - { - for (size_t i = 0; i < NTAGS; ++i) - { - if (fip->field_tag == tagnames[i].tag) - { - field_name = tagnames[i].name; - break; - } - } - } - fprintf(fd, " %s: ", field_name); + if(j < value_count - 1) + fprintf(fd, ","); + } - for (j = 0; j < value_count; j++) - { - if (fip->field_type == TIFF_BYTE) - fprintf(fd, "%" PRIu8, ((uint8_t *)raw_data)[j]); - else if (fip->field_type == TIFF_UNDEFINED) - fprintf(fd, "0x%" PRIx8, ((uint8_t *)raw_data)[j]); - else if (fip->field_type == TIFF_SBYTE) - fprintf(fd, "%" PRId8, ((int8_t *)raw_data)[j]); - else if (fip->field_type == TIFF_SHORT) - fprintf(fd, "%" PRIu16, ((uint16_t *)raw_data)[j]); - else if (fip->field_type == TIFF_SSHORT) - fprintf(fd, "%" PRId16, ((int16_t *)raw_data)[j]); - else if (fip->field_type == TIFF_LONG) - fprintf(fd, "%" PRIu32, ((uint32_t *)raw_data)[j]); - else if (fip->field_type == TIFF_SLONG) - fprintf(fd, "%" PRId32, ((int32_t *)raw_data)[j]); - else if (fip->field_type == TIFF_IFD) - fprintf(fd, "0x%" PRIx32, ((uint32_t *)raw_data)[j]); - else if (fip->field_type == TIFF_RATIONAL || - fip->field_type == TIFF_SRATIONAL) - { - int tv_size = TIFFFieldSetGetSize(fip); - if (tv_size == 8) - fprintf(fd, "%lf", ((double *)raw_data)[j]); - else - fprintf(fd, "%f", ((float *)raw_data)[j]); - } - else if (fip->field_type == TIFF_FLOAT) - fprintf(fd, "%f", ((float *)raw_data)[j]); - else if (fip->field_type == TIFF_LONG8) - fprintf(fd, "%" PRIu64, ((uint64_t *)raw_data)[j]); - else if (fip->field_type == TIFF_SLONG8) - fprintf(fd, "%" PRId64, ((int64_t *)raw_data)[j]); - else if (fip->field_type == TIFF_IFD8) - fprintf(fd, "0x%" PRIx64, ((uint64_t *)raw_data)[j]); - else if (fip->field_type == TIFF_DOUBLE) - fprintf(fd, "%lf", ((double *)raw_data)[j]); - else if (fip->field_type == TIFF_ASCII) - { - fprintf(fd, "%s", (char *)raw_data); - break; - } - else - { - fprintf(fd, ""); - break; - } - - if (j < value_count - 1) - fprintf(fd, ","); - } - - fprintf(fd, "\n"); + fprintf(fd, "\n"); } -static int _TIFFPrettyPrintField(TIFF *tif, const TIFFField *fip, FILE *fd, - uint32_t tag, uint32_t value_count, - void *raw_data) +static int +_TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32 tag, + uint32 value_count, void *raw_data) { - (void)tif; + (void) tif; - /* do not try to pretty print auto-defined fields */ - if (TIFFFieldIsAnonymous(fip)) - { - return 0; - } + /* do not try to pretty print auto-defined fields */ + if ( TIFFFieldIsAnonymous(fip) ) { + return 0; + } + + switch (tag) + { + case TIFFTAG_INKSET: + if (value_count == 2 && fip->field_type == TIFF_SHORT) { + fprintf(fd, " Ink Set: "); + switch (*((uint16*)raw_data)) { + case INKSET_CMYK: + fprintf(fd, "CMYK\n"); + break; + default: + fprintf(fd, "%u (0x%x)\n", + *((uint16*)raw_data), + *((uint16*)raw_data)); + break; + } + return 1; + } + return 0; - switch (tag) - { - case TIFFTAG_INKSET: - if (value_count == 2 && fip->field_type == TIFF_SHORT) - { - fprintf(fd, " Ink Set: "); - switch (*((uint16_t *)raw_data)) - { - case INKSET_CMYK: - fprintf(fd, "CMYK\n"); - break; - default: - fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", - *((uint16_t *)raw_data), - *((uint16_t *)raw_data)); - break; - } - return 1; - } - return 0; + 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]); + return 1; + } + return 0; - case TIFFTAG_DOTRANGE: - if (value_count == 2 && fip->field_type == TIFF_SHORT) - { - fprintf(fd, " Dot Range: %" PRIu16 "-%" PRIu16 "\n", - ((uint16_t *)raw_data)[0], ((uint16_t *)raw_data)[1]); - return 1; - } - return 0; + case TIFFTAG_WHITEPOINT: + if (value_count == 2 && fip->field_type == TIFF_RATIONAL) { + fprintf(fd, " White Point: %g-%g\n", + ((float *)raw_data)[0], ((float *)raw_data)[1]); + return 1; + } + return 0; - case TIFFTAG_WHITEPOINT: - if (value_count == 2 && fip->field_type == TIFF_RATIONAL) - { - fprintf(fd, " White Point: %g-%g\n", ((float *)raw_data)[0], - ((float *)raw_data)[1]); - return 1; - } - return 0; + case TIFFTAG_XMLPACKET: + { + uint32 i; - case TIFFTAG_XMLPACKET: - { - uint32_t i; + fprintf(fd, " XMLPacket (XMP Metadata):\n" ); + for(i = 0; i < value_count; i++) + fputc(((char *)raw_data)[i], fd); + fprintf( fd, "\n" ); + return 1; + } + case TIFFTAG_RICHTIFFIPTC: + fprintf(fd, + " RichTIFFIPTC Data: , %lu bytes\n", + (unsigned long) value_count ); + return 1; - fprintf(fd, " XMLPacket (XMP Metadata):\n"); - for (i = 0; i < value_count; i++) - fputc(((char *)raw_data)[i], fd); - fprintf(fd, "\n"); - return 1; - } - case TIFFTAG_RICHTIFFIPTC: - fprintf(fd, " RichTIFFIPTC Data: , %" PRIu32 " bytes\n", - value_count); - return 1; + case TIFFTAG_PHOTOSHOP: + fprintf(fd, " Photoshop Data: , %lu bytes\n", + (unsigned long) value_count); + return 1; - case TIFFTAG_PHOTOSHOP: - fprintf(fd, " Photoshop Data: , %" PRIu32 " bytes\n", - value_count); - return 1; + case TIFFTAG_ICCPROFILE: + fprintf(fd, " ICC Profile: , %lu bytes\n", + (unsigned long) value_count); + return 1; - case TIFFTAG_ICCPROFILE: - fprintf(fd, " ICC Profile: , %" PRIu32 " bytes\n", - value_count); - return 1; + case TIFFTAG_STONITS: + if (value_count == 1 && fip->field_type == TIFF_DOUBLE) { + fprintf(fd, + " Sample to Nits conversion factor: %.4e\n", + *((double*)raw_data)); + return 1; + } + return 0; + } - case TIFFTAG_STONITS: - if (value_count == 1 && fip->field_type == TIFF_DOUBLE) - { - fprintf(fd, " Sample to Nits conversion factor: %.4e\n", - *((double *)raw_data)); - return 1; - } - return 0; - } - - return 0; + return 0; } /* * Print the contents of the current directory * to the specified stdio file stream. */ -void TIFFPrintDirectory(TIFF *tif, FILE *fd, long flags) +void +TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags) { - TIFFDirectory *td = &tif->tif_dir; - char *sep; - long l, n; + TIFFDirectory *td = &tif->tif_dir; + char *sep; + long l, n; - fprintf(fd, "TIFF Directory at offset 0x%" PRIx64 " (%" PRIu64 ")\n", - tif->tif_diroff, tif->tif_diroff); - if (TIFFFieldSet(tif, FIELD_SUBFILETYPE)) - { - fprintf(fd, " Subfile Type:"); - sep = " "; - if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE) +#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 + if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) { + fprintf(fd, " Subfile Type:"); + sep = " "; + if (td->td_subfiletype & FILETYPE_REDUCEDIMAGE) { + fprintf(fd, "%sreduced-resolution image", sep); + sep = "/"; + } + if (td->td_subfiletype & FILETYPE_PAGE) { + fprintf(fd, "%smulti-page document", sep); + sep = "/"; + } + 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); + } + if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) { + fprintf(fd, " Image Width: %lu Image Length: %lu", + (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength); + if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH)) + fprintf(fd, " Image Depth: %lu", + (unsigned long) 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); + if (TIFFFieldSet(tif,FIELD_TILEDEPTH)) + fprintf(fd, " Tile Depth: %lu", + (unsigned long) td->td_tiledepth); + fprintf(fd, "\n"); + } + if (TIFFFieldSet(tif,FIELD_RESOLUTION)) { + fprintf(fd, " Resolution: %g, %g", + td->td_xresolution, td->td_yresolution); + if (TIFFFieldSet(tif,FIELD_RESOLUTIONUNIT)) { + switch (td->td_resolutionunit) { + case RESUNIT_NONE: + fprintf(fd, " (unitless)"); + break; + case RESUNIT_INCH: + fprintf(fd, " pixels/inch"); + break; + case RESUNIT_CENTIMETER: + fprintf(fd, " pixels/cm"); + break; + default: + fprintf(fd, " (unit %u = 0x%x)", + td->td_resolutionunit, + td->td_resolutionunit); + break; + } + } + fprintf(fd, "\n"); + } + if (TIFFFieldSet(tif,FIELD_POSITION)) + 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); + if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) { + fprintf(fd, " Sample Format: "); + switch (td->td_sampleformat) { + case SAMPLEFORMAT_VOID: + fprintf(fd, "void\n"); + break; + case SAMPLEFORMAT_INT: + fprintf(fd, "signed integer\n"); + break; + case SAMPLEFORMAT_UINT: + fprintf(fd, "unsigned integer\n"); + break; + case SAMPLEFORMAT_IEEEFP: + fprintf(fd, "IEEE floating point\n"); + break; + case SAMPLEFORMAT_COMPLEXINT: + fprintf(fd, "complex signed integer\n"); + break; + case SAMPLEFORMAT_COMPLEXIEEEFP: + fprintf(fd, "complex IEEE floating point\n"); + break; + default: + fprintf(fd, "%u (0x%x)\n", + td->td_sampleformat, td->td_sampleformat); + break; + } + } + if (TIFFFieldSet(tif,FIELD_COMPRESSION)) { + const TIFFCodec* c = TIFFFindCODEC(td->td_compression); + fprintf(fd, " Compression Scheme: "); + if (c) + fprintf(fd, "%s\n", c->name); + else + fprintf(fd, "%u (0x%x)\n", + td->td_compression, td->td_compression); + } + if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) { + fprintf(fd, " Photometric Interpretation: "); + if (td->td_photometric < NPHOTONAMES) + fprintf(fd, "%s\n", photoNames[td->td_photometric]); + else { + switch (td->td_photometric) { + case PHOTOMETRIC_LOGL: + fprintf(fd, "CIE Log2(L)\n"); + break; + case PHOTOMETRIC_LOGLUV: + fprintf(fd, "CIE Log2(L) (u',v')\n"); + break; + default: + fprintf(fd, "%u (0x%x)\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); + sep = ""; + for (i = 0; i < td->td_extrasamples; i++) { + switch (td->td_sampleinfo[i]) { + case EXTRASAMPLE_UNSPECIFIED: + fprintf(fd, "%sunspecified", sep); + break; + case EXTRASAMPLE_ASSOCALPHA: + fprintf(fd, "%sassoc-alpha", sep); + break; + case EXTRASAMPLE_UNASSALPHA: + fprintf(fd, "%sunassoc-alpha", sep); + break; + default: + fprintf(fd, "%s%u (0x%x)", sep, + td->td_sampleinfo[i], td->td_sampleinfo[i]); + break; + } + sep = ", "; + } + fprintf(fd, ">\n"); + } + if (TIFFFieldSet(tif,FIELD_INKNAMES)) { + char* cp; + uint16 i; + fprintf(fd, " Ink Names: "); + i = td->td_samplesperpixel; + sep = ""; + for (cp = td->td_inknames; + i > 0 && cp < td->td_inknames + td->td_inknameslen; + cp = strchr(cp,'\0')+1, i--) { + size_t max_chars = + td->td_inknameslen - (cp - td->td_inknames); + fputs(sep, fd); + _TIFFprintAsciiBounded(fd, cp, max_chars); + sep = ", "; + } + fputs("\n", fd); + } + if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS)) { + fprintf(fd, " NumberOfInks: %d\n", + td->td_numberofinks); + } + if (TIFFFieldSet(tif,FIELD_THRESHHOLDING)) { + fprintf(fd, " Thresholding: "); + switch (td->td_threshholding) { + case THRESHHOLD_BILEVEL: + fprintf(fd, "bilevel art scan\n"); + break; + case THRESHHOLD_HALFTONE: + fprintf(fd, "halftone or dithered scan\n"); + break; + case THRESHHOLD_ERRORDIFFUSE: + fprintf(fd, "error diffused\n"); + break; + default: + fprintf(fd, "%u (0x%x)\n", + td->td_threshholding, td->td_threshholding); + break; + } + } + if (TIFFFieldSet(tif,FIELD_FILLORDER)) { + fprintf(fd, " FillOrder: "); + switch (td->td_fillorder) { + case FILLORDER_MSB2LSB: + fprintf(fd, "msb-to-lsb\n"); + break; + case FILLORDER_LSB2MSB: + fprintf(fd, "lsb-to-msb\n"); + break; + default: + fprintf(fd, "%u (0x%x)\n", + td->td_fillorder, td->td_fillorder); + break; + } + } + if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING)) { - fprintf(fd, "%sreduced-resolution image", sep); - sep = "/"; - } - if (td->td_subfiletype & FILETYPE_PAGE) - { - fprintf(fd, "%smulti-page document", sep); - sep = "/"; - } - if (td->td_subfiletype & FILETYPE_MASK) - fprintf(fd, "%stransparency mask", sep); - fprintf(fd, " (%" PRIu32 " = 0x%" PRIx32 ")\n", td->td_subfiletype, - td->td_subfiletype); - } - if (TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) - { - fprintf(fd, " Image Width: %" PRIu32 " Image Length: %" PRIu32, - td->td_imagewidth, td->td_imagelength); - if (TIFFFieldSet(tif, FIELD_IMAGEDEPTH)) - fprintf(fd, " Image Depth: %" PRIu32, td->td_imagedepth); - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif, FIELD_TILEDIMENSIONS)) - { - fprintf(fd, " Tile Width: %" PRIu32 " Tile Length: %" PRIu32, - td->td_tilewidth, td->td_tilelength); - if (TIFFFieldSet(tif, FIELD_TILEDEPTH)) - fprintf(fd, " Tile Depth: %" PRIu32, td->td_tiledepth); - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif, FIELD_RESOLUTION)) - { - fprintf(fd, " Resolution: %g, %g", td->td_xresolution, - td->td_yresolution); - if (TIFFFieldSet(tif, FIELD_RESOLUTIONUNIT)) - { - switch (td->td_resolutionunit) - { - case RESUNIT_NONE: - fprintf(fd, " (unitless)"); - break; - case RESUNIT_INCH: - fprintf(fd, " pixels/inch"); - break; - case RESUNIT_CENTIMETER: - fprintf(fd, " pixels/cm"); - break; - default: - fprintf(fd, " (unit %" PRIu16 " = 0x%" PRIx16 ")", - td->td_resolutionunit, td->td_resolutionunit); - break; - } - } - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif, FIELD_POSITION)) - fprintf(fd, " Position: %g, %g\n", td->td_xposition, td->td_yposition); - if (TIFFFieldSet(tif, FIELD_BITSPERSAMPLE)) - fprintf(fd, " Bits/Sample: %" PRIu16 "\n", td->td_bitspersample); - if (TIFFFieldSet(tif, FIELD_SAMPLEFORMAT)) - { - fprintf(fd, " Sample Format: "); - switch (td->td_sampleformat) - { - case SAMPLEFORMAT_VOID: - fprintf(fd, "void\n"); - break; - case SAMPLEFORMAT_INT: - fprintf(fd, "signed integer\n"); - break; - case SAMPLEFORMAT_UINT: - fprintf(fd, "unsigned integer\n"); - break; - case SAMPLEFORMAT_IEEEFP: - fprintf(fd, "IEEE floating point\n"); - break; - case SAMPLEFORMAT_COMPLEXINT: - fprintf(fd, "complex signed integer\n"); - break; - case SAMPLEFORMAT_COMPLEXIEEEFP: - fprintf(fd, "complex IEEE floating point\n"); - break; - default: - fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", - td->td_sampleformat, td->td_sampleformat); - break; - } - } - if (TIFFFieldSet(tif, FIELD_COMPRESSION)) - { - const TIFFCodec *c = TIFFFindCODEC(td->td_compression); - fprintf(fd, " Compression Scheme: "); - if (c) - fprintf(fd, "%s\n", c->name); - else - fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", td->td_compression, - td->td_compression); - } - if (TIFFFieldSet(tif, FIELD_PHOTOMETRIC)) - { - fprintf(fd, " Photometric Interpretation: "); - if (td->td_photometric < NPHOTONAMES) - fprintf(fd, "%s\n", photoNames[td->td_photometric]); - else - { - switch (td->td_photometric) - { - case PHOTOMETRIC_LOGL: - fprintf(fd, "CIE Log2(L)\n"); - break; - case PHOTOMETRIC_LOGLUV: - fprintf(fd, "CIE Log2(L) (u',v')\n"); - break; - default: - fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", - td->td_photometric, td->td_photometric); - break; - } - } - } - if (TIFFFieldSet(tif, FIELD_EXTRASAMPLES) && 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]) - { - case EXTRASAMPLE_UNSPECIFIED: - fprintf(fd, "%sunspecified", sep); - break; - case EXTRASAMPLE_ASSOCALPHA: - fprintf(fd, "%sassoc-alpha", sep); - break; - case EXTRASAMPLE_UNASSALPHA: - fprintf(fd, "%sunassoc-alpha", sep); - break; - default: - fprintf(fd, "%s%" PRIu16 " (0x%" PRIx16 ")", sep, - td->td_sampleinfo[i], td->td_sampleinfo[i]); - break; - } - sep = ", "; - } - fprintf(fd, ">\n"); - } - if (TIFFFieldSet(tif, FIELD_INKNAMES)) - { - char *cp; - uint16_t i; - fprintf(fd, " Ink Names: "); - i = td->td_samplesperpixel; - sep = ""; - for (cp = td->td_inknames; - i > 0 && cp < td->td_inknames + td->td_inknameslen; - cp = strchr(cp, '\0') + 1, i--) - { - size_t max_chars = td->td_inknameslen - (cp - td->td_inknames); - fputs(sep, fd); - _TIFFprintAsciiBounded(fd, cp, max_chars); - sep = ", "; - } - fputs("\n", fd); - } - if (TIFFFieldSet(tif, FIELD_NUMBEROFINKS)) - { - fprintf(fd, " NumberOfInks: %d\n", td->td_numberofinks); - } - if (TIFFFieldSet(tif, FIELD_THRESHHOLDING)) - { - fprintf(fd, " Thresholding: "); - switch (td->td_threshholding) - { - case THRESHHOLD_BILEVEL: - fprintf(fd, "bilevel art scan\n"); - break; - case THRESHHOLD_HALFTONE: - fprintf(fd, "halftone or dithered scan\n"); - break; - case THRESHHOLD_ERRORDIFFUSE: - fprintf(fd, "error diffused\n"); - break; - default: - fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", - td->td_threshholding, td->td_threshholding); - break; - } - } - if (TIFFFieldSet(tif, FIELD_FILLORDER)) - { - fprintf(fd, " FillOrder: "); - switch (td->td_fillorder) - { - case FILLORDER_MSB2LSB: - fprintf(fd, "msb-to-lsb\n"); - break; - case FILLORDER_LSB2MSB: - fprintf(fd, "lsb-to-msb\n"); - break; - default: - fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", td->td_fillorder, - td->td_fillorder); - break; - } - } - if (TIFFFieldSet(tif, FIELD_YCBCRSUBSAMPLING)) - { - fprintf(fd, " YCbCr Subsampling: %" PRIu16 ", %" PRIu16 "\n", - td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1]); - } - if (TIFFFieldSet(tif, FIELD_YCBCRPOSITIONING)) - { - fprintf(fd, " YCbCr Positioning: "); - switch (td->td_ycbcrpositioning) - { - case YCBCRPOSITION_CENTERED: - fprintf(fd, "centered\n"); - break; - case YCBCRPOSITION_COSITED: - fprintf(fd, "cosited\n"); - break; - default: - fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", - td->td_ycbcrpositioning, td->td_ycbcrpositioning); - break; - } - } - if (TIFFFieldSet(tif, FIELD_HALFTONEHINTS)) - 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, "%" PRIu16 " (0x%" PRIx16 ")\n", td->td_orientation, - td->td_orientation); - } - if (TIFFFieldSet(tif, FIELD_SAMPLESPERPIXEL)) - fprintf(fd, " Samples/Pixel: %" PRIx16 "\n", td->td_samplesperpixel); - if (TIFFFieldSet(tif, FIELD_ROWSPERSTRIP)) - { - fprintf(fd, " Rows/Strip: "); - if (td->td_rowsperstrip == (uint32_t)-1) - fprintf(fd, "(infinite)\n"); - else - fprintf(fd, "%" PRIu32 "\n", td->td_rowsperstrip); - } - if (TIFFFieldSet(tif, FIELD_MINSAMPLEVALUE)) - fprintf(fd, " Min Sample Value: %" PRIu16 "\n", td->td_minsamplevalue); - if (TIFFFieldSet(tif, FIELD_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; - fprintf(fd, " SMin Sample Value:"); - for (i = 0; i < count; ++i) - fprintf(fd, " %g", td->td_sminsamplevalue[i]); - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif, FIELD_SMAXSAMPLEVALUE)) - { - int i; - int count = - (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; - fprintf(fd, " SMax Sample Value:"); - for (i = 0; i < count; ++i) - fprintf(fd, " %g", td->td_smaxsamplevalue[i]); - fprintf(fd, "\n"); - } - if (TIFFFieldSet(tif, FIELD_PLANARCONFIG)) - { - fprintf(fd, " Planar Configuration: "); - switch (td->td_planarconfig) - { - case PLANARCONFIG_CONTIG: - fprintf(fd, "single image plane\n"); - break; - case PLANARCONFIG_SEPARATE: - fprintf(fd, "separate image planes\n"); - break; - default: - fprintf(fd, "%" PRIu16 " (0x%" PRIx16 ")\n", - td->td_planarconfig, td->td_planarconfig); - break; - } - } - if (TIFFFieldSet(tif, FIELD_PAGENUMBER)) - fprintf(fd, " Page Number: %" PRIu16 "-%" PRIu16 "\n", - td->td_pagenumber[0], td->td_pagenumber[1]); - if (TIFFFieldSet(tif, FIELD_COLORMAP)) - { - fprintf(fd, " Color Map: "); - if (flags & TIFFPRINT_COLORMAP) - { - fprintf(fd, "\n"); - n = 1L << td->td_bitspersample; - for (l = 0; l < n; l++) - fprintf(fd, " %5ld: %5" PRIu16 " %5" PRIu16 " %5" PRIu16 "\n", - l, td->td_colormap[0][l], td->td_colormap[1][l], - td->td_colormap[2][l]); - } - else - fprintf(fd, "(present)\n"); - } - if (TIFFFieldSet(tif, FIELD_REFBLACKWHITE)) - { - int i; - fprintf(fd, " Reference Black/White:\n"); - for (i = 0; i < 3; i++) - fprintf(fd, " %2d: %5g %5g\n", i, - td->td_refblackwhite[2 * i + 0], - td->td_refblackwhite[2 * i + 1]); - } - if (TIFFFieldSet(tif, FIELD_TRANSFERFUNCTION)) - { - fprintf(fd, " Transfer Function: "); - if (flags & TIFFPRINT_CURVES) - { - fprintf(fd, "\n"); - n = 1L << td->td_bitspersample; - for (l = 0; l < n; l++) - { - 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, " %5" PRIu16, td->td_transferfunction[i][l]); - fputc('\n', fd); - } - } - else - fprintf(fd, "(present)\n"); - } - if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) - { - uint16_t i; - fprintf(fd, " SubIFD Offsets:"); - for (i = 0; i < td->td_nsubifd; i++) - fprintf(fd, " %5" PRIu64, td->td_subifd[i]); - fputc('\n', fd); - } + fprintf(fd, " YCbCr Subsampling: %u, %u\n", + td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1] ); + } + if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) { + fprintf(fd, " YCbCr Positioning: "); + switch (td->td_ycbcrpositioning) { + case YCBCRPOSITION_CENTERED: + fprintf(fd, "centered\n"); + break; + case YCBCRPOSITION_COSITED: + fprintf(fd, "cosited\n"); + break; + default: + fprintf(fd, "%u (0x%x)\n", + td->td_ycbcrpositioning, td->td_ycbcrpositioning); + break; + } + } + if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS)) + fprintf(fd, " Halftone Hints: light %u dark %u\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", + td->td_orientation, td->td_orientation); + } + if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL)) + fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel); + if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) { + fprintf(fd, " Rows/Strip: "); + if (td->td_rowsperstrip == (uint32) -1) + fprintf(fd, "(infinite)\n"); + else + fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip); + } + if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE)) + fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue); + if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE)) + fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue); + if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) { + int i; + int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; + fprintf(fd, " SMin Sample Value:"); + for (i = 0; i < count; ++i) + fprintf(fd, " %g", td->td_sminsamplevalue[i]); + fprintf(fd, "\n"); + } + if (TIFFFieldSet(tif,FIELD_SMAXSAMPLEVALUE)) { + int i; + int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1; + fprintf(fd, " SMax Sample Value:"); + for (i = 0; i < count; ++i) + fprintf(fd, " %g", td->td_smaxsamplevalue[i]); + fprintf(fd, "\n"); + } + if (TIFFFieldSet(tif,FIELD_PLANARCONFIG)) { + fprintf(fd, " Planar Configuration: "); + switch (td->td_planarconfig) { + case PLANARCONFIG_CONTIG: + fprintf(fd, "single image plane\n"); + break; + case PLANARCONFIG_SEPARATE: + fprintf(fd, "separate image planes\n"); + break; + default: + fprintf(fd, "%u (0x%x)\n", + td->td_planarconfig, td->td_planarconfig); + break; + } + } + if (TIFFFieldSet(tif,FIELD_PAGENUMBER)) + fprintf(fd, " Page Number: %u-%u\n", + td->td_pagenumber[0], td->td_pagenumber[1]); + if (TIFFFieldSet(tif,FIELD_COLORMAP)) { + fprintf(fd, " Color Map: "); + if (flags & TIFFPRINT_COLORMAP) { + fprintf(fd, "\n"); + n = 1L<td_bitspersample; + for (l = 0; l < n; l++) + fprintf(fd, " %5ld: %5u %5u %5u\n", + l, + td->td_colormap[0][l], + td->td_colormap[1][l], + td->td_colormap[2][l]); + } else + fprintf(fd, "(present)\n"); + } + if (TIFFFieldSet(tif,FIELD_REFBLACKWHITE)) { + int i; + fprintf(fd, " Reference Black/White:\n"); + for (i = 0; i < 3; i++) + fprintf(fd, " %2d: %5g %5g\n", i, + td->td_refblackwhite[2*i+0], + td->td_refblackwhite[2*i+1]); + } + if (TIFFFieldSet(tif,FIELD_TRANSFERFUNCTION)) { + fprintf(fd, " Transfer Function: "); + if (flags & TIFFPRINT_CURVES) { + fprintf(fd, "\n"); + n = 1L<td_bitspersample; + for (l = 0; l < n; l++) { + uint16 i; + fprintf(fd, " %2ld: %5u", + l, td->td_transferfunction[0][l]); + for (i = 1; i < td->td_samplesperpixel - td->td_extrasamples && i < 3; i++) + fprintf(fd, " %5u", + td->td_transferfunction[i][l]); + fputc('\n', fd); + } + } else + fprintf(fd, "(present)\n"); + } + if (TIFFFieldSet(tif, FIELD_SUBIFD) && (td->td_subifd)) { + uint16 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 + fputc('\n', fd); + } - /* - ** Custom tag support. - */ - { - int i; - short count; + /* + ** Custom tag support. + */ + { + int i; + short count; - count = (short)TIFFGetTagListCount(tif); - for (i = 0; i < count; i++) - { - uint32_t tag = TIFFGetTagListEntry(tif, i); - const TIFFField *fip; - uint32_t value_count; - int mem_alloc = 0; - void *raw_data = NULL; - uint16_t dotrange[2]; /* must be kept in that scope and not moved in - the below TIFFTAG_DOTRANGE specific case */ + count = (short) TIFFGetTagListCount(tif); + for(i = 0; i < count; i++) { + uint32 tag = TIFFGetTagListEntry(tif, i); + const TIFFField *fip; + uint32 value_count; + int mem_alloc = 0; + void *raw_data; - fip = TIFFFieldWithTag(tif, tag); - if (fip == NULL) - continue; + fip = TIFFFieldWithTag(tif, tag); + if(fip == NULL) + continue; - if (fip->field_passcount) - { - if (fip->field_readcount == TIFF_VARIABLE2) - { - if (TIFFGetField(tif, tag, &value_count, &raw_data) != 1) - continue; - } - else if (fip->field_readcount == TIFF_VARIABLE) - { - uint16_t small_value_count; - if (TIFFGetField(tif, tag, &small_value_count, &raw_data) != - 1) - continue; - value_count = small_value_count; - } - else - { - assert(fip->field_readcount == TIFF_VARIABLE || - fip->field_readcount == TIFF_VARIABLE2); - continue; - } - } - else - { - if (fip->field_readcount == TIFF_VARIABLE || - fip->field_readcount == TIFF_VARIABLE2) - value_count = 1; - else if (fip->field_readcount == TIFF_SPP) - value_count = td->td_samplesperpixel; - else - value_count = fip->field_readcount; - if (fip->field_tag == TIFFTAG_DOTRANGE && - strcmp(fip->field_name, "DotRange") == 0) - { - /* TODO: This is an evil exception and should not have been - 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 */ - raw_data = dotrange; - TIFFGetField(tif, tag, dotrange + 0, dotrange + 1); - } - else if (fip->field_type == TIFF_ASCII || - fip->field_readcount == TIFF_VARIABLE || - fip->field_readcount == TIFF_VARIABLE2 || - fip->field_readcount == TIFF_SPP || value_count > 1) - { - if (TIFFGetField(tif, tag, &raw_data) != 1) - continue; - } - else - { - /*--: Rational2Double: For Rationals evaluate - * "set_field_type" to determine internal storage size. */ - int tv_size = TIFFFieldSetGetSize(fip); - raw_data = _TIFFmallocExt(tif, tv_size * value_count); - mem_alloc = 1; - if (TIFFGetField(tif, tag, raw_data) != 1) - { - _TIFFfreeExt(tif, raw_data); - continue; - } - } - } + if(fip->field_passcount) { + if (fip->field_readcount == TIFF_VARIABLE2 ) { + if(TIFFGetField(tif, tag, &value_count, &raw_data) != 1) + continue; + } else if (fip->field_readcount == TIFF_VARIABLE ) { + uint16 small_value_count; + if(TIFFGetField(tif, tag, &small_value_count, &raw_data) != 1) + continue; + value_count = small_value_count; + } else { + assert (fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2); + continue; + } + } else { + if (fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2) + value_count = 1; + else if (fip->field_readcount == TIFF_SPP) + value_count = td->td_samplesperpixel; + else + value_count = fip->field_readcount; + if (fip->field_tag == TIFFTAG_DOTRANGE + && strcmp(fip->field_name,"DotRange") == 0) { + /* TODO: This is an evil exception and should not have been + 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]; + raw_data = dotrange; + TIFFGetField(tif, tag, dotrange+0, dotrange+1); + } else if (fip->field_type == TIFF_ASCII + || fip->field_readcount == TIFF_VARIABLE + || fip->field_readcount == TIFF_VARIABLE2 + || fip->field_readcount == TIFF_SPP + || value_count > 1) { + if(TIFFGetField(tif, tag, &raw_data) != 1) + continue; + } else { + /*--: Rational2Double: For Rationals evaluate "set_field_type" to determine internal storage size. */ + int tv_size = _TIFFSetGetFieldSize(fip->set_field_type); + raw_data = _TIFFmalloc( + tv_size + * value_count); + mem_alloc = 1; + if(TIFFGetField(tif, tag, raw_data) != 1) { + _TIFFfree(raw_data); + continue; + } + } + } - /* - * Catch the tags which needs to be specially handled - * and pretty print them. If tag not handled in - * _TIFFPrettyPrintField() fall down and print it as - * any other tag. - */ - if (raw_data != NULL && - !_TIFFPrettyPrintField(tif, fip, fd, tag, value_count, - raw_data)) - _TIFFPrintField(fd, fip, value_count, raw_data); + /* + * Catch the tags which needs to be specially handled + * and pretty print them. If tag not handled in + * _TIFFPrettyPrintField() fall down and print it as + * any other tag. + */ + if (!_TIFFPrettyPrintField(tif, fip, fd, tag, value_count, raw_data)) + _TIFFPrintField(fd, fip, value_count, raw_data); - if (mem_alloc) - _TIFFfreeExt(tif, raw_data); - } - } + if(mem_alloc) + _TIFFfree(raw_data); + } + } + + if (tif->tif_tagmethods.printdir) + (*tif->tif_tagmethods.printdir)(tif, fd, flags); - if (tif->tif_tagmethods.printdir) - (*tif->tif_tagmethods.printdir)(tif, fd, flags); + if ((flags & TIFFPRINT_STRIPS) && + TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) { + uint32 s; - if ((flags & TIFFPRINT_STRIPS) && TIFFFieldSet(tif, FIELD_STRIPOFFSETS)) - { - uint32_t s; - - fprintf(fd, " %" PRIu32 " %s:\n", td->td_nstrips, - isTiled(tif) ? "Tiles" : "Strips"); - for (s = 0; s < td->td_nstrips; s++) - fprintf(fd, " %3" PRIu32 ": [%8" PRIu64 ", %8" PRIu64 "]\n", s, - TIFFGetStrileOffset(tif, s), - TIFFGetStrileByteCount(tif, s)); - } + fprintf(fd, " %lu %s:\n", + (unsigned long) 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 + } } -void _TIFFprintAscii(FILE *fd, const char *cp) +void +_TIFFprintAscii(FILE* fd, const char* cp) { - _TIFFprintAsciiBounded(fd, cp, strlen(cp)); + _TIFFprintAsciiBounded( fd, cp, strlen(cp)); } -static void _TIFFprintAsciiBounded(FILE *fd, const char *cp, size_t max_chars) +static void +_TIFFprintAsciiBounded(FILE* fd, const char* cp, size_t max_chars) { - for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) - { - const char *tp; + for (; max_chars > 0 && *cp != '\0'; cp++, max_chars--) { + const char* tp; - if (isprint((int)*cp)) - { - fputc(*cp, fd); - continue; - } - for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) - if (*tp++ == *cp) - break; - if (*tp) - fprintf(fd, "\\%c", *tp); - else - fprintf(fd, "\\%03o", *cp & 0xff); - } + if (isprint((int)*cp)) { + fputc(*cp, fd); + continue; + } + for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) + if (*tp++ == *cp) + break; + if (*tp) + fprintf(fd, "\\%c", *tp); + else + fprintf(fd, "\\%03o", *cp & 0xff); + } } -void _TIFFprintAsciiTag(FILE *fd, const char *name, const char *value) +void +_TIFFprintAsciiTag(FILE* fd, const char* name, const char* value) { - fprintf(fd, " %s: \"", name); - _TIFFprintAscii(fd, value); - fprintf(fd, "\"\n"); + fprintf(fd, " %s: \"", name); + _TIFFprintAscii(fd, value); + fprintf(fd, "\"\n"); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_read.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_read.c index 4fec83969..c4c868b1c 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_read.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_read.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -29,273 +29,292 @@ #include "tiffiop.h" #include -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_t strip, void *buf, - tmsize_t size, const char *module); -static tmsize_t TIFFReadRawTile1(TIFF *tif, uint32_t tile, void *buf, - tmsize_t size, const char *module); +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); +static int TIFFCheckRead(TIFF*, int); +static tmsize_t +TIFFReadRawStrip1(TIFF* tif, uint32 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); -#define NOSTRIP ((uint32_t)(-1)) /* undefined state */ -#define NOTILE ((uint32_t)(-1)) /* undefined state */ +#define NOSTRIP ((uint32)(-1)) /* undefined state */ +#define NOTILE ((uint32)(-1)) /* undefined state */ #define INITIAL_THRESHOLD (1024 * 1024) #define THRESHOLD_MULTIPLIER 10 -#define MAX_THRESHOLD \ - (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * \ - INITIAL_THRESHOLD) +#define MAX_THRESHOLD (THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * THRESHOLD_MULTIPLIER * INITIAL_THRESHOLD) -#define TIFF_INT64_MAX ((((int64_t)0x7FFFFFFF) << 32) | 0xFFFFFFFF) +#define TIFF_INT64_MAX ((((int64)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_t strip_or_tile, - const char *module) +static int TIFFReadAndRealloc( TIFF* tif, tmsize_t size, + tmsize_t rawdata_offset, + int is_strip, uint32 strip_or_tile, + const char* module ) { #if SIZEOF_SIZE_T == 8 - tmsize_t threshold = INITIAL_THRESHOLD; + tmsize_t threshold = INITIAL_THRESHOLD; #endif - tmsize_t already_read = 0; + tmsize_t already_read = 0; + #if SIZEOF_SIZE_T != 8 - /* On 32 bit processes, if the request is large enough, check against */ - /* file size */ - if (size > 1000 * 1000 * 1000) - { - uint64_t filesize = TIFFGetFileSize(tif); - if ((uint64_t)size >= filesize) + /* On 32 bit processes, if the request is large enough, check against */ + /* file size */ + if( size > 1000 * 1000 * 1000 ) { - TIFFErrorExtR(tif, module, - "Chunk size requested is larger than file size."); - return 0; + uint64 filesize = TIFFGetFileSize(tif); + if( (uint64)size >= filesize ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Chunk size requested is larger than file size."); + return 0; + } } - } #endif - /* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc */ - /* so as to avoid allocating too much memory in case the file is too */ - /* short. We could ask for the file size, but this might be */ - /* expensive with some I/O layers (think of reading a gzipped file) */ - /* Restrict to 64 bit processes, so as to avoid reallocs() */ - /* on 32 bit processes where virtual memory is scarce. */ - while (already_read < size) - { - tmsize_t bytes_read; - tmsize_t to_read = size - already_read; + /* On 64 bit processes, read first a maximum of 1 MB, then 10 MB, etc */ + /* so as to avoid allocating too much memory in case the file is too */ + /* short. We could ask for the file size, but this might be */ + /* expensive with some I/O layers (think of reading a gzipped file) */ + /* Restrict to 64 bit processes, so as to avoid reallocs() */ + /* on 32 bit processes where virtual memory is scarce. */ + while( already_read < size ) + { + tmsize_t bytes_read; + tmsize_t to_read = size - already_read; #if SIZEOF_SIZE_T == 8 - if (to_read >= threshold && threshold < MAX_THRESHOLD && - already_read + to_read + rawdata_offset > tif->tif_rawdatasize) - { - to_read = threshold; - threshold *= THRESHOLD_MULTIPLIER; - } + if( to_read >= threshold && threshold < MAX_THRESHOLD && + already_read + to_read + rawdata_offset > tif->tif_rawdatasize ) + { + to_read = threshold; + threshold *= THRESHOLD_MULTIPLIER; + } #endif - if (already_read + to_read + rawdata_offset > tif->tif_rawdatasize) - { - uint8_t *new_rawdata; - assert((tif->tif_flags & TIFF_MYBUFFER) != 0); - tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64( - (uint64_t)already_read + to_read + rawdata_offset, 1024); - if (tif->tif_rawdatasize == 0) + if (already_read + to_read + rawdata_offset > tif->tif_rawdatasize) { + uint8* new_rawdata; + assert((tif->tif_flags & TIFF_MYBUFFER) != 0); + tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64( + (uint64)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( + 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); + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = 0; + tif->tif_rawdatasize = 0; + return 0; + } + tif->tif_rawdata = new_rawdata; + } + if( tif->tif_rawdata == NULL ) { - TIFFErrorExtR(tif, module, "Invalid buffer size"); + /* should not happen in practice but helps CoverityScan */ return 0; } - new_rawdata = - (uint8_t *)_TIFFrealloc(tif->tif_rawdata, tif->tif_rawdatasize); - if (new_rawdata == 0) - { - TIFFErrorExtR(tif, module, - "No space for data buffer at scanline %" PRIu32, - tif->tif_row); - _TIFFfreeExt(tif, tif->tif_rawdata); - tif->tif_rawdata = 0; - tif->tif_rawdatasize = 0; - return 0; - } - tif->tif_rawdata = new_rawdata; - } - if (tif->tif_rawdata == NULL) - { - /* should not happen in practice but helps CoverityScan */ - return 0; - } - bytes_read = TIFFReadFile( - tif, tif->tif_rawdata + rawdata_offset + already_read, to_read); - already_read += bytes_read; - if (bytes_read != to_read) - { - memset(tif->tif_rawdata + rawdata_offset + already_read, 0, - tif->tif_rawdatasize - rawdata_offset - already_read); - if (is_strip) - { - TIFFErrorExtR(tif, module, - "Read error at scanline %" PRIu32 - "; got %" TIFF_SSIZE_FORMAT " bytes, " - "expected %" TIFF_SSIZE_FORMAT, - tif->tif_row, already_read, size); + bytes_read = TIFFReadFile(tif, + tif->tif_rawdata + rawdata_offset + already_read, to_read); + already_read += bytes_read; + 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); + } + 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); + } +#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; } - else - { - TIFFErrorExtR(tif, module, - "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); - } - return 0; } - } - return 1; + return 1; } -static int TIFFFillStripPartial(TIFF *tif, int strip, tmsize_t read_ahead, - int restart) + +static int +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_t read_offset; - tmsize_t to_read; - tmsize_t read_ahead_mod; - /* tmsize_t bytecountm; */ + static const char module[] = "TIFFFillStripPartial"; + register TIFFDirectory *td = &tif->tif_dir; + tmsize_t unused_data; + uint64 read_offset; + tmsize_t to_read; + tmsize_t read_ahead_mod; + /* tmsize_t bytecountm; */ - /* - * Expand raw data buffer, if needed, to hold data - * strip coming from file (perhaps should set upper - * bound on the size of a buffer we'll use?). - */ + /* + * Expand raw data buffer, if needed, to hold data + * strip coming from file (perhaps should set upper + * bound on the size of a buffer we'll use?). + */ - /* bytecountm=(tmsize_t) TIFFGetStrileByteCount(tif, strip); */ + /* bytecountm=(tmsize_t) TIFFGetStrileByteCount(tif, strip); */ - /* Not completely sure where the * 2 comes from, but probably for */ - /* an exponentional growth strategy of tif_rawdatasize */ - if (read_ahead < TIFF_TMSIZE_T_MAX / 2) - read_ahead_mod = read_ahead * 2; - else - read_ahead_mod = read_ahead; - if (read_ahead_mod > tif->tif_rawdatasize) - { - assert(restart); - - tif->tif_curstrip = NOSTRIP; - if ((tif->tif_flags & TIFF_MYBUFFER) == 0) - { - TIFFErrorExtR(tif, module, - "Data buffer too small to hold part of strip %d", - strip); - return (0); + /* Not completely sure where the * 2 comes from, but probably for */ + /* an exponentional growth strategy of tif_rawdatasize */ + if( read_ahead < TIFF_TMSIZE_T_MAX / 2 ) + read_ahead_mod = read_ahead * 2; + else + read_ahead_mod = read_ahead; + if (read_ahead_mod > tif->tif_rawdatasize) { + assert( 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); + return (0); + } } - } - if (restart) - { - tif->tif_rawdataloaded = 0; - tif->tif_rawdataoff = 0; - } + if( restart ) + { + tif->tif_rawdataloaded = 0; + tif->tif_rawdataoff = 0; + } - /* - ** If we are reading more data, move any unused data to the - ** start of the buffer. - */ - if (tif->tif_rawdataloaded > 0) - unused_data = - tif->tif_rawdataloaded - (tif->tif_rawcp - tif->tif_rawdata); - else - unused_data = 0; + /* + ** If we are reading more data, move any unused data to the + ** start of the buffer. + */ + if( tif->tif_rawdataloaded > 0 ) + unused_data = tif->tif_rawdataloaded - (tif->tif_rawcp - tif->tif_rawdata); + else + unused_data = 0; + + if( unused_data > 0 ) + { + assert((tif->tif_flags&TIFF_BUFFERMMAP)==0); + memmove( tif->tif_rawdata, tif->tif_rawcp, unused_data ); + } - if (unused_data > 0) - { - assert((tif->tif_flags & TIFF_BUFFERMMAP) == 0); - memmove(tif->tif_rawdata, tif->tif_rawcp, unused_data); - } + /* + ** Seek to the point in the file where more data should be read. + */ + read_offset = TIFFGetStrileOffset(tif, strip) + + tif->tif_rawdataoff + tif->tif_rawdataloaded; - /* - ** Seek to the point in the file where more data should be read. - */ - read_offset = TIFFGetStrileOffset(tif, strip) + tif->tif_rawdataoff + - tif->tif_rawdataloaded; + 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); + return 0; + } - if (!SeekOK(tif, read_offset)) - { - TIFFErrorExtR(tif, module, - "Seek error at scanline %" PRIu32 ", strip %d", - tif->tif_row, strip); - return 0; - } + /* + ** How much do we want to read? + */ + if( read_ahead_mod > tif->tif_rawdatasize ) + 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 ) + { + to_read = (tmsize_t) TIFFGetStrileByteCount(tif, strip) + - tif->tif_rawdataoff - tif->tif_rawdataloaded; + } - /* - ** How much do we want to read? - */ - if (read_ahead_mod > tif->tif_rawdatasize) - to_read = read_ahead_mod - unused_data; - else - to_read = tif->tif_rawdatasize - unused_data; - 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; - } + assert((tif->tif_flags&TIFF_BUFFERMMAP)==0); + if( !TIFFReadAndRealloc( tif, to_read, unused_data, + 1, /* is_strip */ + 0, /* strip_or_tile */ + module) ) + { + return 0; + } - assert((tif->tif_flags & TIFF_BUFFERMMAP) == 0); - if (!TIFFReadAndRealloc(tif, to_read, unused_data, 1, /* is_strip */ - 0, /* strip_or_tile */ - module)) - { - return 0; - } + tif->tif_rawdataoff = tif->tif_rawdataoff + tif->tif_rawdataloaded - unused_data ; + tif->tif_rawdataloaded = unused_data + to_read; - tif->tif_rawdataoff = - tif->tif_rawdataoff + tif->tif_rawdataloaded - unused_data; - tif->tif_rawdataloaded = unused_data + to_read; + tif->tif_rawcc = tif->tif_rawdataloaded; + tif->tif_rawcp = tif->tif_rawdata; + + if (!isFillOrder(tif, td->td_fillorder) && + (tif->tif_flags & TIFF_NOBITREV) == 0) { + assert((tif->tif_flags&TIFF_BUFFERMMAP)==0); + TIFFReverseBits(tif->tif_rawdata + unused_data, to_read ); + } - tif->tif_rawcc = tif->tif_rawdataloaded; - tif->tif_rawcp = tif->tif_rawdata; - - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - { - assert((tif->tif_flags & TIFF_BUFFERMMAP) == 0); - TIFFReverseBits(tif->tif_rawdata + unused_data, to_read); - } - - /* - ** When starting a strip from the beginning we need to - ** restart the decoder. - */ - if (restart) - { + /* + ** When starting a strip from the beginning we need to + ** restart the decoder. + */ + if( restart ) + { #ifdef JPEG_SUPPORT - /* A bit messy since breaks the codec abstraction. Ultimately */ - /* there should be a function pointer for that, but it seems */ - /* only JPEG is affected. */ - /* 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_t)tif->tif_rawcc < TIFFGetStrileByteCount(tif, strip)) - { - if (TIFFJPEGIsFullStripRequired(tif)) + /* A bit messy since breaks the codec abstraction. Ultimately */ + /* there should be a function pointer for that, but it seems */ + /* only JPEG is affected. */ + /* 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) ) { - return TIFFFillStrip(tif, strip); + if( TIFFJPEGIsFullStripRequired(tif) ) + { + return TIFFFillStrip(tif, strip); + } } - } #endif - return TIFFStartStrip(tif, strip); - } - else - { - return 1; - } + return TIFFStartStrip(tif, strip); + } + else + { + return 1; + } } /* @@ -306,165 +325,159 @@ static int TIFFFillStripPartial(TIFF *tif, int strip, tmsize_t read_ahead, * and avoid reading the whole compressed raw data for big * strips. */ -static int TIFFSeek(TIFF *tif, uint32_t row, uint16_t sample) +static int +TIFFSeek(TIFF* tif, uint32 row, uint16 sample ) { - register TIFFDirectory *td = &tif->tif_dir; - uint32_t strip; - int whole_strip; - tmsize_t read_ahead = 0; + register TIFFDirectory *td = &tif->tif_dir; + uint32 strip; + int whole_strip; + tmsize_t read_ahead = 0; - /* - ** Establish what strip we are working from. - */ - if (row >= td->td_imagelength) - { /* out of range */ - TIFFErrorExtR(tif, tif->tif_name, - "%" PRIu32 ": Row out of range, max %" PRIu32 "", row, - td->td_imagelength); - return (0); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - { - if (sample >= td->td_samplesperpixel) - { - TIFFErrorExtR(tif, tif->tif_name, - "%" PRIu16 ": Sample out of range, max %" PRIu16 "", - sample, td->td_samplesperpixel); - return (0); - } - strip = (uint32_t)sample * td->td_stripsperimage + - row / td->td_rowsperstrip; - } - else - strip = row / td->td_rowsperstrip; + /* + ** Establish what strip we are working from. + */ + 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); + 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); + return (0); + } + strip = (uint32)sample*td->td_stripsperimage + row/td->td_rowsperstrip; + } else + strip = row / td->td_rowsperstrip; /* * Do we want to treat this strip as one whole chunk or * read it a few lines at a time? */ #if defined(CHUNKY_STRIP_READ_SUPPORT) - whole_strip = TIFFGetStrileByteCount(tif, strip) < 10 || isMapped(tif); - if (td->td_compression == COMPRESSION_LERC || - td->td_compression == COMPRESSION_JBIG) - { - /* Ideally plugins should have a way to declare they don't support - * chunk strip */ - whole_strip = 1; - } + whole_strip = TIFFGetStrileByteCount(tif, strip) < 10 + || isMapped(tif); + if( td->td_compression == COMPRESSION_LERC || + td->td_compression == COMPRESSION_JBIG ) + { + /* Ideally plugins should have a way to declare they don't support + * chunk strip */ + whole_strip = 1; + } #else - whole_strip = 1; + whole_strip = 1; #endif - - if (!whole_strip) - { - /* 16 is for YCbCr mode where we may need to read 16 */ - /* lines at a time to get a decompressed line, and 5000 */ - /* is some constant value, for example for JPEG tables */ - if (tif->tif_scanlinesize < TIFF_TMSIZE_T_MAX / 16 && - tif->tif_scanlinesize * 16 < TIFF_TMSIZE_T_MAX - 5000) + + if( !whole_strip ) { - read_ahead = tif->tif_scanlinesize * 16 + 5000; + /* 16 is for YCbCr mode where we may need to read 16 */ + /* lines at a time to get a decompressed line, and 5000 */ + /* is some constant value, for example for JPEG tables */ + if( tif->tif_scanlinesize < TIFF_TMSIZE_T_MAX / 16 && + tif->tif_scanlinesize * 16 < TIFF_TMSIZE_T_MAX - 5000 ) + { + read_ahead = tif->tif_scanlinesize * 16 + 5000; + } + else + { + read_ahead = tif->tif_scanlinesize; + } } - else - { - read_ahead = tif->tif_scanlinesize; - } - } - /* - * If we haven't loaded this strip, do so now, possibly - * only reading the first part. - */ - if (strip != tif->tif_curstrip) - { /* different strip, refill */ - - if (whole_strip) - { - if (!TIFFFillStrip(tif, strip)) - return (0); - } - else - { - if (!TIFFFillStripPartial(tif, strip, read_ahead, 1)) - return 0; - } - } - - /* - ** If we already have some data loaded, do we need to read some more? - */ - else if (!whole_strip) - { - if (((tif->tif_rawdata + tif->tif_rawdataloaded) - tif->tif_rawcp) < - read_ahead && - (uint64_t)tif->tif_rawdataoff + tif->tif_rawdataloaded < - TIFFGetStrileByteCount(tif, strip)) - { - if (!TIFFFillStripPartial(tif, strip, read_ahead, 0)) - return 0; - } - } - - if (row < tif->tif_row) - { /* - * Moving backwards within the same strip: backup - * to the start and then decode forward (below). - * - * NB: If you're planning on lots of random access within a - * strip, it's better to just read and decode the entire - * strip, and then access the decoded data in a random fashion. + * If we haven't loaded this strip, do so now, possibly + * only reading the first part. */ + if (strip != tif->tif_curstrip) { /* different strip, refill */ + + if( whole_strip ) + { + if (!TIFFFillStrip(tif, strip)) + return (0); + } + else + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,1) ) + return 0; + } + } - if (tif->tif_rawdataoff != 0) - { - if (!TIFFFillStripPartial(tif, strip, read_ahead, 1)) - return 0; - } - else - { - if (!TIFFStartStrip(tif, strip)) - return (0); - } - } - - if (row != tif->tif_row) - { /* - * Seek forward to the desired row. - */ + ** If we already have some data loaded, do we need to read some more? + */ + 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) ) + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,0) ) + return 0; + } + } - /* TODO: Will this really work with partial buffers? */ + if (row < tif->tif_row) { + /* + * Moving backwards within the same strip: backup + * to the start and then decode forward (below). + * + * NB: If you're planning on lots of random access within a + * strip, it's better to just read and decode the entire + * strip, and then access the decoded data in a random fashion. + */ - if (!(*tif->tif_seek)(tif, row - tif->tif_row)) - return (0); - tif->tif_row = row; - } + if( tif->tif_rawdataoff != 0 ) + { + if( !TIFFFillStripPartial(tif,strip,read_ahead,1) ) + return 0; + } + else + { + if (!TIFFStartStrip(tif, strip)) + return (0); + } + } + + if (row != tif->tif_row) { + /* + * Seek forward to the desired row. + */ - return (1); + /* TODO: Will this really work with partial buffers? */ + + if (!(*tif->tif_seek)(tif, row - tif->tif_row)) + return (0); + tif->tif_row = row; + } + + return (1); } -int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row, uint16_t sample) +int +TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) { - int e; + int e; - if (!TIFFCheckRead(tif, 0)) - return (-1); - if ((e = TIFFSeek(tif, row, sample)) != 0) - { - /* - * Decompress desired row into user buffer. - */ - e = (*tif->tif_decoderow)(tif, (uint8_t *)buf, tif->tif_scanlinesize, - sample); + if (!TIFFCheckRead(tif, 0)) + return (-1); + if( (e = TIFFSeek(tif, row, sample)) != 0) { + /* + * Decompress desired row into user buffer. + */ + e = (*tif->tif_decoderow) + (tif, (uint8*) buf, tif->tif_scanlinesize, sample); - /* we are now poised at the beginning of the next row */ - tif->tif_row = row + 1; + /* we are now poised at the beginning of the next row */ + tif->tif_row = row + 1; - if (e) - (*tif->tif_postdecode)(tif, (uint8_t *)buf, tif->tif_scanlinesize); - } - return (e > 0 ? 1 : -1); + if (e) + (*tif->tif_postdecode)(tif, (uint8*) buf, + tif->tif_scanlinesize); + } + return (e > 0 ? 1 : -1); } /* @@ -472,436 +485,471 @@ int TIFFReadScanline(TIFF *tif, void *buf, uint32_t row, uint16_t sample) * rows in the strip (check for truncated last strip on any * of the separations). */ -static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF *tif, uint32_t strip, - uint16_t *pplane) +static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32 strip, uint16* pplane) { - static const char module[] = "TIFFReadEncodedStrip"; - TIFFDirectory *td = &tif->tif_dir; - 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) - { - TIFFErrorExtR(tif, module, - "%" PRIu32 ": Strip out of range, max %" PRIu32, strip, - td->td_nstrips); - return ((tmsize_t)(-1)); - } + static const char module[] = "TIFFReadEncodedStrip"; + TIFFDirectory *td = &tif->tif_dir; + uint32 rowsperstrip; + uint32 stripsperplane; + uint32 stripinplane; + uint32 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); + return((tmsize_t)(-1)); + } - rowsperstrip = td->td_rowsperstrip; - if (rowsperstrip > td->td_imagelength) - rowsperstrip = td->td_imagelength; - stripsperplane = - TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip); - stripinplane = (strip % stripsperplane); - if (pplane) - *pplane = (uint16_t)(strip / stripsperplane); - rows = td->td_imagelength - stripinplane * rowsperstrip; - if (rows > rowsperstrip) - rows = rowsperstrip; - stripsize = TIFFVStripSize(tif, rows); - if (stripsize == 0) - return ((tmsize_t)(-1)); - return stripsize; + rowsperstrip=td->td_rowsperstrip; + if (rowsperstrip>td->td_imagelength) + rowsperstrip=td->td_imagelength; + stripsperplane= TIFFhowmany_32_maxuint_compat(td->td_imagelength, rowsperstrip); + stripinplane=(strip%stripsperplane); + if( pplane ) *pplane=(uint16)(strip/stripsperplane); + rows=td->td_imagelength-stripinplane*rowsperstrip; + if (rows>rowsperstrip) + rows=rowsperstrip; + stripsize=TIFFVStripSize(tif,rows); + if (stripsize==0) + return((tmsize_t)(-1)); + return stripsize; } /* * Read a strip of data and decompress the specified * amount into the user-supplied buffer. */ -tmsize_t TIFFReadEncodedStrip(TIFF *tif, uint32_t strip, void *buf, - tmsize_t size) +tmsize_t +TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) { - static const char module[] = "TIFFReadEncodedStrip"; - TIFFDirectory *td = &tif->tif_dir; - tmsize_t stripsize; - uint16_t plane; + static const char module[] = "TIFFReadEncodedStrip"; + TIFFDirectory *td = &tif->tif_dir; + tmsize_t stripsize; + uint16 plane; - stripsize = TIFFReadEncodedStripGetStripSize(tif, strip, &plane); - if (stripsize == ((tmsize_t)(-1))) - return ((tmsize_t)(-1)); + stripsize=TIFFReadEncodedStripGetStripSize(tif, strip, &plane); + if (stripsize==((tmsize_t)(-1))) + return((tmsize_t)(-1)); /* shortcut to avoid an extra memcpy() */ - if (td->td_compression == COMPRESSION_NONE && size != (tmsize_t)(-1) && - size >= stripsize && !isMapped(tif) && - ((tif->tif_flags & TIFF_NOREADRAW) == 0)) + if( td->td_compression == COMPRESSION_NONE && + size!=(tmsize_t)(-1) && size >= stripsize && + !isMapped(tif) && + ((tif->tif_flags&TIFF_NOREADRAW)==0) ) { if (TIFFReadRawStrip1(tif, strip, buf, stripsize, module) != stripsize) return ((tmsize_t)(-1)); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(buf, stripsize); + TIFFReverseBits(buf,stripsize); - (*tif->tif_postdecode)(tif, buf, stripsize); + (*tif->tif_postdecode)(tif,buf,stripsize); return (stripsize); } - if ((size != (tmsize_t)(-1)) && (size < stripsize)) - stripsize = size; - if (!TIFFFillStrip(tif, strip)) - return ((tmsize_t)(-1)); - if ((*tif->tif_decodestrip)(tif, buf, stripsize, plane) <= 0) - return ((tmsize_t)(-1)); - (*tif->tif_postdecode)(tif, buf, stripsize); - return (stripsize); + if ((size!=(tmsize_t)(-1))&&(sizetif_decodestrip)(tif,buf,stripsize,plane)<=0) + return((tmsize_t)(-1)); + (*tif->tif_postdecode)(tif,buf,stripsize); + return(stripsize); } -/* Variant of TIFFReadEncodedStrip() that does - * * if *buf == NULL, *buf = _TIFFmallocExt(tif, bufsizetoalloc) only after - * TIFFFillStrip() has succeeded. This avoid excessive memory allocation in case - * of truncated file. +/* Variant of TIFFReadEncodedStrip() that does + * * if *buf == NULL, *buf = _TIFFmalloc(bufsizetoalloc) only after TIFFFillStrip() has + * succeeded. This avoid excessive memory allocation in case of truncated + * file. * * calls regular TIFFReadEncodedStrip() if *buf != NULL */ -tmsize_t _TIFFReadEncodedStripAndAllocBuffer(TIFF *tif, uint32_t strip, - void **buf, - tmsize_t bufsizetoalloc, - tmsize_t size_to_read) +tmsize_t +_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip, + void **buf, tmsize_t bufsizetoalloc, + tmsize_t size_to_read) { tmsize_t this_stripsize; - uint16_t plane; + uint16 plane; - if (*buf != NULL) + if( *buf != NULL ) { return TIFFReadEncodedStrip(tif, strip, *buf, size_to_read); } - this_stripsize = TIFFReadEncodedStripGetStripSize(tif, strip, &plane); - if (this_stripsize == ((tmsize_t)(-1))) - return ((tmsize_t)(-1)); + this_stripsize=TIFFReadEncodedStripGetStripSize(tif, strip, &plane); + if (this_stripsize==((tmsize_t)(-1))) + return((tmsize_t)(-1)); - if ((size_to_read != (tmsize_t)(-1)) && (size_to_read < this_stripsize)) - this_stripsize = size_to_read; - if (!TIFFFillStrip(tif, strip)) - return ((tmsize_t)(-1)); + if ((size_to_read!=(tmsize_t)(-1))&&(size_to_readtif_clientdata, TIFFFileName(tif), "No space for strip buffer"); + return((tmsize_t)(-1)); } _TIFFmemset(*buf, 0, bufsizetoalloc); - if ((*tif->tif_decodestrip)(tif, *buf, this_stripsize, plane) <= 0) - return ((tmsize_t)(-1)); - (*tif->tif_postdecode)(tif, *buf, this_stripsize); - return (this_stripsize); + if ((*tif->tif_decodestrip)(tif,*buf,this_stripsize,plane)<=0) + return((tmsize_t)(-1)); + (*tif->tif_postdecode)(tif,*buf,this_stripsize); + return(this_stripsize); + + } -static tmsize_t TIFFReadRawStrip1(TIFF *tif, uint32_t strip, void *buf, - tmsize_t size, const char *module) +static tmsize_t +TIFFReadRawStrip1(TIFF* tif, uint32 strip, void* buf, tmsize_t size, + const char* module) { - assert((tif->tif_flags & TIFF_NOREADRAW) == 0); - if (!isMapped(tif)) - { - tmsize_t cc; + assert((tif->tif_flags&TIFF_NOREADRAW)==0); + if (!isMapped(tif)) { + tmsize_t cc; - if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip))) - { - TIFFErrorExtR(tif, module, - "Seek error at scanline %" PRIu32 ", strip %" PRIu32, - tif->tif_row, strip); - return ((tmsize_t)(-1)); - } - cc = TIFFReadFile(tif, buf, size); - if (cc != size) - { - TIFFErrorExtR(tif, module, - "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_t)TIFF_TMSIZE_T_MAX) || - ((ma = (tmsize_t)TIFFGetStrileOffset(tif, strip)) > tif->tif_size)) - { - n = 0; - } - else if (ma > TIFF_TMSIZE_T_MAX - size) - { - n = 0; - } - else - { - tmsize_t mb = ma + size; - if (mb > tif->tif_size) - n = tif->tif_size - ma; + 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); + 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 + 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)) + { + n=0; + } + else if( ma > TIFF_TMSIZE_T_MAX - size ) + { + n=0; + } + else + { + tmsize_t mb=ma+size; + if (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 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 + return ((tmsize_t)(-1)); + } + _TIFFmemcpy(buf, tif->tif_base + ma, + size); + } + return (size); +} + +static tmsize_t +TIFFReadRawStripOrTile2(TIFF* tif, uint32 strip_or_tile, int is_strip, + tmsize_t size, const char* module) +{ + assert( !isMapped(tif) ); + assert((tif->tif_flags&TIFF_NOREADRAW)==0); + + if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip_or_tile))) { + 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); + } else - n = size; - } - if (n != size) - { - TIFFErrorExtR(tif, module, - "Read error at scanline %" PRIu32 ", strip %" PRIu32 - "; got %" TIFF_SSIZE_FORMAT - " bytes, expected %" TIFF_SSIZE_FORMAT, - tif->tif_row, strip, n, size); + { + 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); + } return ((tmsize_t)(-1)); } - _TIFFmemcpy(buf, tif->tif_base + ma, size); - } - return (size); -} -static tmsize_t TIFFReadRawStripOrTile2(TIFF *tif, uint32_t strip_or_tile, - int is_strip, tmsize_t size, - const char *module) -{ - assert(!isMapped(tif)); - assert((tif->tif_flags & TIFF_NOREADRAW) == 0); - - if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip_or_tile))) - { - if (is_strip) + if( !TIFFReadAndRealloc( tif, size, 0, is_strip, + strip_or_tile, module ) ) { - TIFFErrorExtR(tif, module, - "Seek error at scanline %" PRIu32 ", strip %" PRIu32, - tif->tif_row, strip_or_tile); + return ((tmsize_t)(-1)); } - else - { - TIFFErrorExtR(tif, module, - "Seek error at row %" PRIu32 ", col %" PRIu32 - ", tile %" PRIu32, - tif->tif_row, tif->tif_col, strip_or_tile); - } - return ((tmsize_t)(-1)); - } - if (!TIFFReadAndRealloc(tif, size, 0, is_strip, strip_or_tile, module)) - { - return ((tmsize_t)(-1)); - } - - return (size); + return (size); } /* * Read a strip of data from the file. */ -tmsize_t TIFFReadRawStrip(TIFF *tif, uint32_t strip, void *buf, tmsize_t size) +tmsize_t +TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size) { - static const char module[] = "TIFFReadRawStrip"; - TIFFDirectory *td = &tif->tif_dir; - uint64_t bytecount64; - tmsize_t bytecountm; + static const char module[] = "TIFFReadRawStrip"; + TIFFDirectory *td = &tif->tif_dir; + uint64 bytecount64; + tmsize_t bytecountm; - if (!TIFFCheckRead(tif, 0)) - return ((tmsize_t)(-1)); - if (strip >= td->td_nstrips) - { - TIFFErrorExtR(tif, module, - "%" PRIu32 ": Strip out of range, max %" PRIu32, strip, - td->td_nstrips); - return ((tmsize_t)(-1)); - } - if (tif->tif_flags & TIFF_NOREADRAW) - { - TIFFErrorExtR(tif, module, - "Compression scheme does not support access to raw " - "uncompressed data"); - return ((tmsize_t)(-1)); - } - bytecount64 = TIFFGetStrileByteCount(tif, strip); - if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64) - bytecountm = size; - else - bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module); - if (bytecountm == 0) - { - return ((tmsize_t)(-1)); - } - return (TIFFReadRawStrip1(tif, strip, buf, bytecountm, module)); + 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); + return ((tmsize_t)(-1)); + } + if (tif->tif_flags&TIFF_NOREADRAW) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Compression scheme does not support access to raw uncompressed data"); + return ((tmsize_t)(-1)); + } + bytecount64 = TIFFGetStrileByteCount(tif, strip); + if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64) + bytecountm = size; + else + bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module); + if( bytecountm == 0 ) { + return ((tmsize_t)(-1)); + } + return (TIFFReadRawStrip1(tif, strip, buf, bytecountm, module)); } TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW -static uint64_t NoSanitizeSubUInt64(uint64_t a, uint64_t b) { return a - b; } +static uint64 NoSanitizeSubUInt64(uint64 a, uint64 b) +{ + return a - b; +} /* * Read the specified strip and setup for decoding. The data buffer is * expanded, as necessary, to hold the strip's data. */ -int TIFFFillStrip(TIFF *tif, uint32_t strip) +int +TIFFFillStrip(TIFF* tif, uint32 strip) { - static const char module[] = "TIFFFillStrip"; - TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "TIFFFillStrip"; + TIFFDirectory *td = &tif->tif_dir; - if ((tif->tif_flags & TIFF_NOREADRAW) == 0) - { - uint64_t bytecount = TIFFGetStrileByteCount(tif, strip); - if (bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX) - { - TIFFErrorExtR(tif, module, - "Invalid strip byte count %" PRIu64 - ", strip %" PRIu32, - bytecount, strip); - return (0); - } + 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 + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid strip byte count %llu, strip %lu", + (unsigned long long) bytecount, + (unsigned long) strip); +#endif + return (0); + } - /* To avoid excessive memory allocations: */ - /* Byte count should normally not be larger than a number of */ - /* times the uncompressed size plus some margin */ - if (bytecount > 1024 * 1024) - { - /* 10 and 4096 are just values that could be adjusted. */ - /* Hopefully they are safe enough for all codecs */ - tmsize_t stripsize = TIFFStripSize(tif); - if (stripsize != 0 && (bytecount - 4096) / 10 > (uint64_t)stripsize) - { - uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096; - TIFFErrorExtR(tif, module, - "Too large strip byte count %" PRIu64 - ", strip %" PRIu32 ". Limiting to %" PRIu64, - bytecount, strip, newbytecount); - bytecount = newbytecount; - } - } - - if (isMapped(tif)) - { - /* - * We must check for overflow, potentially causing - * an OOB read. Instead of simple - * - * TIFFGetStrileOffset(tif, strip)+bytecount > tif->tif_size - * - * comparison (which can overflow) we do the following - * two comparisons: - */ - 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. - */ - TIFFErrorExtR( - tif, module, - - "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); - } - } - - if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) || - (tif->tif_flags & TIFF_NOBITREV))) - { - /* - * The image is mapped into memory and we either don't - * need to flip bits or the compression routine is - * going to handle this operation itself. In this - * case, avoid copying the raw data and instead just - * reference the data from the memory mapped file - * image. This assumes that the decompression - * routines do not modify the contents of the raw data - * buffer (if they try to, the application will get a - * fault since the file is mapped read-only). - */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - { - _TIFFfreeExt(tif, tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawdatasize = 0; - } - tif->tif_flags &= ~TIFF_MYBUFFER; - tif->tif_rawdatasize = (tmsize_t)bytecount; - tif->tif_rawdata = - tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, strip); - tif->tif_rawdataoff = 0; - tif->tif_rawdataloaded = (tmsize_t)bytecount; - - /* - * When we have tif_rawdata reference directly into the memory - * mapped file we need to be pretty careful about how we use the - * rawdata. It is not a general purpose working buffer as it - * normally otherwise is. So we keep track of this fact to avoid - * using it improperly. - */ - tif->tif_flags |= TIFF_BUFFERMMAP; - } - else - { - /* - * Expand raw data buffer, if needed, to hold data - * strip coming from file (perhaps should set upper - * bound on the size of a buffer we'll use?). - */ - tmsize_t bytecountm; - bytecountm = (tmsize_t)bytecount; - if ((uint64_t)bytecountm != bytecount) - { - TIFFErrorExtR(tif, module, "Integer overflow"); - return (0); - } - if (bytecountm > tif->tif_rawdatasize) - { - tif->tif_curstrip = NOSTRIP; - if ((tif->tif_flags & TIFF_MYBUFFER) == 0) + /* To avoid excessive memory allocations: */ + /* Byte count should normally not be larger than a number of */ + /* times the uncompressed size plus some margin */ + if( bytecount > 1024 * 1024 ) { - TIFFErrorExtR( - tif, module, - "Data buffer too small to hold strip %" PRIu32, strip); - return (0); - } - } - if (tif->tif_flags & TIFF_BUFFERMMAP) - { - tif->tif_curstrip = NOSTRIP; - tif->tif_rawdata = NULL; - tif->tif_rawdatasize = 0; - tif->tif_flags &= ~TIFF_BUFFERMMAP; - } + /* 10 and 4096 are just values that could be adjusted. */ + /* Hopefully they are safe enough for all codecs */ + tmsize_t stripsize = TIFFStripSize(tif); + if( stripsize != 0 && + (bytecount - 4096) / 10 > (uint64)stripsize ) + { + uint64 newbytecount = (uint64)stripsize * 10 + 4096; + if( newbytecount == 0 || newbytecount > (uint64)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 + bytecount = newbytecount; + } + } + } - if (isMapped(tif)) - { - if (bytecountm > tif->tif_rawdatasize && - !TIFFReadBufferSetup(tif, 0, bytecountm)) - { - return (0); - } - if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata, bytecountm, - module) != bytecountm) - { - return (0); - } - } - else - { - if (TIFFReadRawStripOrTile2(tif, strip, 1, bytecountm, - module) != bytecountm) - { - return (0); - } - } + if (isMapped(tif)) { + /* + * We must check for overflow, potentially causing + * an OOB read. Instead of simple + * + * TIFFGetStrileOffset(tif, strip)+bytecount > tif->tif_size + * + * comparison (which can overflow) we do the following + * two comparisons: + */ + if (bytecount > (uint64)tif->tif_size || + TIFFGetStrileOffset(tif, strip) > (uint64)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, - tif->tif_rawdataoff = 0; - tif->tif_rawdataloaded = bytecountm; + "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, - if (!isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, bytecountm); - } - } - return (TIFFStartStrip(tif, strip)); + "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 + tif->tif_curstrip = NOSTRIP; + return (0); + } + } + + if (isMapped(tif) && + (isFillOrder(tif, td->td_fillorder) + || (tif->tif_flags & TIFF_NOBITREV))) { + /* + * The image is mapped into memory and we either don't + * need to flip bits or the compression routine is + * going to handle this operation itself. In this + * case, avoid copying the raw data and instead just + * reference the data from the memory mapped file + * image. This assumes that the decompression + * routines do not modify the contents of the raw data + * buffer (if they try to, the application will get a + * fault since the file is mapped read-only). + */ + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + } + tif->tif_flags &= ~TIFF_MYBUFFER; + tif->tif_rawdatasize = (tmsize_t)bytecount; + tif->tif_rawdata = tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, strip); + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = (tmsize_t) bytecount; + + /* + * When we have tif_rawdata reference directly into the memory mapped file + * we need to be pretty careful about how we use the rawdata. It is not + * a general purpose working buffer as it normally otherwise is. So we + * keep track of this fact to avoid using it improperly. + */ + tif->tif_flags |= TIFF_BUFFERMMAP; + } else { + /* + * Expand raw data buffer, if needed, to hold data + * strip coming from file (perhaps should set upper + * bound on the size of a buffer we'll use?). + */ + tmsize_t bytecountm; + bytecountm=(tmsize_t)bytecount; + if ((uint64)bytecountm!=bytecount) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + return(0); + } + if (bytecountm > tif->tif_rawdatasize) { + 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); + return (0); + } + } + if (tif->tif_flags&TIFF_BUFFERMMAP) { + tif->tif_curstrip = NOSTRIP; + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + tif->tif_flags &= ~TIFF_BUFFERMMAP; + } + + if( isMapped(tif) ) + { + if (bytecountm > tif->tif_rawdatasize && + !TIFFReadBufferSetup(tif, 0, bytecountm)) + { + return (0); + } + if (TIFFReadRawStrip1(tif, strip, tif->tif_rawdata, + bytecountm, module) != bytecountm) + { + return (0); + } + } + else + { + if (TIFFReadRawStripOrTile2(tif, strip, 1, + bytecountm, module) != bytecountm) + { + return (0); + } + } + + + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = bytecountm; + + if (!isFillOrder(tif, td->td_fillorder) && + (tif->tif_flags & TIFF_NOBITREV) == 0) + TIFFReverseBits(tif->tif_rawdata, bytecountm); + } + } + return (TIFFStartStrip(tif, strip)); } /* @@ -913,162 +961,120 @@ int TIFFFillStrip(TIFF *tif, uint32_t strip) * Read and decompress a tile of data. The * tile is selected by the (x,y,z,s) coordinates. */ -tmsize_t TIFFReadTile(TIFF *tif, void *buf, uint32_t x, uint32_t y, uint32_t z, - uint16_t s) +tmsize_t +TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) { - if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) - return ((tmsize_t)(-1)); - return (TIFFReadEncodedTile(tif, TIFFComputeTile(tif, x, y, z, s), buf, - (tmsize_t)(-1))); + if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) + return ((tmsize_t)(-1)); + return (TIFFReadEncodedTile(tif, + TIFFComputeTile(tif, x, y, z, s), buf, (tmsize_t)(-1))); } /* * Read a tile of data and decompress the specified * amount into the user-supplied buffer. */ -tmsize_t TIFFReadEncodedTile(TIFF *tif, uint32_t tile, void *buf, tmsize_t size) +tmsize_t +TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) { - static const char module[] = "TIFFReadEncodedTile"; - TIFFDirectory *td = &tif->tif_dir; - tmsize_t tilesize = tif->tif_tilesize; + static const char module[] = "TIFFReadEncodedTile"; + TIFFDirectory *td = &tif->tif_dir; + tmsize_t tilesize = tif->tif_tilesize; - if (!TIFFCheckRead(tif, 1)) - return ((tmsize_t)(-1)); - if (tile >= td->td_nstrips) - { - TIFFErrorExtR(tif, module, - "%" PRIu32 ": Tile out of range, max %" PRIu32, tile, - td->td_nstrips); - return ((tmsize_t)(-1)); - } + 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); + return ((tmsize_t)(-1)); + } /* shortcut to avoid an extra memcpy() */ - if (td->td_compression == COMPRESSION_NONE && size != (tmsize_t)(-1) && - size >= tilesize && !isMapped(tif) && - ((tif->tif_flags & TIFF_NOREADRAW) == 0)) + if( td->td_compression == COMPRESSION_NONE && + size!=(tmsize_t)(-1) && size >= tilesize && + !isMapped(tif) && + ((tif->tif_flags&TIFF_NOREADRAW)==0) ) { if (TIFFReadRawTile1(tif, tile, buf, tilesize, module) != tilesize) return ((tmsize_t)(-1)); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(buf, tilesize); + TIFFReverseBits(buf,tilesize); - (*tif->tif_postdecode)(tif, buf, tilesize); + (*tif->tif_postdecode)(tif,buf,tilesize); return (tilesize); } - if (size == (tmsize_t)(-1)) - size = tilesize; - else if (size > tilesize) - size = tilesize; - if (TIFFFillTile(tif, tile) && - (*tif->tif_decodetile)(tif, (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)); + if (size == (tmsize_t)(-1)) + size = tilesize; + 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); + return (size); + } else + return ((tmsize_t)(-1)); } -/* Variant of TIFFReadTile() that does - * * if *buf == NULL, *buf = _TIFFmallocExt(tif, bufsizetoalloc) only after - * TIFFFillTile() has succeeded. This avoid excessive memory allocation in case - * of truncated file. +/* Variant of TIFFReadTile() that does + * * if *buf == NULL, *buf = _TIFFmalloc(bufsizetoalloc) only after TIFFFillTile() has + * succeeded. This avoid excessive memory allocation in case of truncated + * file. * * calls regular TIFFReadEncodedTile() if *buf != NULL */ -tmsize_t _TIFFReadTileAndAllocBuffer(TIFF *tif, void **buf, - tmsize_t bufsizetoalloc, uint32_t x, - uint32_t y, uint32_t z, uint16_t s) +tmsize_t +_TIFFReadTileAndAllocBuffer(TIFF* tif, + void **buf, tmsize_t bufsizetoalloc, + uint32 x, uint32 y, uint32 z, uint16 s) { if (!TIFFCheckRead(tif, 1) || !TIFFCheckTile(tif, x, y, z, s)) - return ((tmsize_t)(-1)); - return (_TIFFReadEncodedTileAndAllocBuffer( - tif, TIFFComputeTile(tif, x, y, z, s), buf, bufsizetoalloc, - (tmsize_t)(-1))); + return ((tmsize_t)(-1)); + return (_TIFFReadEncodedTileAndAllocBuffer(tif, + TIFFComputeTile(tif, x, y, z, s), + buf, bufsizetoalloc, + (tmsize_t)(-1))); } -/* Variant of TIFFReadEncodedTile() that does - * * if *buf == NULL, *buf = _TIFFmallocExt(tif, bufsizetoalloc) only after - * TIFFFillTile() has succeeded. This avoid excessive memory allocation in case - * of truncated file. +/* Variant of TIFFReadEncodedTile() that does + * * if *buf == NULL, *buf = _TIFFmalloc(bufsizetoalloc) only after TIFFFillTile() has + * succeeded. This avoid excessive memory allocation in case of truncated + * file. * * calls regular TIFFReadEncodedTile() if *buf != NULL */ -tmsize_t _TIFFReadEncodedTileAndAllocBuffer(TIFF *tif, uint32_t tile, - void **buf, tmsize_t bufsizetoalloc, - tmsize_t size_to_read) +tmsize_t +_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, + void **buf, tmsize_t bufsizetoalloc, + tmsize_t size_to_read) { static const char module[] = "_TIFFReadEncodedTileAndAllocBuffer"; TIFFDirectory *td = &tif->tif_dir; tmsize_t tilesize = tif->tif_tilesize; - if (*buf != NULL) + if( *buf != NULL ) { return TIFFReadEncodedTile(tif, tile, *buf, size_to_read); } if (!TIFFCheckRead(tif, 1)) - return ((tmsize_t)(-1)); - if (tile >= td->td_nstrips) - { - TIFFErrorExtR(tif, module, - "%" PRIu32 ": Tile out of range, max %" PRIu32, tile, - td->td_nstrips); - return ((tmsize_t)(-1)); - } - - if (!TIFFFillTile(tif, tile)) - return ((tmsize_t)(-1)); - - /* Sanity checks to avoid excessive memory allocation */ - /* Cf https://gitlab.com/libtiff/libtiff/-/issues/479 */ - if (td->td_compression == COMPRESSION_NONE) - { - if (tif->tif_rawdatasize != tilesize) - { - TIFFErrorExtR(tif, TIFFFileName(tif), - "Invalid tile byte count for tile %u. " - "Expected %" PRIu64 ", got %" PRIu64, - tile, (uint64_t)tilesize, - (uint64_t)tif->tif_rawdatasize); return ((tmsize_t)(-1)); - } - } - else - { - /* Max compression ratio experimentally determined. Might be fragile... - * Only apply this heuristics to situations where the memory allocation - * would be big, to avoid breaking nominal use cases. - */ - const int maxCompressionRatio = - td->td_compression == COMPRESSION_ZSTD ? 33000 - : td->td_compression == COMPRESSION_JXL - ? - /* Evaluated on a 8000x8000 tile */ - 25000 * (td->td_planarconfig == PLANARCONFIG_CONTIG - ? td->td_samplesperpixel - : 1) - : td->td_compression == COMPRESSION_LZMA ? 7000 : 1000; - if (bufsizetoalloc > 100 * 1000 * 1000 && - tif->tif_rawdatasize < tilesize / maxCompressionRatio) - { - TIFFErrorExtR(tif, TIFFFileName(tif), - "Likely invalid tile byte count for tile %u. " - "Uncompressed tile size is %" PRIu64 ", " - "compressed one is %" PRIu64, - tile, (uint64_t)tilesize, - (uint64_t)tif->tif_rawdatasize); + 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); return ((tmsize_t)(-1)); - } } - *buf = _TIFFmallocExt(tif, bufsizetoalloc); - if (*buf == NULL) - { - TIFFErrorExtR(tif, TIFFFileName(tif), "No space for tile buffer"); - return ((tmsize_t)(-1)); + if (!TIFFFillTile(tif,tile)) + return((tmsize_t)(-1)); + + *buf = _TIFFmalloc(bufsizetoalloc); + if (*buf == NULL) { + TIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), + "No space for tile buffer"); + return((tmsize_t)(-1)); } _TIFFmemset(*buf, 0, bufsizetoalloc); @@ -1076,261 +1082,287 @@ tmsize_t _TIFFReadEncodedTileAndAllocBuffer(TIFF *tif, uint32_t tile, size_to_read = tilesize; else if (size_to_read > tilesize) size_to_read = tilesize; - if ((*tif->tif_decodetile)(tif, (uint8_t *)*buf, size_to_read, - (uint16_t)(tile / td->td_stripsperimage))) - { - (*tif->tif_postdecode)(tif, (uint8_t *)*buf, size_to_read); + if( (*tif->tif_decodetile)(tif, + (uint8*) *buf, size_to_read, (uint16)(tile/td->td_stripsperimage))) { + (*tif->tif_postdecode)(tif, (uint8*) *buf, size_to_read); return (size_to_read); - } - else + } else return ((tmsize_t)(-1)); } -static tmsize_t TIFFReadRawTile1(TIFF *tif, uint32_t tile, void *buf, - tmsize_t size, const char *module) +static tmsize_t +TIFFReadRawTile1(TIFF* tif, uint32 tile, void* buf, tmsize_t size, const char* module) { - assert((tif->tif_flags & TIFF_NOREADRAW) == 0); - if (!isMapped(tif)) - { - tmsize_t cc; + assert((tif->tif_flags&TIFF_NOREADRAW)==0); + if (!isMapped(tif)) { + tmsize_t cc; - if (!SeekOK(tif, TIFFGetStrileOffset(tif, tile))) - { - TIFFErrorExtR(tif, module, - "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) - { - TIFFErrorExtR(tif, module, - "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 - { - tmsize_t ma, mb; - tmsize_t n; - ma = (tmsize_t)TIFFGetStrileOffset(tif, tile); - mb = ma + 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) - { - TIFFErrorExtR(tif, module, - "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); - } - return (size); + 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); + 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 + return ((tmsize_t)(-1)); + } + } else { + tmsize_t ma,mb; + 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)) + n=0; + else if ((mbtif->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 + return ((tmsize_t)(-1)); + } + _TIFFmemcpy(buf, tif->tif_base + ma, size); + } + return (size); } /* * Read a tile of data from the file. */ -tmsize_t TIFFReadRawTile(TIFF *tif, uint32_t tile, void *buf, tmsize_t size) +tmsize_t +TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size) { - static const char module[] = "TIFFReadRawTile"; - TIFFDirectory *td = &tif->tif_dir; - uint64_t bytecount64; - tmsize_t bytecountm; + static const char module[] = "TIFFReadRawTile"; + TIFFDirectory *td = &tif->tif_dir; + uint64 bytecount64; + tmsize_t bytecountm; - if (!TIFFCheckRead(tif, 1)) - return ((tmsize_t)(-1)); - if (tile >= td->td_nstrips) - { - TIFFErrorExtR(tif, module, - "%" PRIu32 ": Tile out of range, max %" PRIu32, tile, - td->td_nstrips); - return ((tmsize_t)(-1)); - } - if (tif->tif_flags & TIFF_NOREADRAW) - { - TIFFErrorExtR(tif, module, - "Compression scheme does not support access to raw " - "uncompressed data"); - return ((tmsize_t)(-1)); - } - bytecount64 = TIFFGetStrileByteCount(tif, tile); - if (size != (tmsize_t)(-1) && (uint64_t)size <= bytecount64) - bytecountm = size; - else - bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module); - if (bytecountm == 0) - { - return ((tmsize_t)(-1)); - } - return (TIFFReadRawTile1(tif, tile, buf, bytecountm, module)); + 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); + return ((tmsize_t)(-1)); + } + if (tif->tif_flags&TIFF_NOREADRAW) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Compression scheme does not support access to raw uncompressed data"); + return ((tmsize_t)(-1)); + } + bytecount64 = TIFFGetStrileByteCount(tif, tile); + if (size != (tmsize_t)(-1) && (uint64)size <= bytecount64) + bytecountm = size; + else + bytecountm = _TIFFCastUInt64ToSSize(tif, bytecount64, module); + if( bytecountm == 0 ) { + return ((tmsize_t)(-1)); + } + return (TIFFReadRawTile1(tif, tile, buf, bytecountm, module)); } /* * Read the specified tile and setup for decoding. The data buffer is * expanded, as necessary, to hold the tile's data. */ -int TIFFFillTile(TIFF *tif, uint32_t tile) +int +TIFFFillTile(TIFF* tif, uint32 tile) { - static const char module[] = "TIFFFillTile"; - TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "TIFFFillTile"; + TIFFDirectory *td = &tif->tif_dir; - if ((tif->tif_flags & TIFF_NOREADRAW) == 0) - { - uint64_t bytecount = TIFFGetStrileByteCount(tif, tile); - if (bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX) - { - TIFFErrorExtR(tif, module, - "%" PRIu64 ": Invalid tile byte count, tile %" PRIu32, - bytecount, tile); - return (0); - } + 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__)) + 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 + return (0); + } - /* To avoid excessive memory allocations: */ - /* Byte count should normally not be larger than a number of */ - /* times the uncompressed size plus some margin */ - if (bytecount > 1024 * 1024) - { - /* 10 and 4096 are just values that could be adjusted. */ - /* Hopefully they are safe enough for all codecs */ - tmsize_t stripsize = TIFFTileSize(tif); - if (stripsize != 0 && (bytecount - 4096) / 10 > (uint64_t)stripsize) - { - uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096; - TIFFErrorExtR(tif, module, - "Too large tile byte count %" PRIu64 - ", tile %" PRIu32 ". Limiting to %" PRIu64, - bytecount, tile, newbytecount); - bytecount = newbytecount; - } - } - - if (isMapped(tif)) - { - /* - * We must check for overflow, potentially causing - * an OOB read. Instead of simple - * - * TIFFGetStrileOffset(tif, tile)+bytecount > tif->tif_size - * - * comparison (which can overflow) we do the following - * two comparisons: - */ - if (bytecount > (uint64_t)tif->tif_size || - TIFFGetStrileOffset(tif, tile) > - (uint64_t)tif->tif_size - bytecount) - { - tif->tif_curtile = NOTILE; - return (0); - } - } - - if (isMapped(tif) && (isFillOrder(tif, td->td_fillorder) || - (tif->tif_flags & TIFF_NOBITREV))) - { - /* - * The image is mapped into memory and we either don't - * need to flip bits or the compression routine is - * going to handle this operation itself. In this - * case, avoid copying the raw data and instead just - * reference the data from the memory mapped file - * image. This assumes that the decompression - * routines do not modify the contents of the raw data - * buffer (if they try to, the application will get a - * fault since the file is mapped read-only). - */ - if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) - { - _TIFFfreeExt(tif, tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawdatasize = 0; - } - tif->tif_flags &= ~TIFF_MYBUFFER; - - tif->tif_rawdatasize = (tmsize_t)bytecount; - tif->tif_rawdata = - tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, tile); - tif->tif_rawdataoff = 0; - tif->tif_rawdataloaded = (tmsize_t)bytecount; - tif->tif_flags |= TIFF_BUFFERMMAP; - } - else - { - /* - * Expand raw data buffer, if needed, to hold data - * tile coming from file (perhaps should set upper - * bound on the size of a buffer we'll use?). - */ - tmsize_t bytecountm; - bytecountm = (tmsize_t)bytecount; - if ((uint64_t)bytecountm != bytecount) - { - TIFFErrorExtR(tif, module, "Integer overflow"); - return (0); - } - if (bytecountm > tif->tif_rawdatasize) - { - tif->tif_curtile = NOTILE; - if ((tif->tif_flags & TIFF_MYBUFFER) == 0) + /* To avoid excessive memory allocations: */ + /* Byte count should normally not be larger than a number of */ + /* times the uncompressed size plus some margin */ + if( bytecount > 1024 * 1024 ) { - TIFFErrorExtR(tif, module, - "Data buffer too small to hold tile %" PRIu32, - tile); - return (0); - } - } - if (tif->tif_flags & TIFF_BUFFERMMAP) - { - tif->tif_curtile = NOTILE; - tif->tif_rawdata = NULL; - tif->tif_rawdatasize = 0; - tif->tif_flags &= ~TIFF_BUFFERMMAP; - } + /* 10 and 4096 are just values that could be adjusted. */ + /* Hopefully they are safe enough for all codecs */ + tmsize_t stripsize = TIFFTileSize(tif); + if( stripsize != 0 && + (bytecount - 4096) / 10 > (uint64)stripsize ) + { + uint64 newbytecount = (uint64)stripsize * 10 + 4096; + if( newbytecount == 0 || newbytecount > (uint64)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 + bytecount = newbytecount; + } + } + } - if (isMapped(tif)) - { - if (bytecountm > tif->tif_rawdatasize && - !TIFFReadBufferSetup(tif, 0, bytecountm)) - { - return (0); - } - if (TIFFReadRawTile1(tif, tile, tif->tif_rawdata, bytecountm, - module) != bytecountm) - { - return (0); - } - } - else - { - if (TIFFReadRawStripOrTile2(tif, tile, 0, bytecountm, module) != - bytecountm) - { - return (0); - } - } + if (isMapped(tif)) { + /* + * We must check for overflow, potentially causing + * an OOB read. Instead of simple + * + * TIFFGetStrileOffset(tif, tile)+bytecount > tif->tif_size + * + * comparison (which can overflow) we do the following + * two comparisons: + */ + if (bytecount > (uint64)tif->tif_size || + TIFFGetStrileOffset(tif, tile) > (uint64)tif->tif_size - bytecount) { + tif->tif_curtile = NOTILE; + return (0); + } + } - tif->tif_rawdataoff = 0; - tif->tif_rawdataloaded = bytecountm; + if (isMapped(tif) && + (isFillOrder(tif, td->td_fillorder) + || (tif->tif_flags & TIFF_NOBITREV))) { + /* + * The image is mapped into memory and we either don't + * need to flip bits or the compression routine is + * going to handle this operation itself. In this + * case, avoid copying the raw data and instead just + * reference the data from the memory mapped file + * image. This assumes that the decompression + * routines do not modify the contents of the raw data + * buffer (if they try to, the application will get a + * fault since the file is mapped read-only). + */ + if ((tif->tif_flags & TIFF_MYBUFFER) && tif->tif_rawdata) { + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + } + tif->tif_flags &= ~TIFF_MYBUFFER; - if (tif->tif_rawdata != NULL && - !isFillOrder(tif, td->td_fillorder) && - (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits(tif->tif_rawdata, tif->tif_rawdataloaded); - } - } - return (TIFFStartTile(tif, tile)); + tif->tif_rawdatasize = (tmsize_t)bytecount; + tif->tif_rawdata = + tif->tif_base + (tmsize_t)TIFFGetStrileOffset(tif, tile); + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = (tmsize_t) bytecount; + tif->tif_flags |= TIFF_BUFFERMMAP; + } else { + /* + * Expand raw data buffer, if needed, to hold data + * tile coming from file (perhaps should set upper + * bound on the size of a buffer we'll use?). + */ + tmsize_t bytecountm; + bytecountm=(tmsize_t)bytecount; + if ((uint64)bytecountm!=bytecount) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + return(0); + } + if (bytecountm > tif->tif_rawdatasize) { + 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); + return (0); + } + } + if (tif->tif_flags&TIFF_BUFFERMMAP) { + tif->tif_curtile = NOTILE; + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + tif->tif_flags &= ~TIFF_BUFFERMMAP; + } + + if( isMapped(tif) ) + { + if (bytecountm > tif->tif_rawdatasize && + !TIFFReadBufferSetup(tif, 0, bytecountm)) + { + return (0); + } + if (TIFFReadRawTile1(tif, tile, tif->tif_rawdata, + bytecountm, module) != bytecountm) + { + return (0); + } + } + else + { + if (TIFFReadRawStripOrTile2(tif, tile, 0, + bytecountm, module) != bytecountm) + { + return (0); + } + } + + + tif->tif_rawdataoff = 0; + tif->tif_rawdataloaded = bytecountm; + + if (tif->tif_rawdata != NULL && + !isFillOrder(tif, td->td_fillorder) && + (tif->tif_flags & TIFF_NOBITREV) == 0) + TIFFReverseBits(tif->tif_rawdata, + tif->tif_rawdataloaded); + } + } + return (TIFFStartTile(tif, tile)); } /* @@ -1342,191 +1374,180 @@ int TIFFFillTile(TIFF *tif, uint32_t tile) * large enough to hold any individual strip of * raw data. */ -int TIFFReadBufferSetup(TIFF *tif, void *bp, tmsize_t size) +int +TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) { - static const char module[] = "TIFFReadBufferSetup"; + static const char module[] = "TIFFReadBufferSetup"; - assert((tif->tif_flags & TIFF_NOREADRAW) == 0); - tif->tif_flags &= ~TIFF_BUFFERMMAP; + assert((tif->tif_flags&TIFF_NOREADRAW)==0); + tif->tif_flags &= ~TIFF_BUFFERMMAP; - if (tif->tif_rawdata) - { - if (tif->tif_flags & TIFF_MYBUFFER) - _TIFFfreeExt(tif, tif->tif_rawdata); - tif->tif_rawdata = NULL; - tif->tif_rawdatasize = 0; - } - if (bp) - { - tif->tif_rawdatasize = size; - tif->tif_rawdata = (uint8_t *)bp; - tif->tif_flags &= ~TIFF_MYBUFFER; - } - else - { - tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64_t)size, 1024); - if (tif->tif_rawdatasize == 0) - { - TIFFErrorExtR(tif, module, "Invalid buffer size"); - return (0); - } - /* 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_t *)_TIFFcallocExt(tif, 1, tif->tif_rawdatasize); - tif->tif_flags |= TIFF_MYBUFFER; - } - if (tif->tif_rawdata == NULL) - { - TIFFErrorExtR(tif, module, - "No space for data buffer at scanline %" PRIu32, - tif->tif_row); - tif->tif_rawdatasize = 0; - return (0); - } - return (1); + if (tif->tif_rawdata) { + if (tif->tif_flags & TIFF_MYBUFFER) + _TIFFfree(tif->tif_rawdata); + tif->tif_rawdata = NULL; + tif->tif_rawdatasize = 0; + } + if (bp) { + tif->tif_rawdatasize = size; + tif->tif_rawdata = (uint8*) bp; + tif->tif_flags &= ~TIFF_MYBUFFER; + } else { + tif->tif_rawdatasize = (tmsize_t)TIFFroundup_64((uint64)size, 1024); + if (tif->tif_rawdatasize==0) { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid buffer size"); + return (0); + } + /* 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_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); + tif->tif_rawdatasize = 0; + return (0); + } + return (1); } /* * Set state to appear as if a * strip has just been read in. */ -static int TIFFStartStrip(TIFF *tif, uint32_t strip) +static int +TIFFStartStrip(TIFF* tif, uint32 strip) { - TIFFDirectory *td = &tif->tif_dir; + TIFFDirectory *td = &tif->tif_dir; - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) - { - if (!(*tif->tif_setupdecode)(tif)) - return (0); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_curstrip = strip; - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - tif->tif_flags &= ~TIFF_BUF4WRITE; + if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { + if (!(*tif->tif_setupdecode)(tif)) + return (0); + tif->tif_flags |= TIFF_CODERSETUP; + } + tif->tif_curstrip = strip; + tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; + tif->tif_flags &= ~TIFF_BUF4WRITE; - if (tif->tif_flags & TIFF_NOREADRAW) - { - tif->tif_rawcp = NULL; - tif->tif_rawcc = 0; - } - else - { - tif->tif_rawcp = tif->tif_rawdata; - if (tif->tif_rawdataloaded > 0) - tif->tif_rawcc = tif->tif_rawdataloaded; - else - tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, strip); - } - if ((*tif->tif_predecode)(tif, (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 */ - /* codec state. */ - tif->tif_curstrip = NOSTRIP; - return 0; - } - return 1; + if (tif->tif_flags&TIFF_NOREADRAW) + { + tif->tif_rawcp = NULL; + tif->tif_rawcc = 0; + } + else + { + tif->tif_rawcp = tif->tif_rawdata; + if( tif->tif_rawdataloaded > 0 ) + tif->tif_rawcc = tif->tif_rawdataloaded; + else + tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, strip); + } + if ((*tif->tif_predecode)(tif, + (uint16)(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 */ + /* codec state. */ + tif->tif_curstrip = NOSTRIP; + return 0; + } + return 1; } /* * Set state to appear as if a * tile has just been read in. */ -static int TIFFStartTile(TIFF *tif, uint32_t tile) +static int +TIFFStartTile(TIFF* tif, uint32 tile) { - static const char module[] = "TIFFStartTile"; - TIFFDirectory *td = &tif->tif_dir; - uint32_t howmany32; + static const char module[] = "TIFFStartTile"; + TIFFDirectory *td = &tif->tif_dir; + uint32 howmany32; - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) - { - if (!(*tif->tif_setupdecode)(tif)) - return (0); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_curtile = tile; - howmany32 = TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth); - if (howmany32 == 0) - { - TIFFErrorExtR(tif, module, "Zero tiles"); - return 0; - } - tif->tif_row = (tile % howmany32) * td->td_tilelength; - howmany32 = TIFFhowmany_32(td->td_imagelength, td->td_tilelength); - if (howmany32 == 0) - { - TIFFErrorExtR(tif, module, "Zero tiles"); - return 0; - } - tif->tif_col = (tile % howmany32) * td->td_tilewidth; - tif->tif_flags &= ~TIFF_BUF4WRITE; - if (tif->tif_flags & TIFF_NOREADRAW) - { - tif->tif_rawcp = NULL; - tif->tif_rawcc = 0; - } - else - { - tif->tif_rawcp = tif->tif_rawdata; - if (tif->tif_rawdataloaded > 0) - tif->tif_rawcc = tif->tif_rawdataloaded; - else - tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, tile); - } - return ( - (*tif->tif_predecode)(tif, (uint16_t)(tile / td->td_stripsperimage))); + if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { + if (!(*tif->tif_setupdecode)(tif)) + return (0); + tif->tif_flags |= TIFF_CODERSETUP; + } + tif->tif_curtile = tile; + howmany32=TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth); + if (howmany32 == 0) { + TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles"); + return 0; + } + tif->tif_row = (tile % howmany32) * td->td_tilelength; + howmany32=TIFFhowmany_32(td->td_imagelength, td->td_tilelength); + if (howmany32 == 0) { + TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles"); + return 0; + } + tif->tif_col = (tile % howmany32) * td->td_tilewidth; + tif->tif_flags &= ~TIFF_BUF4WRITE; + if (tif->tif_flags&TIFF_NOREADRAW) + { + tif->tif_rawcp = NULL; + tif->tif_rawcc = 0; + } + else + { + tif->tif_rawcp = tif->tif_rawdata; + if( tif->tif_rawdataloaded > 0 ) + tif->tif_rawcc = tif->tif_rawdataloaded; + else + tif->tif_rawcc = (tmsize_t)TIFFGetStrileByteCount(tif, tile); + } + return ((*tif->tif_predecode)(tif, + (uint16)(tile/td->td_stripsperimage))); } -static int TIFFCheckRead(TIFF *tif, int tiles) +static int +TIFFCheckRead(TIFF* tif, int tiles) { - if (tif->tif_mode == O_WRONLY) - { - TIFFErrorExtR(tif, tif->tif_name, "File not open for reading"); - return (0); - } - if (tiles ^ isTiled(tif)) - { - TIFFErrorExtR(tif, tif->tif_name, - tiles ? "Can not read tiles from a striped image" - : "Can not read scanlines from a tiled image"); - return (0); - } - return (1); + if (tif->tif_mode == O_WRONLY) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "File not open for reading"); + return (0); + } + if (tiles ^ isTiled(tif)) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ? + "Can not read tiles from a striped image" : + "Can not read scanlines from a tiled image"); + return (0); + } + return (1); } /* Use the provided input buffer (inbuf, insize) and decompress it into * (outbuf, outsize). - * This function replaces the use of - * TIFFReadEncodedStrip()/TIFFReadEncodedTile() when the user can provide the - * buffer for the input data, for example when he wants to avoid libtiff to read - * the strile offset/count values from the [Strip|Tile][Offsets/ByteCounts] - * array. inbuf content must be writable (if bit reversal is needed) Returns 1 - * in case of success, 0 otherwise. + * This function replaces the use of TIFFReadEncodedStrip()/TIFFReadEncodedTile() + * when the user can provide the buffer for the input data, for example when + * he wants to avoid libtiff to read the strile offset/count values from the + * [Strip|Tile][Offsets/ByteCounts] array. + * inbuf content must be writable (if bit reversal is needed) + * Returns 1 in case of success, 0 otherwise. */ -int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf, - tmsize_t insize, void *outbuf, tmsize_t outsize) +int TIFFReadFromUserBuffer(TIFF* tif, uint32 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_t old_tif_flags = tif->tif_flags; + uint32 old_tif_flags = tif->tif_flags; tmsize_t old_rawdatasize = tif->tif_rawdatasize; - void *old_rawdata = tif->tif_rawdata; + void* old_rawdata = tif->tif_rawdata; - if (tif->tif_mode == O_WRONLY) - { - TIFFErrorExtR(tif, tif->tif_name, "File not open for reading"); + if (tif->tif_mode == O_WRONLY) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "File not open for reading"); return 0; } - if (tif->tif_flags & TIFF_NOREADRAW) + if (tif->tif_flags&TIFF_NOREADRAW) { - TIFFErrorExtR(tif, module, - "Compression scheme does not support access to raw " - "uncompressed data"); + TIFFErrorExt(tif->tif_clientdata, module, + "Compression scheme does not support access to raw uncompressed data"); return 0; } @@ -1543,33 +1564,32 @@ int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf, TIFFReverseBits(inbuf, insize); } - if (TIFFIsTiled(tif)) + if( TIFFIsTiled(tif) ) { - if (!TIFFStartTile(tif, strile) || - !(*tif->tif_decodetile)(tif, (uint8_t *)outbuf, outsize, - (uint16_t)(strile / td->td_stripsperimage))) + if( !TIFFStartTile(tif, strile) || + !(*tif->tif_decodetile)(tif, (uint8*) outbuf, outsize, + (uint16)(strile/td->td_stripsperimage)) ) { ret = 0; } } else { - 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_t *)outbuf, outsize, - (uint16_t)(strile / stripsperplane))) + uint32 rowsperstrip=td->td_rowsperstrip; + uint32 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)) ) { ret = 0; } } - if (ret) + if( ret ) { - (*tif->tif_postdecode)(tif, (uint8_t *)outbuf, outsize); + (*tif->tif_postdecode)(tif, (uint8*) outbuf, outsize); } if (!isFillOrder(tif, td->td_fillorder) && @@ -1578,8 +1598,7 @@ int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf, TIFFReverseBits(inbuf, insize); } - tif->tif_flags = (old_tif_flags & (TIFF_MYBUFFER | TIFF_BUFFERMMAP)) | - (tif->tif_flags & ~(TIFF_MYBUFFER | TIFF_BUFFERMMAP)); + tif->tif_flags = old_tif_flags; tif->tif_rawdatasize = old_rawdatasize; tif->tif_rawdata = old_rawdata; tif->tif_rawdataoff = 0; @@ -1588,37 +1607,49 @@ int TIFFReadFromUserBuffer(TIFF *tif, uint32_t strile, void *inbuf, return ret; } -void _TIFFNoPostDecode(TIFF *tif, uint8_t *buf, tmsize_t cc) +void +_TIFFNoPostDecode(TIFF* tif, uint8* buf, tmsize_t cc) { - (void)tif; - (void)buf; - (void)cc; + (void) tif; (void) buf; (void) cc; } -void _TIFFSwab16BitData(TIFF *tif, uint8_t *buf, tmsize_t cc) +void +_TIFFSwab16BitData(TIFF* tif, uint8* buf, tmsize_t cc) { - (void)tif; + (void) tif; assert((cc & 1) == 0); - TIFFSwabArrayOfShort((uint16_t *)buf, cc / 2); + TIFFSwabArrayOfShort((uint16*) buf, cc/2); } -void _TIFFSwab24BitData(TIFF *tif, uint8_t *buf, tmsize_t cc) +void +_TIFFSwab24BitData(TIFF* tif, uint8* buf, tmsize_t cc) { - (void)tif; + (void) tif; assert((cc % 3) == 0); - TIFFSwabArrayOfTriples((uint8_t *)buf, cc / 3); + TIFFSwabArrayOfTriples((uint8*) buf, cc/3); } -void _TIFFSwab32BitData(TIFF *tif, uint8_t *buf, tmsize_t cc) +void +_TIFFSwab32BitData(TIFF* tif, uint8* buf, tmsize_t cc) { - (void)tif; + (void) tif; assert((cc & 3) == 0); - TIFFSwabArrayOfLong((uint32_t *)buf, cc / 4); + TIFFSwabArrayOfLong((uint32*) buf, cc/4); } -void _TIFFSwab64BitData(TIFF *tif, uint8_t *buf, tmsize_t cc) +void +_TIFFSwab64BitData(TIFF* tif, uint8* buf, tmsize_t cc) { - (void)tif; + (void) tif; assert((cc & 7) == 0); - TIFFSwabArrayOfDouble((double *)buf, cc / 8); + TIFFSwabArrayOfDouble((double*) buf, cc/8); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_stream.cxx b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_stream.cxx index 92ea273c5..7f640a9c0 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_stream.cxx +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_stream.cxx @@ -2,23 +2,23 @@ * Copyright (c) 1988-1996 Sam Leffler * Copyright (c) 1991-1996 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -28,7 +28,9 @@ #include "tiffiop.h" #include +#ifndef __VMS using namespace std; +#endif /* ISO C++ uses a 'std::streamsize' type to define counts. This makes @@ -74,331 +76,359 @@ using namespace std; struct tiffis_data; struct tiffos_data; -extern "C" +extern "C" { + + static tmsize_t _tiffosReadProc(thandle_t, void*, tmsize_t); + 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 int _tiffosCloseProc(thandle_t fd); + static int _tiffisCloseProc(thandle_t fd); + static int _tiffDummyMapProc(thandle_t , void** base, toff_t* size ); + static void _tiffDummyUnmapProc(thandle_t , void* base, toff_t size ); + static TIFF* _tiffStreamOpen(const char* name, const char* mode, void *fd); + +struct tiffis_data { - - static tmsize_t _tiffosReadProc(thandle_t, void *, tmsize_t); - 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_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); - static void _tiffDummyUnmapProc(thandle_t, void *base, toff_t size); - static TIFF *_tiffStreamOpen(const char *name, const char *mode, void *fd); - - struct tiffis_data - { - istream *stream; + istream *stream; ios::pos_type start_pos; - }; +}; - struct tiffos_data - { - ostream *stream; - ios::pos_type start_pos; - }; +struct tiffos_data +{ + ostream *stream; + ios::pos_type start_pos; +}; - static tmsize_t _tiffosReadProc(thandle_t, void *, tmsize_t) { return 0; } +static tmsize_t +_tiffosReadProc(thandle_t, void*, tmsize_t) +{ + return 0; +} - static tmsize_t _tiffisReadProc(thandle_t fd, void *buf, tmsize_t size) - { - tiffis_data *data = reinterpret_cast(fd); +static tmsize_t +_tiffisReadProc(thandle_t fd, void* buf, tmsize_t size) +{ + tiffis_data *data = reinterpret_cast(fd); // Verify that type does not overflow. streamsize request_size = size; if (static_cast(request_size) != size) - return static_cast(-1); + return static_cast(-1); - data->stream->read((char *)buf, request_size); + data->stream->read((char *) buf, request_size); return static_cast(data->stream->gcount()); - } +} - static tmsize_t _tiffosWriteProc(thandle_t fd, void *buf, tmsize_t size) - { - tiffos_data *data = reinterpret_cast(fd); - ostream *os = data->stream; - ios::pos_type pos = os->tellp(); +static tmsize_t +_tiffosWriteProc(thandle_t fd, void* buf, tmsize_t size) +{ + tiffos_data *data = reinterpret_cast(fd); + ostream *os = data->stream; + ios::pos_type pos = os->tellp(); // Verify that type does not overflow. streamsize request_size = size; if (static_cast(request_size) != size) - return static_cast(-1); + return static_cast(-1); - os->write(reinterpret_cast(buf), request_size); + os->write(reinterpret_cast(buf), request_size); - return static_cast(os->tellp() - pos); - } + return static_cast(os->tellp() - pos); +} - static tmsize_t _tiffisWriteProc(thandle_t, void *, tmsize_t) { return 0; } +static tmsize_t +_tiffisWriteProc(thandle_t, void*, tmsize_t) +{ + return 0; +} - static uint64_t _tiffosSeekProc(thandle_t fd, uint64_t off, int whence) - { - tiffos_data *data = reinterpret_cast(fd); - ostream *os = data->stream; +static uint64 +_tiffosSeekProc(thandle_t fd, uint64 off, int whence) +{ + tiffos_data *data = reinterpret_cast(fd); + ostream *os = data->stream; - // if the stream has already failed, don't do anything - if (os->fail()) - return static_cast(-1); + // if the stream has already failed, don't do anything + if( os->fail() ) + return static_cast(-1); - switch (whence) - { - case SEEK_SET: - { - // Compute 64-bit offset - uint64_t new_offset = - static_cast(data->start_pos) + off; + switch(whence) { + case SEEK_SET: + { + // Compute 64-bit offset + uint64 new_offset = static_cast(data->start_pos) + off; - // Verify that value does not overflow - ios::off_type offset = static_cast(new_offset); - if (static_cast(offset) != new_offset) - return static_cast(-1); + // Verify that value does not overflow + ios::off_type offset = static_cast(new_offset); + if (static_cast(offset) != new_offset) + return static_cast(-1); + + os->seekp(offset, ios::beg); + break; + } + case SEEK_CUR: + { + // Verify that value does not overflow + ios::off_type offset = static_cast(off); + if (static_cast(offset) != off) + return static_cast(-1); - os->seekp(offset, ios::beg); - break; - } - case SEEK_CUR: - { - // Verify that value does not overflow - ios::off_type offset = static_cast(off); - if (static_cast(offset) != off) - return static_cast(-1); + os->seekp(offset, ios::cur); + break; + } + case SEEK_END: + { + // Verify that value does not overflow + ios::off_type offset = static_cast(off); + if (static_cast(offset) != off) + return static_cast(-1); - os->seekp(offset, ios::cur); - break; - } - case SEEK_END: - { - // Verify that value does not overflow - ios::off_type offset = static_cast(off); - if (static_cast(offset) != off) - return static_cast(-1); + os->seekp(offset, ios::end); + break; + } + } - os->seekp(offset, ios::end); - break; - } - } + // Attempt to workaround problems with seeking past the end of the + // stream. ofstream doesn't have a problem with this but + // 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; - // Attempt to workaround problems with seeking past the end of the - // stream. ofstream doesn't have a problem with this but - // ostrstream/ostringstream does. In that situation, add intermediate - // '\0' characters. - if (os->fail()) - { - ios::iostate old_state; - ios::pos_type origin; + old_state = os->rdstate(); + // reset the fail bit or else tellp() won't work below + os->clear(os->rdstate() & ~ios::failbit); + switch( whence ) { + case SEEK_SET: + default: + origin = data->start_pos; + break; + case SEEK_CUR: + origin = os->tellp(); + break; + case SEEK_END: + os->seekp(0, ios::end); + origin = os->tellp(); + break; + } + // restore original stream state + os->clear(old_state); - old_state = os->rdstate(); - // reset the fail bit or else tellp() won't work below - os->clear(os->rdstate() & ~ios::failbit); - switch (whence) - { - case SEEK_SET: - default: - origin = data->start_pos; - break; - case SEEK_CUR: - origin = os->tellp(); - break; - case SEEK_END: - os->seekp(0, ios::end); - origin = os->tellp(); - break; - } - // restore original stream state - os->clear(old_state); + // only do something if desired seek position is valid + if( (static_cast(origin) + off) > static_cast(data->start_pos) ) { + uint64 num_fill; - // only do something if desired seek position is valid - if ((static_cast(origin) + off) > - static_cast(data->start_pos)) - { - uint64_t num_fill; + // clear the fail bit + os->clear(os->rdstate() & ~ios::failbit); - // 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(origin)) + off - os->tellp(); + for( uint64 i = 0; i < num_fill; i++ ) + os->put('\0'); - // extend the stream to the expected size - os->seekp(0, ios::end); - num_fill = (static_cast(origin)) + off - os->tellp(); - for (uint64_t i = 0; i < num_fill; i++) - os->put('\0'); + // retry the seek + os->seekp(static_cast(static_cast(origin) + off), ios::beg); + } + } - // retry the seek - os->seekp(static_cast( - static_cast(origin) + off), - ios::beg); - } - } + return static_cast(os->tellp()); +} - return static_cast(os->tellp()); - } +static uint64 +_tiffisSeekProc(thandle_t fd, uint64 off, int whence) +{ + tiffis_data *data = reinterpret_cast(fd); - static uint64_t _tiffisSeekProc(thandle_t fd, uint64_t off, int whence) - { - tiffis_data *data = reinterpret_cast(fd); + switch(whence) { + case SEEK_SET: + { + // Compute 64-bit offset + uint64 new_offset = static_cast(data->start_pos) + off; + + // Verify that value does not overflow + ios::off_type offset = static_cast(new_offset); + if (static_cast(offset) != new_offset) + return static_cast(-1); - switch (whence) - { - case SEEK_SET: - { - // Compute 64-bit offset - uint64_t new_offset = - static_cast(data->start_pos) + off; + data->stream->seekg(offset, ios::beg); + break; + } + case SEEK_CUR: + { + // Verify that value does not overflow + ios::off_type offset = static_cast(off); + if (static_cast(offset) != off) + return static_cast(-1); - // Verify that value does not overflow - ios::off_type offset = static_cast(new_offset); - if (static_cast(offset) != new_offset) - return static_cast(-1); + data->stream->seekg(offset, ios::cur); + break; + } + case SEEK_END: + { + // Verify that value does not overflow + ios::off_type offset = static_cast(off); + if (static_cast(offset) != off) + return static_cast(-1); - data->stream->seekg(offset, ios::beg); - break; - } - case SEEK_CUR: - { - // Verify that value does not overflow - ios::off_type offset = static_cast(off); - if (static_cast(offset) != off) - return static_cast(-1); + data->stream->seekg(offset, ios::end); + break; + } + } - data->stream->seekg(offset, ios::cur); - break; - } - case SEEK_END: - { - // Verify that value does not overflow - ios::off_type offset = static_cast(off); - if (static_cast(offset) != off) - return static_cast(-1); + return (uint64) (data->stream->tellg() - data->start_pos); +} - data->stream->seekg(offset, ios::end); - break; - } - } +static uint64 +_tiffosSizeProc(thandle_t fd) +{ + tiffos_data *data = reinterpret_cast(fd); + ostream *os = data->stream; + ios::pos_type pos = os->tellp(); + ios::pos_type len; - return (uint64_t)(data->stream->tellg() - data->start_pos); - } + os->seekp(0, ios::end); + len = os->tellp(); + os->seekp(pos); - static uint64_t _tiffosSizeProc(thandle_t fd) - { - tiffos_data *data = reinterpret_cast(fd); - ostream *os = data->stream; - ios::pos_type pos = os->tellp(); - ios::pos_type len; + return (uint64) len; +} - os->seekp(0, ios::end); - len = os->tellp(); - os->seekp(pos); +static uint64 +_tiffisSizeProc(thandle_t fd) +{ + tiffis_data *data = reinterpret_cast(fd); + ios::pos_type pos = data->stream->tellg(); + ios::pos_type len; - return (uint64_t)len; - } + data->stream->seekg(0, ios::end); + len = data->stream->tellg(); + data->stream->seekg(pos); - static uint64_t _tiffisSizeProc(thandle_t fd) - { - tiffis_data *data = reinterpret_cast(fd); - ios::pos_type pos = data->stream->tellg(); - ios::pos_type len; + return (uint64) len; +} - data->stream->seekg(0, ios::end); - len = data->stream->tellg(); - data->stream->seekg(pos); +static int +_tiffosCloseProc(thandle_t fd) +{ + // Our stream was not allocated by us, so it shouldn't be closed by us. + delete reinterpret_cast(fd); + return 0; +} - return (uint64_t)len; - } +static int +_tiffisCloseProc(thandle_t fd) +{ + // Our stream was not allocated by us, so it shouldn't be closed by us. + delete reinterpret_cast(fd); + return 0; +} - static int _tiffosCloseProc(thandle_t fd) - { - // Our stream was not allocated by us, so it shouldn't be closed by us. - delete reinterpret_cast(fd); - return 0; - } +static int +_tiffDummyMapProc(thandle_t , void** base, toff_t* size ) +{ + (void) base; + (void) size; + return (0); +} - static int _tiffisCloseProc(thandle_t fd) - { - // Our stream was not allocated by us, so it shouldn't be closed by us. - delete reinterpret_cast(fd); - return 0; - } +static void +_tiffDummyUnmapProc(thandle_t , void* base, toff_t size ) +{ + (void) base; + (void) size; +} - static int _tiffDummyMapProc(thandle_t, void **base, toff_t *size) - { - (void)base; - (void)size; - return (0); - } +/* + * Open a TIFF file descriptor for read/writing. + */ +static TIFF* +_tiffStreamOpen(const char* name, const char* mode, void *fd) +{ + TIFF* tif; - static void _tiffDummyUnmapProc(thandle_t, void *base, toff_t size) - { - (void)base; - (void)size; - } + if( strchr(mode, 'w') ) { + tiffos_data *data = new tiffos_data; + data->stream = reinterpret_cast(fd); + data->start_pos = data->stream->tellp(); - /* - * Open a TIFF file descriptor for read/writing. - */ - static TIFF *_tiffStreamOpen(const char *name, const char *mode, void *fd) - { - TIFF *tif; + // Open for writing. + tif = TIFFClientOpen(name, mode, + reinterpret_cast(data), + _tiffosReadProc, + _tiffosWriteProc, + _tiffosSeekProc, + _tiffosCloseProc, + _tiffosSizeProc, + _tiffDummyMapProc, + _tiffDummyUnmapProc); + if (!tif) { + delete data; + } + } else { + tiffis_data *data = new tiffis_data; + data->stream = reinterpret_cast(fd); + data->start_pos = data->stream->tellg(); + // Open for reading. + tif = TIFFClientOpen(name, mode, + reinterpret_cast(data), + _tiffisReadProc, + _tiffisWriteProc, + _tiffisSeekProc, + _tiffisCloseProc, + _tiffisSizeProc, + _tiffDummyMapProc, + _tiffDummyUnmapProc); + if (!tif) { + delete data; + } + } - if (strchr(mode, 'w')) - { - tiffos_data *data = new tiffos_data; - data->stream = reinterpret_cast(fd); - data->start_pos = data->stream->tellp(); - - // Open for writing. - tif = TIFFClientOpen( - name, mode, reinterpret_cast(data), _tiffosReadProc, - _tiffosWriteProc, _tiffosSeekProc, _tiffosCloseProc, - _tiffosSizeProc, _tiffDummyMapProc, _tiffDummyUnmapProc); - if (!tif) - { - delete data; - } - } - else - { - tiffis_data *data = new tiffis_data; - data->stream = reinterpret_cast(fd); - data->start_pos = data->stream->tellg(); - // Open for reading. - tif = TIFFClientOpen( - name, mode, reinterpret_cast(data), _tiffisReadProc, - _tiffisWriteProc, _tiffisSeekProc, _tiffisCloseProc, - _tiffisSizeProc, _tiffDummyMapProc, _tiffDummyUnmapProc); - if (!tif) - { - delete data; - } - } - - return (tif); - } + return (tif); +} } /* extern "C" */ -TIFF *TIFFStreamOpen(const char *name, ostream *os) +TIFF* +TIFFStreamOpen(const char* name, ostream *os) { - // If os is either a ostrstream or ostringstream, and has no data - // written to it yet, then tellp() will return -1 which will break us. - // We workaround this by writing out a dummy character and - // then seek back to the beginning. - if (!os->fail() && static_cast(os->tellp()) < 0) - { - *os << '\0'; - os->seekp(0); - } + // If os is either a ostrstream or ostringstream, and has no data + // written to it yet, then tellp() will return -1 which will break us. + // We workaround this by writing out a dummy character and + // then seek back to the beginning. + if( !os->fail() && static_cast(os->tellp()) < 0 ) { + *os << '\0'; + os->seekp(0); + } - // NB: We don't support mapped files with streams so add 'm' - return _tiffStreamOpen(name, "wm", os); + // NB: We don't support mapped files with streams so add 'm' + return _tiffStreamOpen(name, "wm", os); } -TIFF *TIFFStreamOpen(const char *name, istream *is) +TIFF* +TIFFStreamOpen(const char* name, istream *is) { - // NB: We don't support mapped files with streams so add 'm' - return _tiffStreamOpen(name, "rm", is); + // NB: We don't support mapped files with streams so add 'm' + return _tiffStreamOpen(name, "rm", is); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ + diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_strip.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_strip.c index 820a2544c..57aba5161 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_strip.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_strip.c @@ -2,23 +2,23 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,145 +32,153 @@ /* * Compute which strip a (row,sample) value is in. */ -uint32_t TIFFComputeStrip(TIFF *tif, uint32_t row, uint16_t sample) +uint32 +TIFFComputeStrip(TIFF* tif, uint32 row, uint16 sample) { - static const char module[] = "TIFFComputeStrip"; - TIFFDirectory *td = &tif->tif_dir; - uint32_t strip; + static const char module[] = "TIFFComputeStrip"; + TIFFDirectory *td = &tif->tif_dir; + uint32 strip; - strip = row / td->td_rowsperstrip; - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - { - if (sample >= td->td_samplesperpixel) - { - TIFFErrorExtR(tif, module, "%lu: Sample out of range, max %lu", - (unsigned long)sample, - (unsigned long)td->td_samplesperpixel); - return (0); - } - strip += (uint32_t)sample * td->td_stripsperimage; - } - return (strip); + strip = row / td->td_rowsperstrip; + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + if (sample >= td->td_samplesperpixel) { + TIFFErrorExt(tif->tif_clientdata, module, + "%lu: Sample out of range, max %lu", + (unsigned long) sample, (unsigned long) td->td_samplesperpixel); + return (0); + } + strip += (uint32)sample*td->td_stripsperimage; + } + return (strip); } /* * Compute how many strips are in an image. */ -uint32_t TIFFNumberOfStrips(TIFF *tif) +uint32 +TIFFNumberOfStrips(TIFF* tif) { - TIFFDirectory *td = &tif->tif_dir; - uint32_t nstrips; + TIFFDirectory *td = &tif->tif_dir; + uint32 nstrips; - 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_t)td->td_samplesperpixel, - "TIFFNumberOfStrips"); - return (nstrips); + nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 : + TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip)); + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel, + "TIFFNumberOfStrips"); + return (nstrips); } /* * Compute the # bytes in a variable height, row-aligned strip. */ -uint64_t TIFFVStripSize64(TIFF *tif, uint32_t nrows) +uint64 +TIFFVStripSize64(TIFF* tif, uint32 nrows) { - static const char module[] = "TIFFVStripSize64"; - TIFFDirectory *td = &tif->tif_dir; - if (nrows == (uint32_t)(-1)) - nrows = td->td_imagelength; - if ((td->td_planarconfig == PLANARCONFIG_CONTIG) && - (td->td_photometric == PHOTOMETRIC_YCBCR) && (!isUpSampled(tif))) - { - /* - * Packed YCbCr data contain one Cb+Cr for every - * HorizontalSampling*VerticalSampling Y values. - * Must also roundup width and height when calculating - * since images that are not a multiple of the - * horizontal/vertical subsampling area include - * YCbCr data for the extended image. - */ - uint16_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) - { - TIFFErrorExtR(tif, module, "Invalid td_samplesperpixel value"); - return 0; - } - TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, - ycbcrsubsampling + 0, ycbcrsubsampling + 1); - if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && - ycbcrsubsampling[0] != 4) || - (ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && - ycbcrsubsampling[1] != 4)) - { - TIFFErrorExtR(tif, module, "Invalid YCbCr subsampling (%dx%d)", - ycbcrsubsampling[0], ycbcrsubsampling[1]); - return 0; - } - samplingblock_samples = ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2; - samplingblocks_hor = - TIFFhowmany_32(td->td_imagewidth, ycbcrsubsampling[0]); - samplingblocks_ver = TIFFhowmany_32(nrows, ycbcrsubsampling[1]); - samplingrow_samples = _TIFFMultiply64(tif, samplingblocks_hor, - samplingblock_samples, module); - samplingrow_size = TIFFhowmany8_64(_TIFFMultiply64( - tif, samplingrow_samples, td->td_bitspersample, module)); - return ( - _TIFFMultiply64(tif, samplingrow_size, samplingblocks_ver, module)); - } - else - return (_TIFFMultiply64(tif, nrows, TIFFScanlineSize64(tif), module)); + static const char module[] = "TIFFVStripSize64"; + TIFFDirectory *td = &tif->tif_dir; + if (nrows==(uint32)(-1)) + nrows=td->td_imagelength; + if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&& + (td->td_photometric == PHOTOMETRIC_YCBCR)&& + (!isUpSampled(tif))) + { + /* + * Packed YCbCr data contain one Cb+Cr for every + * HorizontalSampling*VerticalSampling Y values. + * Must also roundup width and height when calculating + * since images that are not a multiple of the + * horizontal/vertical subsampling area include + * YCbCr data for the extended image. + */ + uint16 ycbcrsubsampling[2]; + uint16 samplingblock_samples; + uint32 samplingblocks_hor; + uint32 samplingblocks_ver; + uint64 samplingrow_samples; + uint64 samplingrow_size; + if(td->td_samplesperpixel!=3) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid td_samplesperpixel value"); + return 0; + } + TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0, + ycbcrsubsampling+1); + if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4) + ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4)) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid YCbCr subsampling (%dx%d)", + ycbcrsubsampling[0], + ycbcrsubsampling[1] ); + return 0; + } + samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2; + samplingblocks_hor=TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]); + samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]); + samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module); + samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module)); + return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module)); + } + else + return(_TIFFMultiply64(tif,nrows,TIFFScanlineSize64(tif),module)); } -tmsize_t TIFFVStripSize(TIFF *tif, uint32_t nrows) +tmsize_t +TIFFVStripSize(TIFF* tif, uint32 nrows) { - static const char module[] = "TIFFVStripSize"; - uint64_t m; - m = TIFFVStripSize64(tif, nrows); - return _TIFFCastUInt64ToSSize(tif, m, module); + static const char module[] = "TIFFVStripSize"; + uint64 m; + m=TIFFVStripSize64(tif,nrows); + return _TIFFCastUInt64ToSSize(tif, m, module); } /* * Compute the # bytes in a raw strip. */ -uint64_t TIFFRawStripSize64(TIFF *tif, uint32_t strip) +uint64 +TIFFRawStripSize64(TIFF* tif, uint32 strip) { - static const char module[] = "TIFFRawStripSize64"; - uint64_t bytecount = TIFFGetStrileByteCount(tif, strip); + static const char module[] = "TIFFRawStripSize64"; + uint64 bytecount = TIFFGetStrileByteCount(tif, strip); - if (bytecount == 0) - { - TIFFErrorExtR(tif, module, - "%" PRIu64 ": Invalid strip byte count, strip %lu", - (uint64_t)bytecount, (unsigned long)strip); - bytecount = (uint64_t)-1; - } + if (bytecount == 0) + { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "%I64u: Invalid strip byte count, strip %lu", + (unsigned __int64) bytecount, + (unsigned long) strip); +#else + TIFFErrorExt(tif->tif_clientdata, module, + "%llu: Invalid strip byte count, strip %lu", + (unsigned long long) bytecount, + (unsigned long) strip); +#endif + bytecount = (uint64) -1; + } - return bytecount; + return bytecount; } -tmsize_t TIFFRawStripSize(TIFF *tif, uint32_t strip) +tmsize_t +TIFFRawStripSize(TIFF* tif, uint32 strip) { - static const char module[] = "TIFFRawStripSize"; - uint64_t m; - tmsize_t n; - m = TIFFRawStripSize64(tif, strip); - if (m == (uint64_t)(-1)) - n = (tmsize_t)(-1); - else - { - n = (tmsize_t)m; - if ((uint64_t)n != m) - { - TIFFErrorExtR(tif, module, "Integer overflow"); - n = 0; - } - } - return (n); + static const char module[] = "TIFFRawStripSize"; + uint64 m; + tmsize_t n; + m=TIFFRawStripSize64(tif,strip); + if (m==(uint64)(-1)) + n=(tmsize_t)(-1); + else + { + n=(tmsize_t)m; + if ((uint64)n!=m) + { + TIFFErrorExt(tif->tif_clientdata,module,"Integer overflow"); + n=0; + } + } + return(n); } /* @@ -181,20 +189,22 @@ tmsize_t TIFFRawStripSize(TIFF *tif, uint32_t strip) * truncated to reflect the actual space required * to hold the strip. */ -uint64_t TIFFStripSize64(TIFF *tif) +uint64 +TIFFStripSize64(TIFF* tif) { - TIFFDirectory *td = &tif->tif_dir; - uint32_t rps = td->td_rowsperstrip; - if (rps > td->td_imagelength) - rps = td->td_imagelength; - return (TIFFVStripSize64(tif, rps)); + TIFFDirectory* td = &tif->tif_dir; + uint32 rps = td->td_rowsperstrip; + if (rps > td->td_imagelength) + rps = td->td_imagelength; + return (TIFFVStripSize64(tif, rps)); } -tmsize_t TIFFStripSize(TIFF *tif) +tmsize_t +TIFFStripSize(TIFF* tif) { - static const char module[] = "TIFFStripSize"; - uint64_t m; - m = TIFFStripSize64(tif); - return _TIFFCastUInt64ToSSize(tif, m, module); + static const char module[] = "TIFFStripSize"; + uint64 m; + m=TIFFStripSize64(tif); + return _TIFFCastUInt64ToSSize(tif, m, module); } /* @@ -203,33 +213,34 @@ tmsize_t TIFFStripSize(TIFF *tif) * request is <1 then we choose a strip size according * to certain heuristics. */ -uint32_t TIFFDefaultStripSize(TIFF *tif, uint32_t request) +uint32 +TIFFDefaultStripSize(TIFF* tif, uint32 request) { - return (*tif->tif_defstripsize)(tif, request); + return (*tif->tif_defstripsize)(tif, request); } -uint32_t _TIFFDefaultStripSize(TIFF *tif, uint32_t s) +uint32 +_TIFFDefaultStripSize(TIFF* tif, uint32 s) { - 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_t scanlinesize; - uint64_t rows; - scanlinesize = TIFFScanlineSize64(tif); - if (scanlinesize == 0) - scanlinesize = 1; - rows = (uint64_t)STRIP_SIZE_DEFAULT / scanlinesize; - if (rows == 0) - rows = 1; - else if (rows > 0xFFFFFFFF) - rows = 0xFFFFFFFF; - s = (uint32_t)rows; - } - return (s); + if ((int32) s < 1) { + /* + * If RowsPerStrip is unspecified, try to break the + * image up into strips that are approximately + * STRIP_SIZE_DEFAULT bytes long. + */ + uint64 scanlinesize; + uint64 rows; + scanlinesize=TIFFScanlineSize64(tif); + if (scanlinesize==0) + scanlinesize=1; + rows=(uint64)STRIP_SIZE_DEFAULT/scanlinesize; + if (rows==0) + rows=1; + else if (rows>0xFFFFFFFFULL) + rows=0xFFFFFFFFULL; + s=(uint32)rows; + } + return (s); } /* @@ -242,79 +253,70 @@ uint32_t _TIFFDefaultStripSize(TIFF *tif, uint32_t s) * subsampling lines divided by vertical subsampling. It should thus make * sense when multiplied by a multiple of vertical subsampling. */ -uint64_t TIFFScanlineSize64(TIFF *tif) +uint64 +TIFFScanlineSize64(TIFF* tif) { - static const char module[] = "TIFFScanlineSize64"; - TIFFDirectory *td = &tif->tif_dir; - uint64_t scanline_size; - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - { - if ((td->td_photometric == PHOTOMETRIC_YCBCR) && - (td->td_samplesperpixel == 3) && (!isUpSampled(tif))) + static const char module[] = "TIFFScanlineSize64"; + TIFFDirectory *td = &tif->tif_dir; + uint64 scanline_size; + if (td->td_planarconfig==PLANARCONFIG_CONTIG) + { + if ((td->td_photometric==PHOTOMETRIC_YCBCR)&& + (td->td_samplesperpixel==3)&& + (!isUpSampled(tif))) + { + uint16 ycbcrsubsampling[2]; + uint16 samplingblock_samples; + uint32 samplingblocks_hor; + uint64 samplingrow_samples; + uint64 samplingrow_size; + if(td->td_samplesperpixel!=3) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid td_samplesperpixel value"); + return 0; + } + TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING, + ycbcrsubsampling+0, + ycbcrsubsampling+1); + if (((ycbcrsubsampling[0]!=1)&&(ycbcrsubsampling[0]!=2)&&(ycbcrsubsampling[0]!=4)) || + ((ycbcrsubsampling[1]!=1)&&(ycbcrsubsampling[1]!=2)&&(ycbcrsubsampling[1]!=4))) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid YCbCr subsampling"); + return 0; + } + samplingblock_samples = ycbcrsubsampling[0]*ycbcrsubsampling[1]+2; + samplingblocks_hor = TIFFhowmany_32(td->td_imagewidth,ycbcrsubsampling[0]); + samplingrow_samples = _TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module); + samplingrow_size = TIFFhowmany_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module),8); + scanline_size = (samplingrow_size/ycbcrsubsampling[1]); + } + else + { + uint64 scanline_samples; + scanline_samples=_TIFFMultiply64(tif,td->td_imagewidth,td->td_samplesperpixel,module); + scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,scanline_samples,td->td_bitspersample,module),8); + } + } + else { - 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) - { - TIFFErrorExtR(tif, module, "Invalid td_samplesperpixel value"); - return 0; - } - TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRSUBSAMPLING, - ycbcrsubsampling + 0, ycbcrsubsampling + 1); - if (((ycbcrsubsampling[0] != 1) && (ycbcrsubsampling[0] != 2) && - (ycbcrsubsampling[0] != 4)) || - ((ycbcrsubsampling[1] != 1) && (ycbcrsubsampling[1] != 2) && - (ycbcrsubsampling[1] != 4))) - { - TIFFErrorExtR(tif, module, "Invalid YCbCr subsampling"); - return 0; - } - samplingblock_samples = - ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2; - samplingblocks_hor = - TIFFhowmany_32(td->td_imagewidth, ycbcrsubsampling[0]); - samplingrow_samples = _TIFFMultiply64( - tif, samplingblocks_hor, samplingblock_samples, module); - samplingrow_size = - TIFFhowmany_64(_TIFFMultiply64(tif, samplingrow_samples, - td->td_bitspersample, module), - 8); - scanline_size = (samplingrow_size / ycbcrsubsampling[1]); + scanline_size=TIFFhowmany_64(_TIFFMultiply64(tif,td->td_imagewidth,td->td_bitspersample,module),8); } - else + if (scanline_size == 0) { - 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); + TIFFErrorExt(tif->tif_clientdata,module,"Computed scanline size is zero"); + return 0; } - } - else - { - scanline_size = - TIFFhowmany_64(_TIFFMultiply64(tif, td->td_imagewidth, - td->td_bitspersample, module), - 8); - } - if (scanline_size == 0) - { - TIFFErrorExtR(tif, module, "Computed scanline size is zero"); - return 0; - } - return (scanline_size); + return(scanline_size); } -tmsize_t TIFFScanlineSize(TIFF *tif) +tmsize_t +TIFFScanlineSize(TIFF* tif) { - static const char module[] = "TIFFScanlineSize"; - uint64_t m; - m = TIFFScanlineSize64(tif); - return _TIFFCastUInt64ToSSize(tif, m, module); + static const char module[] = "TIFFScanlineSize"; + uint64 m; + m=TIFFScanlineSize64(tif); + return _TIFFCastUInt64ToSSize(tif, m, module); } /* @@ -323,28 +325,35 @@ tmsize_t TIFFScanlineSize(TIFF *tif) * I/O size returned by TIFFScanlineSize which may be less * if data is store as separate planes). */ -uint64_t TIFFRasterScanlineSize64(TIFF *tif) +uint64 +TIFFRasterScanlineSize64(TIFF* tif) { - static const char module[] = "TIFFRasterScanlineSize64"; - TIFFDirectory *td = &tif->tif_dir; - uint64_t scanline; + static const char module[] = "TIFFRasterScanlineSize64"; + TIFFDirectory *td = &tif->tif_dir; + uint64 scanline; - scanline = - _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module); - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - { - scanline = - _TIFFMultiply64(tif, scanline, td->td_samplesperpixel, module); - return (TIFFhowmany8_64(scanline)); - } - else - return (_TIFFMultiply64(tif, TIFFhowmany8_64(scanline), - td->td_samplesperpixel, module)); + scanline = _TIFFMultiply64(tif, td->td_bitspersample, td->td_imagewidth, module); + if (td->td_planarconfig == PLANARCONFIG_CONTIG) { + scanline = _TIFFMultiply64(tif, scanline, td->td_samplesperpixel, module); + return (TIFFhowmany8_64(scanline)); + } else + return (_TIFFMultiply64(tif, TIFFhowmany8_64(scanline), + td->td_samplesperpixel, module)); } -tmsize_t TIFFRasterScanlineSize(TIFF *tif) +tmsize_t +TIFFRasterScanlineSize(TIFF* tif) { - static const char module[] = "TIFFRasterScanlineSize"; - uint64_t m; - m = TIFFRasterScanlineSize64(tif); - return _TIFFCastUInt64ToSSize(tif, m, module); + static const char module[] = "TIFFRasterScanlineSize"; + uint64 m; + m=TIFFRasterScanlineSize64(tif); + return _TIFFCastUInt64ToSSize(tif, m, module); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_swab.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_swab.c index 827b025ce..b174ba69c 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_swab.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_swab.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -30,218 +30,169 @@ #include "tiffiop.h" #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabShort) -void TIFFSwabShort(uint16_t *wp) +void +TIFFSwabShort(uint16* wp) { - register unsigned char *cp = (unsigned char *)wp; - unsigned char t; - assert(sizeof(uint16_t) == 2); - t = cp[1]; - cp[1] = cp[0]; - cp[0] = t; + register unsigned char* cp = (unsigned char*) wp; + unsigned char t; + assert(sizeof(uint16)==2); + t = cp[1]; cp[1] = cp[0]; cp[0] = t; } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong) -void TIFFSwabLong(uint32_t *lp) +void +TIFFSwabLong(uint32* lp) { - register unsigned char *cp = (unsigned char *)lp; - unsigned char t; - 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; + register unsigned char* cp = (unsigned char*) lp; + unsigned char t; + assert(sizeof(uint32)==4); + t = cp[3]; cp[3] = cp[0]; cp[0] = t; + t = cp[2]; cp[2] = cp[1]; cp[1] = t; } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabLong8) -void TIFFSwabLong8(uint64_t *lp) +void +TIFFSwabLong8(uint64* lp) { - register unsigned char *cp = (unsigned char *)lp; - unsigned char t; - 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; - t = cp[4]; - cp[4] = cp[3]; - cp[3] = t; + register unsigned char* cp = (unsigned char*) lp; + unsigned char t; + assert(sizeof(uint64)==8); + t = cp[7]; cp[7] = cp[0]; cp[0] = t; + t = cp[6]; cp[6] = cp[1]; cp[1] = t; + t = cp[5]; cp[5] = cp[2]; cp[2] = t; + t = cp[4]; cp[4] = cp[3]; cp[3] = t; } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfShort) -void TIFFSwabArrayOfShort(register uint16_t *wp, tmsize_t n) +void +TIFFSwabArrayOfShort(register uint16* wp, tmsize_t n) { - register unsigned char *cp; - register unsigned char t; - assert(sizeof(uint16_t) == 2); - /* XXX unroll loop some */ - while (n-- > 0) - { - cp = (unsigned char *)wp; - t = cp[1]; - cp[1] = cp[0]; - cp[0] = t; - wp++; - } + register unsigned char* cp; + register unsigned char t; + assert(sizeof(uint16)==2); + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char*) wp; + t = cp[1]; cp[1] = cp[0]; cp[0] = t; + wp++; + } } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfTriples) -void TIFFSwabArrayOfTriples(register uint8_t *tp, tmsize_t n) +void +TIFFSwabArrayOfTriples(register uint8* tp, tmsize_t n) { - unsigned char *cp; - unsigned char t; + unsigned char* cp; + unsigned char t; - /* XXX unroll loop some */ - while (n-- > 0) - { - cp = (unsigned char *)tp; - t = cp[2]; - cp[2] = cp[0]; - cp[0] = t; - tp += 3; - } + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char*) tp; + t = cp[2]; cp[2] = cp[0]; cp[0] = t; + tp += 3; + } } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong) -void TIFFSwabArrayOfLong(register uint32_t *lp, tmsize_t n) +void +TIFFSwabArrayOfLong(register uint32* lp, tmsize_t n) { - register unsigned char *cp; - register unsigned char t; - assert(sizeof(uint32_t) == 4); - /* XXX unroll loop some */ - while (n-- > 0) - { - cp = (unsigned char *)lp; - t = cp[3]; - cp[3] = cp[0]; - cp[0] = t; - t = cp[2]; - cp[2] = cp[1]; - cp[1] = t; - lp++; - } + register unsigned char *cp; + register unsigned char t; + assert(sizeof(uint32)==4); + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char *)lp; + t = cp[3]; cp[3] = cp[0]; cp[0] = t; + t = cp[2]; cp[2] = cp[1]; cp[1] = t; + lp++; + } } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfLong8) -void TIFFSwabArrayOfLong8(register uint64_t *lp, tmsize_t n) +void +TIFFSwabArrayOfLong8(register uint64* lp, tmsize_t n) { - register unsigned char *cp; - register unsigned char t; - assert(sizeof(uint64_t) == 8); - /* XXX unroll loop some */ - while (n-- > 0) - { - cp = (unsigned char *)lp; - t = cp[7]; - cp[7] = cp[0]; - cp[0] = t; - t = cp[6]; - cp[6] = cp[1]; - cp[1] = t; - t = cp[5]; - cp[5] = cp[2]; - cp[2] = t; - t = cp[4]; - cp[4] = cp[3]; - cp[3] = t; - lp++; - } + register unsigned char *cp; + register unsigned char t; + assert(sizeof(uint64)==8); + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char *)lp; + t = cp[7]; cp[7] = cp[0]; cp[0] = t; + t = cp[6]; cp[6] = cp[1]; cp[1] = t; + t = cp[5]; cp[5] = cp[2]; cp[2] = t; + t = cp[4]; cp[4] = cp[3]; cp[3] = t; + lp++; + } } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabFloat) -void TIFFSwabFloat(float *fp) +void +TIFFSwabFloat(float* fp) { - register unsigned char *cp = (unsigned char *)fp; - unsigned char t; - assert(sizeof(float) == 4); - t = cp[3]; - cp[3] = cp[0]; - cp[0] = t; - t = cp[2]; - cp[2] = cp[1]; - cp[1] = t; + register unsigned char* cp = (unsigned char*) fp; + unsigned char t; + assert(sizeof(float)==4); + t = cp[3]; cp[3] = cp[0]; cp[0] = t; + t = cp[2]; cp[2] = cp[1]; cp[1] = t; } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfFloat) -void TIFFSwabArrayOfFloat(register float *fp, tmsize_t n) +void +TIFFSwabArrayOfFloat(register float* fp, tmsize_t n) { - register unsigned char *cp; - register unsigned char t; - assert(sizeof(float) == 4); - /* XXX unroll loop some */ - while (n-- > 0) - { - cp = (unsigned char *)fp; - t = cp[3]; - cp[3] = cp[0]; - cp[0] = t; - t = cp[2]; - cp[2] = cp[1]; - cp[1] = t; - fp++; - } + register unsigned char *cp; + register unsigned char t; + assert(sizeof(float)==4); + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char *)fp; + t = cp[3]; cp[3] = cp[0]; cp[0] = t; + t = cp[2]; cp[2] = cp[1]; cp[1] = t; + fp++; + } } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabDouble) -void TIFFSwabDouble(double *dp) +void +TIFFSwabDouble(double *dp) { - register unsigned char *cp = (unsigned char *)dp; - unsigned char t; - assert(sizeof(double) == 8); - t = cp[7]; - cp[7] = cp[0]; - cp[0] = t; - t = cp[6]; - cp[6] = cp[1]; - cp[1] = t; - t = cp[5]; - cp[5] = cp[2]; - cp[2] = t; - t = cp[4]; - cp[4] = cp[3]; - cp[3] = t; + register unsigned char* cp = (unsigned char*) dp; + unsigned char t; + assert(sizeof(double)==8); + t = cp[7]; cp[7] = cp[0]; cp[0] = t; + t = cp[6]; cp[6] = cp[1]; cp[1] = t; + t = cp[5]; cp[5] = cp[2]; cp[2] = t; + t = cp[4]; cp[4] = cp[3]; cp[3] = t; } #endif #if defined(DISABLE_CHECK_TIFFSWABMACROS) || !defined(TIFFSwabArrayOfDouble) -void TIFFSwabArrayOfDouble(double *dp, tmsize_t n) +void +TIFFSwabArrayOfDouble(double* dp, tmsize_t n) { - register unsigned char *cp; - register unsigned char t; - assert(sizeof(double) == 8); - /* XXX unroll loop some */ - while (n-- > 0) - { - cp = (unsigned char *)dp; - t = cp[7]; - cp[7] = cp[0]; - cp[0] = t; - t = cp[6]; - cp[6] = cp[1]; - cp[1] = t; - t = cp[5]; - cp[5] = cp[2]; - cp[2] = t; - t = cp[4]; - cp[4] = cp[3]; - cp[3] = t; - dp++; - } + register unsigned char *cp; + register unsigned char t; + assert(sizeof(double)==8); + /* XXX unroll loop some */ + while (n-- > 0) { + cp = (unsigned char *)dp; + t = cp[7]; cp[7] = cp[0]; cp[0] = t; + t = cp[6]; cp[6] = cp[1]; cp[1] = t; + t = cp[5]; cp[5] = cp[2]; cp[2] = t; + t = cp[4]; cp[4] = cp[3]; cp[3] = t; + dp++; + } } #endif @@ -255,75 +206,105 @@ void TIFFSwabArrayOfDouble(double *dp, tmsize_t n) * do not reverse bit values. */ static const unsigned char TIFFBitRevTable[256] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, - 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, - 0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc, - 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, - 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, - 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, - 0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9, - 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, - 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d,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xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff +}; static const unsigned char TIFFNoBitRevTable[256] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0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 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, - 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, - 0xfc, 0xfd, 0xfe, 0xff, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, + 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, + 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, + 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, + 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, }; -const unsigned char *TIFFGetBitRevTable(int reversed) +const unsigned char* +TIFFGetBitRevTable(int reversed) { - return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable); + return (reversed ? TIFFBitRevTable : TIFFNoBitRevTable); } -void TIFFReverseBits(uint8_t *cp, tmsize_t n) +void +TIFFReverseBits(uint8* cp, tmsize_t n) { - for (; n > 8; n -= 8) - { - cp[0] = TIFFBitRevTable[cp[0]]; - cp[1] = TIFFBitRevTable[cp[1]]; - cp[2] = TIFFBitRevTable[cp[2]]; - cp[3] = TIFFBitRevTable[cp[3]]; - cp[4] = TIFFBitRevTable[cp[4]]; - cp[5] = TIFFBitRevTable[cp[5]]; - cp[6] = TIFFBitRevTable[cp[6]]; - cp[7] = TIFFBitRevTable[cp[7]]; - cp += 8; - } - while (n-- > 0) - { - *cp = TIFFBitRevTable[*cp]; - cp++; - } + for (; n > 8; n -= 8) { + cp[0] = TIFFBitRevTable[cp[0]]; + cp[1] = TIFFBitRevTable[cp[1]]; + cp[2] = TIFFBitRevTable[cp[2]]; + cp[3] = TIFFBitRevTable[cp[3]]; + cp[4] = TIFFBitRevTable[cp[4]]; + cp[5] = TIFFBitRevTable[cp[5]]; + cp[6] = TIFFBitRevTable[cp[6]]; + cp[7] = TIFFBitRevTable[cp[7]]; + cp += 8; + } + while (n-- > 0) { + *cp = TIFFBitRevTable[*cp]; + cp++; + } } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_thunder.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_thunder.c index 1f97362ca..db6383a81 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_thunder.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_thunder.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -41,158 +41,166 @@ * or 3-bit delta values are used, with the deltas packed * into a single byte. */ -#define THUNDER_DATA 0x3f /* mask for 6-bit data */ -#define THUNDER_CODE 0xc0 /* mask for 2-bit code word */ +#define THUNDER_DATA 0x3f /* mask for 6-bit data */ +#define THUNDER_CODE 0xc0 /* mask for 2-bit code word */ /* code values */ -#define THUNDER_RUN 0x00 /* run of pixels w/ encoded count */ -#define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */ -#define DELTA2_SKIP 2 /* skip code for 2-bit deltas */ -#define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */ -#define DELTA3_SKIP 4 /* skip code for 3-bit deltas */ -#define THUNDER_RAW 0xc0 /* raw data encoded */ +#define THUNDER_RUN 0x00 /* run of pixels w/ encoded count */ +#define THUNDER_2BITDELTAS 0x40 /* 3 pixels w/ encoded 2-bit deltas */ +#define DELTA2_SKIP 2 /* skip code for 2-bit deltas */ +#define THUNDER_3BITDELTAS 0x80 /* 2 pixels w/ encoded 3-bit deltas */ +#define DELTA3_SKIP 4 /* skip code for 3-bit deltas */ +#define THUNDER_RAW 0xc0 /* raw data encoded */ -static const int twobitdeltas[4] = {0, 1, 0, -1}; -static const int threebitdeltas[8] = {0, 1, 2, 3, 0, -3, -2, -1}; +static const int twobitdeltas[4] = { 0, 1, 0, -1 }; +static const int threebitdeltas[8] = { 0, 1, 2, 3, 0, -3, -2, -1 }; -#define SETPIXEL(op, v) \ - { \ - lastpixel = (v)&0xf; \ - if (npixels < maxpixels) \ - { \ - if (npixels++ & 1) \ - *op++ |= lastpixel; \ - else \ - op[0] = (uint8_t)(lastpixel << 4); \ - } \ - } - -static int ThunderSetupDecode(TIFF *tif) -{ - static const char module[] = "ThunderSetupDecode"; - - if (tif->tif_dir.td_bitspersample != 4) - { - TIFFErrorExtR(tif, module, - "Wrong bitspersample value (%d), Thunder decoder only " - "supports 4bits per sample.", - (int)tif->tif_dir.td_bitspersample); - return 0; - } - - return (1); +#define SETPIXEL(op, v) { \ + lastpixel = (v) & 0xf; \ + if ( npixels < maxpixels ) \ + { \ + if (npixels++ & 1) \ + *op++ |= lastpixel; \ + else \ + op[0] = (uint8) (lastpixel << 4); \ + } \ } -static int ThunderDecode(TIFF *tif, uint8_t *op, tmsize_t maxpixels) +static int +ThunderSetupDecode(TIFF* tif) { - static const char module[] = "ThunderDecode"; - register unsigned char *bp; - register tmsize_t cc; - unsigned int lastpixel; - tmsize_t npixels; + static const char module[] = "ThunderSetupDecode"; - bp = (unsigned char *)tif->tif_rawcp; - cc = tif->tif_rawcc; - lastpixel = 0; - npixels = 0; - while (cc > 0 && npixels < maxpixels) - { - int n, delta; - - n = *bp++; - cc--; - switch (n & THUNDER_CODE) + if( tif->tif_dir.td_bitspersample != 4 ) { - case THUNDER_RUN: /* pixel run */ - /* - * Replicate the last pixel n times, - * where n is the lower-order 6 bits. - */ - if (npixels & 1) - { - op[0] |= lastpixel; - lastpixel = *op++; - npixels++; - n--; - } - else - lastpixel |= lastpixel << 4; - npixels += n; - if (npixels < maxpixels) - { - for (; n > 0; n -= 2) - *op++ = (uint8_t)lastpixel; - } - if (n == -1) - *--op &= 0xf0; - lastpixel &= 0xf; - break; - case THUNDER_2BITDELTAS: /* 2-bit deltas */ - if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP) - SETPIXEL(op, - (unsigned)((int)lastpixel + twobitdeltas[delta])); - if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP) - SETPIXEL(op, - (unsigned)((int)lastpixel + twobitdeltas[delta])); - if ((delta = (n & 3)) != DELTA2_SKIP) - SETPIXEL(op, - (unsigned)((int)lastpixel + twobitdeltas[delta])); - break; - case THUNDER_3BITDELTAS: /* 3-bit deltas */ - if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP) - SETPIXEL( - op, (unsigned)((int)lastpixel + threebitdeltas[delta])); - if ((delta = (n & 7)) != DELTA3_SKIP) - SETPIXEL( - op, (unsigned)((int)lastpixel + threebitdeltas[delta])); - break; - case THUNDER_RAW: /* raw data */ - SETPIXEL(op, n); - break; + TIFFErrorExt(tif->tif_clientdata, module, + "Wrong bitspersample value (%d), Thunder decoder only supports 4bits per sample.", + (int) tif->tif_dir.td_bitspersample ); + return 0; } - } - tif->tif_rawcp = (uint8_t *)bp; - tif->tif_rawcc = cc; - if (npixels != maxpixels) - { - TIFFErrorExtR(tif, module, - "%s data at scanline %lu (%" PRIu64 " != %" PRIu64 ")", - npixels < maxpixels ? "Not enough" : "Too much", - (unsigned long)tif->tif_row, (uint64_t)npixels, - (uint64_t)maxpixels); - return (0); - } + - return (1); + return (1); } -static int ThunderDecodeRow(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s) +static int +ThunderDecode(TIFF* tif, uint8* op, tmsize_t maxpixels) { - static const char module[] = "ThunderDecodeRow"; - uint8_t *row = buf; + static const char module[] = "ThunderDecode"; + register unsigned char *bp; + register tmsize_t cc; + unsigned int lastpixel; + tmsize_t npixels; - (void)s; - if (occ % tif->tif_scanlinesize) - { - TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read"); - return (0); - } - while (occ > 0) - { - if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) - return (0); - occ -= tif->tif_scanlinesize; - row += tif->tif_scanlinesize; - } - return (1); + bp = (unsigned char *)tif->tif_rawcp; + cc = tif->tif_rawcc; + lastpixel = 0; + npixels = 0; + while (cc > 0 && npixels < maxpixels) { + int n, delta; + + n = *bp++; + cc--; + switch (n & THUNDER_CODE) { + case THUNDER_RUN: /* pixel run */ + /* + * Replicate the last pixel n times, + * where n is the lower-order 6 bits. + */ + if (npixels & 1) { + op[0] |= lastpixel; + lastpixel = *op++; npixels++; n--; + } else + lastpixel |= lastpixel << 4; + npixels += n; + if (npixels < maxpixels) { + for (; n > 0; n -= 2) + *op++ = (uint8) lastpixel; + } + if (n == -1) + *--op &= 0xf0; + lastpixel &= 0xf; + break; + case THUNDER_2BITDELTAS: /* 2-bit deltas */ + if ((delta = ((n >> 4) & 3)) != DELTA2_SKIP) + SETPIXEL(op, (unsigned)((int)lastpixel + twobitdeltas[delta])); + if ((delta = ((n >> 2) & 3)) != DELTA2_SKIP) + SETPIXEL(op, (unsigned)((int)lastpixel + twobitdeltas[delta])); + if ((delta = (n & 3)) != DELTA2_SKIP) + SETPIXEL(op, (unsigned)((int)lastpixel + twobitdeltas[delta])); + break; + case THUNDER_3BITDELTAS: /* 3-bit deltas */ + if ((delta = ((n >> 3) & 7)) != DELTA3_SKIP) + SETPIXEL(op, (unsigned)((int)lastpixel + threebitdeltas[delta])); + if ((delta = (n & 7)) != DELTA3_SKIP) + SETPIXEL(op, (unsigned)((int)lastpixel + threebitdeltas[delta])); + break; + case THUNDER_RAW: /* raw data */ + SETPIXEL(op, n); + break; + } + } + tif->tif_rawcp = (uint8*) bp; + tif->tif_rawcc = cc; + if (npixels != maxpixels) { +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + TIFFErrorExt(tif->tif_clientdata, module, + "%s data at scanline %lu (%I64u != %I64u)", + npixels < maxpixels ? "Not enough" : "Too much", + (unsigned long) tif->tif_row, + (unsigned __int64) npixels, + (unsigned __int64) maxpixels); +#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 + return (0); + } + + return (1); } -int TIFFInitThunderScan(TIFF *tif, int scheme) +static int +ThunderDecodeRow(TIFF* tif, uint8* buf, tmsize_t occ, uint16 s) { - (void)scheme; + static const char module[] = "ThunderDecodeRow"; + uint8* row = buf; + + (void) s; + if (occ % tif->tif_scanlinesize) + { + TIFFErrorExt(tif->tif_clientdata, module, "Fractional scanlines cannot be read"); + return (0); + } + while (occ > 0) { + if (!ThunderDecode(tif, row, tif->tif_dir.td_imagewidth)) + return (0); + occ -= tif->tif_scanlinesize; + row += tif->tif_scanlinesize; + } + return (1); +} - tif->tif_setupdecode = ThunderSetupDecode; - tif->tif_decoderow = ThunderDecodeRow; - tif->tif_decodestrip = ThunderDecodeRow; - return (1); +int +TIFFInitThunderScan(TIFF* tif, int scheme) +{ + (void) scheme; + + tif->tif_setupdecode = ThunderSetupDecode; + tif->tif_decoderow = ThunderDecodeRow; + tif->tif_decodestrip = ThunderDecodeRow; + return (1); } #endif /* THUNDER_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_tile.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_tile.c index f07032f73..661cc7715 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_tile.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_tile.c @@ -2,23 +2,23 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,230 +32,234 @@ /* * Compute which tile an (x,y,z,s) value is in. */ -uint32_t TIFFComputeTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z, - uint16_t s) +uint32 +TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) { - TIFFDirectory *td = &tif->tif_dir; - uint32_t dx = td->td_tilewidth; - uint32_t dy = td->td_tilelength; - uint32_t dz = td->td_tiledepth; - uint32_t tile = 1; + TIFFDirectory *td = &tif->tif_dir; + uint32 dx = td->td_tilewidth; + uint32 dy = td->td_tilelength; + uint32 dz = td->td_tiledepth; + uint32 tile = 1; - if (td->td_imagedepth == 1) - z = 0; - if (dx == (uint32_t)-1) - dx = td->td_imagewidth; - if (dy == (uint32_t)-1) - dy = td->td_imagelength; - if (dz == (uint32_t)-1) - dz = td->td_imagedepth; - if (dx != 0 && dy != 0 && dz != 0) - { - 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_imagedepth == 1) + z = 0; + if (dx == (uint32) -1) + dx = td->td_imagewidth; + if (dy == (uint32) -1) + dy = td->td_imagelength; + if (dz == (uint32) -1) + dz = td->td_imagedepth; + if (dx != 0 && dy != 0 && dz != 0) { + uint32 xpt = TIFFhowmany_32(td->td_imagewidth, dx); + uint32 ypt = TIFFhowmany_32(td->td_imagelength, dy); + uint32 zpt = TIFFhowmany_32(td->td_imagedepth, dz); - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - tile = (xpt * ypt * zpt) * s + (xpt * ypt) * (z / dz) + - xpt * (y / dy) + x / dx; - else - tile = (xpt * ypt) * (z / dz) + xpt * (y / dy) + x / dx; - } - return (tile); + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + tile = (xpt*ypt*zpt)*s + + (xpt*ypt)*(z/dz) + + xpt*(y/dy) + + x/dx; + else + tile = (xpt*ypt)*(z/dz) + xpt*(y/dy) + x/dx; + } + return (tile); } /* * Check an (x,y,z,s) coordinate * against the image bounds. */ -int TIFFCheckTile(TIFF *tif, uint32_t x, uint32_t y, uint32_t z, uint16_t s) +int +TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s) { - TIFFDirectory *td = &tif->tif_dir; + TIFFDirectory *td = &tif->tif_dir; - if (x >= td->td_imagewidth) - { - TIFFErrorExtR(tif, tif->tif_name, "%lu: Col out of range, max %lu", - (unsigned long)x, (unsigned long)(td->td_imagewidth - 1)); - return (0); - } - if (y >= td->td_imagelength) - { - TIFFErrorExtR(tif, tif->tif_name, "%lu: Row out of range, max %lu", - (unsigned long)y, - (unsigned long)(td->td_imagelength - 1)); - return (0); - } - if (z >= td->td_imagedepth) - { - TIFFErrorExtR(tif, tif->tif_name, "%lu: Depth out of range, max %lu", - (unsigned long)z, (unsigned long)(td->td_imagedepth - 1)); - return (0); - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE && - s >= td->td_samplesperpixel) - { - TIFFErrorExtR(tif, tif->tif_name, "%lu: Sample out of range, max %lu", - (unsigned long)s, - (unsigned long)(td->td_samplesperpixel - 1)); - return (0); - } - return (1); + if (x >= td->td_imagewidth) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%lu: Col out of range, max %lu", + (unsigned long) x, + (unsigned long) (td->td_imagewidth - 1)); + return (0); + } + if (y >= td->td_imagelength) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%lu: Row out of range, max %lu", + (unsigned long) y, + (unsigned long) (td->td_imagelength - 1)); + return (0); + } + if (z >= td->td_imagedepth) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%lu: Depth out of range, max %lu", + (unsigned long) z, + (unsigned long) (td->td_imagedepth - 1)); + return (0); + } + if (td->td_planarconfig == PLANARCONFIG_SEPARATE && + s >= td->td_samplesperpixel) { + TIFFErrorExt(tif->tif_clientdata, tif->tif_name, + "%lu: Sample out of range, max %lu", + (unsigned long) s, + (unsigned long) (td->td_samplesperpixel - 1)); + return (0); + } + return (1); } /* * Compute how many tiles are in an image. */ -uint32_t TIFFNumberOfTiles(TIFF *tif) +uint32 +TIFFNumberOfTiles(TIFF* tif) { - TIFFDirectory *td = &tif->tif_dir; - uint32_t dx = td->td_tilewidth; - uint32_t dy = td->td_tilelength; - uint32_t dz = td->td_tiledepth; - uint32_t ntiles; + TIFFDirectory *td = &tif->tif_dir; + uint32 dx = td->td_tilewidth; + uint32 dy = td->td_tilelength; + uint32 dz = td->td_tiledepth; + uint32 ntiles; - if (dx == (uint32_t)-1) - dx = td->td_imagewidth; - if (dy == (uint32_t)-1) - dy = td->td_imagelength; - 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), - TIFFhowmany_32(td->td_imagelength, dy), - "TIFFNumberOfTiles"), - TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles"); - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel, - "TIFFNumberOfTiles"); - return (ntiles); + if (dx == (uint32) -1) + dx = td->td_imagewidth; + if (dy == (uint32) -1) + dy = td->td_imagelength; + if (dz == (uint32) -1) + dz = td->td_imagedepth; + ntiles = (dx == 0 || dy == 0 || dz == 0) ? 0 : + _TIFFMultiply32(tif, _TIFFMultiply32(tif, TIFFhowmany_32(td->td_imagewidth, dx), + TIFFhowmany_32(td->td_imagelength, dy), + "TIFFNumberOfTiles"), + TIFFhowmany_32(td->td_imagedepth, dz), "TIFFNumberOfTiles"); + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + ntiles = _TIFFMultiply32(tif, ntiles, td->td_samplesperpixel, + "TIFFNumberOfTiles"); + return (ntiles); } /* * Compute the # bytes in each row of a tile. */ -uint64_t TIFFTileRowSize64(TIFF *tif) +uint64 +TIFFTileRowSize64(TIFF* tif) { - static const char module[] = "TIFFTileRowSize64"; - TIFFDirectory *td = &tif->tif_dir; - uint64_t rowsize; - uint64_t tilerowsize; + static const char module[] = "TIFFTileRowSize64"; + TIFFDirectory *td = &tif->tif_dir; + uint64 rowsize; + uint64 tilerowsize; - if (td->td_tilelength == 0) - { - TIFFErrorExtR(tif, module, "Tile length is zero"); - return 0; - } - if (td->td_tilewidth == 0) - { - TIFFErrorExtR(tif, module, "Tile width is zero"); - return (0); - } - rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth, - "TIFFTileRowSize"); - if (td->td_planarconfig == PLANARCONFIG_CONTIG) - { - if (td->td_samplesperpixel == 0) + if (td->td_tilelength == 0) { - TIFFErrorExtR(tif, module, "Samples per pixel is zero"); - return 0; + TIFFErrorExt(tif->tif_clientdata,module,"Tile length is zero"); + return 0; } - rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel, - "TIFFTileRowSize"); - } - tilerowsize = TIFFhowmany8_64(rowsize); - if (tilerowsize == 0) - { - TIFFErrorExtR(tif, module, "Computed tile row size is zero"); - return 0; - } - return (tilerowsize); + if (td->td_tilewidth == 0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Tile width is zero"); + return (0); + } + rowsize = _TIFFMultiply64(tif, td->td_bitspersample, td->td_tilewidth, + "TIFFTileRowSize"); + if (td->td_planarconfig == PLANARCONFIG_CONTIG) + { + if (td->td_samplesperpixel == 0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Samples per pixel is zero"); + return 0; + } + rowsize = _TIFFMultiply64(tif, rowsize, td->td_samplesperpixel, + "TIFFTileRowSize"); + } + tilerowsize=TIFFhowmany8_64(rowsize); + if (tilerowsize == 0) + { + TIFFErrorExt(tif->tif_clientdata,module,"Computed tile row size is zero"); + return 0; + } + return (tilerowsize); } -tmsize_t TIFFTileRowSize(TIFF *tif) +tmsize_t +TIFFTileRowSize(TIFF* tif) { - static const char module[] = "TIFFTileRowSize"; - uint64_t m; - m = TIFFTileRowSize64(tif); - return _TIFFCastUInt64ToSSize(tif, m, module); + static const char module[] = "TIFFTileRowSize"; + uint64 m; + m=TIFFTileRowSize64(tif); + return _TIFFCastUInt64ToSSize(tif, m, module); } /* * Compute the # bytes in a variable length, row-aligned tile. */ -uint64_t TIFFVTileSize64(TIFF *tif, uint32_t nrows) +uint64 +TIFFVTileSize64(TIFF* tif, uint32 nrows) { - static const char module[] = "TIFFVTileSize64"; - TIFFDirectory *td = &tif->tif_dir; - if (td->td_tilelength == 0 || td->td_tilewidth == 0 || - td->td_tiledepth == 0) - return (0); - if ((td->td_planarconfig == PLANARCONFIG_CONTIG) && - (td->td_photometric == PHOTOMETRIC_YCBCR) && - (td->td_samplesperpixel == 3) && (!isUpSampled(tif))) - { - /* - * Packed YCbCr data contain one Cb+Cr for every - * HorizontalSampling*VerticalSampling Y values. - * Must also roundup width and height when calculating - * since images that are not a multiple of the - * horizontal/vertical subsampling area include - * YCbCr data for the extended image. - */ - uint16_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) || - (ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && - ycbcrsubsampling[1] != 4)) - { - TIFFErrorExtR(tif, module, "Invalid YCbCr subsampling (%dx%d)", - ycbcrsubsampling[0], ycbcrsubsampling[1]); - return 0; - } - samplingblock_samples = ycbcrsubsampling[0] * ycbcrsubsampling[1] + 2; - samplingblocks_hor = - TIFFhowmany_32(td->td_tilewidth, ycbcrsubsampling[0]); - samplingblocks_ver = TIFFhowmany_32(nrows, ycbcrsubsampling[1]); - samplingrow_samples = _TIFFMultiply64(tif, samplingblocks_hor, - samplingblock_samples, module); - samplingrow_size = TIFFhowmany8_64(_TIFFMultiply64( - tif, samplingrow_samples, td->td_bitspersample, module)); - return ( - _TIFFMultiply64(tif, samplingrow_size, samplingblocks_ver, module)); - } - else - return (_TIFFMultiply64(tif, nrows, TIFFTileRowSize64(tif), module)); + static const char module[] = "TIFFVTileSize64"; + TIFFDirectory *td = &tif->tif_dir; + if (td->td_tilelength == 0 || td->td_tilewidth == 0 || + td->td_tiledepth == 0) + return (0); + if ((td->td_planarconfig==PLANARCONFIG_CONTIG)&& + (td->td_photometric==PHOTOMETRIC_YCBCR)&& + (td->td_samplesperpixel==3)&& + (!isUpSampled(tif))) + { + /* + * Packed YCbCr data contain one Cb+Cr for every + * HorizontalSampling*VerticalSampling Y values. + * Must also roundup width and height when calculating + * since images that are not a multiple of the + * horizontal/vertical subsampling area include + * YCbCr data for the extended image. + */ + uint16 ycbcrsubsampling[2]; + uint16 samplingblock_samples; + uint32 samplingblocks_hor; + uint32 samplingblocks_ver; + uint64 samplingrow_samples; + uint64 samplingrow_size; + TIFFGetFieldDefaulted(tif,TIFFTAG_YCBCRSUBSAMPLING,ycbcrsubsampling+0, + ycbcrsubsampling+1); + if ((ycbcrsubsampling[0] != 1 && ycbcrsubsampling[0] != 2 && ycbcrsubsampling[0] != 4) + ||(ycbcrsubsampling[1] != 1 && ycbcrsubsampling[1] != 2 && ycbcrsubsampling[1] != 4)) + { + TIFFErrorExt(tif->tif_clientdata,module, + "Invalid YCbCr subsampling (%dx%d)", + ycbcrsubsampling[0], + ycbcrsubsampling[1] ); + return 0; + } + samplingblock_samples=ycbcrsubsampling[0]*ycbcrsubsampling[1]+2; + samplingblocks_hor=TIFFhowmany_32(td->td_tilewidth,ycbcrsubsampling[0]); + samplingblocks_ver=TIFFhowmany_32(nrows,ycbcrsubsampling[1]); + samplingrow_samples=_TIFFMultiply64(tif,samplingblocks_hor,samplingblock_samples,module); + samplingrow_size=TIFFhowmany8_64(_TIFFMultiply64(tif,samplingrow_samples,td->td_bitspersample,module)); + return(_TIFFMultiply64(tif,samplingrow_size,samplingblocks_ver,module)); + } + else + return(_TIFFMultiply64(tif,nrows,TIFFTileRowSize64(tif),module)); } -tmsize_t TIFFVTileSize(TIFF *tif, uint32_t nrows) +tmsize_t +TIFFVTileSize(TIFF* tif, uint32 nrows) { - static const char module[] = "TIFFVTileSize"; - uint64_t m; - m = TIFFVTileSize64(tif, nrows); - return _TIFFCastUInt64ToSSize(tif, m, module); + static const char module[] = "TIFFVTileSize"; + uint64 m; + m=TIFFVTileSize64(tif,nrows); + return _TIFFCastUInt64ToSSize(tif, m, module); } /* * Compute the # bytes in a row-aligned tile. */ -uint64_t TIFFTileSize64(TIFF *tif) +uint64 +TIFFTileSize64(TIFF* tif) { - return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength)); + return (TIFFVTileSize64(tif, tif->tif_dir.td_tilelength)); } -tmsize_t TIFFTileSize(TIFF *tif) +tmsize_t +TIFFTileSize(TIFF* tif) { - static const char module[] = "TIFFTileSize"; - uint64_t m; - m = TIFFTileSize64(tif); - return _TIFFCastUInt64ToSSize(tif, m, module); + static const char module[] = "TIFFTileSize"; + uint64 m; + m=TIFFTileSize64(tif); + return _TIFFCastUInt64ToSSize(tif, m, module); } /* @@ -264,21 +268,32 @@ tmsize_t TIFFTileSize(TIFF *tif) * request is <1 then we choose a size according * to certain heuristics. */ -void TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th) +void +TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) { - (*tif->tif_deftilesize)(tif, tw, th); + (*tif->tif_deftilesize)(tif, tw, th); } -void _TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th) +void +_TIFFDefaultTileSize(TIFF* tif, uint32* tw, uint32* th) { - (void)tif; - if (*(int32_t *)tw < 1) - *tw = 256; - if (*(int32_t *)th < 1) - *th = 256; - /* roundup to a multiple of 16 per the spec */ - if (*tw & 0xf) - *tw = TIFFroundup_32(*tw, 16); - if (*th & 0xf) - *th = TIFFroundup_32(*th, 16); + (void) tif; + if (*(int32*) tw < 1) + *tw = 256; + if (*(int32*) th < 1) + *th = 256; + /* roundup to a multiple of 16 per the spec */ + if (*tw & 0xf) + *tw = TIFFroundup_32(*tw, 16); + if (*th & 0xf) + *th = TIFFroundup_32(*th, 16); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_unix.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_unix.c index 34dd53b98..bea1ef780 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_unix.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_unix.c @@ -30,7 +30,7 @@ #include "tif_config.h" #ifdef HAVE_SYS_TYPES_H -#include +# include #endif #include @@ -40,222 +40,215 @@ #include #ifdef HAVE_UNISTD_H -#include +# include #endif #ifdef HAVE_FCNTL_H -#include +# include #endif #ifdef HAVE_IO_H -#include +# include #endif #include "tiffiop.h" + #define TIFF_IO_MAX 2147483647U + typedef union fd_as_handle_union { - int fd; - thandle_t h; + int fd; + thandle_t h; } fd_as_handle_union_t; -static tmsize_t _tiffReadProc(thandle_t fd, void *buf, tmsize_t size) +static tmsize_t +_tiffReadProc(thandle_t fd, void* buf, tmsize_t size) { - fd_as_handle_union_t fdh; - const size_t bytes_total = (size_t)size; - size_t bytes_read; - tmsize_t count = -1; - if ((tmsize_t)bytes_total != size) - { - errno = EINVAL; - return (tmsize_t)-1; - } - fdh.h = fd; - for (bytes_read = 0; bytes_read < bytes_total; bytes_read += count) - { - char *buf_offset = (char *)buf + bytes_read; - size_t io_size = bytes_total - bytes_read; - if (io_size > TIFF_IO_MAX) - io_size = TIFF_IO_MAX; - count = read(fdh.fd, buf_offset, (TIFFIOSize_t)io_size); - if (count <= 0) - break; - } - if (count < 0) - return (tmsize_t)-1; - return (tmsize_t)bytes_read; + fd_as_handle_union_t fdh; + const size_t bytes_total = (size_t) size; + size_t bytes_read; + tmsize_t count = -1; + if ((tmsize_t) bytes_total != size) + { + errno=EINVAL; + return (tmsize_t) -1; + } + fdh.h = fd; + for (bytes_read=0; bytes_read < bytes_total; bytes_read+=count) + { + char *buf_offset = (char *) buf+bytes_read; + size_t io_size = bytes_total-bytes_read; + if (io_size > TIFF_IO_MAX) + io_size = TIFF_IO_MAX; + count=read(fdh.fd, buf_offset, (TIFFIOSize_t) io_size); + if (count <= 0) + break; + } + if (count < 0) + return (tmsize_t)-1; + return (tmsize_t) bytes_read; } -static tmsize_t _tiffWriteProc(thandle_t fd, void *buf, tmsize_t size) +static tmsize_t +_tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) { - fd_as_handle_union_t fdh; - const size_t bytes_total = (size_t)size; - size_t bytes_written; - tmsize_t count = -1; - if ((tmsize_t)bytes_total != size) - { - errno = EINVAL; - return (tmsize_t)-1; - } - fdh.h = fd; - for (bytes_written = 0; bytes_written < bytes_total; bytes_written += count) - { - const char *buf_offset = (char *)buf + bytes_written; - size_t io_size = bytes_total - bytes_written; - if (io_size > TIFF_IO_MAX) - io_size = TIFF_IO_MAX; - count = write(fdh.fd, buf_offset, (TIFFIOSize_t)io_size); - if (count <= 0) - break; - } - if (count < 0) - return (tmsize_t)-1; - return (tmsize_t)bytes_written; - /* return ((tmsize_t) write(fdh.fd, buf, bytes_total)); */ + fd_as_handle_union_t fdh; + const size_t bytes_total = (size_t) size; + size_t bytes_written; + tmsize_t count = -1; + if ((tmsize_t) bytes_total != size) + { + errno=EINVAL; + return (tmsize_t) -1; + } + fdh.h = fd; + for (bytes_written=0; bytes_written < bytes_total; bytes_written+=count) + { + const char *buf_offset = (char *) buf+bytes_written; + size_t io_size = bytes_total-bytes_written; + if (io_size > TIFF_IO_MAX) + io_size = TIFF_IO_MAX; + count=write(fdh.fd, buf_offset, (TIFFIOSize_t) io_size); + if (count <= 0) + break; + } + if (count < 0) + return (tmsize_t)-1; + return (tmsize_t) bytes_written; + /* return ((tmsize_t) write(fdh.fd, buf, bytes_total)); */ } -static uint64_t _tiffSeekProc(thandle_t fd, uint64_t off, int whence) +static uint64 +_tiffSeekProc(thandle_t fd, uint64 off, int whence) { - fd_as_handle_union_t fdh; - _TIFF_off_t off_io = (_TIFF_off_t)off; - if ((uint64_t)off_io != off) - { - errno = EINVAL; - return (uint64_t)-1; /* this is really gross */ - } - fdh.h = fd; - return ((uint64_t)_TIFF_lseek_f(fdh.fd, off_io, whence)); + fd_as_handle_union_t fdh; + _TIFF_off_t off_io = (_TIFF_off_t) off; + if ((uint64) off_io != off) + { + errno=EINVAL; + return (uint64) -1; /* this is really gross */ + } + fdh.h = fd; + return((uint64)_TIFF_lseek_f(fdh.fd,off_io,whence)); } -static int _tiffCloseProc(thandle_t fd) +static int +_tiffCloseProc(thandle_t fd) { - fd_as_handle_union_t fdh; - fdh.h = fd; - return (close(fdh.fd)); + fd_as_handle_union_t fdh; + fdh.h = fd; + return(close(fdh.fd)); } -static uint64_t _tiffSizeProc(thandle_t fd) +static uint64 +_tiffSizeProc(thandle_t fd) { - _TIFF_stat_s sb; - fd_as_handle_union_t fdh; - fdh.h = fd; - if (_TIFF_fstat_f(fdh.fd, &sb) < 0) - return (0); - else - return ((uint64_t)sb.st_size); + _TIFF_stat_s sb; + fd_as_handle_union_t fdh; + fdh.h = fd; + if (_TIFF_fstat_f(fdh.fd,&sb)<0) + return(0); + else + return((uint64)sb.st_size); } #ifdef HAVE_MMAP #include -static int _tiffMapProc(thandle_t fd, void **pbase, toff_t *psize) +static int +_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { - uint64_t size64 = _tiffSizeProc(fd); - tmsize_t sizem = (tmsize_t)size64; - if (size64 && (uint64_t)sizem == size64) - { - fd_as_handle_union_t fdh; - fdh.h = fd; - *pbase = - (void *)mmap(0, (size_t)sizem, PROT_READ, MAP_SHARED, fdh.fd, 0); - if (*pbase != (void *)-1) - { - *psize = (tmsize_t)sizem; - return (1); - } - } - return (0); + uint64 size64 = _tiffSizeProc(fd); + tmsize_t sizem = (tmsize_t)size64; + if (size64 && (uint64)sizem==size64) { + fd_as_handle_union_t fdh; + fdh.h = fd; + *pbase = (void*) + mmap(0, (size_t)sizem, PROT_READ, MAP_SHARED, fdh.fd, 0); + if (*pbase != (void*) -1) { + *psize = (tmsize_t)sizem; + return (1); + } + } + return (0); } -static void _tiffUnmapProc(thandle_t fd, void *base, toff_t size) +static void +_tiffUnmapProc(thandle_t fd, void* base, toff_t size) { - (void)fd; - (void)munmap(base, (off_t)size); + (void) fd; + (void) munmap(base, (off_t) size); } -#else /* !HAVE_MMAP */ -static int _tiffMapProc(thandle_t fd, void **pbase, toff_t *psize) +#else /* !HAVE_MMAP */ +static int +_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { - (void)fd; - (void)pbase; - (void)psize; - return (0); + (void) fd; (void) pbase; (void) psize; + return (0); } -static void _tiffUnmapProc(thandle_t fd, void *base, toff_t size) +static void +_tiffUnmapProc(thandle_t fd, void* base, toff_t size) { - (void)fd; - (void)base; - (void)size; + (void) fd; (void) base; (void) size; } #endif /* !HAVE_MMAP */ /* * Open a TIFF file descriptor for read/writing. */ -TIFF *TIFFFdOpen(int fd, const char *name, const char *mode) +TIFF* +TIFFFdOpen(int fd, const char* name, const char* mode) { - return TIFFFdOpenExt(fd, name, mode, NULL); -} + TIFF* tif; -TIFF *TIFFFdOpenExt(int fd, const char *name, const char *mode, - TIFFOpenOptions *opts) -{ - TIFF *tif; - - fd_as_handle_union_t fdh; - fdh.fd = fd; - tif = TIFFClientOpenExt(name, mode, fdh.h, _tiffReadProc, _tiffWriteProc, - _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, - _tiffMapProc, _tiffUnmapProc, opts); - if (tif) - tif->tif_fd = fd; - return (tif); + fd_as_handle_union_t fdh; + fdh.fd = fd; + tif = TIFFClientOpen(name, mode, + fdh.h, + _tiffReadProc, _tiffWriteProc, + _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, + _tiffMapProc, _tiffUnmapProc); + if (tif) + tif->tif_fd = fd; + return (tif); } /* * Open a TIFF file for read/writing. */ -TIFF *TIFFOpen(const char *name, const char *mode) +TIFF* +TIFFOpen(const char* name, const char* mode) { - return TIFFOpenExt(name, mode, NULL); -} + static const char module[] = "TIFFOpen"; + int m, fd; + TIFF* tif; -TIFF *TIFFOpenExt(const char *name, const char *mode, TIFFOpenOptions *opts) -{ - static const char module[] = "TIFFOpen"; - int m, fd; - TIFF *tif; - - m = _TIFFgetMode(opts, NULL, mode, module); - if (m == -1) - return ((TIFF *)0); + m = _TIFFgetMode(mode, module); + if (m == -1) + return ((TIFF*)0); /* for cygwin and mingw */ #ifdef O_BINARY - m |= O_BINARY; + m |= O_BINARY; #endif - fd = open(name, m, 0666); - if (fd < 0) - { - if (errno > 0 && strerror(errno) != NULL) - { - _TIFFErrorEarly(opts, NULL, module, "%s: %s", name, - strerror(errno)); - } - else - { - _TIFFErrorEarly(opts, NULL, module, "%s: Cannot open", name); - } - return ((TIFF *)0); - } + fd = open(name, m, 0666); + if (fd < 0) { + if (errno > 0 && strerror(errno) != NULL ) { + TIFFErrorExt(0, module, "%s: %s", name, strerror(errno) ); + } else { + TIFFErrorExt(0, module, "%s: Cannot open", name); + } + return ((TIFF *)0); + } - tif = TIFFFdOpenExt((int)fd, name, mode, opts); - if (!tif) - close(fd); - return tif; + tif = TIFFFdOpen((int)fd, name, mode); + if(!tif) + close(fd); + return tif; } #ifdef __WIN32__ @@ -263,108 +256,129 @@ TIFF *TIFFOpenExt(const char *name, const char *mode, TIFFOpenOptions *opts) /* * Open a TIFF file with a Unicode filename, for read/writing. */ -TIFF *TIFFOpenW(const wchar_t *name, const char *mode) +TIFF* +TIFFOpenW(const wchar_t* name, const char* mode) { - return TIFFOpenWExt(name, mode, NULL); -} -TIFF *TIFFOpenWExt(const wchar_t *name, const char *mode, TIFFOpenOptions *opts) -{ - static const char module[] = "TIFFOpenW"; - int m, fd; - int mbsize; - char *mbname; - TIFF *tif; + static const char module[] = "TIFFOpenW"; + int m, fd; + int mbsize; + char *mbname; + TIFF* tif; - m = _TIFFgetMode(opts, NULL, mode, module); - if (m == -1) - return ((TIFF *)0); + m = _TIFFgetMode(mode, module); + if (m == -1) + return ((TIFF*)0); /* for cygwin and mingw */ #ifdef O_BINARY - m |= O_BINARY; + m |= O_BINARY; #endif - fd = _wopen(name, m, 0666); - if (fd < 0) - { - _TIFFErrorEarly(opts, NULL, module, "%ls: Cannot open", name); - return ((TIFF *)0); - } + fd = _wopen(name, m, 0666); + if (fd < 0) { + TIFFErrorExt(0, module, "%ls: Cannot open", name); + return ((TIFF *)0); + } - mbname = NULL; - mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL); - if (mbsize > 0) - { - mbname = _TIFFmalloc(mbsize); - if (!mbname) - { - _TIFFErrorEarly( - opts, NULL, module, - "Can't allocate space for filename conversion buffer"); - return ((TIFF *)0); - } + mbname = NULL; + mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL); + if (mbsize > 0) { + mbname = _TIFFmalloc(mbsize); + if (!mbname) { + TIFFErrorExt(0, module, + "Can't allocate space for filename conversion buffer"); + return ((TIFF*)0); + } - WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize, NULL, NULL); - } + WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize, + NULL, NULL); + } - tif = TIFFFdOpenExt((int)fd, (mbname != NULL) ? mbname : "", mode, - opts); - - _TIFFfree(mbname); - - if (!tif) - close(fd); - return tif; + tif = TIFFFdOpen((int)fd, (mbname != NULL) ? mbname : "", + mode); + + _TIFFfree(mbname); + + if(!tif) + close(fd); + return tif; } #endif -void *_TIFFmalloc(tmsize_t s) +void* +_TIFFmalloc(tmsize_t s) { - if (s == 0) - return ((void *)NULL); + if (s == 0) + return ((void *) NULL); - return (malloc((size_t)s)); + return (malloc((size_t) s)); } -void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz) +void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz) { - if (nmemb == 0 || siz == 0) - return ((void *)NULL); + if( nmemb == 0 || siz == 0 ) + return ((void *) NULL); - return calloc((size_t)nmemb, (size_t)siz); + return calloc((size_t) nmemb, (size_t)siz); } -void _TIFFfree(void *p) { free(p); } - -void *_TIFFrealloc(void *p, tmsize_t s) { return (realloc(p, (size_t)s)); } - -void _TIFFmemset(void *p, int v, tmsize_t c) { memset(p, v, (size_t)c); } - -void _TIFFmemcpy(void *d, const void *s, tmsize_t c) +void +_TIFFfree(void* p) { - memcpy(d, s, (size_t)c); + free(p); } -int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c) +void* +_TIFFrealloc(void* p, tmsize_t s) { - return (memcmp(p1, p2, (size_t)c)); + return (realloc(p, (size_t) s)); } -static void unixWarningHandler(const char *module, const char *fmt, va_list ap) +void +_TIFFmemset(void* p, int v, tmsize_t c) { - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); + memset(p, v, (size_t) c); +} + +void +_TIFFmemcpy(void* d, const void* s, tmsize_t c) +{ + memcpy(d, s, (size_t) c); +} + +int +_TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) +{ + return (memcmp(p1, p2, (size_t) c)); +} + +static void +unixWarningHandler(const char* module, const char* fmt, va_list ap) +{ + if (module != NULL) + fprintf(stderr, "%s: ", module); + fprintf(stderr, "Warning, "); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFwarningHandler = unixWarningHandler; -static void unixErrorHandler(const char *module, const char *fmt, va_list ap) +static void +unixErrorHandler(const char* module, const char* fmt, va_list ap) { - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); + if (module != NULL) + fprintf(stderr, "%s: ", module); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFerrorHandler = unixErrorHandler; + +/* vim: set ts=8 sts=8 sw=8 noet: */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_version.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_version.c index 0b6c9bc00..60875bbf0 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_version.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_version.c @@ -2,27 +2,38 @@ * Copyright (c) 1992-1997 Sam Leffler * Copyright (c) 1992-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #include "tiffiop.h" static const char TIFFVersion[] = TIFFLIB_VERSION_STR; -const char *TIFFGetVersion(void) { return (TIFFVersion); } +const char* +TIFFGetVersion(void) +{ + return (TIFFVersion); +} +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_vms.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_vms.c new file mode 100644 index 000000000..cf4e9f34d --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_vms.c @@ -0,0 +1,609 @@ +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library VMS-specific Routines. + */ + +#include "tiffiop.h" +#include +#include +#if !HAVE_IEEEFP +#include +#endif + +#ifdef VAXC +#define NOSHARE noshare +#else +#define NOSHARE +#endif + +COMPILATION SHOULD FAIL +This file is not yet updated to reflect changes in LibTiff 4.0. If you have +the opportunity to update and test this file, please contact LibTiff folks +for all assistance you may require and contribute the results + +#ifdef __alpha +/* Dummy entry point for backwards compatibility */ +void TIFFModeCCITTFax3(void){} +#endif + +static tsize_t +_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size) +{ + return (read((int) fd, buf, size)); +} + +static tsize_t +_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size) +{ + return (write((int) fd, buf, size)); +} + +static toff_t +_tiffSeekProc(thandle_t fd, toff_t off, int whence) +{ + return ((toff_t) _TIFF_lseek_f((int) fd, (_TIFF_off_t) off, whence)); +} + +static int +_tiffCloseProc(thandle_t fd) +{ + return (close((int) fd)); +} + +#include + +static toff_t +_tiffSizeProc(thandle_t fd) +{ + _TIFF_stat_s sb; + return (toff_t) (_TIFF_fstat_f((int) fd, &sb) < 0 ? 0 : sb.st_size); +} + +#ifdef HAVE_MMAP +#include +#include +#include + +/* + * Table for storing information on current open sections. + * (Should really be a linked list) + */ +#define MAX_MAPPED 100 +static int no_mapped = 0; +static struct { + char *base; + char *top; + unsigned short channel; +} map_table[MAX_MAPPED]; + +/* + * This routine maps a file into a private section. Note that this + * method of accessing a file is by far the fastest under VMS. + * The routine may fail (i.e. return 0) for several reasons, for + * example: + * - There is no more room for storing the info on sections. + * - The process is out of open file quota, channels, ... + * - fd does not describe an opened file. + * - The file is already opened for write access by this process + * or another process + * - There is no free "hole" in virtual memory that fits the + * size of the file + */ +static int +_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) +{ + char name[256]; + struct FAB fab; + unsigned short channel; + char *inadr[2], *retadr[2]; + unsigned long status; + long size; + + if (no_mapped >= MAX_MAPPED) + return(0); + /* + * We cannot use a file descriptor, we + * must open the file once more. + */ + if (getname((int)fd, name, 1) == NULL) + return(0); + /* prepare the FAB for a user file open */ + fab = cc$rms_fab; + fab.fab$l_fop |= FAB$V_UFO; + fab.fab$b_fac = FAB$M_GET; + fab.fab$b_shr = FAB$M_SHRGET; + fab.fab$l_fna = name; + fab.fab$b_fns = strlen(name); + status = sys$open(&fab); /* open file & get channel number */ + if ((status&1) == 0) + return(0); + channel = (unsigned short)fab.fab$l_stv; + inadr[0] = inadr[1] = (char *)0; /* just an address in P0 space */ + /* + * Map the blocks of the file up to + * the EOF block into virtual memory. + */ + size = _tiffSizeProc(fd); + status = sys$crmpsc(inadr, retadr, 0, SEC$M_EXPREG, 0,0,0, channel, + TIFFhowmany(size,512), 0,0,0); ddd + if ((status&1) == 0){ + sys$dassgn(channel); + return(0); + } + *pbase = (tdata_t) retadr[0]; /* starting virtual address */ + /* + * Use the size of the file up to the + * EOF mark for UNIX compatibility. + */ + *psize = (toff_t) size; + /* Record the section in the table */ + map_table[no_mapped].base = retadr[0]; + map_table[no_mapped].top = retadr[1]; + map_table[no_mapped].channel = channel; + no_mapped++; + + return(1); +} + +/* + * This routine unmaps a section from the virtual address space of + * the process, but only if the base was the one returned from a + * call to TIFFMapFileContents. + */ +static void +_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) +{ + char *inadr[2]; + int i, j; + + /* Find the section in the table */ + for (i = 0;i < no_mapped; i++) { + if (map_table[i].base == (char *) base) { + /* Unmap the section */ + inadr[0] = (char *) base; + inadr[1] = map_table[i].top; + sys$deltva(inadr, 0, 0); + sys$dassgn(map_table[i].channel); + /* Remove this section from the list */ + for (j = i+1; j < no_mapped; j++) + map_table[j-1] = map_table[j]; + no_mapped--; + return; + } + } +} +#else /* !HAVE_MMAP */ +static int +_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) +{ + return (0); +} + +static void +_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size) +{ +} +#endif /* !HAVE_MMAP */ + +/* + * Open a TIFF file descriptor for read/writing. + */ +TIFF* +TIFFFdOpen(int fd, const char* name, const char* mode) +{ + TIFF* tif; + + tif = TIFFClientOpen(name, mode, ddd + (thandle_t) fd, + _tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc, + _tiffSizeProc, _tiffMapProc, _tiffUnmapProc); + if (tif) + tif->tif_fd = fd; + return (tif); +} + +/* + * Open a TIFF file for read/writing. + */ +TIFF* +TIFFOpen(const char* name, const char* mode) +{ + static const char module[] = "TIFFOpen"; + int m, fd; + + m = _TIFFgetMode(mode, module); + if (m == -1) + return ((TIFF*)0); + if (m&O_TRUNC){ + /* + * There is a bug in open in VAXC. If you use + * open w/ m=O_RDWR|O_CREAT|O_TRUNC the + * wrong thing happens. On the other hand + * creat does the right thing. + */ + fd = creat((char *) /* bug in stdio.h */ name, 0666, + "alq = 128", "deq = 64", "mbc = 32", + "fop = tef"); + } else if (m&O_RDWR) { + fd = open(name, m, 0666, + "deq = 64", "mbc = 32", "fop = tef", "ctx = stm"); + } else + fd = open(name, m, 0666, "mbc = 32", "ctx = stm"); + if (fd < 0) { + TIFFErrorExt(0, module, "%s: Cannot open", name); + return ((TIFF*)0); + } + return (TIFFFdOpen(fd, name, mode)); +} + +tdata_t +_TIFFmalloc(tsize_t s) +{ + if (s == 0) + return ((void *) NULL); + + return (malloc((size_t) s)); +} + +void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz) +{ + if( nmemb == 0 || siz == 0 ) + return ((void *) NULL); + + return calloc((size_t) nmemb, (size_t)siz); +} + +void +_TIFFfree(tdata_t p) +{ + free(p); +} + +tdata_t +_TIFFrealloc(tdata_t p, tsize_t s) +{ + return (realloc(p, (size_t) s)); +} + +void +_TIFFmemset(tdata_t p, int v, tsize_t c) +{ + memset(p, v, (size_t) c); +} + +void +_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c) +{ + memcpy(d, s, (size_t) c); +} + +int +_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c) +{ + return (memcmp(p1, p2, (size_t) c)); +} + +/* + * On the VAX, we need to make those global, writable pointers + * non-shareable, otherwise they would be made shareable by default. + * On the AXP, this brain damage has been corrected. + * + * I (Karsten Spang, krs@kampsax.dk) have dug around in the GCC + * manual and the GAS code and have come up with the following + * construct, but I don't have GCC on my VAX, so it is untested. + * Please tell me if it does not work. + */ + +static void +vmsWarningHandler(const char* module, const char* fmt, va_list ap) +{ + if (module != NULL) + fprintf(stderr, "%s: ", module); + fprintf(stderr, "Warning, "); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ".\n"); +} + +NOSHARE TIFFErrorHandler _TIFFwarningHandler = vmsWarningHandler +#if defined(VAX) && defined(__GNUC__) +asm("_$$PsectAttributes_NOSHR$$_TIFFwarningHandler") +#endif +; + +static void +vmsErrorHandler(const char* module, const char* fmt, va_list ap) +{ + if (module != NULL) + fprintf(stderr, "%s: ", module); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ".\n"); +} + +NOSHARE TIFFErrorHandler _TIFFerrorHandler = vmsErrorHandler +#if defined(VAX) && defined(__GNUC__) +asm("_$$PsectAttributes_NOSHR$$_TIFFerrorHandler") +#endif +; + + +#if !HAVE_IEEEFP +/* IEEE floting point handling */ + +typedef struct ieeedouble { + unsigned long mant2; /* fix NDR: full 8-byte swap */ + unsigned long mant : 20, + exp : 11, + sign : 1; +} ieeedouble; +typedef struct ieeefloat { + unsigned long mant : 23, + exp : 8, + sign : 1; +} ieeefloat; + +/* + * NB: These are D_FLOAT's, not G_FLOAT's. A G_FLOAT is + * simply a reverse-IEEE float/double. + */ + +typedef struct { + unsigned long mant1 : 7, + exp : 8, + sign : 1, + mant2 : 16, + mant3 : 16, + mant4 : 16; +} nativedouble; +typedef struct { + unsigned long mant1 : 7, + exp : 8, + sign : 1, + mant2 : 16; +} nativefloat; + +typedef union { + ieeedouble ieee; + nativedouble native; + char b[8]; + uint32 l[2]; + double d; +} double_t; + +typedef union { + ieeefloat ieee; + nativefloat native; + char b[4]; + uint32 l; + float f; +} float_t; + +#if defined(VAXC) || defined(DECC) +#pragma inline(ieeetod,dtoieee) +#endif + +/* + * Convert an IEEE double precision number to native double precision. + * The source is contained in two longwords, the second holding the sign, + * exponent and the higher order bits of the mantissa, and the first + * holding the rest of the mantissa as follows: + * (Note: It is assumed that the number has been eight-byte swapped to + * LSB first.) + * + * First longword: + * 32 least significant bits of mantissa + * Second longword: + * 0-19: 20 most significant bits of mantissa + * 20-30: exponent + * 31: sign + * The exponent is stored as excess 1023. + * The most significant bit of the mantissa is implied 1, and not stored. + * If the exponent and mantissa are zero, the number is zero. + * If the exponent is 0 (i.e. -1023) and the mantissa is non-zero, it is an + * unnormalized number with the most significant bit NOT implied. + * If the exponent is 2047, the number is invalid, in case the mantissa is zero, + * this means overflow (+/- depending of the sign bit), otherwise + * it simply means invalid number. + * + * If the number is too large for the machine or was specified as overflow, + * +/-HUGE_VAL is returned. + */ +INLINE static void +ieeetod(double *dp) +{ + double_t source; + long sign,exp,mant; + double dmant; + + source.ieee = ((double_t*)dp)->ieee; + sign = source.ieee.sign; + exp = source.ieee.exp; + mant = source.ieee.mant; + + if (exp == 2047) { + if (mant) /* Not a Number (NAN) */ + *dp = HUGE_VAL; + else /* +/- infinity */ + *dp = (sign ? -HUGE_VAL : HUGE_VAL); + return; + } + if (!exp) { + if (!(mant || source.ieee.mant2)) { /* zero */ + *dp=0; + return; + } else { /* Unnormalized number */ + /* NB: not -1023, the 1 bit is not implied */ + exp= -1022; + } + } else { + mant |= 1<<20; + exp -= 1023; + } + dmant = (((double) mant) + + ((double) source.ieee.mant2) / (((double) (1<<16)) * + ((double) (1<<16)))) / (double) (1<<20); + dmant = ldexp(dmant, exp); + if (sign) + dmant= -dmant; + *dp = dmant; +} + +INLINE static void +dtoieee(double *dp) +{ + double_t num; + double x; + int exp; + + num.d = *dp; + if (!num.d) { /* Zero is just binary all zeros */ + num.l[0] = num.l[1] = 0; + return; + } + + if (num.d < 0) { /* Sign is encoded separately */ + num.d = -num.d; + num.ieee.sign = 1; + } else { + num.ieee.sign = 0; + } + + /* Now separate the absolute value into mantissa and exponent */ + x = frexp(num.d, &exp); + + /* + * Handle cases where the value is outside the + * range for IEEE floating point numbers. + * (Overflow cannot happen on a VAX, but underflow + * can happen for G float.) + */ + if (exp < -1022) { /* Unnormalized number */ + x = ldexp(x, -1023-exp); + exp = 0; + } else if (exp > 1023) { /* +/- infinity */ + x = 0; + exp = 2047; + } else { /* Get rid of most significant bit */ + x *= 2; + x -= 1; + exp += 1022; /* fix NDR: 1.0 -> x=0.5, exp=1 -> ieee.exp = 1023 */ + } + num.ieee.exp = exp; + + x *= (double) (1<<20); + num.ieee.mant = (long) x; + x -= (double) num.ieee.mant; + num.ieee.mant2 = (long) (x*((double) (1<<16)*(double) (1<<16))); + + if (!(num.ieee.mant || num.ieee.exp || num.ieee.mant2)) { + /* Avoid negative zero */ + num.ieee.sign = 0; + } + ((double_t*)dp)->ieee = num.ieee; +} + +/* + * Beware, these do not handle over/under-flow + * during conversion from ieee to native format. + */ +#define NATIVE2IEEEFLOAT(fp) { \ + float_t t; \ + if (t.ieee.exp = (fp)->native.exp) \ + t.ieee.exp += -129 + 127; \ + t.ieee.sign = (fp)->native.sign; \ + t.ieee.mant = ((fp)->native.mant1<<16)|(fp)->native.mant2; \ + *(fp) = t; \ +} +#define IEEEFLOAT2NATIVE(fp) { \ + float_t t; int v = (fp)->ieee.exp; \ + if (v) v += -127 + 129; /* alter bias of exponent */\ + t.native.exp = v; /* implicit truncation of exponent */\ + t.native.sign = (fp)->ieee.sign; \ + v = (fp)->ieee.mant; \ + t.native.mant1 = v >> 16; \ + t.native.mant2 = v;\ + *(fp) = t; \ +} + +#define IEEEDOUBLE2NATIVE(dp) ieeetod(dp) + +#define NATIVE2IEEEDOUBLE(dp) dtoieee(dp) + + +/* + * These unions are used during floating point + * conversions. The above macros define the + * conversion operations. + */ +void +TIFFCvtIEEEFloatToNative(TIFF* tif, u_int n, float* f) +{ + float_t* fp = (float_t*) f; + + while (n-- > 0) { + IEEEFLOAT2NATIVE(fp); + fp++; + } +} + +void +TIFFCvtNativeToIEEEFloat(TIFF* tif, u_int n, float* f) +{ + float_t* fp = (float_t*) f; + + while (n-- > 0) { + NATIVE2IEEEFLOAT(fp); + fp++; + } +} +void +TIFFCvtIEEEDoubleToNative(TIFF* tif, u_int n, double* f) +{ + double_t* fp = (double_t*) f; + + while (n-- > 0) { + IEEEDOUBLE2NATIVE(fp); + fp++; + } +} + +void +TIFFCvtNativeToIEEEDouble(TIFF* tif, u_int n, double* f) +{ + double_t* fp = (double_t*) f; + + while (n-- > 0) { + NATIVE2IEEEDOUBLE(fp); + fp++; + } +} +#endif +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_warning.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_warning.c index 5468de55f..c482785c2 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_warning.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_warning.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -29,77 +29,59 @@ TIFFErrorHandlerExt _TIFFwarningHandlerExt = NULL; -TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler handler) +TIFFErrorHandler +TIFFSetWarningHandler(TIFFErrorHandler handler) { - TIFFErrorHandler prev = _TIFFwarningHandler; - _TIFFwarningHandler = handler; - return (prev); + TIFFErrorHandler prev = _TIFFwarningHandler; + _TIFFwarningHandler = handler; + return (prev); } -TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler) +TIFFErrorHandlerExt +TIFFSetWarningHandlerExt(TIFFErrorHandlerExt handler) { - TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt; - _TIFFwarningHandlerExt = handler; - return (prev); + TIFFErrorHandlerExt prev = _TIFFwarningHandlerExt; + _TIFFwarningHandlerExt = handler; + return (prev); } -void TIFFWarning(const char *module, const char *fmt, ...) +void +TIFFWarning(const char* module, const char* fmt, ...) { - va_list ap; - if (_TIFFwarningHandler) - { - va_start(ap, fmt); - (*_TIFFwarningHandler)(module, fmt, ap); - va_end(ap); - } - if (_TIFFwarningHandlerExt) - { - va_start(ap, fmt); - (*_TIFFwarningHandlerExt)(0, module, fmt, ap); - va_end(ap); - } + va_list ap; + if (_TIFFwarningHandler) { + va_start(ap, fmt); + (*_TIFFwarningHandler)(module, fmt, ap); + va_end(ap); + } + if (_TIFFwarningHandlerExt) { + va_start(ap, fmt); + (*_TIFFwarningHandlerExt)(0, module, fmt, ap); + va_end(ap); + } } -void TIFFWarningExt(thandle_t fd, const char *module, const char *fmt, ...) +void +TIFFWarningExt(thandle_t fd, const char* module, const char* fmt, ...) { - va_list ap; - if (_TIFFwarningHandler) - { - va_start(ap, fmt); - (*_TIFFwarningHandler)(module, fmt, ap); - va_end(ap); - } - if (_TIFFwarningHandlerExt) - { - va_start(ap, fmt); - (*_TIFFwarningHandlerExt)(fd, module, fmt, ap); - va_end(ap); - } + va_list ap; + if (_TIFFwarningHandler) { + va_start(ap, fmt); + (*_TIFFwarningHandler)(module, fmt, ap); + va_end(ap); + } + if (_TIFFwarningHandlerExt) { + va_start(ap, fmt); + (*_TIFFwarningHandlerExt)(fd, module, fmt, ap); + va_end(ap); + } } -void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt, ...) -{ - va_list ap; - if (tif && tif->tif_warnhandler) - { - va_start(ap, fmt); - int stop = (*tif->tif_warnhandler)(tif, tif->tif_warnhandler_user_data, - module, fmt, ap); - va_end(ap); - if (stop) - return; - } - if (_TIFFwarningHandler) - { - va_start(ap, fmt); - (*_TIFFwarningHandler)(module, fmt, ap); - va_end(ap); - } - if (_TIFFwarningHandlerExt) - { - va_start(ap, fmt); - (*_TIFFwarningHandlerExt)(tif ? tif->tif_clientdata : 0, module, fmt, - ap); - va_end(ap); - } -} + +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_webp.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_webp.c index 07db7cce2..b7eac3793 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_webp.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_webp.c @@ -1,26 +1,26 @@ /* - * Copyright (c) 2018, Mapbox - * Author: - * - * 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. - */ +* Copyright (c) 2018, Mapbox +* Author: +* +* 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 WEBP_SUPPORT @@ -34,7 +34,6 @@ #include "webp/decode.h" #include "webp/encode.h" -#include #include #define LSTATE_INIT_DECODE 0x01 @@ -43,758 +42,661 @@ * State block for each open TIFF * file using WEBP compression/decompression. */ -typedef struct -{ - 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_t *pBuffer; /* buffer to hold raw data on encoding */ - unsigned int buffer_offset; /* current offset into the buffer */ - unsigned int buffer_size; - - WebPIDecoder *psDecoder; /* WebPIDecoder */ - WebPDecBuffer sDecBuffer; /* Decoder buffer */ - int last_y; /* Last row decoded */ - - int state; /* state flags */ - - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ +typedef struct { + uint16 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 */ + unsigned int buffer_offset; /* current offset into the buffer */ + unsigned int buffer_size; + + WebPIDecoder* psDecoder; /* WebPIDecoder */ + WebPDecBuffer sDecBuffer; /* Decoder buffer */ + int last_y; /* Last row decoded */ + + int state; /* state flags */ + + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ } WebPState; -#define LState(tif) ((WebPState *)(tif)->tif_data) -#define DecoderState(tif) LState(tif) -#define EncoderState(tif) LState(tif) +#define LState(tif) ((WebPState*) (tif)->tif_data) +#define DecoderState(tif) LState(tif) +#define EncoderState(tif) LState(tif) -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 TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); +static int TWebPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); -static int TWebPDatasetWriter(const uint8_t *data, size_t data_size, - const WebPPicture *const picture) +static +int TWebPDatasetWriter(const uint8* data, size_t data_size, + const WebPPicture* const picture) { - static const char module[] = "TWebPDatasetWriter"; - TIFF *tif = (TIFF *)(picture->custom_ptr); - - if ((tif->tif_rawcc + (tmsize_t)data_size) > tif->tif_rawdatasize) - { - TIFFErrorExtR( - tif, module, "Buffer too small by %" TIFF_SIZE_FORMAT " bytes.", - (size_t)(tif->tif_rawcc + data_size - tif->tif_rawdatasize)); - return 0; - } - else - { - _TIFFmemcpy(tif->tif_rawcp, data, data_size); - tif->tif_rawcc += data_size; - tif->tif_rawcp += data_size; - return 1; - } + static const char module[] = "TWebPDatasetWriter"; + TIFF* tif = (TIFF*)(picture->custom_ptr); + + if ( (tif->tif_rawcc + (tmsize_t)data_size) > tif->tif_rawdatasize ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Buffer too small by " TIFF_SIZE_FORMAT " bytes.", + (size_t) (tif->tif_rawcc + data_size - tif->tif_rawdatasize)); + return 0; + } else { + _TIFFmemcpy(tif->tif_rawcp, data, data_size); + tif->tif_rawcc += data_size; + tif->tif_rawcp += data_size; + return 1; + } } /* * Encode a chunk of pixels. */ -static int TWebPEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +TWebPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "TWebPEncode"; - WebPState *sp = EncoderState(tif); - (void)s; + static const char module[] = "TWebPEncode"; + WebPState *sp = EncoderState(tif); + (void) s; - assert(sp != NULL); - assert(sp->state == LSTATE_INIT_ENCODE); + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_ENCODE); + + if( (uint64)sp->buffer_offset + + (uint64)cc > sp->buffer_size ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Too many bytes to be written"); + return 0; + } - if ((uint64_t)sp->buffer_offset + (uint64_t)cc > sp->buffer_size) - { - TIFFErrorExtR(tif, module, "Too many bytes to be written"); - return 0; - } + memcpy(sp->pBuffer + sp->buffer_offset, + bp, cc); + sp->buffer_offset += (unsigned)cc; - memcpy(sp->pBuffer + sp->buffer_offset, bp, cc); - sp->buffer_offset += (unsigned)cc; - - return 1; + return 1; + } -static int TWebPDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) +static int +TWebPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - static const char module[] = "WebPDecode"; - VP8StatusCode status = VP8_STATUS_OK; - WebPState *sp = DecoderState(tif); - uint32_t segment_width, segment_height; - bool decode_whole_strile = false; + static const char module[] = "WebPDecode"; + VP8StatusCode status = VP8_STATUS_OK; + WebPState *sp = DecoderState(tif); + (void) s; - (void)s; + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_DECODE); + + if (occ % sp->sDecBuffer.u.RGBA.stride) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Fractional scanlines cannot be read"); + return 0; + } - assert(sp != NULL); - assert(sp->state == LSTATE_INIT_DECODE); + status = WebPIAppend(sp->psDecoder, tif->tif_rawcp, tif->tif_rawcc); - if (sp->psDecoder == NULL) - { - TIFFDirectory *td = &tif->tif_dir; - uint32_t buffer_size; - - if (isTiled(tif)) - { - segment_width = td->td_tilewidth; - segment_height = td->td_tilelength; - } - else - { - segment_width = td->td_imagewidth; - segment_height = td->td_imagelength - tif->tif_row; - if (segment_height > td->td_rowsperstrip) - segment_height = td->td_rowsperstrip; - } - - buffer_size = segment_width * segment_height * sp->nSamples; - if (occ == (tmsize_t)buffer_size) - { - /* If decoding the whole strip/tile, we can directly use the */ - /* output buffer */ - decode_whole_strile = true; - } - else if (sp->pBuffer == NULL || buffer_size > sp->buffer_size) - { - if (sp->pBuffer != NULL) - { - _TIFFfreeExt(tif, sp->pBuffer); - sp->pBuffer = NULL; - } - - sp->pBuffer = _TIFFmallocExt(tif, buffer_size); - if (!sp->pBuffer) - { - TIFFErrorExtR(tif, module, "Cannot allocate buffer"); - return 0; - } - sp->buffer_size = buffer_size; - } - - sp->last_y = 0; - - WebPInitDecBuffer(&sp->sDecBuffer); - - sp->sDecBuffer.is_external_memory = 1; - sp->sDecBuffer.width = segment_width; - sp->sDecBuffer.height = segment_height; - sp->sDecBuffer.u.RGBA.rgba = decode_whole_strile ? op : sp->pBuffer; - sp->sDecBuffer.u.RGBA.stride = segment_width * sp->nSamples; - sp->sDecBuffer.u.RGBA.size = buffer_size; - - if (sp->nSamples > 3) - { - sp->sDecBuffer.colorspace = MODE_RGBA; - } - else - { - sp->sDecBuffer.colorspace = MODE_RGB; - } - - sp->psDecoder = WebPINewDecoder(&sp->sDecBuffer); - - if (sp->psDecoder == NULL) - { - TIFFErrorExtR(tif, module, "Unable to allocate WebP decoder."); - return 0; - } + if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) { + if (status == VP8_STATUS_INVALID_PARAM) { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid parameter used."); + } else if (status == VP8_STATUS_OUT_OF_MEMORY) { + TIFFErrorExt(tif->tif_clientdata, module, + "Out of memory."); + } else { + TIFFErrorExt(tif->tif_clientdata, module, + "Unrecognized error."); } + return 0; + } else { + int current_y, stride; + uint8* buf; - if (occ % sp->sDecBuffer.u.RGBA.stride) - { - TIFFErrorExtR(tif, module, "Fractional scanlines cannot be read"); - return 0; - } - - status = WebPIAppend(sp->psDecoder, tif->tif_rawcp, tif->tif_rawcc); - - if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) - { - if (status == VP8_STATUS_INVALID_PARAM) - { - TIFFErrorExtR(tif, module, "Invalid parameter used."); - } - else if (status == VP8_STATUS_OUT_OF_MEMORY) - { - TIFFErrorExtR(tif, module, "Out of memory."); - } - else - { - TIFFErrorExtR(tif, module, "Unrecognized error."); - } - return 0; - } - else - { - int current_y, stride; - uint8_t *buf; - - /* Returns the RGB/A image decoded so far */ - buf = WebPIDecGetRGB(sp->psDecoder, ¤t_y, NULL, NULL, &stride); - - if ((buf != NULL) && - (occ <= (tmsize_t)stride * (current_y - sp->last_y))) - { - const int numberOfExpectedLines = - (int)(occ / sp->sDecBuffer.u.RGBA.stride); - if (decode_whole_strile) - { - if (current_y != numberOfExpectedLines) - { - TIFFErrorExtR(tif, module, - "Unable to decode WebP data: less lines than " - "expected."); - return 0; - } - } - else - { - memcpy(op, buf + (sp->last_y * stride), occ); - } - - tif->tif_rawcp += tif->tif_rawcc; - tif->tif_rawcc = 0; - sp->last_y += numberOfExpectedLines; - - if (decode_whole_strile) - { - /* We can now free the decoder as we're completely done */ - if (sp->psDecoder != NULL) - { - WebPIDelete(sp->psDecoder); - WebPFreeDecBuffer(&sp->sDecBuffer); - sp->psDecoder = NULL; - } - } - return 1; - } - else - { - TIFFErrorExtR(tif, module, "Unable to decode WebP data."); - return 0; - } + /* Returns the RGB/A image decoded so far */ + buf = WebPIDecGetRGB(sp->psDecoder, ¤t_y, NULL, NULL, &stride); + + if ((buf != NULL) && + (occ <= stride * (current_y - sp->last_y))) { + memcpy(op, + buf + (sp->last_y * stride), + occ); + + tif->tif_rawcp += tif->tif_rawcc; + tif->tif_rawcc = 0; + sp->last_y += occ / sp->sDecBuffer.u.RGBA.stride; + return 1; + } else { + TIFFErrorExt(tif->tif_clientdata, module, "Unable to decode WebP data."); + return 0; } + } } -static int TWebPFixupTags(TIFF *tif) +static int +TWebPFixupTags(TIFF* tif) { - (void)tif; - if (tif->tif_dir.td_planarconfig != PLANARCONFIG_CONTIG) - { - static const char module[] = "TWebPFixupTags"; - TIFFErrorExtR(tif, module, - "TIFF WEBP requires data to be stored contiguously in " - "RGB e.g. RGBRGBRGB " + (void) tif; + if (tif->tif_dir.td_planarconfig != PLANARCONFIG_CONTIG) { + static const char module[] = "TWebPFixupTags"; + TIFFErrorExt(tif->tif_clientdata, module, + "TIFF WEBP requires data to be stored contiguously in RGB e.g. RGBRGBRGB " #if WEBP_ENCODER_ABI_VERSION >= 0x0100 - "or RGBARGBARGBA" + "or RGBARGBARGBA" #endif - ); - return 0; - } - return 1; + ); + return 0; + } + return 1; } -static int TWebPSetupDecode(TIFF *tif) +static int +TWebPSetupDecode(TIFF* tif) { - static const char module[] = "WebPSetupDecode"; - uint16_t nBitsPerSample = tif->tif_dir.td_bitspersample; - uint16_t sampleFormat = tif->tif_dir.td_sampleformat; + static const char module[] = "WebPSetupDecode"; + uint16 nBitsPerSample = tif->tif_dir.td_bitspersample; + uint16 sampleFormat = tif->tif_dir.td_sampleformat; - WebPState *sp = DecoderState(tif); - assert(sp != NULL); + WebPState* sp = DecoderState(tif); + assert(sp != NULL); - sp->nSamples = tif->tif_dir.td_samplesperpixel; + sp->nSamples = tif->tif_dir.td_samplesperpixel; - /* check band count */ - if (sp->nSamples != 3 + /* check band count */ + if ( sp->nSamples != 3 #if WEBP_ENCODER_ABI_VERSION >= 0x0100 - && sp->nSamples != 4 + && sp->nSamples != 4 #endif - ) - { - TIFFErrorExtR(tif, module, - "WEBP driver doesn't support %d bands. Must be 3 (RGB) " -#if WEBP_ENCODER_ABI_VERSION >= 0x0100 - "or 4 (RGBA) " -#endif - "bands.", - sp->nSamples); - return 0; - } + ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "WEBP driver doesn't support %d bands. Must be 3 (RGB) " + #if WEBP_ENCODER_ABI_VERSION >= 0x0100 + "or 4 (RGBA) " + #endif + "bands.", + sp->nSamples ); + return 0; + } - /* check bits per sample and data type */ - if ((nBitsPerSample != 8) && (sampleFormat != 1)) - { - TIFFErrorExtR(tif, module, "WEBP driver requires 8 bit unsigned data"); - return 0; - } + /* check bits per sample and data type */ + if ((nBitsPerSample != 8) && (sampleFormat != 1)) { + TIFFErrorExt(tif->tif_clientdata, module, + "WEBP driver requires 8 bit unsigned data"); + return 0; + } + + /* if we were last encoding, terminate this mode */ + if (sp->state & LSTATE_INIT_ENCODE) { + WebPPictureFree(&sp->sPicture); + if (sp->pBuffer != NULL) { + _TIFFfree(sp->pBuffer); + sp->pBuffer = NULL; + } + sp->buffer_offset = 0; + sp->state = 0; + } - /* if we were last encoding, terminate this mode */ - if (sp->state & LSTATE_INIT_ENCODE) - { - WebPPictureFree(&sp->sPicture); - if (sp->pBuffer != NULL) - { - _TIFFfreeExt(tif, sp->pBuffer); - sp->pBuffer = NULL; - } - sp->buffer_offset = 0; - sp->state = 0; - } + sp->state |= LSTATE_INIT_DECODE; - sp->state |= LSTATE_INIT_DECODE; - - return 1; + return 1; } /* - * Setup state for decoding a strip. - */ -static int TWebPPreDecode(TIFF *tif, uint16_t s) +* Setup state for decoding a strip. +*/ +static int +TWebPPreDecode(TIFF* tif, uint16 s) { - static const char module[] = "TWebPPreDecode"; - uint32_t segment_width, segment_height; - WebPState *sp = DecoderState(tif); - TIFFDirectory *td = &tif->tif_dir; - (void)s; - assert(sp != NULL); + static const char module[] = "TWebPPreDecode"; + uint32 segment_width, segment_height; + WebPState* sp = DecoderState(tif); + TIFFDirectory* td = &tif->tif_dir; + (void) s; + assert(sp != NULL); + + if (isTiled(tif)) { + segment_width = td->td_tilewidth; + segment_height = td->td_tilelength; + } else { + segment_width = td->td_imagewidth; + segment_height = td->td_imagelength - tif->tif_row; + if (segment_height > td->td_rowsperstrip) + segment_height = td->td_rowsperstrip; + } - if (isTiled(tif)) - { - segment_width = td->td_tilewidth; - segment_height = td->td_tilelength; - } - else - { - segment_width = td->td_imagewidth; - segment_height = td->td_imagelength - tif->tif_row; - if (segment_height > td->td_rowsperstrip) - segment_height = td->td_rowsperstrip; - } + if( segment_width > 16383 || segment_height > 16383 ) { + TIFFErrorExt(tif->tif_clientdata, module, + "WEBP maximum image dimensions are 16383 x 16383."); + return 0; + } - if (segment_width > 16383 || segment_height > 16383) - { - TIFFErrorExtR(tif, module, - "WEBP maximum image dimensions are 16383 x 16383."); - return 0; - } + if( (sp->state & LSTATE_INIT_DECODE) == 0 ) + tif->tif_setupdecode(tif); + + if (sp->psDecoder != NULL) { + WebPIDelete(sp->psDecoder); + WebPFreeDecBuffer(&sp->sDecBuffer); + sp->psDecoder = NULL; + } - if ((sp->state & LSTATE_INIT_DECODE) == 0) - tif->tif_setupdecode(tif); - - if (sp->psDecoder != NULL) - { - WebPIDelete(sp->psDecoder); - WebPFreeDecBuffer(&sp->sDecBuffer); - sp->psDecoder = NULL; - } - - return 1; + sp->last_y = 0; + + WebPInitDecBuffer(&sp->sDecBuffer); + + sp->sDecBuffer.is_external_memory = 0; + sp->sDecBuffer.width = segment_width; + sp->sDecBuffer.height = segment_height; + sp->sDecBuffer.u.RGBA.stride = segment_width * sp->nSamples; + sp->sDecBuffer.u.RGBA.size = segment_width * sp->nSamples * segment_height; + + if (sp->nSamples > 3) { + sp->sDecBuffer.colorspace = MODE_RGBA; + } else { + sp->sDecBuffer.colorspace = MODE_RGB; + } + + sp->psDecoder = WebPINewDecoder(&sp->sDecBuffer); + + if (sp->psDecoder == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, + "Unable to allocate WebP decoder."); + return 0; + } + + return 1; } -static int TWebPSetupEncode(TIFF *tif) +static int +TWebPSetupEncode(TIFF* tif) { - static const char module[] = "WebPSetupEncode"; - uint16_t nBitsPerSample = tif->tif_dir.td_bitspersample; - uint16_t sampleFormat = tif->tif_dir.td_sampleformat; + static const char module[] = "WebPSetupEncode"; + uint16 nBitsPerSample = tif->tif_dir.td_bitspersample; + uint16 sampleFormat = tif->tif_dir.td_sampleformat; + + WebPState* sp = EncoderState(tif); + assert(sp != NULL); - WebPState *sp = EncoderState(tif); - assert(sp != NULL); + sp->nSamples = tif->tif_dir.td_samplesperpixel; - sp->nSamples = tif->tif_dir.td_samplesperpixel; - - /* check band count */ - if (sp->nSamples != 3 + /* check band count */ + if ( sp->nSamples != 3 #if WEBP_ENCODER_ABI_VERSION >= 0x0100 - && sp->nSamples != 4 + && sp->nSamples != 4 #endif - ) - { - TIFFErrorExtR(tif, module, - "WEBP driver doesn't support %d bands. Must be 3 (RGB) " + ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "WEBP driver doesn't support %d bands. Must be 3 (RGB) " #if WEBP_ENCODER_ABI_VERSION >= 0x0100 - "or 4 (RGBA) " + "or 4 (RGBA) " #endif - "bands.", - sp->nSamples); - return 0; - } + "bands.", + sp->nSamples ); + return 0; + } + + /* check bits per sample and data type */ + if ((nBitsPerSample != 8) || (sampleFormat != SAMPLEFORMAT_UINT)) { + TIFFErrorExt(tif->tif_clientdata, module, + "WEBP driver requires 8 bit unsigned data"); + return 0; + } + + if (sp->state & LSTATE_INIT_DECODE) { + WebPIDelete(sp->psDecoder); + WebPFreeDecBuffer(&sp->sDecBuffer); + sp->psDecoder = NULL; + sp->last_y = 0; + sp->state = 0; + } - /* check bits per sample and data type */ - if ((nBitsPerSample != 8) || (sampleFormat != SAMPLEFORMAT_UINT)) - { - TIFFErrorExtR(tif, module, "WEBP driver requires 8 bit unsigned data"); - return 0; - } + sp->state |= LSTATE_INIT_ENCODE; - if (sp->state & LSTATE_INIT_DECODE) - { - WebPIDelete(sp->psDecoder); - WebPFreeDecBuffer(&sp->sDecBuffer); - sp->psDecoder = NULL; - sp->last_y = 0; - sp->state = 0; - } + if (!WebPPictureInit(&sp->sPicture)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error initializing WebP picture."); + return 0; + } - sp->state |= LSTATE_INIT_ENCODE; + if (!WebPConfigInitInternal(&sp->sEncoderConfig, WEBP_PRESET_DEFAULT, + (float)sp->quality_level, + WEBP_ENCODER_ABI_VERSION)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error creating WebP encoder configuration."); + return 0; + } - if (!WebPPictureInit(&sp->sPicture)) - { - TIFFErrorExtR(tif, module, "Error initializing WebP picture."); - return 0; - } - - if (!WebPConfigInitInternal(&sp->sEncoderConfig, WEBP_PRESET_DEFAULT, - (float)sp->quality_level, - WEBP_ENCODER_ABI_VERSION)) - { - TIFFErrorExtR(tif, module, - "Error creating WebP encoder configuration."); - return 0; - } - -// WebPConfigInitInternal above sets lossless to false -#if WEBP_ENCODER_ABI_VERSION >= 0x0100 + // WebPConfigInitInternal above sets lossless to false + #if WEBP_ENCODER_ABI_VERSION >= 0x0100 sp->sEncoderConfig.lossless = sp->lossless; - if (sp->lossless) - { - sp->sPicture.use_argb = 1; + if (sp->lossless) { + sp->sPicture.use_argb = 1; } -#endif + #endif - if (!WebPValidateConfig(&sp->sEncoderConfig)) - { - TIFFErrorExtR(tif, module, "Error with WebP encoder configuration."); - return 0; - } + if (!WebPValidateConfig(&sp->sEncoderConfig)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error with WebP encoder configuration."); + return 0; + } - return 1; + return 1; } /* - * Reset encoding state at the start of a strip. - */ -static int TWebPPreEncode(TIFF *tif, uint16_t s) +* Reset encoding state at the start of a strip. +*/ +static int +TWebPPreEncode(TIFF* tif, uint16 s) { - static const char module[] = "TWebPPreEncode"; - uint32_t segment_width, segment_height; - WebPState *sp = EncoderState(tif); - TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "TWebPPreEncode"; + uint32 segment_width, segment_height; + WebPState *sp = EncoderState(tif); + TIFFDirectory* td = &tif->tif_dir; - (void)s; + (void) s; - assert(sp != NULL); - if (sp->state != LSTATE_INIT_ENCODE) - tif->tif_setupencode(tif); + assert(sp != NULL); + if( sp->state != LSTATE_INIT_ENCODE ) + tif->tif_setupencode(tif); - /* - * Set encoding parameters for this strip/tile. - */ - if (isTiled(tif)) - { - segment_width = td->td_tilewidth; - segment_height = td->td_tilelength; - } - else - { - segment_width = td->td_imagewidth; - segment_height = td->td_imagelength - tif->tif_row; - if (segment_height > td->td_rowsperstrip) - segment_height = td->td_rowsperstrip; - } + /* + * Set encoding parameters for this strip/tile. + */ + if (isTiled(tif)) { + segment_width = td->td_tilewidth; + segment_height = td->td_tilelength; + } else { + segment_width = td->td_imagewidth; + segment_height = td->td_imagelength - tif->tif_row; + if (segment_height > td->td_rowsperstrip) + segment_height = td->td_rowsperstrip; + } - if (segment_width > 16383 || segment_height > 16383) - { - TIFFErrorExtR(tif, module, - "WEBP maximum image dimensions are 16383 x 16383."); - return 0; - } + if( segment_width > 16383 || segment_height > 16383 ) { + TIFFErrorExt(tif->tif_clientdata, module, + "WEBP maximum image dimensions are 16383 x 16383."); + return 0; + } - /* set up buffer for raw data */ - /* given above check and that nSamples <= 4, buffer_size is <= 1 GB */ - sp->buffer_size = segment_width * segment_height * sp->nSamples; + /* set up buffer for raw data */ + /* given above check and that nSamples <= 4, buffer_size is <= 1 GB */ + sp->buffer_size = segment_width * segment_height * sp->nSamples; + + if (sp->pBuffer != NULL) { + _TIFFfree(sp->pBuffer); + sp->pBuffer = NULL; + } + + sp->pBuffer = _TIFFmalloc(sp->buffer_size); + if( !sp->pBuffer) { + TIFFErrorExt(tif->tif_clientdata, module, "Cannot allocate buffer"); + return 0; + } + sp->buffer_offset = 0; - if (sp->pBuffer != NULL) - { - _TIFFfreeExt(tif, sp->pBuffer); - sp->pBuffer = NULL; - } + sp->sPicture.width = segment_width; + sp->sPicture.height = segment_height; + sp->sPicture.writer = TWebPDatasetWriter; + sp->sPicture.custom_ptr = tif; - sp->pBuffer = _TIFFmallocExt(tif, sp->buffer_size); - if (!sp->pBuffer) - { - TIFFErrorExtR(tif, module, "Cannot allocate buffer"); - return 0; - } - sp->buffer_offset = 0; - - sp->sPicture.width = segment_width; - sp->sPicture.height = segment_height; - sp->sPicture.writer = TWebPDatasetWriter; - sp->sPicture.custom_ptr = tif; - - return 1; + return 1; } /* - * Finish off an encoded strip by flushing it. - */ -static int TWebPPostEncode(TIFF *tif) +* Finish off an encoded strip by flushing it. +*/ +static int +TWebPPostEncode(TIFF* tif) { - static const char module[] = "WebPPostEncode"; - int64_t stride; - WebPState *sp = EncoderState(tif); - assert(sp != NULL); + static const char module[] = "WebPPostEncode"; + int64_t stride; + WebPState *sp = EncoderState(tif); + assert(sp != NULL); - assert(sp->state == LSTATE_INIT_ENCODE); + assert(sp->state == LSTATE_INIT_ENCODE); - stride = (int64_t)sp->sPicture.width * sp->nSamples; + stride = (int64_t)sp->sPicture.width * sp->nSamples; #if WEBP_ENCODER_ABI_VERSION >= 0x0100 - if (sp->nSamples == 4) - { - if (!WebPPictureImportRGBA(&sp->sPicture, sp->pBuffer, (int)stride)) - { - TIFFErrorExtR(tif, module, "WebPPictureImportRGBA() failed"); - return 0; - } - } - else + if (sp->nSamples == 4) { + if (!WebPPictureImportRGBA(&sp->sPicture, sp->pBuffer, (int)stride)) { + TIFFErrorExt(tif->tif_clientdata, module, + "WebPPictureImportRGBA() failed" ); + return 0; + } + } + else #endif - if (!WebPPictureImportRGB(&sp->sPicture, sp->pBuffer, (int)stride)) - { - TIFFErrorExtR(tif, module, "WebPPictureImportRGB() failed"); - return 0; - } - - if (!WebPEncode(&sp->sEncoderConfig, &sp->sPicture)) - { + if (!WebPPictureImportRGB(&sp->sPicture, sp->pBuffer, (int)stride)) { + TIFFErrorExt(tif->tif_clientdata, module, + "WebPPictureImportRGB() failed"); + return 0; + } + + if (!WebPEncode(&sp->sEncoderConfig, &sp->sPicture)) { #if WEBP_ENCODER_ABI_VERSION >= 0x0100 - const char *pszErrorMsg = NULL; - switch (sp->sPicture.error_code) - { - case VP8_ENC_ERROR_OUT_OF_MEMORY: - pszErrorMsg = "Out of memory"; - break; - case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY: - pszErrorMsg = "Out of memory while flushing bits"; - break; - case VP8_ENC_ERROR_NULL_PARAMETER: - pszErrorMsg = "A pointer parameter is NULL"; - break; - case VP8_ENC_ERROR_INVALID_CONFIGURATION: - pszErrorMsg = "Configuration is invalid"; - break; - case VP8_ENC_ERROR_BAD_DIMENSION: - pszErrorMsg = "Picture has invalid width/height"; - break; - case VP8_ENC_ERROR_PARTITION0_OVERFLOW: - pszErrorMsg = "Partition is bigger than 512k. Try using less " - "SEGMENTS, or increase PARTITION_LIMIT value"; - break; - case VP8_ENC_ERROR_PARTITION_OVERFLOW: - pszErrorMsg = "Partition is bigger than 16M"; - break; - case VP8_ENC_ERROR_BAD_WRITE: - pszErrorMsg = "Error while fludshing bytes"; - break; - case VP8_ENC_ERROR_FILE_TOO_BIG: - pszErrorMsg = "File is bigger than 4G"; - break; - case VP8_ENC_ERROR_USER_ABORT: - pszErrorMsg = "User interrupted"; - break; - default: - TIFFErrorExtR(tif, module, - "WebPEncode returned an unknown error code: %d", - sp->sPicture.error_code); - pszErrorMsg = "Unknown WebP error type."; - break; - } - TIFFErrorExtR(tif, module, "WebPEncode() failed : %s", pszErrorMsg); + const char* pszErrorMsg = NULL; + switch(sp->sPicture.error_code) { + case VP8_ENC_ERROR_OUT_OF_MEMORY: + pszErrorMsg = "Out of memory"; break; + case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY: + pszErrorMsg = "Out of memory while flushing bits"; break; + case VP8_ENC_ERROR_NULL_PARAMETER: + pszErrorMsg = "A pointer parameter is NULL"; break; + case VP8_ENC_ERROR_INVALID_CONFIGURATION: + pszErrorMsg = "Configuration is invalid"; break; + case VP8_ENC_ERROR_BAD_DIMENSION: + pszErrorMsg = "Picture has invalid width/height"; break; + case VP8_ENC_ERROR_PARTITION0_OVERFLOW: + pszErrorMsg = "Partition is bigger than 512k. Try using less " + "SEGMENTS, or increase PARTITION_LIMIT value"; + break; + case VP8_ENC_ERROR_PARTITION_OVERFLOW: + pszErrorMsg = "Partition is bigger than 16M"; + break; + case VP8_ENC_ERROR_BAD_WRITE: + pszErrorMsg = "Error while fludshing bytes"; break; + case VP8_ENC_ERROR_FILE_TOO_BIG: + pszErrorMsg = "File is bigger than 4G"; break; + case VP8_ENC_ERROR_USER_ABORT: + pszErrorMsg = "User interrupted"; + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "WebPEncode returned an unknown error code: %d", + sp->sPicture.error_code); + pszErrorMsg = "Unknown WebP error type."; + break; + } + TIFFErrorExt(tif->tif_clientdata, module, + "WebPEncode() failed : %s", pszErrorMsg); #else - TIFFErrorExtR(tif, module, "Error in WebPEncode()"); + TIFFErrorExt(tif->tif_clientdata, module, + "Error in WebPEncode()"); #endif - return 0; - } + return 0; + } - sp->sPicture.custom_ptr = NULL; + sp->sPicture.custom_ptr = NULL; - if (!TIFFFlushData1(tif)) - { - TIFFErrorExtR(tif, module, "Error flushing TIFF WebP encoder."); - return 0; - } + if (!TIFFFlushData1(tif)) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Error flushing TIFF WebP encoder."); + return 0; + } - return 1; + return 1; } -static void TWebPCleanup(TIFF *tif) +static void +TWebPCleanup(TIFF* tif) { - WebPState *sp = LState(tif); + WebPState* sp = LState(tif); - assert(sp != 0); + assert(sp != 0); - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; - if (sp->state & LSTATE_INIT_ENCODE) - { - WebPPictureFree(&sp->sPicture); - } + if (sp->state & LSTATE_INIT_ENCODE) { + WebPPictureFree(&sp->sPicture); + } - if (sp->psDecoder != NULL) - { - WebPIDelete(sp->psDecoder); - WebPFreeDecBuffer(&sp->sDecBuffer); - sp->psDecoder = NULL; - sp->last_y = 0; - } + if (sp->psDecoder != NULL) { + WebPIDelete(sp->psDecoder); + WebPFreeDecBuffer(&sp->sDecBuffer); + sp->psDecoder = NULL; + sp->last_y = 0; + } + + if (sp->pBuffer != NULL) { + _TIFFfree(sp->pBuffer); + sp->pBuffer = NULL; + } - if (sp->pBuffer != NULL) - { - _TIFFfreeExt(tif, sp->pBuffer); - sp->pBuffer = NULL; - } + _TIFFfree(tif->tif_data); + tif->tif_data = NULL; - _TIFFfreeExt(tif, tif->tif_data); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); + _TIFFSetDefaultCompressionState(tif); } -static int TWebPVSetField(TIFF *tif, uint32_t tag, va_list ap) +static int +TWebPVSetField(TIFF* tif, uint32 tag, va_list ap) { - static const char module[] = "WebPVSetField"; - WebPState *sp = LState(tif); + static const char module[] = "WebPVSetField"; + WebPState* sp = LState(tif); - switch (tag) - { - case TIFFTAG_WEBP_LEVEL: - sp->quality_level = (int)va_arg(ap, int); - if (sp->quality_level <= 0 || sp->quality_level > 100.0f) - { - TIFFWarningExtR(tif, module, - "WEBP_LEVEL should be between 1 and 100"); - } - return 1; - case TIFFTAG_WEBP_LOSSLESS: -#if WEBP_ENCODER_ABI_VERSION >= 0x0100 - sp->lossless = va_arg(ap, int); - if (sp->lossless) - { - sp->quality_level = 100; - } - return 1; -#else - TIFFErrorExtR( - tif, module, - "Need to upgrade WEBP driver, this version doesn't support " - "lossless compression."); - return 0; -#endif - default: - return (*sp->vsetparent)(tif, tag, ap); - } - /*NOTREACHED*/ -} - -static int TWebPVGetField(TIFF *tif, uint32_t tag, va_list ap) -{ - WebPState *sp = LState(tif); - - switch (tag) - { - case TIFFTAG_WEBP_LEVEL: - *va_arg(ap, int *) = sp->quality_level; - break; - case TIFFTAG_WEBP_LOSSLESS: - *va_arg(ap, int *) = sp->lossless; - break; - default: - return (*sp->vgetparent)(tif, tag, ap); + switch (tag) { + case TIFFTAG_WEBP_LEVEL: + sp->quality_level = (int) va_arg(ap, int); + if( sp->quality_level <= 0 || + sp->quality_level > 100.0f ) { + TIFFWarningExt(tif->tif_clientdata, module, + "WEBP_LEVEL should be between 1 and 100"); } return 1; + case TIFFTAG_WEBP_LOSSLESS: + #if WEBP_ENCODER_ABI_VERSION >= 0x0100 + sp->lossless = va_arg(ap, int); + if (sp->lossless){ + sp->quality_level = 100; + } + return 1; + #else + TIFFErrorExt(tif->tif_clientdata, module, + "Need to upgrade WEBP driver, this version doesn't support " + "lossless compression."); + return 0; + #endif + default: + return (*sp->vsetparent)(tif, tag, ap); + } + /*NOTREACHED*/ +} + +static int +TWebPVGetField(TIFF* tif, uint32 tag, va_list ap) +{ + WebPState* sp = LState(tif); + + switch (tag) { + case TIFFTAG_WEBP_LEVEL: + *va_arg(ap, int*) = sp->quality_level; + break; + case TIFFTAG_WEBP_LOSSLESS: + *va_arg(ap, int*) = sp->lossless; + break; + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return 1; } static const TIFFField TWebPFields[] = { - {TIFFTAG_WEBP_LEVEL, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "WEBP quality", NULL}, - {TIFFTAG_WEBP_LOSSLESS, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "WEBP lossless/lossy", - NULL}, + { TIFFTAG_WEBP_LEVEL, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, TRUE, FALSE, "WEBP quality", NULL }, + { TIFFTAG_WEBP_LOSSLESS, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, TRUE, FALSE, "WEBP lossless/lossy", NULL + }, }; -int TIFFInitWebP(TIFF *tif, int scheme) +int +TIFFInitWebP(TIFF* tif, int scheme) { - static const char module[] = "TIFFInitWebP"; - WebPState *sp; + static const char module[] = "TIFFInitWebP"; + WebPState* sp; - (void)scheme; - assert(scheme == COMPRESSION_WEBP); + (void)scheme; + assert( scheme == COMPRESSION_WEBP ); - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, TWebPFields, TIFFArrayCount(TWebPFields))) - { - TIFFErrorExtR(tif, module, "Merging WebP codec-specific tags failed"); - return 0; - } - - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(WebPState)); - 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 = TWebPVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = TWebPVSetField; /* hook for codec tags */ - - /* Default values for codec-specific fields */ - sp->quality_level = 75; /* default comp. level */ - sp->lossless = 0; /* default to false */ - sp->state = 0; - sp->nSamples = 0; - sp->psDecoder = NULL; - sp->last_y = 0; - - sp->buffer_offset = 0; - sp->pBuffer = NULL; - - /* - * Install codec methods. - * Notes: - * encoderow is not supported - */ - tif->tif_fixuptags = TWebPFixupTags; - tif->tif_setupdecode = TWebPSetupDecode; - tif->tif_predecode = TWebPPreDecode; - tif->tif_decoderow = TWebPDecode; - tif->tif_decodestrip = TWebPDecode; - tif->tif_decodetile = TWebPDecode; - tif->tif_setupencode = TWebPSetupEncode; - tif->tif_preencode = TWebPPreEncode; - tif->tif_postencode = TWebPPostEncode; - tif->tif_encoderow = TWebPEncode; - tif->tif_encodestrip = TWebPEncode; - tif->tif_encodetile = TWebPEncode; - tif->tif_cleanup = TWebPCleanup; - - return 1; -bad: - TIFFErrorExtR(tif, module, "No space for WebP state block"); + /* + * Merge codec-specific tag information. + */ + if ( !_TIFFMergeFields(tif, TWebPFields, TIFFArrayCount(TWebPFields)) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging WebP codec-specific tags failed"); return 0; + } + + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof(WebPState)); + 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 = TWebPVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = TWebPVSetField; /* hook for codec tags */ + + /* Default values for codec-specific fields */ + sp->quality_level = 75; /* default comp. level */ + sp->lossless = 0; /* default to false */ + sp->state = 0; + sp->nSamples = 0; + sp->psDecoder = NULL; + sp->last_y = 0; + + sp->buffer_offset = 0; + sp->pBuffer = NULL; + + /* + * Install codec methods. + * Notes: + * encoderow is not supported + */ + tif->tif_fixuptags = TWebPFixupTags; + tif->tif_setupdecode = TWebPSetupDecode; + tif->tif_predecode = TWebPPreDecode; + tif->tif_decoderow = TWebPDecode; + tif->tif_decodestrip = TWebPDecode; + tif->tif_decodetile = TWebPDecode; + tif->tif_setupencode = TWebPSetupEncode; + tif->tif_preencode = TWebPPreEncode; + tif->tif_postencode = TWebPPostEncode; + tif->tif_encoderow = TWebPEncode; + tif->tif_encodestrip = TWebPEncode; + tif->tif_encodetile = TWebPEncode; + tif->tif_cleanup = TWebPCleanup; + + return 1; +bad: + TIFFErrorExt(tif->tif_clientdata, module, + "No space for WebP state block"); + return 0; } #endif /* WEBP_SUPPORT */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_win32.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_win32.c index 1a6b86dff..896456939 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_win32.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_win32.c @@ -2,23 +2,23 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -28,7 +28,6 @@ */ #include "tiffiop.h" -#include #include @@ -55,111 +54,121 @@ static inline thandle_t thandle_from_int(int ifd) return (thandle_t)(intptr_t)ifd; } -static inline int thandle_to_int(thandle_t fd) { return (int)(intptr_t)fd; } - -static tmsize_t _tiffReadProc(thandle_t fd, void *buf, tmsize_t size) +static inline int thandle_to_int(thandle_t fd) { - /* 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_t *ma; - uint64_t mb; - DWORD n; - DWORD o; - tmsize_t p; - ma = (uint8_t *)buf; - mb = size; - p = 0; - while (mb > 0) - { - n = 0x80000000UL; - if ((uint64_t)n > mb) - n = (DWORD)mb; - if (!ReadFile(fd, (LPVOID)ma, n, &o, NULL)) - return (0); - ma += o; - mb -= o; - p += o; - if (o != n) - break; - } - return (p); + return (int)(intptr_t)fd; } -static tmsize_t _tiffWriteProc(thandle_t fd, void *buf, tmsize_t size) +static tmsize_t +_tiffReadProc(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_t *ma; - uint64_t mb; - DWORD n; - DWORD o; - tmsize_t p; - ma = (uint8_t *)buf; - mb = size; - p = 0; - while (mb > 0) - { - n = 0x80000000UL; - if ((uint64_t)n > mb) - n = (DWORD)mb; - if (!WriteFile(fd, (LPVOID)ma, n, &o, NULL)) - return (0); - ma += o; - mb -= o; - p += o; - if (o != n) - break; - } - return (p); + /* tmsize_t is 64bit on 64bit systems, but the WinAPI ReadFile takes + * 32bit sizes, so we loop through the data in suitable 32bit sized + * chunks */ + uint8* ma; + uint64 mb; + DWORD n; + DWORD o; + tmsize_t p; + ma=(uint8*)buf; + mb=size; + p=0; + while (mb>0) + { + n=0x80000000UL; + if ((uint64)n>mb) + n=(DWORD)mb; + if (!ReadFile(fd,(LPVOID)ma,n,&o,NULL)) + return(0); + ma+=o; + mb-=o; + p+=o; + if (o!=n) + break; + } + return(p); } -static uint64_t _tiffSeekProc(thandle_t fd, uint64_t off, int whence) +static tmsize_t +_tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) { - LARGE_INTEGER offli; - DWORD dwMoveMethod; - offli.QuadPart = off; - switch (whence) - { - case SEEK_SET: - dwMoveMethod = FILE_BEGIN; - break; - case SEEK_CUR: - dwMoveMethod = FILE_CURRENT; - break; - case SEEK_END: - dwMoveMethod = FILE_END; - break; - default: - dwMoveMethod = FILE_BEGIN; - break; - } - offli.LowPart = - SetFilePointer(fd, offli.LowPart, &offli.HighPart, dwMoveMethod); - if ((offli.LowPart == INVALID_SET_FILE_POINTER) && - (GetLastError() != NO_ERROR)) - offli.QuadPart = 0; - return (offli.QuadPart); + /* tmsize_t is 64bit on 64bit systems, but the WinAPI WriteFile takes + * 32bit sizes, so we loop through the data in suitable 32bit sized + * chunks */ + uint8* ma; + uint64 mb; + DWORD n; + DWORD o; + tmsize_t p; + ma=(uint8*)buf; + mb=size; + p=0; + while (mb>0) + { + n=0x80000000UL; + if ((uint64)n>mb) + n=(DWORD)mb; + if (!WriteFile(fd,(LPVOID)ma,n,&o,NULL)) + return(0); + ma+=o; + mb-=o; + p+=o; + if (o!=n) + break; + } + return(p); } -static int _tiffCloseProc(thandle_t fd) { return (CloseHandle(fd) ? 0 : -1); } - -static uint64_t _tiffSizeProc(thandle_t fd) +static uint64 +_tiffSeekProc(thandle_t fd, uint64 off, int whence) { - LARGE_INTEGER m; - if (GetFileSizeEx(fd, &m)) - return (m.QuadPart); - else - return (0); + LARGE_INTEGER offli; + DWORD dwMoveMethod; + offli.QuadPart = off; + switch(whence) + { + case SEEK_SET: + dwMoveMethod = FILE_BEGIN; + break; + case SEEK_CUR: + dwMoveMethod = FILE_CURRENT; + break; + case SEEK_END: + dwMoveMethod = FILE_END; + break; + default: + dwMoveMethod = FILE_BEGIN; + break; + } + offli.LowPart=SetFilePointer(fd,offli.LowPart,&offli.HighPart,dwMoveMethod); + if ((offli.LowPart==INVALID_SET_FILE_POINTER)&&(GetLastError()!=NO_ERROR)) + offli.QuadPart=0; + return(offli.QuadPart); } -static int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize) +static int +_tiffCloseProc(thandle_t fd) { - (void)fd; - (void)pbase; - (void)psize; - return (0); + return (CloseHandle(fd) ? 0 : -1); +} + +static uint64 +_tiffSizeProc(thandle_t fd) +{ + LARGE_INTEGER m; + if (GetFileSizeEx(fd,&m)) + return(m.QuadPart); + else + return(0); +} + +static int +_tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize) +{ + (void) fd; + (void) pbase; + (void) psize; + return (0); } /* @@ -173,42 +182,45 @@ static int _tiffDummyMapProc(thandle_t fd, void **pbase, toff_t *psize) * This removes a nasty OS dependency and cures a problem * with Visual C++ 5.0 */ -static int _tiffMapProc(thandle_t fd, void **pbase, toff_t *psize) +static int +_tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) { - uint64_t size; - tmsize_t sizem; - HANDLE hMapFile; + uint64 size; + tmsize_t sizem; + HANDLE hMapFile; - size = _tiffSizeProc(fd); - sizem = (tmsize_t)size; - if (!size || (uint64_t)sizem != size) - return (0); + size = _tiffSizeProc(fd); + sizem = (tmsize_t)size; + if (!size || (uint64)sizem!=size) + return (0); - /* By passing in 0 for the maximum file size, it specifies that we - create a file mapping object for the full file size. */ - hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, 0, NULL); - if (hMapFile == NULL) - return (0); - *pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0); - CloseHandle(hMapFile); - if (*pbase == NULL) - return (0); - *psize = size; - return (1); + /* By passing in 0 for the maximum file size, it specifies that we + create a file mapping object for the full file size. */ + hMapFile = CreateFileMapping(fd, NULL, PAGE_READONLY, 0, 0, NULL); + if (hMapFile == NULL) + return (0); + *pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0); + CloseHandle(hMapFile); + if (*pbase == NULL) + return (0); + *psize = size; + return(1); } -static void _tiffDummyUnmapProc(thandle_t fd, void *base, toff_t size) +static void +_tiffDummyUnmapProc(thandle_t fd, void* base, toff_t size) { - (void)fd; - (void)base; - (void)size; + (void) fd; + (void) base; + (void) size; } -static void _tiffUnmapProc(thandle_t fd, void *base, toff_t size) +static void +_tiffUnmapProc(thandle_t fd, void* base, toff_t size) { - (void)fd; - (void)size; - UnmapViewOfFile(base); + (void) fd; + (void) size; + UnmapViewOfFile(base); } /* @@ -216,36 +228,29 @@ static void _tiffUnmapProc(thandle_t fd, void *base, toff_t size) * Note that TIFFFdOpen and TIFFOpen recognise the character 'u' in the mode * string, which forces the file to be opened unmapped. */ -TIFF *TIFFFdOpen(int ifd, const char *name, const char *mode) +TIFF* +TIFFFdOpen(int ifd, const char* name, const char* mode) { - return TIFFFdOpenExt(ifd, name, mode, NULL); -} - -TIFF *TIFFFdOpenExt(int ifd, const char *name, const char *mode, - TIFFOpenOptions *opts) -{ - TIFF *tif; - int fSuppressMap; - int m; - - fSuppressMap = 0; - for (m = 0; mode[m] != 0; m++) - { - if (mode[m] == 'u') - { - fSuppressMap = 1; - break; - } - } - - tif = TIFFClientOpenExt( - name, mode, thandle_from_int(ifd), _tiffReadProc, _tiffWriteProc, - _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, - fSuppressMap ? _tiffDummyMapProc : _tiffMapProc, - fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc, opts); - if (tif) - tif->tif_fd = ifd; - return (tif); + TIFF* tif; + int fSuppressMap; + int m; + fSuppressMap=0; + for (m=0; mode[m]!=0; m++) + { + if (mode[m]=='u') + { + fSuppressMap=1; + break; + } + } + tif = TIFFClientOpen(name, mode, thandle_from_int(ifd), + _tiffReadProc, _tiffWriteProc, + _tiffSeekProc, _tiffCloseProc, _tiffSizeProc, + fSuppressMap ? _tiffDummyMapProc : _tiffMapProc, + fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc); + if (tif) + tif->tif_fd = ifd; + return (tif); } #ifndef _WIN32_WCE @@ -253,190 +258,184 @@ TIFF *TIFFFdOpenExt(int ifd, const char *name, const char *mode, /* * Open a TIFF file for read/writing. */ -TIFF *TIFFOpen(const char *name, const char *mode) +TIFF* +TIFFOpen(const char* name, const char* mode) { - return TIFFOpenExt(name, mode, NULL); -} + static const char module[] = "TIFFOpen"; + thandle_t fd; + int m; + DWORD dwMode; + TIFF* tif; -TIFF *TIFFOpenExt(const char *name, const char *mode, TIFFOpenOptions *opts) -{ - static const char module[] = "TIFFOpen"; - thandle_t fd; - int m; - DWORD dwMode; - TIFF *tif; + m = _TIFFgetMode(mode, module); - m = _TIFFgetMode(opts, NULL, mode, module); + switch(m) { + case O_RDONLY: dwMode = OPEN_EXISTING; break; + case O_RDWR: dwMode = OPEN_ALWAYS; break; + case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break; + case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break; + case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break; + default: return ((TIFF*)0); + } + + fd = (thandle_t)CreateFileA(name, + (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE), + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, + (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL, + NULL); + if (fd == INVALID_HANDLE_VALUE) { + TIFFErrorExt(0, module, "%s: Cannot open", name); + return ((TIFF *)0); + } - switch (m) - { - case O_RDONLY: - dwMode = OPEN_EXISTING; - break; - case O_RDWR: - dwMode = OPEN_EXISTING; - break; - case O_RDWR | O_CREAT: - dwMode = OPEN_ALWAYS; - break; - case O_RDWR | O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - case O_RDWR | O_CREAT | O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - default: - return ((TIFF *)0); - } - - fd = (thandle_t)CreateFileA( - name, (m == O_RDONLY) ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE), - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, - (m == O_RDONLY) ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL, - NULL); - if (fd == INVALID_HANDLE_VALUE) - { - _TIFFErrorEarly(opts, NULL, module, "%s: Cannot open", name); - return ((TIFF *)0); - } - - tif = TIFFFdOpenExt(thandle_to_int(fd), name, mode, opts); - if (!tif) - CloseHandle(fd); - return tif; + tif = TIFFFdOpen(thandle_to_int(fd), name, mode); + if(!tif) + CloseHandle(fd); + return tif; } /* * Open a TIFF file with a Unicode filename, for read/writing. */ -TIFF *TIFFOpenW(const wchar_t *name, const char *mode) +TIFF* +TIFFOpenW(const wchar_t* name, const char* mode) { - return TIFFOpenWExt(name, mode, NULL); -} + static const char module[] = "TIFFOpenW"; + thandle_t fd; + int m; + DWORD dwMode; + int mbsize; + char *mbname; + TIFF *tif; -TIFF *TIFFOpenWExt(const wchar_t *name, const char *mode, TIFFOpenOptions *opts) -{ - static const char module[] = "TIFFOpenW"; - thandle_t fd; - int m; - DWORD dwMode; - int mbsize; - char *mbname; - TIFF *tif; + m = _TIFFgetMode(mode, module); - m = _TIFFgetMode(opts, NULL, mode, module); + switch(m) { + case O_RDONLY: dwMode = OPEN_EXISTING; break; + case O_RDWR: dwMode = OPEN_ALWAYS; break; + case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break; + case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break; + case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break; + default: return ((TIFF*)0); + } - switch (m) - { - case O_RDONLY: - dwMode = OPEN_EXISTING; - break; - case O_RDWR: - dwMode = OPEN_EXISTING; - break; - case O_RDWR | O_CREAT: - dwMode = OPEN_ALWAYS; - break; - case O_RDWR | O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - case O_RDWR | O_CREAT | O_TRUNC: - dwMode = CREATE_ALWAYS; - break; - default: - return ((TIFF *)0); - } + fd = (thandle_t)CreateFileW(name, + (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE), + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, + (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL, + NULL); + if (fd == INVALID_HANDLE_VALUE) { + TIFFErrorExt(0, module, "%S: Cannot open", name); + return ((TIFF *)0); + } - fd = (thandle_t)CreateFileW( - name, (m == O_RDONLY) ? GENERIC_READ : (GENERIC_READ | GENERIC_WRITE), - FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, - (m == O_RDONLY) ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL, - NULL); - if (fd == INVALID_HANDLE_VALUE) - { - _TIFFErrorEarly(opts, NULL, module, "%S: Cannot open", name); - return ((TIFF *)0); - } + mbname = NULL; + mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL); + if (mbsize > 0) { + mbname = (char *)_TIFFmalloc(mbsize); + if (!mbname) { + TIFFErrorExt(0, module, + "Can't allocate space for filename conversion buffer"); + return ((TIFF*)0); + } - mbname = NULL; - mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL); - if (mbsize > 0) - { - mbname = (char *)_TIFFmalloc(mbsize); - if (!mbname) - { - _TIFFErrorEarly( - opts, NULL, module, - "Can't allocate space for filename conversion buffer"); - return ((TIFF *)0); - } + WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize, + NULL, NULL); + } - WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize, NULL, NULL); - } + tif = TIFFFdOpen(thandle_to_int(fd), + (mbname != NULL) ? mbname : "", mode); + if(!tif) + CloseHandle(fd); - tif = TIFFFdOpenExt(thandle_to_int(fd), - (mbname != NULL) ? mbname : "", mode, opts); - if (!tif) - CloseHandle(fd); + _TIFFfree(mbname); - _TIFFfree(mbname); - - return tif; + return tif; } #endif /* ndef _WIN32_WCE */ -void *_TIFFmalloc(tmsize_t s) +void* +_TIFFmalloc(tmsize_t s) { - if (s == 0) - return ((void *)NULL); + if (s == 0) + return ((void *) NULL); - return (malloc((size_t)s)); + return (malloc((size_t) s)); } -void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz) +void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz) { - if (nmemb == 0 || siz == 0) - return ((void *)NULL); + if( nmemb == 0 || siz == 0 ) + return ((void *) NULL); - return calloc((size_t)nmemb, (size_t)siz); + return calloc((size_t) nmemb, (size_t)siz); } -void _TIFFfree(void *p) { free(p); } - -void *_TIFFrealloc(void *p, tmsize_t s) { return (realloc(p, (size_t)s)); } - -void _TIFFmemset(void *p, int v, tmsize_t c) { memset(p, v, (size_t)c); } - -void _TIFFmemcpy(void *d, const void *s, tmsize_t c) +void +_TIFFfree(void* p) { - memcpy(d, s, (size_t)c); + free(p); } -int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c) +void* +_TIFFrealloc(void* p, tmsize_t s) { - return (memcmp(p1, p2, (size_t)c)); + return (realloc(p, (size_t) s)); +} + +void +_TIFFmemset(void* p, int v, tmsize_t c) +{ + memset(p, v, (size_t) c); +} + +void +_TIFFmemcpy(void* d, const void* s, tmsize_t c) +{ + memcpy(d, s, (size_t) c); +} + +int +_TIFFmemcmp(const void* p1, const void* p2, tmsize_t c) +{ + return (memcmp(p1, p2, (size_t) c)); } #ifndef _WIN32_WCE -static void Win32WarningHandler(const char *module, const char *fmt, va_list ap) +#if (_MSC_VER < 1500) +# define vsnprintf _vsnprintf +#endif + +static void +Win32WarningHandler(const char* module, const char* fmt, va_list ap) { - if (module != NULL) - fprintf(stderr, "%s: ", module); - fprintf(stderr, "Warning, "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); + if (module != NULL) + fprintf(stderr, "%s: ", module); + fprintf(stderr, "Warning, "); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler; -static void Win32ErrorHandler(const char *module, const char *fmt, va_list ap) +static void +Win32ErrorHandler(const char* module, const char* fmt, va_list ap) { - if (module != NULL) - fprintf(stderr, "%s: ", module); - vfprintf(stderr, fmt, ap); - fprintf(stderr, ".\n"); + if (module != NULL) + fprintf(stderr, "%s: ", module); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ".\n"); } TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler; #endif /* ndef _WIN32_WCE */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_win32_versioninfo.rc b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_win32_versioninfo.rc deleted file mode 100644 index a5613f51f..000000000 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_win32_versioninfo.rc +++ /dev/null @@ -1,51 +0,0 @@ - -/* clang-format off */ - -#define APSTUDIO_HIDDEN_SYMBOLS -#include -#undef APSTUDIO_HIDDEN_SYMBOLS -#include - -#include "tiffvers.h" -#include "tif_config.h" - -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1252) -#endif //_WIN32 - -VS_VERSION_INFO VERSIONINFO - FILEVERSION TIFFLIB_MAJOR_VERSION,TIFFLIB_MINOR_VERSION,TIFFLIB_MICRO_VERSION,0 - PRODUCTVERSION TIFFLIB_MAJOR_VERSION,TIFFLIB_MINOR_VERSION,TIFFLIB_MICRO_VERSION,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", "libtiff project" - VALUE "FileDescription", "TIFF Library" - VALUE "FileVersion", PACKAGE_VERSION - VALUE "InternalName", "tiff.dll" - VALUE "LegalCopyright", "See LICENCE.md" - VALUE "OriginalFilename", "tiff.dll" - VALUE "ProductName", "LibTIFF" - VALUE "ProductVersion", PACKAGE_VERSION - VALUE "WebPage", "https://libtiff.gitlab.io/libtiff/\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - - diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_wince.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_wince.c new file mode 100644 index 000000000..b3b168f1c --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_wince.c @@ -0,0 +1,288 @@ +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * Windows CE-specific routines for TIFF Library. + * Adapted from tif_win32.c 01/10/2006 by Mateusz Loskot (mateusz@loskot.net) + */ + +#ifndef _WIN32_WCE +# error "Only Windows CE target is supported!" +#endif + +#include "tiffiop.h" +#include + +COMPILATION SHOULD FAIL +This file is not yet updated to reflect changes in LibTiff 4.0. If you have +the opportunity to update and test this file, please contact LibTiff folks +for all assistance you may require and contribute the results + + +/* + * Open a TIFF file for read/writing. + */ +TIFF* +TIFFOpen(const char* name, const char* mode) +{ + static const char module[] = "TIFFOpen"; + thandle_t fd; + int m; + DWORD dwMode; + TIFF* tif; + size_t nLen; + size_t nWideLen; + wchar_t* wchName; + + m = _TIFFgetMode(mode, module); + + switch(m) + { + case O_RDONLY: + dwMode = OPEN_EXISTING; + break; + case O_RDWR: + dwMode = OPEN_ALWAYS; + break; + case O_RDWR|O_CREAT: + dwMode = OPEN_ALWAYS; + break; + case O_RDWR|O_TRUNC: + dwMode = CREATE_ALWAYS; + break; + case O_RDWR|O_CREAT|O_TRUNC: + dwMode = CREATE_ALWAYS; + break; + default: + return ((TIFF*)0); + } + + /* On Windows CE, CreateFile is mapped to CreateFileW, + * but file path is passed as char-based string, + * so the path has to be converted to wchar_t. + */ + + nWideLen = 0; + wchName = NULL; + nLen = strlen(name) + 1; + + nWideLen = MultiByteToWideChar(CP_ACP, 0, name, nLen, NULL, 0); + wchName = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen); + if (NULL == wchName) + { + TIFFErrorExt(0, module, "Memory allocation error!"); + return ((TIFF *)0); + } + memset(wchName, 0, sizeof(wchar_t) * nWideLen); + MultiByteToWideChar(CP_ACP, 0, name, nLen, wchName, nWideLen); + + fd = (thandle_t)CreateFile(wchName, + (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE), + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, dwMode, + (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL, + NULL); + + free(wchName); + + if (fd == INVALID_HANDLE_VALUE) { + TIFFErrorExt(0, module, "%s: Cannot open", name); + return ((TIFF *)0); + } + + /* TODO - mloskot: change to TIFFdOpenW and pass wchar path */ + + tif = TIFFFdOpen((int)fd, name, mode); + if(!tif) + CloseHandle(fd); + return tif; +} + +/* + * Open a TIFF file with a Unicode filename, for read/writing. + */ +TIFF* +TIFFOpenW(const wchar_t* name, const char* mode) +{ + static const char module[] = "TIFFOpenW"; + thandle_t fd; + int m; + DWORD dwMode; + int mbsize; + char *mbname; + TIFF *tif; + + m = _TIFFgetMode(mode, module); + + switch(m) { + case O_RDONLY: dwMode = OPEN_EXISTING; break; + case O_RDWR: dwMode = OPEN_ALWAYS; break; + case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS; break; + case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS; break; + case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS; break; + default: return ((TIFF*)0); + } + + /* On Windows CE, CreateFile is mapped to CreateFileW, + * so no conversion of wchar_t to char is required. + */ + + fd = (thandle_t)CreateFile(name, + (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE), + FILE_SHARE_READ, NULL, dwMode, + (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL, + NULL); + if (fd == INVALID_HANDLE_VALUE) { + TIFFErrorExt(0, module, "%S: Cannot open", name); + return ((TIFF *)0); + } + + mbname = NULL; + mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1, NULL, 0, NULL, NULL); + if (mbsize > 0) { + mbname = (char *)_TIFFmalloc(mbsize); + if (!mbname) { + TIFFErrorExt(0, module, + "Can't allocate space for filename conversion buffer"); + return ((TIFF*)0); + } + + WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize, + NULL, NULL); + } + + tif = TIFFFdOpen((int)fd, + (mbname != NULL) ? mbname : "", mode); + if(!tif) + CloseHandle(fd); + + _TIFFfree(mbname); + + return tif; +} + +static void +Win32WarningHandler(const char* module, const char* fmt, va_list ap) +{ + /* On Windows CE, MessageBox is mapped to wide-char based MessageBoxW. */ + + size_t nWideLen = 0; + LPTSTR szWideTitle = NULL; + LPTSTR szWideMsg = NULL; + + LPSTR szTitle; + LPSTR szTmp; + LPCSTR szTitleText = "%s Warning"; + LPCSTR szDefaultModule = "LIBTIFF"; + LPCSTR szTmpModule; + + szTmpModule = (module == NULL) ? szDefaultModule : module; + if ((szTitle = (LPSTR)LocalAlloc(LMEM_FIXED, + (strlen(szTmpModule) + strlen(szTitleText) + + strlen(fmt) + 128) * sizeof(char))) == NULL) + return; + + sprintf(szTitle, szTitleText, szTmpModule); + szTmp = szTitle + (strlen(szTitle) + 2) * sizeof(char); + vsprintf(szTmp, fmt, ap); + + /* Convert error message to Unicode. */ + + nWideLen = MultiByteToWideChar(CP_ACP, 0, szTitle, -1, NULL, 0); + szWideTitle = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen); + MultiByteToWideChar(CP_ACP, 0, szTitle, -1, szWideTitle, nWideLen); + + nWideLen = MultiByteToWideChar(CP_ACP, 0, szTmp, -1, NULL, 0); + szWideMsg = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen); + MultiByteToWideChar(CP_ACP, 0, szTmp, -1, szWideMsg, nWideLen); + + /* Display message */ + + MessageBox(GetFocus(), szWideMsg, szWideTitle, MB_OK | MB_ICONEXCLAMATION); + + /* Free resources */ + + LocalFree(szTitle); + free(szWideMsg); + free(szWideTitle); +} + +TIFFErrorHandler _TIFFwarningHandler = Win32WarningHandler; + +static void +Win32ErrorHandler(const char* module, const char* fmt, va_list ap) +{ + /* On Windows CE, MessageBox is mapped to wide-char based MessageBoxW. */ + + size_t nWideLen = 0; + LPTSTR szWideTitle = NULL; + LPTSTR szWideMsg = NULL; + + LPSTR szTitle; + LPSTR szTmp; + LPCSTR szTitleText = "%s Error"; + LPCSTR szDefaultModule = "LIBTIFF"; + LPCSTR szTmpModule; + + szTmpModule = (module == NULL) ? szDefaultModule : module; + if ((szTitle = (LPSTR)LocalAlloc(LMEM_FIXED, + (strlen(szTmpModule) + strlen(szTitleText) + + strlen(fmt) + 128) * sizeof(char))) == NULL) + return; + + sprintf(szTitle, szTitleText, szTmpModule); + szTmp = szTitle + (strlen(szTitle) + 2) * sizeof(char); + vsprintf(szTmp, fmt, ap); + + /* Convert error message to Unicode. */ + + nWideLen = MultiByteToWideChar(CP_ACP, 0, szTitle, -1, NULL, 0); + szWideTitle = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen); + MultiByteToWideChar(CP_ACP, 0, szTitle, -1, szWideTitle, nWideLen); + + nWideLen = MultiByteToWideChar(CP_ACP, 0, szTmp, -1, NULL, 0); + szWideMsg = (wchar_t*)malloc(sizeof(wchar_t) * nWideLen); + MultiByteToWideChar(CP_ACP, 0, szTmp, -1, szWideMsg, nWideLen); + + /* Display message */ + + MessageBox(GetFocus(), szWideMsg, szWideTitle, MB_OK | MB_ICONEXCLAMATION); + + /* Free resources */ + + LocalFree(szTitle); + free(szWideMsg); + free(szWideTitle); +} + +TIFFErrorHandler _TIFFerrorHandler = Win32ErrorHandler; + + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_write.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_write.c index 6631a782f..3af69ab4e 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_write.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_write.c @@ -30,178 +30,174 @@ #include "tiffiop.h" #include -#define STRIPINCR 20 /* expansion factor on strip array */ +#define STRIPINCR 20 /* expansion factor on strip array */ -#define WRITECHECKSTRIPS(tif, module) \ - (((tif)->tif_flags & TIFF_BEENWRITING) || TIFFWriteCheck((tif), 0, module)) -#define WRITECHECKTILES(tif, module) \ - (((tif)->tif_flags & TIFF_BEENWRITING) || TIFFWriteCheck((tif), 1, module)) -#define BUFFERCHECK(tif) \ - ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \ - TIFFWriteBufferSetup((tif), NULL, (tmsize_t)-1)) +#define WRITECHECKSTRIPS(tif, module) \ + (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),0,module)) +#define WRITECHECKTILES(tif, module) \ + (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),1,module)) +#define BUFFERCHECK(tif) \ + ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \ + TIFFWriteBufferSetup((tif), NULL, (tmsize_t) -1)) -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); +static int TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module); +static int TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc); -int TIFFWriteScanline(TIFF *tif, void *buf, uint32_t row, uint16_t sample) +int +TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample) { - static const char module[] = "TIFFWriteScanline"; - register TIFFDirectory *td; - int status, imagegrew = 0; - uint32_t strip; + static const char module[] = "TIFFWriteScanline"; + register TIFFDirectory *td; + int status, imagegrew = 0; + uint32 strip; - if (!WRITECHECKSTRIPS(tif, module)) - return (-1); - /* - * Handle delayed allocation of data buffer. This - * permits it to be sized more intelligently (using - * directory information). - */ - if (!BUFFERCHECK(tif)) - return (-1); - tif->tif_flags |= TIFF_BUF4WRITE; /* not strictly sure this is right*/ + if (!WRITECHECKSTRIPS(tif, module)) + return (-1); + /* + * Handle delayed allocation of data buffer. This + * permits it to be sized more intelligently (using + * directory information). + */ + if (!BUFFERCHECK(tif)) + return (-1); + tif->tif_flags |= TIFF_BUF4WRITE; /* not strictly sure this is right*/ - td = &tif->tif_dir; - /* - * Extend image length if needed - * (but only for PlanarConfig=1). - */ - if (row >= td->td_imagelength) - { /* extend image */ - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - { - TIFFErrorExtR( - tif, module, - "Can not change \"ImageLength\" when using separate planes"); - return (-1); - } - td->td_imagelength = row + 1; - imagegrew = 1; - } - /* - * Calculate strip and check for crossings. - */ - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - { - if (sample >= td->td_samplesperpixel) - { - TIFFErrorExtR(tif, module, "%lu: Sample out of range, max %lu", - (unsigned long)sample, - (unsigned long)td->td_samplesperpixel); - return (-1); - } - strip = sample * td->td_stripsperimage + row / td->td_rowsperstrip; - } - else - strip = row / td->td_rowsperstrip; - /* - * Check strip array to make sure there's space. We don't support - * dynamically growing files that have data organized in separate - * bitplanes because it's too painful. In that case we require that - * the imagelength be set properly before the first write (so that the - * strips array will be fully allocated above). - */ - if (strip >= td->td_nstrips && !TIFFGrowStrips(tif, 1, module)) - return (-1); - if (strip != tif->tif_curstrip) - { - /* - * Changing strips -- flush any data present. - */ - if (!TIFFFlushData(tif)) - return (-1); - tif->tif_curstrip = strip; - /* - * Watch out for a growing image. The value of strips/image - * will initially be 1 (since it can't be deduced until the - * imagelength is known). - */ - if (strip >= td->td_stripsperimage && imagegrew) - td->td_stripsperimage = - TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip); - if (td->td_stripsperimage == 0) - { - TIFFErrorExtR(tif, module, "Zero strips per image"); - return (-1); - } - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) - { - if (!(*tif->tif_setupencode)(tif)) - return (-1); - tif->tif_flags |= TIFF_CODERSETUP; - } + td = &tif->tif_dir; + /* + * Extend image length if needed + * (but only for PlanarConfig=1). + */ + if (row >= td->td_imagelength) { /* extend image */ + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not change \"ImageLength\" when using separate planes"); + return (-1); + } + td->td_imagelength = row+1; + imagegrew = 1; + } + /* + * Calculate strip and check for crossings. + */ + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + if (sample >= td->td_samplesperpixel) { + TIFFErrorExt(tif->tif_clientdata, module, + "%lu: Sample out of range, max %lu", + (unsigned long) sample, (unsigned long) td->td_samplesperpixel); + return (-1); + } + strip = sample*td->td_stripsperimage + row/td->td_rowsperstrip; + } else + strip = row / td->td_rowsperstrip; + /* + * Check strip array to make sure there's space. We don't support + * dynamically growing files that have data organized in separate + * bitplanes because it's too painful. In that case we require that + * the imagelength be set properly before the first write (so that the + * strips array will be fully allocated above). + */ + if (strip >= td->td_nstrips && !TIFFGrowStrips(tif, 1, module)) + return (-1); + if (strip != tif->tif_curstrip) { + /* + * Changing strips -- flush any data present. + */ + if (!TIFFFlushData(tif)) + return (-1); + tif->tif_curstrip = strip; + /* + * Watch out for a growing image. The value of strips/image + * will initially be 1 (since it can't be deduced until the + * imagelength is known). + */ + if (strip >= td->td_stripsperimage && imagegrew) + td->td_stripsperimage = + TIFFhowmany_32(td->td_imagelength,td->td_rowsperstrip); + if (td->td_stripsperimage == 0) { + TIFFErrorExt(tif->tif_clientdata, module, "Zero strips per image"); + return (-1); + } + tif->tif_row = + (strip % td->td_stripsperimage) * td->td_rowsperstrip; + if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { + if (!(*tif->tif_setupencode)(tif)) + return (-1); + tif->tif_flags |= TIFF_CODERSETUP; + } + + tif->tif_rawcc = 0; + tif->tif_rawcp = tif->tif_rawdata; - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; + if( td->td_stripbytecount_p[strip] > 0 ) + { + /* if we are writing over existing tiles, zero length */ + td->td_stripbytecount_p[strip] = 0; - /* this informs TIFFAppendToStrip() we have changed strip */ - tif->tif_curoff = 0; + /* this forces TIFFAppendToStrip() to do a seek */ + tif->tif_curoff = 0; + } - if (!(*tif->tif_preencode)(tif, sample)) - return (-1); - tif->tif_flags |= TIFF_POSTENCODE; - } - /* - * Ensure the write is either sequential or at the - * beginning of a strip (or that we can randomly - * access the data -- i.e. no encoding). - */ - if (row != tif->tif_row) - { - if (row < tif->tif_row) - { - /* - * Moving backwards within the same strip: - * backup to the start and then decode - * forward (below). - */ - tif->tif_row = - (strip % td->td_stripsperimage) * td->td_rowsperstrip; - tif->tif_rawcp = tif->tif_rawdata; - } - /* - * Seek forward to the desired row. - */ - if (!(*tif->tif_seek)(tif, row - tif->tif_row)) - return (-1); - tif->tif_row = row; - } + if (!(*tif->tif_preencode)(tif, sample)) + return (-1); + tif->tif_flags |= TIFF_POSTENCODE; + } + /* + * Ensure the write is either sequential or at the + * beginning of a strip (or that we can randomly + * access the data -- i.e. no encoding). + */ + if (row != tif->tif_row) { + if (row < tif->tif_row) { + /* + * Moving backwards within the same strip: + * backup to the start and then decode + * forward (below). + */ + tif->tif_row = (strip % td->td_stripsperimage) * + td->td_rowsperstrip; + tif->tif_rawcp = tif->tif_rawdata; + } + /* + * Seek forward to the desired row. + */ + if (!(*tif->tif_seek)(tif, row - tif->tif_row)) + return (-1); + tif->tif_row = row; + } - /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode(tif, (uint8_t *)buf, tif->tif_scanlinesize); + /* swab if needed - note that source buffer will be altered */ + tif->tif_postdecode( tif, (uint8*) buf, tif->tif_scanlinesize ); - status = (*tif->tif_encoderow)(tif, (uint8_t *)buf, tif->tif_scanlinesize, - sample); + status = (*tif->tif_encoderow)(tif, (uint8*) buf, + tif->tif_scanlinesize, sample); - /* we are now poised at the beginning of the next row */ - tif->tif_row = row + 1; - return (status); + /* we are now poised at the beginning of the next row */ + tif->tif_row = row + 1; + return (status); } -/* Make sure that at the first attempt of rewriting a tile/strip, we will have - */ +/* Make sure that at the first attempt of rewriting a tile/strip, we will have */ /* 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 */ +/* 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_t strip_or_tile) +static int _TIFFReserveLargeEnoughWriteBuffer(TIFF* tif, uint32 strip_or_tile) { TIFFDirectory *td = &tif->tif_dir; - if (td->td_stripbytecount_p[strip_or_tile] > 0) + 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_t safe_buffer_size = - (uint64_t)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4); - if (tif->tif_rawdatasize <= (tmsize_t)safe_buffer_size) + uint64 safe_buffer_size = (uint64)(td->td_stripbytecount_p[strip_or_tile] + 1 + 4); + if( tif->tif_rawdatasize <= (tmsize_t)safe_buffer_size ) { - if (!(TIFFWriteBufferSetup( - tif, NULL, - (tmsize_t)TIFFroundup_64(safe_buffer_size, 1024)))) + if( !(TIFFWriteBufferSetup(tif, NULL, + (tmsize_t)TIFFroundup_64(safe_buffer_size, 1024))) ) return 0; } + + /* Force TIFFAppendToStrip() to consider placing data at end + of file. */ + tif->tif_curoff = 0; } return 1; } @@ -212,112 +208,103 @@ static int _TIFFReserveLargeEnoughWriteBuffer(TIFF *tif, uint32_t strip_or_tile) * * NB: Image length must be setup before writing. */ -tmsize_t TIFFWriteEncodedStrip(TIFF *tif, uint32_t strip, void *data, - tmsize_t cc) +tmsize_t +TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) { - static const char module[] = "TIFFWriteEncodedStrip"; - TIFFDirectory *td = &tif->tif_dir; - uint16_t sample; + static const char module[] = "TIFFWriteEncodedStrip"; + TIFFDirectory *td = &tif->tif_dir; + uint16 sample; - if (!WRITECHECKSTRIPS(tif, module)) - return ((tmsize_t)-1); - /* - * Check strip array to make sure there's space. - * We don't support dynamically growing files that - * have data organized in separate bitplanes because - * it's too painful. In that case we require that - * the imagelength be set properly before the first - * write (so that the strips array will be fully - * allocated above). - */ - if (strip >= td->td_nstrips) - { - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - { - TIFFErrorExtR( - tif, module, - "Can not grow image by strips when using separate planes"); - return ((tmsize_t)-1); + if (!WRITECHECKSTRIPS(tif, module)) + return ((tmsize_t) -1); + /* + * Check strip array to make sure there's space. + * We don't support dynamically growing files that + * have data organized in separate bitplanes because + * it's too painful. In that case we require that + * the imagelength be set properly before the first + * write (so that the strips array will be fully + * allocated above). + */ + if (strip >= td->td_nstrips) { + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not grow image by strips when using separate planes"); + return ((tmsize_t) -1); + } + if (!TIFFGrowStrips(tif, 1, module)) + return ((tmsize_t) -1); + td->td_stripsperimage = + TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip); + } + /* + * Handle delayed allocation of data buffer. This + * permits it to be sized according to the directory + * info. + */ + if (!BUFFERCHECK(tif)) + return ((tmsize_t) -1); + + tif->tif_flags |= TIFF_BUF4WRITE; + tif->tif_curstrip = strip; + + if( !_TIFFReserveLargeEnoughWriteBuffer(tif, strip) ) { + return ((tmsize_t)(-1)); } - if (!TIFFGrowStrips(tif, 1, module)) - return ((tmsize_t)-1); - td->td_stripsperimage = - TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip); - } - /* - * Handle delayed allocation of data buffer. This - * permits it to be sized according to the directory - * info. - */ - if (!BUFFERCHECK(tif)) - return ((tmsize_t)-1); - tif->tif_flags |= TIFF_BUF4WRITE; + tif->tif_rawcc = 0; + tif->tif_rawcp = tif->tif_rawdata; - tif->tif_curstrip = strip; + if (td->td_stripsperimage == 0) { + TIFFErrorExt(tif->tif_clientdata, module, "Zero strips per image"); + return ((tmsize_t) -1); + } - /* this informs TIFFAppendToStrip() we have changed or reset strip */ - tif->tif_curoff = 0; + tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; + if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { + if (!(*tif->tif_setupencode)(tif)) + return ((tmsize_t) -1); + tif->tif_flags |= TIFF_CODERSETUP; + } - if (!_TIFFReserveLargeEnoughWriteBuffer(tif, strip)) - { - return ((tmsize_t)(-1)); - } - - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - - if (td->td_stripsperimage == 0) - { - TIFFErrorExtR(tif, module, "Zero strips per image"); - return ((tmsize_t)-1); - } - - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) - { - if (!(*tif->tif_setupencode)(tif)) - return ((tmsize_t)-1); - tif->tif_flags |= TIFF_CODERSETUP; - } - - tif->tif_flags &= ~TIFF_POSTENCODE; + tif->tif_flags &= ~TIFF_POSTENCODE; /* shortcut to avoid an extra memcpy() */ - if (td->td_compression == COMPRESSION_NONE) + if( td->td_compression == COMPRESSION_NONE ) { /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode(tif, (uint8_t *)data, cc); + tif->tif_postdecode( tif, (uint8*) data, cc ); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8_t *)data, cc); + TIFFReverseBits((uint8*) data, cc); - if (cc > 0 && !TIFFAppendToStrip(tif, strip, (uint8_t *)data, cc)) - return ((tmsize_t)-1); + if (cc > 0 && + !TIFFAppendToStrip(tif, strip, (uint8*) data, cc)) + return ((tmsize_t) -1); return (cc); } - sample = (uint16_t)(strip / td->td_stripsperimage); - if (!(*tif->tif_preencode)(tif, sample)) - return ((tmsize_t)-1); + sample = (uint16)(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_t *)data, cc); + /* swab if needed - note that source buffer will be altered */ + tif->tif_postdecode( tif, (uint8*) data, cc ); - if (!(*tif->tif_encodestrip)(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(tif->tif_rawdata, tif->tif_rawcc); - if (tif->tif_rawcc > 0 && - !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc)) - return ((tmsize_t)-1); - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - return (cc); + if (!(*tif->tif_encodestrip)(tif, (uint8*) 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(tif->tif_rawdata, tif->tif_rawcc); + if (tif->tif_rawcc > 0 && + !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc)) + return ((tmsize_t) -1); + tif->tif_rawcc = 0; + tif->tif_rawcp = tif->tif_rawdata; + return (cc); } /* @@ -325,78 +312,67 @@ tmsize_t TIFFWriteEncodedStrip(TIFF *tif, uint32_t strip, void *data, * * NB: Image length must be setup before writing. */ -tmsize_t TIFFWriteRawStrip(TIFF *tif, uint32_t strip, void *data, tmsize_t cc) +tmsize_t +TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc) { - static const char module[] = "TIFFWriteRawStrip"; - TIFFDirectory *td = &tif->tif_dir; + static const char module[] = "TIFFWriteRawStrip"; + TIFFDirectory *td = &tif->tif_dir; - if (!WRITECHECKSTRIPS(tif, module)) - return ((tmsize_t)-1); - /* - * Check strip array to make sure there's space. - * We don't support dynamically growing files that - * have data organized in separate bitplanes because - * it's too painful. In that case we require that - * the imagelength be set properly before the first - * write (so that the strips array will be fully - * allocated above). - */ - if (strip >= td->td_nstrips) - { - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - { - TIFFErrorExtR( - tif, module, - "Can not grow image by strips when using separate planes"); - return ((tmsize_t)-1); + if (!WRITECHECKSTRIPS(tif, module)) + return ((tmsize_t) -1); + /* + * Check strip array to make sure there's space. + * We don't support dynamically growing files that + * have data organized in separate bitplanes because + * it's too painful. In that case we require that + * the imagelength be set properly before the first + * write (so that the strips array will be fully + * allocated above). + */ + if (strip >= td->td_nstrips) { + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) { + TIFFErrorExt(tif->tif_clientdata, module, + "Can not grow image by strips when using separate planes"); + return ((tmsize_t) -1); + } + /* + * Watch out for a growing image. The value of + * strips/image will initially be 1 (since it + * can't be deduced until the imagelength is known). + */ + if (strip >= td->td_stripsperimage) + td->td_stripsperimage = + TIFFhowmany_32(td->td_imagelength,td->td_rowsperstrip); + if (!TIFFGrowStrips(tif, 1, module)) + return ((tmsize_t) -1); + } + tif->tif_curstrip = strip; + if (td->td_stripsperimage == 0) { + TIFFErrorExt(tif->tif_clientdata, module,"Zero strips per image"); + return ((tmsize_t) -1); } - /* - * Watch out for a growing image. The value of - * strips/image will initially be 1 (since it - * can't be deduced until the imagelength is known). - */ - if (strip >= td->td_stripsperimage) - td->td_stripsperimage = - TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip); - if (!TIFFGrowStrips(tif, 1, module)) - return ((tmsize_t)-1); - } - - if (tif->tif_curstrip != strip) - { - tif->tif_curstrip = strip; - - /* this informs TIFFAppendToStrip() we have changed or reset strip */ - tif->tif_curoff = 0; - } - - if (td->td_stripsperimage == 0) - { - TIFFErrorExtR(tif, module, "Zero strips per image"); - return ((tmsize_t)-1); - } - tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; - return (TIFFAppendToStrip(tif, strip, (uint8_t *)data, cc) ? cc - : (tmsize_t)-1); + tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip; + return (TIFFAppendToStrip(tif, strip, (uint8*) data, cc) ? + cc : (tmsize_t) -1); } /* * Write and compress a tile of data. The * tile is selected by the (x,y,z,s) coordinates. */ -tmsize_t TIFFWriteTile(TIFF *tif, void *buf, uint32_t x, uint32_t y, uint32_t z, - uint16_t s) +tmsize_t +TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s) { - if (!TIFFCheckTile(tif, x, y, z, s)) - return ((tmsize_t)(-1)); - /* - * NB: A tile size of -1 is used instead of tif_tilesize knowing - * that TIFFWriteEncodedTile will clamp this to the tile size. - * This is done because the tile size may not be defined until - * after the output buffer is setup in TIFFWriteBufferSetup. - */ - return (TIFFWriteEncodedTile(tif, TIFFComputeTile(tif, x, y, z, s), buf, - (tmsize_t)(-1))); + if (!TIFFCheckTile(tif, x, y, z, s)) + return ((tmsize_t)(-1)); + /* + * NB: A tile size of -1 is used instead of tif_tilesize knowing + * that TIFFWriteEncodedTile will clamp this to the tile size. + * This is done because the tile size may not be defined until + * after the output buffer is setup in TIFFWriteBufferSetup. + */ + return (TIFFWriteEncodedTile(tif, + TIFFComputeTile(tif, x, y, z, s), buf, (tmsize_t)(-1))); } /* @@ -411,111 +387,104 @@ tmsize_t TIFFWriteTile(TIFF *tif, void *buf, uint32_t x, uint32_t y, uint32_t z, * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ -tmsize_t TIFFWriteEncodedTile(TIFF *tif, uint32_t tile, void *data, tmsize_t cc) +tmsize_t +TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) { - static const char module[] = "TIFFWriteEncodedTile"; - TIFFDirectory *td; - uint16_t sample; - uint32_t howmany32; + static const char module[] = "TIFFWriteEncodedTile"; + TIFFDirectory *td; + uint16 sample; + uint32 howmany32; - if (!WRITECHECKTILES(tif, module)) - return ((tmsize_t)(-1)); - td = &tif->tif_dir; - if (tile >= td->td_nstrips) - { - TIFFErrorExtR(tif, module, "Tile %lu out of range, max %lu", - (unsigned long)tile, (unsigned long)td->td_nstrips); - return ((tmsize_t)(-1)); - } - /* - * Handle delayed allocation of data buffer. This - * permits it to be sized more intelligently (using - * directory information). - */ - if (!BUFFERCHECK(tif)) - return ((tmsize_t)(-1)); + if (!WRITECHECKTILES(tif, module)) + return ((tmsize_t)(-1)); + td = &tif->tif_dir; + if (tile >= td->td_nstrips) { + TIFFErrorExt(tif->tif_clientdata, module, "Tile %lu out of range, max %lu", + (unsigned long) tile, (unsigned long) td->td_nstrips); + return ((tmsize_t)(-1)); + } + /* + * Handle delayed allocation of data buffer. This + * permits it to be sized more intelligently (using + * directory information). + */ + if (!BUFFERCHECK(tif)) + return ((tmsize_t)(-1)); - tif->tif_flags |= TIFF_BUF4WRITE; + tif->tif_flags |= TIFF_BUF4WRITE; + tif->tif_curtile = tile; - tif->tif_curtile = tile; - - /* this informs TIFFAppendToStrip() we have changed or reset tile */ - tif->tif_curoff = 0; - - if (!_TIFFReserveLargeEnoughWriteBuffer(tif, tile)) - { - return ((tmsize_t)(-1)); - } - - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - - /* - * Compute tiles per row & per column to compute - * current row and column - */ - howmany32 = TIFFhowmany_32(td->td_imagelength, td->td_tilelength); - if (howmany32 == 0) - { - TIFFErrorExtR(tif, module, "Zero tiles"); - return ((tmsize_t)(-1)); - } - tif->tif_row = (tile % howmany32) * td->td_tilelength; - howmany32 = TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth); - if (howmany32 == 0) - { - TIFFErrorExtR(tif, module, "Zero tiles"); - return ((tmsize_t)(-1)); - } - tif->tif_col = (tile % howmany32) * td->td_tilewidth; - - if ((tif->tif_flags & TIFF_CODERSETUP) == 0) - { - if (!(*tif->tif_setupencode)(tif)) + if( !_TIFFReserveLargeEnoughWriteBuffer(tif, tile) ) { return ((tmsize_t)(-1)); - tif->tif_flags |= TIFF_CODERSETUP; - } - tif->tif_flags &= ~TIFF_POSTENCODE; + } - /* - * Clamp write amount to the tile size. This is mostly - * done so that callers can pass in some large number - * (e.g. -1) and have the tile size used instead. - */ - if (cc < 1 || cc > tif->tif_tilesize) - cc = tif->tif_tilesize; + tif->tif_rawcc = 0; + tif->tif_rawcp = tif->tif_rawdata; + + /* + * Compute tiles per row & per column to compute + * current row and column + */ + howmany32=TIFFhowmany_32(td->td_imagelength, td->td_tilelength); + if (howmany32 == 0) { + TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles"); + return ((tmsize_t)(-1)); + } + tif->tif_row = (tile % howmany32) * td->td_tilelength; + howmany32=TIFFhowmany_32(td->td_imagewidth, td->td_tilewidth); + if (howmany32 == 0) { + TIFFErrorExt(tif->tif_clientdata,module,"Zero tiles"); + return ((tmsize_t)(-1)); + } + tif->tif_col = (tile % howmany32) * td->td_tilewidth; + + if ((tif->tif_flags & TIFF_CODERSETUP) == 0) { + if (!(*tif->tif_setupencode)(tif)) + return ((tmsize_t)(-1)); + tif->tif_flags |= TIFF_CODERSETUP; + } + tif->tif_flags &= ~TIFF_POSTENCODE; + + /* + * Clamp write amount to the tile size. This is mostly + * done so that callers can pass in some large number + * (e.g. -1) and have the tile size used instead. + */ + if ( cc < 1 || cc > tif->tif_tilesize) + cc = tif->tif_tilesize; /* shortcut to avoid an extra memcpy() */ - if (td->td_compression == COMPRESSION_NONE) + if( td->td_compression == COMPRESSION_NONE ) { /* swab if needed - note that source buffer will be altered */ - tif->tif_postdecode(tif, (uint8_t *)data, cc); + tif->tif_postdecode( tif, (uint8*) data, cc ); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - TIFFReverseBits((uint8_t *)data, cc); + TIFFReverseBits((uint8*) data, cc); - if (cc > 0 && !TIFFAppendToStrip(tif, tile, (uint8_t *)data, cc)) - return ((tmsize_t)-1); + if (cc > 0 && + !TIFFAppendToStrip(tif, tile, (uint8*) data, cc)) + return ((tmsize_t) -1); return (cc); } - sample = (uint16_t)(tile / td->td_stripsperimage); + sample = (uint16)(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_t *)data, cc); + tif->tif_postdecode( tif, (uint8*) data, cc ); - if (!(*tif->tif_encodetile)(tif, (uint8_t *)data, cc, sample)) - return ((tmsize_t)-1); + if (!(*tif->tif_encodetile)(tif, (uint8*) data, cc, sample)) + return ((tmsize_t) -1); if (!(*tif->tif_postencode)(tif)) - return ((tmsize_t)(-1)); + return ((tmsize_t)(-1)); if (!isFillOrder(tif, td->td_fillorder) && (tif->tif_flags & TIFF_NOBITREV) == 0) - 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)); + TIFFReverseBits((uint8*)tif->tif_rawdata, tif->tif_rawcc); + if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile, + tif->tif_rawdata, tif->tif_rawcc)) + return ((tmsize_t)(-1)); tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; return (cc); @@ -530,64 +499,66 @@ tmsize_t TIFFWriteEncodedTile(TIFF *tif, uint32_t tile, void *data, tmsize_t cc) * interface does not support automatically growing * the image on each write (as TIFFWriteScanline does). */ -tmsize_t TIFFWriteRawTile(TIFF *tif, uint32_t tile, void *data, tmsize_t cc) +tmsize_t +TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc) { - static const char module[] = "TIFFWriteRawTile"; + static const char module[] = "TIFFWriteRawTile"; - if (!WRITECHECKTILES(tif, module)) - return ((tmsize_t)(-1)); - if (tile >= tif->tif_dir.td_nstrips) - { - TIFFErrorExtR(tif, module, "Tile %lu out of range, max %lu", - (unsigned long)tile, - (unsigned long)tif->tif_dir.td_nstrips); - return ((tmsize_t)(-1)); - } - return (TIFFAppendToStrip(tif, tile, (uint8_t *)data, cc) ? cc - : (tmsize_t)(-1)); + if (!WRITECHECKTILES(tif, module)) + return ((tmsize_t)(-1)); + if (tile >= tif->tif_dir.td_nstrips) { + TIFFErrorExt(tif->tif_clientdata, module, "Tile %lu out of range, max %lu", + (unsigned long) tile, + (unsigned long) tif->tif_dir.td_nstrips); + return ((tmsize_t)(-1)); + } + return (TIFFAppendToStrip(tif, tile, (uint8*) data, cc) ? + cc : (tmsize_t)(-1)); } -#define isUnspecified(tif, f) \ - (TIFFFieldSet(tif, f) && (tif)->tif_dir.td_imagelength == 0) +#define isUnspecified(tif, f) \ + (TIFFFieldSet(tif,f) && (tif)->tif_dir.td_imagelength == 0) -int TIFFSetupStrips(TIFF *tif) +int +TIFFSetupStrips(TIFF* tif) { - TIFFDirectory *td = &tif->tif_dir; + TIFFDirectory* td = &tif->tif_dir; - if (isTiled(tif)) - td->td_stripsperimage = isUnspecified(tif, FIELD_TILEDIMENSIONS) - ? td->td_samplesperpixel - : TIFFNumberOfTiles(tif); - else - td->td_stripsperimage = isUnspecified(tif, FIELD_ROWSPERSTRIP) - ? td->td_samplesperpixel - : TIFFNumberOfStrips(tif); - td->td_nstrips = td->td_stripsperimage; - /* TIFFWriteDirectoryTagData has a limitation to 0x80000000U bytes */ - if (td->td_nstrips >= - 0x80000000U / ((tif->tif_flags & TIFF_BIGTIFF) ? 0x8U : 0x4U)) - { - TIFFErrorExtR(tif, "TIFFSetupStrips", - "Too large Strip/Tile Offsets/ByteCounts arrays"); - return 0; - } - if (td->td_planarconfig == PLANARCONFIG_SEPARATE) - td->td_stripsperimage /= td->td_samplesperpixel; - td->td_stripoffset_p = (uint64_t *)_TIFFCheckMalloc( - tif, td->td_nstrips, sizeof(uint64_t), "for \"StripOffsets\" array"); - 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); - /* - * Place data at the end-of-file - * (by setting offsets to zero). - */ - _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); + if (isTiled(tif)) + td->td_stripsperimage = + isUnspecified(tif, FIELD_TILEDIMENSIONS) ? + td->td_samplesperpixel : TIFFNumberOfTiles(tif); + else + td->td_stripsperimage = + isUnspecified(tif, FIELD_ROWSPERSTRIP) ? + td->td_samplesperpixel : TIFFNumberOfStrips(tif); + td->td_nstrips = td->td_stripsperimage; + /* TIFFWriteDirectoryTagData has a limitation to 0x80000000U bytes */ + if( td->td_nstrips >= 0x80000000U / ((tif->tif_flags&TIFF_BIGTIFF)?0x8U:0x4U) ) + { + TIFFErrorExt(tif->tif_clientdata, "TIFFSetupStrips", + "Too large Strip/Tile Offsets/ByteCounts arrays"); + return 0; + } + if (td->td_planarconfig == PLANARCONFIG_SEPARATE) + td->td_stripsperimage /= td->td_samplesperpixel; + td->td_stripoffset_p = (uint64 *) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + "for \"StripOffsets\" array"); + td->td_stripbytecount_p = (uint64 *) + _TIFFCheckMalloc(tif, td->td_nstrips, sizeof (uint64), + "for \"StripByteCounts\" array"); + if (td->td_stripoffset_p == NULL || td->td_stripbytecount_p == NULL) + return (0); + /* + * 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)); + TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS); + TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS); + return (1); } #undef isUnspecified @@ -597,325 +568,241 @@ int TIFFSetupStrips(TIFF *tif) * we also "freeze" the state of the directory so * that important information is not changed. */ -int TIFFWriteCheck(TIFF *tif, int tiles, const char *module) +int +TIFFWriteCheck(TIFF* tif, int tiles, const char* module) { - if (tif->tif_mode == O_RDONLY) - { - TIFFErrorExtR(tif, module, "File not open for writing"); - return (0); - } - if (tiles ^ isTiled(tif)) - { - TIFFErrorExtR(tif, module, - tiles ? "Can not write tiles to a striped image" - : "Can not write scanlines to a tiled image"); - return (0); - } + if (tif->tif_mode == O_RDONLY) { + TIFFErrorExt(tif->tif_clientdata, module, "File not open for writing"); + return (0); + } + if (tiles ^ isTiled(tif)) { + TIFFErrorExt(tif->tif_clientdata, module, tiles ? + "Can not write tiles to a striped image" : + "Can not write scanlines to a tiled image"); + return (0); + } - _TIFFFillStriles(tif); + _TIFFFillStriles( tif ); + + /* + * On the first write verify all the required information + * has been setup and initialize any data structures that + * had to wait until directory information was set. + * Note that a lot of our work is assumed to remain valid + * because we disallow any of the important parameters + * from changing after we start writing (i.e. once + * TIFF_BEENWRITING is set, TIFFSetField will only allow + * the image's length to be changed). + */ + if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Must set \"ImageWidth\" before writing data"); + return (0); + } + if (tif->tif_dir.td_samplesperpixel == 1) { + /* + * Planarconfiguration is irrelevant in case of single band + * images and need not be included. We will set it anyway, + * because this field is used in other parts of library even + * in the single band case. + */ + if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) + tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG; + } else { + if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) { + TIFFErrorExt(tif->tif_clientdata, module, + "Must set \"PlanarConfiguration\" before writing data"); + return (0); + } + } + if (tif->tif_dir.td_stripoffset_p == NULL && !TIFFSetupStrips(tif)) { + tif->tif_dir.td_nstrips = 0; + TIFFErrorExt(tif->tif_clientdata, module, "No space for %s arrays", + isTiled(tif) ? "tile" : "strip"); + return (0); + } + if (isTiled(tif)) + { + tif->tif_tilesize = TIFFTileSize(tif); + if (tif->tif_tilesize == 0) + return (0); + } + else + tif->tif_tilesize = (tmsize_t)(-1); + tif->tif_scanlinesize = TIFFScanlineSize(tif); + if (tif->tif_scanlinesize == 0) + return (0); + tif->tif_flags |= TIFF_BEENWRITING; - /* - * On the first write verify all the required information - * has been setup and initialize any data structures that - * had to wait until directory information was set. - * Note that a lot of our work is assumed to remain valid - * because we disallow any of the important parameters - * from changing after we start writing (i.e. once - * TIFF_BEENWRITING is set, TIFFSetField will only allow - * the image's length to be changed). - */ - if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) - { - TIFFErrorExtR(tif, module, - "Must set \"ImageWidth\" before writing data"); - return (0); - } - if (tif->tif_dir.td_stripoffset_p == NULL && !TIFFSetupStrips(tif)) - { - tif->tif_dir.td_nstrips = 0; - TIFFErrorExtR(tif, module, "No space for %s arrays", - isTiled(tif) ? "tile" : "strip"); - return (0); - } - if (isTiled(tif)) - { - tif->tif_tilesize = TIFFTileSize(tif); - if (tif->tif_tilesize == 0) - return (0); - } - else - tif->tif_tilesize = (tmsize_t)(-1); - tif->tif_scanlinesize = TIFFScanlineSize(tif); - if (tif->tif_scanlinesize == 0) - return (0); - tif->tif_flags |= TIFF_BEENWRITING; + if( tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 && + tif->tif_dir.td_stripoffset_entry.tdir_count == 0 && + tif->tif_dir.td_stripoffset_entry.tdir_type == 0 && + tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 && + tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0 && + !(tif->tif_flags & TIFF_DIRTYDIRECT) ) + { + TIFFForceStrileArrayWriting(tif); + } - if (tif->tif_dir.td_stripoffset_entry.tdir_tag != 0 && - tif->tif_dir.td_stripoffset_entry.tdir_count == 0 && - tif->tif_dir.td_stripoffset_entry.tdir_type == 0 && - tif->tif_dir.td_stripoffset_entry.tdir_offset.toff_long8 == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_tag != 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_count == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_type == 0 && - tif->tif_dir.td_stripbytecount_entry.tdir_offset.toff_long8 == 0 && - !(tif->tif_flags & TIFF_DIRTYDIRECT)) - { - TIFFForceStrileArrayWriting(tif); - } - - return (1); + return (1); } /* * Setup the raw data buffer used for encoding. */ -int TIFFWriteBufferSetup(TIFF *tif, void *bp, tmsize_t size) +int +TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size) { - static const char module[] = "TIFFWriteBufferSetup"; + static const char module[] = "TIFFWriteBufferSetup"; - if (tif->tif_rawdata) - { - if (tif->tif_flags & TIFF_MYBUFFER) - { - _TIFFfreeExt(tif, tif->tif_rawdata); - tif->tif_flags &= ~TIFF_MYBUFFER; - } - tif->tif_rawdata = NULL; - } - if (size == (tmsize_t)(-1)) - { - size = (isTiled(tif) ? tif->tif_tilesize : TIFFStripSize(tif)); + if (tif->tif_rawdata) { + if (tif->tif_flags & TIFF_MYBUFFER) { + _TIFFfree(tif->tif_rawdata); + tif->tif_flags &= ~TIFF_MYBUFFER; + } + tif->tif_rawdata = NULL; + } + if (size == (tmsize_t)(-1)) { + size = (isTiled(tif) ? + tif->tif_tilesize : TIFFStripSize(tif)); - /* Adds 10% margin for cases where compression would expand a bit */ - if (size < TIFF_TMSIZE_T_MAX - size / 10) - size += size / 10; - /* - * Make raw data buffer at least 8K - */ - if (size < 8 * 1024) - size = 8 * 1024; - bp = NULL; /* NB: force malloc */ - } - if (bp == NULL) - { - bp = _TIFFmallocExt(tif, size); - if (bp == NULL) - { - TIFFErrorExtR(tif, module, "No space for output buffer"); - return (0); - } - tif->tif_flags |= TIFF_MYBUFFER; - } - else - tif->tif_flags &= ~TIFF_MYBUFFER; - tif->tif_rawdata = (uint8_t *)bp; - tif->tif_rawdatasize = size; - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - tif->tif_flags |= TIFF_BUFFERSETUP; - return (1); + /* Adds 10% margin for cases where compression would expand a bit */ + if( size < TIFF_TMSIZE_T_MAX - size / 10 ) + size += size / 10; + /* + * Make raw data buffer at least 8K + */ + if (size < 8*1024) + size = 8*1024; + bp = NULL; /* NB: force malloc */ + } + if (bp == NULL) { + bp = _TIFFmalloc(size); + if (bp == NULL) { + TIFFErrorExt(tif->tif_clientdata, module, "No space for output buffer"); + return (0); + } + tif->tif_flags |= TIFF_MYBUFFER; + } else + tif->tif_flags &= ~TIFF_MYBUFFER; + tif->tif_rawdata = (uint8*) bp; + tif->tif_rawdatasize = size; + tif->tif_rawcc = 0; + tif->tif_rawcp = tif->tif_rawdata; + tif->tif_flags |= TIFF_BUFFERSETUP; + return (1); } /* * Grow the strip data structures by delta strips. */ -static int TIFFGrowStrips(TIFF *tif, uint32_t delta, const char *module) +static int +TIFFGrowStrips(TIFF* tif, uint32 delta, const char* module) { - TIFFDirectory *td = &tif->tif_dir; - uint64_t *new_stripoffset; - uint64_t *new_stripbytecount; + TIFFDirectory *td = &tif->tif_dir; + uint64* new_stripoffset; + uint64* new_stripbytecount; - assert(td->td_planarconfig == PLANARCONFIG_CONTIG); - new_stripoffset = (uint64_t *)_TIFFreallocExt( - tif, td->td_stripoffset_p, (td->td_nstrips + delta) * sizeof(uint64_t)); - new_stripbytecount = (uint64_t *)_TIFFreallocExt( - tif, td->td_stripbytecount_p, - (td->td_nstrips + delta) * sizeof(uint64_t)); - if (new_stripoffset == NULL || new_stripbytecount == NULL) - { - if (new_stripoffset) - _TIFFfreeExt(tif, new_stripoffset); - if (new_stripbytecount) - _TIFFfreeExt(tif, new_stripbytecount); - td->td_nstrips = 0; - TIFFErrorExtR(tif, module, "No space to expand strip arrays"); - return (0); - } - td->td_stripoffset_p = new_stripoffset; - td->td_stripbytecount_p = new_stripbytecount; - _TIFFmemset(td->td_stripoffset_p + td->td_nstrips, 0, - delta * sizeof(uint64_t)); - _TIFFmemset(td->td_stripbytecount_p + td->td_nstrips, 0, - delta * sizeof(uint64_t)); - td->td_nstrips += delta; - tif->tif_flags |= TIFF_DIRTYDIRECT; + 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)); + if (new_stripoffset == NULL || new_stripbytecount == NULL) { + if (new_stripoffset) + _TIFFfree(new_stripoffset); + if (new_stripbytecount) + _TIFFfree(new_stripbytecount); + td->td_nstrips = 0; + TIFFErrorExt(tif->tif_clientdata, module, "No space to expand strip arrays"); + return (0); + } + td->td_stripoffset_p = new_stripoffset; + td->td_stripbytecount_p = new_stripbytecount; + _TIFFmemset(td->td_stripoffset_p + td->td_nstrips, + 0, delta*sizeof (uint64)); + _TIFFmemset(td->td_stripbytecount_p + td->td_nstrips, + 0, delta*sizeof (uint64)); + td->td_nstrips += delta; + tif->tif_flags |= TIFF_DIRTYDIRECT; - return (1); + return (1); } /* * Append the data to the specified strip. */ -static int TIFFAppendToStrip(TIFF *tif, uint32_t strip, uint8_t *data, - tmsize_t cc) +static int +TIFFAppendToStrip(TIFF* tif, uint32 strip, uint8* data, tmsize_t cc) { - static const char module[] = "TIFFAppendToStrip"; - TIFFDirectory *td = &tif->tif_dir; - uint64_t m; - int64_t old_byte_count = -1; + static const char module[] = "TIFFAppendToStrip"; + TIFFDirectory *td = &tif->tif_dir; + uint64 m; + int64 old_byte_count = -1; - if (tif->tif_curoff == 0) - tif->tif_lastvalidoff = 0; + if (td->td_stripoffset_p[strip] == 0 || tif->tif_curoff == 0) { + assert(td->td_nstrips > 0); - 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_t)cc) - { - /* - * There is already tile data on disk, and the new tile - * data we have will fit in the same space. The only - * aspect of this that is risky is that there could be - * more data to append to this strip before we are done - * depending on how we are getting called. - */ - if (!SeekOK(tif, td->td_stripoffset_p[strip])) + if( td->td_stripbytecount_p[strip] != 0 + && td->td_stripoffset_p[strip] != 0 + && td->td_stripbytecount_p[strip] >= (uint64) cc ) { - TIFFErrorExtR(tif, module, "Seek error at scanline %lu", - (unsigned long)tif->tif_row); - return (0); + /* + * There is already tile data on disk, and the new tile + * data we have will fit in the same space. The only + * aspect of this that is risky is that there could be + * more data to append to this strip before we are done + * depending on how we are getting called. + */ + if (!SeekOK(tif, td->td_stripoffset_p[strip])) { + TIFFErrorExt(tif->tif_clientdata, module, + "Seek error at scanline %lu", + (unsigned long)tif->tif_row); + return (0); + } + } + else + { + /* + * Seek to end of file, and set that as our location to + * write this strip. + */ + td->td_stripoffset_p[strip] = TIFFSeekFile(tif, 0, SEEK_END); + tif->tif_flags |= TIFF_DIRTYSTRIP; } - tif->tif_lastvalidoff = - td->td_stripoffset_p[strip] + td->td_stripbytecount_p[strip]; - } - else - { + tif->tif_curoff = td->td_stripoffset_p[strip]; + /* - * Seek to end of file, and set that as our location to - * write this strip. + * We are starting a fresh strip/tile, so set the size to zero. */ - td->td_stripoffset_p[strip] = TIFFSeekFile(tif, 0, SEEK_END); + old_byte_count = td->td_stripbytecount_p[strip]; + td->td_stripbytecount_p[strip] = 0; + } + + m = tif->tif_curoff+cc; + if (!(tif->tif_flags&TIFF_BIGTIFF)) + m = (uint32)m; + if ((mtif_curoff)||(m<(uint64)cc)) + { + TIFFErrorExt(tif->tif_clientdata, module, "Maximum TIFF file size exceeded"); + return (0); + } + if (!WriteOK(tif, data, cc)) { + TIFFErrorExt(tif->tif_clientdata, module, "Write error at scanline %lu", + (unsigned long) tif->tif_row); + return (0); + } + tif->tif_curoff = m; + td->td_stripbytecount_p[strip] += cc; + + if( (int64) td->td_stripbytecount_p[strip] != old_byte_count ) tif->tif_flags |= TIFF_DIRTYSTRIP; - } - - tif->tif_curoff = td->td_stripoffset_p[strip]; - - /* - * We are starting a fresh strip/tile, so set the size to zero. - */ - old_byte_count = td->td_stripbytecount_p[strip]; - td->td_stripbytecount_p[strip] = 0; - } - - m = tif->tif_curoff + cc; - if (!(tif->tif_flags & TIFF_BIGTIFF)) - m = (uint32_t)m; - if ((m < tif->tif_curoff) || (m < (uint64_t)cc)) - { - TIFFErrorExtR(tif, module, "Maximum TIFF file size exceeded"); - return (0); - } - - if (tif->tif_lastvalidoff != 0 && m > tif->tif_lastvalidoff && - td->td_stripbytecount_p[strip] > 0) - { - /* Ouch: we have detected that we are rewriting in place a strip/tile */ - /* with several calls to TIFFAppendToStrip(). The first call was with */ - /* a size smaller than the previous size of the strip/tile, so we */ - /* opted to rewrite in place, but a following call causes us to go */ - /* outsize of the strip/tile area, so we have to finally go for a */ - /* append-at-end-of-file strategy, and start by moving what we already - */ - /* wrote. */ - tmsize_t tempSize; - void *temp; - uint64_t offsetRead; - uint64_t offsetWrite; - uint64_t toCopy = td->td_stripbytecount_p[strip]; - - if (toCopy < 1024 * 1024) - tempSize = (tmsize_t)toCopy; - else - tempSize = 1024 * 1024; - - offsetRead = td->td_stripoffset_p[strip]; - offsetWrite = TIFFSeekFile(tif, 0, SEEK_END); - - m = offsetWrite + toCopy + cc; - if (!(tif->tif_flags & TIFF_BIGTIFF) && m != (uint32_t)m) - { - TIFFErrorExtR(tif, module, "Maximum TIFF file size exceeded"); - return (0); - } - - temp = _TIFFmallocExt(tif, tempSize); - if (temp == NULL) - { - TIFFErrorExtR(tif, module, "No space for output buffer"); - return (0); - } - - tif->tif_flags |= TIFF_DIRTYSTRIP; - - td->td_stripoffset_p[strip] = offsetWrite; - td->td_stripbytecount_p[strip] = 0; - - /* Move data written by previous calls to us at end of file */ - while (toCopy > 0) - { - if (!SeekOK(tif, offsetRead)) - { - TIFFErrorExtR(tif, module, "Seek error"); - _TIFFfreeExt(tif, temp); - return (0); - } - if (!ReadOK(tif, temp, tempSize)) - { - TIFFErrorExtR(tif, module, "Cannot read"); - _TIFFfreeExt(tif, temp); - return (0); - } - if (!SeekOK(tif, offsetWrite)) - { - TIFFErrorExtR(tif, module, "Seek error"); - _TIFFfreeExt(tif, temp); - return (0); - } - if (!WriteOK(tif, temp, tempSize)) - { - TIFFErrorExtR(tif, module, "Cannot write"); - _TIFFfreeExt(tif, temp); - return (0); - } - offsetRead += tempSize; - offsetWrite += tempSize; - td->td_stripbytecount_p[strip] += tempSize; - toCopy -= tempSize; - } - _TIFFfreeExt(tif, temp); - - /* Append the data of this call */ - offsetWrite += cc; - m = offsetWrite; - } - - if (!WriteOK(tif, data, cc)) - { - TIFFErrorExtR(tif, module, "Write error at scanline %lu", - (unsigned long)tif->tif_row); - return (0); - } - tif->tif_curoff = m; - td->td_stripbytecount_p[strip] += cc; - - if ((int64_t)td->td_stripbytecount_p[strip] != old_byte_count) - tif->tif_flags |= TIFF_DIRTYSTRIP; - - return (1); + + return (1); } /* @@ -923,28 +810,29 @@ static int TIFFAppendToStrip(TIFF *tif, uint32_t strip, uint8_t *data, * called by ``encodestrip routines'' w/o concern * for infinite recursion. */ -int TIFFFlushData1(TIFF *tif) +int +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_t *)tif->tif_rawdata, tif->tif_rawcc); - if (!TIFFAppendToStrip( - tif, isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, - tif->tif_rawdata, tif->tif_rawcc)) + 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, + tif->tif_rawcc); + if (!TIFFAppendToStrip(tif, + isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip, + tif->tif_rawdata, tif->tif_rawcc)) { /* We update those variables even in case of error since there's */ /* code that doesn't really check the return code of this */ /* function */ tif->tif_rawcc = 0; tif->tif_rawcp = tif->tif_rawdata; - return (0); + return (0); } - tif->tif_rawcc = 0; - tif->tif_rawcp = tif->tif_rawdata; - } - return (1); + tif->tif_rawcc = 0; + tif->tif_rawcp = tif->tif_rawdata; + } + return (1); } /* @@ -953,8 +841,17 @@ int TIFFFlushData1(TIFF *tif) * (very carefully), or to 0 so that the next write gets * appended to the end of the file. */ -void TIFFSetWriteOffset(TIFF *tif, toff_t off) +void +TIFFSetWriteOffset(TIFF* tif, toff_t off) { - tif->tif_curoff = off; - tif->tif_lastvalidoff = 0; + tif->tif_curoff = off; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_zip.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_zip.c index fcf510044..b9f9da494 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_zip.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_zip.c @@ -2,23 +2,23 @@ * Copyright (c) 1995-1997 Sam Leffler * Copyright (c) 1995-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -57,675 +57,644 @@ #error "Antiquated ZLIB software; you must use version 1.0 or later" #endif -#define SAFE_MSG(sp) ((sp)->stream.msg == NULL ? "" : (sp)->stream.msg) +#define SAFE_MSG(sp) ((sp)->stream.msg == NULL ? "" : (sp)->stream.msg) /* * State block for each open TIFF * file using ZIP compression/decompression. */ -typedef struct -{ - TIFFPredictorState predict; - z_stream stream; - int zipquality; /* compression level */ - int state; /* state flags */ - int subcodec; /* DEFLATE_SUBCODEC_ZLIB or DEFLATE_SUBCODEC_LIBDEFLATE */ +typedef struct { + TIFFPredictorState predict; + z_stream stream; + int zipquality; /* compression level */ + int state; /* state flags */ + int subcodec; /* DEFLATE_SUBCODEC_ZLIB or DEFLATE_SUBCODEC_LIBDEFLATE */ #if LIBDEFLATE_SUPPORT - int libdeflate_state; /* -1 = until first time ZIPEncode() / ZIPDecode() is - called, 0 = use zlib, 1 = use libdeflate */ - struct libdeflate_decompressor *libdeflate_dec; - struct libdeflate_compressor *libdeflate_enc; + int libdeflate_state; /* -1 = until first time ZIPEncode() / ZIPDecode() is called, 0 = use zlib, 1 = use libdeflate */ + struct libdeflate_decompressor* libdeflate_dec; + struct libdeflate_compressor* libdeflate_enc; #endif #define ZSTATE_INIT_DECODE 0x01 #define ZSTATE_INIT_ENCODE 0x02 - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ } ZIPState; -#define ZState(tif) ((ZIPState *)(tif)->tif_data) -#define DecoderState(tif) ZState(tif) -#define EncoderState(tif) ZState(tif) +#define ZState(tif) ((ZIPState*) (tif)->tif_data) +#define DecoderState(tif) ZState(tif) +#define EncoderState(tif) ZState(tif) -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 ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); +static int ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); -static int ZIPFixupTags(TIFF *tif) +static int +ZIPFixupTags(TIFF* tif) { - (void)tif; - return (1); + (void) tif; + return (1); } -static int ZIPSetupDecode(TIFF *tif) +static int +ZIPSetupDecode(TIFF* tif) { - static const char module[] = "ZIPSetupDecode"; - ZIPState *sp = DecoderState(tif); + static const char module[] = "ZIPSetupDecode"; + ZIPState* sp = DecoderState(tif); - assert(sp != NULL); + assert(sp != NULL); + + /* if we were last encoding, terminate this mode */ + if (sp->state & ZSTATE_INIT_ENCODE) { + deflateEnd(&sp->stream); + sp->state = 0; + } - /* if we were last encoding, terminate this mode */ - if (sp->state & ZSTATE_INIT_ENCODE) - { - deflateEnd(&sp->stream); - sp->state = 0; - } - - /* This function can possibly be called several times by */ - /* PredictorSetupDecode() if this function succeeds but */ - /* PredictorSetup() fails */ - if ((sp->state & ZSTATE_INIT_DECODE) == 0 && - inflateInit(&sp->stream) != Z_OK) - { - TIFFErrorExtR(tif, module, "%s", SAFE_MSG(sp)); - return (0); - } - else - { - sp->state |= ZSTATE_INIT_DECODE; - return (1); - } + /* This function can possibly be called several times by */ + /* PredictorSetupDecode() if this function succeeds but */ + /* PredictorSetup() fails */ + if ((sp->state & ZSTATE_INIT_DECODE) == 0 && + inflateInit(&sp->stream) != Z_OK) { + TIFFErrorExt(tif->tif_clientdata, module, "%s", SAFE_MSG(sp)); + return (0); + } else { + sp->state |= ZSTATE_INIT_DECODE; + return (1); + } } /* * Setup state for decoding a strip. */ -static int ZIPPreDecode(TIFF *tif, uint16_t s) +static int +ZIPPreDecode(TIFF* tif, uint16 s) { - ZIPState *sp = DecoderState(tif); + ZIPState* sp = DecoderState(tif); - (void)s; - assert(sp != NULL); + (void) s; + assert(sp != NULL); - if ((sp->state & ZSTATE_INIT_DECODE) == 0) - tif->tif_setupdecode(tif); + if( (sp->state & ZSTATE_INIT_DECODE) == 0 ) + tif->tif_setupdecode( tif ); #if LIBDEFLATE_SUPPORT - sp->libdeflate_state = -1; + sp->libdeflate_state = -1; #endif - sp->stream.next_in = tif->tif_rawdata; - assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised, - we need to simplify this code to reflect a ZLib that is likely updated - to deal with 8byte memory sizes, though this code will respond - appropriately even before we simplify it */ - sp->stream.avail_in = (uint64_t)tif->tif_rawcc < 0xFFFFFFFFU - ? (uInt)tif->tif_rawcc - : 0xFFFFFFFFU; - return (inflateReset(&sp->stream) == Z_OK); + sp->stream.next_in = tif->tif_rawdata; + assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + appropriately even before we simplify it */ + sp->stream.avail_in = (uint64)tif->tif_rawcc < 0xFFFFFFFFU ? (uInt) tif->tif_rawcc : 0xFFFFFFFFU; + return (inflateReset(&sp->stream) == Z_OK); } -static int ZIPDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) +static int +ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - static const char module[] = "ZIPDecode"; - ZIPState *sp = DecoderState(tif); + static const char module[] = "ZIPDecode"; + ZIPState* sp = DecoderState(tif); - (void)s; - assert(sp != NULL); - assert(sp->state == ZSTATE_INIT_DECODE); + (void) s; + assert(sp != NULL); + assert(sp->state == ZSTATE_INIT_DECODE); #if LIBDEFLATE_SUPPORT - if (sp->libdeflate_state == 1) - return 0; + if( sp->libdeflate_state == 1 ) + return 0; - /* If we have libdeflate support and we are asked to read a whole */ - /* strip/tile, then go for using it */ - do - { - TIFFDirectory *td = &tif->tif_dir; + /* If we have libdeflate support and we are asked to read a whole */ + /* strip/tile, then go for using it */ + do { + TIFFDirectory *td = &tif->tif_dir; - if (sp->libdeflate_state == 0) - break; - if (sp->subcodec == DEFLATE_SUBCODEC_ZLIB) - break; - - /* Check if we are in the situation where we can use libdeflate */ - if (isTiled(tif)) - { - if (TIFFTileSize64(tif) != (uint64_t)occ) + if( sp->libdeflate_state == 0 ) break; - } - else - { - 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_t)occ) + if( sp->subcodec == DEFLATE_SUBCODEC_ZLIB ) break; - } - /* Check for overflow */ - if ((size_t)tif->tif_rawcc != (uint64_t)tif->tif_rawcc) - break; - if ((size_t)occ != (uint64_t)occ) - break; - - /* Go for decompression using libdeflate */ - { - enum libdeflate_result res; - if (sp->libdeflate_dec == NULL) - { - sp->libdeflate_dec = libdeflate_alloc_decompressor(); - if (sp->libdeflate_dec == NULL) - { + /* Check if we are in the situation where we can use libdeflate */ + if (isTiled(tif)) { + if( TIFFTileSize64(tif) != (uint64)occ ) + break; + } else { + uint32 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 ) break; - } } - sp->libdeflate_state = 1; + /* Check for overflow */ + if( (size_t)tif->tif_rawcc != (uint64)tif->tif_rawcc ) + break; + if( (size_t)occ != (uint64)occ ) + break; - res = libdeflate_zlib_decompress(sp->libdeflate_dec, tif->tif_rawcp, - (size_t)tif->tif_rawcc, op, - (size_t)occ, NULL); - - tif->tif_rawcp += tif->tif_rawcc; - tif->tif_rawcc = 0; - - /* We accept LIBDEFLATE_INSUFFICIENT_SPACE has a return */ - /* There are odd files in the wild where the last strip, when */ - /* it is smaller in height than td_rowsperstrip, actually contains - */ - /* data for td_rowsperstrip lines. Just ignore that silently. */ - if (res != LIBDEFLATE_SUCCESS && - res != LIBDEFLATE_INSUFFICIENT_SPACE) + /* Go for decompression using libdeflate */ { - TIFFErrorExtR(tif, module, "Decoding error at scanline %lu", - (unsigned long)tif->tif_row); - return 0; - } + enum libdeflate_result res; + if( sp->libdeflate_dec == NULL ) + { + sp->libdeflate_dec = libdeflate_alloc_decompressor(); + if( sp->libdeflate_dec == NULL ) + { + break; + } + } - return 1; - } - } while (0); - sp->libdeflate_state = 0; + sp->libdeflate_state = 1; + + res = libdeflate_zlib_decompress( + sp->libdeflate_dec, tif->tif_rawcp, (size_t)tif->tif_rawcc, op, (size_t)occ, NULL); + + tif->tif_rawcp += tif->tif_rawcc; + tif->tif_rawcc = 0; + + /* We accept LIBDEFLATE_INSUFFICIENT_SPACE has a return */ + /* There are odd files in the wild where the last strip, when */ + /* it is smaller in height than td_rowsperstrip, actually contains */ + /* data for td_rowsperstrip lines. Just ignore that silently. */ + if( res != LIBDEFLATE_SUCCESS && + res != LIBDEFLATE_INSUFFICIENT_SPACE ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Decoding error at scanline %lu", + (unsigned long) tif->tif_row); + return 0; + } + + return 1; + } + } while(0); + sp->libdeflate_state = 0; #endif /* LIBDEFLATE_SUPPORT */ - sp->stream.next_in = tif->tif_rawcp; + sp->stream.next_in = tif->tif_rawcp; + + sp->stream.next_out = op; + assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + appropriately even before we simplify it */ + do { + int state; + uInt avail_in_before = (uint64)tif->tif_rawcc <= 0xFFFFFFFFULL ? (uInt)tif->tif_rawcc : 0xFFFFFFFFU; + uInt avail_out_before = (uint64)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); + tif->tif_rawcc -= (avail_in_before - sp->stream.avail_in); + occ -= (avail_out_before - sp->stream.avail_out); + if (state == Z_STREAM_END) + break; + if (state == Z_DATA_ERROR) { + TIFFErrorExt(tif->tif_clientdata, module, + "Decoding error at scanline %lu, %s", + (unsigned long) tif->tif_row, SAFE_MSG(sp)); + return (0); + } + if (state != Z_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "ZLib error: %s", SAFE_MSG(sp)); + return (0); + } + } 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); + return (0); + } - sp->stream.next_out = op; - assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised, - we need to simplify this code to reflect a ZLib that is likely updated - to deal with 8byte memory sizes, though this code will respond - appropriately even before we simplify it */ - do - { - int state; - 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; - /* coverity[overrun-buffer-arg] */ - state = inflate(&sp->stream, Z_PARTIAL_FLUSH); - tif->tif_rawcc -= (avail_in_before - sp->stream.avail_in); - occ -= (avail_out_before - sp->stream.avail_out); - if (state == Z_STREAM_END) - break; - if (state == Z_DATA_ERROR) - { - TIFFErrorExtR(tif, module, "Decoding error at scanline %lu, %s", - (unsigned long)tif->tif_row, SAFE_MSG(sp)); - return (0); - } - if (state != Z_OK) - { - TIFFErrorExtR(tif, module, "ZLib error: %s", SAFE_MSG(sp)); - return (0); - } - } while (occ > 0); - if (occ != 0) - { - TIFFErrorExtR(tif, module, - "Not enough data at scanline %lu (short %" PRIu64 - " bytes)", - (unsigned long)tif->tif_row, (uint64_t)occ); - return (0); - } + tif->tif_rawcp = sp->stream.next_in; - tif->tif_rawcp = sp->stream.next_in; - - return (1); + return (1); } -static int ZIPSetupEncode(TIFF *tif) +static int +ZIPSetupEncode(TIFF* tif) { - static const char module[] = "ZIPSetupEncode"; - ZIPState *sp = EncoderState(tif); - int cappedQuality; + static const char module[] = "ZIPSetupEncode"; + ZIPState* sp = EncoderState(tif); + int cappedQuality; - assert(sp != NULL); - if (sp->state & ZSTATE_INIT_DECODE) - { - inflateEnd(&sp->stream); - sp->state = 0; - } + assert(sp != NULL); + if (sp->state & ZSTATE_INIT_DECODE) { + inflateEnd(&sp->stream); + sp->state = 0; + } - cappedQuality = sp->zipquality; - if (cappedQuality > Z_BEST_COMPRESSION) - cappedQuality = Z_BEST_COMPRESSION; + cappedQuality = sp->zipquality; + if( cappedQuality > Z_BEST_COMPRESSION ) + cappedQuality = Z_BEST_COMPRESSION; - if (deflateInit(&sp->stream, cappedQuality) != Z_OK) - { - TIFFErrorExtR(tif, module, "%s", SAFE_MSG(sp)); - return (0); - } - else - { - sp->state |= ZSTATE_INIT_ENCODE; - return (1); - } + if (deflateInit(&sp->stream, cappedQuality) != Z_OK) { + TIFFErrorExt(tif->tif_clientdata, module, "%s", SAFE_MSG(sp)); + return (0); + } else { + sp->state |= ZSTATE_INIT_ENCODE; + return (1); + } } /* * Reset encoding state at the start of a strip. */ -static int ZIPPreEncode(TIFF *tif, uint16_t s) +static int +ZIPPreEncode(TIFF* tif, uint16 s) { - ZIPState *sp = EncoderState(tif); + ZIPState *sp = EncoderState(tif); - (void)s; - assert(sp != NULL); - if (sp->state != ZSTATE_INIT_ENCODE) - tif->tif_setupencode(tif); + (void) s; + assert(sp != NULL); + if( sp->state != ZSTATE_INIT_ENCODE ) + tif->tif_setupencode( tif ); #if LIBDEFLATE_SUPPORT - sp->libdeflate_state = -1; + sp->libdeflate_state = -1; #endif - sp->stream.next_out = tif->tif_rawdata; - assert(sizeof(sp->stream.avail_out) == 4); /* if this assert gets raised, - we need to simplify this code to reflect a ZLib that is likely updated - to deal with 8byte memory sizes, though this code will respond - appropriately even before we simplify it */ - sp->stream.avail_out = (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU - ? (uInt)tif->tif_rawdatasize - : 0xFFFFFFFFU; - return (deflateReset(&sp->stream) == Z_OK); + sp->stream.next_out = tif->tif_rawdata; + assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + appropriately even before we simplify it */ + sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFULL ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; + return (deflateReset(&sp->stream) == Z_OK); } /* * Encode a chunk of pixels. */ -static int ZIPEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +static int +ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "ZIPEncode"; - ZIPState *sp = EncoderState(tif); + static const char module[] = "ZIPEncode"; + ZIPState *sp = EncoderState(tif); - assert(sp != NULL); - assert(sp->state == ZSTATE_INIT_ENCODE); + assert(sp != NULL); + assert(sp->state == ZSTATE_INIT_ENCODE); - (void)s; + (void) s; #if LIBDEFLATE_SUPPORT - if (sp->libdeflate_state == 1) - return 0; + if( sp->libdeflate_state == 1 ) + return 0; - /* If we have libdeflate support and we are asked to write a whole */ - /* strip/tile, then go for using it */ - do - { - TIFFDirectory *td = &tif->tif_dir; + /* If we have libdeflate support and we are asked to write a whole */ + /* strip/tile, then go for using it */ + do { + TIFFDirectory *td = &tif->tif_dir; - if (sp->libdeflate_state == 0) - break; - if (sp->subcodec == DEFLATE_SUBCODEC_ZLIB) - break; - - /* Libdeflate does not support the 0-compression level */ - if (sp->zipquality == Z_NO_COMPRESSION) - break; - - /* Check if we are in the situation where we can use libdeflate */ - if (isTiled(tif)) - { - if (TIFFTileSize64(tif) != (uint64_t)cc) + if( sp->libdeflate_state == 0 ) break; - } - else - { - 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_t)cc) + if( sp->subcodec == DEFLATE_SUBCODEC_ZLIB ) break; - } - /* Check for overflow */ - if ((size_t)tif->tif_rawdatasize != (uint64_t)tif->tif_rawdatasize) - break; - if ((size_t)cc != (uint64_t)cc) - break; + /* Libdeflate does not support the 0-compression level */ + if( sp->zipquality == Z_NO_COMPRESSION ) + break; - /* Go for compression using libdeflate */ - { - size_t nCompressedBytes; - if (sp->libdeflate_enc == NULL) + /* Check if we are in the situation where we can use libdeflate */ + if (isTiled(tif)) { + if( TIFFTileSize64(tif) != (uint64)cc ) + break; + } else { + uint32 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 ) + break; + } + + /* Check for overflow */ + if( (size_t)tif->tif_rawdatasize != (uint64)tif->tif_rawdatasize ) + break; + if( (size_t)cc != (uint64)cc ) + break; + + /* Go for compression using libdeflate */ { - /* To get results as good as zlib, we asked 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) + size_t nCompressedBytes; + if( sp->libdeflate_enc == NULL ) + { + /* To get results as good as zlib, we asked 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"); + break; + } + } + + /* Make sure the output buffer is large enough for the worse case. */ + /* In TIFFWriteBufferSetup(), when libtiff allocates the buffer */ + /* we've taken a 10% margin over the uncompressed size, which should */ + /* be large enough even for the the worse case scenario. */ + if( libdeflate_zlib_compress_bound(sp->libdeflate_enc, (size_t)cc) > + (size_t)tif->tif_rawdatasize) { - TIFFErrorExtR(tif, module, "Cannot allocate compressor"); break; } + + sp->libdeflate_state = 1; + nCompressedBytes = libdeflate_zlib_compress( + sp->libdeflate_enc, bp, (size_t)cc, tif->tif_rawdata, (size_t)tif->tif_rawdatasize); + + if( nCompressedBytes == 0 ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Encoder error at scanline %lu", + (unsigned long) tif->tif_row); + return 0; + } + + tif->tif_rawcc = nCompressedBytes; + + if( !TIFFFlushData1(tif) ) + return 0; + + return 1; } - - /* Make sure the output buffer is large enough for the worse case. - */ - /* In TIFFWriteBufferSetup(), when libtiff allocates the buffer */ - /* we've taken a 10% margin over the uncompressed size, which should - */ - /* be large enough even for the the worse case scenario. */ - if (libdeflate_zlib_compress_bound(sp->libdeflate_enc, (size_t)cc) > - (size_t)tif->tif_rawdatasize) - { - break; - } - - sp->libdeflate_state = 1; - nCompressedBytes = libdeflate_zlib_compress( - sp->libdeflate_enc, bp, (size_t)cc, tif->tif_rawdata, - (size_t)tif->tif_rawdatasize); - - if (nCompressedBytes == 0) - { - TIFFErrorExtR(tif, module, "Encoder error at scanline %lu", - (unsigned long)tif->tif_row); - return 0; - } - - tif->tif_rawcc = nCompressedBytes; - - if (!TIFFFlushData1(tif)) - return 0; - - return 1; - } - } while (0); - sp->libdeflate_state = 0; + } while(0); + sp->libdeflate_state = 0; #endif /* LIBDEFLATE_SUPPORT */ - sp->stream.next_in = bp; - assert(sizeof(sp->stream.avail_in) == 4); /* if this assert gets raised, - we need to simplify this code to reflect a ZLib that is likely updated - to deal with 8byte memory sizes, though this code will respond - appropriately even before we simplify it */ - do - { - uInt avail_in_before = - (uint64_t)cc <= 0xFFFFFFFFU ? (uInt)cc : 0xFFFFFFFFU; - sp->stream.avail_in = avail_in_before; - /* coverity[overrun-buffer-arg] */ - if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) - { - TIFFErrorExtR(tif, module, "Encoder error: %s", SAFE_MSG(sp)); - return (0); - } - if (sp->stream.avail_out == 0) - { - tif->tif_rawcc = tif->tif_rawdatasize; - if (!TIFFFlushData1(tif)) - return 0; - sp->stream.next_out = tif->tif_rawdata; - 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); - return (1); + sp->stream.next_in = bp; + assert(sizeof(sp->stream.avail_in)==4); /* if this assert gets raised, + we need to simplify this code to reflect a ZLib that is likely updated + to deal with 8byte memory sizes, though this code will respond + appropriately even before we simplify it */ + do { + uInt avail_in_before = (uint64)cc <= 0xFFFFFFFFULL ? (uInt)cc : 0xFFFFFFFFU; + sp->stream.avail_in = avail_in_before; + if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) { + TIFFErrorExt(tif->tif_clientdata, module, + "Encoder error: %s", + SAFE_MSG(sp)); + return (0); + } + if (sp->stream.avail_out == 0) { + tif->tif_rawcc = tif->tif_rawdatasize; + if (!TIFFFlushData1(tif)) + return 0; + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFULL ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; + } + cc -= (avail_in_before - sp->stream.avail_in); + } while (cc > 0); + return (1); } /* * Finish off an encoded strip by flushing the last * string and tacking on an End Of Information code. */ -static int ZIPPostEncode(TIFF *tif) +static int +ZIPPostEncode(TIFF* tif) { - static const char module[] = "ZIPPostEncode"; - ZIPState *sp = EncoderState(tif); - int state; + static const char module[] = "ZIPPostEncode"; + ZIPState *sp = EncoderState(tif); + int state; #if LIBDEFLATE_SUPPORT - if (sp->libdeflate_state == 1) - return 1; -#endif - - sp->stream.avail_in = 0; - do - { - state = deflate(&sp->stream, Z_FINISH); - switch (state) - { - case Z_STREAM_END: - case Z_OK: - if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) - { - tif->tif_rawcc = - tif->tif_rawdatasize - sp->stream.avail_out; - if (!TIFFFlushData1(tif)) - return 0; - sp->stream.next_out = tif->tif_rawdata; - sp->stream.avail_out = - (uint64_t)tif->tif_rawdatasize <= 0xFFFFFFFFU - ? (uInt)tif->tif_rawdatasize - : 0xFFFFFFFFU; - } - break; - default: - TIFFErrorExtR(tif, module, "ZLib error: %s", SAFE_MSG(sp)); - return (0); - } - } while (state != Z_STREAM_END); - return (1); -} - -static void ZIPCleanup(TIFF *tif) -{ - ZIPState *sp = ZState(tif); - - assert(sp != 0); - - (void)TIFFPredictorCleanup(tif); - - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - - if (sp->state & ZSTATE_INIT_ENCODE) - { - deflateEnd(&sp->stream); - sp->state = 0; - } - else if (sp->state & ZSTATE_INIT_DECODE) - { - inflateEnd(&sp->stream); - sp->state = 0; - } - -#if LIBDEFLATE_SUPPORT - if (sp->libdeflate_dec) - libdeflate_free_decompressor(sp->libdeflate_dec); - if (sp->libdeflate_enc) - libdeflate_free_compressor(sp->libdeflate_enc); -#endif - - _TIFFfreeExt(tif, sp); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -static int ZIPVSetField(TIFF *tif, uint32_t tag, va_list ap) -{ - static const char module[] = "ZIPVSetField"; - ZIPState *sp = ZState(tif); - - switch (tag) - { - case TIFFTAG_ZIPQUALITY: - sp->zipquality = (int)va_arg(ap, int); - if (sp->zipquality < Z_DEFAULT_COMPRESSION || - sp->zipquality > LIBDEFLATE_MAX_COMPRESSION_LEVEL) - { - TIFFErrorExtR( - tif, module, - "Invalid ZipQuality value. Should be in [-1,%d] range", - LIBDEFLATE_MAX_COMPRESSION_LEVEL); - return 0; - } - - if (sp->state & ZSTATE_INIT_ENCODE) - { - int cappedQuality = sp->zipquality; - if (cappedQuality > Z_BEST_COMPRESSION) - cappedQuality = Z_BEST_COMPRESSION; - if (deflateParams(&sp->stream, cappedQuality, - Z_DEFAULT_STRATEGY) != Z_OK) - { - TIFFErrorExtR(tif, module, "ZLib error: %s", SAFE_MSG(sp)); - return (0); - } - } - -#if LIBDEFLATE_SUPPORT - if (sp->libdeflate_enc) - { - libdeflate_free_compressor(sp->libdeflate_enc); - sp->libdeflate_enc = NULL; - } -#endif - - return (1); - - case TIFFTAG_DEFLATE_SUBCODEC: - sp->subcodec = (int)va_arg(ap, int); - if (sp->subcodec != DEFLATE_SUBCODEC_ZLIB && - sp->subcodec != DEFLATE_SUBCODEC_LIBDEFLATE) - { - TIFFErrorExtR(tif, module, "Invalid DeflateCodec value."); - return 0; - } -#if !LIBDEFLATE_SUPPORT - if (sp->subcodec == DEFLATE_SUBCODEC_LIBDEFLATE) - { - TIFFErrorExtR(tif, module, - "DeflateCodec = DEFLATE_SUBCODEC_LIBDEFLATE " - "unsupported in this build"); - return 0; - } -#endif + if( sp->libdeflate_state == 1 ) return 1; +#endif - default: - return (*sp->vsetparent)(tif, tag, ap); - } - /*NOTREACHED*/ + sp->stream.avail_in = 0; + do { + state = deflate(&sp->stream, Z_FINISH); + switch (state) { + case Z_STREAM_END: + case Z_OK: + if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) + { + tif->tif_rawcc = tif->tif_rawdatasize - sp->stream.avail_out; + if (!TIFFFlushData1(tif)) + return 0; + sp->stream.next_out = tif->tif_rawdata; + sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFULL ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU; + } + break; + default: + TIFFErrorExt(tif->tif_clientdata, module, + "ZLib error: %s", SAFE_MSG(sp)); + return (0); + } + } while (state != Z_STREAM_END); + return (1); } -static int ZIPVGetField(TIFF *tif, uint32_t tag, va_list ap) +static void +ZIPCleanup(TIFF* tif) { - ZIPState *sp = ZState(tif); + ZIPState* sp = ZState(tif); - switch (tag) - { - case TIFFTAG_ZIPQUALITY: - *va_arg(ap, int *) = sp->zipquality; - break; + assert(sp != 0); + + (void)TIFFPredictorCleanup(tif); + + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; + + if (sp->state & ZSTATE_INIT_ENCODE) { + deflateEnd(&sp->stream); + sp->state = 0; + } else if( sp->state & ZSTATE_INIT_DECODE) { + inflateEnd(&sp->stream); + sp->state = 0; + } + +#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 int +ZIPVSetField(TIFF* tif, uint32 tag, va_list ap) +{ + static const char module[] = "ZIPVSetField"; + ZIPState* sp = ZState(tif); + + switch (tag) { + 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 ( sp->state&ZSTATE_INIT_ENCODE ) { + int cappedQuality = sp->zipquality; + if( cappedQuality > Z_BEST_COMPRESSION ) + cappedQuality = Z_BEST_COMPRESSION; + if (deflateParams(&sp->stream, + cappedQuality, Z_DEFAULT_STRATEGY) != Z_OK) { + TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s", + SAFE_MSG(sp)); + return (0); + } + } + +#if LIBDEFLATE_SUPPORT + if( sp->libdeflate_enc ) + { + libdeflate_free_compressor(sp->libdeflate_enc); + sp->libdeflate_enc = NULL; + } +#endif + + return (1); case TIFFTAG_DEFLATE_SUBCODEC: - *va_arg(ap, int *) = sp->subcodec; - break; + sp->subcodec = (int) va_arg(ap, int); + if( sp->subcodec != DEFLATE_SUBCODEC_ZLIB && + sp->subcodec != DEFLATE_SUBCODEC_LIBDEFLATE ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "Invalid DeflateCodec value."); + return 0; + } +#if !LIBDEFLATE_SUPPORT + if( sp->subcodec == DEFLATE_SUBCODEC_LIBDEFLATE ) + { + TIFFErrorExt(tif->tif_clientdata, module, + "DeflateCodec = DEFLATE_SUBCODEC_LIBDEFLATE unsupported in this build"); + return 0; + } +#endif + return 1; - default: - return (*sp->vgetparent)(tif, tag, ap); - } - return (1); + default: + return (*sp->vsetparent)(tif, tag, ap); + } + /*NOTREACHED*/ +} + +static int +ZIPVGetField(TIFF* tif, uint32 tag, va_list ap) +{ + ZIPState* sp = ZState(tif); + + switch (tag) { + case TIFFTAG_ZIPQUALITY: + *va_arg(ap, int*) = sp->zipquality; + break; + + case TIFFTAG_DEFLATE_SUBCODEC: + *va_arg(ap, int*) = sp->subcodec; + break; + + default: + return (*sp->vgetparent)(tif, tag, ap); + } + return (1); } static const TIFFField zipFields[] = { - {TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL}, - {TIFFTAG_DEFLATE_SUBCODEC, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL}, + { TIFFTAG_ZIPQUALITY, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL }, + { TIFFTAG_DEFLATE_SUBCODEC, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "", NULL }, }; -int TIFFInitZIP(TIFF *tif, int scheme) +int +TIFFInitZIP(TIFF* tif, int scheme) { - static const char module[] = "TIFFInitZIP"; - ZIPState *sp; + static const char module[] = "TIFFInitZIP"; + ZIPState* sp; - assert((scheme == COMPRESSION_DEFLATE) || - (scheme == COMPRESSION_ADOBE_DEFLATE)); + assert( (scheme == COMPRESSION_DEFLATE) + || (scheme == COMPRESSION_ADOBE_DEFLATE)); #ifdef NDEBUG - (void)scheme; + (void)scheme; #endif - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, zipFields, TIFFArrayCount(zipFields))) - { - TIFFErrorExtR(tif, module, - "Merging Deflate codec-specific tags failed"); - return 0; - } + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, zipFields, TIFFArrayCount(zipFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging Deflate codec-specific tags failed"); + return 0; + } - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (uint8_t *)_TIFFcallocExt(tif, sizeof(ZIPState), 1); - if (tif->tif_data == NULL) - goto bad; - sp = ZState(tif); - sp->stream.zalloc = NULL; - sp->stream.zfree = NULL; - sp->stream.opaque = NULL; - sp->stream.data_type = Z_BINARY; + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) _TIFFcalloc(sizeof (ZIPState), 1); + if (tif->tif_data == NULL) + goto bad; + sp = ZState(tif); + sp->stream.zalloc = NULL; + sp->stream.zfree = NULL; + sp->stream.opaque = NULL; + sp->stream.data_type = Z_BINARY; - /* - * Override parent get/set field methods. - */ - sp->vgetparent = tif->tif_tagmethods.vgetfield; - tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = ZIPVSetField; /* hook for codec tags */ + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = ZIPVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = ZIPVSetField; /* hook for codec tags */ - /* Default values for codec-specific fields */ - sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */ - sp->state = 0; + /* Default values for codec-specific fields */ + sp->zipquality = Z_DEFAULT_COMPRESSION; /* default comp. level */ + sp->state = 0; #if LIBDEFLATE_SUPPORT - sp->subcodec = DEFLATE_SUBCODEC_LIBDEFLATE; + sp->subcodec = DEFLATE_SUBCODEC_LIBDEFLATE; #else - sp->subcodec = DEFLATE_SUBCODEC_ZLIB; + sp->subcodec = DEFLATE_SUBCODEC_ZLIB; #endif - /* - * Install codec methods. - */ - tif->tif_fixuptags = ZIPFixupTags; - tif->tif_setupdecode = ZIPSetupDecode; - tif->tif_predecode = ZIPPreDecode; - tif->tif_decoderow = ZIPDecode; - tif->tif_decodestrip = ZIPDecode; - tif->tif_decodetile = ZIPDecode; - tif->tif_setupencode = ZIPSetupEncode; - tif->tif_preencode = ZIPPreEncode; - tif->tif_postencode = ZIPPostEncode; - tif->tif_encoderow = ZIPEncode; - tif->tif_encodestrip = ZIPEncode; - tif->tif_encodetile = ZIPEncode; - tif->tif_cleanup = ZIPCleanup; - /* - * Setup predictor setup. - */ - (void)TIFFPredictorInit(tif); - return (1); + /* + * Install codec methods. + */ + tif->tif_fixuptags = ZIPFixupTags; + tif->tif_setupdecode = ZIPSetupDecode; + tif->tif_predecode = ZIPPreDecode; + tif->tif_decoderow = ZIPDecode; + tif->tif_decodestrip = ZIPDecode; + tif->tif_decodetile = ZIPDecode; + tif->tif_setupencode = ZIPSetupEncode; + tif->tif_preencode = ZIPPreEncode; + tif->tif_postencode = ZIPPostEncode; + tif->tif_encoderow = ZIPEncode; + tif->tif_encodestrip = ZIPEncode; + tif->tif_encodetile = ZIPEncode; + tif->tif_cleanup = ZIPCleanup; + /* + * Setup predictor setup. + */ + (void) TIFFPredictorInit(tif); + return (1); bad: - TIFFErrorExtR(tif, module, "No space for ZIP state block"); - return (0); + TIFFErrorExt(tif->tif_clientdata, module, + "No space for ZIP state block"); + return (0); } #endif /* ZIP_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_zstd.c b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_zstd.c index 646993103..f1c3e2042 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tif_zstd.c +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tif_zstd.c @@ -1,35 +1,35 @@ /* - * Copyright (c) 2017, Planet Labs - * Author: - * - * 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. - */ +* Copyright (c) 2017, Planet Labs +* Author: +* +* 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 ZSTD_SUPPORT /* - * TIFF Library. - * - * ZSTD Compression Support - * - */ +* TIFF Library. +* +* ZSTD Compression Support +* +*/ #include "tif_predict.h" #include "zstd.h" @@ -37,400 +37,406 @@ #include /* - * State block for each open TIFF file using ZSTD compression/decompression. - */ -typedef struct -{ - TIFFPredictorState predict; - ZSTD_DStream *dstream; - ZSTD_CStream *cstream; - int compression_level; /* compression level */ - ZSTD_outBuffer out_buffer; - int state; /* state flags */ +* State block for each open TIFF file using ZSTD compression/decompression. +*/ +typedef struct { + TIFFPredictorState predict; + ZSTD_DStream* dstream; + ZSTD_CStream* cstream; + int compression_level; /* compression level */ + ZSTD_outBuffer out_buffer; + int state; /* state flags */ #define LSTATE_INIT_DECODE 0x01 #define LSTATE_INIT_ENCODE 0x02 - TIFFVGetMethod vgetparent; /* super-class method */ - TIFFVSetMethod vsetparent; /* super-class method */ + TIFFVGetMethod vgetparent; /* super-class method */ + TIFFVSetMethod vsetparent; /* super-class method */ } ZSTDState; -#define LState(tif) ((ZSTDState *)(tif)->tif_data) -#define DecoderState(tif) LState(tif) -#define EncoderState(tif) LState(tif) +#define LState(tif) ((ZSTDState*) (tif)->tif_data) +#define DecoderState(tif) LState(tif) +#define EncoderState(tif) LState(tif) -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 ZSTDEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s); +static int ZSTDDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s); -static int ZSTDFixupTags(TIFF *tif) +static int +ZSTDFixupTags(TIFF* tif) { - (void)tif; - return 1; + (void) tif; + return 1; } -static int ZSTDSetupDecode(TIFF *tif) +static int +ZSTDSetupDecode(TIFF* tif) { - ZSTDState *sp = DecoderState(tif); + ZSTDState* sp = DecoderState(tif); - assert(sp != NULL); + assert(sp != NULL); - /* if we were last encoding, terminate this mode */ - if (sp->state & LSTATE_INIT_ENCODE) - { - ZSTD_freeCStream(sp->cstream); - sp->cstream = NULL; - sp->state = 0; - } + /* if we were last encoding, terminate this mode */ + if (sp->state & LSTATE_INIT_ENCODE) { + ZSTD_freeCStream(sp->cstream); + sp->cstream = NULL; + sp->state = 0; + } - sp->state |= LSTATE_INIT_DECODE; - return 1; + sp->state |= LSTATE_INIT_DECODE; + return 1; } /* - * Setup state for decoding a strip. - */ -static int ZSTDPreDecode(TIFF *tif, uint16_t s) +* Setup state for decoding a strip. +*/ +static int +ZSTDPreDecode(TIFF* tif, uint16 s) { - static const char module[] = "ZSTDPreDecode"; - ZSTDState *sp = DecoderState(tif); - size_t zstd_ret; + static const char module[] = "ZSTDPreDecode"; + ZSTDState* sp = DecoderState(tif); + size_t zstd_ret; - (void)s; - assert(sp != NULL); + (void) s; + assert(sp != NULL); - if ((sp->state & LSTATE_INIT_DECODE) == 0) - tif->tif_setupdecode(tif); + if( (sp->state & LSTATE_INIT_DECODE) == 0 ) + tif->tif_setupdecode(tif); + + if( sp->dstream ) + { + ZSTD_freeDStream(sp->dstream); + sp->dstream = NULL; + } - if (sp->dstream == NULL) - { sp->dstream = ZSTD_createDStream(); - if (sp->dstream == NULL) - { - TIFFErrorExtR(tif, module, "Cannot allocate decompression stream"); + if( sp->dstream == NULL ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate decompression stream"); return 0; } - } - - zstd_ret = ZSTD_initDStream(sp->dstream); - if (ZSTD_isError(zstd_ret)) - { - TIFFErrorExtR(tif, module, "Error in ZSTD_initDStream(): %s", - ZSTD_getErrorName(zstd_ret)); - return 0; - } - - return 1; -} - -static int ZSTDDecode(TIFF *tif, uint8_t *op, tmsize_t occ, uint16_t s) -{ - static const char module[] = "ZSTDDecode"; - ZSTDState *sp = DecoderState(tif); - ZSTD_inBuffer in_buffer; - ZSTD_outBuffer out_buffer; - size_t zstd_ret; - - (void)s; - assert(sp != NULL); - assert(sp->state == LSTATE_INIT_DECODE); - - in_buffer.src = tif->tif_rawcp; - in_buffer.size = (size_t)tif->tif_rawcc; - in_buffer.pos = 0; - - out_buffer.dst = op; - out_buffer.size = (size_t)occ; - out_buffer.pos = 0; - - do - { - zstd_ret = ZSTD_decompressStream(sp->dstream, &out_buffer, &in_buffer); - if (ZSTD_isError(zstd_ret)) - { - TIFFErrorExtR(tif, module, "Error in ZSTD_decompressStream(): %s", - ZSTD_getErrorName(zstd_ret)); + zstd_ret = ZSTD_initDStream(sp->dstream); + if( ZSTD_isError(zstd_ret) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in ZSTD_initDStream(): %s", + ZSTD_getErrorName(zstd_ret)); return 0; } - } while (zstd_ret != 0 && in_buffer.pos < in_buffer.size && - out_buffer.pos < out_buffer.size); - if (out_buffer.pos < (size_t)occ) - { - TIFFErrorExtR(tif, module, - "Not enough data at scanline %lu (short %lu bytes)", - (unsigned long)tif->tif_row, - (unsigned long)((size_t)occ - out_buffer.pos)); - return 0; - } - - tif->tif_rawcp += in_buffer.pos; - tif->tif_rawcc -= in_buffer.pos; - - return 1; + return 1; } -static int ZSTDSetupEncode(TIFF *tif) +static int +ZSTDDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) { - ZSTDState *sp = EncoderState(tif); + static const char module[] = "ZSTDDecode"; + ZSTDState* sp = DecoderState(tif); + ZSTD_inBuffer in_buffer; + ZSTD_outBuffer out_buffer; + size_t zstd_ret; - assert(sp != NULL); - if (sp->state & LSTATE_INIT_DECODE) - { - ZSTD_freeDStream(sp->dstream); - sp->dstream = NULL; - sp->state = 0; - } + (void) s; + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_DECODE); - sp->state |= LSTATE_INIT_ENCODE; - return 1; + in_buffer.src = tif->tif_rawcp; + in_buffer.size = (size_t) tif->tif_rawcc; + in_buffer.pos = 0; + + out_buffer.dst = op; + out_buffer.size = (size_t) occ; + out_buffer.pos = 0; + + do { + zstd_ret = ZSTD_decompressStream(sp->dstream, &out_buffer, + &in_buffer); + if( ZSTD_isError(zstd_ret) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in ZSTD_decompressStream(): %s", + ZSTD_getErrorName(zstd_ret)); + return 0; + } + } while( zstd_ret != 0 && + in_buffer.pos < in_buffer.size && + out_buffer.pos < out_buffer.size ); + + if (out_buffer.pos < (size_t)occ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Not enough data at scanline %lu (short %lu bytes)", + (unsigned long) tif->tif_row, + (unsigned long) ((size_t)occ - out_buffer.pos)); + return 0; + } + + tif->tif_rawcp += in_buffer.pos; + tif->tif_rawcc -= in_buffer.pos; + + return 1; +} + +static int +ZSTDSetupEncode(TIFF* tif) +{ + ZSTDState* sp = EncoderState(tif); + + assert(sp != NULL); + if (sp->state & LSTATE_INIT_DECODE) { + ZSTD_freeDStream(sp->dstream); + sp->dstream = NULL; + sp->state = 0; + } + + sp->state |= LSTATE_INIT_ENCODE; + return 1; } /* - * Reset encoding state at the start of a strip. - */ -static int ZSTDPreEncode(TIFF *tif, uint16_t s) +* Reset encoding state at the start of a strip. +*/ +static int +ZSTDPreEncode(TIFF* tif, uint16 s) { - static const char module[] = "ZSTDPreEncode"; - ZSTDState *sp = EncoderState(tif); - size_t zstd_ret; + static const char module[] = "ZSTDPreEncode"; + ZSTDState *sp = EncoderState(tif); + size_t zstd_ret; - (void)s; - assert(sp != NULL); - if (sp->state != LSTATE_INIT_ENCODE) - tif->tif_setupencode(tif); + (void) s; + assert(sp != NULL); + if( sp->state != LSTATE_INIT_ENCODE ) + tif->tif_setupencode(tif); - if (sp->cstream == NULL) - { + if (sp->cstream) { + ZSTD_freeCStream(sp->cstream); + sp->cstream = NULL; + } sp->cstream = ZSTD_createCStream(); - if (sp->cstream == NULL) - { - TIFFErrorExtR(tif, module, "Cannot allocate compression stream"); + if( sp->cstream == NULL ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Cannot allocate compression stream"); return 0; } - } - zstd_ret = ZSTD_initCStream(sp->cstream, sp->compression_level); - if (ZSTD_isError(zstd_ret)) - { - TIFFErrorExtR(tif, module, "Error in ZSTD_initCStream(): %s", - ZSTD_getErrorName(zstd_ret)); - return 0; - } + zstd_ret = ZSTD_initCStream(sp->cstream, sp->compression_level); + if( ZSTD_isError(zstd_ret) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in ZSTD_initCStream(): %s", + ZSTD_getErrorName(zstd_ret)); + return 0; + } - sp->out_buffer.dst = tif->tif_rawdata; - sp->out_buffer.size = (size_t)tif->tif_rawdatasize; - sp->out_buffer.pos = 0; + sp->out_buffer.dst = tif->tif_rawdata; + sp->out_buffer.size = (size_t)tif->tif_rawdatasize; + sp->out_buffer.pos = 0; - return 1; + return 1; } /* - * Encode a chunk of pixels. - */ -static int ZSTDEncode(TIFF *tif, uint8_t *bp, tmsize_t cc, uint16_t s) +* Encode a chunk of pixels. +*/ +static int +ZSTDEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) { - static const char module[] = "ZSTDEncode"; - ZSTDState *sp = EncoderState(tif); - ZSTD_inBuffer in_buffer; - size_t zstd_ret; + static const char module[] = "ZSTDEncode"; + ZSTDState *sp = EncoderState(tif); + ZSTD_inBuffer in_buffer; + size_t zstd_ret; - assert(sp != NULL); - assert(sp->state == LSTATE_INIT_ENCODE); + assert(sp != NULL); + assert(sp->state == LSTATE_INIT_ENCODE); - (void)s; + (void) s; - in_buffer.src = bp; - in_buffer.size = (size_t)cc; - in_buffer.pos = 0; + in_buffer.src = bp; + in_buffer.size = (size_t)cc; + in_buffer.pos = 0; - do - { - zstd_ret = - ZSTD_compressStream(sp->cstream, &sp->out_buffer, &in_buffer); - if (ZSTD_isError(zstd_ret)) - { - TIFFErrorExtR(tif, module, "Error in ZSTD_compressStream(): %s", - ZSTD_getErrorName(zstd_ret)); - return 0; - } - if (sp->out_buffer.pos == sp->out_buffer.size) - { - tif->tif_rawcc = tif->tif_rawdatasize; - if (!TIFFFlushData1(tif)) - return 0; - sp->out_buffer.dst = tif->tif_rawcp; - sp->out_buffer.pos = 0; - } - } while (in_buffer.pos < in_buffer.size); + do { + zstd_ret = ZSTD_compressStream(sp->cstream, &sp->out_buffer, + &in_buffer); + if( ZSTD_isError(zstd_ret) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in ZSTD_compressStream(): %s", + ZSTD_getErrorName(zstd_ret)); + return 0; + } + if( sp->out_buffer.pos == sp->out_buffer.size ) { + tif->tif_rawcc = tif->tif_rawdatasize; + if (!TIFFFlushData1(tif)) + return 0; + sp->out_buffer.dst = tif->tif_rawcp; + sp->out_buffer.pos = 0; + } + } while( in_buffer.pos < in_buffer.size ); - return 1; + return 1; } /* - * Finish off an encoded strip by flushing it. - */ -static int ZSTDPostEncode(TIFF *tif) +* Finish off an encoded strip by flushing it. +*/ +static int +ZSTDPostEncode(TIFF* tif) { - static const char module[] = "ZSTDPostEncode"; - ZSTDState *sp = EncoderState(tif); - size_t zstd_ret; + static const char module[] = "ZSTDPostEncode"; + ZSTDState *sp = EncoderState(tif); + size_t zstd_ret; - do - { - zstd_ret = ZSTD_endStream(sp->cstream, &sp->out_buffer); - if (ZSTD_isError(zstd_ret)) - { - TIFFErrorExtR(tif, module, "Error in ZSTD_endStream(): %s", - ZSTD_getErrorName(zstd_ret)); - return 0; + do { + zstd_ret = ZSTD_endStream(sp->cstream, &sp->out_buffer); + if( ZSTD_isError(zstd_ret) ) { + TIFFErrorExt(tif->tif_clientdata, module, + "Error in ZSTD_endStream(): %s", + ZSTD_getErrorName(zstd_ret)); + return 0; + } + if( sp->out_buffer.pos > 0 ) { + tif->tif_rawcc = sp->out_buffer.pos; + if (!TIFFFlushData1(tif)) + return 0; + sp->out_buffer.dst = tif->tif_rawcp; + sp->out_buffer.pos = 0; + } + } while (zstd_ret != 0); + return 1; +} + +static void +ZSTDCleanup(TIFF* tif) +{ + ZSTDState* sp = LState(tif); + + assert(sp != 0); + + (void)TIFFPredictorCleanup(tif); + + tif->tif_tagmethods.vgetfield = sp->vgetparent; + tif->tif_tagmethods.vsetfield = sp->vsetparent; + + if (sp->dstream) { + ZSTD_freeDStream(sp->dstream); + sp->dstream = NULL; } - if (sp->out_buffer.pos > 0) - { - tif->tif_rawcc = sp->out_buffer.pos; - if (!TIFFFlushData1(tif)) - return 0; - sp->out_buffer.dst = tif->tif_rawcp; - sp->out_buffer.pos = 0; + if (sp->cstream) { + ZSTD_freeCStream(sp->cstream); + sp->cstream = NULL; } - } while (zstd_ret != 0); - return 1; + _TIFFfree(sp); + tif->tif_data = NULL; + + _TIFFSetDefaultCompressionState(tif); } -static void ZSTDCleanup(TIFF *tif) +static int +ZSTDVSetField(TIFF* tif, uint32 tag, va_list ap) { - ZSTDState *sp = LState(tif); + static const char module[] = "ZSTDVSetField"; + ZSTDState* sp = LState(tif); - assert(sp != 0); - - (void)TIFFPredictorCleanup(tif); - - tif->tif_tagmethods.vgetfield = sp->vgetparent; - tif->tif_tagmethods.vsetfield = sp->vsetparent; - - if (sp->dstream) - { - ZSTD_freeDStream(sp->dstream); - sp->dstream = NULL; - } - if (sp->cstream) - { - ZSTD_freeCStream(sp->cstream); - sp->cstream = NULL; - } - _TIFFfreeExt(tif, sp); - tif->tif_data = NULL; - - _TIFFSetDefaultCompressionState(tif); -} - -static int ZSTDVSetField(TIFF *tif, uint32_t tag, va_list ap) -{ - static const char module[] = "ZSTDVSetField"; - ZSTDState *sp = LState(tif); - - switch (tag) - { + switch (tag) { case TIFFTAG_ZSTD_LEVEL: - sp->compression_level = (int)va_arg(ap, int); - if (sp->compression_level <= 0 || - sp->compression_level > ZSTD_maxCLevel()) - { - TIFFWarningExtR(tif, module, - "ZSTD_LEVEL should be between 1 and %d", - ZSTD_maxCLevel()); - } - return 1; + sp->compression_level = (int) va_arg(ap, int); + if( sp->compression_level <= 0 || + sp->compression_level > ZSTD_maxCLevel() ) + { + TIFFWarningExt(tif->tif_clientdata, module, + "ZSTD_LEVEL should be between 1 and %d", + ZSTD_maxCLevel()); + } + return 1; default: - return (*sp->vsetparent)(tif, tag, ap); - } - /*NOTREACHED*/ + return (*sp->vsetparent)(tif, tag, ap); + } + /*NOTREACHED*/ } -static int ZSTDVGetField(TIFF *tif, uint32_t tag, va_list ap) +static int +ZSTDVGetField(TIFF* tif, uint32 tag, va_list ap) { - ZSTDState *sp = LState(tif); + ZSTDState* sp = LState(tif); - switch (tag) - { + switch (tag) { case TIFFTAG_ZSTD_LEVEL: - *va_arg(ap, int *) = sp->compression_level; - break; + *va_arg(ap, int*) = sp->compression_level; + break; default: - return (*sp->vgetparent)(tif, tag, ap); - } - return 1; + return (*sp->vgetparent)(tif, tag, ap); + } + return 1; } static const TIFFField ZSTDFields[] = { - {TIFFTAG_ZSTD_LEVEL, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, - TIFF_SETGET_UNDEFINED, FIELD_PSEUDO, TRUE, FALSE, "ZSTD compression_level", - NULL}, + { TIFFTAG_ZSTD_LEVEL, 0, 0, TIFF_ANY, 0, TIFF_SETGET_INT, + TIFF_SETGET_UNDEFINED, + FIELD_PSEUDO, TRUE, FALSE, "ZSTD compression_level", NULL }, }; -int TIFFInitZSTD(TIFF *tif, int scheme) +int +TIFFInitZSTD(TIFF* tif, int scheme) { - static const char module[] = "TIFFInitZSTD"; - ZSTDState *sp; + static const char module[] = "TIFFInitZSTD"; + ZSTDState* sp; - (void)scheme; - assert(scheme == COMPRESSION_ZSTD); + assert( scheme == COMPRESSION_ZSTD ); - /* - * Merge codec-specific tag information. - */ - if (!_TIFFMergeFields(tif, ZSTDFields, TIFFArrayCount(ZSTDFields))) - { - TIFFErrorExtR(tif, module, "Merging ZSTD codec-specific tags failed"); - return 0; - } + /* + * Merge codec-specific tag information. + */ + if (!_TIFFMergeFields(tif, ZSTDFields, TIFFArrayCount(ZSTDFields))) { + TIFFErrorExt(tif->tif_clientdata, module, + "Merging ZSTD codec-specific tags failed"); + return 0; + } - /* - * Allocate state block so tag methods have storage to record values. - */ - tif->tif_data = (uint8_t *)_TIFFmallocExt(tif, sizeof(ZSTDState)); - if (tif->tif_data == NULL) - goto bad; - sp = LState(tif); + /* + * Allocate state block so tag methods have storage to record values. + */ + tif->tif_data = (uint8*) _TIFFmalloc(sizeof(ZSTDState)); + 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 = ZSTDVGetField; /* hook for codec tags */ - sp->vsetparent = tif->tif_tagmethods.vsetfield; - tif->tif_tagmethods.vsetfield = ZSTDVSetField; /* hook for codec tags */ + /* + * Override parent get/set field methods. + */ + sp->vgetparent = tif->tif_tagmethods.vgetfield; + tif->tif_tagmethods.vgetfield = ZSTDVGetField; /* hook for codec tags */ + sp->vsetparent = tif->tif_tagmethods.vsetfield; + tif->tif_tagmethods.vsetfield = ZSTDVSetField; /* hook for codec tags */ - /* Default values for codec-specific fields */ - sp->compression_level = 9; /* default comp. level */ - sp->state = 0; - sp->dstream = 0; - sp->cstream = 0; - sp->out_buffer.dst = NULL; - sp->out_buffer.size = 0; - sp->out_buffer.pos = 0; + /* Default values for codec-specific fields */ + sp->compression_level = 9; /* default comp. level */ + sp->state = 0; + sp->dstream = 0; + sp->cstream = 0; + sp->out_buffer.dst = NULL; + sp->out_buffer.size = 0; + sp->out_buffer.pos = 0; - /* - * Install codec methods. - */ - tif->tif_fixuptags = ZSTDFixupTags; - tif->tif_setupdecode = ZSTDSetupDecode; - tif->tif_predecode = ZSTDPreDecode; - tif->tif_decoderow = ZSTDDecode; - tif->tif_decodestrip = ZSTDDecode; - tif->tif_decodetile = ZSTDDecode; - tif->tif_setupencode = ZSTDSetupEncode; - tif->tif_preencode = ZSTDPreEncode; - tif->tif_postencode = ZSTDPostEncode; - tif->tif_encoderow = ZSTDEncode; - tif->tif_encodestrip = ZSTDEncode; - tif->tif_encodetile = ZSTDEncode; - tif->tif_cleanup = ZSTDCleanup; - /* - * Setup predictor setup. - */ - (void)TIFFPredictorInit(tif); - return 1; + /* + * Install codec methods. + */ + tif->tif_fixuptags = ZSTDFixupTags; + tif->tif_setupdecode = ZSTDSetupDecode; + tif->tif_predecode = ZSTDPreDecode; + tif->tif_decoderow = ZSTDDecode; + tif->tif_decodestrip = ZSTDDecode; + tif->tif_decodetile = ZSTDDecode; + tif->tif_setupencode = ZSTDSetupEncode; + tif->tif_preencode = ZSTDPreEncode; + tif->tif_postencode = ZSTDPostEncode; + tif->tif_encoderow = ZSTDEncode; + tif->tif_encodestrip = ZSTDEncode; + tif->tif_encodetile = ZSTDEncode; + tif->tif_cleanup = ZSTDCleanup; + /* + * Setup predictor setup. + */ + (void) TIFFPredictorInit(tif); + return 1; bad: - TIFFErrorExtR(tif, module, "No space for ZSTD state block"); - return 0; + TIFFErrorExt(tif->tif_clientdata, module, + "No space for ZSTD state block"); + return 0; } #endif /* ZSTD_SUPPORT */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tiff.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tiff.h index b2d118668..2d4a47679 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tiff.h +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiff.h @@ -2,28 +2,28 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFF_ -#define _TIFF_ +#define _TIFF_ #include "tiffconf.h" @@ -48,46 +48,32 @@ #define TIFF_VERSION_CLASSIC 42 #define TIFF_VERSION_BIG 43 -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 -#define MDI_LITTLEENDIAN 0x5045 -#define MDI_BIGENDIAN 0x4550 +#define TIFF_BIGENDIAN 0x4d4d +#define TIFF_LITTLEENDIAN 0x4949 +#define MDI_LITTLEENDIAN 0x5045 +#define MDI_BIGENDIAN 0x4550 /* * Intrinsic data types required by the file format: * - * 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 + * 8-bit quantities int8/uint8 + * 16-bit quantities int16/uint16 + * 32-bit quantities int32/uint32 + * 64-bit quantities int64/uint64 * 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 -#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_INT8_T int8; +typedef TIFF_UINT8_T uint8; -typedef TIFF_MSC_DEPRECATED int16_t int16 TIFF_GCC_DEPRECATED; -typedef TIFF_MSC_DEPRECATED uint16_t uint16 TIFF_GCC_DEPRECATED; +typedef TIFF_INT16_T int16; +typedef TIFF_UINT16_T uint16; -typedef TIFF_MSC_DEPRECATED int32_t int32 TIFF_GCC_DEPRECATED; -typedef TIFF_MSC_DEPRECATED uint32_t uint32 TIFF_GCC_DEPRECATED; +typedef TIFF_INT32_T int32; +typedef TIFF_UINT32_T uint32; -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 @@ -102,26 +88,24 @@ typedef int uint16_vap; /* * TIFF header. */ -typedef struct -{ - uint16_t tiff_magic; /* magic number (defines byte order) */ - uint16_t tiff_version; /* TIFF version number */ +typedef struct { + uint16 tiff_magic; /* magic number (defines byte order) */ + uint16 tiff_version; /* TIFF version number */ } TIFFHeaderCommon; -typedef struct -{ - 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 */ +typedef struct { + uint16 tiff_magic; /* magic number (defines byte order) */ + uint16 tiff_version; /* TIFF version number */ + uint32 tiff_diroff; /* byte offset to first directory */ } TIFFHeaderClassic; -typedef struct -{ - uint16_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 */ +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 */ } TIFFHeaderBig; + /* * NB: In the comments below, * - items marked with a + are obsoleted by revision 5.0, @@ -136,551 +120,464 @@ typedef struct * * Note: RATIONALs are the ratio of two 32-bit integer values. *--: - * Note2: TIFF_IFD8 data type is used in tiffFields[]-tag definition in order to - distinguish the write-handling of those tags between ClassicTIFF and BigTiff: - For ClassicTIFF libtiff writes a 32-bit value and the TIFF_IFD - type-id into the file For BigTIFF libtiff writes a 64-bit value and the - TIFF_IFD8 type-id into the file + * Note2: TIFF_IFD8 data type is used in tiffFields[]-tag definition in order to distinguish the write-handling + of those tags between ClassicTIFF and BigTiff: + For ClassicTIFF libtiff writes a 32-bit value and the TIFF_IFD type-id into the file + For BigTIFF libtiff writes a 64-bit value and the TIFF_IFD8 type-id into the file */ -typedef enum -{ - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ - TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ - TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ - TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ - TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ +typedef enum { + TIFF_NOTYPE = 0, /* placeholder */ + TIFF_BYTE = 1, /* 8-bit unsigned integer */ + TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ + TIFF_SHORT = 3, /* 16-bit unsigned integer */ + TIFF_LONG = 4, /* 32-bit unsigned integer */ + TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ + TIFF_SBYTE = 6, /* !8-bit signed integer */ + TIFF_UNDEFINED = 7, /* !8-bit untyped data */ + TIFF_SSHORT = 8, /* !16-bit signed integer */ + TIFF_SLONG = 9, /* !32-bit signed integer */ + TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ + TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ + TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ + TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ + TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ + TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ + TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ } TIFFDataType; /* * TIFF Tag Definitions. */ -/* clang-format off */ /* for better readability of tag comments */ -#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ -#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ -#define FILETYPE_PAGE 0x2 /* one page of many */ -#define FILETYPE_MASK 0x4 /* transparency mask */ -#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ -#define OFILETYPE_IMAGE 1 /* full resolution image data */ -#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ -#define OFILETYPE_PAGE 3 /* one page of many */ -#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ -#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ -#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ -#define TIFFTAG_COMPRESSION 259 /* data compression technique */ -#define COMPRESSION_NONE 1 /* dump mode */ -#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ -#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ -#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ -#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ -#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ -#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ -#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ -#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ -#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ -#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ -#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ -#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ -#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ -#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ +#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ +#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ +#define FILETYPE_PAGE 0x2 /* one page of many */ +#define FILETYPE_MASK 0x4 /* transparency mask */ +#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ +#define OFILETYPE_IMAGE 1 /* full resolution image data */ +#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ +#define OFILETYPE_PAGE 3 /* one page of many */ +#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ +#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ +#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ +#define TIFFTAG_COMPRESSION 259 /* data compression technique */ +#define COMPRESSION_NONE 1 /* dump mode */ +#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ +#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ +#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ +#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ +#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ +#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ +#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ +#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ +#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ +#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ +#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ +#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ +#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ +#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ /* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ -#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ -#define COMPRESSION_JBIG 34661 /* ISO JBIG */ -#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ -#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ -#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ -#define COMPRESSION_LERC 34887 /* ESRI Lerc codec: https://github.com/Esri/lerc */ +#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ +#define COMPRESSION_JBIG 34661 /* ISO JBIG */ +#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ +#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ +#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ +#define COMPRESSION_LERC 34887 /* ESRI Lerc codec: https://github.com/Esri/lerc */ /* compression codes 34887-34889 are reserved for ESRI */ -#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 */ -#define PHOTOMETRIC_RGB 2 /* RGB color model */ -#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ -#define PHOTOMETRIC_MASK 4 /* $holdout mask */ -#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ -#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ -#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ -#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ -#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ -#define PHOTOMETRIC_CFA 32803 /* color filter array */ -#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ -#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ -#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ -#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ -#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ -#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ -#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ -#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ -#define TIFFTAG_FILLORDER 266 /* data order within a byte */ -#define FILLORDER_MSB2LSB 1 /* most significant -> least */ -#define FILLORDER_LSB2MSB 2 /* least significant -> most */ -#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ -#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ -#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ -#define TIFFTAG_MODEL 272 /* scanner model name/number */ -#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ -#define TIFFTAG_ORIENTATION 274 /* +image orientation */ -#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ -#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ -#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ -#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ -#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ -#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ -#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ -#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ -#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ -#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ -#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ -#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ -#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ -#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ -#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ -#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ -#define PLANARCONFIG_CONTIG 1 /* single image plane */ -#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ -#define TIFFTAG_PAGENAME 285 /* page name image is from */ -#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ -#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ -#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ -#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ -#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ -#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ -#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ -#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ -#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ -#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ -#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ -#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ -#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ -#define RESUNIT_NONE 1 /* no meaningful units */ -#define RESUNIT_INCH 2 /* english */ -#define RESUNIT_CENTIMETER 3 /* metric */ -#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ -#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ -#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ -#define TIFFTAG_SOFTWARE 305 /* name & release */ -#define TIFFTAG_DATETIME 306 /* creation date and time */ -#define TIFFTAG_ARTIST 315 /* creator of image */ -#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ -#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ -#define PREDICTOR_NONE 1 /* no prediction scheme used */ -#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ -#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ -#define TIFFTAG_WHITEPOINT 318 /* image white point */ -#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ -#define TIFFTAG_COLORMAP 320 /* RGB map for palette image */ -#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ -#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ -#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ -#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ -#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ -#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ -#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ -#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ -#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ -#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ -#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ -#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ -#define TIFFTAG_INKSET 332 /* !inks in separated image */ -#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ -#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ -#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ -#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ -#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ -#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ -#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ -#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ -#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ -#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ -#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ -#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ -#define SAMPLEFORMAT_INT 2 /* !signed integer data */ -#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ -#define SAMPLEFORMAT_VOID 4 /* !untyped data */ -#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ -#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ -#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ -#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ -#define TIFFTAG_CLIPPATH 343 /* %ClipPath [Adobe TIFF technote 2] */ -#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits [Adobe TIFF technote 2] */ -#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits [Adobe TIFF technote 2] */ -#define TIFFTAG_INDEXED 346 /* %Indexed [Adobe TIFF Technote 3] */ -#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ -#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ +#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 TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ +#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ +#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ +#define PHOTOMETRIC_RGB 2 /* RGB color model */ +#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ +#define PHOTOMETRIC_MASK 4 /* $holdout mask */ +#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ +#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ +#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ +#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ +#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ +#define PHOTOMETRIC_CFA 32803 /* color filter array */ +#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ +#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ +#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ +#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ +#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ +#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ +#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ +#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ +#define TIFFTAG_FILLORDER 266 /* data order within a byte */ +#define FILLORDER_MSB2LSB 1 /* most significant -> least */ +#define FILLORDER_LSB2MSB 2 /* least significant -> most */ +#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ +#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ +#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ +#define TIFFTAG_MODEL 272 /* scanner model name/number */ +#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ +#define TIFFTAG_ORIENTATION 274 /* +image orientation */ +#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ +#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ +#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ +#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ +#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ +#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ +#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ +#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ +#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ +#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ +#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ +#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ +#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ +#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ +#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ +#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ +#define PLANARCONFIG_CONTIG 1 /* single image plane */ +#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ +#define TIFFTAG_PAGENAME 285 /* page name image is from */ +#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ +#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ +#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ +#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ +#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ +#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ +#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ +#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ +#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ +#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ +#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ +#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ +#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ +#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ +#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ +#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ +#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ +#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ +#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ +#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ +#define RESUNIT_NONE 1 /* no meaningful units */ +#define RESUNIT_INCH 2 /* english */ +#define RESUNIT_CENTIMETER 3 /* metric */ +#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ +#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ +#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ +#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ +#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ +#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ +#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ +#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ +#define TIFFTAG_SOFTWARE 305 /* name & release */ +#define TIFFTAG_DATETIME 306 /* creation date and time */ +#define TIFFTAG_ARTIST 315 /* creator of image */ +#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ +#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ +#define PREDICTOR_NONE 1 /* no prediction scheme used */ +#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ +#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ +#define TIFFTAG_WHITEPOINT 318 /* image white point */ +#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ +#define TIFFTAG_COLORMAP 320 /* RGB map for palette image */ +#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ +#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ +#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ +#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ +#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ +#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ +#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ +#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ +#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ +#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ +#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ +#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ +#define TIFFTAG_INKSET 332 /* !inks in separated image */ +#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ +#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ +#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ +#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ +#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ +#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ +#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ +#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ +#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ +#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ +#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ +#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ +#define SAMPLEFORMAT_INT 2 /* !signed integer data */ +#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ +#define SAMPLEFORMAT_VOID 4 /* !untyped data */ +#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ +#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ +#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ +#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ +#define TIFFTAG_CLIPPATH 343 /* %ClipPath + [Adobe TIFF technote 2] */ +#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits + [Adobe TIFF technote 2] */ +#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits + [Adobe TIFF technote 2] */ +#define TIFFTAG_INDEXED 346 /* %Indexed + [Adobe TIFF Technote 3] */ +#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ +#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ /* Tags 400-435 are from the TIFF/FX spec */ -#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ -#define TIFFTAG_PROFILETYPE 401 /* ! */ -#define PROFILETYPE_UNSPECIFIED 0 /* ! */ -#define PROFILETYPE_G3_FAX 1 /* ! */ -#define TIFFTAG_FAXPROFILE 402 /* ! */ -#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ -#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ -#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ -#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ -#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ -#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ -#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ -#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ -#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ -#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ -#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ -#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ -#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ -#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ -#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ -#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ -#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ -#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ +#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ +#define TIFFTAG_PROFILETYPE 401 /* ! */ +#define PROFILETYPE_UNSPECIFIED 0 /* ! */ +#define PROFILETYPE_G3_FAX 1 /* ! */ +#define TIFFTAG_FAXPROFILE 402 /* ! */ +#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ +#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ +#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ +#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ +#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ +#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ +#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ +#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ +#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ +#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ +#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ +#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ +#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ +#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ +#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ +#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ +#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ +#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ /* * Tags 512-521 are obsoleted by Technical Note #2 which specifies a * revised JPEG-in-TIFF scheme. */ -#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ -#define JPEGPROC_BASELINE 1 /* !baseline sequential */ -#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ -#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ -#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ -#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ -#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ -#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ -#define TIFFTAG_JPEGQTABLES 519 /* !Q matrix offsets */ -#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ -#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ -#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ -#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ -#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ -#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ -#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ -#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ -#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ -#define TIFFTAG_XMLPACKET 700 /* %XML packet [Adobe XMP Specification, January 2004 */ -#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID [Adobe TIFF technote] */ -/* For eiStream Annotation Specification, Version 1.00.06 see - * http://web.archive.org/web/20050309141348/http://www.kofile.com/support%20pro/faqs/annospec.htm */ -#define TIFFTAG_TIFFANNOTATIONDATA 32932 +#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ +#define JPEGPROC_BASELINE 1 /* !baseline sequential */ +#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ +#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ +#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ +#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ +#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ +#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ +#define TIFFTAG_JPEGQTABLES 519 /* !Q matrix offsets */ +#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ +#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ +#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ +#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ +#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ +#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ +#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ +#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ +#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ +#define TIFFTAG_XMLPACKET 700 /* %XML packet + [Adobe XMP Specification, + January 2004 */ +#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID + [Adobe TIFF technote] */ +#define TIFFTAG_TIFFANNOTATIONDATA 32932 /* http://web.archive.org/web/20050309141348/http://www.kofile.com/support%20pro/faqs/annospec.htm */ /* tags 32952-32956 are private tags registered to Island Graphics */ -#define TIFFTAG_REFPTS 32953 /* image reference points */ -#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ -#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ -#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ +#define TIFFTAG_REFPTS 32953 /* image reference points */ +#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ +#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ +#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ /* tags 32995-32999 are private tags registered to SGI */ -#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ -#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ -#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ -#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ +#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ +#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ +#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ +#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ /* tags 33300-33309 are private tags registered to Pixar */ /* * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH - * are set when an image has been cropped out of a larger image. + * are set when an image has been cropped out of a larger image. * They reflect the size of the original uncropped image. * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used * to determine the position of the smaller image in the larger one. */ -#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ -#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ -/* Tags 33302-33306 are used to identify special image modes and data - * used by Pixar's texture formats. - */ -#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ -#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ -#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ +#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ +#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ + /* Tags 33302-33306 are used to identify special image modes and data + * used by Pixar's texture formats. + */ +#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ +#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ +#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ #define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 #define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 /* tag 33405 is a private tag registered to Eastman Kodak */ -#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ -#define TIFFTAG_CFAREPEATPATTERNDIM 33421 /* (alias for TIFFTAG_EP_CFAREPEATPATTERNDIM)*/ -#define TIFFTAG_CFAPATTERN 33422 /* (alias for TIFFTAG_EP_CFAPATTERN) */ -#define TIFFTAG_BATTERYLEVEL 33423 /* (alias for TIFFTAG_EP_BATTERYLEVEL) */ +#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ +#define TIFFTAG_CFAREPEATPATTERNDIM 33421 /* dimensions of CFA pattern */ +#define TIFFTAG_CFAPATTERN 33422 /* color filter array pattern */ /* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ -#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ -/* Tags 33445-33452 are used for Molecular Dynamics GEL fileformat, - * see http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf - * (2023: the above web site is unavailable but tags are explained briefly at - * https://www.awaresystems.be/imaging/tiff/tifftags/docs/gel.html +#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ +/* Tags 33445-33452 are used for GEL fileformat, see + * http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ -#define TIFFTAG_MD_FILETAG 33445 /* Specifies the pixel data format encoding in the GEL file format. */ -#define TIFFTAG_MD_SCALEPIXEL 33446 /* scale factor */ -#define TIFFTAG_MD_COLORTABLE 33447 /* conversion from 16bit to 8bit */ -#define TIFFTAG_MD_LABNAME 33448 /* name of the lab that scanned this file. */ -#define TIFFTAG_MD_SAMPLEINFO 33449 /* information about the scanned GEL sample */ -#define TIFFTAG_MD_PREPDATE 33450 /* information about the date the sample was prepared YY/MM/DD */ -#define TIFFTAG_MD_PREPTIME 33451 /* information about the time the sample was prepared HH:MM*/ -#define TIFFTAG_MD_FILEUNITS 33452 /* Units for data in this file, as used in the GEL file format. */ +#define TIFFTAG_MD_FILETAG 33445 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_SCALEPIXEL 33446 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_COLORTABLE 33447 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_LABNAME 33448 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_SAMPLEINFO 33449 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_PREPDATE 33450 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_PREPTIME 33451 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ +#define TIFFTAG_MD_FILEUNITS 33452 /* http://research.stowers-institute.org/mcm/efg/ScientificSoftware/Utility/TiffTags/GEL-FileFormat.pdf */ /* IPTC TAG from RichTIFF specifications */ -#define TIFFTAG_RICHTIFFIPTC 33723 -#define TIFFTAG_INGR_PACKET_DATA_TAG 33918 /* Intergraph Application specific storage. */ -#define TIFFTAG_INGR_FLAG_REGISTERS 33919 /* Intergraph Application specific flags. */ -#define TIFFTAG_IRASB_TRANSORMATION_MATRIX 33920 /* Originally part of Intergraph's GeoTIFF tags, but likely understood by IrasB only. */ -#define TIFFTAG_MODELTIEPOINTTAG 33922 /* GeoTIFF */ +#define TIFFTAG_RICHTIFFIPTC 33723 +#define TIFFTAG_INGR_PACKET_DATA_TAG 33918 /* Intergraph Application specific storage. */ +#define TIFFTAG_INGR_FLAG_REGISTERS 33919 /* Intergraph Application specific flags. */ +#define TIFFTAG_IRASB_TRANSORMATION_MATRIX 33920 /* Originally part of Intergraph's GeoTIFF tags, but likely understood by IrasB only. */ +#define TIFFTAG_MODELTIEPOINTTAG 33922 /* GeoTIFF */ /* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ -#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ +#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ /* tag 34929 is a private tag registered to FedEx */ -#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ -#define TIFFTAG_IMAGESOURCEDATA 37724 /* http://justsolve.archiveteam.org/wiki/PSD, http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ */ -#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to EXIF Interoperability private directory */ -#define TIFFTAG_GDAL_METADATA 42112 /* Used by the GDAL library */ -#define TIFFTAG_GDAL_NODATA 42113 /* Used by the GDAL library */ -#define TIFFTAG_OCE_SCANJOB_DESCRIPTION 50215 /* Used in the Oce scanning process */ -#define TIFFTAG_OCE_APPLICATION_SELECTOR 50216 /* Used in the Oce scanning process. */ -#define TIFFTAG_OCE_IDENTIFICATION_NUMBER 50217 -#define TIFFTAG_OCE_IMAGELOGIC_CHARACTERISTICS 50218 +#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ +#define TIFFTAG_IMAGESOURCEDATA 37724 /* http://justsolve.archiveteam.org/wiki/PSD, http://www.adobe.com/devnet-apps/photoshop/fileformatashtml/ */ +#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ +#define TIFFTAG_GDAL_METADATA 42112 /* Used by the GDAL library */ +#define TIFFTAG_GDAL_NODATA 42113 /* Used by the GDAL library */ +#define TIFFTAG_OCE_SCANJOB_DESCRIPTION 50215 /* Used in the Oce scanning process */ +#define TIFFTAG_OCE_APPLICATION_SELECTOR 50216 /* Used in the Oce scanning process. */ +#define TIFFTAG_OCE_IDENTIFICATION_NUMBER 50217 +#define TIFFTAG_OCE_IMAGELOGIC_CHARACTERISTICS 50218 + /* tags 50674 to 50677 are reserved for ESRI */ -#define TIFFTAG_LERC_PARAMETERS 50674 /* Stores LERC version and additional compression method */ - +#define TIFFTAG_LERC_PARAMETERS 50674 /* Stores LERC version and additional compression method */ /* Adobe Digital Negative (DNG) format tags */ -#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ -#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ -#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ -#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model name (UTF-8) */ -#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space mapping */ -#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ -#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ -#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for the BlackLevel tag */ -#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ -#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level differences (columns) */ -#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level differences (rows) */ -#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding level */ -#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ -#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image area */ -#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image area */ -#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space transformation matrix 1 */ -#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space transformation matrix 2 */ -#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ -#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ -#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction matrix 1 */ -#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction matrix 2 */ -#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw values*/ -#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in linear reference space */ -#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in x-y chromaticity coordinates */ -#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero point */ -#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ -#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of sharpening */ -/* TIFFTAG_BAYERGREENSPLIT: &how closely the values of the green pixels in the blue/green rows - * track the values of the green pixels in the red/green rows */ -#define TIFFTAG_BAYERGREENSPLIT 50733 -#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ -#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ -#define TIFFTAG_LENSINFO 50736 /* info about the lens */ -#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ -#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the camera's anti-alias filter */ -#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ -#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ -#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote tag is safe to preserve along with the rest of the EXIF data */ -#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ -#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ -#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ -#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for the raw image data */ -#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original raw file (UTF-8) */ -#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original raw file */ -#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels of the sensor */ -#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates of fully masked pixels */ -#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ -#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space into ICC profile space */ -#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ -#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ +#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ +#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ +#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ +#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model + name */ +#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space + mapping */ +#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ +#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ +#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for + the BlackLevel tag */ +#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ +#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level + differences (columns) */ +#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level + differences (rows) */ +#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding + level */ +#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ +#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image + area */ +#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image + area */ +#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space + transformation matrix 1 */ +#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space + transformation matrix 2 */ +#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ +#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ +#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction + matrix 1 */ +#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction + matrix 2 */ +#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw + values*/ +#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in + linear reference space */ +#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in + x-y chromaticity + coordinates */ +#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero + point */ +#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ +#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of + sharpening */ +#define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of + the green pixels in the + blue/green rows track the + values of the green pixels + in the red/green rows */ +#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ +#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ +#define TIFFTAG_LENSINFO 50736 /* info about the lens */ +#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ +#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the + camera's anti-alias filter */ +#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ +#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ +#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote + tag is safe to preserve + along with the rest of the + EXIF data */ +#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ +#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ +#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ +#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for + the raw image data */ +#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original + raw file */ +#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original + raw file */ +#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels + of the sensor */ +#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates + of fully masked pixels */ +#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ +#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space + into ICC profile space */ +#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ +#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ -/* DNG 1.2.0.0 */ -#define TIFFTAG_COLORIMETRICREFERENCE 50879 /* &colorimetric reference */ -#define TIFFTAG_CAMERACALIBRATIONSIGNATURE 50931 /* &camera calibration signature (UTF-8) */ -#define TIFFTAG_PROFILECALIBRATIONSIGNATURE 50932 /* &profile calibration signature (UTF-8) */ -/* TIFFTAG_EXTRACAMERAPROFILES 50933 &extra camera profiles : is already defined for GeoTIFF DGIWG */ -#define TIFFTAG_ASSHOTPROFILENAME 50934 /* &as shot profile name (UTF-8) */ -#define TIFFTAG_NOISEREDUCTIONAPPLIED 50935 /* &amount of applied noise reduction */ -#define TIFFTAG_PROFILENAME 50936 /* &camera profile name (UTF-8) */ -#define TIFFTAG_PROFILEHUESATMAPDIMS 50937 /* &dimensions of HSV mapping */ -#define TIFFTAG_PROFILEHUESATMAPDATA1 50938 /* &first HSV mapping table */ -#define TIFFTAG_PROFILEHUESATMAPDATA2 50939 /* &second HSV mapping table */ -#define TIFFTAG_PROFILETONECURVE 50940 /* &default tone curve */ -#define TIFFTAG_PROFILEEMBEDPOLICY 50941 /* &profile embedding policy */ -#define TIFFTAG_PROFILECOPYRIGHT 50942 /* &profile copyright information (UTF-8) */ -#define TIFFTAG_FORWARDMATRIX1 50964 /* &matrix for mapping white balanced camera colors to XYZ D50 */ -#define TIFFTAG_FORWARDMATRIX2 50965 /* &matrix for mapping white balanced camera colors to XYZ D50 */ -#define TIFFTAG_PREVIEWAPPLICATIONNAME 50966 /* &name of application that created preview (UTF-8) */ -#define TIFFTAG_PREVIEWAPPLICATIONVERSION 50967 /* &version of application that created preview (UTF-8) */ -#define TIFFTAG_PREVIEWSETTINGSNAME 50968 /* &name of conversion settings (UTF-8) */ -#define TIFFTAG_PREVIEWSETTINGSDIGEST 50969 /* &unique id of conversion settings */ -#define TIFFTAG_PREVIEWCOLORSPACE 50970 /* &preview color space */ -#define TIFFTAG_PREVIEWDATETIME 50971 /* &date/time preview was rendered */ -#define TIFFTAG_RAWIMAGEDIGEST 50972 /* &md5 of raw image data */ -#define TIFFTAG_ORIGINALRAWFILEDIGEST 50973 /* &md5 of the data stored in the OriginalRawFileData tag */ -#define TIFFTAG_SUBTILEBLOCKSIZE 50974 /* &subtile block size */ -#define TIFFTAG_ROWINTERLEAVEFACTOR 50975 /* &number of interleaved fields */ -#define TIFFTAG_PROFILELOOKTABLEDIMS 50981 /* &num of input samples in each dim of default "look" table */ -#define TIFFTAG_PROFILELOOKTABLEDATA 50982 /* &default "look" table for use as starting point */ +#define TIFFTAG_RPCCOEFFICIENT 50844 /* Define by GDAL for geospatial georeferencing through RPC: http://geotiff.maptools.org/rpc_prop.html */ -/* DNG 1.3.0.0 */ -#define TIFFTAG_OPCODELIST1 51008 /* &opcodes that should be applied to raw image after reading */ -#define TIFFTAG_OPCODELIST2 51009 /* &opcodes that should be applied after mapping to linear reference */ -#define TIFFTAG_OPCODELIST3 51022 /* &opcodes that should be applied after demosaicing */ -#define TIFFTAG_NOISEPROFILE 51041 /* &noise profile */ - -/* DNG 1.4.0.0 */ -#define TIFFTAG_DEFAULTUSERCROP 51125 /* &default user crop rectangle in relative coords */ -#define TIFFTAG_DEFAULTBLACKRENDER 51110 /* &black rendering hint */ -#define TIFFTAG_BASELINEEXPOSUREOFFSET 51109 /* &baseline exposure offset */ -#define TIFFTAG_PROFILELOOKTABLEENCODING 51108 /* &3D LookTable indexing conversion */ -#define TIFFTAG_PROFILEHUESATMAPENCODING 51107 /* &3D HueSatMap indexing conversion */ -#define TIFFTAG_ORIGINALDEFAULTFINALSIZE 51089 /* &default final size of larger original file for this proxy */ -#define TIFFTAG_ORIGINALBESTQUALITYFINALSIZE 51090 /* &best quality final size of larger original file for this proxy */ -#define TIFFTAG_ORIGINALDEFAULTCROPSIZE 51091 /* &the default crop size of larger original file for this proxy */ -#define TIFFTAG_NEWRAWIMAGEDIGEST 51111 /* &modified MD5 digest of the raw image data */ -#define TIFFTAG_RAWTOPREVIEWGAIN 51112 /* &The gain between the main raw FD and the preview IFD containing this tag */ - -/* DNG 1.5.0.0 */ -#define TIFFTAG_DEPTHFORMAT 51177 /* &encoding of the depth data in the file */ -#define TIFFTAG_DEPTHNEAR 51178 /* &distance from the camera represented by value 0 in the depth map */ -#define TIFFTAG_DEPTHFAR 51179 /* &distance from the camera represented by the maximum value in the depth map */ -#define TIFFTAG_DEPTHUNITS 51180 /* &measurement units for DepthNear and DepthFar */ -#define TIFFTAG_DEPTHMEASURETYPE 51181 /* &measurement geometry for the depth map */ -#define TIFFTAG_ENHANCEPARAMS 51182 /* &a string that documents how the enhanced image data was processed. */ - -/* DNG 1.6.0.0 */ -#define TIFFTAG_PROFILEGAINTABLEMAP 52525 /* &spatially varying gain tables that can be applied as starting point */ -#define TIFFTAG_SEMANTICNAME 52526 /* &a string that identifies the semantic mask */ -#define TIFFTAG_SEMANTICINSTANCEID 52528 /* &a string that identifies a specific instance in a semantic mask */ -#define TIFFTAG_MASKSUBAREA 52536 /* &the crop rectangle of this IFD's mask, relative to the main image */ -#define TIFFTAG_RGBTABLES 52543 /* &color transforms to apply to masked image regions */ -#define TIFFTAG_CALIBRATIONILLUMINANT3 52529 /* &the illuminant used for the third set of color calibration tags */ -#define TIFFTAG_COLORMATRIX3 52531 /* &matrix to convert XYZ values to reference camera native color space under CalibrationIlluminant3 */ -#define TIFFTAG_CAMERACALIBRATION3 52530 /* &matrix to transform reference camera native space values to individual camera native space values under CalibrationIlluminant3 */ -#define TIFFTAG_REDUCTIONMATRIX3 52538 /* &dimensionality reduction matrix for use in color conversion to XYZ under CalibrationIlluminant3 */ -#define TIFFTAG_PROFILEHUESATMAPDATA3 52537 /* &the data for the third HSV table */ -#define TIFFTAG_FORWARDMATRIX3 52532 /* &matrix to map white balanced camera colors to XYZ D50 */ -#define TIFFTAG_ILLUMINANTDATA1 52533 /* &data for the first calibration illuminant */ -#define TIFFTAG_ILLUMINANTDATA2 52534 /* &data for the second calibration illuminant */ -#define TIFFTAG_ILLUMINANTDATA3 53535 /* &data for the third calibration illuminant */ - -/* TIFF/EP */ -#define TIFFTAG_EP_CFAREPEATPATTERNDIM 33421 /* dimensions of CFA pattern */ -#define TIFFTAG_EP_CFAPATTERN 33422 /* color filter array pattern */ -#define TIFFTAG_EP_BATTERYLEVEL 33423 /* battery level (rational or ASCII) */ -#define TIFFTAG_EP_INTERLACE 34857 /* Number of multi-field images */ -/* TIFFTAG_EP_IPTC_NAA and TIFFTAG_RICHTIFFIPTC share the same tag number (33723) - * LibTIFF type is UNDEFINED or BYTE, but often times incorrectly specified as LONG, - * because TIFF/EP (ISO/DIS 12234-2) specifies type LONG or ASCII. */ -#define TIFFTAG_EP_IPTC_NAA 33723 /* Alias IPTC/NAA Newspaper Association RichTIFF */ -#define TIFFTAG_EP_TIMEZONEOFFSET 34858 /* Time zone offset relative to UTC */ -#define TIFFTAG_EP_SELFTIMERMODE 34859 /* Number of seconds capture was delayed from button press */ -#define TIFFTAG_EP_FLASHENERGY 37387 /* Flash energy, or range if there is uncertainty */ -#define TIFFTAG_EP_SPATIALFREQUENCYRESPONSE 37388 /* Spatial frequency response */ -#define TIFFTAG_EP_NOISE 37389 /* Camera noise measurement values */ -#define TIFFTAG_EP_FOCALPLANEXRESOLUTION 37390 /* Focal plane X resolution */ -#define TIFFTAG_EP_FOCALPLANEYRESOLUTION 37391 /* Focal plane Y resolution */ -#define TIFFTAG_EP_FOCALPLANERESOLUTIONUNIT 37392 /* Focal plane resolution unit */ -#define TIFFTAG_EP_IMAGENUMBER 37393 /* Number of image when several of burst shot stored in same TIFF/EP */ -#define TIFFTAG_EP_SECURITYCLASSIFICATION 37394 /* Security classification */ -#define TIFFTAG_EP_IMAGEHISTORY 37395 /* Record of what has been done to the image */ -#define TIFFTAG_EP_EXPOSUREINDEX 37397 /* Exposure index */ -#define TIFFTAG_EP_STANDARDID 37398 /* TIFF/EP standard version, n.n.n.n */ -#define TIFFTAG_EP_SENSINGMETHOD 37399 /* Type of image sensor */ -/* - * TIFF/EP tags equivalent to EXIF tags - * Note that TIFF-EP and EXIF use nearly the same metadata tag set, but TIFF-EP stores the tags in IFD 0, - * while EXIF store the tags in a separate IFD. Either location is allowed by DNG, but the EXIF location is preferred. - */ -#define TIFFTAG_EP_EXPOSURETIME 33434 /* Exposure time */ -#define TIFFTAG_EP_FNUMBER 33437 /* F number */ -#define TIFFTAG_EP_EXPOSUREPROGRAM 34850 /* Exposure program */ -#define TIFFTAG_EP_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ -#define TIFFTAG_EP_ISOSPEEDRATINGS 34855 /* ISO speed rating */ -#define TIFFTAG_EP_OECF 34856 /* Optoelectric conversion factor */ -#define TIFFTAG_EP_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ -#define TIFFTAG_EP_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ -#define TIFFTAG_EP_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ -#define TIFFTAG_EP_APERTUREVALUE 37378 /* Aperture */ -#define TIFFTAG_EP_BRIGHTNESSVALUE 37379 /* Brightness */ -#define TIFFTAG_EP_EXPOSUREBIASVALUE 37380 /* Exposure bias */ -#define TIFFTAG_EP_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ -#define TIFFTAG_EP_SUBJECTDISTANCE 37382 /* Subject distance */ -#define TIFFTAG_EP_METERINGMODE 37383 /* Metering mode */ -#define TIFFTAG_EP_LIGHTSOURCE 37384 /* Light source */ -#define TIFFTAG_EP_FLASH 37385 /* Flash */ -#define TIFFTAG_EP_FOCALLENGTH 37386 /* Lens focal length */ -#define TIFFTAG_EP_SUBJECTLOCATION 37396 /* Subject location (area) */ - -#define TIFFTAG_RPCCOEFFICIENT 50844 /* Define by GDAL for geospatial georeferencing through RPC: http://geotiff.maptools.org/rpc_prop.html */ -#define TIFFTAG_ALIAS_LAYER_METADATA 50784 /* Alias Sketchbook Pro layer usage description. */ +#define TIFFTAG_ALIAS_LAYER_METADATA 50784 /* Alias Sketchbook Pro layer usage description. */ /* GeoTIFF DGIWG */ -#define TIFFTAG_TIFF_RSID 50908 /* https://www.awaresystems.be/imaging/tiff/tifftags/tiff_rsid.html */ -#define TIFFTAG_GEO_METADATA 50909 /* https://www.awaresystems.be/imaging/tiff/tifftags/geo_metadata.html */ -#define TIFFTAG_EXTRACAMERAPROFILES 50933 /* http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf */ +#define TIFFTAG_TIFF_RSID 50908 /* https://www.awaresystems.be/imaging/tiff/tifftags/tiff_rsid.html */ +#define TIFFTAG_GEO_METADATA 50909 /* https://www.awaresystems.be/imaging/tiff/tifftags/geo_metadata.html */ + +#define TIFFTAG_EXTRACAMERAPROFILES 50933 /* http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf */ /* tag 65535 is an undefined tag used by Eastman Kodak */ -#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ +#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ /* * The following are ``pseudo tags'' that can be used to control @@ -693,206 +590,211 @@ typedef enum * http://www.remotesensing.org/libtiff/bugs.html with the appropriate * C definitions to add. */ -#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ -#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ -#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ -#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ -#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ -#define FAXMODE_WORDALIGN 0x0008 /* word align row */ -#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ -#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ +#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ +#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ +#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ +#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ +#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ +#define FAXMODE_WORDALIGN 0x0008 /* word align row */ +#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ +#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ /* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ -#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ -#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ -#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ -#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ -#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ -#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ +#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ +#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ +#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ +#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ +#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ +#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ /* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ -#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ -#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ -#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ -#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ -#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ -#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ -#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ -#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ +#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ +#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ +#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ +#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ +#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ +#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ +#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ +#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ /* 65550-65556 are allocated to Oceana Matrix */ -#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ -#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ -#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ -#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ -#define DCSIMAGERFILTER_IR 0 /* infrared filter */ -#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ -#define DCSIMAGERFILTER_CFA 2 /* color filter array */ -#define DCSIMAGERFILTER_OTHER 3 /* other filter */ -#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ -#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ -#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ -#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ -#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ -#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ -#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ -#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ +#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ +#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ +#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ +#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ +#define DCSIMAGERFILTER_IR 0 /* infrared filter */ +#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ +#define DCSIMAGERFILTER_CFA 2 /* color filter array */ +#define DCSIMAGERFILTER_OTHER 3 /* other filter */ +#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ +#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ +#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ +#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ +#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ +#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ +#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ +#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ /* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ -#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ -#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ +#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ +#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ /* 65559 is allocated to Oceana Matrix */ -#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ -#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ -#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ -#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ -#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ -#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ -#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ -#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ -#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ -#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ -#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ -#define PERSAMPLE_MERGED 0 /* present as a single value */ -#define PERSAMPLE_MULTI 1 /* present as multiple values */ -#define TIFFTAG_ZSTD_LEVEL 65564 /* ZSTD compression level */ -#define TIFFTAG_LERC_VERSION 65565 /* LERC version */ -#define LERC_VERSION_2_4 4 -#define TIFFTAG_LERC_ADD_COMPRESSION 65566 /* LERC additional compression */ -#define LERC_ADD_COMPRESSION_NONE 0 -#define LERC_ADD_COMPRESSION_DEFLATE 1 -#define LERC_ADD_COMPRESSION_ZSTD 2 -#define TIFFTAG_LERC_MAXZERROR 65567 /* LERC maximum error */ -#define TIFFTAG_WEBP_LEVEL 65568 /* WebP compression level */ -#define TIFFTAG_WEBP_LOSSLESS 65569 /* WebP lossless/lossy */ -#define TIFFTAG_DEFLATE_SUBCODEC 65570 /* ZIP codec: to get/set the sub-codec to use. Will default to libdeflate when available */ -#define DEFLATE_SUBCODEC_ZLIB 0 -#define DEFLATE_SUBCODEC_LIBDEFLATE 1 +#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ +#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ +#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ +#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ +#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ +#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ +#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ +#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ +#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ +#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ +#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ +#define PERSAMPLE_MERGED 0 /* present as a single value */ +#define PERSAMPLE_MULTI 1 /* present as multiple values */ +#define TIFFTAG_ZSTD_LEVEL 65564 /* ZSTD compression level */ +#define TIFFTAG_LERC_VERSION 65565 /* LERC version */ +#define LERC_VERSION_2_4 4 +#define TIFFTAG_LERC_ADD_COMPRESSION 65566 /* LERC additional compression */ +#define LERC_ADD_COMPRESSION_NONE 0 +#define LERC_ADD_COMPRESSION_DEFLATE 1 +#define LERC_ADD_COMPRESSION_ZSTD 2 +#define TIFFTAG_LERC_MAXZERROR 65567 /* LERC maximum error */ +#define TIFFTAG_WEBP_LEVEL 65568 /* WebP compression level */ +#define TIFFTAG_WEBP_LOSSLESS 65569 /* WebP lossless/lossy */ +#define TIFFTAG_DEFLATE_SUBCODEC 65570 /* ZIP codec: to get/set the sub-codec to use. Will default to libdeflate when available */ +#define DEFLATE_SUBCODEC_ZLIB 0 +#define DEFLATE_SUBCODEC_LIBDEFLATE 1 /* * EXIF tags */ -#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ -#define EXIFTAG_FNUMBER 33437 /* F number */ -#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ -#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ -/* After EXIF 2.2.1 ISOSpeedRatings is named PhotographicSensitivity. - In addition, while "Count=Any", only 1 count should be used. */ -#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ -#define EXIFTAG_PHOTOGRAPHICSENSITIVITY 34855 /* Photographic Sensitivity (new name for tag 34855) */ -#define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ -#define EXIFTAG_EXIFVERSION 36864 /* Exif version */ -#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original data generation */ -#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital data generation */ -#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ -#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ -#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ -#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ -#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ -#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ -#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ -#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ -#define EXIFTAG_METERINGMODE 37383 /* Metering mode */ -#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ -#define EXIFTAG_FLASH 37385 /* Flash */ -#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ -#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ -#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ -#define EXIFTAG_USERCOMMENT 37510 /* User comments */ -#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ -#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ -#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ -#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ -#define EXIFTAG_COLORSPACE 40961 /* Color space information */ -#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ -#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ -#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ -#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ -#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ -#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ -#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ -#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ -#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ -#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ -#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ -#define EXIFTAG_FILESOURCE 41728 /* File source */ -#define EXIFTAG_SCENETYPE 41729 /* Scene type */ -#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ -#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ -#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ -#define EXIFTAG_WHITEBALANCE 41987 /* White balance */ -#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ -#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ -#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_CONTRAST 41992 /* Contrast */ -#define EXIFTAG_SATURATION 41993 /* Saturation */ -#define EXIFTAG_SHARPNESS 41994 /* Sharpness */ -#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ -#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ -#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ +#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ +#define EXIFTAG_FNUMBER 33437 /* F number */ +#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ +#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ +#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ +#define EXIFTAG_PHOTOGRAPHICSENSITIVITY 34855 /* Photographic Sensitivity (new name for tag 34855) */ +#define EXIFTAG_OECF 34856 /* Optoelectric conversion factor */ +#define EXIFTAG_EXIFVERSION 36864 /* Exif version */ +#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original + data generation */ +#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital + data generation */ +#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ +#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ +#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ +#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ +#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ +#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ +#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ +#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ +#define EXIFTAG_METERINGMODE 37383 /* Metering mode */ +#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ +#define EXIFTAG_FLASH 37385 /* Flash */ +#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ +#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ +#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ +#define EXIFTAG_USERCOMMENT 37510 /* User comments */ +#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ +#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ +#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ +#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ +#define EXIFTAG_COLORSPACE 40961 /* Color space information */ +#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ +#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ +#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ +#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ +#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ +#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ +#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ +#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ +#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ +#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ +#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ +#define EXIFTAG_FILESOURCE 41728 /* File source */ +#define EXIFTAG_SCENETYPE 41729 /* Scene type */ +#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ +#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ +#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ +#define EXIFTAG_WHITEBALANCE 41987 /* White balance */ +#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ +#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ +#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ +#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ +#define EXIFTAG_CONTRAST 41992 /* Contrast */ +#define EXIFTAG_SATURATION 41993 /* Saturation */ +#define EXIFTAG_SHARPNESS 41994 /* Sharpness */ +#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ +#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ +#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ /*--: New for EXIF-Version 2.32, May 2019 ... */ -#define EXIFTAG_SENSITIVITYTYPE 34864 /* The SensitivityType tag indicates which one of the parameters of ISO12232 is the PhotographicSensitivity tag. */ -#define EXIFTAG_STANDARDOUTPUTSENSITIVITY 34865 /* This tag indicates the standard output sensitivity value of a camera or input device defined in ISO 12232. */ -#define EXIFTAG_RECOMMENDEDEXPOSUREINDEX 34866 /* recommended exposure index */ -#define EXIFTAG_ISOSPEED 34867 /* ISO speed value */ -#define EXIFTAG_ISOSPEEDLATITUDEYYY 34868 /* ISO speed latitude yyy */ -#define EXIFTAG_ISOSPEEDLATITUDEZZZ 34869 /* ISO speed latitude zzz */ -#define EXIFTAG_OFFSETTIME 36880 /* offset from UTC of the time of DateTime tag. */ -#define EXIFTAG_OFFSETTIMEORIGINAL 36881 /* offset from UTC of the time of DateTimeOriginal tag. */ -#define EXIFTAG_OFFSETTIMEDIGITIZED 36882 /* offset from UTC of the time of DateTimeDigitized tag. */ -#define EXIFTAG_TEMPERATURE 37888 /* Temperature as the ambient situation at the shot in dergee Celsius */ -#define EXIFTAG_HUMIDITY 37889 /* Humidity as the ambient situation at the shot in percent */ -#define EXIFTAG_PRESSURE 37890 /* Pressure as the ambient situation at the shot hecto-Pascal (hPa) */ -#define EXIFTAG_WATERDEPTH 37891 /* WaterDepth as the ambient situation at the shot in meter (m) */ -#define EXIFTAG_ACCELERATION 37892 /* Acceleration (a scalar regardless of direction) as the ambientsituation at the shot in units of mGal (10-5 m/s^2) */ -/* EXIFTAG_CAMERAELEVATIONANGLE: Elevation/depression. angle of the orientation of the camera(imaging optical axis) - * as the ambient situation at the shot in degree from -180deg to +180deg. */ -#define EXIFTAG_CAMERAELEVATIONANGLE 37893 -#define EXIFTAG_CAMERAOWNERNAME 42032 /* owner of a camera */ -#define EXIFTAG_BODYSERIALNUMBER 42033 /* serial number of the body of the camera */ -/* EXIFTAG_LENSSPECIFICATION: minimum focal length (in mm), maximum focal length (in mm),minimum F number in the minimum focal length, - * and minimum F number in the maximum focal length, */ -#define EXIFTAG_LENSSPECIFICATION 42034 -#define EXIFTAG_LENSMAKE 42035 /* the lens manufacturer */ -#define EXIFTAG_LENSMODEL 42036 /* the lens model name and model number */ -#define EXIFTAG_LENSSERIALNUMBER 42037 /* the serial number of the interchangeable lens */ -#define EXIFTAG_GAMMA 42240 /* value of coefficient gamma */ -#define EXIFTAG_COMPOSITEIMAGE 42080 /* composite image */ -#define EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE 42081 /* source image number of composite image */ -#define EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE 42082 /* source exposure times of composite image */ +#define EXIFTAG_SENSITIVITYTYPE 34864 /* The SensitivityType tag indicates which one of the parameters of ISO12232 is the PhotographicSensitivity tag. */ +#define EXIFTAG_STANDARDOUTPUTSENSITIVITY 34865 /* This tag indicates the standard output sensitivity value of a camera or input device defined in ISO 12232. */ +#define EXIFTAG_RECOMMENDEDEXPOSUREINDEX 34866 /* recommended exposure index */ +#define EXIFTAG_ISOSPEED 34867 /* ISO speed value */ +#define EXIFTAG_ISOSPEEDLATITUDEYYY 34868 /* ISO speed latitude yyy */ +#define EXIFTAG_ISOSPEEDLATITUDEZZZ 34869 /* ISO speed latitude zzz */ +#define EXIFTAG_OFFSETTIME 36880 /* offset from UTC of the time of DateTime tag. */ +#define EXIFTAG_OFFSETTIMEORIGINAL 36881 /* offset from UTC of the time of DateTimeOriginal tag. */ +#define EXIFTAG_OFFSETTIMEDIGITIZED 36882 /* offset from UTC of the time of DateTimeDigitized tag. */ +#define EXIFTAG_TEMPERATURE 37888 /* Temperature as the ambient situation at the shot in dergee Celsius */ +#define EXIFTAG_HUMIDITY 37889 /* Humidity as the ambient situation at the shot in percent */ +#define EXIFTAG_PRESSURE 37890 /* Pressure as the ambient situation at the shot hecto-Pascal (hPa) */ +#define EXIFTAG_WATERDEPTH 37891 /* WaterDepth as the ambient situation at the shot in meter (m) */ +#define EXIFTAG_ACCELERATION 37892 /* Acceleration (a scalar regardless of direction) as the ambient situation at the shot in units of mGal (10-5 m/s^2) */ +#define EXIFTAG_CAMERAELEVATIONANGLE 37893 /* Elevation/depression. angle of the orientation of the camera(imaging optical axis) as the ambient situation at the shot in degree from -180deg to +180deg. */ +#define EXIFTAG_CAMERAOWNERNAME 42032 /* owner of a camera */ +#define EXIFTAG_BODYSERIALNUMBER 42033 /* serial number of the body of the camera */ +#define EXIFTAG_LENSSPECIFICATION 42034 /* minimum focal length (in mm), maximum focal length (in mm), minimum F number in the minimum focal length, and minimum F number in the maximum focal length, */ +#define EXIFTAG_LENSMAKE 42035 /* the lens manufacturer */ +#define EXIFTAG_LENSMODEL 42036 /* the lens model name and model number */ +#define EXIFTAG_LENSSERIALNUMBER 42037 /* the serial number of the interchangeable lens */ +#define EXIFTAG_GAMMA 42240 /* value of coefficient gamma */ +#define EXIFTAG_COMPOSITEIMAGE 42080 /* composite image */ +#define EXIFTAG_SOURCEIMAGENUMBEROFCOMPOSITEIMAGE 42081 /* source image number of composite image */ +#define EXIFTAG_SOURCEEXPOSURETIMESOFCOMPOSITEIMAGE 42082 /* source exposure times of composite image */ /* * EXIF-GPS tags (Version 2.31, July 2016) */ -#define GPSTAG_VERSIONID 0 /* Indicates the version of GPSInfoIFD. */ -#define GPSTAG_LATITUDEREF 1 /* Indicates whether the latitude is north or south latitude. */ -#define GPSTAG_LATITUDE 2 /* Indicates the latitude. */ -#define GPSTAG_LONGITUDEREF 3 /* Indicates whether the longitude is east or west longitude. */ -#define GPSTAG_LONGITUDE 4 /* Indicates the longitude. */ -#define GPSTAG_ALTITUDEREF 5 /* Indicates the altitude used as the reference altitude. */ -#define GPSTAG_ALTITUDE 6 /* Indicates the altitude based on the reference in GPSAltitudeRef. */ -#define GPSTAG_TIMESTAMP 7 /*Indicates the time as UTC (Coordinated Universal Time). */ -#define GPSTAG_SATELLITES 8 /*Indicates the GPS satellites used for measurements. */ -#define GPSTAG_STATUS 9 /* Indicates the status of the GPS receiver when the image is recorded. */ -#define GPSTAG_MEASUREMODE 10 /* Indicates the GPS measurement mode. */ -#define GPSTAG_DOP 11 /* Indicates the GPS DOP (data degree of precision). */ -#define GPSTAG_SPEEDREF 12 /* Indicates the unit used to express the GPS receiver speed of movement. */ -#define GPSTAG_SPEED 13 /* Indicates the speed of GPS receiver movement. */ -#define GPSTAG_TRACKREF 14 /* Indicates the reference for giving the direction of GPS receiver movement. */ -#define GPSTAG_TRACK 15 /* Indicates the direction of GPS receiver movement. */ -#define GPSTAG_IMGDIRECTIONREF 16 /* Indicates the reference for giving the direction of the image when it is captured. */ -#define GPSTAG_IMGDIRECTION 17 /* Indicates the direction of the image when it was captured. */ -#define GPSTAG_MAPDATUM 18 /* Indicates the geodetic survey data used by the GPS receiver. (e.g. WGS-84) */ -#define GPSTAG_DESTLATITUDEREF 19 /* Indicates whether the latitude of the destination point is north or south latitude. */ -#define GPSTAG_DESTLATITUDE 20 /* Indicates the latitude of the destination point. */ -#define GPSTAG_DESTLONGITUDEREF 21 /* Indicates whether the longitude of the destination point is east or west longitude. */ -#define GPSTAG_DESTLONGITUDE 22 /* Indicates the longitude of the destination point. */ -#define GPSTAG_DESTBEARINGREF 23 /* Indicates the reference used for giving the bearing to the destination point. */ -#define GPSTAG_DESTBEARING 24 /* Indicates the bearing to the destination point. */ -#define GPSTAG_DESTDISTANCEREF 25 /* Indicates the unit used to express the distance to the destination point. */ -#define GPSTAG_DESTDISTANCE 26 /* Indicates the distance to the destination point. */ -#define GPSTAG_PROCESSINGMETHOD 27 /* A character string recording the name of the method used for location finding. */ -#define GPSTAG_AREAINFORMATION 28 /* A character string recording the name of the GPS area. */ -#define GPSTAG_DATESTAMP 29 /* A character string recording date and time information relative to UTC (Coordinated Universal Time). */ -#define GPSTAG_DIFFERENTIAL 30 /* Indicates whether differential correction is applied to the GPS receiver. */ -#define GPSTAG_GPSHPOSITIONINGERROR 31 /* Indicates horizontal positioning errors in meters. */ +#define GPSTAG_VERSIONID 0 /* Indicates the version of GPSInfoIFD. */ +#define GPSTAG_LATITUDEREF 1 /* Indicates whether the latitude is north or south latitude. */ +#define GPSTAG_LATITUDE 2 /* Indicates the latitude. */ +#define GPSTAG_LONGITUDEREF 3 /* Indicates whether the longitude is east or west longitude. */ +#define GPSTAG_LONGITUDE 4 /* Indicates the longitude. */ +#define GPSTAG_ALTITUDEREF 5 /* Indicates the altitude used as the reference altitude. */ +#define GPSTAG_ALTITUDE 6 /* Indicates the altitude based on the reference in GPSAltitudeRef. */ +#define GPSTAG_TIMESTAMP 7 /* Indicates the time as UTC (Coordinated Universal Time). */ +#define GPSTAG_SATELLITES 8 /* Indicates the GPS satellites used for measurements. */ +#define GPSTAG_STATUS 9 /* Indicates the status of the GPS receiver when the image is recorded. */ +#define GPSTAG_MEASUREMODE 10 /* Indicates the GPS measurement mode. */ +#define GPSTAG_DOP 11 /* Indicates the GPS DOP (data degree of precision). */ +#define GPSTAG_SPEEDREF 12 /* Indicates the unit used to express the GPS receiver speed of movement. */ +#define GPSTAG_SPEED 13 /* Indicates the speed of GPS receiver movement. */ +#define GPSTAG_TRACKREF 14 /* Indicates the reference for giving the direction of GPS receiver movement. */ +#define GPSTAG_TRACK 15 /* Indicates the direction of GPS receiver movement. */ +#define GPSTAG_IMGDIRECTIONREF 16 /* Indicates the reference for giving the direction of the image when it is captured. */ +#define GPSTAG_IMGDIRECTION 17 /* Indicates the direction of the image when it was captured. */ +#define GPSTAG_MAPDATUM 18 /* Indicates the geodetic survey data used by the GPS receiver. (e.g. WGS-84) */ +#define GPSTAG_DESTLATITUDEREF 19 /* Indicates whether the latitude of the destination point is north or south latitude. */ +#define GPSTAG_DESTLATITUDE 20 /* Indicates the latitude of the destination point. */ +#define GPSTAG_DESTLONGITUDEREF 21 /* Indicates whether the longitude of the destination point is east or west longitude. */ +#define GPSTAG_DESTLONGITUDE 22 /* Indicates the longitude of the destination point. */ +#define GPSTAG_DESTBEARINGREF 23 /* Indicates the reference used for giving the bearing to the destination point. */ +#define GPSTAG_DESTBEARING 24 /* Indicates the bearing to the destination point. */ +#define GPSTAG_DESTDISTANCEREF 25 /* Indicates the unit used to express the distance to the destination point. */ +#define GPSTAG_DESTDISTANCE 26 /* Indicates the distance to the destination point. */ +#define GPSTAG_PROCESSINGMETHOD 27 /* A character string recording the name of the method used for location finding. */ +#define GPSTAG_AREAINFORMATION 28 /* A character string recording the name of the GPS area. */ +#define GPSTAG_DATESTAMP 29 /* A character string recording date and time information relative to UTC (Coordinated Universal Time). */ +#define GPSTAG_DIFFERENTIAL 30 /* Indicates whether differential correction is applied to the GPS receiver. */ +#define GPSTAG_GPSHPOSITIONINGERROR 31 /* Indicates horizontal positioning errors in meters. */ #endif /* _TIFF_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h-vms b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h-vms new file mode 100644 index 000000000..72b033905 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h-vms @@ -0,0 +1,90 @@ +/* + Configuration defines for installed libtiff. + This file maintained for backward compatibility. Do not use definitions + from this file in your programs. +*/ + +#ifndef _TIFFCONF_ +#define _TIFFCONF_ + +/* 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 + +/* Compatibility stuff. */ + +/* Define as 0 or 1 according to the floating point format suported by the + machine */ +#define HAVE_IEEEFP 1 + +#define HAVE_GETOPT 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) */ +#define 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_ */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h.cmake.in b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h.cmake.in index 306874f5a..0eb54139b 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h.cmake.in +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h.cmake.in @@ -4,21 +4,9 @@ from this file in your programs. */ -/* clang-format off */ -/* clang-format disabled because CMake scripts are very sensitive to the - * formatting of this file. configure_file variables of type "@VAR@" are - * modified by clang-format and won't be substituted. - */ - #ifndef _TIFFCONF_ #define _TIFFCONF_ - -#include -#include -#include - - /* Signed 16-bit type */ #define TIFF_INT16_T @TIFF_INT16_T@ @@ -43,26 +31,23 @@ /* 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 supported by the +/* Define as 0 or 1 according to the floating point format suported by the machine */ #cmakedefine HAVE_IEEEFP 1 -/* The concept of HOST_FILLORDER is broken. Since libtiff 4.5.1 - * this macro will always be hardcoded to FILLORDER_LSB2MSB on all - * architectures, to reflect past long behavior of doing so on x86 architecture. - * Note however that the default FillOrder used by libtiff is FILLORDER_MSB2LSB, - * as mandated per the TIFF specification. - * The influence of HOST_FILLORDER is only when passing the 'H' mode in - * TIFFOpen(). - * You should NOT rely on this macro to decide the CPU endianness! - * This macro will be removed in libtiff 4.6 - */ -#define HOST_FILLORDER FILLORDER_LSB2MSB +/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ +#define HOST_FILLORDER @HOST_FILLORDER@ /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ @@ -77,9 +62,6 @@ /* 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 @@ -109,7 +91,7 @@ #cmakedefine LIBDEFLATE_SUPPORT 1 /* Support strip chopping (whether or not to convert single-strip uncompressed - images to multiple strips of ~8Kb to reduce memory usage) */ + images to mutiple strips of ~8Kb to reduce memory usage) */ #cmakedefine STRIPCHOP_DEFAULT TIFF_STRIPCHOP /* Enable SubIFD tag (330) support */ @@ -140,5 +122,3 @@ #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ - -/* clang-format on */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h.in b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h.in index ab017357d..9bd6a2de4 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h.in +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.h.in @@ -4,21 +4,9 @@ from this file in your programs. */ -/* clang-format off */ -/* clang-format disabled because CMake scripts are very sensitive to the - * formatting of this file. configure_file variables of type "@VAR@" are - * modified by clang-format and won't be substituted. - */ - #ifndef _TIFFCONF_ #define _TIFFCONF_ - -#include -#include -#include - - /* Signed 16-bit type */ #undef TIFF_INT16_T @@ -46,23 +34,17 @@ /* 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 supported by the +/* Define as 0 or 1 according to the floating point format suported by the machine */ #undef HAVE_IEEEFP -/* The concept of HOST_FILLORDER is broken. Since libtiff 4.5.1 - * this macro will always be hardcoded to FILLORDER_LSB2MSB on all - * architectures, to reflect past long behavior of doing so on x86 architecture. - * Note however that the default FillOrder used by libtiff is FILLORDER_MSB2LSB, - * as mandated per the TIFF specification. - * The influence of HOST_FILLORDER is only when passing the 'H' mode in - * TIFFOpen(). - * You should NOT rely on this macro to decide the CPU endianness! - * This macro will be removed in libtiff 4.6 - */ -#define HOST_FILLORDER FILLORDER_LSB2MSB +/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ +#undef HOST_FILLORDER /* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian (Intel) */ @@ -77,9 +59,6 @@ /* 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 @@ -109,7 +88,7 @@ #undef LIBDEFLATE_SUPPORT /* Support strip chopping (whether or not to convert single-strip uncompressed - images to multiple strips of ~8Kb to reduce memory usage) */ + images to mutiple strips of ~8Kb to reduce memory usage) */ #undef STRIPCHOP_DEFAULT /* Enable SubIFD tag (330) support */ @@ -140,5 +119,3 @@ #define IPTC_SUPPORT #endif /* _TIFFCONF_ */ - -/* clang-format on */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.vc.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.vc.h new file mode 100644 index 000000000..fb37a755f --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.vc.h @@ -0,0 +1,152 @@ +/* + Configuration defines for installed libtiff. + This file maintained for backward compatibility. Do not use definitions + from this file in your programs. +*/ + +#ifndef _TIFFCONF_ +#define _TIFFCONF_ + +/* The size of a `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* Signed 8-bit type */ +#define TIFF_INT8_T signed char + +/* Unsigned 8-bit type */ +#define TIFF_UINT8_T unsigned char + +/* Signed 16-bit type */ +#define TIFF_INT16_T signed short + +/* Unsigned 16-bit type */ +#define TIFF_UINT16_T unsigned short + +/* Signed 32-bit type formatter */ +#define TIFF_INT32_FORMAT "%d" + +/* Signed 32-bit type */ +#define TIFF_INT32_T signed int + +/* Unsigned 32-bit type formatter */ +#define TIFF_UINT32_FORMAT "%u" + +/* Unsigned 32-bit type */ +#define TIFF_UINT32_T unsigned int + +/* Signed 64-bit type formatter */ +#define TIFF_INT64_FORMAT "%I64d" + +/* Signed 64-bit type */ +#define TIFF_INT64_T signed __int64 + +/* Unsigned 64-bit type formatter */ +#define TIFF_UINT64_FORMAT "%I64u" + +/* Unsigned 64-bit type */ +#define TIFF_UINT64_T unsigned __int64 + +#if _WIN64 +/* + Windows 64-bit build +*/ + +/* Signed size type */ +# define TIFF_SSIZE_T TIFF_INT64_T + +#else +/* + Windows 32-bit build +*/ + +/* Signed size type */ +# define TIFF_SSIZE_T signed int + +#endif + +/* 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 JBIG compression (requires JBIG-KIT library) */ +/* #undef JBIG_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 + +/* Support MS MDI magic number files as TIFF */ +/* #undef MDI_SUPPORT */ + +/* + * 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/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.wince.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.wince.h new file mode 100644 index 000000000..013b0960d --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffconf.wince.h @@ -0,0 +1,110 @@ +/* + * 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/thirdparty/SDL2_image/external/libtiff/libtiff/tiffio.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffio.h index 20460542f..9eac24940 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffio.h +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffio.h @@ -23,7 +23,7 @@ */ #ifndef _TIFFIO_ -#define _TIFFIO_ +#define _TIFFIO_ /* * TIFF I/O Library Definitions. @@ -60,22 +60,20 @@ typedef struct tiff TIFF; */ /* * this is the machine addressing size type, only it's signed, so make it - * int32_t on 32bit machines, int64_t on 64bit machines + * int32 on 32bit machines, int64 on 64bit machines */ typedef TIFF_SSIZE_T tmsize_t; -#define TIFF_TMSIZE_T_MAX (tmsize_t)(SIZE_MAX >> 1) - -typedef uint64_t toff_t; /* file offset */ +typedef uint64 toff_t; /* file offset */ /* the following are deprecated and should be replaced by their defining counterparts */ -typedef uint32_t ttag_t; /* directory tag */ -typedef uint32_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 */ -typedef void *tdata_t; /* image data ref */ +typedef uint32 ttag_t; /* directory tag */ +typedef uint16 tdir_t; /* directory index */ +typedef uint16 tsample_t; /* sample number */ +typedef uint32 tstrile_t; /* strip or tile number */ +typedef tstrile_t tstrip_t; /* strip number */ +typedef tstrile_t ttile_t; /* tile number */ +typedef tmsize_t tsize_t; /* i/o size in bytes */ +typedef void* tdata_t; /* image data ref */ #if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) #define __WIN32__ @@ -89,22 +87,21 @@ typedef void *tdata_t; /* image data ref */ */ #if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -#if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && \ - !defined(USE_WIN32_FILEIO) -#define AVOID_WIN32_FILEIO -#endif +# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) +# define AVOID_WIN32_FILEIO +# endif #endif #if defined(USE_WIN32_FILEIO) -#define VC_EXTRALEAN -#include -#ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ +# define VC_EXTRALEAN +# include +# ifdef __WIN32__ +DECLARE_HANDLE(thandle_t); /* Win32 file handle */ +# else +typedef HFILE thandle_t; /* client data handle */ +# endif /* __WIN32__ */ #else -typedef HFILE thandle_t; /* client data handle */ -#endif /* __WIN32__ */ -#else -typedef void *thandle_t; /* client data handle */ +typedef void* thandle_t; /* client data handle */ #endif /* USE_WIN32_FILEIO */ /* @@ -113,15 +110,15 @@ typedef void *thandle_t; /* client data handle */ * very large. Bit-or these flags to enable printing * multiple items. */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ +#define TIFFPRINT_NONE 0x0 /* no extra info */ +#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ +#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ +#define TIFFPRINT_COLORMAP 0x4 /* colormap */ +#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ +#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ +#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ -/* +/* * Colour conversion stuff */ @@ -136,45 +133,42 @@ typedef void *thandle_t; /* client data handle */ /* Structure for holding information about a display device. */ -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ +typedef unsigned char TIFFRGBValue; /* 8-bit samples */ -typedef struct -{ - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCR; /* Light o/p for reference white */ - float d_YCG; - float d_YCB; - uint32_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; - float d_gammaR; /* Gamma values for the three guns */ - float d_gammaG; - float d_gammaB; +typedef struct { + float d_mat[3][3]; /* XYZ -> luminance matrix */ + float d_YCR; /* Light o/p for reference white */ + float d_YCG; + float d_YCB; + uint32 d_Vrwr; /* Pixel values for ref. white */ + uint32 d_Vrwg; + uint32 d_Vrwb; + float d_Y0R; /* Residual light for black pixel */ + float d_Y0G; + float d_Y0B; + float d_gammaR; /* Gamma values for the three guns */ + float d_gammaG; + float d_gammaB; } TIFFDisplay; -typedef struct -{ /* YCbCr->RGB support */ - TIFFRGBValue *clamptab; /* range clamping table */ - int *Cr_r_tab; - int *Cb_b_tab; - int32_t *Cr_g_tab; - int32_t *Cb_g_tab; - int32_t *Y_tab; +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; } TIFFYCbCrToRGB; -typedef struct -{ /* CIE Lab 1976->RGB support */ - int range; /* Size of conversion table */ +typedef struct { /* CIE Lab 1976->RGB support */ + int range; /* Size of conversion table */ #define CIELABTORGB_TABLE_RANGE 1500 - float rstep, gstep, bstep; - float X0, Y0, Z0; /* Reference white point */ - TIFFDisplay display; - float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ - float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ - float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ + float rstep, gstep, bstep; + float X0, Y0, Z0; /* Reference white point */ + TIFFDisplay display; + float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ + float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ + float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ } TIFFCIELabToRGB; /* @@ -184,66 +178,63 @@ typedef struct _TIFFRGBAImage TIFFRGBAImage; /* * The image reading and conversion routines invoke * ``put routines'' to copy/image/whatever tiles of - * raw image data. A default set of routines are + * raw image data. A default set of routines are * provided to convert/copy raw image data to 8-bit * packed ABGR format rasters. Applications can supply * alternate routines that unpack the data into a * different format or, for example, unpack the data * and draw the unpacked raster on the display. */ -typedef void (*tileContigRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t, - uint32_t, uint32_t, uint32_t, int32_t, - int32_t, unsigned char *); -typedef void (*tileSeparateRoutine)(TIFFRGBAImage *, uint32_t *, uint32_t, - uint32_t, uint32_t, uint32_t, int32_t, - int32_t, unsigned char *, unsigned char *, - unsigned char *, unsigned char *); +typedef void (*tileContigRoutine) + (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, + unsigned char*); +typedef void (*tileSeparateRoutine) + (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, + unsigned char*, unsigned char*, unsigned char*, unsigned char*); /* * RGBA-reader state. */ -struct _TIFFRGBAImage -{ - TIFF *tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32_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_t *, uint32_t, uint32_t); - /* put decoded strip/tile */ - union - { - void (*any)(TIFFRGBAImage *); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; - TIFFRGBValue *Map; /* sample mapping array */ - 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 */ +struct _TIFFRGBAImage { + TIFF* tif; /* image handle */ + int stoponerr; /* stop on read error */ + int isContig; /* data is packed/separate */ + int alpha; /* type of alpha data present */ + uint32 width; /* image width */ + uint32 height; /* image height */ + uint16 bitspersample; /* image bits/sample */ + uint16 samplesperpixel; /* image samples/pixel */ + uint16 orientation; /* image orientation */ + uint16 req_orientation; /* requested orientation */ + uint16 photometric; /* image photometric interp */ + uint16* redcmap; /* colormap palette */ + uint16* greencmap; + uint16* bluecmap; + /* get image data routine */ + int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); + /* put decoded strip/tile */ + union { + void (*any)(TIFFRGBAImage*); + tileContigRoutine contig; + tileSeparateRoutine separate; + } put; + TIFFRGBValue* Map; /* sample mapping array */ + uint32** BWmap; /* black&white map */ + uint32** PALmap; /* palette image map */ + TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ + TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - uint8_t *UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ - uint8_t *Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ + uint8* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ + uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ - int row_offset; - int col_offset; + int row_offset; + int col_offset; }; /* * Macros for extracting components from the * packed ABGR form returned by TIFFReadRGBAImage. */ -#define TIFFGetR(abgr) ((abgr)&0xff) +#define TIFFGetR(abgr) ((abgr) & 0xff) #define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) #define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) #define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) @@ -255,22 +246,15 @@ struct _TIFFRGBAImage * More codecs may be registered through calls to the library * and/or the builtin implementations may be overridden. */ -typedef int (*TIFFInitMethod)(TIFF *, int); -typedef struct -{ - char *name; - uint16_t scheme; - TIFFInitMethod init; +typedef int (*TIFFInitMethod)(TIFF*, int); +typedef struct { + char* name; + uint16 scheme; + TIFFInitMethod init; } TIFFCodec; -typedef struct -{ - uint32_t uNum; - uint32_t uDenom; -} TIFFRational_t; - -#include #include +#include /* share internal LogLuv conversion routines? */ #ifndef LOGLUV_PUBLIC @@ -278,376 +262,311 @@ typedef struct #endif #if defined(__GNUC__) || defined(__clang__) || defined(__attribute__) -#define TIFF_ATTRIBUTE(x) __attribute__(x) +# define TIFF_ATTRIBUTE(x) __attribute__(x) #else -#define TIFF_ATTRIBUTE(x) /*nothing*/ +# define TIFF_ATTRIBUTE(x) /*nothing*/ #endif #if defined(c_plusplus) || defined(__cplusplus) -extern "C" -{ +extern "C" { #endif - typedef void (*TIFFErrorHandler)(const char *, const char *, va_list); - typedef void (*TIFFErrorHandlerExt)(thandle_t, const char *, const char *, - va_list); - typedef int (*TIFFErrorHandlerExtR)(TIFF *, void *user_data, const char *, - const char *, va_list); - typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void *, tmsize_t); - typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); - typedef int (*TIFFCloseProc)(thandle_t); - typedef toff_t (*TIFFSizeProc)(thandle_t); - typedef int (*TIFFMapFileProc)(thandle_t, void **base, toff_t *size); - typedef void (*TIFFUnmapFileProc)(thandle_t, void *base, toff_t size); - typedef void (*TIFFExtendProc)(TIFF *); +typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); +typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); +typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); +typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); +typedef int (*TIFFCloseProc)(thandle_t); +typedef toff_t (*TIFFSizeProc)(thandle_t); +typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); +typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); +typedef void (*TIFFExtendProc)(TIFF*); - extern const char *TIFFGetVersion(void); +extern const char* TIFFGetVersion(void); - extern const TIFFCodec *TIFFFindCODEC(uint16_t); - extern TIFFCodec *TIFFRegisterCODEC(uint16_t, const char *, TIFFInitMethod); - extern void TIFFUnRegisterCODEC(TIFFCodec *); - extern int TIFFIsCODECConfigured(uint16_t); - extern TIFFCodec *TIFFGetConfiguredCODECs(void); +extern const TIFFCodec* TIFFFindCODEC(uint16); +extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); +extern void TIFFUnRegisterCODEC(TIFFCodec*); +extern int TIFFIsCODECConfigured(uint16); +extern TIFFCodec* TIFFGetConfiguredCODECs(void); - /* - * Auxiliary functions. - */ +/* + * Auxiliary functions. + */ - extern void *_TIFFmalloc(tmsize_t s); - extern void *_TIFFcalloc(tmsize_t nmemb, tmsize_t siz); - extern void *_TIFFrealloc(void *p, tmsize_t s); - extern void _TIFFmemset(void *p, int v, tmsize_t c); - extern void _TIFFmemcpy(void *d, const void *s, tmsize_t c); - extern int _TIFFmemcmp(const void *p1, const void *p2, tmsize_t c); - extern void _TIFFfree(void *p); +extern void* _TIFFmalloc(tmsize_t s); +extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz); +extern void* _TIFFrealloc(void* p, tmsize_t s); +extern void _TIFFmemset(void* p, int v, tmsize_t c); +extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); +extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); +extern void _TIFFfree(void* p); - /* - ** Stuff, related to tag handling and creating custom tags. - */ - extern int TIFFGetTagListCount(TIFF *); - extern uint32_t TIFFGetTagListEntry(TIFF *, int tag_index); +/* +** Stuff, related to tag handling and creating custom tags. +*/ +extern int TIFFGetTagListCount( TIFF * ); +extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); + +#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ +#define TIFF_VARIABLE -1 /* marker for variable length tags */ +#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ +#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ -#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_t var-length tags */ +#define FIELD_CUSTOM 65 -#define FIELD_CUSTOM 65 +typedef struct _TIFFField TIFFField; +typedef struct _TIFFFieldArray TIFFFieldArray; - typedef struct _TIFFField TIFFField; - typedef struct _TIFFFieldArray TIFFFieldArray; +extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); +extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); +extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); - 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 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*); - 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 *); - extern int - TIFFFieldSetGetSize(const TIFFField *); /* returns internal storage size of - TIFFSetGetFieldType in bytes. */ - extern int TIFFFieldSetGetCountSize( - const TIFFField *); /* returns size of count parameter 0=none, - 2=uint16_t, 4=uint32_t */ - extern int TIFFFieldIsAnonymous(const TIFFField *); +typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); +typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); +typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); - typedef int (*TIFFVSetMethod)(TIFF *, uint32_t, va_list); - typedef int (*TIFFVGetMethod)(TIFF *, uint32_t, va_list); - typedef void (*TIFFPrintMethod)(TIFF *, FILE *, long); +typedef struct { + TIFFVSetMethod vsetfield; /* tag set routine */ + TIFFVGetMethod vgetfield; /* tag get routine */ + TIFFPrintMethod printdir; /* directory print routine */ +} TIFFTagMethods; - typedef struct - { - TIFFVSetMethod vsetfield; /* tag set routine */ - TIFFVGetMethod vgetfield; /* tag get routine */ - TIFFPrintMethod printdir; /* directory print routine */ - } TIFFTagMethods; +extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); +extern void *TIFFGetClientInfo(TIFF *, const char *); +extern void TIFFSetClientInfo(TIFF *, void *, const char *); - extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); - extern void *TIFFGetClientInfo(TIFF *, const char *); - extern void TIFFSetClientInfo(TIFF *, void *, const char *); - - 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_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_t TIFFScanlineSize64(TIFF *tif); - extern tmsize_t TIFFScanlineSize(TIFF *tif); - extern uint64_t TIFFRasterScanlineSize64(TIFF *tif); - extern tmsize_t TIFFRasterScanlineSize(TIFF *tif); - extern uint64_t TIFFStripSize64(TIFF *tif); - extern tmsize_t TIFFStripSize(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_t TIFFTileSize64(TIFF *tif); - extern tmsize_t TIFFTileSize(TIFF *tif); - 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 *); - extern thandle_t TIFFSetClientdata(TIFF *, thandle_t); - extern int TIFFGetMode(TIFF *); - extern int TIFFSetMode(TIFF *, int); - extern int TIFFIsTiled(TIFF *); - extern int TIFFIsByteSwapped(TIFF *); - extern int TIFFIsUpSampled(TIFF *); - extern int TIFFIsMSB2LSB(TIFF *); - extern int TIFFIsBigEndian(TIFF *); - extern int TIFFIsBigTIFF(TIFF *); - extern TIFFReadWriteProc TIFFGetReadProc(TIFF *); - extern TIFFReadWriteProc TIFFGetWriteProc(TIFF *); - extern TIFFSeekProc TIFFGetSeekProc(TIFF *); - extern TIFFCloseProc TIFFGetCloseProc(TIFF *); - extern TIFFSizeProc TIFFGetSizeProc(TIFF *); - extern TIFFMapFileProc TIFFGetMapFileProc(TIFF *); - extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF *); - extern uint32_t TIFFCurrentRow(TIFF *); - extern tdir_t TIFFCurrentDirectory(TIFF *); - extern tdir_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 *); - extern int TIFFWriteCheck(TIFF *, int, const char *); - extern void TIFFFreeDirectory(TIFF *); - extern int TIFFCreateDirectory(TIFF *); - extern int TIFFCreateCustomDirectory(TIFF *, const TIFFFieldArray *); - extern int TIFFCreateEXIFDirectory(TIFF *); - extern int TIFFCreateGPSDirectory(TIFF *); - extern int TIFFLastDirectory(TIFF *); - extern int TIFFSetDirectory(TIFF *, tdir_t); - extern int TIFFSetSubDirectory(TIFF *, uint64_t); - extern int TIFFUnlinkDirectory(TIFF *, tdir_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_t *); - extern int TIFFCheckpointDirectory(TIFF *); - extern int TIFFRewriteDirectory(TIFF *); - extern int TIFFDeferStrileArrayWriting(TIFF *); - extern int TIFFForceStrileArrayWriting(TIFF *); +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 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 tmsize_t TIFFScanlineSize(TIFF* tif); +extern uint64 TIFFRasterScanlineSize64(TIFF* tif); +extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); +extern uint64 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 tmsize_t TIFFTileRowSize(TIFF* tif); +extern uint64 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 int TIFFFileno(TIFF*); +extern int TIFFSetFileno(TIFF*, int); +extern thandle_t TIFFClientdata(TIFF*); +extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); +extern int TIFFGetMode(TIFF*); +extern int TIFFSetMode(TIFF*, int); +extern int TIFFIsTiled(TIFF*); +extern int TIFFIsByteSwapped(TIFF*); +extern int TIFFIsUpSampled(TIFF*); +extern int TIFFIsMSB2LSB(TIFF*); +extern int TIFFIsBigEndian(TIFF*); +extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); +extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); +extern TIFFSeekProc TIFFGetSeekProc(TIFF*); +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 int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); +extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); +extern int TIFFSetupStrips(TIFF *); +extern int TIFFWriteCheck(TIFF*, int, const char *); +extern void TIFFFreeDirectory(TIFF*); +extern int TIFFCreateDirectory(TIFF*); +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 TIFFWriteDirectory(TIFF *); +extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); +extern int TIFFCheckpointDirectory(TIFF *); +extern int TIFFRewriteDirectory(TIFF *); +extern int TIFFDeferStrileArrayWriting(TIFF *); +extern int TIFFForceStrileArrayWriting(TIFF* ); #if defined(c_plusplus) || defined(__cplusplus) - extern void TIFFPrintDirectory(TIFF *, FILE *, long = 0); - 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); +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*, + int = ORIENTATION_BOTLEFT, int = 0); #else -extern void TIFFPrintDirectory(TIFF *, FILE *, long); -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); +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); #endif - 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_t *, uint32_t, - uint32_t); - extern void TIFFRGBAImageEnd(TIFFRGBAImage *); +extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); +extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); +extern int TIFFReadRGBAStripExt(TIFF*, uint32, uint32 *, int stop_on_error ); +extern int TIFFReadRGBATileExt(TIFF*, uint32, uint32, uint32 *, int stop_on_error ); +extern int TIFFRGBAImageOK(TIFF*, char [1024]); +extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); +extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); +extern void TIFFRGBAImageEnd(TIFFRGBAImage*); +extern TIFF* TIFFOpen(const char*, const char*); +# ifdef __WIN32__ +extern TIFF* TIFFOpenW(const wchar_t*, const char*); +# endif /* __WIN32__ */ +extern TIFF* TIFFFdOpen(int, const char*, const char*); +extern TIFF* TIFFClientOpen(const char*, const char*, + thandle_t, + TIFFReadWriteProc, TIFFReadWriteProc, + TIFFSeekProc, TIFFCloseProc, + TIFFSizeProc, + TIFFMapFileProc, TIFFUnmapFileProc); +extern const char* TIFFFileName(TIFF*); +extern const char* TIFFSetFileName(TIFF*, const char *); +extern void TIFFError(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3))); +extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4))); +extern void TIFFWarning(const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,2,3))); +extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) TIFF_ATTRIBUTE((__format__ (__printf__,3,4))); +extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); +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, + 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 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 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 TIFFSwabArrayOfFloat(float* fp, tmsize_t n); +extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); +extern void TIFFReverseBits(uint8* cp, tmsize_t n); +extern const unsigned char* TIFFGetBitRevTable(int); - extern const char *TIFFFileName(TIFF *); - extern const char *TIFFSetFileName(TIFF *, const char *); - extern void TIFFError(const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 2, 3))); - extern void TIFFErrorExt(thandle_t, const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); - extern void TIFFWarning(const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 2, 3))); - extern void TIFFWarningExt(thandle_t, const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); - extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); - extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); - extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); - extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); - - extern void TIFFWarningExtR(TIFF *, const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); - extern void TIFFErrorExtR(TIFF *, const char *, const char *, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 3, 4))); - - typedef struct TIFFOpenOptions TIFFOpenOptions; - extern TIFFOpenOptions *TIFFOpenOptionsAlloc(void); - extern void TIFFOpenOptionsFree(TIFFOpenOptions *); - extern void - TIFFOpenOptionsSetMaxSingleMemAlloc(TIFFOpenOptions *opts, - tmsize_t max_single_mem_alloc); - extern void - TIFFOpenOptionsSetErrorHandlerExtR(TIFFOpenOptions *opts, - TIFFErrorHandlerExtR handler, - void *errorhandler_user_data); - extern void - TIFFOpenOptionsSetWarningHandlerExtR(TIFFOpenOptions *opts, - TIFFErrorHandlerExtR handler, - void *warnhandler_user_data); - - extern TIFF *TIFFOpen(const char *, const char *); - extern TIFF *TIFFOpenExt(const char *, const char *, TIFFOpenOptions *opts); -#ifdef __WIN32__ - extern TIFF *TIFFOpenW(const wchar_t *, const char *); - extern TIFF *TIFFOpenWExt(const wchar_t *, const char *, - TIFFOpenOptions *opts); -#endif /* __WIN32__ */ - extern TIFF *TIFFFdOpen(int, const char *, const char *); - extern TIFF *TIFFFdOpenExt(int, const char *, const char *, - TIFFOpenOptions *opts); - extern TIFF *TIFFClientOpen(const char *, const char *, thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); - extern TIFF *TIFFClientOpenExt(const char *, const char *, thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc, - TIFFOpenOptions *opts); - extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); - 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_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 within TIFF file. */ - extern void TIFFSetWriteOffset(TIFF *tif, toff_t off); - 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_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_t *cp, tmsize_t n); - extern const unsigned char *TIFFGetBitRevTable(int); - - 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); +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); #ifdef LOGLUV_PUBLIC -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. - extern double LogL16toY(int); - extern double LogL10toY(int); - extern void XYZtoRGB24(float *, uint8_t *); - extern int uv_decode(double *, double *, int); - extern void LogLuv24toXYZ(uint32_t, float *); - extern void LogLuv32toXYZ(uint32_t, float *); +#define U_NEU 0.210526316 +#define V_NEU 0.473684211 +#define UVSCALE 410. +extern double LogL16toY(int); +extern double LogL10toY(int); +extern void XYZtoRGB24(float*, uint8*); +extern int uv_decode(double*, double*, int); +extern void LogLuv24toXYZ(uint32, float*); +extern void LogLuv32toXYZ(uint32, 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_t LogLuv24fromXYZ(float *, int = SGILOGENCODE_NODITHER); - extern uint32_t LogLuv32fromXYZ(float *, int = SGILOGENCODE_NODITHER); +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); #else - extern int LogL16fromY(double, int); - extern int LogL10fromY(double, int); - extern int uv_encode(double, double, int); - extern uint32_t LogLuv24fromXYZ(float *, int); - extern uint32_t LogLuv32fromXYZ(float *, int); +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); #endif #endif /* LOGLUV_PUBLIC */ - extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB *, const TIFFDisplay *, - float *); - extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32_t, int32_t, int32_t, - float *, float *, float *); - extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, uint32_t *, - uint32_t *, uint32_t *); +extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); +extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, + float *, float *, float *); +extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, + uint32 *, uint32 *, uint32 *); - extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *, float *, float *); - extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32_t, int32_t, int32_t, - uint32_t *, uint32_t *, uint32_t *); +extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); +extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, + uint32 *, uint32 *, uint32 *); - /**************************************************************************** - * O B S O L E T E D I N T E R F A C E S - * - * Don't use this stuff in your applications, it may be removed in the - *future libtiff versions. - ****************************************************************************/ - typedef struct - { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ - short field_writecount; /* write count/TIFF_VARIABLE */ - TIFFDataType field_type; /* type of associated data */ - unsigned short field_bit; /* bit in fieldsset bit vector */ - unsigned char field_oktochange; /* if true, can change while writing */ - unsigned char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ - } TIFFFieldInfo; - - extern int TIFFMergeFieldInfo(TIFF *, const TIFFFieldInfo[], uint32_t); +/**************************************************************************** + * O B S O L E T E D I N T E R F A C E S + * + * Don't use this stuff in your applications, it may be removed in the future + * libtiff versions. + ****************************************************************************/ +typedef struct { + ttag_t field_tag; /* field's tag */ + short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ + short field_writecount; /* write count/TIFF_VARIABLE */ + TIFFDataType field_type; /* type of associated data */ + unsigned short field_bit; /* bit in fieldsset bit vector */ + unsigned char field_oktochange; /* if true, can change while writing */ + unsigned char field_passcount; /* if true, pass dir count on set */ + char *field_name; /* ASCII name */ +} TIFFFieldInfo; +extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); + #if defined(c_plusplus) || defined(__cplusplus) } #endif #endif /* _TIFFIO_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffio.hxx b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffio.hxx index 6182449b1..df2cbbceb 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffio.hxx +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffio.hxx @@ -2,38 +2,47 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIO_HXX_ -#define _TIFFIO_HXX_ +#define _TIFFIO_HXX_ /* * TIFF I/O library definitions which provide C++ streams API. */ +#include #include "tiff.h" #include "tiffio.h" -#include -extern TIFF *TIFFStreamOpen(const char *, std::ostream *); -extern TIFF *TIFFStreamOpen(const char *, std::istream *); +extern TIFF* TIFFStreamOpen(const char*, std::ostream *); +extern TIFF* TIFFStreamOpen(const char*, std::istream *); #endif /* _TIFFIO_HXX_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c++ + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffiop.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffiop.h index fbf7b0700..e875ca686 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffiop.h +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffiop.h @@ -2,28 +2,28 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef _TIFFIOP_ -#define _TIFFIOP_ +#define _TIFFIOP_ /* * ``Library-private'' definitions. */ @@ -31,48 +31,66 @@ #include "tif_config.h" #ifdef HAVE_FCNTL_H -#include +# include #endif #ifdef HAVE_SYS_TYPES_H -#include +# include #endif -#include +#ifdef HAVE_STRING_H +# include +#endif #ifdef HAVE_ASSERT_H -#include +# include #else -#define assert(x) +# define assert(x) +#endif + +#ifdef HAVE_SEARCH_H +# include +#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 "tif_hash_set.h" #include "tiffio.h" #include "tif_dir.h" -#include - #ifndef STRIP_SIZE_DEFAULT -#define STRIP_SIZE_DEFAULT 8192 +# define STRIP_SIZE_DEFAULT 8192 #endif -#ifndef TIFF_MAX_DIR_COUNT -#define TIFF_MAX_DIR_COUNT 1048576 -#endif - -#define TIFF_NON_EXISTENT_DIR_NUMBER UINT_MAX - -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) #ifndef TRUE -#define TRUE 1 -#define FALSE 0 +#define TRUE 1 +#define FALSE 0 #endif -typedef struct client_info -{ +#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; char *name; @@ -82,231 +100,187 @@ typedef struct client_info * Typedefs for ``method pointers'' used internally. * these are deprecated and provided only for backwards compatibility. */ -typedef unsigned char tidataval_t; /* internal image data value type */ -typedef tidataval_t *tidata_t; /* reference to internal image data */ +typedef unsigned char tidataval_t; /* internal image data value type */ +typedef tidataval_t* tidata_t; /* reference to internal image data */ -typedef void (*TIFFVoidMethod)(TIFF *); -typedef int (*TIFFBoolMethod)(TIFF *); -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 *); +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*); -struct TIFFOffsetAndDirNumber -{ - uint64_t offset; - tdir_t dirNumber; -}; -typedef struct TIFFOffsetAndDirNumber TIFFOffsetAndDirNumber; - -struct tiff -{ - char *tif_name; /* name of open file */ - int tif_fd; /* open file descriptor */ - int tif_mode; /* open mode (O_*) */ - 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 */ -#define TIFF_BUFFERSETUP 0x00010U /* data buffers setup */ -#define TIFF_CODERSETUP 0x00020U /* encoder/decoder setup done */ -#define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */ -#define TIFF_SWAB 0x00080U /* byte swap file information */ -#define TIFF_NOBITREV 0x00100U /* inhibit bit reversal logic */ -#define TIFF_MYBUFFER 0x00200U /* my raw data buffer; free on close */ -#define TIFF_ISTILED 0x00400U /* file is tile, not strip- based */ -#define TIFF_MAPPED 0x00800U /* file is mapped into memory */ -#define TIFF_POSTENCODE 0x01000U /* need call to postencode routine */ -#define TIFF_INSUBIFD 0x02000U /* currently writing a subifd */ -#define TIFF_UPSAMPLED 0x04000U /* library is doing data up-sampling */ -#define TIFF_STRIPCHOP 0x08000U /* enable strip chopping support */ -#define TIFF_HEADERONLY \ - 0x10000U /* read header only, do not process the first directory */ -#define TIFF_NOREADRAW \ - 0x20000U /* skip reading of raw uncompressed image data */ -#define TIFF_INCUSTOMIFD 0x40000U /* currently writing a custom IFD */ -#define TIFF_BIGTIFF 0x80000U /* read/write bigtiff */ -#define TIFF_BUF4WRITE 0x100000U /* rawcc bytes are for writing */ -#define TIFF_DIRTYSTRIP 0x200000U /* stripoffsets/stripbytecount dirty*/ -#define TIFF_PERSAMPLE 0x400000U /* get/set per sample tags as arrays */ -#define TIFF_BUFFERMMAP \ - 0x800000U /* read buffer (tif_rawdata) points into mmap() memory */ -#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_t tif_diroff; /* file offset of current directory */ - uint64_t tif_nextdiroff; /* file offset of following directory */ - uint64_t tif_lastdiroff; /* file offset of last directory written so far */ - TIFFHashSet *tif_map_dir_offset_to_number; - TIFFHashSet *tif_map_dir_number_to_offset; - int tif_setdirectory_force_absolute; /* switch between relative and absolute - stepping in TIFFSetDirectory() */ - TIFFDirectory tif_dir; /* internal rep of current directory */ - TIFFDirectory - tif_customdir; /* custom IFDs are separated from the main ones */ - union - { - TIFFHeaderCommon common; - TIFFHeaderClassic classic; - TIFFHeaderBig big; - } tif_header; - uint16_t tif_header_size; /* file's header block and its length */ - uint32_t tif_row; /* current scanline */ - tdir_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_lastvalidoff; /* last valid offset allowed for rewrite in - place. Used only by TIFFAppendToStrip() */ - uint64_t tif_dataoff; /* current offset for writing dir */ - /* SubIFD support */ - uint16_t tif_nsubifd; /* remaining subifds to write */ - uint64_t tif_subifdoff; /* offset for patching SubIFD link */ - /* tiling support */ - 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; - TIFFBoolMethod tif_fixuptags; /* called in TIFFReadDirectory */ - TIFFBoolMethod tif_setupdecode; /* called once before predecode */ - TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ - TIFFBoolMethod tif_setupencode; /* called once before preencode */ - int tif_encodestatus; - TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ - TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ - TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ - TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ - TIFFCodeMethod tif_decodestrip; /* strip decoding routine */ - TIFFCodeMethod tif_encodestrip; /* strip encoding routine */ - TIFFCodeMethod tif_decodetile; /* tile decoding routine */ - TIFFCodeMethod tif_encodetile; /* tile encoding routine */ - TIFFVoidMethod tif_close; /* cleanup-on-close routine */ - TIFFSeekMethod tif_seek; /* position within a strip routine */ - TIFFVoidMethod tif_cleanup; /* cleanup state routine */ - TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */ - TIFFTileMethod tif_deftilesize; /* calculate/constrain tile size */ - uint8_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_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_t *tif_rawcp; /* current spot in raw buffer */ - tmsize_t tif_rawcc; /* bytes unread from raw buffer */ - /* memory-mapped file support */ - 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 */ - /* input/output callback methods */ - thandle_t tif_clientdata; /* callback parameter */ - TIFFReadWriteProc tif_readproc; /* read method */ - TIFFReadWriteProc tif_writeproc; /* write method */ - TIFFSeekProc tif_seekproc; /* lseek method */ - TIFFCloseProc tif_closeproc; /* close method */ - TIFFSizeProc tif_sizeproc; /* filesize method */ - /* post-decoding support */ - TIFFPostMethod tif_postdecode; /* post decoding routine */ - /* tag support */ - TIFFField **tif_fields; /* sorted table of registered tags */ - size_t tif_nfields; /* # entries in registered tag table */ - const TIFFField *tif_foundfield; /* cached pointer to already found tag */ - TIFFTagMethods tif_tagmethods; /* tag get/set/print routines */ - TIFFClientInfoLink *tif_clientinfo; /* extra client information. */ - /* Backward compatibility stuff. We need these two fields for - * setting up an old tag extension scheme. */ - TIFFFieldArray *tif_fieldscompat; - size_t tif_nfieldscompat; - /* Error handler support */ - TIFFErrorHandlerExtR tif_errorhandler; - void *tif_errorhandler_user_data; - TIFFErrorHandlerExtR tif_warnhandler; - void *tif_warnhandler_user_data; - tmsize_t tif_max_single_mem_alloc; /* in bytes. 0 for unlimited */ +struct tiff { + char* tif_name; /* name of open file */ + int tif_fd; /* open file descriptor */ + int tif_mode; /* open mode (O_*) */ + uint32 tif_flags; + #define TIFF_FILLORDER 0x00003U /* natural bit fill order for machine */ + #define TIFF_DIRTYHEADER 0x00004U /* header must be written on close */ + #define TIFF_DIRTYDIRECT 0x00008U /* current directory must be written */ + #define TIFF_BUFFERSETUP 0x00010U /* data buffers setup */ + #define TIFF_CODERSETUP 0x00020U /* encoder/decoder setup done */ + #define TIFF_BEENWRITING 0x00040U /* written 1+ scanlines to file */ + #define TIFF_SWAB 0x00080U /* byte swap file information */ + #define TIFF_NOBITREV 0x00100U /* inhibit bit reversal logic */ + #define TIFF_MYBUFFER 0x00200U /* my raw data buffer; free on close */ + #define TIFF_ISTILED 0x00400U /* file is tile, not strip- based */ + #define TIFF_MAPPED 0x00800U /* file is mapped into memory */ + #define TIFF_POSTENCODE 0x01000U /* need call to postencode routine */ + #define TIFF_INSUBIFD 0x02000U /* currently writing a subifd */ + #define TIFF_UPSAMPLED 0x04000U /* library is doing data up-sampling */ + #define TIFF_STRIPCHOP 0x08000U /* enable strip chopping support */ + #define TIFF_HEADERONLY 0x10000U /* read header only, do not process the first directory */ + #define TIFF_NOREADRAW 0x20000U /* skip reading of raw uncompressed image data */ + #define TIFF_INCUSTOMIFD 0x40000U /* currently writing a custom IFD */ + #define TIFF_BIGTIFF 0x80000U /* read/write bigtiff */ + #define TIFF_BUF4WRITE 0x100000U /* rawcc bytes are for writing */ + #define TIFF_DIRTYSTRIP 0x200000U /* stripoffsets/stripbytecount dirty*/ + #define TIFF_PERSAMPLE 0x400000U /* get/set per sample tags as arrays */ + #define TIFF_BUFFERMMAP 0x800000U /* read buffer (tif_rawdata) points into mmap() memory */ + #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 */ + TIFFDirectory tif_dir; /* internal rep of current directory */ + TIFFDirectory tif_customdir; /* custom IFDs are separated from the main ones */ + union { + TIFFHeaderCommon common; + TIFFHeaderClassic classic; + TIFFHeaderBig big; + } tif_header; + uint16 tif_header_size; /* file's header block and its length */ + uint32 tif_row; /* current scanline */ + uint16 tif_curdir; /* current directory (index) */ + uint32 tif_curstrip; /* current strip for read/write */ + uint64 tif_curoff; /* current offset for read/write */ + uint64 tif_dataoff; /* current offset for writing dir */ + /* SubIFD support */ + uint16 tif_nsubifd; /* remaining subifds to write */ + uint64 tif_subifdoff; /* offset for patching SubIFD link */ + /* tiling support */ + uint32 tif_col; /* current column (offset by row too) */ + uint32 tif_curtile; /* current tile for read/write */ + tmsize_t tif_tilesize; /* # of bytes in a tile */ + /* compression scheme hooks */ + int tif_decodestatus; + TIFFBoolMethod tif_fixuptags; /* called in TIFFReadDirectory */ + TIFFBoolMethod tif_setupdecode; /* called once before predecode */ + TIFFPreMethod tif_predecode; /* pre- row/strip/tile decoding */ + TIFFBoolMethod tif_setupencode; /* called once before preencode */ + int tif_encodestatus; + TIFFPreMethod tif_preencode; /* pre- row/strip/tile encoding */ + TIFFBoolMethod tif_postencode; /* post- row/strip/tile encoding */ + TIFFCodeMethod tif_decoderow; /* scanline decoding routine */ + TIFFCodeMethod tif_encoderow; /* scanline encoding routine */ + TIFFCodeMethod tif_decodestrip; /* strip decoding routine */ + TIFFCodeMethod tif_encodestrip; /* strip encoding routine */ + TIFFCodeMethod tif_decodetile; /* tile decoding routine */ + TIFFCodeMethod tif_encodetile; /* tile encoding routine */ + TIFFVoidMethod tif_close; /* cleanup-on-close routine */ + TIFFSeekMethod tif_seek; /* position within a strip routine */ + TIFFVoidMethod tif_cleanup; /* cleanup state routine */ + TIFFStripMethod tif_defstripsize; /* calculate/constrain strip size */ + TIFFTileMethod tif_deftilesize; /* calculate/constrain tile size */ + uint8* tif_data; /* compression scheme private data */ + /* input/output buffering */ + tmsize_t tif_scanlinesize; /* # of bytes in a scanline */ + tmsize_t tif_scanlineskew; /* scanline skew for reading strips */ + uint8* tif_rawdata; /* raw data buffer */ + tmsize_t tif_rawdatasize; /* # of bytes in raw data buffer */ + tmsize_t tif_rawdataoff; /* rawdata offset within strip */ + tmsize_t tif_rawdataloaded;/* amount of data in rawdata */ + uint8* tif_rawcp; /* current spot in raw buffer */ + tmsize_t tif_rawcc; /* bytes unread from raw buffer */ + /* memory-mapped file support */ + uint8* tif_base; /* base of mapped file */ + tmsize_t tif_size; /* size of mapped file region (bytes, thus tmsize_t) */ + TIFFMapFileProc tif_mapproc; /* map file method */ + TIFFUnmapFileProc tif_unmapproc; /* unmap file method */ + /* input/output callback methods */ + thandle_t tif_clientdata; /* callback parameter */ + TIFFReadWriteProc tif_readproc; /* read method */ + TIFFReadWriteProc tif_writeproc; /* write method */ + TIFFSeekProc tif_seekproc; /* lseek method */ + TIFFCloseProc tif_closeproc; /* close method */ + TIFFSizeProc tif_sizeproc; /* filesize method */ + /* post-decoding support */ + TIFFPostMethod tif_postdecode; /* post decoding routine */ + /* tag support */ + TIFFField** tif_fields; /* sorted table of registered tags */ + size_t tif_nfields; /* # entries in registered tag table */ + const TIFFField* tif_foundfield; /* cached pointer to already found tag */ + TIFFTagMethods tif_tagmethods; /* tag get/set/print routines */ + TIFFClientInfoLink* tif_clientinfo; /* extra client information. */ + /* Backward compatibility stuff. We need these two fields for + * setting up an old tag extension scheme. */ + TIFFFieldArray* tif_fieldscompat; + size_t tif_nfieldscompat; }; -struct TIFFOpenOptions -{ - TIFFErrorHandlerExtR errorhandler; /* may be NULL */ - void *errorhandler_user_data; /* may be NULL */ - TIFFErrorHandlerExtR warnhandler; /* may be NULL */ - void *warnhandler_user_data; /* may be NULL */ - tmsize_t max_single_mem_alloc; /* in bytes. 0 for unlimited */ -}; - -#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */ +#define isPseudoTag(t) (t > 0xffff) /* is tag value normal or pseudo */ #define isTiled(tif) (((tif)->tif_flags & TIFF_ISTILED) != 0) #define isMapped(tif) (((tif)->tif_flags & TIFF_MAPPED) != 0) #define isFillOrder(tif, o) (((tif)->tif_flags & (o)) != 0) #define isUpSampled(tif) (((tif)->tif_flags & TIFF_UPSAMPLED) != 0) -#define TIFFReadFile(tif, buf, size) \ - ((*(tif)->tif_readproc)((tif)->tif_clientdata, (buf), (size))) -#define TIFFWriteFile(tif, buf, size) \ - ((*(tif)->tif_writeproc)((tif)->tif_clientdata, (buf), (size))) -#define TIFFSeekFile(tif, off, whence) \ - ((*(tif)->tif_seekproc)((tif)->tif_clientdata, (off), (whence))) -#define TIFFCloseFile(tif) ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) -#define TIFFGetFileSize(tif) ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) -#define TIFFMapFileContents(tif, paddr, psize) \ - ((*(tif)->tif_mapproc)((tif)->tif_clientdata, (paddr), (psize))) -#define TIFFUnmapFileContents(tif, addr, size) \ - ((*(tif)->tif_unmapproc)((tif)->tif_clientdata, (addr), (size))) +#define TIFFReadFile(tif, buf, size) \ + ((*(tif)->tif_readproc)((tif)->tif_clientdata,(buf),(size))) +#define TIFFWriteFile(tif, buf, size) \ + ((*(tif)->tif_writeproc)((tif)->tif_clientdata,(buf),(size))) +#define TIFFSeekFile(tif, off, whence) \ + ((*(tif)->tif_seekproc)((tif)->tif_clientdata,(off),(whence))) +#define TIFFCloseFile(tif) \ + ((*(tif)->tif_closeproc)((tif)->tif_clientdata)) +#define TIFFGetFileSize(tif) \ + ((*(tif)->tif_sizeproc)((tif)->tif_clientdata)) +#define TIFFMapFileContents(tif, paddr, psize) \ + ((*(tif)->tif_mapproc)((tif)->tif_clientdata,(paddr),(psize))) +#define TIFFUnmapFileContents(tif, addr, size) \ + ((*(tif)->tif_unmapproc)((tif)->tif_clientdata,(addr),(size))) /* * Default Read/Seek/Write definitions. */ #ifndef ReadOK -#define ReadOK(tif, buf, size) (TIFFReadFile((tif), (buf), (size)) == (size)) +#define ReadOK(tif, buf, size) \ + (TIFFReadFile((tif),(buf),(size))==(size)) #endif #ifndef SeekOK #define SeekOK(tif, off) _TIFFSeekOK(tif, off) #endif #ifndef WriteOK -#define WriteOK(tif, buf, size) (TIFFWriteFile((tif), (buf), (size)) == (size)) +#define WriteOK(tif, buf, size) \ + (TIFFWriteFile((tif),(buf),(size))==(size)) #endif -/* 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) +/* NB: the uint32 casts are to silence certain ANSI-C compilers */ +#define TIFFhowmany_32(x, y) (((uint32)x < (0xffffffff - (uint32)(y-1))) ? \ + ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) : \ + 0U) /* 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_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_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)) +#define TIFFhowmany_32_maxuint_compat(x, y) \ + (((uint32)(x) / (uint32)(y)) + ((((uint32)(x) % (uint32)(y)) != 0) ? 1 : 0)) +#define TIFFhowmany8_32(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) +#define TIFFroundup_32(x, y) (TIFFhowmany_32(x,y)*(y)) +#define TIFFhowmany_64(x, y) ((((uint64)(x))+(((uint64)(y))-1))/((uint64)(y))) +#define TIFFhowmany8_64(x) (((x)&0x07)?((uint64)(x)>>3)+1:(uint64)(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 */ -#define TIFFSafeMultiply(t, v, m) \ - ((((t)(m) != (t)0) && (((t)(((v) * (m)) / (m))) == (t)(v))) \ - ? (t)((v) * (m)) \ - : (t)0) +/* Safe multiply which returns zero if there is an *unsigned* integer overflow. This macro is not safe for *signed* integer types */ +#define TIFFSafeMultiply(t,v,m) ((((t)(m) != (t)0) && (((t)(((v)*(m))/(m))) == (t)(v))) ? (t)((v)*(m)) : (t)0) -#define TIFFmax(A, B) ((A) > (B) ? (A) : (B)) -#define TIFFmin(A, B) ((A) < (B) ? (A) : (B)) +#define TIFFmax(A,B) ((A)>(B)?(A):(B)) +#define TIFFmin(A,B) ((A)<(B)?(A):(B)) -#define TIFFArrayCount(a) (sizeof(a) / sizeof((a)[0])) +#define TIFFArrayCount(a) (sizeof (a) / sizeof ((a)[0])) /* Support for large files. @@ -327,31 +301,28 @@ struct TIFFOpenOptions must be available on the target computer in order for the program to run. */ #if defined(HAVE_FSEEKO) -#define fseek(stream, offset, whence) fseeko(stream, offset, whence) -#define ftell(stream, offset, whence) ftello(stream, offset, whence) +# define fseek(stream,offset,whence) fseeko(stream,offset,whence) +# define ftell(stream,offset,whence) ftello(stream,offset,whence) #endif #endif -#if defined(__WIN32__) && !(defined(_MSC_VER) && _MSC_VER < 1400) && \ - !(defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x800) +#if defined(__WIN32__) && \ + !(defined(_MSC_VER) && _MSC_VER < 1400) && \ + !(defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x800) typedef unsigned int TIFFIOSize_t; -#define _TIFF_lseek_f(fildes, offset, whence) \ - _lseeki64(fildes, /* __int64 */ offset, whence) +#define _TIFF_lseek_f(fildes,offset,whence) _lseeki64(fildes,/* __int64 */ offset,whence) /* #define _TIFF_tell_f(fildes) /\* __int64 *\/ _telli64(fildes) */ -#define _TIFF_fseek_f(stream, offset, whence) \ - _fseeki64(stream, /* __int64 */ offset, whence) -#define _TIFF_fstat_f(fildes, stat_buff) \ - _fstati64(fildes, /* struct _stati64 */ stat_buff) +#define _TIFF_fseek_f(stream,offset,whence) _fseeki64(stream,/* __int64 */ offset,whence) +#define _TIFF_fstat_f(fildes,stat_buff) _fstati64(fildes,/* struct _stati64 */ stat_buff) /* #define _TIFF_ftell_f(stream) /\* __int64 *\/ _ftelli64(stream) */ -/* #define _TIFF_stat_f(path,stat_buff) _stati64(path,/\* struct _stati64 *\/ - * stat_buff) */ +/* #define _TIFF_stat_f(path,stat_buff) _stati64(path,/\* struct _stati64 *\/ stat_buff) */ #define _TIFF_stat_s struct _stati64 #define _TIFF_off_t __int64 #else typedef size_t TIFFIOSize_t; -#define _TIFF_lseek_f(fildes, offset, whence) lseek(fildes, offset, whence) +#define _TIFF_lseek_f(fildes,offset,whence) lseek(fildes,offset,whence) /* #define _TIFF_tell_f(fildes) (_TIFF_lseek_f(fildes,0,SEEK_CUR)) */ -#define _TIFF_fseek_f(stream, offset, whence) fseek(stream, offset, whence) -#define _TIFF_fstat_f(fildes, stat_buff) fstat(fildes, stat_buff) +#define _TIFF_fseek_f(stream,offset,whence) fseek(stream,offset,whence) +#define _TIFF_fstat_f(fildes,stat_buff) fstat(fildes,stat_buff) /* #define _TIFF_ftell_f(stream) ftell(stream) */ /* #define _TIFF_stat_f(path,stat_buff) stat(path,stat_buff) */ #define _TIFF_stat_s struct stat @@ -360,8 +331,7 @@ typedef size_t TIFFIOSize_t; #if defined(__has_attribute) && defined(__clang__) #if __has_attribute(no_sanitize) -#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW \ - __attribute__((no_sanitize("unsigned-integer-overflow"))) +#define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow"))) #else #define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW #endif @@ -369,155 +339,140 @@ typedef size_t TIFFIOSize_t; #define TIFF_NOSANITIZE_UNSIGNED_INT_OVERFLOW #endif + #if defined(__cplusplus) -extern "C" -{ +extern "C" { #endif - extern int _TIFFgetMode(TIFFOpenOptions *opts, thandle_t clientdata, - const char *mode, const char *module); - 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_t, TIFFDataType, tmsize_t, - void *); - extern int TIFFSetCompressionScheme(TIFF *tif, int scheme); - extern int TIFFSetDefaultCompressionState(TIFF *tif); - extern uint32_t _TIFFDefaultStripSize(TIFF *tif, uint32_t s); - extern void _TIFFDefaultTileSize(TIFF *tif, uint32_t *tw, uint32_t *th); +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 TIFFFlushData1(TIFF* tif); +extern int TIFFDefaultDirectory(TIFF* tif); +extern void _TIFFSetDefaultCompressionState(TIFF* tif); +extern int _TIFFRewriteField(TIFF *, uint16, 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 int _TIFFDataSize(TIFFDataType type); +extern int TIFFFieldIsAnonymous(const TIFFField*); - extern void _TIFFsetByteArray(void **, const void *, uint32_t); - extern void _TIFFsetByteArrayExt(TIFF *, void **, const void *, uint32_t); - extern void _TIFFsetShortArray(uint16_t **, const uint16_t *, uint32_t); - extern void _TIFFsetShortArrayExt(TIFF *, uint16_t **, const uint16_t *, - uint32_t); - extern void _TIFFsetLongArray(uint32_t **, const uint32_t *, uint32_t); - extern void _TIFFsetLongArrayExt(TIFF *, uint32_t **, const uint32_t *, - uint32_t); - extern void _TIFFsetFloatArray(float **, const float *, uint32_t); - extern void _TIFFsetFloatArrayExt(TIFF *, float **, const float *, - uint32_t); - extern void _TIFFsetDoubleArray(double **, const double *, uint32_t); - extern void _TIFFsetDoubleArrayExt(TIFF *, double **, const double *, - uint32_t); +/*--: Rational2Double: Return size of TIFFSetGetFieldType in bytes. */ +extern int _TIFFSetGetFieldSize(TIFFSetGetFieldType setgettype); - extern void _TIFFprintAscii(FILE *, const char *); - extern void _TIFFprintAsciiTag(FILE *, const char *, const char *); +extern void _TIFFsetByteArray(void**, void*, uint32); +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 TIFFErrorHandler _TIFFwarningHandler; - extern TIFFErrorHandler _TIFFerrorHandler; - extern TIFFErrorHandlerExt _TIFFwarningHandlerExt; - extern TIFFErrorHandlerExt _TIFFerrorHandlerExt; - void _TIFFErrorEarly(TIFFOpenOptions *opts, thandle_t clientdata, - const char *module, const char *fmt, ...) - TIFF_ATTRIBUTE((__format__(__printf__, 4, 5))); +extern void _TIFFprintAscii(FILE*, const char*); +extern void _TIFFprintAsciiTag(FILE*, const char*, 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_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 TIFFErrorHandler _TIFFwarningHandler; +extern TIFFErrorHandler _TIFFerrorHandler; +extern TIFFErrorHandlerExt _TIFFwarningHandlerExt; +extern TIFFErrorHandlerExt _TIFFerrorHandlerExt; - extern double _TIFFUInt64ToDouble(uint64_t); - extern float _TIFFUInt64ToFloat(uint64_t); +extern uint32 _TIFFMultiply32(TIFF*, uint32, uint32, const char*); +extern uint64 _TIFFMultiply64(TIFF*, uint64, uint64, const char*); +extern tmsize_t _TIFFMultiplySSize(TIFF*, tmsize_t, tmsize_t, const char*); +extern tmsize_t _TIFFCastUInt64ToSSize(TIFF*, uint64, const char*); +extern void* _TIFFCheckMalloc(TIFF*, tmsize_t, tmsize_t, const char*); +extern void* _TIFFCheckRealloc(TIFF*, void*, tmsize_t, tmsize_t, const char*); - extern float _TIFFClampDoubleToFloat(double); - extern uint32_t _TIFFClampDoubleToUInt32(double); +extern double _TIFFUInt64ToDouble(uint64); +extern float _TIFFUInt64ToFloat(uint64); - extern void _TIFFCleanupIFDOffsetAndNumberMaps(TIFF *tif); +extern float _TIFFClampDoubleToFloat(double); - extern tmsize_t _TIFFReadEncodedStripAndAllocBuffer(TIFF *tif, - uint32_t strip, - void **buf, - tmsize_t bufsizetoalloc, - tmsize_t size_to_read); - extern tmsize_t _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_t x, uint32_t y, - uint32_t z, uint16_t s); - extern int _TIFFSeekOK(TIFF *tif, toff_t off); +extern tmsize_t +_TIFFReadEncodedStripAndAllocBuffer(TIFF* tif, uint32 strip, + void **buf, tmsize_t bufsizetoalloc, + tmsize_t size_to_read); +extern tmsize_t +_TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32 tile, + void **buf, tmsize_t bufsizetoalloc, + tmsize_t size_to_read); +extern tmsize_t +_TIFFReadTileAndAllocBuffer(TIFF* tif, + void **buf, tmsize_t bufsizetoalloc, + uint32 x, uint32 y, uint32 z, uint16 s); +extern int _TIFFSeekOK(TIFF* tif, toff_t off); - extern int TIFFInitDumpMode(TIFF *, int); +extern int TIFFInitDumpMode(TIFF*, int); #ifdef PACKBITS_SUPPORT - extern int TIFFInitPackBits(TIFF *, int); +extern int TIFFInitPackBits(TIFF*, int); #endif #ifdef CCITT_SUPPORT - extern int TIFFInitCCITTRLE(TIFF *, int), TIFFInitCCITTRLEW(TIFF *, int); - extern int TIFFInitCCITTFax3(TIFF *, int), TIFFInitCCITTFax4(TIFF *, int); +extern int TIFFInitCCITTRLE(TIFF*, int), TIFFInitCCITTRLEW(TIFF*, int); +extern int TIFFInitCCITTFax3(TIFF*, int), TIFFInitCCITTFax4(TIFF*, int); #endif #ifdef THUNDER_SUPPORT - extern int TIFFInitThunderScan(TIFF *, int); +extern int TIFFInitThunderScan(TIFF*, int); #endif #ifdef NEXT_SUPPORT - extern int TIFFInitNeXT(TIFF *, int); +extern int TIFFInitNeXT(TIFF*, int); #endif #ifdef LZW_SUPPORT - extern int TIFFInitLZW(TIFF *, int); +extern int TIFFInitLZW(TIFF*, int); #endif #ifdef OJPEG_SUPPORT - extern int TIFFInitOJPEG(TIFF *, int); +extern int TIFFInitOJPEG(TIFF*, int); #endif #ifdef JPEG_SUPPORT - extern int TIFFInitJPEG(TIFF *, int); - extern int TIFFJPEGIsFullStripRequired(TIFF *); +extern int TIFFInitJPEG(TIFF*, int); +extern int TIFFJPEGIsFullStripRequired(TIFF*); #endif #ifdef JBIG_SUPPORT - extern int TIFFInitJBIG(TIFF *, int); +extern int TIFFInitJBIG(TIFF*, int); #endif #ifdef ZIP_SUPPORT - extern int TIFFInitZIP(TIFF *, int); +extern int TIFFInitZIP(TIFF*, int); #endif #ifdef PIXARLOG_SUPPORT - extern int TIFFInitPixarLog(TIFF *, int); +extern int TIFFInitPixarLog(TIFF*, int); #endif #ifdef LOGLUV_SUPPORT - extern int TIFFInitSGILog(TIFF *, int); -#endif -#ifdef LERC_SUPPORT - extern int TIFFInitLERC(TIFF *tif, int); +extern int TIFFInitSGILog(TIFF*, int); #endif #ifdef LZMA_SUPPORT - extern int TIFFInitLZMA(TIFF *, int); +extern int TIFFInitLZMA(TIFF*, int); #endif #ifdef ZSTD_SUPPORT - extern int TIFFInitZSTD(TIFF *, int); +extern int TIFFInitZSTD(TIFF*, int); #endif #ifdef WEBP_SUPPORT - extern int TIFFInitWebP(TIFF *, int); +extern int TIFFInitWebP(TIFF*, int); +#endif +#ifdef VMS +extern const TIFFCodec _TIFFBuiltinCODECS[]; +#else +extern TIFFCodec _TIFFBuiltinCODECS[]; #endif - extern const TIFFCodec _TIFFBuiltinCODECS[]; - extern void TIFFCIELab16ToXYZ(TIFFCIELabToRGB *, uint32_t l, int32_t a, - int32_t b, float *, float *, float *); - - extern void *_TIFFmallocExt(TIFF *tif, tmsize_t s); - extern void *_TIFFcallocExt(TIFF *tif, tmsize_t nmemb, tmsize_t siz); - extern void *_TIFFreallocExt(TIFF *tif, void *p, tmsize_t s); - extern void _TIFFfreeExt(TIFF *tif, void *p); #if defined(__cplusplus) } #endif #endif /* _TIFFIOP_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffvers.h b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffvers.h index ed847760c..0cce798b8 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffvers.h +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffvers.h @@ -1,9 +1,4 @@ -/* clang-format off */ - -/* clang-format disabled because FindTIFF.cmake is very sensitive to the - * formatting of below line being a single line. - */ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.5.1\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." +#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.2.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 @@ -11,20 +6,4 @@ * version checking should be done based on the * string returned by TIFFGetVersion. */ -#define TIFFLIB_VERSION 20230609 - -/* The following defines have been added in 4.5.0 */ -#define TIFFLIB_MAJOR_VERSION 4 -#define TIFFLIB_MINOR_VERSION 5 -#define TIFFLIB_MICRO_VERSION 1 - -/* Macro added in 4.5.0. Returns TRUE if the current libtiff version is - * greater or equal to major.minor.micro - */ -#define TIFFLIB_AT_LEAST(major, minor, micro) \ - (TIFFLIB_MAJOR_VERSION > (major) || \ - (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION > (minor)) || \ - (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION == (minor) && \ - TIFFLIB_MICRO_VERSION >= (micro))) - -/* clang-format on */ +#define TIFFLIB_VERSION 20201219 diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffvers.h.in b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffvers.h.in index b98851c07..48ec0eb8d 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/tiffvers.h.in +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/tiffvers.h.in @@ -1,8 +1,3 @@ -/* clang-format off */ - -/* clang-format disabled because FindTIFF.cmake is very sensitive to the - * formatting of below line being a single line. - */ #define TIFFLIB_VERSION_STR "LIBTIFF, Version LIBTIFF_VERSION\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." /* * This define can be used in code that requires @@ -12,19 +7,3 @@ * string returned by TIFFGetVersion. */ #define TIFFLIB_VERSION LIBTIFF_RELEASE_DATE - -/* The following defines have been added in 4.5.0 */ -#define TIFFLIB_MAJOR_VERSION LIBTIFF_MAJOR_VERSION -#define TIFFLIB_MINOR_VERSION LIBTIFF_MINOR_VERSION -#define TIFFLIB_MICRO_VERSION LIBTIFF_MICRO_VERSION - -/* Macro added in 4.5.0. Returns TRUE if the current libtiff version is - * greater or equal to major.minor.micro - */ -#define TIFFLIB_AT_LEAST(major, minor, micro) \ - (TIFFLIB_MAJOR_VERSION > (major) || \ - (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION > (minor)) || \ - (TIFFLIB_MAJOR_VERSION == (major) && TIFFLIB_MINOR_VERSION == (minor) && \ - TIFFLIB_MICRO_VERSION >= (micro))) - -/* clang-format on */ diff --git a/thirdparty/SDL2_image/external/libtiff/libtiff/uvcode.h b/thirdparty/SDL2_image/external/libtiff/libtiff/uvcode.h index fc8772924..6286cfbb0 100644 --- a/thirdparty/SDL2_image/external/libtiff/libtiff/uvcode.h +++ b/thirdparty/SDL2_image/external/libtiff/libtiff/uvcode.h @@ -1,93 +1,180 @@ /* Version 1.0 generated April 7, 1997 by Greg Ward Larson, SGI */ -#define UV_SQSIZ (float)0.003500 -#define UV_NDIVS 16289 -#define UV_VSTART (float)0.016940 -#define UV_NVS 163 -static const struct -{ - float ustart; - short nus, ncum; -} uv_row[UV_NVS] = { - {(float)0.247663, 4, 0}, {(float)0.243779, 6, 4}, - {(float)0.241684, 7, 10}, {(float)0.237874, 9, 17}, - {(float)0.235906, 10, 26}, {(float)0.232153, 12, 36}, - {(float)0.228352, 14, 48}, {(float)0.226259, 15, 62}, - {(float)0.222371, 17, 77}, {(float)0.220410, 18, 94}, - {(float)0.214710, 21, 112}, {(float)0.212714, 22, 133}, - {(float)0.210721, 23, 155}, {(float)0.204976, 26, 178}, - {(float)0.202986, 27, 204}, {(float)0.199245, 29, 231}, - {(float)0.195525, 31, 260}, {(float)0.193560, 32, 291}, - {(float)0.189878, 34, 323}, {(float)0.186216, 36, 357}, - {(float)0.186216, 36, 393}, {(float)0.182592, 38, 429}, - {(float)0.179003, 40, 467}, {(float)0.175466, 42, 507}, - {(float)0.172001, 44, 549}, {(float)0.172001, 44, 593}, - {(float)0.168612, 46, 637}, {(float)0.168612, 46, 683}, - {(float)0.163575, 49, 729}, {(float)0.158642, 52, 778}, - {(float)0.158642, 52, 830}, {(float)0.158642, 52, 882}, - {(float)0.153815, 55, 934}, {(float)0.153815, 55, 989}, - {(float)0.149097, 58, 1044}, {(float)0.149097, 58, 1102}, - {(float)0.142746, 62, 1160}, {(float)0.142746, 62, 1222}, - {(float)0.142746, 62, 1284}, {(float)0.138270, 65, 1346}, - {(float)0.138270, 65, 1411}, {(float)0.138270, 65, 1476}, - {(float)0.132166, 69, 1541}, {(float)0.132166, 69, 1610}, - {(float)0.126204, 73, 1679}, {(float)0.126204, 73, 1752}, - {(float)0.126204, 73, 1825}, {(float)0.120381, 77, 1898}, - {(float)0.120381, 77, 1975}, {(float)0.120381, 77, 2052}, - {(float)0.120381, 77, 2129}, {(float)0.112962, 82, 2206}, - {(float)0.112962, 82, 2288}, {(float)0.112962, 82, 2370}, - {(float)0.107450, 86, 2452}, {(float)0.107450, 86, 2538}, - {(float)0.107450, 86, 2624}, {(float)0.107450, 86, 2710}, - {(float)0.100343, 91, 2796}, {(float)0.100343, 91, 2887}, - {(float)0.100343, 91, 2978}, {(float)0.095126, 95, 3069}, - {(float)0.095126, 95, 3164}, {(float)0.095126, 95, 3259}, - {(float)0.095126, 95, 3354}, {(float)0.088276, 100, 3449}, - {(float)0.088276, 100, 3549}, {(float)0.088276, 100, 3649}, - {(float)0.088276, 100, 3749}, {(float)0.081523, 105, 3849}, - {(float)0.081523, 105, 3954}, {(float)0.081523, 105, 4059}, - {(float)0.081523, 105, 4164}, {(float)0.074861, 110, 4269}, - {(float)0.074861, 110, 4379}, {(float)0.074861, 110, 4489}, - {(float)0.074861, 110, 4599}, {(float)0.068290, 115, 4709}, - {(float)0.068290, 115, 4824}, {(float)0.068290, 115, 4939}, - {(float)0.068290, 115, 5054}, {(float)0.063573, 119, 5169}, - {(float)0.063573, 119, 5288}, {(float)0.063573, 119, 5407}, - {(float)0.063573, 119, 5526}, {(float)0.057219, 124, 5645}, - {(float)0.057219, 124, 5769}, {(float)0.057219, 124, 5893}, - {(float)0.057219, 124, 6017}, {(float)0.050985, 129, 6141}, - {(float)0.050985, 129, 6270}, {(float)0.050985, 129, 6399}, - {(float)0.050985, 129, 6528}, {(float)0.050985, 129, 6657}, - {(float)0.044859, 134, 6786}, {(float)0.044859, 134, 6920}, - {(float)0.044859, 134, 7054}, {(float)0.044859, 134, 7188}, - {(float)0.040571, 138, 7322}, {(float)0.040571, 138, 7460}, - {(float)0.040571, 138, 7598}, {(float)0.040571, 138, 7736}, - {(float)0.036339, 142, 7874}, {(float)0.036339, 142, 8016}, - {(float)0.036339, 142, 8158}, {(float)0.036339, 142, 8300}, - {(float)0.032139, 146, 8442}, {(float)0.032139, 146, 8588}, - {(float)0.032139, 146, 8734}, {(float)0.032139, 146, 8880}, - {(float)0.027947, 150, 9026}, {(float)0.027947, 150, 9176}, - {(float)0.027947, 150, 9326}, {(float)0.023739, 154, 9476}, - {(float)0.023739, 154, 9630}, {(float)0.023739, 154, 9784}, - {(float)0.023739, 154, 9938}, {(float)0.019504, 158, 10092}, - {(float)0.019504, 158, 10250}, {(float)0.019504, 158, 10408}, - {(float)0.016976, 161, 10566}, {(float)0.016976, 161, 10727}, - {(float)0.016976, 161, 10888}, {(float)0.016976, 161, 11049}, - {(float)0.012639, 165, 11210}, {(float)0.012639, 165, 11375}, - {(float)0.012639, 165, 11540}, {(float)0.009991, 168, 11705}, - {(float)0.009991, 168, 11873}, {(float)0.009991, 168, 12041}, - {(float)0.009016, 170, 12209}, {(float)0.009016, 170, 12379}, - {(float)0.009016, 170, 12549}, {(float)0.006217, 173, 12719}, - {(float)0.006217, 173, 12892}, {(float)0.005097, 175, 13065}, - {(float)0.005097, 175, 13240}, {(float)0.005097, 175, 13415}, - {(float)0.003909, 177, 13590}, {(float)0.003909, 177, 13767}, - {(float)0.002340, 177, 13944}, {(float)0.002389, 170, 14121}, - {(float)0.001068, 164, 14291}, {(float)0.001653, 157, 14455}, - {(float)0.000717, 150, 14612}, {(float)0.001614, 143, 14762}, - {(float)0.000270, 136, 14905}, {(float)0.000484, 129, 15041}, - {(float)0.001103, 123, 15170}, {(float)0.001242, 115, 15293}, - {(float)0.001188, 109, 15408}, {(float)0.001011, 103, 15517}, - {(float)0.000709, 97, 15620}, {(float)0.000301, 89, 15717}, - {(float)0.002416, 82, 15806}, {(float)0.003251, 76, 15888}, - {(float)0.003246, 69, 15964}, {(float)0.004141, 62, 16033}, - {(float)0.005963, 55, 16095}, {(float)0.008839, 47, 16150}, - {(float)0.010490, 40, 16197}, {(float)0.016994, 31, 16237}, - {(float)0.023659, 21, 16268}, +#define UV_SQSIZ (float)0.003500 +#define UV_NDIVS 16289 +#define UV_VSTART (float)0.016940 +#define UV_NVS 163 +static const struct { + float ustart; + short nus, ncum; +} uv_row[UV_NVS] = { + { (float)0.247663, 4, 0 }, + { (float)0.243779, 6, 4 }, + { (float)0.241684, 7, 10 }, + { (float)0.237874, 9, 17 }, + { (float)0.235906, 10, 26 }, + { (float)0.232153, 12, 36 }, + { (float)0.228352, 14, 48 }, + { (float)0.226259, 15, 62 }, + { (float)0.222371, 17, 77 }, + { (float)0.220410, 18, 94 }, + { (float)0.214710, 21, 112 }, + { (float)0.212714, 22, 133 }, + { (float)0.210721, 23, 155 }, + { (float)0.204976, 26, 178 }, + { (float)0.202986, 27, 204 }, + { (float)0.199245, 29, 231 }, + { (float)0.195525, 31, 260 }, + { (float)0.193560, 32, 291 }, + { (float)0.189878, 34, 323 }, + { (float)0.186216, 36, 357 }, + { (float)0.186216, 36, 393 }, + { (float)0.182592, 38, 429 }, + { (float)0.179003, 40, 467 }, + { (float)0.175466, 42, 507 }, + { (float)0.172001, 44, 549 }, + { (float)0.172001, 44, 593 }, + { (float)0.168612, 46, 637 }, + { (float)0.168612, 46, 683 }, + { (float)0.163575, 49, 729 }, + { (float)0.158642, 52, 778 }, + { (float)0.158642, 52, 830 }, + { (float)0.158642, 52, 882 }, + { (float)0.153815, 55, 934 }, + { (float)0.153815, 55, 989 }, + { (float)0.149097, 58, 1044 }, + { (float)0.149097, 58, 1102 }, + { (float)0.142746, 62, 1160 }, + { (float)0.142746, 62, 1222 }, + { (float)0.142746, 62, 1284 }, + { (float)0.138270, 65, 1346 }, + { (float)0.138270, 65, 1411 }, + { (float)0.138270, 65, 1476 }, + { (float)0.132166, 69, 1541 }, + { (float)0.132166, 69, 1610 }, + { (float)0.126204, 73, 1679 }, + { (float)0.126204, 73, 1752 }, + { (float)0.126204, 73, 1825 }, + { (float)0.120381, 77, 1898 }, + { (float)0.120381, 77, 1975 }, + { (float)0.120381, 77, 2052 }, + { (float)0.120381, 77, 2129 }, + { (float)0.112962, 82, 2206 }, + { (float)0.112962, 82, 2288 }, + { (float)0.112962, 82, 2370 }, + { (float)0.107450, 86, 2452 }, + { (float)0.107450, 86, 2538 }, + { (float)0.107450, 86, 2624 }, + { (float)0.107450, 86, 2710 }, + { (float)0.100343, 91, 2796 }, + { (float)0.100343, 91, 2887 }, + { (float)0.100343, 91, 2978 }, + { (float)0.095126, 95, 3069 }, + { (float)0.095126, 95, 3164 }, + { (float)0.095126, 95, 3259 }, + { (float)0.095126, 95, 3354 }, + { (float)0.088276, 100, 3449 }, + { (float)0.088276, 100, 3549 }, + { (float)0.088276, 100, 3649 }, + { (float)0.088276, 100, 3749 }, + { (float)0.081523, 105, 3849 }, + { (float)0.081523, 105, 3954 }, + { (float)0.081523, 105, 4059 }, + { (float)0.081523, 105, 4164 }, + { (float)0.074861, 110, 4269 }, + { (float)0.074861, 110, 4379 }, + { (float)0.074861, 110, 4489 }, + { (float)0.074861, 110, 4599 }, + { (float)0.068290, 115, 4709 }, + { (float)0.068290, 115, 4824 }, + { (float)0.068290, 115, 4939 }, + { (float)0.068290, 115, 5054 }, + { (float)0.063573, 119, 5169 }, + { (float)0.063573, 119, 5288 }, + { (float)0.063573, 119, 5407 }, + { (float)0.063573, 119, 5526 }, + { (float)0.057219, 124, 5645 }, + { (float)0.057219, 124, 5769 }, + { (float)0.057219, 124, 5893 }, + { (float)0.057219, 124, 6017 }, + { (float)0.050985, 129, 6141 }, + { (float)0.050985, 129, 6270 }, + { (float)0.050985, 129, 6399 }, + { (float)0.050985, 129, 6528 }, + { (float)0.050985, 129, 6657 }, + { (float)0.044859, 134, 6786 }, + { (float)0.044859, 134, 6920 }, + { (float)0.044859, 134, 7054 }, + { (float)0.044859, 134, 7188 }, + { (float)0.040571, 138, 7322 }, + { (float)0.040571, 138, 7460 }, + { (float)0.040571, 138, 7598 }, + { (float)0.040571, 138, 7736 }, + { (float)0.036339, 142, 7874 }, + { (float)0.036339, 142, 8016 }, + { (float)0.036339, 142, 8158 }, + { (float)0.036339, 142, 8300 }, + { (float)0.032139, 146, 8442 }, + { (float)0.032139, 146, 8588 }, + { (float)0.032139, 146, 8734 }, + { (float)0.032139, 146, 8880 }, + { (float)0.027947, 150, 9026 }, + { (float)0.027947, 150, 9176 }, + { (float)0.027947, 150, 9326 }, + { (float)0.023739, 154, 9476 }, + { (float)0.023739, 154, 9630 }, + { (float)0.023739, 154, 9784 }, + { (float)0.023739, 154, 9938 }, + { (float)0.019504, 158, 10092 }, + { (float)0.019504, 158, 10250 }, + { (float)0.019504, 158, 10408 }, + { (float)0.016976, 161, 10566 }, + { (float)0.016976, 161, 10727 }, + { (float)0.016976, 161, 10888 }, + { (float)0.016976, 161, 11049 }, + { (float)0.012639, 165, 11210 }, + { (float)0.012639, 165, 11375 }, + { (float)0.012639, 165, 11540 }, + { (float)0.009991, 168, 11705 }, + { (float)0.009991, 168, 11873 }, + { (float)0.009991, 168, 12041 }, + { (float)0.009016, 170, 12209 }, + { (float)0.009016, 170, 12379 }, + { (float)0.009016, 170, 12549 }, + { (float)0.006217, 173, 12719 }, + { (float)0.006217, 173, 12892 }, + { (float)0.005097, 175, 13065 }, + { (float)0.005097, 175, 13240 }, + { (float)0.005097, 175, 13415 }, + { (float)0.003909, 177, 13590 }, + { (float)0.003909, 177, 13767 }, + { (float)0.002340, 177, 13944 }, + { (float)0.002389, 170, 14121 }, + { (float)0.001068, 164, 14291 }, + { (float)0.001653, 157, 14455 }, + { (float)0.000717, 150, 14612 }, + { (float)0.001614, 143, 14762 }, + { (float)0.000270, 136, 14905 }, + { (float)0.000484, 129, 15041 }, + { (float)0.001103, 123, 15170 }, + { (float)0.001242, 115, 15293 }, + { (float)0.001188, 109, 15408 }, + { (float)0.001011, 103, 15517 }, + { (float)0.000709, 97, 15620 }, + { (float)0.000301, 89, 15717 }, + { (float)0.002416, 82, 15806 }, + { (float)0.003251, 76, 15888 }, + { (float)0.003246, 69, 15964 }, + { (float)0.004141, 62, 16033 }, + { (float)0.005963, 55, 16095 }, + { (float)0.008839, 47, 16150 }, + { (float)0.010490, 40, 16197 }, + { (float)0.016994, 31, 16237 }, + { (float)0.023659, 21, 16268 }, }; +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/man/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/man/CMakeLists.txt new file mode 100644 index 000000000..be5e2949e --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/CMakeLists.txt @@ -0,0 +1,97 @@ +# CMake build for libtiff +# +# Copyright © 2015 Open Microscopy Environment / University of Dundee +# Written by Roger Leigh +# +# 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. + +set(man1_MANS + fax2ps.1 + fax2tiff.1 + pal2rgb.1 + ppm2tiff.1 + raw2tiff.1 + tiff2bw.1 + tiff2pdf.1 + tiff2ps.1 + tiff2rgba.1 + tiffcmp.1 + tiffcp.1 + tiffcrop.1 + tiffdither.1 + tiffdump.1 + tiffgt.1 + tiffinfo.1 + tiffmedian.1 + tiffset.1 + tiffsplit.1) + +set(man3_MANS + libtiff.3tiff + TIFFbuffer.3tiff + TIFFClose.3tiff + TIFFcodec.3tiff + TIFFcolor.3tiff + TIFFDataWidth.3tiff + TIFFError.3tiff + TIFFFieldDataType.3tiff + TIFFFieldName.3tiff + TIFFFieldPassCount.3tiff + TIFFFieldReadCount.3tiff + TIFFFieldTag.3tiff + TIFFFieldWriteCount.3tiff + TIFFFlush.3tiff + TIFFGetField.3tiff + TIFFmemory.3tiff + TIFFOpen.3tiff + TIFFPrintDirectory.3tiff + TIFFquery.3tiff + TIFFReadDirectory.3tiff + TIFFReadEncodedStrip.3tiff + TIFFReadEncodedTile.3tiff + TIFFReadRawStrip.3tiff + TIFFReadRawTile.3tiff + TIFFReadRGBAImage.3tiff + TIFFReadRGBAStrip.3tiff + TIFFReadRGBATile.3tiff + TIFFReadScanline.3tiff + TIFFReadTile.3tiff + TIFFRGBAImage.3tiff + TIFFSetDirectory.3tiff + TIFFSetField.3tiff + TIFFsize.3tiff + TIFFstrip.3tiff + TIFFswab.3tiff + TIFFtile.3tiff + TIFFWarning.3tiff + TIFFWriteDirectory.3tiff + TIFFWriteEncodedStrip.3tiff + TIFFWriteEncodedTile.3tiff + TIFFWriteRawStrip.3tiff + TIFFWriteRawTile.3tiff + TIFFWriteScanline.3tiff + TIFFWriteTile.3tiff) + +install(FILES ${man1_MANS} + DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man1") +install(FILES ${man3_MANS} + DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man3") + +extra_dist(${man1_MANS} ${man3_MANS}) diff --git a/thirdparty/SDL2_image/external/libtiff/man/Makefile.am b/thirdparty/SDL2_image/external/libtiff/man/Makefile.am new file mode 100644 index 000000000..0fe9e4d08 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/Makefile.am @@ -0,0 +1,94 @@ +# Tag Image File Format (TIFF) Software +# +# Copyright (C) 2004, Andrey Kiselev +# +# 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. + +# Process this file with automake to produce Makefile.in. + +dist_man1_MANS = \ + fax2ps.1 \ + fax2tiff.1 \ + pal2rgb.1 \ + ppm2tiff.1 \ + raw2tiff.1 \ + tiff2bw.1 \ + tiff2pdf.1 \ + tiff2ps.1 \ + tiff2rgba.1 \ + tiffcmp.1 \ + tiffcp.1 \ + tiffcrop.1 \ + tiffdither.1 \ + tiffdump.1 \ + tiffgt.1 \ + tiffinfo.1 \ + tiffmedian.1 \ + tiffset.1 \ + tiffsplit.1 + +dist_man3_MANS = \ + libtiff.3tiff \ + TIFFbuffer.3tiff \ + TIFFClose.3tiff \ + TIFFcodec.3tiff \ + TIFFcolor.3tiff \ + TIFFDataWidth.3tiff \ + TIFFError.3tiff \ + TIFFFieldDataType.3tiff \ + TIFFFieldName.3tiff \ + TIFFFieldPassCount.3tiff \ + TIFFFieldReadCount.3tiff \ + TIFFFieldTag.3tiff \ + TIFFFieldWriteCount.3tiff \ + TIFFFlush.3tiff \ + TIFFGetField.3tiff \ + TIFFmemory.3tiff \ + TIFFOpen.3tiff \ + TIFFPrintDirectory.3tiff \ + TIFFquery.3tiff \ + TIFFReadDirectory.3tiff \ + TIFFReadEncodedStrip.3tiff \ + TIFFReadEncodedTile.3tiff \ + TIFFReadRawStrip.3tiff \ + TIFFReadRawTile.3tiff \ + TIFFReadRGBAImage.3tiff \ + TIFFReadRGBAStrip.3tiff \ + TIFFReadRGBATile.3tiff \ + TIFFReadScanline.3tiff \ + TIFFReadTile.3tiff \ + TIFFRGBAImage.3tiff \ + TIFFSetDirectory.3tiff \ + TIFFSetField.3tiff \ + TIFFsize.3tiff \ + TIFFstrip.3tiff \ + TIFFswab.3tiff \ + TIFFtile.3tiff \ + TIFFWarning.3tiff \ + TIFFWriteDirectory.3tiff \ + TIFFWriteEncodedStrip.3tiff \ + TIFFWriteEncodedTile.3tiff \ + TIFFWriteRawStrip.3tiff \ + TIFFWriteRawTile.3tiff \ + TIFFWriteScanline.3tiff \ + TIFFWriteTile.3tiff + +EXTRA_DIST = \ + CMakeLists.txt diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFClose.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFClose.3tiff new file mode 100644 index 000000000..fc64ccc30 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFClose.3tiff @@ -0,0 +1,52 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFClose 3TIFF "November 2, 2005" "libtiff" +.SH NAME +TIFFClose \- close a previously opened +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "void TIFFClose(TIFF *" tif ")" +.SH DESCRIPTION +.IR TIFFClose +closes a file that was previously opened with +.BR TIFFOpen (3TIFF). +Any buffered data are flushed to the file, including the contents of the +current directory (if modified); and all resources are reclaimed. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +Likewise, warning messages are directed to the +.BR TIFFWarning (3TIFF) +routine. +.SH "SEE ALSO" +.BR libtiff (3TIFF), +.BR TIFFOpen (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFDataWidth.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFDataWidth.3tiff new file mode 100644 index 000000000..efcd39d73 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFDataWidth.3tiff @@ -0,0 +1,73 @@ +.\" +.\" Copyright (c) 2002, Andrey Kiselev +.\" +.\" 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. +.\" +.if n .po 0 +.TH TIFFDataWidth 3TIFF "September 12, 2002" "libtiff" +.SH NAME +TIFFDataWidth \- Get the size of TIFF data types +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFDataWidth(TIFFDataType " type ")" +.SH DESCRIPTION +.I TIFFDataWidth +returns a size of +.I type +in bytes. +Currently following data types are supported: +.br +.I TIFF_BYTE +.br +.I TIFF_ASCII +.br +.I TIFF_SBYTE +.br +.I TIFF_UNDEFINED +.br +.I TIFF_SHORT +.br +.I TIFF_SSHORT +.br +.I TIFF_LONG +.br +.I TIFF_SLONG +.br +.I TIFF_FLOAT +.br +.I TIFF_IFD +.br +.I TIFF_RATIONAL +.br +.I TIFF_SRATIONAL +.br +.I TIFF_DOUBLE +.br +.SH "RETURN VALUES" +.br +.IR TIFFDataWidth +returns a number of bytes occupied by the item of given type. 0 returned when +uknown data type supplied. +.SH "SEE ALSO" +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFError.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFError.3tiff new file mode 100644 index 000000000..5d0c2196e --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFError.3tiff @@ -0,0 +1,68 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFError 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFError, TIFFSetErrorHandler \- library error handling interface +.SH SYNOPSIS +.B "#include " +.sp +.BI "void TIFFError(const char *" module ", const char *" fmt ", " ... ")" +.sp +.B "#include " +.sp +.BI "typedef void (*TIFFErrorHandler)(const char *" module ", const char *" fmt ", va_list " ap ");" +.br +.B "TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler handler);" +.SH DESCRIPTION +.I TIFFError +invokes the library-wide error handling function to (normally) write an error +message to the +.BR stderr . +The +.I fmt +parameter is a +.IR printf (3S) +format string, and any number arguments can be supplied. The +.I module +parameter, if non-zero, is printed before the message; it typically is used to +identify the software module in which an error is detected. +.PP +Applications that desire to capture control in the event of an error should +use +.IR TIFFSetErrorHandler +to override the default error handler. +A +.SM NULL +(0) error handling function may be installed to suppress error messages. +.SH "RETURN VALUES" +.IR TIFFSetErrorHandler +returns a reference to the previous error handling function. +.SH "SEE ALSO" +.BR TIFFWarning (3TIFF), +.BR libtiff (3TIFF), +.BR printf (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldDataType.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldDataType.3tiff new file mode 100644 index 000000000..6049f5918 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldDataType.3tiff @@ -0,0 +1,52 @@ +.\" +.\" Copyright (c) 2012, Tom Lane +.\" +.\" 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. +.\" +.if n .po 0 +.TH TIFFFieldDataType 3TIFF "July 26, 2012" "libtiff" +.SH NAME +TIFFFieldDataType \- Get TIFF data type from field information +.SH SYNOPSIS +.B "#include " +.sp +.BI "TIFFDataType TIFFFieldDataType(const TIFFField* " fip ")" +.SH DESCRIPTION +.BR TIFFFieldDataType +returns the data type stored in a TIFF field. +.P +.I fip +is a field information pointer previously returned by +.BR TIFFFindField , +.BR TIFFFieldWithTag , +or +.BR TIFFFieldWithName . +.br +.SH "RETURN VALUES" +.br +.BR TIFFFieldDataType +returns a member of the enum type +.BR TIFFDataType . +.br +.SH "SEE ALSO" +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldName.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldName.3tiff new file mode 100644 index 000000000..47d9ad844 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldName.3tiff @@ -0,0 +1,51 @@ +.\" +.\" Copyright (c) 2012, Tom Lane +.\" +.\" 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. +.\" +.if n .po 0 +.TH TIFFFieldName 3TIFF "July 26, 2012" "libtiff" +.SH NAME +TIFFFieldName \- Get TIFF field name from field information +.SH SYNOPSIS +.B "#include " +.sp +.BI "const char* TIFFFieldName(const TIFFField* " fip ")" +.SH DESCRIPTION +.BR TIFFFieldName +returns the textual name for a TIFF field. +.P +.I fip +is a field information pointer previously returned by +.BR TIFFFindField , +.BR TIFFFieldWithTag , +or +.BR TIFFFieldWithName . +.br +.SH "RETURN VALUES" +.br +.BR TIFFFieldName +returns a constant C string. +.br +.SH "SEE ALSO" +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldPassCount.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldPassCount.3tiff new file mode 100644 index 000000000..ff14c5202 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldPassCount.3tiff @@ -0,0 +1,72 @@ +.\" +.\" Copyright (c) 2012, Tom Lane +.\" +.\" 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. +.\" +.if n .po 0 +.TH TIFFFieldPassCount 3TIFF "July 26, 2012" "libtiff" +.SH NAME +TIFFFieldPassCount \- Get whether to pass a count to TIFFGet/SetField +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFFieldPassCount(const TIFFField* " fip ")" +.SH DESCRIPTION +.BR TIFFFieldPassCount +returns true (nonzero) if +.BR TIFFGetField +and +.BR TIFFSetField +expect a +.I count +value to be passed before the actual data pointer. +.P +.I fip +is a field information pointer previously returned by +.BR TIFFFindField , +.BR TIFFFieldWithTag , +or +.BR TIFFFieldWithName . +.P +When a +.I count +is required, it will be of type +.BR uint32 +when +.BR TIFFFieldReadCount +reports +.BR TIFF_VARIABLE2 , +and of type +.BR uint16 +otherwise. (This distinction is critical for use of +.BR TIFFGetField , +but normally not so for use of +.BR TIFFSetField .) +.br +.SH "RETURN VALUES" +.br +.BR TIFFFieldPassCount +returns an integer that is always 1 (true) or 0 (false). +.br +.SH "SEE ALSO" +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldReadCount.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldReadCount.3tiff new file mode 100644 index 000000000..b6a4546c2 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldReadCount.3tiff @@ -0,0 +1,76 @@ +.\" +.\" Copyright (c) 2012, Tom Lane +.\" +.\" 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. +.\" +.if n .po 0 +.TH TIFFFieldReadCount 3TIFF "July 26, 2012" "libtiff" +.SH NAME +TIFFFieldReadCount \- Get number of values to be read from field +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFFieldReadCount(const TIFFField* " fip ")" +.SH DESCRIPTION +.BR TIFFFieldReadCount +returns the number of values available to be read from the specified +TIFF field; that is, the number of arguments that should be supplied to +.BR TIFFGetField . +For most field types this is a small positive integer, typically 1 or 2, +but there are some special values: +.br +.BR TIFF_VARIABLE +indicates that a variable number of values is possible; then, a +.BR uint16 +.I count +argument and a pointer +.I data +argument must be supplied to +.BR TIFFGetField . +.br +.BR TIFF_VARIABLE2 +is the same as +.BR TIFF_VARIABLE +except that the +.I count +argument must have type +.BR uint32 . +.br +.BR TIFF_SPP +indicates that the number of arguments is equal to the image's +number of samples per pixel. +.P +.I fip +is a field information pointer previously returned by +.BR TIFFFindField , +.BR TIFFFieldWithTag , +or +.BR TIFFFieldWithName . +.br +.SH "RETURN VALUES" +.br +.BR TIFFFieldReadCount +returns an integer. +.br +.SH "SEE ALSO" +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldTag.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldTag.3tiff new file mode 100644 index 000000000..3d1e83d0f --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldTag.3tiff @@ -0,0 +1,55 @@ +.\" +.\" Copyright (c) 2012, Tom Lane +.\" +.\" 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. +.\" +.if n .po 0 +.TH TIFFFieldTag 3TIFF "July 26, 2012" "libtiff" +.SH NAME +TIFFFieldTag \- Get TIFF field tag value from field information +.SH SYNOPSIS +.B "#include " +.sp +.BI "uint32 TIFFFieldTag(const TIFFField* " fip ")" +.SH DESCRIPTION +.BR TIFFFieldTag +returns the numeric tag value for a TIFF field. +This can be compared to various constants exported by the +.BR libtiff +header files, such as +.BR TIFFTAG_IMAGEWIDTH . +.P +.I fip +is a field information pointer previously returned by +.BR TIFFFindField , +.BR TIFFFieldWithTag , +or +.BR TIFFFieldWithName . +.br +.SH "RETURN VALUES" +.br +.BR TIFFFieldTag +returns an integer tag value. +.br +.SH "SEE ALSO" +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldWriteCount.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldWriteCount.3tiff new file mode 100644 index 000000000..f80290fe4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFFieldWriteCount.3tiff @@ -0,0 +1,87 @@ +.\" +.\" Copyright (c) 2012, Tom Lane +.\" +.\" 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. +.\" +.if n .po 0 +.TH TIFFFieldWriteCount 3TIFF "July 26, 2012" "libtiff" +.SH NAME +TIFFFieldWriteCount \- Get number of values to be written to field +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFFieldWriteCount(const TIFFField* " fip ")" +.SH DESCRIPTION +.BR TIFFFieldWriteCount +returns the number of values to be written into the specified +TIFF field; that is, the number of arguments that should be supplied to +.BR TIFFSetField . +For most field types this is a small positive integer, typically 1 or 2, +but there are some special values: +.br +.BR TIFF_VARIABLE +indicates that a variable number of values is possible; then, a +.BR uint16 +.I count +argument and a pointer +.I data +argument must be supplied to +.BR TIFFSetField . +.br +.BR TIFF_VARIABLE2 +is the same as +.BR TIFF_VARIABLE +except that the +.I count +argument must have type +.BR uint32 . +(On most modern machines, this makes no practical difference, and the +.I count +argument can simply be an +.BR int +in either case.) +.br +.BR TIFF_SPP +indicates that the number of arguments must be equal to the image's +number of samples per pixel. +.P +.I fip +is a field information pointer previously returned by +.BR TIFFFindField , +.BR TIFFFieldWithTag , +or +.BR TIFFFieldWithName . +.P +For most field types, +.BR TIFFFieldWriteCount +returns the same value as +.BR TIFFFieldReadCount , +but there are some exceptions. +.br +.SH "RETURN VALUES" +.br +.BR TIFFFieldWriteCount +returns an integer. +.br +.SH "SEE ALSO" +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFFlush.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFFlush.3tiff new file mode 100644 index 000000000..c46a2a3f2 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFFlush.3tiff @@ -0,0 +1,63 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFFlush 3TIFF "December 16, 1991" "libtiff" +.SH NAME +TIFFFlush, TIFFFlushData \- flush pending writes to an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFFlush(TIFF *" tif ")" +.br +.BI "int TIFFFlushData(TIFF *" tif ")" +.SH DESCRIPTION +.IR TIFFFlush +causes any pending writes for the specified file (including writes for the +current directory) to be done. In normal operation this call is never needed \- +the library automatically does any flushing required. +.PP +.IR TIFFFlushData +flushes any pending image data for the specified file to be written out; +directory-related data are not flushed. In normal operation this call is never +needed \- the library automatically does any flushing required. +.SH "RETURN VALUES" +0 is returned if an error is encountered, otherwise 1 is returned. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFWriteEncodedStrip (3TIFF), +.BR TIFFWriteEncodedTile (3TIFF), +.BR TIFFWriteRawStrip (3TIFF), +.BR TIFFWriteRawTile (3TIFF), +.BR TIFFWriteScanline (3TIFF), +.BR TIFFWriteTile (3TIFF) +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFGetField.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFGetField.3tiff new file mode 100644 index 000000000..431f4ae9b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFGetField.3tiff @@ -0,0 +1,228 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFGetField 3TIFF "March 29, 2020" "libtiff" +.SH NAME +TIFFGetField, TIFFVGetField \- get the value(s) of a tag in an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFGetField(TIFF *" tif ", ttag_t " tag ", " ... ")" +.sp +.B "#include " +.sp +.BI "int TIFFVGetField(TIFF *" tif ", ttag_t " tag ", va_list " ap ")" +.br +.BI "int TIFFGetFieldDefaulted(TIFF *" tif ", ttag_t " tag ", " ... ")" +.br +.BI "int TIFFVGetFieldDefaulted(TIFF *" tif ", ttag_t " tag ", va_list " ap ")" +.SH DESCRIPTION +.IR TIFFGetField +returns the value of a tag or pseudo-tag associated with the the current +directory of the opened +.SM TIFF +file +.IR tif . +(A +.I pseudo-tag +is a parameter that is used to control the operation of the +.SM TIFF +library but whose value is not read or written to the underlying file.) The +file must have been previously opened with +.IR TIFFOpen (3TIFF). +The tag is identified by +.IR tag , +one of the values defined in the include file +.B tiff.h +(see also the table below). The type and number of values returned is +dependent on the tag being requested. The programming interface uses a +variable argument list as prescribed by the +.IR stdarg (3) +interface. The returned values should only be interpreted if +.IR TIFFGetField +returns 1. +.PP +.IR TIFFVGetField +is functionally equivalent to +.IR TIFFGetField +except that it takes a pointer to a variable argument list. +.I TIFFVGetField +is useful for layering interfaces on top of the functionality provided by +.IR TIFFGetField . +.PP +.IR TIFFGetFieldDefaulted +and +.IR TIFFVGetFieldDefaulted +are identical to +.IR TIFFGetField +and +.IR TIFFVGetField , +except that if a tag is not defined in the current directory and it has a +default value, then the default value is returned. +.PP +The tags understood by +.IR libtiff(3TIFF), +the number of parameter values, and the types for the returned values are +shown below. The data types are specified as in C and correspond to the types +used to specify tag values to +.IR TIFFSetField (3TIFF). +Remember that +.IR TIFFGetField +returns parameter values, so all the listed data types are pointers to storage +where values should be returned. +Consult the +.SM TIFF +specification (or relevant industry specification) for information on the +meaning of each tag and their possible values. +.PP +.nf +.ta \w'TIFFTAG_CONSECUTIVEBADFAXLINES'u+2n +\w'Count'u+2n +\w'TIFFFaxFillFunc*'u+2n +\fITag Name\fP \fICount\fP \fITypes\fP \fINotes\fP +.sp 5p +TIFFTAG_ARTIST 1 const char** +TIFFTAG_BADFAXLINES 1 uint32* +TIFFTAG_BITSPERSAMPLE 1 uint16* +TIFFTAG_CLEANFAXDATA 1 uint16* +TIFFTAG_COLORMAP 3 const uint16** 1<" +.sp +.BI "TIFF* TIFFOpen(const char *" filename ", const char *" mode ")" +.br +.BI "TIFF* TIFFFdOpen(const int " fd ", const char *" filename ", const char *" mode ")" +.sp +.B "typedef tsize_t (*TIFFReadWriteProc)(thandle_t, tdata_t, tsize_t);" +.br +.B "typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int);" +.br +.B "typedef int (*TIFFCloseProc)(thandle_t);" +.br +.B "typedef toff_t (*TIFFSizeProc)(thandle_t);" +.br +.B "typedef int (*TIFFMapFileProc)(thandle_t, tdata_t*, toff_t*);" +.br +.B "typedef void (*TIFFUnmapFileProc)(thandle_t, tdata_t, toff_t);" +.sp +.BI "TIFF* TIFFClientOpen(const char *" filename ", const char *" mode ", thandle_t " clientdata ", TIFFReadWriteProc " readproc ", TIFFReadWriteProc " writeproc ", TIFFSeekProc " seekproc ", TIFFCloseProc " closeproc ", TIFFSizeProc " sizeproc ", TIFFMapFileProc " mapproc ", TIFFUnmapFileProc " unmapproc ")" +.SH DESCRIPTION +.IR TIFFOpen +opens a +.SM TIFF +file whose name is +.I filename +and returns a handle to be used in subsequent calls to routines in +.IR libtiff . +If the open operation fails, then zero is returned. +The +.I mode +parameter specifies if the file is to be opened for reading (``r''), +writing (``w''), or appending (``a'') and, optionally, whether +to override certain default aspects of library operation (see below). +When a file is opened for appending, existing data will not +be touched; instead new data will be written as additional subfiles. +If an existing file is opened for writing, all previous data is +overwritten. +.PP +If a file is opened for reading, the first +.SM TIFF +directory in the file is automatically read +(also see +.IR TIFFSetDirectory (3TIFF) +for reading directories other than the first). +If a file is opened for writing or appending, a default directory +is automatically created for writing subsequent data. +This directory has all the default values specified in +.SM TIFF +Revision 6.0: +.IR BitsPerSample =1, +.IR ThreshHolding "=bilevel art scan," +.IR FillOrder =1 +(most significant bit of each data byte is filled first), +.IR Orientation =1 +(the 0th row represents the visual top of the image, and the 0th +column represents the visual left hand side), +.IR SamplesPerPixel =1, +.IR RowsPerStrip =infinity, +.IR ResolutionUnit =2 +(inches), and +.IR Compression =1 +(no compression). +To alter these values, or to define values for additional fields, +.IR TIFFSetField (3TIFF) +must be used. +.PP +.IR TIFFFdOpen +is like +.IR TIFFOpen +except that it opens a +.SM TIFF +file given an open file descriptor +.IR fd . +The file's name and mode must reflect that of the open descriptor. +The object associated with the file descriptor +.BR "must support random access" . +.PP +.IR TIFFClientOpen +is like +.IR TIFFOpen +except that the caller supplies a collection of functions that the +library will use to do \s-1UNIX\s+1-like I/O operations. +The +.I readproc +and +.I writeproc +are called to read and write data at the current file position. +.I seekproc +is called to change the current file position a la +.IR lseek (2). +.I closeproc +is invoked to release any resources associated with an open file. +.I sizeproc +is invoked to obtain the size in bytes of a file. +.I mapproc +and +.I unmapproc +are called to map and unmap a file's contents in memory; c.f. +.IR mmap (2) +and +.IR munmap (2). +The +.I clientdata +parameter is an opaque ``handle'' passed to the client-specified +routines passed as parameters to +.IR TIFFClientOpen . +.SH OPTIONS +The open mode parameter can include the following flags in +addition to the ``r'', ``w'', and ``a'' flags. +Note however that option flags must follow the read-write-append +specification. +.TP +.B l +When creating a new file force information be written with +Little-Endian byte order (but see below). +By default the library will create new files using the native +.SM CPU +byte order. +.TP +.B b +When creating a new file force information be written with +Big-Endian byte order (but see below). +By default the library will create new files using the native +.SM CPU +byte order. +.TP +.B L +Force image data that is read or written to be treated with +bits filled from Least Significant Bit (\s-1LSB\s+1) to +Most Significant Bit (\s-1MSB\s+1). +Note that this is the opposite to the way the library has +worked from its inception. +.TP +.B B +Force image data that is read or written to be treated with +bits filled from Most Significant Bit (\s-1MSB\s+1) to +Least Significant Bit (\s-1LSB\s+1); this is the default. +.TP +.B H +Force image data that is read or written to be treated with +bits filled in the same order as the native +.SM CPU. +.TP +.B M +Enable the use of memory-mapped files for images opened read-only. +If the underlying system does not support memory-mapped files +or if the specific image being opened cannot be memory-mapped +then the library will fallback to using the normal system interface +for reading information. +By default the library will attempt to use memory-mapped files. +.TP +.B m +Disable the use of memory-mapped files. +.TP +.B C +Enable the use of ``strip chopping'' when reading images +that are comprised of a single strip or tile of uncompressed data. +Strip chopping is a mechanism by which the library will automatically +convert the single-strip image to multiple strips, +each of which has about 8 Kilobytes of data. +This facility can be useful in reducing the amount of memory used +to read an image because the library normally reads each strip +in its entirety. +Strip chopping does however alter the apparent contents of the +image because when an image is divided into multiple strips it +looks as though the underlying file contains multiple separate +strips. +Finally, note that default handling of strip chopping is a compile-time +configuration parameter. +The default behaviour, for backwards compatibility, is to enable +strip chopping. +.TP +.B c +Disable the use of strip chopping when reading images. +.TP +.B h +Read TIFF header only, do not load the first image directory. That could be +useful in case of the broken first directory. We can open the file and proceed +to the other directories. +.TP +.B 4 +ClassicTIFF for creating a file (default) +.TP +.B 8 +BigTIFF for creating a file. +.TP +.B D +Enable use of deferred strip/tile offset/bytecount array loading. They will +be loaded the first time they are accessed to. This loading will be done in +its entirety unless the O flag is also specified. +.TP +.B O +On-demand loading of values of the strip/tile offset/bytecount arrays, limited +to the requested strip/tile, instead of whole array loading (implies D) +.SH "BYTE ORDER" +The +.SM TIFF +specification (\fBall versions\fP) states that compliant readers +.IR "must be capable of reading images written in either byte order" . +Nonetheless some software that claims to support the reading of +.SM TIFF +images is incapable of reading images in anything but the native +.SM CPU +byte order on which the software was written. +(Especially notorious +are applications written to run on Intel-based machines.) +By default the library will create new files with the native +byte-order of the +.SM CPU +on which the application is run. +This ensures optimal performance and is portable to any application +that conforms to the TIFF specification. +To force the library to use a specific byte-order when creating +a new file the ``b'' and ``l'' option flags may be included in +the call to open a file; for example, ``wb'' or ``wl''. +.SH "RETURN VALUES" +Upon successful completion +.IR TIFFOpen , +.IR TIFFFdOpen , +and +.IR TIFFClientOpen +return a +.SM TIFF +pointer. +Otherwise, NULL is returned. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +Likewise, warning messages are directed to the +.IR TIFFWarning (3TIFF) +routine. +.PP +\fB"%s": Bad mode\fP. +The specified +.I mode +parameter was not one of ``r'' (read), ``w'' (write), or ``a'' (append). +.PP +.BR "%s: Cannot open" . +.IR TIFFOpen () +was unable to open the specified filename for read/writing. +.PP +.BR "Cannot read TIFF header" . +An error occurred while attempting to read the header information. +.PP +.BR "Error writing TIFF header" . +An error occurred while writing the default header information +for a new file. +.PP +.BR "Not a TIFF file, bad magic number %d (0x%x)" . +The magic number in the header was not (hex) +0x4d4d or (hex) 0x4949. +.PP +.BR "Not a TIFF file, bad version number %d (0x%x)" . +The version field in the header was not 42 (decimal). +.PP +.BR "Cannot append to file that has opposite byte ordering" . +A file with a byte ordering opposite to the native byte +ordering of the current machine was opened for appending (``a''). +This is a limitation of the library. +.SH "SEE ALSO" +.IR libtiff (3TIFF), +.IR TIFFClose (3TIFF) diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFPrintDirectory.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFPrintDirectory.3tiff new file mode 100644 index 000000000..c208f044a --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFPrintDirectory.3tiff @@ -0,0 +1,69 @@ +.\" +.\" Copyright (c) 1991-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFPrintDirectory 3TIFF "December 12, 1991" "libtiff" +.SH NAME +TIFFPrintDirectory \- print a description of a +.SM TIFF +directory +.SH SYNOPSIS +.B "#include " +.sp +.BI "void TIFFPrintDirectory(TIFF *" tif ", FILE *" fd ", long " flags ")" +.SH DESCRIPTION +.I TIFFPrintDirectory +prints a description of the current directory in the specified +.SM TIFF +file to the standard I/O output stream +.IR fd . +The +.I flags +parameter is used to control the +.I "level of detail" +of the printed information; it is a bit-or of the flags defined in +.BR tiffio.h : +.sp .5 +.nf +.ta \w'#define 'u +\w'TIFFPRINT_JPEGDCTABLES 'u +\w'0x200 'u +#define TIFFPRINT_NONE 0x0 /* no extra info */ +#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ +#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ +#define TIFFPRINT_COLORMAP 0x4 /* colormap */ +#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ +#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ +#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ +.fi +.SH NOTES +In C++ the +.I flags +parameter defaults to 0. +.SH "RETURN VALUES" +None. +.SH DIAGNOSTICS +None. +.SH "SEE ALSO" +.IR libtiff (3TIFF), +.IR TIFFOpen (3TIFF), +.IR TIFFReadDirectory (3TIFF), +.IR TIFFSetDirectory (3TIFF) diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFRGBAImage.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFRGBAImage.3tiff new file mode 100644 index 000000000..fe6064fca --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFRGBAImage.3tiff @@ -0,0 +1,285 @@ +.\" +.\" Copyright (c) 1991-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFRGBAImage 3TIFF "October 29, 2004" "libtiff" +.SH NAME +TIFFRGBAImageOK, TIFFRGBAImageBegin, TIFFRGBAImageGet, TIFFRGBAImageEnd +\- read and decode an image into a raster +.SH SYNOPSIS +.B "#include " +.sp +.B "typedef unsigned char TIFFRGBValue;" +.B "typedef struct _TIFFRGBAImage TIFFRGBAImage;" +.sp +.BI "int TIFFRGBAImageOK(TIFF *" tif ", char " emsg[1024] ")" +.br +.BI "int TIFFRGBAImageBegin(TIFFRGBAImage *" img ", TIFF* " tif ", int " stopOnError ", char " emsg[1024] ")" +.br +.BI "int TIFFRGBAImageGet(TIFFRGBAImage *" img ", uint32* " raster ", uint32 " width " , uint32 " height ")" +.br +.BI "void TIFFRGBAImageEnd(TIFFRGBAImage *" img ")" +.br +.SH DESCRIPTION +The routines described here provide a high-level interface +through which +.SM TIFF +images may be read into memory. +Images may be strip- or tile-based and have a variety of different +characteristics: bits/sample, samples/pixel, photometric, etc. +Decoding state is encapsulated in a +.I TIFFRGBAImage +structure making it possible to capture state for multiple images +and quickly switch between them. +The target raster format can be customized to a particular application's +needs by installing custom routines that manipulate image data +according to application requirements. +.PP +The default usage for these routines is: check if an image can +be processed using +.IR TIFFRGBAImageOK , +construct a decoder state block using +.IR TIFFRGBAImageBegin , +read and decode an image into a target raster using +.IR TIFFRGBAImageGet , +and then +release resources using +.IR TIFFRGBAImageEnd . +.I TIFFRGBAImageGet +can be called multiple times to decode an image using different +state parameters. +If multiple images are to be displayed and there is not enough +space for each of the decoded rasters, multiple state blocks can +be managed and then calls can be made to +.I TIFFRGBAImageGet +as needed to display an image. +.PP +The generated raster is assumed to be an array of +.I width +times +.I height +32-bit entries, where +.I width +must be less than or equal to the width of the image (\c +.I height +may be any non-zero size). +If the raster dimensions are smaller than the image, the image data +is cropped to the raster bounds. +If the raster height is greater than that of the image, then the +image data are placed in the lower part of the raster. +(Note that the raster is assume to be organized such that the pixel +at location (\fIx\fP,\fIy\fP) is \fIraster\fP[\fIy\fP*\fIwidth\fP+\fIx\fP]; +with the raster origin in the +.B lower-left +hand corner.) +.PP +Raster pixels are 8-bit packed red, green, blue, alpha samples. +The macros +.IR TIFFGetR , +.IR TIFFGetG , +.IR TIFFGetB , +and +.I TIFFGetA +should be used to access individual samples. +Images without Associated Alpha matting information have a constant +Alpha of 1.0 (255). +.PP +.I TIFFRGBAImageGet +converts non-8-bit images by scaling sample values. +Palette, grayscale, bilevel, +.SM CMYK\c +, and YCbCr images are converted to +.SM RGB +transparently. +Raster pixels are returned uncorrected by any colorimetry information +present in the directory. +.PP +The parameter +.I stopOnError +specifies how to act if an error is encountered while reading +the image. +If +.I stopOnError +is non-zero, then an error will terminate the operation; otherwise +.I TIFFRGBAImageGet +will continue processing data until all the possible data in the +image have been requested. +.SH "ALTERNATE RASTER FORMATS" +To use the core support for reading and processing +.SM TIFF +images, but write the resulting raster data in a different format +one need only override the ``\fIput methods\fP'' used to store raster data. +These methods are are defined in the +.I TIFFRGBAImage +structure and initially setup by +.I TIFFRGBAImageBegin +to point to routines that pack raster data in the default +.SM ABGR +pixel format. +Two different routines are used according to the physical organization +of the image data in the file: +.IR PlanarConfiguration =1 +(packed samples), +and +.IR PlanarConfiguration =2 +(separated samples). +Note that this mechanism can be used to transform the data before +storing it in the raster. +For example one can convert data +to colormap indices for display on a colormap display. +.SH "SIMULTANEOUS RASTER STORE AND DISPLAY" +It is simple to display an image as it is being read into memory +by overriding the put methods as described above for supporting +alternate raster formats. +Simply keep a reference to the default put methods setup by +.I TIFFRGBAImageBegin +and then invoke them before or after each display operation. +For example, the +.IR tiffgt (1) +utility uses the following put method to update the display as +the raster is being filled: +.sp +.nf +.ft C +static void +putContigAndDraw(TIFFRGBAImage* img, uint32* raster, + uint32 x, uint32 y, uint32 w, uint32 h, + int32 fromskew, int32 toskew, + unsigned char* cp) +{ + (*putContig)(img, raster, x, y, w, h, fromskew, toskew, cp); + if (x+w == width) { + w = width; + if (img->orientation == ORIENTATION_TOPLEFT) + lrectwrite(0, y-(h-1), w-1, y, raster-x-(h-1)*w); + else + lrectwrite(0, y, w-1, y+h-1, raster); + } +} +.ft R +.fi +.sp +(the original routine provided by the library is saved in the +variable +.IR putContig .) +.SH "SUPPORTING ADDITIONAL TIFF FORMATS" +The +.I TIFFRGBAImage +routines support the most commonly encountered flavors of +.SM TIFF. +It is possible to extend this support by overriding the ``\fIget method\fP'' +invoked by +.I TIFFRGBAImageGet +to read +.SM TIFF +image data. +Details of doing this are a bit involved, it is best to make a copy +of an existing get method and modify it to suit the needs of an +application. +.SH NOTES +Samples must be either 1, 2, 4, 8, or 16 bits. +Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. +.I SamplesPerPixel +minus +.IR ExtraSamples ). +.PP +Palette image colormaps that appear to be incorrectly written +as 8-bit values are automatically scaled to 16-bits. +.SH "RETURN VALUES" +All routines return +1 if the operation was successful. +Otherwise, 0 is returned if an error was encountered and +.I stopOnError +is zero. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +.PP +.BR "Sorry, can not handle %d-bit pictures" . +The image had +.I BitsPerSample +other than 1, 2, 4, 8, or 16. +.PP +.BR "Sorry, can not handle %d-channel images" . +The image had +.I SamplesPerPixel +other than 1, 3, or 4. +.PP +\fBMissing needed "PhotometricInterpretation" tag\fP. +The image did not have a tag that describes how to display +the data. +.PP +\fBNo "PhotometricInterpretation" tag, assuming RGB\fP. +The image was missing a tag that describes how to display it, +but because it has 3 or 4 samples/pixel, it is assumed to be +.SM RGB. +.PP +\fBNo "PhotometricInterpretation" tag, assuming min-is-black\fP. +The image was missing a tag that describes how to display it, +but because it has 1 sample/pixel, it is assumed to be a grayscale +or bilevel image. +.PP +.BR "No space for photometric conversion table" . +There was insufficient memory for a table used to convert +image samples to 8-bit +.SM RGB. +.PP +\fBMissing required "Colormap" tag\fP. +A Palette image did not have a required +.I Colormap +tag. +.PP +.BR "No space for tile buffer" . +There was insufficient memory to allocate an i/o buffer. +.PP +.BR "No space for strip buffer" . +There was insufficient memory to allocate an i/o buffer. +.PP +.BR "Can not handle format" . +The image has a format (combination of +.IR BitsPerSample , +.IR SamplesPerPixel , +and +.IR PhotometricInterpretation ) +that can not be handled. +.PP +.BR "No space for B&W mapping table" . +There was insufficient memory to allocate a table used to map +grayscale data to +.SM RGB. +.PP +.BR "No space for Palette mapping table" . +There was insufficient memory to allocate a table used to map +data to 8-bit +.SM RGB. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFReadRGBAImage (3TIFF), +.BR TIFFReadRGBAImageOriented (3TIFF), +.BR TIFFReadRGBAStrip (3TIFF), +.BR TIFFReadRGBATile (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadDirectory.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadDirectory.3tiff new file mode 100644 index 000000000..c178c42b8 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadDirectory.3tiff @@ -0,0 +1,163 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadDirectory 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFReadDirectory \- get the contents of the next directory in an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFReadDirectory(TIFF *" tif ")" +.SH DESCRIPTION +Read the next directory in the specified file and make it the current +directory. Applications only need to call +.I TIFFReadDirectory +to read multiple subfiles in a single +.SM TIFF +file\(em +the first directory in a file is automatically read when +.IR TIFFOpen +is called. +.SH NOTES +If the library is compiled with +.SM STRIPCHOP_SUPPORT +enabled, then images that have a single uncompressed strip or tile of data are +automatically treated as if they were made up of multiple strips or tiles of +approximately 8 kilobytes each. This operation is done only in-memory; it does +not alter the contents of the file. However, the construction of the ``chopped +strips'' is visible to the application through the number of strips [tiles] +returned by +.I TIFFNumberOfStrips +[\c +.IR TIFFNumberOfTiles ]. +.SH "RETURN VALUES" +If the next directory was successfully read, 1 is returned. Otherwise, 0 is +returned if an error was encountered, or if there are no more directories to +be read. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +All warning messages are directed to the +.IR TIFFWarning (3TIFF) +routine. +.PP +\fBSeek error accessing TIFF directory\fP. +An error occurred while positioning to the location of the +directory. +.PP +\fBWrong data type %d for field "%s"\fP. +The tag entry in the directory had an incorrect data type. +For example, an +.I ImageDescription +tag with a +.SM SHORT +data type. +.PP +\fBTIFF directory is missing required "%s" field\fP. +The specified tag is required to be present by the +.SM TIFF +5.0 specification, but is missing. +The directory is (usually) unusable. +.PP +\fB%s: Rational with zero denominator\fP. +A directory tag has a +.SM RATIONAL +value whose denominator is zero. +.PP +\fBIncorrect count %d for field "%s" (%lu, expecting %lu); tag ignored\fP. +The specified tag's count field is bad. +For example, a count other than 1 for a +.I SubFileType +tag. +.PP +\fBCannot handle different per-sample values for field "%s"\fP. +The tag has +.I SamplesPerPixel +values and they are not all the same; e.g. +.IR BitsPerSample . +The library is unable to handle images of this sort. +.PP +\fBCount mismatch for field "%s"; expecting %d, got %d\fP. +The count field in a +tag does not agree with the number expected by the library. +This should never happen, so if it does, the library refuses to +read the directory. +.PP +\fBInvalid TIFF directory; tags are not sorted in ascending order\fP. +The directory tags are not properly sorted as specified +in the +.SM TIFF +5.0 specification. +This error is not fatal. +.PP +\fBIgnoring unknown field with tag %d (0x%x)\fP. +An unknown tag was encountered in the directory; +the library ignores all such tags. +.PP +\fBTIFF directory is missing required "ImageLength" field\fP. +The image violates the specification by not having a necessary field. +There is no way for the library to recover from this error. +.PP +\fBTIFF directory is missing required "PlanarConfig" field\fP. +The image violates the specification by not having a necessary field. +There is no way for the library to recover from this error. +.PP +\fBTIFF directory is missing required "StripOffsets" field\fP. +The image has multiple strips, but is missing the tag that +specifies the file offset to each strip of data. +There is no way for the library to recover from this error. +.PP +\fBTIFF directory is missing required "TileOffsets" field\fP. +The image has multiple tiles, but is missing the tag that +specifies the file offset to each tile of data. +There is no way for the library to recover from this error. +.PP +\fBTIFF directory is missing required "StripByteCounts" field\fP. +The image has multiple strips, but is missing the tag that +specifies the size of each strip of data. +There is no way for the library to recover from this error. +.PP +\fBTIFF directory is missing required "StripByteCounts" field, calculating from imagelength\fP. +The image violates the specification by not having a necessary field. +However, when the image is comprised of only one strip or tile, the +library will estimate the missing value based on the file size. +.PP +\fBBogus "StripByteCounts" field, ignoring and calculating from imagelength\fP. +Certain vendors violate the specification by writing zero for +the StripByteCounts tag when they want to leave the value +unspecified. +If the image has a single strip, the library will estimate +the missing value based on the file size. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFWriteDirectory (3TIFF), +.BR TIFFSetDirectory (3TIFF), +.BR TIFFSetSubDirectory (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadEncodedStrip.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadEncodedStrip.3tiff new file mode 100644 index 000000000..05ddefb94 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadEncodedStrip.3tiff @@ -0,0 +1,77 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadEncodedStrip 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFReadEncodedStrip \- read and decode a strip of data from an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tmsize_t TIFFReadEncodedStrip(TIFF *" tif ", uint32 " strip ", void *" buf ", tmsize_t " size ")" +.SH DESCRIPTION +Read the specified strip of data and place up to +.I size +bytes of decompressed information in the (user supplied) data buffer. +.SH NOTES +The value of +.I strip +is a ``raw strip number.'' +That is, the caller must take into account whether or not the data are +organized in separate planes (\c +.IR PlanarConfiguration =2). +To read a full strip of data the data buffer should typically be at least as +large as the number returned by +.BR TIFFStripSize (3TIFF). +If the -1 passed in +.I size +parameter, the whole strip will be read. You should be sure you have enough +space allocated for the buffer. +.PP +The library attempts to hide bit- and byte-ordering differences between the +image and the native machine by converting data to the native machine order. +Bit reversal is done if the +.I FillOrder +tag is opposite to the native machine bit order. 16- and 32-bit samples are +automatically byte-swapped if the file was written with a byte order opposite +to the native machine byte order, +.SH "RETURN VALUES" +The actual number of bytes of data that were placed in +.I buf +is returned; +.IR TIFFReadEncodedStrip +returns \-1 if an error was encountered. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFReadRawStrip (3TIFF), +.BR TIFFReadScanline (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadEncodedTile.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadEncodedTile.3tiff new file mode 100644 index 000000000..6f8d64969 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadEncodedTile.3tiff @@ -0,0 +1,75 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadEncodedTile 3TIFF "October 13, 2006" "libtiff" +.SH NAME +TIFFReadEncodedTile \- read and decode a tile of data from an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFReadEncodedTile(TIFF *" tif ", ttile_t " tile ", tdata_t " buf ", tsize_t " size ")" +.SH DESCRIPTION +Read the specified tile of data and place up to +.I size +bytes of decompressed information in the (user supplied) data buffer. +.SH NOTES +The value of +.I tile +is a ``raw tile number.'' +That is, the caller must take into account whether or not the data are +organized in separate planes (\c +.IR PlanarConfiguration =2). +.IR TIFFComputeTile +automatically does this when converting an (x,y,z,sample) coordinate quadruple +to a tile number. To read a full tile of data the data buffer should be at +least as large as the value returned by +.IR TIFFTileSize . +.PP +The library attempts to hide bit- and byte-ordering differences between the +image and the native machine by converting data to the native machine order. +Bit reversal is done if the +.I FillOrder +tag is opposite to the native machine bit order. 16- and 32-bit samples are +automatically byte-swapped if the file was written with a byte order opposite +to the native machine byte order, +.SH "RETURN VALUES" +The actual number of bytes of data that were placed in +.I buf +is returned; +.IR TIFFReadEncodedTile +returns \-1 if an error was encountered. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFReadRawTile (3TIFF), +.BR TIFFReadTile (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBAImage.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBAImage.3tiff new file mode 100644 index 000000000..920fc3704 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBAImage.3tiff @@ -0,0 +1,217 @@ +.\" +.\" Copyright (c) 1991-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadRGBAImage 3TIFF "October 13, 2006" "libtiff" +.SH NAME +TIFFReadRGBAImage, TIFFReadRGBAImageOriented \- read and decode an image +into a fixed-format raster +.SH SYNOPSIS +.B "#include " +.sp +.B "#define TIFFGetR(abgr) ((abgr) & 0xff)" +.br +.B "#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)" +.br +.B "#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)" +.br +.B "#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)" +.sp +.BI "int TIFFReadRGBAImage(TIFF *" tif ", uint32 " width ", uint32 " height ", uint32 *" raster ", int " stopOnError ")" +.br +.BI "int TIFFReadRGBAImageOriented(TIFF *" tif ", uint32 " width ", uint32 " height ", uint32 *" raster ", int " orientation ", int " stopOnError ")" +.br +.SH DESCRIPTION +.IR TIFFReadRGBAImage +reads a strip- or tile-based image into memory, storing the +result in the user supplied +.IR raster . +The raster is assumed to be an array of +.I width +times +.I height +32-bit entries, where +.I width +must be less than or equal to the width of the image (\c +.I height +may be any non-zero size). +If the raster dimensions are smaller than the image, the image data +is cropped to the raster bounds. +If the raster height is greater than that of the image, then the +image data are placed in the lower part of the raster. +(Note that the raster is assume to be organized such that the pixel +at location (\fIx\fP,\fIy\fP) is \fIraster\fP[\fIy\fP*\fIwidth\fP+\fIx\fP]; +with the raster origin in the lower-left hand corner.) +.PP +.IR TIFFReadRGBAImageOriented +works like +.IR TIFFReadRGBAImage +with except of that user can specify the raster origin position with the +.I orientation +parameter. Four orientations supported: +.TP +.B ORIENTATION_TOPLEFT +origin in top-left corner, +.TP +.B ORIENTATION_TOPRIGHT +origin in top-right corner, +.TP +.B ORIENTATION_BOTLEFT +origin in bottom-left corner +and +.TP +.B ORIENTATION_BOTRIGHT +origin in bottom-right corner. +.LP +If you choose +.B ORIENTATION_BOTLEFT +result will be the same as returned by the +.IR TIFFReadRGBAImage. +.PP +Raster pixels are 8-bit packed red, green, blue, alpha samples. +The macros +.IR TIFFGetR , +.IR TIFFGetG , +.IR TIFFGetB , +and +.I TIFFGetA +should be used to access individual samples. +Images without Associated Alpha matting information have a constant +Alpha of 1.0 (255). +.PP +.I TIFFReadRGBAImage +converts non-8-bit images by scaling sample values. +Palette, grayscale, bilevel, +.SM CMYK\c +, and YCbCr images are converted to +.SM RGB +transparently. +Raster pixels are returned uncorrected by any colorimetry information +present in the directory. +.PP +The paramater +.I stopOnError +specifies how to act if an error is encountered while reading +the image. +If +.I stopOnError +is non-zero, then an error will terminate the operation; otherwise +.I TIFFReadRGBAImage +will continue processing data until all the possible data in the +image have been requested. +.SH NOTES +In C++ the +.I stopOnError +parameter defaults to 0. +.PP +Samples must be either 1, 2, 4, 8, or 16 bits. +Colorimetric samples/pixel must be either 1, 3, or 4 (i.e. +.I SamplesPerPixel +minus +.IR ExtraSamples ). +.PP +Palettte image colormaps that appear to be incorrectly written +as 8-bit values are automatically scaled to 16-bits. +.PP +.I TIFFReadRGBAImage +is just a wrapper around the more general +.IR TIFFRGBAImage (3TIFF) +facilities. +.SH "RETURN VALUES" +1 is returned if the image was successfully read and converted. +Otherwise, 0 is returned if an error was encountered and +.I stopOnError +is zero. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +.PP +.BR "Sorry, can not handle %d-bit pictures" . +The image had +.I BitsPerSample +other than 1, 2, 4, 8, or 16. +.PP +.BR "Sorry, can not handle %d-channel images" . +The image had +.I SamplesPerPixel +other than 1, 3, or 4. +.PP +\fBMissing needed "PhotometricInterpretation" tag\fP. +The image did not have a tag that describes how to display +the data. +.PP +\fBNo "PhotometricInterpretation" tag, assuming RGB\fP. +The image was missing a tag that describes how to display it, +but because it has 3 or 4 samples/pixel, it is assumed to be +.SM RGB. +.PP +\fBNo "PhotometricInterpretation" tag, assuming min-is-black\fP. +The image was missing a tag that describes how to display it, +but because it has 1 sample/pixel, it is assumed to be a grayscale +or bilevel image. +.PP +.BR "No space for photometric conversion table" . +There was insufficient memory for a table used to convert +image samples to 8-bit +.SM RGB. +.PP +\fBMissing required "Colormap" tag\fP. +A Palette image did not have a required +.I Colormap +tag. +.PP +.BR "No space for tile buffer" . +There was insufficient memory to allocate an i/o buffer. +.PP +.BR "No space for strip buffer" . +There was insufficient memory to allocate an i/o buffer. +.PP +.BR "Can not handle format" . +The image has a format (combination of +.IR BitsPerSample , +.IR SamplesPerPixel , +and +.IR PhotometricInterpretation ) +that +.I TIFFReadRGBAImage +can not handle. +.PP +.BR "No space for B&W mapping table" . +There was insufficient memory to allocate a table used to map +grayscale data to +.SM RGB. +.PP +.BR "No space for Palette mapping table" . +There was insufficient memory to allocate a table used to map +data to 8-bit +.SM RGB. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFRGBAImage (3TIFF), +.BR TIFFReadRGBAStrip (3TIFF), +.BR TIFFReadRGBATile (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBAStrip.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBAStrip.3tiff new file mode 100644 index 000000000..316041245 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBAStrip.3tiff @@ -0,0 +1,169 @@ +.\" +.\" Copyright (c) 1991-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadRGBAStrip 3TIFF "December 10, 1998" "libtiff" +.SH NAME +TIFFReadRGBAStrip \- read and decode an image strip into a fixed-format raster +.SH SYNOPSIS +.B "#include " +.sp +.B "#define TIFFGetR(abgr) ((abgr) & 0xff)" +.br +.B "#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)" +.br +.B "#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)" +.br +.B "#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)" +.sp +.BI "int TIFFReadRGBAStrip(TIFF *" tif ", uint32 " row ", uint32 *" raster ")" +.SH DESCRIPTION +.IR TIFFReadRGBAStrip +reads a single strip of a strip-based image into memory, storing the result in +the user supplied RGBA +.IR raster . +The raster is assumed to be an array of width times rowsperstrip 32-bit +entries, where width is the width of the image (TIFFTAG_IMAGEWIDTH) and +rowsperstrip is the maximum lines in a strip (TIFFTAG_ROWSPERSTRIP). + +.PP +The +.IR row +value should be the row of the first row in the strip (strip * rowsperstrip, +zero based). + +.PP +Note that the raster is assume to be organized such that the pixel at location +(\fIx\fP,\fIy\fP) is \fIraster\fP[\fIy\fP*\fIwidth\fP+\fIx\fP]; with the +raster origin in the +.I lower-left hand corner +of the strip. That is bottom to top organization. When reading a partial last +strip in the file the last line of the image will begin at the beginning of +the buffer. + +.PP +Raster pixels are 8-bit packed red, green, blue, alpha samples. The macros +.IR TIFFGetR , +.IR TIFFGetG , +.IR TIFFGetB , +and +.I TIFFGetA +should be used to access individual samples. Images without Associated Alpha +matting information have a constant Alpha of 1.0 (255). +.PP +See the +.IR TIFFRGBAImage (3TIFF) +page for more details on how various image types are converted to RGBA values. +.SH NOTES +Samples must be either 1, 2, 4, 8, or 16 bits. Colorimetric samples/pixel must +be either 1, 3, or 4 (i.e. +.I SamplesPerPixel +minus +.IR ExtraSamples ). +.PP +Palette image colormaps that appear to be incorrectly written as 8-bit values +are automatically scaled to 16-bits. +.PP +.I TIFFReadRGBAStrip +is just a wrapper around the more general +.IR TIFFRGBAImage (3TIFF) +facilities. It's main advantage over the similar +.IR TIFFReadRGBAImage() +function is that for large images a single buffer capable of holding the whole +image doesn't need to be allocated, only enough for one strip. The +.IR TIFFReadRGBATile() +function does a similar operation for tiled images. +.SH "RETURN VALUES" +1 is returned if the image was successfully read and converted. +Otherwise, 0 is returned if an error was encountered. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +.PP +.BR "Sorry, can not handle %d-bit pictures" . +The image had +.I BitsPerSample +other than 1, 2, 4, 8, or 16. +.PP +.BR "Sorry, can not handle %d-channel images" . +The image had +.I SamplesPerPixel +other than 1, 3, or 4. +.PP +\fBMissing needed "PhotometricInterpretation" tag\fP. +The image did not have a tag that describes how to display the data. +.PP +\fBNo "PhotometricInterpretation" tag, assuming RGB\fP. +The image was missing a tag that describes how to display it, but because it +has 3 or 4 samples/pixel, it is assumed to be +.SM RGB. +.PP +\fBNo "PhotometricInterpretation" tag, assuming min-is-black\fP. The image was +missing a tag that describes how to display it, but because it has 1 +sample/pixel, it is assumed to be a grayscale or bilevel image. +.PP +.BR "No space for photometric conversion table" . +There was insufficient memory for a table used to convert image samples to +8-bit +.SM RGB. +.PP +\fBMissing required "Colormap" tag\fP. +A Palette image did not have a required +.I Colormap +tag. +.PP +.BR "No space for tile buffer" . +There was insufficient memory to allocate an i/o buffer. +.PP +.BR "No space for strip buffer" . +There was insufficient memory to allocate an i/o buffer. +.PP +.BR "Can not handle format" . +The image has a format (combination of +.IR BitsPerSample , +.IR SamplesPerPixel , +and +.IR PhotometricInterpretation ) +that +.I TIFFReadRGBAImage +can not handle. +.PP +.BR "No space for B&W mapping table" . +There was insufficient memory to allocate a table used to map grayscale data +to +.SM RGB. +.PP +.BR "No space for Palette mapping table" . +There was insufficient memory to allocate a table used to map data to 8-bit +.SM RGB. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFRGBAImage (3TIFF), +.BR TIFFReadRGBAImage (3TIFF), +.BR TIFFReadRGBATile (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ + diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBATile.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBATile.3tiff new file mode 100644 index 000000000..5b9b4bf2f --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRGBATile.3tiff @@ -0,0 +1,170 @@ +.\" +.\" Copyright (c) 1991-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadRGBATile 3TIFF "December 10, 1998" "libtiff" +.SH NAME +TIFFReadRGBATile \- read and decode an image tile into a fixed-format raster +.SH SYNOPSIS +.B "#include " +.sp +.B "#define TIFFGetR(abgr) ((abgr) & 0xff)" +.br +.B "#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff)" +.br +.B "#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff)" +.br +.B "#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff)" +.sp +.BI "int TIFFReadRGBATile(TIFF *" tif ", uint32 " x ", uint32 " y ", uint32 *" raster ")" +.SH DESCRIPTION +.IR TIFFReadRGBATile +reads a single tile of a tile-based image into memory, storing the result in +the user supplied RGBA +.IR raster . +The raster is assumed to be an array of width times length 32-bit entries, +where width is the width of a tile (TIFFTAG_TILEWIDTH) and length is the +height of a tile (TIFFTAG_TILELENGTH). + +.PP +The +.IR x +and +.IR y +values are the offsets from the top left corner to the top left corner of the +tile to be read. They must be an exact multiple of the tile width and length. + +.PP +Note that the raster is assume to be organized such that the pixel at location +(\fIx\fP,\fIy\fP) is \fIraster\fP[\fIy\fP*\fIwidth\fP+\fIx\fP]; with the +raster origin in the +.I lower-left hand corner +of the tile. That is bottom to top organization. Edge tiles which partly fall +off the image will be filled out with appropriate zeroed areas. + +.PP +Raster pixels are 8-bit packed red, green, blue, alpha samples. The macros +.IR TIFFGetR , +.IR TIFFGetG , +.IR TIFFGetB , +and +.I TIFFGetA +should be used to access individual samples. Images without Associated Alpha +matting information have a constant Alpha of 1.0 (255). +.PP +See the +.IR TIFFRGBAImage (3TIFF) +page for more details on how various image types are converted to RGBA values. +.SH NOTES +Samples must be either 1, 2, 4, 8, or 16 bits. Colorimetric samples/pixel must +be either 1, 3, or 4 (i.e. +.I SamplesPerPixel +minus +.IR ExtraSamples ). +.PP +Palette image colormaps that appear to be incorrectly written as 8-bit values +are automatically scaled to 16-bits. +.PP +.I TIFFReadRGBATile +is just a wrapper around the more general +.IR TIFFRGBAImage (3TIFF) +facilities. It's main advantage over the similar +.IR TIFFReadRGBAImage() +function is that for large images a single buffer capable of holding the whole +image doesn't need to be allocated, only enough for one tile. The +.IR TIFFReadRGBAStrip() +function does a similar operation for stripped images. +.SH "RETURN VALUES" +1 is returned if the image was successfully read and converted. +Otherwise, 0 is returned if an error was encountered. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +.PP +.BR "Sorry, can not handle %d-bit pictures" . +The image had +.I BitsPerSample +other than 1, 2, 4, 8, or 16. +.PP +.BR "Sorry, can not handle %d-channel images" . +The image had +.I SamplesPerPixel +other than 1, 3, or 4. +.PP +\fBMissing needed "PhotometricInterpretation" tag\fP. +The image did not have a tag that describes how to display the data. +.PP +\fBNo "PhotometricInterpretation" tag, assuming RGB\fP. +The image was missing a tag that describes how to display it, but because it +has 3 or 4 samples/pixel, it is assumed to be +.SM RGB. +.PP +\fBNo "PhotometricInterpretation" tag, assuming min-is-black\fP. +The image was missing a tag that describes how to display it, +but because it has 1 sample/pixel, it is assumed to be a grayscale +or bilevel image. +.PP +.BR "No space for photometric conversion table" . +There was insufficient memory for a table used to convert +image samples to 8-bit +.SM RGB. +.PP +\fBMissing required "Colormap" tag\fP. +A Palette image did not have a required +.I Colormap +tag. +.PP +.BR "No space for tile buffer" . +There was insufficient memory to allocate an i/o buffer. +.PP +.BR "No space for strip buffer" . +There was insufficient memory to allocate an i/o buffer. +.PP +.BR "Can not handle format" . +The image has a format (combination of +.IR BitsPerSample , +.IR SamplesPerPixel , +and +.IR PhotometricInterpretation ) +that +.I TIFFReadRGBAImage +can not handle. +.PP +.BR "No space for B&W mapping table" . +There was insufficient memory to allocate a table used to map +grayscale data to +.SM RGB. +.PP +.BR "No space for Palette mapping table" . +There was insufficient memory to allocate a table used to map data to 8-bit +.SM RGB. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFRGBAImage (3TIFF), +.BR TIFFReadRGBAImage (3TIFF), +.BR TIFFReadRGBAStrip (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRawStrip.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRawStrip.3tiff new file mode 100644 index 000000000..dfd5a51f2 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRawStrip.3tiff @@ -0,0 +1,63 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadRawStrip 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFReadRawStrip \- return the undecoded contents of a strip of data from an +open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tsize_t TIFFReadRawStrip(TIFF *" tif ", tstrip_t " strip ", tdata_t " buf ", tsize_t " size ")" +.SH DESCRIPTION +Read the contents of the specified strip into the (user supplied) data buffer. +Note that the value of +.I strip +is a ``raw strip number.'' That is, the caller must take into account whether +or not the data is organized in separate planes (\c +.IR PlanarConfiguration =2). +To read a full strip of data the data buffer should typically be at least as +large as the number returned by +.IR TIFFStripSize . +.SH "RETURN VALUES" +The actual number of bytes of data that were placed in +.I buf +is returned; +.IR TIFFReadRawStrip +returns \-1 if an error was encountered. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFReadEncodedStrip (3TIFF), +.BR TIFFReadScanline (3TIFF), +.BR TIFFStripSize (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRawTile.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRawTile.3tiff new file mode 100644 index 000000000..9c60888a5 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadRawTile.3tiff @@ -0,0 +1,64 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadRawTile 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFReadRawTile \- return an undecoded tile of data from an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tsize_t TIFFReadRawTile(TIFF *" tif ", ttile_t " tile ", tdata_t " buf ", tsize_t " size ")" +.SH DESCRIPTION +Read the contents of the specified tile into the (user supplied) data buffer. +Note that the value of +.I tile +is a ``raw tile number.'' That is, the caller must take into account whether +or not the data is organized in separate planes (\c +.IR PlanarConfiguration =2). +.I TIFFComputeTile +automatically does this when converting an (x,y,z,sample) coordinate quadruple +to a tile number. To read a full tile of data the data buffer should typically +be at least as large as the value returned by +.IR TIFFTileSize . +.SH "RETURN VALUES" +The actual number of bytes of data that were placed in +.I buf +is returned; +.IR TIFFReadEncodedTile +returns \-1 if an error was encountered. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFReadEncodedTile (3TIFF), +.BR TIFFReadTile (3TIFF), +.BR TIFFTileSize (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadScanline.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadScanline.3tiff new file mode 100644 index 000000000..ca4b8368d --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadScanline.3tiff @@ -0,0 +1,93 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadScanline 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFReadScanline \- read and decode a scanline of data from an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFReadScanline(TIFF *" tif ", tdata_t " buf ", uint32 " row ", tsample_t " sample ")" +.SH DESCRIPTION +Read the data for the specified row into the (user supplied) data buffer +.IR buf . +The data are returned decompressed and, in the native byte- and bit-ordering, +but are otherwise packed (see further below). The buffer must be large enough +to hold an entire scanline of data. Applications should call the routine +.IR TIFFScanlineSize +to find out the size (in bytes) of a scanline buffer. +The +.I row +parameter is always used by +.IR TIFFReadScanline ; +the +.I sample +parameter is used only if data are organized in separate planes (\c +.IR PlanarConfiguration =2). +.SH NOTES +The library attempts to hide bit- and byte-ordering differences between the +image and the native machine by converting data to the native machine order. +Bit reversal is done if the +.I FillOrder +tag is opposite to the native machine bit order. 16- and 32-bit samples are +automatically byte-swapped if the file was written with a byte order opposite +to the native machine byte order, +.PP +In C++ the +.I sample +parameter defaults to 0. +.SH "RETURN VALUES" +.IR TIFFReadScanline +returns \-1 if it detects an error; otherwise 1 is returned. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +.PP +.BR "Compression algorithm does not support random access" . +Data was requested in a non-sequential order from a file that uses a +compression algorithm and that has +.I RowsPerStrip +greater than one. +That is, data in the image is stored in a compressed form, and with multiple +rows packed into a strip. In this case, the library does not support random +access to the data. The data should either be accessed sequentially, or the +file should be converted so that each strip is made up of one row of data. +.SH BUGS +Reading subsampled YCbCR data does not work correctly because, for +.IR PlanarConfiguration =2 +the size of a scanline is not calculated on a per-sample basis, and for +.IR PlanarConfiguration =1 +the library does not unpack the block-interleaved samples; use the strip- and +tile-based interfaces to read these formats. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFReadEncodedStrip (3TIFF), +.BR TIFFReadRawStrip (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFReadTile.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadTile.3tiff new file mode 100644 index 000000000..cf0f21dc7 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFReadTile.3tiff @@ -0,0 +1,83 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFReadTile 3TIFF "December 16, 1991" "libtiff" +.SH NAME +TIFFReadTile \- read and decode a tile of data from an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tsize_t TIFFReadTile(TIFF *" tif ", tdata_t " buf ", uint32 " x ", uint32 " y ", uint32 " z ", tsample_t " sample ")" +.SH DESCRIPTION +Return the data for the tile +.I containing +the specified coordinates. The data placed in +.I buf +are returned decompressed and, typically, in the native byte- and +bit-ordering, but are otherwise packed (see further below). The buffer must be +large enough to hold an entire tile of data. Applications should call the +routine +.IR TIFFTileSize +to find out the size (in bytes) of a tile buffer. The +.I x +and +.I y +parameters are always used by +.IR TIFFReadTile . +The +.I z +parameter is used if the image is deeper than 1 slice (\c +.IR ImageDepth >1). +The +.I sample +parameter is used only if data are organized in separate planes (\c +.IR PlanarConfiguration =2). +.SH NOTES +The library attempts to hide bit- and byte-ordering differences between the +image and the native machine by converting data to the native machine order. +Bit reversal is done if the +.I FillOrder +tag is opposite to the native machine bit order. 16- and 32-bit samples are +automatically byte-swapped if the file was written with a byte order opposite +to the native machine byte order, +.SH "RETURN VALUES" +.IR TIFFReadTile +returns \-1 if it detects an error; otherwise the number of bytes in the +decoded tile is returned. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.SH "SEE ALSO" +.BR TIFFCheckTile (3TIFF), +.BR TIFFComputeTile (3TIFF), +.BR TIFFOpen (3TIFF), +.BR TIFFReadEncodedTile (3TIFF), +.BR TIFFReadRawTile (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFSetDirectory.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFSetDirectory.3tiff new file mode 100644 index 000000000..734c0155e --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFSetDirectory.3tiff @@ -0,0 +1,78 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFSetDirectory 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFSetDirectory, TIFFSetSubDirectory \- set the current directory for an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFSetDirectory(TIFF *" tif ", tdir_t " dirnum ")" +.br +.BI "int TIFFSetSubDirectory(TIFF *" tif ", uint64 " diroff ")" +.SH DESCRIPTION +.I TIFFSetDirectory +changes the current directory and reads its contents with +.IR TIFFReadDirectory . +The parameter +.I dirnum +specifies the subfile/directory as an integer number, with the first directory +numbered zero. +.PP +.I TIFFSetSubDirectory +acts like +.IR TIFFSetDirectory , +except the directory is specified as a file offset instead of an index; this +is required for accessing subdirectories linked through a +.I SubIFD +tag. +.SH "RETURN VALUES" +On successful return 1 is returned. Otherwise, 0 is returned if +.I dirnum +or +.I diroff +specifies a non-existent directory, or if an error was encountered while +reading the directory's contents. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +.PP +.BR "%s: Error fetching directory count" . +An error was encountered while reading the ``directory count'' field. +.PP +.BR "%s: Error fetching directory link" . +An error was encountered while reading the ``link value'' that points to the +next directory in a file. +.SH "SEE ALSO" +.IR TIFFCurrentDirectory (3TIFF), +.IR TIFFOpen (3TIFF), +.IR TIFFReadDirectory (3TIFF), +.IR TIFFWriteDirectory (3TIFF), +.IR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFSetField.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFSetField.3tiff new file mode 100644 index 000000000..df2a5ea2e --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFSetField.3tiff @@ -0,0 +1,216 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFSetField 3TIFF "October 29, 2004" "libtiff" +.SH NAME +TIFFSetField, TIFFVSetField \- set the value(s) of a tag in a +.SM TIFF +file open for writing +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFSetField(TIFF *" tif ", ttag_t " tag ", " ... ")" +.sp +.B "#include " +.sp +.BI "int TIFFVSetField(TIFF *" tif ", ttag_t " tag ", va_list " ap ")" +.SH DESCRIPTION +.IR TIFFSetField +sets the value of a field +or pseudo-tag in the current directory associated with +the open +.SM TIFF +file +.IR tif . +(A +.I pseudo-tag +is a parameter that is used to control the operation of the +.SM TIFF +library but whose value is not read or written to the underlying file.) +To set the value of a field +the file must have been previously opened for writing with +.IR TIFFOpen (3TIFF); +pseudo-tags can be set whether the file was opened for reading +or writing. +The field is identified by +.IR tag , +one of the values defined in the include file +.B tiff.h +(see also the table below). +The actual value is specified using a variable argument list, +as prescribed by the +.IR stdarg (3) +interface (\c +or, on some machines, the +.IR varargs (3) +interface.) +.PP +.IR TIFFVSetField +is functionally equivalent to +.IR TIFFSetField +except that it takes a pointer to a variable +argument list. +.I TIFFVSetField +is useful for writing routines that are layered +on top of the functionality provided by +.IR TIFFSetField . +.PP +The tags understood by +.IR libtiff , +the number of parameter values, and the +expected types for the parameter values are shown below. +The data types are: +.I char* +is null-terminated string and corresponds to the +.SM ASCII +data type; +.I uint16 +is an unsigned 16-bit value; +.I uint32 +is an unsigned 32-bit value; +.I uint16* +is an array of unsigned 16-bit values. +.I void* +is an array of data values of unspecified type. + +Consult the +.SM TIFF +specification for information on the meaning of each tag. +.PP +.nf +.ta \w'TIFFTAG_CONSECUTIVEBADFAXLINES'u+2n +\w'Count'u+2n +\w'TIFFFaxFillFunc \(dg'u+2n +\fITag Name\fP \fICount\fP \fITypes\fP \fINotes\fP +.sp 5p +TIFFTAG_ARTIST 1 char* +TIFFTAG_BADFAXLINES 1 uint32 +TIFFTAG_BITSPERSAMPLE 1 uint16 \(dg +TIFFTAG_CLEANFAXDATA 1 uint16 +TIFFTAG_COLORMAP 3 uint16* 1< 0 +TIFFTAG_SAMPLEFORMAT 1 uint16 \(dg +TIFFTAG_SAMPLESPERPIXEL 1 uint16 \(dg value must be <= 4 +TIFFTAG_SMAXSAMPLEVALUE 1 double +TIFFTAG_SMINSAMPLEVALUE 1 double +TIFFTAG_SOFTWARE 1 char* +TIFFTAG_STONITS 1 double \(dg +TIFFTAG_SUBFILETYPE 1 uint32 +TIFFTAG_SUBIFD 2 uint16,uint64* count & offsets array +TIFFTAG_TARGETPRINTER 1 char* +TIFFTAG_THRESHHOLDING 1 uint16 +TIFFTAG_TILEDEPTH 1 uint32 \(dg +TIFFTAG_TILELENGTH 1 uint32 \(dg must be a multiple of 8 +TIFFTAG_TILEWIDTH 1 uint32 \(dg must be a multiple of 8 +TIFFTAG_TRANSFERFUNCTION 1 or 3\(dd uint16* 1<" +.sp +.BI "void TIFFWarning(const char *" module ", const char *" fmt ", " ... ")" +.sp +.B "#include " +.sp +.BI "typedef void (*TIFFWarningHandler)(const char *" module ", const char *" fmt ", va_list " ap ");" +.sp +.BI "TIFFWarningHandler TIFFSetWarningHandler(TIFFWarningHandler " handler ");" +.SH DESCRIPTION +.I TIFFWarning +invokes the library-wide warning handler function to (normally) write a +warning message to the +.BR stderr . +The +.I fmt +parameter is a +.IR printf (3S) +format string, and any number arguments can be supplied. The +.I module +parameter is interpreted as a string that, if non-zero, should be printed +before the message; it typically is used to identify the software module in +which a warning is detected. +.PP +Applications that desire to capture control in the event of a warning should +use +.IR TIFFSetWarningHandler +to override the default warning handler. +A +.SM NULL +(0) warning handler function may be installed to suppress error messages. +.SH "RETURN VALUES" +.IR TIFFSetWarningHandler +returns a reference to the previous error handling function. +.SH "SEE ALSO" +.BR TIFFError (3TIFF), +.BR libtiff (3TIFF), +.BR printf (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteDirectory.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteDirectory.3tiff new file mode 100644 index 000000000..e7b84b6d7 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteDirectory.3tiff @@ -0,0 +1,137 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFWriteDirectory 3TIFF "September 26, 2001" "libtiff" +.SH NAME +TIFFWriteDirectory, TIFFRewriteDirectory, TIFFCheckpointDirectory \- write the +current directory in an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFWriteDirectory(TIFF *" tif ")" +.br +.BI "int TIFFRewriteDirectory(TIFF *" tif ")" +.br +.BI "int TIFFCheckpointDirectory(TIFF *" tif ")" +.SH DESCRIPTION +.IR TIFFWriteDirectory +will write the contents of the current directory to the file and setup to +create a new subfile in the same file. Applications only need to call +.IR TIFFWriteDirectory +when writing multiple subfiles to a single +.SM TIFF +file. +.IR TIFFWriteDirectory +is automatically called by +.IR TIFFClose +and +.IR TIFFFlush +to write a modified directory if the file is open for writing. +.PP +The +.IR TIFFRewriteDirectory +function operates similarly to +.IR TIFFWriteDirectory, +but can be called with directories previously read or written that already +have an established location in the file. It will rewrite the directory, +but instead of place it at it's old location (as +.IR TIFFWriteDirectory +would) it will place them at the end of the file, correcting the pointer from +the preceding directory or file header to point to it's new location. This +is particularly important in cases where the size of the directory and +pointed to data has grown, so it won't fit in the space available at the +old location. +.PP +The +.IR TIFFCheckpointDirectory +writes the current state of the tiff directory into the file to make what +is currently in the file readable. Unlike +.IR TIFFWriteDirectory, +.IR TIFFCheckpointDirectory +does not free up the directory data structures in memory, so they can be +updated (as strips/tiles are written) and written again. Reading such +a partial file you will at worst get a tiff read error for the first +strip/tile encountered that is incomplete, but you will at least get +all the valid data in the file before that. When the file is complete, +just use +.IR TIFFWriteDirectory +as usual to finish it off cleanly. +.SH "RETURN VALUES" +1 is returned when the contents are successfully written to the file. +Otherwise, 0 is returned if an error was encountered when writing +the directory contents. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +.PP +.BR "Error post-encoding before directory write" . +Before writing the contents of the current directory, any pending data are +flushed. This message indicates that an error occurred while doing this. +.PP +.BR "Error flushing data before directory write" . +Before writing the contents of the current directory, any pending data are +flushed. This message indicates that an error occurred while doing this. +.PP +.BR "Cannot write directory, out of space" . +There was not enough space to allocate a temporary area for the directory that +was to be written. +.PP +.BR "Error writing directory count" . +A write error occurred when writing the count of fields in the directory. +.PP +.BR "Error writing directory contents" . +A write error occurred when writing the directory fields. +.PP +.BR "Error writing directory link" . +A write error occurred when writing the link to the next directory. +.PP +\fBError writing data for field "%s"\fP. +A write error occurred when writing indirect data for the specified field. +.PP +.BR "Error writing TIFF header" . +A write error occurred when re-writing header at the front of the file. +.PP +.BR "Error fetching directory count" . +A read error occurred when fetching the directory count field for +a previous directory. +This can occur when setting up a link to the directory that is being +written. +.PP +.BR "Error fetching directory link" . +A read error occurred when fetching the directory link field for +a previous directory. +This can occur when setting up a link to the directory that is being +written. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFError (3TIFF), +.BR TIFFReadDirectory (3TIFF), +.BR TIFFSetDirectory (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteEncodedStrip.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteEncodedStrip.3tiff new file mode 100644 index 000000000..dc410e415 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteEncodedStrip.3tiff @@ -0,0 +1,101 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFWriteEncodedStrip 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFWritedEncodedStrip \- compress and write a strip of data to an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tsize_t TIFFWriteEncodedStrip(TIFF *" tif ", tstrip_t " strip ", tdata_t " buf ", tsize_t " size ")" +.SH DESCRIPTION +Compress +.I size +bytes of raw data from +.I buf +and write the result to the specified strip; replacing any previously written +data. Note that the value of +.I strip +is a ``raw strip number.'' That is, the caller must take into account whether +or not the data are organized in separate planes (\c +.IR PlanarConfiguration =2). +.SH NOTES +The library writes encoded data using the native machine byte order. Correctly +implemented +.SM TIFF +readers are expected to do any necessary byte-swapping to correctly process +image data with BitsPerSample greater than 8. +.PP +The strip number must be valid according to the current settings of the +.I ImageLength +and +.I RowsPerStrip +tags. +An image may be dynamically grown by increasing the value of +.I ImageLength +prior to each call to +.IR TIFFWriteEncodedStrip . +.SH "RETURN VALUES" +\-1 is returned if an error was encountered. Otherwise, the value of +.IR size +is returned. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +.PP +\fB%s: File not open for writing\fP. The file was opened for reading, not +writing. +.PP +\fBCan not write scanlines to a tiled image\fP. The image is assumed to be +organized in tiles because the +.I TileWidth +and +.I TileLength +tags have been set with +.IR TIFFSetField (3TIFF). +.PP +\fB%s: Must set "ImageWidth" before writing data\fP. +The image's width has not be set before the first write. See +.IR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fB%s: Must set "PlanarConfiguration" before writing data\fP. +The organization of data has not be defined before the first write. See +.IR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fB%s: No space for strip arrays"\fP. +There was not enough space for the arrays that hold strip offsets and byte +counts. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFWriteScanline (3TIFF), +.BR TIFFWriteRawStrip (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteEncodedTile.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteEncodedTile.3tiff new file mode 100644 index 000000000..d94f4d0ed --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteEncodedTile.3tiff @@ -0,0 +1,95 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFWriteEncodedTile 3TIFF "December 16, 1991" "libtiff" +.SH NAME +TIFFWritedEncodedTile \- compress and write a tile of data to an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tsize_t TIFFWriteEncodedTile(TIFF *" tif ", ttile_t " tile ", tdata_t " buf ", tsize_t " size ")" +.SH DESCRIPTION +Compress +.I size +bytes of raw data from +.I buf +and +.B append +the result to the end of the specified tile. Note that the value of +.I tile +is a ``raw tile number.'' That is, the caller must take into account whether +or not the data are organized in separate places (\c +.IR PlanarConfiguration =2). +.IR TIFFComputeTile +automatically does this when converting an (x,y,z,sample) coordinate quadruple +to a tile number. +.SH NOTES +The library writes encoded data using the native machine byte order. Correctly +implemented +.SM TIFF +readers are expected to do any necessary byte-swapping to correctly process +image data with BitsPerSample greater than 8. +.SH "RETURN VALUES" +\-1 is returned if an error was encountered. Otherwise, the value of +.IR size +is returned. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.PP +\fB%s: File not open for writing\fP. +The file was opened for reading, not writing. +.PP +\fBCan not write tiles to a stripped image\fP. +The image is assumed to be organized in strips because neither of the +.I TileWidth +or +.I TileLength +tags have been set with +.BR TIFFSetField (3TIFF). +.PP +\fB%s: Must set "ImageWidth" before writing data\fP. The image's width has not +be set before the first write. See +.BR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fB%s: Must set "PlanarConfiguration" before writing data\fP. The organization +of data has not be defined before the first write. See +.BR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fB%s: No space for tile arrays"\fP. +There was not enough space for the arrays that hold tile offsets and byte +counts. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFWriteTile (3TIFF), +.BR TIFFWriteRawTile (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteRawStrip.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteRawStrip.3tiff new file mode 100644 index 000000000..784a6e031 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteRawStrip.3tiff @@ -0,0 +1,95 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFWriteRawstrip 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFWriteRawStrip \- write a strip of raw data to an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tsize_t TIFFWriteRawStrip(TIFF *" tif ", tstrip_t " strip ", tdata_t " buf ", tsize_t " size ")" +.SH DESCRIPTION +Append +.I size +bytes of raw data to the specified strip. +.SH NOTES +The strip number must be valid according to the current settings of the +.I ImageLength +and +.I RowsPerStrip +tags. +An image may be dynamically grown by increasing the value of +.I ImageLength +prior to each call to +.IR TIFFWriteRawStrip . +.SH "RETURN VALUES" +\-1 is returned if an error occurred. +Otherwise, the value of +.IR size +is returned. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.PP +\fB%s: File not open for writing\fP. +The file was opened for reading, not writing. +.PP +\fBCan not write scanlines to a tiled image\fP. The image is assumed to be +organized in tiles because the +.I TileWidth +and +.I TileLength +tags have been set with +.BR TIFFSetField (3TIFF). +.PP +\fB%s: Must set "ImageWidth" before writing data\fP. +The image's width has not be set before the first write. +See +.BR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fB%s: Must set "PlanarConfiguration" before writing data\fP. +The organization of data has not be defined before the first write. +See +.BR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fB%s: No space for strip arrays"\fP. +There was not enough space for the arrays that hold strip +offsets and byte counts. +.PP +\fB%s: Strip %d out of range, max %d\fP. +The specified strip is not a valid strip according to the +currently specified image dimensions. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFWriteEncodedStrip (3TIFF), +.BR TIFFWriteScanline (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteRawTile.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteRawTile.3tiff new file mode 100644 index 000000000..f3334b85b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteRawTile.3tiff @@ -0,0 +1,83 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFWriteRawtile 3TIFF "December 16, 1991" "libtiff" +.SH NAME +TIFFWriteRawTile \- write a tile of raw data to an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tsize_t TIFFWriteRawTile(TIFF *" tif ", ttile_t " tile ", tdata_t " buf ", tsize_t " size ")" +.SH DESCRIPTION +Append +.I size +bytes of raw data to the specified tile. +.SH "RETURN VALUES" +\-1 is returned if an error occurred. Otherwise, the value of +.IR size +is returned. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.PP +\fB%s: File not open for writing\fP. +The file was opened for reading, not writing. +.PP +\fBCan not write tiles to a stripped image\fP. +The image is assumed to be organized in strips because neither of the +.I TileWidth +or +.I TileLength +tags have been set with +.BR TIFFSetField (3TIFF). +.PP +\fB%s: Must set "ImageWidth" before writing data\fP. +The image's width has not be set before the first write. +See +.BR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fB%s: Must set "PlanarConfiguration" before writing data\fP. The organization +of data has not be defined before the first write. See +.BR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fB%s: No space for tile arrays"\fP. +There was not enough space for the arrays that hold tile offsets and byte +counts. +.PP +\fB%s: Specified tile %d out of range, max %d\fP. +The specified tile is not valid according to the currently specified image +dimensions. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFWriteEncodedTile (3TIFF), +.BR TIFFWriteScanline (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteScanline.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteScanline.3tiff new file mode 100644 index 000000000..a51cec529 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteScanline.3tiff @@ -0,0 +1,153 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFWriteScanline 3TIFF "December 16, 1991" "libtiff" +.SH NAME +TIFFWriteScanline \- write a scanline to an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFWriteScanline(TIFF *" tif ", tdata_t " buf ", uint32 " row ", tsample_t " sample ")" +.SH DESCRIPTION +Write data to a file at the specified row. The +.I sample +parameter is used only if data are organized in separate planes (\c +.IR PlanarConfiguration =2). +The data are assumed to be uncompressed and in the native bit- and byte-order +of the host machine. The data written to the file is compressed according to +the compression scheme of the current +.SM TIFF +directory (see further below). If the current scanline is past the end of the +current subfile, the +.I ImageLength +field is automatically increased to include the scanline (except +for +.IR PlanarConfiguration =2, +where the +.I ImageLength +cannot be changed once the first data are written). If the +.I ImageLength +is increased, the +.I StripOffsets +and +.I StripByteCounts +fields are similarly enlarged to reflect data written past the previous end of +image. +.SH NOTES +The library writes encoded data using the native machine byte order. Correctly +implemented +.SM TIFF +readers are expected to do any necessary byte-swapping to correctly process +image data with BitsPerSample greater than 8. The library attempts to hide +bit-ordering differences between the image and the native machine by +converting data from the native machine order. +.PP +In C++ the +.I sample +parameter defaults to 0. +.PP +Once data are written to a file for the current directory, the values of +certain tags may not be altered; see +.IR TIFFSetField (3TIFF) +for more information. +.PP +It is not possible to write scanlines to a file that uses a tiled +organization. The routine +.IR TIFFIsTiled +can be used to determine if the file is organized as tiles or strips. +.SH "RETURN VALUES" +.IR TIFFWriteScanline +returns \-1 if it immediately detects an error and 1 for a successful write. +.SH DIAGNOSTICS +All error messages are directed to the +.IR TIFFError (3TIFF) +routine. +.PP +.BR "%s: File not open for writing . +The file was opened for reading, not writing. +.PP +.BR "Can not write scanlines to a tiled image" . +An attempt was made to write a scanline to a tiled image. The image is assumed +to be organized in tiles because the +.I TileWidth +and +.I TileLength +tags have been set with +.IR TIFFSetField (3TIFF). +.PP +.BR "Compression algorithm does not support random access" . +Data was written in a non-sequential order to a file that uses a compression +algorithm and that has +.I RowsPerStrip +greater than one. That is, data in the image is to be stored in a compressed +form, and with multiple rows packed into a strip. In this case, the library +does not support random access to the data. The data should either be written +as entire strips, sequentially by rows, or the value of +.I RowsPerStrip +should be set to one. +.PP +\fB%s: Must set "ImageWidth" before writing data\fP. +The image's width has not be set before the first write. +See +.BR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fB%s: Must set "PlanarConfiguration" before writing data\fP. +The organization of data has not be defined before the first write. +See +.BR TIFFSetField (3TIFF) +for information on how to do this. +.PP +\fBCan not change "ImageLength" when using separate planes\fP. Separate image +planes are being used (\c +.IR PlanarConfiguration =2), +but the number of rows has not been specified before the first write. The +library supports the dynamic growth of an image only when data are organized +in a contiguous manner (\c +.IR PlanarConfiguration =1). +.PP +.BR "%d: Sample out of range, max %d" . +The +.I sample +parameter was greater than the value of the SamplesPerPixel tag. +.PP +.BR "%s: No space for strip arrays . +There was not enough space for the arrays that hold strip offsets and byte +counts. +.SH BUGS +Writing subsampled YCbCR data does not work correctly because, for +.IR PlanarConfiguration =2 +the size of a scanline is not calculated on a per-sample basis, and for +.IR PlanarConfiguration =1 +the library does not pack the block-interleaved samples. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFWriteEncodedStrip (3TIFF), +.BR TIFFWriteRawStrip (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteTile.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteTile.3tiff new file mode 100644 index 000000000..a6700258a --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFWriteTile.3tiff @@ -0,0 +1,76 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFWriteTile 3TIFF "November 29, 1999" "libtiff" +.SH NAME +TIFFWriteTile \- encode and write a tile of data to an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tsize_t TIFFWriteTile(TIFF *" tif ", tdata_t " buf ", uint32 " x ", uint32 " y ", uint32 " z ", tsample_t " sample ")" +.SH DESCRIPTION +Write the data for the tile +.I containing +the specified coordinates. The data in +.I buf +are is (potentially) compressed, and written to the indicated file, normally +being appended to the end of the file. The buffer must be contain an entire +tile of data. Applications should call the routine +.IR TIFFTileSize +to find out the size (in bytes) of a tile buffer. The +.I x +and +.I y +parameters are always used by +.IR TIFFWriteTile . +The +.I z +parameter is used if the image is deeper than 1 slice (\c +.IR ImageDepth >1). +The +.I sample +parameter is used only if data are organized in separate planes (\c +.IR PlanarConfiguration =2). +.SH "RETURN VALUES" +.IR TIFFWriteTile +returns \-1 if it detects an error; otherwise the number of bytes in the tile +is returned. +.SH DIAGNOSTICS +All error messages are directed to the +.BR TIFFError (3TIFF) +routine. +.SH "SEE ALSO" +.BR TIFFCheckTile (3TIFF), +.BR TIFFComputeTile (3TIFF), +.BR TIFFOpen (3TIFF), +.BR TIFFReadTile (3TIFF), +.BR TIFFWriteScanline (3TIFF), +.BR TIFFWriteEncodedTile (3TIFF), +.BR TIFFWriteRawTile (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFbuffer.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFbuffer.3tiff new file mode 100644 index 000000000..201117012 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFbuffer.3tiff @@ -0,0 +1,76 @@ +.\" +.\" Copyright (c) 1995 Sam Leffler +.\" Copyright (c) 1995 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFBUFFER 3TIFF "November 1, 2005" "libtiff" +.SH NAME +TIFFReadBufferSetup, TIFFWriteBufferSetup \- I/O buffering control routines +.SH SYNOPSIS +.nf +.B "#include " +.sp +.BI "int TIFFReadBufferSetup(TIFF *" tif ", tdata_t " buffer ", tsize_t " size ");" +.BI "int TIFFWriteBufferSetup(TIFF *" tif ", tdata_t " buffer ", tsize_t " size ");" +.fi +.SH DESCRIPTION +The following routines are provided for client-control of the I/O buffers used +by the library. Applications need never use these routines; they are provided +only for ``intelligent clients'' that wish to optimize memory usage and/or +eliminate potential copy operations that can occur when working with images +that have data stored without compression. +.PP +.I TIFFReadBufferSetup +sets up the data buffer used to read raw (encoded) data from a file. If the +specified pointer is +.SM NULL +(zero), then a buffer of the appropriate size is allocated. Otherwise the +caller must guarantee that the buffer is large enough to hold any individual +strip of raw data. +.I TIFFReadBufferSetup +returns a non-zero value if the setup was successful and zero otherwise. +.PP +.I TIFFWriteBufferSetup +sets up the data buffer used to write raw (encoded) data to a file. If the +specified +.I size +is \-1 then the buffer size is selected to hold a complete tile or strip, or +at least 8 kilobytes, whichever is greater. If the specified +.I buffer +is +.SM NULL +(zero), then a buffer of the appropriate size is dynamically allocated. +.I TIFFWriteBufferSetup +returns a non-zero value if the setup was successful and zero otherwise. +.SH DIAGNOSTICS +.BR "%s: No space for data buffer at scanline %ld" . +.I TIFFReadBufferSetup +was unable to dynamically allocate space for a data buffer. +.PP +.BR "%s: No space for output buffer" . +.I TIFFWriteBufferSetup +was unable to dynamically allocate space for a data buffer. +.SH "SEE ALSO" +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFcodec.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFcodec.3tiff new file mode 100644 index 000000000..aa3a8c63f --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFcodec.3tiff @@ -0,0 +1,81 @@ +.\" +.\" Copyright (c) 1995 Sam Leffler +.\" Copyright (c) 1995 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH CODEC 3TIFF "October 29, 2004" "libtiff" +.SH NAME +TIFFFindCODEC, TIFFRegisterCODEC, TIFFUnRegisterCODEC, TIFFIsCODECConfigured +\- codec-related utility routines +.SH SYNOPSIS +.B "#include " +.sp +.BI "const TIFFCodec* TIFFFindCODEC(uint16 " scheme ");" +.br +.BI "TIFFCodec* TIFFRegisterCODEC(uint16 " scheme ", const char *" method ", TIFFInitMethod " init ");" +.br +.BI "void TIFFUnRegisterCODEC(TIFFCodec *" codec ");" +.br +.BI "int TIFFIsCODECConfigured(uint16 " scheme ");" +.SH DESCRIPTION +.I libtiff +supports a variety of compression schemes implemented by software +.IR codecs . +Each codec adheres to a modular interface that provides for +the decoding and encoding of image data; as well as some other +methods for initialization, setup, cleanup, and the control +of default strip and tile sizes. +Codecs are identified by the associated value of the +.SM TIFF +.I Compression +tag; e.g. 5 for +.SM LZW +compression. +.PP +The +.I TIFFRegisterCODEC +routine can be used to +augment or override the set of codecs available to an application. +If the specified +.I scheme +already has a registered codec then it is +.I overridden +and any images with data encoded with this +compression scheme will be decoded using the supplied codec. +.PP +.I TIFFIsCODECConfigured +returns 1 if the codec is configured and working. Otherwise 0 will be returned. +.SH DIAGNOSTICS +.BR "No space to register compression scheme %s" . +.I TIFFRegisterCODEC +was unable to allocate memory for the data structures needed +to register a codec. +.PP +.BR "Cannot remove compression scheme %s; not registered" . +.I TIFFUnRegisterCODEC +did not locate the specified codec in the table of registered +compression schemes. +.SH "SEE ALSO" +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFcolor.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFcolor.3tiff new file mode 100644 index 000000000..1d2bb2b87 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFcolor.3tiff @@ -0,0 +1,267 @@ +.\" +.\" Copyright (c) 2003, Andrey Kiselev +.\" +.\" 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. +.\" +.if n .po 0 +.TH COLOR 3TIFF "December 21, 2003" "libtiff" +.SH NAME +TIFFYCbCrToRGBInit, TIFFYCbCrtoRGB, TIFFCIELabToRGBInit, TIFFCIELabToXYZ, +TIFFXYZToRGB \- color conversion routines. +.SH SYNOPSIS +.B "#include " +.sp +.BI "int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB *" ycbcr ", float *" luma ", float *"refBlackWhite" );" +.br +.BI "void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *" ycbcr ", uint32 " Y ", int32 " Cb ", int32 " Cr ", uint32 *" R ", uint32 *" G ", uint32 *" B " );" +.sp +.BI "int TIFFCIELabToRGBInit(TIFFCIELabToRGB *" cielab ", const TIFFDisplay *" display ", float *" refWhite ");" +.br +.BI "void TIFFCIELabToXYZ(TIFFCIELabToRGB *" cielab ", uint32 " L ", int32 " a ", int32 " b ", float *" X ", float *" Y ", float *" Z ");" +.br +.BI "void TIFFXYZToRGB(TIFFCIELabToRGB *" cielab ", float " X ", float " Y ", float " Z" , uint32 *" R ", uint32 *" G ", uint32 *" B ");" +.SH DESCRIPTION +TIFF supports several color spaces for images stored in that format. There is +usually a problem of application to handle the data properly and convert +between different colorspaces for displaying and printing purposes. To +simplify this task libtiff implements several color conversion routines +itself. In particular, these routines used in +.B TIFFRGBAImage(3TIFF) +interface. +.PP +.B TIFFYCbCrToRGBInit() +used to initialize +.I YCbCr +to +.I RGB +conversion state. Allocating and freeing of the +.I ycbcr +structure belongs to programmer. +.I TIFFYCbCrToRGB +defined in +.B tiffio.h +as +.PP +.RS +.nf +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; +} TIFFYCbCrToRGB; +.fi +.RE +.PP +.I luma +is a float array of three values representing proportions of the red, green +and blue in luminance, Y (see section 21 of the TIFF 6.0 specification, where +the YCbCr images discussed). +.I TIFFTAG_YCBCRCOEFFICIENTS +holds that values in TIFF file. +.I refBlackWhite +is a float array of 6 values which specifies a pair of headroom and footroom +image data values (codes) for each image component (see section 20 of the +TIFF 6.0 specification where the colorinmetry fields discussed). +.I TIFFTAG_REFERENCEBLACKWHITE +is responsible for storing these values in TIFF file. Following code snippet +should helps to understand the the technique: +.PP +.RS +.nf +float *luma, *refBlackWhite; +uint16 hs, vs; + +/* Initialize structures */ +ycbcr = (TIFFYCbCrToRGB*) + _TIFFmalloc(TIFFroundup(sizeof(TIFFYCbCrToRGB), sizeof(long)) + + 4*256*sizeof(TIFFRGBValue) + + 2*256*sizeof(int) + + 3*256*sizeof(int32)); +if (ycbcr == NULL) { + TIFFError("YCbCr->RGB", + "No space for YCbCr->RGB conversion state"); + exit(0); +} + +TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &luma); +TIFFGetFieldDefaulted(tif, TIFFTAG_REFERENCEBLACKWHITE, &refBlackWhite); +if (TIFFYCbCrToRGBInit(ycbcr, luma, refBlackWhite) < 0) + exit(0); + +/* Start conversion */ +uint32 r, g, b; +uint32 Y; +int32 Cb, Cr; + +for each pixel in image + TIFFYCbCrtoRGB(img->ycbcr, Y, Cb, Cr, &r, &g, &b); + +/* Free state structure */ +_TIFFfree(ycbcr); +.fi +.RE +.PP + +.PP +.B TIFFCIELabToRGBInit() +initializes the +.I CIE L*a*b* 1976 +to +.I RGB +conversion state. +.B TIFFCIELabToRGB +defined as +.PP +.RS +.nf +#define CIELABTORGB_TABLE_RANGE 1500 + +typedef struct { /* CIE Lab 1976->RGB support */ + int range; /* Size of conversion table */ + float rstep, gstep, bstep; + float X0, Y0, Z0; /* Reference white point */ + TIFFDisplay display; + float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ + float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ + float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ +} TIFFCIELabToRGB; +.fi +.RE +.PP +.I display +is a display device description, declared as +.PP +.RS +.nf +typedef struct { + float d_mat[3][3]; /* XYZ -> luminance matrix */ + float d_YCR; /* Light o/p for reference white */ + float d_YCG; + float d_YCB; + uint32 d_Vrwr; /* Pixel values for ref. white */ + uint32 d_Vrwg; + uint32 d_Vrwb; + float d_Y0R; /* Residual light for black pixel */ + float d_Y0G; + float d_Y0B; + float d_gammaR; /* Gamma values for the three guns */ + float d_gammaG; + float d_gammaB; +} TIFFDisplay; +.fi +.RE +.PP +For example, the one can use sRGB device, which has the following parameters: +.PP +.RS +.nf +TIFFDisplay display_sRGB = { + { /* XYZ -> luminance matrix */ + { 3.2410F, -1.5374F, -0.4986F }, + { -0.9692F, 1.8760F, 0.0416F }, + { 0.0556F, -0.2040F, 1.0570F } + }, + 100.0F, 100.0F, 100.0F, /* Light o/p for reference white */ + 255, 255, 255, /* Pixel values for ref. white */ + 1.0F, 1.0F, 1.0F, /* Residual light o/p for black pixel */ + 2.4F, 2.4F, 2.4F, /* Gamma values for the three guns */ +}; +.fi +.RE +.PP +.I refWhite +is a color temperature of the reference white. The +.I TIFFTAG_WHITEPOINT +contains the chromaticity of the white point of the image from where the +reference white can be calculated using following formulae: +.PP +.RS +refWhite_Y = 100.0 +.br +refWhite_X = whitePoint_x / whitePoint_y * refWhite_Y +.br +refWhite_Z = (1.0 - whitePoint_x - whitePoint_y) / whitePoint_y * refWhite_X +.br +.RE +.PP +The conversion itself performed in two steps: at the first one we will convert +.I CIE L*a*b* 1976 +to +.I CIE XYZ +using +.B TIFFCIELabToXYZ() +routine, and at the second step we will convert +.I CIE XYZ +to +.I RGB +using +.B TIFFXYZToRGB(). +Look at the code sample below: +.PP +.RS +.nf +float *whitePoint; +float refWhite[3]; + +/* Initialize structures */ +img->cielab = (TIFFCIELabToRGB *) + _TIFFmalloc(sizeof(TIFFCIELabToRGB)); +if (!cielab) { + TIFFError("CIE L*a*b*->RGB", + "No space for CIE L*a*b*->RGB conversion state."); + exit(0); +} + +TIFFGetFieldDefaulted(tif, TIFFTAG_WHITEPOINT, &whitePoint); +refWhite[1] = 100.0F; +refWhite[0] = whitePoint[0] / whitePoint[1] * refWhite[1]; +refWhite[2] = (1.0F - whitePoint[0] - whitePoint[1]) + / whitePoint[1] * refWhite[1]; +if (TIFFCIELabToRGBInit(cielab, &display_sRGB, refWhite) < 0) { + TIFFError("CIE L*a*b*->RGB", + "Failed to initialize CIE L*a*b*->RGB conversion state."); + _TIFFfree(cielab); + exit(0); +} + +/* Now we can start to convert */ +uint32 r, g, b; +uint32 L; +int32 a, b; +float X, Y, Z; + +for each pixel in image + TIFFCIELabToXYZ(cielab, L, a, b, &X, &Y, &Z); + TIFFXYZToRGB(cielab, X, Y, Z, &r, &g, &b); + +/* Don't forget to free the state structure */ +_TIFFfree(cielab); +.fi +.RE +.PP +.SH "SEE ALSO" +.BR TIFFRGBAImage (3TIFF) +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFmemory.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFmemory.3tiff new file mode 100644 index 000000000..70a821238 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFmemory.3tiff @@ -0,0 +1,89 @@ +.\" +.\" Copyright (c) 1995 Sam Leffler +.\" Copyright (c) 1995 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH MEMORY 3TIFF "October 15, 1995" "libtiff" +.SH NAME +_TIFFmalloc, \c +_TIFFrealloc, \c +_TIFFfree, \c +_TIFFmemset, \c +_TIFFmemcpy, \c +_TIFFmemcmp, \c +\- memory management-related functions for use with +.SM TIFF +files +.SH SYNOPSIS +.B "#include " +.sp +.BI "tdata_t _TIFFmalloc(tsize_t " size ");" +.br +.BI "tdata_t _TIFFrealloc(tdata_t " buffer ", tsize_t " size ");" +.br +.BI "void _TIFFfree(tdata_t " buffer ");" +.br +.BI "void _TIFFmemset(tdata_t " s ", int " c ", tsize_t " n ");" +.br +.BI "void _TIFFmemcpy(tdata_t " dest ", const tdata_t " src ", tsize_t " n ");" +.br +.BI "int _TIFFmemcmp(const tdata_t " s1 ", const tdata_t "s2 ", tsize_t " n ");" +.SH DESCRIPTION +These routines are provided for writing portable software that uses +.IR libtiff ; +they hide any memory-management related issues, such as dealing with segmented +architectures found on 16-bit machines. +.PP +.I _TIFFmalloc +and +.I _TIFFrealloc +are used to dynamically allocate and reallocate memory used by +.IR libtiff ; +such as memory passed into the I/O routines. Memory allocated through these +interfaces is released back to the system using the +.I _TIFFfree +routine. +.PP +Memory allocated through one of the above interfaces can be set to a known +value using +.IR _TIFFmemset , +copied to another memory location using +.IR _TIFFmemcpy , +or compared for equality using +.IR _TIFFmemcmp . +These routines conform to the equivalent +.SM ANSI +C routines: +.IR memset , +.IR memcpy , +and +.IR memcmp , +respectively. +.SH DIAGNOSTICS +None. +.SH "SEE ALSO" +.BR malloc (3), +.BR memory (3), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFquery.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFquery.3tiff new file mode 100644 index 000000000..4d95f5f45 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFquery.3tiff @@ -0,0 +1,141 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH QUERY 3TIFF "October 29, 2004" "libtiff" +.SH NAME +TIFFCurrentRow, +TIFFCurrentStrip, +TIFFCurrentTile, +TIFFCurrentDirectory, +TIFFLastDirectory, +TIFFFileno, +TIFFFileName, +TIFFGetMode, +TIFFIsTiled, +TIFFIsByteSwapped, +TIFFIsUpSampled, +TIFFIsMSB2LSB, +TIFFGetVersion +\- query routines +.SH SYNOPSIS +.B "#include " +.sp +.BI "uint32 TIFFCurrentRow(TIFF* " tif ")" +.br +.BI "tstrip_t TIFFCurrentStrip(TIFF* " tif ")" +.br +.BI "ttile_t TIFFCurrentTile(TIFF* " tif ")" +.br +.BI "tdir_t TIFFCurrentDirectory(TIFF* " tif ")" +.br +.BI "int TIFFLastDirectory(TIFF* " tif ")" +.br +.BI "int TIFFFileno(TIFF* " tif ")" +.br +.BI "char* TIFFFileName(TIFF* " tif ")" +.br +.BI "int TIFFGetMode(TIFF* " tif ")" +.br +.BI "int TIFFIsTiled(TIFF* " tif ")" +.br +.BI "int TIFFIsByteSwapped(TIFF* " tif ")" +.br +.BI "int TIFFIsUpSampled(TIFF* " tif ")" +.br +.BI "int TIFFIsMSB2LSB(TIFF* " tif ")" +.br +.BI "const char* TIFFGetVersion(void)" +.SH DESCRIPTION +The following routines return status information about an open +.SM TIFF +file. +.PP +.IR TIFFCurrentDirectory +returns the index of the current directory (directories are numbered starting +at 0). This number is suitable for use with the +.IR TIFFSetDirectory +routine. +.PP +.IR TIFFLastDirectory +returns a non-zero value if the current directory is the last directory in the +file; otherwise zero is returned. +.PP +.IR TIFFCurrentRow , +.IR TIFFCurrentStrip , +and +.IR TIFFCurrentTile , +return the current row, strip, and tile, respectively, that is being read or +written. These values are updated each time a read or write is done. +.PP +.IR TIFFFileno +returns the underlying file descriptor used to access the +.SM TIFF +image in the filesystem. +.PP +.IR TIFFFileName +returns the pathname argument passed to +.IR TIFFOpen +or +.IR TIFFFdOpen . +.PP +.IR TIFFGetMode +returns the mode with which the underlying file was opened. On +.SM UNIX +systems, this is the value passed to the +.IR open (2) +system call. +.PP +.IR TIFFIsTiled +returns a non-zero value if the image data has a tiled organization. Zero is +returned if the image data is organized in strips. +.PP +.IR TIFFIsByteSwapped +returns a non-zero value if the image data was in a different byte-order than +the host machine. Zero is returned if the TIFF file and local host byte-orders +are the same. Note that TIFFReadTile(), TIFFReadEncodedStrip() and +TIFFReadScanline() functions already normally perform byte swapping to local +host order if needed. +.PP +.I TIFFIsUpSampled +returns a non-zero value if image data returned through the read interface +routines is being up-sampled. This can be useful to applications that want to +calculate I/O buffer sizes to reflect this usage (though the usual strip and +tile size routines already do this). +.PP +.I TIFFIsMSB2LSB +returns a non-zero value if the image data is being returned with bit 0 as the +most significant bit. +.PP +.IR TIFFGetVersion +returns an +.SM ASCII +string that has a version stamp for the +.SM TIFF +library software. +.SH DIAGNOSTICS +None. +.SH "SEE ALSO" +.IR libtiff (3TIFF), +.IR TIFFOpen (3TIFF), +.IR TIFFFdOpen (3TIFF) diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFsize.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFsize.3tiff new file mode 100644 index 000000000..5fbc6bc99 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFsize.3tiff @@ -0,0 +1,58 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFSIZE 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFScanlineSize, TIFFRasterScanlineSize, +\- return the size of various items associated with an open +.SM TIFF +file +.SH SYNOPSIS +.B "#include " +.sp +.BI "tsize_t TIFFRasterScanlineSize(TIFF *" tif ")" +.br +.BI "tsize_t TIFFScanlineSize(TIFF *" tif ")" +.SH DESCRIPTION +.I TIFFScanlineSize +returns the size in bytes of a row of data as it would be returned in a call +to +.IR TIFFReadScanline , +or as it would be expected in a call to +.IR TIFFWriteScanline . +.PP +.I TIFFRasterScanlineSize +returns the size in bytes of a complete decoded and packed raster scanline. +Note that this value may be different from the value returned by +.I TIFFScanlineSize +if data is stored as separate planes. +.SH DIAGNOSTICS +None. +.SH "SEE ALSO" +.BR TIFFOpen (3TIFF), +.BR TIFFReadScanline (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFstrip.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFstrip.3tiff new file mode 100644 index 000000000..ce3f718c1 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFstrip.3tiff @@ -0,0 +1,98 @@ +.\" +.\" Copyright (c) 1992-1997 Sam Leffler +.\" Copyright (c) 1992-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFSTRIP 3TIFF "October 15, 1995" "libtiff" +.SH NAME +TIFFDefaultStripSize, TIFFStripSize, TIFFVStripSize, TIFFRawStripSize, +TIFFComputeStrip, TIFFNumberOfStrips \- strip-related utility routines +.SH SYNOPSIS +.B "#include " +.sp +.BI "uint32 TIFFDefaultStripSize(TIFF *" tif ", uint32 " estimate ")" +.br +.BI "tmsize_t TIFFStripSize(TIFF *" tif ")" +.br +.BI "tmsize_t TIFFVStripSize(TIFF *" tif ", uint32 " nrows ")" +.br +.BI "tmsize_t TIFFRawStripSize(TIFF *" tif ", uint32 " strip ")" +.br +.BI "tstrip_t TIFFComputeStrip(TIFF *" tif ", uint32 " row ", tsample_t " sample ")" +.br +.BI "tstrip_t TIFFNumberOfStrips(TIFF *" tif ")" +.SH DESCRIPTION +.I TIFFDefaultStripSize +returns the number of rows for a reasonable-sized strip according to the +current settings of the +.IR ImageWidth , +.IR BitsPerSample , +.IR SamplesPerPixel , +tags and any compression-specific requirements. If the +.I estimate +parameter, if non-zero, then it is taken as an estimate of the desired strip +size and adjusted according to any compression-specific requirements. The +value returned by this function is typically used to define the +.I RowsPerStrip +tag. In lieu of any unusual requirements +.I TIFFDefaultStripSize +tries to create strips that have approximately +8 kilobytes of uncompressed data. +.PP +.IR TIFFStripSize +returns the equivalent size for a strip of data as it would be returned in a +call to +.IR TIFFReadEncodedStrip +or as it would be expected in a call to +.IR TIFFWriteEncodedStrip . +.PP +.I TIFFVStripSize +returns the number of bytes in a strip with +.I nrows +rows of data. +.PP +.I TIFFRawStripSize +returns the number of bytes in a raw strip (i.e. not decoded). +.PP +.IR TIFFComputeStrip +returns the strip that contains the specified coordinates. A valid strip is +always returned; out-of-range coordinate values are clamped to the bounds of +the image. The +.I row +parameter is always used in calculating a strip. The +.I sample +parameter is used only if data are organized in separate planes (\c +.IR PlanarConfiguration =2). +.PP +.IR TIFFNumberOfStrips +returns the number of strips in the image. +.SH DIAGNOSTICS +None. +.SH "SEE ALSO" +.BR TIFFReadEncodedStrip (3TIFF), +.BR TIFFReadRawStrip (3TIFF), +.BR TIFFWriteEncodedStrip (3TIFF), +.BR TIFFWriteRawStrip (3TIFF), +.BR libtiff (3TIFF), +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFswab.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFswab.3tiff new file mode 100644 index 000000000..3d7a47bc0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFswab.3tiff @@ -0,0 +1,79 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH SWAB 3TIFF "November 04, 2004" "libtiff" +.SH NAME +TIFFGetBitRevTable, TIFFReverseBits, TIFFSwabShort, TIFFSwabLong, +TIFFSwabArrayOfShort, TIFFSwabArrayOfLong \- byte- and bit-swapping routines +.SH SYNOPSIS +.B "#include " +.sp +.BI "const unsigned char* TIFFGetBitRevTable(int " reversed ")" +.br +.BI "void TIFFReverseBits(u_char *" data ", unsigned long " nbytes ")" +.br +.BI "void TIFFSwabShort(uint16 *" data ")" +.br +.BI "void TIFFSwabLong(uint32 *" data ")" +.br +.BI "void TIFFSwabArrayOfShort(uint16 *" data ", unsigned long " nshorts ")" +.br +.BI "void TIFFSwabArrayOfLong(uint32 *" data ", unsigned long " nlongs ")" +.SH DESCRIPTION +The following routines are used by the library to swap +16- and 32-bit data and to reverse the order of bits in bytes. +.PP +.IR TIFFSwabShort +and +.IR TIFFSwabLong +swap the bytes in a single 16-bit and 32-bit item, respectively. +.IR TIFFSwabArrayOfShort +and +.IR TIFFSwabArrayOfLong +swap the bytes in an array of 16-bit and 32-bit items, respectively. +.PP +.IR TIFFReverseBits +replaces each byte in +.I data +with the equivalent bit-reversed value. This operation is performed with a +lookup table, which is returned using the +.IR TIFFGetBitRevTable +function. +.I reversed +parameter specifies which table should be returned. Supply +.I 1 +if you want bit reversal table. Supply +.I 0 +to get the table that do not reverse bit values. It is a lookup table that can +be used as an +.IR "identity function" ; +i.e. +.IR "TIFFNoBitRevTable[n] == n" . +.SH DIAGNOSTICS +None. +.SH "SEE ALSO" +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/TIFFtile.3tiff b/thirdparty/SDL2_image/external/libtiff/man/TIFFtile.3tiff new file mode 100644 index 000000000..10310a063 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/TIFFtile.3tiff @@ -0,0 +1,130 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFTILE 3TIFF "February 14, 1992" "libtiff" +.SH NAME +TIFFTileSize, TIFFTileRowSize, TIFFVTileSize, TIFFDefaultTileSize, +TIFFComputeTile, TIFFCheckTile, TIFFNumberOfTiles \- tile-related utility +routines +.SH SYNOPSIS +.B "#include " +.sp +.BI "void TIFFDefaultTileSize(TIFF *" tif ", uint32 *" tw ", uint32 *" th ")" +.br +.BI "tsize_t TIFFTileSize(TIFF *" tif ")" +.br +.BI "tsize_t TIFFTileRowSize(TIFF *" tif ")" +.br +.BI "tsize_t TIFFVTileSize(TIFF *" tif ", uint32 " nrows ")" +.br +.BI "ttile_t TIFFComputeTile(TIFF *" tif ", uint32 " x ", uint32 " y ", uint32 " z ", tsample_t " sample ")" +.br +.BI "int TIFFCheckTile(TIFF *" tif ", uint32 " x ", uint32 " y ", uint32 " z ", tsample_t " sample ")" +.br +.BI "ttile_t TIFFNumberOfTiles(TIFF *" tif ")" +.br +.SH DESCRIPTION +.I TIFFDefaultTileSize +returns the pixel width and height of a reasonable-sized tile; suitable for +setting up the +.I TileWidth +and +.I TileLength +tags. +If the +.I tw +and +.I th +values passed in are non-zero, then they are adjusted to reflect any +compression-specific requirements. The returned width and height are +constrained to be a multiple of 16 pixels to conform with the +.SM TIFF +specification. +.PP +.I TIFFTileSize +returns the equivalent size for a tile of data as it would be returned in a +call to +.I TIFFReadTile +or as it would be expected in a call to +.IR TIFFWriteTile . +.PP +.I TIFFVTileSize +returns the number of bytes in a row-aligned tile with +.I nrows +of data. +.PP +.I TIFFTileRowSize +returns the number of bytes of a row of data in a tile. +.PP +.IR TIFFComputeTile +returns the tile that contains the specified coordinates. A valid tile is +always returned; out-of-range coordinate values are clamped to the bounds of +the image. The +.I x +and +.I y +parameters are always used in calculating a tile. The +.I z +parameter is used if the image is deeper than 1 slice (\c +.IR ImageDepth >1). +The +.I sample +parameter is used only if data are organized in separate planes (\c +.IR PlanarConfiguration =2). +.PP +.IR TIFFCheckTile +returns a non-zero value if the supplied coordinates are within the bounds of +the image and zero otherwise. The +.I x +parameter is checked against the value of the +.I ImageWidth +tag. The +.I y +parameter is checked against the value of the +.I ImageLength +tag. The +.I z +parameter is checked against the value of the +.I ImageDepth +tag (if defined). The +.I sample +parameter is checked against the value of the +.I SamplesPerPixel +parameter if the data are organized in separate planes. +.PP +.IR TIFFNumberOfTiles +returns the number of tiles in the image. +.SH DIAGNOSTICS +None. +.SH "SEE ALSO" +.BR TIFFReadEncodedTile (3TIFF), +.BR TIFFReadRawTile (3TIFF), +.BR TIFFReadTile (3TIFF), +.BR TIFFWriteEncodedTile (3TIFF), +.BR TIFFWriteRawTile (3TIFF), +.BR TIFFWriteTile (3TIFF), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/fax2ps.1 b/thirdparty/SDL2_image/external/libtiff/man/fax2ps.1 new file mode 100644 index 000000000..7aeea4f90 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/fax2ps.1 @@ -0,0 +1,158 @@ +.\" +.\" Copyright (c) 1991-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.ds Ps PostScript +.if n .po 0 +.TH FAX2PS 1 "November 2, 2005" "libtiff" +.SH NAME +fax2ps \- convert a +.SM TIFF +facsimile to compressed \*(Ps\(tm +.SH SYNOPSIS +.B fax2ps +[ +.I options +] [ +.I file ...\& +] +.SH DESCRIPTION +.I fax2ps +reads one or more +.SM TIFF +facsimile image files and prints a compressed form of +\*(Ps on the standard output that is suitable for printing. +.PP +By default, each page is scaled to reflect the +image dimensions and resolutions stored in the file. +The +.B \-x +and +.B \-y +options can be used to specify the horizontal and vertical +image resolutions (lines/inch), respectively. +If the +.B \-S +option is specified, each page is scaled to fill an output page. +The default output page is 8.5 by 11 inches. +Alternate page dimensions can be specified in inches with the +.B \-W +and +.B \-H +options. +.PP +By default +.I fax2ps +generates \*(Ps for all pages in the file. +The +.B \-p +option can be used to select one or more pages from +a multi-page document. +.PP +.I fax2ps +generates a compressed form of \*(Ps that is +optimized for sending pages of text to a \*(Ps +printer attached to a host through a low-speed link (such +as a serial line). +Each output page is filled with white and then only +the black areas are drawn. +The \*(Ps specification of the black drawing operations +is optimized by using a special font that encodes the +move-draw operations required to fill +the black regions on the page. +This compression scheme typically results in a substantially +reduced \*(Ps description, relative to the straightforward +imaging of the page with a \*(Ps +.I image +operator. +This algorithm can, however, be ineffective +for continuous-tone and white-on-black images. +For these images, it sometimes is more efficient to send +the raster bitmap image directly; see +.BR tiff2ps (1). +.SH OPTIONS +.TP 10 +.BI \-p " number" +Print only the indicated page. +Multiple pages may be printed by specifying +this option more than once. +.TP 10 +.BI \-x " resolution" +Use +.I resolution +as the horizontal resolution, in dots/inch, of the image data. +By default this value is taken from the file. +.TP 10 +.BI \-y " resolution" +Use +.I resolution +as the vertical resolution, in lines/inch, of the image data. +By default this value is taken from the file. +.TP 10 +.B \-S +Scale each page of image data to fill the output page dimensions. +By default images are presented according to the dimension +information recorded in the +.SM TIFF +file. +.TP 10 +.BI \-W " width" +Use +.I width +as the width, in inches, of the output page. +.TP 10 +.BI \-H " height" +Use +.I height +as the height, in inches, of the output page. +.SH DIAGNOSTICS +Some messages about malformed +.SM TIFF +images come from the +.SM TIFF +library. +.PP +Various messages about badly formatted facsimile images +may be generated due to transmission errors in received +facsimile. +.I fax2ps +attempts to recover from such data errors by resynchronizing +decoding at the end of the current scanline. +This can result in long horizontal black lines in the resultant +\*(Ps image. +.SH NOTES +If the destination printer supports \*(Ps Level II then +it is always faster to just send the encoded bitmap generated +by the +.BR tiff2ps (1) +program. +.SH BUGS +.I fax2ps +should probably figure out when it is doing a poor +job of compressing the output and just generate +\*(Ps to image the bitmap raster instead. +.SH "SEE ALSO" +.BR tiff2ps (1), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/fax2tiff.1 b/thirdparty/SDL2_image/external/libtiff/man/fax2tiff.1 new file mode 100644 index 000000000..97144c9f5 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/fax2tiff.1 @@ -0,0 +1,285 @@ +.\" +.\" Copyright (c) 1990-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH FAX2TIFF 1 "November 2, 2005" "libtiff" +.SH NAME +fax2tiff \- create a +.SM TIFF +Class F fax file from raw fax data +.SH SYNOPSIS +.B fax2tiff +[ +.I options +] [ +.B \-o +.I output.tif +] +.I input.raw +.SH DESCRIPTION +.I Fax2tiff +creates a +.SM TIFF +file containing +.SM CCITT +Group 3 or Group 4 encoded data from one or more files containing ``raw'' +Group 3 or Group 4 encoded data (typically obtained directly from a fax modem). +By default, each row of data in the resultant +.SM TIFF +file is 1-dimensionally encoded and +padded or truncated to 1728 pixels, as needed. +The resultant image is a set of low resolution (98 lines/inch) +or medium resolution (196 lines/inch) +pages, each of which is a single strip of data. +The generated file conforms to the +.SM TIFF +Class F (\c +.SM FAX\c +) specification for storing facsimile data. +This means, in particular, that each page of the data does +.B not +include the trailing +.I "return to control" +(\c +.SM RTC\c +) code; as required +for transmission by the +.SM CCITT +Group 3 specifications. +The old, ``classic'', format is created if the +.B \-c +option is used. +(The Class F format can also be requested with the +.B \-f +option.) +.PP +The default name of the output image is +.IR fax.tif ; +this can be changed with the +.B \-o +option. +Each input file is assumed to be a separate page of facsimile data +from the same document. +The order in which input files are specified on the command +line is the order in which the resultant pages appear in the +output file. +.SH OPTIONS +Options that affect the interpretation of input data are: +.TP +.B \-3 +Assume input data is +.SM CCITT +Group 3 encoded (default). +.TP +.B \-4 +Assume input data is +.SM CCITT +Group 4 encoded. +.TP +.B \-U +Assume input data is uncompressed (Group 3 or Group 4). +.TP +.B \-1 +Assume input data is encoded with the 1-dimensional version of the +.SM CCITT +Group 3 Huffman encoding algorithm (default). +.TP +.B \-2 +Assume input data is 2-dimensional version of the +.SM CCITT +Group 3 Huffman encoding algorithm. +.TP +.B \-P +Assume input data is +.B not +EOL-aligned (default). This option has effect with Group 3 encoded input only. +.TP +.B \-A +Assume input data is EOL-aligned. This option has effect with Group 3 +encoded input only. +.TP +.B \-M +Treat input data as having bits filled from most significant bit (\c +.SM MSB\c +) to most least bit (\c +.SM LSB\c +). +.TP +.B \-L +Treat input data as having bits filled from least significant bit (\c +.SM LSB\c +) to most significant bit (\c +.SM MSB\c +) (default). +.TP +.B \-B +Assume input data was encoded with black as 0 and white as 1. +.TP +.B \-W +Assume input data was encoded with black as 1 and white as 0 (default). +.TP +.B \-R +Specify the vertical resolution, in lines/inch, of the input images. +By default input are assumed to have a vertical resolution of 196 lines/inch. +If images are low resolution facsimile, a value of 98 lines/inch should +be specified. +.TP +.B \-X +Specify the width, in pixels, of the input images. +By default input are assumed to have a width of 1728 pixels. +.PP +Options that affect the output file format are: +.TP +.B \-o +Specify the name of the output file. +.TP +.B \-7 +Force output to be compressed with the +.SM CCITT +Group 3 Huffman encoding algorithm (default). +.TP +.B \-8 +Force output to be compressed with the +.SM CCITT +Group 4 Huffman encoding. +.TP +.B \-u +Force output to be uncompressed (Group 3 or Group 4). +.TP +.B \-5 +Force output to be encoded with the 1-dimensional version of the +.SM CCITT +Group 3 Huffman encoding algorithm. +.TP +.B \-6 +Force output to be encoded with the 2-dimensional version of the +.SM CCITT +Group 3 Huffman encoding algorithm (default). +.TP +.B \-a +Force the last bit of each +.I "End Of Line" +(\c +.SM EOL\c +) code to land on a byte boundary (default). This ``zero padding'' will +be reflected in the contents of the +.I Group3Options +tag of the resultant +.SM TIFF +file. This option has effect with Group 3 encoded output only. +.TP +.B \-p +Do not EOL-align output. This option has effect with Group 3 encoded +output only. +.TP +.B \-c +Generate "classic" Group 3 TIFF format. +.TP +.B \-f +Generate TIFF Class F (TIFF/F) format (default). +.TP +.B \-m +Force output data to have bits filled from most significant bit (\c +.SM MSB\c +) to most least bit (\c +.SM LSB\c +). +.TP +.B \-l +Force output data to have bits filled from least significant bit (\c +.SM LSB\c +) to most significant bit (\c +.SM MSB\c +) (default). +.TP +.B \-r +Specify the number of rows (scanlines) in each strip of data +written to the output file. +By default (or when value +.B 0 +is specified), +.I tiffcp +attempts to set the rows/strip +that no more than 8 kilobytes of data appear in a strip (with except of G3/G4 +compression schemes). If you specify special value +.B \-1 +it will results in infinite number of the rows per strip. The entire image +will be the one strip in that case. This is default in case of G3/G4 output +compression schemes. +.TP +.B \-s +Stretch the input image vertically by writing each input row of +data twice to the output file. +.TP +.B \-v +Force +.I fax2tiff +to print the number of rows of data it retrieved from the input file. +.TP +.B \-z +Force output to be compressed with the LZW encoding. +.SH DIAGNOSTICS +The following warnings and errors come from the decoding +routines in the library. +.PP +.BR "Warning, %s: Premature EOL at scanline %d (x %d).\en" . +The input data had a row that was shorter than the expected width. +The row is padded with white. +.PP +.BR "%s: Premature EOF at scanline %d (x %d).\en" . +The decoder ran out of data in the middle of a scanline. +The resultant row is padded with white. +.PP +.BR "%s: Bad code word at row %d, x %d\en" . +An invalid Group 3 +.I code +was encountered while decoding the input file. +The row number and horizontal position is given. +The remainder of the input row is discarded, while +the corresponding output row is padded with white. +.PP +.BR "%s: Bad 2D code word at scanline %d.\en" . +An invalid Group 4 or 2D Group 3 +.I code +was encountered while decoding the input file. +The row number and horizontal position is given. +The remainder of the input row is discarded, while +the corresponding output row is padded with white. +.SH BUGS +Input data are assumed to have a a ``top left'' orientation; +it should be possible to override this assumption +from the command line. +.SH "SEE ALSO" +.BR "\s-1CCITT\s+1 Recommendation T.4" +(Standardization of Group 3 Facsimile Apparatus for Document Transmission). +.PP +.BR "The Spirit of TIFF Class F", +an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies. +.PP +.BR tiffinfo (1), +.BR tiffdither (1), +.BR tiffgt (1), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/libtiff.3tiff b/thirdparty/SDL2_image/external/libtiff/man/libtiff.3tiff new file mode 100644 index 000000000..8e9ff35b7 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/libtiff.3tiff @@ -0,0 +1,544 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH INTRO 3TIFF "November 2, 2005" "libtiff" +.SH NAME +libtiff \- introduction to +.IR libtiff , +a library for reading and writing +.SM TIFF +files +.SH SYNOPSIS +.B "#include " +.sp +cc file.c +.B -ltiff +.SH DESCRIPTION +.I libtiff +is a library for reading and writing data files encoded with the +.I "Tag Image File" +format, Revision 6.0 (or revision 5.0 or revision 4.0). This file format is +suitable for archiving multi-color and monochromatic image data. +.PP +The library supports several compression algorithms, as indicated by the +.I Compression +field, including: +no compression (1), +.SM CCITT +1D Huffman compression (2), +.SM CCITT +Group 3 Facsimile compression (3), +.SM CCITT +Group 4 Facsimile compression (4), +Lempel-Ziv & Welch compression (5), +baseline JPEG compression (7), +word-aligned 1D Huffman compression (32771), +and +PackBits compression (32773). +In addition, several nonstandard compression algorithms are supported: the +4-bit compression algorithm used by the +.I ThunderScan +program (32809) (decompression only), NeXT's 2-bit compression algorithm +(32766) (decompression only), an experimental LZ-style algorithm known as +Deflate (32946), and an experimental CIE LogLuv compression scheme designed +for images with high dynamic range (32845 for LogL and 32845 for LogLuv). +Directory information may be in either little- or big-endian byte order\-byte +swapping is automatically done by the library. Data bit ordering may be either +Most Significant Bit (\c +.SM MSB\c +) to Least Significant Bit (\c +.SM LSB\c +) or +.SM LSB +to +.SM MSB. +Finally, the library does not support files in which the +.IR BitsPerSample , +.IR Compression , +.IR MinSampleValue , +or +.IR MaxSampleValue +fields are defined differently on a per-sample basis +(in Rev. 6.0 the +.I Compression +tag is not defined on a per-sample basis, so this is immaterial). +.SH "DATA TYPES" +The library makes extensive use of C typedefs to promote portability. +Two sets of typedefs are used, one for communication with clients +of the library and one for internal data structures and parsing of the +.SM TIFF +format. +The following typedefs are exposed to users either through function +definitions or through parameters passed through the varargs interfaces. +.in +.5i +.sp 5p +.ta +\w'typedef unsigned <\fIthing\fP> uint32; 'u +.nf +typedef unsigned short uint16; 16-bit unsigned integer +typedef unsigned <\fIthing\fP> uint32; 32-bit unsigned integer +.sp 5p +typedef unsigned int ttag_t; directory tag +typedef uint16 tdir_t; directory index +typedef uint16 tsample_t; sample number +typedef uint32 tstrip_t; strip number +typedef uint32 ttile_t; tile number +typedef int32 tsize_t; i/o size in bytes +typedef void* tdata_t; image data ref +typedef void* thandle_t; client data handle +typedef int32 toff_t; file offset +.fi +.sp 5p +.in -.5i +Note that +.IR tstrip_t , +.IR ttile_t , +and +.I tsize_t +are constrained to be no more than 32-bit quantities by 32-bit fields they are +stored in in the +.SM TIFF +image. +Likewise +.I tsample_t +is limited by the 16-bit field used to store the +.I SamplesPerPixel +tag. +.I tdir_t +constrains the maximum number of +.SM IFDs +that may appear in an image and may be an arbitrary size (w/o penalty). +.I ttag_t +must be either int, unsigned int, pointer, or double because the library uses +a varargs interface and +.SM "ANSI C" +restricts the type of the parameter before an ellipsis to be a promoted type. +.I toff_t +is defined as int32 because TIFF file offsets are (unsigned) 32-bit +quantities. A signed value is used because some interfaces return \-1 on +error. Finally, note that user-specified data references are passed as opaque +handles and only cast at the lowest layers where their type is presumed. +.SH "LIST OF ROUTINES" +The following routines are part of the library. Consult specific manual pages +for details on their operation; on most systems doing ``man function-name'' +will work. +.sp +.nf +.ta \w'TIFFCheckpointDirectory'u+2n +\fIName\fP \fIDescription\fP +.sp 5p +TIFFCheckpointDirectory writes the current state of the directory +TIFFCheckTile very x,y,z,sample is within image +TIFFCIELabToRGBInit initialize CIE L*a*b* 1976 to RGB conversion state +TIFFCIELabToXYZ perform CIE L*a*b* 1976 to CIE XYZ conversion +TIFFClientOpen open a file for reading or writing +TIFFClose close an open file +TIFFComputeStrip return strip containing y,sample +TIFFComputeTile return tile containing x,y,z,sample +TIFFCurrentDirectory return index of current directory +TIFFCurrentRow return index of current scanline +TIFFCurrentStrip return index of current strip +TIFFCurrentTile return index of current tile +TIFFDataWidth return the size of TIFF data types +TIFFError library error handler +TIFFFdOpen open a file for reading or writing +TIFFFieldDataType get data type from field information +TIFFFieldName get field name from field information +TIFFFieldPassCount get whether to pass a value count to Get/SetField +TIFFFieldReadCount get number of values to be read from field +TIFFFieldTag get tag value from field information +TIFFFieldWithName get field information given field name +TIFFFieldWithTag get field information given tag +TIFFFieldWriteCount get number of values to be written to field +TIFFFileName return name of open file +TIFFFileno return open file descriptor +TIFFFindCODEC find standard codec for the specific scheme +TIFFFindField get field information given tag and data type +TIFFFlush flush all pending writes +TIFFFlushData flush pending data writes +TIFFGetBitRevTable return bit reversal table +TIFFGetField return tag value in current directory +TIFFGetFieldDefaulted return tag value in current directory +TIFFGetMode return open file mode +TIFFGetVersion return library version string +TIFFIsCODECConfigured check, whether we have working codec +TIFFIsMSB2LSB return true if image data is being returned + with bit 0 as the most significant bit +TIFFIsTiled return true if image data is tiled +TIFFIsByteSwapped return true if image data is byte-swapped +TIFFNumberOfStrips return number of strips in an image +TIFFNumberOfTiles return number of tiles in an image +TIFFOpen open a file for reading or writing +TIFFPrintDirectory print description of the current directory +TIFFReadBufferSetup specify i/o buffer for reading +TIFFReadDirectory read the next directory +TIFFReadEncodedStrip read and decode a strip of data +TIFFReadEncodedTile read and decode a tile of data +TIFFReadRawStrip read a raw strip of data +TIFFReadRawTile read a raw tile of data +TIFFReadRGBAImage read an image into a fixed format raster +TIFFReadScanline read and decode a row of data +TIFFReadTile read and decode a tile of data +TIFFRegisterCODEC override standard codec for the specific scheme +TIFFReverseBits reverse bits in an array of bytes +TIFFRGBAImageBegin setup decoder state for TIFFRGBAImageGet +TIFFRGBAImageEnd release TIFFRGBAImage decoder state +TIFFRGBAImageGet read and decode an image +TIFFRGBAImageOK is image readable by TIFFRGBAImageGet +TIFFScanlineSize return size of a scanline +TIFFSetDirectory set the current directory +TIFFSetSubDirectory set the current directory +TIFFSetErrorHandler set error handler function +TIFFSetField set a tag's value in the current directory +TIFFSetWarningHandler set warning handler function +TIFFStripSize returns size of a strip +TIFFRawStripSize returns the number of bytes in a raw strip +TIFFSwabShort swap bytes of short +TIFFSwabLong swap bytes of long +TIFFSwabArrayOfShort swap bytes of an array of shorts +TIFFSwabArrayOfLong swap bytes of an array of longs +TIFFTileRowSize return size of a row in a tile +TIFFTileSize return size of a tile +TIFFUnRegisterCODEC unregisters the codec +TIFFVGetField return tag value in current directory +TIFFVGetFieldDefaulted return tag value in current directory +TIFFVSetField set a tag's value in the current directory +TIFFVStripSize returns the number of bytes in a strip +TIFFWarning library warning handler +TIFFWriteDirectory write the current directory +TIFFWriteEncodedStrip compress and write a strip of data +TIFFWriteEncodedTile compress and write a tile of data +TIFFWriteRawStrip write a raw strip of data +TIFFWriteRawTile write a raw tile of data +TIFFWriteScanline write a scanline of data +TIFFWriteTile compress and write a tile of data +TIFFXYZToRGB perform CIE XYZ to RGB conversion +TIFFYCbCrToRGBInit initialize YCbCr to RGB conversion state +TIFFYCbCrtoRGB perform YCbCr to RGB conversion +.sp +Auxiliary functions: +_TIFFfree free memory buffer +_TIFFmalloc dynamically allocate memory buffer +_TIFFmemcmp compare contents of the memory buffers +_TIFFmemcpy copy contents of the one buffer to another +_TIFFmemset fill memory buffer with a constant byte +_TIFFrealloc dynamically reallocate memory buffer + +.fi +.SH "TAG USAGE" +The table below lists the +.SM TIFF +tags that are recognized and handled by the library. +If no use is indicated in the table, then the library +reads and writes the tag, but does not use it internally. +Note that some tags are meaningful only when a particular +compression scheme is being used; e.g. +.I Group3Options +is only useful if +.I Compression +is set to +.SM CCITT +Group 3 encoding. +Tags of this sort are considered +.I codec-specific +tags and the library does not recognize them except when the +.I Compression +tag has been previously set to the relevant compression scheme. +.sp +.nf +.ta \w'TIFFTAG_JPEGTABLESMODE'u+2n +\w'Value'u+2n +\w'R/W'u+2n +\fITag Name\fP \fIValue\fP \fIR/W\fP \fILibrary Use/Notes\fP +.sp 5p +.nf +Artist 315 R/W +BadFaxLines 326 R/W +BitsPerSample 258 R/W lots +CellLength 265 parsed but ignored +CellWidth 264 parsed but ignored +CleanFaxData 327 R/W +ColorMap 320 R/W +ColorResponseUnit 300 parsed but ignored +Compression 259 R/W choosing codec +ConsecutiveBadFaxLines 328 R/W +Copyright 33432 R/W +DataType 32996 R obsoleted by SampleFormat tag +DateTime 306 R/W +DocumentName 269 R/W +DotRange 336 R/W +ExtraSamples 338 R/W lots +FaxRecvParams 34908 R/W +FaxSubAddress 34909 R/W +FaxRecvTime 34910 R/W +FillOrder 266 R/W control bit order +FreeByteCounts 289 parsed but ignored +FreeOffsets 288 parsed but ignored +GrayResponseCurve 291 parsed but ignored +GrayResponseUnit 290 parsed but ignored +Group3Options 292 R/W used by Group 3 codec +Group4Options 293 R/W +HostComputer 316 R/W +ImageDepth 32997 R/W tile/strip calculations +ImageDescription 270 R/W +ImageLength 257 R/W lots +ImageWidth 256 R/W lots +InkNames 333 R/W +InkSet 332 R/W +JPEGTables 347 R/W used by JPEG codec +Make 271 R/W +Matteing 32995 R obsoleted by ExtraSamples tag +MaxSampleValue 281 R/W +MinSampleValue 280 R/W +Model 272 R/W +NewSubFileType 254 R/W called SubFileType in spec +NumberOfInks 334 R/W +Orientation 274 R/W +PageName 285 R/W +PageNumber 297 R/W +PhotometricInterpretation 262 R/W used by Group 3 and JPEG codecs +PlanarConfiguration 284 R/W data i/o +Predictor 317 R/W used by LZW and Deflate codecs +PrimaryChromacities 319 R/W +ReferenceBlackWhite 532 R/W +ResolutionUnit 296 R/W used by Group 3 codec +RowsPerStrip 278 R/W data i/o +SampleFormat 339 R/W +SamplesPerPixel 277 R/W lots +SMinSampleValue 340 R/W +SMaxSampleValue 341 R/W +Software 305 R/W +StoNits 37439 R/W +StripByteCounts 279 R/W data i/o +StripOffsets 273 R/W data i/o +SubFileType 255 R/W called OSubFileType in spec +TargetPrinter 337 R/W +Thresholding 263 R/W +TileByteCounts 324 R/W data i/o +TileDepth 32998 R/W tile/strip calculations +TileLength 323 R/W data i/o +TileOffsets 324 R/W data i/o +TileWidth 322 R/W data i/o +TransferFunction 301 R/W +WhitePoint 318 R/W +XPosition 286 R/W +XResolution 282 R/W +YCbCrCoefficients 529 R/W used by TIFFRGBAImage support +YCbCrPositioning 531 R/W tile/strip size calculations +YCbCrSubsampling 530 R/W +YPosition 286 R/W +YResolution 283 R/W used by Group 3 codec +.SH "PSEUDO TAGS" +In addition to the normal +.SM TIFF +tags the library supports a collection of +tags whose values lie in a range outside the valid range of +.SM TIFF +tags. +These tags are termed +.I pseudo-tags +and are used to control various codec-specific functions within the library. +The table below summarizes the defined pseudo-tags. +.sp +.nf +.ta \w'TIFFTAG_JPEGTABLESMODE'u+2n +\w'Codec'u+2n +\w'R/W'u+2n +\fITag Name\fP \fICodec\fP \fIR/W\fP \fILibrary Use/Notes\fP +.sp 5p +.nf +TIFFTAG_FAXMODE G3 R/W general codec operation +TIFFTAG_FAXFILLFUNC G3/G4 R/W bitmap fill function +TIFFTAG_JPEGQUALITY JPEG R/W compression quality control +TIFFTAG_JPEGCOLORMODE JPEG R/W control colorspace conversions +TIFFTAG_JPEGTABLESMODE JPEG R/W control contents of \fIJPEGTables\fP tag +TIFFTAG_ZIPQUALITY Deflate R/W compression quality level +TIFFTAG_PIXARLOGDATAFMT PixarLog R/W user data format +TIFFTAG_PIXARLOGQUALITY PixarLog R/W compression quality level +TIFFTAG_SGILOGDATAFMT SGILog R/W user data format +.fi +.TP +.B TIFFTAG_FAXMODE +Control the operation of the Group 3 codec. +Possible values (independent bits that can be combined by +or'ing them together) are: +FAXMODE_CLASSIC +(enable old-style format in which the +.SM RTC +is written at the end of the last strip), +FAXMODE_NORTC +(opposite of +FAXMODE_CLASSIC; +also called +FAXMODE_CLASSF), +FAXMODE_NOEOL +(do not write +.SM EOL +codes at the start of each row of data), +FAXMODE_BYTEALIGN +(align each encoded row to an 8-bit boundary), +FAXMODE_WORDALIGN +(align each encoded row to an 16-bit boundary), +The default value is dependent on the compression scheme; this +pseudo-tag is used by the various G3 and G4 codecs to share code. +.TP +.B TIFFTAG_FAXFILLFUNC +Control the function used to convert arrays of black and white +runs to packed bit arrays. +This hook can be used to image decoded scanlines in multi-bit +depth rasters (e.g. for display in colormap mode) +or for other purposes. +The default value is a pointer to a builtin function that images +packed bilevel data. +.TP +.B TIFFTAG_IPTCNEWSPHOTO +Tag contains image metadata per the IPTC newsphoto spec: Headline, +captioning, credit, etc... Used by most wire services. +.TP +.B TIFFTAG_PHOTOSHOP +Tag contains Photoshop captioning information and metadata. Photoshop +uses in parallel and redundantly alongside IPTCNEWSPHOTO information. +.TP +.B TIFFTAG_JPEGQUALITY +Control the compression quality level used in the baseline algorithm. +Note that quality levels are in the range 0-100 with a default value of 75. +.TP +.B TIFFTAG_JPEGCOLORMODE +Control whether or not conversion is done between +RGB and YCbCr colorspaces. +Possible values are: +JPEGCOLORMODE_RAW +(do not convert), and +JPEGCOLORMODE_RGB +(convert to/from RGB) +The default value is JPEGCOLORMODE_RAW. +.TP +.B TIFFTAG_JPEGTABLESMODE +Control the information written in the +.I JPEGTables +tag. +Possible values (independent bits that can be combined by +or'ing them together) are: +JPEGTABLESMODE_QUANT +(include quantization tables), +and +JPEGTABLESMODE_HUFF +(include Huffman encoding tables). +The default value is JPEGTABLESMODE_QUANT|JPEGTABLESMODE_HUFF. +.TP +.B TIFFTAG_ZIPQUALITY +Control the compression technique used by the Deflate codec. +Quality levels are in the range 1-9 with larger numbers yielding better +compression at the cost of more computation. +The default quality level is 6 which yields a good time-space tradeoff. +.TP +.B TIFFTAG_PIXARLOGDATAFMT +Control the format of user data passed +.I in +to the PixarLog codec when encoding and passed +.I out +from when decoding. +Possible values are: +PIXARLOGDATAFMT_8BIT +for 8-bit unsigned pixels, +PIXARLOGDATAFMT_8BITABGR +for 8-bit unsigned ABGR-ordered pixels, +PIXARLOGDATAFMT_11BITLOG +for 11-bit log-encoded raw data, +PIXARLOGDATAFMT_12BITPICIO +for 12-bit PICIO-compatible data, +PIXARLOGDATAFMT_16BIT +for 16-bit signed samples, +and +PIXARLOGDATAFMT_FLOAT +for 32-bit IEEE floating point samples. +.TP +.B TIFFTAG_PIXARLOGQUALITY +Control the compression technique used by the PixarLog codec. +This value is treated identically to TIFFTAG_ZIPQUALITY; see the +above description. +.TP +.B TIFFTAG_SGILOGDATAFMT +Control the format of client data passed +.I in +to the SGILog codec when encoding and passed +.I out +from when decoding. +Possible values are: +SGILOGDATAFMT_FLTXYZ +for converting between LogLuv and 32-bit IEEE floating valued XYZ pixels, +SGILOGDATAFMT_16BITLUV +for 16-bit encoded Luv pixels, +SGILOGDATAFMT_32BITRAW and SGILOGDATAFMT_24BITRAW +for no conversion of data, +SGILOGDATAFMT_8BITRGB +for returning 8-bit RGB data (valid only when decoding LogLuv-encoded data), +SGILOGDATAFMT_FLTY +for converting between LogL and 32-bit IEEE floating valued Y pixels, +SGILOGDATAFMT_16BITL +for 16-bit encoded L pixels, +and +SGILOGDATAFMT_8BITGRY +for returning 8-bit greyscale data +(valid only when decoding LogL-encoded data). +.SH DIAGNOSTICS +All error messages are directed through the +.IR TIFFError +routine. +By default messages are directed to +.B stderr +in the form: +.IR "module: message\en." +Warning messages are likewise directed through the +.IR TIFFWarning +routine. +.SH "SEE ALSO" +.BR fax2tiff (1), +.BR gif2tiff (1), +.BR pal2rgb (1), +.BR ppm2tiff (1), +.BR rgb2ycbcr (1), +.BR ras2tiff (1), +.BR raw2tiff (1), +.BR sgi2tiff (1), +.BR tiff2bw (1), +.BR tiffdither (1), +.BR tiffdump (1), +.BR tiffcp (1), +.BR tiffcmp (1), +.BR tiffgt (1), +.BR tiffinfo (1), +.BR tiffmedian (1), +.BR tiffsplit (1), +.BR tiffsv (1). +.PP +.BR "Tag Image File Format Specification \(em Revision 6.0" , +an Aldus Technical Memorandum. +.PP +.BR "The Spirit of TIFF Class F" , +an appendix to the TIFF 5.0 specification prepared by Cygnet Technologies. +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ +.SH BUGS +The library does not support multi-sample images +where some samples have different bits/sample. +.PP +The library does not support random access to compressed data +that is organized with more than one row per tile or strip. diff --git a/thirdparty/SDL2_image/external/libtiff/man/pal2rgb.1 b/thirdparty/SDL2_image/external/libtiff/man/pal2rgb.1 new file mode 100644 index 000000000..772b4a7bc --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/pal2rgb.1 @@ -0,0 +1,110 @@ +.\" +.\" Copyright (c) 1990-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH PAL2RGB 1 "September 20, 2005" "libtiff" +.SH NAME +pal2rgb \- convert a palette color +.SM TIFF +image to a full color image +.SH SYNOPSIS +.B pal2rgb +[ +.I options +] +.I input.tif +.I output.tif +.SH DESCRIPTION +.I Pal2rgb +converts a palette color +.SM TIFF +image to a full color image by +applying the colormap of the palette image to each sample +to generate a full color +.SM RGB +image. +.SH OPTIONS +Options that affect the interpretation of input data are: +.TP +.B \-C +This option overrides the default behavior of +.I pal2rgb +in determining whether or not +colormap entries contain 16-bit or 8-bit values. +By default the colormap is inspected and +if no colormap entry greater than 255 is found, +the colormap is assumed to have only 8-bit values; otherwise +16-bit values (as required by the +.SM TIFF +specification) are assumed. +The +.B \-C +option can be used to explicitly specify the number of +bits for colormap entries: +.B "\-C 8" +for 8-bit values, +.B "\-C 16" +for 16-bit values. +.PP +Options that affect the output file format are: +.TP +.B \-p +Explicitly select the planar configuration used in organizing +data samples in the output image: +.B "\-p contig" +for samples packed contiguously, and +.B "\-p separate" +for samples stored separately. +By default samples are packed. +.TP +.B \-c +Use the specific compression algorithm to encoded image data +in the output file: +.B "\-c packbits" +for Macintosh Packbits, +.B "\-c lzw" +for Lempel-Ziv & Welch, +.B "\-c zip" +for Deflate, +.B "\-c none" +for no compression. +If no compression-related option is specified, the input +file's compression algorithm is used. +.TP +.B \-r +Explicitly specify the number of rows in each strip of the +output file. +If the +.B \-r +option is not specified, a number is selected such that each +output strip has approximately 8 kilobytes of data in it. +.SH BUGS +Only 8-bit images are handled. +.SH "SEE ALSO" +.BR tiffinfo (1), +.BR tiffcp (1), +.BR tiffmedian (1), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/ppm2tiff.1 b/thirdparty/SDL2_image/external/libtiff/man/ppm2tiff.1 new file mode 100644 index 000000000..12e58e2cb --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/ppm2tiff.1 @@ -0,0 +1,104 @@ +.\" +.\" Copyright (c) 1991-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH PPM2TIFF 1 "March 1, 2006" "libtiff" +.SH NAME +ppm2tiff \- create a +.SM TIFF +file from +.SM PPM, PGM +and +.SM PBM +image files +.SH SYNOPSIS +.B ppm2tiff +[ +.I options +] [ +.I input.ppm +] +.I output.tif +.SH DESCRIPTION +.I ppm2tiff +converts a file in the +.SM PPM, PGM +and +.SM PBM +image formats to +.SM TIFF. +By default, the +.SM TIFF +image is created with data samples packed (\c +.IR PlanarConfiguration =1), +compressed with the Packbits algorithm (\c +.IR Compression =32773), +and with each strip no more than 8 kilobytes. These characteristics can be +overridden, or explicitly specified with the options described below +.PP +If the +.SM PPM +file contains greyscale data, then the +.I PhotometricInterpretation +tag is set to 1 (min-is-black), otherwise it is set to 2 (RGB). +.PP +If no +.SM PPM +file is specified on the command line, +.I ppm2tiff +will read from the standard input. +.SH OPTIONS +.TP +.B \-c +Specify a compression scheme to use when writing image data: +.B none +for no compression, +.B packbits +for PackBits compression (will be used by default), +.B lzw +for Lempel-Ziv & Welch compression, +.B jpeg +for baseline JPEG compression, +.B zip +for Deflate compression, +.B g3 +for CCITT Group 3 (T.4) compression, +and +.B g4 +for CCITT Group 4 (T.6) compression. +.TP +.B \-r +Write data with a specified number of rows per strip; by default the number of +rows/strip is selected so that each strip is approximately 8 kilobytes. +.TP +.B \-R +Mark the resultant image to have the specified X and Y resolution (in +dots/inch). +.SH "SEE ALSO" +.BR tiffinfo (1), +.BR tiffcp (1), +.BR tiffmedian (1), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/raw2tiff.1 b/thirdparty/SDL2_image/external/libtiff/man/raw2tiff.1 new file mode 100644 index 000000000..f45569d4b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/raw2tiff.1 @@ -0,0 +1,195 @@ +.\" +.\" Copyright (c) 1990-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH RAW2TIFF 1 "November 2, 2005" "libtiff" +.SH NAME +raw2tiff \- create a +.SM TIFF +file from a raw data +.SH SYNOPSIS +.B raw2tiff +[ +.I options +] +.I input.raw +.I output.tif +.SH DESCRIPTION +.I raw2tiff +converts a raw byte sequence into +.SM TIFF. +By default, the +.SM TIFF +image is created with data samples packed (\c +.IR PlanarConfiguration =1), +compressed with the PackBits algorithm (\c +.IR Compression =32773), +and with each strip no more than 8 kilobytes. +These characteristics can overridden, or explicitly specified +with the options described below. +.SH OPTIONS +.TP +.BI \-H " number" +size of input image file header in bytes (0 by default). This amount of data +just will be skipped from the start of file while reading. +.TP +.BI \-w " number" +width of input image in pixels (can be guessed, see +.SM +.B "GUESSING THE IMAGE GEOMETRY" +below). +.TP +.BI \-l " number" +length of input image in lines (can be guessed, see +.SM +.B "GUESSING THE IMAGE GEOMETRY" +below). +.TP +.BI \-b " number" +number of bands in input image (1 by default). +.TP +.BI \-d " data_type" +type of samples in input image, where +.I data_type +may be: +.ta \w'\fBdouble \fR'u +.br +.B byte\t +8-bit unsigned integer (default), +.br +.B short\t +16-bit unsigned integer, +.br +.B long\t +32-bit unsigned integer, +.br +.B sbyte\t +8-bit signed integer, +.br +.B sshort\t +16-bit signed integer, +.br +.B slong\t +32-bit signed integer, +.br +.B float\t +32-bit IEEE floating point, +.br +.B double\t +64-bit IEEE floating point. +.TP +.BI \-i " config" +type of samples interleaving in input image, where +.I config +may be: +.ta \w'\fBpixel \fR'u +.br +.B pixel\t +pixel interleaved data (default), +.br +.B band\t +band interleaved data. +.TP +.BI \-p " photo" +photometric interpretation (color space) of the input image, where +.I photo +may be: +.ta \w'\fBminiswhite \fR'u +.br +.B miniswhite\t +white color represented with 0 value, +.br +.B minisblack\t +black color represented with 0 value (default), +.br +.B rgb\t +image has RGB color model, +.br +.B cmyk\t +image has CMYK (separated) color model, +.br +.B ycbcr\t +image has YCbCr color model, +.br +.B cielab\t +image has CIE L*a*b color model, +.br +.B icclab\t +image has ICC L*a*b color model, +.br +.B itulab\t +image has ITU L*a*b color model. +.TP +.B \-s +swap bytes fetched from the input file. +.TP +.B \-L +input data has LSB2MSB bit order (default). +.TP +.B \-M +input data has MSB2LSB bit order. +.TP +.B \-c +Specify a compression scheme to use when writing image data: +.B "\-c none" +for no compression, +.B "\-c packbits" +for the PackBits compression algorithm (the default), +.B "\-c jpeg" +for the baseline JPEG compression algorithm, +.B "\-c zip" +for the Deflate compression algorithm, +and +.B "\-c lzw" +for Lempel-Ziv & Welch. +.TP +.BI \-r " number" +Write data with a specified number of rows per strip; +by default the number of rows/strip is selected so that each strip +is approximately 8 kilobytes. +.SH GUESSING THE IMAGE GEOMETRY +.I raw2tiff +can guess image width and height in case one or both of these parameters are +not specified. If you omit one of those parameters, the complementary one will +be calculated based on the file size (taking into account header size, number +of bands and data type). If you omit both parameters, the statistical approach +will be used. Utility will compute correlation coefficient between two lines +at the image center using several appropriate line sizes and the highest +absolute value of the coefficient will indicate the right line size. That is +why you should be cautious with the very large images, because guessing +process may take a while (depending on your system performance). Of course, the +utility can't guess the header size, number of bands and data type, so it +should be specified manually. If you don't know anything about your image, +just try with the several combinations of those options. +.P +There is no magic, it is just a mathematical statistics, so it can be wrong +in some cases. But for most ordinary images guessing method will work fine. +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR tiffinfo (1), +.BR tiffcp (1), +.BR tiffmedian (1), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/rgb2ycbcr.1 b/thirdparty/SDL2_image/external/libtiff/man/rgb2ycbcr.1 new file mode 100644 index 000000000..908b49ae7 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/rgb2ycbcr.1 @@ -0,0 +1,98 @@ +.\" +.\" Copyright (c) 1991-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH RGB2YCBCR 1 "November 2, 2005" "libtiff" +.SH NAME +rgb2ycbcr \- convert non-YCbCr +.SM TIFF +images to a YCbCr +.SM TIFF +image +.SH SYNOPSIS +.B rgb2ycbcr +[ +.I options +] +.I "src1.tif src2.tif ... dst.tif" +.SH DESCRIPTION +.I rgb2ycbcr +converts +.SM RGB +color, greyscale, or bi-level +.SM TIFF +images to YCbCr images by transforming and sampling pixel data. If multiple +files are specified on the command line each source file is converted to a +separate directory in the destination file. +.PP +By default, chrominance samples are created by sampling +2 by 2 blocks of luminance values; this can be changed with the +.B \-h +and +.B \-v +options. +Output data are compressed with the +.SM PackBits +compression scheme, by default; an alternate scheme can be selected with the +.B \-c +option. +By default, output data are compressed in strips with +the number of rows in each strip selected so that the +size of a strip is never more than 8 kilobytes; +the +.B \-r +option can be used to explicitly set the number of +rows per strip. +.SH OPTIONS +.TP +.B \-c +Specify a compression scheme to use when writing image data: +.B "\-c none" +for no compression, +.B "\-c packbits" +for the PackBits compression algorithm (the default), +.B "\-c jpeg" +for the JPEG compression algorithm, +.B "\-c zip" +for the deflate compression algorithm, +and +.B "\-c lzw" +for Lempel-Ziv & Welch. +.TP +.B \-h +Set the horizontal sampling dimension to one of: 1, 2 (default), or 4. +.TP +.B \-r +Write data with a specified number of rows per strip; +by default the number of rows/strip is selected so that each strip +is approximately 8 kilobytes. +.TP +.B \-v +Set the vertical sampling dimension to one of: 1, 2 (default), or 4. +.SH "SEE ALSO" +.BR tiffinfo (1), +.BR tiffcp (1), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff diff --git a/thirdparty/SDL2_image/external/libtiff/man/thumbnail.1 b/thirdparty/SDL2_image/external/libtiff/man/thumbnail.1 new file mode 100644 index 000000000..f5563ea32 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/thumbnail.1 @@ -0,0 +1,89 @@ +.\" +.\" Copyright (c) 1994-1997 Sam Leffler +.\" Copyright (c) 1994-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH THUMBNAIL 1 "November 2, 2005" "libtiff" +.SH NAME +thumbnail \- create a +.SM TIFF +file with thumbnail images +.SH SYNOPSIS +.B thumbnail +[ +.I options +] +.I input.tif +.I output.tif +.SH DESCRIPTION +.I thumbnail +is a program written to show how one might use the +SubIFD tag (#330) to store thumbnail images. +.I thumbnail +copies a +.SM TIFF +Class F facsimile file to the output file +and for each image an 8-bit greyscale +.IR "thumbnail sketch" . +The output file contains the thumbnail image with the associated +full-resolution page linked below with the SubIFD tag. +.PP +By default, thumbnail images are 216 pixels wide by 274 pixels high. +Pixels are calculated by sampling and filtering the input image +with each pixel value passed through a contrast curve. +.SH OPTIONS +.TP +.B \-w +Specify the width of thumbnail images in pixels. +.TP +.B \-h +Specify the height of thumbnail images in pixels. +.TP +.B \-c +Specify a contrast curve to apply in generating the thumbnail images. +By default pixels values are passed through a linear contrast curve +that simply maps the pixel value ranges. +Alternative curves are: +.B exp50 +for a 50% exponential curve, +.B exp60 +for a 60% exponential curve, +.B exp70 +for a 70% exponential curve, +.B exp80 +for a 80% exponential curve, +.B exp90 +for a 90% exponential curve, +.B exp +for a pure exponential curve, +.B linear +for a linear curve. +.SH BUGS +There are no options to control the format of the saved thumbnail images. +.SH "SEE ALSO" +.BR tiffdump (1), +.BR tiffgt (1), +.BR tiffinfo (1), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiff2bw.1 b/thirdparty/SDL2_image/external/libtiff/man/tiff2bw.1 new file mode 100644 index 000000000..4fe9942f2 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiff2bw.1 @@ -0,0 +1,93 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFF2BW 1 "November 2, 2005" "libtiff" +.SH NAME +tiff2bw \- convert a color +.SM TIFF +image to greyscale +.SH SYNOPSIS +.B tiff2bw +[ +.I options +] +.I input.tif +.I output.tif +.SH DESCRIPTION +.I Tiff2bw +converts an +.SM RGB +or Palette color +.SM TIFF +image to a greyscale image by +combining percentages of the red, green, and blue channels. +By default, output samples are created by taking +28% of the red channel, 59% of the green channel, and 11% of +the blue channel. +To alter these percentages, the +.BR \-R , +.BR \-G , +and +.BR \-B +options may be used. +.SH OPTIONS +.TP +.B \-c +Specify a compression scheme to use when writing image data: +.B "\-c none" +for no compression, +.B "\-c packbits" +for the PackBits compression algorithm, +.B "\-c zip +for the Deflate compression algorithm, +.B "\-c g3 +for the CCITT Group 3 compression algorithm, +.B "\-c g4 +for the CCITT Group 4 compression algorithm, +and +.B "\-c lzw" +for Lempel-Ziv & Welch (the default). +.TP +.B \-r +Write data with a specified number of rows per strip; +by default the number of rows/strip is selected so that each strip +is approximately 8 kilobytes. +.TP +.B \-R +Specify the percentage of the red channel to use (default 28). +.TP +.B \-G +Specify the percentage of the green channel to use (default 59). +.TP +.B \-B +Specify the percentage of the blue channel to use (default 11). +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR tiffinfo (1), +.BR tiffcp (1), +.BR tiffmedian (1), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiff2pdf.1 b/thirdparty/SDL2_image/external/libtiff/man/tiff2pdf.1 new file mode 100644 index 000000000..6b3b4abf5 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiff2pdf.1 @@ -0,0 +1,256 @@ +.\" +.\" Copyright (c) 2003 Ross Finlayson +.\" +.\" 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 name of +.\" Ross Finlayson may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Ross Finlayson. +.\" +.\" 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 ROSS FINLAYSON 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. +.\" +.\" Process this file with +.\" groff -man -Tascii tiff2pdf.1 +.\" +.TH TIFF2PDF 1 "April 20, 2006" "libtiff" +.SH NAME +tiff2pdf \- convert a TIFF image to a PDF document +.SH SYNOPSIS +.B tiff2pdf +[ +.I options +] +.I input.tiff +.SH DESCRIPTION +.I tiff2pdf +opens a TIFF image and writes a PDF document to standard output. +.PP +The program converts one TIFF file to one PDF file, including multiple page +TIFF files, tiled TIFF files, black and white. grayscale, and color TIFF +files that contain data of TIFF photometric interpretations of bilevel, +grayscale, RGB, YCbCr, CMYK separation, and ICC L*a*b* as supported by +.I libtiff +and PDF. +.PP +If you have multiple TIFF files to convert into one PDF file then use +.I tiffcp +or other program to concatenate the files into a multiple page TIFF file. +If the input TIFF file is of huge dimensions (greater than 10000 pixels height +or width) convert the input image to a tiled TIFF if it is not already. +.PP +The standard output is standard output. Set the output file name with the +.BI \-o " output.pdf" +option. +.PP +All black and white files are compressed into a single strip CCITT G4 Fax +compressed PDF, unless tiled, where tiled black and white images are +compressed into tiled CCITT G4 Fax compressed PDF, +.I libtiff +CCITT support is assumed. +.PP +Color and grayscale data can be compressed using either JPEG compression, +ITU-T T.81, or Zip/Deflate LZ77 compression. Set the compression type using +the +.B \-j +or +.B \-z +options. JPEG compression support +requires that +.I libtiff +be configured with JPEG support, and Zip/Deflate compression support requires +that +.I libtiff +be configured with Zip support, in tiffconf.h. Use only one or the other of +.B \-j +and +.B \-z. +.PP +If the input TIFF contains single strip CCITT G4 Fax compressed information, +then that is written to the PDF file without transcoding, unless the options +of no compression and no passthrough are set, +.B \-d +and +.B \-n. +.PP +If the input TIFF contains JPEG or single strip Zip/Deflate compressed +information, and they are configured, then that is written to the PDF file +without transcoding, unless the options of no compression and no passthrough +are set. +.PP +The default page size upon which the TIFF image is placed is determined by +the resolution and extent of the image data. Default values for the TIFF +image resolution can be set using the +.B \-x +and +.B \-y +options. The page size can be set using the +.B \-p +option for paper size, or +.B \-w +and +.B \-l +for paper width and length, then each page of the TIFF image is centered on +its page. The distance unit for default resolution and page width and +length can be set by the +.B \-u +option, the default unit is inch. +.PP +Various items of the output document information can be set with the +.BR \-e , +.BR \-c , +.BR \-a , +.BR \-t , +.BR \-s , +and +.B \-k +options. Setting the argument of the option to "" for these +tags causes the relevant document information field to be not written. Some +of the document information values otherwise get their information from the +input TIFF image, the software, author, document name, and image description. +.PP +The Portable Document Format (PDF) specification is copyrighted by Adobe +Systems, Incorporated. +.SH OPTIONS +.TP +.BI \-o " output-file" +Set the output to go to file. +.I output-file +.TP +.B \-j +Compress with JPEG (requires +.I libjpeg +configured with +.IR libtiff ). +.TP +.B \-z +Compress with Zip/Deflate (requires +.I zlib +configured with +.IR libtiff ). +.TP +.BI \-q " quality" +Set the compression quality, 1-100 for JPEG. +.TP +.B \-n +Do not allow data to be converted without uncompressing, no compressed +data passthrough. +.TP +.BI \-b +Set PDF ``Interpolate'' user preference. +.TP +.B \-d +Do not compress (decompress). +.TP +.B \-i +Invert colors. +.TP +.BI \-p " paper-size" +Set paper size, e.g., +.BR letter , +.BR legal , +.BR A4 . +.TP +.B \-F +Cause the tiff to fill the PDF page. +.TP +.BR \-u " [" i | m ] +Set distance unit, +.B i +for inch, +.B m +for centimeter. +.TP +.BI \-w " width" +Set width in units. +.TP +.BI \-l " length" +Set length in units. +.TP +.BI \-x " xres" +Set x/width resolution default. +.TP +.BI \-y " yres" +Set y/length resolution default. +.TP +.BR \-r " [" d | o ] +Set +.B d +for resolution default for images without resolution, +.B o +for resolution override for all images. +.TP +.BI \-f +Set PDF ``Fit Window'' user preference. +.TP +.BI \-e " YYYYMMDDHHMMSS" +Set document information date, overrides image or current date/time default, +.I YYYYMMDDHHMMSS. +.TP +.BI \-c " creator" +Set document information creator, overrides image software default. +.TP +.BI \-a " author" +Set document information author, overrides image artist default. +.TP +.BI \-t " title" +Set document information title, overrides image document name default. +.TP +.BI \-s " subject" +Set document information subject, overrides image image description default. +.TP +.BI \-k " keywords" +Set document information keywords. +.TP +.BI \-m " size" +Set memory allocation limit (in MiB). Default is 256MiB. Set to 0 to disable the limit. +.TP +.B \-h +List usage reminder to stderr and exit. +.SH EXAMPLES +.TP +The following example would generate the file output.pdf from input.tiff. +.RS +.nf +tiff2pdf \-o output.pdf input.tiff +.fi +.RE +.PP +The following example would generate PDF output from input.tiff and write it +to standard output. +.RS +.nf +tiff2pdf input.tiff +.fi +.RE +.PP +The following example would generate the file output.pdf from input.tiff, +putting the image pages on a letter sized page, compressing the output +with JPEG, with JPEG quality 75, setting the title to ``Document'', and setting +the ``Fit Window'' option. +.RS +.nf +tiff2pdf \-p letter \-j \-q 75 \-t "Document" \-f \-o output.pdf input.tiff +.fi +.RE +.SH BUGS +Please report bugs via the web interface at +.IP +\%http://bugzilla.remotesensing.org/enter_bug.cgi?product=libtiff +.SH "SEE ALSO" +.BR libtiff (3), +.BR tiffcp (1), +.BR tiff2ps (1) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiff2ps.1 b/thirdparty/SDL2_image/external/libtiff/man/tiff2ps.1 new file mode 100644 index 000000000..ce323eeeb --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiff2ps.1 @@ -0,0 +1,297 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.ds Ps PostScript +.if n .po 0 +.TH TIFF2PS 1 "November 2, 2005" "libtiff" +.SH NAME +tiff2ps \- convert a +.SM TIFF +image to \*(Ps\*(Tm +.SH SYNOPSIS +.B tiff2ps +[ +.I options +] +.I "input.tif ..." +.SH DESCRIPTION +.I tiff2ps +reads +.SM TIFF +images and writes \*(Ps or Encapsulated \*(Ps (EPS) +on the standard output. +By default, +.I tiff2ps +writes Encapsulated \*(Ps for the first image in the specified +.SM TIFF +image file. +.PP +By default, +.I tiff2ps +will generate \*(Ps that fills a printed area specified +by the +.SM TIFF +tags in the input file. +If the file does not contain +.I XResolution +or +.I YResolution +tags, then the printed area is set according to the image dimensions. +The +.B \-w +and +.B \-h +options (see below) +can be used to set the dimensions of the printed area in inches; +overriding any relevant +.SM TIFF +tags. +.PP +The \*(Ps generated for +.SM RGB, +palette, and +.SM CMYK +images uses the +.I colorimage +operator. +The \*(Ps generated for +greyscale and bilevel images +uses the +.I image +operator. +When the +.I colorimage +operator is used, \*(Ps code to emulate this operator +on older \*(Ps printers is also generated. +Note that this emulation code can be very slow. +.PP +Color images with associated alpha data are composited over +a white background. +.SH OPTIONS +.TP +.B \-1 +Generate \*(Ps Level 1 (the default). +.TP +.B \-2 +Generate \*(Ps Level 2. +.TP +.B \-3 +Generate \*(Ps Level 3. It basically allows one to use the /flateDecode +filter for ZIP compressed TIFF images. +.TP +.B \-8 +Disable use of ASCII85 encoding with \*(Ps Level 2/3. +.TP +.B \-a +Generate output for all IFDs (pages) in the input file. +.TP +.B \-b +Specify the bottom margin for the output (in inches). This does not affect +the height of the printed image. +.TP +.B \-c +Center the image in the output. This option only shows an effect if both +the +.B \-w +and the +.B \-h +option are given. +.TP +.B \-C +Specify the document creator name. +.TP +.B \-d +Set the initial +.SM TIFF +directory to the specified directory number. +(NB: Directories are numbered starting at zero.) +This option is useful for selecting individual pages in a +multi-page (e.g. facsimile) file. +.TP +.B \-D +Enable duplex printing (two pages per sheet of paper). +.TP +.B \-e +Force the generation of Encapsulated \*(Ps (implies +.BR \-z ). +.TP +.B \-h +Specify the vertical size of the printed area (in inches). +.TP +.B \-H +Specify the maximum height of image (in inches). Images with larger sizes will +be split in several pages. Option +.B \-L +may be used for specifying size of split images overlapping. +.B \-i +Enable/disable pixel interpolation. This option requires a +single numeric value: zero to disable pixel interpolation and +non-zero to enable. The default is enabled. +.TP +.B \-L +Specify the size of overlapping for split images (in inches). Used in +conjunction with +.B \-H +and +.B \-W +options. +.TP +.B \-l +Specify the left margin for the output (in inches). This does not affect +the width of the printed image. +.TP +.BI \-M " size" +Set maximum memory allocation size (in MiB). The default is 256MiB. +Set to 0 to disable the limit. +.TP +.B \-m +Where possible render using the +.I imagemask +\*(Ps operator instead of the +.I image +operator. When this option is specified +.I tiff2ps +will use +.I imagemask +for rendering 1 bit deep images. If this option is not specified +or if the image depth is greater than 1 then the +.I image +operator is used. +.TP +.B \-o +Set the initial +.SM TIFF +directory to the +.SM IFD +at the specified file offset. +This option is useful for selecting thumbnail images and the +like which are hidden using the +.I SubIFD +tag. +.TP +.B \-O +Write \*(Ps to specified file instead of standard output. +.TP +.B \-p +Force the generation of (non-Encapsulated) \*(Ps. +.TP +.B \-P L|P +Set optional PageOrientation DSC comment to Landscape or Portrait. +.TP +.B \-r 90|180|270|auto +Rotate image by 90, 180, 270 degrees or auto. Auto picks the best +fit for the image on the specified paper size (eg portrait +or landscape) if -h or -w is specified. Rotation is in degrees +counterclockwise. Auto rotates 90 degrees ccw to produce landscape. +.TP +.B \-s +Generate output for a single IFD (page) in the input file. +.TP +.B \-t +Specify the document title string. +.TP +.B \-T +Print pages for top edge binding. +.TP +.B \-w +Specify the horizontal size of the printed area (in inches). +.TP +.B \-W +Specify the maximum width of image (in inches). Images with larger sizes will +be split in several pages. Options +.B \-L +and +.B \-W +are mutually exclusive. +.TP +.B \-x +Override resolution units specified in the TIFF as centimeters. +.TP +.B \-y +Override resolution units specified in the TIFF as inches. +.TP +.B \-z +When generating \*(Ps Level 2, data is scaled so that it does not +image into the +.I deadzone +on a page (the outer margin that the printing device is unable to mark). +This option suppresses this behavior. +When \*(Ps Level 1 is generated, data is imaged to the entire printed +page and this option has no affect. +.SH EXAMPLES +The following generates \*(Ps Level 2 for all pages of a facsimile: +.RS +.nf +tiff2ps \-a2 fax.tif | lpr +.fi +.RE +Note also that if you have version 2.6.1 or newer of Ghostscript then you +can efficiently preview facsimile generated with the above command. +.PP +To generate Encapsulated \*(Ps for a the image at directory 2 +of an image use: +.RS +.nf +tiff2ps \-d 1 foo.tif +.fi +.RE +(Notice that directories are numbered starting at zero.) +.PP +If you have a long image, it may be split in several pages: +.RS +.nf +tiff2ps \-h11 \-w8.5 \-H14 \-L.5 foo.tif > foo.ps +.fi +.RE +The page size is set to 8.5x11 by +.B \-w +and +.B \-h +options. We will accept a small amount of vertical compression, so +.B \-H +set to 14. Any pages between 11 and 14 inches will be fit onto one page. +Pages longer than 14 inches are cut off at 11 and continued on the next +page. The +.B \-L.5 +option says to repeat a half inch on the next page (to improve readability). +.SH BUGS +Because \*(Ps does not support the notion of a colormap, +8-bit palette images produce 24-bit \*(Ps images. +This conversion results in output that is six times +bigger than the original image and which takes a long time +to send to a printer over a serial line. +Matters are even worse for 4-, 2-, and 1-bit palette images. +.PP +Does not handle tiled images when generating \*(Ps Level I output. +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR tiffinfo (1), +.BR tiffcp (1), +.BR tiffgt (1), +.BR tiffmedian (1), +.BR tiff2bw (1), +.BR tiffsv (1), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiff2rgba.1 b/thirdparty/SDL2_image/external/libtiff/man/tiff2rgba.1 new file mode 100644 index 000000000..fe9ebb2c6 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiff2rgba.1 @@ -0,0 +1,100 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFF2RGBA 1 "November 2, 2005" "libtiff" +.SH NAME +tiff2rgba \- convert a +.SM TIFF +image to RGBA color space +.SH SYNOPSIS +.B tiff2rgba +[ +.I options +] +.I input.tif +.I output.tif +.SH DESCRIPTION +.I Tiff2rgba +converts a wide variety of TIFF images into an RGBA TIFF image. This +includes the ability to translate different color spaces and photometric +interpretation into RGBA, support for alpha blending, and translation +of many different bit depths into a 32bit RGBA image. +.P +Internally this program is implemented using the +.I TIFFReadRGBAImage() +function, and it suffers any limitations of that image. This includes +limited support for > 8 BitsPerSample images, and flaws with some +esoteric combinations of BitsPerSample, photometric interpretation, +block organization and planar configuration. +.P +The generated images are stripped images with four samples per pixel +(red, green, blue and alpha) or if the +.B \-n +flag is used, three samples +per pixel (red, green, and blue). The resulting images are always planar +configuration contiguous. For this reason, this program is a useful utility +for transform exotic TIFF files into a form ingestible by almost any TIFF +supporting software. +.SH OPTIONS +.TP +.B \-c +Specify a compression scheme to use when writing image data: +.B "\-c none" +for no compression (the default), +.B "\-c packbits" +for the PackBits compression algorithm, +.B "\-c zip" +for the Deflate compression algorithm, +.B "\-c jpeg" +for the JPEG compression algorithm, +and +.B "\-c lzw" +for Lempel-Ziv & Welch. +.TP +.B \-r +Write data with a specified number of rows per strip; +by default the number of rows/strip is selected so that each strip +is approximately 8 kilobytes. +.TP +.B \-b +Process the image one block (strip/tile) at a time instead of by reading +the whole image into memory at once. This may be necessary for very large +images on systems with limited RAM. +.TP +.B \-n +Drop the alpha component from the output file, producing a pure RGB file. +Currently this does not work if the +.B \-b +flag is also in effect. +.TP +.BI \-M " size" +Set maximum memory allocation size (in MiB). The default is 256MiB. +Set to 0 to disable the limit. +.SH "SEE ALSO" +.BR tiff2bw (1), +.BR TIFFReadRGBAImage (3t), +.BR libtiff (3) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffcmp.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffcmp.1 new file mode 100644 index 000000000..ee83a742e --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffcmp.1 @@ -0,0 +1,86 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFCMP 1 "November 2, 2005" "libtiff" +.SH NAME +tiffcmp \- compare two +.SM TIFF +files +.SH SYNOPSIS +.B tiffcmp +[ +.I options +] +.I "file1.tif file2.tif" +.SH DESCRIPTION +.I Tiffcmp +compares the tags and data in two files created according +to the Tagged Image File Format, Revision 6.0. +The schemes used for compressing data in each file +are immaterial when data are compared\-data are compared on +a scanline-by-scanline basis after decompression. +Most directory tags are checked; notable exceptions are: +.IR GrayResponseCurve , +.IR ColorResponseCurve , +and +.IR ColorMap +tags. +Data will not be compared if any of the +.IR BitsPerSample , +.IR SamplesPerPixel , +or +.I ImageWidth +values are not equal. +By default, +.I tiffcmp +will terminate if it encounters any difference. +.SH OPTIONS +.TP +.B \-l +List each byte of image data that differs between the files. +.TP +.BI \-z " number" +List specified number of image data bytes that differs between the files. +.TP +.B \-t +Ignore any differences in directory tags. +.SH BUGS +Tags that are not recognized by the library are not +compared; they may also generate spurious diagnostics. +.PP +The image data of tiled files is not compared, since the +.I TIFFReadScanline() +function is used. An error will be reported for tiled files. +.PP +The pixel and/or sample number reported in differences may be off +in some exotic cases. +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR tiffinfo (1), +.BR tiffcp (1), +.BR tiffmedian (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffcp.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffcp.1 new file mode 100644 index 000000000..6bfee3486 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffcp.1 @@ -0,0 +1,331 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFCP 1 "February 24, 2007" "libtiff" +.SH NAME +tiffcp \- copy (and possibly convert) a +.SM TIFF +file +.SH SYNOPSIS +.B tiffcp +[ +.I options +] +.I "src1.tif ... srcN.tif dst.tif" +.SH DESCRIPTION +.I tiffcp +combines one or more files created according +to the Tag Image File Format, Revision 6.0 +into a single +.SM TIFF +file. +Because the output file may be compressed using a different +algorithm than the input files, +.I tiffcp +is most often used to convert between different compression +schemes. +.PP +By default, +.I tiffcp +will copy all the understood tags in a +.SM TIFF +directory of an input +file to the associated directory in the output file. +.PP +.I tiffcp +can be used to reorganize the storage characteristics of data +in a file, but it is explicitly intended to not alter or convert +the image data content in any way. +.SH OPTIONS +.TP +.B \-a +Append to an existing output file instead of overwriting it. +.TP +.BI \-b " image" +subtract the following monochrome image from all others +processed. This can be used to remove a noise bias +from a set of images. This bias image is typically an +image of noise the camera saw with its shutter closed. +.TP +.B \-B +Force output to be written with Big-Endian byte order. +This option only has an effect when the output file is created or +overwritten and not when it is appended to. +.TP +.B \-C +Suppress the use of ``strip chopping'' when reading images +that have a single strip/tile of uncompressed data. +.TP +.B \-c +Specify the compression to use for data written to the output file: +.B none +for no compression, +.B packbits +for PackBits compression, +.B lzw +for Lempel-Ziv & Welch compression, +.B zip +for Deflate compression, +.B lzma +for LZMA2 compression, +.B jpeg +for baseline JPEG compression, +.B g3 +for CCITT Group 3 (T.4) compression, +.B g4 +for CCITT Group 4 (T.6) compression, +or +.B sgilog +for SGILOG compression. +By default +.I tiffcp +will compress data according to the value of the +.I Compression +tag found in the source file. +.IP +The +.SM CCITT +Group 3 and Group 4 compression algorithms can only +be used with bilevel data. +.IP +Group 3 compression can be specified together with several +T.4-specific options: +.B 1d +for 1-dimensional encoding, +.B 2d +for 2-dimensional encoding, +and +.B fill +to force each encoded scanline to be zero-filled so that the +terminating EOL code lies on a byte boundary. +Group 3-specific options are specified by appending a ``:''-separated +list to the ``g3'' option; e.g. +.B "\-c g3:2d:fill" +to get 2D-encoded data with byte-aligned EOL codes. +.IP +.SM LZW, Deflate +and +.SM LZMA2 +compression can be specified together with a +.I predictor +value. A predictor value of 2 causes each scanline of the output image to +undergo horizontal differencing before it is encoded; a value of 1 forces each +scanline to be encoded without differencing. A value 3 is for floating point +predictor which you can use if the encoded data are in floating point format. +LZW-specific options are specified by appending a ``:''-separated list to the +``lzw'' option; e.g. +.B "\-c lzw:2" +for +.SM LZW +compression with horizontal differencing. +.IP +.SM Deflate +and +.SM LZMA2 +encoders support various compression levels (or encoder presets) set as +character ``p'' and a preset number. ``p1'' is the fastest one with the worst +compression ratio and ``p9'' is the slowest but with the best possible ratio; +e.g. +.B "\-c zip:3:p9" +for +.SM Deflate +encoding with maximum compression level and floating point predictor. +.IP +For the +.SM Deflate +codec, and in a libtiff build with libdeflate enabled, ``p12`` is +actually the maximum level. +.IP +For the +.SM Deflate +codec, and in a libtiff build with libdeflate enabled, ``s0`` can be used to +require zlib to be used, and ``s1`` for libdeflate (defaults to libdeflate when +it is available). +.TP +.B \-f +Specify the bit fill order to use in writing output data. +By default, +.I tiffcp +will create a new file with the same fill order as the original. +Specifying +.B "\-f lsb2msb" +will force data to be written with the FillOrder tag set to +.SM LSB2MSB, +while +.B "\-f msb2lsb" +will force data to be written with the FillOrder tag set to +.SM MSB2LSB. +.TP +.B \-i +Ignore non-fatal read errors and continue processing of the input file. +.TP +.B \-l +Specify the length of a tile (in pixels). +.I tiffcp +attempts to set the tile dimensions so +that no more than 8 kilobytes of data appear in a tile. +.TP +.B \-L +Force output to be written with Little-Endian byte order. +This option only has an effect when the output file is created or +overwritten and not when it is appended to. +.TP +.B \-M +Suppress the use of memory-mapped files when reading images. +.TP +.BI \-o " offset" +Set initial directory offset. +.TP +.B \-p +Specify the planar configuration to use in writing image data +that has one 8-bit sample per pixel. +By default, +.I tiffcp +will create a new file with the same planar configuration as +the original. +Specifying +.B "\-p contig" +will force data to be written with multi-sample data packed +together, while +.B "\-p separate" +will force samples to be written in separate planes. +.TP +.B \-r +Specify the number of rows (scanlines) in each strip of data +written to the output file. +By default (or when value +.B 0 +is specified), +.I tiffcp +attempts to set the rows/strip +that no more than 8 kilobytes of data appear in a strip. If you specify +special value +.B \-1 +it will results in infinite number of the rows per strip. The entire image +will be the one strip in that case. +.TP +.B \-s +Force the output file to be written with data organized in strips +(rather than tiles). +.TP +.B \-t +Force the output file to be written with data organized in tiles (rather than +strips). options can be used to force the resultant image to be written as +strips or tiles of data, respectively. +.TP +.B \-w +Specify the width of a tile (in pixels). +.I tiffcp +attempts to set the tile dimensions so that no more than 8 kilobytes of data +appear in a tile. +.I tiffcp +attempts to set the tile dimensions so that no more than 8 kilobytes of data +appear in a tile. +.TP +.B \-x +Force the output file to be written with PAGENUMBER value in sequence. +.TP +.B \-8 +Write BigTIFF instead of classic TIFF format. +.TP +.BI \-,= character +substitute +.I character +for `,' in parsing image directory indices +in files. This is necessary if filenames contain commas. +Note that +.B \-,= +with whitespace immediately following will disable +the special meaning of the `,' entirely. See examples. +.TP +.BI \-m " size" +Set maximum memory allocation size (in MiB). The default is 256MiB. +Set to 0 to disable the limit. +.SH EXAMPLES +The following concatenates two files and writes the result using +.SM LZW +encoding: +.RS +.nf +tiffcp \-c lzw a.tif b.tif result.tif +.fi +.RE +.PP +To convert a G3 1d-encoded +.SM TIFF +to a single strip of G4-encoded data the following might be used: +.RS +.nf +tiffcp \-c g4 \-r 10000 g3.tif g4.tif +.fi +.RE +(1000 is just a number that is larger than the number of rows in +the source file.) + +To extract a selected set of images from a multi-image TIFF file, the file +name may be immediately followed by a `,' separated list of image directory +indices. The first image is always in directory 0. Thus, to copy the 1st and +3rd images of image file ``album.tif'' to ``result.tif'': +.RS +.nf +tiffcp album.tif,0,2 result.tif +.fi +.RE + +A trailing comma denotes remaining images in sequence. The following command +will copy all image with except the first one: +.RS +.nf +tiffcp album.tif,1, result.tif +.fi +.RE + +Given file ``CCD.tif'' whose first image is a noise bias +followed by images which include that bias, +subtract the noise from all those images following it +(while decompressing) with the command: +.RS +.nf +tiffcp \-c none \-b CCD.tif CCD.tif,1, result.tif +.fi +.RE + +If the file above were named ``CCD,X.tif'', the +.B \-,= +option would +be required to correctly parse this filename with image numbers, +as follows: +.RS +.nf +tiffcp \-c none \-,=% \-b CCD,X.tif CCD,X%1%.tif result.tif +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR tiffinfo (1), +.BR tiffcmp (1), +.BR tiffmedian (1), +.BR tiffsplit (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffcrop.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffcrop.1 new file mode 100644 index 000000000..d7a4c4d74 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffcrop.1 @@ -0,0 +1,574 @@ +.\" tiffcrop -- a port of tiffcp.c extended to include extended processing of images +.\" +.\" Original code: +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.\" Additional code Copyright (c) 2006-2009 Richard Nolde +.\" Lasted Updated 9/2009 +.\" .if n .po 0 +.TH "TIFFCROP" "1" "December, 2008" "libtiff" "" +.SH "NAME" +tiffcrop \- select, copy, crop, convert, extract, and/or process one or more +.SM TIFF +files. +.SH "SYNOPSIS" +.B tiffcrop +[ +.I options +] +.I "src1.tif ... srcN.tif dst.tif" +.SH "DESCRIPTION" +.I Tiffcrop +processes one or more files created according +to the Tag Image File Format, Revision 6.0, specification +into one or more +.SM TIFF +file(s). +.I Tiffcrop +is most often used to extract portions of an image for processing +with bar code recognizer or OCR software when that software cannot +restrict the region of interest to a specific portion of the image +or to improve efficiency when the regions of interest must be rotated. +It can also be used to subdivide all or part of a processed image into +smaller sections and export individual images or sections of images +as separate files or separate images within one or more files derived +from the original input image or images. +.PP +The available functions can be grouped broadly into three classes: +.IP +Those that select individual images or sections of images from the input files. +The options \-N for sequences or lists of individual images in the input files, +\-Z for zones, \-z for regions, \-X and \-Y for fixed sized selections, +\-m for margins, \-U for units, and \-E for edge reference provide a variety of +ways to specify portions of the input image. +.IP +Those that allow the individual images or selections to be exported to one or +more output files in different groupings and control the organization of the +data in the output images. The options \-P for page size grouping, \-S for +subdivision into columns and rows and \-e for export mode options that produce +one or more files from each input image. The options \-r, \-s, \-t, \-w control +strip and tile format and sizes while \-B \-L \-c \-f modify the endian addressing +scheme, the compression options, and the bit fill sequence of images as they +are written. +.IP +Those that perform some action on each image that is selected from the input file. +The options include \-R for rotate, \-I for inversion of the photometric +interpretation and/or data values, and \-F to flip (mirror) the image horizontally +or vertically. +.PP + +Functions are applied to the input image(s) in the following order: +cropping, fixed area extraction, zone and region extraction, +inversion, mirroring, rotation. +.PP +Functions are applied to the output image(s) in the following order: +export mode options for grouping zones, regions, or images into +one or more files, +.I or +row and column divisions with output margins, +.I or +page size divisions with page orientation options. +.PP +Finally, strip, tile, byte order, output resolution, and compression options are +applied to all output images. +.PP +The output file(s) may be organized and compressed using a different +algorithm from the input files. +By default, +.I tiffcrop +will copy all the understood tags in a +.SM TIFF +directory of an input file to the associated directory in the output file. +Options can be used to force the resultant image to be written as strips +or tiles of data, respectively. +.PP +.I Tiffcrop +can be used to reorganize the storage characteristics of data +in a file, and to reorganize, extract, rotate, and otherwise +process the image data as specified at the same time whereas +tiffcp does not alter the image data within the file. +.PP +Using the options for selecting individual input images and the +options for exporting images and/or segments defined as zones or +regions of each input image, +.I tiffcrop +can perform the functions of tiffcp and tiffsplit in a single pass +while applying multiple operations to individual selections or images. +.PP +.SH "OPTIONS" +.TP +.B \-h +Display the syntax summary for tiffcrop. +.TP +.B \-v +Report the current version and last modification date for tiffcrop. +.TP +.B \-N odd|even|#,#\-#,#|last +Specify one or more series or range(s) of images within each file to process. +The words +.B odd +or +.B even +may be used to specify all odd or even numbered images counting from one. +Note that internally, TIFF images are numbered from zero rather than one +but since this convention is not obvious to most users, tiffcrop used 1 +to specifiy the first image in a multipage file. The word +.B last +may be used in place of a number in the sequence to indicate the +final image in the file without knowing how many images there are. +Ranges of images may be specified with a dash and multiple sets +can be indicated by joining them in a comma\-separated list. eg. use +.B \-N 1,5\-7,last +to process the 1st, 5th through 7th, and final image in the file. +.TP +.B \-E top|bottom|left|right +Specify the top, bottom, left, or right edge as the reference from +which to calcuate the width and length of crop regions or sequence +of postions for zones. When used with the \-e option for exporting +zones or regions, the reference edge determines how composite images +are arranged. Using \-E left or right causes successive zones or +regions to be merged horizontally whereas using \-E top or bottom +causes successive zones or regions to be arranged vertically. This +option has no effect on export layout when multiple zones or regions +are not being exported to composite images. Edges may be abbreviated +to the first letter. +.TP +.B \-e combined|divided|image|multiple|separate +Specify the export mode for images and selections from input images. +The final filename on the command line is considered to be the +destination file or filename stem for automatically generated +sequences of files. Modes may be abbreviated to the first letter. +.IP +combined All images and selections are written to a single file with +multiple selections from one image combined into a single image (default) +.IP +divided All images and selections are written to a single file +with each selection from one image written to a new image +.IP +image Each input image is written to a new file (numeric filename sequence) +with multiple selections from the image combined into one image +.IP +multiple Each input image is written to a new file (numeric filename sequence) +with each selection from the image written to a new image +.IP +separate Individual selections from each image are written to separate files +.TP +.B \-U in|cm|px +Specify the type of units to apply to dimensions for margins and +crop regions for input and output images. Inches or centimeters +are converted to pixels using the resolution unit specified in the +TIFF file (which defaults to inches if not specified in the IFD). +.TP +.B \-m #,#,#,# +Specify margins to be removed from the input image. The order must +be top, left, bottom, right with only commas separating the elements +of the list. Margins are scaled according to the current units and +removed before any other extractions are computed.. +.TP +.B \-X # +Set the horizontal (X\-axis) dimension of a region to extract relative to +the specified origin reference. If the origin is the top or bottom +edge, the X axis value will be assumed to start at the left edge. +.TP +.B \-Y # +Set the vertical (Y\-axis) dimension of a region to extract relative to +the specified origin reference. If the origin is the left or right +edge, the Y axis value will be assumed to start at the top. +.TP +.B \-Z #:#,#:# +Specify zones of the image designated as position X of Y equal sized portions +measured from the reference edge, eg 1:3 would be first third of the +image starting from the reference edge minus any margins specified +for the confining edges. Multiple zones can be specified as a comma +separated list but they must reference the same edge. To extract the +top quarter and the bottom third of an image you would use +.B \-Z 1:4,3:3. +.TP +.B \-z x1,y1,x2,y2: ... :xN,yN,xN+1,yN+1 +Specify a series of coordinates to define regions for processing and exporting. +The coordinates represent the top left and lower right corners of each region +in the current units, eg inch, cm, or pixels. Pixels are counted from one to +width or height and inches or cm are calculated from image resolution data. + +Each colon delimited series of four values represents the horizontal and vertical +offsets from the top and left edges of the image, regardless of the edge specified +with the \-E option. The first and third values represent the horizontal offsets of +the corner points from the left edge while the second and fourth values represent +the vertical offsets from the top edge. +.TP +.B \-F horiz|vert +Flip, ie mirror, the image or extracted region horizontally or vertically. +.TP +.B \-R 90|180|270 +Rotate the image or extracted region 90, 180, or 270 degrees clockwise. +.TP +.B \\-I [black|white|data|both] +Invert color space, eg dark to light for bilevel and grayscale images. +This can be used to modify negative images to positive or to correct +images that have the PHOTOMETRIC_INTERPRETATIN tag set incorrectly. +If the value is black or white, the PHOTOMETRIC_INTERPRETATION tag is set to +MinIsBlack or MinIsWhite, without altering the image data. If the argument +is data or both, the data values of the image are modified. Specifying both +inverts the data and the PHOTOMETRIC_INTERPRETATION tag, whereas using data +inverts the data but not the PHOTOMETRIC_INTERPRETATION tag. +No support for modifying the color space of color images in this release. +.TP +.B \-H # +Set the horizontal resolution of output images to # +expressed in the current units. +.TP +.B \-V # +Set the vertical resolution of the output images to # +expressed in the current units. +.TP +.B \-J # +Set the horizontal margin of an output page size to # +expressed in the current units when sectioning image into columns x rows +subimages using the \-S cols:rows option. +.TP +.B \-K # +Set the vertical margin of an output page size to # +expressed in the current units when sectioning image into columns x rows +submiages using the \-S cols:rows option. +.TP +.B \-O portrait|landscape|auto +Set the output orientation of the pages or sections. +Auto will use the arrangement that requires the fewest pages. +This option is only meaningful in conjunction with the -P +option to format an image to fit on a specific paper size. +.TP +.B \-P page +Format the output images to fit on page size paper. Use +\-P list to show the supported page sizes and dimensions. +You can define a custom page size by entering the width and length of the +page in the current units with the following format #.#x#.#. +.TP +.B \-S cols:rows +Divide each image into cols across and rows down equal sections. +.TP +.B \-B +Force output to be written with Big\-Endian byte order. +This option only has an effect when the output file is created or +overwritten and not when it is appended to. +.TP +.B \-C +Suppress the use of ``strip chopping'' when reading images +that have a single strip/tile of uncompressed data. +.TP +.B \-c +Specify the compression to use for data written to the output file: +.B none +for no compression, +.B packbits +for PackBits compression, +.B lzw +for Lempel\-Ziv & Welch compression, +.B jpeg +for baseline JPEG compression. +.B zip +for Deflate compression, +.B g3 +for CCITT Group 3 (T.4) compression, +and +.B g4 +for CCITT Group 4 (T.6) compression. +By default +.I tiffcrop +will compress data according to the value of the +.I Compression +tag found in the source file. +.IP +The +.SM CCITT +Group 3 and Group 4 compression algorithms can only +be used with bilevel data. +.IP +Group 3 compression can be specified together with several +T.4\-specific options: +.B 1d +for 1\-dimensional encoding, +.B 2d +for 2\-dimensional encoding, +and +.B fill +to force each encoded scanline to be zero\-filled so that the +terminating EOL code lies on a byte boundary. +Group 3\-specific options are specified by appending a ``:''\-separated +list to the ``g3'' option; e.g. +.B "\-c g3:2d:fill" +to get 2D\-encoded data with byte\-aligned EOL codes. +.IP +.SM LZW +compression can be specified together with a +.I predictor +value. +A predictor value of 2 causes +each scanline of the output image to undergo horizontal +differencing before it is encoded; a value +of 1 forces each scanline to be encoded without differencing. +LZW\-specific options are specified by appending a ``:''\-separated +list to the ``lzw'' option; e.g. +.B "\-c lzw:2" +for +.SM LZW +compression with horizontal differencing. +.TP +.B \-f +Specify the bit fill order to use in writing output data. +By default, +.I tiffcrop +will create a new file with the same fill order as the original. +Specifying +.B "\-f lsb2msb" +will force data to be written with the FillOrder tag set to +.SM LSB2MSB, +while +.B "\-f msb2lsb" +will force data to be written with the FillOrder tag set to +.SM MSB2LSB. +.TP +.B \-i +Ignore non\-fatal read errors and continue processing of the input file. +.TP +.B "\-k size" +Set maximum memory allocation size (in MiB). The default is 256MiB. +Set to 0 to disable the limit. +.TP +.B \-l +Specify the length of a tile (in pixels). +.I Tiffcrop +attempts to set the tile dimensions so +that no more than 8 kilobytes of data appear in a tile. +.TP +.B \-L +Force output to be written with Little\-Endian byte order. +This option only has an effect when the output file is created or +overwritten and not when it is appended to. +.TP +.B \-M +Suppress the use of memory\-mapped files when reading images. +.TP +.B \-p +Specify the planar configuration to use in writing image data +that has more than one sample per pixel. +By default, +.I tiffcrop +will create a new file with the same planar configuration as +the original. +Specifying +.B "\-p contig" +will force data to be written with multi\-sample data packed +together, while +.B "\-p separate" +will force samples to be written in separate planes. +.TP +.B \-r +Specify the number of rows (scanlines) in each strip of data +written to the output file. +By default (or when value +.B 0 +is specified), +.I tiffcrop +attempts to set the rows/strip that no more than 8 kilobytes of +data appear in a strip. If you specify the special value +.B \-1 +it will results in infinite number of the rows per strip. The entire image +will be the one strip in that case. +.TP +.B \-s +Force the output file to be written with data organized in strips +(rather than tiles). +.TP +.B \-t +Force the output file to be written with data organized in tiles +(rather than strips). +.TP +.B \-w +Specify the width of a tile (in pixels). +.I tiffcrop +attempts to set the tile dimensions so +that no more than 8 kilobytes of data appear in a tile. +.I tiffcrop +attempts to set the tile dimensions so +that no more than 8 kilobytes of data appear in a tile. +.TP +Debug and dump facility +.B \-D opt1:value1,opt2:value2,opt3:value3:opt4:value4 +Display program progress and/or dump raw data to non\-TIFF files. +Options include the following and must be joined as a comma +separated list. The use of this option is generally limited to +program debugging and development of future options. An equal sign +may be substituted for the colon in option:value pairs. +.IP +debug:N Display limited program progress indicators where larger N +increase the level of detail. +.IP +format:txt|raw Format any logged data as ASCII text or raw binary +values. ASCII text dumps include strings of ones and zeroes representing +the binary values in the image data plus identifying headers. +.IP +level:N Specify the level of detail presented in the dump files. +This can vary from dumps of the entire input or output image data to dumps +of data processed by specific functions. Current range of levels is 1 to 3. +.IP +input:full\-path\-to\-directory/input\-dumpname +.IP +output:full\-path\-to\-directory/output\-dumpname +.IP +When dump files are being written, each image will be written to a separate +file with the name built by adding a numeric sequence value to the dumpname +and an extension of .txt for ASCII dumps or .bin for binary dumps. + +The four debug/dump options are independent, though it makes little sense to +specify a dump file without specifying a detail level. +.IP +Note: Tiffcrop may be compiled with -DDEVELMODE to enable additional very + low level debug reporting. +.SH "EXAMPLES" +The following concatenates two files and writes the result using +.SM LZW +encoding: +.RS +.nf +tiffcrop \-c lzw a.tif b.tif result.tif +.fi +.RE +.PP +To convert a G3 1d\-encoded +.SM TIFF +to a single strip of G4\-encoded data the following might be used: +.RS +.nf +tiffcrop \-c g4 \-r 10000 g3.tif g4.tif +.fi +.RE +(1000 is just a number that is larger than the number of rows in +the source file.) + +To extract a selected set of images from a multi\-image TIFF file +use the \-N option described above. Thus, to copy the 1st and 3rd +images of image file "album.tif" to "result.tif": +.RS +.nf +tiffcrop \-N 1,3 album.tif result.tif +.fi +.RE +.PP +Invert a bilevel image scan of a microfilmed document and crop off margins of +0.25 inches on the left and right, 0.5 inch on the top, and 0.75 inch on the +bottom. From the remaining portion of the image, select the second and third +quarters, ie, one half of the area left from the center to each margin. +.RS +tiffcrop \-U in \-m 0.5,0.25,0.75,0.25 \-E left \-Z 2:4,3:4 \-I both MicrofilmNegative.tif MicrofilmPostiveCenter.tif +.fi +.RE +.PP +Extract only the final image of a large Architectural E sized +multipage TIFF file and rotate it 90 degrees clockwise while +reformatting the output to fit on tabloid sized sheets with one +quarter of an inch on each side: +.RS +tiffcrop \-N last \-R 90 \-O auto \-P tabloid \-U in \-J 0.25 \-K 0.25 \-H 300 \-V 300 Big\-PlatMap.tif BigPlatMap\-Tabloid.tif +.fi +.RE +The output images will have a specified resolution of 300 dpi in both +directions. The orientation of each page will be determined by whichever +choice requires the fewest pages. To specify a specific orientation, use +the portrait or landscape option. The paper size option does not resample +the image. It breaks each original image into a series of smaller images +that will fit on the target paper size at the specified resolution. +.fi +.RE +.PP +Extract two regions 2048 pixels wide by 2048 pixels high from each page of +a multi\-page input file and write each region to a separate output file. +.RS +tiffcrop \-U px \-z 1,1,2048,2048:1,2049,2048,4097 \-e separate CheckScans.tiff Check +.fi +.RE +The output file names will use the stem Check with a numeric suffix which is +incremented for each region of each image, eg Check\-001.tiff, Check\-002.tiff ... +Check\-NNN.tiff. To produce a unique file for each page of the input image +with one new image for each region of the input image on that page, change +the export option to \-e multiple. + +.SH "NOTES" +.PP +In general, bilevel, grayscale, palette and RGB(A) data with bit depths +from 1 to 32 bits should work in both interleaved and separate plane +formats. Unlike tiffcp, tiffcrop can read and write tiled images with +bits per sample that are not a multiple of 8 in both interleaved and +separate planar format. Floating point data types are supported at +bit depts of 16, 24, 32 and 64 bits per sample. +.PP +Not all images can be converted from one compression scheme to another. +Data with some photometric interpretations and/or bit depths are tied to +specific compression schemes and vice-versa, e.g. Group 3/4 compression +is only usable for bilevel data. JPEG compression is only usable on 8 +bit per sample data (or 12 bit if +.I LibTIFF +was compiled with 12 bit JPEG support). Support for OJPEG compressed +images is problematic at best. Since OJPEG compression is no longer +supported for writing images with LibTIFF, these images will be updated +to the newer JPEG compression when they are copied or processed. This +may cause the image to appear color shifted or distorted after conversion. +In some cases, it is possible to remove the original compression from +image data using the option -cnone. +.PP +Tiffcrop does not currently provide options to up or downsample data to +different bit depths or convert data from one photometric interpretation +to another, e.g. 16 bits per sample to 8 bits per sample or RGB to grayscale. +.PP +Tiffcrop is very loosely derived from code in +.I tiffcp +with extensive modifications and additions to support the selection of input +images and regions and the exporting of them to one or more output files in +various groupings. The image manipulation routines are entirely new and +additional ones may be added in the future. It will handle tiled images with +bit depths that are not a multiple of eight that tiffcp may refuse to read. +.PP +.I Tiffcrop +was designed to handle large files containing many moderate sized images +with memory usage that is independent of the number of images in the file. +In order to support compression modes that are not based on individual +scanlines, e.g. JPEG, it now reads images by strip or tile rather than by +indvidual scanlines. In addition to the memory required by the input and +output buffers associated with +.I LibTIFF +one or more buffers at least as large as the largest image to be read are +required. The design favors large volume document processing uses over +scientific or graphical manipulation of large datasets as might be found +in research or remote sensing scenarios. +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR tiffinfo (1), +.BR tiffcmp (1), +.BR tiffcp (1), +.BR tiffmedian (1), +.BR tiffsplit (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ + diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffdither.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffdither.1 new file mode 100644 index 000000000..56725b2bc --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffdither.1 @@ -0,0 +1,134 @@ +.\" +.\" Copyright (c) 1990-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFDITHER 1 "September 20, 2005" "libtiff" +.SH NAME +tiffdither \- convert a greyscale image to bilevel using dithering +.SH SYNOPSIS +.B tiffdither +[ +.I options +] +.I input.tif +.I output.tif +.SH DESCRIPTION +.I tiffdither +converts a single channel 8-bit greyscale image to a bilevel image +using Floyd-Steinberg error propagation with thresholding. +.SH OPTIONS +.TP +.B \-c +Specify the compression to use for data written to the output file: +.B none +for no compression, +.B packbits +for PackBits compression, +.B lzw +for Lempel-Ziv & Welch compression, +.B zip +for Deflate compression, +.B g3 +for CCITT Group 3 (T.4) compression, +and +.B g4 +for CCITT Group 4 (T.6) compression. +By default +.I tiffdither +will compress data according to the value of the +.I Compression +tag found in the source file. +.IP +The +.SM CCITT +Group 3 and Group 4 compression algorithms can only +be used with bilevel data. +.IP +Group 3 compression can be specified together with several +T.4-specific options: +.B 1d +for 1-dimensional encoding, +.B 2d +for 2-dimensional encoding, +and +.B fill +to force each encoded scanline to be zero-filled so that the +terminating EOL code lies on a byte boundary. +Group 3-specific options are specified by appending a ``:''-separated +list to the ``g3'' option; e.g. +.B "\-c g3:2d:fill" +to get 2D-encoded data with byte-aligned EOL codes. +.IP +.SM LZW +compression can be specified together with a +.I predictor +value. +A predictor value of 2 causes +each scanline of the output image to undergo horizontal +differencing before it is encoded; a value +of 1 forces each scanline to be encoded without differencing. +LZW-specific options are specified by appending a ``:''-separated +list to the ``lzw'' option; e.g. +.B "\-c lzw:2" +for +.SM LZW +compression with horizontal differencing. +.TP +.B \-f +Specify the bit fill order to use in writing output data. +By default, +.I tiffdither +will create a new file with the same fill order as the original. +Specifying +.B "\-f lsb2msb" +will force data to be written with the +.I Fill\%Order +tag set to +.SM LSB2MSB , +while +.B "\-f msb2lsb" +will force data to be written with the +.I Fill\%Order +tag set to +.SM MSB2LSB . +.TP +.B \-r +Make each strip have no more than the given number of rows. +.TP +.B \-t +Set the threshold value for dithering. +By default the threshold value is 128. +.SH NOTES +The dither algorithm is taken from the +.BR tiffmedian (1) +program (written by Paul Heckbert). +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR fax2tiff (1), +.BR tiffinfo (1), +.BR tiffcp (1), +.BR tiff2bw (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffdump.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffdump.1 new file mode 100644 index 000000000..07b08e3c4 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffdump.1 @@ -0,0 +1,80 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFDUMP 1 "October 23, 2005" "libtiff" +.SH NAME +tiffdump \- print verbatim information about +.SM TIFF +files +.SH SYNOPSIS +.B tiffdump +[ +.I options +] +.I "name \&..." +.SH DESCRIPTION +.I tiffdump +displays directory information from files created according +to the Tag Image File Format, Revision 6.0. +The header of each +.SM TIFF +file (magic number, version, and first directory offset) +is displayed, followed by the tag contents of each directory in the file. +For each tag, the name, data type, count, and value(s) is displayed. +When the symbolic name for a tag or data type is known, the symbolic +name is displayed followed by it's numeric (decimal) value. +Tag values are displayed enclosed in ``<>'' characters immediately +preceded by the value of the count field. +For example, an +.I ImageWidth +tag might be displayed as ``ImageWidth (256) SHORT (3) 1<800>''. +.PP +.I tiffdump +is particularly useful for investigating the contents of +.SM TIFF +files that +.I libtiff +does not understand. +.SH OPTIONS +.TP +.B \-h +Force numeric data to be printed in hexadecimal rather than the +default decimal. +.TP +.BI \-m " items" +Change the number of indirect data items that are printed. By default, this +will be 24. +.TP +.BI \-o " offset" +Dump the contents of the +.SM IFD +at the a particular file offset. +The file offset may be specified using the usual C-style syntax; +i.e. a leading ``0x'' for hexadecimal and a leading ``0'' for octal. +.SH "SEE ALSO" +.BR tiffinfo (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffgt.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffgt.1 new file mode 100644 index 000000000..6ef6209f9 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffgt.1 @@ -0,0 +1,244 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFGT 1 "September 20, 2005" "libtiff" +.SH NAME +tiffgt \- display an image stored in a +.SM TIFF +file (Silicon Graphics version) +.SH SYNOPSIS +.B tiffgt +[ +.I options +] +.I "input.tif ..." +.SH DESCRIPTION +.I tiffgt +displays one or more images stored using the +Tag Image File Format, Revision 6.0. +Each image is placed in a fixed size window that the +user must position on the display (unless configured +otherwise through X defaults). +If the display has fewer than 24 bitplanes, or if the +image does not warrant full color, then +.SM RGB +color values are mapped to the closest values that exist in +the colormap (this is done using the +.I rgbi +routine found in the graphics utility library +.BR \-lgutil .) +.PP +.I tiffgt +correctly handles files with any of the following characteristics: +.sp .5 +.in +0.5i +.ta \w'\fIPhotometricInterpretation\fP 'u +.nf +\fIBitsPerSample\fP 1, 2, 4, 8, 16 +\fISamplesPerPixel\fP 1, 3, 4 (the 4th sample is ignored) +\fIPhotometricInterpretation\fP 0 (min-is-white), 1 (min-is-black), 2 (RGB), 3 (palette), 6 (YCbCr) +\fIPlanarConfiguration\fP 1 (contiguous), 2 (separate) +\fIOrientation\fP 1 (top-left), 4 (bottom-left) +.fi +.in -0.5i +.sp .5 +Data may be organized as strips or tiles and may be +compressed with any of the compression algorithms supported +by the +.IR libtiff (3) +library. +.PP +For palette images (\c +.IR PhotometricInterpretation =3), +.I tiffgt +inspects the colormap values and assumes either 16-bit +or 8-bit values according to the maximum value. +That is, if no colormap entry greater than 255 is found, +.I tiffgt +assumes the colormap has only 8-bit values; otherwise +it assumes 16-bit values. +This inspection is done to handle old images written by +previous (incorrect) versions of +.IR libtiff . +.PP +.I tiffgt +can be used to display multiple images one-at-a-time. +The left mouse button switches the display to the first image in the +.I next +file in the list of files specified on the command line. +The right mouse button switches to the first image in the +.I previous +file in the list. +The middle mouse button causes the first image in the first file +specified on the command line to be displayed. +In addition the following keyboard commands are recognized: +.TP +.B b +Use a +.I PhotometricInterpretation +of MinIsBlack in displaying the current image. +.TP +.B l +Use a +.I FillOrder +of lsb-to-msb in decoding the current image. +.TP +.B m +Use a +.I FillOrder +of msb-to-lsb in decoding the current image. +.TP +.B c +Use a colormap visual to display the current image. +.TP +.B r +Use a true color (24-bit RGB) visual to display the current image. +.TP +.B w +Use a +.I PhotometricInterpretation +of MinIsWhite in displaying the current image. +.TP +.B W +Toggle (enable/disable) display of warning messages from the +.SM TIFF +library when decoding images. +.TP +.B E +Toggle (enable/disable) display of error messages from the +.SM TIFF +library when decoding images. +.TP +.B z +Reset all parameters to their default settings (\c +.IR FillOrder , +.IR PhotometricInterpretation , +handling of warnings and errors). +.TP +.B PageUp +Display the previous image in the current file or the last +image in the previous file. +.TP +.B PageDown +Display the next image in the current file or the first image +in the next file. +.TP +.B Home +Display the first image in the current file. +.TP +.B End +Display the last image in the current file (unimplemented). +.SH OPTIONS +.TP +.B \-c +Force image display in a colormap window. +.TP +.B \-d +Specify an image to display by directory number. +By default the first image in the file is displayed. +Directories are numbered starting at zero. +.TP +.B \-e +Enable reporting of error messages from the +.SM TIFF +library. +By default +.I tiffgt +silently ignores images that cannot be read. +.TP +.B \-f +Force +.I tiffgt +to run as a foreground process. +By default +.I tiffgt +will place itself in the background once it has opened the +requested image file. +.TP +.B \-l +Force the presumed bit ordering to be +.SM LSB +to +.SM MSB. +.TP +.B \-m +Force the presumed bit ordering to be +.SM MSB +to +.SM LSB. +.TP +.B \-o +Specify an image to display by directory offset. +By default the first image in the file is displayed. +Directories offsets may be specified using C-style syntax; +i.e. a leading ``0x'' for hexadecimal and a leading ``0'' for octal. +.TP +.B \-p +Override the value of the +.I PhotometricInterpretation +tag; the parameter may be one of: +.BR miniswhite , +.BR minisblack , +.BR rgb , +.BR palette , +.BR mask , +.BR separated , +.BR ycbcr , +and +.BR cielab . +.TP +.B \-r +Force image display in a full color window. +.TP +.B \-s +Stop on the first read error. +By default all errors in the input data are ignored and +.I tiffgt +does it's best to display as much of an image as possible. +.TP +.B \-w +Enable reporting of warning messages from the +.SM TIFF +library. +By default +.I tiffgt +ignores warning messages generated when reading an image. +.TP +.B \-v +Place information in the title bar describing +what type of window (full color or colormap) is being +used, the name of the input file, and the directory +index of the image (if non-zero). +By default, the window type is not shown in the title bar. +.SH BUGS +Images wider and taller than the display are silently truncated to avoid +crashing old versions of the window manager. +.SH "SEE ALSO" +.BR tiffdump (1), +.BR tiffinfo (1), +.BR tiffcp (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffinfo.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffinfo.1 new file mode 100644 index 000000000..64958a6c0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffinfo.1 @@ -0,0 +1,87 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFINFO 1 "November 2, 2005" "libtiff" +.SH NAME +tiffinfo \- print information about +.SM TIFF +files +.SH SYNOPSIS +.B tiffinfo +[ +.I options +] +.I "input.tif \&..." +.SH DESCRIPTION +.I Tiffinfo +displays information about files created according +to the Tag Image File Format, Revision 6.0. +By default, the contents of each +.SM TIFF +directory in each file +is displayed, with the value of each tag shown symbolically +(where sensible). +.SH OPTIONS +.TP +.B \-c +Display the colormap and color/gray response curves, if present. +.TP +.B \-D +In addition to displaying the directory tags, +read and decompress all the data in each image (but not display it). +.TP +.B \-d +In addition to displaying the directory tags, +print each byte of decompressed data in hexadecimal. +.TP +.B \-j +Display any \s-2JPEG\s0-related tags that are present. +.TP +.B \-o +Set the initial +.SM TIFF +directory according to the specified file offset. +The file offset may be specified using the usual C-style syntax; +i.e. a leading ``0x'' for hexadecimal and a leading ``0'' for octal. +.TP +.B \-s +Display the offsets and byte counts for each data strip in a directory. +.TP +.B \-z +Enable strip chopping when reading image data. +.TP +.B \-# +Set the initial +.SM TIFF +directory to +.IR # . +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR tiffcp (1), +.BR tiffcmp (1), +.BR tiffmedian (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffmedian.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffmedian.1 new file mode 100644 index 000000000..b10ba7989 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffmedian.1 @@ -0,0 +1,111 @@ +.\" +.\" Copyright (c) 1990-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFMEDIAN 1 "November 2, 2005" "libtiff" +.SH NAME +tiffmedian \- apply the median cut algorithm to data in a +.SM TIFF +file +.SH SYNOPSIS +.B tiffmedian +[ +.I options +] +.I input.tif +.I output.tif +.SH DESCRIPTION +.I tiffmedian +applies the median cut algorithm to an +.SM RGB +image in +.I input.tif +to generate a palette image that is written to +.IR output.tif . +The generated colormap has, by default, 256 entries. +The image data is quantized by mapping each +pixel to the closest color values in the colormap. +.SH OPTIONS +.TP +.B \-c +Specify the compression to use for data written to the output file: +.B none +for no compression, +.B packbits +for PackBits compression, +.B lzw +for Lempel-Ziv & Welch compression, +and +.B zip +for Deflate compression. +By default +.I tiffmedian +will compress data according to the value of the +.I Compression +tag found in the source file. +.IP +.SM LZW +compression can be specified together with a +.I predictor +value. +A predictor value of 2 causes +each scanline of the output image to undergo horizontal +differencing before it is encoded; a value +of 1 forces each scanline to be encoded without differencing. +LZW-specific options are specified by appending a ``:''-separated +list to the ``lzw'' option; e.g. +.B "\-c lzw:2" +for +.SM LZW +compression with horizontal differencing. +.TP +.B \-C +Specify the number of entries to use in the generated colormap. +By default all 256 entries/colors are used. +.TP +.B \-f +Apply Floyd-Steinberg dithering before selecting a colormap entry. +.TP +.B \-r +Specify the number of rows (scanlines) in each strip of data +written to the output file. +By default, +.I tiffmedian +attempts to set the rows/strip +that no more than 8 kilobytes of data appear in a strip. +.SH NOTES +This program is derived from Paul Heckbert's +.I median +program. +.SH "SEE ALSO" +.BR pal2rgb (1), +.BR tiffinfo (1), +.BR tiffcp (1), +.BR tiffcmp (1), +.BR libtiff (3TIFF) +.PP +.BR "Color Image Quantization for Frame Buffer Display", +Paul Heckbert, SIGGRAPH proceedings, 1982, pp. 297-307. +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffset.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffset.1 new file mode 100644 index 000000000..513c75671 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffset.1 @@ -0,0 +1,98 @@ +.\" +.\" Copyright (c) 1988-1997 Sam Leffler +.\" Copyright (c) 1991-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFSET 1 "December 3, 2012" "libtiff" +.SH NAME +tiffset \- set or unset a field in a +.SM TIFF +header +.SH SYNOPSIS +.B tiffset +[ +.I options +] +.I filename.tif +.SH DESCRIPTION +.I Tiffset +sets the value of a +.SM TIFF +header to a specified value or removes an existing setting. +.SH OPTIONS +.TP +.BI \-d " dirnumber" +change the current directory (starting at 0). +.TP +.BI \-s " tagnumber" "\fR [\fP" " count" "\fR ]\fP" " value ..." +Set the value of the named tag to the value or values specified. +.TP +.BI \-sd " diroffset" +change the current directory by offset. +.TP +.BI \-sf " tagnumber filename" +Set the value of the tag to the contents of filename. This option is +supported for ASCII tags only. +.TP +.BI \-u " tagnumber" +Unset the tag. +.SH EXAMPLES +The following example sets the image description tag (270) of a.tif to +the contents of the file descrip: +.RS +.nf +tiffset \-sf 270 descrip a.tif +.fi +.RE +.PP +The following example sets the artist tag (315) of a.tif to the string +``Anonymous'': +.RS +.nf +tiffset \-s 315 Anonymous a.tif +.fi +.RE +.PP +This example sets the resolution of the file a.tif to 300 dpi: +.RS +.nf +tiffset \-s 296 2 a.tif +tiffset \-s 282 300.0 a.tif +tiffset \-s 283 300.0 a.tif +.fi +.RE +.PP +Set the photometric interpretation of the third page of a.tif to +min-is-black (ie. inverts it): +.RS +.nf +tiffset -d 2 -s 262 1 a.tif +.fi +.RE +.SH "SEE ALSO" +.BR tiffdump (1), +.BR tiffinfo (1), +.BR tiffcp (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/man/tiffsplit.1 b/thirdparty/SDL2_image/external/libtiff/man/tiffsplit.1 new file mode 100644 index 000000000..fe309f423 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/man/tiffsplit.1 @@ -0,0 +1,68 @@ +.\" +.\" Copyright (c) 1992-1997 Sam Leffler +.\" Copyright (c) 1992-1997 Silicon Graphics, Inc. +.\" +.\" Permission to use, copy, modify, distribute, and sell this software and +.\" its documentation for any purpose is hereby granted without fee, provided +.\" that (i) the above copyright notices and this permission notice appear in +.\" all copies of the software and related documentation, and (ii) the names of +.\" Sam Leffler and Silicon Graphics may not be used in any advertising or +.\" publicity relating to the software without the specific, prior written +.\" permission of Sam Leffler and Silicon Graphics. +.\" +.\" THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +.\" EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +.\" WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +.\" +.\" IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +.\" ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, +.\" OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +.\" WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +.\" LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +.\" OF THIS SOFTWARE. +.\" +.if n .po 0 +.TH TIFFSPLIT 1 "September 20, 2005" "libtiff" +.SH NAME +tiffsplit \- split a multi-image +.SM TIFF +into single-image +.SM TIFF +files +.SH SYNOPSIS +.B tiffsplit +.I src.tif +[ +.I prefix +] +.SH DESCRIPTION +.I tiffsplit +takes a multi-directory (page) +.SM TIFF +file and creates one or more single-directory (page) +.SM TIFF +files from it. +The output files are given names created by concatenating +a prefix, a lexically ordered +suffix in the range [\fIaaa\fP-\fIzzz\fP], the suffix +.I .tif +(e.g. +.IR xaaa.tif , +.IR xaab.tif , +.IR ... , +.IR xzzz.tif ). +If a prefix is not specified on the command line, +the default prefix of +.I x +is used. +.SH OPTIONS +None. +.SH BUGS +Only a select set of ``known tags'' is copied when splitting. +.SH "SEE ALSO" +.BR tiffcp (1), +.BR tiffinfo (1), +.BR libtiff (3TIFF) +.PP +Libtiff library home page: +.BR http://www.simplesystems.org/libtiff/ diff --git a/thirdparty/SDL2_image/external/libtiff/nmake.opt b/thirdparty/SDL2_image/external/libtiff/nmake.opt new file mode 100644 index 000000000..d9bf15f19 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/nmake.opt @@ -0,0 +1,220 @@ +# +# Copyright (C) 2004, Andrey Kiselev +# +# 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. + +# Compile time parameters for MS Visual C++ compiler. +# You may edit this file to specify building options. + +# Options: +# DEBUG - set to disable optimizations and link with debug runtimes +# +# Usage examples (see details below): +# nmake -f makefile.vc +# nmake -f makefile.vc DEBUG=1 +# nmake -f makefile.vc clean +# +# +###### Edit the following lines to choose a feature set you need. ####### +# + +# +# Comment out the following lines to disable internal codecs. +# +# Support for CCITT Group 3 & 4 algorithms +CCITT_SUPPORT = 1 +# Support for Macintosh PackBits algorithm +PACKBITS_SUPPORT = 1 +# Support for LZW algorithm +LZW_SUPPORT = 1 +# Support for ThunderScan 4-bit RLE algorithm +THUNDER_SUPPORT = 1 +# Support for NeXT 2-bit RLE algorithm +NEXT_SUPPORT = 1 +# Support for LogLuv high dynamic range encoding +LOGLUV_SUPPORT = 1 + +# +# Uncomment and edit following lines to enable JPEG support. +# +#JPEG_SUPPORT = 1 +#JPEGDIR = d:/projects/jpeg-6b +#JPEG_INCLUDE = -I$(JPEGDIR) +#JPEG_LIB = $(JPEGDIR)/Release/jpeg.lib + +# +# Uncomment and edit following lines to enable ZIP support +# (required for Deflate compression and Pixar log-format) +# +#ZIP_SUPPORT = 1 +#ZLIBDIR = d:/projects/zlib-1.2.1 +#ZLIB_INCLUDE = -I$(ZLIBDIR) +#ZLIB_LIB = $(ZLIBDIR)/zlib.lib + +# +# Uncomment and edit following lines to enable ISO JBIG support +# +#JBIG_SUPPORT = 1 +#JBIGDIR = d:/projects/jbigkit +#JBIG_INCLUDE = -I$(JBIGDIR)/libjbig +#JBIG_LIB = $(JBIGDIR)/libjbig/jbig.lib + +# +# Uncomment following line to enable Pixar log-format algorithm +# (Zlib required). +# +#PIXARLOG_SUPPORT = 1 + +# +# Comment out the following lines to disable strip chopping +# (whether or not to convert single-strip uncompressed images to mutiple +# strips of specified size to reduce memory usage). Default strip size +# is 8192 bytes, it can be configured via the STRIP_SIZE_DEFAULT parameter +# +STRIPCHOP_SUPPORT = 1 +STRIP_SIZE_DEFAULT = 8192 + +# +# Comment out the following lines to disable treating the fourth sample with +# no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA +# files but don't mark the alpha properly. +# +EXTRASAMPLE_AS_ALPHA_SUPPORT = 1 + +# +# Comment out the following lines to disable picking up YCbCr subsampling +# info from the JPEG data stream to support files lacking the tag. +# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details. +# +CHECK_JPEG_YCBCR_SUBSAMPLING = 1 + +# +####################### Compiler related options. ####################### +# + + +# Indicate if the compiler provides strtoll/strtoull (default 1) +# Users of MSVC++ 14.0 ("Visual Studio 2015") and later should set this to 1 +HAVE_STRTOLL = 1 + +# +# Pick debug or optimized build flags. We default to an optimized build +# with no debugging information. +# NOTE: /EHsc option required if you want to build the C++ stream API +# +!IFDEF DEBUG +OPTFLAGS = /MDd /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE +!ELSE +OPTFLAGS = /Ox /MD /EHsc /W3 /D_CRT_SECURE_NO_DEPRECATE +!ENDIF +#OPTFLAGS = /Zi + +# +# Uncomment following line to enable using Windows Common RunTime Library +# instead of Windows specific system calls. See notes on top of tif_unix.c +# module for details. +# +USE_WIN_CRT_LIB = 1 + +# Compiler specific options. You may probably want to adjust compilation +# parameters in CFLAGS variable. Refer to your compiler documentation +# for the option reference. +# +MAKE = nmake /nologo +CC = cl /nologo +CXX = cl /nologo +AR = lib /nologo +LD = link /nologo + +CFLAGS = $(OPTFLAGS) $(INCL) $(EXTRAFLAGS) +CXXFLAGS = $(OPTFLAGS) $(INCL) $(EXTRAFLAGS) +EXTRAFLAGS = -DHAVE_CONFIG_H +LIBS = + +# Name of the output shared library +DLLNAME = libtiff.dll + +# +########### There is nothing to edit below this line normally. ########### +# + +# Set the native cpu bit order +EXTRAFLAGS = -DFILLODER_LSB2MSB $(EXTRAFLAGS) + +# Codec stuff +!IFDEF CCITT_SUPPORT +EXTRAFLAGS = -DCCITT_SUPPORT $(EXTRAFLAGS) +!ENDIF + +!IFDEF PACKBITS_SUPPORT +EXTRAFLAGS = -DPACKBITS_SUPPORT $(EXTRAFLAGS) +!ENDIF + +!IFDEF LZW_SUPPORT +EXTRAFLAGS = -DLZW_SUPPORT $(EXTRAFLAGS) +!ENDIF + +!IFDEF THUNDER_SUPPORT +EXTRAFLAGS = -DTHUNDER_SUPPORT $(EXTRAFLAGS) +!ENDIF + +!IFDEF NEXT_SUPPORT +EXTRAFLAGS = -DNEXT_SUPPORT $(EXTRAFLAGS) +!ENDIF + +!IFDEF LOGLUV_SUPPORT +EXTRAFLAGS = -DLOGLUV_SUPPORT $(EXTRAFLAGS) +!ENDIF + +!IFDEF JPEG_SUPPORT +LIBS = $(LIBS) $(JPEG_LIB) +EXTRAFLAGS = -DJPEG_SUPPORT -DOJPEG_SUPPORT $(EXTRAFLAGS) +!ENDIF + +!IFDEF ZIP_SUPPORT +LIBS = $(LIBS) $(ZLIB_LIB) +EXTRAFLAGS = -DZIP_SUPPORT $(EXTRAFLAGS) +!IFDEF PIXARLOG_SUPPORT +EXTRAFLAGS = -DPIXARLOG_SUPPORT $(EXTRAFLAGS) +!ENDIF +!ENDIF + +!IFDEF JBIG_SUPPORT +LIBS = $(LIBS) $(JBIG_LIB) +EXTRAFLAGS = -DJBIG_SUPPORT $(EXTRAFLAGS) +!ENDIF + +!IFDEF STRIPCHOP_SUPPORT +EXTRAFLAGS = -DSTRIPCHOP_DEFAULT=TIFF_STRIPCHOP -DSTRIP_SIZE_DEFAULT=$(STRIP_SIZE_DEFAULT) $(EXTRAFLAGS) +!ENDIF + +!IFDEF EXTRASAMPLE_AS_ALPHA_SUPPORT +EXTRAFLAGS = -DDEFAULT_EXTRASAMPLE_AS_ALPHA $(EXTRAFLAGS) +!ENDIF + +!IFDEF CHECK_JPEG_YCBCR_SUBSAMPLING +EXTRAFLAGS = -DCHECK_JPEG_YCBCR_SUBSAMPLING $(EXTRAFLAGS) +!ENDIF + +!IFDEF USE_WIN_CRT_LIB +EXTRAFLAGS = -DAVOID_WIN32_FILEIO $(EXTRAFLAGS) +!ELSE +EXTRAFLAGS = -DUSE_WIN32_FILEIO $(EXTRAFLAGS) +!ENDIF diff --git a/thirdparty/SDL2_image/external/libtiff/placeholder.h b/thirdparty/SDL2_image/external/libtiff/placeholder.h deleted file mode 100644 index 508783063..000000000 --- a/thirdparty/SDL2_image/external/libtiff/placeholder.h +++ /dev/null @@ -1,6 +0,0 @@ -/* - * This file is intentionally empty. - * - * Before CMake 3.11, add_executable() and add_library() need - * at least one source file. - */ diff --git a/thirdparty/SDL2_image/external/libtiff/port/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/port/CMakeLists.txt old mode 100755 new mode 100644 index d03fc3f0b..b7eb3a293 --- a/thirdparty/SDL2_image/external/libtiff/port/CMakeLists.txt +++ b/thirdparty/SDL2_image/external/libtiff/port/CMakeLists.txt @@ -22,30 +22,47 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -# Generate headers -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libport_config.h.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/libport_config.h - @ONLY) - set(port_HEADERS libport.h) +set(port_SOURCES dummy.c) +set(port_optional_SOURCES + getopt.c + lfind.c + strcasecmp.c + strtol.c + strtoll.c + strtoul.c + strtoull.c) + +set(port_USED_FILES ${port_SOURCES} ${port_HEADERS}) -# Only build if any needed features are missing if(NOT HAVE_GETOPT) - add_library(tiff_port STATIC ../placeholder.h) - - # Add getopt if missing - if(NOT HAVE_GETOPT) - target_sources(tiff_port PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/getopt.c) - endif() - - target_include_directories(tiff_port PUBLIC - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}) -else() - # Dummy interface library - add_library(tiff_port INTERFACE) - target_include_directories(tiff_port INTERFACE - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}) + list(APPEND port_USED_FILES getopt.c) endif() +if(NOT HAVE_LFIND) + list(APPEND port_USED_FILES lfind.c) +endif() +if(MSVC AND NOT HAVE_SNPRINTF) + list(APPEND port_USED_FILES snprintf.c) +endif() +if(NOT HAVE_STRCASECMP) + list(APPEND port_USED_FILES strcasecmp.c) +endif() +if(NOT HAVE_STRTOL) + list(APPEND port_USED_FILES strtol.c) +endif() +if(NOT HAVE_STRTOLL) + list(APPEND port_USED_FILES strtoll.c) +endif() +if(NOT HAVE_STRTOUL) + list(APPEND port_USED_FILES strtoul.c) +endif() +if(NOT HAVE_STRTOULL) + list(APPEND port_USED_FILES strtoull.c) +endif() + +add_library(port STATIC ${port_USED_FILES}) + +foreach(file ${port_USED_FILES}) + list(APPEND tiff_port_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/${file}") +endforeach() +set(tiff_port_SOURCES ${tiff_port_SOURCES} PARENT_SCOPE) diff --git a/thirdparty/SDL2_image/external/libtiff/port/Makefile.am b/thirdparty/SDL2_image/external/libtiff/port/Makefile.am index 088a2f7b6..250479fed 100644 --- a/thirdparty/SDL2_image/external/libtiff/port/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/port/Makefile.am @@ -25,8 +25,11 @@ EXTRA_DIST = \ CMakeLists.txt \ + Makefile.vc \ libport.h \ - libport_config.h.cmake.in + snprintf.c \ + _strtol.h \ + _strtoul.h noinst_LTLIBRARIES = libport.la libport_la_SOURCES = dummy.c libport.h diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/InternalCodecs.cmake b/thirdparty/SDL2_image/external/libtiff/port/Makefile.vc similarity index 53% rename from thirdparty/SDL2_image/external/libtiff/cmake/InternalCodecs.cmake rename to thirdparty/SDL2_image/external/libtiff/port/Makefile.vc index 97526e1e0..e4471af51 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/InternalCodecs.cmake +++ b/thirdparty/SDL2_image/external/libtiff/port/Makefile.vc @@ -1,46 +1,83 @@ -# Options to enable and disable internal codecs # -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh +# Copyright (C) 2004, Andrey Kiselev # -# Permission to use, copy, modify, distribute, and sell this software and +# Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +# +# Makefile for MS Visual C and Watcom C compilers. +# +# To build: +# C:\libtiff\port> nmake /f makefile.vc +!INCLUDE ..\nmake.opt -option(ccitt "support for CCITT Group 3 & 4 algorithms" ON) -set(CCITT_SUPPORT ${ccitt}) +HAVE_STRTOL = 1 +HAVE_STRTOUL = 1 -option(packbits "support for Macintosh PackBits algorithm" ON) -set(PACKBITS_SUPPORT ${packbits}) +# strtoul()/strtoull() are provided together +!IF $(HAVE_STRTOLL) +HAVE_STRTOULL = 1 +!ELSE +HAVE_STRTOULL = 0 +!endif -option(lzw "support for LZW algorithm" ON) -set(LZW_SUPPORT ${lzw}) +!IF $(HAVE_STRTOL) +STRTOL_OBJ = +!ELSE +STRTOL_OBJ = strtol.obj +!ENDIF -option(thunder "support for ThunderScan 4-bit RLE algorithm" ON) -set(THUNDER_SUPPORT ${thunder}) +!IF $(HAVE_STRTOUL) +STRTOUL_OBJ = +!ELSE +STRTOUL_OBJ = strtoul.obj +!ENDIF -option(next "support for NeXT 2-bit RLE algorithm" ON) -set(NEXT_SUPPORT ${next}) +!IF $(HAVE_STRTOLL) +STRTOLL_OBJ = +!ELSE +STRTOLL_OBJ = strtoll.obj +!ENDIF -option(logluv "support for LogLuv high dynamic range algorithm" ON) -set(LOGLUV_SUPPORT ${logluv}) +!IF $(HAVE_STRTOULL) +STRTOULL_OBJ = +!ELSE +STRTOULL_OBJ = strtoull.obj +!ENDIF + +INCL = -I..\libtiff + +OBJ = \ + snprintf.obj \ + strcasecmp.obj \ + $(STRTOL_OBJ) \ + $(STRTOUL_OBJ) \ + $(STRTOLL_OBJ) \ + $(STRTOULL_OBJ) \ + getopt.obj + +all: libport.lib + +libport.lib: $(OBJ) + $(AR) /out:libport.lib $(OBJ) + +clean: + -del *.obj + -del *.lib -option(mdi "support for Microsoft Document Imaging" ON) -set(MDI_SUPPORT ${mdi}) diff --git a/thirdparty/SDL2_image/external/libtiff/port/_strtol.h b/thirdparty/SDL2_image/external/libtiff/port/_strtol.h new file mode 100644 index 000000000..73a10063a --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/port/_strtol.h @@ -0,0 +1,160 @@ +/* $NetBSD: _strtol.h,v 1.11 2017/07/06 21:08:44 joerg Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Original version ID: + * NetBSD: src/lib/libc/locale/_wcstol.h,v 1.2 2003/08/07 16:43:03 agc Exp + */ + +#include + +/* + * function template for strtol, strtoll and strtoimax. + * + * parameters: + * _FUNCNAME : function name + * __INT : return type + * __INT_MIN : lower limit of the return type + * __INT_MAX : upper limit of the return type + */ +__INT +_FUNCNAME(const char *nptr, char **endptr, int base) +{ + const char *s; + __INT acc, cutoff; + unsigned char c; + int i, neg, any, cutlim; + + assert(nptr != NULL); + /* endptr may be NULL */ + + /* check base value */ + if (base && (base < 2 || base > 36)) { + errno = EINVAL; + if (endptr != NULL) + /* LINTED interface specification */ + *endptr = (char *)(nptr); + return 0; + } + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X') && + ((s[1] >= '0' && s[1] <= '9') || + (s[1] >= 'a' && s[1] <= 'f') || + (s[1] >= 'A' && s[1] <= 'F'))) { + c = s[1]; + s += 2; + base = 16; + } else if (base == 0) + base = (c == '0' ? 8 : 10); + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = (__INT)(neg ? __INT_MIN : __INT_MAX); + cutlim = (int)(cutoff % base); + cutoff /= base; + if (neg) { + if (cutlim > 0) { + cutlim -= base; + cutoff += 1; + } + cutlim = -cutlim; + } + for (acc = 0, any = 0;; c = *s++) { + if (c >= '0' && c <= '9') + i = c - '0'; + else if (c >= 'a' && c <= 'z') + i = (c - 'a') + 10; + else if (c >= 'A' && c <= 'Z') + i = (c - 'A') + 10; + else + break; + if (i >= base) + break; + if (any < 0) + continue; + if (neg) { + if (acc < cutoff || (acc == cutoff && i > cutlim)) { + acc = __INT_MIN; + any = -1; + errno = ERANGE; + } else { + any = 1; + acc *= base; + acc -= i; + } + } else { + if (acc > cutoff || (acc == cutoff && i > cutlim)) { + acc = __INT_MAX; + any = -1; + errno = ERANGE; + } else { + any = 1; + acc *= base; + acc += i; + } + } + } + if (endptr != NULL) + /* LINTED interface specification */ + *endptr = (char *)(any ? s - 1 : nptr); + return(acc); +} diff --git a/thirdparty/SDL2_image/external/libtiff/port/_strtoul.h b/thirdparty/SDL2_image/external/libtiff/port/_strtoul.h new file mode 100644 index 000000000..5cb62168b --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/port/_strtoul.h @@ -0,0 +1,127 @@ +/* $NetBSD: _strtoul.h,v 1.11 2017/07/06 21:08:44 joerg Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Original version ID: + * NetBSD: src/lib/libc/locale/_wcstoul.h,v 1.2 2003/08/07 16:43:03 agc Exp + */ + +#include + +/* + * function template for strtoul, strtoull and strtoumax. + * + * parameters: + * _FUNCNAME : function name + * __UINT : return type + * __UINT_MAX : upper limit of the return type + */ +__UINT +_FUNCNAME(const char *nptr, char **endptr, int base) +{ + const char *s; + __UINT acc, cutoff; + unsigned char c; + int i, neg, any, cutlim; + + assert(nptr != NULL); + /* endptr may be NULL */ + + /* check base value */ + if (base && (base < 2 || base > 36)) { + errno = EINVAL; + if (endptr != NULL) + /* LINTED interface specification */ + *endptr = (char *)(nptr); + return 0; + } + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X') && + ((s[1] >= '0' && s[1] <= '9') || + (s[1] >= 'a' && s[1] <= 'f') || + (s[1] >= 'A' && s[1] <= 'F'))) { + c = s[1]; + s += 2; + base = 16; + } else if (base == 0) + base = (c == '0' ? 8 : 10); + + /* + * See strtol for comments as to the logic used. + */ + cutoff = ((__UINT)__UINT_MAX / (__UINT)base); + cutlim = (int)((__UINT)__UINT_MAX % (__UINT)base); + for (acc = 0, any = 0;; c = *s++) { + if (c >= '0' && c <= '9') + i = c - '0'; + else if (c >= 'a' && c <= 'z') + i = (c - 'a') + 10; + else if (c >= 'A' && c <= 'Z') + i = (c - 'A') + 10; + else + break; + if (i >= base) + break; + if (any < 0) + continue; + if (acc > cutoff || (acc == cutoff && i > cutlim)) { + acc = __UINT_MAX; + any = -1; + errno = ERANGE; + } else { + any = 1; + acc *= (__UINT)base; + acc += i; + } + } + if (neg && any > 0) + acc = -acc; + if (endptr != NULL) + /* LINTED interface specification */ + *endptr = (char *)(any ? s - 1 : nptr); + return(acc); +} diff --git a/thirdparty/SDL2_image/external/libtiff/port/dummy.c b/thirdparty/SDL2_image/external/libtiff/port/dummy.c index afc55bf34..346a07ee9 100644 --- a/thirdparty/SDL2_image/external/libtiff/port/dummy.c +++ b/thirdparty/SDL2_image/external/libtiff/port/dummy.c @@ -2,4 +2,9 @@ * Dummy function, just to be ensure that the library always will be created. */ -void libport_dummy_function() { return; } +void +libport_dummy_function() +{ + return; +} + diff --git a/thirdparty/SDL2_image/external/libtiff/port/getopt.c b/thirdparty/SDL2_image/external/libtiff/port/getopt.c index b30b622d0..c7bdb116d 100644 --- a/thirdparty/SDL2_image/external/libtiff/port/getopt.c +++ b/thirdparty/SDL2_image/external/libtiff/port/getopt.c @@ -32,99 +32,92 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95"; __RCSID("$NetBSD: getopt.c,v 1.26 2003/08/07 16:43:40 agc Exp $"); #endif -#include "libport.h" #include #include +#include "libport.h" -int opterr = 1, /* if error message should be printed */ - optind = 1, /* index into parent argv vector */ - optopt, /* character checked for validity */ - optreset; /* reset getopt */ -char *optarg; /* argument associated with option */ +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ -#define BADCH (int)'?' -#define BADARG (int)':' -#define EMSG "" +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" /* * getopt -- * Parse argc/argv argument vector. */ -int getopt(int argc, char *const argv[], const char *optstring) +int +getopt(int argc, char * const argv[], const char *optstring) { - static char *place = EMSG; /* option letter processing */ - char *oli; /* option letter list index */ + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ - if (optreset || *place == 0) - { /* update scanning pointer */ - optreset = 0; - place = argv[optind]; - if (optind >= argc || *place++ != '-') - { - /* Argument is absent or is not an option */ - place = EMSG; - return (-1); - } - optopt = *place++; - if (optopt == '-' && *place == 0) - { - /* "--" => end of options */ - ++optind; - place = EMSG; - return (-1); - } - if (optopt == 0) - { - /* Solitary '-', treat as a '-' option - if the program (eg su) is looking for it. */ - place = EMSG; - if (strchr(optstring, '-') == NULL) - return -1; - optopt = '-'; - } - } - else - optopt = *place++; + if (optreset || *place == 0) { /* update scanning pointer */ + optreset = 0; + place = argv[optind]; + if (optind >= argc || *place++ != '-') { + /* Argument is absent or is not an option */ + place = EMSG; + return (-1); + } + optopt = *place++; + if (optopt == '-' && *place == 0) { + /* "--" => end of options */ + ++optind; + place = EMSG; + return (-1); + } + if (optopt == 0) { + /* Solitary '-', treat as a '-' option + if the program (eg su) is looking for it. */ + place = EMSG; + if (strchr(optstring, '-') == NULL) + return -1; + optopt = '-'; + } + } else + optopt = *place++; - /* See if option letter is one the caller wanted... */ - if (optopt == ':' || (oli = strchr(optstring, optopt)) == NULL) - { - if (*place == 0) - ++optind; - if (opterr && *optstring != ':') - (void)fprintf(stderr, "unknown option -- %c\n", optopt); - return (BADCH); - } + /* See if option letter is one the caller wanted... */ + if (optopt == ':' || (oli = strchr(optstring, optopt)) == NULL) { + if (*place == 0) + ++optind; + if (opterr && *optstring != ':') + (void)fprintf(stderr, + "unknown option -- %c\n", optopt); + return (BADCH); + } - /* Does this option need an argument? */ - if (oli[1] != ':') - { - /* don't need argument */ - optarg = NULL; - if (*place == 0) - ++optind; - } - else - { - /* Option-argument is either the rest of this argument or the - entire next argument. */ - if (*place) - optarg = place; - else if (argc > ++optind) - optarg = argv[optind]; - else - { - /* option-argument absent */ - place = EMSG; - if (*optstring == ':') - return (BADARG); - if (opterr) - (void)fprintf(stderr, "option requires an argument -- %c\n", - optopt); - return (BADCH); - } - place = EMSG; - ++optind; - } - return (optopt); /* return option letter */ + /* Does this option need an argument? */ + if (oli[1] != ':') { + /* don't need argument */ + optarg = NULL; + if (*place == 0) + ++optind; + } else { + /* Option-argument is either the rest of this argument or the + entire next argument. */ + if (*place) + optarg = place; + else if (argc > ++optind) + optarg = argv[optind]; + else { + /* option-argument absent */ + place = EMSG; + if (*optstring == ':') + return (BADARG); + if (opterr) + (void)fprintf(stderr, + "option requires an argument -- %c\n", + optopt); + return (BADCH); + } + place = EMSG; + ++optind; + } + return (optopt); /* return option letter */ } diff --git a/thirdparty/SDL2_image/external/libtiff/port/lfind.c b/thirdparty/SDL2_image/external/libtiff/port/lfind.c new file mode 100644 index 000000000..00ab6495c --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/port/lfind.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Roger L. Snyder. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if 0 +static char sccsid[] = "@(#)lsearch.c 8.1 (Berkeley) 6/4/93"; +__RCSID("$NetBSD: lsearch.c,v 1.2 2005/07/06 15:47:15 drochner Exp $"); +#endif + +#ifdef _WIN32_WCE +# include +#else +# include +#endif + +#ifndef NULL +# define NULL 0 +#endif + +void * +lfind(const void *key, const void *base, size_t *nmemb, size_t size, + int(*compar)(const void *, const void *)) +{ + char *element, *end; + + end = (char *)base + *nmemb * size; + for (element = (char *)base; element < end; element += size) + if (!compar(element, key)) /* key found */ + return element; + + return NULL; +} diff --git a/thirdparty/SDL2_image/external/libtiff/port/libport.h b/thirdparty/SDL2_image/external/libtiff/port/libport.h index 879445021..9f2dace14 100644 --- a/thirdparty/SDL2_image/external/libtiff/port/libport.h +++ b/thirdparty/SDL2_image/external/libtiff/port/libport.h @@ -1,18 +1,18 @@ /* * Copyright (c) 2009 Frank Warmerdam * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, @@ -22,22 +22,50 @@ */ #ifndef _LIBPORT_ -#define _LIBPORT_ +#define _LIBPORT_ -#include - -#if HAVE_GETOPT -#if HAVE_UNISTD_H -#include +#if defined(HAVE_CONFIG_H) +# include #endif -#else -int getopt(int argc, char *const argv[], const char *optstring); -extern char *optarg; -extern int opterr; -extern int optind; -extern int optopt; +int getopt(int argc, char * const argv[], const char *optstring); +extern char *optarg; +extern int opterr; +extern int optind; +extern int optopt; +int strcasecmp(const char *s1, const char *s2); + +#ifndef HAVE_GETOPT +# define HAVE_GETOPT 1 +#endif + +#if !defined(HAVE_STRTOL) +long strtol(const char *nptr, char **endptr, int base); +#endif +#if !defined(HAVE_STRTOLL) +long long strtoll(const char *nptr, char **endptr, int base); +#endif +#if !defined(HAVE_STRTOUL) +unsigned long strtoul(const char *nptr, char **endptr, int base); +#endif +#if !defined(HAVE_STRTOULL) +unsigned long long strtoull(const char *nptr, char **endptr, int base); +#endif + +#if 0 +void * +lfind(const void *key, const void *base, size_t *nmemb, size_t size, + int(*compar)(const void *, const void *)); +#endif + +#if !defined(HAVE_SNPRINTF) +#undef vsnprintf +#define vsnprintf _TIFF_vsnprintf_f + +#undef snprintf +#define snprintf _TIFF_snprintf_f +int snprintf(char* str, size_t size, const char* format, ...); #endif #endif /* ndef _LIBPORT_ */ diff --git a/thirdparty/SDL2_image/external/libtiff/port/libport_config.h.cmake.in b/thirdparty/SDL2_image/external/libtiff/port/libport_config.h.cmake.in deleted file mode 100644 index 7446f8727..000000000 --- a/thirdparty/SDL2_image/external/libtiff/port/libport_config.h.cmake.in +++ /dev/null @@ -1,13 +0,0 @@ -/* libtiff/libport_config.h.cmake.in. Not generated, but originated from autoheader. */ -/* This file must be kept up-to-date with needed substitutions from port/libport_config.h.in. */ - -#ifndef _LIBPORT_CONFIG_H_ -#define _LIBPORT_CONFIG_H_ - -/* Define to 1 if you have the `getopt' function. */ -#cmakedefine HAVE_GETOPT 1 - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H 1 - -#endif /* _LIBPORT_CONFIG_H_ */ diff --git a/thirdparty/SDL2_image/external/libtiff/port/libport_config.h.in b/thirdparty/SDL2_image/external/libtiff/port/libport_config.h.in deleted file mode 100644 index b904f6194..000000000 --- a/thirdparty/SDL2_image/external/libtiff/port/libport_config.h.in +++ /dev/null @@ -1,12 +0,0 @@ -/* libtiff/libport_config.h.in. Not generated, but originated from autoheader. */ - -#ifndef _LIBPORT_CONFIG_H_ -#define _LIBPORT_CONFIG_H_ - -/* Define to 1 if you have the `getopt' function. */ -#undef HAVE_GETOPT - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -#endif /* _LIBPORT_CONFIG_H_ */ diff --git a/thirdparty/SDL2_image/external/libtiff/port/libport_config.vc.h b/thirdparty/SDL2_image/external/libtiff/port/libport_config.vc.h deleted file mode 100644 index 6148032b9..000000000 --- a/thirdparty/SDL2_image/external/libtiff/port/libport_config.vc.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _LIBPORT_CONFIG_H_ -#define _LIBPORT_CONFIG_H_ - -/* Define to 1 if you have the `getopt' function. */ -/* #define HAVE_GETOPT 0 */ - -/* Define to 1 if you have the header file. */ -/* #define HAVE_UNISTD_H 0 */ - -#endif /* _LIBPORT_CONFIG_H_ */ diff --git a/thirdparty/SDL2_image/external/libtiff/port/snprintf.c b/thirdparty/SDL2_image/external/libtiff/port/snprintf.c new file mode 100644 index 000000000..3542ab759 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/port/snprintf.c @@ -0,0 +1,42 @@ +/** + * Workaround for lack of snprintf(3) in Visual Studio. See + * http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010/8712996#8712996 + * It's a trivial wrapper around the builtin _vsnprintf_s and + * _vscprintf functions. + */ + +#ifdef _MSC_VER + +#include +#include +#include "libport.h" + +int _TIFF_vsnprintf_f(char* str, size_t size, const char* format, va_list ap) +{ + int count = -1; + + if (size != 0) +#if _MSC_VER <= 1310 + count = _vsnprintf(str, size, format, ap); +#else + count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); +#endif + if (count == -1) + count = _vscprintf(format, ap); + + return count; +} + +int _TIFF_snprintf_f(char* str, size_t size, const char* format, ...) +{ + int count; + va_list ap; + + va_start(ap, format); + count = vsnprintf(str, size, format, ap); + va_end(ap); + + return count; +} + +#endif // _MSC_VER diff --git a/thirdparty/SDL2_image/external/libtiff/port/strcasecmp.c b/thirdparty/SDL2_image/external/libtiff/port/strcasecmp.c new file mode 100644 index 000000000..65e2b411c --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/port/strcasecmp.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if 0 +static char sccsid[] = "@(#)strcasecmp.c 8.1 (Berkeley) 6/4/93"; +__RCSID("$NetBSD: strcasecmp.c,v 1.16 2003/08/07 16:43:49 agc Exp $"); +#endif + +#include +#include +#include "libport.h" + +int +strcasecmp(const char *s1, const char *s2) +{ + const unsigned char *us1 = (const unsigned char *)s1, + *us2 = (const unsigned char *)s2; + + while (tolower((int) *us1) == tolower((int) *us2++)) + if (*us1++ == '\0') + return (0); + return (tolower((int) *us1) - tolower((int) *--us2)); +} diff --git a/thirdparty/SDL2_image/external/libtiff/port/strtol.c b/thirdparty/SDL2_image/external/libtiff/port/strtol.c new file mode 100644 index 000000000..a355dde95 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/port/strtol.c @@ -0,0 +1,45 @@ +/* $NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $ */ + +/*- + * Copyright (c) 2005 The DragonFly Project. All rights reserved. + * Copyright (c) 2003 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if 0 +__RCSID("$NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $"); +#endif + +#include +#include +#include +#include +#include + +#define _FUNCNAME strtol +#define __INT long +#define __INT_MIN LONG_MIN +#define __INT_MAX LONG_MAX + +#include "_strtol.h" diff --git a/thirdparty/SDL2_image/external/libtiff/port/strtoll.c b/thirdparty/SDL2_image/external/libtiff/port/strtoll.c new file mode 100644 index 000000000..4784b0984 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/port/strtoll.c @@ -0,0 +1,44 @@ +/* $NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $ */ + +/*- + * Copyright (c) 2005 The DragonFly Project. All rights reserved. + * Copyright (c) 2003 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if 0 +__RCSID("$NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $"); +#endif + +#include +#include +#include +#include + +#define _FUNCNAME strtoll +#define __INT long long +#define __INT_MIN LLONG_MIN +#define __INT_MAX LLONG_MAX + +#include "_strtol.h" diff --git a/thirdparty/SDL2_image/external/libtiff/port/strtoul.c b/thirdparty/SDL2_image/external/libtiff/port/strtoul.c new file mode 100644 index 000000000..dbd44f162 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/port/strtoul.c @@ -0,0 +1,44 @@ +/* $NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $ */ + +/*- + * Copyright (c) 2005 The DragonFly Project. All rights reserved. + * Copyright (c) 2003 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if 0 +__RCSID("$NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $"); +#endif + +#include +#include +#include +#include +#include + +#define _FUNCNAME strtoul +#define __UINT unsigned long int +#define __UINT_MAX ULONG_MAX + +#include "_strtoul.h" diff --git a/thirdparty/SDL2_image/external/libtiff/port/strtoull.c b/thirdparty/SDL2_image/external/libtiff/port/strtoull.c new file mode 100644 index 000000000..91e4ddfb0 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/port/strtoull.c @@ -0,0 +1,44 @@ +/* $NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $ */ + +/*- + * Copyright (c) 2005 The DragonFly Project. All rights reserved. + * Copyright (c) 2003 Citrus Project, + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if 0 +__RCSID("$NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $"); +#endif + +#include +#include +#include +#include +#include + +#define _FUNCNAME strtoull +#define __UINT unsigned long long int +#define __UINT_MAX ULLONG_MAX + +#include "_strtoul.h" diff --git a/thirdparty/SDL2_image/external/libtiff/test/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/test/CMakeLists.txt index 098007c63..4877ed138 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/CMakeLists.txt +++ b/thirdparty/SDL2_image/external/libtiff/test/CMakeLists.txt @@ -22,12 +22,95 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -# Images for tiff2bw (8-bit RGB only) -set(RGBIMAGES - images/palette-1c-8b.tiff - images/rgb-3c-8b.tiff - images/quad-lzw-compat.tiff -) +include_directories(${PROJECT_SOURCE_DIR}/libtiff + ${PROJECT_BINARY_DIR}/libtiff + ${CMAKE_CURRENT_BINARY_DIR} + ${TIFF_INCLUDES}) + +# Test scripts (not used by CMake) +set(TESTSCRIPTS + bmp2tiff_palette.sh + bmp2tiff_rgb.sh + gif2tiff.sh + ppm2tiff_pbm.sh + ppm2tiff_pgm.sh + ppm2tiff_ppm.sh + fax2tiff.sh + tiffcp-g3.sh + tiffcp-g3-1d.sh + tiffcp-g3-1d-fill.sh + tiffcp-g3-2d.sh + tiffcp-g3-2d-fill.sh + tiffcp-g4.sh + tiffcp-logluv.sh + tiffcp-thumbnail.sh + tiffcp-lzw-compat.sh + tiffcp-lzw-scanline-decode.sh + tiffdump.sh + tiffinfo.sh + tiffcp-split.sh + tiffcp-split-join.sh + tiff2ps-PS1.sh + tiff2ps-PS2.sh + tiff2ps-PS3.sh + tiff2ps-EPS1.sh + tiff2pdf.sh + tiffcrop-doubleflip-logluv-3c-16b.sh + tiffcrop-doubleflip-minisblack-1c-16b.sh + tiffcrop-doubleflip-minisblack-1c-8b.sh + tiffcrop-doubleflip-minisblack-2c-8b-alpha.sh + tiffcrop-doubleflip-miniswhite-1c-1b.sh + tiffcrop-doubleflip-palette-1c-1b.sh + tiffcrop-doubleflip-palette-1c-4b.sh + tiffcrop-doubleflip-palette-1c-8b.sh + tiffcrop-doubleflip-rgb-3c-16b.sh + tiffcrop-doubleflip-rgb-3c-8b.sh + tiffcrop-extract-logluv-3c-16b.sh + tiffcrop-extract-minisblack-1c-16b.sh + tiffcrop-extract-minisblack-1c-8b.sh + tiffcrop-extract-minisblack-2c-8b-alpha.sh + tiffcrop-extract-miniswhite-1c-1b.sh + tiffcrop-extract-palette-1c-1b.sh + tiffcrop-extract-palette-1c-4b.sh + tiffcrop-extract-palette-1c-8b.sh + tiffcrop-extract-rgb-3c-16b.sh + tiffcrop-extract-rgb-3c-8b.sh + tiffcrop-extractz14-logluv-3c-16b.sh + tiffcrop-extractz14-minisblack-1c-16b.sh + tiffcrop-extractz14-minisblack-1c-8b.sh + tiffcrop-extractz14-minisblack-2c-8b-alpha.sh + tiffcrop-extractz14-miniswhite-1c-1b.sh + tiffcrop-extractz14-palette-1c-1b.sh + tiffcrop-extractz14-palette-1c-4b.sh + tiffcrop-extractz14-palette-1c-8b.sh + tiffcrop-extractz14-rgb-3c-16b.sh + tiffcrop-extractz14-rgb-3c-8b.sh + tiffcrop-R90-logluv-3c-16b.sh + tiffcrop-R90-minisblack-1c-16b.sh + tiffcrop-R90-minisblack-1c-8b.sh + tiffcrop-R90-minisblack-2c-8b-alpha.sh + tiffcrop-R90-miniswhite-1c-1b.sh + tiffcrop-R90-palette-1c-1b.sh + tiffcrop-R90-palette-1c-4b.sh + tiffcrop-R90-palette-1c-8b.sh + tiffcrop-R90-rgb-3c-16b.sh + tiffcrop-R90-rgb-3c-8b.sh + tiff2rgba-logluv-3c-16b.sh + tiff2rgba-minisblack-1c-16b.sh + tiff2rgba-minisblack-1c-8b.sh + tiff2rgba-minisblack-2c-8b-alpha.sh + tiff2rgba-miniswhite-1c-1b.sh + tiff2rgba-palette-1c-1b.sh + tiff2rgba-palette-1c-4b.sh + tiff2rgba-palette-1c-8b.sh + tiff2rgba-rgb-3c-16b.sh + tiff2rgba-rgb-3c-8b.sh + tiff2rgba-quad-tile.jpg.sh + tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh + tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh + tiff2rgba-ojpeg_single_strip_no_rowsperstrip.sh + testfax4.sh + testdeflatelaststripextradata.sh) # This list should contain all of the TIFF files in the 'images' # subdirectory which are intended to be used as input images for @@ -44,25 +127,13 @@ set(TIFFIMAGES images/palette-1c-8b.tiff images/rgb-3c-16b.tiff images/rgb-3c-8b.tiff + images/quad-tile.jpg.tiff images/quad-lzw-compat.tiff images/lzw-single-strip.tiff - images/testfax4.tiff - images/testfax3_bug_513.tiff -) -# TIFF images using old-jpeg. Unused unless JPEG support is enabled. -set(TIFFIMAGES_OJPEG) - -if(JPEG_SUPPORT) - list(APPEND TIFFIMAGES images/quad-tile.jpg.tiff) -endif() - -if (OJPEG_SUPPORT) - list(APPEND TIFFIMAGES_OJPEG - images/ojpeg_zackthecat_subsamp22_single_strip.tiff - images/ojpeg_chewey_subsamp21_multi_strip.tiff - images/ojpeg_single_strip_no_rowsperstrip.tiff - ) -endif() + images/ojpeg_zackthecat_subsamp22_single_strip.tiff + images/ojpeg_chewey_subsamp21_multi_strip.tiff + images/ojpeg_single_strip_no_rowsperstrip.tiff + images/testfax4.tiff) set(BMPIMAGES images/palette-1c-8b.bmp @@ -98,123 +169,70 @@ set(IMAGES_EXTRA_DIST ${PNMIMAGES} ${TIFFIMAGES}) +extra_dist( + ${TESTSCRIPTS} + ${IMAGES_EXTRA_DIST} + common.sh) + set(noinst_HEADERS tifftest.h) -set(simple_tests) +add_executable(ascii_tag ascii_tag.c) +target_link_libraries(ascii_tag tiff port) -add_executable(test_signed_tags ../placeholder.h) -target_sources(test_signed_tags PRIVATE test_signed_tags.c) -target_link_libraries(test_signed_tags PRIVATE tiff tiff_port) -list(APPEND simple_tests test_signed_tags) +add_executable(long_tag long_tag.c check_tag.c) +target_link_libraries(long_tag tiff port) -add_executable(ascii_tag ../placeholder.h) -target_sources(ascii_tag PRIVATE ascii_tag.c) -target_link_libraries(ascii_tag PRIVATE tiff tiff_port) -list(APPEND simple_tests ascii_tag) +add_executable(short_tag short_tag.c check_tag.c) +target_link_libraries(short_tag tiff port) -add_executable(long_tag ../placeholder.h) -target_sources(long_tag PRIVATE long_tag.c check_tag.c) -target_link_libraries(long_tag PRIVATE tiff tiff_port) -list(APPEND simple_tests long_tag) +add_executable(strip_rw strip_rw.c strip.c test_arrays.c test_arrays.h) +target_link_libraries(strip_rw tiff port) -add_executable(short_tag ../placeholder.h) -target_sources(short_tag PRIVATE short_tag.c check_tag.c) -target_link_libraries(short_tag PRIVATE tiff tiff_port) -list(APPEND simple_tests short_tag) - -add_executable(strip_rw ../placeholder.h) -target_sources(strip_rw PRIVATE strip_rw.c strip.c test_arrays.c test_arrays.h) -target_link_libraries(strip_rw PRIVATE tiff tiff_port) -list(APPEND simple_tests strip_rw) - -add_executable(rewrite ../placeholder.h) -target_sources(rewrite PRIVATE rewrite_tag.c) -target_link_libraries(rewrite PRIVATE tiff tiff_port) -list(APPEND simple_tests rewrite) +add_executable(rewrite rewrite_tag.c) +target_link_libraries(rewrite tiff port) if(JPEG_SUPPORT) - add_executable(raw_decode ../placeholder.h) - target_sources(raw_decode PRIVATE raw_decode.c) - target_link_libraries(raw_decode PRIVATE tiff tiff_port JPEG::JPEG) - list(APPEND simple_tests raw_decode) + add_executable(raw_decode raw_decode.c) + target_link_libraries(raw_decode tiff port) endif() -add_executable(custom_dir ../placeholder.h) -target_sources(custom_dir PRIVATE custom_dir.c) -target_link_libraries(custom_dir PRIVATE tiff tiff_port) -list(APPEND simple_tests custom_dir) +add_executable(custom_dir custom_dir.c) +target_link_libraries(custom_dir tiff port) -# Uses private functions from static library if(NOT BUILD_SHARED_LIBS) - add_executable(rational_precision2double ../placeholder.h) - target_sources(rational_precision2double PRIVATE rational_precision2double.c) - target_link_libraries(rational_precision2double PRIVATE tiff tiff_port) - list(APPEND simple_tests rational_precision2double) - - add_executable(test_write_read_tags ../placeholder.h) - target_sources(test_write_read_tags PRIVATE test_write_read_tags.c) - target_link_libraries(test_write_read_tags PRIVATE tiff) - list(APPEND simple_tests test_write_read_tags) - add_executable(test_transferfunction_write_read ../placeholder.h) - target_sources(test_transferfunction_write_read PRIVATE test_transferfunction_write_read.c) - target_link_libraries(test_transferfunction_write_read PRIVATE tiff) - list(APPEND simple_tests test_transferfunction_write_read) +add_executable(rational_precision2double rational_precision2double.c) +target_link_libraries(rational_precision2double tiff port) +add_test(NAME "rational_precision2double" + COMMAND "rational_precision2double") endif() -add_executable(custom_dir_EXIF_231 ../placeholder.h) -target_sources(custom_dir_EXIF_231 PRIVATE custom_dir_EXIF_231.c) -target_link_libraries(custom_dir_EXIF_231 PRIVATE tiff tiff_port) -list(APPEND simple_tests custom_dir_EXIF_231) +if(NOT BUILD_SHARED_LIBS) +add_executable(custom_dir_EXIF_231 custom_dir_EXIF_231.c) +target_link_libraries(custom_dir_EXIF_231 tiff port) +add_test(NAME "custom_dir_EXIF_231" + COMMAND "custom_dir_EXIF_231") +endif() -add_executable(defer_strile_loading ../placeholder.h) -target_sources(defer_strile_loading PRIVATE defer_strile_loading.c) -target_link_libraries(defer_strile_loading PRIVATE tiff tiff_port) -list(APPEND simple_tests defer_strile_loading) +add_executable(defer_strile_loading defer_strile_loading.c) +target_link_libraries(defer_strile_loading tiff port) -add_executable(defer_strile_writing ../placeholder.h) -target_sources(defer_strile_writing PRIVATE defer_strile_writing.c) -target_link_libraries(defer_strile_writing PRIVATE tiff tiff_port) -list(APPEND simple_tests defer_strile_writing) +add_executable(defer_strile_writing defer_strile_writing.c) +target_link_libraries(defer_strile_writing tiff port) -add_executable(test_directory ../placeholder.h) -target_sources(test_directory PRIVATE test_directory.c) -target_link_libraries(test_directory PRIVATE tiff tiff_port) -list(APPEND simple_tests test_directory) - -add_executable(testtypes ../placeholder.h) -target_sources(testtypes PRIVATE testtypes.c) -target_link_libraries(testtypes PRIVATE tiff tiff_port) -list(APPEND simple_tests testtypes) - -add_executable(test_open_options ../placeholder.h) -target_sources(test_open_options PRIVATE test_open_options.c) -target_link_libraries(test_open_options PRIVATE tiff tiff_port) -list(APPEND simple_tests test_open_options) - -add_executable(test_append_to_strip ../placeholder.h) -target_sources(test_append_to_strip PRIVATE test_append_to_strip.c) -target_link_libraries(test_append_to_strip PRIVATE tiff tiff_port) -list(APPEND simple_tests test_append_to_strip) - -add_executable(test_ifd_loop_detection ../placeholder.h) -target_sources(test_ifd_loop_detection PRIVATE test_ifd_loop_detection.c) -target_link_libraries(test_ifd_loop_detection PRIVATE tiff tiff_port) -target_compile_definitions(test_ifd_loop_detection PRIVATE SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\") -list(APPEND simple_tests test_ifd_loop_detection) +add_executable(testtypes testtypes.c) +target_link_libraries(testtypes tiff port) if(WEBP_SUPPORT AND EMSCRIPTEN) # Emscripten is pretty finnicky about linker flags. # It needs --shared-memory if and only if atomics or bulk-memory is used. - foreach(target - ascii_tag - long_tag - short_tag - strip_rw - rewrite - custom_dir - defer_strile_loading - defer_strile_writing - ) + foreach(target ascii_tag + custom_dir + defer_strile_loading + defer_strile_writing + long_tag + rewrite + short_tag + strip_rw) target_link_options(${target} PUBLIC "-Wl,--shared-memory") endforeach() if(JPEG_SUPPORT) @@ -225,14 +243,11 @@ endif() set(TEST_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output") file(MAKE_DIRECTORY "${TEST_OUTPUT}") -set(tiff_test_extra_args "-DLIBTIFF=$") - -if(tiff-tools) - list(APPEND tiff_test_extra_args "-DTIFFCP=$") - list(APPEND tiff_test_extra_args "-DTIFFINFO=$") - list(APPEND tiff_test_extra_args "-DTIFFSPLIT=$") -endif() - +set(tiff_test_extra_args + "-DTIFFCP=$" + "-DTIFFINFO=$" + "-DTIFFSPLIT=$" + "-DLIBTIFF=$") if(WIN32) list(APPEND tiff_test_extra_args "-DWIN32=${WIN32}") endif() @@ -240,7 +255,7 @@ if(CYGWIN) list(APPEND tiff_test_extra_args "-DCYGWIN=${CYGWIN}") endif() -function(tiff_test_convert name command1 command2 command3 infile outfile validate) +macro(tiff_test_convert name command1 command2 command3 infile outfile validate) add_test(NAME "${name}" COMMAND "${CMAKE_COMMAND}" "-DCONVERT_COMMAND1=${command1}" @@ -251,12 +266,9 @@ function(tiff_test_convert name command1 command2 command3 infile outfile valida "-DVALIDATE=${validate}" ${tiff_test_extra_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake") -endfunction() +endmacro() -function(tiff_test_stdout name suffix command infile outfile) - if (suffix) - set(name "${name}-${suffix}") - endif() +macro(tiff_test_stdout name command infile outfile) add_test(NAME "${name}" COMMAND "${CMAKE_COMMAND}" "-DSTDOUT_COMMAND=${command}" @@ -264,29 +276,18 @@ function(tiff_test_stdout name suffix command infile outfile) "-DOUTFILE=${outfile}" ${tiff_test_extra_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake") -endfunction() +endmacro() -function(tiff_test_stdout_noargs name command) - add_test(NAME "${name}" - COMMAND "${CMAKE_COMMAND}" - "-DSTDOUT_COMMAND=$" - ${tiff_test_extra_args} - -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - set_tests_properties("${name}" PROPERTIES ENVIRONMENT - "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") -endfunction() - -function(tiff_test_reader name command infile) +macro(tiff_test_reader name command infile) add_test(NAME "${name}" COMMAND "${CMAKE_COMMAND}" "-DREADER_COMMAND=${command}" "-DINFILE=${infile}" ${tiff_test_extra_args} -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffTest.cmake") -endfunction() +endmacro() -function(add_convert_test_multi commandname1 commandname2 commandname3 +macro(add_convert_test_multi commandname1 commandname2 commandname3 categoryname commandargs1 commandargs2 commandargs3 image validate) string(REPLACE " " "^" escaped_commandargs1 "${commandargs1}") @@ -314,20 +315,21 @@ function(add_convert_test_multi commandname1 commandname2 commandname3 set(command3) endif() set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}") - set(outfile "${TEST_OUTPUT}/${commandname1}-${categoryname}-${base}.tiff") + set(outfile "${TEST_OUTPUT}/${commandname1}-${categoryname}-${name}") + string(REGEX REPLACE "\\.tiff\$" "" name "${name}") tiff_test_convert("${testname}" "${command1}" "${command2}" "${command3}" "${infile}" "${outfile}" "${validate}") -endfunction() +endmacro() -function(add_convert_test commandname +macro(add_convert_test commandname categoryname commandargs image validate) add_convert_test_multi("${commandname}" "" "" "${categoryname}" "${commandargs}" "" "" "${image}" "${validate}") -endfunction() +endmacro() -function(add_convert_tests_multi commandname1 commandname2 commandname3 +macro(add_convert_tests_multi commandname commandname2 commandname3 categoryname commandargs1 commandargs2 commandargs3 images validate) @@ -337,16 +339,16 @@ function(add_convert_tests_multi commandname1 commandname2 commandname3 "${commandargs1}" "${commandargs2}" "${commandargs3}" "${file}" "${validate}") endforeach() -endfunction() +endmacro() -function(add_convert_tests commandname categoryname commandargs images validate) +macro(add_convert_tests commandname categoryname commandargs images validate) foreach(file ${${images}}) add_convert_test("${commandname}" "${categoryname}" "${commandargs}" "${file}" "${validate}") endforeach() -endfunction() +endmacro() -function(add_stdout_test commandname suffix commandargs image) +macro(add_stdout_test commandname commandargs image) string(REPLACE " " "^" escaped_commandargs "${commandargs}") get_filename_component(name "${image}" NAME) get_filename_component(base "${image}" NAME_WE) @@ -355,98 +357,89 @@ function(add_stdout_test commandname suffix commandargs image) set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}") set(outfile "${TEST_OUTPUT}/${commandname}-${name}") string(REGEX REPLACE "\\.tiff\$" "" name "${name}") - tiff_test_stdout("${testname}" "${suffix}" "${command}" "${infile}" "${outfile}") -endfunction() + tiff_test_stdout("${testname}" "${command}" "${infile}" "${outfile}") +endmacro() -function(add_reader_test commandname commandargs image) +macro(add_reader_test commandname commandargs image) string(REPLACE " " "^" escaped_commandargs "${commandargs}") get_filename_component(name "${image}" NAME) get_filename_component(base "${image}" NAME_WE) set(testname "${commandname}-${base}") set(command "$^${escaped_commandargs}") set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${image}") + string(REGEX REPLACE "\\.tiff\$" "" name "${name}") tiff_test_reader("${testname}" "${command}" "${infile}") -endfunction() +endmacro() -# Plain executables with no arguments -foreach(target IN LISTS simple_tests) - tiff_test_stdout_noargs("${target}" "${target}") +# BMP +add_convert_test(bmp2tiff palette "" "images/palette-1c-8b.bmp" TRUE) +add_convert_test(bmp2tiff rgb "" "images/rgb-3c-8b.bmp" TRUE) + +# GIF +add_convert_test(gif2tiff palette "" "images/palette-1c-8b.gif" TRUE) + +# PPM +add_convert_test(ppm2tiff miniswhite "" "images/miniswhite-1c-1b.pbm" TRUE) +add_convert_test(ppm2tiff minisblack "" "images/minisblack-1c-8b.pgm" TRUE) +add_convert_test(ppm2tiff rgb "" "images/rgb-3c-16b.ppm" TRUE) +add_convert_test(ppm2tiff rgb "" "images/rgb-3c-8b.ppm" TRUE) + +# tiffcp +add_convert_test(tiffcp g3 "-c g3" "images/miniswhite-1c-1b.tiff" FALSE) +add_convert_test(tiffcp g31d "-c g3:1d" "images/miniswhite-1c-1b.tiff" FALSE) +add_convert_test(tiffcp g31dfill "-c g3:1d:fill" "images/miniswhite-1c-1b.tiff" FALSE) +add_convert_test(tiffcp g32d "-c g3:2d" "images/miniswhite-1c-1b.tiff" FALSE) +add_convert_test(tiffcp g32dfill "-c g3:2d:fill" "images/miniswhite-1c-1b.tiff" FALSE) +add_convert_test(tiffcp g4 "-c g4" "images/miniswhite-1c-1b.tiff" FALSE) +add_convert_test(tiffcp none "-c none" "images/quad-lzw-compat.tiff" FALSE) +add_convert_test(tiffcp noner1 "-c none -r 1" "images/lzw-single-strip.tiff" FALSE) +add_convert_test_multi(tiffcp tiffcp "" logluv "-c none" "-c sgilog" "" + "images/logluv-3c-16b.tiff" FALSE) +add_convert_test_multi(tiffcp thumbnail "" thumbnail "g3:1d" "" "" + "images/miniswhite-1c-1b.tiff" FALSE) + +# tiffdump +add_reader_test(tiffdump "" "images/miniswhite-1c-1b.tiff") + +# tiffinfo +add_reader_test(tiffinfo "-c -D -d -j -s" "images/custom_dir_EXIF_GPS.tiff") +add_reader_test(tiffinfo "-c -D -d -j -s" "images/minisblack-1c-16b.tiff") + +# tiffcp split/join +foreach(image ${UNCOMPRESSEDIMAGES}) + list(APPEND ESCAPED_UNCOMPRESSED "${CMAKE_CURRENT_SOURCE_DIR}/${image}") endforeach() +string(REPLACE ";" "^" ESCAPED_UNCOMPRESSED "${ESCAPED_UNCOMPRESSED}") +add_test(NAME "tiffcp-split" + COMMAND "${CMAKE_COMMAND}" + "-DTESTFILES=${ESCAPED_UNCOMPRESSED}" + "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-conjoined.tif" + "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-split-" + ${tiff_test_extra_args} + -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake") +add_test(NAME "tiffcp-split-join" + COMMAND "${CMAKE_COMMAND}" + "-DTESTFILES=${ESCAPED_UNCOMPRESSED}" + "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-join-conjoined.tif" + "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-join-split-" + "-DRECONJOINED=${TEST_OUTPUT}/tiffcp-split-join-reconjoined.tif" + ${tiff_test_extra_args} + -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake") -if(tiff-tools) - # PPM - add_convert_test(ppm2tiff miniswhite "" "images/miniswhite-1c-1b.pbm" TRUE) - add_convert_test(ppm2tiff minisblack "" "images/minisblack-1c-8b.pgm" TRUE) - add_convert_test(ppm2tiff rgb "" "images/rgb-3c-16b.ppm" TRUE) - add_convert_test(ppm2tiff rgb "" "images/rgb-3c-8b.ppm" TRUE) +# PDF +add_stdout_test(tiff2pdf "" "images/miniswhite-1c-1b.tiff" TRUE) - # tiffcp - add_convert_test(tiffcp g3 "-c g3" "images/miniswhite-1c-1b.tiff" FALSE) - add_convert_test(tiffcp g31d "-c g3:1d" "images/miniswhite-1c-1b.tiff" FALSE) - add_convert_test(tiffcp g31dfill "-c g3:1d:fill" "images/miniswhite-1c-1b.tiff" FALSE) - add_convert_test(tiffcp g32d "-c g3:2d" "images/miniswhite-1c-1b.tiff" FALSE) - add_convert_test(tiffcp g32dfill "-c g3:2d:fill" "images/miniswhite-1c-1b.tiff" FALSE) - add_convert_test(tiffcp g4 "-c g4" "images/miniswhite-1c-1b.tiff" FALSE) - add_convert_test_multi(tiffcp tiffcp "" logluv "-c none" "-c sgilog" "" - "images/logluv-3c-16b.tiff" FALSE) - add_convert_test_multi(tiffcp thumbnail "" thumbnail "-c g3:1d" "" "" - "images/miniswhite-1c-1b.tiff" FALSE) - add_convert_test(tiffcp none "-c none" "images/quad-lzw-compat.tiff" FALSE) - add_convert_test(tiffcp noner1 "-c none -r 1" "images/lzw-single-strip.tiff" FALSE) - add_convert_test(tiffcp float64_lzw_2_le "-c lzw:2" "images/test_float64_predictor2_le_lzw.tif" FALSE) - add_convert_test(tiffcp float64_lzw_2_be "-c lzw:2" "images/test_float64_predictor2_be_lzw.tif" FALSE) +# RGBA +add_convert_tests(tiff2rgba default "" TIFFIMAGES TRUE) +# Test rotations +add_convert_tests(tiffcrop R90 "-R90" TIFFIMAGES TRUE) +# Test flip (mirror) +add_convert_tests(tiffcrop doubleflip "-F both" TIFFIMAGES TRUE) +# Test extracting a section 60 pixels wide and 60 pixels high +add_convert_tests(tiffcrop extract "-U px -E top -X 60 -Y 60" TIFFIMAGES TRUE) +# Test extracting the first and fourth quarters from the left side. +add_convert_tests(tiffcrop extractz14 "-E left -Z1:4,2:4" TIFFIMAGES TRUE) - # tiffdump - add_reader_test(tiffdump "" "images/miniswhite-1c-1b.tiff") - - # tiffinfo - add_reader_test(tiffinfo "-c -D -d -j -s" "images/custom_dir_EXIF_GPS.tiff") - add_reader_test(tiffinfo "-c -D -d -j -s" "images/minisblack-1c-16b.tiff") - add_reader_test(tiffinfo " " "images/tiff_with_subifd_chain.tif") - - # tiffcp split/join - foreach(image ${UNCOMPRESSEDIMAGES}) - list(APPEND ESCAPED_UNCOMPRESSED "${CMAKE_CURRENT_SOURCE_DIR}/${image}") - endforeach() - string(REPLACE ";" "^" ESCAPED_UNCOMPRESSED "${ESCAPED_UNCOMPRESSED}") - add_test(NAME "tiffcp-split" - COMMAND "${CMAKE_COMMAND}" - "-DTESTFILES=${ESCAPED_UNCOMPRESSED}" - "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-conjoined.tiff" - "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-split-" - ${tiff_test_extra_args} - -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake") - add_test(NAME "tiffcp-split-join" - COMMAND "${CMAKE_COMMAND}" - "-DTESTFILES=${ESCAPED_UNCOMPRESSED}" - "-DCONJOINED=${TEST_OUTPUT}/tiffcp-split-join-conjoined.tiff" - "-DSPLITFILE=${TEST_OUTPUT}/tiffcp-split-join-split-" - "-DRECONJOINED=${TEST_OUTPUT}/tiffcp-split-join-reconjoined.tiff" - ${tiff_test_extra_args} - -P "${CMAKE_CURRENT_SOURCE_DIR}/TiffSplitTest.cmake") - - # PDF - add_stdout_test(tiff2pdf "" "" "images/miniswhite-1c-1b.tiff" TRUE) - - # PS - add_stdout_test(tiff2ps "ps-1" "-a -p -1" "images/miniswhite-1c-1b.tiff" TRUE) - add_stdout_test(tiff2ps "ps-2" "-a -p -2" "images/miniswhite-1c-1b.tiff" TRUE) - add_stdout_test(tiff2ps "ps-3" "-a -p -3" "images/miniswhite-1c-1b.tiff" TRUE) - add_stdout_test(tiff2ps "eps-1" "-e -1" "images/miniswhite-1c-1b.tiff" TRUE) - - # BW - add_convert_tests(tiff2bw default "" RGBIMAGES TRUE) - - # RGBA - add_convert_tests(tiff2rgba default "" TIFFIMAGES TRUE) - # RGBA (old-jpeg) - add_convert_tests(tiff2rgba default "" TIFFIMAGES_OJPEG TRUE) - # Test rotations - add_convert_tests(tiffcrop R90 "-R90" TIFFIMAGES TRUE) - # Test flip (mirror) - add_convert_tests(tiffcrop doubleflip "-F both" TIFFIMAGES TRUE) - # Test extracting a section 60 pixels wide and 60 pixels high - add_convert_tests(tiffcrop extract "-U px -E top -X 60 -Y 60" TIFFIMAGES TRUE) - # Test extracting the first and fourth quarters from the left side. - add_convert_tests(tiffcrop extractz14 "-E left -Z1:4,2:4" TIFFIMAGES TRUE) -endif() +# test types +add_test(NAME "testtypes" + COMMAND "testtypes") diff --git a/thirdparty/SDL2_image/external/libtiff/test/Makefile.am b/thirdparty/SDL2_image/external/libtiff/test/Makefile.am index 0a7f9ad52..437503f12 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/test/Makefile.am @@ -44,9 +44,7 @@ EXTRA_DIST = \ TiffTest.cmake # All of the tests to execute via 'make check' -if TIFF_TESTS TESTS = $(check_PROGRAMS) $(TESTSCRIPTS) -endif # Tests which are expected to fail XFAIL_TESTS = @@ -55,33 +53,25 @@ XFAIL_TESTS = CLEANFILES = test_packbits.tif o-* if HAVE_JPEG -if TIFF_TOOLS JPEG_DEPENDENT_CHECK_PROG=raw_decode JPEG_DEPENDENT_TESTSCRIPTS=\ tiff2rgba-quad-tile.jpg.sh \ tiff2rgba-ojpeg_zackthecat_subsamp22_single_strip.sh \ tiff2rgba-ojpeg_chewey_subsamp21_multi_strip.sh \ tiff2rgba-ojpeg_single_strip_no_rowsperstrip.sh -endif + else JPEG_DEPENDENT_CHECK_PROG= JPEG_DEPENDENT_TESTSCRIPTS= endif -if BUILD_STATIC -STATIC_CHECK_PROGS=rational_precision2double -endif - # Executable programs which need to be built in order to support tests -if TIFF_TESTS check_PROGRAMS = \ ascii_tag long_tag short_tag strip_rw rewrite custom_dir custom_dir_EXIF_231 \ - defer_strile_loading defer_strile_writing test_directory test_open_options \ - test_append_to_strip test_ifd_loop_detection testtypes test_signed_tags $(JPEG_DEPENDENT_CHECK_PROG) $(STATIC_CHECK_PROGS) -endif + rational_precision2double defer_strile_loading defer_strile_writing testtypes \ + $(JPEG_DEPENDENT_CHECK_PROG) # Test scripts to execute -if TIFF_TOOLS TESTSCRIPTS = \ ppm2tiff_pbm.sh \ ppm2tiff_pgm.sh \ @@ -160,12 +150,8 @@ TESTSCRIPTS = \ tiff2rgba-rgb-3c-16b.sh \ tiff2rgba-rgb-3c-8b.sh \ testfax4.sh \ - testfax3_bug_513.sh \ testdeflatelaststripextradata.sh \ $(JPEG_DEPENDENT_TESTSCRIPTS) -else -TESTSCRIPTS= -endif # This list should contain the references files # from the 'refs' subdirectory @@ -175,7 +161,6 @@ REFFILES = \ refs/o-tiff2ps-PS2.ps \ refs/o-tiff2ps-PS3.ps \ refs/o-testfax4.tiff \ - refs/o-testfax3_bug_513.tiff \ refs/o-deflate-last-strip-extra-data.tiff # This list should contain all of the TIFF files in the 'images' @@ -200,8 +185,7 @@ TIFFIMAGES = \ images/ojpeg_single_strip_no_rowsperstrip.tiff \ images/testfax4.tiff \ images/deflate-last-strip-extra-data.tiff \ - images/custom_dir_EXIF_GPS.tiff \ - images/testfax3_bug_513.tiff + images/custom_dir_EXIF_GPS.tiff PNMIMAGES = \ images/minisblack-1c-8b.pgm \ @@ -215,20 +199,11 @@ PNMIMAGES = \ IMAGES_EXTRA_DIST = \ images/README.txt \ images/miniswhite-1c-1b.g3 \ - images/test_float64_predictor2_le_lzw.tif \ - images/test_float64_predictor2_be_lzw.tif \ - images/tiff_with_subifd_chain.tif \ - images/test_ifd_loop_to_self.tif \ - images/test_ifd_loop_to_first.tif \ - images/test_two_ifds.tif \ - images/test_ifd_loop_subifd.tif \ $(PNMIMAGES) \ $(TIFFIMAGES) noinst_HEADERS = tifftest.h -test_signed_tags_SOURCES = test_signed_tags.c -test_signed_tags_LDADD = $(LIBTIFF) ascii_tag_SOURCES = ascii_tag.c ascii_tag_LDADD = $(LIBTIFF) long_tag_SOURCES = long_tag.c check_tag.c @@ -243,28 +218,14 @@ raw_decode_SOURCES = raw_decode.c raw_decode_LDADD = $(LIBTIFF) custom_dir_SOURCES = custom_dir.c custom_dir_LDADD = $(LIBTIFF) - -if BUILD_STATIC rational_precision2double_SOURCES = rational_precision2double.c rational_precision2double_LDADD = $(LIBTIFF) -rational_precision2double_LDFLAGS = -static -endif - custom_dir_EXIF_231_SOURCES = custom_dir_EXIF_231.c custom_dir_EXIF_231_LDADD = $(LIBTIFF) defer_strile_loading_SOURCES = defer_strile_loading.c defer_strile_loading_LDADD = $(LIBTIFF) defer_strile_writing_SOURCES = defer_strile_writing.c defer_strile_writing_LDADD = $(LIBTIFF) -test_directory_SOURCES = test_directory.c -test_directory_LDADD = $(LIBTIFF) -test_open_options_SOURCES = test_open_options.c -test_open_options_LDADD = $(LIBTIFF) -test_append_to_strip_SOURCES = test_append_to_strip.c -test_append_to_strip_LDADD = $(LIBTIFF) -test_ifd_loop_detection_CFLAGS = -DSOURCE_DIR=\"@srcdir@\" -test_ifd_loop_detection_SOURCES = test_ifd_loop_detection.c -test_ifd_loop_detection_LDADD = $(LIBTIFF) AM_CPPFLAGS = -I$(top_srcdir)/libtiff diff --git a/thirdparty/SDL2_image/external/libtiff/test/TiffTest.cmake b/thirdparty/SDL2_image/external/libtiff/test/TiffTest.cmake index 924eef264..c1cf4d05b 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/TiffTest.cmake +++ b/thirdparty/SDL2_image/external/libtiff/test/TiffTest.cmake @@ -30,10 +30,6 @@ string(REPLACE "^" ";" CONVERT_COMMAND3 "${CONVERT_COMMAND3}") string(REPLACE "^" ";" STDOUT_COMMAND "${STDOUT_COMMAND}") string(REPLACE "^" ";" READER_COMMAND "${READER_COMMAND}") -if(NOT CONVERT_COMMAND1 AND NOT STDOUT_COMMAND AND NOT READER_COMMAND) - message(FATAL_ERROR "No test command specified") -endif() - if(CONVERT_COMMAND1) test_convert("${CONVERT_COMMAND1}" "${INFILE}" "${OUTFILE}") if(VALIDATE) @@ -41,30 +37,25 @@ if(CONVERT_COMMAND1) endif() endif() -get_filename_component(dir "${OUTFILE}" DIRECTORY) -get_filename_component(base "${OUTFILE}" NAME_WE) +get_filename_component(base "${OUTFILE}" NAME) get_filename_component(ext "${OUTFILE}" EXT) if(CONVERT_COMMAND2) - test_convert("${CONVERT_COMMAND2}" "${OUTFILE}" "${dir}/${base}-2${ext}") + test_convert("${CONVERT_COMMAND2}" "${OUTFILE}" "${base}-2${ext}") if(VALIDATE) tiffinfo_validate("${base}-2${ext}") endif() endif() if(CONVERT_COMMAND3) - test_convert("${CONVERT_COMMAND3}" "${dir}/${base}-2${ext}" "${dir}/${base}-3${ext}") + test_convert("${CONVERT_COMMAND3}" "${base}-2${ext}" "${base}-3${ext}") if(VALIDATE) tiffinfo_validate("${base}-3${ext}") endif() endif() if(STDOUT_COMMAND) - if(INFILE) - test_stdout("${STDOUT_COMMAND}" "${INFILE}" "${OUTFILE}") - else() - test_stdout_noargs("${STDOUT_COMMAND}") - endif() + test_stdout("${STDOUT_COMMAND}" "${INFILE}" "${OUTFILE}") endif() if(READER_COMMAND) diff --git a/thirdparty/SDL2_image/external/libtiff/test/TiffTestCommon.cmake b/thirdparty/SDL2_image/external/libtiff/test/TiffTestCommon.cmake index 6d3b04651..a0db67820 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/TiffTestCommon.cmake +++ b/thirdparty/SDL2_image/external/libtiff/test/TiffTestCommon.cmake @@ -56,7 +56,6 @@ macro(test_convert_multi command infile outfile) message(FATAL_ERROR "Returned failed status ${TEST_STATUS}! Output (if any) is in \"${native_outfile}\"") endif() endmacro() - # # Test a simple command which sends output to stdout # @@ -74,19 +73,6 @@ macro(test_stdout command infile outfile) endif() endmacro() -# -# Test a simple command which sends output to stdout -# -# test_stdout command infile outfile -macro(test_stdout_noargs command) - message(STATUS "Running ${MEMCHECK} ${command}") - execute_process(COMMAND ${MEMCHECK} ${command} - RESULT_VARIABLE TEST_STATUS) - if(TEST_STATUS) - message(FATAL_ERROR "Returned failed status ${TEST_STATUS}!") - endif() -endmacro() - # # Execute a simple command (e.g. tiffinfo) with one input file # diff --git a/thirdparty/SDL2_image/external/libtiff/test/ascii_tag.c b/thirdparty/SDL2_image/external/libtiff/test/ascii_tag.c index df29045a8..9a56d31d9 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/ascii_tag.c +++ b/thirdparty/SDL2_image/external/libtiff/test/ascii_tag.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2004, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,151 +32,144 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif #include "tiffio.h" static const char filename[] = "ascii_test.tiff"; -static const struct -{ - ttag_t tag; - const char *value; -} ascii_tags[] = {{TIFFTAG_DOCUMENTNAME, "Test TIFF image"}, - {TIFFTAG_IMAGEDESCRIPTION, "Temporary test image"}, - {TIFFTAG_MAKE, "This is not scanned image"}, - {TIFFTAG_MODEL, "No scanner"}, - {TIFFTAG_PAGENAME, "Test page"}, - {TIFFTAG_SOFTWARE, "Libtiff library"}, - {TIFFTAG_DATETIME, "2004:09:10 16:09:00"}, - {TIFFTAG_ARTIST, "Andrey V. Kiselev"}, - {TIFFTAG_HOSTCOMPUTER, "Debian GNU/Linux (Sarge)"}, - {TIFFTAG_TARGETPRINTER, "No printer"}, - {TIFFTAG_COPYRIGHT, "Copyright (c) 2004, Andrey Kiselev"}, - {TIFFTAG_FAXSUBADDRESS, "Fax subaddress"}, - /* DGN tags */ - {TIFFTAG_UNIQUECAMERAMODEL, "No camera"}, - {TIFFTAG_CAMERASERIALNUMBER, "1234567890"}}; -#define NTAGS (sizeof(ascii_tags) / sizeof(ascii_tags[0])) +static const struct { + ttag_t tag; + const char *value; +} ascii_tags[] = { + { TIFFTAG_DOCUMENTNAME, "Test TIFF image" }, + { TIFFTAG_IMAGEDESCRIPTION, "Temporary test image" }, + { TIFFTAG_MAKE, "This is not scanned image" }, + { TIFFTAG_MODEL, "No scanner" }, + { TIFFTAG_PAGENAME, "Test page" }, + { TIFFTAG_SOFTWARE, "Libtiff library" }, + { TIFFTAG_DATETIME, "2004:09:10 16:09:00" }, + { TIFFTAG_ARTIST, "Andrey V. Kiselev" }, + { TIFFTAG_HOSTCOMPUTER, "Debian GNU/Linux (Sarge)" }, + { TIFFTAG_TARGETPRINTER, "No printer" }, + { TIFFTAG_COPYRIGHT, "Copyright (c) 2004, Andrey Kiselev" }, + { TIFFTAG_FAXSUBADDRESS, "Fax subaddress" }, + /* DGN tags */ + { TIFFTAG_UNIQUECAMERAMODEL, "No camera" }, + { TIFFTAG_CAMERASERIALNUMBER, "1234567890" } +}; +#define NTAGS (sizeof (ascii_tags) / sizeof (ascii_tags[0])) static const char ink_names[] = "Red\0Green\0Blue"; const int ink_names_size = 15; -int main() +int +main() { - TIFF *tif; - size_t i; - unsigned char buf[] = {0, 127, 255}; - char *value; + TIFF *tif; + size_t i; + unsigned char buf[] = { 0, 127, 255 }; + char *value; - /* Test whether we can write tags. */ - tif = TIFFOpen(filename, "w"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filename); - return 1; - } + /* Test whether we can write tags. */ + tif = TIFFOpen(filename, "w"); + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); + return 1; + } - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 1)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, 1)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, sizeof(buf))) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB)) - { - fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); - goto failure; - } + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 1)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, 1)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, sizeof(buf))) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB)) { + fprintf (stderr, "Can't set PhotometricInterpretation tag.\n"); + goto failure; + } - for (i = 0; i < NTAGS; i++) - { - if (!TIFFSetField(tif, ascii_tags[i].tag, ascii_tags[i].value)) - { - fprintf(stderr, "Can't set tag %" PRIu32 ".\n", ascii_tags[i].tag); - goto failure; - } - } + for (i = 0; i < NTAGS; i++) { + if (!TIFFSetField(tif, ascii_tags[i].tag, + ascii_tags[i].value)) { + fprintf(stderr, "Can't set tag %lu.\n", + (unsigned long)ascii_tags[i].tag); + goto failure; + } + } - /* InkNames tag has special form, so we handle it separately. */ - if (!TIFFSetField(tif, TIFFTAG_NUMBEROFINKS, 3)) - { - fprintf(stderr, "Can't set tag %d (NUMBEROFINKS).\n", - TIFFTAG_NUMBEROFINKS); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_INKNAMES, ink_names_size, ink_names)) - { - fprintf(stderr, "Can't set tag %d (INKNAMES).\n", TIFFTAG_INKNAMES); - goto failure; - } + /* InkNames tag has special form, so we handle it separately. */ + if (!TIFFSetField(tif, TIFFTAG_NUMBEROFINKS, 3)) { + fprintf (stderr, "Can't set tag %d (NUMBEROFINKS).\n", + TIFFTAG_NUMBEROFINKS); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_INKNAMES, ink_names_size, ink_names)) { + fprintf (stderr, "Can't set tag %d (INKNAMES).\n", + TIFFTAG_INKNAMES); + goto failure; + } - /* Write dummy pixel data. */ - if (TIFFWriteScanline(tif, buf, 0, 0) == -1) - { - fprintf(stderr, "Can't write image data.\n"); - goto failure; - } + /* Write dummy pixel data. */ + if (TIFFWriteScanline(tif, buf, 0, 0) == -1) { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } - TIFFClose(tif); + TIFFClose(tif); + + /* Ok, now test whether we can read written values. */ + tif = TIFFOpen(filename, "r"); + if (!tif) { + fprintf (stderr, "Can't open test TIFF file %s.\n", filename); + return 1; + } - /* Ok, now test whether we can read written values. */ - tif = TIFFOpen(filename, "r"); - if (!tif) - { - fprintf(stderr, "Can't open test TIFF file %s.\n", filename); - return 1; - } + for (i = 0; i < NTAGS; i++) { + if (!TIFFGetField(tif, ascii_tags[i].tag, &value) + || strcmp(value, ascii_tags[i].value)) { + fprintf(stderr, "Can't get tag %lu.\n", + (unsigned long)ascii_tags[i].tag); + goto failure; + } + } - for (i = 0; i < NTAGS; i++) - { - if (!TIFFGetField(tif, ascii_tags[i].tag, &value) || - strcmp(value, ascii_tags[i].value)) - { - fprintf(stderr, "Can't get tag %" PRIu32 ".\n", ascii_tags[i].tag); - goto failure; - } - } + if (!TIFFGetField(tif, TIFFTAG_INKNAMES, &value) + || memcmp(value, ink_names, ink_names_size)) { + fprintf (stderr, "Can't get tag %d (INKNAMES).\n", + TIFFTAG_INKNAMES); + goto failure; + } - if (!TIFFGetField(tif, TIFFTAG_INKNAMES, &value) || - memcmp(value, ink_names, ink_names_size)) - { - fprintf(stderr, "Can't get tag %d (INKNAMES).\n", TIFFTAG_INKNAMES); - goto failure; - } - - TIFFClose(tif); - - /* All tests passed; delete file and exit with success status. */ - unlink(filename); - return 0; + TIFFClose(tif); + + /* All tests passed; delete file and exit with success status. */ + unlink(filename); + return 0; failure: - /* - * Something goes wrong; close file and return unsuccessful status. - * Do not remove the file for further manual investigation. - */ - TIFFClose(tif); - return 1; + /* + * Something goes wrong; close file and return unsuccessful status. + * Do not remove the file for further manual investigation. + */ + TIFFClose(tif); + return 1; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/check_tag.c b/thirdparty/SDL2_image/external/libtiff/test/check_tag.c index 66dcbb97a..5750d6839 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/check_tag.c +++ b/thirdparty/SDL2_image/external/libtiff/test/check_tag.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2004, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -29,59 +29,61 @@ #include "tiffio.h" -int CheckShortField(TIFF *tif, const ttag_t field, const uint16_t value) +int +CheckShortField(TIFF *tif, const ttag_t field, const uint16 value) { - uint16_t tmp = 123; + uint16 tmp = 123; - if (!TIFFGetField(tif, field, &tmp)) - { - fprintf(stderr, "Problem fetching tag %" PRIu32 ".\n", field); - return -1; - } - if (tmp != value) - { - fprintf(stderr, "Wrong SHORT value fetched for tag %" PRIu32 ".\n", - field); - return -1; - } + if (!TIFFGetField(tif, field, &tmp)) { + fprintf (stderr, "Problem fetching tag %lu.\n", + (unsigned long) field); + return -1; + } + if (tmp != value) { + fprintf (stderr, "Wrong SHORT value fetched for tag %lu.\n", + (unsigned long) field); + return -1; + } - return 0; + return 0; } -int CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16_t *values) +int +CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values) { - uint16_t tmp[2] = {123, 456}; + uint16 tmp[2] = { 123, 456 }; - if (!TIFFGetField(tif, field, tmp, tmp + 1)) - { - fprintf(stderr, "Problem fetching tag %" PRIu32 ".\n", field); - return -1; - } - if (tmp[0] != values[0] || tmp[1] != values[1]) - { - fprintf(stderr, "Wrong SHORT PAIR fetched for tag %" PRIu32 ".\n", - field); - return -1; - } + if (!TIFFGetField(tif, field, tmp, tmp + 1)) { + fprintf (stderr, "Problem fetching tag %lu.\n", + (unsigned long) field); + return -1; + } + if (tmp[0] != values[0] || tmp[1] != values[1]) { + fprintf (stderr, "Wrong SHORT PAIR fetched for tag %lu.\n", + (unsigned long) field); + return -1; + } - return 0; + return 0; } -int CheckLongField(TIFF *tif, const ttag_t field, const uint32_t value) +int +CheckLongField(TIFF *tif, const ttag_t field, const uint32 value) { - uint32_t tmp = 123; + uint32 tmp = 123; - if (!TIFFGetField(tif, field, &tmp)) - { - fprintf(stderr, "Problem fetching tag %" PRIu32 ".\n", field); - return -1; - } - if (tmp != value) - { - fprintf(stderr, "Wrong LONG value fetched for tag %" PRIu32 ".\n", - field); - return -1; - } + if (!TIFFGetField(tif, field, &tmp)) { + fprintf (stderr, "Problem fetching tag %lu.\n", + (unsigned long) field); + return -1; + } + if (tmp != value) { + fprintf (stderr, "Wrong LONG value fetched for tag %lu.\n", + (unsigned long) field); + return -1; + } - return 0; + return 0; } + + diff --git a/thirdparty/SDL2_image/external/libtiff/test/common.sh b/thirdparty/SDL2_image/external/libtiff/test/common.sh index 3d8e65339..0219ab3a9 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/common.sh +++ b/thirdparty/SDL2_image/external/libtiff/test/common.sh @@ -48,7 +48,6 @@ IMG_MINISWHITE_1C_1B_PBM=${IMAGES}/miniswhite-1c-1b.pbm IMG_MINISBLACK_1C_8B_PGM=${IMAGES}/minisblack-1c-8b.pgm IMG_RGB_3C_16B_PPM=${IMAGES}/rgb-3c-16b.ppm IMG_RGB_3C_8B_PPM=${IMAGES}/rgb-3c-8b.ppm -IMG_TIFF_WITH_SUBIFD_CHAIN=${IMAGES}/tiff_with_subifd_chain.tif # All uncompressed image files IMG_UNCOMPRESSED="${IMG_MINISBLACK_1C_16B} ${IMG_MINISBLACK_1C_8B} ${IMG_MINISWHITE_1C_1B} ${IMG_PALETTE_1C_1B} ${IMG_PALETTE_1C_4B} ${IMG_PALETTE_1C_4B} ${IMG_PALETTE_1C_8B} ${IMG_RGB_3C_8B} ${IMG_RGB_3C_16B}" diff --git a/thirdparty/SDL2_image/external/libtiff/test/custom_dir.c b/thirdparty/SDL2_image/external/libtiff/test/custom_dir.c index 34c512765..3b3ad2794 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/custom_dir.c +++ b/thirdparty/SDL2_image/external/libtiff/test/custom_dir.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2012, Frank Warmerdam * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -31,240 +31,215 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif -#include "tif_dir.h" #include "tiffio.h" +#include "tif_dir.h" #include "tifftest.h" static const char filename[] = "custom_dir.tif"; -#define SPP 3 /* Samples per pixel */ -const uint16_t width = 1; -const uint16_t length = 1; -const uint16_t bps = 8; -const uint16_t photometric = PHOTOMETRIC_RGB; -const uint16_t rows_per_strip = 1; -const uint16_t planarconfig = PLANARCONFIG_CONTIG; +#define SPP 3 /* Samples per pixel */ +const uint16 width = 1; +const uint16 length = 1; +const uint16 bps = 8; +const uint16 photometric = PHOTOMETRIC_RGB; +const uint16 rows_per_strip = 1; +const uint16 planarconfig = PLANARCONFIG_CONTIG; -static TIFFField customFields[] = { - {TIFFTAG_IMAGEWIDTH, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, - TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom1", NULL}, - {TIFFTAG_DOTRANGE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, - TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom2", NULL}, +static TIFFField +customFields[] = { + { TIFFTAG_IMAGEWIDTH, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom1", NULL }, + { TIFFTAG_DOTRANGE, -1, -1, TIFF_ASCII, 0, TIFF_SETGET_ASCII, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 1, 0, "Custom2", NULL }, }; -static TIFFFieldArray customFieldArray = {tfiatOther, 0, 2, customFields}; +static TIFFFieldArray customFieldArray = { tfiatOther, 0, 2, customFields }; -int main() +int +main() { - TIFF *tif; - unsigned char buf[SPP] = {0, 127, 255}; - uint64_t dir_offset = 0, dir_offset2 = 0; - uint64_t read_dir_offset = 0, read_dir_offset2 = 0; - uint64_t *dir_offset2_ptr = NULL; - char *ascii_value; - uint16_t count16 = 0; + TIFF *tif; + unsigned char buf[SPP] = { 0, 127, 255 }; + uint64 dir_offset = 0, dir_offset2 = 0; + uint64 read_dir_offset = 0, read_dir_offset2 = 0; + uint64 *dir_offset2_ptr = NULL; + char *ascii_value; + uint16 count16 = 0; + - /* We write the main directory as a simple image. */ - tif = TIFFOpen(filename, "w+"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filename); - return 1; - } + /* We write the main directory as a simple image. */ + tif = TIFFOpen(filename, "w+"); + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); + return 1; + } - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) - { - fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); - goto failure; - } + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) { + fprintf (stderr, "Can't set PhotometricInterpretation tag.\n"); + goto failure; + } - /* Write dummy pixel data. */ - if (TIFFWriteScanline(tif, buf, 0, 0) == -1) - { - fprintf(stderr, "Can't write image data.\n"); - goto failure; - } + /* Write dummy pixel data. */ + if (TIFFWriteScanline(tif, buf, 0, 0) == -1) { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } - if (!TIFFWriteDirectory(tif)) - { - fprintf(stderr, "TIFFWriteDirectory() failed.\n"); - goto failure; - } + if (!TIFFWriteDirectory( tif )) { + fprintf (stderr, "TIFFWriteDirectory() failed.\n"); + goto failure; + } - /* - * Now create an EXIF directory. - */ - if (TIFFCreateEXIFDirectory(tif) != 0) - { - fprintf(stderr, "TIFFCreateEXIFDirectory() failed.\n"); - goto failure; - } + /* + * Now create an EXIF directory. + */ + if (TIFFCreateEXIFDirectory(tif) != 0) { + fprintf (stderr, "TIFFCreateEXIFDirectory() failed.\n" ); + goto failure; + } - if (!TIFFSetField(tif, EXIFTAG_SPECTRALSENSITIVITY, - "EXIF Spectral Sensitivity")) - { - fprintf(stderr, "Can't write SPECTRALSENSITIVITY\n"); - goto failure; - } + if (!TIFFSetField( tif, EXIFTAG_SPECTRALSENSITIVITY, "EXIF Spectral Sensitivity")) { + fprintf (stderr, "Can't write SPECTRALSENSITIVITY\n" ); + goto failure; + } + + if (!TIFFWriteCustomDirectory( tif, &dir_offset )) { + fprintf (stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n"); + goto failure; + } - if (!TIFFWriteCustomDirectory(tif, &dir_offset)) - { - fprintf(stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n"); - goto failure; - } + /* + * Now create a custom directory with tags that conflict with mainline + * TIFF tags. + */ + + TIFFFreeDirectory( tif ); + if (TIFFCreateCustomDirectory(tif, &customFieldArray) != 0) { + fprintf (stderr, "TIFFCreateEXIFDirectory() failed.\n" ); + goto failure; + } - /* - * Now create a custom directory with tags that conflict with mainline - * TIFF tags. - */ + if (!TIFFSetField( tif, TIFFTAG_IMAGEWIDTH, "*Custom1")) { /* not really IMAGEWIDTH */ + fprintf (stderr, "Can't write pseudo-IMAGEWIDTH.\n" ); + goto failure; + } + + if (!TIFFSetField( tif, TIFFTAG_DOTRANGE, "*Custom2")) { /* not really DOTWIDTH */ + fprintf (stderr, "Can't write pseudo-DOTWIDTH.\n" ); + goto failure; + } + + if (!TIFFWriteCustomDirectory( tif, &dir_offset2 )) { + fprintf (stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n"); + goto failure; + } - TIFFFreeDirectory(tif); - if (TIFFCreateCustomDirectory(tif, &customFieldArray) != 0) - { - fprintf(stderr, "TIFFCreateEXIFDirectory() failed.\n"); - goto failure; - } + /* + * Go back to the first directory, and add the EXIFIFD pointer. + */ + TIFFSetDirectory(tif, 0); + TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset ); + TIFFSetField(tif, TIFFTAG_SUBIFD, 1, &dir_offset2 ); - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, "*Custom1")) - { /* not really IMAGEWIDTH */ - fprintf(stderr, "Can't write pseudo-IMAGEWIDTH.\n"); - goto failure; - } + TIFFClose(tif); + + /* Ok, now test whether we can read written values in the EXIF directory. */ + tif = TIFFOpen(filename, "r"); + + TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset ); + if( read_dir_offset != dir_offset ) { + fprintf (stderr, "Did not get expected EXIFIFD.\n" ); + goto failure; + } - if (!TIFFSetField(tif, TIFFTAG_DOTRANGE, "*Custom2")) - { /* not really DOTWIDTH */ - fprintf(stderr, "Can't write pseudo-DOTWIDTH.\n"); - goto failure; - } + TIFFGetField(tif, TIFFTAG_SUBIFD, &count16, &dir_offset2_ptr ); + read_dir_offset2 = dir_offset2_ptr[0]; + if( read_dir_offset2 != dir_offset2 || count16 != 1) { + fprintf (stderr, "Did not get expected SUBIFD.\n" ); + goto failure; + } - if (!TIFFWriteCustomDirectory(tif, &dir_offset2)) - { - fprintf(stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n"); - goto failure; - } + if( !TIFFReadEXIFDirectory(tif, read_dir_offset) ) { + fprintf (stderr, "TIFFReadEXIFDirectory() failed.\n" ); + goto failure; + } + + if (!TIFFGetField( tif, EXIFTAG_SPECTRALSENSITIVITY, &ascii_value) ) { + fprintf (stderr, "reading SPECTRALSENSITIVITY failed.\n" ); + goto failure; + } - /* - * Go back to the first directory, and add the EXIFIFD pointer. - */ - TIFFSetDirectory(tif, 0); - TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset); - TIFFSetField(tif, TIFFTAG_SUBIFD, 1, &dir_offset2); + if( strcmp(ascii_value,"EXIF Spectral Sensitivity") != 0) { + fprintf (stderr, "got wrong SPECTRALSENSITIVITY value.\n" ); + goto failure; + } - TIFFClose(tif); + /* Try reading the Custom directory */ + + if( !TIFFReadCustomDirectory(tif, read_dir_offset2, &customFieldArray) ) { + fprintf (stderr, "TIFFReadCustomDirectory() failed.\n" ); + goto failure; + } + + if (!TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &ascii_value) ) { + fprintf (stderr, "reading pseudo-IMAGEWIDTH failed.\n" ); + goto failure; + } - /* Ok, now test whether we can read written values in the EXIF directory. */ - tif = TIFFOpen(filename, "r"); + if( strcmp(ascii_value,"*Custom1") != 0) { + fprintf (stderr, "got wrong pseudo-IMAGEWIDTH value.\n" ); + goto failure; + } - TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset); - if (read_dir_offset != dir_offset) - { - fprintf(stderr, "Did not get expected EXIFIFD.\n"); - goto failure; - } + if (!TIFFGetField( tif, TIFFTAG_DOTRANGE, &ascii_value) ) { + fprintf (stderr, "reading pseudo-DOTRANGE failed.\n" ); + goto failure; + } - TIFFGetField(tif, TIFFTAG_SUBIFD, &count16, &dir_offset2_ptr); - read_dir_offset2 = dir_offset2_ptr[0]; - if (read_dir_offset2 != dir_offset2 || count16 != 1) - { - fprintf(stderr, "Did not get expected SUBIFD.\n"); - goto failure; - } + if( strcmp(ascii_value,"*Custom2") != 0) { + fprintf (stderr, "got wrong pseudo-DOTRANGE value.\n" ); + goto failure; + } - if (!TIFFReadEXIFDirectory(tif, read_dir_offset)) - { - fprintf(stderr, "TIFFReadEXIFDirectory() failed.\n"); - goto failure; - } - - if (!TIFFGetField(tif, EXIFTAG_SPECTRALSENSITIVITY, &ascii_value)) - { - fprintf(stderr, "reading SPECTRALSENSITIVITY failed.\n"); - goto failure; - } - - if (strcmp(ascii_value, "EXIF Spectral Sensitivity") != 0) - { - fprintf(stderr, "got wrong SPECTRALSENSITIVITY value.\n"); - goto failure; - } - - /* Try reading the Custom directory */ - - if (!TIFFReadCustomDirectory(tif, read_dir_offset2, &customFieldArray)) - { - fprintf(stderr, "TIFFReadCustomDirectory() failed.\n"); - goto failure; - } - - if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &ascii_value)) - { - fprintf(stderr, "reading pseudo-IMAGEWIDTH failed.\n"); - goto failure; - } - - if (strcmp(ascii_value, "*Custom1") != 0) - { - fprintf(stderr, "got wrong pseudo-IMAGEWIDTH value.\n"); - goto failure; - } - - if (!TIFFGetField(tif, TIFFTAG_DOTRANGE, &ascii_value)) - { - fprintf(stderr, "reading pseudo-DOTRANGE failed.\n"); - goto failure; - } - - if (strcmp(ascii_value, "*Custom2") != 0) - { - fprintf(stderr, "got wrong pseudo-DOTRANGE value.\n"); - goto failure; - } - - TIFFClose(tif); - - /* All tests passed; delete file and exit with success status. */ - unlink(filename); - return 0; + TIFFClose(tif); + + /* All tests passed; delete file and exit with success status. */ + unlink(filename); + return 0; failure: - /* - * Something goes wrong; close file and return unsuccessful status. - * Do not remove the file for further manual investigation. - */ - TIFFClose(tif); - return 1; + /* + * Something goes wrong; close file and return unsuccessful status. + * Do not remove the file for further manual investigation. + */ + TIFFClose(tif); + return 1; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/custom_dir_EXIF_231.c b/thirdparty/SDL2_image/external/libtiff/test/custom_dir_EXIF_231.c index 1e8df768d..854b19a99 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/custom_dir_EXIF_231.c +++ b/thirdparty/SDL2_image/external/libtiff/test/custom_dir_EXIF_231.c @@ -1,1969 +1,1398 @@ -/* - * Copyright (c) 2012, Frank Warmerdam - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * -- Module copied from custom_dir.c -- - *=========== Purpose - *=================================================================================== - * Extended and amended version for testing of EXIF 2.32, GPS and handling of - *custom fields. EXIF 2.32 and GPS are defined in amended files tif_dirinfo.c, - *tif_dirread.c, tiff.h, tiffio.h, tif_dir.h, tif_dir.c - * - *-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are - *defined as double precision and need to be written and also read in double - *precision! In order to maintain this code for both cases, it is checked above - *if the TiffLibrary is compiled with the new interface with Rational2Double or - *still uses the old definitions, by setting blnIsRational2Double above. - * - */ - -/*------------ - * This version writes the GPS and EXIF tags correctly, without additional - main-IFD and parameters! - * In contrary, custom_dir.c does write additional main-IFD and parameters to - file. - -------------*/ - -#define FOR_AUTO_TESTING -#ifdef FOR_AUTO_TESTING -/* Only for automake and CMake infrastructure the test should: - a.) delete any written testfiles when test passed (otherwise autotest - will fail) b.) goto failure, if any failure is detected, which is not - necessary when test is initiated manually for debugging -*/ -#define GOTOFAILURE goto failure; -#define GOTOFAILURE_GPS goto failure; -#define GOTOFAILURE_ALL_EXIF goto failure; -#else -#define GOTOFAILURE -#define GOTOFAILURE_GPS -#define GOTOFAILURE_ALL_EXIF -#endif - -#ifdef _MSC_VER -#pragma warning(disable : 4101) -#endif - -#include "tif_config.h" //necessary for linux compiler - -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "tiffio.h" -#include "tiffiop.h" - -int write_test_tiff(TIFF *tif, const char *filenameRead); - -static const char filename[] = "custom_dir_EXIF_231.tif"; -static const char filenameBigTiff[] = "custom_dir_EXIF_231_Big.tif"; - -#define SPP 3 /* Samples per pixel */ -const uint16_t width = 1; -const uint16_t length = 1; -const uint16_t bps = 8; -const uint16_t photometric = PHOTOMETRIC_RGB; -const uint16_t rows_per_strip = 1; -const uint16_t planarconfig = PLANARCONFIG_CONTIG; - -int main() -{ - TIFF *tif; - int ret, ret1, ret2; - - fprintf(stderr, "==== Test automatically if all EXIF and GPS tags are " - "written/read correctly. ====\n"); - /* --- Test with Classic-TIFF ---*/ - /* delete file, if exists */ - ret = unlink(filename); - if (ret != 0 && errno != ENOENT) - { - fprintf(stderr, "Can't delete test TIFF file %s.\n", filename); - } - - /* We write the main directory as a simple image. */ - tif = TIFFOpen(filename, "w+"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filename); - return 1; - } - fprintf(stderr, "-------- Test with ClassicTIFF started ----------\n"); - ret1 = write_test_tiff(tif, filename); - - if (ret1 > 0) - return (ret1); - - /*--- Test with BIG-TIFF ---*/ - /* delete file, if exists */ - ret = unlink(filenameBigTiff); - if (ret != 0 && errno != ENOENT) - { - fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameBigTiff); - } - - tif = TIFFOpen(filenameBigTiff, "w8"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filenameBigTiff); - return 1; - } - fprintf(stderr, "\n\n-------- Test with BigTIFF started ----------\n"); - ret2 = write_test_tiff(tif, filenameBigTiff); - - if (ret2 > 0) - return (ret2 + 10); - else - return (ret2); - -} /* main() */ - -int write_test_tiff(TIFF *tif, const char *filenameRead) -{ - unsigned char buf[SPP] = {0, 127, 255}; - uint64_t dir_offset = 0; - uint64_t dir_offset_GPS = 0, dir_offset_EXIF = 0; - uint64_t read_dir_offset = 0; - /*-- Additional variables --*/ - int retCode, retCode2; - unsigned char exifVersion[4] = { - '0', '2', '3', - '1'}; /* EXIF 2.31 version is 4 characters of a string! */ - unsigned char gpsVersion[4] = {2, 2, 0, 1}; /* GPS Version is 4 numbers! */ - unsigned char *pGpsVersion; - float auxFloat = 0.0f; - double auxDouble = 0.0; - char auxChar = 0; - uint32_t auxUint32 = 0; - short auxShort = 0; - long auxLong = 0; - void *pVoid; - int blnIsRational2Double; - - int i, j; - long nTags; - - const TIFFFieldArray *tFieldArray; - unsigned long tTag; - TIFFDataType tType; - short tWriteCount; - TIFFSetGetFieldType tSetFieldType; - char *tFieldName; - const TIFFField *fip; - - char blnFillGPSManually = 1; - -#define STRSIZE 1000 -#define N_SIZE 120 -#define VARIABLE_ARRAY_SIZE 6 - - /* -- Test data for writing -- */ - char auxCharArrayW[N_SIZE]; - short auxShortArrayW[N_SIZE]; - long auxLongArrayW[N_SIZE]; - float auxFloatArrayW[N_SIZE]; - double auxDoubleArrayW[N_SIZE]; - char auxTextArrayW[N_SIZE][STRSIZE]; - double auxDoubleArrayGPS1[3] = {1.0 / 7.0, 61.23456789012345, 62.0}; - double auxDoubleArrayGPS2[3] = {1.0 / 19.0, 88.34434, - 15.12345678901234567890}; - double auxDoubleArrayGPSTime[3] = {22.0, 17.0, 15.3456789}; - double auxDoubleGPSAltitude = 3456.0; - double auxDoubleGPSDirection = 63.7; - float auxFloatArrayN1[3] = {1.0f / 7.0f, 61.23456789012345f, 62.3f}; - float auxFloatArrayN2[3] = {-1.0f / 7.0f, -61.23456789012345f, -62.3f}; - float auxFloatArrayResolutions[4] = {5.456789f, 6.666666f, 0.0033f, - 5.0f / 213.0f}; - - /* -- Variables for reading -- */ - uint16_t count16 = 0; - union - { - long Long; - short Short1; - short Short2[2]; - char Char[4]; - } unionLong; - union - { - double dbl; - float flt1; - float flt2; - } auxDblUnion; - void *pVoidArray; - char *pAscii; - char auxCharArray[2 * STRSIZE]; - short auxShortArray[2 * N_SIZE]; - long auxLongArray[2 * N_SIZE]; - float auxFloatArray[2 * N_SIZE]; - double auxDoubleArray[2 * N_SIZE]; - double dblDiff, dblDiffLimit; -#define RATIONAL_EPS \ - (1.0 / 30000.0) /* reduced difference of rational values, approx 3.3e-5 */ - - /*-- Fill test data arrays for writing ----------- */ - for (i = 0; i < N_SIZE; i++) - { - sprintf(auxTextArrayW[i], - "N%d-String-%d_tttttttttttttttttttttttttttttx", i, i); - } - for (i = 0; i < N_SIZE; i++) - { - auxCharArrayW[i] = (char)(i + 1); - } - for (i = 0; i < N_SIZE; i++) - { - auxShortArrayW[i] = (short)(i + 1) * 7; - } - for (i = 0; i < N_SIZE; i++) - { - auxLongArrayW[i] = (i + 1) * 133; - } - for (i = 0; i < N_SIZE; i++) - { - auxFloatArrayW[i] = (float)((i + 1) * 133) / 3.3f; - } - for (i = 0; i < N_SIZE; i++) - { - auxDoubleArrayW[i] = (double)((i + 1) * 3689) / 4.5697; - } - - /*-- Setup standard tags of a simple tiff file --*/ - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) - { - fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); - goto failure; - } - - if (!TIFFSetField(tif, TIFFTAG_XRESOLUTION, auxFloatArrayResolutions[0])) - { - fprintf(stderr, "Can't set TIFFTAG_XRESOLUTION tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_YRESOLUTION, auxFloatArrayResolutions[1])) - { - fprintf(stderr, "Can't set TIFFTAG_YRESOLUTION tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_XPOSITION, auxFloatArrayResolutions[2])) - { - fprintf(stderr, "Can't set TIFFTAG_XPOSITION tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_YPOSITION, auxFloatArrayResolutions[3])) - { - fprintf(stderr, "Can't set TIFFTAG_YPOSITION tag.\n"); - goto failure; - } - -#define ADDITIONAL_TAGS -#ifdef ADDITIONAL_TAGS - /*-- Additional tags to check Rational standard tags, which are also defined - * as FIELD_CUSTOM */ - - /*- TIFFTAG_INKSET is a SHORT parameter (TIFF_SHORT, TIFF_SETGET_UINT16) - * with field_bit=FIELD_CUSTOM !! -*/ - if (!TIFFSetField(tif, TIFFTAG_INKSET, 34)) - { - fprintf(stderr, "Can't set TIFFTAG_INKSET tag.\n"); - goto failure; - } - - /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter ( TIFF_FLOAT, - * TIFF_SETGET_FLOAT) with field_bit=FIELD_CUSTOM !! -*/ - /* - can be written with Double but has to be read with float parameter */ -#define PIXAR_FOVCOT_VAL 5.123456789123456789 - auxFloat = (float)PIXAR_FOVCOT_VAL; - auxDouble = (double)PIXAR_FOVCOT_VAL; - if (!TIFFSetField(tif, TIFFTAG_PIXAR_FOVCOT, auxDouble)) - { - fprintf(stderr, "Can't set TIFFTAG_PIXAR_FOVCOT tag.\n"); - goto failure; - } - /*- TIFFTAG_STONITS is a DOUBLE parameter (TIFF_DOUBLE, TIFF_SETGET_DOUBLE) - * with field_bit=FIELD_CUSTOM! Only TIFFTAG_STONITS is a TIFF_DOUBLE, which - * has to be read as DOUBLE!! - */ -#define STONITS_VAL 6.123456789123456789 - auxDouble = STONITS_VAL; - auxFloat = (float)auxDouble; - if (!TIFFSetField(tif, TIFFTAG_STONITS, auxDouble)) - { - fprintf(stderr, "Can't set TIFFTAG_STONITS tag.\n"); - goto failure; - } - - /*- TIFFTAG_YCBCRPOSITIONING is a SHORT parameter */ - auxLong = auxShort = 5; - if (!TIFFSetField(tif, TIFFTAG_YCBCRPOSITIONING, auxLong)) - { - fprintf(stderr, "Can't set TIFFTAG_YCBCRPOSITIONING tag.\n"); - goto failure; - } - - /* - TIFFTAG_BESTQUALITYSCALE is a Rational parameter, FIELD_CUSTOM and - * TIFF_SETGET_DOUBLE */ - /* With Rational2Double upgrade tag is redefined to TIFF_SETGET_FLOAT, but - * can be still written with double. */ -#define BESTQUALITYSCALE_VAL 15.3 - auxDouble = BESTQUALITYSCALE_VAL; - if (!TIFFSetField(tif, TIFFTAG_BESTQUALITYSCALE, auxDouble)) - { - fprintf(stderr, "Can't set TIFFTAG_BESTQUALITYSCALE tag.\n"); - goto failure; - } - - /* - TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT */ - if (!TIFFSetField(tif, TIFFTAG_BASELINENOISE, auxDouble)) - { - fprintf(stderr, "Can't set TIFFTAG_BASELINENOISE tag.\n"); - goto failure; - } - - /*--- For static or variable ARRAYs the case is different ---*/ - /*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter - * TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable - * length of array. */ - if (!TIFFSetField(tif, TIFFTAG_DECODE, 3, auxFloatArrayN2)) - { - fprintf(stderr, "Can't set TIFFTAG_DECODE tag.\n"); - goto failure; - } - - /*- Variable Array: TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT */ - if (!TIFFSetField(tif, TIFFTAG_BLACKLEVEL, 3, auxFloatArrayN1)) - { - fprintf(stderr, "Can't set TIFFTAG_BLACKLEVEL tag.\n"); - goto failure; - } - - /*- Fixed Array: TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, - * TIFF_SETGET_C0_FLOAT */ - if (!TIFFSetField(tif, TIFFTAG_DEFAULTCROPSIZE, &auxFloatArrayW[0])) - { - fprintf(stderr, "Can't set TIFFTAG_DEFAULTCROPSIZE tag.\n"); - goto failure; - } -#endif /* -- ADDITIONAL_TAGS -- */ - - /*================== Rational2Double Interface Check =====================*/ - /*-- Check, if the TiffLibrary is compiled with the new interface with - Rational2Double or still uses the old definitions. For that, - TIFF_RATIONAL tags with FIELD_CUSTOM are changed from TIFF_SETGET_DOUBLE - to TIFF_SETGET_FLOAT for the new interface in order to prevent the old - reading behaviour. Tags to check: TIFFTAG_BESTQUALITYSCALE, - TIFFTAG_BASELINENOISE, TIFFTAG_BASELINESHARPNESS - */ - fip = TIFFFindField(tif, TIFFTAG_BESTQUALITYSCALE, TIFF_ANY); - tSetFieldType = fip->set_field_type; - if (tSetFieldType == TIFF_SETGET_DOUBLE) - { - blnIsRational2Double = FALSE; - } - else - { - blnIsRational2Double = TRUE; - fprintf(stderr, "-- Rational2Double from TIFF tag detected --\n"); - } - - /*================== Write GPS and EXIF tags =====================*/ - - /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve - * space for final dir_offset value, */ - /* which is properly written at the end. */ - dir_offset = 0; /* Zero, in case no Custom-IFD is written */ - -#define WRITE_GPS_TAGS -#ifdef WRITE_GPS_TAGS - if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset)) - { - fprintf(stderr, "Can't write TIFFTAG_GPSIFD\n"); - } -#endif - - /*------- And also do the same for the EXIF IFD tag here, because we have to - * save the main directory next ------*/ - /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve - * space for final dir_offset value, which is properly written at the end. - */ -#define WRITE_EXIF_TAGS -#ifdef WRITE_EXIF_TAGS - if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset)) - { - fprintf(stderr, "Can't write TIFFTAG_EXIFIFD\n"); - } -#endif - -#ifndef WRITEPIXELLAST - /*-- Write dummy pixel data. --*/ - if (TIFFWriteScanline(tif, buf, 0, 0) < 0) - { - fprintf(stderr, "Can't write image data.\n"); - goto failure; - } -#endif - -#ifdef WRITE_GPS_TAGS -#define READ_GPS_TAGS - /*================== Write GPS tags =====================*/ - - /*-- Save current tiff-directory to file before directory is changed. - * Otherwise it will be lost! */ - /* The tif-structure is overwritten/ freshly initialized by any - * "CreateDirectory" */ - /*retCode = TIFFCheckpointDirectory(tif);*/ /* does not cleanup - Tiff-Structure */ - retCode = TIFFWriteDirectory(tif); /* cleanup Tiff-structure */ - - /*-- Now create a GPS directory. */ - if (TIFFCreateGPSDirectory(tif) != 0) - { - fprintf(stderr, "TIFFCreateGPSDirectory() failed.\n"); - goto failure; - } - - if (!TIFFSetField(tif, GPSTAG_VERSIONID, gpsVersion)) - { - fprintf(stderr, "Can't write GPSTAG_VERSIONID\n"); - goto failure; - } - - if (blnFillGPSManually) - { - /*================= Write manually valid data to the GPS fields - * ==============*/ - if (!TIFFSetField(tif, GPSTAG_LATITUDEREF, "N\0")) - { - fprintf(stderr, "Can't write GPSTAG_LATITUDEREF\n"); - goto failure; - } - /*-- Unfortunately, Rational values are defined as SETGET_DOUBLE but are - * internally always stored as float. Single Rational values do not - * matter for writing, because TIFFSetField() uses va_arg() which - * performs "variables promotion" from type float to type double! - * However, for reading of Rational values ONLY float-variables are - * allowed - in contrary to the SETGET_DOUBLE specification at - * tiffFields[] in tif_dirinfo.c. - */ - /*-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG - * values are defined as double precision and need to be written and - * also read in double precision! In order to maintain this code for - * both cases, it is checked above if the TiffLibrary is compiled with - * the new interface with Rational2Double or still uses the old - * definitions, by setting blnIsRational2Double above. - */ - if (blnIsRational2Double) - { - fprintf(stderr, - "-- GPS tags are written using Rational2Double --\n"); - } - else - { - fprintf(stderr, "-- GPS tags are written using standard --\n"); - } - if (!blnIsRational2Double) - { - for (j = 0; j < 3; j++) - auxFloatArray[j] = (float)auxDoubleArrayGPS1[j]; - if (!TIFFSetField(tif, GPSTAG_LATITUDE, auxFloatArray)) - { - fprintf(stderr, "Can't write GPSTAG_LATITUDE\n"); - goto failure; - } - } - else - { - /* Rational2Double interface for GPSTAG */ - if (!TIFFSetField(tif, GPSTAG_LATITUDE, auxDoubleArrayGPS1)) - { - fprintf(stderr, "Can't write GPSTAG_LATITUDE\n"); - goto failure; - } - } - if (!TIFFSetField(tif, GPSTAG_LONGITUDEREF, "W\0")) - { - fprintf(stderr, "Can't write GPSTAG_LONGITUDEREF\n"); - goto failure; - } - if (!blnIsRational2Double) - { - for (j = 0; j < 3; j++) - auxFloatArray[j] = (float)auxDoubleArrayGPS2[j]; - if (!TIFFSetField(tif, GPSTAG_LONGITUDE, auxFloatArray)) - { - fprintf(stderr, "Can't write GPSTAG_LONGITUDE\n"); - goto failure; - } - } - else - { - /* Rational2Double interface for GPSTAG */ - if (!TIFFSetField(tif, GPSTAG_LONGITUDE, auxDoubleArrayGPS2)) - { - fprintf(stderr, "Can't write GPSTAG_LONGITUDE\n"); - goto failure; - } - } - /*-- AltitudeRef: default is above sea level!! */ - if (!TIFFSetField(tif, GPSTAG_ALTITUDEREF, 0)) - { - fprintf(stderr, "Can't write GPSTAG_ALTITUDEREF\n"); - goto failure; - } - if (!TIFFSetField(tif, GPSTAG_ALTITUDE, auxDoubleGPSAltitude)) - { - fprintf(stderr, "Can't write GPSTAG_ALTITUDE\n"); - goto failure; - } - /*-- TimeStamp is only hh:mm:ss. See also DateTime string */ - if (!TIFFSetField(tif, GPSTAG_TIMESTAMP, auxDoubleArrayGPSTime)) - { - fprintf(stderr, "Can't write GPSTAG_TIMESTAMP\n"); - goto failure; - } - if (!TIFFSetField(tif, GPSTAG_DATESTAMP, "2012:11:04")) - { - fprintf(stderr, "Can't write GPSTAG_DATESTAMP\n"); - goto failure; - } - - if (!TIFFSetField(tif, GPSTAG_IMGDIRECTIONREF, "T\0")) - { - fprintf(stderr, "Can't write GPSTAG_IMGDIRECTIONREF\n"); - goto failure; - } - if (!TIFFSetField(tif, GPSTAG_IMGDIRECTION, auxDoubleGPSDirection)) - { - fprintf(stderr, "Can't write GPSTAG_IMGDIRECTION\n"); - goto failure; - } - - /*-- Type TIFF_UNDEFINED */ - if (!TIFFSetField(tif, GPSTAG_PROCESSINGMETHOD, 3, &auxCharArrayW[10])) - { - fprintf(stderr, "Can't write GPSTAG_PROCESSINGMETHOD\n"); - goto failure; - } - if (!TIFFSetField(tif, GPSTAG_AREAINFORMATION, 4, &auxCharArrayW[20])) - { - fprintf(stderr, "Can't write GPSTAG_AREAINFORMATION\n"); - goto failure; - } - - /*-- PSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, - * TIFF_SETGET_UINT16 */ - if (!TIFFSetField(tif, GPSTAG_DIFFERENTIAL, auxShortArrayW[5])) - { - fprintf(stderr, "Can't write GPSTAG_DIFFERENTIAL\n"); - goto failure; - } - - /* GPSTAG_GPSHPOSITIONINGERROR , 1, 1, TIFF_RATIONAL , 0, - * TIFF_SETGET_DOUBLE but here written in float-precision */ -#define GPSHPOSITIONINGERROR_VAL 0.369 - auxFloat = (float)GPSHPOSITIONINGERROR_VAL; - if (!TIFFSetField(tif, GPSTAG_GPSHPOSITIONINGERROR, auxFloat)) - { - fprintf(stderr, "Can't write GPSTAG_GPSHPOSITIONINGERROR\n"); - goto failure; - } - } - else - { - /*================= Write arbitrary data to the GPS fields - * ==============*/ - - /*-- Get array, where GPS tag fields are defined --*/ - tFieldArray = _TIFFGetGpsFields(); - nTags = tFieldArray->count; - - /*-- TODO: fill in the for / switch part of EXIF writing, when finished - * and tested!! */ - - } /*-- if (blnFillGPSManually) --*/ - - /*-- GPS - write custom directory GPS into file...---*/ - /* (Get back the offset of GPS directory) */ - if (!TIFFWriteCustomDirectory(tif, &dir_offset_GPS)) - { - fprintf(stderr, "TIFFWriteCustomDirectory() with GPS failed.\n"); - goto failure; - } - - /*--- CheckpointDirectory at this place generates a second Main-IFD!!! */ - /* retCode = TIFFCheckpointDirectory(tif); */ - - /*-- Set / reload previously saved main directory from file ---*/ - if (!TIFFSetDirectory(tif, 0)) - { - fprintf(stderr, "TIFFSetDirectory() within GPS failed.\n"); - goto failure; - } - - /*-- Write GPS tag reference / offset into GPSIFD tag in main directory --*/ - if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset_GPS)) - { - fprintf(stderr, "Can't write TIFFTAG_GPSIFD\n"); - goto failure; - } - - /*=============== END writing GPS tags ==========================*/ -#endif /*-- WRITE_GPS_TAGS --*/ - - /*================== Write EXIF 2.31 tags =====================*/ - - /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve - * space for final dir_offset value, */ - /* which is properly written at the end.*/ - /*- We did this already above together with the GPS IFD-tag. Otherwise we - * would do this here !! --------*/ - /* if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset )) { - fprintf (stderr, "Can't write TIFFTAG_EXIFIFD\n" ); - } - */ - -#ifdef WRITE_EXIF_TAGS -#define READ_EXIF_TAGS - /*-- Save current tiff-directory to file before directory is changed. - * Otherwise it will be lost! The tif-structure is overwritten/ freshly - * initialized by any "CreateDirectory" - */ - - /*----- What is needed here ??? ---- - * In custom_dir.c only TIFFFreeDirectory( tif ); is used to set - *fields of another Sub-Directory TIFFFreeDirectory(tif); *-- Release - *storage associated with a directory, especially custom-fields. - *-- Using only TIFFFreeDirectory() here leads to an error!! - *-- Using here TIFFCheckpointDirectory() leads to an additional Main-IFD ?? - */ - /*retCode = TIFFCheckpointDirectory(tif);*/ /* does not cleanup - Tiff-Structure */ - retCode = TIFFWriteDirectory(tif); /* cleanup Tiff-structure */ - - /*-- Now create an EXIF directory. */ - if (TIFFCreateEXIFDirectory(tif) != 0) - { - fprintf(stderr, "TIFFCreateEXIFDirectory() failed.\n"); - goto failure; - } - -#define WRITE_ALL_EXIF_TAGS -#ifdef WRITE_ALL_EXIF_TAGS -#define READ_ALL_EXIF_TAGS - /*================= EXIF: Write arbitrary data to the EXIF fields - * ==============*/ - /*-- Get array, where EXIF tag fields are defined - * EXIF tags are written automatically with the defined precision - * according to its tSetFieldType using the code below --*/ - tFieldArray = _TIFFGetExifFields(); - nTags = tFieldArray->count; - - for (i = 0; i < nTags; i++) - { - bool deferredSetField = false; - tTag = tFieldArray->fields[i].field_tag; - tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ - tWriteCount = tFieldArray->fields[i].field_writecount; - tSetFieldType = tFieldArray->fields[i] - .set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ - tFieldName = tFieldArray->fields[i].field_name; - pVoid = NULL; - - /*-- dependent on set_field_type write value --*/ - switch (tSetFieldType) - { - case TIFF_SETGET_ASCII: - /* Either the stringlength is defined as a fixed length in - * .field_writecount or a NULL-terminated string is used. */ - /* Shorter strings than in auxTextArraxW need a - * NULL-termination. Therefore copy the string. */ - if (tWriteCount > 0) - auxLong = tWriteCount - 1; - else - auxLong = (long)strlen(auxTextArrayW[i]) - 1; - strncpy(auxCharArray, auxTextArrayW[i], auxLong); - auxCharArray[auxLong] = 0; - if (!TIFFSetField(tif, tTag, auxCharArray)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - break; - case TIFF_SETGET_UINT8: - case TIFF_SETGET_UINT16: - case TIFF_SETGET_UINT32: - case TIFF_SETGET_IFD8: - case TIFF_SETGET_INT: - /*-- All those can be written with char, short or long - * parameter. Only value range should be in line. */ - if (!TIFFSetField(tif, tTag, auxLongArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - break; - case TIFF_SETGET_SINT8: - case TIFF_SETGET_SINT16: - case TIFF_SETGET_SINT32: - /*-- All those can be written with char, short or long - * parameter. Only value range should be in line. */ - if (!TIFFSetField(tif, tTag, -1.0 * auxLongArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - break; - case TIFF_SETGET_FLOAT: - case TIFF_SETGET_DOUBLE: - if (tWriteCount == 1) - { - /*-- All single values can be written with float or double - * parameter. Only value range should be in line. */ - if (!TIFFSetField(tif, tTag, auxDoubleArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - } - else - { - fprintf( - stderr, - "WriteCount for .set_field_type %d should be 1! %s\n", - tSetFieldType, tFieldArray->fields[i].field_name); - } - break; - case TIFF_SETGET_C0_FLOAT: - case TIFF_SETGET_C0_DOUBLE: - case TIFF_SETGET_C16_FLOAT: - case TIFF_SETGET_C16_DOUBLE: - case TIFF_SETGET_C32_FLOAT: - case TIFF_SETGET_C32_DOUBLE: - /* _Cxx_ just defines the size of the count parameter for the - * array as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array or a - * variable array */ - if (tWriteCount == 1) - { - fprintf(stderr, - "WriteCount for .set_field_type %d should be -1 or " - "greater than 1! %s\n", - tSetFieldType, tFieldArray->fields[i].field_name); - } - else - { - /*-- Either fix or variable array --*/ - /* For arrays, distinguishing between float or double is - * essential, even for writing */ - if (tSetFieldType == TIFF_SETGET_C0_FLOAT || - tSetFieldType == TIFF_SETGET_C16_FLOAT || - tSetFieldType == TIFF_SETGET_C32_FLOAT) - pVoid = &auxFloatArrayW[i]; - else - pVoid = &auxDoubleArrayW[i]; - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) - { - /* fixed array with needed arraysize defined in - * .field_writecount */ - if (!TIFFSetField(tif, tTag, pVoid)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - } - else - { - /* special treatment of variable array */ - /* for test, use always arraysize of VARIABLE_ARRAY_SIZE - */ - if (!TIFFSetField(tif, tTag, VARIABLE_ARRAY_SIZE, - pVoid)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - } - } - break; - case TIFF_SETGET_C0_UINT8: - case TIFF_SETGET_C0_SINT8: - case TIFF_SETGET_C16_UINT8: - case TIFF_SETGET_C16_SINT8: - case TIFF_SETGET_C32_UINT8: - case TIFF_SETGET_C32_SINT8: - /* For arrays, distinguishing between float or double is - * essential, even for writing */ - pVoid = &auxCharArrayW[i]; - deferredSetField = true; - break; - case TIFF_SETGET_C0_UINT16: - case TIFF_SETGET_C0_SINT16: - case TIFF_SETGET_C16_UINT16: - case TIFF_SETGET_C16_SINT16: - case TIFF_SETGET_C32_UINT16: - case TIFF_SETGET_C32_SINT16: - pVoid = &auxShortArrayW[i]; - deferredSetField = true; - break; - case TIFF_SETGET_C0_UINT32: - case TIFF_SETGET_C0_SINT32: - case TIFF_SETGET_C16_UINT32: - case TIFF_SETGET_C16_SINT32: - case TIFF_SETGET_C32_UINT32: - case TIFF_SETGET_C32_SINT32: - pVoid = &auxLongArrayW[i]; - deferredSetField = true; - break; - default: - fprintf(stderr, - "SetFieldType %d not defined within writing switch for " - "%s.\n", - tSetFieldType, tFieldName); - }; /*-- switch() --*/ - - if (deferredSetField) - { - /* _Cxx_ just defines the size of the count parameter for the array - * as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array or a variable - * array */ - if (tWriteCount == 1) - { - fprintf(stderr, - "WriteCount for .set_field_type %d should be -1 or " - "greater than 1! %s\n", - tSetFieldType, tFieldArray->fields[i].field_name); - } - else - { - /*-- Either fix or variable array --*/ - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) - { - /* fixed array with needed arraysize defined in - * .field_writecount */ - if (!TIFFSetField(tif, tTag, pVoid)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - } - else - { - /* special treatment of variable array */ - /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ - if (!TIFFSetField(tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - } - } - } - } /*-- for() --*/ - /*================= EXIF: END Writing arbitrary data to the EXIF fields END - * END END ==============*/ -#endif /*-- WRITE_ALL_EXIF_TAGS --*/ - - /*--- Set valid EXIF version, which is a 4 byte string --*/ - if (!TIFFSetField(tif, EXIFTAG_EXIFVERSION, exifVersion)) - { - fprintf(stderr, "Can't write EXIFTAG_EXIFVERSION\n"); - goto failure; - } - - /*-- EXIF - write custom directory EXIF into file...---*/ - /* (Get back the offset of EXIF directory) */ - if (!TIFFWriteCustomDirectory(tif, &dir_offset_EXIF)) - { - fprintf(stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n"); - goto failure; - } - - /*-- Go back to the first (main) directory, and set correct value of the - * EXIFIFD pointer. */ - /* (directory is reloaded from file!) */ - TIFFSetDirectory(tif, 0); - TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset_EXIF); -#endif /*-- WRITE_EXIF_TAGS --*/ - -#ifdef WRITEPIXELLAST - /*-- Write dummy pixel data. --*/ - if (TIFFWriteScanline(tif, buf, 0, 0) < 0) - { - fprintf(stderr, "Can't write image data.\n"); - goto failure; - } -#endif - /*-- Write directory to file --*/ - /* Always WriteDirectory before using/creating another directory. */ - /* Not necessary before TIFFClose(), however, TIFFClose() uses - * TIFFReWriteDirectory(), which forces directory to be written at another - * location. */ - retCode = TIFFWriteDirectory(tif); - - /*-- Write File to disk and close file --*/ - /* TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be - * written at another location. */ - /* Therefore, better use TIFFWriteDirectory() before. */ - TIFFClose(tif); - - fprintf(stderr, "-------- Continue Test ---------- reading ...\n"); - - /*========================= READING ============= READING - * ========================================*/ - /* Ok, now test whether we can read written values correctly. */ - tif = TIFFOpen(filenameRead, "r"); - - /*-- Read some parameters out of the main directory --*/ - - /*-- IMAGEWIDTH and -LENGTH are defined as TIFF_SETGET_UINT32 */ - retCode = TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &auxUint32); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGEWIDTH"); - } - if (auxUint32 != width) - { - fprintf(stderr, - "Read value of IMAGEWIDTH %" PRIu32 - " differs from set value %" PRIu16 "\n", - auxUint32, width); - } - retCode = TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &auxUint32); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGELENGTH"); - } - if (auxUint32 != width) - { - fprintf(stderr, - "Read value of TIFFTAG_IMAGELENGTH %" PRIu32 - " differs from set value %" PRIu16 "\n", - auxUint32, length); - } - -#ifdef ADDITIONAL_TAGS - /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter of type FIELD_CUSTOM !! */ - retCode = TIFFGetField(tif, TIFFTAG_PIXAR_FOVCOT, &auxFloat); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_PIXAR_FOVCOT"); - } - if (auxFloat != (float)PIXAR_FOVCOT_VAL) - { - fprintf( - stderr, - "Read value of TIFFTAG_PIXAR_FOVCOT %f differs from set value %f\n", - auxFloat, PIXAR_FOVCOT_VAL); - } - - /* - TIFFTAG_BESTQUALITYSCALE is a Rational parameter, FIELD_CUSTOM and - * TIFF_SETGET_FLOAT */ - retCode = TIFFGetField(tif, TIFFTAG_BESTQUALITYSCALE, &auxFloat); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_BESTQUALITYSCALE"); - } - if (auxFloat != (float)BESTQUALITYSCALE_VAL) - { - fprintf(stderr, - "Read value of TIFFTAG_BESTQUALITYSCALE %f differs from set " - "value %f\n", - auxFloat, BESTQUALITYSCALE_VAL); - } - - /* - TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT */ - retCode = TIFFGetField(tif, TIFFTAG_BASELINENOISE, &auxDblUnion.dbl); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_BASELINENOISE"); - } - if (auxDblUnion.flt1 != (float)BESTQUALITYSCALE_VAL) - { - fprintf(stderr, - "Read float value of TIFFTAG_BASELINENOISE %f differs from set " - "value %f\n", - auxDblUnion.flt1, BESTQUALITYSCALE_VAL); - } - - /*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter - * TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable - * length of array. */ - retCode = TIFFGetField(tif, TIFFTAG_DECODE, &count16, &pVoidArray); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_DECODE"); - } - /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, - * contents needs to be saved. */ - memcpy(&auxFloatArray, pVoidArray, (count16 * sizeof(auxFloatArray[0]))); - for (i = 0; i < count16; i++) - { - dblDiffLimit = RATIONAL_EPS * auxFloatArrayN2[i]; - dblDiff = auxFloatArray[i] - auxFloatArrayN2[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of TIFFTAG_DECODE Array %f differs from set " - "value %f\n", - i, auxFloatArray[i], auxFloatArrayN2[i]); - } - } - - retCode = TIFFGetField(tif, TIFFTAG_BLACKLEVEL, &count16, &pVoidArray); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_BLACKLEVEL"); - } - /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, - * contents needs to be saved. */ - memcpy(&auxFloatArray, pVoidArray, (count16 * sizeof(auxFloatArray[0]))); - for (i = 0; i < count16; i++) - { - dblDiffLimit = RATIONAL_EPS * auxFloatArrayN1[i]; - dblDiff = auxFloatArray[i] - auxFloatArrayN1[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of TIFFTAG_BLACKLEVEL Array %f differs from " - "set value %f\n", - i, auxFloatArray[i], auxFloatArrayN1[i]); - } - } - - /*- Fixed Array: TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, - * TIFF_SETGET_C0_FLOAT */ - retCode = TIFFGetField(tif, TIFFTAG_DEFAULTCROPSIZE, &pVoidArray); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_DEFAULTCROPSIZE"); - } - /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, - * contents needs to be saved. */ - memcpy(&auxFloatArray, pVoidArray, (2 * sizeof(auxFloatArray[0]))); - for (i = 0; i < 2; i++) - { - dblDiffLimit = RATIONAL_EPS * auxFloatArrayW[i]; - dblDiff = auxFloatArray[i] - auxFloatArrayW[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of TIFFTAG_DEFAULTCROPSIZE Array %f differs " - "from set value %f\n", - i, auxFloatArray[i], auxFloatArrayW[i]); - } - } - -#endif /*-- ADDITIONAL_TAGS --*/ - -#ifdef READ_GPS_TAGS - /*================== Reading GPS tags =====================*/ - /*-- First get offset to GPS-directory and set it active (this will destroy - * previously main directory fields in memory!) */ - retCode = TIFFGetField(tif, TIFFTAG_GPSIFD, &read_dir_offset); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_GPSIFD"); - } - retCode = TIFFReadGPSDirectory(tif, read_dir_offset); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFReadGPSDirectory()"); - } - - /*-- Now read some parameters from GPS-directory --*/ - - /*-- Fixed Array: GPS-Version is a fixed array (of 4 characters) */ - retCode = TIFFGetField(tif, GPSTAG_VERSIONID, &pGpsVersion); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "GPSTAG_VERSIONID"); - } - else - { - memcpy(auxCharArray, pGpsVersion, sizeof(gpsVersion)); - for (i = 0; i < 4; i++) - { - if (auxCharArray[i] != pGpsVersion[i]) - { - fprintf(stderr, - "Read value %d of GPSTAG_VERSIONID %d differs from set " - "value %d\n", - i, auxCharArray[i], pGpsVersion[i]); - } - } - } - /*-- LATITUDEREF is a fixed String of one character plus ending zero. */ - retCode = TIFFGetField(tif, GPSTAG_LATITUDEREF, &pAscii); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "GPSTAG_LATITUDEREF"); - } - retCode2 = strncmp("N", pAscii, 1); - if (retCode2 != 0) - { - fprintf(stderr, - "Read value %d of GPSTAG_LATITUDEREF %s differs from set value " - "%s\n", - i, "N", pAscii); - } - - /*-- Fixed Array: Latitude is an array of 3 Rational-values. TIFFGetField() - * returns a pointer to a temporary float-/double-array. */ - /*-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values - * are defined as double precision and need to be written and also read in - * double precision! In order to maintain this code for both cases, it is - * checked above if the TiffLibrary is compiled with the new interface with - * Rational2Double or still uses the old definitions, by setting - * blnIsRational2Double above. - */ - if (blnIsRational2Double) - { - fprintf(stderr, "-- GPS tags are read using Rational2Double --\n"); - } - else - { - fprintf(stderr, "-- GPS tags are read using standard --\n"); - } - retCode = TIFFGetField(tif, GPSTAG_LATITUDE, &pVoidArray); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "GPSTAG_LATITUDE"); - } - if (!blnIsRational2Double) - { - /* Reset arrays for debugging purpose first */ - memset(auxFloatArray, 0, sizeof(auxFloatArray)); - memcpy(auxFloatArray, pVoidArray, 3 * sizeof(float)); - /* for comparison copy to doubleArray */ - for (i = 0; i < 3; i++) - auxDoubleArray[i] = (double)auxFloatArray[i]; - } - else - { - /* Rational2Double interface for GPSTAG reads double array */ - memset(auxDoubleArray, 0, sizeof(auxDoubleArray)); - memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double)); - } - for (i = 0; i < 3; i++) - { - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayGPS1[i]; - dblDiff = auxDoubleArray[i] - auxDoubleArrayGPS1[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of GPSTAG_LATITUDE %f differs from set " - "value %f\n", - i, auxDoubleArray[i], auxDoubleArrayGPS1[i]); - } - } - - /*-- LONGITUDEREF is a fixed String of one character plus ending zero. */ - retCode = TIFFGetField(tif, GPSTAG_LONGITUDEREF, &pAscii); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "GPSTAG_LONGITUDEREF"); - } - retCode2 = strncmp("W", pAscii, 1); - if (retCode2 != 0) - { - fprintf(stderr, - "Read value %d of GPSTAG_LONGITUDEREF %s differs from set " - "value %s\n", - i, "W", pAscii); - } - - retCode = TIFFGetField(tif, GPSTAG_LONGITUDE, &pVoidArray); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "GPSTAG_LONGITUDE"); - } - if (!blnIsRational2Double) - { - /* Reset arrays for debugging purpose first */ - memset(auxFloatArray, 0, sizeof(auxFloatArray)); - memcpy(auxFloatArray, pVoidArray, 3 * sizeof(float)); - /* for comparison copy to doubleArray */ - for (i = 0; i < 3; i++) - auxDoubleArray[i] = (double)auxFloatArray[i]; - } - else - { - /* Rational2Double interface for GPSTAG reads double array */ - memset(auxDoubleArray, 0, sizeof(auxDoubleArray)); - memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double)); - } - for (i = 0; i < 3; i++) - { - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayGPS2[i]; - dblDiff = auxDoubleArray[i] - auxDoubleArrayGPS2[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of GPSTAG_LONGITUDE %f differs from set " - "value %f\n", - i, auxDoubleArray[i], auxDoubleArrayGPS2[i]); - } - } - - /* TIFF_RATIONAL, TIFF_SETGET_DOUBLE */ - if (!TIFFGetField(tif, GPSTAG_ALTITUDE, &auxDblUnion.dbl)) - { - fprintf(stderr, "Can't read GPSTAG_ALTITUDE\n"); - GOTOFAILURE_GPS - } - if (blnIsRational2Double) - { - /* New interface allows also double precision for TIFF_RATIONAL */ - auxDouble = auxDblUnion.dbl; - } - else - { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE - * always as FLOAT */ - auxDouble = (double)auxDblUnion.flt1; - } - /* compare read values with written ones */ - dblDiffLimit = RATIONAL_EPS * auxDoubleGPSAltitude; - dblDiff = auxDouble - auxDoubleGPSAltitude; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value of GPSTAG_ALTITUDE %f differs from set value %f\n", - auxDouble, auxDoubleGPSAltitude); - GOTOFAILURE_GPS - } - - /*-- TimeStamp is only hh:mm:ss. See also DateTime string 3, TIFF_RATIONAL, - * TIFF_SETGET_C0_DOUBLE */ - retCode = TIFFGetField(tif, GPSTAG_TIMESTAMP, &pVoidArray); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "GPSTAG_TIMESTAMP"); - } - if (!blnIsRational2Double) - { - /* Reset arrays for debugging purpose first */ - memset(auxFloatArray, 0, sizeof(auxFloatArray)); - memcpy(auxFloatArray, pVoidArray, 3 * sizeof(float)); - /* for comparison copy to doubleArray */ - for (i = 0; i < 3; i++) - auxDoubleArray[i] = (double)auxFloatArray[i]; - } - else - { - /* Rational2Double interface for GPSTAG reads double array */ - memset(auxDoubleArray, 0, sizeof(auxDoubleArray)); - memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double)); - } - for (i = 0; i < 3; i++) - { - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayGPSTime[i]; - dblDiff = auxDoubleArray[i] - auxDoubleArrayGPSTime[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of GPSTAG_TIMESTAMP %f differs from set " - "value %f\n", - i, auxDoubleArray[i], auxDoubleArrayGPS2[i]); - GOTOFAILURE_GPS - } - } - - /* GPSTAG_IMGDIRECTION --- TIFF_RATIONAL, TIFF_SETGET_DOUBLE */ - if (!TIFFGetField(tif, GPSTAG_IMGDIRECTION, &auxDblUnion.dbl)) - { - fprintf(stderr, "Can't read GPSTAG_IMGDIRECTION\n"); - GOTOFAILURE_GPS - } - if (blnIsRational2Double) - { - /* New interface allows also double precision for TIFF_RATIONAL */ - auxDouble = auxDblUnion.dbl; - } - else - { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE - * always as FLOAT */ - auxDouble = (double)auxDblUnion.flt1; - } - /* compare read values with written ones */ - dblDiffLimit = RATIONAL_EPS * auxDoubleGPSDirection; - dblDiff = auxDouble - auxDoubleGPSDirection; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf( - stderr, - "Read value of GPSTAG_IMGDIRECTION %f differs from set value %f\n", - auxDouble, auxDoubleGPSDirection); - GOTOFAILURE_GPS - } - - /*-- GPSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, - * TIFF_SETGET_UINT16 - */ - retCode = TIFFGetField(tif, GPSTAG_DIFFERENTIAL, &auxShort); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "GPSTAG_DIFFERENTIAL"); - } - if (auxShort != auxShortArrayW[5]) - { - fprintf( - stderr, - "Read value of GPSTAG_DIFFERENTIAL %d differs from set value %d\n", - auxShort, auxShortArrayW[5]); - GOTOFAILURE_GPS - } - - /*-- GPSHPOSITIONINGERROR - new tag for EXIF 2.31 --*/ - if (!TIFFGetField(tif, GPSTAG_GPSHPOSITIONINGERROR, &auxDblUnion.dbl)) - { - fprintf(stderr, "Can't read GPSTAG_GPSHPOSITIONINGERROR\n"); - GOTOFAILURE_GPS - } - if (blnIsRational2Double) - { - /* New interface allows also double precision for TIFF_RATIONAL */ - auxDouble = auxDblUnion.dbl; - } - else - { - /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE - * always as FLOAT */ - auxDouble = (double)auxDblUnion.flt1; - } - /* compare read values with written ones */ - auxFloat = (float)GPSHPOSITIONINGERROR_VAL; - dblDiffLimit = RATIONAL_EPS * auxFloat; - dblDiff = auxDouble - auxFloat; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value of GPSTAG_GPSHPOSITIONINGERROR %f differs from set " - "value %f\n", - auxDouble, auxFloat); - GOTOFAILURE_GPS - } - - /*=============== END reading GPS tags ==========================*/ -#endif /*-- READ_GPS_TAGS --*/ - - /*================== Reading EXIF 2.31 tags =====================*/ - - /*--- Firstly, get EXIF directory offset from main directory. */ - - /*-- Go back to the first (main) directory, and get value of the EXIFIFD - * directory- offset. */ - /* (directory is reloaded from file!) */ - TIFFSetDirectory(tif, 0); - retCode = TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset); - -#ifdef READ_EXIF_TAGS - /*-- Now read EXIF directory from file into memory --*/ - retCode = TIFFReadEXIFDirectory(tif, read_dir_offset); - - /*-- Now get some parameters from EXIF-directory (already read into memory) - * --*/ - retCode = TIFFGetField(tif, EXIFTAG_EXIFVERSION, &pAscii); - -#ifdef READ_ALL_EXIF_TAGS - /*-- Get array, where EXIF tag fields are defined --*/ - tFieldArray = _TIFFGetExifFields(); - nTags = tFieldArray->count; - /*-- Check, if the TiffLibrary is compiled with the new interface with - * Rational2Double or still uses the old definitions. */ - /* tif points to EXIF tags, so TIFFFindField() can only access the EXIF tag - * fields */ - fip = TIFFFindField(tif, EXIFTAG_EXPOSURETIME, TIFF_ANY); - tSetFieldType = fip->set_field_type; - if (tSetFieldType == TIFF_SETGET_DOUBLE) - { - blnIsRational2Double = FALSE; - fprintf(stderr, "-- EXIF tags read with standard --\n"); - } - else - { - blnIsRational2Double = TRUE; - fprintf(stderr, - "-- Rational2Double for reading EXIF tags detected --\n"); - } - - for (i = 0; i < nTags; i++) - { - bool deferredSetField = false; - tTag = tFieldArray->fields[i].field_tag; - tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ - tWriteCount = tFieldArray->fields[i].field_writecount; - tSetFieldType = tFieldArray->fields[i] - .set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ - tFieldName = tFieldArray->fields[i].field_name; - - /*-- dependent on set_field_type read value --*/ - switch (tSetFieldType) - { - case TIFF_SETGET_ASCII: - /* Either the stringlength is defined as a fixed length in - * .field_writecount or a NULL-terminated string is used. */ - if (!TIFFGetField(tif, tTag, &pAscii)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* Save string from temporary buffer and compare with written - * string. */ - strncpy(auxCharArray, pAscii, sizeof(auxCharArray) - 1u); - auxCharArray[sizeof(auxCharArray) - 1u] = '\0'; - if (tWriteCount > 0) - auxLong = tWriteCount - 1; - else - auxLong = (long)strlen(auxCharArray); - retCode2 = strncmp(auxCharArray, auxTextArrayW[i], auxLong); - if (retCode2 != 0) - { - fprintf( - stderr, - "%d:Read value of %s %s differs from set value %s\n", i, - tFieldName, auxCharArray, auxTextArrayW[i]); - GOTOFAILURE_ALL_EXIF - } - break; - /*-- For reading, the parameter size is to be observed !! */ - case TIFF_SETGET_UINT8: - case TIFF_SETGET_SINT8: - if (!TIFFGetField(tif, tTag, &auxChar)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* compare read values with written ones */ - auxLong = auxChar; - if (auxLong != (char)auxLongArrayW[i]) - { - fprintf( - stderr, - "%d:Read value of %s %ld differs from set value %ld\n", - i, tFieldName, auxLong, auxLongArrayW[i]); - } - break; - case TIFF_SETGET_UINT16: - case TIFF_SETGET_SINT16: - if (!TIFFGetField(tif, tTag, &auxShort)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* compare read values with written ones */ - auxLong = auxShort; - if (auxLong != (short)auxLongArrayW[i]) - { - fprintf( - stderr, - "%d:Read value of %s %ld differs from set value %ld\n", - i, tFieldName, auxLong, auxLongArrayW[i]); - } - break; - case TIFF_SETGET_UINT32: - case TIFF_SETGET_SINT32: - case TIFF_SETGET_IFD8: - case TIFF_SETGET_INT: - if (!TIFFGetField(tif, tTag, &auxUint32)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* compare read values with written ones */ - auxLong = auxUint32; - if (auxLong != auxLongArrayW[i]) - { - fprintf( - stderr, - "%d:Read value of %s %ld differs from set value %ld\n", - i, tFieldName, auxLong, auxLongArrayW[i]); - } - break; - case TIFF_SETGET_FLOAT: - if (!TIFFGetField(tif, tTag, &auxFloat)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - dblDiff = auxFloat - auxDoubleArrayW[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of - * "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to - * indicate infinite distance! However, there are two other - * EXIF tags where numerator indicates a special value and - * six other cases where the denominator indicates special - * values, which are not treated within LibTiff!! - */ - if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxFloat == -1.0)) - { - fprintf(stderr, - "%d:Read value of %s %f differs from set value " - "%f\n", - i, tFieldName, auxFloat, auxDoubleArrayW[i]); - GOTOFAILURE_ALL_EXIF - } - } - break; - case TIFF_SETGET_DOUBLE: - /*-- Unfortunately, TIFF_SETGET_DOUBLE is used for TIFF_RATIONAL - * but those have to be read with FLOAT !!! */ - /* Only TIFFTAG_STONITS is a TIFF_DOUBLE, which has to be read - * as DOUBLE!! */ - /*-- ATTENTION: ---- - * Only after update with Rational2Double feature, also - TIFF_RATIONAL can be read in double precision!!! - * Therefore, use a union to avoid overflow in TIFFGetField() - return value - * and depending on version check for the right interface - here: - * - old interface: correct value should be here a float - * - new interface: correct value should be here a double - * Interface version (old/new) is determined above. - -------------------*/ - if (!TIFFGetField(tif, tTag, &auxDblUnion.dbl)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - { - if (blnIsRational2Double) - { - /* New interface allows also double precision for - * TIFF_RATIONAL */ - auxDouble = auxDblUnion.dbl; - } - else - { - /* Old interface reads TIFF_RATIONAL defined as - * TIFF_SETGET_DOUBLE always as FLOAT */ - auxDouble = (double)auxDblUnion.flt1; - } - } - else - { - auxDouble = auxDblUnion.dbl; - } - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - dblDiff = auxDouble - auxDoubleArrayW[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of - * "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to - * indicate infinite distance! */ - if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxDouble == -1.0)) - { - fprintf(stderr, - "%d:Read value of %s %f differs from set value " - "%f\n", - i, tFieldName, auxDouble, auxDoubleArrayW[i]); - GOTOFAILURE_ALL_EXIF - } - } - break; - - case TIFF_SETGET_C0_FLOAT: - case TIFF_SETGET_C0_DOUBLE: - case TIFF_SETGET_C16_FLOAT: - case TIFF_SETGET_C16_DOUBLE: - case TIFF_SETGET_C32_FLOAT: - case TIFF_SETGET_C32_DOUBLE: - /* _Cxx_ just defines the size of the count parameter for the - * array as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array or a - * variable array */ - if (tWriteCount == 1) - { - fprintf(stderr, - "Reading: WriteCount for .set_field_type %d should " - "be -1 or greater than 1! %s\n", - tSetFieldType, tFieldArray->fields[i].field_name); - } - else - { - /*-- Either fix or variable array --*/ - /* For arrays, distinguishing between float or double is - * essential. */ - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) - { - /* fixed array with needed arraysize defined in - * .field_writecount */ - if (!TIFFGetField(tif, tTag, &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* set tWriteCount to number of read samples for next - * steps */ - auxLong = tWriteCount; - } - else - { - /* Special treatment of variable array. */ - /* Dependent on Cxx, the count parameter is char, short - * or long. Therefore use unionLong! */ - if (!TIFFGetField(tif, tTag, &unionLong, &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* set tWriteCount to number of read samples for next - * steps */ - auxLong = unionLong.Short1; - } - /* Save values from temporary array */ - if (tSetFieldType == TIFF_SETGET_C0_FLOAT || - tSetFieldType == TIFF_SETGET_C16_FLOAT || - tSetFieldType == TIFF_SETGET_C32_FLOAT) - { - memcpy(&auxFloatArray, pVoidArray, - (auxLong * sizeof(auxFloatArray[0]))); - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - for (j = 0; j < auxLong; j++) - { - dblDiff = auxFloatArray[j] - auxFloatArrayW[i + j]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*if (auxFloatArray[j] != - * (float)auxFloatArrayW[i+j]) { */ - fprintf(stderr, - "Read value %d of %s #%d %f differs " - "from set value %f\n", - i, tFieldName, j, auxFloatArray[j], - auxFloatArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } - } - else - { - memcpy(&auxDoubleArray, pVoidArray, - (auxLong * sizeof(auxDoubleArray[0]))); - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - for (j = 0; j < auxLong; j++) - { - dblDiff = - auxDoubleArray[j] - auxDoubleArrayW[i + j]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*if (auxDoubleArray[j] != auxDoubleArrayW[i+j]) - * { */ - fprintf(stderr, - "Read value %d of %s #%d %f differs " - "from set value %f\n", - i, tFieldName, j, auxDoubleArray[j], - auxDoubleArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } - } - } - break; - case TIFF_SETGET_C0_UINT8: - case TIFF_SETGET_C0_SINT8: - case TIFF_SETGET_C16_UINT8: - case TIFF_SETGET_C16_SINT8: - case TIFF_SETGET_C32_UINT8: - case TIFF_SETGET_C32_SINT8: - /* For arrays, distinguishing between float or double is - * essential, even for writing */ - deferredSetField = true; - break; - case TIFF_SETGET_C0_UINT16: - case TIFF_SETGET_C0_SINT16: - case TIFF_SETGET_C16_UINT16: - case TIFF_SETGET_C16_SINT16: - case TIFF_SETGET_C32_UINT16: - case TIFF_SETGET_C32_SINT16: - deferredSetField = true; - break; - case TIFF_SETGET_C0_UINT32: - case TIFF_SETGET_C0_SINT32: - case TIFF_SETGET_C16_UINT32: - case TIFF_SETGET_C16_SINT32: - case TIFF_SETGET_C32_UINT32: - case TIFF_SETGET_C32_SINT32: - deferredSetField = true; - break; - default: - fprintf(stderr, - "SetFieldType %d not defined within writing switch for " - "%s.\n", - tSetFieldType, tFieldName); - GOTOFAILURE - }; /*-- switch() --*/ - - if (deferredSetField) - { - /* _Cxx_ just defines the size of the count parameter for the array - * as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array or a variable - * array */ - if (tWriteCount == 1) - { - fprintf(stderr, - "WriteCount for .set_field_type %d should be -1 or " - "greater than 1! %s\n", - tSetFieldType, tFieldArray->fields[i].field_name); - } - else - { - /*-- Either fix or variable array --*/ - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) - { - /* fixed array with needed arraysize defined in - * .field_writecount */ - if (!TIFFGetField(tif, tTag, &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* set tWriteCount to number of read samples for next steps - */ - auxLong = tWriteCount; - } - else - { - /* special treatment of variable array */ - /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ - if (!TIFFGetField(tif, tTag, &unionLong, &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE_ALL_EXIF - break; - } - /* set tWriteCount to number of read samples for next steps - */ - auxLong = unionLong.Short1; - } - /* Save values from temporary array */ - if (tSetFieldType == TIFF_SETGET_C0_UINT8 || - tSetFieldType == TIFF_SETGET_C0_SINT8 || - tSetFieldType == TIFF_SETGET_C16_UINT8 || - tSetFieldType == TIFF_SETGET_C16_SINT8 || - tSetFieldType == TIFF_SETGET_C32_UINT8 || - tSetFieldType == TIFF_SETGET_C32_SINT8) - { - memcpy(&auxCharArray, pVoidArray, - (auxLong * sizeof(auxCharArray[0]))); - /* Compare and check values */ - for (j = 0; j < auxLong; j++) - { - if (tTag == EXIFTAG_EXIFVERSION) - { - /*-- Use exifVersion[] instead of auxCharArrayW[] - * for differently set EXIFVERSION tag */ - if (auxCharArray[j] != exifVersion[j]) - { - fprintf(stderr, - "Read value %d of %s #%d %d differs " - "from set value %d\n", - i, tFieldName, j, auxCharArray[j], - auxCharArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } - else - { - if (auxCharArray[j] != auxCharArrayW[i + j]) - { - fprintf(stderr, - "Read value %d of %s #%d %d differs " - "from set value %d\n", - i, tFieldName, j, auxCharArray[j], - auxCharArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } - } - } - else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || - tSetFieldType == TIFF_SETGET_C0_SINT16 || - tSetFieldType == TIFF_SETGET_C16_UINT16 || - tSetFieldType == TIFF_SETGET_C16_SINT16 || - tSetFieldType == TIFF_SETGET_C32_UINT16 || - tSetFieldType == TIFF_SETGET_C32_SINT16) - { - memcpy(&auxShortArray, pVoidArray, - (auxLong * sizeof(auxShortArray[0]))); - /* Compare and check values */ - for (j = 0; j < auxLong; j++) - { - if (auxShortArray[j] != auxShortArrayW[i + j]) - { - fprintf(stderr, - "Read value %d of %s #%d %d differs from " - "set value %d\n", - i, tFieldName, j, auxShortArray[j], - auxShortArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } - } - else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || - tSetFieldType == TIFF_SETGET_C0_SINT32 || - tSetFieldType == TIFF_SETGET_C16_UINT32 || - tSetFieldType == TIFF_SETGET_C16_SINT32 || - tSetFieldType == TIFF_SETGET_C32_UINT32 || - tSetFieldType == TIFF_SETGET_C32_SINT32) - { - memcpy(&auxLongArray, pVoidArray, - (auxLong * sizeof(auxLongArray[0]))); - /* Compare and check values */ - for (j = 0; j < auxLong; j++) - { - if (auxLongArray[j] != auxLongArrayW[i + j]) - { - fprintf(stderr, - "Read value %d of %s #%d %ld differs from " - "set value %ld\n", - i, tFieldName, j, auxLongArray[j], - auxLongArrayW[i + j]); - GOTOFAILURE_ALL_EXIF - } - } - } - else - { - fprintf(stderr, - "SetFieldType %d not defined within switch case " - "reading for UINT for %s.\n", - tSetFieldType, tFieldName); - GOTOFAILURE - } - } - } - } /*-- for() --*/ - /*================= EXIF: END Reading arbitrary data to the EXIF fields END - * END END ==============*/ -#endif /*-- READ_ALL_EXIF_TAGS --*/ -#endif /*-- READ_EXIF_TAGS --*/ - - TIFFClose(tif); - - /* All tests passed; delete file and exit with success status. */ -#ifdef FOR_AUTO_TESTING - unlink(filenameRead); -#endif - fprintf(stderr, "-------- Test finished OK ----------\n"); - return 0; - -failure: - /* - * Something goes wrong; close file and return unsuccessful status. - * Do not remove the file for further manual investigation. - */ - TIFFClose(tif); - fprintf(stderr, "-------- Test finished with FAILURE --------\n"); - return 1; -} + +/* + * Copyright (c) 2012, Frank Warmerdam + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library + * + * -- Module copied from custom_dir.c -- + *=========== Purpose =================================================================================== + * Extended and amended version for testing of EXIF 2.32, GPS and handling of custom fields. + * EXIF 2.32 and GPS are defined in amended files tif_dirinfo.c, tif_dirread.c, tiff.h, tiffio.h, tif_dir.h, tif_dir.c + * + *-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are defined as double precision + * and need to be written and also read in double precision! + * In order to maintain this code for both cases, it is checked above if the TiffLibrary is + * compiled with the new interface with Rational2Double or still uses the old definitions, + * by setting blnIsRational2Double above. + * + */ + + +/*------------ + * This version writes the GPS and EXIF tags correctly, without additonal main-IFD and parameters! + * In contrary, custom_dir.c does write additional main-IFD and parameters to file. + -------------*/ + + +#define FOR_AUTO_TESTING +#ifdef FOR_AUTO_TESTING +/* Only for automake and CMake infrastructure the test should: + a.) delete any written testfiles when test passed (otherwise autotest will fail) + b.) goto failure, if any failure is detected, which is not necessary when test is initiated manually for debugging +*/ +#define GOTOFAILURE goto failure; +#define GOTOFAILURE_GPS goto failure; +#define GOTOFAILURE_ALL_EXIF goto failure; +#else +#define GOTOFAILURE +#define GOTOFAILURE_GPS +#define GOTOFAILURE_ALL_EXIF +#endif + + +#ifdef _MSC_VER +#pragma warning( disable : 4101) +#endif + +#include "tif_config.h" +#include +#include +#include +#include + +#ifdef HAVE_UNISTD_H +# include +#endif + +#include "tiffio.h" +#include "tiffiop.h" +#include "tif_dir.h" +#include "tifftest.h" + + + +int write_test_tiff(TIFF *tif, const char *filenameRead); + +static const char filename[] = "custom_dir_EXIF_231.tif"; +static const char filenameBigTiff[] = "custom_dir_EXIF_231_Big.tif"; + +#define SPP 3 /* Samples per pixel */ +const uint16 width = 1; +const uint16 length = 1; +const uint16 bps = 8; +const uint16 photometric = PHOTOMETRIC_RGB; +const uint16 rows_per_strip = 1; +const uint16 planarconfig = PLANARCONFIG_CONTIG; + + +int +main() +{ + TIFF *tif; + int ret, ret1, ret2; + + fprintf(stderr, "==== Test automatically if all EXIF and GPS tags are written/read correctly. ====\n"); + /* --- Test with Classic-TIFF ---*/ + /* delete file, if exists */ + ret = unlink(filename); + if (ret != 0 && errno != ENOENT) { + fprintf(stderr, "Can't delete test TIFF file %s.\n", filename); + } + + /* We write the main directory as a simple image. */ + tif = TIFFOpen(filename, "w+"); + if (!tif) { + fprintf(stderr, "Can't create test TIFF file %s.\n", filename); + return 1; + } + fprintf(stderr, "-------- Test with ClassicTIFF started ----------\n"); + ret1 = write_test_tiff(tif, filename); + + if (ret1 > 0) return(ret1); + + /*--- Test with BIG-TIFF ---*/ + /* delete file, if exists */ + ret = unlink(filenameBigTiff); + if (ret != 0 && errno != ENOENT) { + fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameBigTiff); + } + + tif = TIFFOpen(filenameBigTiff, "w8"); + if (!tif) { + fprintf(stderr, "Can't create test TIFF file %s.\n", filenameBigTiff); + return 1; + } + fprintf(stderr, "\n\n-------- Test with BigTIFF started ----------\n"); + ret2 = write_test_tiff(tif, filenameBigTiff); + + if (ret2 > 0) return(ret2 + 10); else return(ret2); + +} /* main() */ + + + + + + + +int +write_test_tiff(TIFF *tif, const char *filenameRead) +{ + unsigned char buf[SPP] = { 0, 127, 255 }; + uint64 dir_offset = 0; + uint64 dir_offset_GPS = 0, dir_offset_EXIF = 0; + uint64 read_dir_offset = 0; + /*-- Additional variables --*/ + int retCode, retCode2; + unsigned char exifVersion[4] = {'0','2','3','1'}; /* EXIF 2.31 version is 4 characters of a string! */ + unsigned char gpsVersion[4] = {2,2,0,1}; /* GPS Version is 4 numbers! */ + unsigned char *pGpsVersion; + float auxFloat = 0.0f; + double auxDouble = 0.0; + char auxChar = 0; + uint32 auxUint32 = 0; + short auxShort=0; + long auxLong = 0; + void *pVoid; + int blnIsRational2Double; + + int i, j; + long nTags; + + const TIFFFieldArray* tFieldArray; + unsigned long tTag; + TIFFDataType tType; + short tWriteCount; + TIFFSetGetFieldType tSetFieldType; + char *tFieldName; + const TIFFField *fip; + + char blnFillGPSManually = 1; + +#define STRSIZE 1000 +#define N_SIZE 120 +#define VARIABLE_ARRAY_SIZE 6 + + /* -- Test data for writing -- */ + char auxCharArrayW[N_SIZE]; + short auxShortArrayW[N_SIZE]; + long auxLongArrayW[N_SIZE]; + float auxFloatArrayW[N_SIZE]; + double auxDoubleArrayW[N_SIZE]; + char auxTextArrayW[N_SIZE][STRSIZE]; + double auxDoubleArrayGPS1[3] = {1.0/7.0, 61.23456789012345, 62.0}; + double auxDoubleArrayGPS2[3] = {1.0/19.0, 88.34434, 15.12345678901234567890}; + double auxDoubleArrayGPSTime[3] = {22.0, 17.0, 15.3456789}; + double auxDoubleGPSAltitude = 3456.0; + double auxDoubleGPSDirection = 63.7; + float auxFloatArrayN1[3] = { 1.0f / 7.0f, 61.23456789012345f, 62.3f }; + float auxFloatArrayN2[3] = { -1.0f / 7.0f, -61.23456789012345f, -62.3f }; + + /* -- Variables for reading -- */ + uint16 count16 = 0; + union { + long Long; + short Short1; + short Short2[2]; + char Char[4]; + } unionLong; + union { + double dbl; + float flt1; + float flt2; + } auxDblUnion; + void *pVoidArray; + char *pAscii; + char auxCharArray[2*STRSIZE]; + short auxShortArray[2*N_SIZE]; + long auxLongArray[2*N_SIZE]; + float auxFloatArray[2*N_SIZE]; + double auxDoubleArray[2*N_SIZE]; + double dblDiff, dblDiffLimit; +#define RATIONAL_EPS (1.0/30000.0) /* reduced difference of rational values, approx 3.3e-5 */ + + /*-- Fill test data arrays for writing ----------- */ + for (i=0; iset_field_type; + if (tSetFieldType == TIFF_SETGET_DOUBLE) { + blnIsRational2Double = FALSE; + } else { + blnIsRational2Double = TRUE; + fprintf(stderr, "-- Rational2Double from TIFF tag detected --\n"); + } + +/*================== Write GPS and EXIF tags =====================*/ + + /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve space for final dir_offset value, */ + /* which is properly written at the end. */ + dir_offset = 0; /* Zero, in case no Custom-IFD is written */ + +#define WRITE_GPS_TAGS +#ifdef WRITE_GPS_TAGS + if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset )) { + fprintf (stderr, "Can't write TIFFTAG_GPSIFD\n" ); + } +#endif + + /*------- And also do the same for the EXIF IFD tag here, because we have to save the main directory next ------*/ + /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve space for final dir_offset value, + * which is properly written at the end. + */ +#define WRITE_EXIF_TAGS +#ifdef WRITE_EXIF_TAGS + if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset )) { + fprintf (stderr, "Can't write TIFFTAG_EXIFIFD\n" ); + } +#endif + +#ifndef WRITEPIXELLAST + /*-- Write dummy pixel data. --*/ + if (TIFFWriteScanline(tif, buf, 0, 0) < 0) { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } +#endif + + +#ifdef WRITE_GPS_TAGS +#define READ_GPS_TAGS + /*================== Write GPS tags =====================*/ + + /*-- Save current tiff-directory to file before directory is changed. Otherwise it will be lost! */ + /* The tif-structure is overwritten/ freshly initialized by any "CreateDirectory" */ + /*retCode = TIFFCheckpointDirectory(tif);*/ /* does not cleanup Tiff-Structure */ + retCode = TIFFWriteDirectory(tif); /* cleanup Tiff-structure */ + + /*-- Now create a GPS directory. */ + if (TIFFCreateGPSDirectory(tif) != 0) { + fprintf (stderr, "TIFFCreateGPSDirectory() failed.\n" ); + goto failure; + } + + if (!TIFFSetField( tif, GPSTAG_VERSIONID, gpsVersion)) { + fprintf (stderr, "Can't write GPSTAG_VERSIONID\n" ); + goto failure; + } + + if (blnFillGPSManually) { + /*================= Write manually valid data to the GPS fields ==============*/ + if (!TIFFSetField( tif, GPSTAG_LATITUDEREF, "N\0")) { + fprintf (stderr, "Can't write GPSTAG_LATITUDEREF\n" ); + goto failure; + } + /*-- Unfortunately, Rational values are defined as SETGET_DOUBLE but are internally always stored as float. + * Single Rational values do not matter for writing, because TIFFSetField() uses va_arg() which performs "variables promotion" from type float to type double! + * However, for reading of Rational values ONLY float-variables are allowed - in contrary to the SETGET_DOUBLE specification at tiffFields[] in tif_dirinfo.c. + */ + /*-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are defined as double precision + * and need to be written and also read in double precision! + * In order to maintain this code for both cases, it is checked above if the TiffLibrary is + * compiled with the new interface with Rational2Double or still uses the old definitions, + * by setting blnIsRational2Double above. + */ + if (blnIsRational2Double) { + fprintf(stderr, "-- GPS tags are written using Rational2Double --\n"); + } else { + fprintf(stderr, "-- GPS tags are written using standard --\n"); + } + if (!blnIsRational2Double) { + for (j = 0; j < 3; j++) auxFloatArray[j] = (float)auxDoubleArrayGPS1[j]; + if (!TIFFSetField(tif, GPSTAG_LATITUDE, auxFloatArray)) { + fprintf(stderr, "Can't write GPSTAG_LATITUDE\n"); + goto failure; + } + } else { + /* Rational2Double interface for GPSTAG */ + if (!TIFFSetField(tif, GPSTAG_LATITUDE, auxDoubleArrayGPS1)) { + fprintf(stderr, "Can't write GPSTAG_LATITUDE\n"); + goto failure; + } + } + if (!TIFFSetField( tif, GPSTAG_LONGITUDEREF, "W\0")) { + fprintf (stderr, "Can't write GPSTAG_LONGITUDEREF\n" ); + goto failure; + } + if (!blnIsRational2Double) { + for (j=0; j<3; j++) auxFloatArray[j] = (float)auxDoubleArrayGPS2[j]; + if (!TIFFSetField( tif, GPSTAG_LONGITUDE, auxFloatArray)) { + fprintf (stderr, "Can't write GPSTAG_LONGITUDE\n" ); + goto failure; + } + } else { + /* Rational2Double interface for GPSTAG */ + if (!TIFFSetField(tif, GPSTAG_LONGITUDE, auxDoubleArrayGPS2)) { + fprintf(stderr, "Can't write GPSTAG_LATITUDE\n"); + goto failure; + } + } + /*-- AltitudeRef: default is above sea level!! */ + if (!TIFFSetField( tif, GPSTAG_ALTITUDEREF, 0)) { + fprintf (stderr, "Can't write GPSTAG_ALTITUDEREF\n" ); + goto failure; + } + if (!TIFFSetField( tif, GPSTAG_ALTITUDE, auxDoubleGPSAltitude)) { + fprintf (stderr, "Can't write GPSTAG_ALTITUDE\n" ); + goto failure; + } + /*-- TimeStamp is only hh:mm:ss. See also DateTime string */ + if (!TIFFSetField( tif, GPSTAG_TIMESTAMP, auxDoubleArrayGPSTime)) { + fprintf (stderr, "Can't write GPSTAG_TIMESTAMP\n" ); + goto failure; + } + if (!TIFFSetField( tif, GPSTAG_DATESTAMP, "2012:11:04")) { + fprintf (stderr, "Can't write GPSTAG_DATESTAMP\n" ); + goto failure; + } + + if (!TIFFSetField( tif, GPSTAG_IMGDIRECTIONREF, "T\0")) { + fprintf (stderr, "Can't write GPSTAG_IMGDIRECTIONREF\n" ); + goto failure; + } + if (!TIFFSetField( tif, GPSTAG_IMGDIRECTION, auxDoubleGPSDirection)) { + fprintf (stderr, "Can't write GPSTAG_IMGDIRECTION\n" ); + goto failure; + } + + /*-- Type TIFF_UNDEFINED */ + if (!TIFFSetField( tif, GPSTAG_PROCESSINGMETHOD, 3, &auxCharArrayW[10])) { + fprintf (stderr, "Can't write GPSTAG_PROCESSINGMETHOD\n" ); + goto failure; + } + if (!TIFFSetField( tif, GPSTAG_AREAINFORMATION, 4, &auxCharArrayW[20])) { + fprintf (stderr, "Can't write GPSTAG_AREAINFORMATION\n" ); + goto failure; + } + + /*-- PSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, TIFF_SETGET_UINT16 */ + if (!TIFFSetField( tif, GPSTAG_DIFFERENTIAL, auxShortArrayW[5])) { + fprintf (stderr, "Can't write GPSTAG_DIFFERENTIAL\n" ); + goto failure; + } + + /* GPSTAG_GPSHPOSITIONINGERROR , 1, 1, TIFF_RATIONAL , 0, TIFF_SETGET_DOUBLE but here written in float-precision */ +#define GPSHPOSITIONINGERROR_VAL 0.369 + auxFloat = (float)GPSHPOSITIONINGERROR_VAL; + if (!TIFFSetField( tif, GPSTAG_GPSHPOSITIONINGERROR, auxFloat)) { + fprintf (stderr, "Can't write GPSTAG_GPSHPOSITIONINGERROR\n" ); + goto failure; + } + + } else { + /*================= Write arbitrary data to the GPS fields ==============*/ + + /*-- Get array, where GPS tag fields are defined --*/ + tFieldArray = _TIFFGetGpsFields(); + nTags = tFieldArray->count; + + /*-- TODO: fill in the for / switch part of EXIF writing, when finished and tested!! */ + + } /*-- if (blnFillGPSManually) --*/ + + + + + /*-- GPS - write custom directory GPS into file...---*/ + /* (Get back the offset of GPS directory) */ + if (!TIFFWriteCustomDirectory( tif, &dir_offset_GPS )) { + fprintf (stderr, "TIFFWriteCustomDirectory() with GPS failed.\n"); + goto failure; + } + + /*--- CheckpointDirectory at this place generates a second Main-IFD!!! */ + /* retCode = TIFFCheckpointDirectory(tif); */ + + /*-- Set / reload previously saved main directory from file ---*/ + if (!TIFFSetDirectory(tif, 0)) { + fprintf (stderr, "TIFFSetDirectory() within GPS failed.\n"); + goto failure; + } + + /*-- Write GPS tag reference / offset into GPSIFD tag in main directory --*/ + if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset_GPS )) { + fprintf (stderr, "Can't write TIFFTAG_GPSIFD\n"); + goto failure; + } + + /*=============== END writing GPS tags ==========================*/ +#endif /*-- WRITE_GPS_TAGS --*/ + + +/*================== Write EXIF 2.31 tags =====================*/ + + /*-- Set dummy EXIF/GPS tag in original tiff-structure in order to reserve space for final dir_offset value, */ + /* which is properly written at the end.*/ + /*- We did this already above together with the GPS IFD-tag. Otherwise we would do this here !! --------*/ + /* if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset )) { + fprintf (stderr, "Can't write TIFFTAG_EXIFIFD\n" ); + } + */ + +#ifdef WRITE_EXIF_TAGS +#define READ_EXIF_TAGS + /*-- Save current tiff-directory to file before directory is changed. Otherwise it will be lost! + * The tif-structure is overwritten/ freshly initialized by any "CreateDirectory" + */ + + /*----- What is needed here ??? ---- + * In custom_dir.c only TIFFFreeDirectory( tif ); is used to set fields of another Sub-Directory + * TIFFFreeDirectory(tif); *-- Release storage associated with a directory, especially custom-fields. + *-- Using only TIFFFreeDirectory() here leads to an error!! + *-- Using here TIFFCheckpointDirectory() leads to an additional Main-IFD ?? + */ + /*retCode = TIFFCheckpointDirectory(tif);*/ /* does not cleanup Tiff-Structure */ + retCode = TIFFWriteDirectory(tif); /* cleanup Tiff-structure */ + + /*-- Now create an EXIF directory. */ + if (TIFFCreateEXIFDirectory(tif) != 0) { + fprintf (stderr, "TIFFCreateEXIFDirectory() failed.\n" ); + goto failure; + } + +#define WRITE_ALL_EXIF_TAGS +#ifdef WRITE_ALL_EXIF_TAGS +#define READ_ALL_EXIF_TAGS + /*================= EXIF: Write arbitrary data to the EXIF fields ==============*/ + /*-- Get array, where EXIF tag fields are defined + * EXIF tags are written automatically with the defined precision according to its tSetFieldType using the code below --*/ + tFieldArray = _TIFFGetExifFields(); + nTags = tFieldArray->count; + + for (i=0; ifields[i].field_tag; + tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ + tWriteCount = tFieldArray->fields[i].field_writecount; + tSetFieldType = tFieldArray->fields[i].set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ + tFieldName = tFieldArray->fields[i].field_name; + pVoid = NULL; + + /*-- dependent on set_field_type write value --*/ + switch (tSetFieldType) + { + case TIFF_SETGET_ASCII: + /* Either the stringlength is defined as a fixed length in .field_writecount or a NULL-terminated string is used. */ + /* Shorter strings than in auxTextArraxW need a NULL-termination. Therefore copy the string. */ + if (tWriteCount > 0) auxLong = tWriteCount-1; else auxLong = (long)strlen(auxTextArrayW[i])-1; + strncpy(auxCharArray, auxTextArrayW[i], auxLong); + auxCharArray[auxLong] = 0; + if (!TIFFSetField( tif, tTag, auxCharArray)) { + fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + break; + case TIFF_SETGET_UINT8: + case TIFF_SETGET_UINT16: + case TIFF_SETGET_UINT32: + case TIFF_SETGET_IFD8: + case TIFF_SETGET_INT: + /*-- All those can be written with char, short or long parameter. Only value range should be in line. */ + if (!TIFFSetField( tif, tTag, auxLongArrayW[i])) { + fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + break; + case TIFF_SETGET_SINT8: + case TIFF_SETGET_SINT16: + case TIFF_SETGET_SINT32: + /*-- All those can be written with char, short or long parameter. Only value range should be in line. */ + if (!TIFFSetField( tif, tTag, -1.0*auxLongArrayW[i])) { + fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + break; + case TIFF_SETGET_FLOAT: + case TIFF_SETGET_DOUBLE: + if (tWriteCount == 1) { + /*-- All single values can be written with float or double parameter. Only value range should be in line. */ + if (!TIFFSetField( tif, tTag, auxDoubleArrayW[i])) { + fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + } else { + fprintf (stderr, "WriteCount for .set_field_type %d should be 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + } + break; + case TIFF_SETGET_C0_FLOAT: + case TIFF_SETGET_C0_DOUBLE: + case TIFF_SETGET_C16_FLOAT: + case TIFF_SETGET_C16_DOUBLE: + case TIFF_SETGET_C32_FLOAT: + case TIFF_SETGET_C32_DOUBLE: + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + } else { + /*-- Either fix or variable array --*/ + /* For arrays, distinguishing between float or double is essential, even for writing */ + if (tSetFieldType == TIFF_SETGET_C0_FLOAT || tSetFieldType == TIFF_SETGET_C16_FLOAT || tSetFieldType == TIFF_SETGET_C32_FLOAT) + pVoid = &auxFloatArrayW[i]; else pVoid = &auxDoubleArrayW[i]; + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFSetField( tif, tTag, pVoid)) { + fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + } else { + /* special treatment of variable array */ + /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ + if (!TIFFSetField( tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) { + fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + } + } + break; + case TIFF_SETGET_C0_UINT8: + case TIFF_SETGET_C0_SINT8: + case TIFF_SETGET_C16_UINT8: + case TIFF_SETGET_C16_SINT8: + case TIFF_SETGET_C32_UINT8: + case TIFF_SETGET_C32_SINT8: + /* For arrays, distinguishing between float or double is essential, even for writing */ + pVoid = &auxCharArrayW[i]; + case TIFF_SETGET_C0_UINT16: + case TIFF_SETGET_C0_SINT16: + case TIFF_SETGET_C16_UINT16: + case TIFF_SETGET_C16_SINT16: + case TIFF_SETGET_C32_UINT16: + case TIFF_SETGET_C32_SINT16: + if (pVoid == NULL) pVoid = &auxShortArrayW[i]; + case TIFF_SETGET_C0_UINT32: + case TIFF_SETGET_C0_SINT32: + case TIFF_SETGET_C16_UINT32: + case TIFF_SETGET_C16_SINT32: + case TIFF_SETGET_C32_UINT32: + case TIFF_SETGET_C32_SINT32: + if (pVoid == NULL) pVoid = &auxLongArrayW[i]; + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + } else { + /*-- Either fix or variable array --*/ + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFSetField( tif, tTag, pVoid)) { + fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + } else { + /* special treatment of variable array */ + /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ + if (!TIFFSetField( tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) { + fprintf (stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + } + } + break; + default: + fprintf (stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); + }; /*-- switch() --*/ + } /*-- for() --*/ + /*================= EXIF: END Writing arbitrary data to the EXIF fields END END END ==============*/ +#endif /*-- WRITE_ALL_EXIF_TAGS --*/ + + /*--- Set valid EXIF version, which is a 4 byte string --*/ + if (!TIFFSetField( tif, EXIFTAG_EXIFVERSION, exifVersion)) { + fprintf (stderr, "Can't write EXIFTAG_EXIFVERSION\n" ); + goto failure; + } + + + /*-- EXIF - write custom directory EXIF into file...---*/ + /* (Get back the offset of EXIF directory) */ + if (!TIFFWriteCustomDirectory( tif, &dir_offset_EXIF )) { + fprintf (stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n"); + goto failure; + } + + /*-- Go back to the first (main) directory, and set correct value of the EXIFIFD pointer. */ + /* (directory is reloaded from file!) */ + TIFFSetDirectory(tif, 0); + TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset_EXIF ); +#endif /*-- WRITE_EXIF_TAGS --*/ + +#ifdef WRITEPIXELLAST + /*-- Write dummy pixel data. --*/ + if (TIFFWriteScanline(tif, buf, 0, 0) < 0) { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } +#endif + /*-- Write directory to file --*/ + /* Always WriteDirectory before using/creating another directory. */ + /* Not necessary before TIFFClose(), however, TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be written at another location. */ + retCode = TIFFWriteDirectory(tif); + + /*-- Write File to disk and close file --*/ + /* TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be written at another location. */ + /* Therefore, better use TIFFWriteDirectory() before. */ + TIFFClose(tif); + + fprintf (stderr, "-------- Continue Test ---------- reading ...\n"); + +/*========================= READING ============= READING ========================================*/ + /* Ok, now test whether we can read written values correctly. */ + tif = TIFFOpen(filenameRead, "r"); + + + /*-- Read some parameters out of the main directory --*/ + + /*-- IMAGEWIDTH and -LENGTH are defined as TIFF_SETGET_UINT32 */ + retCode = TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &auxUint32 ); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGEWIDTH"); } + if (auxUint32 != width) { + fprintf (stderr, "Read value of IMAGEWIDTH %d differs from set value %d\n", auxUint32, width); + } + retCode = TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &auxUint32 ); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_IMAGELENGTH"); } + if (auxUint32 != width) { + fprintf (stderr, "Read value of TIFFTAG_IMAGELENGTH %d differs from set value %d\n", auxUint32, length); + } + +#ifdef ADDITIONAL_TAGS + /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter of type FIELD_CUSTOM !! */ + retCode = TIFFGetField(tif, TIFFTAG_PIXAR_FOVCOT, &auxFloat ); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_PIXAR_FOVCOT"); } + if (auxFloat != (float)PIXAR_FOVCOT_VAL) { + fprintf (stderr, "Read value of TIFFTAG_PIXAR_FOVCOT %f differs from set value %f\n", auxFloat, PIXAR_FOVCOT_VAL); + } + + /* - TIFFTAG_BESTQUALITYSCALE is a Rational parameter, FIELD_CUSTOM and TIFF_SETGET_FLOAT */ + retCode = TIFFGetField(tif, TIFFTAG_BESTQUALITYSCALE, &auxFloat ); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_BESTQUALITYSCALE"); } + if (auxFloat != (float)BESTQUALITYSCALE_VAL) { + fprintf (stderr, "Read value of TIFFTAG_BESTQUALITYSCALE %f differs from set value %f\n", auxFloat, BESTQUALITYSCALE_VAL); + } + + /* - TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_FLOAT */ + retCode = TIFFGetField(tif, TIFFTAG_BASELINENOISE, &auxDblUnion.dbl); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_BASELINENOISE"); } + if (auxDblUnion.flt1 != (float)BESTQUALITYSCALE_VAL) { + fprintf(stderr, "Read float value of TIFFTAG_BASELINENOISE %f differs from set value %f\n", auxDblUnion.flt1, BESTQUALITYSCALE_VAL); + } + + + /*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable length of array. */ + retCode = TIFFGetField(tif, TIFFTAG_DECODE, &count16, &pVoidArray ); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_DECODE"); } + /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */ + memcpy(&auxFloatArray, pVoidArray,(count16 * sizeof(auxFloatArray[0]))); + for (i=0; i fabs(dblDiffLimit)) { + fprintf (stderr, "Read value %d of TIFFTAG_DECODE Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayN2[i]); + } + } + + retCode = TIFFGetField(tif, TIFFTAG_BLACKLEVEL, &count16, &pVoidArray); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_BLACKLEVEL"); } + /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */ + memcpy(&auxFloatArray, pVoidArray, (count16 * sizeof(auxFloatArray[0]))); + for (i = 0; i fabs(dblDiffLimit)) { + fprintf(stderr, "Read value %d of TIFFTAG_BLACKLEVEL Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayN1[i]); + } + } + + /*- Fixed Array: TIFFTAG_DEFAULTCROPSIZE, 2, 2, TIFF_RATIONAL, 0, TIFF_SETGET_C0_FLOAT */ + retCode = TIFFGetField(tif, TIFFTAG_DEFAULTCROPSIZE, &pVoidArray); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_DEFAULTCROPSIZE"); } + /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */ + memcpy(&auxFloatArray, pVoidArray, (2 * sizeof(auxFloatArray[0]))); + for (i = 0; i < 2; i++) { + dblDiffLimit = RATIONAL_EPS * auxFloatArrayW[i]; + dblDiff = auxFloatArray[i] - auxFloatArrayW[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value %d of TIFFTAG_DEFAULTCROPSIZE Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayW[i]); + } + } + +#endif /*-- ADDITIONAL_TAGS --*/ + + +#ifdef READ_GPS_TAGS +/*================== Reading GPS tags =====================*/ + /*-- First get offset to GPS-directory and set it active (this will destroy previously main directory fields in memory!) */ + retCode = TIFFGetField(tif, TIFFTAG_GPSIFD, &read_dir_offset ); + if (!retCode) {fprintf(stderr, "Can't read %s\n", "TIFFTAG_GPSIFD"); } + retCode = TIFFReadGPSDirectory(tif, read_dir_offset); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFReadGPSDirectory()"); } + + /*-- Now read some parameters from GPS-directory --*/ + + /*-- Fixed Array: GPS-Version is a fixed array (of 4 characters) */ + retCode = TIFFGetField(tif, GPSTAG_VERSIONID, &pGpsVersion); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_VERSIONID"); } + else { + memcpy(auxCharArray, pGpsVersion, sizeof(gpsVersion)); + for (i = 0; i < 4; i++) { + if (auxCharArray[i] != pGpsVersion[i]) { + fprintf(stderr, "Read value %d of GPSTAG_VERSIONID %d differs from set value %d\n", i, auxCharArray[i], pGpsVersion[i]); + } + } + } + /*-- LATITUDEREF is a fixed String of one character plus ending zero. */ + retCode = TIFFGetField(tif, GPSTAG_LATITUDEREF, &pAscii); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LATITUDEREF"); } + retCode2 = strncmp("N", pAscii, 1); + if (retCode2 != 0) { + fprintf (stderr, "Read value %d of GPSTAG_LATITUDEREF %s differs from set value %s\n", i, "N", pAscii); + } + + /*-- Fixed Array: Latitude is an array of 3 Rational-values. TIFFGetField() returns a pointer to a temporary float-/double-array. */ + /*-- ATTENTION: After the upgrade with Rational2Double, the GPSTAG values are defined as double precision + * and need to be written and also read in double precision! + * In order to maintain this code for both cases, it is checked above if the TiffLibrary is + * compiled with the new interface with Rational2Double or still uses the old definitions, + * by setting blnIsRational2Double above. + */ + if (blnIsRational2Double) { + fprintf(stderr, "-- GPS tags are read using Rational2Double --\n"); + } else { + fprintf(stderr, "-- GPS tags are read using standard --\n"); + } + retCode = TIFFGetField(tif, GPSTAG_LATITUDE, &pVoidArray); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LATITUDE"); } + if (!blnIsRational2Double) { + /* Reset arrays for debugging purpose first */ + memset(auxFloatArray, 0, sizeof(auxFloatArray)); + memcpy(auxFloatArray, pVoidArray, 3*sizeof(float)); + /* for comparison copy to doubleArray */ + for (i=0; i<3; i++) auxDoubleArray[i] = (double)auxFloatArray[i]; + } else { + /* Rational2Double interface for GPSTAG reads double array */ + memset(auxDoubleArray, 0, sizeof(auxDoubleArray)); + memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double)); + } + for (i=0; i<3; i++) { + dblDiffLimit = RATIONAL_EPS*auxDoubleArrayGPS1[i]; + dblDiff = auxDoubleArray[i] - auxDoubleArrayGPS1[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf (stderr, "Read value %d of GPSTAG_LATITUDE %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayGPS1[i]); + } + } + + /*-- LONGITUDEREF is a fixed String of one character plus ending zero. */ + retCode = TIFFGetField(tif, GPSTAG_LONGITUDEREF, &pAscii); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LONGITUDEREF"); } + retCode2 = strncmp("W", pAscii, 1); + if (retCode2 != 0) { + fprintf(stderr, "Read value %d of GPSTAG_LONGITUDEREF %s differs from set value %s\n", i, "W", pAscii); + } + + retCode = TIFFGetField(tif, GPSTAG_LONGITUDE, &pVoidArray); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_LONGITUDE"); } + if (!blnIsRational2Double) { + /* Reset arrays for debugging purpose first */ + memset(auxFloatArray, 0, sizeof(auxFloatArray)); + memcpy(auxFloatArray, pVoidArray, 3 * sizeof(float)); + /* for comparison copy to doubleArray */ + for (i = 0; i < 3; i++) auxDoubleArray[i] = (double)auxFloatArray[i]; + } else { + /* Rational2Double interface for GPSTAG reads double array */ + memset(auxDoubleArray, 0, sizeof(auxDoubleArray)); + memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double)); + } + for (i = 0; i < 3; i++) { + dblDiffLimit = RATIONAL_EPS * auxDoubleArrayGPS2[i]; + dblDiff = auxDoubleArray[i] - auxDoubleArrayGPS2[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value %d of GPSTAG_LONGITUDE %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayGPS2[i]); + } + } + + /* TIFF_RATIONAL, TIFF_SETGET_DOUBLE */ + if (!TIFFGetField(tif, GPSTAG_ALTITUDE, &auxDblUnion.dbl)) { + fprintf(stderr, "Can't read GPSTAG_ALTITUDE\n"); + GOTOFAILURE_GPS + } + if (blnIsRational2Double) { + /* New interface allows also double precision for TIFF_RATIONAL */ + auxDouble = auxDblUnion.dbl; + } else { + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + auxDouble = (double)auxDblUnion.flt1; + } + /* compare read values with written ones */ + dblDiffLimit = RATIONAL_EPS * auxDoubleGPSAltitude; + dblDiff = auxDouble - auxDoubleGPSAltitude; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value of GPSTAG_ALTITUDE %f differs from set value %f\n", auxDouble, auxDoubleGPSAltitude); + GOTOFAILURE_GPS + } + + /*-- TimeStamp is only hh:mm:ss. See also DateTime string 3, TIFF_RATIONAL, TIFF_SETGET_C0_DOUBLE */ + retCode = TIFFGetField(tif, GPSTAG_TIMESTAMP, &pVoidArray); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_TIMESTAMP"); } + if (!blnIsRational2Double) { + /* Reset arrays for debugging purpose first */ + memset(auxFloatArray, 0, sizeof(auxFloatArray)); + memcpy(auxFloatArray, pVoidArray, 3 * sizeof(float)); + /* for comparison copy to doubleArray */ + for (i = 0; i < 3; i++) auxDoubleArray[i] = (double)auxFloatArray[i]; + } else { + /* Rational2Double interface for GPSTAG reads double array */ + memset(auxDoubleArray, 0, sizeof(auxDoubleArray)); + memcpy(auxDoubleArray, pVoidArray, 3 * sizeof(double)); + } + for (i = 0; i < 3; i++) { + dblDiffLimit = RATIONAL_EPS * auxDoubleArrayGPSTime[i]; + dblDiff = auxDoubleArray[i] - auxDoubleArrayGPSTime[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value %d of GPSTAG_TIMESTAMP %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayGPS2[i]); + GOTOFAILURE_GPS + } + } + + /* GPSTAG_IMGDIRECTION --- TIFF_RATIONAL, TIFF_SETGET_DOUBLE */ + if (!TIFFGetField(tif, GPSTAG_IMGDIRECTION, &auxDblUnion.dbl)) { + fprintf(stderr, "Can't read GPSTAG_IMGDIRECTION\n"); + GOTOFAILURE_GPS + } + if (blnIsRational2Double) { + /* New interface allows also double precision for TIFF_RATIONAL */ + auxDouble = auxDblUnion.dbl; + } else { + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + auxDouble = (double)auxDblUnion.flt1; + } + /* compare read values with written ones */ + dblDiffLimit = RATIONAL_EPS * auxDoubleGPSDirection; + dblDiff = auxDouble - auxDoubleGPSDirection; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value of GPSTAG_IMGDIRECTION %f differs from set value %f\n", auxDouble, auxDoubleGPSDirection); + GOTOFAILURE_GPS + } + + /*-- GPSTAG_DIFFERENTIAL , 1, 1, TIFF_SHORT , 0, TIFF_SETGET_UINT16 */ + retCode = TIFFGetField(tif, GPSTAG_DIFFERENTIAL, &auxShort); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "GPSTAG_DIFFERENTIAL"); } + if (auxShort != auxShortArrayW[5]) { + fprintf(stderr, "Read value of GPSTAG_DIFFERENTIAL %d differs from set value %d\n", auxShort, auxShortArrayW[5]); + GOTOFAILURE_GPS + } + + /*-- GPSHPOSITIONINGERROR - new tag for EXIF 2.31 --*/ + if (!TIFFGetField(tif, GPSTAG_GPSHPOSITIONINGERROR, &auxDblUnion.dbl)) { + fprintf(stderr, "Can't read GPSTAG_GPSHPOSITIONINGERROR\n"); + GOTOFAILURE_GPS + } + if (blnIsRational2Double) { + /* New interface allows also double precision for TIFF_RATIONAL */ + auxDouble = auxDblUnion.dbl; + } else { + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + auxDouble = (double)auxDblUnion.flt1; + } + /* compare read values with written ones */ + auxFloat = (float)GPSHPOSITIONINGERROR_VAL; + dblDiffLimit = RATIONAL_EPS * auxFloat; + dblDiff = auxDouble - auxFloat; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value of GPSTAG_GPSHPOSITIONINGERROR %f differs from set value %f\n", auxDouble, auxFloat); + GOTOFAILURE_GPS + } + + /*=============== END reading GPS tags ==========================*/ +#endif /*-- READ_GPS_TAGS --*/ + + + +/*================== Reading EXIF 2.31 tags =====================*/ + + /*--- Firstly, get EXIF directory offset from main directory. */ + + /*-- Go back to the first (main) directory, and get value of the EXIFIFD directory- offset. */ + /* (directory is reloaded from file!) */ + TIFFSetDirectory(tif, 0); + retCode = TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset ); + +#ifdef READ_EXIF_TAGS + /*-- Now read EXIF directory from file into memory --*/ + retCode = TIFFReadEXIFDirectory(tif, read_dir_offset); + + /*-- Now get some parameters from EXIF-directory (already read into memory) --*/ + retCode = TIFFGetField(tif, EXIFTAG_EXIFVERSION, &pAscii); + + +#ifdef READ_ALL_EXIF_TAGS + /*-- Get array, where EXIF tag fields are defined --*/ + tFieldArray = _TIFFGetExifFields(); + nTags = tFieldArray->count; + /*-- Check, if the TiffLibrary is compiled with the new interface with Rational2Double or still uses the old definitions. */ + /* tif points to EXIF tags, so TIFFFindField() can only access the EXIF tag fields */ + fip = TIFFFindField(tif, EXIFTAG_EXPOSURETIME, TIFF_ANY); + tSetFieldType = fip->set_field_type; + if (tSetFieldType == TIFF_SETGET_DOUBLE) { + blnIsRational2Double = FALSE; + fprintf(stderr, "-- EXIF tags read with standard --\n"); + } else { + blnIsRational2Double = TRUE; + fprintf(stderr, "-- Rational2Double for reading EXIF tags detected --\n"); + } + + for (i=0; ifields[i].field_tag; + tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ + tWriteCount = tFieldArray->fields[i].field_writecount; + tSetFieldType = tFieldArray->fields[i].set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ + tFieldName = tFieldArray->fields[i].field_name; + pVoid = NULL; + + /*-- dependent on set_field_type read value --*/ + switch (tSetFieldType) + { + case TIFF_SETGET_ASCII: + /* Either the stringlength is defined as a fixed length in .field_writecount or a NULL-terminated string is used. */ + if (!TIFFGetField( tif, tTag, &pAscii)) { + fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* Save string from temporary buffer and compare with written string. */ + strncpy(auxCharArray, pAscii, sizeof(auxCharArray)); + if (tWriteCount > 0) auxLong = tWriteCount-1; else auxLong = (long)strlen(auxCharArray); + retCode2 = strncmp(auxCharArray, auxTextArrayW[i], auxLong); + if (retCode2 != 0) { + fprintf (stderr, "%d:Read value of %s %s differs from set value %s\n", i, tFieldName, auxCharArray, auxTextArrayW[i]); + GOTOFAILURE_ALL_EXIF + } + break; + /*-- For reading, the parameter size is to be observed !! */ + case TIFF_SETGET_UINT8: + case TIFF_SETGET_SINT8: + if (!TIFFGetField( tif, tTag, &auxChar)) { + fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* compare read values with written ones */ + auxLong = auxChar; + if (auxLong != (char)auxLongArrayW[i]) { + fprintf (stderr, "%d:Read value of %s %ld differs from set value %ld\n", i, tFieldName, auxLong, auxLongArrayW[i]); + } + break; + case TIFF_SETGET_UINT16: + case TIFF_SETGET_SINT16: + if (!TIFFGetField( tif, tTag, &auxShort)) { + fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* compare read values with written ones */ + auxLong = auxShort; + if (auxLong != (short)auxLongArrayW[i]) { + fprintf (stderr, "%d:Read value of %s %ld differs from set value %ld\n", i, tFieldName, auxLong, auxLongArrayW[i]); + } + break; + case TIFF_SETGET_UINT32: + case TIFF_SETGET_SINT32: + case TIFF_SETGET_IFD8: + case TIFF_SETGET_INT: + if (!TIFFGetField( tif, tTag, &auxUint32)) { + fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* compare read values with written ones */ + auxLong = auxUint32; + if (auxLong != auxLongArrayW[i]) { + fprintf (stderr, "%d:Read value of %s %ld differs from set value %ld\n", i, tFieldName, auxLong, auxLongArrayW[i]); + } + break; + case TIFF_SETGET_FLOAT: + if (!TIFFGetField( tif, tTag, &auxFloat)) { + fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* compare read values with written ones */ + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6; + dblDiff = auxFloat - auxDoubleArrayW[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance! + * However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values, + * which are not treated within LibTiff!! + */ + if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxFloat == -1.0)) { + fprintf (stderr, "%d:Read value of %s %f differs from set value %f\n", i, tFieldName, auxFloat, auxDoubleArrayW[i]); + GOTOFAILURE_ALL_EXIF + } + } + break; + case TIFF_SETGET_DOUBLE: + /*-- Unfortunately, TIFF_SETGET_DOUBLE is used for TIFF_RATIONAL but those have to be read with FLOAT !!! */ + /* Only TIFFTAG_STONITS is a TIFF_DOUBLE, which has to be read as DOUBLE!! */ + /*-- ATTENTION: ---- + * Only after update with Rational2Double feature, also TIFF_RATIONAL can be read in double precision!!! + * Therefore, use a union to avoid overflow in TIFFGetField() return value + * and depending on version check for the right interface here: + * - old interface: correct value should be here a float + * - new interface: correct value should be here a double + * Interface version (old/new) is determined above. + -------------------*/ + if (!TIFFGetField(tif, tTag, &auxDblUnion.dbl)) { + fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) { + if (blnIsRational2Double) { + /* New interface allows also double precision for TIFF_RATIONAL */ + auxDouble = auxDblUnion.dbl; + } + else { + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + auxDouble = (double)auxDblUnion.flt1; + } + } + else { + auxDouble = auxDblUnion.dbl; + } + /* compare read values with written ones */ + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6; + dblDiff = auxDouble - auxDoubleArrayW[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance! */ + if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxDouble == -1.0)) { + fprintf (stderr, "%d:Read value of %s %f differs from set value %f\n", i, tFieldName, auxDouble, auxDoubleArrayW[i]); + GOTOFAILURE_ALL_EXIF + } + } + break; + + case TIFF_SETGET_C0_FLOAT: + case TIFF_SETGET_C0_DOUBLE: + case TIFF_SETGET_C16_FLOAT: + case TIFF_SETGET_C16_DOUBLE: + case TIFF_SETGET_C32_FLOAT: + case TIFF_SETGET_C32_DOUBLE: + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf (stderr, "Reading: WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + } else { + /*-- Either fix or variable array --*/ + /* For arrays, distinguishing between float or double is essential. */ + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFGetField( tif, tTag, &pVoidArray)) { + fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* set tWriteCount to number of read samples for next steps */ + auxLong = tWriteCount; + } else { + /* Special treatment of variable array. */ + /* Dependent on Cxx, the count parameter is char, short or long. Therefore use unionLong! */ + if (!TIFFGetField( tif, tTag, &unionLong, &pVoidArray)) { + fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* set tWriteCount to number of read samples for next steps */ + auxLong = unionLong.Short1; + } + /* Save values from temporary array */ + if (tSetFieldType == TIFF_SETGET_C0_FLOAT || tSetFieldType == TIFF_SETGET_C16_FLOAT || tSetFieldType == TIFF_SETGET_C32_FLOAT) { + memcpy(&auxFloatArray, pVoidArray,(auxLong * sizeof(auxFloatArray[0]))); + /* compare read values with written ones */ + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6; + for (j=0; j fabs(dblDiffLimit)) { + /*if (auxFloatArray[j] != (float)auxFloatArrayW[i+j]) { */ + fprintf (stderr, "Read value %d of %s #%d %f differs from set value %f\n", i, tFieldName, j, auxFloatArray[j], auxFloatArrayW[i+j]); + GOTOFAILURE_ALL_EXIF + } + } + } else { + memcpy(&auxDoubleArray, pVoidArray,(auxLong * sizeof(auxDoubleArray[0]))); + /* compare read values with written ones */ + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS*auxDoubleArrayW[i]; else dblDiffLimit = 1e-6; + for (j=0; j fabs(dblDiffLimit)) { + /*if (auxDoubleArray[j] != auxDoubleArrayW[i+j]) { */ + fprintf (stderr, "Read value %d of %s #%d %f differs from set value %f\n", i, tFieldName, j, auxDoubleArray[j], auxDoubleArrayW[i+j]); + GOTOFAILURE_ALL_EXIF + } + } + } + } + break; + case TIFF_SETGET_C0_UINT8: + case TIFF_SETGET_C0_SINT8: + case TIFF_SETGET_C16_UINT8: + case TIFF_SETGET_C16_SINT8: + case TIFF_SETGET_C32_UINT8: + case TIFF_SETGET_C32_SINT8: + /* For arrays, distinguishing between float or double is essential, even for writing */ + pVoid = &auxCharArrayW[i]; + case TIFF_SETGET_C0_UINT16: + case TIFF_SETGET_C0_SINT16: + case TIFF_SETGET_C16_UINT16: + case TIFF_SETGET_C16_SINT16: + case TIFF_SETGET_C32_UINT16: + case TIFF_SETGET_C32_SINT16: + if (pVoid == NULL) pVoid = &auxShortArrayW[i]; + case TIFF_SETGET_C0_UINT32: + case TIFF_SETGET_C0_SINT32: + case TIFF_SETGET_C16_UINT32: + case TIFF_SETGET_C16_SINT32: + case TIFF_SETGET_C32_UINT32: + case TIFF_SETGET_C32_SINT32: + if (pVoid == NULL) pVoid = &auxLongArrayW[i]; + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf (stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + } else { + /*-- Either fix or variable array --*/ + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFGetField( tif, tTag, &pVoidArray)) { + fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* set tWriteCount to number of read samples for next steps */ + auxLong = tWriteCount; + } else { + /* special treatment of variable array */ + /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ + if (!TIFFGetField( tif, tTag, &unionLong, &pVoidArray)) { + fprintf (stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE_ALL_EXIF + break; + } + /* set tWriteCount to number of read samples for next steps */ + auxLong = unionLong.Short1; + } + /* Save values from temporary array */ + if (tSetFieldType == TIFF_SETGET_C0_UINT8 || tSetFieldType == TIFF_SETGET_C0_SINT8 || + tSetFieldType == TIFF_SETGET_C16_UINT8 || tSetFieldType == TIFF_SETGET_C16_SINT8 || + tSetFieldType == TIFF_SETGET_C32_UINT8 || tSetFieldType == TIFF_SETGET_C32_SINT8 ) { + memcpy(&auxCharArray, pVoidArray,(auxLong * sizeof(auxCharArray[0]))); + /* Compare and check values */ + for (j=0; j * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -33,27 +33,25 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif #include "tiffio.h" #include "tifftest.h" int test(int classictif, int height, int tiled) { - const char *filename = "defer_strile_loading.tif"; - TIFF *tif; + const char* filename = "defer_strile_loading.tif"; + TIFF* tif; int i; int ret = 0; - FILE *f; + FILE* f; (void)ret; - tif = TIFFOpen(filename, - classictif ? "wDO" - : "w8DO"); /* O should be ignored in write mode */ - if (!tif) + tif = TIFFOpen(filename, classictif ? "wDO" : "w8DO"); /* O should be ignored in write mode */ + if(!tif) { fprintf(stderr, "cannot create %s\n", filename); return 1; @@ -70,18 +68,18 @@ int test(int classictif, int height, int tiled) assert(ret); ret = TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); assert(ret); - if (tiled) + if( tiled ) { int j; ret = TIFFSetField(tif, TIFFTAG_TILEWIDTH, 16); - assert(ret); + assert( ret ); ret = TIFFSetField(tif, TIFFTAG_TILELENGTH, 16); - assert(ret); - for (j = 0; j < (height + 15) / 16; j++) + assert( ret ); + for( j = 0; j < (height+15) / 16; j++ ) { unsigned char tilebuffer[256]; memset(tilebuffer, (unsigned char)j, 256); - ret = TIFFWriteEncodedTile(tif, j, tilebuffer, 256); + ret = TIFFWriteEncodedTile( tif, j, tilebuffer, 256 ); assert(ret == 256); } } @@ -89,47 +87,47 @@ int test(int classictif, int height, int tiled) { ret = TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); assert(ret); - for (i = 0; i < height; i++) + for( i = 0; i < height; i++ ) { unsigned char c = (unsigned char)i; - ret = TIFFWriteEncodedStrip(tif, i, &c, 1); + ret = TIFFWriteEncodedStrip( tif, i, &c, 1 ); assert(ret == 1); - if (i == 1 && height > 100000) - i = height - 2; + if( i == 1 && height > 100000 ) + i = height - 2; } } TIFFClose(tif); f = fopen(filename, "rb"); - if (!f) + if( !f ) return 1; - for (i = 0; i < 2; i++) + for( i = 0; i < 2; i++ ) { tif = TIFFOpen(filename, i == 0 ? "rD" : "rO"); - if (!tif) + if(!tif) { fprintf(stderr, "cannot open %s\n", filename); fclose(f); return 1; } - if (tiled) + if( tiled ) { int j; - for (j = 0; j < (height + 15) / 16; j++) + for( j = 0; j < (height+15) / 16; j++ ) { int retry; unsigned char expected_c = (unsigned char)j; - for (retry = 0; retry < 2; retry++) + for( retry = 0; retry < 2; retry++ ) { unsigned char tilebuffer[256]; - memset(tilebuffer, 0, 256); - ret = TIFFReadEncodedTile(tif, j, tilebuffer, 256); + memset(tilebuffer,0, 256); + ret = TIFFReadEncodedTile( tif, j, tilebuffer, 256 ); assert(ret == 256); - if (tilebuffer[0] != expected_c || - tilebuffer[255] != expected_c) + if( tilebuffer[0] != expected_c || + tilebuffer[255] != expected_c ) { fprintf(stderr, "unexpected value at tile %d: %d %d\n", j, tilebuffer[0], tilebuffer[255]); @@ -160,12 +158,13 @@ int test(int classictif, int height, int tiled) (void)nread; } - memset(tilebuffer, 0, 256); - ret = TIFFReadFromUserBuffer(tif, j, inputbuffer, 256, - tilebuffer, 256); + memset(tilebuffer,0, 256); + ret = TIFFReadFromUserBuffer(tif, j, + inputbuffer, 256, + tilebuffer, 256 ); assert(ret == 1); - if (tilebuffer[0] != expected_c || - tilebuffer[255] != expected_c) + if( tilebuffer[0] != expected_c || + tilebuffer[255] != expected_c ) { fprintf(stderr, "unexpected value at tile %d: %d %d\n", j, tilebuffer[0], tilebuffer[255]); @@ -179,19 +178,19 @@ int test(int classictif, int height, int tiled) else { int j; - for (j = 0; j < height; j++) + for( j = 0; j < height; j++ ) { int retry; unsigned char expected_c = (unsigned char)j; - for (retry = 0; retry < 2; retry++) + for( retry = 0; retry < 2; retry++ ) { unsigned char c = 0; - ret = TIFFReadEncodedStrip(tif, j, &c, 1); + ret = TIFFReadEncodedStrip( tif, j, &c, 1 ); assert(ret == 1); - if (c != expected_c) + if( c != expected_c ) { - fprintf(stderr, "unexpected value at line %d: %d\n", j, - c); + fprintf(stderr, "unexpected value at line %d: %d\n", + j, c); TIFFClose(tif); fclose(f); return 1; @@ -218,25 +217,26 @@ int test(int classictif, int height, int tiled) size_t nread = fread(inputbuffer, 1, 1, f); (void)nread; } - memset(tilebuffer, 0, 1); - ret = TIFFReadFromUserBuffer(tif, j, inputbuffer, 1, - tilebuffer, 1); + memset(tilebuffer,0, 1); + ret = TIFFReadFromUserBuffer(tif, j, + inputbuffer, 1, + tilebuffer, 1 ); assert(ret == 1); - if (tilebuffer[0] != expected_c) + if( tilebuffer[0] != expected_c ) { - fprintf(stderr, "unexpected value at line %d: %d\n", j, - tilebuffer[0]); + fprintf(stderr, "unexpected value at line %d: %d\n", + j, tilebuffer[0]); TIFFClose(tif); fclose(f); return 1; } } - if (j == 1 && height > 100000) - j = height - 2; + if( j == 1 && height > 100000 ) + j = height - 2; } - if (height > 100000) + if( height > 100000 ) { /* Missing strip */ int err = 0; @@ -247,6 +247,7 @@ int test(int classictif, int height, int tiled) ret = TIFFGetStrileByteCountWithErr(tif, 2, &err); assert(ret == 0); assert(err == 0); + } } @@ -262,26 +263,24 @@ int test(int classictif, int height, int tiled) } { - toff_t *offsets = NULL; - toff_t *bytecounts = NULL; - ret = TIFFGetField( - tif, tiled ? TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS, - &offsets); + toff_t* offsets = NULL; + toff_t* bytecounts = NULL; + ret = TIFFGetField( tif, + tiled ? TIFFTAG_TILEOFFSETS : TIFFTAG_STRIPOFFSETS, &offsets ); assert(ret); assert(offsets); - ret = TIFFGetField( - tif, tiled ? TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS, - &bytecounts); + ret = TIFFGetField( tif, + tiled ? TIFFTAG_TILEBYTECOUNTS : TIFFTAG_STRIPBYTECOUNTS, &bytecounts ); assert(ret); assert(bytecounts); - if (tiled) + if( tiled ) { assert(bytecounts[0] == 256); } else { assert(bytecounts[0] == 1); - if (height > 1 && height <= 100000) + if( height > 1 && height <= 100000) { assert(offsets[1] == offsets[0] + 1); assert(offsets[height - 1] == offsets[0] + height - 1); @@ -298,20 +297,21 @@ int test(int classictif, int height, int tiled) return 0; } -int main() +int +main() { int is_classic; - for (is_classic = 1; is_classic >= 0; is_classic--) + for( is_classic = 1; is_classic >= 0; is_classic-- ) { int tiled; - for (tiled = 0; tiled <= 1; tiled++) + for( tiled = 0; tiled <= 1; tiled ++ ) { - if (test(is_classic, 1, tiled)) + if( test(is_classic, 1, tiled) ) return 1; - if (test(is_classic, 8192, tiled)) + if( test(is_classic, 8192, tiled) ) return 1; } - if (test(is_classic, 2000000, 0)) + if( test(is_classic, 2000000, 0) ) return 1; } return 0; diff --git a/thirdparty/SDL2_image/external/libtiff/test/defer_strile_writing.c b/thirdparty/SDL2_image/external/libtiff/test/defer_strile_writing.c index e153f2ff4..4e358567a 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/defer_strile_writing.c +++ b/thirdparty/SDL2_image/external/libtiff/test/defer_strile_writing.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2019, Even Rouault * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -33,22 +33,22 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif #include "tiffio.h" -int test(const char *mode, int tiled, int height) +int test(const char* mode, int tiled, int height) { - const char *filename = "defer_strile_writing.tif"; - TIFF *tif; + const char* filename = "defer_strile_writing.tif"; + TIFF* tif; int i; int ret = 0; (void)ret; tif = TIFFOpen(filename, mode); - if (!tif) + if(!tif) { fprintf(stderr, "cannot create %s\n", filename); return 1; @@ -66,12 +66,12 @@ int test(const char *mode, int tiled, int height) ret = TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); assert(ret); - if (tiled) + if( tiled ) { ret = TIFFSetField(tif, TIFFTAG_TILEWIDTH, 16); - assert(ret); + assert( ret ); ret = TIFFSetField(tif, TIFFTAG_TILELENGTH, 16); - assert(ret); + assert( ret ); } else { @@ -82,17 +82,17 @@ int test(const char *mode, int tiled, int height) ret = TIFFDeferStrileArrayWriting(tif); assert(ret); - ret = TIFFWriteCheck(tif, tiled, "test"); + ret = TIFFWriteCheck( tif, tiled, "test" ); assert(ret); - ret = TIFFWriteDirectory(tif); + ret = TIFFWriteDirectory( tif ); assert(ret); /* Create other directory */ - TIFFFreeDirectory(tif); - TIFFCreateDirectory(tif); + TIFFFreeDirectory( tif ); + TIFFCreateDirectory( tif ); - ret = TIFFSetField(tif, TIFFTAG_SUBFILETYPE, FILETYPE_PAGE); + ret = TIFFSetField( tif, TIFFTAG_SUBFILETYPE, FILETYPE_PAGE ); assert(ret); ret = TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); assert(ret); @@ -112,79 +112,79 @@ int test(const char *mode, int tiled, int height) ret = TIFFDeferStrileArrayWriting(tif); assert(ret); - ret = TIFFWriteCheck(tif, 0, "test"); + ret = TIFFWriteCheck( tif, 0, "test" ); assert(ret); - ret = TIFFWriteDirectory(tif); + ret = TIFFWriteDirectory( tif ); assert(ret); /* Force writing of strile arrays */ - ret = TIFFSetDirectory(tif, 0); + ret = TIFFSetDirectory( tif, 0 ); assert(ret); ret = TIFFForceStrileArrayWriting(tif); assert(ret); - ret = TIFFSetDirectory(tif, 1); + ret = TIFFSetDirectory( tif, 1 ); assert(ret); ret = TIFFForceStrileArrayWriting(tif); assert(ret); - /* Now write data on first directory */ - ret = TIFFSetDirectory(tif, 0); + /* Now write data on frist directory */ + ret = TIFFSetDirectory( tif, 0 ); assert(ret); - if (tiled) + if( tiled ) { int j; - for (j = 0; j < (height + 15) / 16; j++) + for( j = 0; j < (height+15) / 16; j++ ) { unsigned char tilebuffer[256]; memset(tilebuffer, (unsigned char)j, 256); - ret = TIFFWriteEncodedTile(tif, j, tilebuffer, 256); + ret = TIFFWriteEncodedTile( tif, j, tilebuffer, 256 ); assert(ret == 256); } } else { - for (i = 0; i < height; i++) + for( i = 0; i < height; i++ ) { unsigned char c = (unsigned char)i; - ret = TIFFWriteEncodedStrip(tif, i, &c, 1); + ret = TIFFWriteEncodedStrip( tif, i, &c, 1 ); assert(ret == 1); - if (i == 1 && height > 100000) - i = height - 2; + if( i == 1 && height > 100000 ) + i = height - 2; } } TIFFClose(tif); tif = TIFFOpen(filename, "r"); - if (!tif) + if(!tif) { fprintf(stderr, "cannot open %s\n", filename); return 1; } - if (tiled) + if( tiled ) { int j; - for (j = 0; j < (height + 15) / 16; j++) + for( j = 0; j < (height+15) / 16; j++ ) { int retry; - for (retry = 0; retry < 2; retry++) + for( retry = 0; retry < 2; retry++ ) { unsigned char tilebuffer[256]; unsigned char expected_c = (unsigned char)j; - memset(tilebuffer, 0, 256); - ret = TIFFReadEncodedTile(tif, j, tilebuffer, 256); + memset(tilebuffer,0, 256); + ret = TIFFReadEncodedTile( tif, j, tilebuffer, 256 ); assert(ret == 256); - if (tilebuffer[0] != expected_c || - tilebuffer[255] != expected_c) + if( tilebuffer[0] != expected_c || + tilebuffer[255] != expected_c ) { - fprintf(stderr, "unexpected value at tile %d: %d %d\n", j, - tilebuffer[0], tilebuffer[255]); + fprintf(stderr, "unexpected value at tile %d: %d %d\n", + j, tilebuffer[0], tilebuffer[255]); TIFFClose(tif); return 1; } @@ -194,18 +194,19 @@ int test(const char *mode, int tiled, int height) else { int j; - for (j = 0; j < height; j++) + for( j = 0; j < height; j++ ) { int retry; - for (retry = 0; retry < 2; retry++) + for( retry = 0; retry < 2; retry++ ) { unsigned char c = 0; unsigned char expected_c = (unsigned char)j; - ret = TIFFReadEncodedStrip(tif, j, &c, 1); + ret = TIFFReadEncodedStrip( tif, j, &c, 1 ); assert(ret == 1); - if (c != expected_c) + if( c != expected_c ) { - fprintf(stderr, "unexpected value at line %d: %d\n", j, c); + fprintf(stderr, "unexpected value at line %d: %d\n", + j, c); TIFFClose(tif); return 1; } @@ -219,18 +220,19 @@ int test(const char *mode, int tiled, int height) return 0; } -int main() +int +main() { int tiled; - for (tiled = 0; tiled <= 1; tiled++) + for( tiled = 0; tiled <= 1; tiled ++ ) { - if (test("w", tiled, 1)) + if( test("w", tiled, 1) ) return 1; - if (test("w", tiled, 10)) + if( test("w", tiled, 10) ) return 1; - if (test("w8", tiled, 1)) + if( test("w8", tiled, 1) ) return 1; - if (test("wD", tiled, 1)) + if( test("wD", tiled, 1) ) return 1; } return 0; diff --git a/thirdparty/SDL2_image/external/libtiff/test/images/minisblack-1c-8b.pgm b/thirdparty/SDL2_image/external/libtiff/test/images/minisblack-1c-8b.pgm index 0faca40f04121eb769510d9221033341fefee8fd..08edbe3997f91e002f4e3d53cdf75a110a9d1215 100644 GIT binary patch literal 130 zcmWN{I}*Ym5CG7gQ*Z$TF25zWVPO$wR5F4oJiV!2^G^QEKHjpebuDcz N2_R=zU#2*M-C*=SD literal 23722 zcmX85hg;icvNpV%Y}~-u;2!r9+i}BSdhfl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KikzwzJ999TqBLr)4 z#md0zhZv%i5GE2!VpH;K8`_3Hb*A$mSqB(ev;@2{vE)TmSOgSgqhk;uP<%+0-+le& zr@C}(X{NZTudb6Yj@apkyPtsX5s|9YXjaxWOKK=^eqS}LZf>nBr-t734GiPNJUmi} zdjtf8nHdxrV;@I{d#dBkodJ|UB#oCPVPgX#0vq5mLV5~gqqLl|`nHeCm5J900Rkkt zkex&WBt-I}9e6&7JHox->?URAm%r;?RnG!jpP2`G=pq2!SU@6LaibFF1|(Gxllm16 z;#i|w(pmMEwG2T!(($m`_3=S2FMVQ1%+0vTsGBFl33Pg73up!egt?pT0>@^tF zy0oH)Bg60%ap=N0HQ_wS>MkjDTH*t-`4$&u=TV^zq02drlo)cSUzD&|O9)ef=BC#h zR*0_%DeT(KjpgStm}5y3(iK^0IKzN8BlccG8afnpUE`~hFMEfF|40cGqEC*sW?v{A bdIWqGv?y^B6I5)_J)iWheH+)U=$HNn62M+o diff --git a/thirdparty/SDL2_image/external/libtiff/test/images/test_float64_predictor2_be_lzw.tif b/thirdparty/SDL2_image/external/libtiff/test/images/test_float64_predictor2_be_lzw.tif deleted file mode 100644 index 7ad5a60e0..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/images/test_float64_predictor2_be_lzw.tif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:92b52def55d4fad284fe74b447b1a4a008c4ae0c2eeb80044e18b8f5a192f670 -size 872 diff --git a/thirdparty/SDL2_image/external/libtiff/test/images/test_float64_predictor2_le_lzw.tif b/thirdparty/SDL2_image/external/libtiff/test/images/test_float64_predictor2_le_lzw.tif deleted file mode 100644 index 61abc585c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/images/test_float64_predictor2_le_lzw.tif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0aa2ac5e2513e9a9f76ac70eaab47002f255ddd3648c4335b30a1fdd337ed821 -size 887 diff --git a/thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_subifd.tif b/thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_subifd.tif deleted file mode 100644 index a72e51d0b..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_subifd.tif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9f7b0b1ef6fe925f2b4913e2e108ecfb1f9547346de17e53c61068888b7345aa -size 1654 diff --git a/thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_to_first.tif b/thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_to_first.tif deleted file mode 100644 index 115f6c51c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_to_first.tif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:516a304cc30116b6f3a123544ad287d7fbe93aae1bf741a883b1d0b92f7dec9d -size 312 diff --git a/thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_to_self.tif b/thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_to_self.tif deleted file mode 100644 index 99b865f7c..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/images/test_ifd_loop_to_self.tif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:38b3093d53a1a80fdb949992ee51d6cb184894cc82ddec7a7f71ea5817e49868 -size 558 diff --git a/thirdparty/SDL2_image/external/libtiff/test/images/test_two_ifds.tif b/thirdparty/SDL2_image/external/libtiff/test/images/test_two_ifds.tif deleted file mode 100644 index ac9d2e6b6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/images/test_two_ifds.tif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e8167ea8ec1d9e145798ac7fc19a3fd79c6eee55ed0923b17a305f4fca0d6810 -size 312 diff --git a/thirdparty/SDL2_image/external/libtiff/test/images/testfax3_bug_513.tiff b/thirdparty/SDL2_image/external/libtiff/test/images/testfax3_bug_513.tiff deleted file mode 100644 index ac0c5821d..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/images/testfax3_bug_513.tiff +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2f8639e9a1e9fc5c4561541c15dcb59f77a710b1e06aede23ed5ed6ca5580ceb -size 198 diff --git a/thirdparty/SDL2_image/external/libtiff/test/images/tiff_with_subifd_chain.tif b/thirdparty/SDL2_image/external/libtiff/test/images/tiff_with_subifd_chain.tif deleted file mode 100644 index 6b83580c1..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/images/tiff_with_subifd_chain.tif +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e50130294baf254b8ab54a46b96e8d8d13abe840e4d8a447086028375de97c37 -size 19484 diff --git a/thirdparty/SDL2_image/external/libtiff/test/long_tag.c b/thirdparty/SDL2_image/external/libtiff/test/long_tag.c index df3202f36..4bfdf8051 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/long_tag.c +++ b/thirdparty/SDL2_image/external/libtiff/test/long_tag.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2004, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -31,131 +31,124 @@ #include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif #include "tiffio.h" -extern int CheckLongField(TIFF *, ttag_t, uint32_t); +extern int CheckLongField(TIFF *, ttag_t, uint32); -const char *filename = "long_test.tiff"; +const char *filename = "long_test.tiff"; -static struct Tags +static struct Tags { + ttag_t tag; + short count; + uint32 value; +} long_tags[] = { + { TIFFTAG_SUBFILETYPE, 1, FILETYPE_REDUCEDIMAGE|FILETYPE_PAGE|FILETYPE_MASK } +}; +#define NTAGS (sizeof (long_tags) / sizeof (long_tags[0])) + +const uint32 width = 1; +const uint32 length = 1; +const uint32 rows_per_strip = 1; + +int +main(int argc, char **argv) { - ttag_t tag; - short count; - uint32_t value; -} long_tags[] = {{TIFFTAG_SUBFILETYPE, 1, - FILETYPE_REDUCEDIMAGE | FILETYPE_PAGE | FILETYPE_MASK}}; -#define NTAGS (sizeof(long_tags) / sizeof(long_tags[0])) + TIFF *tif; + unsigned int i; + unsigned char buf[3] = { 0, 127, 255 }; + (void) argc; + (void) argv; -const uint32_t width = 1; -const uint32_t length = 1; -const uint32_t rows_per_strip = 1; + /* Test whether we can write tags. */ + tif = TIFFOpen(filename, "w"); + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); + return 1; + } -int main(int argc, char **argv) -{ - TIFF *tif; - unsigned int i; - unsigned char buf[3] = {0, 127, 255}; - (void)argc; - (void)argv; + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB)) { + fprintf (stderr, "Can't set PhotometricInterpretation tag.\n"); + goto failure; + } - /* Test whether we can write tags. */ - tif = TIFFOpen(filename, "w"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filename); - return 1; - } + for (i = 0; i < NTAGS; i++) { + if (!TIFFSetField(tif, long_tags[i].tag, + long_tags[i].value)) { + fprintf(stderr, "Can't set tag %d.\n", + (int)long_tags[i].tag); + goto failure; + } + } - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB)) - { - fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); - goto failure; - } + /* Write dummy pixel data. */ + if (TIFFWriteScanline(tif, buf, 0, 0) == -1) { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } - for (i = 0; i < NTAGS; i++) - { - if (!TIFFSetField(tif, long_tags[i].tag, long_tags[i].value)) - { - fprintf(stderr, "Can't set tag %d.\n", (int)long_tags[i].tag); - goto failure; - } - } + TIFFClose(tif); + + /* Ok, now test whether we can read written values. */ + tif = TIFFOpen(filename, "r"); + if (!tif) { + fprintf (stderr, "Can't open test TIFF file %s.\n", filename); + return 1; + } - /* Write dummy pixel data. */ - if (TIFFWriteScanline(tif, buf, 0, 0) == -1) - { - fprintf(stderr, "Can't write image data.\n"); - goto failure; - } + if (CheckLongField(tif, TIFFTAG_IMAGEWIDTH, width) < 0) + goto failure; - TIFFClose(tif); + if (CheckLongField(tif, TIFFTAG_IMAGELENGTH, length) < 0) + goto failure; - /* Ok, now test whether we can read written values. */ - tif = TIFFOpen(filename, "r"); - if (!tif) - { - fprintf(stderr, "Can't open test TIFF file %s.\n", filename); - return 1; - } + if (CheckLongField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip) < 0) + goto failure; - if (CheckLongField(tif, TIFFTAG_IMAGEWIDTH, width) < 0) - goto failure; + for (i = 0; i < NTAGS; i++) { + if (CheckLongField(tif, long_tags[i].tag, + long_tags[i].value) < 0) + goto failure; + } - if (CheckLongField(tif, TIFFTAG_IMAGELENGTH, length) < 0) - goto failure; - - if (CheckLongField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip) < 0) - goto failure; - - for (i = 0; i < NTAGS; i++) - { - if (CheckLongField(tif, long_tags[i].tag, long_tags[i].value) < 0) - goto failure; - } - - TIFFClose(tif); - - /* All tests passed; delete file and exit with success status. */ - unlink(filename); - return 0; + TIFFClose(tif); + + /* All tests passed; delete file and exit with success status. */ + unlink(filename); + return 0; failure: - /* Something goes wrong; close file and return unsuccessful status. */ - TIFFClose(tif); - unlink(filename); - return 1; + /* Something goes wrong; close file and return unsuccessful status. */ + TIFFClose(tif); + unlink(filename); + return 1; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/rational_precision2double.c b/thirdparty/SDL2_image/external/libtiff/test/rational_precision2double.c index 0c27a4e1e..e33cc97d1 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/rational_precision2double.c +++ b/thirdparty/SDL2_image/external/libtiff/test/rational_precision2double.c @@ -2,23 +2,23 @@ /* * Copyright (c) 2012, Frank Warmerdam * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -26,1313 +26,947 @@ * TIFF Library * * -- Module copied from custom_dir.c -- - *=========== Purpose - *=================================================================================== - * Extended and amended version for testing the TIFFSetField() / and - *TIFFGetField()- interface for custom fields of type RATIONAL when the TIFFLib - *internal precision is updated from FLOAT to DOUBLE! The external interface of - *already defined tags schould be kept. This is verified for some of those tags - *with this test. + *=========== Purpose =================================================================================== + * Extended and amended version for testing the TIFFSetField() / and TIFFGetField()- interface + * for custom fields of type RATIONAL when the TIFFLib internal precision is updated from FLOAT to DOUBLE! + * The external interface of already defined tags schould be kept. + * This is verified for some of those tags with this test. * */ + #define FOR_AUTO_TESTING #ifdef FOR_AUTO_TESTING -/* Only for automake and CMake infrastructure the test should: - a.) delete any written testfiles when test passed (otherwise autotest will - fail) b.) goto failure, if any failure is detected, which is not necessary - when test is initiated manually for debugging +/* Only for automake and CMake infrastructure the test should: + a.) delete any written testfiles when test passed (otherwise autotest will fail) + b.) goto failure, if any failure is detected, which is not necessary when test is initiated manually for debugging */ -#define GOTOFAILURE goto failure; +#define GOTOFAILURE goto failure; #else #define GOTOFAILURE #endif #ifdef _MSC_VER -#pragma warning(disable : 4101) +#pragma warning( disable : 4101) #endif #include "tif_config.h" -#include -#include #include #include +#include +#include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif -#include "tif_dir.h" #include "tiffio.h" #include "tiffiop.h" +#include "tif_dir.h" #include "tifftest.h" + #include "tif_dirwrite.c" + int write_test_tiff(TIFF *tif, const char *filenameRead, int blnAllCustomTags); -#define SPP 3 /* Samples per pixel */ -const uint16_t width = 1; -const uint16_t length = 1; -const uint16_t bps = 8; -const uint16_t photometric = PHOTOMETRIC_RGB; -const uint16_t rows_per_strip = 1; -const uint16_t planarconfig = PLANARCONFIG_CONTIG; +#define SPP 3 /* Samples per pixel */ +const uint16 width = 1; +const uint16 length = 1; +const uint16 bps = 8; +const uint16 photometric = PHOTOMETRIC_RGB; +const uint16 rows_per_strip = 1; +const uint16 planarconfig = PLANARCONFIG_CONTIG; /*-- Additional custom TIFF tags for testing of Rational2Double precision --*/ -#define TIFFTAG_RATIONAL_DOUBLE 60000 -#define TIFFTAG_SRATIONAL_DOUBLE 60001 -#define TIFFTAG_RATIONAL_C0_DOUBLE 60002 -#define TIFFTAG_SRATIONAL_C16_DOUBLE 60003 +#define TIFFTAG_RATIONAL_DOUBLE 60000 +#define TIFFTAG_SRATIONAL_DOUBLE 60001 +#define TIFFTAG_RATIONAL_C0_DOUBLE 60002 +#define TIFFTAG_SRATIONAL_C16_DOUBLE 60003 + /*--- TIFFField Definition --- - field_tag: the tag number. For instance 277 for the SamplesPerPixel tag. - Builtin tags will generally have a #define in tiff.h for each known tag. - field_readcount: The number of values which should be read. The special - value TIFF_VARIABLE (-1) indicates that a variable number of values may be - read. The special value TIFFTAG_SPP (-2) indicates that there should be one - value for each sample as defined by TIFFTAG_SAMPLESPERPIXEL. The special - value TIFF_VARIABLE2 (-3) is presumably similar to TIFF_VARIABLE though I am - not sure what the distinction in behaviour is. This field is TIFF_VARIABLE - for variable length ascii fields. field_writecount: The number of values - which should be written. Generally the same as field_readcount. A few - built-in exceptions exist, but I haven't analysed why they differ. - field_type: Type of the field. One of TIFF_BYTE, TIFF_ASCII, TIFF_SHORT, - TIFF_LONG, TIFF_RATIONAL, TIFF_SBYTE, TIFF_UNDEFINED, TIFF_SSHORT, - TIFF_SLONG, TIFF_SRATIONAL, TIFF_FLOAT, TIFF_DOUBLE or TIFF_IFD. Note that - some fields can support more than one type (for instance short and long). - These fields should have multiple TIFFFieldInfos. reserved: set_field_type: - TIFF_SETGET_DOUBLE get_field_type: - not used - field_bit: Built-in tags - stored in special fields in the TIFF structure have assigned field numbers to - distinguish them (ie. FIELD_SAMPLESPERPIXEL). New tags should generally just - use FIELD_CUSTOM indicating they are stored in the generic tag list. - field_oktochange: TRUE if it is OK to change this tag value while an - image is being written. FALSE for stuff that must be set once and then left - unchanged (like ImageWidth, or PhotometricInterpretation for instance). - field_passcount: If TRUE, then the count value must be passed in - TIFFSetField(), and TIFFGetField(), otherwise the count is not required. This - should generally be TRUE for non-ascii variable count tags unless the count - is implicit (such as with the colormap). field_name: A name for the tag. - Normally mixed case (studly caps) like "StripByteCounts" and relatively - short. + field_tag: the tag number. For instance 277 for the SamplesPerPixel tag. Builtin tags will generally have a #define in tiff.h for each known tag. + field_readcount: The number of values which should be read. The special value TIFF_VARIABLE (-1) indicates that a variable number of values may be read. The special value TIFFTAG_SPP (-2) indicates that there should be one value for each sample as defined by TIFFTAG_SAMPLESPERPIXEL. The special value TIFF_VARIABLE2 (-3) is presumably similar to TIFF_VARIABLE though I am not sure what the distinction in behaviour is. This field is TIFF_VARIABLE for variable length ascii fields. + field_writecount: The number of values which should be written. Generally the same as field_readcount. A few built-in exceptions exist, but I haven't analysed why they differ. + field_type: Type of the field. One of TIFF_BYTE, TIFF_ASCII, TIFF_SHORT, TIFF_LONG, TIFF_RATIONAL, TIFF_SBYTE, TIFF_UNDEFINED, TIFF_SSHORT, TIFF_SLONG, TIFF_SRATIONAL, TIFF_FLOAT, TIFF_DOUBLE or TIFF_IFD. Note that some fields can support more than one type (for instance short and long). These fields should have multiple TIFFFieldInfos. + reserved: + set_field_type: TIFF_SETGET_DOUBLE + get_field_type: - not used - + field_bit: Built-in tags stored in special fields in the TIFF structure have assigned field numbers to distinguish them (ie. FIELD_SAMPLESPERPIXEL). New tags should generally just use FIELD_CUSTOM indicating they are stored in the generic tag list. + field_oktochange: TRUE if it is OK to change this tag value while an image is being written. FALSE for stuff that must be set once and then left unchanged (like ImageWidth, or PhotometricInterpretation for instance). + field_passcount: If TRUE, then the count value must be passed in TIFFSetField(), and TIFFGetField(), otherwise the count is not required. This should generally be TRUE for non-ascii variable count tags unless the count is implicit (such as with the colormap). + field_name: A name for the tag. Normally mixed case (studly caps) like "StripByteCounts" and relatively short. */ -static const TIFFField tifFieldInfo[] = { - {TIFFTAG_RATIONAL_DOUBLE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, - TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Rational2Double_U_Double", - NULL}, - {TIFFTAG_SRATIONAL_DOUBLE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, - TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Rational2Double_S_Double", - NULL}, - {TIFFTAG_RATIONAL_C0_DOUBLE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, - TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Rational2Double_C0", NULL}, - {TIFFTAG_SRATIONAL_C16_DOUBLE, -1, -1, TIFF_SRATIONAL, 0, - TIFF_SETGET_C16_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, - "Rational2Double_S_C16", NULL}, +static const TIFFField +tifFieldInfo[] = { + { TIFFTAG_RATIONAL_DOUBLE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Rational2Double_U_Double", NULL }, + { TIFFTAG_SRATIONAL_DOUBLE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Rational2Double_S_Double", NULL }, + { TIFFTAG_RATIONAL_C0_DOUBLE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 0, "Rational2Double_C0", NULL }, + { TIFFTAG_SRATIONAL_C16_DOUBLE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_DOUBLE, TIFF_SETGET_UNDEFINED, FIELD_CUSTOM, 0, 1, "Rational2Double_S_C16", NULL }, }; -#define N(a) (sizeof(a) / sizeof(a[0])) +#define N(a) (sizeof (a) / sizeof (a[0])) -/*--- Add aditional Rational-Double Tags to TIFF - ref: html\addingtags.html but with new function _TIFFMergeFields(). +/*--- Add aditional Rational-Double Tags to TIFF + ref: html\addingtags.html but with new function _TIFFMergeFields(). ---*/ -/* In libtiff 3.6.0 a new mechanism was introduced allowing libtiff to read - unrecognised tags automatically. When an unknown tags is encountered, it is - automatically internally defined with a default name and a type derived from - the tag value in the file. Applications only need to predefine application - specific tags if they need to be able to set them in a file, or if particular - calling conventions are desired for TIFFSetField() and TIFFGetField(). When - tags are autodefined like this the field_readcount and field_writecount - values are always TIFF_VARIABLE. The field_passcount is always TRUE, and the - field_bit is FIELD_CUSTOM. The field name will be "Tag %d" where the %d is - the tag number. +/* In libtiff 3.6.0 a new mechanism was introduced allowing libtiff to read unrecognised tags automatically. + When an unknown tags is encountered, it is automatically internally defined with a default name and a type derived from the tag value in the file. + Applications only need to predefine application specific tags if they need to be able to set them in a file, or if particular calling conventions + are desired for TIFFSetField() and TIFFGetField(). + When tags are autodefined like this the field_readcount and field_writecount values are always TIFF_VARIABLE. + The field_passcount is always TRUE, and the field_bit is FIELD_CUSTOM. The field name will be "Tag %d" where the %d is the tag number. */ -/*The tags need to be defined for each TIFF file opened - and when reading they - should be defined before the tags of the file are read, yet a valid TIFF * is - needed to merge the tags against. In order to get them registered at the - appropriate part of the setup process, it is necessary to register our merge - function as an extender callback with libtiff. This is done with - TIFFSetTagExtender(). We also keep track of the previous tag extender (if any) - so that we can call it from our extender allowing a chain of customizations to - take effect. +/*The tags need to be defined for each TIFF file opened - and when reading they should be defined before the tags of the file are read, + yet a valid TIFF * is needed to merge the tags against. In order to get them registered at the appropriate part of the setup process, + it is necessary to register our merge function as an extender callback with libtiff. This is done with TIFFSetTagExtender(). + We also keep track of the previous tag extender (if any) so that we can call it from our extender allowing a chain of customizations to take effect. */ static TIFFExtendProc _ParentExtender = NULL; static void _XTIFFDefaultDirectory(TIFF *tif); -static void _XTIFFInitialize(void) +static +void _XTIFFInitialize(void) { - static int first_time = 1; + static int first_time=1; + + if (! first_time) return; /* Been there. Done that. */ +first_time = 0; - if (!first_time) - return; /* Been there. Done that. */ - first_time = 0; - - /* Grab the inherited method and install */ - _ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory); +/* Grab the inherited method and install */ +_ParentExtender = TIFFSetTagExtender(_XTIFFDefaultDirectory); } /* The extender callback is looks like this. -It merges in our new fields and then calls the next extender if there is one in -effect. +It merges in our new fields and then calls the next extender if there is one in effect. */ -static void _XTIFFDefaultDirectory(TIFF *tif) +static void +_XTIFFDefaultDirectory(TIFF *tif) { - uint32_t n, nadded; + uint32 n, nadded; - /* Install the extended Tag field info */ - n = N(tifFieldInfo); - //_TIFFMergeFields(tif, const TIFFField info[], uint32_t n); - nadded = _TIFFMergeFields(tif, tifFieldInfo, n); - (void)nadded; + /* Install the extended Tag field info */ + n = N(tifFieldInfo); + //_TIFFMergeFields(tif, const TIFFField info[], uint32 n); + nadded = _TIFFMergeFields(tif, tifFieldInfo, n); + (void)nadded; - /* Since an XTIFF client module may have overridden - * the default directory method, we call it now to - * allow it to set up the rest of its own methods. - */ + /* Since an XTIFF client module may have overridden + * the default directory method, we call it now to + * allow it to set up the rest of its own methods. + */ - if (_ParentExtender) - (*_ParentExtender)(tif); + if (_ParentExtender) + (*_ParentExtender)(tif); } -int main() + +int +main() { - static const char filenameClassicTiff[] = "rationalPrecision2Double.tif"; - static const char filenameBigTiff[] = "rationalPrecision2Double_Big.tif"; + static const char filenameClassicTiff[] = "rationalPrecision2Double.tif"; + static const char filenameBigTiff[] = "rationalPrecision2Double_Big.tif"; - TIFF *tif; - int ret; - int errorNo; + TIFF *tif; + int ret; + int errorNo; - /*-- Initialize TIFF-Extender to add additonal TIFF-Tags --*/ - _XTIFFInitialize(); + /*-- Initialize TIFF-Extender to add additonal TIFF-Tags --*/ + _XTIFFInitialize(); - fprintf(stderr, "==== Test if Set()/Get() interface for some custom " - "rational tags behave as before change. ====\n"); - /* --- Test with Classic-TIFF ---*/ - /* delete file, if exists */ - ret = unlink(filenameClassicTiff); - errorNo = errno; - if (ret != 0 && errorNo != ENOENT) - { - fprintf(stderr, "Can't delete test TIFF file %s.\n", - filenameClassicTiff); - } + fprintf(stderr, "==== Test if Set()/Get() interface for some custom rational tags behave as before change. ====\n"); + /* --- Test with Classic-TIFF ---*/ + /* delete file, if exists */ + ret = unlink(filenameClassicTiff); + errorNo = errno; + if (ret != 0 && errorNo != ENOENT) { + fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameClassicTiff); + } - /* We write the main directory as a simple image. */ - tif = TIFFOpen(filenameClassicTiff, "w+"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", - filenameClassicTiff); - return 1; - } - fprintf(stderr, "-------- Test with ClassicTIFF started ----------\n"); - ret = write_test_tiff(tif, filenameClassicTiff, FALSE); - if (ret > 0) - return (ret); + /* We write the main directory as a simple image. */ + tif = TIFFOpen(filenameClassicTiff, "w+"); + if (!tif) { + fprintf(stderr, "Can't create test TIFF file %s.\n", filenameClassicTiff); + return 1; + } + fprintf(stderr, "-------- Test with ClassicTIFF started ----------\n"); + ret = write_test_tiff(tif, filenameClassicTiff, FALSE); + if (ret > 0) return(ret); - /*--- Test with BIG-TIFF ---*/ - /* delete file, if exists */ - ret = unlink(filenameBigTiff); - if (ret != 0 && errorNo != ENOENT) - { - fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameBigTiff); - } + /*--- Test with BIG-TIFF ---*/ + /* delete file, if exists */ + ret = unlink(filenameBigTiff); + if (ret != 0 && errorNo != ENOENT) { + fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameBigTiff); + } - tif = TIFFOpen(filenameBigTiff, "w8"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filenameBigTiff); - return 1; - } - fprintf(stderr, "\n-------- Test with BigTIFF started ----------\n"); - ret = write_test_tiff(tif, filenameBigTiff, FALSE); - if (ret > 0) - return (ret); + tif = TIFFOpen(filenameBigTiff, "w8"); + if (!tif) { + fprintf(stderr, "Can't create test TIFF file %s.\n", filenameBigTiff); + return 1; + } + fprintf(stderr, "\n-------- Test with BigTIFF started ----------\n"); + ret = write_test_tiff(tif, filenameBigTiff, FALSE); + if (ret > 0) return(ret); - fprintf(stderr, "\n\n==== Test automatically, if all custom rational tags " - "are written/read correctly. ====\n"); - /* --- Test with Classic-TIFF ---*/ - /* delete file, if exists */ - ret = unlink(filenameClassicTiff); - errorNo = errno; - if (ret != 0 && errorNo != ENOENT) - { - fprintf(stderr, "Can't delete test TIFF file %s.\n", - filenameClassicTiff); - } - /* We write the main directory as a simple image. */ - tif = TIFFOpen(filenameClassicTiff, "w+"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", - filenameClassicTiff); - return 1; - } - fprintf(stderr, "-------- Test with ClassicTIFF started ----------\n"); - ret = write_test_tiff(tif, filenameClassicTiff, TRUE); - if (ret > 0) - return (ret); + fprintf(stderr, "\n\n==== Test automatically, if all custom rational tags are written/read correctly. ====\n"); + /* --- Test with Classic-TIFF ---*/ + /* delete file, if exists */ + ret = unlink(filenameClassicTiff); + errorNo = errno; + if (ret != 0 && errorNo != ENOENT) { + fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameClassicTiff); + } - /*--- Test with BIG-TIFF ---*/ - /* delete file, if exists */ - ret = unlink(filenameBigTiff); - if (ret != 0 && errno != ENOENT) - { - fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameBigTiff); - } + /* We write the main directory as a simple image. */ + tif = TIFFOpen(filenameClassicTiff, "w+"); + if (!tif) { + fprintf(stderr, "Can't create test TIFF file %s.\n", filenameClassicTiff); + return 1; + } + fprintf(stderr, "-------- Test with ClassicTIFF started ----------\n"); + ret = write_test_tiff(tif, filenameClassicTiff, TRUE); + if (ret > 0) return(ret); - tif = TIFFOpen(filenameBigTiff, "w8"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filenameBigTiff); - return 1; - } - fprintf(stderr, "\n-------- Test with BigTIFF started ----------\n"); - ret = write_test_tiff(tif, filenameBigTiff, TRUE); - return (ret); + /*--- Test with BIG-TIFF ---*/ + /* delete file, if exists */ + ret = unlink(filenameBigTiff); + if (ret != 0 && errno != ENOENT) { + fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameBigTiff); + } + + tif = TIFFOpen(filenameBigTiff, "w8"); + if (!tif) { + fprintf(stderr, "Can't create test TIFF file %s.\n", filenameBigTiff); + return 1; + } + fprintf(stderr, "\n-------- Test with BigTIFF started ----------\n"); + ret = write_test_tiff(tif, filenameBigTiff, TRUE); + return(ret); } /* main() */ -int write_test_tiff(TIFF *tif, const char *filenameRead, int blnAllCustomTags) -{ - unsigned char buf[SPP] = {0, 127, 255}; - /*-- Additional variables --*/ - int retCode; - float auxFloat = 0.0f; - double auxDouble = 0.0; - uint16_t auxUint16 = 0; - uint32_t auxUint32 = 0; - long auxLong = 0; - void *pVoid; - int blnIsRational2Double; - int i, j; - long nTags; - const TIFFFieldArray *tFieldArray; - unsigned long tTag; - TIFFDataType tType; - short tWriteCount; - TIFFSetGetFieldType tSetFieldType; - unsigned short tFieldBit; - const TIFFField *fip; - char *tFieldName; + +int +write_test_tiff(TIFF* tif, const char* filenameRead, int blnAllCustomTags) { + unsigned char buf[SPP] = {0, 127, 255}; + /*-- Additional variables --*/ + int retCode; + float auxFloat = 0.0f; + double auxDouble = 0.0; + uint16 auxUint16 = 0; + uint32 auxUint32 = 0; + long auxLong = 0; + void* pVoid; + int blnIsRational2Double; + + int i, j; + long nTags; + + const TIFFFieldArray* tFieldArray; + unsigned long tTag; + TIFFDataType tType; + short tWriteCount; + TIFFSetGetFieldType tSetFieldType; + unsigned short tFieldBit; + const TIFFField *fip; + char* tFieldName; + #define STRSIZE 1000 -#define N_SIZE 400 +#define N_SIZE 200 #define VARIABLE_ARRAY_SIZE 6 - /* -- Test data for writing -- */ - float auxFloatArrayW[N_SIZE]; - double auxDoubleArrayW[N_SIZE]; - char auxTextArrayW[N_SIZE][STRSIZE]; - float auxFloatArrayN1[3] = {1.0f / 7.0f, 61.23456789012345f, 62.3f}; - float auxFloatArrayResolutions[4] = {5.456789f, 6.666666f, 0.0033f, - 5.0f / 213.0f}; + /* -- Test data for writing -- */ + float auxFloatArrayW[N_SIZE]; + double auxDoubleArrayW[N_SIZE]; + char auxTextArrayW[N_SIZE][STRSIZE]; + float auxFloatArrayN1[3] = {1.0f / 7.0f, 61.23456789012345f, 62.3f}; + float auxFloatArrayResolutions[4] = {5.456789f, 6.666666f, 0.0033f, 5.0f / 213.0f}; - /* -- Variables for reading -- */ - uint16_t count16 = 0; - union - { - long Long; - short Short1; - short Short2[2]; - char Char[4]; - } auxLongUnion; - union - { - double dbl; - float flt1; - float flt2; - } auxDblUnion; + /* -- Variables for reading -- */ + uint16 count16 = 0; + union { + long Long; + short Short1; + short Short2[2]; + char Char[4]; + } auxLongUnion; + union { + double dbl; + float flt1; + float flt2; + } auxDblUnion; - void *pVoidArray; - float *pFloatArray; - float auxFloatArray[2 * N_SIZE]; - double auxDoubleArray[2 * N_SIZE]; - double dblDiff, dblDiffLimit; - float fltDiff; -#define RATIONAL_EPS \ - (1.0 / 30000.0) /* reduced difference of rational values, approx 3.3e-5 */ + void* pVoidArray; + float* pFloatArray; + float auxFloatArray[2 * N_SIZE]; + double auxDoubleArray[2 * N_SIZE]; + double dblDiff, dblDiffLimit; + float fltDiff; +#define RATIONAL_EPS (1.0/30000.0) /* reduced difference of rational values, approx 3.3e-5 */ - /*-- Fill test data arrays for writing ----------- */ - for (i = 0; i < N_SIZE; i++) - { - sprintf(auxTextArrayW[i], - "N%d-String-%d_tttttttttttttttttttttttttttttx", i, i); - } - for (i = 0; i < N_SIZE; i++) - { - auxFloatArrayW[i] = (float)((i + 1) * 133) / 3.3f; - } - for (i = 0; i < N_SIZE; i++) - { - auxDoubleArrayW[i] = (double)((i + 1) * 3689) / 4.5697; - } - /*-- Setup standard tags of a simple tiff file --*/ - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) - { - fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); - goto failure; - } + /*-- Fill test data arrays for writing ----------- */ + for (i = 0; i < N_SIZE; i++) { + sprintf(auxTextArrayW[i], "N%d-String-%d_tttttttttttttttttttttttttttttx", i, i); + } + for (i = 0; i < N_SIZE; i++) { + auxFloatArrayW[i] = (float)((i + 1) * 133) / 3.3f; + } + for (i = 0; i < N_SIZE; i++) { + auxDoubleArrayW[i] = (double)((i + 1) * 3689) / 4.5697; + } - /*--- Standard tags with TIFF_RATIONAL and TIFF_SETGET_DOUBLE to - TIFF_SETGET_FLOAT change. --- - * They can be written either using float or double but have to be read - using float. - -------------------------------------------------------------------------------------------- - */ - if (!TIFFSetField(tif, TIFFTAG_XRESOLUTION, auxFloatArrayResolutions[0])) - { - fprintf(stderr, "Can't set TIFFTAG_XRESOLUTION tag.\n"); - goto failure; - } - /* Test here the double input possibility */ - if (!TIFFSetField(tif, TIFFTAG_YRESOLUTION, - (double)auxFloatArrayResolutions[1])) - { - fprintf(stderr, "Can't set TIFFTAG_YRESOLUTION tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_XPOSITION, auxFloatArrayResolutions[2])) - { - fprintf(stderr, "Can't set TIFFTAG_XPOSITION tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_YPOSITION, auxFloatArrayResolutions[3])) - { - fprintf(stderr, "Can't set TIFFTAG_YPOSITION tag.\n"); - goto failure; - } + /*-- Setup standard tags of a simple tiff file --*/ + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf(stderr, "Can't set ImageWidth tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf(stderr, "Can't set ImageLength tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) { + fprintf(stderr, "Can't set BitsPerSample tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) { + fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) { + fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) { + fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) { + fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); + goto failure; + } - /*--- Some additional FIELD_CUSTOM tags to check standard interface ---*/ + /*--- Standard tags with TIFF_RATIONAL and TIFF_SETGET_DOUBLE to TIFF_SETGET_FLOAT change. --- + * They can be written either using float or double but have to be read using float. + -------------------------------------------------------------------------------------------- */ + if (!TIFFSetField(tif, TIFFTAG_XRESOLUTION, auxFloatArrayResolutions[0])) { + fprintf(stderr, "Can't set TIFFTAG_XRESOLUTION tag.\n"); + goto failure; + } + /* Test here the double input possibility */ + if (!TIFFSetField(tif, TIFFTAG_YRESOLUTION, (double)auxFloatArrayResolutions[1])) { + fprintf(stderr, "Can't set TIFFTAG_YRESOLUTION tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_XPOSITION, auxFloatArrayResolutions[2])) { + fprintf(stderr, "Can't set TIFFTAG_XPOSITION tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_YPOSITION, auxFloatArrayResolutions[3])) { + fprintf(stderr, "Can't set TIFFTAG_YPOSITION tag.\n"); + goto failure; + } - /*- TIFFTAG_INKSET is a SHORT parameter (TIFF_SHORT, TIFF_SETGET_UINT16) - * with field_bit=FIELD_CUSTOM !! -*/ - if (!TIFFSetField(tif, TIFFTAG_INKSET, 34)) - { - fprintf(stderr, "Can't set TIFFTAG_INKSET tag.\n"); - goto failure; - } + /*--- Some additional FIELD_CUSTOM tags to check standard interface ---*/ - /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter ( TIFF_FLOAT, - * TIFF_SETGET_FLOAT) with field_bit=FIELD_CUSTOM !! -*/ - /* - can be written with Double but has to be read with float parameter */ -#define PIXAR_FOVCOT_VAL 5.123456789123456789 - auxFloat = (float)PIXAR_FOVCOT_VAL; - /* if (!TIFFSetField(tif, TIFFTAG_PIXAR_FOVCOT, auxFloat )) { - fprintf (stderr, "Can't set TIFFTAG_PIXAR_FOVCOT tag.\n"); - goto failure; - } - */ - auxDouble = (double)PIXAR_FOVCOT_VAL; - if (!TIFFSetField(tif, TIFFTAG_PIXAR_FOVCOT, auxDouble)) - { - fprintf(stderr, "Can't set TIFFTAG_PIXAR_FOVCOT tag.\n"); - goto failure; - } - /*- TIFFTAG_STONITS is a DOUBLE parameter (TIFF_DOUBLE, TIFF_SETGET_DOUBLE) - *with field_bit=FIELD_CUSTOM! - *-- Unfortunately, TIFF_SETGET_DOUBLE is used for TIFF_RATIONAL but those - *have to be read with FLOAT !!! Only TIFFTAG_STONITS is a TIFF_DOUBLE, - *which has to be read as DOUBLE!! - */ + /*- TIFFTAG_INKSET is a SHORT parameter (TIFF_SHORT, TIFF_SETGET_UINT16) with field_bit=FIELD_CUSTOM !! -*/ + if (!TIFFSetField(tif, TIFFTAG_INKSET, 34)) { + fprintf(stderr, "Can't set TIFFTAG_INKSET tag.\n"); + goto failure; + } + + /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter ( TIFF_FLOAT, TIFF_SETGET_FLOAT) with field_bit=FIELD_CUSTOM !! -*/ + /* - can be written with Double but has to be read with float parameter */ +#define PIXAR_FOVCOT_VAL 5.123456789123456789 + auxFloat = (float)PIXAR_FOVCOT_VAL; + /* if (!TIFFSetField(tif, TIFFTAG_PIXAR_FOVCOT, auxFloat )) { + fprintf (stderr, "Can't set TIFFTAG_PIXAR_FOVCOT tag.\n"); + goto failure; + } + */ + auxDouble = (double)PIXAR_FOVCOT_VAL; + if (!TIFFSetField(tif, TIFFTAG_PIXAR_FOVCOT, auxDouble)) { + fprintf(stderr, "Can't set TIFFTAG_PIXAR_FOVCOT tag.\n"); + goto failure; + } + /*- TIFFTAG_STONITS is a DOUBLE parameter (TIFF_DOUBLE, TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! + *-- Unfortunately, TIFF_SETGET_DOUBLE is used for TIFF_RATIONAL but those have to be read with FLOAT !!! + * Only TIFFTAG_STONITS is a TIFF_DOUBLE, which has to be read as DOUBLE!! + */ #define STONITS_VAL 6.123456789123456789 - auxDouble = STONITS_VAL; - auxFloat = (float)auxDouble; - if (!TIFFSetField(tif, TIFFTAG_STONITS, auxDouble)) - { - fprintf(stderr, "Can't set TIFFTAG_STONITS tag.\n"); - goto failure; - } + auxDouble = STONITS_VAL; + auxFloat = (float)auxDouble; + if (!TIFFSetField(tif, TIFFTAG_STONITS, auxDouble)) { + fprintf(stderr, "Can't set TIFFTAG_STONITS tag.\n"); + goto failure; + } - /*-- Additional tags to check Rational standard tags, which are also defined - * with field_bit=FIELD_CUSTOM */ - /* - The following standard tags have field_type = TIFF_RATIONAL with - field_bit=FIELD_CUSTOM: TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, - TIFF_SETGET_DOUBLE TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, - TIFF_SETGET_DOUBLE TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, - TIFF_SETGET_DOUBLE TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, - TIFF_SETGET_DOUBLE TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, - TIFF_SETGET_DOUBLE TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, - TIFF_SETGET_DOUBLE TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, - TIFF_SETGET_DOUBLE and with Signed Rational: TIFFTAG_BASELINEEXPOSURE, 1, - 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE Due to the fact that - TIFFSetField() and TIFFGetField() interface is using va_args, variable - promotion is applied, which means: If the actual argument is of type - float, it is promoted to type double when function is to be made. - - Any signed or unsigned char, short, enumerated type, or bit field - is converted to either a signed or an unsigned int using integral - promotion. - - Any argument of class type is passed by value as a data structure; - the copy is created by binary copying instead of by invoking the class’s - copy constructor (if one exists). So, if your argument types are of float - type, you should expect the argument retrieved to be of type double and - it is char or short, you should expect it to be signed or unsigned int. - Otherwise, the code will give you wrong results. - */ - if (!blnAllCustomTags) - { -/*--- TEST: First tag is written with FLOAT and second tag is written with - * DOUBLE parameter ---*/ -/*- TIFFTAG_SHADOWSCALE is a Rational parameter (TIFF_RATIONAL, - * TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! -*/ -#define SHADOWSCALE_VAL 15.123456789123456789 - auxFloat = (float)SHADOWSCALE_VAL; - if (!TIFFSetField(tif, TIFFTAG_SHADOWSCALE, auxFloat)) - { - fprintf(stderr, "Can't set TIFFTAG_SHADOWSCALE tag.\n"); - goto failure; - } + /*-- Additional tags to check Rational standard tags, which are also defined with field_bit=FIELD_CUSTOM */ + /* + The following standard tags have field_type = TIFF_RATIONAL with field_bit=FIELD_CUSTOM: + TIFFTAG_BASELINENOISE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE + TIFFTAG_BASELINESHARPNESS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE + TIFFTAG_LINEARRESPONSELIMIT, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE + TIFFTAG_CHROMABLURRADIUS, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE + TIFFTAG_ANTIALIASSTRENGTH, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE + TIFFTAG_SHADOWSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE + TIFFTAG_BESTQUALITYSCALE, 1, 1, TIFF_RATIONAL, 0, TIFF_SETGET_DOUBLE + and with Signed Rational: + TIFFTAG_BASELINEEXPOSURE, 1, 1, TIFF_SRATIONAL, 0, TIFF_SETGET_DOUBLE + Due to the fact that TIFFSetField() and TIFFGetField() interface is using va_args, variable promotion is applied, + which means: + If the actual argument is of type float, it is promoted to type double when function is to be made. + - Any signed or unsigned char, short, enumerated type, or bit field is converted to either a signed or an unsigned int + using integral promotion. + - Any argument of class type is passed by value as a data structure; the copy is created by binary copying instead + of by invoking the class’s copy constructor (if one exists). + So, if your argument types are of float type, you should expect the argument retrieved to be of type double + and it is char or short, you should expect it to be signed or unsigned int. Otherwise, the code will give you wrong results. + */ -/*- TIFFTAG_BESTQUALITYSCALE is a Rational parameter (TIFF_RATIONAL, - * TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! -*/ -#define BESTQUALITYSCALE_VAL 17.123456789123456789 - auxDouble = BESTQUALITYSCALE_VAL; - if (!TIFFSetField(tif, TIFFTAG_BESTQUALITYSCALE, auxDouble)) - { - fprintf(stderr, "Can't set TIFFTAG_BESTQUALITYSCALE tag.\n"); - goto failure; - } + if (!blnAllCustomTags) { + /*--- TEST: First tag is written with FLOAT and second tag is written with DOUBLE parameter ---*/ + /*- TIFFTAG_SHADOWSCALE is a Rational parameter (TIFF_RATIONAL, TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! -*/ + #define SHADOWSCALE_VAL 15.123456789123456789 + auxFloat = (float)SHADOWSCALE_VAL; + if (!TIFFSetField(tif, TIFFTAG_SHADOWSCALE, auxFloat)) { + fprintf(stderr, "Can't set TIFFTAG_SHADOWSCALE tag.\n"); + goto failure; + } -/*- TIFFTAG_BASELINEEXPOSURE is a Rational parameter (TIFF_SRATIONAL, - * TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! -*/ -#define BASELINEEXPOSURE_VAL (-3.14159265358979323846) - /* - fprintf(stderr, "(-3.14159265358979323846) as float= %.18f, - double=%.18f\n", (float)BASELINEEXPOSURE_VAL, - (double)BASELINEEXPOSURE_VAL, BASELINEEXPOSURE_VAL); fprintf(stderr, - "(-3.141592742098056) as float= %.18f, double=%.18f\n", - (float)(-3.141592742098056), (double)(-3.141592742098056)); - */ - auxDouble = BASELINEEXPOSURE_VAL; - if (!TIFFSetField(tif, TIFFTAG_BASELINEEXPOSURE, auxDouble)) - { - fprintf(stderr, "Can't set TIFFTAG_BASELINEEXPOSURE tag.\n"); - goto failure; - } + /*- TIFFTAG_BESTQUALITYSCALE is a Rational parameter (TIFF_RATIONAL, TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! -*/ + #define BESTQUALITYSCALE_VAL 17.123456789123456789 + auxDouble = BESTQUALITYSCALE_VAL; + if (!TIFFSetField(tif, TIFFTAG_BESTQUALITYSCALE, auxDouble)) { + fprintf(stderr, "Can't set TIFFTAG_BESTQUALITYSCALE tag.\n"); + goto failure; + } - /*--- For static or variable ARRAYs the case is different ---*/ - /*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter - * TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable - * length of array. */ - if (!TIFFSetField(tif, TIFFTAG_DECODE, 3, auxFloatArrayN1)) - { /* for TIFF_SETGET_C16_DOUBLE */ - fprintf(stderr, "Can't set TIFFTAG_DECODE tag.\n"); - goto failure; - } + /*- TIFFTAG_BASELINEEXPOSURE is a Rational parameter (TIFF_SRATIONAL, TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! -*/ + #define BASELINEEXPOSURE_VAL (-3.14159265358979323846) + /* + fprintf(stderr, "(-3.14159265358979323846) as float= %.18f, double=%.18f\n", (float)BASELINEEXPOSURE_VAL, (double)BASELINEEXPOSURE_VAL, BASELINEEXPOSURE_VAL); + fprintf(stderr, "(-3.141592742098056) as float= %.18f, double=%.18f\n", (float)(-3.141592742098056), (double)(-3.141592742098056)); + */ + auxDouble = BASELINEEXPOSURE_VAL; + if (!TIFFSetField(tif, TIFFTAG_BASELINEEXPOSURE, auxDouble)) { + fprintf(stderr, "Can't set TIFFTAG_BASELINEEXPOSURE tag.\n"); + goto failure; + } - /*- Varable Array: TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT */ - if (!TIFFSetField(tif, TIFFTAG_BLACKLEVEL, 3, auxFloatArrayN1)) - { /* for TIFF_SETGET_C16_FLOAT */ - fprintf(stderr, "Can't set TIFFTAG_BLACKLEVEL tag.\n"); - goto failure; - } - /*-- Check, if the TiffLibrary is compiled with the new interface with - * Rational2Double or still uses the old definitions. */ - /* tags to check: TIFFTAG_BESTQUALITYSCALE, TIFFTAG_BASELINENOISE, - * TIFFTAG_BASELINESHARPNESS, */ - fip = TIFFFindField(tif, TIFFTAG_BESTQUALITYSCALE, TIFF_ANY); - tSetFieldType = fip->set_field_type; - if (tSetFieldType == TIFF_SETGET_DOUBLE) - blnIsRational2Double = FALSE; - else - blnIsRational2Double = TRUE; + /*--- For static or variable ARRAYs the case is different ---*/ - /*--- Write now additional Rational2Double test tags ---*/ - /*--- However, this additional tags are only written as Double - correctly, if blnIsRational2Double is defined! - ------------------------------------------------------*/ - if (blnIsRational2Double) - { - if (!TIFFSetField(tif, TIFFTAG_RATIONAL_DOUBLE, - auxDoubleArrayW[100])) - { - fprintf(stderr, "Can't set TIFFTAG_RATIONAL_DOUBLE tag.\n"); - goto failure; - } - /* test for plain integers */ - if (!TIFFSetField(tif, TIFFTAG_SRATIONAL_DOUBLE, (-1.0))) - { - fprintf(stderr, "Can't set TIFFTAG_SRATIONAL_DOUBLE tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_RATIONAL_C0_DOUBLE, - &auxDoubleArrayW[110])) - { - fprintf(stderr, "Can't set TIFFTAG_RATIONAL_C0_DOUBLE tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_SRATIONAL_C16_DOUBLE, 2, - &auxDoubleArrayW[120])) - { - fprintf(stderr, - "Can't set TIFFTAG_SRATIONAL_C16_DOUBLE tag.\n"); - goto failure; - } - } - } - else - { /* blnAllCustomTags */ - /*==== Automatically check all custom rational tags == WRITING ===*/ - /*-- Get array, where TIFF tag fields are defined --*/ - tFieldArray = _TIFFGetFields(); - nTags = tFieldArray->count; + /*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable length of array. */ + if (!TIFFSetField(tif, TIFFTAG_DECODE, 3, auxFloatArrayN1)) { /* for TIFF_SETGET_C16_DOUBLE */ + fprintf(stderr, "Can't set TIFFTAG_DECODE tag.\n"); + goto failure; + } - for (i = 0; i < nTags; i++) - { - tTag = tFieldArray->fields[i].field_tag; - tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ - tWriteCount = tFieldArray->fields[i].field_writecount; - tSetFieldType = tFieldArray->fields[i] - .set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ - tFieldBit = tFieldArray->fields[i].field_bit; - tFieldName = tFieldArray->fields[i].field_name; - pVoid = NULL; + /*- Varable Array: TIFF_RATIONAL, 0, TIFF_SETGET_C16_FLOAT */ + if (!TIFFSetField(tif, TIFFTAG_BLACKLEVEL, 3, auxFloatArrayN1)) { /* for TIFF_SETGET_C16_FLOAT */ + fprintf(stderr, "Can't set TIFFTAG_BLACKLEVEL tag.\n"); + goto failure; + } - if ((tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) && - tFieldBit == FIELD_CUSTOM) - { - /*-- dependent on set_field_type write value --*/ - switch (tSetFieldType) - { - case TIFF_SETGET_FLOAT: - case TIFF_SETGET_DOUBLE: - if (tWriteCount == 1) - { - /*-- All single values can be written with float or - * double parameter. Only value range should be in - * line. */ - if (!TIFFSetField(tif, tTag, auxDoubleArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - } - else - { - fprintf(stderr, - "WriteCount for .set_field_type %d should " - "be 1! %s\n", - tSetFieldType, - tFieldArray->fields[i].field_name); - } - break; - case TIFF_SETGET_C0_FLOAT: - case TIFF_SETGET_C0_DOUBLE: - case TIFF_SETGET_C16_FLOAT: - case TIFF_SETGET_C16_DOUBLE: - case TIFF_SETGET_C32_FLOAT: - case TIFF_SETGET_C32_DOUBLE: - /* _Cxx_ just defines the size of the count parameter - * for the array as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array - * or a variable array */ - if (tWriteCount == 1) - { - fprintf(stderr, - "WriteCount for .set_field_type %d should " - "be -1 or greather than 1! %s\n", - tSetFieldType, - tFieldArray->fields[i].field_name); - } - else - { - /*-- Either fix or variable array --*/ - /* For arrays, distinguishing between float or - * double is essential, even for writing */ - if (tSetFieldType == TIFF_SETGET_C0_FLOAT || - tSetFieldType == TIFF_SETGET_C16_FLOAT || - tSetFieldType == TIFF_SETGET_C32_FLOAT) - pVoid = &auxFloatArrayW[i]; - else - pVoid = &auxDoubleArrayW[i]; - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) - { - /* fixed array with needed arraysize defined in - * .field_writecount */ - if (!TIFFSetField(tif, tTag, pVoid)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - } - else - { - /* special treatment of variable array */ - /* for test, use always arraysize of - * VARIABLE_ARRAY_SIZE */ - if (!TIFFSetField(tif, tTag, - VARIABLE_ARRAY_SIZE, pVoid)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[i].field_name); - goto failure; - } - } - } - break; - default: - fprintf(stderr, - "SetFieldType %d not defined within writing " - "switch for %s.\n", - tSetFieldType, tFieldName); - }; /*-- switch() --*/ - } /* if () */ - } /*-- for() --*/ - } /* blnAllCustomTags */ /*==== END END - Automatically check all custom - rational tags == WRITING END ===*/ + /*-- Check, if the TiffLibrary is compiled with the new interface with Rational2Double or still uses the old definitions. */ + /* tags to check: TIFFTAG_BESTQUALITYSCALE, TIFFTAG_BASELINENOISE, TIFFTAG_BASELINESHARPNESS, */ + fip = TIFFFindField(tif, TIFFTAG_BESTQUALITYSCALE, TIFF_ANY); + tSetFieldType = fip->set_field_type; + if (tSetFieldType == TIFF_SETGET_DOUBLE) + blnIsRational2Double = FALSE; + else + blnIsRational2Double = TRUE; - /*-- Write dummy pixel data. --*/ - if (TIFFWriteScanline(tif, buf, 0, 0) < 0) - { - fprintf(stderr, "Can't write image data.\n"); - goto failure; - } + /*--- Write now additional Rational2Double test tags ---*/ + /*--- However, this additional tags are only written as Double correctly, + if blnIsRational2Double is defined! + ------------------------------------------------------*/ + if (blnIsRational2Double) { + if (!TIFFSetField(tif, TIFFTAG_RATIONAL_DOUBLE, auxDoubleArrayW[100])) { + fprintf(stderr, "Can't set TIFFTAG_RATIONAL_DOUBLE tag.\n"); + goto failure; + } + /* test for plain integers */ + if (!TIFFSetField(tif, TIFFTAG_SRATIONAL_DOUBLE, (-1.0 ))) { + fprintf(stderr, "Can't set TIFFTAG_SRATIONAL_DOUBLE tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_RATIONAL_C0_DOUBLE, &auxDoubleArrayW[110])) { + fprintf(stderr, "Can't set TIFFTAG_RATIONAL_C0_DOUBLE tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SRATIONAL_C16_DOUBLE, 2, &auxDoubleArrayW[120])) { + fprintf(stderr, "Can't set TIFFTAG_SRATIONAL_C16_DOUBLE tag.\n"); + goto failure; + } + } - /*-- Write directory to file --*/ - /* Always WriteDirectory before using/creating another directory. */ - /* Not necessary before TIFFClose(), however, TIFFClose() uses - * TIFFReWriteDirectory(), which forces directory to be written at another - * location. */ - retCode = TIFFWriteDirectory(tif); + } else { /* blnAllCustomTags */ + /*==== Automatically check all custom rational tags == WRITING ===*/ + /*-- Get array, where TIFF tag fields are defined --*/ + tFieldArray = _TIFFGetFields(); + nTags = tFieldArray->count; - /*-- Write File to disk and close file --*/ - /* TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be - * written at another location. */ - /* Therefore, better use TIFFWriteDirectory() before. */ - TIFFClose(tif); + for (i = 0; i < nTags; i++) { + tTag = tFieldArray->fields[i].field_tag; + tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ + tWriteCount = tFieldArray->fields[i].field_writecount; + tSetFieldType = tFieldArray->fields[i].set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ + tFieldBit = tFieldArray->fields[i].field_bit; + tFieldName = tFieldArray->fields[i].field_name; + pVoid = NULL; - fprintf(stderr, "-------- Continue Test ---------- reading ...\n"); + if (tType == TIFF_RATIONAL && tFieldBit == FIELD_CUSTOM) { + /*-- dependent on set_field_type write value --*/ + switch (tSetFieldType) { + case TIFF_SETGET_FLOAT: + case TIFF_SETGET_DOUBLE: + if (tWriteCount == 1) { + /*-- All single values can be written with float or double parameter. Only value range should be in line. */ + if (!TIFFSetField(tif, tTag, auxDoubleArrayW[i])) { + fprintf(stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + } else { + fprintf(stderr, "WriteCount for .set_field_type %d should be 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + } + break; + case TIFF_SETGET_C0_FLOAT: + case TIFF_SETGET_C0_DOUBLE: + case TIFF_SETGET_C16_FLOAT: + case TIFF_SETGET_C16_DOUBLE: + case TIFF_SETGET_C32_FLOAT: + case TIFF_SETGET_C32_DOUBLE: + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf(stderr, "WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + } else { + /*-- Either fix or variable array --*/ + /* For arrays, distinguishing between float or double is essential, even for writing */ + if (tSetFieldType == TIFF_SETGET_C0_FLOAT || tSetFieldType == TIFF_SETGET_C16_FLOAT || tSetFieldType == TIFF_SETGET_C32_FLOAT) + pVoid = &auxFloatArrayW[i]; else pVoid = &auxDoubleArrayW[i]; + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFSetField(tif, tTag, pVoid)) { + fprintf(stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + } else { + /* special treatment of variable array */ + /* for test, use always arraysize of VARIABLE_ARRAY_SIZE */ + if (!TIFFSetField(tif, tTag, VARIABLE_ARRAY_SIZE, pVoid)) { + fprintf(stderr, "Can't write %s\n", tFieldArray->fields[i].field_name); + goto failure; + } + } + } + break; + default: + fprintf(stderr, "SetFieldType %d not defined within writing switch for %s.\n", tSetFieldType, tFieldName); + }; /*-- switch() --*/ + } /* if () */ + } /*-- for() --*/ + } /* blnAllCustomTags */ /*==== END END - Automatically check all custom rational tags == WRITING END ===*/ - /*========================= READING ============= READING - * ========================================*/ - /* Ok, now test whether we can read written values in the EXIF directory. */ - tif = TIFFOpen(filenameRead, "r"); + /*-- Write dummy pixel data. --*/ + if (TIFFWriteScanline(tif, buf, 0, 0) < 0) { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } - /*-- Read some parameters out of the main directory --*/ + /*-- Write directory to file --*/ + /* Always WriteDirectory before using/creating another directory. */ + /* Not necessary before TIFFClose(), however, TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be written at another location. */ + retCode = TIFFWriteDirectory(tif); - /*-- IMAGEWIDTH and -LENGTH are defined as TIFF_SETGET_UINT32 */ - retCode = TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &auxUint32); - if (auxUint32 != width) - { - fprintf(stderr, - "Read value of IMAGEWIDTH %d differs from set value %d\n", - auxUint32, width); - GOTOFAILURE - } - retCode = TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &auxUint32); - if (auxUint32 != width) - { - fprintf( - stderr, - "Read value of TIFFTAG_IMAGELENGTH %d differs from set value %d\n", - auxUint32, length); - GOTOFAILURE - } + /*-- Write File to disk and close file --*/ + /* TIFFClose() uses TIFFReWriteDirectory(), which forces directory to be written at another location. */ + /* Therefore, better use TIFFWriteDirectory() before. */ + TIFFClose(tif); - /*--- Standard tags with TIFF_RATIONAL and TIFF_SETGET_DOUBLE to - TIFF_SETGET_FLOAT change. --- - * They can be written either using float or double but have to be read - using float. - -------------------------------------------------------------------------------------------- - */ - dblDiffLimit = RATIONAL_EPS; - retCode = TIFFGetField(tif, TIFFTAG_XRESOLUTION, &auxFloat); - dblDiff = auxFloat - auxFloatArrayResolutions[0]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf( - stderr, - "Read value of TIFFTAG_XRESOLUTION %f differs from set value %f\n", - auxFloat, auxFloatArrayResolutions[0]); - GOTOFAILURE - } - retCode = TIFFGetField(tif, TIFFTAG_YRESOLUTION, &auxFloat); - dblDiff = auxFloat - auxFloatArrayResolutions[1]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf( - stderr, - "Read value of TIFFTAG_YRESOLUTION %f differs from set value %f\n", - auxFloat, auxFloatArrayResolutions[1]); - GOTOFAILURE - } - retCode = TIFFGetField(tif, TIFFTAG_XPOSITION, &auxFloat); - dblDiff = auxFloat - auxFloatArrayResolutions[2]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf( - stderr, - "Read value of TIFFTAG_XPOSITION %f differs from set value %f\n", - auxFloat, auxFloatArrayResolutions[2]); - GOTOFAILURE - } - retCode = TIFFGetField(tif, TIFFTAG_YPOSITION, &auxFloat); - dblDiff = auxFloat - auxFloatArrayResolutions[3]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf( - stderr, - "Read value of TIFFTAG_YPOSITION %f differs from set value %f\n", - auxFloat, auxFloatArrayResolutions[3]); - GOTOFAILURE - } + fprintf (stderr, "-------- Continue Test ---------- reading ...\n"); - /*- TIFFTAG_INKSET is a SHORT parameter (TIFF_SHORT, TIFF_SETGET_UINT16) - * with field_bit=FIELD_CUSTOM !! -*/ - retCode = TIFFGetField(tif, TIFFTAG_INKSET, &auxUint16); - if (auxUint16 != 34) - { - fprintf( - stderr, - "Read value of TIFFTAG_PIXAR_FOVCOT %d differs from set value %d\n", - auxUint16, TIFFTAG_INKSET); - GOTOFAILURE - } +/*========================= READING ============= READING ========================================*/ + /* Ok, now test whether we can read written values in the EXIF directory. */ + tif = TIFFOpen(filenameRead, "r"); - /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter ( TIFF_FLOAT, - * TIFF_SETGET_FLOAT) with field_bit=FIELD_CUSTOM !! -*/ - /* - was written with Double but has to be read with Float */ - retCode = TIFFGetField(tif, TIFFTAG_PIXAR_FOVCOT, &auxFloat); - if (auxFloat != (float)PIXAR_FOVCOT_VAL) - { - fprintf( - stderr, - "Read value of TIFFTAG_PIXAR_FOVCOT %f differs from set value %f\n", - auxFloat, PIXAR_FOVCOT_VAL); - GOTOFAILURE - } - /*- TIFFTAG_STONITS is a DOUBLE parameter (TIFF_DOUBLE, TIFF_SETGET_DOUBLE) - * with field_bit=FIELD_CUSTOM!! -*/ - retCode = TIFFGetField(tif, TIFFTAG_STONITS, &auxDouble); - if (auxDouble != (double)STONITS_VAL) - { - fprintf(stderr, - "Read value of TIFFTAG_STONITS %f differs from set value %f\n", - auxDouble, STONITS_VAL); - GOTOFAILURE - } + /*-- Read some parameters out of the main directory --*/ - /*-- Check, if the TiffLibrary is compiled with the new interface with - * Rational2Double or still uses the old definitions. */ - /* tags to check: TIFFTAG_BESTQUALITYSCALE, TIFFTAG_BASELINENOISE, - * TIFFTAG_BASELINESHARPNESS, */ - fip = TIFFFindField(tif, TIFFTAG_BESTQUALITYSCALE, TIFF_ANY); - tSetFieldType = fip->set_field_type; - if (tSetFieldType == TIFF_SETGET_DOUBLE) - blnIsRational2Double = FALSE; - else - blnIsRational2Double = TRUE; + /*-- IMAGEWIDTH and -LENGTH are defined as TIFF_SETGET_UINT32 */ + retCode = TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &auxUint32 ); + if (auxUint32 != width) { + fprintf (stderr, "Read value of IMAGEWIDTH %d differs from set value %d\n", auxUint32, width); + GOTOFAILURE + } + retCode = TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &auxUint32 ); + if (auxUint32 != width) { + fprintf (stderr, "Read value of TIFFTAG_IMAGELENGTH %d differs from set value %d\n", auxUint32, length); + GOTOFAILURE + } - if (!blnAllCustomTags) - { + /*--- Standard tags with TIFF_RATIONAL and TIFF_SETGET_DOUBLE to TIFF_SETGET_FLOAT change. --- + * They can be written either using float or double but have to be read using float. + -------------------------------------------------------------------------------------------- */ + dblDiffLimit = RATIONAL_EPS; + retCode = TIFFGetField(tif, TIFFTAG_XRESOLUTION, &auxFloat); + dblDiff = auxFloat - auxFloatArrayResolutions[0]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value of TIFFTAG_XRESOLUTION %f differs from set value %f\n", auxFloat, auxFloatArrayResolutions[0]); + GOTOFAILURE + } + retCode = TIFFGetField(tif, TIFFTAG_YRESOLUTION, &auxFloat); + dblDiff = auxFloat - auxFloatArrayResolutions[1]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value of TIFFTAG_YRESOLUTION %f differs from set value %f\n", auxFloat, auxFloatArrayResolutions[1]); + GOTOFAILURE + } + retCode = TIFFGetField(tif, TIFFTAG_XPOSITION, &auxFloat); + dblDiff = auxFloat - auxFloatArrayResolutions[2]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value of TIFFTAG_XPOSITION %f differs from set value %f\n", auxFloat, auxFloatArrayResolutions[2]); + GOTOFAILURE + } + retCode = TIFFGetField(tif, TIFFTAG_YPOSITION, &auxFloat); + dblDiff = auxFloat - auxFloatArrayResolutions[3]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value of TIFFTAG_YPOSITION %f differs from set value %f\n", auxFloat, auxFloatArrayResolutions[3]); + GOTOFAILURE + } - /*- TIFFTAG_BESTQUALITYSCALE is a Rational parameter (TIFF_RATIONAL, - TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! and written with - double parameter -*/ - /*- Read into a union to test the correct precision (float or double) - * returned. Float-parameter should be correct, but double-parameter - * should give a wrong value - */ - auxDblUnion.dbl = 0; - retCode = TIFFGetField(tif, TIFFTAG_BESTQUALITYSCALE, &auxDblUnion.dbl); - dblDiffLimit = RATIONAL_EPS * (double)BESTQUALITYSCALE_VAL; - dblDiff = auxDblUnion.dbl - (double)BESTQUALITYSCALE_VAL; - fltDiff = auxDblUnion.flt1 - (float)BESTQUALITYSCALE_VAL; - if (!((fabs(dblDiff) > fabs(dblDiffLimit)) && - !(fabs(fltDiff) > fabs(dblDiffLimit)))) - { - fprintf(stderr, - "Float-Read value of TIFFTAG_BESTQUALITYSCALE %.12f " - "differs from set value %.12f too much,\n", - auxDblUnion.flt1, BESTQUALITYSCALE_VAL); - fprintf(stderr, - "whereas Double-Read value of TIFFTAG_BESTQUALITYSCALE " - "%.12f is nearly equal to set value %.12f\n", - auxDblUnion.dbl, BESTQUALITYSCALE_VAL); - GOTOFAILURE - } - /*--- Now the same for a Signed Rational ---*/ - /*- TIFFTAG_BASELINEEXPOSURE is a Rational parameter (TIFF_SRATIONAL, - TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! - and written with - double parameter - */ - /*- Read into a union to test the correct precision (float or double) - * returned. Float-parameter should be correct, but double-parameter - * should give a wrong value - */ - auxDblUnion.dbl = 0; - retCode = TIFFGetField(tif, TIFFTAG_BASELINEEXPOSURE, &auxDblUnion.dbl); - dblDiffLimit = RATIONAL_EPS * (double)BASELINEEXPOSURE_VAL; - dblDiff = auxDblUnion.dbl - (double)BASELINEEXPOSURE_VAL; - fltDiff = auxDblUnion.flt1 - (float)BASELINEEXPOSURE_VAL; - if (!((fabs(dblDiff) > fabs(dblDiffLimit)) && - !(fabs(fltDiff) > fabs(dblDiffLimit)))) - { - fprintf(stderr, - "Float-Read value of TIFFTAG_BASELINEEXPOSURE %.12f " - "differs from set value %.12f too much,\n", - auxDblUnion.flt1, BASELINEEXPOSURE_VAL); - fprintf(stderr, - "whereas Double-Read value of TIFFTAG_BESTQUALITYSCALE " - "%.12f is nearly equal to set value %.12f\n", - auxDblUnion.dbl, BASELINEEXPOSURE_VAL); - GOTOFAILURE - } + /*- TIFFTAG_INKSET is a SHORT parameter (TIFF_SHORT, TIFF_SETGET_UINT16) with field_bit=FIELD_CUSTOM !! -*/ + retCode = TIFFGetField(tif, TIFFTAG_INKSET, &auxUint16); + if (auxUint16 != 34) { + fprintf(stderr, "Read value of TIFFTAG_PIXAR_FOVCOT %d differs from set value %d\n", auxUint16, TIFFTAG_INKSET); + GOTOFAILURE + } - /*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter - * TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable - * length of array. */ - retCode = TIFFGetField(tif, TIFFTAG_DECODE, &count16, &pVoidArray); - retCode = TIFFGetField(tif, TIFFTAG_DECODE, &count16, &pFloatArray); - /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, - * contents needs to be saved. */ - memcpy(&auxFloatArray, pVoidArray, - (count16 * sizeof(auxFloatArray[0]))); - for (i = 0; i < count16; i++) - { - dblDiffLimit = RATIONAL_EPS * auxFloatArrayN1[i]; - dblDiff = auxFloatArray[i] - auxFloatArrayN1[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of TIFFTAG_DECODE Array %f differs from " - "set value %f\n", - i, auxFloatArray[i], auxFloatArrayN1[i]); - GOTOFAILURE - } - } + /*- TIFFTAG_PIXAR_FOVCOT is a FLOAT parameter ( TIFF_FLOAT, TIFF_SETGET_FLOAT) with field_bit=FIELD_CUSTOM !! -*/ + /* - was written with Double but has to be read with Float */ + retCode = TIFFGetField(tif, TIFFTAG_PIXAR_FOVCOT, &auxFloat ); + if (auxFloat != (float)PIXAR_FOVCOT_VAL) { + fprintf (stderr, "Read value of TIFFTAG_PIXAR_FOVCOT %f differs from set value %f\n", auxFloat, PIXAR_FOVCOT_VAL); + GOTOFAILURE + } - retCode = TIFFGetField(tif, TIFFTAG_BLACKLEVEL, &count16, &pVoidArray); - /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, - * contents needs to be saved. */ - memcpy(&auxFloatArray, pVoidArray, - (count16 * sizeof(auxFloatArray[0]))); - for (i = 0; i < count16; i++) - { - dblDiffLimit = RATIONAL_EPS * auxFloatArrayN1[i]; - dblDiff = auxFloatArray[i] - auxFloatArrayN1[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of TIFFTAG_BLACKLEVEL Array %f differs " - "from set value %f\n", - i, auxFloatArray[i], auxFloatArrayN1[i]); - GOTOFAILURE - } - } + /*- TIFFTAG_STONITS is a DOUBLE parameter (TIFF_DOUBLE, TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM!! -*/ + retCode = TIFFGetField(tif, TIFFTAG_STONITS, &auxDouble); + if (auxDouble != (double)STONITS_VAL) { + fprintf(stderr, "Read value of TIFFTAG_STONITS %f differs from set value %f\n", auxDouble, STONITS_VAL); + GOTOFAILURE + } - /*--- Read now additional Rational2Double test tags --- - This should be now with nearly double precision - However, this additional tags are only read as Double, - if blnIsRational2Double is defined! - ------------------------------------------------------*/ - if (blnIsRational2Double) - { - auxDblUnion.dbl = 0; - retCode = - TIFFGetField(tif, TIFFTAG_RATIONAL_DOUBLE, &auxDblUnion.dbl); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_RATIONAL_DOUBLE"); - GOTOFAILURE - } - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[100]; - dblDiff = auxDblUnion.dbl - auxDoubleArrayW[100]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value of TIFFTAG_RATIONAL_DOUBLE %f differs from " - "set value %f\n", - auxDblUnion.dbl, auxDoubleArrayW[100]); - GOTOFAILURE - } - auxDblUnion.dbl = 0; - retCode = - TIFFGetField(tif, TIFFTAG_SRATIONAL_DOUBLE, &auxDblUnion.dbl); - if (!retCode) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_SRATIONAL_DOUBLE"); - GOTOFAILURE - } - auxDouble = -1.0; - dblDiffLimit = RATIONAL_EPS * auxDouble; - dblDiff = auxDblUnion.dbl - auxDouble; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value of TIFFTAG_SRATIONAL_DOUBLE %f differs " - "from set value %f\n", - auxDblUnion.dbl, auxDouble); - GOTOFAILURE - } - /*- Fixed Array: TIFFTAG_RATIONAL_C0_DOUBLE, 3, 3, TIFF_RATIONAL, 0, - * TIFF_SETGET_C0_DOUBLE */ - count16 = 3; /* set fixed array length for checking */ - retCode = - TIFFGetField(tif, TIFFTAG_RATIONAL_C0_DOUBLE, &pVoidArray); - /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, - * contents needs to be saved. */ - memcpy(&auxDoubleArray, pVoidArray, - (count16 * sizeof(auxDoubleArray[0]))); - for (i = 0; i < count16; i++) - { - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[110 + i]; - dblDiff = auxDoubleArray[i] - auxDoubleArrayW[110 + i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of TIFFTAG_RATIONAL_C0_DOUBLE Array " - "%f differs from set value %f\n", - i, auxDoubleArray[i], auxDoubleArrayW[110 + i]); - GOTOFAILURE - } - } - /*- Variable Array: TIFFTAG_SRATIONAL_C16_DOUBLE, -1, -1, - * TIFF_SRATIONAL, 0, TIFF_SETGET_C16_DOUBLE */ - retCode = TIFFGetField(tif, TIFFTAG_SRATIONAL_C16_DOUBLE, &count16, - &pVoidArray); - /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, - * contents needs to be saved. */ - memcpy(&auxDoubleArray, pVoidArray, - (count16 * sizeof(auxDoubleArray[0]))); - for (i = 0; i < count16; i++) - { - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[120 + i]; - dblDiff = auxDoubleArray[i] - auxDoubleArrayW[120 + i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of TIFFTAG_SRATIONAL_C16_DOUBLE " - "Array %f differs from set value %f\n", - i, auxDoubleArray[i], auxDoubleArrayW[120 + i]); - GOTOFAILURE - } - } - } - } - else - { /* blnAllCustomTags */ - /*==== Automatically check all custom rational tags == READING ===*/ + /*-- Check, if the TiffLibrary is compiled with the new interface with Rational2Double or still uses the old definitions. */ + /* tags to check: TIFFTAG_BESTQUALITYSCALE, TIFFTAG_BASELINENOISE, TIFFTAG_BASELINESHARPNESS, */ + fip = TIFFFindField(tif, TIFFTAG_BESTQUALITYSCALE, TIFF_ANY); + tSetFieldType = fip->set_field_type; + if (tSetFieldType == TIFF_SETGET_DOUBLE) + blnIsRational2Double = FALSE; + else + blnIsRational2Double = TRUE; - /*-- Get array, where standard TIFF tag fields are defined --*/ - tFieldArray = _TIFFGetFields(); - nTags = tFieldArray->count; - for (i = 0; i < nTags; i++) - { - tTag = tFieldArray->fields[i].field_tag; - tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ - tWriteCount = tFieldArray->fields[i].field_writecount; - tSetFieldType = tFieldArray->fields[i] - .set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ - tFieldBit = tFieldArray->fields[i].field_bit; - tFieldName = tFieldArray->fields[i].field_name; - pVoid = NULL; - auxDblUnion.dbl = 0; + if (!blnAllCustomTags) { - if ((tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) && - tFieldBit == FIELD_CUSTOM) - { - /*-- dependent on set_field_type read value --*/ - switch (tSetFieldType) - { - case TIFF_SETGET_FLOAT: - if (!TIFFGetField(tif, tTag, &auxFloat)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE - break; - } - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - dblDiff = auxFloat - auxDoubleArrayW[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value - * of "-1.0" if numerator equals 4294967295 - * (0xFFFFFFFF) to indicate infinite distance! - * However, there are two other EXIF tags where - * numerator indicates a special value and six other - * cases where the denominator indicates special - * values, which are not treated within LibTiff!! - */ - if (!(tTag == EXIFTAG_SUBJECTDISTANCE && - auxFloat == -1.0)) - { - fprintf(stderr, - "%d:Read value of %s %f differs from " - "set value %f\n", - i, tFieldName, auxFloat, - auxDoubleArrayW[i]); - GOTOFAILURE - } - } - break; - case TIFF_SETGET_DOUBLE: - /*-- Unfortunately, TIFF_SETGET_DOUBLE is used for - * TIFF_RATIONAL but those have to be read with FLOAT - * !!! */ - /* Only after update with Rational2Double feature, - * also TIFF_RATIONAL can be read in double precision!!! - */ - /* Therefore, use a union to avoid overflow in - * TIFFGetField() return value and depending on version - * check for the right interface here: - * - old interface: correct value should be here a - * float - * - new interface: correct value should be here a - * double Interface version (old/new) is determined - * above. - */ - if (!TIFFGetField(tif, tTag, &auxDblUnion.dbl)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE - break; - } - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - { - if (blnIsRational2Double) - { - /* New interface allows also double precision - * for TIFF_RATIONAL */ - auxDouble = auxDblUnion.dbl; - } - else - { - /* Old interface reads TIFF_RATIONAL defined as - * TIFF_SETGET_DOUBLE alwasy as FLOAT */ - auxDouble = (double)auxDblUnion.flt1; - } - } - else - { - auxDouble = auxDblUnion.dbl; - } - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - dblDiff = auxDouble - auxDoubleArrayW[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value - * of "-1.0" if numerator equals 4294967295 - * (0xFFFFFFFF) to indicate infinite distance! */ - if (!(tTag == EXIFTAG_SUBJECTDISTANCE && - auxDouble == -1.0)) - { - fprintf(stderr, - "%d:Read value of %s %f differs from " - "set value %f\n", - i, tFieldName, auxDouble, - auxDoubleArrayW[i]); - GOTOFAILURE - } - } - break; + /*- TIFFTAG_BESTQUALITYSCALE is a Rational parameter (TIFF_RATIONAL, TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! + and written with double parameter -*/ + /*- Read into a union to test the correct precision (float or double) returned. + * Float-parameter should be correct, but double-parameter should give a wrong value + */ + auxDblUnion.dbl = 0; + retCode = TIFFGetField(tif, TIFFTAG_BESTQUALITYSCALE, &auxDblUnion.dbl); + dblDiffLimit = RATIONAL_EPS * (double)BESTQUALITYSCALE_VAL; + dblDiff = auxDblUnion.dbl - (double)BESTQUALITYSCALE_VAL; + fltDiff = auxDblUnion.flt1 - (float)BESTQUALITYSCALE_VAL; + if (!((fabs(dblDiff) > fabs(dblDiffLimit)) && !(fabs(fltDiff) > fabs(dblDiffLimit)))) { + fprintf(stderr, "Float-Read value of TIFFTAG_BESTQUALITYSCALE %.12f differs from set value %.12f too much,\n", auxDblUnion.flt1, BESTQUALITYSCALE_VAL); + fprintf(stderr, "whereas Double-Read value of TIFFTAG_BESTQUALITYSCALE %.12f is nearly equal to set value %.12f\n", auxDblUnion.dbl, BESTQUALITYSCALE_VAL); + GOTOFAILURE + } - case TIFF_SETGET_C0_FLOAT: - case TIFF_SETGET_C0_DOUBLE: - case TIFF_SETGET_C16_FLOAT: - case TIFF_SETGET_C16_DOUBLE: - case TIFF_SETGET_C32_FLOAT: - case TIFF_SETGET_C32_DOUBLE: - /* _Cxx_ just defines the size of the count parameter - * for the array as C0=char, C16=short or C32=long */ - /*-- Check, if it is a single parameter, a fixed array - * or a variable array */ - if (tWriteCount == 1) - { - fprintf(stderr, - "Reading: WriteCount for .set_field_type " - "%d should be -1 or greather than 1! %s\n", - tSetFieldType, - tFieldArray->fields[i].field_name); - GOTOFAILURE - } - else - { - /*-- Either fix or variable array --*/ - /* For arrays, distinguishing between float or - * double is essential. */ - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) - { - /* fixed array with needed arraysize defined in - * .field_writecount */ - if (!TIFFGetField(tif, tTag, &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE - break; - } - /* set tWriteCount to number of read samples for - * next steps */ - auxLong = tWriteCount; - } - else - { - /* Special treatment of variable array. */ - /* Dependent on Cxx, the count parameter is - * char, short or long. Therefore use unionLong! - */ - if (!TIFFGetField(tif, tTag, &auxLongUnion, - &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[i].field_name); - GOTOFAILURE - break; - } - /* set tWriteCount to number of read samples for - * next steps */ - auxLong = auxLongUnion.Short1; - } - /* Save values from temporary array */ - if (tSetFieldType == TIFF_SETGET_C0_FLOAT || - tSetFieldType == TIFF_SETGET_C16_FLOAT || - tSetFieldType == TIFF_SETGET_C32_FLOAT) - { - memcpy(&auxFloatArray, pVoidArray, - (auxLong * sizeof(auxFloatArray[0]))); - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || - tType == TIFF_SRATIONAL) - dblDiffLimit = - RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - for (j = 0; j < auxLong; j++) - { - dblDiff = auxFloatArray[j] - - auxFloatArrayW[i + j]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*if (auxFloatArray[j] != - * (float)auxFloatArrayW[i+j]) { */ - fprintf(stderr, - "Read value %d of %s #%d %f " - "differs from set value %f\n", - i, tFieldName, j, - auxFloatArray[j], - auxFloatArrayW[i + j]); - GOTOFAILURE - } - } - } - else - { - memcpy(&auxDoubleArray, pVoidArray, - (auxLong * sizeof(auxDoubleArray[0]))); - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || - tType == TIFF_SRATIONAL) - dblDiffLimit = - RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - for (j = 0; j < auxLong; j++) - { - dblDiff = auxDoubleArray[j] - - auxDoubleArrayW[i + j]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*if (auxDoubleArray[j] != - * auxDoubleArrayW[i+j]) { */ - fprintf(stderr, - "Read value %d of %s #%d %f " - "differs from set value %f\n", - i, tFieldName, j, - auxDoubleArray[j], - auxDoubleArrayW[i + j]); - GOTOFAILURE - } - } - } - } - break; - default: - fprintf(stderr, - "SetFieldType %d not defined within reading " - "switch for %s.\n", - tSetFieldType, tFieldName); - }; /*-- switch() --*/ - } /* if () */ - } /*-- for() --*/ + /*--- Now the same for a Signed Rational ---*/ + /*- TIFFTAG_BASELINEEXPOSURE is a Rational parameter (TIFF_SRATIONAL, TIFF_SETGET_DOUBLE) with field_bit=FIELD_CUSTOM! - + and written with double parameter - */ + /*- Read into a union to test the correct precision (float or double) returned. + * Float-parameter should be correct, but double-parameter should give a wrong value + */ + auxDblUnion.dbl = 0; + retCode = TIFFGetField(tif, TIFFTAG_BASELINEEXPOSURE, &auxDblUnion.dbl); + dblDiffLimit = RATIONAL_EPS * (double)BASELINEEXPOSURE_VAL; + dblDiff = auxDblUnion.dbl - (double)BASELINEEXPOSURE_VAL; + fltDiff = auxDblUnion.flt1 - (float)BASELINEEXPOSURE_VAL; + if (!((fabs(dblDiff) > fabs(dblDiffLimit)) && !(fabs(fltDiff) > fabs(dblDiffLimit)))) { + fprintf(stderr, "Float-Read value of TIFFTAG_BASELINEEXPOSURE %.12f differs from set value %.12f too much,\n", auxDblUnion.flt1, BASELINEEXPOSURE_VAL); + fprintf(stderr, "whereas Double-Read value of TIFFTAG_BESTQUALITYSCALE %.12f is nearly equal to set value %.12f\n", auxDblUnion.dbl, BASELINEEXPOSURE_VAL); + GOTOFAILURE + } - } /* blnAllCustomTags */ /*==== END END - Automatically check all custom - rational tags == READING END ===*/ + /*- Variable Array: TIFFTAG_DECODE is a SRATIONAL parameter TIFF_SETGET_C16_FLOAT type FIELD_CUSTOM with passcount=1 and variable length of array. */ + retCode = TIFFGetField(tif, TIFFTAG_DECODE, &count16, &pVoidArray); + retCode = TIFFGetField(tif, TIFFTAG_DECODE, &count16, &pFloatArray); + /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */ + memcpy(&auxFloatArray, pVoidArray, (count16 * sizeof(auxFloatArray[0]))); + for (i = 0; i < count16; i++) { + dblDiffLimit = RATIONAL_EPS * auxFloatArrayN1[i]; + dblDiff = auxFloatArray[i] - auxFloatArrayN1[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value %d of TIFFTAG_DECODE Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayN1[i]); + GOTOFAILURE + } + } - TIFFClose(tif); + retCode = TIFFGetField(tif, TIFFTAG_BLACKLEVEL, &count16, &pVoidArray); + /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */ + memcpy(&auxFloatArray, pVoidArray, (count16 * sizeof(auxFloatArray[0]))); + for (i = 0; i < count16; i++) { + dblDiffLimit = RATIONAL_EPS * auxFloatArrayN1[i]; + dblDiff = auxFloatArray[i] - auxFloatArrayN1[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value %d of TIFFTAG_BLACKLEVEL Array %f differs from set value %f\n", i, auxFloatArray[i], auxFloatArrayN1[i]); + GOTOFAILURE + } + } - /* All tests passed; delete file and exit with success status. */ + + /*--- Read now additional Rational2Double test tags --- + This should be now with nearly double precision + However, this additional tags are only read as Double, + if blnIsRational2Double is defined! + ------------------------------------------------------*/ + if (blnIsRational2Double) { + auxDblUnion.dbl = 0; + retCode = TIFFGetField(tif, TIFFTAG_RATIONAL_DOUBLE, &auxDblUnion.dbl); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_RATIONAL_DOUBLE"); GOTOFAILURE } + dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[100]; + dblDiff = auxDblUnion.dbl - auxDoubleArrayW[100]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value of TIFFTAG_RATIONAL_DOUBLE %f differs from set value %f\n", auxDblUnion.dbl, auxDoubleArrayW[100]); + GOTOFAILURE + } + + auxDblUnion.dbl = 0; + retCode = TIFFGetField(tif, TIFFTAG_SRATIONAL_DOUBLE, &auxDblUnion.dbl); + if (!retCode) { fprintf(stderr, "Can't read %s\n", "TIFFTAG_SRATIONAL_DOUBLE"); GOTOFAILURE } + auxDouble = -1.0; + dblDiffLimit = RATIONAL_EPS * auxDouble; + dblDiff = auxDblUnion.dbl - auxDouble; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value of TIFFTAG_SRATIONAL_DOUBLE %f differs from set value %f\n", auxDblUnion.dbl, auxDouble); + GOTOFAILURE + } + + /*- Fixed Array: TIFFTAG_RATIONAL_C0_DOUBLE, 3, 3, TIFF_RATIONAL, 0, TIFF_SETGET_C0_DOUBLE */ + count16 = 3; /* set fixed array length for checking */ + retCode = TIFFGetField(tif, TIFFTAG_RATIONAL_C0_DOUBLE, &pVoidArray); + /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */ + memcpy(&auxDoubleArray, pVoidArray, (count16 * sizeof(auxDoubleArray[0]))); + for (i = 0; i < count16; i++) { + dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[110 + i]; + dblDiff = auxDoubleArray[i] - auxDoubleArrayW[110 + i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value %d of TIFFTAG_RATIONAL_C0_DOUBLE Array %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayW[110 + i]); + GOTOFAILURE + } + } + + /*- Variable Array: TIFFTAG_SRATIONAL_C16_DOUBLE, -1, -1, TIFF_SRATIONAL, 0, TIFF_SETGET_C16_DOUBLE */ + retCode = TIFFGetField(tif, TIFFTAG_SRATIONAL_C16_DOUBLE, &count16, &pVoidArray); + /*- pVoidArray points to a Tiff-internal temporary memorypart. Thus, contents needs to be saved. */ + memcpy(&auxDoubleArray, pVoidArray, (count16 * sizeof(auxDoubleArray[0]))); + for (i = 0; i < count16; i++) { + dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[120 + i]; + dblDiff = auxDoubleArray[i] - auxDoubleArrayW[120 + i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + fprintf(stderr, "Read value %d of TIFFTAG_SRATIONAL_C16_DOUBLE Array %f differs from set value %f\n", i, auxDoubleArray[i], auxDoubleArrayW[120 + i]); + GOTOFAILURE + } + } + } + + } else { /* blnAllCustomTags */ + /*==== Automatically check all custom rational tags == READING ===*/ + + /*-- Get array, where standard TIFF tag fields are defined --*/ + tFieldArray = _TIFFGetFields(); + nTags = tFieldArray->count; + + for (i = 0; i < nTags; i++) { + tTag = tFieldArray->fields[i].field_tag; + tType = tFieldArray->fields[i].field_type; /* e.g. TIFF_RATIONAL */ + tWriteCount = tFieldArray->fields[i].field_writecount; + tSetFieldType = tFieldArray->fields[i].set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ + tFieldBit = tFieldArray->fields[i].field_bit; + tFieldName = tFieldArray->fields[i].field_name; + pVoid = NULL; + auxDblUnion.dbl = 0; + + if (tType == TIFF_RATIONAL && tFieldBit == FIELD_CUSTOM) { + /*-- dependent on set_field_type read value --*/ + switch (tSetFieldType) { + case TIFF_SETGET_FLOAT: + if (!TIFFGetField(tif, tTag, &auxFloat)) { + fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE + break; + } + /* compare read values with written ones */ + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; else dblDiffLimit = 1e-6; + dblDiff = auxFloat - auxDoubleArrayW[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance! + * However, there are two other EXIF tags where numerator indicates a special value and six other cases where the denominator indicates special values, + * which are not treated within LibTiff!! + */ + if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxFloat == -1.0)) { + fprintf(stderr, "%d:Read value of %s %f differs from set value %f\n", i, tFieldName, auxFloat, auxDoubleArrayW[i]); + GOTOFAILURE + } + } + break; + case TIFF_SETGET_DOUBLE: + /*-- Unfortunately, TIFF_SETGET_DOUBLE is used for TIFF_RATIONAL but those have to be read with FLOAT !!! */ + /* Only after update with Rational2Double feature, also TIFF_RATIONAL can be read in double precision!!! */ + /* Therefore, use a union to avoid overflow in TIFFGetField() return value + * and depending on version check for the right interface here: + * - old interface: correct value should be here a float + * - new interface: correct value should be here a double + * Interface version (old/new) is determined above. + */ + if (!TIFFGetField(tif, tTag, &auxDblUnion.dbl)) { + fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE + break; + } + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) { + if (blnIsRational2Double) { + /* New interface allows also double precision for TIFF_RATIONAL */ + auxDouble = auxDblUnion.dbl; + } + else { + /* Old interface reads TIFF_RATIONAL defined as TIFF_SETGET_DOUBLE alwasy as FLOAT */ + auxDouble = (double)auxDblUnion.flt1; + } + } else { + auxDouble = auxDblUnion.dbl; + } + /* compare read values with written ones */ + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; else dblDiffLimit = 1e-6; + dblDiff = auxDouble - auxDoubleArrayW[i]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to indicate infinite distance! */ + if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxDouble == -1.0)) + fprintf(stderr, "%d:Read value of %s %f differs from set value %f\n", i, tFieldName, auxDouble, auxDoubleArrayW[i]); + GOTOFAILURE + } + break; + + case TIFF_SETGET_C0_FLOAT: + case TIFF_SETGET_C0_DOUBLE: + case TIFF_SETGET_C16_FLOAT: + case TIFF_SETGET_C16_DOUBLE: + case TIFF_SETGET_C32_FLOAT: + case TIFF_SETGET_C32_DOUBLE: + /* _Cxx_ just defines the size of the count parameter for the array as C0=char, C16=short or C32=long */ + /*-- Check, if it is a single parameter, a fixed array or a variable array */ + if (tWriteCount == 1) { + fprintf(stderr, "Reading: WriteCount for .set_field_type %d should be -1 or greather than 1! %s\n", tSetFieldType, tFieldArray->fields[i].field_name); + GOTOFAILURE + } else { + /*-- Either fix or variable array --*/ + /* For arrays, distinguishing between float or double is essential. */ + /* Now decide between fixed or variable array */ + if (tWriteCount > 1) { + /* fixed array with needed arraysize defined in .field_writecount */ + if (!TIFFGetField(tif, tTag, &pVoidArray)) { + fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE + break; + } + /* set tWriteCount to number of read samples for next steps */ + auxLong = tWriteCount; + } else { + /* Special treatment of variable array. */ + /* Dependent on Cxx, the count parameter is char, short or long. Therefore use unionLong! */ + if (!TIFFGetField(tif, tTag, &auxLongUnion, &pVoidArray)) { + fprintf(stderr, "Can't read %s\n", tFieldArray->fields[i].field_name); + GOTOFAILURE + break; + } + /* set tWriteCount to number of read samples for next steps */ + auxLong = auxLongUnion.Short1; + } + /* Save values from temporary array */ + if (tSetFieldType == TIFF_SETGET_C0_FLOAT || tSetFieldType == TIFF_SETGET_C16_FLOAT || tSetFieldType == TIFF_SETGET_C32_FLOAT) { + memcpy(&auxFloatArray, pVoidArray, (auxLong * sizeof(auxFloatArray[0]))); + /* compare read values with written ones */ + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; else dblDiffLimit = 1e-6; + for (j = 0; j < auxLong; j++) { + dblDiff = auxFloatArray[j] - auxFloatArrayW[i + j]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + /*if (auxFloatArray[j] != (float)auxFloatArrayW[i+j]) { */ + fprintf(stderr, "Read value %d of %s #%d %f differs from set value %f\n", i, tFieldName, j, auxFloatArray[j], auxFloatArrayW[i + j]); + GOTOFAILURE + } + } + } else { + memcpy(&auxDoubleArray, pVoidArray, (auxLong * sizeof(auxDoubleArray[0]))); + /* compare read values with written ones */ + if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; else dblDiffLimit = 1e-6; + for (j = 0; j < auxLong; j++) { + dblDiff = auxDoubleArray[j] - auxDoubleArrayW[i + j]; + if (fabs(dblDiff) > fabs(dblDiffLimit)) { + /*if (auxDoubleArray[j] != auxDoubleArrayW[i+j]) { */ + fprintf(stderr, "Read value %d of %s #%d %f differs from set value %f\n", i, tFieldName, j, auxDoubleArray[j], auxDoubleArrayW[i + j]); + GOTOFAILURE + } + } + } + } + break; + default: + fprintf(stderr, "SetFieldType %d not defined within reading switch for %s.\n", tSetFieldType, tFieldName); + }; /*-- switch() --*/ + } /* if () */ + } /*-- for() --*/ + + + } /* blnAllCustomTags */ /*==== END END - Automatically check all custom rational tags == READING END ===*/ + + + + TIFFClose(tif); + + /* All tests passed; delete file and exit with success status. */ #ifdef FOR_AUTO_TESTING - unlink(filenameRead); + unlink(filenameRead); #endif - fprintf(stderr, "-------- Test finished OK ----------\n"); - return 0; + fprintf(stderr, "-------- Test finished OK ----------\n"); + return 0; failure: - /* - * Something goes wrong; close file and return unsuccessful status. - * Do not remove the file for further manual investigation. - */ - TIFFClose(tif); - fprintf(stderr, "-------- Test finished with FAILURE --------\n"); - return 1; + /* + * Something goes wrong; close file and return unsuccessful status. + * Do not remove the file for further manual investigation. + */ + TIFFClose(tif); + fprintf(stderr, "-------- Test finished with FAILURE --------\n"); + return 1; } diff --git a/thirdparty/SDL2_image/external/libtiff/test/raw_decode.c b/thirdparty/SDL2_image/external/libtiff/test/raw_decode.c index cf6ef00e1..a2fca03a8 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/raw_decode.c +++ b/thirdparty/SDL2_image/external/libtiff/test/raw_decode.c @@ -1,32 +1,32 @@ /* * Copyright (c) 2012, Frank Warmerdam * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ /* * TIFF Library * - * The objective of this test suite is to test the JPEGRawDecode() + * The objective of this test suite is to test the JPEGRawDecode() * interface via TIFReadEncodedTile(). This function with YCbCr subsampling - * is a frequent source of bugs. + * is a frequent source of bugs. */ #include "tif_config.h" @@ -34,9 +34,9 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif #include "tiffio.h" @@ -47,7 +47,7 @@ a conficting typedef given the headers which are included. */ #if defined(__BORLANDC__) || defined(__MINGW32__) -#define XMD_H 1 +# define XMD_H 1 #endif /* @@ -59,248 +59,244 @@ "JPEGLib: JPEG parameter struct mismatch: library thinks size is 432, caller expects 464" - For such users we will fix the problem here. See install.doc file from + For such users we wil fix the problem here. See install.doc file from the JPEG library distribution for details. */ /* Define "boolean" as unsigned char, not int, per Windows custom. */ #if defined(__WIN32__) && !defined(__MINGW32__) -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ +# ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ + typedef unsigned char boolean; +# endif +# define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ #endif #include "jpeglib.h" /* Needed for JPEG_LIB_VERSION */ -static unsigned char cluster_0[] = {0, 0, 2, 0, 138, 139}; -static unsigned char cluster_64[] = {0, 0, 9, 6, 134, 119}; -static unsigned char cluster_128[] = {44, 40, 63, 59, 230, 95}; +static unsigned char cluster_0[] = { 0, 0, 2, 0, 138, 139 }; +static unsigned char cluster_64[] = { 0, 0, 9, 6, 134, 119 }; +static unsigned char cluster_128[] = { 44, 40, 63, 59, 230, 95 }; -static int check_cluster(int cluster, unsigned char *buffer, - unsigned char *expected_cluster) -{ - unsigned char *target = buffer + cluster * 6; +static int check_cluster( int cluster, unsigned char *buffer, unsigned char *expected_cluster ) { + unsigned char *target = buffer + cluster*6; - if (memcmp(target, expected_cluster, 6) == 0) - { - return 0; - } + if (memcmp(target, expected_cluster, 6) == 0) { + return 0; + } - fprintf(stderr, "Cluster %d did not match expected results.\n", cluster); - fprintf(stderr, - "Expect: %3d %3d %3d %3d\n" - " %3d %3d\n", - expected_cluster[0], expected_cluster[1], expected_cluster[4], - expected_cluster[5], expected_cluster[2], expected_cluster[3]); - fprintf(stderr, - " Got: %3d %3d %3d %3d\n" - " %3d %3d\n", - target[0], target[1], target[4], target[5], target[2], target[3]); - return 1; + fprintf( stderr, "Cluster %d did not match expected results.\n", cluster ); + fprintf( stderr, + "Expect: %3d %3d %3d %3d\n" + " %3d %3d\n", + expected_cluster[0], expected_cluster[1], + expected_cluster[4], expected_cluster[5], + expected_cluster[2], expected_cluster[3] ); + fprintf( stderr, + " Got: %3d %3d %3d %3d\n" + " %3d %3d\n", + target[0], target[1], + target[4], target[5], + target[2], target[3] ); + return 1; } -static int check_rgb_pixel(int pixel, int min_red, int max_red, int min_green, - int max_green, int min_blue, int max_blue, - unsigned char *buffer) -{ - unsigned char *rgb = buffer + 3 * pixel; +static int check_rgb_pixel( int pixel, + int min_red, int max_red, + int min_green, int max_green, + int min_blue, int max_blue, + unsigned char *buffer ) { + unsigned char *rgb = buffer + 3 * pixel; + + if( rgb[0] >= min_red && rgb[0] <= max_red && + rgb[1] >= min_green && rgb[1] <= max_green && + rgb[2] >= min_blue && rgb[2] <= max_blue ) { + return 0; + } - if (rgb[0] >= min_red && rgb[0] <= max_red && rgb[1] >= min_green && - rgb[1] <= max_green && rgb[2] >= min_blue && rgb[2] <= max_blue) - { - return 0; - } - - fprintf(stderr, "Pixel %d did not match expected results.\n", pixel); - fprintf(stderr, - "Got R=%d (expected %d..%d), G=%d (expected %d..%d), B=%d " - "(expected %d..%d)\n", - rgb[0], min_red, max_red, rgb[1], min_green, max_green, rgb[2], - min_blue, max_blue); - return 1; + fprintf( stderr, "Pixel %d did not match expected results.\n", pixel ); + fprintf( stderr, "Got R=%d (expected %d..%d), G=%d (expected %d..%d), B=%d (expected %d..%d)\n", + rgb[0], min_red, max_red, + rgb[1], min_green, max_green, + rgb[2], min_blue, max_blue ); + return 1; } -static int check_rgba_pixel(int pixel, int min_red, int max_red, int min_green, - int max_green, int min_blue, int max_blue, - int min_alpha, int max_alpha, uint32_t *buffer) -{ - /* RGBA images are upside down - adjust for normal ordering */ - int adjusted_pixel = pixel % 128 + (127 - (pixel / 128)) * 128; - uint32_t rgba = buffer[adjusted_pixel]; +static int check_rgba_pixel( int pixel, + int min_red, int max_red, + int min_green, int max_green, + int min_blue, int max_blue, + int min_alpha, int max_alpha, + uint32 *buffer ) { + /* RGBA images are upside down - adjust for normal ordering */ + int adjusted_pixel = pixel % 128 + (127 - (pixel/128)) * 128; + uint32 rgba = buffer[adjusted_pixel]; - if (TIFFGetR(rgba) >= (uint32_t)min_red && - TIFFGetR(rgba) <= (uint32_t)max_red && - TIFFGetG(rgba) >= (uint32_t)min_green && - TIFFGetG(rgba) <= (uint32_t)max_green && - TIFFGetB(rgba) >= (uint32_t)min_blue && - TIFFGetB(rgba) <= (uint32_t)max_blue && - TIFFGetA(rgba) >= (uint32_t)min_alpha && - TIFFGetA(rgba) <= (uint32_t)max_alpha) - { - return 0; - } + if( TIFFGetR(rgba) >= (uint32) min_red && + TIFFGetR(rgba) <= (uint32) max_red && + TIFFGetG(rgba) >= (uint32) min_green && + TIFFGetG(rgba) <= (uint32) max_green && + TIFFGetB(rgba) >= (uint32) min_blue && + TIFFGetB(rgba) <= (uint32) max_blue && + TIFFGetA(rgba) >= (uint32) min_alpha && + TIFFGetA(rgba) <= (uint32) max_alpha ) { + return 0; + } - fprintf(stderr, "Pixel %d did not match expected results.\n", pixel); - fprintf(stderr, - "Got R=%d (expected %d..%d), G=%d (expected %d..%d), B=%d " - "(expected %d..%d), A=%d (expected %d..%d)\n", - TIFFGetR(rgba), min_red, max_red, TIFFGetG(rgba), min_green, - max_green, TIFFGetB(rgba), min_blue, max_blue, TIFFGetA(rgba), - min_alpha, max_alpha); - return 1; + fprintf( stderr, "Pixel %d did not match expected results.\n", pixel ); + fprintf( stderr, "Got R=%d (expected %d..%d), G=%d (expected %d..%d), B=%d (expected %d..%d), A=%d (expected %d..%d)\n", + TIFFGetR(rgba), min_red, max_red, + TIFFGetG(rgba), min_green, max_green, + TIFFGetB(rgba), min_blue, max_blue, + TIFFGetA(rgba), min_alpha, max_alpha ); + return 1; } -int main(int argc, char **argv) +int +main(int argc, char **argv) { - TIFF *tif; - static const char *srcfilerel = "images/quad-tile.jpg.tiff"; - char *srcdir = NULL; - char srcfile[1024]; - unsigned short h, v; - int status; - unsigned char *buffer; - uint32_t *rgba_buffer; - tsize_t sz, szout; - unsigned int pixel_status = 0; + TIFF *tif; + static const char *srcfilerel = "images/quad-tile.jpg.tiff"; + char *srcdir = NULL; + char srcfile[1024]; + unsigned short h, v; + int status; + unsigned char *buffer; + uint32 *rgba_buffer; + tsize_t sz, szout; + unsigned int pixel_status = 0; - (void)argc; - (void)argv; + (void) argc; + (void) argv; - if ((srcdir = getenv("srcdir")) == NULL) - { - srcdir = "."; - } - if ((strlen(srcdir) + 1 + strlen(srcfilerel)) >= sizeof(srcfile)) - { - fprintf(stderr, "srcdir too long %s\n", srcdir); - exit(1); - } - strcpy(srcfile, srcdir); - strcat(srcfile, "/"); - strcat(srcfile, srcfilerel); + if ((srcdir = getenv("srcdir")) == NULL) { + srcdir = "."; + } + if ((strlen(srcdir) + 1 + strlen(srcfilerel)) >= sizeof(srcfile)) { + fprintf( stderr, "srcdir too long %s\n", srcdir); + exit( 1 ); + } + strcpy(srcfile,srcdir); + strcat(srcfile,"/"); + strcat(srcfile,srcfilerel); - tif = TIFFOpen(srcfile, "r"); - if (tif == NULL) - { - fprintf(stderr, "Could not open %s\n", srcfile); - exit(1); - } + tif = TIFFOpen(srcfile,"r"); + if ( tif == NULL ) { + fprintf( stderr, "Could not open %s\n", srcfile); + exit( 1 ); + } - status = TIFFGetField(tif, TIFFTAG_YCBCRSUBSAMPLING, &h, &v); - if (status == 0 || h != 2 || v != 2) - { - fprintf(stderr, "Could not retrieve subsampling tag.\n"); - exit(1); - } + status = TIFFGetField(tif,TIFFTAG_YCBCRSUBSAMPLING, &h, &v); + if ( status == 0 || h != 2 || v != 2) { + fprintf( stderr, "Could not retrieve subsampling tag.\n" ); + exit(1); + } - /* - * What is the appropriate size of a YCbCr encoded tile? - */ - sz = TIFFTileSize(tif); - if (sz != 24576) - { - fprintf(stderr, "tiles are %d bytes\n", (int)sz); - exit(1); - } + /* + * What is the appropriate size of a YCbCr encoded tile? + */ + sz = TIFFTileSize(tif); + if( sz != 24576) { + fprintf(stderr, "tiles are %d bytes\n", (int)sz); + exit(1); + } - buffer = (unsigned char *)malloc(sz); + buffer = (unsigned char *) malloc(sz); - /* - * Read a tile in decompressed form, but still YCbCr subsampled. - */ - szout = TIFFReadEncodedTile(tif, 9, buffer, sz); - if (szout != sz) - { - fprintf(stderr, - "Did not get expected result code from " - "TIFFReadEncodedTile()(%d instead of %d)\n", - (int)szout, (int)sz); - return 1; - } + /* + * Read a tile in decompressed form, but still YCbCr subsampled. + */ + szout = TIFFReadEncodedTile(tif,9,buffer,sz); + if (szout != sz) { + fprintf( stderr, + "Did not get expected result code from TIFFReadEncodedTile()(%d instead of %d)\n", + (int) szout, (int) sz ); + return 1; + } - if (check_cluster(0, buffer, cluster_0) || - check_cluster(64, buffer, cluster_64) || - check_cluster(128, buffer, cluster_128)) - { - exit(1); - } - free(buffer); + if( check_cluster( 0, buffer, cluster_0 ) + || check_cluster( 64, buffer, cluster_64 ) + || check_cluster( 128, buffer, cluster_128 ) ) { + exit(1); + } + free(buffer); - /* - * Read a tile using the built-in conversion to RGB format provided by the - * JPEG library. - */ - TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + /* + * Read a tile using the built-in conversion to RGB format provided by the JPEG library. + */ + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - sz = TIFFTileSize(tif); - if (sz != 128 * 128 * 3) - { - fprintf(stderr, "tiles are %d bytes\n", (int)sz); - exit(1); - } + sz = TIFFTileSize(tif); + if( sz != 128*128*3) { + fprintf(stderr, "tiles are %d bytes\n", (int)sz); + exit(1); + } - buffer = (unsigned char *)malloc(sz); + buffer = (unsigned char *) malloc(sz); - szout = TIFFReadEncodedTile(tif, 9, buffer, sz); - if (szout != sz) - { - fprintf(stderr, - "Did not get expected result code from " - "TIFFReadEncodedTile()(%d instead of %d)\n", - (int)szout, (int)sz); - return 1; - } + szout = TIFFReadEncodedTile(tif,9,buffer,sz); + if (szout != sz) { + fprintf( stderr, + "Did not get expected result code from TIFFReadEncodedTile()(%d instead of %d)\n", + (int) szout, (int) sz ); + return 1; + } - /* - * JPEG decoding is inherently inexact, so we can't test for exact - * pixel values. (Well, if we knew exactly which libjpeg version - * we were using, and with what settings, we could expect specific - * values ... but it's not worth the trouble to keep track of.) - * Hence, use ranges of expected values. The ranges may need to be - * widened over time as more versions of libjpeg appear. - */ - pixel_status |= check_rgb_pixel(0, 15, 18, 0, 0, 18, 41, buffer); - pixel_status |= check_rgb_pixel(64, 0, 0, 0, 0, 0, 2, buffer); - pixel_status |= check_rgb_pixel(512, 5, 6, 34, 36, 182, 196, buffer); + /* + * JPEG decoding is inherently inexact, so we can't test for exact + * pixel values. (Well, if we knew exactly which libjpeg version + * we were using, and with what settings, we could expect specific + * values ... but it's not worth the trouble to keep track of.) + * Hence, use ranges of expected values. The ranges may need to be + * widened over time as more versions of libjpeg appear. + */ + pixel_status |= check_rgb_pixel( 0, 15, 18, 0, 0, 18, 41, buffer ); + pixel_status |= check_rgb_pixel( 64, 0, 0, 0, 0, 0, 2, buffer ); + pixel_status |= check_rgb_pixel( 512, 5, 6, 34, 36, 182, 196, buffer ); - free(buffer); + free( buffer ); - TIFFClose(tif); + TIFFClose(tif); - /* - * Reopen and test reading using the RGBA interface. - */ - tif = TIFFOpen(srcfile, "r"); + /* + * Reopen and test reading using the RGBA interface. + */ + tif = TIFFOpen(srcfile,"r"); + + sz = 128 * 128 * sizeof(uint32); + rgba_buffer = (uint32 *) malloc(sz); + + if (!TIFFReadRGBATile( tif, 1*128, 2*128, rgba_buffer )) { + fprintf( stderr, "TIFFReadRGBATile() returned failure code.\n" ); + return 1; + } - sz = 128 * 128 * sizeof(uint32_t); - rgba_buffer = (uint32_t *)malloc(sz); + /* + * Currently TIFFReadRGBATile() just uses JPEGCOLORMODE_RGB so this + * trivally matches the last results. Eventually we should actually + * accomplish it from the YCbCr subsampled buffer ourselves in which + * case the results may be subtly different but similar. + */ + pixel_status |= check_rgba_pixel( 0, 15, 18, 0, 0, 18, 41, 255, 255, + rgba_buffer ); + pixel_status |= check_rgba_pixel( 64, 0, 0, 0, 0, 0, 2, 255, 255, + rgba_buffer ); + pixel_status |= check_rgba_pixel( 512, 5, 6, 34, 36, 182, 196, 255, 255, + rgba_buffer ); - if (!TIFFReadRGBATile(tif, 1 * 128, 2 * 128, rgba_buffer)) - { - fprintf(stderr, "TIFFReadRGBATile() returned failure code.\n"); - return 1; - } + free( rgba_buffer ); + TIFFClose(tif); - /* - * Currently TIFFReadRGBATile() just uses JPEGCOLORMODE_RGB so this - * trivially matches the last results. Eventually we should actually - * accomplish it from the YCbCr subsampled buffer ourselves in which - * case the results may be subtly different but similar. - */ - pixel_status |= - check_rgba_pixel(0, 15, 18, 0, 0, 18, 41, 255, 255, rgba_buffer); - pixel_status |= - check_rgba_pixel(64, 0, 0, 0, 0, 0, 2, 255, 255, rgba_buffer); - pixel_status |= - check_rgba_pixel(512, 5, 6, 34, 36, 182, 196, 255, 255, rgba_buffer); - - free(rgba_buffer); - TIFFClose(tif); - - if (pixel_status) - { - exit(1); - } - - exit(0); + if (pixel_status) { + exit(1); + } + + exit( 0 ); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/refs/o-testfax3_bug_513.tiff b/thirdparty/SDL2_image/external/libtiff/test/refs/o-testfax3_bug_513.tiff deleted file mode 100644 index 5929b11d6..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/refs/o-testfax3_bug_513.tiff +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3aafc32877dbec52e6187aea78b0239678613858d55bab06e61c3aecf4749de3 -size 154 diff --git a/thirdparty/SDL2_image/external/libtiff/test/rewrite_tag.c b/thirdparty/SDL2_image/external/libtiff/test/rewrite_tag.c index d91b76c28..1708b024d 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/rewrite_tag.c +++ b/thirdparty/SDL2_image/external/libtiff/test/rewrite_tag.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2007, Frank Warmerdam * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,77 +32,69 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif #include "tiffio.h" #include "tiffiop.h" -const uint32_t length = 40; -const uint32_t rows_per_strip = 1; +const uint32 length = 40; +const uint32 rows_per_strip = 1; int test_packbits() { - TIFF *tif; - int i; - unsigned char buf[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + TIFF *tif; + int i; + unsigned char buf[10] = {0,0,0,0,0,0,0,0,0,0}; - uint32_t width = 10; - int length = 20; + uint32 width = 10; + int length = 20; const char *filename = "test_packbits.tif"; /* Test whether we can write tags. */ tif = TIFFOpen(filename, "w"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filename); + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); return 1; } - if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS)) - { - fprintf(stderr, "Can't set Compression tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS)) { + fprintf (stderr, "Can't set Compression tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); goto failure; } - for (i = 0; i < length; i++) + for (i = 0; i < length; i++ ) { - if (!TIFFWriteEncodedStrip(tif, i, buf, 10)) + if( !TIFFWriteEncodedStrip( tif, i, buf, 10 ) ) { - fprintf(stderr, "Can't write image data.\n"); + fprintf (stderr, "Can't write image data.\n"); goto failure; } } @@ -113,18 +105,17 @@ int test_packbits() tif = TIFFOpen(filename, "r+"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filename); + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); return 1; } buf[3] = 17; buf[6] = 12; - if (!TIFFWriteEncodedStrip(tif, 6, buf, 10)) + if( !TIFFWriteEncodedStrip( tif, 6, buf, 10 ) ) { - fprintf(stderr, "Can't write image data.\n"); + fprintf (stderr, "Can't write image data.\n"); goto failure; } @@ -134,242 +125,231 @@ int test_packbits() return 0; -failure: + failure: /* Something goes wrong; close file and return unsuccessful status. */ TIFFClose(tif); /* unlink(filename); */ return 1; + } /************************************************************************/ /* rewrite_test() */ /************************************************************************/ -int rewrite_test(const char *filename, uint32_t width, int length, int bigtiff, - uint64_t base_value) +int rewrite_test( const char *filename, uint32 width, int length, int bigtiff, + uint64 base_value ) { - TIFF *tif; - int i; - unsigned char *buf; - uint64_t *rowoffset, *rowbytes; - uint64_t *upd_rowoffset = NULL; - uint64_t *upd_bytecount = NULL; + TIFF *tif; + int i; + unsigned char *buf; + uint64 *rowoffset, *rowbytes; + uint64 *upd_rowoffset; + uint64 *upd_bytecount; buf = calloc(1, width); assert(buf); /* Test whether we can write tags. */ - if (bigtiff) + if( bigtiff ) tif = TIFFOpen(filename, "w8"); else tif = TIFFOpen(filename, "w4"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filename); + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); free(buf); return 1; } - if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS)) - { - fprintf(stderr, "Can't set Compression tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS)) { + fprintf (stderr, "Can't set Compression tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); goto failure; } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); goto failure; } - for (i = 0; i < length; i++) + for (i = 0; i < length; i++ ) { - if (TIFFWriteScanline(tif, buf, i, 0) == -1) + if( TIFFWriteScanline( tif, buf, i, 0 ) == -1 ) { - fprintf(stderr, "Can't write image data.\n"); + fprintf (stderr, "Can't write image data.\n"); goto failure; } } TIFFClose(tif); - + /* Ok, now test whether we can read written values. */ tif = TIFFOpen(filename, "r+"); - if (!tif) - { - fprintf(stderr, "Can't open test TIFF file %s.\n", filename); + if (!tif) { + fprintf (stderr, "Can't open test TIFF file %s.\n", filename); free(buf); return 1; } - - if (!TIFFGetField(tif, TIFFTAG_STRIPOFFSETS, &rowoffset)) + + if( !TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &rowoffset ) ) { - fprintf(stderr, "Can't fetch STRIPOFFSETS.\n"); + fprintf (stderr, "Can't fetch STRIPOFFSETS.\n"); + goto failure; + } + + if( !TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &rowbytes ) ) + { + fprintf (stderr, "Can't fetch STRIPBYTECOUNTS.\n"); goto failure; } - if (!TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &rowbytes)) + upd_rowoffset = (uint64 *) _TIFFmalloc(sizeof(uint64) * length); + for( i = 0; i < length; i++ ) + upd_rowoffset[i] = base_value + i*width; + + if( !_TIFFRewriteField( tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8, + length, upd_rowoffset ) ) { - fprintf(stderr, "Can't fetch STRIPBYTECOUNTS.\n"); + fprintf (stderr, "Can't rewrite STRIPOFFSETS.\n"); goto failure; } - upd_rowoffset = (uint64_t *)_TIFFmalloc(sizeof(uint64_t) * length); - for (i = 0; i < length; i++) - upd_rowoffset[i] = base_value + i * width; + _TIFFfree( upd_rowoffset ); - if (!_TIFFRewriteField(tif, TIFFTAG_STRIPOFFSETS, TIFF_LONG8, length, - upd_rowoffset)) + upd_bytecount = (uint64 *) _TIFFmalloc(sizeof(uint64) * length); + for( i = 0; i < length; i++ ) + upd_bytecount[i] = 100 + i*width; + + if( !_TIFFRewriteField( tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8, + length, upd_bytecount ) ) { - fprintf(stderr, "Can't rewrite STRIPOFFSETS.\n"); + fprintf (stderr, "Can't rewrite STRIPBYTECOUNTS.\n"); goto failure; } - _TIFFfree(upd_rowoffset); - upd_rowoffset = NULL; - - upd_bytecount = (uint64_t *)_TIFFmalloc(sizeof(uint64_t) * length); - for (i = 0; i < length; i++) - upd_bytecount[i] = 100 + i * width; - - if (!_TIFFRewriteField(tif, TIFFTAG_STRIPBYTECOUNTS, TIFF_LONG8, length, - upd_bytecount)) - { - fprintf(stderr, "Can't rewrite STRIPBYTECOUNTS.\n"); - goto failure; - } - - _TIFFfree(upd_bytecount); - upd_bytecount = NULL; + _TIFFfree( upd_bytecount ); TIFFClose(tif); /* Reopen file and read back to verify contents */ tif = TIFFOpen(filename, "r"); - if (!tif) - { - fprintf(stderr, "Can't open test TIFF file %s.\n", filename); + if (!tif) { + fprintf (stderr, "Can't open test TIFF file %s.\n", filename); free(buf); return 1; } - - if (!TIFFGetField(tif, TIFFTAG_STRIPOFFSETS, &rowoffset)) + + if( !TIFFGetField( tif, TIFFTAG_STRIPOFFSETS, &rowoffset ) ) { - fprintf(stderr, "Can't fetch STRIPOFFSETS.\n"); + fprintf (stderr, "Can't fetch STRIPOFFSETS.\n"); goto failure; } - - for (i = 0; i < length; i++) + + for( i = 0; i < length; i++ ) { - uint64_t expect = base_value + i * width; + uint64 expect = base_value + i*width; - if (rowoffset[i] != expect) + if( rowoffset[i] != expect ) { - fprintf(stderr, - "%s:STRIPOFFSETS[%d]: Got %X:%08X instead of %X:%08X.\n", - filename, i, (int)(rowoffset[i] >> 32), - (int)(rowoffset[i] & 0xFFFFFFFF), (int)(expect >> 32), - (int)(expect & 0xFFFFFFFF)); + fprintf( stderr, + "%s:STRIPOFFSETS[%d]: Got %X:%08X instead of %X:%08X.\n", + filename, i, + (int) (rowoffset[i] >> 32), + (int) (rowoffset[i]&0xFFFFFFFF), + (int) (expect >> 32), + (int) (expect & 0xFFFFFFFF) ); goto failure; } } - if (!TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &rowbytes)) + if( !TIFFGetField( tif, TIFFTAG_STRIPBYTECOUNTS, &rowbytes ) ) { - fprintf(stderr, "Can't fetch STRIPBYTECOUNTS.\n"); + fprintf (stderr, "Can't fetch STRIPBYTECOUNTS.\n"); goto failure; } - - for (i = 0; i < length; i++) + + for( i = 0; i < length; i++ ) { - uint64_t expect = 100 + i * width; + uint64 expect = 100 + i*width; - if (rowbytes[i] != expect) + if( rowbytes[i] != expect ) { - fprintf(stderr, - "%s:STRIPBYTECOUNTS[%d]: Got %X:%08X instead of %X:%08X.\n", - filename, i, (int)(rowbytes[i] >> 32), - (int)(rowbytes[i] & 0xFFFFFFFF), (int)(expect >> 32), - (int)(expect & 0xFFFFFFFF)); + fprintf( stderr, + "%s:STRIPBYTECOUNTS[%d]: Got %X:%08X instead of %X:%08X.\n", + filename, i, + (int) (rowbytes[i] >> 32), + (int) (rowbytes[i] & 0xFFFFFFFF), + (int) (expect >> 32), + (int) (expect & 0xFFFFFFFF) ); goto failure; } } - TIFFClose(tif); + TIFFClose( tif ); free(buf); /* All tests passed; delete file and exit with success status. */ unlink(filename); return 0; -failure: + failure: /* Something goes wrong; close file and return unsuccessful status. */ TIFFClose(tif); free(buf); - if (upd_rowoffset != NULL) - { - _TIFFfree(upd_rowoffset); - } - if (upd_bytecount != NULL) - { - _TIFFfree(upd_bytecount); - } /* unlink(filename); */ return 1; + } /************************************************************************/ /* main() */ /************************************************************************/ -int main(void) +int +main(void) { int failure = 0; failure |= test_packbits(); /* test fairly normal use */ - failure |= rewrite_test("rewrite1.tif", 10, 10, 0, 100); - failure |= rewrite_test("rewrite2.tif", 10, 10, 1, 100); + failure |= rewrite_test( "rewrite1.tif", 10, 10, 0, 100 ); + failure |= rewrite_test( "rewrite2.tif", 10, 10, 1, 100 ); /* test case of fitting all in directory entry */ - failure |= rewrite_test("rewrite3.tif", 10, 1, 0, 100); - failure |= rewrite_test("rewrite4.tif", 10, 1, 1, 100); + failure |= rewrite_test( "rewrite3.tif", 10, 1, 0, 100 ); + failure |= rewrite_test( "rewrite4.tif", 10, 1, 1, 100 ); /* test with very large values that don't fit in 4bytes (bigtiff only) */ - failure |= rewrite_test("rewrite5.tif", 10, 1000, 1, 0x6000000000ULL); - failure |= rewrite_test("rewrite6.tif", 10, 1, 1, 0x6000000000ULL); + failure |= rewrite_test( "rewrite5.tif", 10, 1000, 1, 0x6000000000ULL ); + failure |= rewrite_test( "rewrite6.tif", 10, 1, 1, 0x6000000000ULL ); /* StripByteCounts on LONG */ - failure |= rewrite_test("rewrite7.tif", 65536, 1, 0, 100); - failure |= rewrite_test("rewrite8.tif", 65536, 2, 0, 100); + failure |= rewrite_test( "rewrite7.tif", 65536, 1, 0, 100 ); + failure |= rewrite_test( "rewrite8.tif", 65536, 2, 0, 100 ); return failure; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/short_tag.c b/thirdparty/SDL2_image/external/libtiff/test/short_tag.c index 36abba566..75e7f5d5f 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/short_tag.c +++ b/thirdparty/SDL2_image/external/libtiff/test/short_tag.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2004, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -31,184 +31,173 @@ #include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif #include "tiffio.h" #include "tifftest.h" static const char filename[] = "short_test.tiff"; -#define SPP 3 /* Samples per pixel */ -const uint16_t width = 1; -const uint16_t length = 1; -const uint16_t bps = 8; -const uint16_t photometric = PHOTOMETRIC_RGB; -const uint16_t rows_per_strip = 1; -const uint16_t planarconfig = PLANARCONFIG_CONTIG; +#define SPP 3 /* Samples per pixel */ +const uint16 width = 1; +const uint16 length = 1; +const uint16 bps = 8; +const uint16 photometric = PHOTOMETRIC_RGB; +const uint16 rows_per_strip = 1; +const uint16 planarconfig = PLANARCONFIG_CONTIG; -static const struct +static const struct { + const ttag_t tag; + const uint16 value; +} short_single_tags[] = { + { TIFFTAG_COMPRESSION, COMPRESSION_NONE }, + { TIFFTAG_FILLORDER, FILLORDER_MSB2LSB }, + { TIFFTAG_ORIENTATION, ORIENTATION_BOTRIGHT }, + { TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH }, + { TIFFTAG_MINSAMPLEVALUE, 23 }, + { TIFFTAG_MAXSAMPLEVALUE, 241 }, + { TIFFTAG_INKSET, INKSET_MULTIINK }, + { TIFFTAG_NUMBEROFINKS, SPP }, + { TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT } +}; +#define NSINGLETAGS (sizeof(short_single_tags) / sizeof(short_single_tags[0])) + +static const struct { + const ttag_t tag; + const uint16 values[2]; +} short_paired_tags[] = { + { TIFFTAG_PAGENUMBER, {1, 1} }, + { TIFFTAG_HALFTONEHINTS, {0, 255} }, + { TIFFTAG_DOTRANGE, {8, 16} }, + { TIFFTAG_YCBCRSUBSAMPLING, {2, 1} } +}; +#define NPAIREDTAGS (sizeof(short_paired_tags) / sizeof(short_paired_tags[0])) + +int +main() { - const ttag_t tag; - const uint16_t value; -} short_single_tags[] = {{TIFFTAG_COMPRESSION, COMPRESSION_NONE}, - {TIFFTAG_FILLORDER, FILLORDER_MSB2LSB}, - {TIFFTAG_ORIENTATION, ORIENTATION_BOTRIGHT}, - {TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH}, - {TIFFTAG_MINSAMPLEVALUE, 23}, - {TIFFTAG_MAXSAMPLEVALUE, 241}, - {TIFFTAG_INKSET, INKSET_MULTIINK}, - {TIFFTAG_NUMBEROFINKS, SPP}, - {TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT}}; -#define NSINGLETAGS (sizeof(short_single_tags) / sizeof(short_single_tags[0])) + TIFF *tif; + size_t i; + unsigned char buf[SPP] = { 0, 127, 255 }; -static const struct -{ - const ttag_t tag; - const uint16_t values[2]; -} short_paired_tags[] = {{TIFFTAG_PAGENUMBER, {1, 1}}, - {TIFFTAG_HALFTONEHINTS, {0, 255}}, - {TIFFTAG_DOTRANGE, {8, 16}}, - {TIFFTAG_YCBCRSUBSAMPLING, {2, 1}}}; -#define NPAIREDTAGS (sizeof(short_paired_tags) / sizeof(short_paired_tags[0])) + /* Test whether we can write tags. */ + tif = TIFFOpen(filename, "w"); + if (!tif) { + fprintf (stderr, "Can't create test TIFF file %s.\n", filename); + return 1; + } -int main() -{ - TIFF *tif; - size_t i; - unsigned char buf[SPP] = {0, 127, 255}; + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) { + fprintf (stderr, "Can't set PhotometricInterpretation tag.\n"); + goto failure; + } - /* Test whether we can write tags. */ - tif = TIFFOpen(filename, "w"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filename); - return 1; - } + for (i = 0; i < NSINGLETAGS; i++) { + if (!TIFFSetField(tif, short_single_tags[i].tag, + short_single_tags[i].value)) { + fprintf(stderr, "Can't set tag %lu.\n", + (unsigned long)short_single_tags[i].tag); + goto failure; + } + } - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) - { - fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); - goto failure; - } + for (i = 0; i < NPAIREDTAGS; i++) { + if (!TIFFSetField(tif, short_paired_tags[i].tag, + short_paired_tags[i].values[0], + short_paired_tags[i].values[1])) { + fprintf(stderr, "Can't set tag %lu.\n", + (unsigned long)short_paired_tags[i].tag); + goto failure; + } + } - for (i = 0; i < NSINGLETAGS; i++) - { - if (!TIFFSetField(tif, short_single_tags[i].tag, - short_single_tags[i].value)) - { - fprintf(stderr, "Can't set tag %" PRIu32 ".\n", - short_single_tags[i].tag); - goto failure; - } - } + /* Write dummy pixel data. */ + if (TIFFWriteScanline(tif, buf, 0, 0) == -1) { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } - for (i = 0; i < NPAIREDTAGS; i++) - { - if (!TIFFSetField(tif, short_paired_tags[i].tag, - short_paired_tags[i].values[0], - short_paired_tags[i].values[1])) - { - fprintf(stderr, "Can't set tag %" PRIu32 ".\n", - short_paired_tags[i].tag); - goto failure; - } - } + TIFFClose(tif); + + /* Ok, now test whether we can read written values. */ + tif = TIFFOpen(filename, "r"); + if (!tif) { + fprintf (stderr, "Can't open test TIFF file %s.\n", filename); + return 1; + } + + if (CheckLongField(tif, TIFFTAG_IMAGEWIDTH, width) < 0) + goto failure; - /* Write dummy pixel data. */ - if (TIFFWriteScanline(tif, buf, 0, 0) == -1) - { - fprintf(stderr, "Can't write image data.\n"); - goto failure; - } + if (CheckLongField(tif, TIFFTAG_IMAGELENGTH, length) < 0) + goto failure; - TIFFClose(tif); + if (CheckShortField(tif, TIFFTAG_BITSPERSAMPLE, bps) < 0) + goto failure; - /* Ok, now test whether we can read written values. */ - tif = TIFFOpen(filename, "r"); - if (!tif) - { - fprintf(stderr, "Can't open test TIFF file %s.\n", filename); - return 1; - } + if (CheckShortField(tif, TIFFTAG_PHOTOMETRIC, photometric) < 0) + goto failure; - if (CheckLongField(tif, TIFFTAG_IMAGEWIDTH, width) < 0) - goto failure; + if (CheckShortField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP) < 0) + goto failure; - if (CheckLongField(tif, TIFFTAG_IMAGELENGTH, length) < 0) - goto failure; + if (CheckLongField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip) < 0) + goto failure; - if (CheckShortField(tif, TIFFTAG_BITSPERSAMPLE, bps) < 0) - goto failure; + if (CheckShortField(tif, TIFFTAG_PLANARCONFIG, planarconfig) < 0) + goto failure; - if (CheckShortField(tif, TIFFTAG_PHOTOMETRIC, photometric) < 0) - goto failure; + for (i = 0; i < NSINGLETAGS; i++) { + if (CheckShortField(tif, short_single_tags[i].tag, + short_single_tags[i].value) < 0) + goto failure; + } - if (CheckShortField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP) < 0) - goto failure; + for (i = 0; i < NPAIREDTAGS; i++) { + if (CheckShortPairedField(tif, short_paired_tags[i].tag, + short_paired_tags[i].values) < 0) + goto failure; + } - if (CheckLongField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip) < 0) - goto failure; - - if (CheckShortField(tif, TIFFTAG_PLANARCONFIG, planarconfig) < 0) - goto failure; - - for (i = 0; i < NSINGLETAGS; i++) - { - if (CheckShortField(tif, short_single_tags[i].tag, - short_single_tags[i].value) < 0) - goto failure; - } - - for (i = 0; i < NPAIREDTAGS; i++) - { - if (CheckShortPairedField(tif, short_paired_tags[i].tag, - short_paired_tags[i].values) < 0) - goto failure; - } - - TIFFClose(tif); - - /* All tests passed; delete file and exit with success status. */ - unlink(filename); - return 0; + TIFFClose(tif); + + /* All tests passed; delete file and exit with success status. */ + unlink(filename); + return 0; failure: - /* - * Something goes wrong; close file and return unsuccessful status. - * Do not remove the file for further manual investigation. - */ - TIFFClose(tif); - return 1; + /* + * Something goes wrong; close file and return unsuccessful status. + * Do not remove the file for further manual investigation. + */ + TIFFClose(tif); + return 1; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/strip.c b/thirdparty/SDL2_image/external/libtiff/test/strip.c index d61c6f84e..f2cb77352 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/strip.c +++ b/thirdparty/SDL2_image/external/libtiff/test/strip.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2004, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,279 +32,257 @@ #include "tiffio.h" -int write_strips(TIFF *tif, const tdata_t array, const tsize_t size) +int +write_strips(TIFF *tif, const tdata_t array, const tsize_t size) { - tstrip_t strip, nstrips; - tsize_t stripsize, offset; + tstrip_t strip, nstrips; + tsize_t stripsize, offset; - stripsize = TIFFStripSize(tif); - if (!stripsize) - { - fprintf(stderr, "Wrong size of strip.\n"); - return -1; - } + stripsize = TIFFStripSize(tif); + if (!stripsize) { + fprintf (stderr, "Wrong size of strip.\n"); + return -1; + } - nstrips = TIFFNumberOfStrips(tif); - for (offset = 0, strip = 0; offset < size && strip < nstrips; - offset += stripsize, strip++) - { - /* - * Properly write last strip. - */ - tsize_t bufsize = size - offset; - if (bufsize > stripsize) - bufsize = stripsize; + nstrips = TIFFNumberOfStrips(tif); + for (offset = 0, strip = 0; + offset < size && strip < nstrips; + offset+=stripsize, strip++) { + /* + * Properly write last strip. + */ + tsize_t bufsize = size - offset; + if (bufsize > stripsize) + bufsize = stripsize; - if (TIFFWriteEncodedStrip(tif, strip, (char *)array + offset, - bufsize) != bufsize) - { - fprintf(stderr, "Can't write strip %" PRIu32 ".\n", strip); - return -1; + if (TIFFWriteEncodedStrip(tif, strip, (char *)array + offset, + bufsize) != bufsize) { + fprintf (stderr, "Can't write strip %lu.\n", + (unsigned long)strip); + return -1; + } } - } - return 0; + return 0; } -int read_strips(TIFF *tif, const tdata_t array, const tsize_t size) +int +read_strips(TIFF *tif, const tdata_t array, const tsize_t size) { - tstrip_t strip, nstrips; - tsize_t stripsize, offset; - tdata_t buf = NULL; + tstrip_t strip, nstrips; + tsize_t stripsize, offset; + tdata_t buf = NULL; - stripsize = TIFFStripSize(tif); - if (!stripsize) - { - fprintf(stderr, "Wrong size of strip.\n"); - return -1; - } + stripsize = TIFFStripSize(tif); + if (!stripsize) { + fprintf (stderr, "Wrong size of strip.\n"); + return -1; + } - buf = _TIFFmalloc(stripsize); - if (!buf) - { - fprintf(stderr, "Can't allocate space for strip buffer.\n"); - return -1; - } + buf = _TIFFmalloc(stripsize); + if (!buf) { + fprintf (stderr, "Can't allocate space for strip buffer.\n"); + return -1; + } - nstrips = TIFFNumberOfStrips(tif); - for (offset = 0, strip = 0; offset < size && strip < nstrips; - offset += stripsize, strip++) - { - /* - * Properly read last strip. - */ - tsize_t bufsize = size - offset; - if (bufsize > stripsize) - bufsize = stripsize; + nstrips = TIFFNumberOfStrips(tif); + for (offset = 0, strip = 0; + offset < size && strip < nstrips; + offset+=stripsize, strip++) { + /* + * Properly read last strip. + */ + tsize_t bufsize = size - offset; + if (bufsize > stripsize) + bufsize = stripsize; - if (TIFFReadEncodedStrip(tif, strip, buf, -1) != bufsize) - { - fprintf(stderr, "Can't read strip %" PRIu32 ".\n", strip); - return -1; + if (TIFFReadEncodedStrip(tif, strip, buf, -1) != bufsize) { + fprintf (stderr, "Can't read strip %lu.\n", + (unsigned long)strip); + return -1; + } + if (memcmp(buf, (char *)array + offset, bufsize) != 0) { + fprintf (stderr, "Wrong data read for strip %lu.\n", + (unsigned long)strip); + _TIFFfree(buf); + return -1; + } } - if (memcmp(buf, (char *)array + offset, bufsize) != 0) - { - fprintf(stderr, "Wrong data read for strip %" PRIu32 ".\n", strip); - _TIFFfree(buf); - return -1; - } - } - _TIFFfree(buf); + _TIFFfree(buf); - return 0; + return 0; } -int create_image_striped(const char *name, uint32_t width, uint32_t length, - uint32_t rowsperstrip, uint16_t compression, - uint16_t spp, uint16_t bps, uint16_t photometric, - uint16_t sampleformat, uint16_t planarconfig, - const tdata_t array, const tsize_t size) +int +create_image_striped(const char *name, uint32 width, uint32 length, + uint32 rowsperstrip, uint16 compression, + uint16 spp, uint16 bps, uint16 photometric, + uint16 sampleformat, uint16 planarconfig, + const tdata_t array, const tsize_t size) { - TIFF *tif; + TIFF *tif; - /* Test whether we can write tags. */ - tif = TIFFOpen(name, "w"); - if (!tif) - goto openfailure; + /* Test whether we can write tags. */ + tif = TIFFOpen(name, "w"); + if (!tif) + goto openfailure; - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, spp)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip)) - { - fprintf(stderr, "Can't set RowsPerStrip tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) - { - fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); - goto failure; - } + if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) { + fprintf (stderr, "Can't set ImageWidth tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) { + fprintf (stderr, "Can't set ImageLength tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) { + fprintf (stderr, "Can't set BitsPerSample tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, spp)) { + fprintf (stderr, "Can't set SamplesPerPixel tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip)) { + fprintf (stderr, "Can't set RowsPerStrip tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) { + fprintf (stderr, "Can't set PlanarConfiguration tag.\n"); + goto failure; + } + if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) { + fprintf (stderr, "Can't set PhotometricInterpretation tag.\n"); + goto failure; + } - if (write_strips(tif, array, size) < 0) - { - fprintf(stderr, "Can't write image data.\n"); - goto failure; - } + if (write_strips(tif, array, size) < 0) { + fprintf (stderr, "Can't write image data.\n"); + goto failure; + } - TIFFClose(tif); - return 0; + TIFFClose(tif); + return 0; failure: - TIFFClose(tif); + TIFFClose(tif); openfailure: - fprintf(stderr, - "Can't create test TIFF file %s:\n" - " ImageWidth=%" PRIu32 ", ImageLength=%" PRIu32 - ", RowsPerStrip=%" PRIu32 ", Compression=%" PRIu16 ",\n" - " BitsPerSample=%" PRIu16 ", SamplesPerPixel=%" PRIu16 - ", SampleFormat=%" PRIu16 ",\n" - " PlanarConfiguration=%" PRIu16 - ", PhotometricInterpretation=%" PRIu16 ".\n", - name, width, length, rowsperstrip, compression, bps, spp, - sampleformat, planarconfig, photometric); - return -1; + fprintf (stderr, "Can't create test TIFF file %s:\n" +" ImageWidth=%ld, ImageLength=%ld, RowsPerStrip=%ld, Compression=%d,\n" +" BitsPerSample=%d, SamplesPerPixel=%d, SampleFormat=%d,\n" +" PlanarConfiguration=%d, PhotometricInterpretation=%d.\n", + name, (long) width, (long) length, (long) rowsperstrip, + compression, bps, spp, sampleformat, planarconfig, + photometric); + return -1; } -int read_image_striped(const char *name, uint32_t width, uint32_t length, - uint32_t rowsperstrip, uint16_t compression, - uint16_t spp, uint16_t bps, uint16_t photometric, - uint16_t sampleformat, uint16_t planarconfig, - const tdata_t array, const tsize_t size) +int +read_image_striped(const char *name, uint32 width, uint32 length, + uint32 rowsperstrip, uint16 compression, + uint16 spp, uint16 bps, uint16 photometric, + uint16 sampleformat, uint16 planarconfig, + const tdata_t array, const tsize_t size) { - TIFF *tif; - uint16_t value_u16; - uint32_t value_u32; + TIFF *tif; + uint16 value_u16; + uint32 value_u32; - /* Test whether we can read written values. */ - tif = TIFFOpen(name, "r"); - if (!tif) - goto openfailure; + /* Test whether we can read written values. */ + tif = TIFFOpen(name, "r"); + if (!tif) + goto openfailure; + + if (TIFFIsTiled(tif)) { + fprintf (stderr, "Can't read image %s, it is tiled.\n", + name); + goto failure; + } + if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &value_u32) + || value_u32 != width) { + fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGEWIDTH); + goto failure; + } + if (!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &value_u32) + || value_u32 != length) { + fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGELENGTH); + goto failure; + } + if (!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &value_u16) + || value_u16 != bps) { + fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_BITSPERSAMPLE); + goto failure; + } + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &value_u16) + || value_u16 != photometric) { + fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_PHOTOMETRIC); + goto failure; + } + if (!TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &value_u16) + || value_u16 != spp) { + fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_SAMPLESPERPIXEL); + goto failure; + } + if (!TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &value_u32) + || value_u32 != rowsperstrip) { + fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_ROWSPERSTRIP); + goto failure; + } + if (!TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &value_u16) + || value_u16 != planarconfig) { + fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_PLANARCONFIG); + goto failure; + } - if (TIFFIsTiled(tif)) - { - fprintf(stderr, "Can't read image %s, it is tiled.\n", name); - goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &value_u32) || - value_u32 != width) - { - fprintf(stderr, "Can't get tag %d.\n", TIFFTAG_IMAGEWIDTH); - goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &value_u32) || - value_u32 != length) - { - fprintf(stderr, "Can't get tag %d.\n", TIFFTAG_IMAGELENGTH); - goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &value_u16) || - value_u16 != bps) - { - fprintf(stderr, "Can't get tag %d.\n", TIFFTAG_BITSPERSAMPLE); - goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &value_u16) || - value_u16 != photometric) - { - fprintf(stderr, "Can't get tag %d.\n", TIFFTAG_PHOTOMETRIC); - goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &value_u16) || - value_u16 != spp) - { - fprintf(stderr, "Can't get tag %d.\n", TIFFTAG_SAMPLESPERPIXEL); - goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &value_u32) || - value_u32 != rowsperstrip) - { - fprintf(stderr, "Can't get tag %d.\n", TIFFTAG_ROWSPERSTRIP); - goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &value_u16) || - value_u16 != planarconfig) - { - fprintf(stderr, "Can't get tag %d.\n", TIFFTAG_PLANARCONFIG); - goto failure; - } + if (read_strips(tif, array, size) < 0) { + fprintf (stderr, "Can't read image data.\n"); + goto failure; + } - if (read_strips(tif, array, size) < 0) - { - fprintf(stderr, "Can't read image data.\n"); - goto failure; - } - - TIFFClose(tif); - return 0; + TIFFClose(tif); + return 0; failure: - TIFFClose(tif); + TIFFClose(tif); openfailure: - fprintf(stderr, - "Can't read test TIFF file %s:\n" - " ImageWidth=%" PRIu32 ", ImageLength=%" PRIu32 - ", RowsPerStrip=%" PRIu32 ", Compression=%" PRIu16 ",\n" - " BitsPerSample=%" PRIu16 ", SamplesPerPixel=%" PRIu16 - ", SampleFormat=%" PRIu16 ",\n" - " PlanarConfiguration=%" PRIu16 - ", PhotometricInterpretation=%" PRIu16 ".\n", - name, width, length, rowsperstrip, compression, bps, spp, - sampleformat, planarconfig, photometric); - return -1; + fprintf (stderr, "Can't read test TIFF file %s:\n" +" ImageWidth=%ld, ImageLength=%ld, RowsPerStrip=%ld, Compression=%d,\n" +" BitsPerSample=%d, SamplesPerPixel=%d, SampleFormat=%d,\n" +" PlanarConfiguration=%d, PhotometricInterpretation=%d.\n", + name, (long) width, (long) length, (long) rowsperstrip, + compression, bps, spp, sampleformat, planarconfig, + photometric); + return -1; } -int write_scanlines(TIFF *tif, const tdata_t array, const tsize_t size) +int +write_scanlines(TIFF *tif, const tdata_t array, const tsize_t size) { - uint32_t length, row; - tsize_t scanlinesize, offset; - (void)size; + uint32 length, row; + tsize_t scanlinesize, offset; + (void) size; - if (!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &length)) - { - fprintf(stderr, "Can't get tag %d.\n", TIFFTAG_IMAGELENGTH); - return -1; - } + if (!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &length)) { + fprintf (stderr, "Can't get tag %d.\n", TIFFTAG_IMAGELENGTH); + return -1; + } + + scanlinesize = TIFFScanlineSize(tif); + if (!scanlinesize) { + fprintf (stderr, "Wrong size of scanline.\n"); + return -1; + } - scanlinesize = TIFFScanlineSize(tif); - if (!scanlinesize) - { - fprintf(stderr, "Wrong size of scanline.\n"); - return -1; - } - - for (offset = 0, row = 0; row < length; offset += scanlinesize, row++) - { - if (TIFFWriteScanline(tif, (char *)array + offset, row, 0) == -1) - { - fprintf(stderr, "Can't write image data at row %" PRIu32 ".\n", - row); - return -1; + for (offset = 0, row = 0; row < length; offset+=scanlinesize, row++) { + if (TIFFWriteScanline(tif, (char *)array + offset, row, 0) == -1) { + fprintf (stderr, + "Can't write image data at row %lu.\n", (long) row); + return -1; + } } - } - return 0; + return 0; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/strip_rw.c b/thirdparty/SDL2_image/external/libtiff/test/strip_rw.c index 493d36d0f..bcf7d7357 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/strip_rw.c +++ b/thirdparty/SDL2_image/external/libtiff/test/strip_rw.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2004, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -31,125 +31,125 @@ #include -#ifdef HAVE_UNISTD_H -#include -#endif +#ifdef HAVE_UNISTD_H +# include +#endif -#include "test_arrays.h" #include "tiffio.h" +#include "test_arrays.h" -extern int create_image_striped(const char *, uint32_t, uint32_t, uint32_t, - uint16_t, uint16_t, uint16_t, uint16_t, - uint16_t, uint16_t, const tdata_t, - const tsize_t); -extern int read_image_striped(const char *, uint32_t, uint32_t, uint32_t, - uint16_t, uint16_t, uint16_t, uint16_t, uint16_t, - uint16_t, const tdata_t, const tsize_t); +extern int +create_image_striped(const char *, uint32, uint32, uint32, uint16, uint16, + uint16, uint16, uint16, uint16, const tdata_t, + const tsize_t); +extern int +read_image_striped(const char *, uint32, uint32, uint32, uint16, uint16, + uint16, uint16, uint16, uint16, const tdata_t, + const tsize_t); -const char *filename = "strip_test.tiff"; +const char *filename = "strip_test.tiff"; -int main(int argc, char **argv) +int +main(int argc, char **argv) { - uint32_t rowsperstrip; - uint16_t compression; - uint16_t spp, bps, photometric, sampleformat, planarconfig; - (void)argc; - (void)argv; + uint32 rowsperstrip; + uint16 compression; + uint16 spp, bps, photometric, sampleformat, planarconfig; + (void) argc; + (void) argv; - /* - * Test two special cases: image consisting from single line and image - * consisting from single column. - */ - rowsperstrip = 1; - compression = COMPRESSION_NONE; - spp = 1; - bps = 8; - photometric = PHOTOMETRIC_MINISBLACK; - sampleformat = SAMPLEFORMAT_UINT; - planarconfig = PLANARCONFIG_CONTIG; + /* + * Test two special cases: image consisting from single line and image + * consisting from single column. + */ + rowsperstrip = 1; + compression = COMPRESSION_NONE; + spp = 1; + bps = 8; + photometric = PHOTOMETRIC_MINISBLACK; + sampleformat = SAMPLEFORMAT_UINT; + planarconfig = PLANARCONFIG_CONTIG; - if (create_image_striped(filename, XSIZE * YSIZE, 1, rowsperstrip, - compression, spp, bps, photometric, sampleformat, - planarconfig, (const tdata_t)byte_array1, - byte_array1_size) < 0) - { - fprintf(stderr, "Can't create TIFF file %s.\n", filename); - goto failure; - } - if (read_image_striped(filename, XSIZE * YSIZE, 1, rowsperstrip, - compression, spp, bps, photometric, sampleformat, - planarconfig, (const tdata_t)byte_array1, - byte_array1_size) < 0) - { - fprintf(stderr, "Can't read TIFF file %s.\n", filename); - goto failure; - } - unlink(filename); + if (create_image_striped(filename, XSIZE * YSIZE, 1, rowsperstrip, + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { + fprintf (stderr, "Can't create TIFF file %s.\n", filename); + goto failure; + } + if (read_image_striped(filename, XSIZE * YSIZE, 1, rowsperstrip, + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { + fprintf (stderr, "Can't read TIFF file %s.\n", filename); + goto failure; + } + unlink(filename); + + if (create_image_striped(filename, 1, XSIZE * YSIZE, rowsperstrip, + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { + fprintf (stderr, "Can't create TIFF file %s.\n", filename); + goto failure; + } + if (read_image_striped(filename, 1, XSIZE * YSIZE, rowsperstrip, + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { + fprintf (stderr, "Can't read TIFF file %s.\n", filename); + goto failure; + } + unlink(filename); + + /* + * Test one-channel image with different parameters. + */ + rowsperstrip = 1; + spp = 1; + bps = 8; + photometric = PHOTOMETRIC_MINISBLACK; + sampleformat = SAMPLEFORMAT_UINT; + planarconfig = PLANARCONFIG_CONTIG; - if (create_image_striped(filename, 1, XSIZE * YSIZE, rowsperstrip, - compression, spp, bps, photometric, sampleformat, - planarconfig, (const tdata_t)byte_array1, - byte_array1_size) < 0) - { - fprintf(stderr, "Can't create TIFF file %s.\n", filename); - goto failure; - } - if (read_image_striped(filename, 1, XSIZE * YSIZE, rowsperstrip, - compression, spp, bps, photometric, sampleformat, - planarconfig, (const tdata_t)byte_array1, - byte_array1_size) < 0) - { - fprintf(stderr, "Can't read TIFF file %s.\n", filename); - goto failure; - } - unlink(filename); + if (create_image_striped(filename, XSIZE, YSIZE, rowsperstrip, + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { + fprintf (stderr, "Can't create TIFF file %s.\n", filename); + goto failure; + } + if (read_image_striped(filename, XSIZE, YSIZE, rowsperstrip, + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { + fprintf (stderr, "Can't read TIFF file %s.\n", filename); + goto failure; + } + unlink(filename); + + rowsperstrip = YSIZE; + if (create_image_striped(filename, XSIZE, YSIZE, rowsperstrip, + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { + fprintf (stderr, "Can't create TIFF file %s.\n", filename); + goto failure; + } + if (read_image_striped(filename, XSIZE, YSIZE, rowsperstrip, + compression, spp, bps, photometric, + sampleformat, planarconfig, + (const tdata_t) byte_array1, byte_array1_size) < 0) { + fprintf (stderr, "Can't read TIFF file %s.\n", filename); + goto failure; + } + unlink(filename); - /* - * Test one-channel image with different parameters. - */ - rowsperstrip = 1; - spp = 1; - bps = 8; - photometric = PHOTOMETRIC_MINISBLACK; - sampleformat = SAMPLEFORMAT_UINT; - planarconfig = PLANARCONFIG_CONTIG; - - if (create_image_striped(filename, XSIZE, YSIZE, rowsperstrip, compression, - spp, bps, photometric, sampleformat, planarconfig, - (const tdata_t)byte_array1, byte_array1_size) < 0) - { - fprintf(stderr, "Can't create TIFF file %s.\n", filename); - goto failure; - } - if (read_image_striped(filename, XSIZE, YSIZE, rowsperstrip, compression, - spp, bps, photometric, sampleformat, planarconfig, - (const tdata_t)byte_array1, byte_array1_size) < 0) - { - fprintf(stderr, "Can't read TIFF file %s.\n", filename); - goto failure; - } - unlink(filename); - - rowsperstrip = YSIZE; - if (create_image_striped(filename, XSIZE, YSIZE, rowsperstrip, compression, - spp, bps, photometric, sampleformat, planarconfig, - (const tdata_t)byte_array1, byte_array1_size) < 0) - { - fprintf(stderr, "Can't create TIFF file %s.\n", filename); - goto failure; - } - if (read_image_striped(filename, XSIZE, YSIZE, rowsperstrip, compression, - spp, bps, photometric, sampleformat, planarconfig, - (const tdata_t)byte_array1, byte_array1_size) < 0) - { - fprintf(stderr, "Can't read TIFF file %s.\n", filename); - goto failure; - } - unlink(filename); - - return 0; + return 0; failure: - unlink(filename); - return 1; + unlink(filename); + return 1; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/test_append_to_strip.c b/thirdparty/SDL2_image/external/libtiff/test/test_append_to_strip.c deleted file mode 100644 index 4aada5b7a..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/test_append_to_strip.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2022, Even Rouault - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * Test TIFFAppendToStrip() through TIFFWriteRawStrip() - * Scenario of https://gitlab.com/libtiff/libtiff/-/issues/489 - */ - -#include "tif_config.h" - -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "tiffio.h" - -int main() -{ - int ret; - TIFF *tif = TIFFOpen("test_append_to_strip.tif", "w"); - if (tif == NULL) - { - fprintf(stderr, "Cannot create test_append_to_strip.tif"); - return 1; - } - ret = TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - assert(ret); - ret = TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 1); - assert(ret); - ret = TIFFSetField(tif, TIFFTAG_IMAGELENGTH, 9); - assert(ret); - ret = TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 5); - assert(ret); - ret = TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); - assert(ret); - ret = TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); - assert(ret); - int row; - for (row = 0; row < 9; ++row) - { - char c = (char)row; - int strip = (row < 5) ? 0 : 1; - ret = TIFFWriteRawStrip(tif, strip, &c, 1); - assert(ret == 1); - } - (void)ret; - TIFFClose(tif); - tif = TIFFOpen("test_append_to_strip.tif", "r"); - if (tif == NULL) - { - fprintf(stderr, "Cannot create test_append_to_strip.tif"); - return 1; - } - toff_t *panByteCounts = NULL; - TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &panByteCounts); - assert(panByteCounts); - int exitCode = 0; - if (panByteCounts[0] != 5) - { - exitCode = 1; - fprintf(stderr, "panByteCounts[0] = %d. Expected 5.\n", - (int)panByteCounts[0]); - } - if (panByteCounts[1] != 4) - { - exitCode = 1; - fprintf(stderr, "panByteCounts[1] = %d. Expected 4.\n", - (int)panByteCounts[1]); - } - for (row = 0; row < 9; ++row) - { - char c; - TIFFReadScanline(tif, &c, row, 0); - if (c != row) - { - fprintf( - stderr, - "TIFFReadScanline() for scanline %d returned %d. %d expected\n", - row, c, row); - exitCode = 1; - } - } - TIFFClose(tif); - unlink("test_append_to_strip.tif"); - return exitCode; -} diff --git a/thirdparty/SDL2_image/external/libtiff/test/test_arrays.c b/thirdparty/SDL2_image/external/libtiff/test/test_arrays.c index c645a511d..226e9d0c8 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/test_arrays.c +++ b/thirdparty/SDL2_image/external/libtiff/test/test_arrays.c @@ -1,23 +1,23 @@ /* * Copyright (c) 2004, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -31,699 +31,797 @@ #include "test_arrays.h" -const unsigned char byte_array1[XSIZE * YSIZE] = { - 86, 84, 86, 90, 89, 85, 90, 78, 77, 79, 75, 77, 79, 86, 87, - 83, 82, 87, 89, 88, 86, 87, 88, 87, 81, 84, 85, 85, 84, 86, - 88, 91, 96, 95, 97, 95, 89, 85, 82, 81, 88, 89, 85, 89, 83, - 74, 79, 76, 77, 80, 87, 87, 84, 84, 88, 90, 89, 87, 85, 87, - 88, 83, 80, 82, 84, 85, 87, 90, 95, 96, 95, 95, 92, 90, 85, - 81, 79, 84, 90, 87, 88, 88, 73, 79, 75, 76, 79, 88, 88, 87, - 85, 90, 92, 89, 88, 88, 87, 86, 84, 82, 82, 83, 87, 89, 93, - 94, 93, 93, 92, 92, 96, 85, 82, 76, 80, 88, 89, 88, 89, 73, - 80, 75, 75, 77, 89, 92, 93, 91, 89, 94, 92, 90, 89, 88, 84, - 84, 82, 82, 85, 88, 91, 94, 93, 93, 89, 90, 96, 96, 87, 83, - 75, 77, 83, 89, 90, 90, 74, 78, 76, 76, 76, 84, 94, 100, 89, - 92, 94, 92, 90, 89, 90, 85, 84, 83, 83, 87, 91, 92, 88, 92, - 91, 88, 90, 97, 95, 89, 83, 74, 77, 82, 84, 90, 92, 78, 72, - 76, 75, 75, 81, 95, 101, 95, 92, 95, 93, 90, 89, 90, 87, 86, - 84, 86, 88, 90, 90, 87, 90, 89, 90, 89, 98, 98, 92, 84, 75, - 76, 81, 81, 86, 91, 81, 72, 74, 74, 75, 81, 104, 108, 93, 92, - 95, 94, 88, 87, 89, 87, 85, 85, 88, 89, 93, 91, 88, 88, 91, - 88, 91, 106, 108, 93, 89, 78, 75, 77, 80, 85, 86, 85, 73, 72, - 73, 74, 79, 102, 101, 88, 92, 93, 91, 87, 87, 86, 87, 85, 86, - 88, 89, 94, 94, 90, 88, 85, 86, 98, 109, 113, 92, 93, 83, 76, - 74, 79, 84, 85, 81, 75, 72, 73, 74, 79, 105, 86, 86, 92, 96, - 98, 104, 86, 85, 85, 85, 88, 90, 90, 93, 92, 88, 87, 86, 89, - 97, 110, 109, 92, 93, 89, 78, 79, 78, 89, 84, 75, 76, 73, 72, - 73, 78, 105, 83, 82, 88, 83, 107, 95, 84, 85, 84, 86, 87, 90, - 91, 92, 90, 88, 87, 89, 90, 91, 99, 107, 96, 94, 91, 82, 84, - 86, 91, 87, 75, 74, 73, 73, 73, 77, 101, 86, 83, 89, 92, 99, - 98, 86, 86, 87, 83, 84, 89, 89, 92, 92, 92, 96, 96, 87, 91, - 90, 98, 96, 97, 94, 87, 88, 89, 92, 90, 79, 72, 73, 73, 74, - 77, 100, 92, 84, 86, 98, 100, 92, 87, 88, 88, 84, 83, 87, 89, - 91, 94, 94, 96, 93, 87, 87, 84, 109, 93, 92, 95, 92, 94, 93, - 92, 91, 82, 72, 73, 74, 74, 76, 95, 89, 85, 84, 102, 89, 85, - 88, 94, 86, 82, 83, 82, 91, 94, 97, 90, 92, 85, 90, 85, 79, - 125, 89, 96, 94, 90, 94, 95, 91, 91, 85, 76, 72, 73, 74, 75, - 88, 100, 83, 84, 84, 83, 85, 88, 90, 85, 84, 83, 84, 88, 92, - 93, 90, 89, 84, 90, 94, 79, 139, 93, 97, 97, 93, 92, 95, 91, - 90, 87, 81, 74, 73, 73, 74, 85, 97, 95, 95, 89, 86, 86, 92, - 87, 85, 84, 90, 86, 85, 91, 87, 87, 86, 93, 124, 140, 106, 143, - 101, 95, 97, 97, 96, 95, 84, 88, 87, 82, 78, 73, 73, 74, 82, - 92, 104, 95, 88, 89, 87, 89, 86, 85, 86, 87, 87, 81, 81, 83, - 91, 106, 131, 153, 151, 123, 133, 99, 101, 102, 99, 96, 90, 83, 82, - 85, 84, 79, 76, 74, 74, 78, 81, 89, 96, 90, 93, 88, 88, 86, - 88, 89, 95, 89, 82, 81, 85, 104, 118, 141, 160, 129, 137, 147, 103, - 104, 98, 99, 90, 88, 81, 76, 81, 83, 79, 77, 75, 75, 75, 76, - 80, 90, 94, 87, 86, 87, 92, 85, 85, 85, 87, 87, 89, 91, 112, - 115, 145, 154, 145, 141, 147, 106, 103, 100, 99, 92, 82, 78, 75, 78, - 81, 79, 77, 77, 78, 78, 76, 77, 81, 89, 87, 84, 84, 90, 86, - 85, 84, 80, 85, 97, 104, 119, 119, 149, 147, 144, 146, 152, 107, 105, - 103, 100, 93, 83, 78, 74, 74, 79, 78, 77, 76, 78, 80, 79, 76, - 78, 83, 84, 81, 81, 84, 83, 82, 78, 78, 85, 86, 97, 105, 114, - 145, 146, 148, 147, 150, 107, 105, 103, 97, 92, 84, 72, 72, 75, 77, - 76, 75, 76, 79, 80, 80, 77, 76, 82, 81, 80, 81, 80, 80, 80, - 77, 74, 74, 73, 77, 91, 110, 132, 141, 152, 152, 145, 107, 105, 103, - 96, 92, 86, 73, 71, 73, 75, 75, 76, 76, 78, 80, 80, 80, 98, - 80, 80, 82, 82, 80, 78, 76, 73, 71, 72, 71, 74, 80, 108, 119, - 136, 158, 142, 137, 107, 104, 101, 97, 85, 87, 75, 70, 70, 74, 74, - 75, 77, 78, 80, 82, 110, 117, 110, 78, 81, 83, 81, 78, 76, 73, - 71, 69, 68, 71, 74, 95, 120, 138, 148, 143, 139}; +const unsigned char byte_array1[XSIZE * YSIZE]= +{ +86, 84, 86, 90, 89, 85, 90, 78, 77, 79, 75, 77, 79, 86, +87, 83, 82, 87, 89, 88, 86, 87, 88, 87, 81, 84, 85, 85, +84, 86, 88, 91, 96, 95, 97, 95, 89, +85, 82, 81, 88, 89, 85, 89, 83, 74, 79, 76, 77, 80, 87, +87, 84, 84, 88, 90, 89, 87, 85, 87, 88, 83, 80, 82, 84, +85, 87, 90, 95, 96, 95, 95, 92, 90, +85, 81, 79, 84, 90, 87, 88, 88, 73, 79, 75, 76, 79, 88, +88, 87, 85, 90, 92, 89, 88, 88, 87, 86, 84, 82, 82, 83, +87, 89, 93, 94, 93, 93, 92, 92, 96, +85, 82, 76, 80, 88, 89, 88, 89, 73, 80, 75, 75, 77, 89, +92, 93, 91, 89, 94, 92, 90, 89, 88, 84, 84, 82, 82, 85, +88, 91, 94, 93, 93, 89, 90, 96, 96, +87, 83, 75, 77, 83, 89, 90, 90, 74, 78, 76, 76, 76, 84, +94, 100, 89, 92, 94, 92, 90, 89, 90, 85, 84, 83, 83, 87, +91, 92, 88, 92, 91, 88, 90, 97, 95, +89, 83, 74, 77, 82, 84, 90, 92, 78, 72, 76, 75, 75, 81, +95, 101, 95, 92, 95, 93, 90, 89, 90, 87, 86, 84, 86, 88, +90, 90, 87, 90, 89, 90, 89, 98, 98, +92, 84, 75, 76, 81, 81, 86, 91, 81, 72, 74, 74, 75, 81, +104, 108, 93, 92, 95, 94, 88, 87, 89, 87, 85, 85, 88, 89, +93, 91, 88, 88, 91, 88, 91, 106, 108, +93, 89, 78, 75, 77, 80, 85, 86, 85, 73, 72, 73, 74, 79, +102, 101, 88, 92, 93, 91, 87, 87, 86, 87, 85, 86, 88, 89, +94, 94, 90, 88, 85, 86, 98, 109, 113, +92, 93, 83, 76, 74, 79, 84, 85, 81, 75, 72, 73, 74, 79, +105, 86, 86, 92, 96, 98, 104, 86, 85, 85, 85, 88, 90, 90, +93, 92, 88, 87, 86, 89, 97, 110, 109, +92, 93, 89, 78, 79, 78, 89, 84, 75, 76, 73, 72, 73, 78, +105, 83, 82, 88, 83, 107, 95, 84, 85, 84, 86, 87, 90, 91, +92, 90, 88, 87, 89, 90, 91, 99, 107, +96, 94, 91, 82, 84, 86, 91, 87, 75, 74, 73, 73, 73, 77, +101, 86, 83, 89, 92, 99, 98, 86, 86, 87, 83, 84, 89, 89, +92, 92, 92, 96, 96, 87, 91, 90, 98, +96, 97, 94, 87, 88, 89, 92, 90, 79, 72, 73, 73, 74, 77, +100, 92, 84, 86, 98, 100, 92, 87, 88, 88, 84, 83, 87, 89, +91, 94, 94, 96, 93, 87, 87, 84, 109, +93, 92, 95, 92, 94, 93, 92, 91, 82, 72, 73, 74, 74, 76, +95, 89, 85, 84, 102, 89, 85, 88, 94, 86, 82, 83, 82, 91, +94, 97, 90, 92, 85, 90, 85, 79, 125, +89, 96, 94, 90, 94, 95, 91, 91, 85, 76, 72, 73, 74, 75, +88, 100, 83, 84, 84, 83, 85, 88, 90, 85, 84, 83, 84, 88, +92, 93, 90, 89, 84, 90, 94, 79, 139, +93, 97, 97, 93, 92, 95, 91, 90, 87, 81, 74, 73, 73, 74, +85, 97, 95, 95, 89, 86, 86, 92, 87, 85, 84, 90, 86, 85, +91, 87, 87, 86, 93, 124, 140, 106, 143, +101, 95, 97, 97, 96, 95, 84, 88, 87, 82, 78, 73, 73, 74, +82, 92, 104, 95, 88, 89, 87, 89, 86, 85, 86, 87, 87, 81, +81, 83, 91, 106, 131, 153, 151, 123, 133, +99, 101, 102, 99, 96, 90, 83, 82, 85, 84, 79, 76, 74, 74, +78, 81, 89, 96, 90, 93, 88, 88, 86, 88, 89, 95, 89, 82, +81, 85, 104, 118, 141, 160, 129, 137, 147, +103, 104, 98, 99, 90, 88, 81, 76, 81, 83, 79, 77, 75, 75, +75, 76, 80, 90, 94, 87, 86, 87, 92, 85, 85, 85, 87, 87, +89, 91, 112, 115, 145, 154, 145, 141, 147, +106, 103, 100, 99, 92, 82, 78, 75, 78, 81, 79, 77, 77, 78, +78, 76, 77, 81, 89, 87, 84, 84, 90, 86, 85, 84, 80, 85, +97, 104, 119, 119, 149, 147, 144, 146, 152, +107, 105, 103, 100, 93, 83, 78, 74, 74, 79, 78, 77, 76, 78, +80, 79, 76, 78, 83, 84, 81, 81, 84, 83, 82, 78, 78, 85, +86, 97, 105, 114, 145, 146, 148, 147, 150, +107, 105, 103, 97, 92, 84, 72, 72, 75, 77, 76, 75, 76, 79, +80, 80, 77, 76, 82, 81, 80, 81, 80, 80, 80, 77, 74, 74, +73, 77, 91, 110, 132, 141, 152, 152, 145, +107, 105, 103, 96, 92, 86, 73, 71, 73, 75, 75, 76, 76, 78, +80, 80, 80, 98, 80, 80, 82, 82, 80, 78, 76, 73, 71, 72, +71, 74, 80, 108, 119, 136, 158, 142, 137, +107, 104, 101, 97, 85, 87, 75, 70, 70, 74, 74, 75, 77, 78, +80, 82, 110, 117, 110, 78, 81, 83, 81, 78, 76, 73, 71, 69, +68, 71, 74, 95, 120, 138, 148, 143, 139 +}; const size_t byte_array1_size = sizeof(byte_array1); -const unsigned char byte_array2[YSIZE * XSIZE] = { - 77, 73, 76, 80, 79, 75, 82, 65, 62, 64, 59, 59, 61, 72, 70, - 67, 65, 70, 71, 70, 68, 66, 65, 67, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 65, 63, 63, 62, 75, 71, 71, 79, 81, 75, 81, 73, - 59, 65, 60, 60, 64, 73, 73, 68, 66, 70, 72, 71, 68, 66, 66, - 67, 66, 66, 66, 67, 67, 67, 66, 67, 66, 64, 63, 63, 63, 76, - 71, 66, 73, 81, 78, 80, 79, 59, 66, 60, 59, 62, 74, 74, 71, - 67, 70, 73, 71, 68, 66, 65, 65, 66, 66, 67, 67, 67, 67, 67, - 67, 66, 64, 64, 64, 64, 76, 72, 64, 68, 79, 81, 80, 80, 59, - 68, 60, 59, 60, 75, 75, 73, 67, 68, 73, 72, 68, 66, 65, 63, - 67, 67, 67, 67, 68, 67, 67, 66, 65, 64, 65, 65, 65, 79, 72, - 63, 66, 73, 80, 83, 82, 60, 65, 61, 61, 60, 66, 75, 75, 65, - 70, 73, 72, 68, 66, 65, 64, 68, 67, 68, 68, 68, 67, 67, 66, - 65, 65, 65, 66, 65, 81, 73, 62, 65, 72, 74, 82, 85, 66, 59, - 62, 60, 60, 63, 75, 76, 68, 69, 72, 72, 68, 66, 66, 65, 67, - 68, 68, 68, 68, 68, 66, 66, 64, 66, 65, 66, 66, 84, 74, 64, - 64, 70, 71, 78, 84, 70, 58, 60, 59, 59, 63, 75, 80, 73, 67, - 72, 72, 68, 66, 66, 65, 66, 68, 68, 68, 68, 68, 66, 65, 65, - 65, 66, 67, 68, 87, 81, 66, 63, 65, 68, 76, 76, 75, 59, 58, - 59, 59, 60, 71, 92, 65, 64, 74, 72, 69, 67, 65, 65, 65, 68, - 69, 68, 69, 67, 65, 65, 65, 65, 67, 68, 69, 86, 86, 73, 64, - 62, 67, 75, 76, 70, 61, 58, 58, 59, 60, 81, 68, 59, 63, 74, - 90, 99, 67, 65, 65, 64, 67, 68, 68, 68, 67, 65, 65, 66, 65, - 66, 68, 68, 85, 85, 80, 66, 67, 67, 81, 74, 62, 63, 59, 58, - 58, 60, 93, 61, 59, 59, 68, 115, 76, 67, 66, 64, 64, 66, 68, - 68, 68, 66, 65, 65, 66, 65, 64, 65, 69, 90, 87, 83, 71, 74, - 77, 83, 79, 63, 60, 59, 59, 58, 58, 90, 61, 59, 59, 67, 80, - 71, 68, 66, 64, 63, 63, 68, 68, 68, 66, 65, 66, 67, 65, 64, - 62, 87, 91, 92, 86, 76, 78, 81, 85, 82, 67, 59, 59, 59, 59, - 60, 88, 72, 59, 60, 74, 80, 70, 67, 66, 64, 62, 60, 65, 68, - 67, 66, 65, 67, 66, 64, 62, 59, 111, 84, 84, 87, 85, 87, 85, - 84, 84, 72, 59, 59, 59, 59, 59, 73, 71, 62, 59, 100, 70, 70, - 67, 66, 64, 60, 58, 58, 67, 68, 66, 65, 66, 64, 63, 59, 56, - 131, 80, 90, 87, 83, 88, 89, 84, 83, 76, 64, 59, 59, 59, 58, - 59, 97, 64, 62, 71, 68, 70, 73, 66, 63, 61, 58, 58, 62, 67, - 66, 64, 65, 63, 63, 61, 57, 149, 86, 91, 92, 87, 85, 88, 83, - 81, 78, 69, 61, 59, 59, 59, 59, 61, 83, 72, 67, 67, 69, 69, - 66, 64, 61, 72, 56, 57, 64, 64, 64, 64, 65, 115, 150, 93, 151, - 97, 89, 91, 92, 89, 88, 74, 80, 78, 71, 65, 59, 58, 59, 58, - 59, 71, 72, 67, 70, 70, 69, 67, 64, 63, 66, 56, 54, 57, 59, - 64, 87, 139, 162, 160, 128, 141, 94, 96, 97, 94, 89, 82, 71, 70, - 76, 73, 67, 61, 59, 59, 58, 59, 61, 71, 67, 75, 70, 68, 70, - 65, 63, 63, 59, 56, 54, 55, 90, 121, 149, 168, 138, 144, 157, 99, - 100, 93, 93, 82, 80, 70, 62, 70, 72, 67, 63, 60, 60, 58, 58, - 60, 68, 70, 70, 69, 68, 79, 68, 64, 62, 60, 59, 57, 57, 88, - 120, 151, 162, 154, 149, 155, 103, 99, 95, 94, 84, 73, 67, 62, 65, - 69, 67, 64, 63, 64, 63, 59, 60, 65, 71, 69, 69, 67, 78, 65, - 63, 61, 59, 61, 60, 68, 100, 128, 155, 155, 152, 155, 164, 104, 102, - 99, 95, 86, 74, 67, 61, 61, 66, 65, 63, 63, 64, 65, 63, 60, - 63, 70, 69, 67, 67, 67, 65, 62, 60, 58, 57, 62, 58, 71, 117, - 150, 154, 157, 155, 163, 104, 101, 99, 91, 84, 74, 59, 59, 62, 64, - 63, 61, 62, 64, 64, 64, 61, 60, 69, 68, 67, 69, 67, 65, 62, - 59, 58, 57, 57, 56, 59, 104, 137, 147, 159, 161, 158, 104, 101, 99, - 90, 85, 77, 60, 57, 60, 62, 62, 62, 63, 64, 65, 65, 66, 100, - 67, 67, 69, 69, 67, 65, 63, 60, 58, 56, 54, 55, 56, 77, 122, - 142, 166, 157, 150, 104, 101, 97, 92, 77, 79, 64, 57, 57, 62, 62, - 62, 64, 65, 66, 65, 115, 138, 129, 64, 68, 70, 68, 66, 64, 60, - 58, 56, 53, 53, 56, 62, 115, 143, 157, 156, 159}; +const unsigned char byte_array2[YSIZE * XSIZE] = +{ +77, 73, 76, 80, 79, 75, 82, 65, 62, 64, 59, 59, 61, 72, +70, 67, 65, 70, 71, 70, 68, 66, 65, 67, 66, 66, 66, 66, +66, 66, 66, 66, 66, 65, 63, 63, 62, +75, 71, 71, 79, 81, 75, 81, 73, 59, 65, 60, 60, 64, 73, +73, 68, 66, 70, 72, 71, 68, 66, 66, 67, 66, 66, 66, 67, +67, 67, 66, 67, 66, 64, 63, 63, 63, +76, 71, 66, 73, 81, 78, 80, 79, 59, 66, 60, 59, 62, 74, +74, 71, 67, 70, 73, 71, 68, 66, 65, 65, 66, 66, 67, 67, +67, 67, 67, 67, 66, 64, 64, 64, 64, +76, 72, 64, 68, 79, 81, 80, 80, 59, 68, 60, 59, 60, 75, +75, 73, 67, 68, 73, 72, 68, 66, 65, 63, 67, 67, 67, 67, +68, 67, 67, 66, 65, 64, 65, 65, 65, +79, 72, 63, 66, 73, 80, 83, 82, 60, 65, 61, 61, 60, 66, +75, 75, 65, 70, 73, 72, 68, 66, 65, 64, 68, 67, 68, 68, +68, 67, 67, 66, 65, 65, 65, 66, 65, +81, 73, 62, 65, 72, 74, 82, 85, 66, 59, 62, 60, 60, 63, +75, 76, 68, 69, 72, 72, 68, 66, 66, 65, 67, 68, 68, 68, +68, 68, 66, 66, 64, 66, 65, 66, 66, +84, 74, 64, 64, 70, 71, 78, 84, 70, 58, 60, 59, 59, 63, +75, 80, 73, 67, 72, 72, 68, 66, 66, 65, 66, 68, 68, 68, +68, 68, 66, 65, 65, 65, 66, 67, 68, +87, 81, 66, 63, 65, 68, 76, 76, 75, 59, 58, 59, 59, 60, +71, 92, 65, 64, 74, 72, 69, 67, 65, 65, 65, 68, 69, 68, +69, 67, 65, 65, 65, 65, 67, 68, 69, +86, 86, 73, 64, 62, 67, 75, 76, 70, 61, 58, 58, 59, 60, +81, 68, 59, 63, 74, 90, 99, 67, 65, 65, 64, 67, 68, 68, +68, 67, 65, 65, 66, 65, 66, 68, 68, +85, 85, 80, 66, 67, 67, 81, 74, 62, 63, 59, 58, 58, 60, +93, 61, 59, 59, 68, 115, 76, 67, 66, 64, 64, 66, 68, 68, +68, 66, 65, 65, 66, 65, 64, 65, 69, +90, 87, 83, 71, 74, 77, 83, 79, 63, 60, 59, 59, 58, 58, +90, 61, 59, 59, 67, 80, 71, 68, 66, 64, 63, 63, 68, 68, +68, 66, 65, 66, 67, 65, 64, 62, 87, +91, 92, 86, 76, 78, 81, 85, 82, 67, 59, 59, 59, 59, 60, +88, 72, 59, 60, 74, 80, 70, 67, 66, 64, 62, 60, 65, 68, +67, 66, 65, 67, 66, 64, 62, 59, 111, +84, 84, 87, 85, 87, 85, 84, 84, 72, 59, 59, 59, 59, 59, +73, 71, 62, 59, 100, 70, 70, 67, 66, 64, 60, 58, 58, 67, +68, 66, 65, 66, 64, 63, 59, 56, 131, +80, 90, 87, 83, 88, 89, 84, 83, 76, 64, 59, 59, 59, 58, +59, 97, 64, 62, 71, 68, 70, 73, 66, 63, 61, 58, 58, 62, +67, 66, 64, 65, 63, 63, 61, 57, 149, +86, 91, 92, 87, 85, 88, 83, 81, 78, 69, 61, 59, 59, 59, +59, 61, 83, 72, 67, 67, 69, 69, 66, 64, 61, 72, 56, 57, +64, 64, 64, 64, 65, 115, 150, 93, 151, +97, 89, 91, 92, 89, 88, 74, 80, 78, 71, 65, 59, 58, 59, +58, 59, 71, 72, 67, 70, 70, 69, 67, 64, 63, 66, 56, 54, +57, 59, 64, 87, 139, 162, 160, 128, 141, +94, 96, 97, 94, 89, 82, 71, 70, 76, 73, 67, 61, 59, 59, +58, 59, 61, 71, 67, 75, 70, 68, 70, 65, 63, 63, 59, 56, +54, 55, 90, 121, 149, 168, 138, 144, 157, +99, 100, 93, 93, 82, 80, 70, 62, 70, 72, 67, 63, 60, 60, +58, 58, 60, 68, 70, 70, 69, 68, 79, 68, 64, 62, 60, 59, +57, 57, 88, 120, 151, 162, 154, 149, 155, +103, 99, 95, 94, 84, 73, 67, 62, 65, 69, 67, 64, 63, 64, +63, 59, 60, 65, 71, 69, 69, 67, 78, 65, 63, 61, 59, 61, +60, 68, 100, 128, 155, 155, 152, 155, 164, +104, 102, 99, 95, 86, 74, 67, 61, 61, 66, 65, 63, 63, 64, +65, 63, 60, 63, 70, 69, 67, 67, 67, 65, 62, 60, 58, 57, +62, 58, 71, 117, 150, 154, 157, 155, 163, +104, 101, 99, 91, 84, 74, 59, 59, 62, 64, 63, 61, 62, 64, +64, 64, 61, 60, 69, 68, 67, 69, 67, 65, 62, 59, 58, 57, +57, 56, 59, 104, 137, 147, 159, 161, 158, +104, 101, 99, 90, 85, 77, 60, 57, 60, 62, 62, 62, 63, 64, +65, 65, 66, 100, 67, 67, 69, 69, 67, 65, 63, 60, 58, 56, +54, 55, 56, 77, 122, 142, 166, 157, 150, +104, 101, 97, 92, 77, 79, 64, 57, 57, 62, 62, 62, 64, 65, +66, 65, 115, 138, 129, 64, 68, 70, 68, 66, 64, 60, 58, 56, +53, 53, 56, 62, 115, 143, 157, 156, 159 +}; const size_t byte_array2_size = sizeof(byte_array2); -const unsigned char byte_array3[YSIZE * XSIZE] = { - 211, 221, 216, 201, 205, 216, 195, 236, 244, 237, 250, 250, 248, 218, 223, - 232, 236, 224, 221, 221, 227, 231, 232, 227, 229, 227, 227, 225, 227, 225, - 226, 226, 226, 228, 234, 234, 234, 216, 226, 228, 205, 200, 214, 198, 215, - 250, 233, 247, 250, 242, 219, 220, 229, 235, 225, 217, 220, 227, 232, 230, - 228, 229, 228, 227, 224, 225, 223, 226, 225, 226, 230, 233, 233, 234, 213, - 227, 237, 220, 200, 204, 202, 201, 248, 231, 246, 250, 245, 214, 215, 223, - 232, 225, 218, 218, 225, 230, 232, 231, 229, 227, 225, 224, 223, 226, 224, - 225, 228, 229, 230, 232, 231, 215, 223, 242, 233, 206, 200, 201, 197, 250, - 227, 250, 249, 248, 211, 212, 216, 233, 229, 216, 218, 225, 230, 232, 237, - 226, 224, 224, 223, 225, 225, 224, 225, 228, 229, 231, 229, 231, 208, 220, - 247, 238, 221, 202, 194, 194, 245, 237, 247, 247, 249, 234, 210, 212, 237, - 222, 219, 217, 226, 229, 232, 235, 222, 222, 223, 223, 223, 224, 224, 227, - 226, 229, 229, 228, 231, 200, 221, 247, 239, 224, 217, 196, 189, 229, 248, - 245, 248, 250, 241, 210, 210, 230, 225, 218, 218, 224, 230, 230, 229, 224, - 222, 222, 222, 222, 223, 225, 226, 231, 226, 228, 229, 230, 191, 216, 246, - 245, 226, 228, 207, 191, 221, 251, 248, 249, 251, 245, 214, 214, 233, 229, - 217, 217, 224, 229, 230, 229, 225, 220, 223, 221, 222, 224, 224, 227, 230, - 227, 226, 229, 230, 187, 199, 238, 248, 242, 231, 213, 211, 209, 246, 248, - 251, 251, 250, 226, 215, 236, 237, 217, 215, 222, 226, 229, 229, 227, 222, - 222, 223, 222, 225, 227, 228, 226, 227, 228, 228, 230, 188, 189, 221, 243, - 247, 237, 215, 209, 223, 241, 248, 248, 250, 248, 228, 234, 251, 239, 219, - 210, 205, 224, 229, 228, 230, 221, 223, 223, 222, 226, 229, 228, 224, 227, - 229, 230, 232, 190, 190, 201, 235, 236, 238, 198, 214, 243, 238, 248, 248, - 250, 249, 215, 244, 250, 250, 240, 168, 220, 224, 228, 230, 231, 226, 221, - 224, 223, 226, 230, 227, 226, 226, 230, 233, 234, 179, 185, 195, 224, 215, - 210, 195, 204, 239, 245, 250, 250, 252, 254, 216, 243, 249, 249, 233, 210, - 215, 223, 227, 230, 234, 234, 224, 223, 223, 227, 230, 226, 226, 228, 231, - 235, 212, 178, 174, 190, 211, 207, 199, 189, 194, 230, 250, 250, 250, 253, - 253, 222, 225, 250, 248, 218, 216, 217, 225, 226, 232, 239, 242, 229, 223, - 224, 229, 230, 225, 228, 230, 236, 241, 183, 194, 194, 185, 190, 185, 190, - 191, 191, 219, 250, 251, 250, 253, 254, 241, 225, 246, 249, 198, 217, 220, - 224, 225, 234, 241, 242, 246, 224, 223, 227, 229, 227, 228, 234, 237, 245, - 149, 203, 178, 182, 193, 185, 179, 191, 194, 211, 236, 252, 252, 254, 254, - 253, 192, 240, 244, 235, 224, 220, 229, 224, 236, 239, 243, 244, 236, 224, - 229, 230, 229, 231, 230, 233, 244, 128, 188, 177, 171, 184, 191, 182, 196, - 197, 208, 224, 247, 253, 255, 252, 250, 248, 226, 216, 228, 230, 220, 220, - 227, 234, 237, 231, 247, 244, 231, 231, 229, 228, 229, 182, 128, 196, 118, - 160, 182, 174, 172, 179, 183, 216, 203, 206, 220, 236, 253, 254, 253, 253, - 249, 225, 219, 232, 230, 220, 224, 227, 233, 237, 234, 244, 250, 245, 240, - 224, 212, 174, 123, 124, 176, 127, 171, 163, 161, 167, 177, 198, 221, 228, - 212, 215, 233, 245, 252, 255, 253, 252, 251, 223, 231, 216, 222, 227, 231, - 231, 234, 227, 238, 245, 249, 244, 210, 177, 124, 129, 134, 124, 113, 156, - 155, 172, 168, 197, 201, 224, 247, 224, 219, 233, 242, 249, 250, 252, 254, - 252, 230, 230, 224, 224, 225, 225, 227, 232, 232, 235, 239, 239, 241, 213, - 178, 131, 128, 128, 120, 114, 149, 157, 165, 168, 191, 218, 231, 246, 237, - 226, 234, 241, 243, 239, 244, 252, 249, 237, 225, 226, 224, 227, 220, 229, - 235, 235, 239, 238, 236, 230, 204, 177, 125, 131, 127, 117, 111, 146, 151, - 158, 166, 187, 215, 230, 246, 246, 231, 238, 243, 246, 243, 241, 244, 253, - 245, 226, 226, 229, 229, 229, 231, 236, 238, 241, 240, 241, 235, 224, 188, - 134, 123, 127, 116, 116, 144, 151, 158, 173, 190, 214, 251, 250, 243, 236, - 242, 249, 246, 241, 241, 244, 251, 251, 228, 230, 230, 226, 232, 231, 236, - 241, 243, 244, 243, 243, 235, 200, 150, 128, 122, 119, 117, 144, 151, 156, - 176, 190, 207, 246, 253, 244, 239, 244, 246, 244, 242, 240, 243, 249, 198, - 239, 234, 226, 226, 228, 234, 238, 241, 244, 245, 247, 250, 244, 219, 182, - 138, 118, 118, 116, 143, 150, 162, 173, 208, 205, 238, 253, 251, 241, 244, - 244, 242, 243, 238, 246, 193, 146, 173, 246, 231, 223, 230, 232, 236, 240, - 245, 247, 252, 252, 245, 233, 195, 138, 114, 118, 108}; +const unsigned char byte_array3[YSIZE * XSIZE] = +{ +211, 221, 216, 201, 205, 216, 195, 236, 244, 237, 250, 250, 248, 218, +223, 232, 236, 224, 221, 221, 227, 231, 232, 227, 229, 227, 227, 225, +227, 225, 226, 226, 226, 228, 234, 234, 234, 216, 226, 228, 205, 200, +214, 198, 215, 250, 233, 247, 250, 242, 219, 220, 229, 235, 225, 217, +220, 227, 232, 230, 228, 229, 228, 227, 224, 225, 223, 226, 225, 226, +230, 233, 233, 234, 213, 227, 237, 220, 200, 204, 202, 201, 248, 231, +246, 250, 245, 214, 215, 223, 232, 225, 218, 218, 225, 230, 232, 231, +229, 227, 225, 224, 223, 226, 224, 225, 228, 229, 230, 232, 231, 215, +223, 242, 233, 206, 200, 201, 197, 250, 227, 250, 249, 248, 211, 212, +216, 233, 229, 216, 218, 225, 230, 232, 237, 226, 224, 224, 223, 225, +225, 224, 225, 228, 229, 231, 229, 231, 208, 220, 247, 238, 221, 202, +194, 194, 245, 237, 247, 247, 249, 234, 210, 212, 237, 222, 219, 217, +226, 229, 232, 235, 222, 222, 223, 223, 223, 224, 224, 227, 226, 229, +229, 228, 231, 200, 221, 247, 239, 224, 217, 196, 189, 229, 248, 245, +248, 250, 241, 210, 210, 230, 225, 218, 218, 224, 230, 230, 229, 224, +222, 222, 222, 222, 223, 225, 226, 231, 226, 228, 229, 230, 191, 216, +246, 245, 226, 228, 207, 191, 221, 251, 248, 249, 251, 245, 214, 214, +233, 229, 217, 217, 224, 229, 230, 229, 225, 220, 223, 221, 222, 224, +224, 227, 230, 227, 226, 229, 230, 187, 199, 238, 248, 242, 231, 213, +211, 209, 246, 248, 251, 251, 250, 226, 215, 236, 237, 217, 215, 222, +226, 229, 229, 227, 222, 222, 223, 222, 225, 227, 228, 226, 227, 228, +228, 230, 188, 189, 221, 243, 247, 237, 215, 209, 223, 241, 248, 248, +250, 248, 228, 234, 251, 239, 219, 210, 205, 224, 229, 228, 230, 221, +223, 223, 222, 226, 229, 228, 224, 227, 229, 230, 232, 190, 190, 201, +235, 236, 238, 198, 214, 243, 238, 248, 248, 250, 249, 215, 244, 250, +250, 240, 168, 220, 224, 228, 230, 231, 226, 221, 224, 223, 226, 230, +227, 226, 226, 230, 233, 234, 179, 185, 195, 224, 215, 210, 195, 204, +239, 245, 250, 250, 252, 254, 216, 243, 249, 249, 233, 210, 215, 223, +227, 230, 234, 234, 224, 223, 223, 227, 230, 226, 226, 228, 231, 235, +212, 178, 174, 190, 211, 207, 199, 189, 194, 230, 250, 250, 250, 253, +253, 222, 225, 250, 248, 218, 216, 217, 225, 226, 232, 239, 242, 229, +223, 224, 229, 230, 225, 228, 230, 236, 241, 183, 194, 194, 185, 190, +185, 190, 191, 191, 219, 250, 251, 250, 253, 254, 241, 225, 246, 249, +198, 217, 220, 224, 225, 234, 241, 242, 246, 224, 223, 227, 229, 227, +228, 234, 237, 245, 149, 203, 178, 182, 193, 185, 179, 191, 194, 211, +236, 252, 252, 254, 254, 253, 192, 240, 244, 235, 224, 220, 229, 224, +236, 239, 243, 244, 236, 224, 229, 230, 229, 231, 230, 233, 244, 128, +188, 177, 171, 184, 191, 182, 196, 197, 208, 224, 247, 253, 255, 252, +250, 248, 226, 216, 228, 230, 220, 220, 227, 234, 237, 231, 247, 244, +231, 231, 229, 228, 229, 182, 128, 196, 118, 160, 182, 174, 172, 179, +183, 216, 203, 206, 220, 236, 253, 254, 253, 253, 249, 225, 219, 232, +230, 220, 224, 227, 233, 237, 234, 244, 250, 245, 240, 224, 212, 174, +123, 124, 176, 127, 171, 163, 161, 167, 177, 198, 221, 228, 212, 215, +233, 245, 252, 255, 253, 252, 251, 223, 231, 216, 222, 227, 231, 231, +234, 227, 238, 245, 249, 244, 210, 177, 124, 129, 134, 124, 113, 156, +155, 172, 168, 197, 201, 224, 247, 224, 219, 233, 242, 249, 250, 252, +254, 252, 230, 230, 224, 224, 225, 225, 227, 232, 232, 235, 239, 239, +241, 213, 178, 131, 128, 128, 120, 114, 149, 157, 165, 168, 191, 218, +231, 246, 237, 226, 234, 241, 243, 239, 244, 252, 249, 237, 225, 226, +224, 227, 220, 229, 235, 235, 239, 238, 236, 230, 204, 177, 125, 131, +127, 117, 111, 146, 151, 158, 166, 187, 215, 230, 246, 246, 231, 238, +243, 246, 243, 241, 244, 253, 245, 226, 226, 229, 229, 229, 231, 236, +238, 241, 240, 241, 235, 224, 188, 134, 123, 127, 116, 116, 144, 151, +158, 173, 190, 214, 251, 250, 243, 236, 242, 249, 246, 241, 241, 244, +251, 251, 228, 230, 230, 226, 232, 231, 236, 241, 243, 244, 243, 243, +235, 200, 150, 128, 122, 119, 117, 144, 151, 156, 176, 190, 207, 246, +253, 244, 239, 244, 246, 244, 242, 240, 243, 249, 198, 239, 234, 226, +226, 228, 234, 238, 241, 244, 245, 247, 250, 244, 219, 182, 138, 118, +118, 116, 143, 150, 162, 173, 208, 205, 238, 253, 251, 241, 244, 244, +242, 243, 238, 246, 193, 146, 173, 246, 231, 223, 230, 232, 236, 240, +245, 247, 252, 252, 245, 233, 195, 138, 114, 118, 108 +}; const size_t byte_array3_size = sizeof(byte_array3); -const float array_float1[YSIZE * XSIZE] = { - 234.866, 229.404, 234.866, 245.790, 243.059, 232.135, 245.790, 213.018, - 210.287, 215.749, 204.825, 210.287, 215.749, 234.866, 237.597, 226.673, - 223.942, 237.597, 243.059, 240.328, 234.866, 237.597, 240.328, 237.597, - 221.211, 229.404, 232.135, 232.135, 229.404, 234.866, 240.328, 248.521, - 262.176, 259.445, 264.907, 259.445, 243.059, 232.135, 223.942, 221.211, - 240.328, 243.059, 232.135, 243.059, 226.673, 202.094, 215.749, 207.556, - 210.287, 218.480, 237.597, 237.597, 229.404, 229.404, 240.328, 245.790, - 243.059, 237.597, 232.135, 237.597, 240.328, 226.673, 218.480, 223.942, - 229.404, 232.135, 237.597, 245.790, 259.445, 262.176, 259.445, 259.445, - 251.252, 245.790, 232.135, 221.211, 215.749, 229.404, 245.790, 237.597, - 240.328, 240.328, 199.363, 215.749, 204.825, 207.556, 215.749, 240.328, - 240.328, 237.597, 232.135, 245.790, 251.252, 243.059, 240.328, 240.328, - 237.597, 234.866, 229.404, 223.942, 223.942, 226.673, 237.597, 243.059, - 253.983, 256.714, 253.983, 253.983, 251.252, 251.252, 262.176, 232.135, - 223.942, 207.556, 218.480, 240.328, 243.059, 240.328, 243.059, 199.363, - 218.480, 204.825, 204.825, 210.287, 243.059, 251.252, 253.983, 248.521, - 243.059, 256.714, 251.252, 245.790, 243.059, 240.328, 229.404, 229.404, - 223.942, 223.942, 232.135, 240.328, 248.521, 256.714, 253.983, 253.983, - 243.059, 245.790, 262.176, 262.176, 237.597, 226.673, 204.825, 210.287, - 226.673, 243.059, 245.790, 245.790, 202.094, 213.018, 207.556, 207.556, - 207.556, 229.404, 256.714, 273.100, 243.059, 251.252, 256.714, 251.252, - 245.790, 243.059, 245.790, 232.135, 229.404, 226.673, 226.673, 237.597, - 248.521, 251.252, 240.328, 251.252, 248.521, 240.328, 245.790, 264.907, - 259.445, 243.059, 226.673, 202.094, 210.287, 223.942, 229.404, 245.790, - 251.252, 213.018, 196.632, 207.556, 204.825, 204.825, 221.211, 259.445, - 275.831, 259.445, 251.252, 259.445, 253.983, 245.790, 243.059, 245.790, - 237.597, 234.866, 229.404, 234.866, 240.328, 245.790, 245.790, 237.597, - 245.790, 243.059, 245.790, 243.059, 267.638, 267.638, 251.252, 229.404, - 204.825, 207.556, 221.211, 221.211, 234.866, 248.521, 221.211, 196.632, - 202.094, 202.094, 204.825, 221.211, 284.024, 294.948, 253.983, 251.252, - 259.445, 256.714, 240.328, 237.597, 243.059, 237.597, 232.135, 232.135, - 240.328, 243.059, 253.983, 248.521, 240.328, 240.328, 248.521, 240.328, - 248.521, 289.486, 294.948, 253.983, 243.059, 213.018, 204.825, 210.287, - 218.480, 232.135, 234.866, 232.135, 199.363, 196.632, 199.363, 202.094, - 215.749, 278.562, 275.831, 240.328, 251.252, 253.983, 248.521, 237.597, - 237.597, 234.866, 237.597, 232.135, 234.866, 240.328, 243.059, 256.714, - 256.714, 245.790, 240.328, 232.135, 234.866, 267.638, 297.679, 308.603, - 251.252, 253.983, 226.673, 207.556, 202.094, 215.749, 229.404, 232.135, - 221.211, 204.825, 196.632, 199.363, 202.094, 215.749, 286.755, 234.866, - 234.866, 251.252, 262.176, 267.638, 284.024, 234.866, 232.135, 232.135, - 232.135, 240.328, 245.790, 245.790, 253.983, 251.252, 240.328, 237.597, - 234.866, 243.059, 264.907, 300.410, 297.679, 251.252, 253.983, 243.059, - 213.018, 215.749, 213.018, 243.059, 229.404, 204.825, 207.556, 199.363, - 196.632, 199.363, 213.018, 286.755, 226.673, 223.942, 240.328, 226.673, - 292.217, 259.445, 229.404, 232.135, 229.404, 234.866, 237.597, 245.790, - 248.521, 251.252, 245.790, 240.328, 237.597, 243.059, 245.790, 248.521, - 270.369, 292.217, 262.176, 256.714, 248.521, 223.942, 229.404, 234.866, - 248.521, 237.597, 204.825, 202.094, 199.363, 199.363, 199.363, 210.287, - 275.831, 234.866, 226.673, 243.059, 251.252, 270.369, 267.638, 234.866, - 234.866, 237.597, 226.673, 229.404, 243.059, 243.059, 251.252, 251.252, - 251.252, 262.176, 262.176, 237.597, 248.521, 245.790, 267.638, 262.176, - 264.907, 256.714, 237.597, 240.328, 243.059, 251.252, 245.790, 215.749, - 196.632, 199.363, 199.363, 202.094, 210.287, 273.100, 251.252, 229.404, - 234.866, 267.638, 273.100, 251.252, 237.597, 240.328, 240.328, 229.404, - 226.673, 237.597, 243.059, 248.521, 256.714, 256.714, 262.176, 253.983, - 237.597, 237.597, 229.404, 297.679, 253.983, 251.252, 259.445, 251.252, - 256.714, 253.983, 251.252, 248.521, 223.942, 196.632, 199.363, 202.094, - 202.094, 207.556, 259.445, 243.059, 232.135, 229.404, 278.562, 243.059, - 232.135, 240.328, 256.714, 234.866, 223.942, 226.673, 223.942, 248.521, - 256.714, 264.907, 245.790, 251.252, 232.135, 245.790, 232.135, 215.749, - 341.375, 243.059, 262.176, 256.714, 245.790, 256.714, 259.445, 248.521, - 248.521, 232.135, 207.556, 196.632, 199.363, 202.094, 204.825, 240.328, - 273.100, 226.673, 229.404, 229.404, 226.673, 232.135, 240.328, 245.790, - 232.135, 229.404, 226.673, 229.404, 240.328, 251.252, 253.983, 245.790, - 243.059, 229.404, 245.790, 256.714, 215.749, 379.609, 253.983, 264.907, - 264.907, 253.983, 251.252, 259.445, 248.521, 245.790, 237.597, 221.211, - 202.094, 199.363, 199.363, 202.094, 232.135, 264.907, 259.445, 259.445, - 243.059, 234.866, 234.866, 251.252, 237.597, 232.135, 229.404, 245.790, - 234.866, 232.135, 248.521, 237.597, 237.597, 234.866, 253.983, 338.644, - 382.340, 289.486, 390.533, 275.831, 259.445, 264.907, 264.907, 262.176, - 259.445, 229.404, 240.328, 237.597, 223.942, 213.018, 199.363, 199.363, - 202.094, 223.942, 251.252, 284.024, 259.445, 240.328, 243.059, 237.597, - 243.059, 234.866, 232.135, 234.866, 237.597, 237.597, 221.211, 221.211, - 226.673, 248.521, 289.486, 357.761, 417.843, 412.381, 335.913, 363.223, - 270.369, 275.831, 278.562, 270.369, 262.176, 245.790, 226.673, 223.942, - 232.135, 229.404, 215.749, 207.556, 202.094, 202.094, 213.018, 221.211, - 243.059, 262.176, 245.790, 253.983, 240.328, 240.328, 234.866, 240.328, - 243.059, 259.445, 243.059, 223.942, 221.211, 232.135, 284.024, 322.258, - 385.071, 436.960, 352.299, 374.147, 401.457, 281.293, 284.024, 267.638, - 270.369, 245.790, 240.328, 221.211, 207.556, 221.211, 226.673, 215.749, - 210.287, 204.825, 204.825, 204.825, 207.556, 218.480, 245.790, 256.714, - 237.597, 234.866, 237.597, 251.252, 232.135, 232.135, 232.135, 237.597, - 237.597, 243.059, 248.521, 305.872, 314.065, 395.995, 420.574, 395.995, - 385.071, 401.457, 289.486, 281.293, 273.100, 270.369, 251.252, 223.942, - 213.018, 204.825, 213.018, 221.211, 215.749, 210.287, 210.287, 213.018, - 213.018, 207.556, 210.287, 221.211, 243.059, 237.597, 229.404, 229.404, - 245.790, 234.866, 232.135, 229.404, 218.480, 232.135, 264.907, 284.024, - 324.989, 324.989, 406.919, 401.457, 393.264, 398.726, 415.112, 292.217, - 286.755, 281.293, 273.100, 253.983, 226.673, 213.018, 202.094, 202.094, - 215.749, 213.018, 210.287, 207.556, 213.018, 218.480, 215.749, 207.556, - 213.018, 226.673, 229.404, 221.211, 221.211, 229.404, 226.673, 223.942, - 213.018, 213.018, 232.135, 234.866, 264.907, 286.755, 311.334, 395.995, - 398.726, 404.188, 401.457, 409.650, 292.217, 286.755, 281.293, 264.907, - 251.252, 229.404, 196.632, 196.632, 204.825, 210.287, 207.556, 204.825, - 207.556, 215.749, 218.480, 218.480, 210.287, 207.556, 223.942, 221.211, - 218.480, 221.211, 218.480, 218.480, 218.480, 210.287, 202.094, 202.094, - 199.363, 210.287, 248.521, 300.410, 360.492, 385.071, 415.112, 415.112, - 395.995, 292.217, 286.755, 281.293, 262.176, 251.252, 234.866, 199.363, - 193.901, 199.363, 204.825, 204.825, 207.556, 207.556, 213.018, 218.480, - 218.480, 218.480, 267.638, 218.480, 218.480, 223.942, 223.942, 218.480, - 213.018, 207.556, 199.363, 193.901, 196.632, 193.901, 202.094, 218.480, - 294.948, 324.989, 371.416, 431.498, 387.802, 374.147, 292.217, 284.024, - 275.831, 264.907, 232.135, 237.597, 204.825, 191.170, 191.170, 202.094, - 202.094, 204.825, 210.287, 213.018, 218.480, 223.942, 300.410, 319.527, - 300.410, 213.018, 221.211, 226.673, 221.211, 213.018, 207.556, 199.363, - 193.901, 188.439, 185.708, 193.901, 202.094, 259.445, 327.720, 376.878, - 404.188, 390.533, 379.609}; +const float array_float1[YSIZE * XSIZE] = +{ +234.866, 229.404, 234.866, 245.790, 243.059, 232.135, 245.790, 213.018, +210.287, 215.749, 204.825, 210.287, 215.749, 234.866, 237.597, 226.673, +223.942, 237.597, 243.059, 240.328, 234.866, 237.597, 240.328, 237.597, +221.211, 229.404, 232.135, 232.135, 229.404, 234.866, 240.328, 248.521, +262.176, 259.445, 264.907, 259.445, 243.059, +232.135, 223.942, 221.211, 240.328, 243.059, 232.135, 243.059, 226.673, +202.094, 215.749, 207.556, 210.287, 218.480, 237.597, 237.597, 229.404, +229.404, 240.328, 245.790, 243.059, 237.597, 232.135, 237.597, 240.328, +226.673, 218.480, 223.942, 229.404, 232.135, 237.597, 245.790, 259.445, +262.176, 259.445, 259.445, 251.252, 245.790, +232.135, 221.211, 215.749, 229.404, 245.790, 237.597, 240.328, 240.328, +199.363, 215.749, 204.825, 207.556, 215.749, 240.328, 240.328, 237.597, +232.135, 245.790, 251.252, 243.059, 240.328, 240.328, 237.597, 234.866, +229.404, 223.942, 223.942, 226.673, 237.597, 243.059, 253.983, 256.714, +253.983, 253.983, 251.252, 251.252, 262.176, +232.135, 223.942, 207.556, 218.480, 240.328, 243.059, 240.328, 243.059, +199.363, 218.480, 204.825, 204.825, 210.287, 243.059, 251.252, 253.983, +248.521, 243.059, 256.714, 251.252, 245.790, 243.059, 240.328, 229.404, +229.404, 223.942, 223.942, 232.135, 240.328, 248.521, 256.714, 253.983, +253.983, 243.059, 245.790, 262.176, 262.176, +237.597, 226.673, 204.825, 210.287, 226.673, 243.059, 245.790, 245.790, +202.094, 213.018, 207.556, 207.556, 207.556, 229.404, 256.714, 273.100, +243.059, 251.252, 256.714, 251.252, 245.790, 243.059, 245.790, 232.135, +229.404, 226.673, 226.673, 237.597, 248.521, 251.252, 240.328, 251.252, +248.521, 240.328, 245.790, 264.907, 259.445, +243.059, 226.673, 202.094, 210.287, 223.942, 229.404, 245.790, 251.252, +213.018, 196.632, 207.556, 204.825, 204.825, 221.211, 259.445, 275.831, +259.445, 251.252, 259.445, 253.983, 245.790, 243.059, 245.790, 237.597, +234.866, 229.404, 234.866, 240.328, 245.790, 245.790, 237.597, 245.790, +243.059, 245.790, 243.059, 267.638, 267.638, +251.252, 229.404, 204.825, 207.556, 221.211, 221.211, 234.866, 248.521, +221.211, 196.632, 202.094, 202.094, 204.825, 221.211, 284.024, 294.948, +253.983, 251.252, 259.445, 256.714, 240.328, 237.597, 243.059, 237.597, +232.135, 232.135, 240.328, 243.059, 253.983, 248.521, 240.328, 240.328, +248.521, 240.328, 248.521, 289.486, 294.948, +253.983, 243.059, 213.018, 204.825, 210.287, 218.480, 232.135, 234.866, +232.135, 199.363, 196.632, 199.363, 202.094, 215.749, 278.562, 275.831, +240.328, 251.252, 253.983, 248.521, 237.597, 237.597, 234.866, 237.597, +232.135, 234.866, 240.328, 243.059, 256.714, 256.714, 245.790, 240.328, +232.135, 234.866, 267.638, 297.679, 308.603, +251.252, 253.983, 226.673, 207.556, 202.094, 215.749, 229.404, 232.135, +221.211, 204.825, 196.632, 199.363, 202.094, 215.749, 286.755, 234.866, +234.866, 251.252, 262.176, 267.638, 284.024, 234.866, 232.135, 232.135, +232.135, 240.328, 245.790, 245.790, 253.983, 251.252, 240.328, 237.597, +234.866, 243.059, 264.907, 300.410, 297.679, +251.252, 253.983, 243.059, 213.018, 215.749, 213.018, 243.059, 229.404, +204.825, 207.556, 199.363, 196.632, 199.363, 213.018, 286.755, 226.673, +223.942, 240.328, 226.673, 292.217, 259.445, 229.404, 232.135, 229.404, +234.866, 237.597, 245.790, 248.521, 251.252, 245.790, 240.328, 237.597, +243.059, 245.790, 248.521, 270.369, 292.217, +262.176, 256.714, 248.521, 223.942, 229.404, 234.866, 248.521, 237.597, +204.825, 202.094, 199.363, 199.363, 199.363, 210.287, 275.831, 234.866, +226.673, 243.059, 251.252, 270.369, 267.638, 234.866, 234.866, 237.597, +226.673, 229.404, 243.059, 243.059, 251.252, 251.252, 251.252, 262.176, +262.176, 237.597, 248.521, 245.790, 267.638, +262.176, 264.907, 256.714, 237.597, 240.328, 243.059, 251.252, 245.790, +215.749, 196.632, 199.363, 199.363, 202.094, 210.287, 273.100, 251.252, +229.404, 234.866, 267.638, 273.100, 251.252, 237.597, 240.328, 240.328, +229.404, 226.673, 237.597, 243.059, 248.521, 256.714, 256.714, 262.176, +253.983, 237.597, 237.597, 229.404, 297.679, +253.983, 251.252, 259.445, 251.252, 256.714, 253.983, 251.252, 248.521, +223.942, 196.632, 199.363, 202.094, 202.094, 207.556, 259.445, 243.059, +232.135, 229.404, 278.562, 243.059, 232.135, 240.328, 256.714, 234.866, +223.942, 226.673, 223.942, 248.521, 256.714, 264.907, 245.790, 251.252, +232.135, 245.790, 232.135, 215.749, 341.375, +243.059, 262.176, 256.714, 245.790, 256.714, 259.445, 248.521, 248.521, +232.135, 207.556, 196.632, 199.363, 202.094, 204.825, 240.328, 273.100, +226.673, 229.404, 229.404, 226.673, 232.135, 240.328, 245.790, 232.135, +229.404, 226.673, 229.404, 240.328, 251.252, 253.983, 245.790, 243.059, +229.404, 245.790, 256.714, 215.749, 379.609, +253.983, 264.907, 264.907, 253.983, 251.252, 259.445, 248.521, 245.790, +237.597, 221.211, 202.094, 199.363, 199.363, 202.094, 232.135, 264.907, +259.445, 259.445, 243.059, 234.866, 234.866, 251.252, 237.597, 232.135, +229.404, 245.790, 234.866, 232.135, 248.521, 237.597, 237.597, 234.866, +253.983, 338.644, 382.340, 289.486, 390.533, +275.831, 259.445, 264.907, 264.907, 262.176, 259.445, 229.404, 240.328, +237.597, 223.942, 213.018, 199.363, 199.363, 202.094, 223.942, 251.252, +284.024, 259.445, 240.328, 243.059, 237.597, 243.059, 234.866, 232.135, +234.866, 237.597, 237.597, 221.211, 221.211, 226.673, 248.521, 289.486, +357.761, 417.843, 412.381, 335.913, 363.223, +270.369, 275.831, 278.562, 270.369, 262.176, 245.790, 226.673, 223.942, +232.135, 229.404, 215.749, 207.556, 202.094, 202.094, 213.018, 221.211, +243.059, 262.176, 245.790, 253.983, 240.328, 240.328, 234.866, 240.328, +243.059, 259.445, 243.059, 223.942, 221.211, 232.135, 284.024, 322.258, +385.071, 436.960, 352.299, 374.147, 401.457, +281.293, 284.024, 267.638, 270.369, 245.790, 240.328, 221.211, 207.556, +221.211, 226.673, 215.749, 210.287, 204.825, 204.825, 204.825, 207.556, +218.480, 245.790, 256.714, 237.597, 234.866, 237.597, 251.252, 232.135, +232.135, 232.135, 237.597, 237.597, 243.059, 248.521, 305.872, 314.065, +395.995, 420.574, 395.995, 385.071, 401.457, +289.486, 281.293, 273.100, 270.369, 251.252, 223.942, 213.018, 204.825, +213.018, 221.211, 215.749, 210.287, 210.287, 213.018, 213.018, 207.556, +210.287, 221.211, 243.059, 237.597, 229.404, 229.404, 245.790, 234.866, +232.135, 229.404, 218.480, 232.135, 264.907, 284.024, 324.989, 324.989, +406.919, 401.457, 393.264, 398.726, 415.112, +292.217, 286.755, 281.293, 273.100, 253.983, 226.673, 213.018, 202.094, +202.094, 215.749, 213.018, 210.287, 207.556, 213.018, 218.480, 215.749, +207.556, 213.018, 226.673, 229.404, 221.211, 221.211, 229.404, 226.673, +223.942, 213.018, 213.018, 232.135, 234.866, 264.907, 286.755, 311.334, +395.995, 398.726, 404.188, 401.457, 409.650, +292.217, 286.755, 281.293, 264.907, 251.252, 229.404, 196.632, 196.632, +204.825, 210.287, 207.556, 204.825, 207.556, 215.749, 218.480, 218.480, +210.287, 207.556, 223.942, 221.211, 218.480, 221.211, 218.480, 218.480, +218.480, 210.287, 202.094, 202.094, 199.363, 210.287, 248.521, 300.410, +360.492, 385.071, 415.112, 415.112, 395.995, +292.217, 286.755, 281.293, 262.176, 251.252, 234.866, 199.363, 193.901, +199.363, 204.825, 204.825, 207.556, 207.556, 213.018, 218.480, 218.480, +218.480, 267.638, 218.480, 218.480, 223.942, 223.942, 218.480, 213.018, +207.556, 199.363, 193.901, 196.632, 193.901, 202.094, 218.480, 294.948, +324.989, 371.416, 431.498, 387.802, 374.147, +292.217, 284.024, 275.831, 264.907, 232.135, 237.597, 204.825, 191.170, +191.170, 202.094, 202.094, 204.825, 210.287, 213.018, 218.480, 223.942, +300.410, 319.527, 300.410, 213.018, 221.211, 226.673, 221.211, 213.018, +207.556, 199.363, 193.901, 188.439, 185.708, 193.901, 202.094, 259.445, +327.720, 376.878, 404.188, 390.533, 379.609 +}; const size_t array_float1_size = sizeof(array_float1); -const float array_float2[YSIZE * XSIZE] = { - 210.287, 199.363, 207.556, 218.480, 215.749, 204.825, 223.942, 177.515, - 169.322, 174.784, 161.129, 161.129, 166.591, 196.632, 191.170, 182.977, - 177.515, 191.170, 193.901, 191.170, 185.708, 180.246, 177.515, 182.977, - 180.246, 180.246, 180.246, 180.246, 180.246, 180.246, 180.246, 180.246, - 180.246, 177.515, 172.053, 172.053, 169.322, 204.825, 193.901, 193.901, - 215.749, 221.211, 204.825, 221.211, 199.363, 161.129, 177.515, 163.860, - 163.860, 174.784, 199.363, 199.363, 185.708, 180.246, 191.170, 196.632, - 193.901, 185.708, 180.246, 180.246, 182.977, 180.246, 180.246, 180.246, - 182.977, 182.977, 182.977, 180.246, 182.977, 180.246, 174.784, 172.053, - 172.053, 172.053, 207.556, 193.901, 180.246, 199.363, 221.211, 213.018, - 218.480, 215.749, 161.129, 180.246, 163.860, 161.129, 169.322, 202.094, - 202.094, 193.901, 182.977, 191.170, 199.363, 193.901, 185.708, 180.246, - 177.515, 177.515, 180.246, 180.246, 182.977, 182.977, 182.977, 182.977, - 182.977, 182.977, 180.246, 174.784, 174.784, 174.784, 174.784, 207.556, - 196.632, 174.784, 185.708, 215.749, 221.211, 218.480, 218.480, 161.129, - 185.708, 163.860, 161.129, 163.860, 204.825, 204.825, 199.363, 182.977, - 185.708, 199.363, 196.632, 185.708, 180.246, 177.515, 172.053, 182.977, - 182.977, 182.977, 182.977, 185.708, 182.977, 182.977, 180.246, 177.515, - 174.784, 177.515, 177.515, 177.515, 215.749, 196.632, 172.053, 180.246, - 199.363, 218.480, 226.673, 223.942, 163.860, 177.515, 166.591, 166.591, - 163.860, 180.246, 204.825, 204.825, 177.515, 191.170, 199.363, 196.632, - 185.708, 180.246, 177.515, 174.784, 185.708, 182.977, 185.708, 185.708, - 185.708, 182.977, 182.977, 180.246, 177.515, 177.515, 177.515, 180.246, - 177.515, 221.211, 199.363, 169.322, 177.515, 196.632, 202.094, 223.942, - 232.135, 180.246, 161.129, 169.322, 163.860, 163.860, 172.053, 204.825, - 207.556, 185.708, 188.439, 196.632, 196.632, 185.708, 180.246, 180.246, - 177.515, 182.977, 185.708, 185.708, 185.708, 185.708, 185.708, 180.246, - 180.246, 174.784, 180.246, 177.515, 180.246, 180.246, 229.404, 202.094, - 174.784, 174.784, 191.170, 193.901, 213.018, 229.404, 191.170, 158.398, - 163.860, 161.129, 161.129, 172.053, 204.825, 218.480, 199.363, 182.977, - 196.632, 196.632, 185.708, 180.246, 180.246, 177.515, 180.246, 185.708, - 185.708, 185.708, 185.708, 185.708, 180.246, 177.515, 177.515, 177.515, - 180.246, 182.977, 185.708, 237.597, 221.211, 180.246, 172.053, 177.515, - 185.708, 207.556, 207.556, 204.825, 161.129, 158.398, 161.129, 161.129, - 163.860, 193.901, 251.252, 177.515, 174.784, 202.094, 196.632, 188.439, - 182.977, 177.515, 177.515, 177.515, 185.708, 188.439, 185.708, 188.439, - 182.977, 177.515, 177.515, 177.515, 177.515, 182.977, 185.708, 188.439, - 234.866, 234.866, 199.363, 174.784, 169.322, 182.977, 204.825, 207.556, - 191.170, 166.591, 158.398, 158.398, 161.129, 163.860, 221.211, 185.708, - 161.129, 172.053, 202.094, 245.790, 270.369, 182.977, 177.515, 177.515, - 174.784, 182.977, 185.708, 185.708, 185.708, 182.977, 177.515, 177.515, - 180.246, 177.515, 180.246, 185.708, 185.708, 232.135, 232.135, 218.480, - 180.246, 182.977, 182.977, 221.211, 202.094, 169.322, 172.053, 161.129, - 158.398, 158.398, 163.860, 253.983, 166.591, 161.129, 161.129, 185.708, - 314.065, 207.556, 182.977, 180.246, 174.784, 174.784, 180.246, 185.708, - 185.708, 185.708, 180.246, 177.515, 177.515, 180.246, 177.515, 174.784, - 177.515, 188.439, 245.790, 237.597, 226.673, 193.901, 202.094, 210.287, - 226.673, 215.749, 172.053, 163.860, 161.129, 161.129, 158.398, 158.398, - 245.790, 166.591, 161.129, 161.129, 182.977, 218.480, 193.901, 185.708, - 180.246, 174.784, 172.053, 172.053, 185.708, 185.708, 185.708, 180.246, - 177.515, 180.246, 182.977, 177.515, 174.784, 169.322, 237.597, 248.521, - 251.252, 234.866, 207.556, 213.018, 221.211, 232.135, 223.942, 182.977, - 161.129, 161.129, 161.129, 161.129, 163.860, 240.328, 196.632, 161.129, - 163.860, 202.094, 218.480, 191.170, 182.977, 180.246, 174.784, 169.322, - 163.860, 177.515, 185.708, 182.977, 180.246, 177.515, 182.977, 180.246, - 174.784, 169.322, 161.129, 303.141, 229.404, 229.404, 237.597, 232.135, - 237.597, 232.135, 229.404, 229.404, 196.632, 161.129, 161.129, 161.129, - 161.129, 161.129, 199.363, 193.901, 169.322, 161.129, 273.100, 191.170, - 191.170, 182.977, 180.246, 174.784, 163.860, 158.398, 158.398, 182.977, - 185.708, 180.246, 177.515, 180.246, 174.784, 172.053, 161.129, 152.936, - 357.761, 218.480, 245.790, 237.597, 226.673, 240.328, 243.059, 229.404, - 226.673, 207.556, 174.784, 161.129, 161.129, 161.129, 158.398, 161.129, - 264.907, 174.784, 169.322, 193.901, 185.708, 191.170, 199.363, 180.246, - 172.053, 166.591, 158.398, 158.398, 169.322, 182.977, 180.246, 174.784, - 177.515, 172.053, 172.053, 166.591, 155.667, 406.919, 234.866, 248.521, - 251.252, 237.597, 232.135, 240.328, 226.673, 221.211, 213.018, 188.439, - 166.591, 161.129, 161.129, 161.129, 161.129, 166.591, 226.673, 196.632, - 182.977, 182.977, 188.439, 188.439, 180.246, 174.784, 166.591, 196.632, - 152.936, 155.667, 174.784, 174.784, 174.784, 174.784, 177.515, 314.065, - 409.650, 253.983, 412.381, 264.907, 243.059, 248.521, 251.252, 243.059, - 240.328, 202.094, 218.480, 213.018, 193.901, 177.515, 161.129, 158.398, - 161.129, 158.398, 161.129, 193.901, 196.632, 182.977, 191.170, 191.170, - 188.439, 182.977, 174.784, 172.053, 180.246, 152.936, 147.474, 155.667, - 161.129, 174.784, 237.597, 379.609, 442.422, 436.960, 349.568, 385.071, - 256.714, 262.176, 264.907, 256.714, 243.059, 223.942, 193.901, 191.170, - 207.556, 199.363, 182.977, 166.591, 161.129, 161.129, 158.398, 161.129, - 166.591, 193.901, 182.977, 204.825, 191.170, 185.708, 191.170, 177.515, - 172.053, 172.053, 161.129, 152.936, 147.474, 150.205, 245.790, 330.451, - 406.919, 458.808, 376.878, 393.264, 428.767, 270.369, 273.100, 253.983, - 253.983, 223.942, 218.480, 191.170, 169.322, 191.170, 196.632, 182.977, - 172.053, 163.860, 163.860, 158.398, 158.398, 163.860, 185.708, 191.170, - 191.170, 188.439, 185.708, 215.749, 185.708, 174.784, 169.322, 163.860, - 161.129, 155.667, 155.667, 240.328, 327.720, 412.381, 442.422, 420.574, - 406.919, 423.305, 281.293, 270.369, 259.445, 256.714, 229.404, 199.363, - 182.977, 169.322, 177.515, 188.439, 182.977, 174.784, 172.053, 174.784, - 172.053, 161.129, 163.860, 177.515, 193.901, 188.439, 188.439, 182.977, - 213.018, 177.515, 172.053, 166.591, 161.129, 166.591, 163.860, 185.708, - 273.100, 349.568, 423.305, 423.305, 415.112, 423.305, 447.884, 284.024, - 278.562, 270.369, 259.445, 234.866, 202.094, 182.977, 166.591, 166.591, - 180.246, 177.515, 172.053, 172.053, 174.784, 177.515, 172.053, 163.860, - 172.053, 191.170, 188.439, 182.977, 182.977, 182.977, 177.515, 169.322, - 163.860, 158.398, 155.667, 169.322, 158.398, 193.901, 319.527, 409.650, - 420.574, 428.767, 423.305, 445.153, 284.024, 275.831, 270.369, 248.521, - 229.404, 202.094, 161.129, 161.129, 169.322, 174.784, 172.053, 166.591, - 169.322, 174.784, 174.784, 174.784, 166.591, 163.860, 188.439, 185.708, - 182.977, 188.439, 182.977, 177.515, 169.322, 161.129, 158.398, 155.667, - 155.667, 152.936, 161.129, 284.024, 374.147, 401.457, 434.229, 439.691, - 431.498, 284.024, 275.831, 270.369, 245.790, 232.135, 210.287, 163.860, - 155.667, 163.860, 169.322, 169.322, 169.322, 172.053, 174.784, 177.515, - 177.515, 180.246, 273.100, 182.977, 182.977, 188.439, 188.439, 182.977, - 177.515, 172.053, 163.860, 158.398, 152.936, 147.474, 150.205, 152.936, - 210.287, 333.182, 387.802, 453.346, 428.767, 409.650, 284.024, 275.831, - 264.907, 251.252, 210.287, 215.749, 174.784, 155.667, 155.667, 169.322, - 169.322, 169.322, 174.784, 177.515, 180.246, 177.515, 314.065, 376.878, - 352.299, 174.784, 185.708, 191.170, 185.708, 180.246, 174.784, 163.860, - 158.398, 152.936, 144.743, 144.743, 152.936, 169.322, 314.065, 390.533, - 428.767, 426.036, 434.229}; +const float array_float2[YSIZE * XSIZE] = +{ +210.287, 199.363, 207.556, 218.480, 215.749, 204.825, 223.942, 177.515, +169.322, 174.784, 161.129, 161.129, 166.591, 196.632, 191.170, 182.977, +177.515, 191.170, 193.901, 191.170, 185.708, 180.246, 177.515, 182.977, +180.246, 180.246, 180.246, 180.246, 180.246, 180.246, 180.246, 180.246, +180.246, 177.515, 172.053, 172.053, 169.322, +204.825, 193.901, 193.901, 215.749, 221.211, 204.825, 221.211, 199.363, +161.129, 177.515, 163.860, 163.860, 174.784, 199.363, 199.363, 185.708, +180.246, 191.170, 196.632, 193.901, 185.708, 180.246, 180.246, 182.977, +180.246, 180.246, 180.246, 182.977, 182.977, 182.977, 180.246, 182.977, +180.246, 174.784, 172.053, 172.053, 172.053, +207.556, 193.901, 180.246, 199.363, 221.211, 213.018, 218.480, 215.749, +161.129, 180.246, 163.860, 161.129, 169.322, 202.094, 202.094, 193.901, +182.977, 191.170, 199.363, 193.901, 185.708, 180.246, 177.515, 177.515, +180.246, 180.246, 182.977, 182.977, 182.977, 182.977, 182.977, 182.977, +180.246, 174.784, 174.784, 174.784, 174.784, +207.556, 196.632, 174.784, 185.708, 215.749, 221.211, 218.480, 218.480, +161.129, 185.708, 163.860, 161.129, 163.860, 204.825, 204.825, 199.363, +182.977, 185.708, 199.363, 196.632, 185.708, 180.246, 177.515, 172.053, +182.977, 182.977, 182.977, 182.977, 185.708, 182.977, 182.977, 180.246, +177.515, 174.784, 177.515, 177.515, 177.515, +215.749, 196.632, 172.053, 180.246, 199.363, 218.480, 226.673, 223.942, +163.860, 177.515, 166.591, 166.591, 163.860, 180.246, 204.825, 204.825, +177.515, 191.170, 199.363, 196.632, 185.708, 180.246, 177.515, 174.784, +185.708, 182.977, 185.708, 185.708, 185.708, 182.977, 182.977, 180.246, +177.515, 177.515, 177.515, 180.246, 177.515, +221.211, 199.363, 169.322, 177.515, 196.632, 202.094, 223.942, 232.135, +180.246, 161.129, 169.322, 163.860, 163.860, 172.053, 204.825, 207.556, +185.708, 188.439, 196.632, 196.632, 185.708, 180.246, 180.246, 177.515, +182.977, 185.708, 185.708, 185.708, 185.708, 185.708, 180.246, 180.246, +174.784, 180.246, 177.515, 180.246, 180.246, +229.404, 202.094, 174.784, 174.784, 191.170, 193.901, 213.018, 229.404, +191.170, 158.398, 163.860, 161.129, 161.129, 172.053, 204.825, 218.480, +199.363, 182.977, 196.632, 196.632, 185.708, 180.246, 180.246, 177.515, +180.246, 185.708, 185.708, 185.708, 185.708, 185.708, 180.246, 177.515, +177.515, 177.515, 180.246, 182.977, 185.708, +237.597, 221.211, 180.246, 172.053, 177.515, 185.708, 207.556, 207.556, +204.825, 161.129, 158.398, 161.129, 161.129, 163.860, 193.901, 251.252, +177.515, 174.784, 202.094, 196.632, 188.439, 182.977, 177.515, 177.515, +177.515, 185.708, 188.439, 185.708, 188.439, 182.977, 177.515, 177.515, +177.515, 177.515, 182.977, 185.708, 188.439, +234.866, 234.866, 199.363, 174.784, 169.322, 182.977, 204.825, 207.556, +191.170, 166.591, 158.398, 158.398, 161.129, 163.860, 221.211, 185.708, +161.129, 172.053, 202.094, 245.790, 270.369, 182.977, 177.515, 177.515, +174.784, 182.977, 185.708, 185.708, 185.708, 182.977, 177.515, 177.515, +180.246, 177.515, 180.246, 185.708, 185.708, +232.135, 232.135, 218.480, 180.246, 182.977, 182.977, 221.211, 202.094, +169.322, 172.053, 161.129, 158.398, 158.398, 163.860, 253.983, 166.591, +161.129, 161.129, 185.708, 314.065, 207.556, 182.977, 180.246, 174.784, +174.784, 180.246, 185.708, 185.708, 185.708, 180.246, 177.515, 177.515, +180.246, 177.515, 174.784, 177.515, 188.439, +245.790, 237.597, 226.673, 193.901, 202.094, 210.287, 226.673, 215.749, +172.053, 163.860, 161.129, 161.129, 158.398, 158.398, 245.790, 166.591, +161.129, 161.129, 182.977, 218.480, 193.901, 185.708, 180.246, 174.784, +172.053, 172.053, 185.708, 185.708, 185.708, 180.246, 177.515, 180.246, +182.977, 177.515, 174.784, 169.322, 237.597, +248.521, 251.252, 234.866, 207.556, 213.018, 221.211, 232.135, 223.942, +182.977, 161.129, 161.129, 161.129, 161.129, 163.860, 240.328, 196.632, +161.129, 163.860, 202.094, 218.480, 191.170, 182.977, 180.246, 174.784, +169.322, 163.860, 177.515, 185.708, 182.977, 180.246, 177.515, 182.977, +180.246, 174.784, 169.322, 161.129, 303.141, +229.404, 229.404, 237.597, 232.135, 237.597, 232.135, 229.404, 229.404, +196.632, 161.129, 161.129, 161.129, 161.129, 161.129, 199.363, 193.901, +169.322, 161.129, 273.100, 191.170, 191.170, 182.977, 180.246, 174.784, +163.860, 158.398, 158.398, 182.977, 185.708, 180.246, 177.515, 180.246, +174.784, 172.053, 161.129, 152.936, 357.761, +218.480, 245.790, 237.597, 226.673, 240.328, 243.059, 229.404, 226.673, +207.556, 174.784, 161.129, 161.129, 161.129, 158.398, 161.129, 264.907, +174.784, 169.322, 193.901, 185.708, 191.170, 199.363, 180.246, 172.053, +166.591, 158.398, 158.398, 169.322, 182.977, 180.246, 174.784, 177.515, +172.053, 172.053, 166.591, 155.667, 406.919, +234.866, 248.521, 251.252, 237.597, 232.135, 240.328, 226.673, 221.211, +213.018, 188.439, 166.591, 161.129, 161.129, 161.129, 161.129, 166.591, +226.673, 196.632, 182.977, 182.977, 188.439, 188.439, 180.246, 174.784, +166.591, 196.632, 152.936, 155.667, 174.784, 174.784, 174.784, 174.784, +177.515, 314.065, 409.650, 253.983, 412.381, +264.907, 243.059, 248.521, 251.252, 243.059, 240.328, 202.094, 218.480, +213.018, 193.901, 177.515, 161.129, 158.398, 161.129, 158.398, 161.129, +193.901, 196.632, 182.977, 191.170, 191.170, 188.439, 182.977, 174.784, +172.053, 180.246, 152.936, 147.474, 155.667, 161.129, 174.784, 237.597, +379.609, 442.422, 436.960, 349.568, 385.071, +256.714, 262.176, 264.907, 256.714, 243.059, 223.942, 193.901, 191.170, +207.556, 199.363, 182.977, 166.591, 161.129, 161.129, 158.398, 161.129, +166.591, 193.901, 182.977, 204.825, 191.170, 185.708, 191.170, 177.515, +172.053, 172.053, 161.129, 152.936, 147.474, 150.205, 245.790, 330.451, +406.919, 458.808, 376.878, 393.264, 428.767, +270.369, 273.100, 253.983, 253.983, 223.942, 218.480, 191.170, 169.322, +191.170, 196.632, 182.977, 172.053, 163.860, 163.860, 158.398, 158.398, +163.860, 185.708, 191.170, 191.170, 188.439, 185.708, 215.749, 185.708, +174.784, 169.322, 163.860, 161.129, 155.667, 155.667, 240.328, 327.720, +412.381, 442.422, 420.574, 406.919, 423.305, +281.293, 270.369, 259.445, 256.714, 229.404, 199.363, 182.977, 169.322, +177.515, 188.439, 182.977, 174.784, 172.053, 174.784, 172.053, 161.129, +163.860, 177.515, 193.901, 188.439, 188.439, 182.977, 213.018, 177.515, +172.053, 166.591, 161.129, 166.591, 163.860, 185.708, 273.100, 349.568, +423.305, 423.305, 415.112, 423.305, 447.884, +284.024, 278.562, 270.369, 259.445, 234.866, 202.094, 182.977, 166.591, +166.591, 180.246, 177.515, 172.053, 172.053, 174.784, 177.515, 172.053, +163.860, 172.053, 191.170, 188.439, 182.977, 182.977, 182.977, 177.515, +169.322, 163.860, 158.398, 155.667, 169.322, 158.398, 193.901, 319.527, +409.650, 420.574, 428.767, 423.305, 445.153, +284.024, 275.831, 270.369, 248.521, 229.404, 202.094, 161.129, 161.129, +169.322, 174.784, 172.053, 166.591, 169.322, 174.784, 174.784, 174.784, +166.591, 163.860, 188.439, 185.708, 182.977, 188.439, 182.977, 177.515, +169.322, 161.129, 158.398, 155.667, 155.667, 152.936, 161.129, 284.024, +374.147, 401.457, 434.229, 439.691, 431.498, +284.024, 275.831, 270.369, 245.790, 232.135, 210.287, 163.860, 155.667, +163.860, 169.322, 169.322, 169.322, 172.053, 174.784, 177.515, 177.515, +180.246, 273.100, 182.977, 182.977, 188.439, 188.439, 182.977, 177.515, +172.053, 163.860, 158.398, 152.936, 147.474, 150.205, 152.936, 210.287, +333.182, 387.802, 453.346, 428.767, 409.650, +284.024, 275.831, 264.907, 251.252, 210.287, 215.749, 174.784, 155.667, +155.667, 169.322, 169.322, 169.322, 174.784, 177.515, 180.246, 177.515, +314.065, 376.878, 352.299, 174.784, 185.708, 191.170, 185.708, 180.246, +174.784, 163.860, 158.398, 152.936, 144.743, 144.743, 152.936, 169.322, +314.065, 390.533, 428.767, 426.036, 434.229 +}; const size_t array_float2_size = sizeof(array_float2); -const double array_double1[YSIZE * XSIZE] = { - 148.914762, 145.451628, 148.914762, 155.841030, 154.109463, 147.183195, - 155.841030, 135.062226, 133.330659, 136.793793, 129.867525, 133.330659, - 136.793793, 148.914762, 150.646329, 143.720061, 141.988494, 150.646329, - 154.109463, 152.377896, 148.914762, 150.646329, 152.377896, 150.646329, - 140.256927, 145.451628, 147.183195, 147.183195, 145.451628, 148.914762, - 152.377896, 157.572597, 166.230432, 164.498865, 167.961999, 164.498865, - 154.109463, 147.183195, 141.988494, 140.256927, 152.377896, 154.109463, - 147.183195, 154.109463, 143.720061, 128.135958, 136.793793, 131.599092, - 133.330659, 138.525360, 150.646329, 150.646329, 145.451628, 145.451628, - 152.377896, 155.841030, 154.109463, 150.646329, 147.183195, 150.646329, - 152.377896, 143.720061, 138.525360, 141.988494, 145.451628, 147.183195, - 150.646329, 155.841030, 164.498865, 166.230432, 164.498865, 164.498865, - 159.304164, 155.841030, 147.183195, 140.256927, 136.793793, 145.451628, - 155.841030, 150.646329, 152.377896, 152.377896, 126.404391, 136.793793, - 129.867525, 131.599092, 136.793793, 152.377896, 152.377896, 150.646329, - 147.183195, 155.841030, 159.304164, 154.109463, 152.377896, 152.377896, - 150.646329, 148.914762, 145.451628, 141.988494, 141.988494, 143.720061, - 150.646329, 154.109463, 161.035731, 162.767298, 161.035731, 161.035731, - 159.304164, 159.304164, 166.230432, 147.183195, 141.988494, 131.599092, - 138.525360, 152.377896, 154.109463, 152.377896, 154.109463, 126.404391, - 138.525360, 129.867525, 129.867525, 133.330659, 154.109463, 159.304164, - 161.035731, 157.572597, 154.109463, 162.767298, 159.304164, 155.841030, - 154.109463, 152.377896, 145.451628, 145.451628, 141.988494, 141.988494, - 147.183195, 152.377896, 157.572597, 162.767298, 161.035731, 161.035731, - 154.109463, 155.841030, 166.230432, 166.230432, 150.646329, 143.720061, - 129.867525, 133.330659, 143.720061, 154.109463, 155.841030, 155.841030, - 128.135958, 135.062226, 131.599092, 131.599092, 131.599092, 145.451628, - 162.767298, 173.156700, 154.109463, 159.304164, 162.767298, 159.304164, - 155.841030, 154.109463, 155.841030, 147.183195, 145.451628, 143.720061, - 143.720061, 150.646329, 157.572597, 159.304164, 152.377896, 159.304164, - 157.572597, 152.377896, 155.841030, 167.961999, 164.498865, 154.109463, - 143.720061, 128.135958, 133.330659, 141.988494, 145.451628, 155.841030, - 159.304164, 135.062226, 124.672824, 131.599092, 129.867525, 129.867525, - 140.256927, 164.498865, 174.888267, 164.498865, 159.304164, 164.498865, - 161.035731, 155.841030, 154.109463, 155.841030, 150.646329, 148.914762, - 145.451628, 148.914762, 152.377896, 155.841030, 155.841030, 150.646329, - 155.841030, 154.109463, 155.841030, 154.109463, 169.693566, 169.693566, - 159.304164, 145.451628, 129.867525, 131.599092, 140.256927, 140.256927, - 148.914762, 157.572597, 140.256927, 124.672824, 128.135958, 128.135958, - 129.867525, 140.256927, 180.082968, 187.009236, 161.035731, 159.304164, - 164.498865, 162.767298, 152.377896, 150.646329, 154.109463, 150.646329, - 147.183195, 147.183195, 152.377896, 154.109463, 161.035731, 157.572597, - 152.377896, 152.377896, 157.572597, 152.377896, 157.572597, 183.546102, - 187.009236, 161.035731, 154.109463, 135.062226, 129.867525, 133.330659, - 138.525360, 147.183195, 148.914762, 147.183195, 126.404391, 124.672824, - 126.404391, 128.135958, 136.793793, 176.619834, 174.888267, 152.377896, - 159.304164, 161.035731, 157.572597, 150.646329, 150.646329, 148.914762, - 150.646329, 147.183195, 148.914762, 152.377896, 154.109463, 162.767298, - 162.767298, 155.841030, 152.377896, 147.183195, 148.914762, 169.693566, - 188.740803, 195.667071, 159.304164, 161.035731, 143.720061, 131.599092, - 128.135958, 136.793793, 145.451628, 147.183195, 140.256927, 129.867525, - 124.672824, 126.404391, 128.135958, 136.793793, 181.814535, 148.914762, - 148.914762, 159.304164, 166.230432, 169.693566, 180.082968, 148.914762, - 147.183195, 147.183195, 147.183195, 152.377896, 155.841030, 155.841030, - 161.035731, 159.304164, 152.377896, 150.646329, 148.914762, 154.109463, - 167.961999, 190.472370, 188.740803, 159.304164, 161.035731, 154.109463, - 135.062226, 136.793793, 135.062226, 154.109463, 145.451628, 129.867525, - 131.599092, 126.404391, 124.672824, 126.404391, 135.062226, 181.814535, - 143.720061, 141.988494, 152.377896, 143.720061, 185.277669, 164.498865, - 145.451628, 147.183195, 145.451628, 148.914762, 150.646329, 155.841030, - 157.572597, 159.304164, 155.841030, 152.377896, 150.646329, 154.109463, - 155.841030, 157.572597, 171.425133, 185.277669, 166.230432, 162.767298, - 157.572597, 141.988494, 145.451628, 148.914762, 157.572597, 150.646329, - 129.867525, 128.135958, 126.404391, 126.404391, 126.404391, 133.330659, - 174.888267, 148.914762, 143.720061, 154.109463, 159.304164, 171.425133, - 169.693566, 148.914762, 148.914762, 150.646329, 143.720061, 145.451628, - 154.109463, 154.109463, 159.304164, 159.304164, 159.304164, 166.230432, - 166.230432, 150.646329, 157.572597, 155.841030, 169.693566, 166.230432, - 167.961999, 162.767298, 150.646329, 152.377896, 154.109463, 159.304164, - 155.841030, 136.793793, 124.672824, 126.404391, 126.404391, 128.135958, - 133.330659, 173.156700, 159.304164, 145.451628, 148.914762, 169.693566, - 173.156700, 159.304164, 150.646329, 152.377896, 152.377896, 145.451628, - 143.720061, 150.646329, 154.109463, 157.572597, 162.767298, 162.767298, - 166.230432, 161.035731, 150.646329, 150.646329, 145.451628, 188.740803, - 161.035731, 159.304164, 164.498865, 159.304164, 162.767298, 161.035731, - 159.304164, 157.572597, 141.988494, 124.672824, 126.404391, 128.135958, - 128.135958, 131.599092, 164.498865, 154.109463, 147.183195, 145.451628, - 176.619834, 154.109463, 147.183195, 152.377896, 162.767298, 148.914762, - 141.988494, 143.720061, 141.988494, 157.572597, 162.767298, 167.961999, - 155.841030, 159.304164, 147.183195, 155.841030, 147.183195, 136.793793, - 216.445875, 154.109463, 166.230432, 162.767298, 155.841030, 162.767298, - 164.498865, 157.572597, 157.572597, 147.183195, 131.599092, 124.672824, - 126.404391, 128.135958, 129.867525, 152.377896, 173.156700, 143.720061, - 145.451628, 145.451628, 143.720061, 147.183195, 152.377896, 155.841030, - 147.183195, 145.451628, 143.720061, 145.451628, 152.377896, 159.304164, - 161.035731, 155.841030, 154.109463, 145.451628, 155.841030, 162.767298, - 136.793793, 240.687813, 161.035731, 167.961999, 167.961999, 161.035731, - 159.304164, 164.498865, 157.572597, 155.841030, 150.646329, 140.256927, - 128.135958, 126.404391, 126.404391, 128.135958, 147.183195, 167.961999, - 164.498865, 164.498865, 154.109463, 148.914762, 148.914762, 159.304164, - 150.646329, 147.183195, 145.451628, 155.841030, 148.914762, 147.183195, - 157.572597, 150.646329, 150.646329, 148.914762, 161.035731, 214.714308, - 242.419380, 183.546102, 247.614081, 174.888267, 164.498865, 167.961999, - 167.961999, 166.230432, 164.498865, 145.451628, 152.377896, 150.646329, - 141.988494, 135.062226, 126.404391, 126.404391, 128.135958, 141.988494, - 159.304164, 180.082968, 164.498865, 152.377896, 154.109463, 150.646329, - 154.109463, 148.914762, 147.183195, 148.914762, 150.646329, 150.646329, - 140.256927, 140.256927, 143.720061, 157.572597, 183.546102, 226.835277, - 264.929751, 261.466617, 212.982741, 230.298411, 171.425133, 174.888267, - 176.619834, 171.425133, 166.230432, 155.841030, 143.720061, 141.988494, - 147.183195, 145.451628, 136.793793, 131.599092, 128.135958, 128.135958, - 135.062226, 140.256927, 154.109463, 166.230432, 155.841030, 161.035731, - 152.377896, 152.377896, 148.914762, 152.377896, 154.109463, 164.498865, - 154.109463, 141.988494, 140.256927, 147.183195, 180.082968, 204.324906, - 244.150947, 277.050720, 223.372143, 237.224679, 254.540349, 178.351401, - 180.082968, 169.693566, 171.425133, 155.841030, 152.377896, 140.256927, - 131.599092, 140.256927, 143.720061, 136.793793, 133.330659, 129.867525, - 129.867525, 129.867525, 131.599092, 138.525360, 155.841030, 162.767298, - 150.646329, 148.914762, 150.646329, 159.304164, 147.183195, 147.183195, - 147.183195, 150.646329, 150.646329, 154.109463, 157.572597, 193.935504, - 199.130205, 251.077215, 266.661318, 251.077215, 244.150947, 254.540349, - 183.546102, 178.351401, 173.156700, 171.425133, 159.304164, 141.988494, - 135.062226, 129.867525, 135.062226, 140.256927, 136.793793, 133.330659, - 133.330659, 135.062226, 135.062226, 131.599092, 133.330659, 140.256927, - 154.109463, 150.646329, 145.451628, 145.451628, 155.841030, 148.914762, - 147.183195, 145.451628, 138.525360, 147.183195, 167.961999, 180.082968, - 206.056473, 206.056473, 258.003483, 254.540349, 249.345648, 252.808782, - 263.198184, 185.277669, 181.814535, 178.351401, 173.156700, 161.035731, - 143.720061, 135.062226, 128.135958, 128.135958, 136.793793, 135.062226, - 133.330659, 131.599092, 135.062226, 138.525360, 136.793793, 131.599092, - 135.062226, 143.720061, 145.451628, 140.256927, 140.256927, 145.451628, - 143.720061, 141.988494, 135.062226, 135.062226, 147.183195, 148.914762, - 167.961999, 181.814535, 197.398638, 251.077215, 252.808782, 256.271916, - 254.540349, 259.735050, 185.277669, 181.814535, 178.351401, 167.961999, - 159.304164, 145.451628, 124.672824, 124.672824, 129.867525, 133.330659, - 131.599092, 129.867525, 131.599092, 136.793793, 138.525360, 138.525360, - 133.330659, 131.599092, 141.988494, 140.256927, 138.525360, 140.256927, - 138.525360, 138.525360, 138.525360, 133.330659, 128.135958, 128.135958, - 126.404391, 133.330659, 157.572597, 190.472370, 228.566844, 244.150947, - 263.198184, 263.198184, 251.077215, 185.277669, 181.814535, 178.351401, - 166.230432, 159.304164, 148.914762, 126.404391, 122.941257, 126.404391, - 129.867525, 129.867525, 131.599092, 131.599092, 135.062226, 138.525360, - 138.525360, 138.525360, 169.693566, 138.525360, 138.525360, 141.988494, - 141.988494, 138.525360, 135.062226, 131.599092, 126.404391, 122.941257, - 124.672824, 122.941257, 128.135958, 138.525360, 187.009236, 206.056473, - 235.493112, 273.587586, 245.882514, 237.224679, 185.277669, 180.082968, - 174.888267, 167.961999, 147.183195, 150.646329, 129.867525, 121.209690, - 121.209690, 128.135958, 128.135958, 129.867525, 133.330659, 135.062226, - 138.525360, 141.988494, 190.472370, 202.593339, 190.472370, 135.062226, - 140.256927, 143.720061, 140.256927, 135.062226, 131.599092, 126.404391, - 122.941257, 119.478123, 117.746556, 122.941257, 128.135958, 164.498865, - 207.788040, 238.956246, 256.271916, 247.614081, 240.687813}; +const double array_double1[YSIZE * XSIZE] = +{ +148.914762, 145.451628, 148.914762, 155.841030, 154.109463, 147.183195, +155.841030, 135.062226, 133.330659, 136.793793, 129.867525, 133.330659, +136.793793, 148.914762, 150.646329, 143.720061, 141.988494, 150.646329, +154.109463, 152.377896, 148.914762, 150.646329, 152.377896, 150.646329, +140.256927, 145.451628, 147.183195, 147.183195, 145.451628, 148.914762, +152.377896, 157.572597, 166.230432, 164.498865, 167.961999, 164.498865, +154.109463, +147.183195, 141.988494, 140.256927, 152.377896, 154.109463, 147.183195, +154.109463, 143.720061, 128.135958, 136.793793, 131.599092, 133.330659, +138.525360, 150.646329, 150.646329, 145.451628, 145.451628, 152.377896, +155.841030, 154.109463, 150.646329, 147.183195, 150.646329, 152.377896, +143.720061, 138.525360, 141.988494, 145.451628, 147.183195, 150.646329, +155.841030, 164.498865, 166.230432, 164.498865, 164.498865, 159.304164, +155.841030, +147.183195, 140.256927, 136.793793, 145.451628, 155.841030, 150.646329, +152.377896, 152.377896, 126.404391, 136.793793, 129.867525, 131.599092, +136.793793, 152.377896, 152.377896, 150.646329, 147.183195, 155.841030, +159.304164, 154.109463, 152.377896, 152.377896, 150.646329, 148.914762, +145.451628, 141.988494, 141.988494, 143.720061, 150.646329, 154.109463, +161.035731, 162.767298, 161.035731, 161.035731, 159.304164, 159.304164, +166.230432, +147.183195, 141.988494, 131.599092, 138.525360, 152.377896, 154.109463, +152.377896, 154.109463, 126.404391, 138.525360, 129.867525, 129.867525, +133.330659, 154.109463, 159.304164, 161.035731, 157.572597, 154.109463, +162.767298, 159.304164, 155.841030, 154.109463, 152.377896, 145.451628, +145.451628, 141.988494, 141.988494, 147.183195, 152.377896, 157.572597, +162.767298, 161.035731, 161.035731, 154.109463, 155.841030, 166.230432, +166.230432, +150.646329, 143.720061, 129.867525, 133.330659, 143.720061, 154.109463, +155.841030, 155.841030, 128.135958, 135.062226, 131.599092, 131.599092, +131.599092, 145.451628, 162.767298, 173.156700, 154.109463, 159.304164, +162.767298, 159.304164, 155.841030, 154.109463, 155.841030, 147.183195, +145.451628, 143.720061, 143.720061, 150.646329, 157.572597, 159.304164, +152.377896, 159.304164, 157.572597, 152.377896, 155.841030, 167.961999, +164.498865, +154.109463, 143.720061, 128.135958, 133.330659, 141.988494, 145.451628, +155.841030, 159.304164, 135.062226, 124.672824, 131.599092, 129.867525, +129.867525, 140.256927, 164.498865, 174.888267, 164.498865, 159.304164, +164.498865, 161.035731, 155.841030, 154.109463, 155.841030, 150.646329, +148.914762, 145.451628, 148.914762, 152.377896, 155.841030, 155.841030, +150.646329, 155.841030, 154.109463, 155.841030, 154.109463, 169.693566, +169.693566, +159.304164, 145.451628, 129.867525, 131.599092, 140.256927, 140.256927, +148.914762, 157.572597, 140.256927, 124.672824, 128.135958, 128.135958, +129.867525, 140.256927, 180.082968, 187.009236, 161.035731, 159.304164, +164.498865, 162.767298, 152.377896, 150.646329, 154.109463, 150.646329, +147.183195, 147.183195, 152.377896, 154.109463, 161.035731, 157.572597, +152.377896, 152.377896, 157.572597, 152.377896, 157.572597, 183.546102, +187.009236, +161.035731, 154.109463, 135.062226, 129.867525, 133.330659, 138.525360, +147.183195, 148.914762, 147.183195, 126.404391, 124.672824, 126.404391, +128.135958, 136.793793, 176.619834, 174.888267, 152.377896, 159.304164, +161.035731, 157.572597, 150.646329, 150.646329, 148.914762, 150.646329, +147.183195, 148.914762, 152.377896, 154.109463, 162.767298, 162.767298, +155.841030, 152.377896, 147.183195, 148.914762, 169.693566, 188.740803, +195.667071, +159.304164, 161.035731, 143.720061, 131.599092, 128.135958, 136.793793, +145.451628, 147.183195, 140.256927, 129.867525, 124.672824, 126.404391, +128.135958, 136.793793, 181.814535, 148.914762, 148.914762, 159.304164, +166.230432, 169.693566, 180.082968, 148.914762, 147.183195, 147.183195, +147.183195, 152.377896, 155.841030, 155.841030, 161.035731, 159.304164, +152.377896, 150.646329, 148.914762, 154.109463, 167.961999, 190.472370, +188.740803, +159.304164, 161.035731, 154.109463, 135.062226, 136.793793, 135.062226, +154.109463, 145.451628, 129.867525, 131.599092, 126.404391, 124.672824, +126.404391, 135.062226, 181.814535, 143.720061, 141.988494, 152.377896, +143.720061, 185.277669, 164.498865, 145.451628, 147.183195, 145.451628, +148.914762, 150.646329, 155.841030, 157.572597, 159.304164, 155.841030, +152.377896, 150.646329, 154.109463, 155.841030, 157.572597, 171.425133, +185.277669, +166.230432, 162.767298, 157.572597, 141.988494, 145.451628, 148.914762, +157.572597, 150.646329, 129.867525, 128.135958, 126.404391, 126.404391, +126.404391, 133.330659, 174.888267, 148.914762, 143.720061, 154.109463, +159.304164, 171.425133, 169.693566, 148.914762, 148.914762, 150.646329, +143.720061, 145.451628, 154.109463, 154.109463, 159.304164, 159.304164, +159.304164, 166.230432, 166.230432, 150.646329, 157.572597, 155.841030, +169.693566, +166.230432, 167.961999, 162.767298, 150.646329, 152.377896, 154.109463, +159.304164, 155.841030, 136.793793, 124.672824, 126.404391, 126.404391, +128.135958, 133.330659, 173.156700, 159.304164, 145.451628, 148.914762, +169.693566, 173.156700, 159.304164, 150.646329, 152.377896, 152.377896, +145.451628, 143.720061, 150.646329, 154.109463, 157.572597, 162.767298, +162.767298, 166.230432, 161.035731, 150.646329, 150.646329, 145.451628, +188.740803, +161.035731, 159.304164, 164.498865, 159.304164, 162.767298, 161.035731, +159.304164, 157.572597, 141.988494, 124.672824, 126.404391, 128.135958, +128.135958, 131.599092, 164.498865, 154.109463, 147.183195, 145.451628, +176.619834, 154.109463, 147.183195, 152.377896, 162.767298, 148.914762, +141.988494, 143.720061, 141.988494, 157.572597, 162.767298, 167.961999, +155.841030, 159.304164, 147.183195, 155.841030, 147.183195, 136.793793, +216.445875, +154.109463, 166.230432, 162.767298, 155.841030, 162.767298, 164.498865, +157.572597, 157.572597, 147.183195, 131.599092, 124.672824, 126.404391, +128.135958, 129.867525, 152.377896, 173.156700, 143.720061, 145.451628, +145.451628, 143.720061, 147.183195, 152.377896, 155.841030, 147.183195, +145.451628, 143.720061, 145.451628, 152.377896, 159.304164, 161.035731, +155.841030, 154.109463, 145.451628, 155.841030, 162.767298, 136.793793, +240.687813, +161.035731, 167.961999, 167.961999, 161.035731, 159.304164, 164.498865, +157.572597, 155.841030, 150.646329, 140.256927, 128.135958, 126.404391, +126.404391, 128.135958, 147.183195, 167.961999, 164.498865, 164.498865, +154.109463, 148.914762, 148.914762, 159.304164, 150.646329, 147.183195, +145.451628, 155.841030, 148.914762, 147.183195, 157.572597, 150.646329, +150.646329, 148.914762, 161.035731, 214.714308, 242.419380, 183.546102, +247.614081, +174.888267, 164.498865, 167.961999, 167.961999, 166.230432, 164.498865, +145.451628, 152.377896, 150.646329, 141.988494, 135.062226, 126.404391, +126.404391, 128.135958, 141.988494, 159.304164, 180.082968, 164.498865, +152.377896, 154.109463, 150.646329, 154.109463, 148.914762, 147.183195, +148.914762, 150.646329, 150.646329, 140.256927, 140.256927, 143.720061, +157.572597, 183.546102, 226.835277, 264.929751, 261.466617, 212.982741, +230.298411, +171.425133, 174.888267, 176.619834, 171.425133, 166.230432, 155.841030, +143.720061, 141.988494, 147.183195, 145.451628, 136.793793, 131.599092, +128.135958, 128.135958, 135.062226, 140.256927, 154.109463, 166.230432, +155.841030, 161.035731, 152.377896, 152.377896, 148.914762, 152.377896, +154.109463, 164.498865, 154.109463, 141.988494, 140.256927, 147.183195, +180.082968, 204.324906, 244.150947, 277.050720, 223.372143, 237.224679, +254.540349, +178.351401, 180.082968, 169.693566, 171.425133, 155.841030, 152.377896, +140.256927, 131.599092, 140.256927, 143.720061, 136.793793, 133.330659, +129.867525, 129.867525, 129.867525, 131.599092, 138.525360, 155.841030, +162.767298, 150.646329, 148.914762, 150.646329, 159.304164, 147.183195, +147.183195, 147.183195, 150.646329, 150.646329, 154.109463, 157.572597, +193.935504, 199.130205, 251.077215, 266.661318, 251.077215, 244.150947, +254.540349, +183.546102, 178.351401, 173.156700, 171.425133, 159.304164, 141.988494, +135.062226, 129.867525, 135.062226, 140.256927, 136.793793, 133.330659, +133.330659, 135.062226, 135.062226, 131.599092, 133.330659, 140.256927, +154.109463, 150.646329, 145.451628, 145.451628, 155.841030, 148.914762, +147.183195, 145.451628, 138.525360, 147.183195, 167.961999, 180.082968, +206.056473, 206.056473, 258.003483, 254.540349, 249.345648, 252.808782, +263.198184, +185.277669, 181.814535, 178.351401, 173.156700, 161.035731, 143.720061, +135.062226, 128.135958, 128.135958, 136.793793, 135.062226, 133.330659, +131.599092, 135.062226, 138.525360, 136.793793, 131.599092, 135.062226, +143.720061, 145.451628, 140.256927, 140.256927, 145.451628, 143.720061, +141.988494, 135.062226, 135.062226, 147.183195, 148.914762, 167.961999, +181.814535, 197.398638, 251.077215, 252.808782, 256.271916, 254.540349, +259.735050, +185.277669, 181.814535, 178.351401, 167.961999, 159.304164, 145.451628, +124.672824, 124.672824, 129.867525, 133.330659, 131.599092, 129.867525, +131.599092, 136.793793, 138.525360, 138.525360, 133.330659, 131.599092, +141.988494, 140.256927, 138.525360, 140.256927, 138.525360, 138.525360, +138.525360, 133.330659, 128.135958, 128.135958, 126.404391, 133.330659, +157.572597, 190.472370, 228.566844, 244.150947, 263.198184, 263.198184, +251.077215, +185.277669, 181.814535, 178.351401, 166.230432, 159.304164, 148.914762, +126.404391, 122.941257, 126.404391, 129.867525, 129.867525, 131.599092, +131.599092, 135.062226, 138.525360, 138.525360, 138.525360, 169.693566, +138.525360, 138.525360, 141.988494, 141.988494, 138.525360, 135.062226, +131.599092, 126.404391, 122.941257, 124.672824, 122.941257, 128.135958, +138.525360, 187.009236, 206.056473, 235.493112, 273.587586, 245.882514, +237.224679, +185.277669, 180.082968, 174.888267, 167.961999, 147.183195, 150.646329, +129.867525, 121.209690, 121.209690, 128.135958, 128.135958, 129.867525, +133.330659, 135.062226, 138.525360, 141.988494, 190.472370, 202.593339, +190.472370, 135.062226, 140.256927, 143.720061, 140.256927, 135.062226, +131.599092, 126.404391, 122.941257, 119.478123, 117.746556, 122.941257, +128.135958, 164.498865, 207.788040, 238.956246, 256.271916, 247.614081, +240.687813 +}; const size_t array_double1_size = sizeof(array_double1); -const double array_double2[YSIZE * XSIZE] = { - 133.330659, 126.404391, 131.599092, 138.525360, 136.793793, 129.867525, - 141.988494, 112.551855, 107.357154, 110.820288, 102.162453, 102.162453, - 105.625587, 124.672824, 121.209690, 116.014989, 112.551855, 121.209690, - 122.941257, 121.209690, 117.746556, 114.283422, 112.551855, 116.014989, - 114.283422, 114.283422, 114.283422, 114.283422, 114.283422, 114.283422, - 114.283422, 114.283422, 114.283422, 112.551855, 109.088721, 109.088721, - 107.357154, 129.867525, 122.941257, 122.941257, 136.793793, 140.256927, - 129.867525, 140.256927, 126.404391, 102.162453, 112.551855, 103.894020, - 103.894020, 110.820288, 126.404391, 126.404391, 117.746556, 114.283422, - 121.209690, 124.672824, 122.941257, 117.746556, 114.283422, 114.283422, - 116.014989, 114.283422, 114.283422, 114.283422, 116.014989, 116.014989, - 116.014989, 114.283422, 116.014989, 114.283422, 110.820288, 109.088721, - 109.088721, 109.088721, 131.599092, 122.941257, 114.283422, 126.404391, - 140.256927, 135.062226, 138.525360, 136.793793, 102.162453, 114.283422, - 103.894020, 102.162453, 107.357154, 128.135958, 128.135958, 122.941257, - 116.014989, 121.209690, 126.404391, 122.941257, 117.746556, 114.283422, - 112.551855, 112.551855, 114.283422, 114.283422, 116.014989, 116.014989, - 116.014989, 116.014989, 116.014989, 116.014989, 114.283422, 110.820288, - 110.820288, 110.820288, 110.820288, 131.599092, 124.672824, 110.820288, - 117.746556, 136.793793, 140.256927, 138.525360, 138.525360, 102.162453, - 117.746556, 103.894020, 102.162453, 103.894020, 129.867525, 129.867525, - 126.404391, 116.014989, 117.746556, 126.404391, 124.672824, 117.746556, - 114.283422, 112.551855, 109.088721, 116.014989, 116.014989, 116.014989, - 116.014989, 117.746556, 116.014989, 116.014989, 114.283422, 112.551855, - 110.820288, 112.551855, 112.551855, 112.551855, 136.793793, 124.672824, - 109.088721, 114.283422, 126.404391, 138.525360, 143.720061, 141.988494, - 103.894020, 112.551855, 105.625587, 105.625587, 103.894020, 114.283422, - 129.867525, 129.867525, 112.551855, 121.209690, 126.404391, 124.672824, - 117.746556, 114.283422, 112.551855, 110.820288, 117.746556, 116.014989, - 117.746556, 117.746556, 117.746556, 116.014989, 116.014989, 114.283422, - 112.551855, 112.551855, 112.551855, 114.283422, 112.551855, 140.256927, - 126.404391, 107.357154, 112.551855, 124.672824, 128.135958, 141.988494, - 147.183195, 114.283422, 102.162453, 107.357154, 103.894020, 103.894020, - 109.088721, 129.867525, 131.599092, 117.746556, 119.478123, 124.672824, - 124.672824, 117.746556, 114.283422, 114.283422, 112.551855, 116.014989, - 117.746556, 117.746556, 117.746556, 117.746556, 117.746556, 114.283422, - 114.283422, 110.820288, 114.283422, 112.551855, 114.283422, 114.283422, - 145.451628, 128.135958, 110.820288, 110.820288, 121.209690, 122.941257, - 135.062226, 145.451628, 121.209690, 100.430886, 103.894020, 102.162453, - 102.162453, 109.088721, 129.867525, 138.525360, 126.404391, 116.014989, - 124.672824, 124.672824, 117.746556, 114.283422, 114.283422, 112.551855, - 114.283422, 117.746556, 117.746556, 117.746556, 117.746556, 117.746556, - 114.283422, 112.551855, 112.551855, 112.551855, 114.283422, 116.014989, - 117.746556, 150.646329, 140.256927, 114.283422, 109.088721, 112.551855, - 117.746556, 131.599092, 131.599092, 129.867525, 102.162453, 100.430886, - 102.162453, 102.162453, 103.894020, 122.941257, 159.304164, 112.551855, - 110.820288, 128.135958, 124.672824, 119.478123, 116.014989, 112.551855, - 112.551855, 112.551855, 117.746556, 119.478123, 117.746556, 119.478123, - 116.014989, 112.551855, 112.551855, 112.551855, 112.551855, 116.014989, - 117.746556, 119.478123, 148.914762, 148.914762, 126.404391, 110.820288, - 107.357154, 116.014989, 129.867525, 131.599092, 121.209690, 105.625587, - 100.430886, 100.430886, 102.162453, 103.894020, 140.256927, 117.746556, - 102.162453, 109.088721, 128.135958, 155.841030, 171.425133, 116.014989, - 112.551855, 112.551855, 110.820288, 116.014989, 117.746556, 117.746556, - 117.746556, 116.014989, 112.551855, 112.551855, 114.283422, 112.551855, - 114.283422, 117.746556, 117.746556, 147.183195, 147.183195, 138.525360, - 114.283422, 116.014989, 116.014989, 140.256927, 128.135958, 107.357154, - 109.088721, 102.162453, 100.430886, 100.430886, 103.894020, 161.035731, - 105.625587, 102.162453, 102.162453, 117.746556, 199.130205, 131.599092, - 116.014989, 114.283422, 110.820288, 110.820288, 114.283422, 117.746556, - 117.746556, 117.746556, 114.283422, 112.551855, 112.551855, 114.283422, - 112.551855, 110.820288, 112.551855, 119.478123, 155.841030, 150.646329, - 143.720061, 122.941257, 128.135958, 133.330659, 143.720061, 136.793793, - 109.088721, 103.894020, 102.162453, 102.162453, 100.430886, 100.430886, - 155.841030, 105.625587, 102.162453, 102.162453, 116.014989, 138.525360, - 122.941257, 117.746556, 114.283422, 110.820288, 109.088721, 109.088721, - 117.746556, 117.746556, 117.746556, 114.283422, 112.551855, 114.283422, - 116.014989, 112.551855, 110.820288, 107.357154, 150.646329, 157.572597, - 159.304164, 148.914762, 131.599092, 135.062226, 140.256927, 147.183195, - 141.988494, 116.014989, 102.162453, 102.162453, 102.162453, 102.162453, - 103.894020, 152.377896, 124.672824, 102.162453, 103.894020, 128.135958, - 138.525360, 121.209690, 116.014989, 114.283422, 110.820288, 107.357154, - 103.894020, 112.551855, 117.746556, 116.014989, 114.283422, 112.551855, - 116.014989, 114.283422, 110.820288, 107.357154, 102.162453, 192.203937, - 145.451628, 145.451628, 150.646329, 147.183195, 150.646329, 147.183195, - 145.451628, 145.451628, 124.672824, 102.162453, 102.162453, 102.162453, - 102.162453, 102.162453, 126.404391, 122.941257, 107.357154, 102.162453, - 173.156700, 121.209690, 121.209690, 116.014989, 114.283422, 110.820288, - 103.894020, 100.430886, 100.430886, 116.014989, 117.746556, 114.283422, - 112.551855, 114.283422, 110.820288, 109.088721, 102.162453, 96.967752, - 226.835277, 138.525360, 155.841030, 150.646329, 143.720061, 152.377896, - 154.109463, 145.451628, 143.720061, 131.599092, 110.820288, 102.162453, - 102.162453, 102.162453, 100.430886, 102.162453, 167.961999, 110.820288, - 107.357154, 122.941257, 117.746556, 121.209690, 126.404391, 114.283422, - 109.088721, 105.625587, 100.430886, 100.430886, 107.357154, 116.014989, - 114.283422, 110.820288, 112.551855, 109.088721, 109.088721, 105.625587, - 98.699319, 258.003483, 148.914762, 157.572597, 159.304164, 150.646329, - 147.183195, 152.377896, 143.720061, 140.256927, 135.062226, 119.478123, - 105.625587, 102.162453, 102.162453, 102.162453, 102.162453, 105.625587, - 143.720061, 124.672824, 116.014989, 116.014989, 119.478123, 119.478123, - 114.283422, 110.820288, 105.625587, 124.672824, 96.967752, 98.699319, - 110.820288, 110.820288, 110.820288, 110.820288, 112.551855, 199.130205, - 259.735050, 161.035731, 261.466617, 167.961999, 154.109463, 157.572597, - 159.304164, 154.109463, 152.377896, 128.135958, 138.525360, 135.062226, - 122.941257, 112.551855, 102.162453, 100.430886, 102.162453, 100.430886, - 102.162453, 122.941257, 124.672824, 116.014989, 121.209690, 121.209690, - 119.478123, 116.014989, 110.820288, 109.088721, 114.283422, 96.967752, - 93.504618, 98.699319, 102.162453, 110.820288, 150.646329, 240.687813, - 280.513854, 277.050720, 221.640576, 244.150947, 162.767298, 166.230432, - 167.961999, 162.767298, 154.109463, 141.988494, 122.941257, 121.209690, - 131.599092, 126.404391, 116.014989, 105.625587, 102.162453, 102.162453, - 100.430886, 102.162453, 105.625587, 122.941257, 116.014989, 129.867525, - 121.209690, 117.746556, 121.209690, 112.551855, 109.088721, 109.088721, - 102.162453, 96.967752, 93.504618, 95.236185, 155.841030, 209.519607, - 258.003483, 290.903256, 238.956246, 249.345648, 271.856019, 171.425133, - 173.156700, 161.035731, 161.035731, 141.988494, 138.525360, 121.209690, - 107.357154, 121.209690, 124.672824, 116.014989, 109.088721, 103.894020, - 103.894020, 100.430886, 100.430886, 103.894020, 117.746556, 121.209690, - 121.209690, 119.478123, 117.746556, 136.793793, 117.746556, 110.820288, - 107.357154, 103.894020, 102.162453, 98.699319, 98.699319, 152.377896, - 207.788040, 261.466617, 280.513854, 266.661318, 258.003483, 268.392885, - 178.351401, 171.425133, 164.498865, 162.767298, 145.451628, 126.404391, - 116.014989, 107.357154, 112.551855, 119.478123, 116.014989, 110.820288, - 109.088721, 110.820288, 109.088721, 102.162453, 103.894020, 112.551855, - 122.941257, 119.478123, 119.478123, 116.014989, 135.062226, 112.551855, - 109.088721, 105.625587, 102.162453, 105.625587, 103.894020, 117.746556, - 173.156700, 221.640576, 268.392885, 268.392885, 263.198184, 268.392885, - 283.976988, 180.082968, 176.619834, 171.425133, 164.498865, 148.914762, - 128.135958, 116.014989, 105.625587, 105.625587, 114.283422, 112.551855, - 109.088721, 109.088721, 110.820288, 112.551855, 109.088721, 103.894020, - 109.088721, 121.209690, 119.478123, 116.014989, 116.014989, 116.014989, - 112.551855, 107.357154, 103.894020, 100.430886, 98.699319, 107.357154, - 100.430886, 122.941257, 202.593339, 259.735050, 266.661318, 271.856019, - 268.392885, 282.245421, 180.082968, 174.888267, 171.425133, 157.572597, - 145.451628, 128.135958, 102.162453, 102.162453, 107.357154, 110.820288, - 109.088721, 105.625587, 107.357154, 110.820288, 110.820288, 110.820288, - 105.625587, 103.894020, 119.478123, 117.746556, 116.014989, 119.478123, - 116.014989, 112.551855, 107.357154, 102.162453, 100.430886, 98.699319, - 98.699319, 96.967752, 102.162453, 180.082968, 237.224679, 254.540349, - 275.319153, 278.782287, 273.587586, 180.082968, 174.888267, 171.425133, - 155.841030, 147.183195, 133.330659, 103.894020, 98.699319, 103.894020, - 107.357154, 107.357154, 107.357154, 109.088721, 110.820288, 112.551855, - 112.551855, 114.283422, 173.156700, 116.014989, 116.014989, 119.478123, - 119.478123, 116.014989, 112.551855, 109.088721, 103.894020, 100.430886, - 96.967752, 93.504618, 95.236185, 96.967752, 133.330659, 211.251174, - 245.882514, 287.440122, 271.856019, 259.735050, 180.082968, 174.888267, - 167.961999, 159.304164, 133.330659, 136.793793, 110.820288, 98.699319, - 98.699319, 107.357154, 107.357154, 107.357154, 110.820288, 112.551855, - 114.283422, 112.551855, 199.130205, 238.956246, 223.372143, 110.820288, - 117.746556, 121.209690, 117.746556, 114.283422, 110.820288, 103.894020, - 100.430886, 96.967752, 91.773051, 91.773051, 96.967752, 107.357154, - 199.130205, 247.614081, 271.856019, 270.124452, 275.319153}; +const double array_double2[YSIZE * XSIZE] = +{ +133.330659, 126.404391, 131.599092, 138.525360, 136.793793, 129.867525, +141.988494, 112.551855, 107.357154, 110.820288, 102.162453, 102.162453, +105.625587, 124.672824, 121.209690, 116.014989, 112.551855, 121.209690, +122.941257, 121.209690, 117.746556, 114.283422, 112.551855, 116.014989, +114.283422, 114.283422, 114.283422, 114.283422, 114.283422, 114.283422, +114.283422, 114.283422, 114.283422, 112.551855, 109.088721, 109.088721, +107.357154, +129.867525, 122.941257, 122.941257, 136.793793, 140.256927, 129.867525, +140.256927, 126.404391, 102.162453, 112.551855, 103.894020, 103.894020, +110.820288, 126.404391, 126.404391, 117.746556, 114.283422, 121.209690, +124.672824, 122.941257, 117.746556, 114.283422, 114.283422, 116.014989, +114.283422, 114.283422, 114.283422, 116.014989, 116.014989, 116.014989, +114.283422, 116.014989, 114.283422, 110.820288, 109.088721, 109.088721, +109.088721, +131.599092, 122.941257, 114.283422, 126.404391, 140.256927, 135.062226, +138.525360, 136.793793, 102.162453, 114.283422, 103.894020, 102.162453, +107.357154, 128.135958, 128.135958, 122.941257, 116.014989, 121.209690, +126.404391, 122.941257, 117.746556, 114.283422, 112.551855, 112.551855, +114.283422, 114.283422, 116.014989, 116.014989, 116.014989, 116.014989, +116.014989, 116.014989, 114.283422, 110.820288, 110.820288, 110.820288, +110.820288, +131.599092, 124.672824, 110.820288, 117.746556, 136.793793, 140.256927, +138.525360, 138.525360, 102.162453, 117.746556, 103.894020, 102.162453, +103.894020, 129.867525, 129.867525, 126.404391, 116.014989, 117.746556, +126.404391, 124.672824, 117.746556, 114.283422, 112.551855, 109.088721, +116.014989, 116.014989, 116.014989, 116.014989, 117.746556, 116.014989, +116.014989, 114.283422, 112.551855, 110.820288, 112.551855, 112.551855, +112.551855, +136.793793, 124.672824, 109.088721, 114.283422, 126.404391, 138.525360, +143.720061, 141.988494, 103.894020, 112.551855, 105.625587, 105.625587, +103.894020, 114.283422, 129.867525, 129.867525, 112.551855, 121.209690, +126.404391, 124.672824, 117.746556, 114.283422, 112.551855, 110.820288, +117.746556, 116.014989, 117.746556, 117.746556, 117.746556, 116.014989, +116.014989, 114.283422, 112.551855, 112.551855, 112.551855, 114.283422, +112.551855, +140.256927, 126.404391, 107.357154, 112.551855, 124.672824, 128.135958, +141.988494, 147.183195, 114.283422, 102.162453, 107.357154, 103.894020, +103.894020, 109.088721, 129.867525, 131.599092, 117.746556, 119.478123, +124.672824, 124.672824, 117.746556, 114.283422, 114.283422, 112.551855, +116.014989, 117.746556, 117.746556, 117.746556, 117.746556, 117.746556, +114.283422, 114.283422, 110.820288, 114.283422, 112.551855, 114.283422, +114.283422, +145.451628, 128.135958, 110.820288, 110.820288, 121.209690, 122.941257, +135.062226, 145.451628, 121.209690, 100.430886, 103.894020, 102.162453, +102.162453, 109.088721, 129.867525, 138.525360, 126.404391, 116.014989, +124.672824, 124.672824, 117.746556, 114.283422, 114.283422, 112.551855, +114.283422, 117.746556, 117.746556, 117.746556, 117.746556, 117.746556, +114.283422, 112.551855, 112.551855, 112.551855, 114.283422, 116.014989, +117.746556, +150.646329, 140.256927, 114.283422, 109.088721, 112.551855, 117.746556, +131.599092, 131.599092, 129.867525, 102.162453, 100.430886, 102.162453, +102.162453, 103.894020, 122.941257, 159.304164, 112.551855, 110.820288, +128.135958, 124.672824, 119.478123, 116.014989, 112.551855, 112.551855, +112.551855, 117.746556, 119.478123, 117.746556, 119.478123, 116.014989, +112.551855, 112.551855, 112.551855, 112.551855, 116.014989, 117.746556, +119.478123, +148.914762, 148.914762, 126.404391, 110.820288, 107.357154, 116.014989, +129.867525, 131.599092, 121.209690, 105.625587, 100.430886, 100.430886, +102.162453, 103.894020, 140.256927, 117.746556, 102.162453, 109.088721, +128.135958, 155.841030, 171.425133, 116.014989, 112.551855, 112.551855, +110.820288, 116.014989, 117.746556, 117.746556, 117.746556, 116.014989, +112.551855, 112.551855, 114.283422, 112.551855, 114.283422, 117.746556, +117.746556, +147.183195, 147.183195, 138.525360, 114.283422, 116.014989, 116.014989, +140.256927, 128.135958, 107.357154, 109.088721, 102.162453, 100.430886, +100.430886, 103.894020, 161.035731, 105.625587, 102.162453, 102.162453, +117.746556, 199.130205, 131.599092, 116.014989, 114.283422, 110.820288, +110.820288, 114.283422, 117.746556, 117.746556, 117.746556, 114.283422, +112.551855, 112.551855, 114.283422, 112.551855, 110.820288, 112.551855, +119.478123, +155.841030, 150.646329, 143.720061, 122.941257, 128.135958, 133.330659, +143.720061, 136.793793, 109.088721, 103.894020, 102.162453, 102.162453, +100.430886, 100.430886, 155.841030, 105.625587, 102.162453, 102.162453, +116.014989, 138.525360, 122.941257, 117.746556, 114.283422, 110.820288, +109.088721, 109.088721, 117.746556, 117.746556, 117.746556, 114.283422, +112.551855, 114.283422, 116.014989, 112.551855, 110.820288, 107.357154, +150.646329, +157.572597, 159.304164, 148.914762, 131.599092, 135.062226, 140.256927, +147.183195, 141.988494, 116.014989, 102.162453, 102.162453, 102.162453, +102.162453, 103.894020, 152.377896, 124.672824, 102.162453, 103.894020, +128.135958, 138.525360, 121.209690, 116.014989, 114.283422, 110.820288, +107.357154, 103.894020, 112.551855, 117.746556, 116.014989, 114.283422, +112.551855, 116.014989, 114.283422, 110.820288, 107.357154, 102.162453, +192.203937, +145.451628, 145.451628, 150.646329, 147.183195, 150.646329, 147.183195, +145.451628, 145.451628, 124.672824, 102.162453, 102.162453, 102.162453, +102.162453, 102.162453, 126.404391, 122.941257, 107.357154, 102.162453, +173.156700, 121.209690, 121.209690, 116.014989, 114.283422, 110.820288, +103.894020, 100.430886, 100.430886, 116.014989, 117.746556, 114.283422, +112.551855, 114.283422, 110.820288, 109.088721, 102.162453, 96.967752, +226.835277, +138.525360, 155.841030, 150.646329, 143.720061, 152.377896, 154.109463, +145.451628, 143.720061, 131.599092, 110.820288, 102.162453, 102.162453, +102.162453, 100.430886, 102.162453, 167.961999, 110.820288, 107.357154, +122.941257, 117.746556, 121.209690, 126.404391, 114.283422, 109.088721, +105.625587, 100.430886, 100.430886, 107.357154, 116.014989, 114.283422, +110.820288, 112.551855, 109.088721, 109.088721, 105.625587, 98.699319, +258.003483, +148.914762, 157.572597, 159.304164, 150.646329, 147.183195, 152.377896, +143.720061, 140.256927, 135.062226, 119.478123, 105.625587, 102.162453, +102.162453, 102.162453, 102.162453, 105.625587, 143.720061, 124.672824, +116.014989, 116.014989, 119.478123, 119.478123, 114.283422, 110.820288, +105.625587, 124.672824, 96.967752, 98.699319, 110.820288, 110.820288, +110.820288, 110.820288, 112.551855, 199.130205, 259.735050, 161.035731, +261.466617, +167.961999, 154.109463, 157.572597, 159.304164, 154.109463, 152.377896, +128.135958, 138.525360, 135.062226, 122.941257, 112.551855, 102.162453, +100.430886, 102.162453, 100.430886, 102.162453, 122.941257, 124.672824, +116.014989, 121.209690, 121.209690, 119.478123, 116.014989, 110.820288, +109.088721, 114.283422, 96.967752, 93.504618, 98.699319, 102.162453, +110.820288, 150.646329, 240.687813, 280.513854, 277.050720, 221.640576, +244.150947, +162.767298, 166.230432, 167.961999, 162.767298, 154.109463, 141.988494, +122.941257, 121.209690, 131.599092, 126.404391, 116.014989, 105.625587, +102.162453, 102.162453, 100.430886, 102.162453, 105.625587, 122.941257, +116.014989, 129.867525, 121.209690, 117.746556, 121.209690, 112.551855, +109.088721, 109.088721, 102.162453, 96.967752, 93.504618, 95.236185, +155.841030, 209.519607, 258.003483, 290.903256, 238.956246, 249.345648, +271.856019, +171.425133, 173.156700, 161.035731, 161.035731, 141.988494, 138.525360, +121.209690, 107.357154, 121.209690, 124.672824, 116.014989, 109.088721, +103.894020, 103.894020, 100.430886, 100.430886, 103.894020, 117.746556, +121.209690, 121.209690, 119.478123, 117.746556, 136.793793, 117.746556, +110.820288, 107.357154, 103.894020, 102.162453, 98.699319, 98.699319, +152.377896, 207.788040, 261.466617, 280.513854, 266.661318, 258.003483, +268.392885, +178.351401, 171.425133, 164.498865, 162.767298, 145.451628, 126.404391, +116.014989, 107.357154, 112.551855, 119.478123, 116.014989, 110.820288, +109.088721, 110.820288, 109.088721, 102.162453, 103.894020, 112.551855, +122.941257, 119.478123, 119.478123, 116.014989, 135.062226, 112.551855, +109.088721, 105.625587, 102.162453, 105.625587, 103.894020, 117.746556, +173.156700, 221.640576, 268.392885, 268.392885, 263.198184, 268.392885, +283.976988, +180.082968, 176.619834, 171.425133, 164.498865, 148.914762, 128.135958, +116.014989, 105.625587, 105.625587, 114.283422, 112.551855, 109.088721, +109.088721, 110.820288, 112.551855, 109.088721, 103.894020, 109.088721, +121.209690, 119.478123, 116.014989, 116.014989, 116.014989, 112.551855, +107.357154, 103.894020, 100.430886, 98.699319, 107.357154, 100.430886, +122.941257, 202.593339, 259.735050, 266.661318, 271.856019, 268.392885, +282.245421, +180.082968, 174.888267, 171.425133, 157.572597, 145.451628, 128.135958, +102.162453, 102.162453, 107.357154, 110.820288, 109.088721, 105.625587, +107.357154, 110.820288, 110.820288, 110.820288, 105.625587, 103.894020, +119.478123, 117.746556, 116.014989, 119.478123, 116.014989, 112.551855, +107.357154, 102.162453, 100.430886, 98.699319, 98.699319, 96.967752, +102.162453, 180.082968, 237.224679, 254.540349, 275.319153, 278.782287, +273.587586, +180.082968, 174.888267, 171.425133, 155.841030, 147.183195, 133.330659, +103.894020, 98.699319, 103.894020, 107.357154, 107.357154, 107.357154, +109.088721, 110.820288, 112.551855, 112.551855, 114.283422, 173.156700, +116.014989, 116.014989, 119.478123, 119.478123, 116.014989, 112.551855, +109.088721, 103.894020, 100.430886, 96.967752, 93.504618, 95.236185, +96.967752, 133.330659, 211.251174, 245.882514, 287.440122, 271.856019, +259.735050, +180.082968, 174.888267, 167.961999, 159.304164, 133.330659, 136.793793, +110.820288, 98.699319, 98.699319, 107.357154, 107.357154, 107.357154, +110.820288, 112.551855, 114.283422, 112.551855, 199.130205, 238.956246, +223.372143, 110.820288, 117.746556, 121.209690, 117.746556, 114.283422, +110.820288, 103.894020, 100.430886, 96.967752, 91.773051, 91.773051, +96.967752, 107.357154, 199.130205, 247.614081, 271.856019, 270.124452, +275.319153 +}; const size_t array_double2_size = sizeof(array_double2); + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/test_arrays.h b/thirdparty/SDL2_image/external/libtiff/test/test_arrays.h index c2fa832d4..62e1d33c7 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/test_arrays.h +++ b/thirdparty/SDL2_image/external/libtiff/test/test_arrays.h @@ -1,23 +1,23 @@ /* * Copyright (c) 2004, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -27,7 +27,7 @@ * Few declarations for the test numerical arrays. */ -#ifndef _TEST_ARRAYS_ +#ifndef _TEST_ARRAYS_ #define _TEST_ARRAYS_ #include @@ -57,3 +57,5 @@ extern const double array_double2[]; extern const size_t array_double2_size; #endif /* _TEST_ARRAYS_ */ + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/test_directory.c b/thirdparty/SDL2_image/external/libtiff/test/test_directory.c deleted file mode 100644 index 6cc3baf84..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/test_directory.c +++ /dev/null @@ -1,1184 +0,0 @@ -/* - * TIFF Library - * - * The purpose of this test suite is to test the correctness of - * TIFFWriteDirectory() when appending multiple directories to an open file. - * - * Currently, there is an optimization where the TIFF data structure stores the - * offset of the last written directory in order to avoid having to traverse the - * entire directory list each time a new one is added. The offset is not stored - * in the file itself, only in the in-memory data structure. This means we still - * go through the entire list the first time a directory is appended to a - * newly-opened file, and the shortcut is taken for subsequent directory writes. - * - * In order to test the correctness of the optimization, the - * `test_lastdir_offset` function writes 10 directories to two different files. - * For the first file we use the optimization, by simply calling - * TIFFWriteDirectory() repeatedly on an open TIFF handle. For the second file, - * we avoid the optimization by closing the file after each call to - * TIFFWriteDirectory(), which means the next directory write will traverse the - * entire list. - * - * Finally, the two files are compared to check that the number of directories - * written is the same, and that their offsets match. The test is then repeated - * using BigTIFF files. - * - * Furthermore, arbitrary directory loading using TIFFSetDirectory() is checked, - * especially after the update with "relative" movement possibility. Also - * TIFFUnlinkDirectory() is tested. - * - */ - -#include "tif_config.h" - -#include -#include -#include -#include - -#include "tiffio.h" - -#ifdef HAVE_UNISTD_H -#include -#endif - -#define SPP 3 /* Samples per pixel */ -#define N_DIRECTORIES 10 /* Number of directories to write */ -const uint16_t width = 1; -const uint16_t length = 1; -const uint16_t bps = 8; -const uint16_t photometric = PHOTOMETRIC_RGB; -const uint16_t rows_per_strip = 1; -const uint16_t planarconfig = PLANARCONFIG_CONTIG; - -int write_data_to_current_directory(TIFF *tif, int i) -{ - unsigned char buf[SPP] = {0, 127, 255}; - char auxString[128]; - - if (!tif) - { - fprintf(stderr, "Invalid TIFF handle.\n"); - return 1; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); - return 1; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); - return 1; - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); - return 1; - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - return 1; - } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - return 1; - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); - return 1; - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) - { - fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); - return 1; - } - /* Write IFD identification number to ASCII string of PageName tag. */ - sprintf(auxString, "%d th. IFD", i); - if (!TIFFSetField(tif, TIFFTAG_PAGENAME, auxString)) - { - fprintf(stderr, "Can't set TIFFTAG_PAGENAME tag.\n"); - return 1; - } - - /* Write dummy pixel data. */ - if (TIFFWriteScanline(tif, buf, 0, 0) == -1) - { - fprintf(stderr, "Can't write image data.\n"); - return 1; - } - - return 0; -} - -int write_directory_to_closed_file(const char *filename, bool is_big_tiff, - int i) -{ - TIFF *tif; - tif = TIFFOpen(filename, is_big_tiff ? "a8" : "a"); - if (!tif) - { - fprintf(stderr, "Can't create/open %s\n", filename); - return 1; - } - - if (write_data_to_current_directory(tif, i)) - { - fprintf(stderr, "Can't write data to directory %d of %s.\n", i, - filename); - TIFFClose(tif); - return 1; - } - - if (!TIFFWriteDirectory(tif)) - { - fprintf(stderr, "TIFFWriteDirectory() failed for directory %d of %s.\n", - i, filename); - TIFFClose(tif); - return 1; - } - - TIFFClose(tif); - return 0; -} - -int count_directories(const char *filename, int *count) -{ - TIFF *tif; - *count = 0; - - tif = TIFFOpen(filename, "r"); - if (!tif) - { - fprintf(stderr, "Can't read %s\n", filename); - return 1; - } - - do - { - (*count)++; - } while (TIFFReadDirectory(tif)); - - TIFFClose(tif); - return 0; -} - -/* Compare 'requested_dir_number' with number written in PageName tag - * into the IFD to identify that IFD. */ -int is_requested_directory(TIFF *tif, int requested_dir_number, - const char *filename) -{ - char *ptr = NULL; - char *auxStr = NULL; - - if (!TIFFGetField(tif, TIFFTAG_PAGENAME, &ptr)) - { - fprintf(stderr, "Can't get TIFFTAG_PAGENAME tag.\n"); - return 0; - } - - /* Check for reading errors */ - if (ptr != NULL) - auxStr = strchr(ptr, ' '); - - if (ptr == NULL || auxStr == NULL || strncmp(auxStr, " th.", 4)) - { - ptr = ptr == NULL ? "(null)" : ptr; - fprintf(stderr, - "Error reading IFD directory number from PageName tag: %s\n", - ptr); - return 0; - } - - /* Retrieve IFD identification number from ASCII string */ - const int nthIFD = atoi(ptr); - if (nthIFD == requested_dir_number) - { - return 1; - } - fprintf(stderr, "Expected directory %d from %s was not loaded but: %s\n", - requested_dir_number, filename, ptr); - - return 0; -} - -enum DirWalkMode -{ - DirWalkMode_ReadDirectory, - DirWalkMode_SetDirectory, - DirWalkMode_SetDirectory_Reverse, -}; -/* Gets a list of the directory offsets in a file. Assumes the file has at least - * N_DIRECTORIES directories. - * There are three methods to test walking through the IFD chain. - * This tests the optimization of faster SetDirectory(). */ -int get_dir_offsets(const char *filename, uint64_t *offsets, - enum DirWalkMode dirWalkMode) -{ - TIFF *tif; - int i; - - tif = TIFFOpen(filename, "r"); - if (!tif) - { - fprintf(stderr, "Can't read %s\n", filename); - return 1; - } - - for (i = 0; i < N_DIRECTORIES; i++) - { - tdir_t dirn = (dirWalkMode == DirWalkMode_SetDirectory_Reverse) - ? (N_DIRECTORIES - i - 1) - : i; - - if (dirWalkMode != DirWalkMode_ReadDirectory && - !TIFFSetDirectory(tif, dirn) && dirn < (N_DIRECTORIES - 1)) - { - fprintf(stderr, "Can't set %d.th directory from %s\n", i, filename); - TIFFClose(tif); - return 3; - } - - offsets[dirn] = TIFFCurrentDirOffset(tif); - - /* Check, if dirn is requested directory */ - if (!is_requested_directory(tif, dirn, filename)) - { - TIFFClose(tif); - return 4; - } - - if (dirWalkMode == DirWalkMode_ReadDirectory && - !TIFFReadDirectory(tif) && i < (N_DIRECTORIES - 1)) - { - fprintf(stderr, "Can't read %d.th directory from %s\n", i, - filename); - TIFFClose(tif); - return 2; - } - } - - TIFFClose(tif); - return 0; -} - -/* Checks that TIFFSetDirectory() work well after update for relative seeking - * to following directories. - * - * There are several issues especially when SubIFDs and custom directories are - * involved. There are no real directory number for those and TIFFSetDirectory() - * cannot be used. However, TIFFSetDirectory() is needed to switch back to the - * main-IFD chain. Furthermore, IFD-loop handling needs to be supported in any - * cases. - * Also the case where directly after TIFFWriteDirectory() that directory - * is re-read using TIFFSetDirectory() is tested. - */ -int test_arbitrary_directrory_loading(bool is_big_tiff) -{ - const char *filename = "test_arbitrary_directrory_loading.tif"; - TIFF *tif; - uint64_t offsets_base[N_DIRECTORIES]; - int expected_original_dirnumber; - - /* Create a file and write N_DIRECTORIES (10) directories to it */ - tif = TIFFOpen(filename, is_big_tiff ? "w8" : "w"); - if (!tif) - { - fprintf(stderr, "Can't create %s\n", filename); - return 1; - } - TIFFSetDirectory(tif, 0); - for (int i = 0; i < N_DIRECTORIES; i++) - { - if (write_data_to_current_directory(tif, i)) - { - fprintf(stderr, "Can't write data to current directory in %s\n", - filename); - goto failure; - } - if (!TIFFWriteDirectory(tif)) - { - fprintf(stderr, "Can't write directory to %s\n", filename); - goto failure; - } - if (i >= 2 && i <= 4) - { - if (i == 3) - { - /* Invalidate directory - TIFFSetSubDirectory() will fail */ - if (TIFFSetSubDirectory(tif, 0)) - { - fprintf(stderr, - "Unexpected return at invalidate directory %d " - "within %s.\n", - i, filename); - goto failure; - } - } - /* Test jump back to just written directory. */ - if (!TIFFSetDirectory(tif, i)) - { - fprintf(stderr, - "Can't set directory %d within %s " - "right after TIFFWriteDirectory().\n", - i, filename); - goto failure; - } - if (i == 4) - { - /* Invalidate directory - TIFFSetSubDirectory() will fail */ - if (TIFFSetSubDirectory(tif, 0)) - { - fprintf(stderr, - "Unexpected return at invalidate directory %d " - "within %s.\n", - i, filename); - goto failure; - } - } - /*Check if correct directory is loaded */ - if (!is_requested_directory(tif, i, filename)) - { - goto failure; - } - /* Reset to next directory to go on with writing. */ - TIFFCreateDirectory(tif); - } - } - TIFFClose(tif); - - /* Reopen prepared testfile */ - tif = TIFFOpen(filename, "r+"); - if (!tif) - { - fprintf(stderr, "Can't create %s\n", filename); - return 1; - } - - /* Get directory offsets */ - if (get_dir_offsets(filename, offsets_base, DirWalkMode_ReadDirectory)) - { - fprintf(stderr, "Error reading directory offsets from %s.\n", filename); - goto failure; - } - - /* Set last directory and then one after, which should fail. */ - if (!TIFFSetDirectory(tif, N_DIRECTORIES - 1)) - { - fprintf(stderr, "Can't set last directory %d within %s\n", - N_DIRECTORIES - 1, filename); - goto failure; - } - if (TIFFSetDirectory(tif, N_DIRECTORIES + 1)) - { - fprintf(stderr, - "End of IFD chain not detected. Set non existing directory %d " - "within %s\n", - N_DIRECTORIES + 1, filename); - goto failure; - } - - /* Test very fast TIFFSetDirectory() using IFD loop directory list. - * First populate IFD loop directory list and then go through directories in - * reverse order. Within between read after end of IFDs using - * TIFFReadDirectory() where IFD loop directory list should be kept. */ - for (int i = 0; i < N_DIRECTORIES; i++) - { - if (!TIFFSetDirectory(tif, i)) - { - fprintf(stderr, "Can't set %d.th directory from %s\n", i, filename); - goto failure; - } - } - TIFFReadDirectory(tif); - for (int i = N_DIRECTORIES - 1; i >= 0; i--) - { - if (!TIFFSetDirectory(tif, i)) - { - fprintf(stderr, "Can't set %d.th directory from %s\n", i, filename); - goto failure; - } - if (!is_requested_directory(tif, i, filename)) - { - goto failure; - } - } - - /* Test not existing directory number */ - if (TIFFSetDirectory(tif, N_DIRECTORIES)) - { - fprintf(stderr, - "No expected fail for accessing not existant directory number " - "%d in file %s\n", - N_DIRECTORIES, filename); - goto failure; - } - - /* Close and Reopen prepared testfile */ - TIFFClose(tif); - tif = TIFFOpen(filename, "r+"); - if (!tif) - { - fprintf(stderr, "Can't create %s\n", filename); - return 1; - } - - /* Step through directories just using TIFFSetSubDirectory() */ - for (int i = N_DIRECTORIES - 1; i >= 0; i--) - { - if (!TIFFSetSubDirectory(tif, offsets_base[i])) - { - fprintf(stderr, "Can't set %d.th directory from %s\n", i, filename); - goto failure; - } - if (!is_requested_directory(tif, i, filename)) - { - goto failure; - } - } - - /* More specialized test cases for relative seeking within TIFFSetDirectory. - * However, with using IFD loop directory list, most of this test cases will - * never be reached! */ - if (!TIFFSetDirectory(tif, 2)) - { - fprintf(stderr, "Can't set directory %d within %s\n", 2, filename); - goto failure; - } - uint64_t off2 = TIFFCurrentDirOffset(tif); - /* Note that dirnum = 2 is deleted here since TIFFUnlinkDirectory() - * starts with 1 instead of 0. */ - if (!TIFFUnlinkDirectory(tif, 3)) - { - fprintf(stderr, "Can't unlink directory %d within %s\n", 3, filename); - goto failure; - } - /* Move to the unlinked IFD. This sets tif_curdir=0 because unlinked IFD - * offset is not in the IFD loop list. This indicates a SubIFD chain. */ - if (!TIFFSetSubDirectory(tif, off2)) - { - fprintf(stderr, - "Can't set sub-directory at offset 0x%" PRIx64 " (%" PRIu64 - ") within %s\n", - off2, off2, filename); - goto failure; - } - /*Check if correct directory is loaded */ - expected_original_dirnumber = 2; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - /* This should move back to the main-IFD chain and load the third - * directory which has IFD number 4, due to the deleted third IFD. */ - if (!TIFFSetDirectory(tif, 3)) - { - fprintf(stderr, "Can't set new directory %d within %s\n", 3, filename); - goto failure; - } - expected_original_dirnumber = 4; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - /* Test backwards jump. */ - if (!TIFFSetDirectory(tif, 2)) - { - fprintf(stderr, "Can't set new directory %d within %s\n", 2, filename); - goto failure; - } - expected_original_dirnumber = 3; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - - /* Second UnlinkDirectory -> two IFDs are missing in the main-IFD chain - * then, orignal dirnum 2 and 3 */ - if (!TIFFUnlinkDirectory(tif, 3)) - { - fprintf(stderr, "Can't unlink directory %d within %s\n", 3, filename); - goto failure; - } - if (!TIFFSetDirectory(tif, 2)) - { - fprintf(stderr, - "Can't set new directory %d after second " - "TIFFUnlinkDirectory(3) within %s\n", - 2, filename); - goto failure; - } - /* which should now be the previous dir-3. */ - expected_original_dirnumber = 4; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - - /* Check, if third original directory could be loaded and the following, - * still chained one. This is like for a SubIFD. */ - if (!TIFFSetSubDirectory(tif, offsets_base[2])) - { - fprintf(stderr, - "Can't set sub-directory at offset 0x%" PRIx64 " (%" PRIu64 - ") within %s\n", - offsets_base[2], offsets_base[2], filename); - goto failure; - } - if (!TIFFReadDirectory(tif)) - { - fprintf(stderr, - "Can't read directory after directory at offset 0x%" PRIx64 - " (%" PRIu64 ") within %s\n", - offsets_base[2], offsets_base[2], filename); - goto failure; - } - /* Check if correct directory is loaded, which was unlinked the second - * time. - */ - expected_original_dirnumber = 3; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - - /* Load unlinked directory like a SubIFD and then go back to the - * main-IFD chain using TIFFSetDirectory(). Also check two loads of the - * same directory. */ - if (!TIFFSetSubDirectory(tif, offsets_base[2])) - { - fprintf(stderr, - "Can't set sub-directory at offset 0x%" PRIx64 " (%" PRIu64 - ") within %s\n", - offsets_base[2], offsets_base[2], filename); - goto failure; - } - if (!TIFFSetDirectory(tif, 3)) - { - fprintf(stderr, "Can't set new directory %d within %s\n", 3, filename); - goto failure; - } - if (!TIFFSetDirectory(tif, 3)) - { - fprintf(stderr, "Can't set new directory %d a second time within %s\n", - 3, filename); - goto failure; - } - /*Check if correct directory is loaded. Because two original IFDs are - * unlinked / missing, the original dirnumber is now 5. */ - expected_original_dirnumber = 5; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - - /* Another sequence for testing. */ - if (!TIFFSetDirectory(tif, 2)) - { - fprintf(stderr, "Can't set new directory %d a second time within %s\n", - 2, filename); - goto failure; - } - if (!TIFFSetDirectory(tif, 3)) - { - fprintf(stderr, "Can't set new directory %d a second time within %s\n", - 3, filename); - goto failure; - } - if (!TIFFSetSubDirectory(tif, offsets_base[2])) - { - fprintf(stderr, - "Can't set sub-directory at offset 0x%" PRIx64 " (%" PRIu64 - ") within %s\n", - offsets_base[2], offsets_base[2], filename); - goto failure; - } - expected_original_dirnumber = 2; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - if (!TIFFSetDirectory(tif, 3)) - { - fprintf(stderr, "Can't set new directory %d a second time within %s\n", - 3, filename); - goto failure; - } - /*Check if correct directory is loaded. Because two original IFDs are - * unlinked / missing, the original dirnumber is now 5. */ - expected_original_dirnumber = 5; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - - /* Third UnlinkDirectory -> three IFDs are missing in the main-IFD chain - * then, orignal dirnum 0, 2 and 3 - * Furthermore, this test checks that TIFFUnlinkDirectory() can unlink - * the first directory dirnum = 0 and a following TIFFSetDirectory(0) - * does not load the unlinked directory. */ - if (!TIFFUnlinkDirectory(tif, 1)) - { - fprintf(stderr, "Can't unlink directory %d within %s\n", 0, filename); - goto failure; - } - /* Now three directories are missing (0,2,3) and thus directory 0 is - * original directory 1 and directory 2 is original directory 5. */ - if (!TIFFSetDirectory(tif, 0)) - { - fprintf(stderr, - "Can't set new directory %d after third " - "TIFFUnlinkDirectory(1) within %s\n", - 0, filename); - goto failure; - } - expected_original_dirnumber = 1; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - if (!TIFFSetDirectory(tif, 2)) - { - fprintf(stderr, - "Can't set new directory %d after third " - "TIFFUnlinkDirectory(1) within %s\n", - 2, filename); - goto failure; - } - expected_original_dirnumber = 5; - if (!is_requested_directory(tif, expected_original_dirnumber, filename)) - { - goto failure; - } - - /* TIFFUnlinkDirectory(0) is not allowed, because dirnum starts for - * this function with 1 instead of 0. - * An error return is expected here. */ - if (TIFFUnlinkDirectory(tif, 0)) - { - fprintf(stderr, "TIFFUnlinkDirectory(0) did not return an error.\n"); - goto failure; - } - - TIFFClose(tif); - unlink(filename); - return 0; - -failure: - if (tif) - { - TIFFClose(tif); - } - unlink(filename); - return 1; -} - -/* Tests SubIFD writing and reading - * - * - */ -int test_SubIFD_directrory_handling(bool is_big_tiff) -{ - const char *filename = "test_SubIFD_directrory_handling.tif"; - -/* Define the number of sub-IFDs you are going to write */ -#define NUMBER_OF_SUBIFDs 3 - uint16_t number_of_sub_IFDs = NUMBER_OF_SUBIFDs; - toff_t sub_IFDs_offsets[NUMBER_OF_SUBIFDs] = { - 0UL}; /* array for SubIFD tag */ - int blnWriteSubIFD = 0; - int i; - int iIFD = 0, iSubIFD = 0; - TIFF *tif; - int expected_original_dirnumber; - - /* Create a file and write N_DIRECTORIES (10) directories to it */ - tif = TIFFOpen(filename, is_big_tiff ? "w8" : "w"); - if (!tif) - { - fprintf(stderr, "Can't create %s\n", filename); - return 1; - } - for (i = 0; i < N_DIRECTORIES; i++) - { - if (write_data_to_current_directory( - tif, blnWriteSubIFD ? 200 + iSubIFD++ : iIFD++)) - { - fprintf(stderr, "Can't write data to current directory in %s\n", - filename); - goto failure; - } - if (blnWriteSubIFD) - { - /* SUBFILETYPE tag is not mandatory for SubIFD writing, but a - * good idea to indicate thumbnails */ - if (!TIFFSetField(tif, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE)) - goto failure; - } - - /* For the second multi-page image, trigger TIFFWriteDirectory() to - * switch for the next number_of_sub_IFDs calls to add those as SubIFDs - * e.g. for thumbnails */ - if (1 == i) - { - blnWriteSubIFD = 1; - /* Now here is the trick: the next n directories written - * will be sub-IFDs of the main-IFD (where n is number_of_sub_IFDs - * specified when you set the TIFFTAG_SUBIFD field. - * The SubIFD offset array sub_IFDs_offsets is filled automatically - * with the proper offset values by the following number_of_sub_IFDs - * TIFFWriteDirectory() calls and are updated in the related - * main-IFD with the last call. - */ - if (!TIFFSetField(tif, TIFFTAG_SUBIFD, number_of_sub_IFDs, - sub_IFDs_offsets)) - goto failure; - } - - if (!TIFFWriteDirectory(tif)) - { - fprintf(stderr, "Can't write directory to %s\n", filename); - goto failure; - } - - if (iSubIFD >= number_of_sub_IFDs) - blnWriteSubIFD = 0; - } - TIFFClose(tif); - - /* Reopen prepared testfile */ - tif = TIFFOpen(filename, "r+"); - if (!tif) - { - fprintf(stderr, "Can't create %s\n", filename); - goto failure; - } - - tdir_t numberOfMainIFDs = TIFFNumberOfDirectories(tif); - if (numberOfMainIFDs != N_DIRECTORIES - number_of_sub_IFDs) - { - fprintf(stderr, - "Unexpected number of directories in %s. Expected %i, " - "found %i.\n", - filename, N_DIRECTORIES - number_of_sub_IFDs, numberOfMainIFDs); - goto failure; - } - - tdir_t currentDirNumber = TIFFCurrentDirectory(tif); - - /* The first directory is already read through TIFFOpen() */ - int blnRead = 0; - expected_original_dirnumber = 1; - do - { - /* Check if there are SubIFD subfiles */ - void *ptr; - if (TIFFGetField(tif, TIFFTAG_SUBIFD, &number_of_sub_IFDs, &ptr)) - { - /* Copy SubIFD array from pointer */ - memcpy(sub_IFDs_offsets, ptr, - number_of_sub_IFDs * sizeof(sub_IFDs_offsets[0])); - - for (i = 0; i < number_of_sub_IFDs; i++) - { - /* Read first SubIFD directory */ - if (!TIFFSetSubDirectory(tif, sub_IFDs_offsets[i])) - goto failure; - if (!is_requested_directory(tif, 200 + i, filename)) - { - goto failure; - } - /* Check if there is a SubIFD chain behind the first one from - * the array, as specified by Adobe */ - int n = 0; - while (TIFFReadDirectory(tif)) - { - /* analyse subfile */ - if (!is_requested_directory(tif, 201 + i + n++, filename)) - goto failure; - } - } - /* Go back to main-IFD chain and re-read that main-IFD directory */ - if (!TIFFSetDirectory(tif, currentDirNumber)) - goto failure; - } - /* Read next main-IFD directory (subfile) */ - blnRead = TIFFReadDirectory(tif); - currentDirNumber = TIFFCurrentDirectory(tif); - if (blnRead && !is_requested_directory( - tif, expected_original_dirnumber++, filename)) - goto failure; - } while (blnRead); - - /*--- Now test arbitrary directory loading with SubIFDs ---*/ - if (!TIFFSetSubDirectory(tif, sub_IFDs_offsets[1])) - goto failure; - if (!is_requested_directory(tif, 201, filename)) - { - goto failure; - } - - TIFFClose(tif); - unlink(filename); - return 0; - -failure: - if (tif) - { - TIFFClose(tif); - tif = NULL; - } - unlink(filename); - return 1; -} /*--- test_SubIFD_directrory_handling() ---*/ - -/* Checks that rewriting a directory does not break the directory linked - * list - * - * This could happen because TIFFRewriteDirectory relies on the traversal of - * the directory linked list in order to move the rewritten directory to the - * end of the file. This means the `lastdir_offset` optimization should be - * skipped, otherwise the linked list will be broken at the point where it - * connected to the rewritten directory, resulting in the loss of the - * directories that come after it. - * Rewriting the first directory requires an additional test, because it is - * treated differently from the directories that have a predecessor in the list. - */ -int test_rewrite_lastdir_offset(bool is_big_tiff) -{ - const char *filename = "test_directory_rewrite.tif"; - int i, count; - TIFF *tif; - - /* Create a file and write N_DIRECTORIES (10) directories to it */ - tif = TIFFOpen(filename, is_big_tiff ? "w8" : "w"); - if (!tif) - { - fprintf(stderr, "Can't create %s\n", filename); - return 1; - } - for (i = 0; i < N_DIRECTORIES; i++) - { - if (write_data_to_current_directory(tif, i)) - { - fprintf(stderr, "Can't write data to current directory in %s\n", - filename); - goto failure; - } - if (!TIFFWriteDirectory(tif)) - { - fprintf(stderr, "Can't write directory to %s\n", filename); - goto failure; - } - } - - /* Without closing the file, go to the fifth directory - * and check, if dirn is requested directory. */ - TIFFSetDirectory(tif, 4); - if (!is_requested_directory(tif, 4, filename)) - { - TIFFClose(tif); - return 4; - } - - /* Rewrite the fifth directory by calling TIFFRewriteDirectory - * and check, if the offset of IFD loaded by TIFFSetDirectory() is - * different. Then, the IFD loop directory list is correctly maintained for - * speed up of TIFFSetDirectory() with directly getting the offset that - * list. - */ - uint64_t off1 = TIFFCurrentDirOffset(tif); - if (write_data_to_current_directory(tif, 4)) - { - fprintf(stderr, "Can't write data to fifth directory in %s\n", - filename); - goto failure; - } - if (!TIFFRewriteDirectory(tif)) - { - fprintf(stderr, "Can't rewrite fifth directory to %s\n", filename); - goto failure; - } - i = 4; - if (!TIFFSetDirectory(tif, i)) - { - fprintf(stderr, "Can't set %d.th directory from %s\n", i, filename); - goto failure; - } - uint64_t off2 = TIFFCurrentDirOffset(tif); - if (!is_requested_directory(tif, i, filename)) - { - goto failure; - } - if (off1 == off2) - { - fprintf(stderr, - "Rewritten directory %d was not correctly accessed by " - "TIFFSetDirectory() in file %s\n", - i, filename); - goto failure; - } - - /* Now, perform the test for the first directory */ - TIFFSetDirectory(tif, 0); - if (!is_requested_directory(tif, 0, filename)) - { - TIFFClose(tif); - return 5; - } - off1 = TIFFCurrentDirOffset(tif); - if (write_data_to_current_directory(tif, 0)) - { - fprintf(stderr, "Can't write data to first directory in %s\n", - filename); - goto failure; - } - if (!TIFFRewriteDirectory(tif)) - { - fprintf(stderr, "Can't rewrite first directory to %s\n", filename); - goto failure; - } - i = 0; - if (!TIFFSetDirectory(tif, i)) - { - fprintf(stderr, "Can't set %d.th directory from %s\n", i, filename); - goto failure; - } - off2 = TIFFCurrentDirOffset(tif); - if (!is_requested_directory(tif, i, filename)) - { - goto failure; - } - if (off1 == off2) - { - fprintf(stderr, - "Rewritten directory %d was not correctly accessed by " - "TIFFSetDirectory() in file %s\n", - i, filename); - goto failure; - } - - TIFFClose(tif); - tif = NULL; - - /* Check that the file has the expected number of directories*/ - if (count_directories(filename, &count)) - { - fprintf(stderr, "Error counting directories in file %s.\n", filename); - goto failure; - } - if (count != N_DIRECTORIES) - { - fprintf(stderr, - "Unexpected number of directories in %s. Expected %i, " - "found %i.\n", - filename, N_DIRECTORIES, count); - goto failure; - } - - unlink(filename); - return 0; - -failure: - if (tif) - { - TIFFClose(tif); - } - unlink(filename); - return 1; -} - -/* Compares multi-directory files written with and without the lastdir - * optimization */ -int test_lastdir_offset(bool is_big_tiff) -{ - const char *filename_optimized = "test_directory_optimized.tif"; - const char *filename_non_optimized = "test_directory_non_optimized.tif"; - int i, count_optimized, count_non_optimized; - uint64_t offsets_base[N_DIRECTORIES]; - uint64_t offsets_comparison[N_DIRECTORIES]; - TIFF *tif; - - /* First file: open it and add multiple directories. This uses the - * lastdir optimization. */ - tif = TIFFOpen(filename_optimized, is_big_tiff ? "w8" : "w"); - if (!tif) - { - fprintf(stderr, "Can't create %s\n", filename_optimized); - return 1; - } - for (i = 0; i < N_DIRECTORIES; i++) - { - if (write_data_to_current_directory(tif, i)) - { - fprintf(stderr, "Can't write data to current directory in %s\n", - filename_optimized); - goto failure; - } - if (!TIFFWriteDirectory(tif)) - { - fprintf(stderr, "Can't write directory to %s\n", - filename_optimized); - goto failure; - } - } - TIFFClose(tif); - tif = NULL; - - /* Second file: close it after adding each directory. This avoids the - * lastdir optimization. */ - for (i = 0; i < N_DIRECTORIES; i++) - { - if (write_directory_to_closed_file(filename_non_optimized, is_big_tiff, - i)) - { - fprintf(stderr, "Can't write directory to %s\n", - filename_non_optimized); - goto failure; - } - } - - /* Check that both files have the expected number of directories */ - if (count_directories(filename_optimized, &count_optimized)) - { - fprintf(stderr, "Error counting directories in file %s.\n", - filename_optimized); - goto failure; - } - if (count_optimized != N_DIRECTORIES) - { - fprintf(stderr, - "Unexpected number of directories in %s. Expected %i, " - "found %i.\n", - filename_optimized, N_DIRECTORIES, count_optimized); - goto failure; - } - if (count_directories(filename_non_optimized, &count_non_optimized)) - { - fprintf(stderr, "Error counting directories in file %s.\n", - filename_non_optimized); - goto failure; - } - if (count_non_optimized != N_DIRECTORIES) - { - fprintf(stderr, - "Unexpected number of directories in %s. Expected %i, " - "found %i.\n", - filename_non_optimized, N_DIRECTORIES, count_non_optimized); - goto failure; - } - - /* Check that both files have the same directory offsets */ - /* In parallel of comparing offsets between optimized base file and - * non-optimized file, test also three methods of walking through the - * IFD chain within get_dir_offsets(). This tests the optimization of - * faster SetDirectory(). */ - if (get_dir_offsets(filename_optimized, offsets_base, - DirWalkMode_ReadDirectory)) - { - fprintf(stderr, "Error reading directory offsets from %s.\n", - filename_optimized); - goto failure; - } - for (int file_i = 0; file_i < 2; ++file_i) - { - const char *filename = - (file_i == 0) ? filename_optimized : filename_non_optimized; - - for (enum DirWalkMode mode = DirWalkMode_ReadDirectory; - mode <= DirWalkMode_SetDirectory_Reverse; ++mode) - { - if (get_dir_offsets(filename, offsets_comparison, mode)) - { - fprintf(stderr, - "Error reading directory offsets from %s in mode %d.\n", - filename, mode); - goto failure; - } - for (i = 0; i < N_DIRECTORIES; i++) - { - if (offsets_base[i] != offsets_comparison[i]) - { - fprintf(stderr, - "Unexpected directory offset for directory %i, " - "expected " - "offset %" PRIu64 " but got %" PRIu64 ".\n", - i, offsets_base[i], offsets_comparison[i]); - goto failure; - } - } - } - } - - unlink(filename_optimized); - unlink(filename_non_optimized); - - return 0; - -failure: - if (tif) - { - TIFFClose(tif); - } - unlink(filename_optimized); - unlink(filename_non_optimized); - return 1; -} - -int main() -{ - if (test_lastdir_offset(false)) - { - fprintf(stderr, "Failed during non-BigTIFF WriteDirectory test.\n"); - return 1; - } - if (test_lastdir_offset(true)) - { - fprintf(stderr, "Failed during BigTIFF WriteDirectory test.\n"); - return 1; - } - - if (test_rewrite_lastdir_offset(false)) - { - fprintf(stderr, "Failed during non-BigTIFF RewriteDirectory test.\n"); - return 1; - } - if (test_rewrite_lastdir_offset(true)) - { - fprintf(stderr, "Failed during BigTIFF RewriteDirectory test.\n"); - return 1; - } - - /* Test arbitrary directory loading */ - if (test_arbitrary_directrory_loading(false)) - { - fprintf(stderr, - "Failed during non-BigTIFF ArbitraryDirectoryLoading test.\n"); - return 1; - } - if (test_arbitrary_directrory_loading(true)) - { - fprintf(stderr, - "Failed during BigTIFF ArbitraryDirectoryLoading test.\n"); - return 1; - } - - /* Test SubIFD writing and reading */ - if (test_SubIFD_directrory_handling(false)) - { - fprintf(stderr, - "Failed during non-BigTIFF SubIFD_directrory_handling test.\n"); - return 1; - } - if (test_SubIFD_directrory_handling(true)) - { - fprintf(stderr, - "Failed during BigTIFF SubIFD_directrory_handling test.\n"); - return 1; - } - - return 0; -} diff --git a/thirdparty/SDL2_image/external/libtiff/test/test_ifd_loop_detection.c b/thirdparty/SDL2_image/external/libtiff/test/test_ifd_loop_detection.c deleted file mode 100644 index 866da39a7..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/test_ifd_loop_detection.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) 2022, Even Rouault - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * Test IFD loop detection - */ - -#include "tif_config.h" - -#include -#include -#include -#include - -#include "tiffio.h" - -/* Compare 'requested_dir_number' with number written in PageName tag - * into the IFD to identify that IFD. */ -int is_requested_directory(TIFF *tif, int requested_dir_number, - const char *filename) -{ - char *ptr = NULL; - char *auxStr = NULL; - - if (!TIFFGetField(tif, TIFFTAG_PAGENAME, &ptr)) - { - fprintf(stderr, "Can't get TIFFTAG_PAGENAME tag.\n"); - return 0; - } - - /* Check for reading errors */ - if (ptr != NULL) - auxStr = strchr(ptr, ' '); - - if (ptr == NULL || auxStr == NULL || strncmp(auxStr, " th.", 4)) - { - ptr = ptr == NULL ? "(null)" : ptr; - fprintf(stderr, - "Error reading IFD directory number from PageName tag: %s\n", - ptr); - return 0; - } - - /* Retrieve IFD identification number from ASCII string */ - const int nthIFD = atoi(ptr); - if (nthIFD == requested_dir_number) - { - return 1; - } - fprintf(stderr, "Expected directory %d from %s was not loaded but: %s\n", - requested_dir_number, filename, ptr); - - return 0; -} - -/* Test loop detection within chained SubIFDs. - * test_ifd_loop_subifd.tif contains seven main-IFDs (0 to 6) and within IFD 1 - * there are three SubIFDs (0 to 2). Main IFD 4 loops back to main IFD 2. - * SubIFD 2 loops back to SubIFD 1. - * Within each IFD the tag PageName is filled with a string, indicating the - * IFD. The main IFDs are numbered 0 to 6 and the SubIFDs 200 to 202. */ -int test_subifd_loop(void) -{ - const char *filename = SOURCE_DIR "/images/test_ifd_loop_subifd.tif"; - TIFF *tif; - int i, n; - int ret = 0; -#define NUMBER_OF_SUBIFDs 3 - toff_t sub_IFDs_offsets[NUMBER_OF_SUBIFDs] = { - 0UL}; /* array for SubIFD tag */ - void *ptr; - uint16_t number_of_sub_IFDs = 0; - - tif = TIFFOpen(filename, "r"); - if (!tif) - { - fprintf(stderr, "Can't open %s\n", filename); - return 1; - } - - /* Try to read six further main directories. Fifth read shall fail. */ - for (i = 0; i < 6; i++) - { - if (!TIFFReadDirectory(tif)) - break; - } - if (i != 4) - { - fprintf(stderr, "(30) Expected fifth TIFFReadDirectory() to fail\n"); - ret = 1; - } - if (!is_requested_directory(tif, 4, filename)) - { - fprintf(stderr, "(31) Expected fifth main IFD to be loaded\n"); - ret = 1; - } - - /* Switch to IFD 1 and get SubIFDs. - * Then read through SubIFDs and detect SubIFD loop. - * Finally go back to main-IFD and check if right IFD is loaded. - */ - if (!TIFFSetDirectory(tif, 1)) - ret = 1; - - /* Check if there are SubIFD subfiles */ - if (TIFFGetField(tif, TIFFTAG_SUBIFD, &number_of_sub_IFDs, &ptr) && - (number_of_sub_IFDs == 3)) - { - /* Copy SubIFD array from pointer */ - memcpy(sub_IFDs_offsets, ptr, - number_of_sub_IFDs * sizeof(sub_IFDs_offsets[0])); - - for (i = 0; i < number_of_sub_IFDs; i++) - { - /* Read SubIFD directory directly via offset. - * SubIFDs PageName string contains numbers 200 to 202. */ - if (!TIFFSetSubDirectory(tif, sub_IFDs_offsets[i])) - ret = 1; - if (!is_requested_directory(tif, 200 + i, filename)) - { - fprintf(stderr, "(32) Expected SubIFD %d to be loaded.\n", i); - ret = 1; - } - /* Now test SubIFD loop detection. - * The (i+n).th read in the SubIFD chain shall fail. */ - for (n = 0; n < number_of_sub_IFDs; n++) - { - if (!TIFFReadDirectory(tif)) - break; - } - if ((i + n) != 2) - { - fprintf( - stderr, - "(33) Expected third SubIFD-TIFFReadDirectory() to fail\n"); - ret = 1; - } - } - /* Go back to main-IFD chain and re-read that main-IFD directory */ - if (!TIFFSetDirectory(tif, 3)) - ret = 1; - if (!is_requested_directory(tif, 3, filename)) - { - fprintf(stderr, "(34) Expected fourth main IFD to be loaded\n"); - ret = 1; - } - } - else - { - fprintf(stderr, "(35) No or wrong expected SubIFDs within main IFD\n"); - ret = 1; - } - - TIFFClose(tif); - return ret; -} /*-- test_subifd_loop() --*/ - -int main() -{ - int ret = 0; - { - TIFF *tif = - TIFFOpen(SOURCE_DIR "/images/test_ifd_loop_to_self.tif", "r"); - assert(tif); - if (TIFFReadDirectory(tif)) - { - fprintf(stderr, "(1) Expected TIFFReadDirectory() to fail\n"); - ret = 1; - } - TIFFClose(tif); - } - { - TIFF *tif = - TIFFOpen(SOURCE_DIR "/images/test_ifd_loop_to_self.tif", "r"); - assert(tif); - int n = TIFFNumberOfDirectories(tif); - if (n != 1) - { - fprintf( - stderr, - "(2) Expected TIFFNumberOfDirectories() to return 1. Got %d\n", - n); - ret = 1; - } - TIFFClose(tif); - } - { - TIFF *tif = - TIFFOpen(SOURCE_DIR "/images/test_ifd_loop_to_first.tif", "r"); - assert(tif); - if (TIFFReadDirectory(tif) != 1) - { - fprintf(stderr, "(3) Expected TIFFReadDirectory() to succeed\n"); - ret = 1; - } - if (TIFFReadDirectory(tif)) - { - fprintf(stderr, "(4) Expected TIFFReadDirectory() to fail\n"); - ret = 1; - } - if (TIFFSetDirectory(tif, 1) != 1) - { - fprintf(stderr, "(5) Expected TIFFSetDirectory() to succeed\n"); - ret = 1; - } - if (TIFFReadDirectory(tif)) - { - fprintf(stderr, "(6) Expected TIFFReadDirectory() to fail\n"); - ret = 1; - } - if (TIFFSetDirectory(tif, 0) != 1) - { - fprintf(stderr, "(7) Expected TIFFSetDirectory() to succeed\n"); - ret = 1; - } - if (TIFFReadDirectory(tif) != 1) - { - fprintf(stderr, "(8) Expected TIFFReadDirectory() to succeed\n"); - ret = 1; - } - if (TIFFReadDirectory(tif)) - { - fprintf(stderr, "(9) Expected TIFFReadDirectory() to fail\n"); - ret = 1; - } - TIFFClose(tif); - } - { - TIFF *tif = - TIFFOpen(SOURCE_DIR "/images/test_ifd_loop_to_first.tif", "r"); - assert(tif); - int n = TIFFNumberOfDirectories(tif); - if (n != 2) - { - fprintf( - stderr, - "(10) Expected TIFFNumberOfDirectories() to return 2. Got %d\n", - n); - ret = 1; - } - TIFFClose(tif); - } - { - TIFF *tif = TIFFOpen(SOURCE_DIR "/images/test_two_ifds.tif", "r"); - assert(tif); - if (TIFFReadDirectory(tif) != 1) - { - fprintf(stderr, "(11) Expected TIFFReadDirectory() to succeed\n"); - ret = 1; - } - if (TIFFReadDirectory(tif)) - { - fprintf(stderr, "(12) Expected TIFFReadDirectory() to fail\n"); - ret = 1; - } - if (TIFFSetDirectory(tif, 1) != 1) - { - fprintf(stderr, "(13) Expected TIFFSetDirectory() to succeed\n"); - ret = 1; - } - if (TIFFReadDirectory(tif)) - { - fprintf(stderr, "(14) Expected TIFFReadDirectory() to fail\n"); - ret = 1; - } - if (TIFFSetDirectory(tif, 0) != 1) - { - fprintf(stderr, "(15) Expected TIFFSetDirectory() to succeed\n"); - ret = 1; - } - if (TIFFReadDirectory(tif) != 1) - { - fprintf(stderr, "(16) Expected TIFFReadDirectory() to succeed\n"); - ret = 1; - } - if (TIFFReadDirectory(tif)) - { - fprintf(stderr, "(17) Expected TIFFReadDirectory() to fail\n"); - ret = 1; - } - if (TIFFSetDirectory(tif, 0) != 1) - { - fprintf(stderr, "(18) Expected TIFFSetDirectory() to succeed\n"); - ret = 1; - } - if (TIFFSetDirectory(tif, 1) != 1) - { - fprintf(stderr, "(19) Expected TIFFSetDirectory() to succeed\n"); - ret = 1; - } - if (TIFFSetDirectory(tif, 2)) - { - fprintf(stderr, "(20) Expected TIFFSetDirectory() to fail\n"); - ret = 1; - } - if (TIFFSetDirectory(tif, 1) != 1) - { - fprintf(stderr, "(21) Expected TIFFSetDirectory() to succeed\n"); - ret = 1; - } - if (TIFFSetDirectory(tif, 0) != 1) - { - fprintf(stderr, "(22) Expected TIFFSetDirectory() to succeed\n"); - ret = 1; - } - TIFFClose(tif); - } - { - TIFF *tif = TIFFOpen(SOURCE_DIR "/images/test_two_ifds.tif", "r"); - assert(tif); - int n = TIFFNumberOfDirectories(tif); - if (n != 2) - { - fprintf( - stderr, - "(23) Expected TIFFNumberOfDirectories() to return 2. Got %d\n", - n); - ret = 1; - } - TIFFClose(tif); - } - ret += test_subifd_loop(); - return ret; -} diff --git a/thirdparty/SDL2_image/external/libtiff/test/test_open_options.c b/thirdparty/SDL2_image/external/libtiff/test/test_open_options.c deleted file mode 100644 index e7608a194..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/test_open_options.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2022, Even Rouault - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -/* - * TIFF Library - * - * Test open options - */ - -#include "tif_config.h" - -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "tiffio.h" -#include "tiffiop.h" // for struct TIFF - -#define ERROR_STRING_SIZE 1024 - -/* Test TIFFLIB_AT_LEAST() macro */ -#if !TIFFLIB_AT_LEAST(TIFFLIB_MAJOR_VERSION, TIFFLIB_MINOR_VERSION, \ - TIFFLIB_MICRO_VERSION) -#error "TIFFLIB_AT_LEAST broken" -#endif -#if !TIFFLIB_AT_LEAST(TIFFLIB_MAJOR_VERSION, TIFFLIB_MINOR_VERSION, 0) -#error "TIFFLIB_AT_LEAST broken" -#endif -#if !TIFFLIB_AT_LEAST(TIFFLIB_MAJOR_VERSION, 0, 0) -#error "TIFFLIB_AT_LEAST broken" -#endif -#if !TIFFLIB_AT_LEAST(TIFFLIB_MAJOR_VERSION - 1, 0, 0) -#error "TIFFLIB_AT_LEAST broken" -#endif -#if TIFFLIB_AT_LEAST(TIFFLIB_MAJOR_VERSION + 1, 0, 0) -#error "TIFFLIB_AT_LEAST broken" -#endif -#if TIFFLIB_AT_LEAST(TIFFLIB_MAJOR_VERSION, TIFFLIB_MINOR_VERSION + 1, 0) -#error "TIFFLIB_AT_LEAST broken" -#endif -#if TIFFLIB_AT_LEAST(TIFFLIB_MAJOR_VERSION, TIFFLIB_MINOR_VERSION, \ - TIFFLIB_MICRO_VERSION + 1) -#error "TIFFLIB_AT_LEAST broken" -#endif - -typedef struct MyErrorHandlerUserDataStruct -{ - char *buffer; - size_t buffer_size; - TIFF *tif_got_from_callback; - char module[64]; -} MyErrorHandlerUserDataStruct; - -static int myErrorHandler(TIFF *tiff, void *user_data, const char *module, - const char *fmt, va_list ap) -{ - MyErrorHandlerUserDataStruct *errorhandler_user_data = - (MyErrorHandlerUserDataStruct *)user_data; - vsnprintf(errorhandler_user_data->buffer, - errorhandler_user_data->buffer_size, fmt, ap); - errorhandler_user_data->tif_got_from_callback = tiff; - snprintf(errorhandler_user_data->module, - sizeof(errorhandler_user_data->module), "%s", module); - return 1; -} - -static int test_error_handler() -{ - int ret = 0; - char error_buffer[ERROR_STRING_SIZE] = {0}; - char warn_buffer[ERROR_STRING_SIZE] = {0}; - MyErrorHandlerUserDataStruct errorhandler_user_data = { - .buffer = error_buffer, .buffer_size = ERROR_STRING_SIZE}; - MyErrorHandlerUserDataStruct warnhandler_user_data = { - .buffer = warn_buffer, .buffer_size = ERROR_STRING_SIZE}; - - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - assert(opts); - TIFFOpenOptionsSetErrorHandlerExtR(opts, myErrorHandler, - &errorhandler_user_data); - TIFFOpenOptionsSetWarningHandlerExtR(opts, myErrorHandler, - &warnhandler_user_data); - TIFF *tif = TIFFOpenExt("test_error_handler.tif", "w", opts); - TIFFOpenOptionsFree(opts); - - if (tif == NULL) - { - fprintf(stderr, "Cannot create test_error_handler.tif"); - exit(1); - } - - // Simulate an error emitted by libtiff - TIFFErrorExtR(tif, "my_error_module", "%s", "some error message"); - if (strcmp(error_buffer, "some error message") != 0) - { - fprintf(stderr, "Did not get expected error message\n"); - ret = 1; - } - if (strcmp(errorhandler_user_data.module, "my_error_module") != 0) - { - fprintf(stderr, "Did not get expected error module\n"); - ret = 1; - } - if (errorhandler_user_data.tif_got_from_callback != tif) - { - fprintf(stderr, - "errorhandler_user_data.tif_got_from_callback != tif\n"); - ret = 1; - } - - // Simulate a warning emitted by libtiff - TIFFWarningExtR(tif, "my_warning_module", "%s", "some warning message"); - if (strcmp(warn_buffer, "some warning message") != 0) - { - fprintf(stderr, "Did not get expected warning message\n"); - ret = 1; - } - if (strcmp(warnhandler_user_data.module, "my_warning_module") != 0) - { - fprintf(stderr, "Did not get expected warning module\n"); - ret = 1; - } - if (warnhandler_user_data.tif_got_from_callback != tif) - { - fprintf(stderr, "warnhandler_user_data.tif_got_from_callback != tif\n"); - ret = 1; - } - - TIFFClose(tif); - unlink("test_error_handler.tif"); - return ret; -} - -static int test_TIFFOpenOptionsSetMaxSingleMemAlloc( - tmsize_t limit, int expected_to_fail_in_open, - int expected_to_fail_in_write_directory, bool is_big_tiff) -{ - int ret = 0; - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - assert(opts); - TIFFOpenOptionsSetMaxSingleMemAlloc(opts, limit); - TIFF *tif = - TIFFOpenExt("test_error_handler.tif", is_big_tiff ? "w8" : "w", opts); - TIFFOpenOptionsFree(opts); - if (expected_to_fail_in_open) - { - if (tif != NULL) - { - fprintf( - stderr, - "Expected TIFFOpenExt() to fail due to memory limitation\n"); - ret = 1; - TIFFClose(tif); - } - } - else - { - if (tif == NULL) - { - fprintf(stderr, "Expected TIFFOpenExt() to succeed\n"); - ret = 1; - } - else - { -#define VALUE_SAMPLESPERPIXEL 10000 - TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, VALUE_SAMPLESPERPIXEL); - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); - if (TIFFWriteDirectory(tif) == 0) - { - if (!expected_to_fail_in_write_directory) - { - fprintf(stderr, - "Expected TIFFWriteDirectory() to succeed\n"); - ret = 1; - } - } - else - { - if (expected_to_fail_in_write_directory) - { - fprintf(stderr, "Expected TIFFWriteDirectory() to fail\n"); - ret = 1; - } - } - TIFFClose(tif); - } - } - unlink("test_error_handler.tif"); - return ret; -} - -int main() -{ - int ret = 0; - ret += test_error_handler(); - fprintf(stderr, "---- test_TIFFOpenOptionsSetMaxSingleMemAlloc " - "with non-BigTIFF ---- \n"); - ret += test_TIFFOpenOptionsSetMaxSingleMemAlloc(1, TRUE, -1, FALSE); - ret += test_TIFFOpenOptionsSetMaxSingleMemAlloc( - sizeof(TIFF) + strlen("test_error_handler.tif") + 1, FALSE, TRUE, - FALSE); - ret += test_TIFFOpenOptionsSetMaxSingleMemAlloc( - VALUE_SAMPLESPERPIXEL * sizeof(short), FALSE, FALSE, FALSE); - - fprintf(stderr, "\n---- test_TIFFOpenOptionsSetMaxSingleMemAlloc " - "with BigTIFF ---- \n"); - ret += test_TIFFOpenOptionsSetMaxSingleMemAlloc(1, TRUE, -1, TRUE); - ret += test_TIFFOpenOptionsSetMaxSingleMemAlloc( - sizeof(TIFF) + strlen("test_error_handler.tif") + 1, FALSE, TRUE, TRUE); - ret += test_TIFFOpenOptionsSetMaxSingleMemAlloc( - VALUE_SAMPLESPERPIXEL * sizeof(short), FALSE, FALSE, TRUE); - return ret; -} diff --git a/thirdparty/SDL2_image/external/libtiff/test/test_signed_tags.c b/thirdparty/SDL2_image/external/libtiff/test/test_signed_tags.c deleted file mode 100644 index df0e2a48a..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/test_signed_tags.c +++ /dev/null @@ -1,525 +0,0 @@ -/* - * Copyright (c) 2022, Su Laus @Su_Laus - * - * 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 - -#include "tif_config.h" /* necessary for linux compiler to get HAVE_UNISTD_H */ -#ifdef HAVE_UNISTD_H -#include /* for unlink() on linux */ -#endif - -#include - -#define FAULT_RETURN 1 -#define OK_RETURN 0 -#define GOTOFAILURE goto failure; - -#define N(a) (sizeof(a) / sizeof(a[0])) - -enum -{ - SINT8 = 65100, - SINT16, - SINT32, - SINT64, - C0_SINT8, - C0_SINT16, - C0_SINT32, - C0_SINT64, - C16_SINT8, - C16_SINT16, - C16_SINT32, - C16_SINT64, - C32_SINT8, - C32_SINT16, - C32_SINT32, - C32_SINT64, -}; - -static const TIFFFieldInfo tiff_field_info[] = { - {SINT8, 1, 1, TIFF_SBYTE, FIELD_CUSTOM, 0, 0, "SINT8"}, - {SINT16, 1, 1, TIFF_SSHORT, FIELD_CUSTOM, 0, 0, "SINT16"}, - {SINT32, 1, 1, TIFF_SLONG, FIELD_CUSTOM, 0, 0, "SINT32"}, - {SINT64, 1, 1, TIFF_SLONG8, FIELD_CUSTOM, 0, 0, "SINT64"}, - {C0_SINT8, 6, 6, TIFF_SBYTE, FIELD_CUSTOM, 0, 0, "C0_SINT8"}, - {C0_SINT16, 6, 6, TIFF_SSHORT, FIELD_CUSTOM, 0, 0, "C0_SINT16"}, - {C0_SINT32, 6, 6, TIFF_SLONG, FIELD_CUSTOM, 0, 0, "C0_SINT32"}, - {C0_SINT64, 6, 6, TIFF_SLONG8, FIELD_CUSTOM, 0, 0, "C0_SINT64"}, - {C16_SINT8, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SBYTE, FIELD_CUSTOM, 0, 1, - "C16_SINT8"}, - {C16_SINT16, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SSHORT, FIELD_CUSTOM, 0, 1, - "C16_SINT16"}, - {C16_SINT32, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SLONG, FIELD_CUSTOM, 0, 1, - "C16_SINT32"}, - {C16_SINT64, TIFF_VARIABLE, TIFF_VARIABLE, TIFF_SLONG8, FIELD_CUSTOM, 0, 1, - "C16_SINT64"}, - {C32_SINT8, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_SBYTE, FIELD_CUSTOM, 0, 1, - "C32_SINT8"}, - {C32_SINT16, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_SSHORT, FIELD_CUSTOM, 0, - 1, "C32_SINT16"}, - {C32_SINT32, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_SLONG, FIELD_CUSTOM, 0, 1, - "C32_SINT32"}, - {C32_SINT64, TIFF_VARIABLE2, TIFF_VARIABLE2, TIFF_SLONG8, FIELD_CUSTOM, 0, - 1, "C32_SINT64"}, -}; - -static TIFFExtendProc parent = NULL; - -static void extender(TIFF *tif) -{ - TIFFMergeFieldInfo(tif, tiff_field_info, - sizeof(tiff_field_info) / sizeof(tiff_field_info[0])); - if (parent) - { - (*parent)(tif); - } -} - -/*-- Global test fields --*/ -int8_t s8[] = {-8, -9, -10, -11, INT8_MAX, INT8_MIN}; -int16_t s16[] = {-16, -17, -18, -19, INT16_MAX, INT16_MIN}; -int32_t s32[] = {-32, -33, -34, -35, INT32_MAX, INT32_MIN}; -int64_t s64[] = {-64, -65, -66, -67, INT64_MAX, INT64_MIN}; - -const uint32_t idxSingle = 0; - -static int writeTestTiff(const char *szFileName, int isBigTiff) -{ - int ret; - TIFF *tif; - int retcode = FAULT_RETURN; - - unlink(szFileName); - if (isBigTiff) - { - fprintf(stdout, "\n-- Writing signed values to BigTIFF...\n"); - tif = TIFFOpen(szFileName, "w8"); - } - else - { - fprintf(stdout, "\n-- Writing signed values to ClassicTIFF...\n"); - tif = TIFFOpen(szFileName, "w"); - } - if (!tif) - { - fprintf(stdout, "Can't create test TIFF file %s.\n", szFileName); - return (FAULT_RETURN); - } - - ret = TIFFSetField(tif, SINT8, s8[idxSingle]); - if (ret != 1) - { - fprintf(stdout, "Error writing SINT8: ret=%d\n", ret); - GOTOFAILURE; - } - ret = TIFFSetField(tif, SINT16, s16[idxSingle]); - if (ret != 1) - { - fprintf(stdout, "Error writing SINT16: ret=%d\n", ret); - GOTOFAILURE; - } - ret = TIFFSetField(tif, SINT32, s32[idxSingle]); - if (ret != 1) - { - fprintf(stdout, "Error writing SINT32: ret=%d\n", ret); - GOTOFAILURE; - } - - TIFFSetField(tif, C0_SINT8, &s8); - TIFFSetField(tif, C0_SINT16, &s16); - TIFFSetField(tif, C0_SINT32, &s32); - - TIFFSetField(tif, C16_SINT8, 6, &s8); - TIFFSetField(tif, C16_SINT16, 6, &s16); - TIFFSetField(tif, C16_SINT32, 6, &s32); - - TIFFSetField(tif, C16_SINT8, 6, &s8); - TIFFSetField(tif, C16_SINT16, 6, &s16); - TIFFSetField(tif, C16_SINT32, 6, &s32); - - TIFFSetField(tif, C32_SINT8, 6, &s8); - TIFFSetField(tif, C32_SINT16, 6, &s16); - TIFFSetField(tif, C32_SINT32, 6, &s32); - - if (isBigTiff) - { - ret = TIFFSetField(tif, SINT64, s64[0]); - if (ret != 1) - { - fprintf(stdout, "Error writing SINT64: ret=%d\n", ret); - GOTOFAILURE; - } - ret = TIFFSetField(tif, C0_SINT64, &s64); - if (ret != 1) - { - fprintf(stdout, "Error writing C0_SINT64: ret=%d\n", ret); - GOTOFAILURE; - } - ret = TIFFSetField(tif, C16_SINT64, N(s64), &s64); - if (ret != 1) - { - fprintf(stdout, "Error writing C16_SINT64: ret=%d\n", ret); - GOTOFAILURE; - } - ret = TIFFSetField(tif, C32_SINT64, N(s64), &s64); - if (ret != 1) - { - fprintf(stdout, "Error writing C32_SINT64: ret=%d\n", ret); - GOTOFAILURE; - } - } - - TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, 1); - TIFFSetField(tif, TIFFTAG_IMAGELENGTH, 1); - TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); - TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1); - TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, 1); - ret = (int)TIFFWriteEncodedStrip(tif, 0, "\0", 1); - if (ret != 1) - { - fprintf(stdout, "Error TIFFWriteEncodedStrip: ret=%d\n", ret); - GOTOFAILURE; - } - - retcode = OK_RETURN; -failure: - TIFFClose(tif); - return (retcode); -} - -static int readTestTiff(const char *szFileName, int isBigTiff) -{ - int ret; - int i; - int8_t s8l, *s8p; - int16_t s16l, *s16p; - int32_t s32l, *s32p; - int64_t s64l, *s64p; - uint16_t count; - uint32_t count32; - int retcode = FAULT_RETURN; - - fprintf(stdout, "-- Reading signed values ...\n"); - TIFF *tif = TIFFOpen(szFileName, "r"); - if (!tif) - { - fprintf(stdout, "Can't open test TIFF file %s.\n", szFileName); - return (FAULT_RETURN); - } - - ret = TIFFGetField(tif, SINT8, &s8l); - if (ret != 1) - { - fprintf(stdout, "Error reading SINT8: ret=%d\n", ret); - GOTOFAILURE - } - else - { - if (s8l != s8[idxSingle]) - { - fprintf(stdout, - "Read value of SINT8 %d differs from set value %d\n", s8l, - s8[idxSingle]); - GOTOFAILURE - } - } - ret = TIFFGetField(tif, SINT16, &s16l); - if (ret != 1) - { - fprintf(stdout, "Error reading SINT16: ret=%d\n", ret); - GOTOFAILURE - } - else - { - if (s16l != s16[idxSingle]) - { - fprintf(stdout, - "Read value of SINT16 %d differs from set value %d\n", - s16l, s16[idxSingle]); - GOTOFAILURE - } - } - ret = TIFFGetField(tif, SINT32, &s32l); - if (ret != 1) - { - fprintf(stdout, "Error reading SINT32: ret=%d\n", ret); - GOTOFAILURE - } - else - { - if (s32l != s32[idxSingle]) - { - fprintf(stdout, - "Read value of SINT32 %d differs from set value %d\n", - s32l, s32[idxSingle]); - GOTOFAILURE - } - } - - ret = TIFFGetField(tif, C0_SINT8, &s8p); - if (ret != 1) - { - fprintf(stdout, "Error reading C0_SINT8: ret=%d\n", ret); - GOTOFAILURE - } - count = N(s8); - for (i = 0; i < count; i++) - { - if (s8p[i] != s8[i]) - { - fprintf(stdout, - "Read value %d of C0_SINT8-Array %d differs from set value " - "%d\n", - i, s8p[i], s8[i]); - GOTOFAILURE - } - } - - ret = TIFFGetField(tif, C0_SINT16, &s16p); - if (ret != 1) - { - fprintf(stdout, "Error reading C0_SINT16: ret=%d\n", ret); - GOTOFAILURE - } - count = N(s16); - for (i = 0; i < count; i++) - { - if (s16p[i] != s16[i]) - { - fprintf(stdout, - "Read value %d of C0_SINT16-Array %d differs from set " - "value %d\n", - i, s16p[i], s16[i]); - GOTOFAILURE - } - } - - ret = TIFFGetField(tif, C0_SINT32, &s32p); - if (ret != 1) - { - fprintf(stdout, "Error reading C0_SINT32: ret=%d\n", ret); - GOTOFAILURE - } - count = N(s32); - for (i = 0; i < count; i++) - { - if (s32p[i] != s32[i]) - { - fprintf(stdout, - "Read value %d of C0_SINT32-Array %d differs from set " - "value %d\n", - i, s32p[i], s32[i]); - GOTOFAILURE - } - } - - s8p = NULL; - ret = TIFFGetField(tif, C16_SINT8, &count, &s8p); - if (ret != 1 || s8p == NULL) - { - fprintf(stdout, - "Error reading C16_SINT8: ret=%d; count=%d; pointer=%p\n", ret, - count, s8p); - GOTOFAILURE - } - else - { - for (i = 0; i < count; i++) - { - if (s8p[i] != s8[i]) - { - fprintf( - stdout, - "Read value %d of s8-Array %d differs from set value %d\n", - i, s8p[i], s8[i]); - GOTOFAILURE - } - } - } - - s16p = NULL; - ret = TIFFGetField(tif, C16_SINT16, &count, &s16p); - if (ret != 1 || s16p == NULL) - { - fprintf(stdout, - "Error reading C16_SINT16: ret=%d; count=%d; pointer=%p\n", ret, - count, s16p); - GOTOFAILURE - } - else - { - for (i = 0; i < count; i++) - { - if (s16p[i] != s16[i]) - { - fprintf(stdout, - "Read value %d of C16_SINT16-Array %d differs from set " - "value %d\n", - i, s16p[i], s16[i]); - GOTOFAILURE - } - } - } - - s32p = NULL; - ret = TIFFGetField(tif, C16_SINT32, &count, &s32p); - if (ret != 1 || s32p == NULL) - { - fprintf(stdout, - "Error reading C16_SINT32: ret=%d; count=%d; pointer=%p\n", ret, - count, s32p); - GOTOFAILURE - } - else - { - for (i = 0; i < count; i++) - { - if (s32p[i] != s32[i]) - { - fprintf(stdout, - "Read value %d of C16_SINT32-Array %d differs from set " - "value %d\n", - i, s32p[i], s32[i]); - GOTOFAILURE - } - } - } - - if (isBigTiff) - { - ret = TIFFGetField(tif, SINT64, &s64l); - if (ret != 1) - { - fprintf(stdout, "Error reading SINT64: ret=%d\n", ret); - GOTOFAILURE - } - else - { - if (s64l != s64[idxSingle]) - { - fprintf(stdout, - "Read value of SINT64 %" PRIi64 - " differs from set value %" PRIi64 "\n", - s64l, s64[idxSingle]); - GOTOFAILURE - } - } - - s64p = NULL; - ret = TIFFGetField(tif, C0_SINT64, &s64p); - count = N(s64); - if (ret != 1) - { - fprintf(stdout, "Error reading C0_SINT64: ret=%d\n", ret); - GOTOFAILURE - } - else - { - for (i = 0; i < count; i++) - { - if (s64p[i] != s64[i]) - { - fprintf(stdout, - "Read value %d of C0_SINT64-Array %" PRIi64 - " differs from set value %" PRIi64 "\n", - i, s64p[i], s64[i]); - GOTOFAILURE - } - } - } - - s64p = NULL; - ret = TIFFGetField(tif, C16_SINT64, &count, &s64p); - if (ret != 1 || s64p == NULL) - { - fprintf(stdout, - "Error reading C16_SINT64: ret=%d; count=%d; pointer=%p\n", - ret, count, s64p); - GOTOFAILURE - } - else - { - for (i = 0; i < count; i++) - { - if (s64p[i] != s64[i]) - { - fprintf(stdout, - "Read value %d of C16_SINT64-Array %" PRIi64 - " differs from set value %" PRIi64 "\n", - i, s64p[i], s64[i]); - GOTOFAILURE - } - } - } - - s64p = NULL; - ret = TIFFGetField(tif, C32_SINT64, &count32, &s64p); - if (ret != 1 || s64p == NULL) - { - fprintf(stdout, - "Error reading C32_SINT64: ret=%d; count=%d; pointer=%p\n", - ret, count, s64p); - GOTOFAILURE - } - else - { - for (i = 0; i < (int)count32; i++) - { - if (s64p[i] != s64[i]) - { - fprintf(stdout, - "Read value %d of C32_SINT64-Array %" PRIi64 - " differs from set value %" PRIi64 "\n", - i, s64p[i], s64[i]); - GOTOFAILURE - } - } - } - } /*-- if(isBigTiff) --*/ - - retcode = OK_RETURN; -failure: - - fprintf(stdout, "-- End of test. Closing TIFF file. --\n"); - TIFFClose(tif); - return (retcode); -} - -int main(void) -{ - parent = TIFFSetTagExtender(&extender); - if (writeTestTiff("temp.tif", 0) != OK_RETURN) - return (-1); - if (readTestTiff("temp.tif", 0) != OK_RETURN) - return (-1); - unlink("temp.tif"); - if (writeTestTiff("tempBig.tif", 1) != OK_RETURN) - return (-1); - if (readTestTiff("tempBig.tif", 1) != OK_RETURN) - return (-1); - unlink("tempBig.tif"); - fprintf(stdout, "---------- Test finished OK -----------\n"); - return 0; -} diff --git a/thirdparty/SDL2_image/external/libtiff/test/test_transferfunction_write_read.c b/thirdparty/SDL2_image/external/libtiff/test/test_transferfunction_write_read.c deleted file mode 100644 index 705fa5b4a..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/test_transferfunction_write_read.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * TIFF Library - * - * The purpose of this test suite is to test the correctness of - * writing and reading transfer functions with TIFFTAG_TRANSFERFUNCTION. - * - * Depending on the SamplesPerPixel (and ExtraSamples) values, - * exactly one (1) or exactly three (3) transfer functions shall be written - * to file and are expected for reading from file. - * An exception is if all three transfer functions are equal. - * Then only one transfer function is written to file and - * at reading that transfer function is returned in three - * pointers to TIFFGetField(). - * If only one array is returned, as for images with SamplesPerPixel=1, - * the other two are set to NULL. - * - * Each transfer function length is (1 << BitsPerSample) times uint16_t values. - * - */ -/* clang-format off */ - -#include "tif_config.h" - -#include -#include -#include - -#include "tiffio.h" - -#ifdef HAVE_UNISTD_H -#include /* for unlink() on linux */ -#endif - -/* Define basic TIFF file settings */ -uint16_t spp = 3; -const uint16_t width = 4; -const uint16_t length = 6; -const uint16_t bps = 8; -const uint16_t photometric = PHOTOMETRIC_RGB; -const uint16_t rows_per_strip = 100; /* up to 2**32-1 */ -const uint16_t planarconfig = PLANARCONFIG_CONTIG; -const char *filename = "test_transferfunction_write_read.tif"; - -/* Data and pointer to three transfer functions. */ -uint16_t *pTransferFunctionData; -uint32_t nSamplesPerTransferFunction; -/* Pointers into pTransferFunctionData for writing */ -const uint16_t *ptf0; -const uint16_t *ptf1; -const uint16_t *ptf2; -/* Pointers for reading */ -const uint16_t *ptfR0; -const uint16_t *ptfR1; -const uint16_t *ptfR2; - -#define GOTOFAILURE(x) \ - { \ - retval = x; \ - goto failure; \ - } - -/*-- setup_transferfunctions() -- - * Initializes the transfer function array pTransferFunctionData - * with three transfer functions. - * Pointer ptf0, ptf1, ptf2 are initialized to the first array element of - * each transfer function. - */ -int setup_transfer_functions(void) -{ - if (pTransferFunctionData) - _TIFFfree(pTransferFunctionData); - - /* Setup array with some more values to shift start of the three arrays. */ - nSamplesPerTransferFunction = ((uint32_t)1 << bps); - pTransferFunctionData = _TIFFmalloc(3 * (tmsize_t)nSamplesPerTransferFunction * sizeof(uint16_t)); - if (!pTransferFunctionData) - return 1; - - for (uint32_t i = 0; i < 3 * nSamplesPerTransferFunction; i++) - pTransferFunctionData[i] = (uint16_t)(i + 1); - - ptf0 = &pTransferFunctionData[0]; - ptf1 = &pTransferFunctionData[nSamplesPerTransferFunction]; - ptf2 = &pTransferFunctionData[2 * nSamplesPerTransferFunction]; - - return 0; -} /*-- setup_transferfunctions() --*/ - -/*--read_check_transferfunctions -- - * The file is opened and the transfer functions are read. - * Then the read transfer functions are compared against the arrays provided - * with ptfx0, ptfx1, ptfx2. - * Depending on blnClose, the opened file is closed. - * TIFF **ptif returns the TIFF pointer. - * The function returns a bit-field with one bit set for each successfully read transfer function. - */ -int read_check_transferfunctions(TIFF **ptif, const char *filename, int blnClose, const uint16_t *ptfx0, - const uint16_t *ptfx1, const uint16_t *ptfx2) -{ - /* Test reading of transfer functions */ - int retval = 0; - TIFF *tif = TIFFOpen(filename, "r"); - *ptif = tif; - if (!tif) - { - fprintf(stderr, "read_check_transferfunctions(): Can't open %s for reading.\n", filename); - GOTOFAILURE(-1); - } - - if (!TIFFGetField(tif, TIFFTAG_TRANSFERFUNCTION, &ptfR0, &ptfR1, &ptfR2)) - { - fprintf(stderr, "read_check_transferfunctions(): TIFFGetField for TIFFTAG_TRANSFERFUNCTION failed.\n"); - GOTOFAILURE(-1); - } - else - { - if (ptfR0 != NULL && !_TIFFmemcmp(ptfx0, ptfR0, nSamplesPerTransferFunction * sizeof(uint16_t))) - retval += 1; - if (ptfR1 != NULL && !_TIFFmemcmp(ptfx1, ptfR1, nSamplesPerTransferFunction * sizeof(uint16_t))) - retval += 2; - if (ptfR2 != NULL && !_TIFFmemcmp(ptfx2, ptfR2, nSamplesPerTransferFunction * sizeof(uint16_t))) - retval += 4; - } - -failure: - if (blnClose) - { - TIFFClose(tif); - tif = NULL; - } - *ptif = tif; - - return retval; -} /*-- read_check_transferfunctions() --*/ - -/*-- write_basic_IFD_data() -- - * Opens a file for writing and initializes a basic TIFF image with the - * globally specified parameters. - * - * wrtTransferFunction: 0 = don't write TIFFTAG_TRANSFERFUNCTION tag - * 1 = write TIFFTAG_TRANSFERFUNCTION tag before and - * 2 = after ExtraSamples tag. - * blnExtraSamples=true writes ExtraSamples tag. - * Only if blnCloseFile is true, the file is closed. - * TIFF **ptif returns the pointer to the opened TIFF file. - */ -int write_basic_IFD_data(TIFF **ptif, const char *fileneme, int wrtTransferFunction, int nExtraSamples, - int blnCloseFile) -{ - unsigned char buf[3] = {0, 127, 255}; - int retval = 0; - uint8_t *bufLine = NULL; - TIFF *tif = TIFFOpen(filename, "w"); - *ptif = tif; - if (!tif) - { - fprintf(stderr, "write_basic_IFD_data(): Can't create %s\n", filename); - GOTOFAILURE(1); - } - - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "write_basic_IFD_data(): Can't set ImageWidth tag.\n"); - GOTOFAILURE(1); - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "write_basic_IFD_data(): Can't set ImageLength tag.\n"); - GOTOFAILURE(1); - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) - { - fprintf(stderr, "write_basic_IFD_data(): Can't set BitsPerSample tag.\n"); - GOTOFAILURE(1); - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, spp)) - { - fprintf(stderr, "write_basic_IFD_data(): Can't set SamplesPerPixel tag.\n"); - GOTOFAILURE(1); - } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "write_basic_IFD_data(): Can't set SamplesPerPixel tag.\n"); - GOTOFAILURE(1); - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) - { - fprintf(stderr, "write_basic_IFD_data(): Can't set PlanarConfiguration tag.\n"); - GOTOFAILURE(1); - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) - { - fprintf(stderr, "write_basic_IFD_data(): Can't set PhotometricInterpretation tag.\n"); - GOTOFAILURE(1); - } - - /* Set transfer function before ExtraSamples*/ - if (wrtTransferFunction == 1) - { - - if (!TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, ptf0, ptf1, ptf2)) - { - fprintf(stderr, "write_basic_IFD_data(): TIFFSetField for TIFFTAG_TRANSFERFUNCTION failed.\n"); - GOTOFAILURE(1); - } - } - - /* Set ExtraSamples thus SamplesPerPixel for transfer functions is reduced by one. */ - uint16_t extraSamples[4] = {EXTRASAMPLE_UNSPECIFIED, EXTRASAMPLE_UNSPECIFIED, EXTRASAMPLE_UNSPECIFIED, - EXTRASAMPLE_UNSPECIFIED}; - if (nExtraSamples > 0 && nExtraSamples < 4) - { - if (!TIFFSetField(tif, TIFFTAG_EXTRASAMPLES, nExtraSamples, extraSamples)) - { - fprintf(stderr, "write_basic_IFD_data(): Warning: Could not set TIFFTAG_EXTRASAMPLES tag.\n"); - } - } - - /* Set transfer function after ExtraSamples*/ - if (wrtTransferFunction == 2) - { - - if (!TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, ptf0, ptf1, ptf2)) - { - fprintf(stderr, "write_basic_IFD_data(): TIFFSetField for TIFFTAG_TRANSFERFUNCTION failed.\n"); - GOTOFAILURE(1); - } - } - - /* Setup buffer for image line */ - size_t bufLen = (size_t)width * spp * (bps + 7) / 8; - bufLine = _TIFFmalloc(bufLen); - if (!bufLine) - { - fprintf(stderr, "write_basic_IFD_data(): Can't allocate bufLine buffer.\n"); - GOTOFAILURE(1); - } - if (bufLen > sizeof(buf)) - _TIFFmemcpy(bufLine, buf, sizeof(buf)); - - /* Write dummy pixel data. */ - for (int i = 0; i < length; i++) - { - if (TIFFWriteScanline(tif, bufLine, i, 0) == -1) - { - fprintf(stderr, "write_basic_IFD_data(): Can't write image data.\n"); - GOTOFAILURE(1); - } - size_t idx = (size_t)i * spp < bufLen ? (size_t)i * spp : bufLen - 2; - bufLine[idx] = (uint8_t)(i * 80); - } - -failure: - if (bufLine) - _TIFFfree(bufLine); - if (blnCloseFile) - { - TIFFClose(tif); - tif = NULL; - } - *ptif = tif; - - return retval; -} /*-- write_basic_IFD_data() --*/ - -/*==== main() ====*/ -int main() -{ - if (setup_transfer_functions()) - return 1; - - int ret; - TIFF *tif = NULL; - - fprintf(stderr, - "--- Testing TIFF_TRANSFERFUNCTION tag writing and reding. ---\n Expect 6 warning messages ...\n"); - - /* Test with RGB data */ - spp = 3; - if (write_basic_IFD_data(&tif, filename, 2, 0, true)) - return 1; - ret = read_check_transferfunctions(&tif, filename, true, ptf0, ptf1, ptf2); - if (ret != 7) - { - fprintf(stderr, "TRANSFERFUNCTION for RGB (SPP=3) could not be read correctly.\n"); - return 1; - } - - /* Test with Grayscale data */ - spp = 1; - if (write_basic_IFD_data(&tif, filename, 2, 0, true)) - return 1; - ret = read_check_transferfunctions(&tif, filename, true, ptf0, ptf1, ptf2); - if (ret != 1) - { - fprintf(stderr, "TRANSFERFUNCTION SPP=1 could not be read correctly.\n"); - return 1; - } - - /* Test with RGB and ExtraSample, thus only 2 SamplesPerPixel left. - * ExtraSample is written before transfer function. - * --> For v4.5.1: This gives an Error when reading the transfer functions! - */ - spp = 3; - if (write_basic_IFD_data(&tif, filename, 2, 1, true)) - return 1; - ret = read_check_transferfunctions(&tif, filename, true, ptf0, ptf1, ptf2); - if (ret != 7) - { - fprintf(stderr, "One ExtraSample plus TRANSFERFUNCTION SPP=3 could not be read correctly.\n"); - return 1; - } - /* Now write two ExtraSamples, thus only one transfer function is written to file and read. */ - if (write_basic_IFD_data(&tif, filename, 2, 2, true)) - return 1; - ret = read_check_transferfunctions(&tif, filename, true, ptf0, ptf1, ptf2); - if (ret != 1) - { - fprintf(stderr, "Two ExtraSamples plus TRANSFERFUNCTION SPP=3 could not be read correctly.\n"); - return 1; - } - - /* Test with tree times the same transfer functions. - * Thus, only one should be written to file and when read copied three times. - */ - spp = 3; - if (write_basic_IFD_data(&tif, filename, 0, 0, false)) - return 1; - ret = TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, ptf0, ptf0, ptf0); - TIFFClose(tif); - ret = read_check_transferfunctions(&tif, filename, true, ptf0, ptf0, ptf0); - if (ret != 7) - { - fprintf(stderr, "TRANSFERFUNCTIONs with same content could not be read correctly.\n"); - return 1; - } - - /*---- Test the setting of the transfer functions with different wrong calls of TIFFSetField(). ----*/ - /* (ptf0, NULL, NULL) For v4.5.1: writes ptf0 to file and reads it back. - * Now, this should work for spp=1 but not for spp=3 - */ - spp = 1; - if (write_basic_IFD_data(&tif, filename, 0, 0, false)) - return 1; - ret = TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, ptf0, NULL, NULL); - TIFFClose(tif); - ret = read_check_transferfunctions(&tif, filename, true, ptf0, ptf1, ptf2); - if (ret != 1) - { - fprintf(stderr, "Unexpected at %d.\n", __LINE__); - return 1; - } - spp = 3; - /* (ptf0, NULL, NULL) For v4.5.1: writes ptf0 to file and reads it back.*/ - if (write_basic_IFD_data(&tif, filename, 0, 0, false)) - return 1; - ret = TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, ptf0, NULL, NULL); - TIFFClose(tif); - ret = read_check_transferfunctions(&tif, filename, true, ptf0, ptf1, ptf2); - if (ret != -1) - { - fprintf(stderr, "Unexpected at %d.\n", __LINE__); - return 1; - } - - /* (ptf0, NULL, ptf2): For v4.5.1: Overflow error, when second ptf1 is copied in - * TIFFWriteDirectoryTagTransferfunction().*/ - if (write_basic_IFD_data(&tif, filename, 0, 0, false)) - return 1; - ret = TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, ptf0, NULL, ptf2); - TIFFClose(tif); - ret = read_check_transferfunctions(&tif, filename, true, ptf0, ptf1, ptf2); - if (ret != -1) - { - fprintf(stderr, "Unexpected at %d.\n", __LINE__); - return 1; - } - - /* (ptf0, ptf1, NULL) For v4.5.1: writes ptf0 and ptf1 to file but does not read it back, because only 2 but 3 - * required.*/ - if (write_basic_IFD_data(&tif, filename, 0, 0, false)) - return 1; - ret = TIFFSetField(tif, TIFFTAG_TRANSFERFUNCTION, ptf0, ptf1, NULL); - TIFFClose(tif); - ret = read_check_transferfunctions(&tif, filename, true, ptf0, ptf1, ptf2); - if (ret != -1) - { - fprintf(stderr, "Unexpected at %d.\n", __LINE__); - return 1; - } - - /* All tests passed; delete file and exit with success status. */ - unlink(filename); - fprintf(stderr, "-------- Test finished OK ----------\n"); - return 0; -} diff --git a/thirdparty/SDL2_image/external/libtiff/test/test_write_read_tags.c b/thirdparty/SDL2_image/external/libtiff/test/test_write_read_tags.c deleted file mode 100644 index 950005dd7..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/test_write_read_tags.c +++ /dev/null @@ -1,1852 +0,0 @@ -/* - * Copyright (c) 2023, LibTIFF Contributors - * - * 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. - */ - -/* - *=========== Purpose ======================================================== - * TIFF Library Testing: - * - Write- and read- test of most tags defined within tif_dirinfo.c - * - Write- and read- test of custom directories for EXIF and GPS. - * - * Attention: - * This test program uses private functions from static LibTIFF library. - * Therefore, it does not work when compiled for shared library. - */ - -#define FOR_AUTO_TESTING -#ifdef FOR_AUTO_TESTING -/* Only for automake and CMake infrastructure the test should: - a.) delete any written testfiles when test passed (otherwise autotest - will fail) - b.) goto failure, if any failure is detected, which is not - necessary when test is initiated manually for debugging -*/ -#define GOTOFAILURE goto failure; -#else -#define GOTOFAILURE -#endif - -#ifdef _MSC_VER -#pragma warning(disable : 4101) -#endif - -#include "tif_config.h" //necessary for linux compiler - -#include -#include -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "tiffio.h" -#include "tiffiop.h" - -static const char filename[] = "test_write_read_tags.tif"; -static const char filenameBigTiff[] = "test_write_read_tags_Big.tif"; - -/* Settings for basic TIFF image to be written */ -#define SPP 3 /* Samples per pixel */ -const uint16_t width = 1; -const uint16_t length = 1; -const uint16_t bps = 8; -const uint16_t photometric = PHOTOMETRIC_RGB; -const uint16_t rows_per_strip = 1; -const uint16_t planarconfig = PLANARCONFIG_CONTIG; - -/* -- Test data for writing -- */ -#define STRSIZE 1000 -#define N_SIZE 400 -#define VARIABLE_ARRAY_SIZE 6 - -char auxCharArrayW[N_SIZE]; -short auxShortArrayW[N_SIZE]; -long auxLongArrayW[N_SIZE]; -float auxFloatArrayW[N_SIZE]; -double auxDoubleArrayW[N_SIZE]; -char auxTextArrayW[N_SIZE][STRSIZE]; - -/*-- Additional variables --*/ -char exifVersion[4] = { - '0', '2', '3', '1'}; /* EXIF 2.31 version is 4 characters of a string! */ -char gpsVersion[4] = {2, 2, 0, 1}; /* GPS Version is 4 numbers! */ - -/* Inkname string is separated but not closed at the very end with a NULL. - * Otherwise NumberOfInks would be counted to four by countInkNamesString() - * at TIFFSetField() for the inkname string. - */ -#define NINKS 3 -char inkNamesW[] = {"Ink1\0Ink2\0Ink3"}; - -#define NUM_ELEMENTS(x) (sizeof(x) / sizeof(x[0])) - -/* -- List of tags, which must not be written with arbitrary values because they - * are written explicitely by the test program (like the basic TIFF tags), - * are automatically written by LibTIFF (e.g.TIFFTAG_NUMBEROFINKS), - * have some special characteristics, or write procedure is not supported - * yet. - * - For TileOffsets and TileBytecounts the same variable is used as for - * StripOffsets and StripBytecounts, respectively. - */ -uint32_t listTagsNotToWrite[] = {TIFFTAG_OSUBFILETYPE, - TIFFTAG_STRIPOFFSETS, - TIFFTAG_COMPRESSION, - TIFFTAG_STRIPBYTECOUNTS, - TIFFTAG_IMAGEWIDTH, - TIFFTAG_IMAGELENGTH, - TIFFTAG_BITSPERSAMPLE, - TIFFTAG_SAMPLESPERPIXEL, - TIFFTAG_ROWSPERSTRIP, - TIFFTAG_PLANARCONFIG, - TIFFTAG_PHOTOMETRIC, - TIFFTAG_FREEOFFSETS, - TIFFTAG_FREEBYTECOUNTS, - TIFFTAG_GRAYRESPONSEUNIT, - TIFFTAG_GRAYRESPONSECURVE, - TIFFTAG_TRANSFERFUNCTION, - TIFFTAG_COLORMAP, - TIFFTAG_COLORRESPONSEUNIT, - TIFFTAG_TILEWIDTH, - TIFFTAG_TILELENGTH, - TIFFTAG_TILEOFFSETS, - TIFFTAG_TILEBYTECOUNTS, - TIFFTAG_SUBIFD, - TIFFTAG_NUMBEROFINKS, - TIFFTAG_GPSIFD, - TIFFTAG_EXIFIFD, - TIFFTAG_DATATYPE, - TIFFTAG_MATTEING}; - -/* Some tag definitions do not follow the rules for - * readcount/writecount/set_field_type/passcount-flag. - * Most of them are handled by LibTIFF in special cases anyway, so the tag - * definition is irrelevant. - */ -uint32_t listTagsNotFollowPasscountRules[] = { - TIFFTAG_STRIPOFFSETS, TIFFTAG_STRIPBYTECOUNTS, - TIFFTAG_MINSAMPLEVALUE, TIFFTAG_MAXSAMPLEVALUE, - TIFFTAG_FREEOFFSETS, TIFFTAG_FREEBYTECOUNTS, - TIFFTAG_GRAYRESPONSECURVE, TIFFTAG_TRANSFERFUNCTION, - TIFFTAG_COLORMAP, TIFFTAG_SAMPLEFORMAT, - TIFFTAG_SMINSAMPLEVALUE, TIFFTAG_SMAXSAMPLEVALUE, - TIFFTAG_DATATYPE, TIFFTAG_TILEOFFSETS, - TIFFTAG_TILEBYTECOUNTS, TIFFTAG_PERSAMPLE}; - -/* Function definition */ -int check_tag_definitions(void); -int write_test_tiff(TIFF *tif, const char *filenameRead); -int write_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray, - uint32_t *listTagsNotToWrite, uint32_t nTagsInList, - uint32_t *iCnt); -int tagIsInList(uint32_t tTag, uint32_t *list, uint32_t nTagsInList); -int testPasscountFlag(const char *szMsg, const TIFFFieldArray *tFieldArray, - uint32_t *listTagsNotFollowPasscountRules, - uint32_t nTagsInList); -int read_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray, - uint32_t *listTagsNotToWrite, uint32_t nTagsNotToWrite, - uint32_t *iCnt); - -/* ==== main() ======================================================== - * Main program checks for correct tags definition. - * Then, writing/reading is tested for ClassicTIFF and BigTIFF. - * Testprograms shall return 0 for success. - */ -int main() -{ - int ret, ret1, ret2; - - fprintf(stderr, "==== Test automatically if all tags are " - "written/read correctly. ====\n"); - /* --- Test with Classic-TIFF ---*/ - /* Delete file, if exists and open it freshly. */ - ret = unlink(filename); - if (ret != 0 && errno != ENOENT) - { - fprintf(stderr, "Can't delete test TIFF file %s.\n", filename); - } - TIFF *tif = TIFFOpen(filename, "w+"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filename); - return 1; - } - - /* Firstly, check for correct definition of tags. */ - fprintf(stderr, "-------- Check tag definition -------------------\n"); - ret1 = check_tag_definitions(); - - if (ret1 > 0) - return (ret1); - - /* Write a simple image with all tags and check if correctly written - * by reading all tags. */ - fprintf(stderr, "-------- Test with ClassicTIFF started ----------\n"); - ret1 = write_test_tiff(tif, filename); - - if (ret1 > 0) - return (ret1); - - /*--- Test with BIG-TIFF ---*/ - ret = unlink(filenameBigTiff); - if (ret != 0 && errno != ENOENT) - { - fprintf(stderr, "Can't delete test TIFF file %s.\n", filenameBigTiff); - } - tif = TIFFOpen(filenameBigTiff, "w8"); - if (!tif) - { - fprintf(stderr, "Can't create test TIFF file %s.\n", filenameBigTiff); - return 1; - } - fprintf(stderr, "\n\n-------- Test with BigTIFF started ----------\n"); - ret2 = write_test_tiff(tif, filenameBigTiff); - - if (ret2 > 0) - return (ret2 + 10); - else - return (ret2); -} /* main() */ - -/* ==== check_tag_definitions() ======================================= - * Check for correct definition of tags within tags FieldArray wrt passcount - * flag and set_field_type. - */ -int check_tag_definitions(void) -{ - const TIFFFieldArray *tFieldArray; - int ret = 0; - - tFieldArray = _TIFFGetFields(); - ret = testPasscountFlag("---- TIFF tags:", tFieldArray, - listTagsNotFollowPasscountRules, - NUM_ELEMENTS(listTagsNotFollowPasscountRules)); - - tFieldArray = _TIFFGetGpsFields(); - ret += testPasscountFlag("---- GPS tags:", tFieldArray, NULL, 0); - - tFieldArray = _TIFFGetExifFields(); - ret += testPasscountFlag("---- EXIF tags:", tFieldArray, NULL, 0); - - return ret; -} /*-- check_tag_definitions() --*/ - -/* ==== write_test_tiff() ============================================= - * Performs write and read test of all tags defined within LibTiff - * to the opened file passed through "tif". - * All TIFF, GPS and EXIF tags are written with arbitrary values. - * Finally, the file is closed, re-opened and all tags are read - * and compared to their written value. - */ - -int write_test_tiff(TIFF *tif, const char *filenameRead) -{ - unsigned char buf[SPP] = {0, 127, 255}; - uint16_t auxUint16 = 0; - uint32_t auxUint32 = 0; - int i; - - /*-- Fill test data arrays for writing and later comparison when written - * tags are checked. */ - for (i = 0; i < N_SIZE; i++) - { - sprintf(auxTextArrayW[i], - "N%d-String-%d_tttttttttttttttttttttttttttttx", i, i); - } - for (i = 0; i < N_SIZE; i++) - { - auxCharArrayW[i] = (char)(i + 1); - } - for (i = 0; i < N_SIZE; i++) - { - auxShortArrayW[i] = (short)(i + 1) * 7; - } - for (i = 0; i < N_SIZE; i++) - { - auxLongArrayW[i] = (i + 1) * 133; - } - for (i = 0; i < N_SIZE; i++) - { - auxFloatArrayW[i] = (float)((i + 1) * 133) / 3.3f; - } - for (i = 0; i < N_SIZE; i++) - { - auxDoubleArrayW[i] = (double)((i + 1) * 3689) / 4.5697; - } - - /*-- Setup standard tags of a simple tiff file --*/ - fprintf(stderr, "----Write TIFF tags ...\n"); - if (!TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width)) - { - fprintf(stderr, "Can't set ImageWidth tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_IMAGELENGTH, length)) - { - fprintf(stderr, "Can't set ImageLength tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, bps)) - { - fprintf(stderr, "Can't set BitsPerSample tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, SPP)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rows_per_strip)) - { - fprintf(stderr, "Can't set SamplesPerPixel tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PLANARCONFIG, planarconfig)) - { - fprintf(stderr, "Can't set PlanarConfiguration tag.\n"); - goto failure; - } - if (!TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photometric)) - { - fprintf(stderr, "Can't set PhotometricInterpretation tag.\n"); - goto failure; - } - - /*============ Write GPS and EXIF Dummy tags =====================*/ - /*-- Set dummy EXIF/GPS tag in original tif-structure in order to reserve - * space for final dir_offset value, - * which is properly written at the end. - */ - uint64_t dir_offset = 0; /* Zero, in case no Custom-IFD is written */ - - if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset)) - { - fprintf(stderr, "Can't write TIFFTAG_GPSIFD\n"); - } - - if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset)) - { - fprintf(stderr, "Can't write TIFFTAG_EXIFIFD\n"); - } - - /*============ Write mostly all other TIFF tags ==================*/ - /* Get array, where tag fields are defined. */ - const TIFFFieldArray *tFieldArray = _TIFFGetFields(); - - /*-- write_all_tags() writes all tags automatically with the defined - * precision according to its set_field_type definition. --*/ - uint32_t iDataCnt = 0; - if (write_all_tags(tif, tFieldArray, listTagsNotToWrite, - NUM_ELEMENTS(listTagsNotToWrite), &iDataCnt)) - { - fprintf(stderr, "Error during TIFF tag writing.\n"); - goto failure; - } - -#ifndef WRITEPIXELLAST - /*-- Write dummy pixel data. --*/ - if (TIFFWriteScanline(tif, buf, 0, 0) < 0) - { - fprintf(stderr, "Can't write image data.\n"); - goto failure; - } -#endif - - /*================== Save TIFF Directory =====================*/ - /*-- Save current TIFF-directory to file before directory is changed. - * Otherwise it will be lost! - * The tif-structure is overwritten/ freshly initialized by any - * "CreateDirectory". - *----- What is needed here ??? ---- - * In custom_dir.c only TIFFFreeDirectory( tif ); is used to set - * fields of another Sub-Directory. It releases storage associated - * with a directory, especially custom-fields. - *-- Using only TIFFFreeDirectory() here leads to an error!! - *-- Using here TIFFCheckpointDirectory() leads to an additional Main-IFD - * because it does not cleanup the tif-structure. - *-- TIFFWriteDirectory() does cleanup the tif-structure and tries to - * write the IFD to the same location. - */ - /*retCode = TIFFCheckpointDirectory(tif);*/ - if (!TIFFWriteDirectory(tif)) - { - fprintf(stderr, - "Can't write TIFF directory after TIFF tags and image data.\n"); - goto failure; - } - - /*======================= GPS Directory =============================*/ - /*====== Create GPS Directory and write all GPS fields ==============*/ - /* - Create the GPS directory. - * - Get GPS field array, where tag fields are defined. - * - Then write all tags automatically according to their set_field_type - * definition. - */ - fprintf(stderr, "----Write GPS tags ...\n"); - if (TIFFCreateGPSDirectory(tif) != 0) - { - fprintf(stderr, "TIFFCreateGPSDirectory() failed.\n"); - goto failure; - } - - tFieldArray = _TIFFGetGpsFields(); - if (write_all_tags(tif, tFieldArray, NULL, 0, &iDataCnt)) - { - fprintf(stderr, "Error during GPS tag writing.\n"); - goto failure; - } - - /*-- Re-write a valid GPS version ID --*/ - if (!TIFFSetField(tif, GPSTAG_VERSIONID, gpsVersion)) - { - fprintf(stderr, "Can't write GPSTAG_VERSIONID\n"); - goto failure; - } - - /*-- GPS - write custom directory GPS into file and - * get back the offset of GPS directory. - */ - uint64_t dir_offset_GPS = 0; - if (!TIFFWriteCustomDirectory(tif, &dir_offset_GPS)) - { - fprintf(stderr, "TIFFWriteCustomDirectory() with GPS failed.\n"); - goto failure; - } - - /*-- Go back to the first (main) directory, and set correct value of the - * GPS IFD pointer. (main directory is reloaded from file!) - */ - if (!TIFFSetDirectory(tif, 0)) - { - fprintf(stderr, "TIFFSetDirectory(0) after writing GPS failed.\n"); - goto failure; - } - /*-- Write GPS tag reference / offset into GPSIFD tag in main directory --*/ - if (!TIFFSetField(tif, TIFFTAG_GPSIFD, dir_offset_GPS)) - { - fprintf(stderr, "Can't write TIFFTAG_GPSIFD.\n"); - goto failure; - } - - /*-- Save current TIFF-directory to file before directory is changed. - * Otherwise it will be lost! The tif-structure is overwritten/ freshly - * initialized by any "CreateDirectory". - * TIFFWriteDirectory() does cleanup tif-structure. - */ - if (!TIFFWriteDirectory(tif)) - { - fprintf(stderr, "Can't write TIFF directory after GPS tags.\n"); - goto failure; - } - - /*======================= EXIF Directory ============================*/ - /*====== Create EXIF Directory and write all EXIF fields ============*/ - /* - Create the EXIF directory. - * - Get EXIF field array, where tag fields are defined. - * - Then write all tags automatically according to their set_field_type - * definition. - */ - fprintf(stderr, "----Write EXIF tags ...\n"); - if (TIFFCreateEXIFDirectory(tif) != 0) - { - fprintf(stderr, "TIFFCreateEXIFDirectory() failed.\n"); - goto failure; - } - - tFieldArray = _TIFFGetExifFields(); - if (write_all_tags(tif, tFieldArray, listTagsNotToWrite, - NUM_ELEMENTS(listTagsNotToWrite), &iDataCnt)) - { - fprintf(stderr, "Error during GPS tag writing.\n"); - goto failure; - } - - /*--- Set valid EXIF version, which is a 4 byte string --*/ - if (!TIFFSetField(tif, EXIFTAG_EXIFVERSION, exifVersion)) - { - fprintf(stderr, "Can't write EXIFTAG_EXIFVERSION\n"); - goto failure; - } - - /*-- EXIF - write custom directory EXIF into file and - * get back the offset of EXIF directory. - */ - uint64_t dir_offset_EXIF = 0; - if (!TIFFWriteCustomDirectory(tif, &dir_offset_EXIF)) - { - fprintf(stderr, "TIFFWriteCustomDirectory() with EXIF failed.\n"); - goto failure; - } - - /*-- Go back to the first (main) directory, and set correct value of the - * EXIF IFD pointer. (main directory is reloaded from file!) - */ - if (!TIFFSetDirectory(tif, 0)) - { - fprintf(stderr, "TIFFSetDirectory(0) after writing EXIF failed.\n"); - goto failure; - } - /*-- Write EXIF tag reference / offset into EXIFIFD tag in main directory - * --*/ - if (!TIFFSetField(tif, TIFFTAG_EXIFIFD, dir_offset_EXIF)) - { - fprintf(stderr, "Can't write TIFFTAG_EXIFIFD.\n"); - goto failure; - } - -#ifdef WRITEPIXELLAST - /*-- Write dummy pixel data at the end of all directories. --*/ - if (TIFFWriteScanline(tif, buf, 0, 0) < 0) - { - fprintf(stderr, "Can't write image data after all direcories.\n"); - goto failure; - } -#endif - - /*================= Close TIFF file ====================*/ - /* Always TIFFWriteDirectory() before using/creating another directory. - * Not necessary before TIFFClose(), however, TIFFClose() uses - * TIFFReWriteDirectory(), which forces directory to be written at another - * location. - * Therefore, better use TIFFWriteDirectory() just before TIFFCllose(). - */ - if (!TIFFWriteDirectory(tif)) - { - fprintf(stderr, "Can't write TIFF directory after EXIF tags.\n"); - goto failure; - } - TIFFClose(tif); - - fprintf(stderr, "-------- Continue Test ---------- reading ...\n"); - - /*=========== READING ============= READING ==========================*/ - /* Ok, now test whether we can read written values correctly. */ - tif = TIFFOpen(filenameRead, "r"); - if (!tif) - { - fprintf(stderr, "Can't open test TIFF file %s for reading.\n", - filenameRead); - goto failure; - } - - /*-- Read some special parameters out of the main directory --*/ - if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &auxUint32)) - { - fprintf(stderr, "Can't read %s.\n", "TIFFTAG_IMAGEWIDTH"); - goto failure; - } - if (auxUint32 != width) - { - fprintf(stderr, - "Read value of IMAGEWIDTH %" PRIu32 - " differs from set value %" PRIu16 ".\n", - auxUint32, width); - goto failure; - } - if (!TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &auxUint32)) - { - fprintf(stderr, "Can't read %s.\n", "TIFFTAG_IMAGELENGTH"); - goto failure; - } - if (auxUint32 != width) - { - fprintf(stderr, - "Read value of TIFFTAG_IMAGELENGTH %" PRIu32 - " differs from set value %" PRIu16 ".\n", - auxUint32, length); - goto failure; - } - - /* TIFFTAG_NUMBEROFINKS is a special tag, which is automatically set when - * InkNames string is written. */ - if (!TIFFGetField(tif, TIFFTAG_NUMBEROFINKS, &auxUint16)) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_NUMBEROFINKS"); - goto failure; - } - else - { - if (auxUint16 != NINKS) - { - fprintf(stderr, - "Read value of TIFFTAG_NUMBEROFINKS %" PRIu32 - " differs from set value %" PRIu16 ".\n", - auxUint16, NINKS); - goto failure; - } - } - - /*================== Reading all TIFF tags =======================*/ - fprintf(stderr, "----Read TIFF tags ...\n"); - tFieldArray = _TIFFGetFields(); - iDataCnt = 0; - if (read_all_tags(tif, tFieldArray, listTagsNotToWrite, - NUM_ELEMENTS(listTagsNotToWrite), &iDataCnt)) - { - fprintf(stderr, "Error during TIFF tag reading.\n"); - goto failure; - } - - /*================== Reading GPS tags ============================*/ - /*-- First get offset to GPS-directory and set it active with - * TIFFReadGPSDirectory(). - * (this will destroy previously main directory fields in memory!) - */ - uint64_t read_dir_offset = 0; - fprintf(stderr, "----Read GPS tags ...\n"); - if (!TIFFGetField(tif, TIFFTAG_GPSIFD, &read_dir_offset)) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_GPSIFD"); - goto failure; - } - if (!TIFFReadGPSDirectory(tif, read_dir_offset)) - { - fprintf(stderr, "Can't read %s\n", "TIFFReadGPSDirectory()"); - goto failure; - } - - /*-- Now read and compare tags from GPS-directory --*/ - tFieldArray = _TIFFGetGpsFields(); - if (read_all_tags(tif, tFieldArray, NULL, 0, &iDataCnt)) - { - fprintf(stderr, "Error during GPS tag reading.\n"); - goto failure; - } - - /*================== Reading EXIF tags ===========================*/ - /*-- Go back to the first (main) directory using TIFFSetDirectory(), - * and then get value of the EXIFIFD directory offset. - * Then read EXIF directory tags from file into tif-structure. - * Finally, read and compare tags to the written values. - */ - TIFFSetDirectory(tif, 0); - fprintf(stderr, "----Read EXIF tags ...\n"); - if (!TIFFGetField(tif, TIFFTAG_EXIFIFD, &read_dir_offset)) - { - fprintf(stderr, "Can't read %s\n", "TIFFTAG_EXIFIFD"); - goto failure; - } - - if (!TIFFReadEXIFDirectory(tif, read_dir_offset)) - { - fprintf(stderr, "Can't read %s\n", "TIFFReadEXIFDirectory()"); - goto failure; - } - - tFieldArray = _TIFFGetExifFields(); - if (read_all_tags(tif, tFieldArray, NULL, 0, &iDataCnt)) - { - fprintf(stderr, "Error during EXIF tag reading.\n"); - goto failure; - } - - TIFFClose(tif); - - /* All tests passed; delete file and exit with success status. */ -#ifdef FOR_AUTO_TESTING - unlink(filenameRead); -#endif - fprintf(stderr, "-------- Test finished OK ----------\n"); - return 0; - -failure: - /* - * Something went wrong; close file and return unsuccessful status. - * Do not remove the file for further manual investigation. - */ - TIFFClose(tif); - fprintf(stderr, "-------- Test finished with FAILURE --------\n"); - return 1; -} /*-- write_test_tiff() --*/ - -/* ==== testPasscountFlag() =========================================== - * Checks the tag FieldArray settings for the passcount flag. - * Some tags, which are handled directly, do not follow the rules. - * - */ -int testPasscountFlag(const char *szMsg, const TIFFFieldArray *tFieldArray, - uint32_t *listTagsNotFollowPasscountRules, - uint32_t nTagsInList) -{ - uint32_t t; - int retFails = 0; - - uint32_t nTags = tFieldArray->count; - /*-- Test ReadCount equals WriteCount. --*/ - int nFails = 0; - fprintf(stderr, "%-16s Check if writecount equals readcount ... ", szMsg); - for (t = 0; t < nTags; t++) - { - if (tagIsInList(tFieldArray->fields[t].field_tag, - listTagsNotFollowPasscountRules, nTagsInList)) - continue; - - if (tFieldArray->fields[t].field_writecount != - tFieldArray->fields[t].field_readcount) - { - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf(stderr, - "WriteCount %d for tag \t%-25s not equal ReadCount %d.\n", - tFieldArray->fields[t].field_writecount, - tFieldArray->fields[t].field_name, - tFieldArray->fields[t].field_readcount); - nFails++; - } - } /* for - readcount == writecount */ - if (nFails == 0) - fprintf(stderr, "--> OK\n"); - retFails += nFails; - - /*-- Test correct setting of passcount flag. --*/ - nFails = 0; - fprintf(stderr, - "%-16s Check if passcount flag is set according to " - "writecount value ... ", - szMsg); - for (t = 0; t < nTags; t++) - { - if (tagIsInList(tFieldArray->fields[t].field_tag, - listTagsNotFollowPasscountRules, nTagsInList)) - continue; - - if (tFieldArray->fields[t].field_writecount < 0) - { - if (tFieldArray->fields[t].field_type != TIFF_ASCII && - tFieldArray->fields[t].field_passcount == 0) - { - if (tFieldArray->fields[t].field_readcount != TIFF_SPP) - { - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf(stderr, - "Passcount flag for variable rd/wrtcount tag " - "\t%-25s not " - "correctly set. Should be " - "TRUE.\n", - tFieldArray->fields[t].field_name); - } - else - { - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf( - stderr, - "Passcount flag for TIFF_SPP readcount tag \t%-25s not " - "correctly set. Should be " - "TRUE.\n", - tFieldArray->fields[t].field_name); - } - nFails++; - } - else if (tFieldArray->fields[t].field_type == TIFF_ASCII && - tFieldArray->fields[t].set_field_type == - TIFF_SETGET_ASCII && - tFieldArray->fields[t].field_writecount != - TIFF_VARIABLE2 && - tFieldArray->fields[t].field_passcount != 0) - { - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf( - stderr, - "Passcount flag for ASCII tag \t%-25s not correctly set. " - "Should be " - "FALSE.\n", - tFieldArray->fields[t].field_name); - nFails++; - } - else if (tFieldArray->fields[t].field_type == TIFF_ASCII && - tFieldArray->fields[t].field_writecount == - TIFF_VARIABLE2 && - tFieldArray->fields[t].field_passcount == 0) - { - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf(stderr, - "Passcount flag for ASCII 'TIFF_VARIABLE2' tag \t%-25s " - "not correctly set. " - "Should be TRUE.\n", - tFieldArray->fields[t].field_name); - nFails++; - } - } - else - { - /* field_writecount >= 0 */ - if (tFieldArray->fields[t].field_passcount != 0) - { - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf(stderr, - "Passcount flag for tag \t%-25s not correctly set. " - "Should be " - "FALSE.\n", - tFieldArray->fields[t].field_name); - nFails++; - } - if (tFieldArray->fields[t].field_writecount == 0) - { - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf(stderr, - "WriteCount for tag \t%-25s shall be not zero.\n", - tFieldArray->fields[t].field_name); - nFails++; - } - } - } /* for() - passcount flag */ - if (nFails == 0) - fprintf(stderr, "--> OK\n"); - retFails += nFails; - - /*-- Test correct read-/writecount and TIFF_SETGET type. --*/ - nFails = 0; - fprintf(stderr, "%-16s Check if writecount fits to set_field_type ... ", - szMsg); - for (t = 0; t < nTags; t++) - { - if (tagIsInList(tFieldArray->fields[t].field_tag, - listTagsNotFollowPasscountRules, nTagsInList)) - continue; - - /* TIFF_SETGET_UNDEFINED tags FIELD_IGNORE tags are not written to file. - * Thus definition is obsolete. */ - // if (tFieldArray->fields[t].set_field_type >= TIFF_SETGET_UNDEFINED && - // tFieldArray->fields[t].field_bit == FIELD_IGNORE) - // continue; - - if (tFieldArray->fields[t].field_writecount == TIFF_VARIABLE2 && - !(tFieldArray->fields[t].set_field_type >= TIFF_SETGET_C32_ASCII && - tFieldArray->fields[t].set_field_type <= TIFF_SETGET_C32_IFD8)) - { - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf(stderr, - "WriteCount %d for tag \t%-25s does not fit to " - "'set_field_type' %d. " - "Should be TIFF_VARIABLE2=-3\n", - tFieldArray->fields[t].field_writecount, - tFieldArray->fields[t].field_name, - tFieldArray->fields[t].set_field_type); - nFails++; - } - else if (tFieldArray->fields[t].field_writecount == TIFF_VARIABLE && - tFieldArray->fields[t].field_type != TIFF_ASCII && - !(tFieldArray->fields[t].set_field_type >= - TIFF_SETGET_C16_ASCII && - tFieldArray->fields[t].set_field_type <= - TIFF_SETGET_C16_IFD8)) - { - if (tFieldArray->fields[t].field_readcount == TIFF_SPP) - { - /* Special case for tags defined with one value per sample, - * thus readcount == SamplesPerPixel. - */ - } - else - { - - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf(stderr, - "WriteCount %d for tag \t%-25s does not fit to " - "'set_field_type' %d. " - "Should be TIFF_VARIABLE=-1\n", - tFieldArray->fields[t].field_writecount, - tFieldArray->fields[t].field_name, - tFieldArray->fields[t].set_field_type); - nFails++; - } - } - else if (tFieldArray->fields[t].field_writecount > 1 && - !((tFieldArray->fields[t].set_field_type >= - TIFF_SETGET_C0_ASCII && - tFieldArray->fields[t].set_field_type <= - TIFF_SETGET_C0_IFD8) || - tFieldArray->fields[t].set_field_type == TIFF_SETGET_ASCII)) - { - if (!(tFieldArray->fields[t].set_field_type == - TIFF_SETGET_UINT16_PAIR && - tFieldArray->fields[t].field_writecount == 2)) - { - - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf(stderr, - "WriteCount %d for tag \t%-25s does not fit to " - "'set_field_type' %d. " - "Should be >1. \n", - tFieldArray->fields[t].field_writecount, - tFieldArray->fields[t].field_name, - tFieldArray->fields[t].set_field_type); - nFails++; - } - } - else if (tFieldArray->fields[t].field_writecount == 1 && - !(tFieldArray->fields[t].set_field_type >= - TIFF_SETGET_UNDEFINED && - tFieldArray->fields[t].set_field_type <= TIFF_SETGET_INT)) - { - if (nFails == 0) - fprintf(stderr, "\n"); - fprintf(stderr, - "WriteCount %d for tag \t%-25s does not fit to " - "'set_field_type' %d. " - "Should be 1. \n", - tFieldArray->fields[t].field_writecount, - tFieldArray->fields[t].field_name, - tFieldArray->fields[t].set_field_type); - nFails++; - } - } /* for - read-/writecount and TIFF_SETGET type */ - if (nFails == 0) - fprintf(stderr, "--> OK\n"); - retFails += nFails; - - fprintf(stderr, "\n"); - return retFails; -} /*-- testPassountFlag() --*/ - -/* ==== write_all_tags() ============================================== - * Writes all tags within tFieldArray according to their set_field_type - * definition except tags listed in listTagsNotToWrite. - * iCnt is an index into predefined arrays for the values to write. - */ -int write_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray, - uint32_t *listTagsNotToWrite, uint32_t nTagsInList, - uint32_t *iCnt) -{ - - char auxCharArray[2 * STRSIZE]; - - uint32_t i = *iCnt; - uint32_t nTags = tFieldArray->count; - for (uint32_t t = 0; t < nTags; i++, t++) - { - bool deferredSetField = false; - /* Allways reset variableArrayCount to default value here. */ - uint32_t variableArrayCount = VARIABLE_ARRAY_SIZE; - - uint32_t tTag = tFieldArray->fields[t].field_tag; - if (tagIsInList(tTag, listTagsNotToWrite, nTagsInList)) - continue; - - TIFFDataType tType = - tFieldArray->fields[t].field_type; /* e.g. TIFF_RATIONAL */ - (void)tType; - short tWriteCount = tFieldArray->fields[t].field_writecount; - TIFFSetGetFieldType tSetFieldType = - tFieldArray->fields[t] - .set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ - char *tFieldName = tFieldArray->fields[t].field_name; - void *pVoid = NULL; - - /*-- dependent on set_field_type write value --*/ - long auxLong = 0; - switch (tSetFieldType) - { - case TIFF_SETGET_ASCII: - /* Either the stringlength is defined as a fixed length in - * .field_writecount or a NULL-terminated string is used. - * Shorter strings than in auxTextArraxW need a - * NULL-termination. Therefore copy the string. */ - if (tWriteCount > 0) - auxLong = tWriteCount - 1; - else - auxLong = (long)strlen(auxTextArrayW[i]) - 1; - auxLong = auxLong >= sizeof(auxCharArray) - ? sizeof(auxCharArray) - 1 - : auxLong; - strncpy(auxCharArray, auxTextArrayW[i], auxLong); - auxCharArray[auxLong] = 0; - if (!TIFFSetField(tif, tTag, auxCharArray)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - break; - case TIFF_SETGET_C16_ASCII: - if (tTag == TIFFTAG_INKNAMES) - { - if (!TIFFSetField(tif, tTag, sizeof(inkNamesW), inkNamesW)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - } - break; - case TIFF_SETGET_UINT8: - if (auxLongArrayW[i] > 255) - auxLongArrayW[i] = 255; - case TIFF_SETGET_UINT16: - if (auxLongArrayW[i] > 65535) - auxLongArrayW[i] = 65535; - case TIFF_SETGET_UINT32: - case TIFF_SETGET_INT: - case TIFF_SETGET_UNDEFINED: - /*-- All those can be written with char, short or long - * parameter. Only value range should be in line. */ - if (tTag == TIFFTAG_FILLORDER) - auxLongArrayW[i] = 1; - if (tTag == TIFFTAG_ORIENTATION) - auxLongArrayW[i] = 7; - if (tTag == TIFFTAG_RESOLUTIONUNIT) - auxLongArrayW[i] = 3; - if (tTag == TIFFTAG_SAMPLEFORMAT) - auxLongArrayW[i] = SAMPLEFORMAT_UINT; - if (!TIFFSetField(tif, tTag, auxLongArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - break; - case TIFF_SETGET_UINT16_PAIR: - if (auxLongArrayW[i] > 65535) - auxLongArrayW[i] = 65535; - if (!TIFFSetField(tif, tTag, 7, auxLongArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - break; - case TIFF_SETGET_UINT64: - case TIFF_SETGET_IFD8: - /* IFD8 is uint64_t but we write here only values for uint32 - * size, even for BigTIFF. - * -- Attention: -- - * "Variable promotion" for va_arg parameters are promoted to - * "int", which is different in x64 and x86 compilations. - * Thus cast to expected uint64_t. - */ - if (!TIFFSetField(tif, tTag, (uint64_t)auxLongArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - break; - case TIFF_SETGET_SINT8: - case TIFF_SETGET_SINT16: - case TIFF_SETGET_SINT32: - /*-- All those can be written with char, short or long - * parameter. Only value range should be in line. */ - if (!TIFFSetField(tif, tTag, -1.0 * auxLongArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - break; - case TIFF_SETGET_FLOAT: - case TIFF_SETGET_DOUBLE: - if (tWriteCount == 1) - { - /*-- All single values can be written with float or - * double parameter. Only value range should be in line. - */ - if (!TIFFSetField(tif, tTag, auxDoubleArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - } - else if (tFieldArray->fields[t].field_readcount == TIFF_SPP) - { - /*-- Some tags are written per SamplesPerPixel. For - * those, readcount is TIFF_SPP. */ - if (tTag == TIFFTAG_SMINSAMPLEVALUE || - tTag == TIFFTAG_SMAXSAMPLEVALUE) - { - auxDoubleArrayW[i] = 250; - } - if (!TIFFSetField(tif, tTag, auxDoubleArrayW[i])) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - } - else - { - fprintf(stderr, - "WriteCount for .set_field_type %d should be " - "1! %s\n", - tSetFieldType, tFieldArray->fields[t].field_name); - } - break; - /* _Cxx_ just defines the precense and size of the count - * parameter for the array: - * - C0=no count parameter (fixed array where, - * positive readcount/writecount gives array count) - * - C16=short (uint16_t) count parameter size - * - C32=long (uint32_t) count parameter size - * Check, if it is a single parameter, a fixed array or a - * variable array. - */ - case TIFF_SETGET_C0_FLOAT: - case TIFF_SETGET_C16_FLOAT: - case TIFF_SETGET_C32_FLOAT: - /* For arrays, distinguishing between float or double is - * essential, even for writing. */ - pVoid = &auxFloatArrayW[i]; - deferredSetField = true; - break; - case TIFF_SETGET_C0_DOUBLE: - case TIFF_SETGET_C16_DOUBLE: - case TIFF_SETGET_C32_DOUBLE: - /* For arrays, distinguishing between float or double is - * essential, even for writing. */ - pVoid = &auxDoubleArrayW[i]; - deferredSetField = true; - break; - case TIFF_SETGET_C0_UINT8: - case TIFF_SETGET_C0_SINT8: - case TIFF_SETGET_C16_UINT8: - case TIFF_SETGET_C16_SINT8: - case TIFF_SETGET_C32_UINT8: - case TIFF_SETGET_C32_SINT8: - pVoid = &auxCharArrayW[i]; - deferredSetField = true; - break; - case TIFF_SETGET_C0_UINT16: - case TIFF_SETGET_C0_SINT16: - case TIFF_SETGET_C16_UINT16: - case TIFF_SETGET_C16_SINT16: - case TIFF_SETGET_C32_UINT16: - case TIFF_SETGET_C32_SINT16: - if (tTag == TIFFTAG_EXTRASAMPLES) - { - variableArrayCount = 1; - auxShortArrayW[i] = 2; - } - pVoid = &auxShortArrayW[i]; - deferredSetField = true; - break; - case TIFF_SETGET_C0_UINT32: - case TIFF_SETGET_C0_SINT32: - case TIFF_SETGET_C16_UINT32: - case TIFF_SETGET_C16_SINT32: - case TIFF_SETGET_C32_UINT32: - case TIFF_SETGET_C32_SINT32: - pVoid = &auxLongArrayW[i]; - deferredSetField = true; - break; - case TIFF_SETGET_C16_IFD8: - if (tTag == TIFFTAG_EXTRACAMERAPROFILES) - { - uint64_t a = 18; - if (!TIFFSetField(tif, tTag, 1, &a)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - } - else - { - pVoid = &auxLongArrayW[i]; - deferredSetField = true; - } - break; - case TIFF_SETGET_OTHER: - /* Transferfunction and Colormap to be inserted here. */ - fprintf(stderr, - "Writing of TIFF_SETGET_OTHER for tag %s not supported " - "yet.\n", - tFieldArray->fields[t].field_name); - break; - default: - fprintf(stderr, - "SetFieldType %d not defined within writing switch for " - "%s.\n", - tSetFieldType, tFieldName); - }; /*-- switch(tSetFieldType) --*/ - - if (deferredSetField) - { - /* deferredSetField is used to write fixed arrays and - * variable arrays. - * pVoid pointer is set above to the corresponding array and - * some other parameters like variableArrayCount are set for the - * field, which is written now. - */ - if (tWriteCount == 1) - { - fprintf(stderr, - "WriteCount for .set_field_type %d should be -1 or " - "greater than 1! %s\n", - tSetFieldType, tFieldArray->fields[t].field_name); - } - else - { - /*-- Either fix or variable array --*/ - /* Now decide between fixed or variable array */ - if (tWriteCount > 1) - { - /* fixed array with needed arraysize defined in - * .field_writecount */ - if (!TIFFSetField(tif, tTag, pVoid)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - } - else - { - /*-- Special treatment of variable array -- - * For test, use always arraysize of - * VARIABLE_ARRAY_SIZE, apart a few exceptions, - * for which variableArrayCount is set differently above. - */ - if (!TIFFSetField(tif, tTag, variableArrayCount, pVoid)) - { - fprintf(stderr, "Can't write %s\n", - tFieldArray->fields[t].field_name); - goto failure; - } - } - } - } - } /*-- for() --*/ - - *iCnt = i; - return 0; -failure: - fprintf(stderr, "\n"); - *iCnt = i; - return 1; -} /*--- write_all_tags() ---*/ - -/* ==== tagIsInList() ================================================= - * Returns TRUE if tag is in the list, otherwise FALSE. - * When the pointer to the list is NULL also FALSE is returned. - */ -int tagIsInList(uint32_t tTag, uint32_t *list, uint32_t nTagsInList) -{ - if (list == NULL) - return 0; - - for (uint32_t i = 0; i < nTagsInList; i++) - { - if (tTag == list[i]) - return 1; - } - return 0; -} /*--- tagIsInList() ---*/ - -/* ==== read_all_tags() =============================================== - * Reads all tags within tFieldArray according to their set_field_type - * definition except tags listed in listTagsNotToWrite. - * iCnt is an index into predefined arrays for the values written. - * The read values are compared to the written ones. - */ -int read_all_tags(TIFF *tif, const TIFFFieldArray *tFieldArray, - uint32_t *listTagsNotToWrite, uint32_t nTagsNotToWrite, - uint32_t *iCnt) -{ - - /* -- Variables for reading within the switch() -- */ - int32_t j; - float auxFloat = 0.0f; - double auxDouble = 0.0; - char auxChar = 0; - uint32_t auxUint32 = 0; - uint64_t auxUint64 = 0; - short auxShort = 0; - long auxLong = 0; - union - { - long Long; - short Short1; - short Short2[2]; - char Char[4]; - } unionLong; - void *pVoidArray; - char *pAscii; - double dblDiff, dblDiffLimit; - - char auxCharArray[2 * STRSIZE]; - short auxShortArray[2 * N_SIZE]; - long auxLongArray[2 * N_SIZE]; - float auxFloatArray[2 * N_SIZE]; - double auxDoubleArray[2 * N_SIZE]; -#define RATIONAL_EPS \ - (1.0 / 30000.0) /* reduced difference of rational values, approx 3.3e-5 */ - - uint32_t i = *iCnt; - uint32_t nTags = tFieldArray->count; - for (uint32_t t = 0; t < nTags; t++, i++) - { - uint32_t tTag = tFieldArray->fields[t].field_tag; - TIFFDataType tType = - tFieldArray->fields[t].field_type; /* e.g. TIFF_RATIONAL */ - short tWriteCount = tFieldArray->fields[t].field_writecount; - TIFFSetGetFieldType tSetFieldType = - tFieldArray->fields[t] - .set_field_type; /* e.g. TIFF_SETGET_C0_FLOAT */ - char *tFieldName = tFieldArray->fields[t].field_name; - if (tagIsInList(tTag, listTagsNotToWrite, nTagsNotToWrite)) - continue; - - /*-- dependent on set_field_type read value --*/ - switch (tSetFieldType) - { - case TIFF_SETGET_ASCII: - /* Either the stringlength is defined as a fixed length in - * .field_writecount or a NULL-terminated string is used. */ - if (!TIFFGetField(tif, tTag, &pAscii)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - /* Save string from temporary buffer and compare with - * written string. */ - strncpy(auxCharArray, pAscii, sizeof(auxCharArray) - 1u); - auxCharArray[sizeof(auxCharArray) - 1u] = '\0'; - if (tWriteCount > 0) - auxLong = tWriteCount - 1; - else - auxLong = (long)strlen(auxCharArray); - int retCode2 = strncmp(auxCharArray, auxTextArrayW[i], auxLong); - if (retCode2 != 0) - { - fprintf(stderr, - "%d:Read value of %s %s differs from set value " - "%s\n", - i, tFieldName, auxCharArray, auxTextArrayW[i]); - GOTOFAILURE - } - break; - case TIFF_SETGET_C16_ASCII: - if (tTag == TIFFTAG_INKNAMES) - { - if (!TIFFGetField(tif, tTag, &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - if (_TIFFmemcmp(inkNamesW, pVoidArray, sizeof(inkNamesW)) != - 0) - { - fprintf(stderr, - "InkNames read (%s) are different from " - "InkNamesW " - "written %s.\n", - (char *)pVoidArray, inkNamesW); - GOTOFAILURE - } - } - break; - /*-- For reading, the parameter size is to be observed !! */ - case TIFF_SETGET_UINT8: - case TIFF_SETGET_SINT8: - if (!TIFFGetField(tif, tTag, &auxChar)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - /* compare read values with written ones */ - auxLong = auxChar; - if (auxLong != (char)auxLongArrayW[i]) - { - fprintf(stderr, - "%d:Read value of %s %ld differs from set " - "value %ld\n", - i, tFieldName, auxLong, auxLongArrayW[i]); - } - break; - case TIFF_SETGET_UINT16: - case TIFF_SETGET_SINT16: - if (!TIFFGetField(tif, tTag, &auxShort)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - /* compare read values with written ones */ - auxLong = auxShort; - if (auxLong != (short)auxLongArrayW[i]) - { - fprintf(stderr, - "%d:Read value of %s %ld differs from set " - "value %ld\n", - i, tFieldName, auxLong, auxLongArrayW[i]); - GOTOFAILURE - } - break; - case TIFF_SETGET_UINT16_PAIR: - if (!TIFFGetField(tif, tTag, &auxShortArray[0], - &auxShortArray[1])) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - if (auxShortArray[0] != 7 || - auxShortArray[1] != auxLongArrayW[i]) - { - fprintf(stderr, - "%d:Read value of %s %d/%d UINT16_PAIR differs " - "from set " - "values %d/%ld\n", - i, tFieldName, auxShortArray[0], auxShortArray[1], - 7, auxLongArrayW[i]); - GOTOFAILURE - } - break; - case TIFF_SETGET_UINT32: - case TIFF_SETGET_SINT32: - case TIFF_SETGET_INT: - if (!TIFFGetField(tif, tTag, &auxUint32)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - /* compare read values with written ones */ - auxLong = auxUint32; - if (auxLong != auxLongArrayW[i]) - { - uint32_t auxU; - if (tTag == TIFFTAG_TILEDEPTH && - TIFFGetField(tif, TIFFTAG_IMAGEDEPTH, &auxU)) - { - /* At directory re-reading from file, - tif->tif_dir.td_tiledepth = - tif->tif_dir.td_imagedepth is set. */ - if (auxLong != auxU) - { - fprintf(stderr, - "%d:Read value of %s %ld differs " - "from set " - "value %d\n", - i, tFieldName, auxLong, auxU); - GOTOFAILURE - } - } - else - { - fprintf(stderr, - "%d:Read value of %s %ld differs from set " - "value %ld\n", - i, tFieldName, auxLong, auxLongArrayW[i]); - GOTOFAILURE - } - } - break; - case TIFF_SETGET_IFD8: - if (!TIFFGetField(tif, tTag, &auxUint64)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - /* compare read values with written ones, we wrote only - * unit32 values! */ - if (auxUint64 != (uint64_t)auxLongArrayW[i]) - { - fprintf(stderr, - "%d:Read value of %s %" PRIu64 " differs from set" - "value %ld\n", - i, tFieldName, auxUint64, auxLongArrayW[i]); - GOTOFAILURE - } - break; - - case TIFF_SETGET_C16_IFD8: - if (!TIFFGetField(tif, tTag, &unionLong, &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - if (tTag == TIFFTAG_EXTRACAMERAPROFILES) - { - auxUint64 = *(uint64_t *)pVoidArray; - if (unionLong.Short1 != 1 && auxUint64 != 18) - { - fprintf(stderr, - "%d:Read value of %s %" PRIu64 - " differs from set" - "value %d\n", - i, tFieldName, auxUint64, 18); - GOTOFAILURE - } - } - else - { - /* ToDo: Such tags are not written yet. - */ - fprintf(stderr, "TIFF_SETGET_C16_IFD8 arrays not supported " - "in this testprogram.\n"); - GOTOFAILURE - } - break; - case TIFF_SETGET_FLOAT: - if (!TIFFGetField(tif, tTag, &auxFloat)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-3; - dblDiff = auxFloat - auxDoubleArrayW[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of - * "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to - * indicate infinite distance! However, there are two - * other EXIF tags where numerator indicates a special - * value and six other cases where the denominator - * indicates special values, which are not treated - * within LibTiff!! - */ - if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxFloat == -1.0)) - { - fprintf(stderr, - "%d:Read value of %s %f differs from set value " - "%f\n", - i, tFieldName, auxFloat, auxDoubleArrayW[i]); - GOTOFAILURE - } - } - break; - case TIFF_SETGET_DOUBLE: - if (!TIFFGetField(tif, tTag, &auxDouble)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - dblDiff = auxDouble - auxDoubleArrayW[i]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - /*--: EXIFTAG_SUBJECTDISTANCE: LibTiff returns value of - * "-1.0" if numerator equals 4294967295 (0xFFFFFFFF) to - * indicate infinite distance! - */ - if (!(tTag == EXIFTAG_SUBJECTDISTANCE && auxDouble == -1.0)) - { - fprintf(stderr, - "%d:Read value of %s %f differs from set value " - "%f\n", - i, tFieldName, auxDouble, auxDoubleArrayW[i]); - GOTOFAILURE - } - } - break; - case TIFF_SETGET_C0_FLOAT: - case TIFF_SETGET_C0_DOUBLE: - case TIFF_SETGET_C16_FLOAT: - case TIFF_SETGET_C16_DOUBLE: - case TIFF_SETGET_C32_FLOAT: - case TIFF_SETGET_C32_DOUBLE: - case TIFF_SETGET_C0_UINT8: - case TIFF_SETGET_C0_SINT8: - case TIFF_SETGET_C16_UINT8: - case TIFF_SETGET_C16_SINT8: - case TIFF_SETGET_C32_UINT8: - case TIFF_SETGET_C32_SINT8: - case TIFF_SETGET_C0_UINT16: - case TIFF_SETGET_C0_SINT16: - case TIFF_SETGET_C16_UINT16: - case TIFF_SETGET_C16_SINT16: - case TIFF_SETGET_C32_UINT16: - case TIFF_SETGET_C32_SINT16: - case TIFF_SETGET_C0_UINT32: - case TIFF_SETGET_C0_SINT32: - case TIFF_SETGET_C16_UINT32: - case TIFF_SETGET_C16_SINT32: - case TIFF_SETGET_C32_UINT32: - case TIFF_SETGET_C32_SINT32: - { - /* _Cxx_ just defines the precense and size of the count - * parameter for the array: - * - C0=no count parameter (fixed array where, - * positive readcount/writecount gives array count) - * - C16=short (uint16_t) count parameter size - * - C32=long (uint32_t) count parameter size - * Check, if it is a single parameter, a fixed array or a - * variable array. - */ - if (tWriteCount == 1) - { - fprintf(stderr, - "WriteCount for .set_field_type %d should be -1, " - "-2, -3 or " - "greater than 1! %s\n", - tSetFieldType, tFieldArray->fields[t].field_name); - GOTOFAILURE - } - else - { - /*-- Either fix or variable array --*/ - if (tWriteCount > 1) - { - /* fixed array with needed arraysize defined in - * .field_writecount */ - if (!TIFFGetField(tif, tTag, &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - /* set tWriteCount to number of read samples for - * next steps - */ - auxLong = tWriteCount; - } - else - { - /*-- Special treatment of variable array. -- - * Dependent on _Cxx_, the count parameter is - * short or long. Therefore use unionLong! - */ - if (!TIFFGetField(tif, tTag, &unionLong, &pVoidArray)) - { - fprintf(stderr, "Can't read %s\n", - tFieldArray->fields[t].field_name); - GOTOFAILURE - break; - } - /* set tWriteCount to number of read samples for - * next steps - */ - if (tSetFieldType == TIFF_SETGET_C32_UINT8 || - tSetFieldType == TIFF_SETGET_C32_SINT8 || - tSetFieldType == TIFF_SETGET_C32_UINT16 || - tSetFieldType == TIFF_SETGET_C32_SINT16 || - tSetFieldType == TIFF_SETGET_C32_UINT32 || - tSetFieldType == TIFF_SETGET_C32_SINT32 || - tSetFieldType == TIFF_SETGET_C32_FLOAT || - tSetFieldType == TIFF_SETGET_C32_DOUBLE) - { - auxLong = unionLong.Long; - } - else - { - auxLong = unionLong.Short1; - } - } - /* Save values from temporary array and compare to - * written values. */ - if (tSetFieldType == TIFF_SETGET_C0_FLOAT || - tSetFieldType == TIFF_SETGET_C16_FLOAT || - tSetFieldType == TIFF_SETGET_C32_FLOAT) - { - memcpy(&auxFloatArray, pVoidArray, - (auxLong * sizeof(auxFloatArray[0]))); - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - for (j = 0; j < auxLong; j++) - { - dblDiff = auxFloatArray[j] - auxFloatArrayW[i + j]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of %s #%d %f differs " - "from set value %f\n", - i, tFieldName, j, auxFloatArray[j], - auxFloatArrayW[i + j]); - GOTOFAILURE - } - } - } - else if (tSetFieldType == TIFF_SETGET_C0_DOUBLE || - tSetFieldType == TIFF_SETGET_C16_DOUBLE || - tSetFieldType == TIFF_SETGET_C32_DOUBLE) - { - memcpy(&auxDoubleArray, pVoidArray, - (auxLong * sizeof(auxDoubleArray[0]))); - /* compare read values with written ones */ - if (tType == TIFF_RATIONAL || tType == TIFF_SRATIONAL) - dblDiffLimit = RATIONAL_EPS * auxDoubleArrayW[i]; - else - dblDiffLimit = 1e-6; - for (j = 0; j < auxLong; j++) - { - dblDiff = - auxDoubleArray[j] - auxDoubleArrayW[i + j]; - if (fabs(dblDiff) > fabs(dblDiffLimit)) - { - fprintf(stderr, - "Read value %d of %s #%d %f differs " - "from set value %f\n", - i, tFieldName, j, auxDoubleArray[j], - auxDoubleArrayW[i + j]); - GOTOFAILURE - } - } - } - else if (tSetFieldType == TIFF_SETGET_C0_UINT8 || - tSetFieldType == TIFF_SETGET_C0_SINT8 || - tSetFieldType == TIFF_SETGET_C16_UINT8 || - tSetFieldType == TIFF_SETGET_C16_SINT8 || - tSetFieldType == TIFF_SETGET_C32_UINT8 || - tSetFieldType == TIFF_SETGET_C32_SINT8) - { - memcpy(&auxCharArray, pVoidArray, - (auxLong * sizeof(auxCharArray[0]))); - /* Compare and check values */ - char *auxCharCompare; - if (tTag == EXIFTAG_EXIFVERSION) - { - auxCharCompare = exifVersion; - } - else if (tTag == GPSTAG_VERSIONID) - { - auxCharCompare = gpsVersion; - } - else - { - auxCharCompare = &auxCharArrayW[i]; - } - - for (j = 0; j < auxLong; j++) - { - if (auxCharArray[j] != auxCharCompare[j]) - { - fprintf(stderr, - "Read value %d of %s #%d %d differs " - "from set value %d\n", - i, tFieldName, j, auxCharArray[j], - auxCharArrayW[i + j]); - GOTOFAILURE - } - } - } - else if (tSetFieldType == TIFF_SETGET_C0_UINT16 || - tSetFieldType == TIFF_SETGET_C0_SINT16 || - tSetFieldType == TIFF_SETGET_C16_UINT16 || - tSetFieldType == TIFF_SETGET_C16_SINT16 || - tSetFieldType == TIFF_SETGET_C32_UINT16 || - tSetFieldType == TIFF_SETGET_C32_SINT16) - { - memcpy(&auxShortArray, pVoidArray, - (auxLong * sizeof(auxShortArray[0]))); - /* Compare and check values */ - for (j = 0; j < auxLong; j++) - { - if (auxShortArray[j] != auxShortArrayW[i + j]) - { - fprintf(stderr, - "Read value %d of %s #%d %d " - "differs from " - "set value %d\n", - i, tFieldName, j, auxShortArray[j], - auxShortArrayW[i + j]); - GOTOFAILURE - } - } - } - else if (tSetFieldType == TIFF_SETGET_C0_UINT32 || - tSetFieldType == TIFF_SETGET_C0_SINT32 || - tSetFieldType == TIFF_SETGET_C16_UINT32 || - tSetFieldType == TIFF_SETGET_C16_SINT32 || - tSetFieldType == TIFF_SETGET_C32_UINT32 || - tSetFieldType == TIFF_SETGET_C32_SINT32) - { - memcpy(&auxLongArray, pVoidArray, - (auxLong * sizeof(auxLongArray[0]))); - /* Compare and check values */ - for (j = 0; j < auxLong; j++) - { - if (auxLongArray[j] != auxLongArrayW[i + j]) - { - fprintf(stderr, - "Read value %d of %s #%d %ld " - "differs from " - "set value %ld\n", - i, tFieldName, j, auxLongArray[j], - auxLongArrayW[i + j]); - GOTOFAILURE - } - } - } - else - { - fprintf(stderr, - "SetFieldType %d not defined within array" - "reading clause for %s.\n", - tSetFieldType, tFieldName); - GOTOFAILURE - } - } - } /* case for all arrays */ - break; - case TIFF_SETGET_OTHER: - /* ToDo: Transferfunction and Colormap to be inserted here. */ - break; - case TIFF_SETGET_UNDEFINED: - /* Such tags are not written to file. */ - break; - default: - fprintf(stderr, - "SetFieldType %d not defined within reading switch for " - "%s.\n", - tSetFieldType, tFieldName); - GOTOFAILURE - }; /*-- switch(tSetFieldType) --*/ - } /*-- for(t to nTags) --*/ - - *iCnt = i; - return 0; -failure: - fprintf(stderr, "\n"); - *iCnt = i; - return 1; -} /*--- read_all_tags() ---*/ diff --git a/thirdparty/SDL2_image/external/libtiff/test/testfax3_bug_513.sh b/thirdparty/SDL2_image/external/libtiff/test/testfax3_bug_513.sh deleted file mode 100755 index 751db960d..000000000 --- a/thirdparty/SDL2_image/external/libtiff/test/testfax3_bug_513.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# check decoding of a CCITT Group 3 encoded TIFF -# hitting https://gitlab.com/libtiff/libtiff/-/issues/513 -. ${srcdir:-.}/common.sh -infile="${IMAGES}/testfax3_bug_513.tiff" -outfile="o-testfax3_bug_513.tiff" -rm -f $outfile -echo "$MEMCHECK ${TIFFCP} -c none $infile $outfile" -eval "$MEMCHECK ${TIFFCP} -c none $infile $outfile" -status=$? -if [ $status != 0 ] ; then - echo "Returned failed status $status!" - echo "Output (if any) is in \"${outfile}\"." - exit $status -fi -echo "$MEMCHECK ${TIFFCMP} $outfile ${REFS}/$outfile" -eval "$MEMCHECK ${TIFFCMP} $outfile ${REFS}/$outfile" -status=$? -if [ $status != 0 ] ; then - echo "Returned failed status $status!" - echo "\"${outfile}\" differs from reference file." - exit $status -fi diff --git a/thirdparty/SDL2_image/external/libtiff/test/testtypes.c b/thirdparty/SDL2_image/external/libtiff/test/testtypes.c index fefc1ff74..a36d21e56 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/testtypes.c +++ b/thirdparty/SDL2_image/external/libtiff/test/testtypes.c @@ -33,24 +33,26 @@ #include "tiffio.h" -#define CHECK_TYPE(t, s) \ - if (sizeof(t) != s) \ - { \ - fprintf(stderr, "sizeof(" #t ")=%d, it should be %d\n", \ - (int)sizeof(t), (int)s); \ - return 1; \ - } +#define CHECK_TYPE(t, s) \ + if (sizeof(t) != s) { \ + fprintf(stderr, "sizeof(" # t ")=%d, it should be %d\n", (int)sizeof(t), (int)s); \ + return 1; \ + } -int main() +int +main() { - CHECK_TYPE(int8_t, 1) - CHECK_TYPE(int16_t, 2) - CHECK_TYPE(int32_t, 4) - CHECK_TYPE(int64_t, 8) - CHECK_TYPE(uint8_t, 1) - CHECK_TYPE(uint16_t, 2) - CHECK_TYPE(uint32_t, 4) - CHECK_TYPE(uint64_t, 8) - CHECK_TYPE(tmsize_t, sizeof(size_t)) - return 0; + CHECK_TYPE(TIFF_INT8_T, 1) + CHECK_TYPE(TIFF_INT16_T, 2) + CHECK_TYPE(TIFF_INT32_T, 4) + CHECK_TYPE(TIFF_INT64_T, 8) + CHECK_TYPE(TIFF_UINT8_T, 1) + CHECK_TYPE(TIFF_UINT16_T, 2) + CHECK_TYPE(TIFF_UINT32_T, 4) + CHECK_TYPE(TIFF_UINT64_T, 8) + CHECK_TYPE(TIFF_SIZE_T, sizeof(size_t)) + CHECK_TYPE(TIFF_SSIZE_T, sizeof(size_t)) + return 0; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ diff --git a/thirdparty/SDL2_image/external/libtiff/test/tiffinfo.sh b/thirdparty/SDL2_image/external/libtiff/test/tiffinfo.sh index 9764bd51b..cb572483c 100755 --- a/thirdparty/SDL2_image/external/libtiff/test/tiffinfo.sh +++ b/thirdparty/SDL2_image/external/libtiff/test/tiffinfo.sh @@ -4,4 +4,3 @@ # . ${srcdir:-.}/common.sh f_test_reader "${TIFFINFO} -c -D -d -j -s " "${IMG_MINISBLACK_1C_16B}" -f_test_reader "${TIFFINFO} " "${IMG_TIFF_WITH_SUBIFD_CHAIN}" diff --git a/thirdparty/SDL2_image/external/libtiff/test/tifftest.h b/thirdparty/SDL2_image/external/libtiff/test/tifftest.h index cfd0fbbe5..391b0f645 100644 --- a/thirdparty/SDL2_image/external/libtiff/test/tifftest.h +++ b/thirdparty/SDL2_image/external/libtiff/test/tifftest.h @@ -1,23 +1,23 @@ /* * Copyright (c) 2008, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ @@ -32,8 +32,9 @@ #include "tiffio.h" -int CheckShortField(TIFF *, const ttag_t, const uint16_t); -int CheckShortPairedField(TIFF *, const ttag_t, const uint16_t *); -int CheckLongField(TIFF *, const ttag_t, const uint32_t); +int CheckShortField(TIFF *, const ttag_t, const uint16); +int CheckShortPairedField(TIFF *, const ttag_t, const uint16*); +int CheckLongField(TIFF *, const ttag_t, const uint32); #endif /* _TIFFTEST_ */ + diff --git a/thirdparty/SDL2_image/external/libtiff/tools/CMakeLists.txt b/thirdparty/SDL2_image/external/libtiff/tools/CMakeLists.txt old mode 100755 new mode 100644 index c0ea2fd33..ff2a1ddc2 --- a/thirdparty/SDL2_image/external/libtiff/tools/CMakeLists.txt +++ b/thirdparty/SDL2_image/external/libtiff/tools/CMakeLists.txt @@ -22,96 +22,73 @@ # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. -# MSVC specific resource preparation -if (WIN32 AND MSVC) - message(STATUS "Include resource version information for TOOLS") - set(MSVC_RESSOURCE_FILE tif_tools_versioninfo.rc) - source_group("Resource Files" FILES tif_tools_versioninfo.rc) -endif () +extra_dist(Makefile.vc) +include_directories(${PROJECT_SOURCE_DIR}/libtiff + ${PROJECT_BINARY_DIR}/libtiff + ${PROJECT_SOURCE_DIR}/port + ${CMAKE_CURRENT_BINARY_DIR}) -add_executable(fax2ps ../placeholder.h) -target_sources(fax2ps PRIVATE fax2ps.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(fax2ps PRIVATE tiff tiff_port) +add_executable(fax2ps fax2ps.c) +target_link_libraries(fax2ps tiff port) -add_executable(fax2tiff ../placeholder.h) -target_sources(fax2tiff PRIVATE fax2tiff.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(fax2tiff PRIVATE tiff tiff_port) +add_executable(fax2tiff fax2tiff.c) +target_link_libraries(fax2tiff tiff port) -add_executable(pal2rgb ../placeholder.h) -target_sources(pal2rgb PRIVATE pal2rgb.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(pal2rgb PRIVATE tiff tiff_port) +add_executable(pal2rgb pal2rgb.c) +target_link_libraries(pal2rgb tiff port) -add_executable(ppm2tiff ../placeholder.h) -target_sources(ppm2tiff PRIVATE ppm2tiff.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(ppm2tiff PRIVATE tiff tiff_port) +add_executable(ppm2tiff ppm2tiff.c) +target_link_libraries(ppm2tiff tiff port) -add_executable(raw2tiff ../placeholder.h) -target_sources(raw2tiff PRIVATE raw2tiff.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(raw2tiff PRIVATE tiff tiff_port CMath::CMath) +add_executable(raw2tiff raw2tiff.c) +target_link_libraries(raw2tiff tiff port) -add_executable(rgb2ycbcr ../placeholder.h) -target_sources(rgb2ycbcr PRIVATE rgb2ycbcr.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(rgb2ycbcr PRIVATE tiff tiff_port) +add_executable(rgb2ycbcr rgb2ycbcr.c) +target_link_libraries(rgb2ycbcr tiff port) -add_executable(thumbnail ../placeholder.h) -target_sources(thumbnail PRIVATE thumbnail.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(thumbnail PRIVATE tiff tiff_port CMath::CMath) +add_executable(thumbnail thumbnail.c) +target_link_libraries(thumbnail tiff port) -add_executable(tiff2bw ../placeholder.h) -target_sources(tiff2bw PRIVATE tiff2bw.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiff2bw PRIVATE tiff tiff_port) +add_executable(tiff2bw tiff2bw.c) +target_link_libraries(tiff2bw tiff port) -add_executable(tiff2pdf ../placeholder.h) -target_sources(tiff2pdf PRIVATE tiff2pdf.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiff2pdf PRIVATE tiff tiff_port) +add_executable(tiff2pdf tiff2pdf.c) +target_link_libraries(tiff2pdf tiff port) -add_executable(tiff2ps ../placeholder.h) -target_sources(tiff2ps PRIVATE tiff2ps.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiff2ps PRIVATE tiff tiff_port CMath::CMath) +add_executable(tiff2ps tiff2ps.c) +target_link_libraries(tiff2ps tiff port) -add_executable(tiff2rgba ../placeholder.h) -target_sources(tiff2rgba PRIVATE tiff2rgba.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiff2rgba PRIVATE tiff tiff_port) +add_executable(tiff2rgba tiff2rgba.c) +target_link_libraries(tiff2rgba tiff port) -add_executable(tiffcmp ../placeholder.h) -target_sources(tiffcmp PRIVATE tiffcmp.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiffcmp PRIVATE tiff tiff_port) +add_executable(tiffcmp tiffcmp.c) +target_link_libraries(tiffcmp tiff port) -add_executable(tiffcp ../placeholder.h) -target_sources(tiffcp PRIVATE tiffcp.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiffcp PRIVATE tiff tiff_port) +add_executable(tiffcp tiffcp.c) +target_link_libraries(tiffcp tiff port) -add_executable(tiffcrop ../placeholder.h) -target_sources(tiffcrop PRIVATE tiffcrop.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiffcrop PRIVATE tiff tiff_port CMath::CMath) +add_executable(tiffcrop tiffcrop.c) +target_link_libraries(tiffcrop tiff port) -add_executable(tiffdither ../placeholder.h) -target_sources(tiffdither PRIVATE tiffdither.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiffdither PRIVATE tiff tiff_port) +add_executable(tiffdither tiffdither.c) +target_link_libraries(tiffdither tiff port) -add_executable(tiffdump ../placeholder.h) -target_sources(tiffdump PRIVATE tiffdump.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiffdump PRIVATE tiff tiff_port) +add_executable(tiffdump tiffdump.c) +target_link_libraries(tiffdump tiff port) -add_executable(tiffinfo ../placeholder.h) -target_sources(tiffinfo PRIVATE tiffinfo.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiffinfo PRIVATE tiff tiff_port) +add_executable(tiffinfo tiffinfo.c) +target_link_libraries(tiffinfo tiff port) -add_executable(tiffmedian ../placeholder.h) -target_sources(tiffmedian PRIVATE tiffmedian.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiffmedian PRIVATE tiff tiff_port) +add_executable(tiffmedian tiffmedian.c) +target_link_libraries(tiffmedian tiff port) -add_executable(tiffset ../placeholder.h) -target_sources(tiffset PRIVATE tiffset.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiffset PRIVATE tiff tiff_port) +add_executable(tiffset tiffset.c) +target_link_libraries(tiffset tiff port) -add_executable(tiffsplit ../placeholder.h) -target_sources(tiffsplit PRIVATE tiffsplit.c ${MSVC_RESSOURCE_FILE}) -target_link_libraries(tiffsplit PRIVATE tiff tiff_port) +add_executable(tiffsplit tiffsplit.c) +target_link_libraries(tiffsplit tiff port) -# rgb2ycbcr and thumbnail are intended to *NOT* be installed. They are for -# testing purposes only. install(TARGETS fax2ps fax2tiff pal2rgb @@ -130,16 +107,21 @@ install(TARGETS fax2ps tiffmedian tiffset tiffsplit - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") -if(OPENGL_SUPPORT) - add_executable(tiffgt ../placeholder.h) - target_sources(tiffgt PRIVATE tiffgt.c) - target_link_libraries(tiffgt PRIVATE tiff tiff_port) - target_link_libraries(tiffgt PRIVATE OpenGL::GL GLUT::GLUT) +if(HAVE_OPENGL) + if(OPENGL_INCLUDE_DIR) + include_directories(${OPENGL_INCLUDE_DIR}) + endif() + if(GLUT_INCLUDE_DIR) + include_directories(${GLUT_INCLUDE_DIR}) + endif() + + add_executable(tiffgt tiffgt.c) + target_link_libraries(tiffgt tiff port ${GLUT_LIBRARIES} ${OPENGL_LIBRARIES}) install(TARGETS tiffgt - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") endif() if(WEBP_SUPPORT AND EMSCRIPTEN) diff --git a/thirdparty/SDL2_image/external/libtiff/tools/Makefile.am b/thirdparty/SDL2_image/external/libtiff/tools/Makefile.am index 877ffb26d..3054bee3f 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/Makefile.am +++ b/thirdparty/SDL2_image/external/libtiff/tools/Makefile.am @@ -28,9 +28,8 @@ LIBTIFF = $(top_builddir)/libtiff/libtiff.la EXTRA_DIST = \ CMakeLists.txt \ - tif_tools_versioninfo.rc + Makefile.vc -if TIFF_TOOLS bin_PROGRAMS = \ fax2ps \ fax2tiff \ @@ -53,16 +52,13 @@ bin_PROGRAMS = \ if HAVE_OPENGL bin_PROGRAMS += tiffgt endif -endif EXTRA_PROGRAMS = rgb2ycbcr thumbnail # Executable programs which need to be built in order to support tests -if TIFF_TESTS check_PROGRAMS = \ rgb2ycbcr \ thumbnail -endif if HAVE_RPATH AM_LDFLAGS = $(LIBDIR) @@ -132,7 +128,7 @@ tiffgt_SOURCES = tiffgt.c tiffgt_CFLAGS = $(CFLAGS) $(GLUT_CFLAGS) $(AM_CFLAGS) tiffgt_LDADD = $(LIBTIFF) $(LIBPORT) $(X_LIBS) $(GLUT_LIBS) -AM_CPPFLAGS = -I$(top_srcdir)/libtiff -I$(top_srcdir)/port +AM_CPPFLAGS = -I$(top_srcdir)/libtiff echo: (echo $(CFLAGS)) diff --git a/thirdparty/SDL2_image/external/libtiff/tools/Makefile.lcc b/thirdparty/SDL2_image/external/libtiff/tools/Makefile.lcc new file mode 100644 index 000000000..a51432e50 --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/tools/Makefile.lcc @@ -0,0 +1,132 @@ +# +# TIFF Library Tools +# +# Copyright (c) 1988-1997 Sam Leffler +# Copyright (c) 1991-1997 Silicon Graphics, Inc. +# +# Permission to use, copy, modify, distribute, and sell this software and +# its documentation for any purpose is hereby granted without fee, provided +# that (i) the above copyright notices and this permission notice appear in +# all copies of the software and related documentation, and (ii) the names of +# Sam Leffler and Silicon Graphics may not be used in any advertising or +# publicity relating to the software without the specific, prior written +# permission of Stanford 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. +# +NULL= +IPATH= -I..\libtiff +# +# If you don't want the public domain getopt code, then +# simply null this out and you'll get whatever is in your +# libc (or similar). +# +GETOPT= getopt.o +# +# Library-wide configuration defines: +# Note that if you change the library-wide configuration, you'll +# need to manual force a full rebuild. +# +CONF_LIBRARY=\ + ${NULL} +COPTS= -Oloop -cwagshf -d1 -b0 -v -DNDEBUG -rr -j135i +CFLAGS= ${COPTS} ${IPATH} +# +LIBTIFF=..\libtiff\tiffrnb.lib +LIBS= -l${LIBTIFF} -lm +MACHALL=ras2tiff.ttp +OBJS=\ + fax2tiff.o \ + pal2rgb.o \ + ppm2tiff.o \ + rgb2ycbcr.o \ + tiff2bw.o \ + tiff2rgba.o \ + tiff2ps.o \ + tiffcmp.o \ + tiffcp.o \ + tiffdither.o \ + tiffdump.o \ + tiffinfo.o \ + tiffmedian.o \ + tiffsplit.o \ + raw2tiff.o \ + ${GETOPT} \ + ${NULL} +ALL=\ + fax2tiff.ttp \ + pal2rgb.ttp \ + ppm2tiff.ttp \ + rgb2ycbcr.ttp \ + tiff2bw.ttp \ + tiff2rgba.ttp \ + tiff2ps.ttp \ + tiffcmp.ttp \ + tiffcp.ttp \ + tiffdither.ttp \ + tiffdump.ttp \ + tiffinfo.ttp \ + tiffmedian.ttp \ + tiffsplit.ttp \ + raw2tiff.ttp \ + ${MACHALL} \ + ${NULL} + +all: ${ALL} + +tiffinfo.ttp: tiffinfo.c ${GETOPT} ${LIBTIFF} + ${CC} -o tiffinfo.ttp ${CFLAGS} tiffinfo.c ${GETOPT} ${LIBS} +tiffcmp.ttp: tiffcmp.c ${GETOPT} ${LIBTIFF} + ${CC} -o tiffcmp.ttp ${CFLAGS} tiffcmp.c ${GETOPT} ${LIBS} +tiffcp.ttp: tiffcp.c ${LIBTIFF} + ${CC} -o tiffcp.ttp ${CFLAGS} tiffcp.c ${LIBS} +tiffdump.ttp: tiffdump.c + ${CC} -o tiffdump.ttp ${CFLAGS} tiffdump.c -lm ${LIBS} +tiffmedian.ttp: tiffmedian.c ${LIBTIFF} + ${CC} -o tiffmedian.ttp ${CFLAGS} tiffmedian.c ${LIBS} +tiffsplit.ttp: tiffsplit.c ${LIBTIFF} + ${CC} -o tiffsplit.ttp ${CFLAGS} tiffsplit.c ${LIBS} +tiff2ps.ttp: tiff2ps.c ${LIBTIFF} + ${CC} -o tiff2ps.ttp ${CFLAGS} tiff2ps.c ${LIBS} +# junky stuff... +# convert RGB image to B&W +tiff2bw.ttp: tiff2bw.c ${GETOPT} ${LIBTIFF} + ${CC} -o tiff2bw.ttp ${CFLAGS} tiff2bw.c ${GETOPT} ${LIBS} +# convert anything to RGBA +tiff2rgba.ttp: tiff2rgba.c ${GETOPT} ${LIBTIFF} + ${CC} -o tiff2rgba.ttp ${CFLAGS} tiff2rgba.c ${GETOPT} ${LIBS} +# convert B&W image to bilevel w/ FS dithering +tiffdither.ttp: tiffdither.c ${LIBTIFF} + ${CC} -o tiffdither.ttp ${CFLAGS} tiffdither.c ${LIBS} +# Group 3 FAX file converter +fax2tiff.ttp: fax2tiff.c ${GETOPT} ${LIBTIFF} + ${CC} -o fax2tiff.ttp ${CFLAGS} ${CONF_LIBRARY} fax2tiff.c ${GETOPT} ${LIBS} +# convert Palette image to RGB +pal2rgb.ttp: pal2rgb.c ${LIBTIFF} + ${CC} -o pal2rgb.ttp ${CFLAGS} pal2rgb.c ${LIBS} +# convert RGB image to YCbCr +rgb2ycbcr.ttp: rgb2ycbcr.c ${GETOPT} ${LIBTIFF} + ${CC} -o rgb2ycbcr.ttp ${CFLAGS} rgb2ycbcr.c ${GETOPT} ${LIBS} +# PBM converter +ppm2tiff.ttp: ppm2tiff.c ${LIBTIFF} + ${CC} -o ppm2tiff.ttp ${CFLAGS} ppm2tiff.c ${LIBS} +# convert raw images to TIFFs +raw2tiff.ttp: raw2tiff.c ${LIBTIFF} + ${CC} -o raw2tiff.ttp ${CFLAGS} raw2tiff.c ${LIBS} +# generate thumbnail images from fax +thumbnail: thumbnail.c ${LIBTIFF} + ${CC} -o thumbnail ${CFLAGS} thumbnail.c ${LIBS} -lm + +install: all + +clean: + rm -f ${ALL} ${OBJS} ycbcr.ttp diff --git a/thirdparty/SDL2_image/external/libtiff/cmake/WindowsSupport.cmake b/thirdparty/SDL2_image/external/libtiff/tools/Makefile.vc similarity index 56% rename from thirdparty/SDL2_image/external/libtiff/cmake/WindowsSupport.cmake rename to thirdparty/SDL2_image/external/libtiff/tools/Makefile.vc index a60bba9b7..453db43e9 100644 --- a/thirdparty/SDL2_image/external/libtiff/cmake/WindowsSupport.cmake +++ b/thirdparty/SDL2_image/external/libtiff/tools/Makefile.vc @@ -1,47 +1,51 @@ -# Windows support # -# Copyright © 2015 Open Microscopy Environment / University of Dundee -# Copyright © 2021 Roger Leigh -# Written by Roger Leigh +# Copyright (C) 2004, Andrey Kiselev # -# Permission to use, copy, modify, distribute, and sell this software and +# Permission to use, copy, modify, distribute, and sell this software and # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. -# -# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, -# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY -# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. -# +# +# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. +# # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF -# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF +# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. +# +# Makefile for MS Visual C and Watcom C compilers. +# +# To build: +# C:\libtiff\tools> nmake /f makefile.vc -if(MSVC) - # Debug postfix - set(CMAKE_DEBUG_POSTFIX "d") +!INCLUDE ..\nmake.opt - # disable deprecation warnings - add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE) - # suppress deprecation warning for MSVC POSIX names - add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) +TARGETS = tiffinfo.exe tiffdump.exe fax2tiff.exe \ + fax2ps.exe pal2rgb.exe ppm2tiff.exe \ + rgb2ycbcr.exe thumbnail.exe raw2tiff.exe \ + tiff2bw.exe tiff2rgba.exe tiff2pdf.exe tiff2ps.exe \ + tiffcmp.exe tiffcp.exe tiffcrop.exe tiffdither.exe \ + tiffmedian.exe tiffset.exe tiffsplit.exe - # Don't warn about use of deprecated functions - add_compile_options(/wd4996) -endif() +INCL = -I..\libtiff -I..\port -DNEED_LIBPORT +LIBS = $(LIBS) ..\port\libport.lib ..\libtiff\libtiff.lib -# Win32 file I/O -set(win32_io_default OFF) -if(WIN32) - set(win32_io_default ON) -endif() +default: $(TARGETS) -option(win32-io "Use Win32 I/O" ${win32_io_default}) +.c.exe: + $(CC) $(CFLAGS) $*.c $(EXTRA_OBJ) $(LIBS) -set(USE_WIN32_FILEIO ${win32-io}) +tiffgt.exe: + $(CC) $(CFLAGS) tiffgt.c $(EXTRA_OBJ) $(LIBS) + +clean: + -del *.exe + -del *.exe.manifest + -del *.obj diff --git a/thirdparty/SDL2_image/external/libtiff/tools/fax2ps.c b/thirdparty/SDL2_image/external/libtiff/tools/fax2ps.c index 5f8fe5571..f59f4921b 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/fax2ps.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/fax2ps.c @@ -2,247 +2,238 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" -#include -#include #include +#include #include +#include #include #ifdef HAVE_UNISTD_H -#include +# include #endif #ifdef HAVE_FCNTL_H -#include +# include #endif #ifdef HAVE_IO_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif -#include "tiffio.h" #include "tiffiop.h" +#include "tiffio.h" #ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 +#define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 +#define EXIT_FAILURE 1 #endif -float defxres = 204.; /* default x resolution (pixels/inch) */ -float defyres = 98.; /* default y resolution (lines/inch) */ +float defxres = 204.; /* default x resolution (pixels/inch) */ +float defyres = 98.; /* default y resolution (lines/inch) */ const float half = 0.5; const float points = 72.0; -float pageWidth = 0; /* image page width (inches) */ -float pageHeight = 0; /* image page length (inches) */ -int scaleToPage = 0; /* if true, scale raster to page dimensions */ -int totalPages = 0; /* total # pages printed */ -int row; /* current output row */ -int maxline = 512; /* max output line of PostScript */ +float pageWidth = 0; /* image page width (inches) */ +float pageHeight = 0; /* image page length (inches) */ +int scaleToPage = 0; /* if true, scale raster to page dimensions */ +int totalPages = 0; /* total # pages printed */ +int row; /* current output row */ +int maxline = 512; /* max output line of PostScript */ /* * Turn a bit-mapped scanline into the appropriate sequence * of PostScript characters to be rendered. - * + * * Original version written by Bret D. Whissel, * Florida State University Meteorology Department * March 13-15, 1995. */ -static void printruns(unsigned char *buf, uint32_t *runs, uint32_t *erun, - uint32_t lastx) +static void +printruns(unsigned char* buf, uint32* runs, uint32* erun, uint32 lastx) { - static struct - { - char white, black; - unsigned short width; - } WBarr[] = {{'d', 'n', 512}, {'e', 'o', 256}, {'f', 'p', 128}, - {'g', 'q', 64}, {'h', 'r', 32}, {'i', 's', 16}, - {'j', 't', 8}, {'k', 'u', 4}, {'l', 'v', 2}, - {'m', 'w', 1}}; - static char *svalue = - " !\"#$&'*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abc"; - int colormode = 1; /* 0 for white, 1 for black */ - uint32_t runlength = 0; + static struct { + char white, black; + unsigned short width; + } WBarr[] = { + { 'd', 'n', 512 }, { 'e', 'o', 256 }, { 'f', 'p', 128 }, + { 'g', 'q', 64 }, { 'h', 'r', 32 }, { 'i', 's', 16 }, + { 'j', 't', 8 }, { 'k', 'u', 4 }, { 'l', 'v', 2 }, + { 'm', 'w', 1 } + }; + static char* svalue = + " !\"#$&'*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abc"; + int colormode = 1; /* 0 for white, 1 for black */ + uint32 runlength = 0; int n = maxline; - uint32_t x = 0; + uint32 x = 0; int l; - (void)buf; + (void) buf; printf("%d m(", row++); - while (runs < erun) - { - if (runlength <= 0) - { - colormode ^= 1; - runlength = *runs++; - if (x + runlength > lastx) - runlength = runs[-1] = lastx - x; - x += runlength; - if (!colormode && runs == erun) - break; /* don't bother printing the final white run */ - } - /* - * If a runlength is greater than 6 pixels, then spit out - * black or white characters until the runlength drops to - * 6 or less. Once a runlength is <= 6, then combine black - * and white runlengths until a 6-pixel pattern is obtained. - * Then write out the special character. Six-pixel patterns - * were selected since 64 patterns is the largest power of - * two less than the 92 "easily printable" PostScript - * characters (i.e., no escape codes or octal chars). - */ - l = 0; - while (runlength > 6) - { /* Run is greater than six... */ - if (runlength >= WBarr[l].width) - { - if (n == 0) - { - putchar('\n'); - n = maxline; - } - putchar(colormode ? WBarr[l].black : WBarr[l].white), n--; - runlength -= WBarr[l].width; - } - else - l++; - } - while (runlength > 0 && runlength <= 6) - { - uint32_t bitsleft = 6; - int t = 0; - while (bitsleft) - { - if (runlength <= bitsleft) - { - if (colormode) - t |= ((1 << runlength) - 1) << (bitsleft - runlength); - bitsleft -= runlength; - runlength = 0; - if (bitsleft) - { - if (runs >= erun) - break; - colormode ^= 1; - runlength = *runs++; - if (x + runlength > lastx) - runlength = runs[-1] = lastx - x; - x += runlength; - } - } - else - { /* runlength exceeds bits left */ - if (colormode) - t |= ((1 << bitsleft) - 1); - runlength -= bitsleft; - bitsleft = 0; - } - } - if (n == 0) - { - putchar('\n'); - n = maxline; - } - putchar(svalue[t]), n--; - } + while (runs < erun) { + if (runlength <= 0) { + colormode ^= 1; + runlength = *runs++; + if (x+runlength > lastx) + runlength = runs[-1] = lastx-x; + x += runlength; + if (!colormode && runs == erun) + break; /* don't bother printing the final white run */ + } + /* + * If a runlength is greater than 6 pixels, then spit out + * black or white characters until the runlength drops to + * 6 or less. Once a runlength is <= 6, then combine black + * and white runlengths until a 6-pixel pattern is obtained. + * Then write out the special character. Six-pixel patterns + * were selected since 64 patterns is the largest power of + * two less than the 92 "easily printable" PostScript + * characters (i.e., no escape codes or octal chars). + */ + l = 0; + while (runlength > 6) { /* Run is greater than six... */ + if (runlength >= WBarr[l].width) { + if (n == 0) { + putchar('\n'); + n = maxline; + } + putchar(colormode ? WBarr[l].black : WBarr[l].white), n--; + runlength -= WBarr[l].width; + } else + l++; + } + while (runlength > 0 && runlength <= 6) { + uint32 bitsleft = 6; + int t = 0; + while (bitsleft) { + if (runlength <= bitsleft) { + if (colormode) + t |= ((1 << runlength)-1) << (bitsleft-runlength); + bitsleft -= runlength; + runlength = 0; + if (bitsleft) { + if (runs >= erun) + break; + colormode ^= 1; + runlength = *runs++; + if (x+runlength > lastx) + runlength = runs[-1] = lastx-x; + x += runlength; + } + } else { /* runlength exceeds bits left */ + if (colormode) + t |= ((1 << bitsleft)-1); + runlength -= bitsleft; + bitsleft = 0; + } + } + if (n == 0) { + putchar('\n'); + n = maxline; + } + putchar(svalue[t]), n--; + } } printf(")s\n"); } -/* +/* * Create a special PostScript font for printing FAX documents. By taking - * advantage of the font-cacheing mechanism, a substantial speed-up in - * rendering time is realized. + * advantage of the font-cacheing mechanism, a substantial speed-up in + * rendering time is realized. */ -static void emitFont(FILE *fd) +static void +emitFont(FILE* fd) { - static const char *fontPrologue[] = { - "/newfont 10 dict def newfont begin /FontType 3 def /FontMatrix [1", - "0 0 1 0 0] def /FontBBox [0 0 512 1] def /Encoding 256 array def", - "0 1 31{Encoding exch /255 put}for 120 1 255{Encoding exch /255", - "put}for Encoding 37 /255 put Encoding 40 /255 put Encoding 41 /255", - "put Encoding 92 /255 put /count 0 def /ls{Encoding exch count 3", - "string cvs cvn put /count count 1 add def}def 32 1 36{ls}for", - "38 1 39{ls}for 42 1 91{ls}for 93 1 99{ls}for /count 100", - "def 100 1 119{ls}for /CharDict 5 dict def CharDict begin /white", - "{dup 255 eq{pop}{1 dict begin 100 sub neg 512 exch bitshift", - "/cw exch def cw 0 0 0 cw 1 setcachedevice end}ifelse}def /black", - "{dup 255 eq{pop}{1 dict begin 110 sub neg 512 exch bitshift", - "/cw exch def cw 0 0 0 cw 1 setcachedevice 0 0 moveto cw 0 rlineto", - "0 1 rlineto cw neg 0 rlineto closepath fill end}ifelse}def /numbuild", - "{dup 255 eq{pop}{6 0 0 0 6 1 setcachedevice 0 1 5{0 moveto", - "dup 32 and 32 eq{1 0 rlineto 0 1 rlineto -1 0 rlineto closepath", - "fill newpath}if 1 bitshift}for pop}ifelse}def /.notdef {}", - "def /255 {}def end /BuildChar{exch begin dup 110 ge{Encoding", - "exch get 3 string cvs cvi CharDict /black get}{dup 100 ge {Encoding", - "exch get 3 string cvs cvi CharDict /white get}{Encoding exch get", - "3 string cvs cvi CharDict /numbuild get}ifelse}ifelse exec end", - "}def end /Bitfont newfont definefont 1 scalefont setfont", - NULL}; + static const char* fontPrologue[] = { + "/newfont 10 dict def newfont begin /FontType 3 def /FontMatrix [1", + "0 0 1 0 0] def /FontBBox [0 0 512 1] def /Encoding 256 array def", + "0 1 31{Encoding exch /255 put}for 120 1 255{Encoding exch /255", + "put}for Encoding 37 /255 put Encoding 40 /255 put Encoding 41 /255", + "put Encoding 92 /255 put /count 0 def /ls{Encoding exch count 3", + "string cvs cvn put /count count 1 add def}def 32 1 36{ls}for", + "38 1 39{ls}for 42 1 91{ls}for 93 1 99{ls}for /count 100", + "def 100 1 119{ls}for /CharDict 5 dict def CharDict begin /white", + "{dup 255 eq{pop}{1 dict begin 100 sub neg 512 exch bitshift", + "/cw exch def cw 0 0 0 cw 1 setcachedevice end}ifelse}def /black", + "{dup 255 eq{pop}{1 dict begin 110 sub neg 512 exch bitshift", + "/cw exch def cw 0 0 0 cw 1 setcachedevice 0 0 moveto cw 0 rlineto", + "0 1 rlineto cw neg 0 rlineto closepath fill end}ifelse}def /numbuild", + "{dup 255 eq{pop}{6 0 0 0 6 1 setcachedevice 0 1 5{0 moveto", + "dup 32 and 32 eq{1 0 rlineto 0 1 rlineto -1 0 rlineto closepath", + "fill newpath}if 1 bitshift}for pop}ifelse}def /.notdef {}", + "def /255 {}def end /BuildChar{exch begin dup 110 ge{Encoding", + "exch get 3 string cvs cvi CharDict /black get}{dup 100 ge {Encoding", + "exch get 3 string cvs cvi CharDict /white get}{Encoding exch get", + "3 string cvs cvi CharDict /numbuild get}ifelse}ifelse exec end", + "}def end /Bitfont newfont definefont 1 scalefont setfont", + NULL + }; int i; for (i = 0; fontPrologue[i] != NULL; i++) - fprintf(fd, "%s\n", fontPrologue[i]); + fprintf(fd, "%s\n", fontPrologue[i]); } -void printTIF(TIFF *tif, uint16_t pageNumber) +void +printTIF(TIFF* tif, uint16 pageNumber) { - uint32_t w, h; - uint16_t unit, compression; + uint32 w, h; + uint16 unit, compression; float xres, yres, scale = 1.0; tstrip_t s, ns; time_t creation_time; TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - if (!TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression) || - compression < COMPRESSION_CCITTRLE || - compression > COMPRESSION_CCITT_T6) - return; - if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) || !xres) - { - TIFFWarning(TIFFFileName(tif), "No x-resolution, assuming %g dpi", - defxres); - xres = defxres; + if (!TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression) + || compression < COMPRESSION_CCITTRLE + || compression > COMPRESSION_CCITT_T6) + return; + if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) || !xres) { + TIFFWarning(TIFFFileName(tif), + "No x-resolution, assuming %g dpi", defxres); + xres = defxres; } - if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) || !yres) - { - TIFFWarning(TIFFFileName(tif), "No y-resolution, assuming %g lpi", - defyres); - yres = defyres; /* XXX */ + if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) || !yres) { + TIFFWarning(TIFFFileName(tif), + "No y-resolution, assuming %g lpi", defyres); + yres = defyres; /* XXX */ } if (TIFFGetField(tif, TIFFTAG_RESOLUTIONUNIT, &unit) && - unit == RESUNIT_CENTIMETER) - { - xres *= 2.54F; - yres *= 2.54F; + unit == RESUNIT_CENTIMETER) { + xres *= 2.54F; + yres *= 2.54F; } if (pageWidth == 0) - pageWidth = w / xres; + pageWidth = w / xres; if (pageHeight == 0) - pageHeight = h / yres; + pageHeight = h / yres; printf("%%!PS-Adobe-3.0\n"); printf("%%%%Creator: fax2ps\n"); @@ -252,8 +243,8 @@ void printTIF(TIFF *tif, uint16_t pageNumber) creation_time = time(0); printf("%%%%CreationDate: %s", ctime(&creation_time)); printf("%%%%Origin: 0 0\n"); - printf("%%%%BoundingBox: 0 0 %u %u\n", (int)(pageWidth * points), - (int)(pageHeight * points)); /* XXX */ + printf("%%%%BoundingBox: 0 0 %u %u\n", + (int)(pageWidth * points), (int)(pageHeight * points)); /* XXX */ printf("%%%%Pages: (atend)\n"); printf("%%%%EndComments\n"); printf("%%%%BeginProlog\n"); @@ -261,195 +252,179 @@ void printTIF(TIFF *tif, uint16_t pageNumber) printf("/d{bind def}def\n"); /* bind and def proc */ printf("/m{0 exch moveto}d\n"); printf("/s{show}d\n"); - printf("/p{showpage}d \n"); /* end page */ + printf("/p{showpage}d \n"); /* end page */ printf("%%%%EndProlog\n"); printf("%%%%Page: \"%u\" %u\n", pageNumber, pageNumber); printf("/$pageTop save def gsave\n"); if (scaleToPage) - scale = pageHeight / (h / yres) < pageWidth / (w / xres) - ? pageHeight / (h / yres) - : pageWidth / (w / xres); - printf("%g %g translate\n", points * (pageWidth - scale * w / xres) * half, - points * - (scale * h / yres + (pageHeight - scale * h / yres) * half)); - printf("%g %g scale\n", points / xres * scale, -points / yres * scale); + scale = pageHeight / (h/yres) < pageWidth / (w/xres) ? + pageHeight / (h/yres) : pageWidth / (w/xres); + printf("%g %g translate\n", + points * (pageWidth - scale*w/xres) * half, + points * (scale*h/yres + (pageHeight - scale*h/yres) * half)); + printf("%g %g scale\n", points/xres*scale, -points/yres*scale); printf("0 setgray\n"); TIFFSetField(tif, TIFFTAG_FAXFILLFUNC, printruns); ns = TIFFNumberOfStrips(tif); row = 0; for (s = 0; s < ns; s++) - (void)TIFFReadEncodedStrip(tif, s, (tdata_t)NULL, (tsize_t)-1); + (void) TIFFReadEncodedStrip(tif, s, (tdata_t) NULL, (tsize_t) -1); printf("p\n"); printf("grestore $pageTop restore\n"); totalPages++; } -#define GetPageNumber(tif) TIFFGetField(tif, TIFFTAG_PAGENUMBER, &pn, &ptotal) +#define GetPageNumber(tif) \ +TIFFGetField(tif, TIFFTAG_PAGENUMBER, &pn, &ptotal) -int findPage(TIFF *tif, uint16_t pageNumber) +int +findPage(TIFF* tif, uint16 pageNumber) { - uint16_t pn = (uint16_t)-1; - uint16_t ptotal = (uint16_t)-1; - if (GetPageNumber(tif)) - { - while (pn != (pageNumber - 1) && TIFFReadDirectory(tif) && - GetPageNumber(tif)) - ; - return (pn == (pageNumber - 1)); - } - else - return (TIFFSetDirectory(tif, (tdir_t)(pageNumber - 1))); + uint16 pn = (uint16) -1; + uint16 ptotal = (uint16) -1; + if (GetPageNumber(tif)) { + while (pn != (pageNumber-1) && TIFFReadDirectory(tif) && GetPageNumber(tif)) + ; + return (pn == (pageNumber-1)); + } else + return (TIFFSetDirectory(tif, (tdir_t)(pageNumber-1))); } -void fax2ps(TIFF *tif, uint16_t npages, uint16_t *pages, char *filename) +void +fax2ps(TIFF* tif, uint16 npages, uint16* pages, char* filename) { - if (npages > 0) - { - uint16_t pn, ptotal; - int i; + if (npages > 0) { + uint16 pn, ptotal; + int i; - if (!GetPageNumber(tif)) - fprintf(stderr, "%s: No page numbers, counting directories.\n", - filename); - for (i = 0; i < npages; i++) - { - if (findPage(tif, pages[i])) - printTIF(tif, pages[i]); - else - fprintf(stderr, "%s: No page number %d\n", filename, pages[i]); - } - } - else - { - uint16_t pageNumber = 0; - do - printTIF(tif, pageNumber++); - while (TIFFReadDirectory(tif)); + if (!GetPageNumber(tif)) + fprintf(stderr, "%s: No page numbers, counting directories.\n", + filename); + for (i = 0; i < npages; i++) { + if (findPage(tif, pages[i])) + printTIF(tif, pages[i]); + else + fprintf(stderr, "%s: No page number %d\n", filename, pages[i]); + } + } else { + uint16 pageNumber = 0; + do + printTIF(tif, pageNumber++); + while (TIFFReadDirectory(tif)); } } #undef GetPageNumber -static int pcompar(const void *va, const void *vb) +static int +pcompar(const void* va, const void* vb) { - const uint16_t *pa = (const uint16_t *)va; - const uint16_t *pb = (const uint16_t *)vb; - return ((int32_t)*pa - (int32_t)*pb); + const int* pa = (const int*) va; + const int* pb = (const int*) vb; + return (*pa - *pb); } -static void usage(int code); +static void usage(int code); -int main(int argc, char **argv) +int +main(int argc, char** argv) { #if !HAVE_DECL_OPTARG extern int optind; - extern char *optarg; + extern char* optarg; #endif - uint16_t *pages = NULL, npages = 0, pageNumber; - int c, dowarnings = 0; /* if 1, enable library warnings */ - TIFF *tif; + uint16 *pages = NULL, npages = 0, pageNumber; + int c, dowarnings = 0; /* if 1, enable library warnings */ + TIFF* tif; while ((c = getopt(argc, argv, "l:p:x:y:W:H:wSh")) != -1) - switch (c) - { - case 'H': /* page height */ - pageHeight = (float)atof(optarg); - break; - case 'S': /* scale to page */ - scaleToPage = 1; - break; - case 'W': /* page width */ - pageWidth = (float)atof(optarg); - break; - case 'p': /* print specific page */ - pageNumber = (uint16_t)atoi(optarg); - if (pages) - pages = (uint16_t *)realloc(pages, (npages + 1) * - sizeof(uint16_t)); - else - pages = (uint16_t *)malloc(sizeof(uint16_t)); - if (pages == NULL) - { - fprintf(stderr, "Out of memory\n"); - exit(EXIT_FAILURE); - } - pages[npages++] = pageNumber; - break; - case 'w': - dowarnings = 1; - break; - case 'x': - defxres = (float)atof(optarg); - break; - case 'y': - defyres = (float)atof(optarg); - break; - case 'l': - maxline = atoi(optarg); - break; - case 'h': - usage(EXIT_SUCCESS); - break; - case '?': - usage(EXIT_FAILURE); - } + switch (c) { + case 'H': /* page height */ + pageHeight = (float)atof(optarg); + break; + case 'S': /* scale to page */ + scaleToPage = 1; + break; + case 'W': /* page width */ + pageWidth = (float)atof(optarg); + break; + case 'p': /* print specific page */ + pageNumber = (uint16)atoi(optarg); + if (pages) + pages = (uint16*) realloc(pages, (npages+1)*sizeof(uint16)); + else + pages = (uint16*) malloc(sizeof(uint16)); + if( pages == NULL ) + { + fprintf(stderr, "Out of memory\n"); + exit(EXIT_FAILURE); + } + pages[npages++] = pageNumber; + break; + case 'w': + dowarnings = 1; + break; + case 'x': + defxres = (float)atof(optarg); + break; + case 'y': + defyres = (float)atof(optarg); + break; + case 'l': + maxline = atoi(optarg); + break; + case 'h': + usage(EXIT_SUCCESS); + case '?': + usage(EXIT_FAILURE); + } if (npages > 0) - qsort(pages, npages, sizeof(uint16_t), pcompar); + qsort(pages, npages, sizeof(uint16), pcompar); if (!dowarnings) - TIFFSetWarningHandler(0); - if (optind < argc) - { - do - { - tif = TIFFOpen(argv[optind], "r"); - if (tif) - { - fax2ps(tif, npages, pages, argv[optind]); - TIFFClose(tif); - } - else - fprintf(stderr, "%s: Can not open, or not a TIFF file.\n", - argv[optind]); - } while (++optind < argc); - } - else - { - int n; - FILE *fd; - char buf[16 * 1024]; + TIFFSetWarningHandler(0); + if (optind < argc) { + do { + tif = TIFFOpen(argv[optind], "r"); + if (tif) { + fax2ps(tif, npages, pages, argv[optind]); + TIFFClose(tif); + } else + fprintf(stderr, "%s: Can not open, or not a TIFF file.\n", + argv[optind]); + } while (++optind < argc); + } else { + int n; + FILE* fd; + char buf[16*1024]; - fd = tmpfile(); - if (fd == NULL) - { - fprintf(stderr, "Could not obtain temporary file.\n"); - exit(EXIT_FAILURE); - } + fd = tmpfile(); + if (fd == NULL) { + fprintf(stderr, "Could not obtain temporary file.\n"); + exit(EXIT_FAILURE); + } #if defined(HAVE_SETMODE) && defined(O_BINARY) - setmode(fileno(stdin), O_BINARY); + setmode(fileno(stdin), O_BINARY); #endif - while ((n = read(fileno(stdin), buf, sizeof(buf))) > 0) - { - if (write(fileno(fd), buf, n) != n) - { - fclose(fd); - fprintf(stderr, "Could not copy stdin to temporary file.\n"); - exit(EXIT_FAILURE); - } + while ((n = read(fileno(stdin), buf, sizeof (buf))) > 0) { + if (write(fileno(fd), buf, n) != n) { + fclose(fd); + fprintf(stderr, + "Could not copy stdin to temporary file.\n"); + exit(EXIT_FAILURE); + } } - _TIFF_lseek_f(fileno(fd), 0, SEEK_SET); + _TIFF_lseek_f(fileno(fd), 0, SEEK_SET); #if defined(_WIN32) && defined(USE_WIN32_FILEIO) - tif = TIFFFdOpen(_get_osfhandle(fileno(fd)), "temp", "r"); + tif = TIFFFdOpen(_get_osfhandle(fileno(fd)), "temp", "r"); #else - tif = TIFFFdOpen(fileno(fd), "temp", "r"); + tif = TIFFFdOpen(fileno(fd), "temp", "r"); #endif - if (tif) - { - fax2ps(tif, npages, pages, ""); - TIFFClose(tif); - } - else - fprintf(stderr, "Can not open, or not a TIFF file.\n"); - fclose(fd); + if (tif) { + fax2ps(tif, npages, pages, ""); + TIFFClose(tif); + } else + fprintf(stderr, "Can not open, or not a TIFF file.\n"); + fclose(fd); } printf("%%%%Trailer\n"); printf("%%%%Pages: %u\n", totalPages); @@ -458,24 +433,37 @@ int main(int argc, char **argv) return (EXIT_SUCCESS); } -static const char usage_info[] = - "Convert a TIFF facsimile to compressed PostScript\n\n" - "usage: fax2ps [options] [input.tif ...]\n" - "where options are:\n" - " -w suppress warning messages\n" - " -l chars set maximum output line length for generated PostScript\n" - " -p page# select page to print (can use multiple times)\n" - " -x xres set default horizontal resolution of input data (dpi)\n" - " -y yres set default vertical resolution of input data (lpi)\n" - " -S scale output to page size\n" - " -W width set output page width (inches), default is 8.5\n" - " -H height set output page height (inches), default is 11\n"; +const char* stuff[] = { +"usage: fax2ps [options] [input.tif ...]", +"where options are:", +" -w suppress warning messages", +" -l chars set maximum output line length for generated PostScript", +" -p page# select page to print (can use multiple times)", +" -x xres set default horizontal resolution of input data (dpi)", +" -y yres set default vertical resolution of input data (lpi)", +" -S scale output to page size", +" -W width set output page width (inches), default is 8.5", +" -H height set output page height (inches), default is 11", +NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/fax2tiff.c b/thirdparty/SDL2_image/external/libtiff/tools/fax2tiff.c index 27c88c345..eecb41e33 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/fax2tiff.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/fax2tiff.c @@ -2,71 +2,73 @@ * Copyright (c) 1990-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -/* +/* * Convert a CCITT Group 3 or 4 FAX file to TIFF Group 3 or 4 format. */ -#include "libport.h" #include "tif_config.h" #include -#include /* should have atof & getopt */ +#include /* should have atof & getopt */ #ifdef HAVE_UNISTD_H -#include +# include #endif #ifdef HAVE_FCNTL_H -#include +# include #endif #ifdef HAVE_IO_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffiop.h" #ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 +# define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 +# define EXIT_FAILURE 1 #endif -#define TIFFhowmany8(x) \ - (((x)&0x07) ? ((uint32_t)(x) >> 3) + 1 : (uint32_t)(x) >> 3) +#define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) -TIFF *faxTIFF; -char *rowbuf; -char *refbuf; +TIFF *faxTIFF; +char *rowbuf; +char *refbuf; -uint32_t xsize = 1728; -int verbose; -int stretch; -uint16_t badfaxrun; -uint32_t badfaxlines; +uint32 xsize = 1728; +int verbose; +int stretch; +uint16 badfaxrun; +uint32 badfaxlines; -int copyFaxFile(TIFF *tifin, TIFF *tifout); -static void usage(int code); +int copyFaxFile(TIFF* tifin, TIFF* tifout); +static void usage(int code); /* Struct to carry client data. Note that it does not appear that the client @@ -74,420 +76,411 @@ static void usage(int code); */ typedef union _FAX_Client_Data { - thandle_t fh; /* Operating system file handle */ - int fd; /* Integer file descriptor */ + thandle_t fh; /* Operating system file handle */ + int fd; /* Integer file descriptor */ } FAX_Client_Data; -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - FILE *in; - TIFF *out = NULL; - FAX_Client_Data client_data; - TIFFErrorHandler whandler = NULL; - int compression_in = COMPRESSION_CCITTFAX3; - int compression_out = COMPRESSION_CCITTFAX3; - int fillorder_in = FILLORDER_LSB2MSB; - int fillorder_out = FILLORDER_LSB2MSB; - uint32_t group3options_in = 0; /* 1d-encoded */ - uint32_t group3options_out = 0; /* 1d-encoded */ - uint32_t group4options_in = 0; /* compressed */ - uint32_t group4options_out = 0; /* compressed */ - uint32_t defrowsperstrip = (uint32_t)0; - uint32_t rowsperstrip; - int photometric_in = PHOTOMETRIC_MINISWHITE; - int photometric_out = PHOTOMETRIC_MINISWHITE; - int mode = FAXMODE_CLASSF; - int rows; - int c; - int pn, npages; - float resY = 196.0; + FILE *in; + TIFF *out = NULL; + FAX_Client_Data client_data; + TIFFErrorHandler whandler = NULL; + int compression_in = COMPRESSION_CCITTFAX3; + int compression_out = COMPRESSION_CCITTFAX3; + int fillorder_in = FILLORDER_LSB2MSB; + int fillorder_out = FILLORDER_LSB2MSB; + uint32 group3options_in = 0; /* 1d-encoded */ + uint32 group3options_out = 0; /* 1d-encoded */ + uint32 group4options_in = 0; /* compressed */ + uint32 group4options_out = 0; /* compressed */ + uint32 defrowsperstrip = (uint32) 0; + uint32 rowsperstrip; + int photometric_in = PHOTOMETRIC_MINISWHITE; + int photometric_out = PHOTOMETRIC_MINISWHITE; + int mode = FAXMODE_CLASSF; + int rows; + int c; + int pn, npages; + float resY = 196.0; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - while ((c = getopt(argc, argv, "R:X:o:r:1234ABLMPUW5678abcflmprsuvwzh")) != - -1) - switch (c) - { - /* input-related options */ - case '3': /* input is g3-encoded */ - compression_in = COMPRESSION_CCITTFAX3; - break; - case '4': /* input is g4-encoded */ - compression_in = COMPRESSION_CCITTFAX4; - break; - case 'U': /* input is uncompressed (g3 and g4) */ - group3options_in |= GROUP3OPT_UNCOMPRESSED; - group4options_in |= GROUP4OPT_UNCOMPRESSED; - break; - case '1': /* input is 1d-encoded (g3 only) */ - group3options_in &= ~GROUP3OPT_2DENCODING; - break; - case '2': /* input is 2d-encoded (g3 only) */ - group3options_in |= GROUP3OPT_2DENCODING; - break; - case 'P': /* input has not-aligned EOL (g3 only) */ - group3options_in &= ~GROUP3OPT_FILLBITS; - break; - case 'A': /* input has aligned EOL (g3 only) */ - group3options_in |= GROUP3OPT_FILLBITS; - break; - case 'W': /* input has 0 mean white */ - photometric_in = PHOTOMETRIC_MINISWHITE; - break; - case 'B': /* input has 0 mean black */ - photometric_in = PHOTOMETRIC_MINISBLACK; - break; - case 'L': /* input has lsb-to-msb fillorder */ - fillorder_in = FILLORDER_LSB2MSB; - break; - case 'M': /* input has msb-to-lsb fillorder */ - fillorder_in = FILLORDER_MSB2LSB; - break; - case 'R': /* input resolution */ - resY = (float)atof(optarg); - break; - case 'X': /* input width */ - xsize = (uint32_t)atoi(optarg); - break; + while ((c = getopt(argc, argv, "R:X:o:r:1234ABLMPUW5678abcflmprsuvwzh")) != -1) + switch (c) { + /* input-related options */ + case '3': /* input is g3-encoded */ + compression_in = COMPRESSION_CCITTFAX3; + break; + case '4': /* input is g4-encoded */ + compression_in = COMPRESSION_CCITTFAX4; + break; + case 'U': /* input is uncompressed (g3 and g4) */ + group3options_in |= GROUP3OPT_UNCOMPRESSED; + group4options_in |= GROUP4OPT_UNCOMPRESSED; + break; + case '1': /* input is 1d-encoded (g3 only) */ + group3options_in &= ~GROUP3OPT_2DENCODING; + break; + case '2': /* input is 2d-encoded (g3 only) */ + group3options_in |= GROUP3OPT_2DENCODING; + break; + case 'P': /* input has not-aligned EOL (g3 only) */ + group3options_in &= ~GROUP3OPT_FILLBITS; + break; + case 'A': /* input has aligned EOL (g3 only) */ + group3options_in |= GROUP3OPT_FILLBITS; + break; + case 'W': /* input has 0 mean white */ + photometric_in = PHOTOMETRIC_MINISWHITE; + break; + case 'B': /* input has 0 mean black */ + photometric_in = PHOTOMETRIC_MINISBLACK; + break; + case 'L': /* input has lsb-to-msb fillorder */ + fillorder_in = FILLORDER_LSB2MSB; + break; + case 'M': /* input has msb-to-lsb fillorder */ + fillorder_in = FILLORDER_MSB2LSB; + break; + case 'R': /* input resolution */ + resY = (float) atof(optarg); + break; + case 'X': /* input width */ + xsize = (uint32) atoi(optarg); + break; - /* output-related options */ - case '7': /* generate g3-encoded output */ - compression_out = COMPRESSION_CCITTFAX3; - break; - case '8': /* generate g4-encoded output */ - compression_out = COMPRESSION_CCITTFAX4; - break; - case 'u': /* generate uncompressed output (g3 and g4) */ - group3options_out |= GROUP3OPT_UNCOMPRESSED; - group4options_out |= GROUP4OPT_UNCOMPRESSED; - break; - case '5': /* generate 1d-encoded output (g3 only) */ - group3options_out &= ~GROUP3OPT_2DENCODING; - break; - case '6': /* generate 2d-encoded output (g3 only) */ - group3options_out |= GROUP3OPT_2DENCODING; - break; - case 'c': /* generate "classic" g3 format */ - mode = FAXMODE_CLASSIC; - break; - case 'f': /* generate Class F format */ - mode = FAXMODE_CLASSF; - break; - case 'm': /* output's fillorder is msb-to-lsb */ - fillorder_out = FILLORDER_MSB2LSB; - break; - case 'l': /* output's fillorder is lsb-to-msb */ - fillorder_out = FILLORDER_LSB2MSB; - break; - case 'o': - out = TIFFOpen(optarg, "w"); - if (out == NULL) - { - fprintf(stderr, "%s: Can not create or open %s\n", argv[0], - optarg); - return EXIT_FAILURE; - } - break; - case 'a': /* generate EOL-aligned output (g3 only) */ - group3options_out |= GROUP3OPT_FILLBITS; - break; - case 'p': /* generate not EOL-aligned output (g3 only) */ - group3options_out &= ~GROUP3OPT_FILLBITS; - break; - case 'r': /* rows/strip */ - defrowsperstrip = atol(optarg); - break; - case 's': /* stretch image by dup'ng scanlines */ - stretch = 1; - break; - case 'w': /* undocumented -- for testing */ - photometric_out = PHOTOMETRIC_MINISWHITE; - break; - case 'b': /* undocumented -- for testing */ - photometric_out = PHOTOMETRIC_MINISBLACK; - break; - case 'z': /* undocumented -- for testing */ - compression_out = COMPRESSION_LZW; - break; - case 'v': /* -v for info */ - verbose++; - break; - case 'h': - usage(EXIT_SUCCESS); - break; - case '?': - usage(EXIT_FAILURE); - /*NOTREACHED*/ - } - npages = argc - optind; - if (npages < 1) - usage(EXIT_FAILURE); + /* output-related options */ + case '7': /* generate g3-encoded output */ + compression_out = COMPRESSION_CCITTFAX3; + break; + case '8': /* generate g4-encoded output */ + compression_out = COMPRESSION_CCITTFAX4; + break; + case 'u': /* generate uncompressed output (g3 and g4) */ + group3options_out |= GROUP3OPT_UNCOMPRESSED; + group4options_out |= GROUP4OPT_UNCOMPRESSED; + break; + case '5': /* generate 1d-encoded output (g3 only) */ + group3options_out &= ~GROUP3OPT_2DENCODING; + break; + case '6': /* generate 2d-encoded output (g3 only) */ + group3options_out |= GROUP3OPT_2DENCODING; + break; + case 'c': /* generate "classic" g3 format */ + mode = FAXMODE_CLASSIC; + break; + case 'f': /* generate Class F format */ + mode = FAXMODE_CLASSF; + break; + case 'm': /* output's fillorder is msb-to-lsb */ + fillorder_out = FILLORDER_MSB2LSB; + break; + case 'l': /* output's fillorder is lsb-to-msb */ + fillorder_out = FILLORDER_LSB2MSB; + break; + case 'o': + out = TIFFOpen(optarg, "w"); + if (out == NULL) { + fprintf(stderr, + "%s: Can not create or open %s\n", + argv[0], optarg); + return EXIT_FAILURE; + } + break; + case 'a': /* generate EOL-aligned output (g3 only) */ + group3options_out |= GROUP3OPT_FILLBITS; + break; + case 'p': /* generate not EOL-aligned output (g3 only) */ + group3options_out &= ~GROUP3OPT_FILLBITS; + break; + case 'r': /* rows/strip */ + defrowsperstrip = atol(optarg); + break; + case 's': /* stretch image by dup'ng scanlines */ + stretch = 1; + break; + case 'w': /* undocumented -- for testing */ + photometric_out = PHOTOMETRIC_MINISWHITE; + break; + case 'b': /* undocumented -- for testing */ + photometric_out = PHOTOMETRIC_MINISBLACK; + break; + case 'z': /* undocumented -- for testing */ + compression_out = COMPRESSION_LZW; + break; + case 'v': /* -v for info */ + verbose++; + break; + case 'h': + usage(EXIT_SUCCESS); + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } + npages = argc - optind; + if (npages < 1) + usage(EXIT_FAILURE); - rowbuf = _TIFFmalloc(TIFFhowmany8(xsize)); - refbuf = _TIFFmalloc(TIFFhowmany8(xsize)); - if (rowbuf == NULL || refbuf == NULL) - { - fprintf(stderr, "%s: Not enough memory\n", argv[0]); - return (EXIT_FAILURE); - } + rowbuf = _TIFFmalloc(TIFFhowmany8(xsize)); + refbuf = _TIFFmalloc(TIFFhowmany8(xsize)); + if (rowbuf == NULL || refbuf == NULL) { + fprintf(stderr, "%s: Not enough memory\n", argv[0]); + return (EXIT_FAILURE); + } - if (out == NULL) - { - out = TIFFOpen("fax.tif", "w"); - if (out == NULL) - { - fprintf(stderr, "%s: Can not create fax.tif\n", argv[0]); - return (EXIT_FAILURE); - } - } - - faxTIFF = TIFFClientOpen( - "(FakeInput)", "w", - /* TIFFClientOpen() fails if we don't set existing value here */ - TIFFClientdata(out), TIFFGetReadProc(out), TIFFGetWriteProc(out), - TIFFGetSeekProc(out), TIFFGetCloseProc(out), TIFFGetSizeProc(out), - TIFFGetMapFileProc(out), TIFFGetUnmapFileProc(out)); - if (faxTIFF == NULL) - { - fprintf(stderr, "%s: Can not create fake input file\n", argv[0]); - return (EXIT_FAILURE); - } - TIFFSetMode(faxTIFF, O_RDONLY); - TIFFSetField(faxTIFF, TIFFTAG_IMAGEWIDTH, xsize); - TIFFSetField(faxTIFF, TIFFTAG_SAMPLESPERPIXEL, 1); - TIFFSetField(faxTIFF, TIFFTAG_BITSPERSAMPLE, 1); - TIFFSetField(faxTIFF, TIFFTAG_FILLORDER, fillorder_in); - TIFFSetField(faxTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(faxTIFF, TIFFTAG_PHOTOMETRIC, photometric_in); - TIFFSetField(faxTIFF, TIFFTAG_YRESOLUTION, resY); - TIFFSetField(faxTIFF, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - - /* NB: this must be done after directory info is setup */ - TIFFSetField(faxTIFF, TIFFTAG_COMPRESSION, compression_in); - if (compression_in == COMPRESSION_CCITTFAX3) - TIFFSetField(faxTIFF, TIFFTAG_GROUP3OPTIONS, group3options_in); - else if (compression_in == COMPRESSION_CCITTFAX4) - TIFFSetField(faxTIFF, TIFFTAG_GROUP4OPTIONS, group4options_in); - for (pn = 0; optind < argc; pn++, optind++) - { - in = fopen(argv[optind], "rb"); - if (in == NULL) - { - fprintf(stderr, "%s: %s: Can not open\n", argv[0], argv[optind]); - continue; - } + if (out == NULL) { + out = TIFFOpen("fax.tif", "w"); + if (out == NULL) { + fprintf(stderr, "%s: Can not create fax.tif\n", + argv[0]); + return (EXIT_FAILURE); + } + } + + faxTIFF = TIFFClientOpen("(FakeInput)", "w", + /* TIFFClientOpen() fails if we don't set existing value here */ + TIFFClientdata(out), + TIFFGetReadProc(out), TIFFGetWriteProc(out), + TIFFGetSeekProc(out), TIFFGetCloseProc(out), + TIFFGetSizeProc(out), TIFFGetMapFileProc(out), + TIFFGetUnmapFileProc(out)); + if (faxTIFF == NULL) { + fprintf(stderr, "%s: Can not create fake input file\n", + argv[0]); + return (EXIT_FAILURE); + } + TIFFSetMode(faxTIFF, O_RDONLY); + TIFFSetField(faxTIFF, TIFFTAG_IMAGEWIDTH, xsize); + TIFFSetField(faxTIFF, TIFFTAG_SAMPLESPERPIXEL, 1); + TIFFSetField(faxTIFF, TIFFTAG_BITSPERSAMPLE, 1); + TIFFSetField(faxTIFF, TIFFTAG_FILLORDER, fillorder_in); + TIFFSetField(faxTIFF, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(faxTIFF, TIFFTAG_PHOTOMETRIC, photometric_in); + TIFFSetField(faxTIFF, TIFFTAG_YRESOLUTION, resY); + TIFFSetField(faxTIFF, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); + + /* NB: this must be done after directory info is setup */ + TIFFSetField(faxTIFF, TIFFTAG_COMPRESSION, compression_in); + if (compression_in == COMPRESSION_CCITTFAX3) + TIFFSetField(faxTIFF, TIFFTAG_GROUP3OPTIONS, group3options_in); + else if (compression_in == COMPRESSION_CCITTFAX4) + TIFFSetField(faxTIFF, TIFFTAG_GROUP4OPTIONS, group4options_in); + for (pn = 0; optind < argc; pn++, optind++) { + in = fopen(argv[optind], "rb"); + if (in == NULL) { + fprintf(stderr, + "%s: %s: Can not open\n", argv[0], argv[optind]); + continue; + } #if defined(_WIN32) && defined(USE_WIN32_FILEIO) - client_data.fh = (thandle_t)_get_osfhandle(fileno(in)); + client_data.fh = (thandle_t)_get_osfhandle(fileno(in)); #else - client_data.fd = fileno(in); + client_data.fd = fileno(in); #endif - TIFFSetClientdata(faxTIFF, client_data.fh); - TIFFSetFileName(faxTIFF, (const char *)argv[optind]); - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1); - TIFFSetField(out, TIFFTAG_COMPRESSION, compression_out); - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric_out); - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); - switch (compression_out) - { - /* g3 */ - case COMPRESSION_CCITTFAX3: - TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, group3options_out); - TIFFSetField(out, TIFFTAG_FAXMODE, mode); - rowsperstrip = - (defrowsperstrip) ? defrowsperstrip : (uint32_t)-1L; - break; + TIFFSetClientdata(faxTIFF, client_data.fh); + TIFFSetFileName(faxTIFF, (const char*)argv[optind]); + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, xsize); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1); + TIFFSetField(out, TIFFTAG_COMPRESSION, compression_out); + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric_out); + TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); + switch (compression_out) { + /* g3 */ + case COMPRESSION_CCITTFAX3: + TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, + group3options_out); + TIFFSetField(out, TIFFTAG_FAXMODE, mode); + rowsperstrip = + (defrowsperstrip)?defrowsperstrip:(uint32)-1L; + break; - /* g4 */ - case COMPRESSION_CCITTFAX4: - TIFFSetField(out, TIFFTAG_GROUP4OPTIONS, group4options_out); - TIFFSetField(out, TIFFTAG_FAXMODE, mode); - rowsperstrip = - (defrowsperstrip) ? defrowsperstrip : (uint32_t)-1L; - break; + /* g4 */ + case COMPRESSION_CCITTFAX4: + TIFFSetField(out, TIFFTAG_GROUP4OPTIONS, + group4options_out); + TIFFSetField(out, TIFFTAG_FAXMODE, mode); + rowsperstrip = + (defrowsperstrip)?defrowsperstrip:(uint32)-1L; + break; - default: - rowsperstrip = (defrowsperstrip) ? defrowsperstrip - : TIFFDefaultStripSize(out, 0); - } - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(out, TIFFTAG_FILLORDER, fillorder_out); - TIFFSetField(out, TIFFTAG_SOFTWARE, "fax2tiff"); - TIFFSetField(out, TIFFTAG_XRESOLUTION, 204.0); - if (!stretch) - { - TIFFGetField(faxTIFF, TIFFTAG_YRESOLUTION, &resY); - TIFFSetField(out, TIFFTAG_YRESOLUTION, resY); - } - else - TIFFSetField(out, TIFFTAG_YRESOLUTION, 196.); - TIFFSetField(out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - TIFFSetField(out, TIFFTAG_PAGENUMBER, pn, npages); + default: + rowsperstrip = (defrowsperstrip) ? + defrowsperstrip : TIFFDefaultStripSize(out, 0); + } + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(out, TIFFTAG_FILLORDER, fillorder_out); + TIFFSetField(out, TIFFTAG_SOFTWARE, "fax2tiff"); + TIFFSetField(out, TIFFTAG_XRESOLUTION, 204.0); + if (!stretch) { + TIFFGetField(faxTIFF, TIFFTAG_YRESOLUTION, &resY); + TIFFSetField(out, TIFFTAG_YRESOLUTION, resY); + } else + TIFFSetField(out, TIFFTAG_YRESOLUTION, 196.); + TIFFSetField(out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); + TIFFSetField(out, TIFFTAG_PAGENUMBER, pn, npages); - if (!verbose) - whandler = TIFFSetWarningHandler(NULL); - rows = copyFaxFile(faxTIFF, out); - fclose(in); - if (!verbose) - (void)TIFFSetWarningHandler(whandler); + if (!verbose) + whandler = TIFFSetWarningHandler(NULL); + rows = copyFaxFile(faxTIFF, out); + fclose(in); + if (!verbose) + (void) TIFFSetWarningHandler(whandler); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, rows); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, rows); - if (verbose) - { - fprintf(stderr, "%s:\n", argv[optind]); - fprintf(stderr, "%d rows in input\n", rows); - fprintf(stderr, "%" PRIu32 " total bad rows\n", badfaxlines); - fprintf(stderr, "%" PRIu16 " max consecutive bad rows\n", - badfaxrun); - } - if (compression_out == COMPRESSION_CCITTFAX3 && mode == FAXMODE_CLASSF) - { - TIFFSetField(out, TIFFTAG_BADFAXLINES, badfaxlines); - TIFFSetField(out, TIFFTAG_CLEANFAXDATA, - badfaxlines ? CLEANFAXDATA_REGENERATED - : CLEANFAXDATA_CLEAN); - TIFFSetField(out, TIFFTAG_CONSECUTIVEBADFAXLINES, badfaxrun); - } - TIFFWriteDirectory(out); - } - TIFFClose(out); - _TIFFfree(rowbuf); - _TIFFfree(refbuf); - return (EXIT_SUCCESS); + if (verbose) { + fprintf(stderr, "%s:\n", argv[optind]); + fprintf(stderr, "%d rows in input\n", rows); + fprintf(stderr, "%ld total bad rows\n", + (long) badfaxlines); + fprintf(stderr, "%d max consecutive bad rows\n", badfaxrun); + } + if (compression_out == COMPRESSION_CCITTFAX3 && + mode == FAXMODE_CLASSF) { + TIFFSetField(out, TIFFTAG_BADFAXLINES, badfaxlines); + TIFFSetField(out, TIFFTAG_CLEANFAXDATA, badfaxlines ? + CLEANFAXDATA_REGENERATED : CLEANFAXDATA_CLEAN); + TIFFSetField(out, TIFFTAG_CONSECUTIVEBADFAXLINES, badfaxrun); + } + TIFFWriteDirectory(out); + } + TIFFClose(out); + _TIFFfree(rowbuf); + _TIFFfree(refbuf); + return (EXIT_SUCCESS); } -int copyFaxFile(TIFF *tifin, TIFF *tifout) +int +copyFaxFile(TIFF* tifin, TIFF* tifout) { - uint32_t row; - uint32_t linesize = TIFFhowmany8(xsize); - uint16_t badrun; - int ok; + uint32 row; + uint32 linesize = TIFFhowmany8(xsize); + uint16 badrun; + int ok; - tifin->tif_rawdatasize = (tmsize_t)TIFFGetFileSize(tifin); - if (tifin->tif_rawdatasize == 0) - { - TIFFError(tifin->tif_name, "Empty input file"); - return (0); - } - tifin->tif_rawdata = _TIFFmalloc(tifin->tif_rawdatasize); - if (tifin->tif_rawdata == NULL) - { - TIFFError(tifin->tif_name, "Not enough memory"); - return (0); - } - if (!ReadOK(tifin, tifin->tif_rawdata, tifin->tif_rawdatasize)) - { - TIFFError(tifin->tif_name, "Read error at scanline 0"); - return (0); - } - tifin->tif_rawcp = tifin->tif_rawdata; - tifin->tif_rawcc = tifin->tif_rawdatasize; + tifin->tif_rawdatasize = (tmsize_t)TIFFGetFileSize(tifin); + if (tifin->tif_rawdatasize == 0) { + TIFFError(tifin->tif_name, "Empty input file"); + return (0); + } + tifin->tif_rawdata = _TIFFmalloc(tifin->tif_rawdatasize); + if (tifin->tif_rawdata == NULL) { + TIFFError(tifin->tif_name, "Not enough memory"); + return (0); + } + if (!ReadOK(tifin, tifin->tif_rawdata, tifin->tif_rawdatasize)) { + TIFFError(tifin->tif_name, "Read error at scanline 0"); + return (0); + } + tifin->tif_rawcp = tifin->tif_rawdata; + tifin->tif_rawcc = tifin->tif_rawdatasize; - (*tifin->tif_setupdecode)(tifin); - (*tifin->tif_predecode)(tifin, (tsample_t)0); - tifin->tif_row = 0; - badfaxlines = 0; - badfaxrun = 0; + (*tifin->tif_setupdecode)(tifin); + (*tifin->tif_predecode)(tifin, (tsample_t) 0); + tifin->tif_row = 0; + badfaxlines = 0; + badfaxrun = 0; - _TIFFmemset(refbuf, 0, linesize); - row = 0; - badrun = 0; /* current run of bad lines */ - while (tifin->tif_rawcc > 0) - { - ok = (*tifin->tif_decoderow)(tifin, (tdata_t)rowbuf, linesize, 0); - if (!ok) - { - badfaxlines++; - badrun++; - /* regenerate line from previous good line */ - _TIFFmemcpy(rowbuf, refbuf, linesize); - } - else - { - if (badrun > badfaxrun) - badfaxrun = badrun; - badrun = 0; - _TIFFmemcpy(refbuf, rowbuf, linesize); - } - tifin->tif_row++; + _TIFFmemset(refbuf, 0, linesize); + row = 0; + badrun = 0; /* current run of bad lines */ + while (tifin->tif_rawcc > 0) { + ok = (*tifin->tif_decoderow)(tifin, (tdata_t) rowbuf, + linesize, 0); + if (!ok) { + badfaxlines++; + badrun++; + /* regenerate line from previous good line */ + _TIFFmemcpy(rowbuf, refbuf, linesize); + } else { + if (badrun > badfaxrun) + badfaxrun = badrun; + badrun = 0; + _TIFFmemcpy(refbuf, rowbuf, linesize); + } + tifin->tif_row++; - if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) - { - fprintf(stderr, "%s: Write error at row %" PRIu32 ".\n", - tifout->tif_name, row); - break; - } - row++; - if (stretch) - { - if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) - { - fprintf(stderr, "%s: Write error at row %" PRIu32 ".\n", - tifout->tif_name, row); - break; - } - row++; - } - } - if (badrun > badfaxrun) - badfaxrun = badrun; - _TIFFfree(tifin->tif_rawdata); - return (row); + if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) { + fprintf(stderr, "%s: Write error at row %ld.\n", + tifout->tif_name, (long) row); + break; + } + row++; + if (stretch) { + if (TIFFWriteScanline(tifout, rowbuf, row, 0) < 0) { + fprintf(stderr, "%s: Write error at row %ld.\n", + tifout->tif_name, (long) row); + break; + } + row++; + } + } + if (badrun > badfaxrun) + badfaxrun = badrun; + _TIFFfree(tifin->tif_rawdata); + return (row); } -static const char usage_info[] = - "Create a TIFF Class F fax file from raw fax data\n\n" - "usage: fax2tiff [options] input.raw...\n" - "where options are:\n" - " -3 input data is G3-encoded [default]\n" - " -4 input data is G4-encoded\n" - " -U input data is uncompressed (G3 or G4)\n" - " -1 input data is 1D-encoded (G3 only) [default]\n" - " -2 input data is 2D-encoded (G3 only)\n" - " -P input is not EOL-aligned (G3 only) [default]\n" - " -A input is EOL-aligned (G3 only)\n" - " -M input data has MSB2LSB bit order\n" - " -L input data has LSB2MSB bit order [default]\n" - " -B input data has min 0 means black\n" - " -W input data has min 0 means white [default]\n" - " -R # input data has # resolution (lines/inch) [default is " - "196]\n" - " -X # input data has # width [default is " - "1728]\n" - "\n" - " -o out.tif write output to out.tif\n" -#ifdef CCITT_SUPPORT - " -7 generate G3-encoded output [default]\n" - " -8 generate G4-encoded output\n" - " -u generate uncompressed output (G3 or G4)\n" - " -5 generate 1D-encoded output (G3 only)\n" - " -6 generate 2D-encoded output (G3 only) [default]\n" - " -p generate not EOL-aligned output (G3 only)\n" - " -a generate EOL-aligned output (G3 only) [default]\n" -#endif - " -c generate \"classic\" TIFF format\n" - " -f generate TIFF Class F (TIFF/F) format [default]\n" - " -m output fill order is MSB2LSB\n" - " -l output fill order is LSB2MSB [default]\n" - " -r # make each strip have no more than # rows\n" - " -s stretch image by duplicating scanlines\n" - " -v print information about conversion work\n" -#ifdef LZW_SUPPORT - " -z generate LZW compressed output\n" -#endif - ; +const char* stuff[] = { +"usage: fax2tiff [options] input.raw...", +"where options are:", +" -3 input data is G3-encoded [default]", +" -4 input data is G4-encoded", +" -U input data is uncompressed (G3 or G4)", +" -1 input data is 1D-encoded (G3 only) [default]", +" -2 input data is 2D-encoded (G3 only)", +" -P input is not EOL-aligned (G3 only) [default]", +" -A input is EOL-aligned (G3 only)", +" -M input data has MSB2LSB bit order", +" -L input data has LSB2MSB bit order [default]", +" -B input data has min 0 means black", +" -W input data has min 0 means white [default]", +" -R # input data has # resolution (lines/inch) [default is 196]", +" -X # input data has # width [default is 1728]", +"", +" -o out.tif write output to out.tif", +" -7 generate G3-encoded output [default]", +" -8 generate G4-encoded output", +" -u generate uncompressed output (G3 or G4)", +" -5 generate 1D-encoded output (G3 only)", +" -6 generate 2D-encoded output (G3 only) [default]", +" -p generate not EOL-aligned output (G3 only)", +" -a generate EOL-aligned output (G3 only) [default]", +" -c generate \"classic\" TIFF format", +" -f generate TIFF Class F (TIFF/F) format [default]", +" -m output fill order is MSB2LSB", +" -l output fill order is LSB2MSB [default]", +" -r # make each strip have no more than # rows", +" -s stretch image by duplicating scanlines", +" -v print information about conversion work", +" -z generate LZW compressed output", +NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/pal2rgb.c b/thirdparty/SDL2_image/external/libtiff/tools/pal2rgb.c index 6b111a036..bf95cb37a 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/pal2rgb.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/pal2rgb.c @@ -2,36 +2,39 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" -#include #include -#include #include +#include +#include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffio.h" @@ -43,353 +46,313 @@ #define EXIT_FAILURE 1 #endif -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) -static void usage(int code); -static void cpTags(TIFF *in, TIFF *out); +static void usage(int code); +static void cpTags(TIFF* in, TIFF* out); -static int checkcmap(int n, uint16_t *r, uint16_t *g, uint16_t *b) +static int +checkcmap(int n, uint16* r, uint16* g, uint16* b) { - while (n-- > 0) - if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) - return (16); - fprintf(stderr, "Warning, assuming 8-bit colormap.\n"); - return (8); + while (n-- > 0) + if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) + return (16); + fprintf(stderr, "Warning, assuming 8-bit colormap.\n"); + return (8); } -#define CopyField(tag, v) \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v) -#define CopyField3(tag, v1, v2, v3) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3)) \ - TIFFSetField(out, tag, v1, v2, v3) +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) +#define CopyField3(tag, v1, v2, v3) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) -static uint16_t compression = (uint16_t)-1; -static uint16_t predictor = 0; -static int quality = 75; /* JPEG quality */ -static int jpegcolormode = JPEGCOLORMODE_RGB; -static int processCompressOptions(char *); +static uint16 compression = (uint16) -1; +static uint16 predictor = 0; +static int quality = 75; /* JPEG quality */ +static int jpegcolormode = JPEGCOLORMODE_RGB; +static int processCompressOptions(char*); -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - uint16_t bitspersample, shortv; - uint32_t imagewidth, imagelength; - uint16_t config = PLANARCONFIG_CONTIG; - uint32_t rowsperstrip = (uint32_t)-1; - uint16_t photometric = PHOTOMETRIC_RGB; - uint16_t *rmap, *gmap, *bmap; - uint32_t row; - int cmap = -1; - TIFF *in, *out; - int c; + uint16 bitspersample, shortv; + uint32 imagewidth, imagelength; + uint16 config = PLANARCONFIG_CONTIG; + uint32 rowsperstrip = (uint32) -1; + uint16 photometric = PHOTOMETRIC_RGB; + uint16 *rmap, *gmap, *bmap; + uint32 row; + int cmap = -1; + TIFF *in, *out; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - while ((c = getopt(argc, argv, "C:c:p:r:h")) != -1) - switch (c) - { - case 'C': /* force colormap interpretation */ - cmap = atoi(optarg); - break; - case 'c': /* compression scheme */ - if (!processCompressOptions(optarg)) - usage(EXIT_FAILURE); - break; - case 'p': /* planar configuration */ - if (streq(optarg, "separate")) - config = PLANARCONFIG_SEPARATE; - else if (streq(optarg, "contig")) - config = PLANARCONFIG_CONTIG; - else - usage(EXIT_FAILURE); - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case 'h': - usage(EXIT_SUCCESS); - break; - case '?': - usage(EXIT_FAILURE); - /*NOTREACHED*/ - } - if (argc - optind != 2) - usage(EXIT_FAILURE); - in = TIFFOpen(argv[optind], "r"); - if (in == NULL) - return (EXIT_FAILURE); - if (!TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &shortv) || - shortv != PHOTOMETRIC_PALETTE) - { - fprintf(stderr, "%s: Expecting a palette image.\n", argv[optind]); - (void)TIFFClose(in); - return (EXIT_FAILURE); - } - if (!TIFFGetField(in, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) - { - fprintf(stderr, "%s: No colormap (not a valid palette image).\n", - argv[optind]); - (void)TIFFClose(in); - return (EXIT_FAILURE); - } - bitspersample = 0; - TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); - if (bitspersample != 8) - { - fprintf(stderr, "%s: Sorry, can only handle 8-bit images.\n", - argv[optind]); - (void)TIFFClose(in); - return (EXIT_FAILURE); - } - out = TIFFOpen(argv[optind + 1], "w"); - if (out == NULL) - { - (void)TIFFClose(in); - return (EXIT_FAILURE); - } - cpTags(in, out); - TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &imagewidth); - TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); - if (compression != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - else - TIFFGetField(in, TIFFTAG_COMPRESSION, &compression); - switch (compression) - { - case COMPRESSION_JPEG: - if (jpegcolormode == JPEGCOLORMODE_RGB) - photometric = PHOTOMETRIC_YCBCR; - else - photometric = PHOTOMETRIC_RGB; - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != 0) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - break; - } - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, - rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip)); - (void)TIFFGetField(in, TIFFTAG_PLANARCONFIG, &shortv); - if (cmap == -1) - cmap = checkcmap(1 << bitspersample, rmap, gmap, bmap); - if (cmap == 16) - { - /* - * Convert 16-bit colormap to 8-bit. - */ - int i; + while ((c = getopt(argc, argv, "C:c:p:r:h")) != -1) + switch (c) { + case 'C': /* force colormap interpretation */ + cmap = atoi(optarg); + break; + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(EXIT_FAILURE); + break; + case 'p': /* planar configuration */ + if (streq(optarg, "separate")) + config = PLANARCONFIG_SEPARATE; + else if (streq(optarg, "contig")) + config = PLANARCONFIG_CONTIG; + else + usage(EXIT_FAILURE); + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case 'h': + usage(EXIT_SUCCESS); + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } + if (argc - optind != 2) + usage(EXIT_FAILURE); + in = TIFFOpen(argv[optind], "r"); + if (in == NULL) + return (EXIT_FAILURE); + if (!TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &shortv) || + shortv != PHOTOMETRIC_PALETTE) { + fprintf(stderr, "%s: Expecting a palette image.\n", + argv[optind]); + (void) TIFFClose(in); + return (EXIT_FAILURE); + } + if (!TIFFGetField(in, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { + fprintf(stderr, + "%s: No colormap (not a valid palette image).\n", + argv[optind]); + (void) TIFFClose(in); + return (EXIT_FAILURE); + } + bitspersample = 0; + TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); + if (bitspersample != 8) { + fprintf(stderr, "%s: Sorry, can only handle 8-bit images.\n", + argv[optind]); + (void) TIFFClose(in); + return (EXIT_FAILURE); + } + out = TIFFOpen(argv[optind+1], "w"); + if (out == NULL) { + (void) TIFFClose(in); + return (EXIT_FAILURE); + } + cpTags(in, out); + TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &imagewidth); + TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); + if (compression != (uint16)-1) + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + else + TIFFGetField(in, TIFFTAG_COMPRESSION, &compression); + switch (compression) { + case COMPRESSION_JPEG: + if (jpegcolormode == JPEGCOLORMODE_RGB) + photometric = PHOTOMETRIC_YCBCR; + else + photometric = PHOTOMETRIC_RGB; + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); + break; + case COMPRESSION_LZW: + case COMPRESSION_DEFLATE: + if (predictor != 0) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + break; + } + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, + rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip)); + (void) TIFFGetField(in, TIFFTAG_PLANARCONFIG, &shortv); + if (cmap == -1) + cmap = checkcmap(1<= 0; i--) - { -#define CVT(x) (((x)*255) / ((1L << 16) - 1)) - rmap[i] = CVT(rmap[i]); - gmap[i] = CVT(gmap[i]); - bmap[i] = CVT(bmap[i]); - } - } - { - unsigned char *ibuf, *obuf; - register unsigned char *pp; - register uint32_t x; - tmsize_t tss_in = TIFFScanlineSize(in); - tmsize_t tss_out = TIFFScanlineSize(out); - if (tss_out / tss_in < 3) - { - /* - * BUG 2750: The following code does not know about chroma - * subsampling of JPEG data. It assumes that the output buffer is 3x - * the length of the input buffer due to exploding the palette into - * RGB tuples. If this assumption is incorrect, it could lead to a - * buffer overflow. Go ahead and fail now to prevent that. - */ - fprintf(stderr, "Could not determine correct image size for " - "output. Exiting.\n"); - return EXIT_FAILURE; - } - ibuf = (unsigned char *)_TIFFmalloc(tss_in); - obuf = (unsigned char *)_TIFFmalloc(tss_out); - switch (config) - { - case PLANARCONFIG_CONTIG: - for (row = 0; row < imagelength; row++) - { - if (!TIFFReadScanline(in, ibuf, row, 0)) - goto done; - pp = obuf; - for (x = 0; x < imagewidth; x++) - { - *pp++ = (unsigned char)rmap[ibuf[x]]; - *pp++ = (unsigned char)gmap[ibuf[x]]; - *pp++ = (unsigned char)bmap[ibuf[x]]; - } - if (!TIFFWriteScanline(out, obuf, row, 0)) - goto done; - } - break; - case PLANARCONFIG_SEPARATE: - for (row = 0; row < imagelength; row++) - { - if (!TIFFReadScanline(in, ibuf, row, 0)) - goto done; - for (pp = obuf, x = 0; x < imagewidth; x++) - *pp++ = (unsigned char)rmap[ibuf[x]]; - if (!TIFFWriteScanline(out, obuf, row, 0)) - goto done; - for (pp = obuf, x = 0; x < imagewidth; x++) - *pp++ = (unsigned char)gmap[ibuf[x]]; - if (!TIFFWriteScanline(out, obuf, row, 0)) - goto done; - for (pp = obuf, x = 0; x < imagewidth; x++) - *pp++ = (unsigned char)bmap[ibuf[x]]; - if (!TIFFWriteScanline(out, obuf, row, 0)) - goto done; - } - break; - } - _TIFFfree(ibuf); - _TIFFfree(obuf); - } + for (i = (1<= 0; i--) { +#define CVT(x) (((x) * 255) / ((1L<<16)-1)) + rmap[i] = CVT(rmap[i]); + gmap[i] = CVT(gmap[i]); + bmap[i] = CVT(bmap[i]); + } + } + { unsigned char *ibuf, *obuf; + register unsigned char* pp; + register uint32 x; + tmsize_t tss_in = TIFFScanlineSize(in); + tmsize_t tss_out = TIFFScanlineSize(out); + if (tss_out / tss_in < 3) { + /* + * BUG 2750: The following code does not know about chroma + * subsampling of JPEG data. It assumes that the output buffer is 3x + * the length of the input buffer due to exploding the palette into + * RGB tuples. If this assumption is incorrect, it could lead to a + * buffer overflow. Go ahead and fail now to prevent that. + */ + fprintf(stderr, "Could not determine correct image size for output. Exiting.\n"); + return EXIT_FAILURE; + } + ibuf = (unsigned char*)_TIFFmalloc(tss_in); + obuf = (unsigned char*)_TIFFmalloc(tss_out); + switch (config) { + case PLANARCONFIG_CONTIG: + for (row = 0; row < imagelength; row++) { + if (!TIFFReadScanline(in, ibuf, row, 0)) + goto done; + pp = obuf; + for (x = 0; x < imagewidth; x++) { + *pp++ = (unsigned char) rmap[ibuf[x]]; + *pp++ = (unsigned char) gmap[ibuf[x]]; + *pp++ = (unsigned char) bmap[ibuf[x]]; + } + if (!TIFFWriteScanline(out, obuf, row, 0)) + goto done; + } + break; + case PLANARCONFIG_SEPARATE: + for (row = 0; row < imagelength; row++) { + if (!TIFFReadScanline(in, ibuf, row, 0)) + goto done; + for (pp = obuf, x = 0; x < imagewidth; x++) + *pp++ = (unsigned char) rmap[ibuf[x]]; + if (!TIFFWriteScanline(out, obuf, row, 0)) + goto done; + for (pp = obuf, x = 0; x < imagewidth; x++) + *pp++ = (unsigned char) gmap[ibuf[x]]; + if (!TIFFWriteScanline(out, obuf, row, 0)) + goto done; + for (pp = obuf, x = 0; x < imagewidth; x++) + *pp++ = (unsigned char) bmap[ibuf[x]]; + if (!TIFFWriteScanline(out, obuf, row, 0)) + goto done; + } + break; + } + _TIFFfree(ibuf); + _TIFFfree(obuf); + } done: - (void)TIFFClose(in); - (void)TIFFClose(out); - return (EXIT_SUCCESS); + (void) TIFFClose(in); + (void) TIFFClose(out); + return (EXIT_SUCCESS); } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) { - if (streq(opt, "none")) - compression = COMPRESSION_NONE; - else if (streq(opt, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (strneq(opt, "jpeg", 4)) - { - char *cp = strchr(opt, ':'); + if (streq(opt, "none")) + compression = COMPRESSION_NONE; + else if (streq(opt, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (strneq(opt, "jpeg", 4)) { + char* cp = strchr(opt, ':'); - compression = COMPRESSION_JPEG; - while (cp) - { - if (isdigit((int)cp[1])) - quality = atoi(cp + 1); - else if (cp[1] == 'r') - jpegcolormode = JPEGCOLORMODE_RAW; - else - usage(EXIT_FAILURE); + compression = COMPRESSION_JPEG; + while( cp ) + { + if (isdigit((int)cp[1])) + quality = atoi(cp+1); + else if (cp[1] == 'r' ) + jpegcolormode = JPEGCOLORMODE_RAW; + else + usage(EXIT_FAILURE); - cp = strchr(cp + 1, ':'); - } - } - else if (strneq(opt, "lzw", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + cp = strchr(cp+1,':'); + } + } else if (strneq(opt, "lzw", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strneq(opt, "zip", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -#define CopyField(tag, v) \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v) -#define CopyField2(tag, v1, v2) \ - if (TIFFGetField(in, tag, &v1, &v2)) \ - TIFFSetField(out, tag, v1, v2) -#define CopyField3(tag, v1, v2, v3) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3)) \ - TIFFSetField(out, tag, v1, v2, v3) -#define CopyField4(tag, v1, v2, v3, v4) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) \ - TIFFSetField(out, tag, v1, v2, v3, v4) +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) +#define CopyField2(tag, v1, v2) \ + if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) +#define CopyField3(tag, v1, v2, v3) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) +#define CopyField4(tag, v1, v2, v3, v4) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) -static void cpTag(TIFF *in, TIFF *out, uint16_t tag, uint16_t count, - TIFFDataType type) +static void +cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) { - switch (type) - { - case TIFF_SHORT: - if (count == 1) - { - uint16_t shortv; - CopyField(tag, shortv); - } - else if (count == 2) - { - uint16_t shortv1, shortv2; - CopyField2(tag, shortv1, shortv2); - } - else if (count == 4) - { - uint16_t *tr, *tg, *tb, *ta; - CopyField4(tag, tr, tg, tb, ta); - } - else if (count == (uint16_t)-1) - { - uint16_t shortv1; - uint16_t *shortav; - CopyField2(tag, shortv1, shortav); - } - break; - case TIFF_LONG: - { - uint32_t longv; - CopyField(tag, longv); - } - break; - case TIFF_RATIONAL: - if (count == 1) - { - float floatv; - CopyField(tag, floatv); - } - else if (count == (uint16_t)-1) - { - float *floatav; - CopyField(tag, floatav); - } - break; - case TIFF_ASCII: - { - char *stringv; - CopyField(tag, stringv); - } - break; - case TIFF_DOUBLE: - if (count == 1) - { - double doublev; - CopyField(tag, doublev); - } - else if (count == (uint16_t)-1) - { - double *doubleav; - CopyField(tag, doubleav); - } - break; - default: - TIFFError(TIFFFileName(in), - "Data type %d is not supported, tag %d skipped.", tag, - type); - } + switch (type) { + case TIFF_SHORT: + if (count == 1) { + uint16 shortv; + CopyField(tag, shortv); + } else if (count == 2) { + uint16 shortv1, shortv2; + CopyField2(tag, shortv1, shortv2); + } else if (count == 4) { + uint16 *tr, *tg, *tb, *ta; + CopyField4(tag, tr, tg, tb, ta); + } else if (count == (uint16) -1) { + uint16 shortv1; + uint16* shortav; + CopyField2(tag, shortv1, shortav); + } + break; + case TIFF_LONG: + { uint32 longv; + CopyField(tag, longv); + } + break; + case TIFF_RATIONAL: + if (count == 1) { + float floatv; + CopyField(tag, floatv); + } else if (count == (uint16) -1) { + float* floatav; + CopyField(tag, floatav); + } + break; + case TIFF_ASCII: + { char* stringv; + CopyField(tag, stringv); + } + break; + case TIFF_DOUBLE: + if (count == 1) { + double doublev; + CopyField(tag, doublev); + } else if (count == (uint16) -1) { + double* doubleav; + CopyField(tag, doubleav); + } + break; + default: + TIFFError(TIFFFileName(in), + "Data type %d is not supported, tag %d skipped.", + tag, type); + } } #undef CopyField4 @@ -397,79 +360,75 @@ static void cpTag(TIFF *in, TIFF *out, uint16_t tag, uint16_t count, #undef CopyField2 #undef CopyField -static const struct cpTag -{ - uint16_t tag; - uint16_t count; +static struct cpTag { + uint16 tag; + uint16 count; TIFFDataType type; } tags[] = { - {TIFFTAG_IMAGEWIDTH, 1, TIFF_LONG}, - {TIFFTAG_IMAGELENGTH, 1, TIFF_LONG}, - {TIFFTAG_BITSPERSAMPLE, 1, TIFF_SHORT}, - {TIFFTAG_COMPRESSION, 1, TIFF_SHORT}, - {TIFFTAG_FILLORDER, 1, TIFF_SHORT}, - {TIFFTAG_ROWSPERSTRIP, 1, TIFF_LONG}, - {TIFFTAG_GROUP3OPTIONS, 1, TIFF_LONG}, - {TIFFTAG_SUBFILETYPE, 1, TIFF_LONG}, - {TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT}, - {TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII}, - {TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII}, - {TIFFTAG_MAKE, 1, TIFF_ASCII}, - {TIFFTAG_MODEL, 1, TIFF_ASCII}, - {TIFFTAG_ORIENTATION, 1, TIFF_SHORT}, - {TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_PAGENAME, 1, TIFF_ASCII}, - {TIFFTAG_XPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_YPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG}, - {TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT}, - {TIFFTAG_PAGENUMBER, 2, TIFF_SHORT}, - {TIFFTAG_SOFTWARE, 1, TIFF_ASCII}, - {TIFFTAG_DATETIME, 1, TIFF_ASCII}, - {TIFFTAG_ARTIST, 1, TIFF_ASCII}, - {TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII}, - {TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL}, - {TIFFTAG_PRIMARYCHROMATICITIES, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT}, - {TIFFTAG_BADFAXLINES, 1, TIFF_LONG}, - {TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT}, - {TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG}, - {TIFFTAG_INKSET, 1, TIFF_SHORT}, - /*{ TIFFTAG_INKNAMES, 1, TIFF_ASCII },*/ /* Needs much - more - complicated - logic. See - tiffcp */ - {TIFFTAG_DOTRANGE, 2, TIFF_SHORT}, - {TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII}, - {TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT}, - {TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT}, - {TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT}, - {TIFFTAG_REFERENCEBLACKWHITE, (uint16_t)-1, TIFF_RATIONAL}, + { TIFFTAG_IMAGEWIDTH, 1, TIFF_LONG }, + { TIFFTAG_IMAGELENGTH, 1, TIFF_LONG }, + { TIFFTAG_BITSPERSAMPLE, 1, TIFF_SHORT }, + { TIFFTAG_COMPRESSION, 1, TIFF_SHORT }, + { TIFFTAG_FILLORDER, 1, TIFF_SHORT }, + { TIFFTAG_ROWSPERSTRIP, 1, TIFF_LONG }, + { TIFFTAG_GROUP3OPTIONS, 1, TIFF_LONG }, + { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, + { TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT }, + { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, + { TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII }, + { TIFFTAG_MAKE, 1, TIFF_ASCII }, + { TIFFTAG_MODEL, 1, TIFF_ASCII }, + { TIFFTAG_ORIENTATION, 1, TIFF_SHORT }, + { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, + { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT }, + { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, + /*{ TIFFTAG_INKNAMES, 1, TIFF_ASCII },*/ /* Needs much more complicated logic. See tiffcp */ + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, }; -#define NTAGS (sizeof(tags) / sizeof(tags[0])) +#define NTAGS (sizeof (tags) / sizeof (tags[0])) -static void cpTags(TIFF *in, TIFF *out) +static void +cpTags(TIFF* in, TIFF* out) { - const struct cpTag *p; + struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) { - if (p->tag == TIFFTAG_GROUP3OPTIONS) + if( p->tag == TIFFTAG_GROUP3OPTIONS ) { - uint16_t compression; - if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || - compression != COMPRESSION_CCITTFAX3) + uint16 compression; + if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || + compression != COMPRESSION_CCITTFAX3 ) continue; } - if (p->tag == TIFFTAG_GROUP4OPTIONS) + if( p->tag == TIFFTAG_GROUP4OPTIONS ) { - uint16_t compression; - if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || - compression != COMPRESSION_CCITTFAX4) + uint16 compression; + if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || + compression != COMPRESSION_CCITTFAX4 ) continue; } cpTag(in, out, p->tag, p->count, p->type); @@ -477,41 +436,43 @@ static void cpTags(TIFF *in, TIFF *out) } #undef NTAGS -static const char usage_info[] = - "Convert a palette color TIFF image to a full color image\n\n" - "usage: pal2rgb [options] input.tif output.tif\n" - "where options are:\n" - " -p contig pack samples contiguously (e.g. RGBRGB...)\n" - " -p separate store samples separately (e.g. RRR...GGG...BBB...)\n" - " -r # make each strip have no more than # rows\n" - " -C 8 assume 8-bit colormap values (instead of 16-bit)\n" - " -C 16 assume 16-bit colormap values\n" - "\n" -#ifdef LZW_SUPPORT - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" - /* " LZW options:\n" */ - " # set predictor value\n" - " For example, -c lzw:2 to get LZW-encoded data with horizontal " - "differencing\n" -#endif -#ifdef ZIP_SUPPORT - " -c zip[:opts] compress output with deflate encoding\n" - /* " Deflate (ZIP) options:\n" */ - " # set predictor value\n" -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits compress output with packbits encoding\n" -#endif -#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) - " -c none use no compression algorithm on output\n" -#endif - ; +const char* stuff[] = { +"usage: pal2rgb [options] input.tif output.tif", +"where options are:", +" -p contig pack samples contiguously (e.g. RGBRGB...)", +" -p separate store samples separately (e.g. RRR...GGG...BBB...)", +" -r # make each strip have no more than # rows", +" -C 8 assume 8-bit colormap values (instead of 16-bit)", +" -C 16 assume 16-bit colormap values", +"", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c packbits compress output with packbits encoding", +" -c none use no compression algorithm on output", +"", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/ppm2tiff.c b/thirdparty/SDL2_image/external/libtiff/tools/ppm2tiff.c index e64e26d06..c63324397 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/ppm2tiff.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/ppm2tiff.c @@ -2,48 +2,55 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" -#include #include #include #include +#include #ifdef HAVE_UNISTD_H -#include +# include #endif #ifdef HAVE_FCNTL_H -#include +# include #endif #ifdef HAVE_IO_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffio.h" +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); +#endif + #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif @@ -51,521 +58,477 @@ #define EXIT_FAILURE 1 #endif -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) -static uint16_t compression = COMPRESSION_PACKBITS; -static uint16_t predictor = 0; -static int quality = 75; /* JPEG quality */ -static int jpegcolormode = JPEGCOLORMODE_RGB; -static uint32_t g3opts; +static uint16 compression = COMPRESSION_PACKBITS; +static uint16 predictor = 0; +static int quality = 75; /* JPEG quality */ +static int jpegcolormode = JPEGCOLORMODE_RGB; +static uint32 g3opts; -static void usage(int code); -static int processCompressOptions(char *); +static void usage(int code); +static int processCompressOptions(char*); -static void pack_none(unsigned char *buf, unsigned int smpls, uint16_t bps) +static void +pack_none (unsigned char *buf, unsigned int smpls, uint16 bps) { - (void)buf; - (void)smpls; - (void)bps; - return; + (void)buf; + (void)smpls; + (void)bps; + return; } -static void pack_swab(unsigned char *buf, unsigned int smpls, uint16_t bps) +static void +pack_swab (unsigned char *buf, unsigned int smpls, uint16 bps) { - unsigned int s; - unsigned char h; - unsigned char l; - (void)bps; + unsigned int s; + unsigned char h; + unsigned char l; + (void)bps; - for (s = 0; smpls > s; s++) - { + for (s = 0; smpls > s; s++) { - h = buf[s * 2 + 0]; - l = buf[s * 2 + 1]; + h = buf [s * 2 + 0]; + l = buf [s * 2 + 1]; - buf[s * 2 + 0] = l; - buf[s * 2 + 1] = h; - } - return; + buf [s * 2 + 0] = l; + buf [s * 2 + 1] = h; + } + return; } -static void pack_bytes(unsigned char *buf, unsigned int smpls, uint16_t bps) +static void +pack_bytes (unsigned char *buf, unsigned int smpls, uint16 bps) { - unsigned int s; - unsigned int in; - unsigned int out; - int bits; - uint16_t t; + unsigned int s; + unsigned int in; + unsigned int out; + int bits; + uint16 t; - in = 0; - out = 0; - bits = 0; - t = 0; + in = 0; + out = 0; + bits = 0; + t = 0; - for (s = 0; smpls > s; s++) - { + for (s = 0; smpls > s; s++) { - t <<= bps; - t |= (uint16_t)buf[in++]; + t <<= bps; + t |= (uint16) buf [in++]; - bits += bps; + bits += bps; - if (8 <= bits) - { - bits -= 8; - buf[out++] = (t >> bits) & 0xFF; - } - } - if (0 != bits) - buf[out] = (t << (8 - bits)) & 0xFF; + if (8 <= bits) { + bits -= 8; + buf [out++] = (t >> bits) & 0xFF; + } + } + if (0 != bits) + buf [out] = (t << (8 - bits)) & 0xFF; } -static void pack_words(unsigned char *buf, unsigned int smpls, uint16_t bps) +static void +pack_words (unsigned char *buf, unsigned int smpls, uint16 bps) { - unsigned int s; - unsigned int in; - unsigned int out; - int bits; - uint32_t t; + unsigned int s; + unsigned int in; + unsigned int out; + int bits; + uint32 t; - in = 0; - out = 0; - bits = 0; - t = 0; + in = 0; + out = 0; + bits = 0; + t = 0; - for (s = 0; smpls > s; s++) - { + for (s = 0; smpls > s; s++) { - t <<= bps; - t |= (uint32_t)buf[in++] << 8; - t |= (uint32_t)buf[in++] << 0; + t <<= bps; + t |= (uint32) buf [in++] << 8; + t |= (uint32) buf [in++] << 0; - bits += bps; + bits += bps; - if (16 <= bits) - { + if (16 <= bits) { - bits -= 16; - buf[out++] = (t >> (bits + 8)); - buf[out++] = (t >> (bits + 0)); - } - } - if (0 != bits) - { - t <<= 16 - bits; + bits -= 16; + buf [out++] = (t >> (bits + 8)); + buf [out++] = (t >> (bits + 0)); + } + } + if (0 != bits) { + t <<= 16 - bits; - buf[out++] = (t >> (16 + 8)); - buf[out++] = (t >> (16 + 0)); - } + buf [out++] = (t >> (16 + 8)); + buf [out++] = (t >> (16 + 0)); + } } -static void BadPPM(char *file) +static void +BadPPM(char* file) { - fprintf(stderr, "%s: Not a PPM file.\n", file); - exit(EXIT_FAILURE); + fprintf(stderr, "%s: Not a PPM file.\n", file); + exit(EXIT_FAILURE); } -static tmsize_t multiply_ms(tmsize_t m1, tmsize_t m2) + +#define TIFF_SIZE_T_MAX ((size_t) ~ ((size_t)0)) +#define TIFF_TMSIZE_T_MAX (tmsize_t)(TIFF_SIZE_T_MAX >> 1) + +static tmsize_t +multiply_ms(tmsize_t m1, tmsize_t m2) { - if (m1 == 0 || m2 > TIFF_TMSIZE_T_MAX / m1) - return 0; - return m1 * m2; + if( m1 == 0 || m2 > TIFF_TMSIZE_T_MAX / m1 ) + return 0; + return m1 * m2; } -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - uint16_t photometric = 0; - uint32_t rowsperstrip = (uint32_t)-1; - double resolution = -1; - unsigned char *buf = NULL; - tmsize_t linebytes = 0; - int pbm; - uint16_t spp = 1; - uint16_t bpp = 8; - void (*pack_func)(unsigned char *buf, unsigned int smpls, uint16_t bps); - TIFF *out; - FILE *in; - unsigned int w, h, prec, row; - char *infile; - int c; + uint16 photometric = 0; + uint32 rowsperstrip = (uint32) -1; + double resolution = -1; + unsigned char *buf = NULL; + tmsize_t linebytes = 0; + int pbm; + uint16 spp = 1; + uint16 bpp = 8; + void (*pack_func) (unsigned char *buf, unsigned int smpls, uint16 bps); + TIFF *out; + FILE *in; + unsigned int w, h, prec, row; + char *infile; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - tmsize_t scanline_size; + tmsize_t scanline_size; - if (argc < 2) - { - fprintf(stderr, "%s: Too few arguments\n", argv[0]); - usage(EXIT_FAILURE); - } - while ((c = getopt(argc, argv, "c:r:R:h")) != -1) - switch (c) - { - case 'c': /* compression scheme */ - if (!processCompressOptions(optarg)) - usage(EXIT_FAILURE); - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case 'R': /* resolution */ - resolution = atof(optarg); - break; - case 'h': - usage(EXIT_SUCCESS); - break; - case '?': - usage(EXIT_FAILURE); - /*NOTREACHED*/ - } + if (argc < 2) { + fprintf(stderr, "%s: Too few arguments\n", argv[0]); + usage(EXIT_FAILURE); + } + while ((c = getopt(argc, argv, "c:r:R:h")) != -1) + switch (c) { + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(EXIT_FAILURE); + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case 'R': /* resolution */ + resolution = atof(optarg); + break; + case 'h': + usage(EXIT_SUCCESS); + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } - if (optind + 2 < argc) - { - fprintf(stderr, "%s: Too many arguments\n", argv[0]); - usage(EXIT_FAILURE); - } + if (optind + 2 < argc) { + fprintf(stderr, "%s: Too many arguments\n", argv[0]); + usage(EXIT_FAILURE); + } - /* - * If only one file is specified, read input from - * stdin; otherwise usage is: ppm2tiff input output. - */ - if (argc - optind > 1) - { - infile = argv[optind++]; - in = fopen(infile, "rb"); - if (in == NULL) - { - fprintf(stderr, "%s: Can not open.\n", infile); - return (EXIT_FAILURE); - } - } - else - { - infile = ""; - in = stdin; + /* + * If only one file is specified, read input from + * stdin; otherwise usage is: ppm2tiff input output. + */ + if (argc - optind > 1) { + infile = argv[optind++]; + in = fopen(infile, "rb"); + if (in == NULL) { + fprintf(stderr, "%s: Can not open.\n", infile); + return (EXIT_FAILURE); + } + } else { + infile = ""; + in = stdin; #if defined(HAVE_SETMODE) && defined(O_BINARY) - setmode(fileno(stdin), O_BINARY); + setmode(fileno(stdin), O_BINARY); #endif - } + } - if (fgetc(in) != 'P') - BadPPM(infile); - switch (fgetc(in)) - { - case '4': /* it's a PBM file */ - pbm = !0; - spp = 1; - photometric = PHOTOMETRIC_MINISWHITE; - break; - case '5': /* it's a PGM file */ - pbm = 0; - spp = 1; - photometric = PHOTOMETRIC_MINISBLACK; - break; - case '6': /* it's a PPM file */ - pbm = 0; - spp = 3; - photometric = PHOTOMETRIC_RGB; - if (compression == COMPRESSION_JPEG && - jpegcolormode == JPEGCOLORMODE_RGB) - photometric = PHOTOMETRIC_YCBCR; - break; - default: - BadPPM(infile); - } + if (fgetc(in) != 'P') + BadPPM(infile); + switch (fgetc(in)) { + case '4': /* it's a PBM file */ + pbm = !0; + spp = 1; + photometric = PHOTOMETRIC_MINISWHITE; + break; + case '5': /* it's a PGM file */ + pbm = 0; + spp = 1; + photometric = PHOTOMETRIC_MINISBLACK; + break; + case '6': /* it's a PPM file */ + pbm = 0; + spp = 3; + photometric = PHOTOMETRIC_RGB; + if (compression == COMPRESSION_JPEG && + jpegcolormode == JPEGCOLORMODE_RGB) + photometric = PHOTOMETRIC_YCBCR; + break; + default: + BadPPM(infile); + } - /* Parse header */ - while (1) - { - if (feof(in)) - BadPPM(infile); - c = fgetc(in); - /* Skip whitespaces (blanks, TABs, CRs, LFs) */ - if (strchr(" \t\r\n", c)) - continue; + /* Parse header */ + while(1) { + if (feof(in)) + BadPPM(infile); + c = fgetc(in); + /* Skip whitespaces (blanks, TABs, CRs, LFs) */ + if (strchr(" \t\r\n", c)) + continue; - /* Check for comment line */ - if (c == '#') - { - do - { - c = fgetc(in); - } while (!(strchr("\r\n", c) || feof(in))); - continue; - } + /* Check for comment line */ + if (c == '#') { + do { + c = fgetc(in); + } while(!(strchr("\r\n", c) || feof(in))); + continue; + } - ungetc(c, in); - break; - } - if (pbm) - { - if (fscanf(in, " %u %u", &w, &h) != 2) - BadPPM(infile); - if (fgetc(in) != '\n') - BadPPM(infile); - bpp = 1; - pack_func = pack_none; - } - else - { - if (fscanf(in, " %u %u %u", &w, &h, &prec) != 3) - BadPPM(infile); - if (fgetc(in) != '\n' || 0 == prec || 65535 < prec) - BadPPM(infile); + ungetc(c, in); + break; + } + if (pbm) { + if (fscanf(in, " %u %u", &w, &h) != 2) + BadPPM(infile); + if (fgetc(in) != '\n') + BadPPM(infile); + bpp = 1; + pack_func = pack_none; + } else { + if (fscanf(in, " %u %u %u", &w, &h, &prec) != 3) + BadPPM(infile); + if (fgetc(in) != '\n' || 0 == prec || 65535 < prec) + BadPPM(infile); - if (0 != (prec & (prec + 1))) - { - fprintf(stderr, "%s: unsupported maxval %u.\n", infile, prec); - exit(EXIT_FAILURE); - } - bpp = 0; - if ((prec + 1) & 0xAAAAAAAA) - bpp |= 1; - if ((prec + 1) & 0xCCCCCCCC) - bpp |= 2; - if ((prec + 1) & 0xF0F0F0F0) - bpp |= 4; - if ((prec + 1) & 0xFF00FF00) - bpp |= 8; - if ((prec + 1) & 0xFFFF0000) - bpp |= 16; + if (0 != (prec & (prec + 1))) { + fprintf(stderr, "%s: unsupported maxval %u.\n", + infile, prec); + exit(EXIT_FAILURE); + } + bpp = 0; + if ((prec + 1) & 0xAAAAAAAA) bpp |= 1; + if ((prec + 1) & 0xCCCCCCCC) bpp |= 2; + if ((prec + 1) & 0xF0F0F0F0) bpp |= 4; + if ((prec + 1) & 0xFF00FF00) bpp |= 8; + if ((prec + 1) & 0xFFFF0000) bpp |= 16; - switch (bpp) - { - case 8: - pack_func = pack_none; - break; - case 16: - { - const unsigned short i = 0x0100; + switch (bpp) { + case 8: + pack_func = pack_none; + break; + case 16: + { + const unsigned short i = 0x0100; - if (0 == *(unsigned char *)&i) - pack_func = pack_swab; - else - pack_func = pack_none; - } - break; - default: - if (8 >= bpp) - pack_func = pack_bytes; - else - pack_func = pack_words; - break; - } - } - out = TIFFOpen(argv[optind], "w"); - if (out == NULL) - return (EXIT_FAILURE); - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t)w); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t)h); - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bpp); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - switch (compression) - { - case COMPRESSION_JPEG: - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != 0) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - break; + if (0 == *(unsigned char*) &i) + pack_func = pack_swab; + else + pack_func = pack_none; + } + break; + default: + if (8 >= bpp) + pack_func = pack_bytes; + else + pack_func = pack_words; + break; + } + } + out = TIFFOpen(argv[optind], "w"); + if (out == NULL) + return (EXIT_FAILURE); + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) w); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) h); + TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bpp); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + switch (compression) { + case COMPRESSION_JPEG: + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); + break; + case COMPRESSION_LZW: + case COMPRESSION_DEFLATE: + if (predictor != 0) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + break; case COMPRESSION_CCITTFAX3: - TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); - break; - } - if (pbm) - { - /* if round-up overflows, result will be zero, OK */ - linebytes = (multiply_ms(spp, w) + (8 - 1)) / 8; - } - else if (bpp <= 8) - { - linebytes = multiply_ms(spp, w); - } - else - { - linebytes = multiply_ms(2 * spp, w); - } - if (rowsperstrip == (uint32_t)-1) - { - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, h); - } - else - { - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, - TIFFDefaultStripSize(out, rowsperstrip)); - } - if (linebytes == 0) - { - fprintf(stderr, "%s: scanline size overflow\n", infile); - (void)TIFFClose(out); - exit(EXIT_FAILURE); - } - scanline_size = TIFFScanlineSize(out); - if (scanline_size == 0) - { - /* overflow - TIFFScanlineSize already printed a message */ - (void)TIFFClose(out); - exit(EXIT_FAILURE); - } - if (scanline_size < linebytes) - buf = (unsigned char *)_TIFFmalloc(linebytes); - else - buf = (unsigned char *)_TIFFmalloc(scanline_size); - if (buf == NULL) - { - fprintf(stderr, "%s: Not enough memory\n", infile); - (void)TIFFClose(out); - exit(EXIT_FAILURE); - } - if (resolution > 0) - { - TIFFSetField(out, TIFFTAG_XRESOLUTION, resolution); - TIFFSetField(out, TIFFTAG_YRESOLUTION, resolution); - TIFFSetField(out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); - } - for (row = 0; row < h; row++) - { - if (fread(buf, linebytes, 1, in) != 1) - { - fprintf(stderr, "%s: scanline %u: Read error.\n", infile, row); - break; + TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); + break; + } + if (pbm) { + /* if round-up overflows, result will be zero, OK */ + linebytes = (multiply_ms(spp, w) + (8 - 1)) / 8; + } else if (bpp <= 8) { + linebytes = multiply_ms(spp, w); + } else { + linebytes = multiply_ms(2 * spp, w); + } + if (rowsperstrip == (uint32) -1) { + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, h); + } else { + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, + TIFFDefaultStripSize(out, rowsperstrip)); + } + if (linebytes == 0) { + fprintf(stderr, "%s: scanline size overflow\n", infile); + (void) TIFFClose(out); + exit(EXIT_FAILURE); + } + scanline_size = TIFFScanlineSize(out); + if (scanline_size == 0) { + /* overflow - TIFFScanlineSize already printed a message */ + (void) TIFFClose(out); + exit(EXIT_FAILURE); + } + if (scanline_size < linebytes) + buf = (unsigned char *)_TIFFmalloc(linebytes); + else + buf = (unsigned char *)_TIFFmalloc(scanline_size); + if (buf == NULL) { + fprintf(stderr, "%s: Not enough memory\n", infile); + (void) TIFFClose(out); + exit(EXIT_FAILURE); + } + if (resolution > 0) { + TIFFSetField(out, TIFFTAG_XRESOLUTION, resolution); + TIFFSetField(out, TIFFTAG_YRESOLUTION, resolution); + TIFFSetField(out, TIFFTAG_RESOLUTIONUNIT, RESUNIT_INCH); + } + for (row = 0; row < h; row++) { + if (fread(buf, linebytes, 1, in) != 1) { + fprintf(stderr, "%s: scanline %lu: Read error.\n", + infile, (unsigned long) row); + break; + } + pack_func (buf, w * spp, bpp); + if (TIFFWriteScanline(out, buf, row, 0) < 0) + break; + } + if (in != stdin) + fclose(in); + (void) TIFFClose(out); + if (buf) + _TIFFfree(buf); + return (EXIT_SUCCESS); +} + +static void +processG3Options(char* cp) +{ + g3opts = 0; + if( (cp = strchr(cp, ':')) ) { + do { + cp++; + if (strneq(cp, "1d", 2)) + g3opts &= ~GROUP3OPT_2DENCODING; + else if (strneq(cp, "2d", 2)) + g3opts |= GROUP3OPT_2DENCODING; + else if (strneq(cp, "fill", 4)) + g3opts |= GROUP3OPT_FILLBITS; + else + usage(EXIT_FAILURE); + } while( (cp = strchr(cp, ':')) ); } - pack_func(buf, w * spp, bpp); - if (TIFFWriteScanline(out, buf, row, 0) < 0) - break; - } - if (in != stdin) - fclose(in); - (void)TIFFClose(out); - if (buf) - _TIFFfree(buf); - return (EXIT_SUCCESS); } -static void processG3Options(char *cp) +static int +processCompressOptions(char* opt) { - g3opts = 0; - if ((cp = strchr(cp, ':'))) - { - do - { - cp++; - if (strneq(cp, "1d", 2)) - g3opts &= ~GROUP3OPT_2DENCODING; - else if (strneq(cp, "2d", 2)) - g3opts |= GROUP3OPT_2DENCODING; - else if (strneq(cp, "fill", 4)) - g3opts |= GROUP3OPT_FILLBITS; - else - usage(EXIT_FAILURE); - } while ((cp = strchr(cp, ':'))); - } + if (streq(opt, "none")) + compression = COMPRESSION_NONE; + else if (streq(opt, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (strneq(opt, "jpeg", 4)) { + char* cp = strchr(opt, ':'); + + compression = COMPRESSION_JPEG; + while (cp) + { + if (isdigit((int)cp[1])) + quality = atoi(cp+1); + else if (cp[1] == 'r' ) + jpegcolormode = JPEGCOLORMODE_RAW; + else + usage(EXIT_FAILURE); + + cp = strchr(cp+1,':'); + } + } else if (strneq(opt, "g3", 2)) { + processG3Options(opt); + compression = COMPRESSION_CCITTFAX3; + } else if (streq(opt, "g4")) { + compression = COMPRESSION_CCITTFAX4; + } else if (strneq(opt, "lzw", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strneq(opt, "zip", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -static int processCompressOptions(char *opt) +const char* stuff[] = { +"usage: ppm2tiff [options] input.ppm output.tif", +"where options are:", +" -r # make each strip have no more than # rows", +" -R # set x&y resolution (dpi)", +"", +" -c jpeg[:opts] compress output with JPEG encoding", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c packbits compress output with packbits encoding (the default)", +" -c g3[:opts] compress output with CCITT Group 3 encoding", +" -c g4 compress output with CCITT Group 4 encoding", +" -c none use no compression algorithm on output", +"", +"JPEG options:", +" # set compression quality level (0-100, default 75)", +" r output color image as RGB rather than YCbCr", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +NULL +}; + +static void +usage(int code) { - if (streq(opt, "none")) - compression = COMPRESSION_NONE; - else if (streq(opt, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (strneq(opt, "jpeg", 4)) - { - char *cp = strchr(opt, ':'); + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - compression = COMPRESSION_JPEG; - while (cp) - { - if (isdigit((int)cp[1])) - quality = atoi(cp + 1); - else if (cp[1] == 'r') - jpegcolormode = JPEGCOLORMODE_RAW; - else - usage(EXIT_FAILURE); - - cp = strchr(cp + 1, ':'); - } - } - else if (strneq(opt, "g3", 2)) - { - processG3Options(opt); - compression = COMPRESSION_CCITTFAX3; - } - else if (streq(opt, "g4")) - { - compression = COMPRESSION_CCITTFAX4; - } - else if (strneq(opt, "lzw", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } -static const char usage_info[] = - "Create a TIFF file from PPM, PGM and PBM image files\n\n" - "usage: ppm2tiff [options] input.ppm output.tif\n" - "where options are:\n" - " -r # make each strip have no more than # rows\n" - " -R # set x&y resolution (dpi)\n" - "\n" -#ifdef JPEG_SUPPORT - " -c jpeg[:opts] compress output with JPEG encoding\n" - /* "JPEG options:\n" */ - " # set compression quality level (0-100, default 75)\n" - " r output color image as RGB rather than YCbCr\n" -#endif -#ifdef LZW_SUPPORT - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" - /* " LZW options:\n" */ - " # set predictor value\n" - " For example, -c lzw:2 for LZW-encoded data with horizontal " - "differencing\n" -#endif -#ifdef ZIP_SUPPORT - " -c zip[:opts] compress output with deflate encoding\n" - /* " Deflate (ZIP) options:\n" */ - " # set predictor value\n" -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits compress output with packbits encoding (the default)\n" -#endif -#ifdef CCITT_SUPPORT - " -c g3[:opts] compress output with CCITT Group 3 encoding\n" - " -c g4 compress output with CCITT Group 4 encoding\n" -#endif -#if defined(JPEG_SUPPORT) || defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || \ - defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) - " -c none use no compression algorithm on output\n" -#endif - ; - -static void usage(int code) -{ - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; - - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); -} +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/raw2tiff.c b/thirdparty/SDL2_image/external/libtiff/tools/raw2tiff.c index 4ee59e5d7..8bbdc045c 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/raw2tiff.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/raw2tiff.c @@ -6,55 +6,58 @@ ****************************************************************************** * Copyright (c) 2002, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" -#include -#include #include #include #include #include #include +#include +#include #ifdef HAVE_UNISTD_H -#include +# include #endif #if HAVE_FCNTL_H -#include +# include #endif #if HAVE_SYS_TYPES_H -#include +# include #endif #if HAVE_IO_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif -#include "tiffio.h" #include "tiffiop.h" +#include "tiffio.h" #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 @@ -63,688 +66,641 @@ #define EXIT_FAILURE 1 #endif -#ifndef O_BINARY -#define O_BINARY 0 +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); #endif -typedef enum -{ - PIXEL, - BAND +#ifndef O_BINARY +# define O_BINARY 0 +#endif + +typedef enum { + PIXEL, + BAND } InterleavingType; -static uint16_t compression = (uint16_t)-1; -static int jpegcolormode = JPEGCOLORMODE_RGB; -static int quality = 75; /* JPEG quality */ -static uint16_t predictor = 0; +static uint16 compression = (uint16) -1; +static int jpegcolormode = JPEGCOLORMODE_RGB; +static int quality = 75; /* JPEG quality */ +static uint16 predictor = 0; -static void swapBytesInScanline(void *, uint32_t, TIFFDataType); -static int guessSize(int, TIFFDataType, _TIFF_off_t, uint32_t, int, uint32_t *, - uint32_t *); -static double correlation(void *, void *, uint32_t, TIFFDataType); +static void swapBytesInScanline(void *, uint32, TIFFDataType); +static int guessSize(int, TIFFDataType, _TIFF_off_t, uint32, int, + uint32 *, uint32 *); +static double correlation(void *, void *, uint32, TIFFDataType); static void usage(int); -static int processCompressOptions(char *); +static int processCompressOptions(char*); -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - uint32_t width = 0, length = 0, linebytes, bufsize; - uint32_t nbands = 1; /* number of bands in input image*/ - _TIFF_off_t hdr_size = 0; /* size of the header to skip */ - TIFFDataType dtype = TIFF_BYTE; - int16_t depth = 1; /* bytes per pixel in input image */ - int swab = 0; /* byte swapping flag */ - InterleavingType interleaving = 0; /* interleaving type flag */ - uint32_t rowsperstrip = (uint32_t)-1; - uint16_t photometric = PHOTOMETRIC_MINISBLACK; - uint16_t config = PLANARCONFIG_CONTIG; - uint16_t fillorder = FILLORDER_LSB2MSB; - int fd; - char *outfilename = NULL; - TIFF *out; + uint32 width = 0, length = 0, linebytes, bufsize; + uint32 nbands = 1; /* number of bands in input image*/ + _TIFF_off_t hdr_size = 0; /* size of the header to skip */ + TIFFDataType dtype = TIFF_BYTE; + int16 depth = 1; /* bytes per pixel in input image */ + int swab = 0; /* byte swapping flag */ + InterleavingType interleaving = 0; /* interleaving type flag */ + uint32 rowsperstrip = (uint32) -1; + uint16 photometric = PHOTOMETRIC_MINISBLACK; + uint16 config = PLANARCONFIG_CONTIG; + uint16 fillorder = FILLORDER_LSB2MSB; + int fd; + char *outfilename = NULL; + TIFF *out; - uint32_t row, col, band; - int c; - unsigned char *buf = NULL, *buf1 = NULL; + uint32 row, col, band; + int c; + unsigned char *buf = NULL, *buf1 = NULL; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - while ((c = getopt(argc, argv, "c:r:H:w:l:b:d:LMp:si:o:h")) != -1) - { - switch (c) - { - case 'c': /* compression scheme */ - if (!processCompressOptions(optarg)) - usage(EXIT_FAILURE); - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case 'H': /* size of input image file header */ - hdr_size = atoi(optarg); - break; - case 'w': /* input image width */ - width = atoi(optarg); - break; - case 'l': /* input image length */ - length = atoi(optarg); - break; - case 'b': /* number of bands in input image */ - nbands = atoi(optarg); - break; - case 'd': /* type of samples in input image */ - if (strncmp(optarg, "byte", 4) == 0) - dtype = TIFF_BYTE; - else if (strncmp(optarg, "short", 5) == 0) - dtype = TIFF_SHORT; - else if (strncmp(optarg, "long", 4) == 0) - dtype = TIFF_LONG; - else if (strncmp(optarg, "sbyte", 5) == 0) - dtype = TIFF_SBYTE; - else if (strncmp(optarg, "sshort", 6) == 0) - dtype = TIFF_SSHORT; - else if (strncmp(optarg, "slong", 5) == 0) - dtype = TIFF_SLONG; - else if (strncmp(optarg, "float", 5) == 0) - dtype = TIFF_FLOAT; - else if (strncmp(optarg, "double", 6) == 0) - dtype = TIFF_DOUBLE; - else - dtype = TIFF_BYTE; - depth = TIFFDataWidth(dtype); - break; - case 'L': /* input has lsb-to-msb fillorder */ - fillorder = FILLORDER_LSB2MSB; - break; - case 'M': /* input has msb-to-lsb fillorder */ - fillorder = FILLORDER_MSB2LSB; - break; - case 'p': /* photometric interpretation */ - if (strncmp(optarg, "miniswhite", 10) == 0) - photometric = PHOTOMETRIC_MINISWHITE; - else if (strncmp(optarg, "minisblack", 10) == 0) - photometric = PHOTOMETRIC_MINISBLACK; - else if (strncmp(optarg, "rgb", 3) == 0) - photometric = PHOTOMETRIC_RGB; - else if (strncmp(optarg, "cmyk", 4) == 0) - photometric = PHOTOMETRIC_SEPARATED; - else if (strncmp(optarg, "ycbcr", 5) == 0) - photometric = PHOTOMETRIC_YCBCR; - else if (strncmp(optarg, "cielab", 6) == 0) - photometric = PHOTOMETRIC_CIELAB; - else if (strncmp(optarg, "icclab", 6) == 0) - photometric = PHOTOMETRIC_ICCLAB; - else if (strncmp(optarg, "itulab", 6) == 0) - photometric = PHOTOMETRIC_ITULAB; - else - photometric = PHOTOMETRIC_MINISBLACK; - break; - case 's': /* do we need to swap bytes? */ - swab = 1; - break; - case 'i': /* type of interleaving */ - if (strncmp(optarg, "pixel", 4) == 0) - interleaving = PIXEL; - else if (strncmp(optarg, "band", 6) == 0) - interleaving = BAND; - else - interleaving = 0; - break; - case 'o': - outfilename = optarg; - break; - case 'h': - usage(EXIT_SUCCESS); - default: - break; - } - } - - if (argc - optind < 2) - usage(EXIT_FAILURE); - - fd = open(argv[optind], O_RDONLY | O_BINARY, 0); - if (fd < 0) - { - fprintf(stderr, "%s: %s: Cannot open input file.\n", argv[0], - argv[optind]); - return (EXIT_FAILURE); - } - - if (nbands == 0) - { - fprintf(stderr, "The number of bands is illegal.\n"); - return (-1); - } - - if (guessSize(fd, dtype, hdr_size, nbands, swab, &width, &length) < 0) - return EXIT_FAILURE; - - if (outfilename == NULL) - outfilename = argv[optind + 1]; - out = TIFFOpen(outfilename, "w"); - if (out == NULL) - { - fprintf(stderr, "%s: %s: Cannot open file for output.\n", argv[0], - outfilename); - return (EXIT_FAILURE); - } - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, length); - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, nbands); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, depth * 8); - TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); - switch (dtype) - { - case TIFF_BYTE: - case TIFF_SHORT: - case TIFF_LONG: - TIFFSetField(out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); - break; - case TIFF_SBYTE: - case TIFF_SSHORT: - case TIFF_SLONG: - TIFFSetField(out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); - break; - case TIFF_FLOAT: - case TIFF_DOUBLE: - TIFFSetField(out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); - break; - default: - TIFFSetField(out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_VOID); - break; - } - if (compression == (uint16_t)-1) - compression = COMPRESSION_PACKBITS; - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - switch (compression) - { - case COMPRESSION_JPEG: - if (photometric == PHOTOMETRIC_RGB && - jpegcolormode == JPEGCOLORMODE_RGB) - photometric = PHOTOMETRIC_YCBCR; - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != 0) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - break; - } - switch (interleaving) - { - case BAND: /* band interleaved data */ - linebytes = width * depth; - buf = (unsigned char *)_TIFFmalloc(linebytes); - break; - case PIXEL: /* pixel interleaved data */ - default: - linebytes = width * nbands * depth; - break; - } - bufsize = width * nbands * depth; - buf1 = (unsigned char *)_TIFFmalloc(bufsize); - - rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); - if (rowsperstrip > length) - { - rowsperstrip = length; - } - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - - _TIFF_lseek_f(fd, hdr_size, SEEK_SET); /* Skip the file header */ - for (row = 0; row < length; row++) - { - switch (interleaving) - { - case BAND: /* band interleaved data */ - for (band = 0; band < nbands; band++) - { - if (_TIFF_lseek_f( - fd, hdr_size + (length * band + row) * linebytes, - SEEK_SET) == (_TIFF_off_t)-1) - { - fprintf(stderr, - "%s: %s: scanline %" PRIu32 ": seek error.\n", - argv[0], argv[optind], row); - break; - } - if (read(fd, buf, linebytes) < 0) - { - fprintf(stderr, - "%s: %s: scanline %" PRIu32 ": Read error.\n", - argv[0], argv[optind], row); - break; - } - if (swab) /* Swap bytes if needed */ - swapBytesInScanline(buf, width, dtype); - for (col = 0; col < width; col++) - memcpy(buf1 + (col * nbands + band) * depth, - buf + col * depth, depth); - } - break; - case PIXEL: /* pixel interleaved data */ - default: - if (read(fd, buf1, bufsize) < 0) - { - fprintf(stderr, - "%s: %s: scanline %" PRIu32 ": Read error.\n", - argv[0], argv[optind], row); - break; - } - if (swab) /* Swap bytes if needed */ - swapBytesInScanline(buf1, width, dtype); - break; + while ((c = getopt(argc, argv, "c:r:H:w:l:b:d:LMp:si:o:h")) != -1) { + switch (c) { + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(EXIT_FAILURE); + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case 'H': /* size of input image file header */ + hdr_size = atoi(optarg); + break; + case 'w': /* input image width */ + width = atoi(optarg); + break; + case 'l': /* input image length */ + length = atoi(optarg); + break; + case 'b': /* number of bands in input image */ + nbands = atoi(optarg); + break; + case 'd': /* type of samples in input image */ + if (strncmp(optarg, "byte", 4) == 0) + dtype = TIFF_BYTE; + else if (strncmp(optarg, "short", 5) == 0) + dtype = TIFF_SHORT; + else if (strncmp(optarg, "long", 4) == 0) + dtype = TIFF_LONG; + else if (strncmp(optarg, "sbyte", 5) == 0) + dtype = TIFF_SBYTE; + else if (strncmp(optarg, "sshort", 6) == 0) + dtype = TIFF_SSHORT; + else if (strncmp(optarg, "slong", 5) == 0) + dtype = TIFF_SLONG; + else if (strncmp(optarg, "float", 5) == 0) + dtype = TIFF_FLOAT; + else if (strncmp(optarg, "double", 6) == 0) + dtype = TIFF_DOUBLE; + else + dtype = TIFF_BYTE; + depth = TIFFDataWidth(dtype); + break; + case 'L': /* input has lsb-to-msb fillorder */ + fillorder = FILLORDER_LSB2MSB; + break; + case 'M': /* input has msb-to-lsb fillorder */ + fillorder = FILLORDER_MSB2LSB; + break; + case 'p': /* photometric interpretation */ + if (strncmp(optarg, "miniswhite", 10) == 0) + photometric = PHOTOMETRIC_MINISWHITE; + else if (strncmp(optarg, "minisblack", 10) == 0) + photometric = PHOTOMETRIC_MINISBLACK; + else if (strncmp(optarg, "rgb", 3) == 0) + photometric = PHOTOMETRIC_RGB; + else if (strncmp(optarg, "cmyk", 4) == 0) + photometric = PHOTOMETRIC_SEPARATED; + else if (strncmp(optarg, "ycbcr", 5) == 0) + photometric = PHOTOMETRIC_YCBCR; + else if (strncmp(optarg, "cielab", 6) == 0) + photometric = PHOTOMETRIC_CIELAB; + else if (strncmp(optarg, "icclab", 6) == 0) + photometric = PHOTOMETRIC_ICCLAB; + else if (strncmp(optarg, "itulab", 6) == 0) + photometric = PHOTOMETRIC_ITULAB; + else + photometric = PHOTOMETRIC_MINISBLACK; + break; + case 's': /* do we need to swap bytes? */ + swab = 1; + break; + case 'i': /* type of interleaving */ + if (strncmp(optarg, "pixel", 4) == 0) + interleaving = PIXEL; + else if (strncmp(optarg, "band", 6) == 0) + interleaving = BAND; + else + interleaving = 0; + break; + case 'o': + outfilename = optarg; + break; + case 'h': + usage(EXIT_SUCCESS); + default: + break; + } } - if (TIFFWriteScanline(out, buf1, row, 0) < 0) - { - fprintf(stderr, "%s: %s: scanline %" PRIu32 ": Write error.\n", - argv[0], outfilename, row); - break; - } - } - if (buf) - _TIFFfree(buf); - if (buf1) - _TIFFfree(buf1); - TIFFClose(out); - return (EXIT_SUCCESS); + if (argc - optind < 2) + usage(EXIT_FAILURE); + + fd = open(argv[optind], O_RDONLY|O_BINARY, 0); + if (fd < 0) { + fprintf(stderr, "%s: %s: Cannot open input file.\n", + argv[0], argv[optind]); + return (EXIT_FAILURE); + } + + if (guessSize(fd, dtype, hdr_size, nbands, swab, &width, &length) < 0) + return EXIT_FAILURE; + + if (outfilename == NULL) + outfilename = argv[optind+1]; + out = TIFFOpen(outfilename, "w"); + if (out == NULL) { + fprintf(stderr, "%s: %s: Cannot open file for output.\n", + argv[0], outfilename); + return (EXIT_FAILURE); + } + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, length); + TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, nbands); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, depth * 8); + TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, photometric); + switch (dtype) { + case TIFF_BYTE: + case TIFF_SHORT: + case TIFF_LONG: + TIFFSetField(out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT); + break; + case TIFF_SBYTE: + case TIFF_SSHORT: + case TIFF_SLONG: + TIFFSetField(out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_INT); + break; + case TIFF_FLOAT: + case TIFF_DOUBLE: + TIFFSetField(out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); + break; + default: + TIFFSetField(out, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_VOID); + break; + } + if (compression == (uint16) -1) + compression = COMPRESSION_PACKBITS; + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + switch (compression) { + case COMPRESSION_JPEG: + if (photometric == PHOTOMETRIC_RGB + && jpegcolormode == JPEGCOLORMODE_RGB) + photometric = PHOTOMETRIC_YCBCR; + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); + break; + case COMPRESSION_LZW: + case COMPRESSION_DEFLATE: + if (predictor != 0) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + break; + } + switch(interleaving) { + case BAND: /* band interleaved data */ + linebytes = width * depth; + buf = (unsigned char *)_TIFFmalloc(linebytes); + break; + case PIXEL: /* pixel interleaved data */ + default: + linebytes = width * nbands * depth; + break; + } + bufsize = width * nbands * depth; + buf1 = (unsigned char *)_TIFFmalloc(bufsize); + + rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); + if (rowsperstrip > length) { + rowsperstrip = length; + } + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip ); + + _TIFF_lseek_f(fd, hdr_size, SEEK_SET); /* Skip the file header */ + for (row = 0; row < length; row++) { + switch(interleaving) { + case BAND: /* band interleaved data */ + for (band = 0; band < nbands; band++) { + if (_TIFF_lseek_f(fd, + hdr_size + (length*band+row)*linebytes, + SEEK_SET) == (_TIFF_off_t)-1) { + fprintf(stderr, + "%s: %s: scanline %lu: seek error.\n", + argv[0], argv[optind], + (unsigned long) row); + break; + } + if (read(fd, buf, linebytes) < 0) { + fprintf(stderr, + "%s: %s: scanline %lu: Read error.\n", + argv[0], argv[optind], + (unsigned long) row); + break; + } + if (swab) /* Swap bytes if needed */ + swapBytesInScanline(buf, width, dtype); + for (col = 0; col < width; col++) + memcpy(buf1 + (col*nbands+band)*depth, + buf + col * depth, depth); + } + break; + case PIXEL: /* pixel interleaved data */ + default: + if (read(fd, buf1, bufsize) < 0) { + fprintf(stderr, + "%s: %s: scanline %lu: Read error.\n", + argv[0], argv[optind], + (unsigned long) row); + break; + } + if (swab) /* Swap bytes if needed */ + swapBytesInScanline(buf1, width, dtype); + break; + } + + if (TIFFWriteScanline(out, buf1, row, 0) < 0) { + fprintf(stderr, "%s: %s: scanline %lu: Write error.\n", + argv[0], outfilename, (unsigned long) row); + break; + } + } + if (buf) + _TIFFfree(buf); + if (buf1) + _TIFFfree(buf1); + TIFFClose(out); + return (EXIT_SUCCESS); } -static void swapBytesInScanline(void *buf, uint32_t width, TIFFDataType dtype) +static void +swapBytesInScanline(void *buf, uint32 width, TIFFDataType dtype) { - switch (dtype) - { - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16_t *)buf, (unsigned long)width); - break; - case TIFF_LONG: - case TIFF_SLONG: - TIFFSwabArrayOfLong((uint32_t *)buf, (unsigned long)width); - break; - /* case TIFF_FLOAT: */ /* FIXME */ - case TIFF_DOUBLE: - TIFFSwabArrayOfDouble((double *)buf, (unsigned long)width); - break; - default: - break; - } + switch (dtype) { + case TIFF_SHORT: + case TIFF_SSHORT: + TIFFSwabArrayOfShort((uint16*)buf, + (unsigned long)width); + break; + case TIFF_LONG: + case TIFF_SLONG: + TIFFSwabArrayOfLong((uint32*)buf, + (unsigned long)width); + break; + /* case TIFF_FLOAT: */ /* FIXME */ + case TIFF_DOUBLE: + TIFFSwabArrayOfDouble((double*)buf, + (unsigned long)width); + break; + default: + break; + } } -static int guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, - uint32_t nbands, int swab, uint32_t *width, - uint32_t *length) +static int +guessSize(int fd, TIFFDataType dtype, _TIFF_off_t hdr_size, uint32 nbands, + int swab, uint32 *width, uint32 *length) { - const float longt = 40.0; /* maximum possible height/width ratio */ - char *buf1, *buf2; - _TIFF_stat_s filestat; - uint32_t w, h, scanlinesize, imagesize; - uint32_t depth = TIFFDataWidth(dtype); - double cor_coef = 0, tmp; + const float longt = 40.0; /* maximum possible height/width ratio */ + char *buf1, *buf2; + _TIFF_stat_s filestat; + uint32 w, h, scanlinesize, imagesize; + uint32 depth = TIFFDataWidth(dtype); + double cor_coef = 0, tmp; - if (_TIFF_fstat_f(fd, &filestat) == -1) - { - fprintf(stderr, "Failed to obtain file size.\n"); - return -1; - } - - if (filestat.st_size < hdr_size) - { - fprintf(stderr, "Too large header size specified.\n"); - return -1; - } - - imagesize = (filestat.st_size - hdr_size) / nbands / depth; - - if (*width != 0 && *length == 0) - { - fprintf(stderr, "Image height is not specified.\n"); - - *length = imagesize / *width; - - fprintf(stderr, "Height is guessed as %" PRIu32 ".\n", *length); - - return 1; - } - else if (*width == 0 && *length != 0) - { - fprintf(stderr, "Image width is not specified.\n"); - - *width = imagesize / *length; - - fprintf(stderr, "Width is guessed as %" PRIu32 ".\n", *width); - - return 1; - } - else if (*width == 0 && *length == 0) - { - unsigned int fail = 0; - fprintf(stderr, "Image width and height are not specified.\n"); - w = (uint32_t)sqrt(imagesize / longt); - if (w == 0) - { - fprintf(stderr, "Too small image size.\n"); - return -1; + if (_TIFF_fstat_f(fd, &filestat) == -1) { + fprintf(stderr, "Failed to obtain file size.\n"); + return -1; } - for (; w < sqrt(imagesize * longt); w++) - { - if (imagesize % w == 0) - { - scanlinesize = w * depth; - h = imagesize / w; - if (h < 2) - continue; - /* reads 2 lines at the middle of the image and calculate their - * correlation. it works for h >= 2. (in this case it will - * compare line 0 and line 1 */ - buf1 = _TIFFmalloc(scanlinesize); - buf2 = _TIFFmalloc(scanlinesize); - do + if (filestat.st_size < hdr_size) { + fprintf(stderr, "Too large header size specified.\n"); + return -1; + } + + imagesize = (filestat.st_size - hdr_size) / nbands / depth; + + if (*width != 0 && *length == 0) { + fprintf(stderr, "Image height is not specified.\n"); + + *length = imagesize / *width; + + fprintf(stderr, "Height is guessed as %lu.\n", + (unsigned long)*length); + + return 1; + } else if (*width == 0 && *length != 0) { + fprintf(stderr, "Image width is not specified.\n"); + + *width = imagesize / *length; + + fprintf(stderr, "Width is guessed as %lu.\n", + (unsigned long)*width); + + return 1; + } else if (*width == 0 && *length == 0) { + unsigned int fail = 0; + fprintf(stderr, "Image width and height are not specified.\n"); + w = (uint32) sqrt(imagesize / longt); + if( w == 0 ) { - if (_TIFF_lseek_f( - fd, hdr_size + (int)((h - 1) / 2) * scanlinesize, - SEEK_SET) == (_TIFF_off_t)-1) - { - fprintf(stderr, "seek error.\n"); - fail = 1; - break; - } - /* read line (h-1)/2 */ - if (read(fd, buf1, scanlinesize) != (long)scanlinesize) - { - fprintf(stderr, "read error.\n"); - fail = 1; - break; - } - /* read line ((h-1)/2)+1 */ - if (read(fd, buf2, scanlinesize) != (long)scanlinesize) - { - fprintf(stderr, "read error.\n"); - fail = 1; - break; - } - if (swab) - { - swapBytesInScanline(buf1, w, dtype); - swapBytesInScanline(buf2, w, dtype); - } - if (0 == memcmp(buf1, buf2, scanlinesize)) - { - *width = w, *length = h; - } - else - { - tmp = fabs(correlation(buf1, buf2, w, dtype)); - if (tmp > cor_coef) - { - cor_coef = tmp; - *width = w, *length = h; - } - } - } while (0); + fprintf(stderr, "Too small image size.\n"); + return -1; + } - _TIFFfree(buf1); - _TIFFfree(buf2); - } - } + for (; + w < sqrt(imagesize * longt); + w++) { + if (imagesize % w == 0) { + scanlinesize = w * depth; + h = imagesize / w; + if (h < 2) + continue; + /* reads 2 lines at the middle of the image and calculate their correlation. + * it works for h >= 2. (in this case it will compare line 0 and line 1 */ + buf1 = _TIFFmalloc(scanlinesize); + buf2 = _TIFFmalloc(scanlinesize); + do { + if (_TIFF_lseek_f(fd, hdr_size + (int)((h - 1)/2)*scanlinesize, + SEEK_SET) == (_TIFF_off_t)-1) { + fprintf(stderr, "seek error.\n"); + fail=1; + break; + } + /* read line (h-1)/2 */ + if (read(fd, buf1, scanlinesize) != + (long) scanlinesize) { + fprintf(stderr, "read error.\n"); + fail=1; + break; + } + /* read line ((h-1)/2)+1 */ + if (read(fd, buf2, scanlinesize) != + (long) scanlinesize) { + fprintf(stderr, "read error.\n"); + fail=1; + break; + } + if (swab) { + swapBytesInScanline(buf1, w, dtype); + swapBytesInScanline(buf2, w, dtype); + } + if (0 == memcmp(buf1, buf2, scanlinesize)) { + *width = w, *length = h; + } else { + tmp = fabs(correlation(buf1, buf2, + w, dtype)); + if (tmp > cor_coef) { + cor_coef = tmp; + *width = w, *length = h; + } + } + } while (0); - if (fail) - { - return -1; - } + _TIFFfree(buf1); + _TIFFfree(buf2); + } + } - fprintf(stderr, - "Width is guessed as %" PRIu32 ", height is guessed as %" PRIu32 - ".\n", - *width, *length); + if (fail) { + return -1; + } - return 1; - } - else - { - if (filestat.st_size < - (_TIFF_off_t)(hdr_size + (*width) * (*length) * nbands * depth)) - { - fprintf(stderr, "Input file too small.\n"); - return -1; - } - } + fprintf(stderr, + "Width is guessed as %lu, height is guessed as %lu.\n", + (unsigned long)*width, (unsigned long)*length); - return 1; + return 1; + } else { + if (filestat.st_size<(_TIFF_off_t)(hdr_size+(*width)*(*length)*nbands*depth)) { + fprintf(stderr, "Input file too small.\n"); + return -1; + } + } + + return 1; } /* Calculate correlation coefficient between two numeric vectors */ -static double correlation(void *buf1, void *buf2, uint32_t n_elem, - TIFFDataType dtype) +static double +correlation(void *buf1, void *buf2, uint32 n_elem, TIFFDataType dtype) { - double X, Y, M1 = 0.0, M2 = 0.0, D1 = 0.0, D2 = 0.0, K = 0.0; - uint32_t i; + double X, Y, M1 = 0.0, M2 = 0.0, D1 = 0.0, D2 = 0.0, K = 0.0; + uint32 i; - switch (dtype) - { - case TIFF_BYTE: - default: - for (i = 0; i < n_elem; i++) - { - X = ((unsigned char *)buf1)[i]; - Y = ((unsigned char *)buf2)[i]; - M1 += X, M2 += Y; - D1 += X * X, D2 += Y * Y; - K += X * Y; - } - break; - case TIFF_SBYTE: - for (i = 0; i < n_elem; i++) - { - X = ((signed char *)buf1)[i]; - Y = ((signed char *)buf2)[i]; - M1 += X, M2 += Y; - D1 += X * X, D2 += Y * Y; - K += X * Y; - } - break; - case TIFF_SHORT: - for (i = 0; i < n_elem; i++) - { - X = ((uint16_t *)buf1)[i]; - Y = ((uint16_t *)buf2)[i]; - M1 += X, M2 += Y; - D1 += X * X, D2 += Y * Y; - K += X * Y; - } - break; - case TIFF_SSHORT: - for (i = 0; i < n_elem; i++) - { - X = ((int16_t *)buf1)[i]; - Y = ((int16_t *)buf2)[i]; - M1 += X, M2 += Y; - D1 += X * X, D2 += Y * Y; - K += X * Y; - } - break; - case TIFF_LONG: - for (i = 0; i < n_elem; i++) - { - X = ((uint32_t *)buf1)[i]; - Y = ((uint32_t *)buf2)[i]; - M1 += X, M2 += Y; - D1 += X * X, D2 += Y * Y; - K += X * Y; - } - break; - case TIFF_SLONG: - for (i = 0; i < n_elem; i++) - { - X = ((int32_t *)buf1)[i]; - Y = ((int32_t *)buf2)[i]; - M1 += X, M2 += Y; - D1 += X * X, D2 += Y * Y; - K += X * Y; - } - break; - case TIFF_FLOAT: - for (i = 0; i < n_elem; i++) - { - X = ((float *)buf1)[i]; - Y = ((float *)buf2)[i]; - M1 += X, M2 += Y; - D1 += X * X, D2 += Y * Y; - K += X * Y; - } - break; - case TIFF_DOUBLE: - for (i = 0; i < n_elem; i++) - { - X = ((double *)buf1)[i]; - Y = ((double *)buf2)[i]; - M1 += X, M2 += Y; - D1 += X * X, D2 += Y * Y; - K += X * Y; - } - break; - } + switch (dtype) { + case TIFF_BYTE: + default: + for (i = 0; i < n_elem; i++) { + X = ((unsigned char *)buf1)[i]; + Y = ((unsigned char *)buf2)[i]; + M1 += X, M2 += Y; + D1 += X * X, D2 += Y * Y; + K += X * Y; + } + break; + case TIFF_SBYTE: + for (i = 0; i < n_elem; i++) { + X = ((signed char *)buf1)[i]; + Y = ((signed char *)buf2)[i]; + M1 += X, M2 += Y; + D1 += X * X, D2 += Y * Y; + K += X * Y; + } + break; + case TIFF_SHORT: + for (i = 0; i < n_elem; i++) { + X = ((uint16 *)buf1)[i]; + Y = ((uint16 *)buf2)[i]; + M1 += X, M2 += Y; + D1 += X * X, D2 += Y * Y; + K += X * Y; + } + break; + case TIFF_SSHORT: + for (i = 0; i < n_elem; i++) { + X = ((int16 *)buf1)[i]; + Y = ((int16 *)buf2)[i]; + M1 += X, M2 += Y; + D1 += X * X, D2 += Y * Y; + K += X * Y; + } + break; + case TIFF_LONG: + for (i = 0; i < n_elem; i++) { + X = ((uint32 *)buf1)[i]; + Y = ((uint32 *)buf2)[i]; + M1 += X, M2 += Y; + D1 += X * X, D2 += Y * Y; + K += X * Y; + } + break; + case TIFF_SLONG: + for (i = 0; i < n_elem; i++) { + X = ((int32 *)buf1)[i]; + Y = ((int32 *)buf2)[i]; + M1 += X, M2 += Y; + D1 += X * X, D2 += Y * Y; + K += X * Y; + } + break; + case TIFF_FLOAT: + for (i = 0; i < n_elem; i++) { + X = ((float *)buf1)[i]; + Y = ((float *)buf2)[i]; + M1 += X, M2 += Y; + D1 += X * X, D2 += Y * Y; + K += X * Y; + } + break; + case TIFF_DOUBLE: + for (i = 0; i < n_elem; i++) { + X = ((double *)buf1)[i]; + Y = ((double *)buf2)[i]; + M1 += X, M2 += Y; + D1 += X * X, D2 += Y * Y; + K += X * Y; + } + break; + } - M1 /= n_elem; - M2 /= n_elem; - D1 -= M1 * M1 * n_elem; - D2 -= M2 * M2 * n_elem; - if (D1 * D2 == 0.0) - return 0.0; /* avoid divide by zero */ - K = (K - M1 * M2 * n_elem) / sqrt(D1 * D2); + M1 /= n_elem; + M2 /= n_elem; + D1 -= M1 * M1 * n_elem; + D2 -= M2 * M2 * n_elem; + if (D1 * D2 == 0.0) return 0.0; /* avoid divide by zero */ + K = (K - M1 * M2 * n_elem) / sqrt(D1 * D2); - return K; + return K; } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) { - if (strcmp(opt, "none") == 0) - compression = COMPRESSION_NONE; - else if (strcmp(opt, "packbits") == 0) - compression = COMPRESSION_PACKBITS; - else if (strncmp(opt, "jpeg", 4) == 0) - { - char *cp = strchr(opt, ':'); + if (strcmp(opt, "none") == 0) + compression = COMPRESSION_NONE; + else if (strcmp(opt, "packbits") == 0) + compression = COMPRESSION_PACKBITS; + else if (strncmp(opt, "jpeg", 4) == 0) { + char* cp = strchr(opt, ':'); - compression = COMPRESSION_JPEG; - while (cp) - { - if (isdigit((int)cp[1])) - quality = atoi(cp + 1); - else if (cp[1] == 'r') - jpegcolormode = JPEGCOLORMODE_RAW; - else - usage(EXIT_FAILURE); + compression = COMPRESSION_JPEG; + while( cp ) + { + if (isdigit((int)cp[1])) + quality = atoi(cp+1); + else if (cp[1] == 'r' ) + jpegcolormode = JPEGCOLORMODE_RAW; + else + usage(EXIT_FAILURE); - cp = strchr(cp + 1, ':'); - } - } - else if (strncmp(opt, "lzw", 3) == 0) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strncmp(opt, "zip", 3) == 0) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + cp = strchr(cp+1,':'); + } + } else if (strncmp(opt, "lzw", 3) == 0) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strncmp(opt, "zip", 3) == 0) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -static const char usage_info[] = - "Create a TIFF file from raw data\n\n" - "usage: raw2tiff [options] input.raw output.tif\n" - "where options are:\n" - " -L input data has LSB2MSB bit order (default)\n" - " -M input data has MSB2LSB bit order\n" - " -r # make each strip have no more than # rows\n" - " -H # size of input image file header in bytes (0 by " - "default)\n" - " -w # width of input image in pixels\n" - " -l # length of input image in lines\n" - " -b # number of bands in input image (1 by default)\n" - "\n" - " -d data_type type of samples in input image\n" - "where data_type may be:\n" - " byte 8-bit unsigned integer (default)\n" - " short 16-bit unsigned integer\n" - " long 32-bit unsigned integer\n" - " sbyte 8-bit signed integer\n" - " sshort 16-bit signed integer\n" - " slong 32-bit signed integer\n" - " float 32-bit IEEE floating point\n" - " double 64-bit IEEE floating point\n" - "\n" - " -p photo photometric interpretation (color space) of the input image\n" - "where photo may be:\n" - " miniswhite white color represented with 0 value\n" - " minisblack black color represented with 0 value (default)\n" - " rgb image has RGB color model\n" - " cmyk image has CMYK (separated) color model\n" - " ycbcr image has YCbCr color model\n" - " cielab image has CIE L*a*b color model\n" - " icclab image has ICC L*a*b color model\n" - " itulab image has ITU L*a*b color model\n" - "\n" - " -s swap bytes fetched from input file\n" - "\n" - " -i config type of samples interleaving in input image\n" - "where config may be:\n" - " pixel pixel interleaved data (default)\n" - " band band interleaved data\n" - "\n" -#ifdef LZW_SUPPORT - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" - /* " LZW options:\n" */ - " # set predictor value\n" - " For example, -c lzw:2 for LZW-encoded data with horizontal " - "differencing\n" -#endif -#ifdef ZIP_SUPPORT - " -c zip[:opts] compress output with deflate encoding\n" - /* " Deflate (ZIP) options:\n" */ - " # set predictor value\n" -#endif -#ifdef JPEG_SUPPORT - " -c jpeg[:opts] compress output with JPEG encoding\n" - /* " JPEG options:\n" */ - " # set compression quality level (0-100, default 75)\n" - " r output color image as RGB rather than YCbCr\n" - " For example, -c jpeg:r:50 for JPEG-encoded RGB data with 50% comp. " - "quality\n" -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits compress output with packbits encoding\n" -#endif -#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(JPEG_SUPPORT) || \ - defined(PACKBITS_SUPPORT) - " -c none use no compression algorithm on output\n" -#endif - "\n" - " -o out.tif write output to out.tif\n" - " -h this help message\n"; +static const char* stuff[] = { +"raw2tiff --- tool for converting raw byte sequences in TIFF images", +"usage: raw2tiff [options] input.raw output.tif", +"where options are:", +" -L input data has LSB2MSB bit order (default)", +" -M input data has MSB2LSB bit order", +" -r # make each strip have no more than # rows", +" -H # size of input image file header in bytes (0 by default)", +" -w # width of input image in pixels", +" -l # length of input image in lines", +" -b # number of bands in input image (1 by default)", +"", +" -d data_type type of samples in input image", +"where data_type may be:", +" byte 8-bit unsigned integer (default)", +" short 16-bit unsigned integer", +" long 32-bit unsigned integer", +" sbyte 8-bit signed integer", +" sshort 16-bit signed integer", +" slong 32-bit signed integer", +" float 32-bit IEEE floating point", +" double 64-bit IEEE floating point", +"", +" -p photo photometric interpretation (color space) of the input image", +"where photo may be:", +" miniswhite white color represented with 0 value", +" minisblack black color represented with 0 value (default)", +" rgb image has RGB color model", +" cmyk image has CMYK (separated) color model", +" ycbcr image has YCbCr color model", +" cielab image has CIE L*a*b color model", +" icclab image has ICC L*a*b color model", +" itulab image has ITU L*a*b color model", +"", +" -s swap bytes fetched from input file", +"", +" -i config type of samples interleaving in input image", +"where config may be:", +" pixel pixel interleaved data (default)", +" band band interleaved data", +"", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c jpeg[:opts] compress output with JPEG encoding", +" -c packbits compress output with packbits encoding", +" -c none use no compression algorithm on output", +"", +"JPEG options:", +" # set compression quality level (0-100, default 75)", +" r output color image as RGB rather than YCbCr", +"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", +"", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +" -o out.tif write output to out.tif", +" -h this help message", +NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/rgb2ycbcr.c b/thirdparty/SDL2_image/external/libtiff/tools/rgb2ycbcr.c index d4eabbb10..482cc5b47 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/rgb2ycbcr.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/rgb2ycbcr.c @@ -2,39 +2,42 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" #include -#include #include +#include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif -#include "tiffio.h" #include "tiffiop.h" +#include "tiffio.h" #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 @@ -43,177 +46,173 @@ #define EXIT_FAILURE 1 #endif -#define streq(a, b) (strcmp(a, b) == 0) -#define CopyField(tag, v) \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v) +#define streq(a,b) (strcmp(a,b) == 0) +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #ifndef howmany -#define howmany(x, y) (((x) + ((y)-1)) / (y)) +#define howmany(x, y) (((x)+((y)-1))/(y)) #endif -#define roundup(x, y) (howmany(x, y) * ((uint32_t)(y))) +#define roundup(x, y) (howmany(x,y)*((uint32)(y))) -#define LumaRed ycbcrCoeffs[0] -#define LumaGreen ycbcrCoeffs[1] -#define LumaBlue ycbcrCoeffs[2] +#define LumaRed ycbcrCoeffs[0] +#define LumaGreen ycbcrCoeffs[1] +#define LumaBlue ycbcrCoeffs[2] -uint16_t compression = COMPRESSION_PACKBITS; -uint32_t rowsperstrip = (uint32_t)-1; +uint16 compression = COMPRESSION_PACKBITS; +uint32 rowsperstrip = (uint32) -1; -uint16_t horizSubSampling = 2; /* YCbCr horizontal subsampling */ -uint16_t vertSubSampling = 2; /* YCbCr vertical subsampling */ -float ycbcrCoeffs[3] = {.299F, .587F, .114F}; +uint16 horizSubSampling = 2; /* YCbCr horizontal subsampling */ +uint16 vertSubSampling = 2; /* YCbCr vertical subsampling */ +float ycbcrCoeffs[3] = { .299F, .587F, .114F }; /* default coding range is CCIR Rec 601-1 with no headroom/footroom */ -float refBlackWhite[6] = {0.F, 255.F, 128.F, 255.F, 128.F, 255.F}; +float refBlackWhite[6] = { 0.F, 255.F, 128.F, 255.F, 128.F, 255.F }; -static int tiffcvt(TIFF *in, TIFF *out); -static void usage(int code); -static void setupLumaTables(void); +static int tiffcvt(TIFF* in, TIFF* out); +static void usage(int code); +static void setupLumaTables(void); -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - TIFF *in, *out; - int c; + TIFF *in, *out; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char *optarg; #endif - while ((c = getopt(argc, argv, "c:h:r:v:z")) != -1) - switch (c) - { - case 'c': - if (streq(optarg, "none")) - compression = COMPRESSION_NONE; - else if (streq(optarg, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (streq(optarg, "lzw")) - compression = COMPRESSION_LZW; - else if (streq(optarg, "jpeg")) - compression = COMPRESSION_JPEG; - else if (streq(optarg, "zip")) - compression = COMPRESSION_ADOBE_DEFLATE; - else - usage(EXIT_FAILURE); - break; - case 'h': - horizSubSampling = atoi(optarg); - if (horizSubSampling != 1 && horizSubSampling != 2 && - horizSubSampling != 4) - usage(EXIT_FAILURE); - break; - case 'v': - vertSubSampling = atoi(optarg); - if (vertSubSampling != 1 && vertSubSampling != 2 && - vertSubSampling != 4) - usage(EXIT_FAILURE); - break; - case 'r': - rowsperstrip = atoi(optarg); - break; - case 'z': /* CCIR Rec 601-1 w/ headroom/footroom */ - refBlackWhite[0] = 16.; - refBlackWhite[1] = 235.; - refBlackWhite[2] = 128.; - refBlackWhite[3] = 240.; - refBlackWhite[4] = 128.; - refBlackWhite[5] = 240.; - break; - case '?': + while ((c = getopt(argc, argv, "c:h:r:v:z")) != -1) + switch (c) { + case 'c': + if (streq(optarg, "none")) + compression = COMPRESSION_NONE; + else if (streq(optarg, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (streq(optarg, "lzw")) + compression = COMPRESSION_LZW; + else if (streq(optarg, "jpeg")) + compression = COMPRESSION_JPEG; + else if (streq(optarg, "zip")) + compression = COMPRESSION_ADOBE_DEFLATE; + else + usage(EXIT_FAILURE); + break; + case 'h': + horizSubSampling = atoi(optarg); + if( horizSubSampling != 1 && horizSubSampling != 2 && horizSubSampling != 4 ) usage(EXIT_FAILURE); - /*NOTREACHED*/ - } - if (argc - optind < 2) - usage(EXIT_FAILURE); - out = TIFFOpen(argv[argc - 1], "w"); - if (out == NULL) - return (EXIT_FAILURE); - setupLumaTables(); - for (; optind < argc - 1; optind++) - { - in = TIFFOpen(argv[optind], "r"); - if (in != NULL) - { - do - { - if (!tiffcvt(in, out) || !TIFFWriteDirectory(out)) - { - (void)TIFFClose(out); - (void)TIFFClose(in); - return (1); - } - } while (TIFFReadDirectory(in)); - (void)TIFFClose(in); - } - } - (void)TIFFClose(out); - return (EXIT_SUCCESS); + break; + case 'v': + vertSubSampling = atoi(optarg); + if( vertSubSampling != 1 && vertSubSampling != 2 && vertSubSampling != 4 ) + usage(EXIT_FAILURE); + break; + case 'r': + rowsperstrip = atoi(optarg); + break; + case 'z': /* CCIR Rec 601-1 w/ headroom/footroom */ + refBlackWhite[0] = 16.; + refBlackWhite[1] = 235.; + refBlackWhite[2] = 128.; + refBlackWhite[3] = 240.; + refBlackWhite[4] = 128.; + refBlackWhite[5] = 240.; + break; + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } + if (argc - optind < 2) + usage(EXIT_FAILURE); + out = TIFFOpen(argv[argc-1], "w"); + if (out == NULL) + return (EXIT_FAILURE); + setupLumaTables(); + for (; optind < argc-1; optind++) { + in = TIFFOpen(argv[optind], "r"); + if (in != NULL) { + do { + if (!tiffcvt(in, out) || + !TIFFWriteDirectory(out)) { + (void) TIFFClose(out); + (void) TIFFClose(in); + return (1); + } + } while (TIFFReadDirectory(in)); + (void) TIFFClose(in); + } + } + (void) TIFFClose(out); + return (EXIT_SUCCESS); } -float *lumaRed; -float *lumaGreen; -float *lumaBlue; -float D1, D2; -int Yzero; +float *lumaRed; +float *lumaGreen; +float *lumaBlue; +float D1, D2; +int Yzero; -static float *setupLuma(float c) +static float* +setupLuma(float c) { - float *v = (float *)_TIFFmalloc(256 * sizeof(float)); - int i; - for (i = 0; i < 256; i++) - v[i] = c * i; - return (v); + float *v = (float *)_TIFFmalloc(256 * sizeof (float)); + int i; + for (i = 0; i < 256; i++) + v[i] = c * i; + return (v); } -static unsigned V2Code(float f, float RB, float RW, int CR) +static unsigned +V2Code(float f, float RB, float RW, int CR) { - unsigned int c = (unsigned int)((((f) * (RW - RB) / CR) + RB) + .5); - return (c > 255 ? 255 : c); + unsigned int c = (unsigned int)((((f)*(RW-RB)/CR)+RB)+.5); + return (c > 255 ? 255 : c); } -static void setupLumaTables(void) +static void +setupLumaTables(void) { - lumaRed = setupLuma(LumaRed); - lumaGreen = setupLuma(LumaGreen); - lumaBlue = setupLuma(LumaBlue); - D1 = 1.F / (2.F - 2.F * LumaBlue); - D2 = 1.F / (2.F - 2.F * LumaRed); - Yzero = V2Code(0, refBlackWhite[0], refBlackWhite[1], 255); + lumaRed = setupLuma(LumaRed); + lumaGreen = setupLuma(LumaGreen); + lumaBlue = setupLuma(LumaBlue); + D1 = 1.F/(2.F - 2.F*LumaBlue); + D2 = 1.F/(2.F - 2.F*LumaRed); + Yzero = V2Code(0, refBlackWhite[0], refBlackWhite[1], 255); } -static void cvtClump(unsigned char *op, uint32_t *raster, uint32_t ch, - uint32_t cw, uint32_t w) +static void +cvtClump(unsigned char* op, uint32* raster, uint32 ch, uint32 cw, uint32 w) { - float Y, Cb = 0, Cr = 0; - uint32_t j, k; - /* - * Convert ch-by-cw block of RGB - * to YCbCr and sample accordingly. - */ - for (k = 0; k < ch; k++) - { - for (j = 0; j < cw; j++) - { - uint32_t RGB = (raster - k * w)[j]; - Y = lumaRed[TIFFGetR(RGB)] + lumaGreen[TIFFGetG(RGB)] + - lumaBlue[TIFFGetB(RGB)]; - /* accumulate chrominance */ - Cb += (TIFFGetB(RGB) - Y) * D1; - Cr += (TIFFGetR(RGB) - Y) * D2; - /* emit luminence */ - *op++ = V2Code(Y, refBlackWhite[0], refBlackWhite[1], 255); - } - for (; j < horizSubSampling; j++) - *op++ = Yzero; - } - for (; k < vertSubSampling; k++) - { - for (j = 0; j < horizSubSampling; j++) - *op++ = Yzero; - } - /* emit sampled chrominance values */ - *op++ = V2Code(Cb / (ch * cw), refBlackWhite[2], refBlackWhite[3], 127); - *op++ = V2Code(Cr / (ch * cw), refBlackWhite[4], refBlackWhite[5], 127); + float Y, Cb = 0, Cr = 0; + uint32 j, k; + /* + * Convert ch-by-cw block of RGB + * to YCbCr and sample accordingly. + */ + for (k = 0; k < ch; k++) { + for (j = 0; j < cw; j++) { + uint32 RGB = (raster - k*w)[j]; + Y = lumaRed[TIFFGetR(RGB)] + + lumaGreen[TIFFGetG(RGB)] + + lumaBlue[TIFFGetB(RGB)]; + /* accumulate chrominance */ + Cb += (TIFFGetB(RGB) - Y) * D1; + Cr += (TIFFGetR(RGB) - Y) * D2; + /* emit luminence */ + *op++ = V2Code(Y, + refBlackWhite[0], refBlackWhite[1], 255); + } + for (; j < horizSubSampling; j++) + *op++ = Yzero; + } + for (; k < vertSubSampling; k++) { + for (j = 0; j < horizSubSampling; j++) + *op++ = Yzero; + } + /* emit sampled chrominance values */ + *op++ = V2Code(Cb / (ch*cw), refBlackWhite[2], refBlackWhite[3], 127); + *op++ = V2Code(Cr / (ch*cw), refBlackWhite[4], refBlackWhite[5], 127); } #undef LumaRed #undef LumaGreen @@ -224,194 +223,179 @@ static void cvtClump(unsigned char *op, uint32_t *raster, uint32_t ch, * Convert a strip of RGB data to YCbCr and * sample to generate the output data. */ -static void cvtStrip(unsigned char *op, uint32_t *raster, uint32_t nrows, - uint32_t width) +static void +cvtStrip(unsigned char* op, uint32* raster, uint32 nrows, uint32 width) { - uint32_t x; - int clumpSize = vertSubSampling * horizSubSampling + 2; - uint32_t *tp; + uint32 x; + int clumpSize = vertSubSampling * horizSubSampling + 2; + uint32 *tp; - for (; nrows >= vertSubSampling; nrows -= vertSubSampling) - { - tp = raster; - for (x = width; x >= horizSubSampling; x -= horizSubSampling) - { - cvtClump(op, tp, vertSubSampling, horizSubSampling, width); - op += clumpSize; - tp += horizSubSampling; - } - if (x > 0) - { - cvtClump(op, tp, vertSubSampling, x, width); - op += clumpSize; - } - raster -= vertSubSampling * width; - } - if (nrows > 0) - { - tp = raster; - for (x = width; x >= horizSubSampling; x -= horizSubSampling) - { - cvtClump(op, tp, nrows, horizSubSampling, width); - op += clumpSize; - tp += horizSubSampling; - } - if (x > 0) - cvtClump(op, tp, nrows, x, width); - } + for (; nrows >= vertSubSampling; nrows -= vertSubSampling) { + tp = raster; + for (x = width; x >= horizSubSampling; x -= horizSubSampling) { + cvtClump(op, tp, + vertSubSampling, horizSubSampling, width); + op += clumpSize; + tp += horizSubSampling; + } + if (x > 0) { + cvtClump(op, tp, vertSubSampling, x, width); + op += clumpSize; + } + raster -= vertSubSampling*width; + } + if (nrows > 0) { + tp = raster; + for (x = width; x >= horizSubSampling; x -= horizSubSampling) { + cvtClump(op, tp, nrows, horizSubSampling, width); + op += clumpSize; + tp += horizSubSampling; + } + if (x > 0) + cvtClump(op, tp, nrows, x, width); + } } -static int cvtRaster(TIFF *tif, uint32_t *raster, uint32_t width, - uint32_t height) +static int +cvtRaster(TIFF* tif, uint32* raster, uint32 width, uint32 height) { - uint32_t y; - tstrip_t strip = 0; - tsize_t cc, acc; - unsigned char *buf; - uint32_t rwidth = roundup(width, horizSubSampling); - uint32_t rheight = roundup(height, vertSubSampling); - uint32_t nrows = (rowsperstrip > rheight ? rheight : rowsperstrip); - uint32_t rnrows = roundup(nrows, vertSubSampling); + uint32 y; + tstrip_t strip = 0; + tsize_t cc, acc; + unsigned char* buf; + uint32 rwidth = roundup(width, horizSubSampling); + uint32 rheight = roundup(height, vertSubSampling); + uint32 nrows = (rowsperstrip > rheight ? rheight : rowsperstrip); + uint32 rnrows = roundup(nrows,vertSubSampling); - cc = rnrows * rwidth + - 2 * ((rnrows * rwidth) / (horizSubSampling * vertSubSampling)); - buf = (unsigned char *)_TIFFmalloc(cc); - // FIXME unchecked malloc - for (y = height; (int32_t)y > 0; y -= nrows) - { - uint32_t nr = (y > nrows ? nrows : y); - cvtStrip(buf, raster + (y - 1) * width, nr, width); - nr = roundup(nr, vertSubSampling); - acc = nr * rwidth + - 2 * ((nr * rwidth) / (horizSubSampling * vertSubSampling)); - if (!TIFFWriteEncodedStrip(tif, strip++, buf, acc)) - { - _TIFFfree(buf); - return (0); - } - } - _TIFFfree(buf); - return (1); + cc = rnrows*rwidth + + 2*((rnrows*rwidth) / (horizSubSampling*vertSubSampling)); + buf = (unsigned char*)_TIFFmalloc(cc); + // FIXME unchecked malloc + for (y = height; (int32) y > 0; y -= nrows) { + uint32 nr = (y > nrows ? nrows : y); + cvtStrip(buf, raster + (y-1)*width, nr, width); + nr = roundup(nr, vertSubSampling); + acc = nr*rwidth + + 2*((nr*rwidth)/(horizSubSampling*vertSubSampling)); + if (!TIFFWriteEncodedStrip(tif, strip++, buf, acc)) { + _TIFFfree(buf); + return (0); + } + } + _TIFFfree(buf); + return (1); } -static int tiffcvt(TIFF *in, TIFF *out) +static int +tiffcvt(TIFF* in, TIFF* out) { - uint32_t width, height; /* image width & height */ - uint32_t *raster; /* retrieve RGBA image */ - uint16_t shortv; - float floatv; - char *stringv; - uint32_t longv; - int result; - size_t pixel_count; + uint32 width, height; /* image width & height */ + uint32* raster; /* retrieve RGBA image */ + uint16 shortv; + float floatv; + char *stringv; + uint32 longv; + int result; + size_t pixel_count; - TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); - TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); - pixel_count = width * height; + TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); + TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); + pixel_count = width * height; - /* XXX: Check the integer overflow. */ - if (!width || !height || pixel_count / width != height) - { - TIFFError(TIFFFileName(in), - "Malformed input file; " - "can't allocate buffer for raster of %" PRIu32 "x%" PRIu32 - " size", - width, height); - return 0; - } + /* XXX: Check the integer overflow. */ + if (!width || !height || pixel_count / width != height) { + TIFFError(TIFFFileName(in), + "Malformed input file; " + "can't allocate buffer for raster of %lux%lu size", + (unsigned long)width, (unsigned long)height); + return 0; + } + + raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32), + "raster buffer"); + if (raster == 0) { + TIFFError(TIFFFileName(in), + "Failed to allocate buffer (%lu elements of %lu each)", + (unsigned long)pixel_count, + (unsigned long)sizeof(uint32)); + return (0); + } - raster = (uint32_t *)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32_t), - "raster buffer"); - if (raster == 0) - { - TIFFError(TIFFFileName(in), - "Failed to allocate buffer (%" TIFF_SIZE_FORMAT - " elements of %" TIFF_SIZE_FORMAT " each)", - pixel_count, sizeof(uint32_t)); - return (0); - } + if (!TIFFReadRGBAImage(in, width, height, raster, 0)) { + _TIFFfree(raster); + return (0); + } - if (!TIFFReadRGBAImage(in, width, height, raster, 0)) - { + CopyField(TIFFTAG_SUBFILETYPE, longv); + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, height); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); + if (compression == COMPRESSION_JPEG) + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RAW); + CopyField(TIFFTAG_FILLORDER, shortv); + TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3); + CopyField(TIFFTAG_XRESOLUTION, floatv); + CopyField(TIFFTAG_YRESOLUTION, floatv); + CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + { char buf[2048]; + char *cp = strrchr(TIFFFileName(in), '/'); + snprintf(buf, sizeof(buf), "YCbCr conversion of %s", + cp ? cp+1 : TIFFFileName(in)); + TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, buf); + } + TIFFSetField(out, TIFFTAG_SOFTWARE, TIFFGetVersion()); + CopyField(TIFFTAG_DOCUMENTNAME, stringv); + + TIFFSetField(out, TIFFTAG_REFERENCEBLACKWHITE, refBlackWhite); + TIFFSetField(out, TIFFTAG_YCBCRSUBSAMPLING, + horizSubSampling, vertSubSampling); + TIFFSetField(out, TIFFTAG_YCBCRPOSITIONING, YCBCRPOSITION_CENTERED); + TIFFSetField(out, TIFFTAG_YCBCRCOEFFICIENTS, ycbcrCoeffs); + rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + + result = cvtRaster(out, raster, width, height); _TIFFfree(raster); - return (0); - } - - CopyField(TIFFTAG_SUBFILETYPE, longv); - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, height); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); - if (compression == COMPRESSION_JPEG) - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RAW); - CopyField(TIFFTAG_FILLORDER, shortv); - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3); - CopyField(TIFFTAG_XRESOLUTION, floatv); - CopyField(TIFFTAG_YRESOLUTION, floatv); - CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - { - char buf[2048]; - char *cp = strrchr(TIFFFileName(in), '/'); - snprintf(buf, sizeof(buf), "YCbCr conversion of %s", - cp ? cp + 1 : TIFFFileName(in)); - TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, buf); - } - TIFFSetField(out, TIFFTAG_SOFTWARE, TIFFGetVersion()); - CopyField(TIFFTAG_DOCUMENTNAME, stringv); - - TIFFSetField(out, TIFFTAG_REFERENCEBLACKWHITE, refBlackWhite); - TIFFSetField(out, TIFFTAG_YCBCRSUBSAMPLING, horizSubSampling, - vertSubSampling); - TIFFSetField(out, TIFFTAG_YCBCRPOSITIONING, YCBCRPOSITION_CENTERED); - TIFFSetField(out, TIFFTAG_YCBCRCOEFFICIENTS, ycbcrCoeffs); - rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - - result = cvtRaster(out, raster, width, height); - _TIFFfree(raster); - return result; + return result; } -const char *usage_info[] = { - /* Help information format modified for the sake of consistency with the - other tiff tools */ - /* "usage: rgb2ycbcr [-c comp] [-r rows] [-h N] [-v N] input... - output\n", */ - /* "where comp is one of the following compression algorithms:\n", */ - "Convert RGB color, greyscale, or bi-level TIFF images to YCbCr images\n\n" - "usage: rgb2ycbcr [options] input output", - "where options are:", -#ifdef JPEG_SUPPORT - " -c jpeg JPEG encoding", -#endif -#ifdef ZIP_SUPPORT - " -c zip Zip/Deflate encoding", -#endif -#ifdef LZW_SUPPORT - " -c lzw Lempel-Ziv & Welch encoding", -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits PackBits encoding (default)", -#endif -#if defined(JPEG_SUPPORT) || defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || \ - defined(PACKBITS_SUPPORT) - " -c none no compression", -#endif - "", - /* "and the other options are:\n", */ - " -r rows/strip", " -h horizontal sampling factor (1,2,4)", - " -v vertical sampling factor (1,2,4)", NULL}; +const char* stuff[] = { + "usage: rgb2ycbcr [-c comp] [-r rows] [-h N] [-v N] input... output\n", + "where comp is one of the following compression algorithms:\n", + " jpeg\t\tJPEG encoding\n", + " lzw\t\tLempel-Ziv & Welch encoding\n", + " zip\t\tdeflate encoding\n", + " packbits\tPackBits encoding (default)\n", + " none\t\tno compression\n", + "and the other options are:\n", + " -r\trows/strip\n", + " -h\thorizontal sampling factor (1,2,4)\n", + " -v\tvertical sampling factor (1,2,4)\n", + NULL +}; -static void usage(int code) +static void +usage(int code) { - int i; - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; usage_info[i] != NULL; i++) - fprintf(out, "%s\n", usage_info[i]); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/thumbnail.c b/thirdparty/SDL2_image/external/libtiff/tools/thumbnail.c index 8ce0d9b08..edb699837 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/thumbnail.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/thumbnail.c @@ -2,36 +2,39 @@ * Copyright (c) 1994-1997 Sam Leffler * Copyright (c) 1994-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" -#include #include #include #include +#include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffio.h" @@ -43,15 +46,17 @@ #define EXIT_FAILURE 1 #endif -#define streq(a, b) (strcmp(a, b) == 0) - -#ifndef TIFFhowmany8 -#define TIFFhowmany8(x) \ - (((x)&0x07) ? ((uint32_t)(x) >> 3) + 1 : (uint32_t)(x) >> 3) +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); #endif -typedef enum -{ +#define streq(a,b) (strcmp(a,b) == 0) + +#ifndef TIFFhowmany8 +# define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) +#endif + +typedef enum { EXP50, EXP60, EXP70, @@ -61,188 +66,154 @@ typedef enum LINEAR } Contrast; -static uint32_t tnw = 216; /* thumbnail width */ -static uint32_t tnh = 274; /* thumbnail height */ -static Contrast contrast = LINEAR; /* current contrast */ -static uint8_t *thumbnail; +static uint32 tnw = 216; /* thumbnail width */ +static uint32 tnh = 274; /* thumbnail height */ +static Contrast contrast = LINEAR; /* current contrast */ +static uint8* thumbnail; -static int cpIFD(TIFF *, TIFF *); -static int generateThumbnail(TIFF *, TIFF *); -static void initScale(); -static void usage(int code); +static int cpIFD(TIFF*, TIFF*); +static int generateThumbnail(TIFF*, TIFF*); +static void initScale(); +static void usage(int code); #if !HAVE_DECL_OPTARG -extern char *optarg; -extern int optind; +extern char* optarg; +extern int optind; #endif -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - TIFF *in; - TIFF *out; + TIFF* in; + TIFF* out; int c; - while ((c = getopt(argc, argv, "w:h:c:")) != -1) - { - switch (c) - { - case 'w': - tnw = strtoul(optarg, NULL, 0); - break; - case 'h': - tnh = strtoul(optarg, NULL, 0); - break; - case 'c': - contrast = streq(optarg, "exp50") ? EXP50 - : streq(optarg, "exp60") ? EXP60 - : streq(optarg, "exp70") ? EXP70 - : streq(optarg, "exp80") ? EXP80 - : streq(optarg, "exp90") ? EXP90 - : streq(optarg, "exp") ? EXP - : streq(optarg, "linear") ? LINEAR - : EXP; - break; - default: - usage(EXIT_FAILURE); - } + while ((c = getopt(argc, argv, "w:h:c:")) != -1) { + switch (c) { + case 'w': tnw = strtoul(optarg, NULL, 0); break; + case 'h': tnh = strtoul(optarg, NULL, 0); break; + case 'c': contrast = streq(optarg, "exp50") ? EXP50 : + streq(optarg, "exp60") ? EXP60 : + streq(optarg, "exp70") ? EXP70 : + streq(optarg, "exp80") ? EXP80 : + streq(optarg, "exp90") ? EXP90 : + streq(optarg, "exp") ? EXP : + streq(optarg, "linear")? LINEAR : + EXP; + break; + default: usage(EXIT_FAILURE); + } } - if (argc - optind != 2) - usage(EXIT_FAILURE); + if (argc-optind != 2) + usage(EXIT_FAILURE); - out = TIFFOpen(argv[optind + 1], "w"); + out = TIFFOpen(argv[optind+1], "w"); if (out == NULL) - return 2; + return 2; in = TIFFOpen(argv[optind], "r"); - if (in == NULL) + if( in == NULL ) return 2; - thumbnail = (uint8_t *)_TIFFmalloc(tnw * tnh); - if (!thumbnail) - { - TIFFError(TIFFFileName(in), - "Can't allocate space for thumbnail buffer."); - return EXIT_FAILURE; + thumbnail = (uint8*) _TIFFmalloc(tnw * tnh); + if (!thumbnail) { + TIFFError(TIFFFileName(in), + "Can't allocate space for thumbnail buffer."); + return EXIT_FAILURE; } - if (in != NULL) - { - initScale(); - do - { - if (!generateThumbnail(in, out)) - goto bad; - if (!cpIFD(in, out) || !TIFFWriteDirectory(out)) - goto bad; - } while (TIFFReadDirectory(in)); - (void)TIFFClose(in); + if (in != NULL) { + initScale(); + do { + if (!generateThumbnail(in, out)) + goto bad; + if (!cpIFD(in, out) || !TIFFWriteDirectory(out)) + goto bad; + } while (TIFFReadDirectory(in)); + (void) TIFFClose(in); } - (void)TIFFClose(out); + (void) TIFFClose(out); return EXIT_SUCCESS; bad: - (void)TIFFClose(out); + (void) TIFFClose(out); return EXIT_FAILURE; } -#define CopyField(tag, v) \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v) -#define CopyField2(tag, v1, v2) \ - if (TIFFGetField(in, tag, &v1, &v2)) \ - TIFFSetField(out, tag, v1, v2) -#define CopyField3(tag, v1, v2, v3) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3)) \ - TIFFSetField(out, tag, v1, v2, v3) -#define CopyField4(tag, v1, v2, v3, v4) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) \ - TIFFSetField(out, tag, v1, v2, v3, v4) +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) +#define CopyField2(tag, v1, v2) \ + if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) +#define CopyField3(tag, v1, v2, v3) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) +#define CopyField4(tag, v1, v2, v3, v4) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) -static void cpTag(TIFF *in, TIFF *out, uint16_t tag, uint16_t count, - TIFFDataType type) +static void +cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) { - switch (type) - { - case TIFF_SHORT: - if (count == 1) - { - uint16_t shortv; - CopyField(tag, shortv); - } - else if (count == 2) - { - uint16_t shortv1, shortv2; - CopyField2(tag, shortv1, shortv2); - } - else if (count == 4) - { - uint16_t *tr, *tg, *tb, *ta; - CopyField4(tag, tr, tg, tb, ta); - } - else if (count == (uint16_t)-1) - { - uint16_t shortv1; - uint16_t *shortav; - CopyField2(tag, shortv1, shortav); - } - break; - case TIFF_LONG: - { - uint32_t longv; - CopyField(tag, longv); - } - break; - case TIFF_LONG8: - { - uint64_t longv8; - CopyField(tag, longv8); - } - break; - case TIFF_SLONG8: - { - int64_t longv8; - CopyField(tag, longv8); - } - break; - case TIFF_RATIONAL: - if (count == 1) - { - float floatv; - CopyField(tag, floatv); - } - else if (count == (uint16_t)-1) - { - float *floatav; - CopyField(tag, floatav); - } - break; - case TIFF_ASCII: - { - char *stringv; - CopyField(tag, stringv); - } - break; - case TIFF_DOUBLE: - if (count == 1) - { - double doublev; - CopyField(tag, doublev); - } - else if (count == (uint16_t)-1) - { - double *doubleav; - CopyField(tag, doubleav); - } - break; - case TIFF_IFD8: - { - toff_t ifd8; - CopyField(tag, ifd8); - } - break; - default: - TIFFError(TIFFFileName(in), - "Data type %d is not supported, tag %d skipped.", tag, - type); - } + switch (type) { + case TIFF_SHORT: + if (count == 1) { + uint16 shortv; + CopyField(tag, shortv); + } else if (count == 2) { + uint16 shortv1, shortv2; + CopyField2(tag, shortv1, shortv2); + } else if (count == 4) { + uint16 *tr, *tg, *tb, *ta; + CopyField4(tag, tr, tg, tb, ta); + } else if (count == (uint16) -1) { + uint16 shortv1; + uint16* shortav; + CopyField2(tag, shortv1, shortav); + } + break; + case TIFF_LONG: + { uint32 longv; + CopyField(tag, longv); + } + break; + case TIFF_LONG8: + { uint64 longv8; + CopyField(tag, longv8); + } + break; + case TIFF_SLONG8: + { int64 longv8; + CopyField(tag, longv8); + } + break; + case TIFF_RATIONAL: + if (count == 1) { + float floatv; + CopyField(tag, floatv); + } else if (count == (uint16) -1) { + float* floatav; + CopyField(tag, floatav); + } + break; + case TIFF_ASCII: + { char* stringv; + CopyField(tag, stringv); + } + break; + case TIFF_DOUBLE: + if (count == 1) { + double doublev; + CopyField(tag, doublev); + } else if (count == (uint16) -1) { + double* doubleav; + CopyField(tag, doubleav); + } + break; + case TIFF_IFD8: + { toff_t ifd8; + CopyField(tag, ifd8); + } + break; default: + TIFFError(TIFFFileName(in), + "Data type %d is not supported, tag %d skipped.", + tag, type); + } } #undef CopyField4 @@ -250,288 +221,255 @@ static void cpTag(TIFF *in, TIFF *out, uint16_t tag, uint16_t count, #undef CopyField2 #undef CopyField -static const struct cpTag -{ - uint16_t tag; - uint16_t count; +static struct cpTag { + uint16 tag; + uint16 count; TIFFDataType type; } tags[] = { - {TIFFTAG_IMAGEWIDTH, 1, TIFF_LONG}, - {TIFFTAG_IMAGELENGTH, 1, TIFF_LONG}, - {TIFFTAG_BITSPERSAMPLE, 1, TIFF_SHORT}, - {TIFFTAG_COMPRESSION, 1, TIFF_SHORT}, - {TIFFTAG_FILLORDER, 1, TIFF_SHORT}, - {TIFFTAG_SAMPLESPERPIXEL, 1, TIFF_SHORT}, - {TIFFTAG_ROWSPERSTRIP, 1, TIFF_LONG}, - {TIFFTAG_PLANARCONFIG, 1, TIFF_SHORT}, - {TIFFTAG_GROUP3OPTIONS, 1, TIFF_LONG}, - {TIFFTAG_SUBFILETYPE, 1, TIFF_LONG}, - {TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT}, - {TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT}, - {TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII}, - {TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII}, - {TIFFTAG_MAKE, 1, TIFF_ASCII}, - {TIFFTAG_MODEL, 1, TIFF_ASCII}, - {TIFFTAG_ORIENTATION, 1, TIFF_SHORT}, - {TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_PAGENAME, 1, TIFF_ASCII}, - {TIFFTAG_XPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_YPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG}, - {TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT}, - {TIFFTAG_PAGENUMBER, 2, TIFF_SHORT}, - {TIFFTAG_SOFTWARE, 1, TIFF_ASCII}, - {TIFFTAG_DATETIME, 1, TIFF_ASCII}, - {TIFFTAG_ARTIST, 1, TIFF_ASCII}, - {TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII}, - {TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL}, - {TIFFTAG_PRIMARYCHROMATICITIES, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT}, - {TIFFTAG_BADFAXLINES, 1, TIFF_LONG}, - {TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT}, - {TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG}, - {TIFFTAG_INKSET, 1, TIFF_SHORT}, - /*{ TIFFTAG_INKNAMES, 1, TIFF_ASCII },*/ /* Needs much - more - complicated - logic. See - tiffcp */ - {TIFFTAG_DOTRANGE, 2, TIFF_SHORT}, - {TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII}, - {TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT}, - {TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT}, - {TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT}, - {TIFFTAG_REFERENCEBLACKWHITE, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_EXTRASAMPLES, (uint16_t)-1, TIFF_SHORT}, + { TIFFTAG_IMAGEWIDTH, 1, TIFF_LONG }, + { TIFFTAG_IMAGELENGTH, 1, TIFF_LONG }, + { TIFFTAG_BITSPERSAMPLE, 1, TIFF_SHORT }, + { TIFFTAG_COMPRESSION, 1, TIFF_SHORT }, + { TIFFTAG_FILLORDER, 1, TIFF_SHORT }, + { TIFFTAG_SAMPLESPERPIXEL, 1, TIFF_SHORT }, + { TIFFTAG_ROWSPERSTRIP, 1, TIFF_LONG }, + { TIFFTAG_PLANARCONFIG, 1, TIFF_SHORT }, + { TIFFTAG_GROUP3OPTIONS, 1, TIFF_LONG }, + { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, + { TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT }, + { TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT }, + { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, + { TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII }, + { TIFFTAG_MAKE, 1, TIFF_ASCII }, + { TIFFTAG_MODEL, 1, TIFF_ASCII }, + { TIFFTAG_ORIENTATION, 1, TIFF_SHORT }, + { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_PAGENUMBER, 2, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_BADFAXLINES, 1, TIFF_LONG }, + { TIFFTAG_CLEANFAXDATA, 1, TIFF_SHORT }, + { TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, + /*{ TIFFTAG_INKNAMES, 1, TIFF_ASCII },*/ /* Needs much more complicated logic. See tiffcp */ + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, }; -#define NTAGS (sizeof(tags) / sizeof(tags[0])) +#define NTAGS (sizeof (tags) / sizeof (tags[0])) -static void cpTags(TIFF *in, TIFF *out) +static void +cpTags(TIFF* in, TIFF* out) { - const struct cpTag *p; + struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) - { - /* Horrible: but TIFFGetField() expects 2 arguments to be passed */ - /* if we request a tag that is defined in a codec, but that codec */ - /* isn't used */ - if (p->tag == TIFFTAG_GROUP3OPTIONS) - { - uint16_t compression; - if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || - compression != COMPRESSION_CCITTFAX3) - continue; - } - if (p->tag == TIFFTAG_GROUP4OPTIONS) - { - uint16_t compression; - if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || - compression != COMPRESSION_CCITTFAX4) - continue; - } - cpTag(in, out, p->tag, p->count, p->type); - } + { + /* Horrible: but TIFFGetField() expects 2 arguments to be passed */ + /* if we request a tag that is defined in a codec, but that codec */ + /* isn't used */ + if( p->tag == TIFFTAG_GROUP3OPTIONS ) + { + uint16 compression; + if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || + compression != COMPRESSION_CCITTFAX3 ) + continue; + } + if( p->tag == TIFFTAG_GROUP4OPTIONS ) + { + uint16 compression; + if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || + compression != COMPRESSION_CCITTFAX4 ) + continue; + } + cpTag(in, out, p->tag, p->count, p->type); + } } #undef NTAGS -static int cpStrips(TIFF *in, TIFF *out) +static int +cpStrips(TIFF* in, TIFF* out) { - tsize_t bufsize = TIFFStripSize(in); + tsize_t bufsize = TIFFStripSize(in); unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); - if (buf) - { - tstrip_t s, ns = TIFFNumberOfStrips(in); - uint64_t *bytecounts; + if (buf) { + tstrip_t s, ns = TIFFNumberOfStrips(in); + uint64 *bytecounts; - TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts); - for (s = 0; s < ns; s++) - { - if (bytecounts[s] > (uint64_t)bufsize) - { - buf = - (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[s]); - if (!buf) - goto bad; - bufsize = (tmsize_t)bytecounts[s]; - } - if (TIFFReadRawStrip(in, s, buf, (tmsize_t)bytecounts[s]) < 0 || - TIFFWriteRawStrip(out, s, buf, (tmsize_t)bytecounts[s]) < 0) - { - _TIFFfree(buf); - return 0; - } - } - _TIFFfree(buf); - return 1; + TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts); + for (s = 0; s < ns; s++) { + if (bytecounts[s] > (uint64) bufsize) { + buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[s]); + if (!buf) + goto bad; + bufsize = (tmsize_t)bytecounts[s]; + } + if (TIFFReadRawStrip(in, s, buf, (tmsize_t)bytecounts[s]) < 0 || + TIFFWriteRawStrip(out, s, buf, (tmsize_t)bytecounts[s]) < 0) { + _TIFFfree(buf); + return 0; + } + } + _TIFFfree(buf); + return 1; } bad: - TIFFError(TIFFFileName(in), "Can't allocate space for strip buffer."); - return 0; + TIFFError(TIFFFileName(in), + "Can't allocate space for strip buffer."); + return 0; } -static int cpTiles(TIFF *in, TIFF *out) +static int +cpTiles(TIFF* in, TIFF* out) { tsize_t bufsize = TIFFTileSize(in); unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); - if (buf) - { - ttile_t t, nt = TIFFNumberOfTiles(in); - uint64_t *bytecounts; + if (buf) { + ttile_t t, nt = TIFFNumberOfTiles(in); + uint64 *bytecounts; - TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); - for (t = 0; t < nt; t++) - { - if (bytecounts[t] > (uint64_t)bufsize) - { - buf = - (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[t]); - if (!buf) - goto bad; - bufsize = (tmsize_t)bytecounts[t]; - } - if (TIFFReadRawTile(in, t, buf, (tmsize_t)bytecounts[t]) < 0 || - TIFFWriteRawTile(out, t, buf, (tmsize_t)bytecounts[t]) < 0) - { - _TIFFfree(buf); - return 0; - } - } - _TIFFfree(buf); - return 1; + TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); + for (t = 0; t < nt; t++) { + if (bytecounts[t] > (uint64) bufsize) { + buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[t]); + if (!buf) + goto bad; + bufsize = (tmsize_t)bytecounts[t]; + } + if (TIFFReadRawTile(in, t, buf, (tmsize_t)bytecounts[t]) < 0 || + TIFFWriteRawTile(out, t, buf, (tmsize_t)bytecounts[t]) < 0) { + _TIFFfree(buf); + return 0; + } + } + _TIFFfree(buf); + return 1; } bad: - TIFFError(TIFFFileName(in), "Can't allocate space for tile buffer."); - return (0); + TIFFError(TIFFFileName(in), + "Can't allocate space for tile buffer."); + return (0); } -static int cpIFD(TIFF *in, TIFF *out) +static int +cpIFD(TIFF* in, TIFF* out) { cpTags(in, out); - if (TIFFIsTiled(in)) - { - if (!cpTiles(in, out)) - return (0); - } - else - { - if (!cpStrips(in, out)) - return (0); + if (TIFFIsTiled(in)) { + if (!cpTiles(in, out)) + return (0); + } else { + if (!cpStrips(in, out)) + return (0); } return (1); } -static uint16_t photometric; /* current photometric of raster */ -static uint16_t filterWidth; /* filter width in pixels */ -static uint32_t stepSrcWidth; /* src image stepping width */ -static uint32_t stepDstWidth; /* dest stepping width */ -static uint8_t *src0; /* horizontal bit stepping (start) */ -static uint8_t *src1; /* horizontal bit stepping (middle) */ -static uint8_t *src2; /* horizontal bit stepping (end) */ -static uint32_t *rowoff; /* row offset for stepping */ -static uint8_t cmap[256]; /* colormap indexes */ -static uint8_t bits[256]; /* count of bits set */ +static uint16 photometric; /* current photometric of raster */ +static uint16 filterWidth; /* filter width in pixels */ +static uint32 stepSrcWidth; /* src image stepping width */ +static uint32 stepDstWidth; /* dest stepping width */ +static uint8* src0; /* horizontal bit stepping (start) */ +static uint8* src1; /* horizontal bit stepping (middle) */ +static uint8* src2; /* horizontal bit stepping (end) */ +static uint32* rowoff; /* row offset for stepping */ +static uint8 cmap[256]; /* colormap indexes */ +static uint8 bits[256]; /* count of bits set */ -static void setupBitsTables() +static void +setupBitsTables() { int i; - for (i = 0; i < 256; i++) - { - int n = 0; - if (i & 0x01) - n++; - if (i & 0x02) - n++; - if (i & 0x04) - n++; - if (i & 0x08) - n++; - if (i & 0x10) - n++; - if (i & 0x20) - n++; - if (i & 0x40) - n++; - if (i & 0x80) - n++; - bits[i] = n; + for (i = 0; i < 256; i++) { + int n = 0; + if (i&0x01) n++; + if (i&0x02) n++; + if (i&0x04) n++; + if (i&0x08) n++; + if (i&0x10) n++; + if (i&0x20) n++; + if (i&0x40) n++; + if (i&0x80) n++; + bits[i] = n; } } static int clamp(float v, int low, int high) -{ - return (v < low ? low : v > high ? high : (int)v); -} + { return (v < low ? low : v > high ? high : (int)v); } #ifndef M_E -#define M_E 2.7182818284590452354 +#define M_E 2.7182818284590452354 #endif -static void expFill(float pct[], uint32_t p, uint32_t n) +static void +expFill(float pct[], uint32 p, uint32 n) { - uint32_t i; - uint32_t c = (p * n) / 100; + uint32 i; + uint32 c = (p * n) / 100; for (i = 1; i < c; i++) - pct[i] = (float)(1 - exp(i / ((double)(n - 1))) / M_E); + pct[i] = (float) (1-exp(i/((double)(n-1)))/ M_E); for (; i < n; i++) - pct[i] = 0.; + pct[i] = 0.; } -static void setupCmap() +static void +setupCmap() { - float pct[256]; /* known to be large enough */ - uint32_t i; - pct[0] = 1; /* force white */ - switch (contrast) - { - case EXP50: - expFill(pct, 50, 256); - break; - case EXP60: - expFill(pct, 60, 256); - break; - case EXP70: - expFill(pct, 70, 256); - break; - case EXP80: - expFill(pct, 80, 256); - break; - case EXP90: - expFill(pct, 90, 256); - break; - case EXP: - expFill(pct, 100, 256); - break; - case LINEAR: - for (i = 1; i < 256; i++) - pct[i] = 1 - ((float)i) / (256 - 1); - break; + float pct[256]; /* known to be large enough */ + uint32 i; + pct[0] = 1; /* force white */ + switch (contrast) { + case EXP50: expFill(pct, 50, 256); break; + case EXP60: expFill(pct, 60, 256); break; + case EXP70: expFill(pct, 70, 256); break; + case EXP80: expFill(pct, 80, 256); break; + case EXP90: expFill(pct, 90, 256); break; + case EXP: expFill(pct, 100, 256); break; + case LINEAR: + for (i = 1; i < 256; i++) + pct[i] = 1-((float)i)/(256-1); + break; } - switch (photometric) - { - case PHOTOMETRIC_MINISWHITE: - for (i = 0; i < 256; i++) - cmap[i] = clamp(255 * pct[(256 - 1) - i], 0, 255); - break; - case PHOTOMETRIC_MINISBLACK: - for (i = 0; i < 256; i++) - cmap[i] = clamp(255 * pct[i], 0, 255); - break; + switch (photometric) { + case PHOTOMETRIC_MINISWHITE: + for (i = 0; i < 256; i++) + cmap[i] = clamp(255*pct[(256-1)-i], 0, 255); + break; + case PHOTOMETRIC_MINISBLACK: + for (i = 0; i < 256; i++) + cmap[i] = clamp(255*pct[i], 0, 255); + break; } } -static void initScale() +static void +initScale() { - src0 = (uint8_t *)_TIFFmalloc(sizeof(uint8_t) * tnw); - src1 = (uint8_t *)_TIFFmalloc(sizeof(uint8_t) * tnw); - src2 = (uint8_t *)_TIFFmalloc(sizeof(uint8_t) * tnw); - rowoff = (uint32_t *)_TIFFmalloc(sizeof(uint32_t) * tnw); + src0 = (uint8*) _TIFFmalloc(sizeof (uint8) * tnw); + src1 = (uint8*) _TIFFmalloc(sizeof (uint8) * tnw); + src2 = (uint8*) _TIFFmalloc(sizeof (uint8) * tnw); + rowoff = (uint32*) _TIFFmalloc(sizeof (uint32) * tnw); filterWidth = 0; stepDstWidth = stepSrcWidth = 0; setupBitsTables(); @@ -541,86 +479,73 @@ static void initScale() * Calculate the horizontal accumulation parameteres * according to the widths of the src and dst images. */ -static void setupStepTables(uint32_t sw) +static void +setupStepTables(uint32 sw) { - if (stepSrcWidth != sw || stepDstWidth != tnw) - { - int step = sw; - int limit = tnw; - int err = 0; - uint32_t sx = 0; - uint32_t x; - int fw; - uint8_t b; - for (x = 0; x < tnw; x++) - { - uint32_t sx0 = sx; - err += step; - while (err >= limit) - { - err -= limit; - sx++; - } - rowoff[x] = sx0 >> 3; - fw = sx - sx0; /* width */ - b = (fw < 8) ? 0xff << (8 - fw) : 0xff; - src0[x] = b >> (sx0 & 7); - fw -= 8 - (sx0 & 7); - if (fw < 0) - fw = 0; - src1[x] = fw >> 3; - fw -= (fw >> 3) << 3; - src2[x] = 0xff << (8 - fw); - } - stepSrcWidth = sw; - stepDstWidth = tnw; + if (stepSrcWidth != sw || stepDstWidth != tnw) { + int step = sw; + int limit = tnw; + int err = 0; + uint32 sx = 0; + uint32 x; + int fw; + uint8 b; + for (x = 0; x < tnw; x++) { + uint32 sx0 = sx; + err += step; + while (err >= limit) { + err -= limit; + sx++; + } + rowoff[x] = sx0 >> 3; + fw = sx - sx0; /* width */ + b = (fw < 8) ? 0xff<<(8-fw) : 0xff; + src0[x] = b >> (sx0&7); + fw -= 8 - (sx0&7); + if (fw < 0) + fw = 0; + src1[x] = fw >> 3; + fw -= (fw>>3)<<3; + src2[x] = 0xff << (8-fw); + } + stepSrcWidth = sw; + stepDstWidth = tnw; } } -static void setrow(uint8_t *row, uint32_t nrows, const uint8_t *rows[]) +static void +setrow(uint8* row, uint32 nrows, const uint8* rows[]) { - uint32_t x; - uint32_t area = nrows * filterWidth; - for (x = 0; x < tnw; x++) - { - uint32_t mask0 = src0[x]; - uint32_t fw = src1[x]; - uint32_t mask1 = src1[x]; - uint32_t off = rowoff[x]; - uint32_t acc = 0; - uint32_t y, i; - for (y = 0; y < nrows; y++) - { - const uint8_t *src = rows[y] + off; - acc += bits[*src++ & mask0]; - switch (fw) - { - default: - for (i = fw; i > 8; i--) - acc += bits[*src++]; - /* fall through... */ - case 8: - acc += bits[*src++]; /* fall through */ - case 7: - acc += bits[*src++]; /* fall through */ - case 6: - acc += bits[*src++]; /* fall through */ - case 5: - acc += bits[*src++]; /* fall through */ - case 4: - acc += bits[*src++]; /* fall through */ - case 3: - acc += bits[*src++]; /* fall through */ - case 2: - acc += bits[*src++]; /* fall through */ - case 1: - acc += bits[*src++]; /* fall through */ - case 0: - break; - } - acc += bits[*src & mask1]; - } - *row++ = cmap[(255 * acc) / area]; + uint32 x; + uint32 area = nrows * filterWidth; + for (x = 0; x < tnw; x++) { + uint32 mask0 = src0[x]; + uint32 fw = src1[x]; + uint32 mask1 = src1[x]; + uint32 off = rowoff[x]; + uint32 acc = 0; + uint32 y, i; + for (y = 0; y < nrows; y++) { + const uint8* src = rows[y] + off; + acc += bits[*src++ & mask0]; + switch (fw) { + default: + for (i = fw; i > 8; i--) + acc += bits[*src++]; + /* fall through... */ + case 8: acc += bits[*src++]; /* fall through */ + case 7: acc += bits[*src++]; /* fall through */ + case 6: acc += bits[*src++]; /* fall through */ + case 5: acc += bits[*src++]; /* fall through */ + case 4: acc += bits[*src++]; /* fall through */ + case 3: acc += bits[*src++]; /* fall through */ + case 2: acc += bits[*src++]; /* fall through */ + case 1: acc += bits[*src++]; /* fall through */ + case 0: break; + } + acc += bits[*src & mask1]; + } + *row++ = cmap[(255*acc)/area]; } } @@ -630,54 +555,54 @@ static void setrow(uint8_t *row, uint32_t nrows, const uint8_t *rows[]) * a box filter. The resultant pixels are mapped * with a user-selectable contrast curve. */ -static void setImage1(const uint8_t *br, uint32_t rw, uint32_t rh) +static void +setImage1(const uint8* br, uint32 rw, uint32 rh) { int step = rh; int limit = tnh; int err = 0; int bpr = TIFFhowmany8(rw); int sy = 0; - uint8_t *row = thumbnail; - uint32_t dy; - for (dy = 0; dy < tnh; dy++) - { - const uint8_t *rows[256]; - uint32_t nrows = 1; - fprintf(stderr, "bpr=%d, sy=%d, bpr*sy=%d\n", bpr, sy, bpr * sy); - rows[0] = br + bpr * sy; - err += step; - while (err >= limit) - { - err -= limit; - sy++; - if (err >= limit) - { - /* We should perhaps error loudly, but I can't make sense of - * that */ - /* code... */ - if (nrows == 256) - break; - rows[nrows++] = br + bpr * sy; - } - } - setrow(row, nrows, rows); - row += tnw; + uint8* row = thumbnail; + uint32 dy; + for (dy = 0; dy < tnh; dy++) { + const uint8* rows[256]; + uint32 nrows = 1; + fprintf(stderr, "bpr=%d, sy=%d, bpr*sy=%d\n", bpr, sy, bpr*sy); + rows[0] = br + bpr*sy; + err += step; + while (err >= limit) { + err -= limit; + sy++; + if (err >= limit) + { + /* We should perhaps error loudly, but I can't make sense of that */ + /* code... */ + if( nrows == 256 ) + break; + rows[nrows++] = br + bpr*sy; + } + } + setrow(row, nrows, rows); + row += tnw; } } -static void setImage(const uint8_t *br, uint32_t rw, uint32_t rh) +static void +setImage(const uint8* br, uint32 rw, uint32 rh) { - filterWidth = (uint16_t)ceil((double)rw / (double)tnw); + filterWidth = (uint16) ceil((double) rw / (double) tnw); setupStepTables(rw); setImage1(br, rw, rh); } -static int generateThumbnail(TIFF *in, TIFF *out) +static int +generateThumbnail(TIFF* in, TIFF* out) { - unsigned char *raster; - unsigned char *rp; - uint32_t sw, sh, rps; - uint16_t bps, spp; + unsigned char* raster; + unsigned char* rp; + uint32 sw, sh, rps; + uint16 bps, spp; tsize_t rowsize, rastersize; tstrip_t s, ns = TIFFNumberOfStrips(in); toff_t diroff[1]; @@ -688,26 +613,25 @@ static int generateThumbnail(TIFF *in, TIFF *out) TIFFGetFieldDefaulted(in, TIFFTAG_SAMPLESPERPIXEL, &spp); TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); if (spp != 1 || bps != 1) - return 0; + return 0; rowsize = TIFFScanlineSize(in); rastersize = sh * rowsize; fprintf(stderr, "rastersize=%u\n", (unsigned int)rastersize); - /* +3 : add a few guard bytes since setrow() can read a bit */ - /* outside buffer */ - raster = (unsigned char *)_TIFFmalloc(rastersize + 3); - if (!raster) - { - TIFFError(TIFFFileName(in), "Can't allocate space for raster buffer."); - return 0; + /* +3 : add a few guard bytes since setrow() can read a bit */ + /* outside buffer */ + raster = (unsigned char*)_TIFFmalloc(rastersize+3); + if (!raster) { + TIFFError(TIFFFileName(in), + "Can't allocate space for raster buffer."); + return 0; } raster[rastersize] = 0; - raster[rastersize + 1] = 0; - raster[rastersize + 2] = 0; + raster[rastersize+1] = 0; + raster[rastersize+2] = 0; rp = raster; - for (s = 0; s < ns; s++) - { - (void)TIFFReadEncodedStrip(in, s, rp, -1); - rp += rps * rowsize; + for (s = 0; s < ns; s++) { + (void) TIFFReadEncodedStrip(in, s, rp, -1); + rp += rps * rowsize; } TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric); setupCmap(); @@ -715,47 +639,57 @@ static int generateThumbnail(TIFF *in, TIFF *out) _TIFFfree(raster); TIFFSetField(out, TIFFTAG_SUBFILETYPE, FILETYPE_REDUCEDIMAGE); - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32_t)tnw); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32_t)tnh); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (uint16_t)8); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, (uint16_t)1); + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) tnw); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) tnh); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (uint16) 8); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, (uint16) 1); TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS); TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE); TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - cpTag(in, out, TIFFTAG_SOFTWARE, (uint16_t)-1, TIFF_ASCII); - cpTag(in, out, TIFFTAG_IMAGEDESCRIPTION, (uint16_t)-1, TIFF_ASCII); - cpTag(in, out, TIFFTAG_DATETIME, (uint16_t)-1, TIFF_ASCII); - cpTag(in, out, TIFFTAG_HOSTCOMPUTER, (uint16_t)-1, TIFF_ASCII); + cpTag(in, out, TIFFTAG_SOFTWARE, (uint16) -1, TIFF_ASCII); + cpTag(in, out, TIFFTAG_IMAGEDESCRIPTION, (uint16) -1, TIFF_ASCII); + cpTag(in, out, TIFFTAG_DATETIME, (uint16) -1, TIFF_ASCII); + cpTag(in, out, TIFFTAG_HOSTCOMPUTER, (uint16) -1, TIFF_ASCII); diroff[0] = 0UL; TIFFSetField(out, TIFFTAG_SUBIFD, 1, diroff); - return (TIFFWriteEncodedStrip(out, 0, thumbnail, tnw * tnh) != -1 && + return (TIFFWriteEncodedStrip(out, 0, thumbnail, tnw*tnh) != -1 && TIFFWriteDirectory(out) != -1); } -const char *usage_info[] = { - "Create a TIFF file with thumbnail images\n\n" - "usage: thumbnail [options] input.tif output.tif", - "where options are:", - " -h # specify thumbnail image height (default is 274)", - " -w # specify thumbnail image width (default is 216)", - "", - " -c linear use linear contrast curve", - " -c exp50 use 50% exponential contrast curve", - " -c exp60 use 60% exponential contrast curve", - " -c exp70 use 70% exponential contrast curve", - " -c exp80 use 80% exponential contrast curve", - " -c exp90 use 90% exponential contrast curve", - " -c exp use pure exponential contrast curve", - NULL}; +const char* stuff[] = { +"usage: thumbnail [options] input.tif output.tif", +"where options are:", +" -h # specify thumbnail image height (default is 274)", +" -w # specify thumbnail image width (default is 216)", +"", +" -c linear use linear contrast curve", +" -c exp50 use 50% exponential contrast curve", +" -c exp60 use 60% exponential contrast curve", +" -c exp70 use 70% exponential contrast curve", +" -c exp80 use 80% exponential contrast curve", +" -c exp90 use 90% exponential contrast curve", +" -c exp use pure exponential contrast curve", +NULL +}; -static void usage(int code) +static void +usage(int code) { - int i; - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; usage_info[i] != NULL; i++) - fprintf(out, "%s\n", usage_info[i]); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tif_tools_versioninfo.rc b/thirdparty/SDL2_image/external/libtiff/tools/tif_tools_versioninfo.rc deleted file mode 100644 index 6d560c3fd..000000000 --- a/thirdparty/SDL2_image/external/libtiff/tools/tif_tools_versioninfo.rc +++ /dev/null @@ -1,51 +0,0 @@ - -/* clang-format off */ - -#define APSTUDIO_HIDDEN_SYMBOLS -#include -#undef APSTUDIO_HIDDEN_SYMBOLS -#include - -#include "tiffvers.h" -#include "tif_config.h" - -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1252) -#endif //_WIN32 - -VS_VERSION_INFO VERSIONINFO - FILEVERSION TIFFLIB_MAJOR_VERSION,TIFFLIB_MINOR_VERSION,TIFFLIB_MICRO_VERSION,0 - PRODUCTVERSION TIFFLIB_MAJOR_VERSION,TIFFLIB_MINOR_VERSION,TIFFLIB_MICRO_VERSION,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", "libtiff project" - VALUE "FileDescription", "TIFF Tools" - VALUE "FileVersion", PACKAGE_VERSION - VALUE "InternalName", "" - VALUE "LegalCopyright", "See LICENCE.md" - VALUE "OriginalFilename", "" - VALUE "ProductName", "LibTIFF" - VALUE "ProductVersion", PACKAGE_VERSION - VALUE "WebPage", "https://libtiff.gitlab.io/libtiff/\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END - - diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiff2bw.c b/thirdparty/SDL2_image/external/libtiff/tools/tiff2bw.c index 51f50ca50..654bd3248 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiff2bw.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiff2bw.c @@ -2,36 +2,39 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" -#include #include #include #include +#include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffio.h" @@ -45,427 +48,386 @@ #endif /* x% weighting -> fraction of full color */ -#define PCT(x) (((x)*256 + 50) / 100) -int RED = PCT(30); /* 30% */ -int GREEN = PCT(59); /* 59% */ -int BLUE = PCT(11); /* 11% */ +#define PCT(x) (((x)*256+50)/100) +int RED = PCT(30); /* 30% */ +int GREEN = PCT(59); /* 59% */ +int BLUE = PCT(11); /* 11% */ -static void usage(int code); -static int processCompressOptions(char *); +static void usage(int code); +static int processCompressOptions(char*); -static void compresscontig(unsigned char *out, unsigned char *rgb, uint32_t n) +static void +compresscontig(unsigned char* out, unsigned char* rgb, uint32 n) { - register int v, red = RED, green = GREEN, blue = BLUE; + register int v, red = RED, green = GREEN, blue = BLUE; - while (n-- > 0) - { - v = red * (*rgb++); - v += green * (*rgb++); - v += blue * (*rgb++); - *out++ = v >> 8; - } + while (n-- > 0) { + v = red*(*rgb++); + v += green*(*rgb++); + v += blue*(*rgb++); + *out++ = v>>8; + } } -static void compresssep(unsigned char *out, unsigned char *r, unsigned char *g, - unsigned char *b, uint32_t n) +static void +compresssep(unsigned char* out, + unsigned char* r, unsigned char* g, unsigned char* b, uint32 n) { - register uint32_t red = RED, green = GREEN, blue = BLUE; + register uint32 red = RED, green = GREEN, blue = BLUE; - while (n-- > 0) - *out++ = - (unsigned char)((red * (*r++) + green * (*g++) + blue * (*b++)) >> - 8); + while (n-- > 0) + *out++ = (unsigned char) + ((red*(*r++) + green*(*g++) + blue*(*b++)) >> 8); } -static int checkcmap(TIFF *tif, int n, uint16_t *r, uint16_t *g, uint16_t *b) +static int +checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) { - while (n-- > 0) - if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) - return (16); - TIFFWarning(TIFFFileName(tif), "Assuming 8-bit colormap"); - return (8); + while (n-- > 0) + if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) + return (16); + TIFFWarning(TIFFFileName(tif), "Assuming 8-bit colormap"); + return (8); } -static void compresspalette(unsigned char *out, unsigned char *data, uint32_t n, - uint16_t *rmap, uint16_t *gmap, uint16_t *bmap) +static void +compresspalette(unsigned char* out, unsigned char* data, uint32 n, uint16* rmap, uint16* gmap, uint16* bmap) { - register int v, red = RED, green = GREEN, blue = BLUE; + register int v, red = RED, green = GREEN, blue = BLUE; - while (n-- > 0) - { - unsigned int ix = *data++; - v = red * rmap[ix]; - v += green * gmap[ix]; - v += blue * bmap[ix]; - *out++ = v >> 8; - } + while (n-- > 0) { + unsigned int ix = *data++; + v = red*rmap[ix]; + v += green*gmap[ix]; + v += blue*bmap[ix]; + *out++ = v>>8; + } } -static uint16_t compression = (uint16_t)-1; -static uint16_t predictor = 0; -static int jpegcolormode = JPEGCOLORMODE_RGB; -static int quality = 75; /* JPEG quality */ +static uint16 compression = (uint16) -1; +static uint16 predictor = 0; +static int jpegcolormode = JPEGCOLORMODE_RGB; +static int quality = 75; /* JPEG quality */ -static void cpTags(TIFF *in, TIFF *out); +static void cpTags(TIFF* in, TIFF* out); -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - uint32_t rowsperstrip = (uint32_t)-1; - TIFF *in, *out; - uint32_t w, h; - uint16_t samplesperpixel; - uint16_t bitspersample; - uint16_t config; - uint16_t photometric; - uint16_t *red; - uint16_t *green; - uint16_t *blue; - tsize_t rowsize; - register uint32_t row; - register tsample_t s; - unsigned char *inbuf, *outbuf; - char thing[1024]; - int c; + uint32 rowsperstrip = (uint32) -1; + TIFF *in, *out; + uint32 w, h; + uint16 samplesperpixel; + uint16 bitspersample; + uint16 config; + uint16 photometric; + uint16* red; + uint16* green; + uint16* blue; + tsize_t rowsize; + register uint32 row; + register tsample_t s; + unsigned char *inbuf, *outbuf; + char thing[1024]; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char *optarg; #endif + + in = (TIFF *) NULL; + out = (TIFF *) NULL; + inbuf = (unsigned char *) NULL; + outbuf = (unsigned char *) NULL; - in = (TIFF *)NULL; - out = (TIFF *)NULL; - inbuf = (unsigned char *)NULL; - outbuf = (unsigned char *)NULL; + while ((c = getopt(argc, argv, "c:r:R:G:B:h")) != -1) + switch (c) { + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(EXIT_FAILURE); + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case 'R': + RED = PCT(atoi(optarg)); + break; + case 'G': + GREEN = PCT(atoi(optarg)); + break; + case 'B': + BLUE = PCT(atoi(optarg)); + break; + case 'h': + usage(EXIT_SUCCESS); + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } + if (argc - optind < 2) + usage(EXIT_FAILURE); + in = TIFFOpen(argv[optind], "r"); + if (in == NULL) + return (EXIT_FAILURE); + photometric = 0; + TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric); + if (photometric != PHOTOMETRIC_RGB && photometric != PHOTOMETRIC_PALETTE ) { + fprintf(stderr, + "%s: Bad photometric; can only handle RGB and Palette images.\n", + argv[optind]); + goto tiff2bw_error; + } + TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + if (samplesperpixel != 1 && samplesperpixel != 3) { + fprintf(stderr, "%s: Bad samples/pixel %u.\n", + argv[optind], samplesperpixel); + goto tiff2bw_error; + } + if( photometric == PHOTOMETRIC_RGB && samplesperpixel != 3) { + fprintf(stderr, "%s: Bad samples/pixel %u for PHOTOMETRIC_RGB.\n", + argv[optind], samplesperpixel); + goto tiff2bw_error; + } + TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); + if (bitspersample != 8) { + fprintf(stderr, + " %s: Sorry, only handle 8-bit samples.\n", argv[optind]); + goto tiff2bw_error; + } + TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(in, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(in, TIFFTAG_PLANARCONFIG, &config); - while ((c = getopt(argc, argv, "c:r:R:G:B:h")) != -1) - switch (c) + out = TIFFOpen(argv[optind+1], "w"); + if (out == NULL) + { + goto tiff2bw_error; + } + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, w); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, h); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + cpTags(in, out); + if (compression != (uint16) -1) { + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + switch (compression) { + case COMPRESSION_JPEG: + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); + break; + case COMPRESSION_LZW: + case COMPRESSION_DEFLATE: + if (predictor != 0) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + break; + } + } + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); + snprintf(thing, sizeof(thing), "B&W version of %s", argv[optind]); + TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing); + TIFFSetField(out, TIFFTAG_SOFTWARE, "tiff2bw"); + outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out)); + if( !outbuf ) { - case 'c': /* compression scheme */ - if (!processCompressOptions(optarg)) - usage(EXIT_FAILURE); - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case 'R': - RED = PCT(atoi(optarg)); - break; - case 'G': - GREEN = PCT(atoi(optarg)); - break; - case 'B': - BLUE = PCT(atoi(optarg)); - break; - case 'h': - usage(EXIT_SUCCESS); - /*NOTREACHED*/ - break; - case '?': - usage(EXIT_FAILURE); - /*NOTREACHED*/ - break; + fprintf(stderr, "Out of memory\n"); + goto tiff2bw_error; } - if (argc - optind < 2) - usage(EXIT_FAILURE); - in = TIFFOpen(argv[optind], "r"); - if (in == NULL) - return (EXIT_FAILURE); - photometric = 0; - TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric); - if (photometric != PHOTOMETRIC_RGB && photometric != PHOTOMETRIC_PALETTE) - { - fprintf( - stderr, - "%s: Bad photometric; can only handle RGB and Palette images.\n", - argv[optind]); - goto tiff2bw_error; - } - TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); - if (samplesperpixel != 1 && samplesperpixel != 3) - { - fprintf(stderr, "%s: Bad samples/pixel %u.\n", argv[optind], - samplesperpixel); - goto tiff2bw_error; - } - if (photometric == PHOTOMETRIC_RGB && samplesperpixel != 3) - { - fprintf(stderr, "%s: Bad samples/pixel %u for PHOTOMETRIC_RGB.\n", - argv[optind], samplesperpixel); - goto tiff2bw_error; - } - TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); - if (bitspersample != 8) - { - fprintf(stderr, " %s: Sorry, only handle 8-bit samples.\n", - argv[optind]); - goto tiff2bw_error; - } - TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(in, TIFFTAG_IMAGELENGTH, &h); - TIFFGetField(in, TIFFTAG_PLANARCONFIG, &config); + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, + TIFFDefaultStripSize(out, rowsperstrip)); - out = TIFFOpen(argv[optind + 1], "w"); - if (out == NULL) - { - goto tiff2bw_error; - } - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, w); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, h); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - cpTags(in, out); - if (compression != (uint16_t)-1) - { - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - switch (compression) - { - case COMPRESSION_JPEG: - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != 0) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - break; - } - } - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); - snprintf(thing, sizeof(thing), "B&W version of %s", argv[optind]); - TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing); - TIFFSetField(out, TIFFTAG_SOFTWARE, "tiff2bw"); - outbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out)); - if (!outbuf) - { - fprintf(stderr, "Out of memory\n"); - goto tiff2bw_error; - } - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, - TIFFDefaultStripSize(out, rowsperstrip)); - -#define pack(a, b) ((a) << 8 | (b)) - switch (pack(photometric, config)) - { - case pack(PHOTOMETRIC_PALETTE, PLANARCONFIG_CONTIG): - case pack(PHOTOMETRIC_PALETTE, PLANARCONFIG_SEPARATE): - TIFFGetField(in, TIFFTAG_COLORMAP, &red, &green, &blue); - /* - * Convert 16-bit colormap to 8-bit (unless it looks - * like an old-style 8-bit colormap). - */ - if (checkcmap(in, 1 << bitspersample, red, green, blue) == 16) - { - int i; -#define CVT(x) (((x)*255L) / ((1L << 16) - 1)) - for (i = (1 << bitspersample) - 1; i >= 0; i--) - { - red[i] = CVT(red[i]); - green[i] = CVT(green[i]); - blue[i] = CVT(blue[i]); - } +#define pack(a,b) ((a)<<8 | (b)) + switch (pack(photometric, config)) { + case pack(PHOTOMETRIC_PALETTE, PLANARCONFIG_CONTIG): + case pack(PHOTOMETRIC_PALETTE, PLANARCONFIG_SEPARATE): + TIFFGetField(in, TIFFTAG_COLORMAP, &red, &green, &blue); + /* + * Convert 16-bit colormap to 8-bit (unless it looks + * like an old-style 8-bit colormap). + */ + if (checkcmap(in, 1<= 0; i--) { + red[i] = CVT(red[i]); + green[i] = CVT(green[i]); + blue[i] = CVT(blue[i]); + } #undef CVT - } - inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); - if (!inbuf) - { - fprintf(stderr, "Out of memory\n"); - goto tiff2bw_error; - } - for (row = 0; row < h; row++) - { - if (TIFFReadScanline(in, inbuf, row, 0) < 0) - break; - compresspalette(outbuf, inbuf, w, red, green, blue); - if (TIFFWriteScanline(out, outbuf, row, 0) < 0) - break; - } - break; - case pack(PHOTOMETRIC_RGB, PLANARCONFIG_CONTIG): - inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); - if (!inbuf) - { - fprintf(stderr, "Out of memory\n"); - goto tiff2bw_error; - } - for (row = 0; row < h; row++) - { - if (TIFFReadScanline(in, inbuf, row, 0) < 0) - break; - compresscontig(outbuf, inbuf, w); - if (TIFFWriteScanline(out, outbuf, row, 0) < 0) - break; - } - break; - case pack(PHOTOMETRIC_RGB, PLANARCONFIG_SEPARATE): + } + inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); + if( !inbuf ) + { + fprintf(stderr, "Out of memory\n"); + goto tiff2bw_error; + } + for (row = 0; row < h; row++) { + if (TIFFReadScanline(in, inbuf, row, 0) < 0) + break; + compresspalette(outbuf, inbuf, w, red, green, blue); + if (TIFFWriteScanline(out, outbuf, row, 0) < 0) + break; + } + break; + case pack(PHOTOMETRIC_RGB, PLANARCONFIG_CONTIG): + inbuf = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); + if( !inbuf ) + { + fprintf(stderr, "Out of memory\n"); + goto tiff2bw_error; + } + for (row = 0; row < h; row++) { + if (TIFFReadScanline(in, inbuf, row, 0) < 0) + break; + compresscontig(outbuf, inbuf, w); + if (TIFFWriteScanline(out, outbuf, row, 0) < 0) + break; + } + break; + case pack(PHOTOMETRIC_RGB, PLANARCONFIG_SEPARATE): { - tmsize_t inbufsize; - rowsize = TIFFScanlineSize(in); - inbufsize = TIFFSafeMultiply(tmsize_t, 3, rowsize); - inbuf = (unsigned char *)_TIFFmalloc(inbufsize); - if (!inbuf) - { - fprintf(stderr, "Out of memory\n"); - goto tiff2bw_error; - } - for (row = 0; row < h; row++) - { - for (s = 0; s < 3; s++) - if (TIFFReadScanline(in, inbuf + s * rowsize, row, s) < 0) - goto tiff2bw_error; - compresssep(outbuf, inbuf, inbuf + rowsize, inbuf + 2 * rowsize, - w); - if (TIFFWriteScanline(out, outbuf, row, 0) < 0) - break; - } - break; + tmsize_t inbufsize; + rowsize = TIFFScanlineSize(in); + inbufsize = TIFFSafeMultiply(tmsize_t, 3, rowsize); + inbuf = (unsigned char *)_TIFFmalloc(inbufsize); + if( !inbuf ) + { + fprintf(stderr, "Out of memory\n"); + goto tiff2bw_error; + } + for (row = 0; row < h; row++) { + for (s = 0; s < 3; s++) + if (TIFFReadScanline(in, + inbuf+s*rowsize, row, s) < 0) + goto tiff2bw_error; + compresssep(outbuf, + inbuf, inbuf+rowsize, inbuf+2*rowsize, w); + if (TIFFWriteScanline(out, outbuf, row, 0) < 0) + break; + } + break; } - } + } #undef pack - if (inbuf) - _TIFFfree(inbuf); - if (outbuf) - _TIFFfree(outbuf); - TIFFClose(in); - TIFFClose(out); - return (EXIT_SUCCESS); - -tiff2bw_error: - if (inbuf) - _TIFFfree(inbuf); - if (outbuf) - _TIFFfree(outbuf); - if (out) - TIFFClose(out); - if (in) + if (inbuf) + _TIFFfree(inbuf); + if (outbuf) + _TIFFfree(outbuf); TIFFClose(in); - return (EXIT_FAILURE); + TIFFClose(out); + return (EXIT_SUCCESS); + + tiff2bw_error: + if (inbuf) + _TIFFfree(inbuf); + if (outbuf) + _TIFFfree(outbuf); + if (out) + TIFFClose(out); + if (in) + TIFFClose(in); + return (EXIT_FAILURE); } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) { - if (streq(opt, "none")) - compression = COMPRESSION_NONE; - else if (streq(opt, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (strneq(opt, "jpeg", 4)) - { - char *cp = strchr(opt, ':'); + if (streq(opt, "none")) + compression = COMPRESSION_NONE; + else if (streq(opt, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (strneq(opt, "jpeg", 4)) { + char* cp = strchr(opt, ':'); - compression = COMPRESSION_JPEG; - while (cp) - { - if (isdigit((int)cp[1])) - quality = atoi(cp + 1); - else if (cp[1] == 'r') - jpegcolormode = JPEGCOLORMODE_RAW; - else - usage(EXIT_FAILURE); + compression = COMPRESSION_JPEG; + while( cp ) + { + if (isdigit((int)cp[1])) + quality = atoi(cp+1); + else if (cp[1] == 'r' ) + jpegcolormode = JPEGCOLORMODE_RAW; + else + usage(EXIT_FAILURE); - cp = strchr(cp + 1, ':'); - } - } - else if (strneq(opt, "lzw", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + cp = strchr(cp+1,':'); + } + } else if (strneq(opt, "lzw", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strneq(opt, "zip", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -#define CopyField(tag, v) \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v) -#define CopyField2(tag, v1, v2) \ - if (TIFFGetField(in, tag, &v1, &v2)) \ - TIFFSetField(out, tag, v1, v2) -#define CopyField3(tag, v1, v2, v3) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3)) \ - TIFFSetField(out, tag, v1, v2, v3) -#define CopyField4(tag, v1, v2, v3, v4) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) \ - TIFFSetField(out, tag, v1, v2, v3, v4) +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) +#define CopyField2(tag, v1, v2) \ + if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) +#define CopyField3(tag, v1, v2, v3) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) +#define CopyField4(tag, v1, v2, v3, v4) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) -static void cpTag(TIFF *in, TIFF *out, uint16_t tag, uint16_t count, - TIFFDataType type) +static void +cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) { - switch (type) - { - case TIFF_SHORT: - if (count == 1) - { - uint16_t shortv; - CopyField(tag, shortv); - } - else if (count == 2) - { - uint16_t shortv1, shortv2; - CopyField2(tag, shortv1, shortv2); - } - else if (count == 4) - { - uint16_t *tr, *tg, *tb, *ta; - CopyField4(tag, tr, tg, tb, ta); - } - else if (count == (uint16_t)-1) - { - uint16_t shortv1; - uint16_t *shortav; - CopyField2(tag, shortv1, shortav); - } - break; - case TIFF_LONG: - { - uint32_t longv; - CopyField(tag, longv); - } - break; - case TIFF_RATIONAL: - if (count == 1) - { - float floatv; - CopyField(tag, floatv); - } - else if (count == (uint16_t)-1) - { - float *floatav; - CopyField(tag, floatav); - } - break; - case TIFF_ASCII: - { - char *stringv; - CopyField(tag, stringv); - } - break; - case TIFF_DOUBLE: - if (count == 1) - { - double doublev; - CopyField(tag, doublev); - } - else if (count == (uint16_t)-1) - { - double *doubleav; - CopyField(tag, doubleav); - } - break; - default: - TIFFError(TIFFFileName(in), - "Data type %d is not supported, tag %d skipped.", tag, - type); - } + switch (type) { + case TIFF_SHORT: + if (count == 1) { + uint16 shortv; + CopyField(tag, shortv); + } else if (count == 2) { + uint16 shortv1, shortv2; + CopyField2(tag, shortv1, shortv2); + } else if (count == 4) { + uint16 *tr, *tg, *tb, *ta; + CopyField4(tag, tr, tg, tb, ta); + } else if (count == (uint16) -1) { + uint16 shortv1; + uint16* shortav; + CopyField2(tag, shortv1, shortav); + } + break; + case TIFF_LONG: + { uint32 longv; + CopyField(tag, longv); + } + break; + case TIFF_RATIONAL: + if (count == 1) { + float floatv; + CopyField(tag, floatv); + } else if (count == (uint16) -1) { + float* floatav; + CopyField(tag, floatav); + } + break; + case TIFF_ASCII: + { char* stringv; + CopyField(tag, stringv); + } + break; + case TIFF_DOUBLE: + if (count == 1) { + double doublev; + CopyField(tag, doublev); + } else if (count == (uint16) -1) { + double* doubleav; + CopyField(tag, doubleav); + } + break; + default: + TIFFError(TIFFFileName(in), + "Data type %d is not supported, tag %d skipped.", + tag, type); + } } #undef CopyField4 @@ -473,65 +435,65 @@ static void cpTag(TIFF *in, TIFF *out, uint16_t tag, uint16_t count, #undef CopyField2 #undef CopyField -static const struct cpTag -{ - uint16_t tag; - uint16_t count; - TIFFDataType type; +static struct cpTag { + uint16 tag; + uint16 count; + TIFFDataType type; } tags[] = { - {TIFFTAG_SUBFILETYPE, 1, TIFF_LONG}, - {TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT}, - {TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII}, - {TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII}, - {TIFFTAG_MAKE, 1, TIFF_ASCII}, - {TIFFTAG_MODEL, 1, TIFF_ASCII}, - {TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_PAGENAME, 1, TIFF_ASCII}, - {TIFFTAG_XPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_YPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT}, - {TIFFTAG_SOFTWARE, 1, TIFF_ASCII}, - {TIFFTAG_DATETIME, 1, TIFF_ASCII}, - {TIFFTAG_ARTIST, 1, TIFF_ASCII}, - {TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII}, - {TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL}, - {TIFFTAG_PRIMARYCHROMATICITIES, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT}, - {TIFFTAG_INKSET, 1, TIFF_SHORT}, - {TIFFTAG_DOTRANGE, 2, TIFF_SHORT}, - {TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII}, - {TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT}, - {TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT}, - {TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT}, - {TIFFTAG_REFERENCEBLACKWHITE, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_EXTRASAMPLES, (uint16_t)-1, TIFF_SHORT}, - {TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE}, - {TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE}, - {TIFFTAG_STONITS, 1, TIFF_DOUBLE}, + { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, + { TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT }, + { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, + { TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII }, + { TIFFTAG_MAKE, 1, TIFF_ASCII }, + { TIFFTAG_MODEL, 1, TIFF_ASCII }, + { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, 2, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, + { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, }; -#define NTAGS (sizeof(tags) / sizeof(tags[0])) +#define NTAGS (sizeof (tags) / sizeof (tags[0])) -static void cpTags(TIFF *in, TIFF *out) +static void +cpTags(TIFF* in, TIFF* out) { - const struct cpTag *p; + struct cpTag *p; for (p = tags; p < &tags[NTAGS]; p++) { - if (p->tag == TIFFTAG_GROUP3OPTIONS) + if( p->tag == TIFFTAG_GROUP3OPTIONS ) { - uint16_t compression; - if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || - compression != COMPRESSION_CCITTFAX3) + uint16 compression; + if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || + compression != COMPRESSION_CCITTFAX3 ) continue; } - if (p->tag == TIFFTAG_GROUP4OPTIONS) + if( p->tag == TIFFTAG_GROUP4OPTIONS ) { - uint16_t compression; - if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || - compression != COMPRESSION_CCITTFAX4) + uint16 compression; + if( !TIFFGetField(in, TIFFTAG_COMPRESSION, &compression) || + compression != COMPRESSION_CCITTFAX4 ) continue; } cpTag(in, out, p->tag, p->count, p->type); @@ -539,46 +501,45 @@ static void cpTags(TIFF *in, TIFF *out) } #undef NTAGS -static const char usage_info[] = - "Convert a color TIFF image to greyscale\n\n" - "usage: tiff2bw [options] input.tif output.tif\n" - "where options are:\n" - " -R % use #% from red channel\n" - " -G % use #% from green channel\n" - " -B % use #% from blue channel\n" - "\n" - " -r # make each strip have no more than # rows\n" - "\n" -#ifdef LZW_SUPPORT - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" - /* " LZW options:\n" */ - " # set predictor value\n" - " For example, -c lzw:2 for LZW-encoded data with horizontal " - "differencing\n" -#endif -#ifdef ZIP_SUPPORT - " -c zip[:opts] compress output with deflate encoding\n" - /* " Deflate (ZIP) options:\n" */ - " # set predictor value\n" -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits compress output with packbits encoding\n" -#endif -#ifdef CCITT_SUPPORT - " -c g3[:opts] compress output with CCITT Group 3 encoding\n" - " -c g4 compress output with CCITT Group 4 encoding\n" -#endif -#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || \ - defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) - " -c none use no compression algorithm on output\n" -#endif - "\n"; +const char* stuff[] = { +"usage: tiff2bw [options] input.tif output.tif", +"where options are:", +" -R % use #% from red channel", +" -G % use #% from green channel", +" -B % use #% from blue channel", +"", +" -r # make each strip have no more than # rows", +"", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c packbits compress output with packbits encoding", +" -c g3[:opts] compress output with CCITT Group 3 encoding", +" -c g4 compress output with CCITT Group 4 encoding", +" -c none use no compression algorithm on output", +"", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiff2pdf.c b/thirdparty/SDL2_image/external/libtiff/tools/tiff2pdf.c index 1dbdc87af..db45b59c3 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiff2pdf.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiff2pdf.c @@ -4,391 +4,364 @@ * * Copyright (c) 2003 Ross Finlayson * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the name of * Ross Finlayson may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Ross Finlayson. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL ROSS FINLAYSON BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include -#include -#include +#include "tif_config.h" + #include #include #include +#include #include +#include +#include #if HAVE_UNISTD_H -#include +# include #endif #ifdef HAVE_FCNTL_H -#include +# include #endif #ifdef HAVE_IO_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif -#include "libport.h" -#include "tif_config.h" -#include "tiffio.h" #include "tiffiop.h" +#include "tiffio.h" + +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); +#endif #ifndef EXIT_SUCCESS -#define EXIT_SUCCESS 0 +# define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE -#define EXIT_FAILURE 1 +# define EXIT_FAILURE 1 #endif #define TIFF2PDF_MODULE "tiff2pdf" -#define PS_UNIT_SIZE 72.0F +#define PS_UNIT_SIZE 72.0F -#define TIFF_DIR_MAX 65534 +#define TIFF_DIR_MAX 65534 #define DEFAULT_MAX_MALLOC (256 * 1024 * 1024) /* This type is of PDF color spaces. */ -typedef enum -{ - T2P_CS_BILEVEL = 0x01, /* Bilevel, black and white */ - T2P_CS_GRAY = 0x02, /* Single channel */ - T2P_CS_RGB = 0x04, /* Three channel tristimulus RGB */ - T2P_CS_CMYK = 0x08, /* Four channel CMYK print inkset */ - T2P_CS_LAB = 0x10, /* Three channel L*a*b* color space */ - T2P_CS_PALETTE = 0x1000, /* One of the above with a color map */ - T2P_CS_CALGRAY = 0x20, /* Calibrated single channel */ - T2P_CS_CALRGB = 0x40, /* Calibrated three channel tristimulus RGB */ - T2P_CS_ICCBASED = 0x80 /* ICC profile color specification */ +typedef enum { + T2P_CS_BILEVEL = 0x01, /* Bilevel, black and white */ + T2P_CS_GRAY = 0x02, /* Single channel */ + T2P_CS_RGB = 0x04, /* Three channel tristimulus RGB */ + T2P_CS_CMYK = 0x08, /* Four channel CMYK print inkset */ + T2P_CS_LAB = 0x10, /* Three channel L*a*b* color space */ + T2P_CS_PALETTE = 0x1000,/* One of the above with a color map */ + T2P_CS_CALGRAY = 0x20, /* Calibrated single channel */ + T2P_CS_CALRGB = 0x40, /* Calibrated three channel tristimulus RGB */ + T2P_CS_ICCBASED = 0x80 /* ICC profile color specification */ } t2p_cs_t; /* This type is of PDF compression types. */ -typedef enum -{ - T2P_COMPRESS_NONE = 0x00 +typedef enum{ + T2P_COMPRESS_NONE=0x00 #ifdef CCITT_SUPPORT - , - T2P_COMPRESS_G4 = 0x01 + , T2P_COMPRESS_G4=0x01 #endif #if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT) - , - T2P_COMPRESS_JPEG = 0x02 + , T2P_COMPRESS_JPEG=0x02 #endif #ifdef ZIP_SUPPORT - , - T2P_COMPRESS_ZIP = 0x04 + , T2P_COMPRESS_ZIP=0x04 #endif } t2p_compress_t; -/* This type is whether TIFF image data can be used in PDF without transcoding. - */ -typedef enum -{ - T2P_TRANSCODE_RAW = 0x01, /* The raw data from the input can be used without - recompressing */ - T2P_TRANSCODE_ENCODE = - 0x02 /* The data from the input is perhaps unencoded and reencoded */ +/* This type is whether TIFF image data can be used in PDF without transcoding. */ +typedef enum{ + T2P_TRANSCODE_RAW=0x01, /* The raw data from the input can be used without recompressing */ + T2P_TRANSCODE_ENCODE=0x02 /* The data from the input is perhaps unencoded and reencoded */ } t2p_transcode_t; /* This type is of information about the data samples of the input image. */ -typedef enum -{ - T2P_SAMPLE_NOTHING = - 0x0000, /* The unencoded samples are normal for the output colorspace */ - T2P_SAMPLE_ABGR_TO_RGB = - 0x0001, /* The unencoded samples are the result of ReadRGBAImage */ - T2P_SAMPLE_RGBA_TO_RGB = - 0x0002, /* The unencoded samples are contiguous RGBA */ - T2P_SAMPLE_RGBAA_TO_RGB = - 0x0004, /* The unencoded samples are RGBA with premultiplied alpha */ - T2P_SAMPLE_YCBCR_TO_RGB = 0x0008, - T2P_SAMPLE_YCBCR_TO_LAB = 0x0010, - T2P_SAMPLE_REALIZE_PALETTE = - 0x0020, /* The unencoded samples are indexes into the color map */ - T2P_SAMPLE_SIGNED_TO_UNSIGNED = - 0x0040, /* The unencoded samples are signed instead of unsignd */ - T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED = - 0x0040, /* The L*a*b* samples have a* and b* signed */ - T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG = - 0x0100 /* The unencoded samples are separate instead of contiguous */ +typedef enum{ + T2P_SAMPLE_NOTHING=0x0000, /* The unencoded samples are normal for the output colorspace */ + T2P_SAMPLE_ABGR_TO_RGB=0x0001, /* The unencoded samples are the result of ReadRGBAImage */ + T2P_SAMPLE_RGBA_TO_RGB=0x0002, /* The unencoded samples are contiguous RGBA */ + T2P_SAMPLE_RGBAA_TO_RGB=0x0004, /* The unencoded samples are RGBA with premultiplied alpha */ + T2P_SAMPLE_YCBCR_TO_RGB=0x0008, + T2P_SAMPLE_YCBCR_TO_LAB=0x0010, + T2P_SAMPLE_REALIZE_PALETTE=0x0020, /* The unencoded samples are indexes into the color map */ + T2P_SAMPLE_SIGNED_TO_UNSIGNED=0x0040, /* The unencoded samples are signed instead of unsignd */ + T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED=0x0040, /* The L*a*b* samples have a* and b* signed */ + T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG=0x0100 /* The unencoded samples are separate instead of contiguous */ } t2p_sample_t; /* This type is of error status of the T2P struct. */ -typedef enum -{ - T2P_ERR_OK = - 0, /* This is the value of t2p->t2p_error when there is no error */ - T2P_ERR_ERROR = - 1 /* This is the value of t2p->t2p_error when there was an error */ +typedef enum{ + T2P_ERR_OK = 0, /* This is the value of t2p->t2p_error when there is no error */ + T2P_ERR_ERROR = 1 /* This is the value of t2p->t2p_error when there was an error */ } t2p_err_t; /* This struct defines a logical page of a TIFF. */ -typedef struct -{ - tdir_t page_directory; - uint32_t page_number; - ttile_t page_tilecount; - uint32_t page_extra; +typedef struct { + tdir_t page_directory; + uint32 page_number; + ttile_t page_tilecount; + uint32 page_extra; } T2P_PAGE; /* This struct defines a PDF rectangle's coordinates. */ -typedef struct -{ - float x1; - float y1; - float x2; - float y2; - float mat[9]; +typedef struct { + float x1; + float y1; + float x2; + float y2; + float mat[9]; } T2P_BOX; /* This struct defines a tile of a PDF. */ -typedef struct -{ - T2P_BOX tile_box; +typedef struct { + T2P_BOX tile_box; } T2P_TILE; /* This struct defines information about the tiles on a PDF page. */ -typedef struct -{ - ttile_t tiles_tilecount; - uint32_t tiles_tilewidth; - uint32_t tiles_tilelength; - uint32_t tiles_tilecountx; - uint32_t tiles_tilecounty; - uint32_t tiles_edgetilewidth; - uint32_t tiles_edgetilelength; - T2P_TILE *tiles_tiles; +typedef struct { + ttile_t tiles_tilecount; + uint32 tiles_tilewidth; + uint32 tiles_tilelength; + uint32 tiles_tilecountx; + uint32 tiles_tilecounty; + uint32 tiles_edgetilewidth; + uint32 tiles_edgetilelength; + T2P_TILE* tiles_tiles; } T2P_TILES; /* This struct is the context of a function to generate PDF from a TIFF. */ -typedef struct -{ - t2p_err_t t2p_error; - T2P_PAGE *tiff_pages; - T2P_TILES *tiff_tiles; - tdir_t tiff_pagecount; - uint16_t tiff_compression; - uint16_t tiff_photometric; - uint16_t tiff_fillorder; - uint16_t tiff_bitspersample; - uint16_t tiff_samplesperpixel; - uint16_t tiff_planar; - uint32_t tiff_width; - uint32_t tiff_length; - float tiff_xres; - float tiff_yres; - uint16_t tiff_orientation; - toff_t tiff_dataoffset; - tsize_t tiff_datasize; - tsize_t tiff_maxdatasize; - uint16_t tiff_resunit; - uint16_t pdf_centimeters; - uint16_t pdf_overrideres; - uint16_t pdf_overridepagesize; - float pdf_defaultxres; - float pdf_defaultyres; - float pdf_xres; - float pdf_yres; - float pdf_defaultpagewidth; - float pdf_defaultpagelength; - float pdf_pagewidth; - float pdf_pagelength; - float pdf_imagewidth; - float pdf_imagelength; - int pdf_image_fillpage; /* 0 (default: no scaling, 1:scale imagesize to - pagesize */ - T2P_BOX pdf_mediabox; - T2P_BOX pdf_imagebox; - uint16_t pdf_majorversion; - uint16_t pdf_minorversion; - uint32_t pdf_catalog; - uint32_t pdf_pages; - uint32_t pdf_info; - uint32_t pdf_palettecs; - uint16_t pdf_fitwindow; - uint32_t pdf_startxref; +typedef struct { + t2p_err_t t2p_error; + T2P_PAGE* tiff_pages; + T2P_TILES* tiff_tiles; + tdir_t tiff_pagecount; + uint16 tiff_compression; + uint16 tiff_photometric; + uint16 tiff_fillorder; + uint16 tiff_bitspersample; + uint16 tiff_samplesperpixel; + uint16 tiff_planar; + uint32 tiff_width; + uint32 tiff_length; + float tiff_xres; + float tiff_yres; + uint16 tiff_orientation; + toff_t tiff_dataoffset; + tsize_t tiff_datasize; + tsize_t tiff_maxdatasize; + uint16 tiff_resunit; + uint16 pdf_centimeters; + uint16 pdf_overrideres; + uint16 pdf_overridepagesize; + float pdf_defaultxres; + float pdf_defaultyres; + float pdf_xres; + float pdf_yres; + float pdf_defaultpagewidth; + float pdf_defaultpagelength; + float pdf_pagewidth; + float pdf_pagelength; + float pdf_imagewidth; + float pdf_imagelength; + int pdf_image_fillpage; /* 0 (default: no scaling, 1:scale imagesize to pagesize */ + T2P_BOX pdf_mediabox; + T2P_BOX pdf_imagebox; + uint16 pdf_majorversion; + uint16 pdf_minorversion; + uint32 pdf_catalog; + uint32 pdf_pages; + uint32 pdf_info; + uint32 pdf_palettecs; + uint16 pdf_fitwindow; + uint32 pdf_startxref; #define TIFF2PDF_FILEID_SIZE 33 - char pdf_fileid[TIFF2PDF_FILEID_SIZE]; + char pdf_fileid[TIFF2PDF_FILEID_SIZE]; #define TIFF2PDF_DATETIME_SIZE 17 - char pdf_datetime[TIFF2PDF_DATETIME_SIZE]; + char pdf_datetime[TIFF2PDF_DATETIME_SIZE]; #define TIFF2PDF_CREATOR_SIZE 512 - char pdf_creator[TIFF2PDF_CREATOR_SIZE]; - int pdf_creator_set; + char pdf_creator[TIFF2PDF_CREATOR_SIZE]; + int pdf_creator_set; #define TIFF2PDF_AUTHOR_SIZE 512 - char pdf_author[TIFF2PDF_AUTHOR_SIZE]; - int pdf_author_set; + char pdf_author[TIFF2PDF_AUTHOR_SIZE]; + int pdf_author_set; #define TIFF2PDF_TITLE_SIZE 512 - char pdf_title[TIFF2PDF_TITLE_SIZE]; - int pdf_title_set; + char pdf_title[TIFF2PDF_TITLE_SIZE]; + int pdf_title_set; #define TIFF2PDF_SUBJECT_SIZE 512 - char pdf_subject[TIFF2PDF_SUBJECT_SIZE]; - int pdf_subject_set; + char pdf_subject[TIFF2PDF_SUBJECT_SIZE]; + int pdf_subject_set; #define TIFF2PDF_KEYWORDS_SIZE 512 - char pdf_keywords[TIFF2PDF_KEYWORDS_SIZE]; - int pdf_keywords_set; - t2p_cs_t pdf_colorspace; - uint16_t pdf_colorspace_invert; - uint16_t pdf_switchdecode; - uint16_t pdf_palettesize; - unsigned char *pdf_palette; - int pdf_labrange[4]; - t2p_compress_t pdf_defaultcompression; - uint16_t pdf_defaultcompressionquality; - t2p_compress_t pdf_compression; - uint16_t - pdf_compressionquality; /* for deflate : 100 * zipquality + predictor */ - uint16_t pdf_nopassthrough; - t2p_transcode_t pdf_transcode; - t2p_sample_t pdf_sample; - uint32_t *pdf_xrefoffsets; - uint32_t pdf_xrefcount; - tdir_t pdf_page; + char pdf_keywords[TIFF2PDF_KEYWORDS_SIZE]; + int pdf_keywords_set; + t2p_cs_t pdf_colorspace; + uint16 pdf_colorspace_invert; + uint16 pdf_switchdecode; + uint16 pdf_palettesize; + unsigned char* pdf_palette; + int pdf_labrange[4]; + t2p_compress_t pdf_defaultcompression; + uint16 pdf_defaultcompressionquality; + t2p_compress_t pdf_compression; + uint16 pdf_compressionquality; /* for deflate : 100 * zipquality + predictor */ + uint16 pdf_nopassthrough; + t2p_transcode_t pdf_transcode; + t2p_sample_t pdf_sample; + uint32* pdf_xrefoffsets; + uint32 pdf_xrefcount; + tdir_t pdf_page; #ifdef OJPEG_SUPPORT - tdata_t pdf_ojpegdata; - uint32_t pdf_ojpegdatalength; - uint32_t pdf_ojpegiflength; + tdata_t pdf_ojpegdata; + uint32 pdf_ojpegdatalength; + uint32 pdf_ojpegiflength; #endif - float tiff_whitechromaticities[2]; - float tiff_primarychromaticities[6]; - float tiff_referenceblackwhite[2]; - uint16_t *tiff_transferfunction[3]; - int pdf_image_interpolate; /* 0 (default) : do not interpolate, - 1 : interpolate */ - uint16_t tiff_transferfunctioncount; - uint32_t pdf_icccs; - uint32_t tiff_iccprofilelength; - tdata_t tiff_iccprofile; + float tiff_whitechromaticities[2]; + float tiff_primarychromaticities[6]; + float tiff_referenceblackwhite[2]; + uint16* tiff_transferfunction[3]; + int pdf_image_interpolate; /* 0 (default) : do not interpolate, + 1 : interpolate */ + uint16 tiff_transferfunctioncount; + uint32 pdf_icccs; + uint32 tiff_iccprofilelength; + tdata_t tiff_iccprofile; - /* fields for custom read/write procedures */ - FILE *outputfile; - int outputdisable; - tsize_t outputwritten; + /* fields for custom read/write procedures */ + FILE *outputfile; + int outputdisable; + tsize_t outputwritten; } T2P; /* These functions are called by main. */ -static void usage_info(int); -int tiff2pdf_match_paper_size(float *, float *, char *); +static void tiff2pdf_usage(int); +int tiff2pdf_match_paper_size(float*, float*, char*); -/* These functions are used to generate a PDF from a TIFF. */ +/* These functions are used to generate a PDF from a TIFF. */ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif - T2P *t2p_init(void); - void t2p_validate(T2P *); - tsize_t t2p_write_pdf(T2P *, TIFF *, TIFF *); - void t2p_free(T2P *); +T2P* t2p_init(void); +void t2p_validate(T2P*); +tsize_t t2p_write_pdf(T2P*, TIFF*, TIFF*); +void t2p_free(T2P*); #ifdef __cplusplus } #endif -void t2p_read_tiff_init(T2P *, TIFF *); -int t2p_cmp_t2p_page(const void *, const void *); -void t2p_read_tiff_data(T2P *, TIFF *); -void t2p_read_tiff_size(T2P *, TIFF *); -void t2p_read_tiff_size_tile(T2P *, TIFF *, ttile_t); +void t2p_read_tiff_init(T2P*, TIFF*); +int t2p_cmp_t2p_page(const void*, const void*); +void t2p_read_tiff_data(T2P*, TIFF*); +void t2p_read_tiff_size(T2P*, TIFF*); +void t2p_read_tiff_size_tile(T2P*, TIFF*, ttile_t); int t2p_tile_is_right_edge(T2P_TILES, ttile_t); int t2p_tile_is_bottom_edge(T2P_TILES, ttile_t); int t2p_tile_is_edge(T2P_TILES, ttile_t); int t2p_tile_is_corner_edge(T2P_TILES, ttile_t); -tsize_t t2p_readwrite_pdf_image(T2P *, TIFF *, TIFF *); -tsize_t t2p_readwrite_pdf_image_tile(T2P *, TIFF *, TIFF *, ttile_t); +tsize_t t2p_readwrite_pdf_image(T2P*, TIFF*, TIFF*); +tsize_t t2p_readwrite_pdf_image_tile(T2P*, TIFF*, TIFF*, ttile_t); #ifdef OJPEG_SUPPORT -int t2p_process_ojpeg_tables(T2P *, TIFF *); +int t2p_process_ojpeg_tables(T2P*, TIFF*); #endif #ifdef JPEG_SUPPORT -int t2p_process_jpeg_strip(unsigned char *, tsize_t *, unsigned char *, tsize_t, - tsize_t *, tstrip_t, uint32_t); +int t2p_process_jpeg_strip(unsigned char*, tsize_t*, unsigned char*, tsize_t, tsize_t*, tstrip_t, uint32); #endif -void t2p_tile_collapse_left(tdata_t, tsize_t, uint32_t, uint32_t, uint32_t); -void t2p_write_advance_directory(T2P *, TIFF *); -tsize_t t2p_sample_planar_separate_to_contig(T2P *, unsigned char *, - unsigned char *, tsize_t); -tsize_t t2p_sample_realize_palette(T2P *, unsigned char *); -tsize_t t2p_sample_abgr_to_rgb(tdata_t, uint32_t); -tsize_t t2p_sample_rgba_to_rgb(tdata_t, uint32_t); -tsize_t t2p_sample_rgbaa_to_rgb(tdata_t, uint32_t); -tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t, uint32_t); -tsize_t t2p_write_pdf_header(T2P *, TIFF *); -tsize_t t2p_write_pdf_obj_start(uint32_t, TIFF *); -tsize_t t2p_write_pdf_obj_end(TIFF *); -tsize_t t2p_write_pdf_name(const unsigned char *, TIFF *); -tsize_t t2p_write_pdf_string(const char *, TIFF *); -tsize_t t2p_write_pdf_stream(tdata_t, tsize_t, TIFF *); -tsize_t t2p_write_pdf_stream_start(TIFF *); -tsize_t t2p_write_pdf_stream_end(TIFF *); -tsize_t t2p_write_pdf_stream_dict(tsize_t, uint32_t, TIFF *); -tsize_t t2p_write_pdf_stream_dict_start(TIFF *); -tsize_t t2p_write_pdf_stream_dict_end(TIFF *); -tsize_t t2p_write_pdf_stream_length(tsize_t, TIFF *); -tsize_t t2p_write_pdf_catalog(T2P *, TIFF *); -tsize_t t2p_write_pdf_info(T2P *, TIFF *, TIFF *); -void t2p_pdf_currenttime(T2P *); -void t2p_pdf_tifftime(T2P *, TIFF *); -tsize_t t2p_write_pdf_pages(T2P *, TIFF *); -tsize_t t2p_write_pdf_page(uint32_t, T2P *, TIFF *); -void t2p_compose_pdf_page(T2P *); -void t2p_compose_pdf_page_orient(T2P_BOX *, uint16_t); -void t2p_compose_pdf_page_orient_flip(T2P_BOX *, uint16_t); -tsize_t t2p_write_pdf_page_content(T2P *, TIFF *); -tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t, T2P *, TIFF *); -tsize_t t2p_write_pdf_xobject_cs(T2P *, TIFF *); -tsize_t t2p_write_pdf_transfer(T2P *, TIFF *); -tsize_t t2p_write_pdf_transfer_dict(T2P *, TIFF *, uint16_t); -tsize_t t2p_write_pdf_transfer_stream(T2P *, TIFF *, uint16_t); -tsize_t t2p_write_pdf_xobject_calcs(T2P *, TIFF *); -tsize_t t2p_write_pdf_xobject_icccs(T2P *, TIFF *); -tsize_t t2p_write_pdf_xobject_icccs_dict(T2P *, TIFF *); -tsize_t t2p_write_pdf_xobject_icccs_stream(T2P *, TIFF *); -tsize_t t2p_write_pdf_xobject_cs_stream(T2P *, TIFF *); -tsize_t t2p_write_pdf_xobject_decode(T2P *, TIFF *); -tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t, T2P *, TIFF *); -tsize_t t2p_write_pdf_xreftable(T2P *, TIFF *); -tsize_t t2p_write_pdf_trailer(T2P *, TIFF *); +void t2p_tile_collapse_left(tdata_t, tsize_t, uint32, uint32, uint32); +void t2p_write_advance_directory(T2P*, TIFF*); +tsize_t t2p_sample_planar_separate_to_contig(T2P*, unsigned char*, unsigned char*, tsize_t); +tsize_t t2p_sample_realize_palette(T2P*, unsigned char*); +tsize_t t2p_sample_abgr_to_rgb(tdata_t, uint32); +tsize_t t2p_sample_rgba_to_rgb(tdata_t, uint32); +tsize_t t2p_sample_rgbaa_to_rgb(tdata_t, uint32); +tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t, uint32); +tsize_t t2p_write_pdf_header(T2P*, TIFF*); +tsize_t t2p_write_pdf_obj_start(uint32, TIFF*); +tsize_t t2p_write_pdf_obj_end(TIFF*); +tsize_t t2p_write_pdf_name(const unsigned char*, TIFF*); +tsize_t t2p_write_pdf_string(const char*, TIFF*); +tsize_t t2p_write_pdf_stream(tdata_t, tsize_t, TIFF*); +tsize_t t2p_write_pdf_stream_start(TIFF*); +tsize_t t2p_write_pdf_stream_end(TIFF*); +tsize_t t2p_write_pdf_stream_dict(tsize_t, uint32, TIFF*); +tsize_t t2p_write_pdf_stream_dict_start(TIFF*); +tsize_t t2p_write_pdf_stream_dict_end(TIFF*); +tsize_t t2p_write_pdf_stream_length(tsize_t, TIFF*); +tsize_t t2p_write_pdf_catalog(T2P*, TIFF*); +tsize_t t2p_write_pdf_info(T2P*, TIFF*, TIFF*); +void t2p_pdf_currenttime(T2P*); +void t2p_pdf_tifftime(T2P*, TIFF*); +tsize_t t2p_write_pdf_pages(T2P*, TIFF*); +tsize_t t2p_write_pdf_page(uint32, T2P*, TIFF*); +void t2p_compose_pdf_page(T2P*); +void t2p_compose_pdf_page_orient(T2P_BOX*, uint16); +void t2p_compose_pdf_page_orient_flip(T2P_BOX*, uint16); +tsize_t t2p_write_pdf_page_content(T2P*, TIFF*); +tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t, T2P*, TIFF*); +tsize_t t2p_write_pdf_xobject_cs(T2P*, TIFF*); +tsize_t t2p_write_pdf_transfer(T2P*, TIFF*); +tsize_t t2p_write_pdf_transfer_dict(T2P*, TIFF*, uint16); +tsize_t t2p_write_pdf_transfer_stream(T2P*, TIFF*, uint16); +tsize_t t2p_write_pdf_xobject_calcs(T2P*, TIFF*); +tsize_t t2p_write_pdf_xobject_icccs(T2P*, TIFF*); +tsize_t t2p_write_pdf_xobject_icccs_dict(T2P*, TIFF*); +tsize_t t2p_write_pdf_xobject_icccs_stream(T2P*, TIFF*); +tsize_t t2p_write_pdf_xobject_cs_stream(T2P*, TIFF*); +tsize_t t2p_write_pdf_xobject_decode(T2P*, TIFF*); +tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t, T2P*, TIFF*); +tsize_t t2p_write_pdf_xreftable(T2P*, TIFF*); +tsize_t t2p_write_pdf_trailer(T2P*, TIFF*); -#define check_snprintf_ret(t2p, rv, buf) \ - do \ - { \ - if ((rv) < 0) \ - rv = 0; \ - else if ((rv) >= (int)sizeof(buf)) \ - (rv) = sizeof(buf) - 1; \ - else \ - break; \ - if ((t2p) != NULL) \ - (t2p)->t2p_error = T2P_ERR_ERROR; \ - } while (0) +#define check_snprintf_ret(t2p, rv, buf) do { \ + if ((rv) < 0) rv = 0; \ + else if((rv) >= (int)sizeof(buf)) (rv) = sizeof(buf) - 1; \ + else break; \ + if ((t2p) != NULL) (t2p)->t2p_error = T2P_ERR_ERROR; \ +} while(0) -static void t2p_disable(TIFF *tif) +static void +t2p_disable(TIFF *tif) { - T2P *t2p = (T2P *)TIFFClientdata(tif); - t2p->outputdisable = 1; + T2P *t2p = (T2P*) TIFFClientdata(tif); + t2p->outputdisable = 1; } -static void t2p_enable(TIFF *tif) +static void +t2p_enable(TIFF *tif) { - T2P *t2p = (T2P *)TIFFClientdata(tif); - t2p->outputdisable = 0; + T2P *t2p = (T2P*) TIFFClientdata(tif); + t2p->outputdisable = 0; } /* @@ -396,191 +369,196 @@ static void t2p_enable(TIFF *tif) */ #ifdef OJPEG_SUPPORT -static tmsize_t t2pReadFile(TIFF *tif, tdata_t data, tmsize_t size) +static tmsize_t +t2pReadFile(TIFF *tif, tdata_t data, tmsize_t size) { - thandle_t client = TIFFClientdata(tif); - TIFFReadWriteProc proc = TIFFGetReadProc(tif); - if (proc) - return proc(client, data, size); - return -1; + thandle_t client = TIFFClientdata(tif); + TIFFReadWriteProc proc = TIFFGetReadProc(tif); + if (proc) + return proc(client, data, size); + return -1; } #endif /* OJPEG_SUPPORT */ -static tmsize_t t2pWriteFile(TIFF *tif, tdata_t data, tmsize_t size) +static tmsize_t +t2pWriteFile(TIFF *tif, tdata_t data, tmsize_t size) { - thandle_t client = TIFFClientdata(tif); - TIFFReadWriteProc proc = TIFFGetWriteProc(tif); - if (proc) - return proc(client, data, size); - return -1; + thandle_t client = TIFFClientdata(tif); + TIFFReadWriteProc proc = TIFFGetWriteProc(tif); + if (proc) + return proc(client, data, size); + return -1; } -static uint64_t t2pSeekFile(TIFF *tif, toff_t offset, int whence) +static uint64 +t2pSeekFile(TIFF *tif, toff_t offset, int whence) { - thandle_t client = TIFFClientdata(tif); - TIFFSeekProc proc = TIFFGetSeekProc(tif); - if (proc) - return proc(client, offset, whence); - return -1; + thandle_t client = TIFFClientdata(tif); + TIFFSeekProc proc = TIFFGetSeekProc(tif); + if (proc) + return proc(client, offset, whence); + return -1; } -static tmsize_t t2p_readproc(thandle_t handle, tdata_t data, tmsize_t size) +static tmsize_t +t2p_readproc(thandle_t handle, tdata_t data, tmsize_t size) { - (void)handle, (void)data, (void)size; - return -1; + (void) handle, (void) data, (void) size; + return -1; } -static tmsize_t t2p_writeproc(thandle_t handle, tdata_t data, tmsize_t size) +static tmsize_t +t2p_writeproc(thandle_t handle, tdata_t data, tmsize_t size) { - T2P *t2p = (T2P *)handle; - if (t2p->outputdisable <= 0 && t2p->outputfile) - { - tsize_t written = fwrite(data, 1, size, t2p->outputfile); - t2p->outputwritten += written; - return written; - } - return size; + T2P *t2p = (T2P*) handle; + if (t2p->outputdisable <= 0 && t2p->outputfile) { + tsize_t written = fwrite(data, 1, size, t2p->outputfile); + t2p->outputwritten += written; + return written; + } + return size; } -static uint64_t t2p_seekproc(thandle_t handle, uint64_t offset, int whence) -{ - T2P *t2p = (T2P *)handle; - if (t2p->outputdisable <= 0 && t2p->outputfile != stdout && t2p->outputfile) - return _TIFF_fseek_f(t2p->outputfile, (_TIFF_off_t)offset, whence); - return offset; +static uint64 +t2p_seekproc(thandle_t handle, uint64 offset, int whence) +{ + T2P *t2p = (T2P*) handle; + if (t2p->outputdisable <= 0 && t2p->outputfile) + return _TIFF_fseek_f(t2p->outputfile, (_TIFF_off_t) offset, whence); + return offset; } -static int t2p_closeproc(thandle_t handle) -{ - T2P *t2p = (T2P *)handle; - return fclose(t2p->outputfile); +static int +t2p_closeproc(thandle_t handle) +{ + T2P *t2p = (T2P*) handle; + return fclose(t2p->outputfile); } -static uint64_t t2p_sizeproc(thandle_t handle) +static uint64 +t2p_sizeproc(thandle_t handle) { - (void)handle; - return -1; + (void) handle; + return -1; } -static int t2p_mapproc(thandle_t handle, void **data, toff_t *offset) -{ - (void)handle, (void)data, (void)offset; - return -1; +static int +t2p_mapproc(thandle_t handle, void **data, toff_t *offset) +{ + (void) handle, (void) data, (void) offset; + return -1; } -static void t2p_unmapproc(thandle_t handle, void *data, toff_t offset) -{ - (void)handle, (void)data, (void)offset; +static void +t2p_unmapproc(thandle_t handle, void *data, toff_t offset) +{ + (void) handle, (void) data, (void) offset; } #if defined(OJPEG_SUPPORT) || defined(JPEG_SUPPORT) -static uint64_t checkAdd64(uint64_t summand1, uint64_t summand2, T2P *t2p) +static uint64 +checkAdd64(uint64 summand1, uint64 summand2, T2P* t2p) { - uint64_t bytes = summand1 + summand2; + uint64 bytes = summand1 + summand2; - if (bytes < summand1) - { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - bytes = 0; - } + if (bytes < summand1) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + bytes = 0; + } - return bytes; + return bytes; } #endif /* defined(OJPEG_SUPPORT) || defined(JPEG_SUPPORT) */ -static uint64_t checkMultiply64(uint64_t first, uint64_t second, T2P *t2p) +static uint64 +checkMultiply64(uint64 first, uint64 second, T2P* t2p) { - uint64_t bytes = first * second; + uint64 bytes = first * second; - if (second && bytes / second != first) - { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - bytes = 0; - } + if (second && bytes / second != first) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + bytes = 0; + } - return bytes; + return bytes; } /* This is the main function. - The program converts one TIFF file to one PDF file, including multiple page - TIFF files, tiled TIFF files, black and white. grayscale, and color TIFF - files that contain data of TIFF photometric interpretations of bilevel, - grayscale, RGB, YCbCr, CMYK separation, and ICC L*a*b* as supported by + The program converts one TIFF file to one PDF file, including multiple page + TIFF files, tiled TIFF files, black and white. grayscale, and color TIFF + files that contain data of TIFF photometric interpretations of bilevel, + grayscale, RGB, YCbCr, CMYK separation, and ICC L*a*b* as supported by libtiff and PDF. - If you have multiple TIFF files to convert into one PDF file then use tiffcp - or other program to concatenate the files into a multiple page TIFF file. + If you have multiple TIFF files to convert into one PDF file then use tiffcp + or other program to concatenate the files into a multiple page TIFF file. If the input TIFF file is of huge dimensions (greater than 10000 pixels height or width) convert the input image to a tiled TIFF if it is not already. - The standard output is standard output. Set the output file name with the + The standard output is standard output. Set the output file name with the "-o output.pdf" option. - All black and white files are compressed into a single strip CCITT G4 Fax - compressed PDF, unless tiled, where tiled black and white images are - compressed into tiled CCITT G4 Fax compressed PDF, libtiff CCITT support + All black and white files are compressed into a single strip CCITT G4 Fax + compressed PDF, unless tiled, where tiled black and white images are + compressed into tiled CCITT G4 Fax compressed PDF, libtiff CCITT support is assumed. - Color and grayscale data can be compressed using either JPEG compression, - ITU-T T.81, or Zip/Deflate LZ77 compression, per PNG 1.2 and RFC 1951. Set - the compression type using the -j or -z options. JPEG compression support - requires that libtiff be configured with JPEG support, and Zip/Deflate - compression support requires that libtiff is configured with Zip support, - in tiffconf.h. Use only one or the other of -j and -z. The -q option - sets the image compression quality, that is 1-100 with libjpeg JPEG - compression and one of 1, 10, 11, 12, 13, 14, or 15 for PNG group compression + Color and grayscale data can be compressed using either JPEG compression, + ITU-T T.81, or Zip/Deflate LZ77 compression, per PNG 1.2 and RFC 1951. Set + the compression type using the -j or -z options. JPEG compression support + requires that libtiff be configured with JPEG support, and Zip/Deflate + compression support requires that libtiff is configured with Zip support, + in tiffconf.h. Use only one or the other of -j and -z. The -q option + sets the image compression quality, that is 1-100 with libjpeg JPEG + compression and one of 1, 10, 11, 12, 13, 14, or 15 for PNG group compression predictor methods, add 100, 200, ..., 900 to set zlib compression quality 1-9. PNG Group differencing predictor methods are not currently implemented. - If the input TIFF contains single strip CCITT G4 Fax compressed information, - then that is written to the PDF file without transcoding, unless the options + If the input TIFF contains single strip CCITT G4 Fax compressed information, + then that is written to the PDF file without transcoding, unless the options of no compression and no passthrough are set, -d and -n. - If the input TIFF contains JPEG or single strip Zip/Deflate compressed - information, and they are configured, then that is written to the PDF file - without transcoding, unless the options of no compression and no passthrough + If the input TIFF contains JPEG or single strip Zip/Deflate compressed + information, and they are configured, then that is written to the PDF file + without transcoding, unless the options of no compression and no passthrough are set. - The default page size upon which the TIFF image is placed is determined by - the resolution and extent of the image data. Default values for the TIFF - image resolution can be set using the -x and -y options. The page size can - be set using the -p option for paper size, or -w and -l for paper width and - length, then each page of the TIFF image is centered on its page. The - distance unit for default resolution and page width and length can be set + The default page size upon which the TIFF image is placed is determined by + the resolution and extent of the image data. Default values for the TIFF + image resolution can be set using the -x and -y options. The page size can + be set using the -p option for paper size, or -w and -l for paper width and + length, then each page of the TIFF image is centered on its page. The + distance unit for default resolution and page width and length can be set by the -u option, the default unit is inch. - Various items of the output document information can be set with the -e, -c, - -a, -t, -s, and -k tags. Setting the argument of the option to "" for these - tags causes the relevant document information field to be not written. Some - of the document information values otherwise get their information from the + Various items of the output document information can be set with the -e, -c, + -a, -t, -s, and -k tags. Setting the argument of the option to "" for these + tags causes the relevant document information field to be not written. Some + of the document information values otherwise get their information from the input TIFF image, the software, author, document name, and image description. - The output PDF file conforms to the PDF 1.1 specification or PDF 1.2 if using - Zip/Deflate compression. - - The Portable Document Format (PDF) specification is copyrighted by Adobe + The output PDF file conforms to the PDF 1.1 specification or PDF 1.2 if using + Zip/Deflate compression. + + The Portable Document Format (PDF) specification is copyrighted by Adobe Systems, Incorporated. Todos derechos reservados. - Here is a listing of the usage example and the options to the tiff2pdf - program that is part of the libtiff distribution. Options followed by + Here is a listing of the usage example and the options to the tiff2pdf + program that is part of the libtiff distribution. Options followed by a colon have a required argument. - + usage: tiff2pdf [options] input.tif options: -o: output to file name -#ifdef JPEG_SUPPORT -j: compress with JPEG (requires libjpeg configured with libtiff) -#endif -#ifdef ZIP_SUPPORT -printf (-z: compress with Zip/Deflate (requires zlib configured with libtiff)); -#endif + -z: compress with Zip/Deflate (requires zlib configured with libtiff) -q: compression quality -n: no compressed data passthrough -d: do not compress (decompress) @@ -621,741 +599,686 @@ printf (-z: compress with Zip/Deflate (requires zlib configured with libtiff)); putting the image pages on a letter sized page, compressing the output with JPEG. - Please report bugs through: + Please report bugs through: - http://bugzilla.remotesensing.org/buglist.cgi?product=libtiff + http://bugzilla.remotesensing.org/buglist.cgi?product=libtiff See also libtiff.3t, tiffcp. */ -int main(int argc, char **argv) -{ +int main(int argc, char** argv){ #if !HAVE_DECL_OPTARG - extern char *optarg; - extern int optind; + extern char *optarg; + extern int optind; #endif - const char *outfilename = NULL; - T2P *t2p = NULL; - TIFF *input = NULL, *output = NULL; - int c, ret = EXIT_SUCCESS; + const char *outfilename = NULL; + T2P *t2p = NULL; + TIFF *input = NULL, *output = NULL; + int c, ret = EXIT_SUCCESS; - t2p = t2p_init(); + t2p = t2p_init(); - if (t2p == NULL) - { - TIFFError(TIFF2PDF_MODULE, "Can't initialize context"); - goto fail; - } + if (t2p == NULL){ + TIFFError(TIFF2PDF_MODULE, "Can't initialize context"); + goto fail; + } - while (argv && - (c = getopt(argc, argv, - "m:o:q:u:x:y:w:l:r:p:e:c:a:t:s:k:jzndifbhF")) != -1) - { - switch (c) - { - case 'm': - t2p->tiff_maxdatasize = (tsize_t)strtoul(optarg, NULL, 0) << 20; - break; - case 'o': - outfilename = optarg; - break; + while (argv && + (c = getopt(argc, argv, + "m:o:q:u:x:y:w:l:r:p:e:c:a:t:s:k:jzndifbhF")) != -1){ + switch (c) { + case 'm': + t2p->tiff_maxdatasize = (tsize_t)strtoul(optarg, NULL, 0) << 20; + break; + case 'o': + outfilename = optarg; + break; #ifdef JPEG_SUPPORT - case 'j': - t2p->pdf_defaultcompression = T2P_COMPRESS_JPEG; - break; + case 'j': + t2p->pdf_defaultcompression=T2P_COMPRESS_JPEG; + break; #endif #ifndef JPEG_SUPPORT - case 'j': - TIFFWarning(TIFF2PDF_MODULE, - "JPEG support in libtiff required for JPEG " - "compression, ignoring option"); - break; + case 'j': + TIFFWarning( + TIFF2PDF_MODULE, + "JPEG support in libtiff required for JPEG compression, ignoring option"); + break; #endif #ifdef ZIP_SUPPORT - case 'z': - t2p->pdf_defaultcompression = T2P_COMPRESS_ZIP; - break; + case 'z': + t2p->pdf_defaultcompression=T2P_COMPRESS_ZIP; + break; #endif #ifndef ZIP_SUPPORT - case 'z': - TIFFWarning(TIFF2PDF_MODULE, - "Zip support in libtiff required for Zip " - "compression, ignoring option"); - break; + case 'z': + TIFFWarning( + TIFF2PDF_MODULE, + "Zip support in libtiff required for Zip compression, ignoring option"); + break; #endif - case 'q': - t2p->pdf_defaultcompressionquality = atoi(optarg); - break; - case 'n': - t2p->pdf_nopassthrough = 1; - break; - case 'd': - t2p->pdf_defaultcompression = T2P_COMPRESS_NONE; - break; - case 'u': - if (optarg[0] == 'm') - { - t2p->pdf_centimeters = 1; - } - break; - case 'x': - t2p->pdf_defaultxres = - (float)atof(optarg) / (t2p->pdf_centimeters ? 2.54F : 1.0F); - break; - case 'y': - t2p->pdf_defaultyres = - (float)atof(optarg) / (t2p->pdf_centimeters ? 2.54F : 1.0F); - break; - case 'w': - t2p->pdf_overridepagesize = 1; - t2p->pdf_defaultpagewidth = - ((float)atof(optarg) * PS_UNIT_SIZE) / - (t2p->pdf_centimeters ? 2.54F : 1.0F); - break; - case 'l': - t2p->pdf_overridepagesize = 1; - t2p->pdf_defaultpagelength = - ((float)atof(optarg) * PS_UNIT_SIZE) / - (t2p->pdf_centimeters ? 2.54F : 1.0F); - break; - case 'r': - if (optarg[0] == 'o') - { - t2p->pdf_overrideres = 1; - } - break; - case 'p': - if (tiff2pdf_match_paper_size(&(t2p->pdf_defaultpagewidth), - &(t2p->pdf_defaultpagelength), - optarg)) - { - t2p->pdf_overridepagesize = 1; - } - else - { - TIFFWarning(TIFF2PDF_MODULE, - "Unknown paper size %s, ignoring option", - optarg); - } - break; - case 'i': - t2p->pdf_colorspace_invert = 1; - break; - case 'F': - t2p->pdf_image_fillpage = 1; - break; - case 'f': - t2p->pdf_fitwindow = 1; - break; - case 'e': - if (strlen(optarg) == 0) - { - t2p->pdf_datetime[0] = '\0'; - } - else - { - t2p->pdf_datetime[0] = 'D'; - t2p->pdf_datetime[1] = ':'; - strncpy(t2p->pdf_datetime + 2, optarg, - sizeof(t2p->pdf_datetime) - 3); - t2p->pdf_datetime[sizeof(t2p->pdf_datetime) - 1] = '\0'; - } - break; - case 'c': - strncpy(t2p->pdf_creator, optarg, sizeof(t2p->pdf_creator) - 1); - t2p->pdf_creator[sizeof(t2p->pdf_creator) - 1] = '\0'; - t2p->pdf_creator_set = 1; - break; - case 'a': - strncpy(t2p->pdf_author, optarg, sizeof(t2p->pdf_author) - 1); - t2p->pdf_author[sizeof(t2p->pdf_author) - 1] = '\0'; - t2p->pdf_author_set = 1; - break; - case 't': - strncpy(t2p->pdf_title, optarg, sizeof(t2p->pdf_title) - 1); - t2p->pdf_title[sizeof(t2p->pdf_title) - 1] = '\0'; - t2p->pdf_title_set = 1; - break; - case 's': - strncpy(t2p->pdf_subject, optarg, sizeof(t2p->pdf_subject) - 1); - t2p->pdf_subject[sizeof(t2p->pdf_subject) - 1] = '\0'; - t2p->pdf_subject_set = 1; - break; - case 'k': - strncpy(t2p->pdf_keywords, optarg, - sizeof(t2p->pdf_keywords) - 1); - t2p->pdf_keywords[sizeof(t2p->pdf_keywords) - 1] = '\0'; - t2p->pdf_keywords_set = 1; - break; - case 'b': - t2p->pdf_image_interpolate = 1; - break; - case 'h': - usage_info(EXIT_SUCCESS); - goto success; - case '?': - usage_info(EXIT_FAILURE); - goto fail; - } - } + case 'q': + t2p->pdf_defaultcompressionquality=atoi(optarg); + break; + case 'n': + t2p->pdf_nopassthrough=1; + break; + case 'd': + t2p->pdf_defaultcompression=T2P_COMPRESS_NONE; + break; + case 'u': + if(optarg[0]=='m'){ + t2p->pdf_centimeters=1; + } + break; + case 'x': + t2p->pdf_defaultxres = + (float)atof(optarg) / (t2p->pdf_centimeters?2.54F:1.0F); + break; + case 'y': + t2p->pdf_defaultyres = + (float)atof(optarg) / (t2p->pdf_centimeters?2.54F:1.0F); + break; + case 'w': + t2p->pdf_overridepagesize=1; + t2p->pdf_defaultpagewidth = + ((float)atof(optarg) * PS_UNIT_SIZE) / (t2p->pdf_centimeters?2.54F:1.0F); + break; + case 'l': + t2p->pdf_overridepagesize=1; + t2p->pdf_defaultpagelength = + ((float)atof(optarg) * PS_UNIT_SIZE) / (t2p->pdf_centimeters?2.54F:1.0F); + break; + case 'r': + if(optarg[0]=='o'){ + t2p->pdf_overrideres=1; + } + break; + case 'p': + if(tiff2pdf_match_paper_size( + &(t2p->pdf_defaultpagewidth), + &(t2p->pdf_defaultpagelength), + optarg)){ + t2p->pdf_overridepagesize=1; + } else { + TIFFWarning(TIFF2PDF_MODULE, + "Unknown paper size %s, ignoring option", + optarg); + } + break; + case 'i': + t2p->pdf_colorspace_invert=1; + break; + case 'F': + t2p->pdf_image_fillpage = 1; + break; + case 'f': + t2p->pdf_fitwindow=1; + break; + case 'e': + if (strlen(optarg) == 0) { + t2p->pdf_datetime[0] = '\0'; + } else { + t2p->pdf_datetime[0] = 'D'; + t2p->pdf_datetime[1] = ':'; + strncpy(t2p->pdf_datetime + 2, optarg, + sizeof(t2p->pdf_datetime) - 3); + t2p->pdf_datetime[sizeof(t2p->pdf_datetime) - 1] = '\0'; + } + break; + case 'c': + strncpy(t2p->pdf_creator, optarg, sizeof(t2p->pdf_creator) - 1); + t2p->pdf_creator[sizeof(t2p->pdf_creator) - 1] = '\0'; + t2p->pdf_creator_set = 1; + break; + case 'a': + strncpy(t2p->pdf_author, optarg, sizeof(t2p->pdf_author) - 1); + t2p->pdf_author[sizeof(t2p->pdf_author) - 1] = '\0'; + t2p->pdf_author_set = 1; + break; + case 't': + strncpy(t2p->pdf_title, optarg, sizeof(t2p->pdf_title) - 1); + t2p->pdf_title[sizeof(t2p->pdf_title) - 1] = '\0'; + t2p->pdf_title_set = 1; + break; + case 's': + strncpy(t2p->pdf_subject, optarg, sizeof(t2p->pdf_subject) - 1); + t2p->pdf_subject[sizeof(t2p->pdf_subject) - 1] = '\0'; + t2p->pdf_subject_set = 1; + break; + case 'k': + strncpy(t2p->pdf_keywords, optarg, sizeof(t2p->pdf_keywords) - 1); + t2p->pdf_keywords[sizeof(t2p->pdf_keywords) - 1] = '\0'; + t2p->pdf_keywords_set = 1; + break; + case 'b': + t2p->pdf_image_interpolate = 1; + break; + case 'h': + tiff2pdf_usage(EXIT_SUCCESS); + goto success; + case '?': + tiff2pdf_usage(EXIT_FAILURE); + goto fail; + } + } - /* - * Input - */ - if (argc > optind) - { - input = TIFFOpen(argv[optind++], "r"); - if (input == NULL) - { - TIFFError(TIFF2PDF_MODULE, "Can't open input file %s for reading", - argv[optind - 1]); - goto fail; - } - } - else - { - TIFFError(TIFF2PDF_MODULE, "No input file specified"); - usage_info(EXIT_FAILURE); - goto fail; - } + /* + * Input + */ + if(argc > optind) { + input = TIFFOpen(argv[optind++], "r"); + if (input==NULL) { + TIFFError(TIFF2PDF_MODULE, + "Can't open input file %s for reading", + argv[optind-1]); + goto fail; + } + } else { + TIFFError(TIFF2PDF_MODULE, "No input file specified"); + tiff2pdf_usage(EXIT_FAILURE); + goto fail; + } - if (argc > optind) - { - TIFFError(TIFF2PDF_MODULE, "No support for multiple input files"); - usage_info(EXIT_FAILURE); - goto fail; - } + if(argc > optind) { + TIFFError(TIFF2PDF_MODULE, + "No support for multiple input files"); + tiff2pdf_usage(EXIT_FAILURE); + goto fail; + } - /* - * Output - */ - t2p->outputdisable = 1; - if (outfilename) - { - t2p->outputfile = fopen(outfilename, "wb"); - if (t2p->outputfile == NULL) - { - TIFFError(TIFF2PDF_MODULE, "Can't open output file %s for writing", - outfilename); - goto fail; - } - } - else - { - outfilename = "-"; - t2p->outputfile = stdout; - } + /* + * Output + */ + t2p->outputdisable = 1; + if (outfilename) { + t2p->outputfile = fopen(outfilename, "wb"); + if (t2p->outputfile == NULL) { + TIFFError(TIFF2PDF_MODULE, + "Can't open output file %s for writing", + outfilename); + goto fail; + } + } else { + outfilename = "-"; + t2p->outputfile = stdout; + } - output = TIFFClientOpen(outfilename, "w", (thandle_t)t2p, t2p_readproc, - t2p_writeproc, t2p_seekproc, t2p_closeproc, - t2p_sizeproc, t2p_mapproc, t2p_unmapproc); - t2p->outputdisable = 0; - if (output == NULL) - { - TIFFError(TIFF2PDF_MODULE, "Can't initialize output descriptor"); - goto fail; - } + output = TIFFClientOpen(outfilename, "w", (thandle_t) t2p, + t2p_readproc, t2p_writeproc, t2p_seekproc, + t2p_closeproc, t2p_sizeproc, + t2p_mapproc, t2p_unmapproc); + t2p->outputdisable = 0; + if (output == NULL) { + TIFFError(TIFF2PDF_MODULE, + "Can't initialize output descriptor"); + goto fail; + } + + /* + * Validate + */ + t2p_validate(t2p); + t2pSeekFile(output, (toff_t) 0, SEEK_SET); - /* - * Validate - */ - t2p_validate(t2p); - t2pSeekFile(output, (toff_t)0, SEEK_SET); + /* + * Write + */ + t2p_write_pdf(t2p, input, output); + if (t2p->t2p_error != 0) { + TIFFError(TIFF2PDF_MODULE, + "An error occurred creating output PDF file"); + goto fail; + } - /* - * Write - */ - t2p_write_pdf(t2p, input, output); - if (t2p->t2p_error != 0) - { - TIFFError(TIFF2PDF_MODULE, - "An error occurred creating output PDF file"); - goto fail; - } - - goto success; + goto success; fail: - ret = EXIT_FAILURE; + ret = EXIT_FAILURE; success: - if (input != NULL) - TIFFClose(input); - if (output != NULL) - TIFFClose(output); - if (t2p != NULL) - t2p_free(t2p); - return ret; + if(input != NULL) + TIFFClose(input); + if (output != NULL) + TIFFClose(output); + if (t2p != NULL) + t2p_free(t2p); + return ret; + } -static void usage_info(int code) -{ - static const char lines[] = - "Convert a TIFF image to a PDF document\n\n" - "usage: tiff2pdf [options] input.tiff\n" - "where options are:\n" - " -o: output to file name\n" +static void tiff2pdf_usage(int code) { + static const char* lines[]={ + "usage: tiff2pdf [options] input.tiff", + "options:", + " -o: output to file name", #ifdef JPEG_SUPPORT - " -j: compress with JPEG\n" + " -j: compress with JPEG", #endif #ifdef ZIP_SUPPORT - " -z: compress with Zip/Deflate\n" + " -z: compress with Zip/Deflate", #endif -#if defined(JPEG_SUPPORT) || defined(ZIP_SUPPORT) - " -q: compression quality\n" - " -n: no compressed data passthrough\n" - " -d: do not compress (decompress)\n" -#endif - " -i: invert colors\n" - " -u: set distance unit, 'i' for inch, 'm' for centimeter\n" - " -x: set x resolution default in dots per unit\n" - " -y: set y resolution default in dots per unit\n" - " -w: width in units\n" - " -l: length in units\n" - " -r: 'd' for resolution default, 'o' for resolution override\n" - " -p: paper size, eg \"letter\", \"legal\", \"A4\"\n" - " -F: make the tiff fill the PDF page\n" - " -f: set PDF \"Fit Window\" user preference\n" - " -e: date, overrides image or current date/time default, " - "YYYYMMDDHHMMSS\n" - " -c: sets document creator, overrides image software default\n" - " -a: sets document author, overrides image artist default\n" - " -t: sets document title, overrides image document name default\n" - " -s: sets document subject, overrides image image description " - "default\n" - " -k: sets document keywords\n" - " -b: set PDF \"Interpolate\" user preference\n" - " -m: set memory allocation limit (in MiB). set to 0 to disable limit\n" - " -h: usage\n"; - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + " -q: compression quality", + " -n: no compressed data passthrough", + " -d: do not compress (decompress)", + " -i: invert colors", + " -u: set distance unit, 'i' for inch, 'm' for centimeter", + " -x: set x resolution default in dots per unit", + " -y: set y resolution default in dots per unit", + " -w: width in units", + " -l: length in units", + " -r: 'd' for resolution default, 'o' for resolution override", + " -p: paper size, eg \"letter\", \"legal\", \"A4\"", + " -F: make the tiff fill the PDF page", + " -f: set PDF \"Fit Window\" user preference", + " -e: date, overrides image or current date/time default, YYYYMMDDHHMMSS", + " -c: sets document creator, overrides image software default", + " -a: sets document author, overrides image artist default", + " -t: sets document title, overrides image document name default", + " -s: sets document subject, overrides image image description default", + " -k: sets document keywords", + " -b: set PDF \"Interpolate\" user preference", + " -m: set memory allocation limit (in MiB). set to 0 to disable limit", + " -h: usage", + NULL + }; + int i=0; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", lines); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i=0;lines[i]!=NULL;i++){ + fprintf(out, "%s\n", lines[i]); + } - return; + return; } -int tiff2pdf_match_paper_size(float *width, float *length, char *papersize) -{ +int tiff2pdf_match_paper_size(float* width, float* length, char* papersize){ - size_t i, len; - const char *sizes[] = { - "LETTER", "A4", "LEGAL", "EXECUTIVE", "LETTER", "LEGAL", - "LEDGER", "TABLOID", "A", "B", "C", "D", - "E", "F", "G", "H", "J", "K", - "A10", "A9", "A8", "A7", "A6", "A5", - "A4", "A3", "A2", "A1", "A0", "2A0", - "4A0", "2A", "4A", "B10", "B9", "B8", - "B7", "B6", "B5", "B4", "B3", "B2", - "B1", "B0", "JISB10", "JISB9", "JISB8", "JISB7", - "JISB6", "JISB5", "JISB4", "JISB3", "JISB2", "JISB1", - "JISB0", "C10", "C9", "C8", "C7", "C6", - "C5", "C4", "C3", "C2", "C1", "C0", - "RA2", "RA1", "RA0", "SRA4", "SRA3", "SRA2", - "SRA1", "SRA0", "A3EXTRA", "A4EXTRA", "STATEMENT", "FOLIO", - "QUARTO", NULL}; - const int widths[] = { - 612, 595, 612, 522, 612, 612, 792, 792, 612, 792, 1224, 1584, - 2448, 2016, 792, 2016, 2448, 2880, 74, 105, 147, 210, 298, 420, - 595, 842, 1191, 1684, 2384, 3370, 4768, 3370, 4768, 88, 125, 176, - 249, 354, 499, 709, 1001, 1417, 2004, 2835, 91, 128, 181, 258, - 363, 516, 729, 1032, 1460, 2064, 2920, 79, 113, 162, 230, 323, - 459, 649, 918, 1298, 1298, 2599, 1219, 1729, 2438, 638, 907, 1276, - 1814, 2551, 914, 667, 396, 612, 609, 0}; - const int lengths[] = { - 792, 842, 1008, 756, 792, 1008, 1224, 1224, 792, 1224, - 1584, 2448, 3168, 2880, 6480, 10296, 12672, 10296, 105, 147, - 210, 298, 420, 595, 842, 1191, 1684, 2384, 3370, 4768, - 6741, 4768, 6741, 125, 176, 249, 354, 499, 709, 1001, - 1417, 2004, 2835, 4008, 128, 181, 258, 363, 516, 729, - 1032, 1460, 2064, 2920, 4127, 113, 162, 230, 323, 459, - 649, 918, 1298, 1837, 1837, 3677, 1729, 2438, 3458, 907, - 1276, 1814, 2551, 3628, 1262, 914, 612, 936, 780, 0}; + size_t i, len; + const char* sizes[]={ + "LETTER", "A4", "LEGAL", + "EXECUTIVE", "LETTER", "LEGAL", "LEDGER", "TABLOID", + "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", + "A10", "A9", "A8", "A7", "A6", "A5", "A4", "A3", "A2", "A1", "A0", + "2A0", "4A0", "2A", "4A", + "B10", "B9", "B8", "B7", "B6", "B5", "B4", "B3", "B2", "B1", "B0", + "JISB10", "JISB9", "JISB8", "JISB7", "JISB6", "JISB5", "JISB4", + "JISB3", "JISB2", "JISB1", "JISB0", + "C10", "C9", "C8", "C7", "C6", "C5", "C4", "C3", "C2", "C1", "C0", + "RA2", "RA1", "RA0", "SRA4", "SRA3", "SRA2", "SRA1", "SRA0", + "A3EXTRA", "A4EXTRA", + "STATEMENT", "FOLIO", "QUARTO", + NULL + } ; + const int widths[]={ + 612, 595, 612, + 522, 612,612,792,792, + 612,792,1224,1584,2448,2016,792,2016,2448,2880, + 74,105,147,210,298,420,595,842,1191,1684,2384,3370,4768,3370,4768, + 88,125,176,249,354,499,709,1001,1417,2004,2835, + 91,128,181,258,363,516,729,1032,1460,2064,2920, + 79,113,162,230,323,459,649,918,1298,1298,2599, + 1219,1729,2438,638,907,1276,1814,2551, + 914,667, + 396, 612, 609, + 0 + }; + const int lengths[]={ + 792,842,1008, + 756,792,1008,1224,1224, + 792,1224,1584,2448,3168,2880,6480,10296,12672,10296, + 105,147,210,298,420,595,842,1191,1684,2384,3370,4768,6741,4768,6741, + 125,176,249,354,499,709,1001,1417,2004,2835,4008, + 128,181,258,363,516,729,1032,1460,2064,2920,4127, + 113,162,230,323,459,649,918,1298,1837,1837,3677, + 1729,2438,3458,907,1276,1814,2551,3628, + 1262,914, + 612, 936, 780, + 0 + }; - len = strlen(papersize); - for (i = 0; i < len; i++) - { - papersize[i] = toupper((int)papersize[i]); - } - for (i = 0; sizes[i] != NULL; i++) - { - if (strcmp((const char *)papersize, sizes[i]) == 0) - { - *width = (float)widths[i]; - *length = (float)lengths[i]; - return (1); - } - } + len=strlen(papersize); + for(i=0;ipdf_majorversion = 1; - t2p->pdf_minorversion = 1; - t2p->pdf_defaultxres = 300.0; - t2p->pdf_defaultyres = 300.0; - t2p->pdf_defaultpagewidth = 612.0; - t2p->pdf_defaultpagelength = 792.0; - t2p->pdf_xrefcount = 3; /* Catalog, Info, Pages */ - t2p->tiff_maxdatasize = DEFAULT_MAX_MALLOC; - - return (t2p); + T2P* t2p = (T2P*) _TIFFmalloc(sizeof(T2P)); + if(t2p==NULL){ + TIFFError( + TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_init", + (unsigned long) sizeof(T2P)); + return( (T2P*) NULL ); + } + _TIFFmemset(t2p, 0x00, sizeof(T2P)); + t2p->pdf_majorversion=1; + t2p->pdf_minorversion=1; + t2p->pdf_defaultxres=300.0; + t2p->pdf_defaultyres=300.0; + t2p->pdf_defaultpagewidth=612.0; + t2p->pdf_defaultpagelength=792.0; + t2p->pdf_xrefcount=3; /* Catalog, Info, Pages */ + t2p->tiff_maxdatasize = DEFAULT_MAX_MALLOC; + + return(t2p); } /* - * This function frees a T2P context struct pointer and any allocated data - * fields of it. + * This function frees a T2P context struct pointer and any allocated data fields of it. */ -void t2p_free(T2P *t2p) +void t2p_free(T2P* t2p) { - int i = 0; + int i = 0; - if (t2p != NULL) - { - if (t2p->pdf_xrefoffsets != NULL) - { - _TIFFfree((tdata_t)t2p->pdf_xrefoffsets); - } - if (t2p->tiff_pages != NULL) - { - _TIFFfree((tdata_t)t2p->tiff_pages); - } - for (i = 0; i < t2p->tiff_pagecount; i++) - { - if (t2p->tiff_tiles[i].tiles_tiles != NULL) - { - _TIFFfree((tdata_t)t2p->tiff_tiles[i].tiles_tiles); - } - } - if (t2p->tiff_tiles != NULL) - { - _TIFFfree((tdata_t)t2p->tiff_tiles); - } - if (t2p->pdf_palette != NULL) - { - _TIFFfree((tdata_t)t2p->pdf_palette); - } + if (t2p != NULL) { + if(t2p->pdf_xrefoffsets != NULL){ + _TIFFfree( (tdata_t) t2p->pdf_xrefoffsets); + } + if(t2p->tiff_pages != NULL){ + _TIFFfree( (tdata_t) t2p->tiff_pages); + } + for(i=0;itiff_pagecount;i++){ + if(t2p->tiff_tiles[i].tiles_tiles != NULL){ + _TIFFfree( (tdata_t) t2p->tiff_tiles[i].tiles_tiles); + } + } + if(t2p->tiff_tiles != NULL){ + _TIFFfree( (tdata_t) t2p->tiff_tiles); + } + if(t2p->pdf_palette != NULL){ + _TIFFfree( (tdata_t) t2p->pdf_palette); + } #ifdef OJPEG_SUPPORT - if (t2p->pdf_ojpegdata != NULL) - { - _TIFFfree((tdata_t)t2p->pdf_ojpegdata); - } + if(t2p->pdf_ojpegdata != NULL){ + _TIFFfree( (tdata_t) t2p->pdf_ojpegdata); + } #endif - _TIFFfree((tdata_t)t2p); - } + _TIFFfree( (tdata_t) t2p ); + } - return; + return; } /* - This function validates the values of a T2P context struct pointer + This function validates the values of a T2P context struct pointer before calling t2p_write_pdf with it. */ -void t2p_validate(T2P *t2p) -{ - (void)t2p; +void t2p_validate(T2P* t2p){ + (void)t2p; #ifdef JPEG_SUPPORT - if (t2p->pdf_defaultcompression == T2P_COMPRESS_JPEG) - { - if (t2p->pdf_defaultcompressionquality > 100 || - t2p->pdf_defaultcompressionquality < 1) - { - t2p->pdf_defaultcompressionquality = 0; - } - } + if(t2p->pdf_defaultcompression==T2P_COMPRESS_JPEG){ + if(t2p->pdf_defaultcompressionquality>100 || + t2p->pdf_defaultcompressionquality<1){ + t2p->pdf_defaultcompressionquality=0; + } + } #endif #ifdef ZIP_SUPPORT - if (t2p->pdf_defaultcompression == T2P_COMPRESS_ZIP) - { - uint16_t m = t2p->pdf_defaultcompressionquality % 100; - if (t2p->pdf_defaultcompressionquality / 100 > 9 || (m > 1 && m < 10) || - m > 15) - { - t2p->pdf_defaultcompressionquality = 0; - } - if (t2p->pdf_defaultcompressionquality % 100 != 0) - { - t2p->pdf_defaultcompressionquality /= 100; - t2p->pdf_defaultcompressionquality *= 100; - TIFFError(TIFF2PDF_MODULE, - "PNG Group predictor differencing not implemented, " - "assuming compression quality %" PRIu16, - t2p->pdf_defaultcompressionquality); - } - t2p->pdf_defaultcompressionquality %= 100; - if (t2p->pdf_minorversion < 2) - { - t2p->pdf_minorversion = 2; - } - } + if(t2p->pdf_defaultcompression==T2P_COMPRESS_ZIP){ + uint16 m=t2p->pdf_defaultcompressionquality%100; + if(t2p->pdf_defaultcompressionquality/100 > 9 || + (m>1 && m<10) || m>15){ + t2p->pdf_defaultcompressionquality=0; + } + if(t2p->pdf_defaultcompressionquality%100 !=0){ + t2p->pdf_defaultcompressionquality/=100; + t2p->pdf_defaultcompressionquality*=100; + TIFFError( + TIFF2PDF_MODULE, + "PNG Group predictor differencing not implemented, assuming compression quality %u", + t2p->pdf_defaultcompressionquality); + } + t2p->pdf_defaultcompressionquality%=100; + if(t2p->pdf_minorversion<2){t2p->pdf_minorversion=2;} + } #endif - return; + return; } + /* - This function scans the input TIFF file for pages. It attempts + This function scans the input TIFF file for pages. It attempts to determine which IFD's of the TIFF file contain image document pages. For each, it gathers some information that has to do - with the output of the PDF document as a whole. + with the output of the PDF document as a whole. */ -void t2p_read_tiff_init(T2P *t2p, TIFF *input) -{ +void t2p_read_tiff_init(T2P* t2p, TIFF* input){ - tdir_t directorycount = 0; - tdir_t i = 0; - uint16_t pagen = 0; - uint16_t paged = 0; - uint16_t xuint16 = 0; - uint16_t tiff_transferfunctioncount = 0; - uint16_t *tiff_transferfunction[3]; + tdir_t directorycount=0; + tdir_t i=0; + uint16 pagen=0; + uint16 paged=0; + uint16 xuint16=0; + uint16 tiff_transferfunctioncount=0; + uint16* tiff_transferfunction[3]; - directorycount = TIFFNumberOfDirectories(input); - if (directorycount > TIFF_DIR_MAX) - { - TIFFError(TIFF2PDF_MODULE, "TIFF contains too many directories, %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->tiff_pages = (T2P_PAGE *)_TIFFmalloc( - TIFFSafeMultiply(tmsize_t, directorycount, sizeof(T2P_PAGE))); - if (t2p->tiff_pages == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SIZE_FORMAT - " bytes of memory for tiff_pages array, %s", - sizeof(T2P_PAGE) * directorycount, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - _TIFFmemset(t2p->tiff_pages, 0x00, directorycount * sizeof(T2P_PAGE)); - t2p->tiff_tiles = (T2P_TILES *)_TIFFmalloc( - TIFFSafeMultiply(tmsize_t, directorycount, sizeof(T2P_TILES))); - if (t2p->tiff_tiles == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SIZE_FORMAT - " bytes of memory for tiff_tiles array, %s", - sizeof(T2P_TILES) * directorycount, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - _TIFFmemset(t2p->tiff_tiles, 0x00, directorycount * sizeof(T2P_TILES)); - for (i = 0; i < directorycount; i++) - { - uint32_t subfiletype = 0; + directorycount=TIFFNumberOfDirectories(input); + if(directorycount > TIFF_DIR_MAX) { + TIFFError( + TIFF2PDF_MODULE, + "TIFF contains too many directories, %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p->tiff_pages = (T2P_PAGE*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t,directorycount,sizeof(T2P_PAGE))); + if(t2p->tiff_pages==NULL){ + TIFFError( + TIFF2PDF_MODULE, + "Can't allocate " TIFF_SIZE_FORMAT " bytes of memory for tiff_pages array, %s", + (TIFF_SIZE_T) directorycount * sizeof(T2P_PAGE), + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + _TIFFmemset( t2p->tiff_pages, 0x00, directorycount * sizeof(T2P_PAGE)); + t2p->tiff_tiles = (T2P_TILES*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t,directorycount,sizeof(T2P_TILES))); + if(t2p->tiff_tiles==NULL){ + TIFFError( + TIFF2PDF_MODULE, + "Can't allocate " TIFF_SIZE_FORMAT " bytes of memory for tiff_tiles array, %s", + (TIFF_SIZE_T) directorycount * sizeof(T2P_TILES), + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + _TIFFmemset( t2p->tiff_tiles, 0x00, directorycount * sizeof(T2P_TILES)); + for(i=0;it2p_error = T2P_ERR_ERROR; + return; + } + if(TIFFGetField(input, TIFFTAG_PAGENUMBER, &pagen, &paged)){ + if((pagen>paged) && (paged != 0)){ + t2p->tiff_pages[t2p->tiff_pagecount].page_number = + paged; + } else { + t2p->tiff_pages[t2p->tiff_pagecount].page_number = + pagen; + } + goto ispage2; + } + if(TIFFGetField(input, TIFFTAG_SUBFILETYPE, &subfiletype)){ + if ( ((subfiletype & FILETYPE_PAGE) != 0) + || (subfiletype == 0)){ + goto ispage; + } else { + goto isnotpage; + } + } + if(TIFFGetField(input, TIFFTAG_OSUBFILETYPE, &subfiletype)){ + if ((subfiletype == OFILETYPE_IMAGE) + || (subfiletype == OFILETYPE_PAGE) + || (subfiletype == 0) ){ + goto ispage; + } else { + goto isnotpage; + } + } + ispage: + t2p->tiff_pages[t2p->tiff_pagecount].page_number=t2p->tiff_pagecount; + ispage2: + t2p->tiff_pages[t2p->tiff_pagecount].page_directory=i; + if(TIFFIsTiled(input)){ + t2p->tiff_pages[t2p->tiff_pagecount].page_tilecount = + TIFFNumberOfTiles(input); + } + t2p->tiff_pagecount++; + isnotpage: + (void)0; + } + + qsort((void*) t2p->tiff_pages, t2p->tiff_pagecount, + sizeof(T2P_PAGE), t2p_cmp_t2p_page); - if (!TIFFSetDirectory(input, i)) - { - TIFFError(TIFF2PDF_MODULE, - "Can't set directory %" PRIu16 " of input file %s", i, - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if (TIFFGetField(input, TIFFTAG_PAGENUMBER, &pagen, &paged)) - { - if ((pagen > paged) && (paged != 0)) - { - t2p->tiff_pages[t2p->tiff_pagecount].page_number = paged; - } - else - { - t2p->tiff_pages[t2p->tiff_pagecount].page_number = pagen; - } - goto ispage2; - } - if (TIFFGetField(input, TIFFTAG_SUBFILETYPE, &subfiletype)) - { - if (((subfiletype & FILETYPE_PAGE) != 0) || (subfiletype == 0)) - { - goto ispage; - } - else - { - goto isnotpage; - } - } - if (TIFFGetField(input, TIFFTAG_OSUBFILETYPE, &subfiletype)) - { - if ((subfiletype == OFILETYPE_IMAGE) || - (subfiletype == OFILETYPE_PAGE) || (subfiletype == 0)) - { - goto ispage; - } - else - { - goto isnotpage; - } - } - ispage: - t2p->tiff_pages[t2p->tiff_pagecount].page_number = t2p->tiff_pagecount; - ispage2: - t2p->tiff_pages[t2p->tiff_pagecount].page_directory = i; - if (TIFFIsTiled(input)) - { - t2p->tiff_pages[t2p->tiff_pagecount].page_tilecount = - TIFFNumberOfTiles(input); - } - t2p->tiff_pagecount++; - isnotpage: - (void)0; - } - - qsort((void *)t2p->tiff_pages, t2p->tiff_pagecount, sizeof(T2P_PAGE), - t2p_cmp_t2p_page); - - for (i = 0; i < t2p->tiff_pagecount; i++) - { - t2p->pdf_xrefcount += 5; - TIFFSetDirectory(input, t2p->tiff_pages[i].page_directory); - if ((TIFFGetField(input, TIFFTAG_PHOTOMETRIC, &xuint16) && - (xuint16 == PHOTOMETRIC_PALETTE)) || - TIFFGetField(input, TIFFTAG_INDEXED, &xuint16)) - { - t2p->tiff_pages[i].page_extra++; - t2p->pdf_xrefcount++; - } + for(i=0;itiff_pagecount;i++){ + t2p->pdf_xrefcount += 5; + TIFFSetDirectory(input, t2p->tiff_pages[i].page_directory ); + if((TIFFGetField(input, TIFFTAG_PHOTOMETRIC, &xuint16) + && (xuint16==PHOTOMETRIC_PALETTE)) + || TIFFGetField(input, TIFFTAG_INDEXED, &xuint16)) { + t2p->tiff_pages[i].page_extra++; + t2p->pdf_xrefcount++; + } #ifdef ZIP_SUPPORT - if (TIFFGetField(input, TIFFTAG_COMPRESSION, &xuint16)) - { - if ((xuint16 == COMPRESSION_DEFLATE || - xuint16 == COMPRESSION_ADOBE_DEFLATE) && - ((t2p->tiff_pages[i].page_tilecount != 0) || - TIFFNumberOfStrips(input) == 1) && - (t2p->pdf_nopassthrough == 0)) - { - if (t2p->pdf_minorversion < 2) - { - t2p->pdf_minorversion = 2; + if (TIFFGetField(input, TIFFTAG_COMPRESSION, &xuint16)) { + if( (xuint16== COMPRESSION_DEFLATE || + xuint16== COMPRESSION_ADOBE_DEFLATE) && + ((t2p->tiff_pages[i].page_tilecount != 0) + || TIFFNumberOfStrips(input)==1) && + (t2p->pdf_nopassthrough==0) ){ + if(t2p->pdf_minorversion<2){t2p->pdf_minorversion=2;} + } } - } - } #endif - if (TIFFGetField( - input, TIFFTAG_TRANSFERFUNCTION, &(tiff_transferfunction[0]), - &(tiff_transferfunction[1]), &(tiff_transferfunction[2]))) - { + if (TIFFGetField(input, TIFFTAG_TRANSFERFUNCTION, + &(tiff_transferfunction[0]), + &(tiff_transferfunction[1]), + &(tiff_transferfunction[2]))) { - if ((tiff_transferfunction[1] != (uint16_t *)NULL) && - (tiff_transferfunction[2] != (uint16_t *)NULL)) - { - tiff_transferfunctioncount = 3; - } - else - { - tiff_transferfunctioncount = 1; - } - } - else - { - tiff_transferfunctioncount = 0; - } + if((tiff_transferfunction[1] != (uint16*) NULL) && + (tiff_transferfunction[2] != (uint16*) NULL) + ) { + tiff_transferfunctioncount=3; + } else { + tiff_transferfunctioncount=1; + } + } else { + tiff_transferfunctioncount=0; + } - if (i > 0) - { - if (tiff_transferfunctioncount != t2p->tiff_transferfunctioncount) - { - TIFFError(TIFF2PDF_MODULE, - "Different transfer function on page %" PRIu16, i); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - } + if (i > 0){ + if (tiff_transferfunctioncount != t2p->tiff_transferfunctioncount){ + TIFFError( + TIFF2PDF_MODULE, + "Different transfer function on page %d", + i); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + } - t2p->tiff_transferfunctioncount = tiff_transferfunctioncount; - t2p->tiff_transferfunction[0] = tiff_transferfunction[0]; - t2p->tiff_transferfunction[1] = tiff_transferfunction[1]; - t2p->tiff_transferfunction[2] = tiff_transferfunction[2]; - if (tiff_transferfunctioncount == 3) - { - t2p->tiff_pages[i].page_extra += 4; - t2p->pdf_xrefcount += 4; - if (t2p->pdf_minorversion < 2) - t2p->pdf_minorversion = 2; - } - else if (tiff_transferfunctioncount == 1) - { - t2p->tiff_pages[i].page_extra += 2; - t2p->pdf_xrefcount += 2; - if (t2p->pdf_minorversion < 2) - t2p->pdf_minorversion = 2; - } + t2p->tiff_transferfunctioncount = tiff_transferfunctioncount; + t2p->tiff_transferfunction[0] = tiff_transferfunction[0]; + t2p->tiff_transferfunction[1] = tiff_transferfunction[1]; + t2p->tiff_transferfunction[2] = tiff_transferfunction[2]; + if(tiff_transferfunctioncount == 3){ + t2p->tiff_pages[i].page_extra += 4; + t2p->pdf_xrefcount += 4; + if(t2p->pdf_minorversion < 2) + t2p->pdf_minorversion = 2; + } else if (tiff_transferfunctioncount == 1){ + t2p->tiff_pages[i].page_extra += 2; + t2p->pdf_xrefcount += 2; + if(t2p->pdf_minorversion < 2) + t2p->pdf_minorversion = 2; + } - if (TIFFGetField(input, TIFFTAG_ICCPROFILE, - &(t2p->tiff_iccprofilelength), - &(t2p->tiff_iccprofile)) != 0) - { - t2p->tiff_pages[i].page_extra++; - t2p->pdf_xrefcount++; - if (t2p->pdf_minorversion < 3) - { - t2p->pdf_minorversion = 3; - } - } - t2p->tiff_tiles[i].tiles_tilecount = t2p->tiff_pages[i].page_tilecount; - if ((TIFFGetField(input, TIFFTAG_PLANARCONFIG, &xuint16) != 0) && - (xuint16 == PLANARCONFIG_SEPARATE)) - { - if (!TIFFGetField(input, TIFFTAG_SAMPLESPERPIXEL, &xuint16)) - { - TIFFError(TIFF2PDF_MODULE, "Missing SamplesPerPixel, %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if ((t2p->tiff_tiles[i].tiles_tilecount % xuint16) != 0) - { - TIFFError(TIFF2PDF_MODULE, "Invalid tile count, %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->tiff_tiles[i].tiles_tilecount /= xuint16; - } - if (t2p->tiff_tiles[i].tiles_tilecount > 0) - { - t2p->pdf_xrefcount += (t2p->tiff_tiles[i].tiles_tilecount - 1) * 2; - TIFFGetField(input, TIFFTAG_TILEWIDTH, - &(t2p->tiff_tiles[i].tiles_tilewidth)); - TIFFGetField(input, TIFFTAG_TILELENGTH, - &(t2p->tiff_tiles[i].tiles_tilelength)); - t2p->tiff_tiles[i].tiles_tiles = (T2P_TILE *)_TIFFmalloc( - TIFFSafeMultiply(tmsize_t, t2p->tiff_tiles[i].tiles_tilecount, - sizeof(T2P_TILE))); - if (t2p->tiff_tiles[i].tiles_tiles == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SIZE_FORMAT - " bytes of memory for t2p_read_tiff_init, %s", - sizeof(T2P_TILE) * t2p->tiff_tiles[i].tiles_tilecount, - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - } - } + if( TIFFGetField( + input, + TIFFTAG_ICCPROFILE, + &(t2p->tiff_iccprofilelength), + &(t2p->tiff_iccprofile)) != 0){ + t2p->tiff_pages[i].page_extra++; + t2p->pdf_xrefcount++; + if(t2p->pdf_minorversion<3){t2p->pdf_minorversion=3;} + } + t2p->tiff_tiles[i].tiles_tilecount= + t2p->tiff_pages[i].page_tilecount; + if( (TIFFGetField(input, TIFFTAG_PLANARCONFIG, &xuint16) != 0) + && (xuint16 == PLANARCONFIG_SEPARATE ) ){ + if( !TIFFGetField(input, TIFFTAG_SAMPLESPERPIXEL, &xuint16) ) + { + TIFFError( + TIFF2PDF_MODULE, + "Missing SamplesPerPixel, %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + if( (t2p->tiff_tiles[i].tiles_tilecount % xuint16) != 0 ) + { + TIFFError( + TIFF2PDF_MODULE, + "Invalid tile count, %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p->tiff_tiles[i].tiles_tilecount/= xuint16; + } + if( t2p->tiff_tiles[i].tiles_tilecount > 0){ + t2p->pdf_xrefcount += + (t2p->tiff_tiles[i].tiles_tilecount -1)*2; + TIFFGetField(input, + TIFFTAG_TILEWIDTH, + &( t2p->tiff_tiles[i].tiles_tilewidth) ); + TIFFGetField(input, + TIFFTAG_TILELENGTH, + &( t2p->tiff_tiles[i].tiles_tilelength) ); + t2p->tiff_tiles[i].tiles_tiles = + (T2P_TILE*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t,t2p->tiff_tiles[i].tiles_tilecount, + sizeof(T2P_TILE)) ); + if( t2p->tiff_tiles[i].tiles_tiles == NULL){ + TIFFError( + TIFF2PDF_MODULE, + "Can't allocate " TIFF_SIZE_FORMAT " bytes of memory for t2p_read_tiff_init, %s", + (TIFF_SIZE_T) t2p->tiff_tiles[i].tiles_tilecount * sizeof(T2P_TILE), + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + } + } - return; + return; } /* @@ -1364,1023 +1287,904 @@ void t2p_read_tiff_init(T2P *t2p, TIFF *input) * directory numbers to preserve the order of the input file. */ -int t2p_cmp_t2p_page(const void *e1, const void *e2) -{ +int t2p_cmp_t2p_page(const void* e1, const void* e2){ - int d; - d = (int32_t)(((T2P_PAGE *)e1)->page_number) - - (int32_t)(((T2P_PAGE *)e2)->page_number); - if (d == 0) - { - d = (int32_t)(((T2P_PAGE *)e1)->page_directory) - - (int32_t)(((T2P_PAGE *)e2)->page_directory); - } - return d; + int d; + d = (int32)(((T2P_PAGE*)e1)->page_number) - (int32)(((T2P_PAGE*)e2)->page_number); + if(d == 0){ + d = (int32)(((T2P_PAGE*)e1)->page_directory) - (int32)(((T2P_PAGE*)e2)->page_directory); + } + return d; } /* - This function sets the input directory to the directory of a given - page and determines information about the image. It checks - the image characteristics to determine if it is possible to convert - the image data into a page of PDF output, setting values of the T2P - struct for this page. It determines what color space is used in - the output PDF to represent the image. - - It determines if the image can be converted as raw data without - requiring transcoding of the image data. + This function sets the input directory to the directory of a given + page and determines information about the image. It checks + the image characteristics to determine if it is possible to convert + the image data into a page of PDF output, setting values of the T2P + struct for this page. It determines what color space is used in + the output PDF to represent the image. + + It determines if the image can be converted as raw data without + requiring transcoding of the image data. */ -void t2p_read_tiff_data(T2P *t2p, TIFF *input) -{ +void t2p_read_tiff_data(T2P* t2p, TIFF* input){ - int i = 0; - uint16_t *r = NULL; - uint16_t *g = NULL; - uint16_t *b = NULL; - uint16_t *a = NULL; - uint16_t xuint16; - uint16_t *xuint16p; - float *xfloatp; - int palette_16bit = 0; - int palette_shift = 8; + int i=0; + uint16* r = NULL; + uint16* g = NULL; + uint16* b = NULL; + uint16* a = NULL; + uint16 xuint16; + uint16* xuint16p; + float* xfloatp; - t2p->pdf_transcode = T2P_TRANSCODE_ENCODE; - t2p->pdf_sample = T2P_SAMPLE_NOTHING; - t2p->pdf_switchdecode = t2p->pdf_colorspace_invert; + t2p->pdf_transcode = T2P_TRANSCODE_ENCODE; + t2p->pdf_sample = T2P_SAMPLE_NOTHING; + t2p->pdf_switchdecode = t2p->pdf_colorspace_invert; + + + TIFFSetDirectory(input, t2p->tiff_pages[t2p->pdf_page].page_directory); - TIFFSetDirectory(input, t2p->tiff_pages[t2p->pdf_page].page_directory); + TIFFGetField(input, TIFFTAG_IMAGEWIDTH, &(t2p->tiff_width)); + if(t2p->tiff_width == 0){ + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with zero width", + TIFFFileName(input) ); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } - TIFFGetField(input, TIFFTAG_IMAGEWIDTH, &(t2p->tiff_width)); - if (t2p->tiff_width == 0) - { - TIFFError(TIFF2PDF_MODULE, "No support for %s with zero width", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } + TIFFGetField(input, TIFFTAG_IMAGELENGTH, &(t2p->tiff_length)); + if(t2p->tiff_length == 0){ + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with zero length", + TIFFFileName(input) ); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } - TIFFGetField(input, TIFFTAG_IMAGELENGTH, &(t2p->tiff_length)); - if (t2p->tiff_length == 0) - { - TIFFError(TIFF2PDF_MODULE, "No support for %s with zero length", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - - if (TIFFGetField(input, TIFFTAG_COMPRESSION, &(t2p->tiff_compression)) == 0) - { - TIFFError(TIFF2PDF_MODULE, "No support for %s with no compression tag", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if (TIFFIsCODECConfigured(t2p->tiff_compression) == 0) - { - TIFFError(TIFF2PDF_MODULE, - "No support for %s with compression type %" PRIu16 - ": not configured", - TIFFFileName(input), t2p->tiff_compression); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - - TIFFGetFieldDefaulted(input, TIFFTAG_BITSPERSAMPLE, - &(t2p->tiff_bitspersample)); - switch (t2p->tiff_bitspersample) - { - case 1: - case 2: - case 4: - case 8: - break; - case 0: - TIFFWarning(TIFF2PDF_MODULE, - "Image %s has 0 bits per sample, assuming 1", - TIFFFileName(input)); - t2p->tiff_bitspersample = 1; - break; - default: - TIFFError(TIFF2PDF_MODULE, - "No support for %s with %" PRIu16 " bits per sample", - TIFFFileName(input), t2p->tiff_bitspersample); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - - TIFFGetFieldDefaulted(input, TIFFTAG_SAMPLESPERPIXEL, - &(t2p->tiff_samplesperpixel)); - if (t2p->tiff_samplesperpixel > 4) - { - TIFFError(TIFF2PDF_MODULE, - "No support for %s with %" PRIu16 " samples per pixel", - TIFFFileName(input), t2p->tiff_samplesperpixel); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if (t2p->tiff_samplesperpixel == 0) - { - TIFFWarning(TIFF2PDF_MODULE, - "Image %s has 0 samples per pixel, assuming 1", - TIFFFileName(input)); - t2p->tiff_samplesperpixel = 1; - } - - if (TIFFGetField(input, TIFFTAG_SAMPLEFORMAT, &xuint16) != 0) - { - switch (xuint16) - { - case 0: - case 1: - case 4: - break; - default: - TIFFError(TIFF2PDF_MODULE, - "No support for %s with sample format %" PRIu16, - TIFFFileName(input), xuint16); - t2p->t2p_error = T2P_ERR_ERROR; - return; - break; - } - } - - TIFFGetFieldDefaulted(input, TIFFTAG_FILLORDER, &(t2p->tiff_fillorder)); - - if (TIFFGetField(input, TIFFTAG_PHOTOMETRIC, &(t2p->tiff_photometric)) == 0) - { - TIFFError(TIFF2PDF_MODULE, - "No support for %s with no photometric interpretation tag", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - - switch (t2p->tiff_photometric) - { - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - if (t2p->tiff_bitspersample == 1) - { - t2p->pdf_colorspace = T2P_CS_BILEVEL; - if (t2p->tiff_photometric == PHOTOMETRIC_MINISWHITE) - { - t2p->pdf_switchdecode ^= 1; - } - } - else - { - t2p->pdf_colorspace = T2P_CS_GRAY; - if (t2p->tiff_photometric == PHOTOMETRIC_MINISWHITE) - { - t2p->pdf_switchdecode ^= 1; - } - } - break; - case PHOTOMETRIC_RGB: - t2p->pdf_colorspace = T2P_CS_RGB; - if (t2p->tiff_samplesperpixel == 3) - { - break; - } - if (TIFFGetField(input, TIFFTAG_INDEXED, &xuint16)) - { - if (xuint16 == 1) - goto photometric_palette; - } - if (t2p->tiff_samplesperpixel > 3) - { - if (t2p->tiff_samplesperpixel == 4) - { - t2p->pdf_colorspace = T2P_CS_RGB; - if (TIFFGetField(input, TIFFTAG_EXTRASAMPLES, &xuint16, - &xuint16p) && - xuint16 == 1) - { - if (xuint16p[0] == EXTRASAMPLE_ASSOCALPHA) - { - if (t2p->tiff_bitspersample != 8) - { - TIFFError( - TIFF2PDF_MODULE, - "No support for BitsPerSample=%" PRIu16 - " for RGBA", - t2p->tiff_bitspersample); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->pdf_sample = T2P_SAMPLE_RGBAA_TO_RGB; - break; - } - if (xuint16p[0] == EXTRASAMPLE_UNASSALPHA) - { - if (t2p->tiff_bitspersample != 8) - { - TIFFError( - TIFF2PDF_MODULE, - "No support for BitsPerSample=%" PRIu16 - " for RGBA", - t2p->tiff_bitspersample); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->pdf_sample = T2P_SAMPLE_RGBA_TO_RGB; - break; - } - TIFFWarning(TIFF2PDF_MODULE, - "RGB image %s has 4 samples per pixel, " - "assuming RGBA", - TIFFFileName(input)); - break; - } - t2p->pdf_colorspace = T2P_CS_CMYK; - t2p->pdf_switchdecode ^= 1; - TIFFWarning(TIFF2PDF_MODULE, - "RGB image %s has 4 samples per pixel, " - "assuming inverse CMYK", - TIFFFileName(input)); - break; - } - else - { - TIFFError(TIFF2PDF_MODULE, - "No support for RGB image %s with %" PRIu16 - " samples per pixel", - TIFFFileName(input), t2p->tiff_samplesperpixel); - t2p->t2p_error = T2P_ERR_ERROR; - break; - } - } - else - { - TIFFError(TIFF2PDF_MODULE, - "No support for RGB image %s with %" PRIu16 - " samples per pixel", - TIFFFileName(input), t2p->tiff_samplesperpixel); - t2p->t2p_error = T2P_ERR_ERROR; - break; - } - case PHOTOMETRIC_PALETTE: - photometric_palette: - if (t2p->tiff_samplesperpixel != 1) - { - TIFFError(TIFF2PDF_MODULE, - "No support for palettized image %s with not one " - "sample per pixel", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->pdf_colorspace = T2P_CS_RGB | T2P_CS_PALETTE; - t2p->pdf_palettesize = 0x0001 << t2p->tiff_bitspersample; - if (!TIFFGetField(input, TIFFTAG_COLORMAP, &r, &g, &b)) - { - TIFFError(TIFF2PDF_MODULE, - "Palettized image %s has no color map", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if (r == NULL || g == NULL || b == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Error getting 3 components from color map"); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if (t2p->pdf_palette != NULL) - { - _TIFFfree(t2p->pdf_palette); - t2p->pdf_palette = NULL; - } - t2p->pdf_palette = (unsigned char *)_TIFFmalloc( - TIFFSafeMultiply(tmsize_t, t2p->pdf_palettesize, 3)); - if (t2p->pdf_palette == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" PRIu16 - " bytes of memory for t2p_read_tiff_image, %s", - t2p->pdf_palettesize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - /* Some older tiffs may have colors in the palette - * ranging from 0 to 255 rather than 0 to 65535. */ - for (i = 0; i < t2p->pdf_palettesize; i++) - { - if ((r[i] > 255) || (g[i] > 255) || (b[i] > 255)) - { - palette_16bit = 1; - break; - } - } - if (palette_16bit == 0) - { - TIFFWarning(TIFFFileName(input), "Assuming 8-bit colormap"); - palette_shift = 0; - } - for (i = 0; i < t2p->pdf_palettesize; i++) - { - t2p->pdf_palette[(i * 3)] = - (unsigned char)(r[i] >> palette_shift); - t2p->pdf_palette[(i * 3) + 1] = - (unsigned char)(g[i] >> palette_shift); - t2p->pdf_palette[(i * 3) + 2] = - (unsigned char)(b[i] >> palette_shift); - } - t2p->pdf_palettesize *= 3; - break; - case PHOTOMETRIC_SEPARATED: - if (TIFFGetField(input, TIFFTAG_INDEXED, &xuint16)) - { - if (xuint16 == 1) - { - goto photometric_palette_cmyk; - } - } - if (TIFFGetField(input, TIFFTAG_INKSET, &xuint16)) - { - if (xuint16 != INKSET_CMYK) - { - TIFFError( - TIFF2PDF_MODULE, - "No support for %s because its inkset is not CMYK", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - } - if (t2p->tiff_samplesperpixel == 4) - { - t2p->pdf_colorspace = T2P_CS_CMYK; - } - else - { - TIFFError(TIFF2PDF_MODULE, - "No support for %s because it has %" PRIu16 - " samples per pixel", - TIFFFileName(input), t2p->tiff_samplesperpixel); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - break; - photometric_palette_cmyk: - if (t2p->tiff_samplesperpixel != 1) - { - TIFFError(TIFF2PDF_MODULE, - "No support for palettized CMYK image %s with not " - "one sample per pixel", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->pdf_colorspace = T2P_CS_CMYK | T2P_CS_PALETTE; - t2p->pdf_palettesize = 0x0001 << t2p->tiff_bitspersample; - if (!TIFFGetField(input, TIFFTAG_COLORMAP, &r, &g, &b, &a)) - { - TIFFError(TIFF2PDF_MODULE, - "Palettized image %s has no color map", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if (r == NULL || g == NULL || b == NULL || a == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Error getting 4 components from color map"); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if (t2p->pdf_palette != NULL) - { - _TIFFfree(t2p->pdf_palette); - t2p->pdf_palette = NULL; - } - t2p->pdf_palette = (unsigned char *)_TIFFmalloc( - TIFFSafeMultiply(tmsize_t, t2p->pdf_palettesize, 4)); - if (t2p->pdf_palette == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" PRIu16 - " bytes of memory for t2p_read_tiff_image, %s", - t2p->pdf_palettesize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - for (i = 0; i < t2p->pdf_palettesize; i++) - { - t2p->pdf_palette[(i * 4)] = (unsigned char)(r[i] >> 8); - t2p->pdf_palette[(i * 4) + 1] = (unsigned char)(g[i] >> 8); - t2p->pdf_palette[(i * 4) + 2] = (unsigned char)(b[i] >> 8); - t2p->pdf_palette[(i * 4) + 3] = (unsigned char)(a[i] >> 8); - } - t2p->pdf_palettesize *= 4; - break; - case PHOTOMETRIC_YCBCR: - t2p->pdf_colorspace = T2P_CS_RGB; - if (t2p->tiff_samplesperpixel == 1) - { - t2p->pdf_colorspace = T2P_CS_GRAY; - t2p->tiff_photometric = PHOTOMETRIC_MINISBLACK; - break; - } - t2p->pdf_sample = T2P_SAMPLE_YCBCR_TO_RGB; -#ifdef JPEG_SUPPORT - if (t2p->pdf_defaultcompression == T2P_COMPRESS_JPEG) - { - t2p->pdf_sample = T2P_SAMPLE_NOTHING; - } -#endif - break; - case PHOTOMETRIC_CIELAB: - if (t2p->tiff_samplesperpixel != 3) - { - TIFFError(TIFF2PDF_MODULE, - "Unsupported samplesperpixel = %" PRIu16 - " for CIELAB", - t2p->tiff_samplesperpixel); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if (t2p->tiff_bitspersample != 8) - { - TIFFError(TIFF2PDF_MODULE, - "Invalid bitspersample = %" PRIu16 " for CIELAB", - t2p->tiff_bitspersample); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->pdf_labrange[0] = -127; - t2p->pdf_labrange[1] = 127; - t2p->pdf_labrange[2] = -127; - t2p->pdf_labrange[3] = 127; - t2p->pdf_sample = T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED; - t2p->pdf_colorspace = T2P_CS_LAB; - break; - case PHOTOMETRIC_ICCLAB: - t2p->pdf_labrange[0] = 0; - t2p->pdf_labrange[1] = 255; - t2p->pdf_labrange[2] = 0; - t2p->pdf_labrange[3] = 255; - t2p->pdf_colorspace = T2P_CS_LAB; - break; - case PHOTOMETRIC_ITULAB: - if (t2p->tiff_samplesperpixel != 3) - { - TIFFError(TIFF2PDF_MODULE, - "Unsupported samplesperpixel = %" PRIu16 - " for ITULAB", - t2p->tiff_samplesperpixel); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - if (t2p->tiff_bitspersample != 8) - { - TIFFError(TIFF2PDF_MODULE, - "Invalid bitspersample = %" PRIu16 " for ITULAB", - t2p->tiff_bitspersample); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->pdf_labrange[0] = -85; - t2p->pdf_labrange[1] = 85; - t2p->pdf_labrange[2] = -75; - t2p->pdf_labrange[3] = 124; - t2p->pdf_sample = T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED; - t2p->pdf_colorspace = T2P_CS_LAB; - break; - case PHOTOMETRIC_LOGL: - case PHOTOMETRIC_LOGLUV: - TIFFError( - TIFF2PDF_MODULE, - "No support for %s with photometric interpretation LogL/LogLuv", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - default: - TIFFError( - TIFF2PDF_MODULE, - "No support for %s with photometric interpretation %" PRIu16, - TIFFFileName(input), t2p->tiff_photometric); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - - if (TIFFGetField(input, TIFFTAG_PLANARCONFIG, &(t2p->tiff_planar))) - { - switch (t2p->tiff_planar) - { - case 0: - TIFFWarning(TIFF2PDF_MODULE, - "Image %s has planar configuration 0, assuming 1", - TIFFFileName(input)); - t2p->tiff_planar = PLANARCONFIG_CONTIG; - case PLANARCONFIG_CONTIG: - break; - case PLANARCONFIG_SEPARATE: - t2p->pdf_sample = T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG; - if (t2p->tiff_bitspersample != 8) - { - TIFFError(TIFF2PDF_MODULE, - "No support for %s with separated planar " - "configuration and %" PRIu16 " bits per sample", - TIFFFileName(input), t2p->tiff_bitspersample); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - break; - default: + if(TIFFGetField(input, TIFFTAG_COMPRESSION, &(t2p->tiff_compression)) == 0){ TIFFError( - TIFF2PDF_MODULE, - "No support for %s with planar configuration %" PRIu16, - TIFFFileName(input), t2p->tiff_planar); + TIFF2PDF_MODULE, + "No support for %s with no compression tag", + TIFFFileName(input) ); t2p->t2p_error = T2P_ERR_ERROR; return; + } - } + if( TIFFIsCODECConfigured(t2p->tiff_compression) == 0){ + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with compression type %u: not configured", + TIFFFileName(input), + t2p->tiff_compression + ); + t2p->t2p_error = T2P_ERR_ERROR; + return; + + } - TIFFGetFieldDefaulted(input, TIFFTAG_ORIENTATION, &(t2p->tiff_orientation)); - if (t2p->tiff_orientation > 8) - { - TIFFWarning(TIFF2PDF_MODULE, - "Image %s has orientation %" PRIu16 ", assuming 0", - TIFFFileName(input), t2p->tiff_orientation); - t2p->tiff_orientation = 0; - } + TIFFGetFieldDefaulted(input, TIFFTAG_BITSPERSAMPLE, &(t2p->tiff_bitspersample)); + switch(t2p->tiff_bitspersample){ + case 1: + case 2: + case 4: + case 8: + break; + case 0: + TIFFWarning( + TIFF2PDF_MODULE, + "Image %s has 0 bits per sample, assuming 1", + TIFFFileName(input)); + t2p->tiff_bitspersample=1; + break; + default: + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with %u bits per sample", + TIFFFileName(input), + t2p->tiff_bitspersample); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } - if (TIFFGetField(input, TIFFTAG_XRESOLUTION, &(t2p->tiff_xres)) == 0) - { - t2p->tiff_xres = 0.0; - } - if (TIFFGetField(input, TIFFTAG_YRESOLUTION, &(t2p->tiff_yres)) == 0) - { - t2p->tiff_yres = 0.0; - } - TIFFGetFieldDefaulted(input, TIFFTAG_RESOLUTIONUNIT, &(t2p->tiff_resunit)); - if (t2p->tiff_resunit == RESUNIT_CENTIMETER) - { - t2p->tiff_xres *= 2.54F; - t2p->tiff_yres *= 2.54F; - } - else if (t2p->tiff_resunit != RESUNIT_INCH && t2p->pdf_centimeters != 0) - { - t2p->tiff_xres *= 2.54F; - t2p->tiff_yres *= 2.54F; - } + TIFFGetFieldDefaulted(input, TIFFTAG_SAMPLESPERPIXEL, &(t2p->tiff_samplesperpixel)); + if(t2p->tiff_samplesperpixel>4){ + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with %u samples per pixel", + TIFFFileName(input), + t2p->tiff_samplesperpixel); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + if(t2p->tiff_samplesperpixel==0){ + TIFFWarning( + TIFF2PDF_MODULE, + "Image %s has 0 samples per pixel, assuming 1", + TIFFFileName(input)); + t2p->tiff_samplesperpixel=1; + } + + if(TIFFGetField(input, TIFFTAG_SAMPLEFORMAT, &xuint16) != 0 ){ + switch(xuint16){ + case 0: + case 1: + case 4: + break; + default: + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with sample format %u", + TIFFFileName(input), + xuint16); + t2p->t2p_error = T2P_ERR_ERROR; + return; + break; + } + } + + TIFFGetFieldDefaulted(input, TIFFTAG_FILLORDER, &(t2p->tiff_fillorder)); + + if(TIFFGetField(input, TIFFTAG_PHOTOMETRIC, &(t2p->tiff_photometric)) == 0){ + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with no photometric interpretation tag", + TIFFFileName(input) ); + t2p->t2p_error = T2P_ERR_ERROR; + return; - t2p_compose_pdf_page(t2p); - if (t2p->t2p_error == T2P_ERR_ERROR) - return; - - t2p->pdf_transcode = T2P_TRANSCODE_ENCODE; - /* It seems that T2P_TRANSCODE_RAW mode doesn't support separate->contig */ - /* conversion. At least t2p_read_tiff_size and t2p_read_tiff_size_tile */ - /* do not take into account the number of samples, and thus */ - /* that can cause heap buffer overflows such as in */ - /* http://bugzilla.maptools.org/show_bug.cgi?id=2715 */ - if (t2p->pdf_nopassthrough == 0 && - t2p->tiff_planar != PLANARCONFIG_SEPARATE) - { -#ifdef CCITT_SUPPORT - if (t2p->tiff_compression == COMPRESSION_CCITTFAX4) - { - if (TIFFIsTiled(input) || (TIFFNumberOfStrips(input) == 1)) - { - t2p->pdf_transcode = T2P_TRANSCODE_RAW; - t2p->pdf_compression = T2P_COMPRESS_G4; + } + + switch(t2p->tiff_photometric){ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + if (t2p->tiff_bitspersample==1){ + t2p->pdf_colorspace=T2P_CS_BILEVEL; + if(t2p->tiff_photometric==PHOTOMETRIC_MINISWHITE){ + t2p->pdf_switchdecode ^= 1; + } + } else { + t2p->pdf_colorspace=T2P_CS_GRAY; + if(t2p->tiff_photometric==PHOTOMETRIC_MINISWHITE){ + t2p->pdf_switchdecode ^= 1; + } + } + break; + case PHOTOMETRIC_RGB: + t2p->pdf_colorspace=T2P_CS_RGB; + if(t2p->tiff_samplesperpixel == 3){ + break; + } + if(TIFFGetField(input, TIFFTAG_INDEXED, &xuint16)){ + if(xuint16==1) + goto photometric_palette; + } + if(t2p->tiff_samplesperpixel > 3) { + if(t2p->tiff_samplesperpixel == 4) { + t2p->pdf_colorspace = T2P_CS_RGB; + if(TIFFGetField(input, + TIFFTAG_EXTRASAMPLES, + &xuint16, &xuint16p) + && xuint16 == 1) { + if(xuint16p[0] == EXTRASAMPLE_ASSOCALPHA){ + if( t2p->tiff_bitspersample != 8 ) + { + TIFFError( + TIFF2PDF_MODULE, + "No support for BitsPerSample=%d for RGBA", + t2p->tiff_bitspersample); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p->pdf_sample=T2P_SAMPLE_RGBAA_TO_RGB; + break; + } + if(xuint16p[0] == EXTRASAMPLE_UNASSALPHA){ + if( t2p->tiff_bitspersample != 8 ) + { + TIFFError( + TIFF2PDF_MODULE, + "No support for BitsPerSample=%d for RGBA", + t2p->tiff_bitspersample); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p->pdf_sample=T2P_SAMPLE_RGBA_TO_RGB; + break; + } + TIFFWarning( + TIFF2PDF_MODULE, + "RGB image %s has 4 samples per pixel, assuming RGBA", + TIFFFileName(input)); + break; + } + t2p->pdf_colorspace=T2P_CS_CMYK; + t2p->pdf_switchdecode ^= 1; + TIFFWarning( + TIFF2PDF_MODULE, + "RGB image %s has 4 samples per pixel, assuming inverse CMYK", + TIFFFileName(input)); + break; + } else { + TIFFError( + TIFF2PDF_MODULE, + "No support for RGB image %s with %u samples per pixel", + TIFFFileName(input), + t2p->tiff_samplesperpixel); + t2p->t2p_error = T2P_ERR_ERROR; + break; + } + } else { + TIFFError( + TIFF2PDF_MODULE, + "No support for RGB image %s with %u samples per pixel", + TIFFFileName(input), + t2p->tiff_samplesperpixel); + t2p->t2p_error = T2P_ERR_ERROR; + break; + } + case PHOTOMETRIC_PALETTE: + photometric_palette: + if(t2p->tiff_samplesperpixel!=1){ + TIFFError( + TIFF2PDF_MODULE, + "No support for palettized image %s with not one sample per pixel", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p->pdf_colorspace=T2P_CS_RGB | T2P_CS_PALETTE; + t2p->pdf_palettesize=0x0001<tiff_bitspersample; + if(!TIFFGetField(input, TIFFTAG_COLORMAP, &r, &g, &b)){ + TIFFError( + TIFF2PDF_MODULE, + "Palettized image %s has no color map", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + if(r == NULL || g == NULL || b == NULL){ + TIFFError( + TIFF2PDF_MODULE, + "Error getting 3 components from color map"); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + if(t2p->pdf_palette != NULL){ + _TIFFfree(t2p->pdf_palette); + t2p->pdf_palette=NULL; + } + t2p->pdf_palette = (unsigned char*) + _TIFFmalloc(TIFFSafeMultiply(tmsize_t,t2p->pdf_palettesize,3)); + if(t2p->pdf_palette==NULL){ + TIFFError( + TIFF2PDF_MODULE, + "Can't allocate %u bytes of memory for t2p_read_tiff_image, %s", + t2p->pdf_palettesize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + for(i=0;ipdf_palettesize;i++){ + t2p->pdf_palette[(i*3)] = (unsigned char) (r[i]>>8); + t2p->pdf_palette[(i*3)+1]= (unsigned char) (g[i]>>8); + t2p->pdf_palette[(i*3)+2]= (unsigned char) (b[i]>>8); + } + t2p->pdf_palettesize *= 3; + break; + case PHOTOMETRIC_SEPARATED: + if(TIFFGetField(input, TIFFTAG_INDEXED, &xuint16)){ + if(xuint16==1){ + goto photometric_palette_cmyk; + } + } + if( TIFFGetField(input, TIFFTAG_INKSET, &xuint16) ){ + if(xuint16 != INKSET_CMYK){ + TIFFError( + TIFF2PDF_MODULE, + "No support for %s because its inkset is not CMYK", + TIFFFileName(input) ); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + } + if(t2p->tiff_samplesperpixel==4){ + t2p->pdf_colorspace=T2P_CS_CMYK; + } else { + TIFFError( + TIFF2PDF_MODULE, + "No support for %s because it has %u samples per pixel", + TIFFFileName(input), + t2p->tiff_samplesperpixel); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + break; + photometric_palette_cmyk: + if(t2p->tiff_samplesperpixel!=1){ + TIFFError( + TIFF2PDF_MODULE, + "No support for palettized CMYK image %s with not one sample per pixel", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p->pdf_colorspace=T2P_CS_CMYK | T2P_CS_PALETTE; + t2p->pdf_palettesize=0x0001<tiff_bitspersample; + if(!TIFFGetField(input, TIFFTAG_COLORMAP, &r, &g, &b, &a)){ + TIFFError( + TIFF2PDF_MODULE, + "Palettized image %s has no color map", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + if(r == NULL || g == NULL || b == NULL || a == NULL){ + TIFFError( + TIFF2PDF_MODULE, + "Error getting 4 components from color map"); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + if(t2p->pdf_palette != NULL){ + _TIFFfree(t2p->pdf_palette); + t2p->pdf_palette=NULL; + } + t2p->pdf_palette = (unsigned char*) + _TIFFmalloc(TIFFSafeMultiply(tmsize_t,t2p->pdf_palettesize,4)); + if(t2p->pdf_palette==NULL){ + TIFFError( + TIFF2PDF_MODULE, + "Can't allocate %u bytes of memory for t2p_read_tiff_image, %s", + t2p->pdf_palettesize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + for(i=0;ipdf_palettesize;i++){ + t2p->pdf_palette[(i*4)] = (unsigned char) (r[i]>>8); + t2p->pdf_palette[(i*4)+1]= (unsigned char) (g[i]>>8); + t2p->pdf_palette[(i*4)+2]= (unsigned char) (b[i]>>8); + t2p->pdf_palette[(i*4)+3]= (unsigned char) (a[i]>>8); + } + t2p->pdf_palettesize *= 4; + break; + case PHOTOMETRIC_YCBCR: + t2p->pdf_colorspace=T2P_CS_RGB; + if(t2p->tiff_samplesperpixel==1){ + t2p->pdf_colorspace=T2P_CS_GRAY; + t2p->tiff_photometric=PHOTOMETRIC_MINISBLACK; + break; + } + t2p->pdf_sample=T2P_SAMPLE_YCBCR_TO_RGB; +#ifdef JPEG_SUPPORT + if(t2p->pdf_defaultcompression==T2P_COMPRESS_JPEG){ + t2p->pdf_sample=T2P_SAMPLE_NOTHING; + } +#endif + break; + case PHOTOMETRIC_CIELAB: + if( t2p->tiff_samplesperpixel != 3){ + TIFFError( + TIFF2PDF_MODULE, + "Unsupported samplesperpixel = %d for CIELAB", + t2p->tiff_samplesperpixel); + t2p->t2p_error = T2P_ERR_ERROR; + return; } + if( t2p->tiff_bitspersample != 8){ + TIFFError( + TIFF2PDF_MODULE, + "Invalid bitspersample = %d for CIELAB", + t2p->tiff_bitspersample); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p->pdf_labrange[0]= -127; + t2p->pdf_labrange[1]= 127; + t2p->pdf_labrange[2]= -127; + t2p->pdf_labrange[3]= 127; + t2p->pdf_sample=T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED; + t2p->pdf_colorspace=T2P_CS_LAB; + break; + case PHOTOMETRIC_ICCLAB: + t2p->pdf_labrange[0]= 0; + t2p->pdf_labrange[1]= 255; + t2p->pdf_labrange[2]= 0; + t2p->pdf_labrange[3]= 255; + t2p->pdf_colorspace=T2P_CS_LAB; + break; + case PHOTOMETRIC_ITULAB: + if( t2p->tiff_samplesperpixel != 3){ + TIFFError( + TIFF2PDF_MODULE, + "Unsupported samplesperpixel = %d for ITULAB", + t2p->tiff_samplesperpixel); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + if( t2p->tiff_bitspersample != 8){ + TIFFError( + TIFF2PDF_MODULE, + "Invalid bitspersample = %d for ITULAB", + t2p->tiff_bitspersample); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p->pdf_labrange[0]=-85; + t2p->pdf_labrange[1]=85; + t2p->pdf_labrange[2]=-75; + t2p->pdf_labrange[3]=124; + t2p->pdf_sample=T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED; + t2p->pdf_colorspace=T2P_CS_LAB; + break; + case PHOTOMETRIC_LOGL: + case PHOTOMETRIC_LOGLUV: + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with photometric interpretation LogL/LogLuv", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + default: + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with photometric interpretation %u", + TIFFFileName(input), + t2p->tiff_photometric); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + + if(TIFFGetField(input, TIFFTAG_PLANARCONFIG, &(t2p->tiff_planar))){ + switch(t2p->tiff_planar){ + case 0: + TIFFWarning( + TIFF2PDF_MODULE, + "Image %s has planar configuration 0, assuming 1", + TIFFFileName(input)); + t2p->tiff_planar=PLANARCONFIG_CONTIG; + case PLANARCONFIG_CONTIG: + break; + case PLANARCONFIG_SEPARATE: + t2p->pdf_sample=T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG; + if(t2p->tiff_bitspersample!=8){ + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with separated planar configuration and %u bits per sample", + TIFFFileName(input), + t2p->tiff_bitspersample); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + break; + default: + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with planar configuration %u", + TIFFFileName(input), + t2p->tiff_planar); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + } + + TIFFGetFieldDefaulted(input, TIFFTAG_ORIENTATION, + &(t2p->tiff_orientation)); + if(t2p->tiff_orientation>8){ + TIFFWarning(TIFF2PDF_MODULE, + "Image %s has orientation %u, assuming 0", + TIFFFileName(input), t2p->tiff_orientation); + t2p->tiff_orientation=0; } + + if(TIFFGetField(input, TIFFTAG_XRESOLUTION, &(t2p->tiff_xres) ) == 0){ + t2p->tiff_xres=0.0; + } + if(TIFFGetField(input, TIFFTAG_YRESOLUTION, &(t2p->tiff_yres) ) == 0){ + t2p->tiff_yres=0.0; + } + TIFFGetFieldDefaulted(input, TIFFTAG_RESOLUTIONUNIT, + &(t2p->tiff_resunit)); + if(t2p->tiff_resunit == RESUNIT_CENTIMETER) { + t2p->tiff_xres *= 2.54F; + t2p->tiff_yres *= 2.54F; + } else if (t2p->tiff_resunit != RESUNIT_INCH + && t2p->pdf_centimeters != 0) { + t2p->tiff_xres *= 2.54F; + t2p->tiff_yres *= 2.54F; + } + + t2p_compose_pdf_page(t2p); + if( t2p->t2p_error == T2P_ERR_ERROR ) + return; + + t2p->pdf_transcode = T2P_TRANSCODE_ENCODE; + /* It seems that T2P_TRANSCODE_RAW mode doesn't support separate->contig */ + /* conversion. At least t2p_read_tiff_size and t2p_read_tiff_size_tile */ + /* do not take into account the number of samples, and thus */ + /* that can cause heap buffer overflows such as in */ + /* http://bugzilla.maptools.org/show_bug.cgi?id=2715 */ + if(t2p->pdf_nopassthrough==0 && t2p->tiff_planar!=PLANARCONFIG_SEPARATE){ +#ifdef CCITT_SUPPORT + if(t2p->tiff_compression==COMPRESSION_CCITTFAX4 + ){ + if(TIFFIsTiled(input) || (TIFFNumberOfStrips(input)==1) ){ + t2p->pdf_transcode = T2P_TRANSCODE_RAW; + t2p->pdf_compression=T2P_COMPRESS_G4; + } + } #endif #ifdef ZIP_SUPPORT - if (t2p->tiff_compression == COMPRESSION_ADOBE_DEFLATE || - t2p->tiff_compression == COMPRESSION_DEFLATE) - { - if (TIFFIsTiled(input) || (TIFFNumberOfStrips(input) == 1)) - { - uint16_t predictor; - t2p->pdf_transcode = T2P_TRANSCODE_RAW; - t2p->pdf_compression = T2P_COMPRESS_ZIP; - if (TIFFGetField(input, TIFFTAG_PREDICTOR, &predictor)) - { - t2p->pdf_compressionquality = predictor; - } - else - { - t2p->pdf_compressionquality = PREDICTOR_NONE; - } - /* TIFFTAG_ZIPQUALITY is always Z_DEFAULT_COMPRESSION on reading - */ - } - } + if(t2p->tiff_compression== COMPRESSION_ADOBE_DEFLATE + || t2p->tiff_compression==COMPRESSION_DEFLATE){ + if(TIFFIsTiled(input) || (TIFFNumberOfStrips(input)==1) ){ + uint16 predictor; + t2p->pdf_transcode = T2P_TRANSCODE_RAW; + t2p->pdf_compression=T2P_COMPRESS_ZIP; + TIFFGetField(input, TIFFTAG_PREDICTOR, &predictor); + t2p->pdf_compressionquality = predictor; + /* TIFFTAG_ZIPQUALITY is always Z_DEFAULT_COMPRESSION on reading */ + } + } #endif #ifdef OJPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_OJPEG) - { - t2p->pdf_transcode = T2P_TRANSCODE_RAW; - t2p->pdf_compression = T2P_COMPRESS_JPEG; - t2p_process_ojpeg_tables(t2p, input); - } + if(t2p->tiff_compression==COMPRESSION_OJPEG){ + t2p->pdf_transcode = T2P_TRANSCODE_RAW; + t2p->pdf_compression=T2P_COMPRESS_JPEG; + t2p_process_ojpeg_tables(t2p, input); + } #endif #ifdef JPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_JPEG) - { - t2p->pdf_transcode = T2P_TRANSCODE_RAW; - t2p->pdf_compression = T2P_COMPRESS_JPEG; - } + if(t2p->tiff_compression==COMPRESSION_JPEG){ + t2p->pdf_transcode = T2P_TRANSCODE_RAW; + t2p->pdf_compression=T2P_COMPRESS_JPEG; + } #endif - (void)0; - } + (void)0; + } - if (t2p->pdf_transcode != T2P_TRANSCODE_RAW) - { - t2p->pdf_compression = t2p->pdf_defaultcompression; - } + if(t2p->pdf_transcode!=T2P_TRANSCODE_RAW){ + t2p->pdf_compression = t2p->pdf_defaultcompression; + } #ifdef JPEG_SUPPORT - if (t2p->pdf_defaultcompression == T2P_COMPRESS_JPEG) - { - if (t2p->pdf_colorspace & T2P_CS_PALETTE) - { - t2p->pdf_sample |= T2P_SAMPLE_REALIZE_PALETTE; - t2p->pdf_colorspace ^= T2P_CS_PALETTE; - t2p->tiff_pages[t2p->pdf_page].page_extra--; - } - } - if (t2p->tiff_compression == COMPRESSION_JPEG) - { - if (t2p->tiff_planar == PLANARCONFIG_SEPARATE) - { - TIFFError(TIFF2PDF_MODULE, - "No support for %s with JPEG compression and separated " - "planar configuration", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - } + if(t2p->pdf_defaultcompression==T2P_COMPRESS_JPEG){ + if(t2p->pdf_colorspace & T2P_CS_PALETTE){ + t2p->pdf_sample|=T2P_SAMPLE_REALIZE_PALETTE; + t2p->pdf_colorspace ^= T2P_CS_PALETTE; + t2p->tiff_pages[t2p->pdf_page].page_extra--; + } + } + if(t2p->tiff_compression==COMPRESSION_JPEG){ + if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){ + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with JPEG compression and separated planar configuration", + TIFFFileName(input)); + t2p->t2p_error=T2P_ERR_ERROR; + return; + } + } #endif #ifdef OJPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_OJPEG) - { - if (t2p->tiff_planar == PLANARCONFIG_SEPARATE) - { - TIFFError(TIFF2PDF_MODULE, - "No support for %s with OJPEG compression and separated " - "planar configuration", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - } + if(t2p->tiff_compression==COMPRESSION_OJPEG){ + if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){ + TIFFError( + TIFF2PDF_MODULE, + "No support for %s with OJPEG compression and separated planar configuration", + TIFFFileName(input)); + t2p->t2p_error=T2P_ERR_ERROR; + return; + } + } #endif - if (t2p->pdf_sample & T2P_SAMPLE_REALIZE_PALETTE) - { - if (t2p->pdf_colorspace & T2P_CS_CMYK) - { - t2p->tiff_samplesperpixel = 4; - t2p->tiff_photometric = PHOTOMETRIC_SEPARATED; - } - else - { - t2p->tiff_samplesperpixel = 3; - t2p->tiff_photometric = PHOTOMETRIC_RGB; - } - } - - if (TIFFGetField( - input, TIFFTAG_TRANSFERFUNCTION, &(t2p->tiff_transferfunction[0]), - &(t2p->tiff_transferfunction[1]), &(t2p->tiff_transferfunction[2]))) - { - if ((t2p->tiff_transferfunction[1] != (uint16_t *)NULL) && - (t2p->tiff_transferfunction[2] != (uint16_t *)NULL)) - { - t2p->tiff_transferfunctioncount = 3; - } - else - { - t2p->tiff_transferfunctioncount = 1; - } - } - else - { - t2p->tiff_transferfunctioncount = 0; - } - if (TIFFGetField(input, TIFFTAG_WHITEPOINT, &xfloatp) != 0) - { - t2p->tiff_whitechromaticities[0] = xfloatp[0]; - t2p->tiff_whitechromaticities[1] = xfloatp[1]; - if (t2p->pdf_colorspace & T2P_CS_GRAY) - { - t2p->pdf_colorspace |= T2P_CS_CALGRAY; - } - if (t2p->pdf_colorspace & T2P_CS_RGB) - { - t2p->pdf_colorspace |= T2P_CS_CALRGB; - } - } - if (TIFFGetField(input, TIFFTAG_PRIMARYCHROMATICITIES, &xfloatp) != 0) - { - t2p->tiff_primarychromaticities[0] = xfloatp[0]; - t2p->tiff_primarychromaticities[1] = xfloatp[1]; - t2p->tiff_primarychromaticities[2] = xfloatp[2]; - t2p->tiff_primarychromaticities[3] = xfloatp[3]; - t2p->tiff_primarychromaticities[4] = xfloatp[4]; - t2p->tiff_primarychromaticities[5] = xfloatp[5]; - if (t2p->pdf_colorspace & T2P_CS_RGB) - { - t2p->pdf_colorspace |= T2P_CS_CALRGB; - } - } - if (t2p->pdf_colorspace & T2P_CS_LAB) - { - if (TIFFGetField(input, TIFFTAG_WHITEPOINT, &xfloatp) != 0) - { - t2p->tiff_whitechromaticities[0] = xfloatp[0]; - t2p->tiff_whitechromaticities[1] = xfloatp[1]; - } - else - { - t2p->tiff_whitechromaticities[0] = 0.3457F; /* 0.3127F; */ - t2p->tiff_whitechromaticities[1] = 0.3585F; /* 0.3290F; */ - } - } - if (TIFFGetField(input, TIFFTAG_ICCPROFILE, &(t2p->tiff_iccprofilelength), - &(t2p->tiff_iccprofile)) != 0) - { - t2p->pdf_colorspace |= T2P_CS_ICCBASED; - } - else - { - t2p->tiff_iccprofilelength = 0; - t2p->tiff_iccprofile = NULL; - } + if(t2p->pdf_sample & T2P_SAMPLE_REALIZE_PALETTE){ + if(t2p->pdf_colorspace & T2P_CS_CMYK){ + t2p->tiff_samplesperpixel=4; + t2p->tiff_photometric=PHOTOMETRIC_SEPARATED; + } else { + t2p->tiff_samplesperpixel=3; + t2p->tiff_photometric=PHOTOMETRIC_RGB; + } + } + if (TIFFGetField(input, TIFFTAG_TRANSFERFUNCTION, + &(t2p->tiff_transferfunction[0]), + &(t2p->tiff_transferfunction[1]), + &(t2p->tiff_transferfunction[2]))) { + if((t2p->tiff_transferfunction[1] != (uint16*) NULL) && + (t2p->tiff_transferfunction[2] != (uint16*) NULL) + ) { + t2p->tiff_transferfunctioncount=3; + } else { + t2p->tiff_transferfunctioncount=1; + } + } else { + t2p->tiff_transferfunctioncount=0; + } + if(TIFFGetField(input, TIFFTAG_WHITEPOINT, &xfloatp)!=0){ + t2p->tiff_whitechromaticities[0]=xfloatp[0]; + t2p->tiff_whitechromaticities[1]=xfloatp[1]; + if(t2p->pdf_colorspace & T2P_CS_GRAY){ + t2p->pdf_colorspace |= T2P_CS_CALGRAY; + } + if(t2p->pdf_colorspace & T2P_CS_RGB){ + t2p->pdf_colorspace |= T2P_CS_CALRGB; + } + } + if(TIFFGetField(input, TIFFTAG_PRIMARYCHROMATICITIES, &xfloatp)!=0){ + t2p->tiff_primarychromaticities[0]=xfloatp[0]; + t2p->tiff_primarychromaticities[1]=xfloatp[1]; + t2p->tiff_primarychromaticities[2]=xfloatp[2]; + t2p->tiff_primarychromaticities[3]=xfloatp[3]; + t2p->tiff_primarychromaticities[4]=xfloatp[4]; + t2p->tiff_primarychromaticities[5]=xfloatp[5]; + if(t2p->pdf_colorspace & T2P_CS_RGB){ + t2p->pdf_colorspace |= T2P_CS_CALRGB; + } + } + if(t2p->pdf_colorspace & T2P_CS_LAB){ + if(TIFFGetField(input, TIFFTAG_WHITEPOINT, &xfloatp) != 0){ + t2p->tiff_whitechromaticities[0]=xfloatp[0]; + t2p->tiff_whitechromaticities[1]=xfloatp[1]; + } else { + t2p->tiff_whitechromaticities[0]=0.3457F; /* 0.3127F; */ + t2p->tiff_whitechromaticities[1]=0.3585F; /* 0.3290F; */ + } + } + if(TIFFGetField(input, + TIFFTAG_ICCPROFILE, + &(t2p->tiff_iccprofilelength), + &(t2p->tiff_iccprofile))!=0){ + t2p->pdf_colorspace |= T2P_CS_ICCBASED; + } else { + t2p->tiff_iccprofilelength=0; + t2p->tiff_iccprofile=NULL; + } + #ifdef CCITT_SUPPORT - if (t2p->tiff_bitspersample == 1 && t2p->tiff_samplesperpixel == 1) - { - t2p->pdf_compression = T2P_COMPRESS_G4; - } + if( t2p->tiff_bitspersample==1 && + t2p->tiff_samplesperpixel==1){ + t2p->pdf_compression = T2P_COMPRESS_G4; + } #endif - return; -} -/** - * checks for overflow - */ -static void t2p_set_tiff_datasize(T2P *t2p, uint64_t k) -{ - if (k != (uint64_t)(tmsize_t)k || (tmsize_t)k < 0) - { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p->tiff_datasize = (tmsize_t)k; -} - -/** - This function returns the necessary size of a data buffer to contain the - raw or uncompressed image data from the input TIFF for a page. -*/ -void t2p_read_tiff_size(T2P *t2p, TIFF *input) -{ - - uint64_t *sbc = NULL; -#if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT) - unsigned char *jpt = NULL; - tstrip_t i = 0; - tstrip_t stripcount = 0; -#endif - uint64_t k = 0; - - if (t2p->pdf_transcode == T2P_TRANSCODE_RAW) - { -#if defined(CCITT_SUPPORT) || defined(ZIP_SUPPORT) -#if defined(CCITT_SUPPORT) && defined(ZIP_SUPPORT) - if (t2p->pdf_compression == T2P_COMPRESS_G4 || - t2p->pdf_compression == T2P_COMPRESS_ZIP) -#elif defined(CCITT_SUPPORT) - if (t2p->pdf_compression == T2P_COMPRESS_G4) -#else - if (t2p->pdf_compression == T2P_COMPRESS_ZIP) -#endif - { - if (!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)) - { - TIFFError( - TIFF2PDF_MODULE, - "Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - t2p_set_tiff_datasize(t2p, sbc[0]); - return; - } -#endif -#ifdef OJPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_OJPEG) - { - if (!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)) - { - TIFFError( - TIFF2PDF_MODULE, - "Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - stripcount = TIFFNumberOfStrips(input); - for (i = 0; i < stripcount; i++) - { - k = checkAdd64(k, sbc[i], t2p); - } - if (TIFFGetField(input, TIFFTAG_JPEGIFOFFSET, - &(t2p->tiff_dataoffset))) - { - if (t2p->tiff_dataoffset != 0) - { - if (TIFFGetField(input, TIFFTAG_JPEGIFBYTECOUNT, - &(t2p->tiff_datasize)) != 0) - { - if ((uint64_t)t2p->tiff_datasize < k) - { - TIFFWarning(TIFF2PDF_MODULE, - "Input file %s has short JPEG " - "interchange file byte count", - TIFFFileName(input)); - t2p->pdf_ojpegiflength = t2p->tiff_datasize; - k = checkAdd64(k, t2p->tiff_datasize, t2p); - k = checkAdd64(k, 6, t2p); - k = checkAdd64(k, stripcount, t2p); - k = checkAdd64(k, stripcount, t2p); - t2p_set_tiff_datasize(t2p, k); - return; - } - return; - } - else - { - TIFFError(TIFF2PDF_MODULE, - "Input file %s missing field: " - "TIFFTAG_JPEGIFBYTECOUNT", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - } - } - k = checkAdd64(k, stripcount, t2p); - k = checkAdd64(k, stripcount, t2p); - k = checkAdd64(k, 2048, t2p); - t2p_set_tiff_datasize(t2p, k); - return; - } -#endif -#ifdef JPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_JPEG) - { - uint32_t count = 0; - if (TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) - { - if (count > 4) - { - k += count; - k -= 2; /* don't use EOI of header */ - } - } - else - { - k = 2; /* SOI for first strip */ - } - stripcount = TIFFNumberOfStrips(input); - if (!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)) - { - TIFFError( - TIFF2PDF_MODULE, - "Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - for (i = 0; i < stripcount; i++) - { - k = checkAdd64(k, sbc[i], t2p); - k -= 2; /* don't use EOI of strip */ - k += 2; /* add space for restart marker */ - } - k = checkAdd64(k, 2, t2p); /* use EOI of last strip */ - k = checkAdd64(k, 6, t2p); /* for DRI marker of first strip */ - t2p_set_tiff_datasize(t2p, k); - return; - } -#endif - (void)0; - } -#ifdef JPEG_SUPPORT - if (t2p->pdf_compression == T2P_COMPRESS_JPEG && - t2p->tiff_photometric == PHOTOMETRIC_YCBCR) - { - k = checkMultiply64(TIFFNumberOfStrips(input), TIFFStripSize(input), - t2p); - } - else -#endif - { - k = checkMultiply64(TIFFScanlineSize(input), t2p->tiff_length, t2p); - if (t2p->tiff_planar == PLANARCONFIG_SEPARATE) - { - k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p); - } - } - if (k == 0) - { - /* Assume we had overflow inside TIFFScanlineSize */ - t2p->t2p_error = T2P_ERR_ERROR; - } - - t2p_set_tiff_datasize(t2p, k); - - return; + return; } /* - This function returns the necessary size of a data buffer to contain the - raw or uncompressed image data from the input TIFF for a tile of a page. + This function returns the necessary size of a data buffer to contain the raw or + uncompressed image data from the input TIFF for a page. */ -void t2p_read_tiff_size_tile(T2P *t2p, TIFF *input, ttile_t tile) -{ +void t2p_read_tiff_size(T2P* t2p, TIFF* input){ - uint64_t *tbc = NULL; - uint16_t edge = 0; -#ifdef JPEG_SUPPORT - unsigned char *jpt; + uint64* sbc=NULL; +#if defined(JPEG_SUPPORT) || defined (OJPEG_SUPPORT) + unsigned char* jpt=NULL; + tstrip_t i=0; + tstrip_t stripcount=0; #endif - uint64_t k; + uint64 k = 0; - edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile); - edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile); - - if (t2p->pdf_transcode == T2P_TRANSCODE_RAW) - { - if (edge -#if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT) - && !(t2p->pdf_compression == T2P_COMPRESS_JPEG) -#endif - ) - { - t2p->tiff_datasize = TIFFTileSize(input); - if (t2p->tiff_datasize == 0) - { - /* Assume we had overflow inside TIFFTileSize */ + if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){ +#ifdef CCITT_SUPPORT + if(t2p->pdf_compression == T2P_COMPRESS_G4 ){ + TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); + if (sbc[0] != (uint64)(tmsize_t)sbc[0]) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); t2p->t2p_error = T2P_ERR_ERROR; } - return; - } - else - { - TIFFGetField(input, TIFFTAG_TILEBYTECOUNTS, &tbc); - k = tbc[tile]; -#ifdef OJPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_OJPEG) - { - k = checkAdd64(k, 2048, t2p); + t2p->tiff_datasize=(tmsize_t)sbc[0]; + return; + } +#endif +#ifdef ZIP_SUPPORT + if(t2p->pdf_compression == T2P_COMPRESS_ZIP){ + TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); + if (sbc[0] != (uint64)(tmsize_t)sbc[0]) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; } + t2p->tiff_datasize=(tmsize_t)sbc[0]; + return; + } +#endif +#ifdef OJPEG_SUPPORT + if(t2p->tiff_compression == COMPRESSION_OJPEG){ + if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){ + TIFFError(TIFF2PDF_MODULE, + "Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + stripcount=TIFFNumberOfStrips(input); + for(i=0;itiff_dataoffset))){ + if(t2p->tiff_dataoffset != 0){ + if(TIFFGetField(input, TIFFTAG_JPEGIFBYTECOUNT, &(t2p->tiff_datasize))!=0){ + if((uint64)t2p->tiff_datasize < k) { + TIFFWarning(TIFF2PDF_MODULE, + "Input file %s has short JPEG interchange file byte count", + TIFFFileName(input)); + t2p->pdf_ojpegiflength=t2p->tiff_datasize; + k = checkAdd64(k, t2p->tiff_datasize, t2p); + k = checkAdd64(k, 6, t2p); + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, stripcount, t2p); + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } + return; + }else { + TIFFError(TIFF2PDF_MODULE, + "Input file %s missing field: TIFFTAG_JPEGIFBYTECOUNT", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + } + } + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, stripcount, t2p); + k = checkAdd64(k, 2048, t2p); + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } #endif #ifdef JPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_JPEG) - { - uint32_t count = 0; - if (TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) - { - if (count > 4) - { - k = checkAdd64(k, count, t2p); - k -= 2; /* don't use EOI of header or SOI of tile */ - } - } - } + if(t2p->tiff_compression == COMPRESSION_JPEG) { + uint32 count = 0; + if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0 ){ + if(count > 4){ + k += count; + k -= 2; /* don't use EOI of header */ + } + } else { + k = 2; /* SOI for first strip */ + } + stripcount=TIFFNumberOfStrips(input); + if(!TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc)){ + TIFFError(TIFF2PDF_MODULE, + "Input file %s missing field: TIFFTAG_STRIPBYTECOUNTS", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + for(i=0;itiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } #endif - t2p_set_tiff_datasize(t2p, k); - return; - } - } - k = TIFFTileSize(input); - if (t2p->tiff_planar == PLANARCONFIG_SEPARATE) - { - k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p); - } - if (k == 0) - { - /* Assume we had overflow inside TIFFTileSize */ - t2p->t2p_error = T2P_ERR_ERROR; - } + (void) 0; + } +#ifdef JPEG_SUPPORT + if(t2p->pdf_compression == T2P_COMPRESS_JPEG + && t2p->tiff_photometric == PHOTOMETRIC_YCBCR) { + k = checkMultiply64(TIFFNumberOfStrips(input), TIFFStripSize(input), t2p); + } else +#endif + { + k = checkMultiply64(TIFFScanlineSize(input), t2p->tiff_length, t2p); + if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){ + k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p); + } + } + if (k == 0) { + /* Assume we had overflow inside TIFFScanlineSize */ + t2p->t2p_error = T2P_ERR_ERROR; + } - t2p_set_tiff_datasize(t2p, k); + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } - return; + return; +} + +/* + This function returns the necessary size of a data buffer to contain the raw or + uncompressed image data from the input TIFF for a tile of a page. +*/ + +void t2p_read_tiff_size_tile(T2P* t2p, TIFF* input, ttile_t tile){ + + uint64* tbc = NULL; + uint16 edge=0; +#ifdef JPEG_SUPPORT + unsigned char* jpt; +#endif + uint64 k; + + edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile); + edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile); + + if(t2p->pdf_transcode==T2P_TRANSCODE_RAW){ + if(edge +#if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT) + && !(t2p->pdf_compression==T2P_COMPRESS_JPEG) +#endif + ){ + t2p->tiff_datasize=TIFFTileSize(input); + if (t2p->tiff_datasize == 0) { + /* Assume we had overflow inside TIFFTileSize */ + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } else { + TIFFGetField(input, TIFFTAG_TILEBYTECOUNTS, &tbc); + k=tbc[tile]; +#ifdef OJPEG_SUPPORT + if(t2p->tiff_compression==COMPRESSION_OJPEG){ + k = checkAdd64(k, 2048, t2p); + } +#endif +#ifdef JPEG_SUPPORT + if(t2p->tiff_compression==COMPRESSION_JPEG) { + uint32 count = 0; + if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt)!=0){ + if(count > 4){ + k = checkAdd64(k, count, t2p); + k -= 2; /* don't use EOI of header or SOI of tile */ + } + } + } +#endif + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } + return; + } + } + k = TIFFTileSize(input); + if(t2p->tiff_planar==PLANARCONFIG_SEPARATE){ + k = checkMultiply64(k, t2p->tiff_samplesperpixel, t2p); + } + if (k == 0) { + /* Assume we had overflow inside TIFFTileSize */ + t2p->t2p_error = T2P_ERR_ERROR; + } + + t2p->tiff_datasize = (tsize_t) k; + if ((uint64) t2p->tiff_datasize != k) { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + } + + return; } /* @@ -2388,18 +2192,14 @@ void t2p_read_tiff_size_tile(T2P *t2p, TIFF *input, ttile_t tile) * and does not have full imaged tile width. */ -int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile) -{ +int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile){ - if (((tile + 1) % tiles.tiles_tilecountx == 0) && - (tiles.tiles_edgetilewidth != 0)) - { - return (1); - } - else - { - return (0); - } + if( ((tile+1) % tiles.tiles_tilecountx == 0) + && (tiles.tiles_edgetilewidth != 0) ){ + return(1); + } else { + return(0); + } } /* @@ -2407,18 +2207,14 @@ int t2p_tile_is_right_edge(T2P_TILES tiles, ttile_t tile) * and does not have full imaged tile length. */ -int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile) -{ +int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile){ - if (((tile + 1) > (tiles.tiles_tilecount - tiles.tiles_tilecountx)) && - (tiles.tiles_edgetilelength != 0)) - { - return (1); - } - else - { - return (0); - } + if( ((tile+1) > (tiles.tiles_tilecount-tiles.tiles_tilecountx) ) + && (tiles.tiles_edgetilelength != 0) ){ + return(1); + } else { + return(0); + } } /* @@ -2426,261 +2222,249 @@ int t2p_tile_is_bottom_edge(T2P_TILES tiles, ttile_t tile) * or a bottom edge tile. */ -int t2p_tile_is_edge(T2P_TILES tiles, ttile_t tile) -{ +int t2p_tile_is_edge(T2P_TILES tiles, ttile_t tile){ - return (t2p_tile_is_right_edge(tiles, tile) | - t2p_tile_is_bottom_edge(tiles, tile)); + return(t2p_tile_is_right_edge(tiles, tile) | t2p_tile_is_bottom_edge(tiles, tile) ); } /* - This function returns a non-zero value when the tile is a right edge - tile and a bottom edge tile. + This function returns a non-zero value when the tile is a right edge tile and a bottom + edge tile. */ -int t2p_tile_is_corner_edge(T2P_TILES tiles, ttile_t tile) -{ +int t2p_tile_is_corner_edge(T2P_TILES tiles, ttile_t tile){ - return (t2p_tile_is_right_edge(tiles, tile) & - t2p_tile_is_bottom_edge(tiles, tile)); + return(t2p_tile_is_right_edge(tiles, tile) & t2p_tile_is_bottom_edge(tiles, tile) ); } #if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT) -static const unsigned char jpeg_eof_marker[] = {0xff, 0xd9}; +static const unsigned char jpeg_eof_marker[] = { 0xff, 0xd9 }; #endif /* - This function reads the raster image data from the input TIFF for an - image and writes the data to the output PDF XObject image dictionary stream. - It returns the amount written or zero on error. + This function reads the raster image data from the input TIFF for an image and writes + the data to the output PDF XObject image dictionary stream. It returns the amount written + or zero on error. */ -tsize_t t2p_readwrite_pdf_image(T2P *t2p, TIFF *input, TIFF *output) -{ +tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ - tsize_t written = 0; - unsigned char *buffer = NULL; - unsigned char *samplebuffer = NULL; - tsize_t bufferoffset = 0; - tsize_t samplebufferoffset = 0; - tsize_t read = 0; - tstrip_t i = 0; - tstrip_t j = 0; - tstrip_t stripcount = 0; - tsize_t stripsize = 0; - tsize_t sepstripcount = 0; - tsize_t sepstripsize = 0; + tsize_t written=0; + unsigned char* buffer=NULL; + unsigned char* samplebuffer=NULL; + tsize_t bufferoffset=0; + tsize_t samplebufferoffset=0; + tsize_t read=0; + tstrip_t i=0; + tstrip_t j=0; + tstrip_t stripcount=0; + tsize_t stripsize=0; + tsize_t sepstripcount=0; + tsize_t sepstripsize=0; #ifdef OJPEG_SUPPORT - toff_t inputoffset = 0; - uint16_t h_samp = 1; - uint16_t v_samp = 1; - uint16_t ri = 1; - uint32_t rows = 0; + toff_t inputoffset=0; + uint16 h_samp=1; + uint16 v_samp=1; + uint16 ri=1; + uint32 rows=0; #endif /* ifdef OJPEG_SUPPORT */ #ifdef JPEG_SUPPORT - unsigned char *jpt; - float *xfloatp; - uint64_t *sbc; - unsigned char *stripbuffer; - tsize_t striplength = 0; - uint32_t max_striplength = 0; + unsigned char* jpt; + float* xfloatp; + uint64* sbc; + unsigned char* stripbuffer; + tsize_t striplength=0; + uint32 max_striplength=0; #endif /* ifdef JPEG_SUPPORT */ - /* Fail if prior error (in particular, can't trust tiff_datasize) */ - if (t2p->t2p_error != T2P_ERR_OK) - return (0); + /* Fail if prior error (in particular, can't trust tiff_datasize) */ + if (t2p->t2p_error != T2P_ERR_OK) + return(0); - if (t2p->pdf_transcode == T2P_TRANSCODE_RAW) - { + if(t2p->pdf_transcode == T2P_TRANSCODE_RAW){ #ifdef CCITT_SUPPORT - if (t2p->pdf_compression == T2P_COMPRESS_G4) - { - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for " - "t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - if (TIFFReadRawStrip(input, 0, (tdata_t)buffer, - t2p->tiff_datasize) < 0) - { - TIFFError(TIFF2PDF_MODULE, "TIFFReadRawStrip() failed"); - _TIFFfree(buffer); - return (0); - } - if (t2p->tiff_fillorder == FILLORDER_LSB2MSB) - { - /* - * make sure is lsb-to-msb - * bit-endianness fill order - */ - TIFFReverseBits(buffer, t2p->tiff_datasize); - } - t2pWriteFile(output, (tdata_t)buffer, t2p->tiff_datasize); - _TIFFfree(buffer); - return (t2p->tiff_datasize); - } + if(t2p->pdf_compression == T2P_COMPRESS_G4){ + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); + if (buffer == NULL) { + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for " + "t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + if (TIFFReadRawStrip(input, 0, (tdata_t) buffer, + t2p->tiff_datasize) < 0) { + TIFFError(TIFF2PDF_MODULE, + "TIFFReadRawStrip() failed"); + _TIFFfree(buffer); + return(0); + } + if (t2p->tiff_fillorder==FILLORDER_LSB2MSB){ + /* + * make sure is lsb-to-msb + * bit-endianness fill order + */ + TIFFReverseBits(buffer, + t2p->tiff_datasize); + } + t2pWriteFile(output, (tdata_t) buffer, + t2p->tiff_datasize); + _TIFFfree(buffer); + return(t2p->tiff_datasize); + } #endif /* ifdef CCITT_SUPPORT */ #ifdef ZIP_SUPPORT - if (t2p->pdf_compression == T2P_COMPRESS_ZIP) - { - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - if (TIFFReadRawStrip(input, 0, (tdata_t)buffer, - t2p->tiff_datasize) < 0) - { - TIFFError(TIFF2PDF_MODULE, "TIFFReadRawStrip() failed"); - _TIFFfree(buffer); - return (0); - } - if (t2p->tiff_fillorder == FILLORDER_LSB2MSB) - { - TIFFReverseBits(buffer, t2p->tiff_datasize); - } - t2pWriteFile(output, (tdata_t)buffer, t2p->tiff_datasize); - _TIFFfree(buffer); - return (t2p->tiff_datasize); - } + if (t2p->pdf_compression == T2P_COMPRESS_ZIP) { + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); + if(buffer == NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + if (TIFFReadRawStrip(input, 0, (tdata_t) buffer, + t2p->tiff_datasize) < 0) { + TIFFError(TIFF2PDF_MODULE, + "TIFFReadRawStrip() failed"); + _TIFFfree(buffer); + return(0); + } + if (t2p->tiff_fillorder==FILLORDER_LSB2MSB) { + TIFFReverseBits(buffer, + t2p->tiff_datasize); + } + t2pWriteFile(output, (tdata_t) buffer, + t2p->tiff_datasize); + _TIFFfree(buffer); + return(t2p->tiff_datasize); + } #endif /* ifdef ZIP_SUPPORT */ #ifdef OJPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_OJPEG) - { + if(t2p->tiff_compression == COMPRESSION_OJPEG) { - if (t2p->tiff_dataoffset != 0) - { - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError( - TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - if (t2p->pdf_ojpegiflength == 0) - { - inputoffset = t2pSeekFile(input, 0, SEEK_CUR); - t2pSeekFile(input, t2p->tiff_dataoffset, SEEK_SET); - t2pReadFile(input, (tdata_t)buffer, t2p->tiff_datasize); - t2pSeekFile(input, inputoffset, SEEK_SET); - t2pWriteFile(output, (tdata_t)buffer, t2p->tiff_datasize); - _TIFFfree(buffer); - return (t2p->tiff_datasize); - } - else - { - inputoffset = t2pSeekFile(input, 0, SEEK_CUR); - t2pSeekFile(input, t2p->tiff_dataoffset, SEEK_SET); - bufferoffset = t2pReadFile(input, (tdata_t)buffer, - t2p->pdf_ojpegiflength); - t2p->pdf_ojpegiflength = 0; - t2pSeekFile(input, inputoffset, SEEK_SET); - TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &h_samp, - &v_samp); - buffer[bufferoffset++] = 0xff; - buffer[bufferoffset++] = 0xdd; - buffer[bufferoffset++] = 0x00; - buffer[bufferoffset++] = 0x04; - h_samp *= 8; - v_samp *= 8; - ri = (t2p->tiff_width + h_samp - 1) / h_samp; - TIFFGetField(input, TIFFTAG_ROWSPERSTRIP, &rows); - ri *= (rows + v_samp - 1) / v_samp; - buffer[bufferoffset++] = (ri >> 8) & 0xff; - buffer[bufferoffset++] = ri & 0xff; - stripcount = TIFFNumberOfStrips(input); - for (i = 0; i < stripcount; i++) - { - if (i != 0) - { - buffer[bufferoffset++] = 0xff; - buffer[bufferoffset++] = (0xd0 | ((i - 1) % 8)); - } - bufferoffset += TIFFReadRawStrip( - input, i, - (tdata_t) & - (((unsigned char *)buffer)[bufferoffset]), - -1); - } - t2pWriteFile(output, (tdata_t)buffer, bufferoffset); - _TIFFfree(buffer); - return (bufferoffset); - } - } - else - { - if (!t2p->pdf_ojpegdata) - { - TIFFError(TIFF2PDF_MODULE, - "No support for OJPEG image %s with bad tables", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError( - TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - _TIFFmemcpy(buffer, t2p->pdf_ojpegdata, - t2p->pdf_ojpegdatalength); - bufferoffset = t2p->pdf_ojpegdatalength; - stripcount = TIFFNumberOfStrips(input); - for (i = 0; i < stripcount; i++) - { - tsize_t retTIFFReadRawStrip; - if (i != 0) - { - buffer[bufferoffset++] = 0xff; - buffer[bufferoffset++] = (0xd0 | ((i - 1) % 8)); - } - retTIFFReadRawStrip = TIFFReadRawStrip( - input, i, - (tdata_t) & (((unsigned char *)buffer)[bufferoffset]), - -1); - if (retTIFFReadRawStrip < 0) - { - TIFFError(TIFF2PDF_MODULE, "TIFFReadRawStrip()"); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - bufferoffset += retTIFFReadRawStrip; - } - t2pWriteFile(output, (tdata_t)buffer, bufferoffset); - if (!((buffer[bufferoffset - 1] == 0xd9) && - (buffer[bufferoffset - 2] == 0xff))) - { - t2pWriteFile(output, (tdata_t)jpeg_eof_marker, - sizeof(jpeg_eof_marker)); - } - _TIFFfree(buffer); - return (bufferoffset); + if(t2p->tiff_dataoffset != 0) { + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); + if(buffer == NULL) { + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + if(t2p->pdf_ojpegiflength==0){ + inputoffset=t2pSeekFile(input, 0, + SEEK_CUR); + t2pSeekFile(input, + t2p->tiff_dataoffset, + SEEK_SET); + t2pReadFile(input, (tdata_t) buffer, + t2p->tiff_datasize); + t2pSeekFile(input, inputoffset, + SEEK_SET); + t2pWriteFile(output, (tdata_t) buffer, + t2p->tiff_datasize); + _TIFFfree(buffer); + return(t2p->tiff_datasize); + } else { + inputoffset=t2pSeekFile(input, 0, + SEEK_CUR); + t2pSeekFile(input, + t2p->tiff_dataoffset, + SEEK_SET); + bufferoffset = t2pReadFile(input, + (tdata_t) buffer, + t2p->pdf_ojpegiflength); + t2p->pdf_ojpegiflength = 0; + t2pSeekFile(input, inputoffset, + SEEK_SET); + TIFFGetField(input, + TIFFTAG_YCBCRSUBSAMPLING, + &h_samp, &v_samp); + buffer[bufferoffset++]= 0xff; + buffer[bufferoffset++]= 0xdd; + buffer[bufferoffset++]= 0x00; + buffer[bufferoffset++]= 0x04; + h_samp*=8; + v_samp*=8; + ri=(t2p->tiff_width+h_samp-1) / h_samp; + TIFFGetField(input, + TIFFTAG_ROWSPERSTRIP, + &rows); + ri*=(rows+v_samp-1)/v_samp; + buffer[bufferoffset++]= (ri>>8) & 0xff; + buffer[bufferoffset++]= ri & 0xff; + stripcount=TIFFNumberOfStrips(input); + for(i=0;ipdf_ojpegdata){ + TIFFError(TIFF2PDF_MODULE, + "No support for OJPEG image %s with bad tables", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + _TIFFmemcpy(buffer, t2p->pdf_ojpegdata, t2p->pdf_ojpegdatalength); + bufferoffset=t2p->pdf_ojpegdatalength; + stripcount=TIFFNumberOfStrips(input); + for(i=0;it2p_error = T2P_ERR_ERROR; + return(0); + } + bufferoffset += retTIFFReadRawStrip; + } + t2pWriteFile(output, (tdata_t) buffer, bufferoffset); + if( ! ( (buffer[bufferoffset-1]==0xd9) && (buffer[bufferoffset-2]==0xff) ) ){ + t2pWriteFile(output, (tdata_t) jpeg_eof_marker, sizeof(jpeg_eof_marker)); + } + _TIFFfree(buffer); + return(bufferoffset); #if 0 /* This hunk of code removed code is clearly @@ -2693,426 +2477,391 @@ tsize_t t2p_readwrite_pdf_image(T2P *t2p, TIFF *input, TIFF *output) t2p->t2p_error = T2P_ERR_ERROR; return(0); #endif - } - } + } + } #endif /* ifdef OJPEG_SUPPORT */ #ifdef JPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_JPEG) - { - uint32_t count = 0; - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - if (TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) - { - if (count > 4) - { - _TIFFmemcpy(buffer, jpt, count); - bufferoffset += count - 2; - } - } - stripcount = TIFFNumberOfStrips(input); - TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); - for (i = 0; i < stripcount; i++) - { - if (sbc[i] > max_striplength) - max_striplength = sbc[i]; - } - stripbuffer = (unsigned char *)_TIFFmalloc(max_striplength); - if (stripbuffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" PRId32 - " bytes of memory for t2p_readwrite_pdf_image, %s", - max_striplength, TIFFFileName(input)); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(stripbuffer, 0, max_striplength); - for (i = 0; i < stripcount; i++) - { - striplength = - TIFFReadRawStrip(input, i, (tdata_t)stripbuffer, -1); - if (striplength < 0) - { - TIFFError(TIFF2PDF_MODULE, "TIFFReadRawStrip() failed"); - _TIFFfree(samplebuffer); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - if (!t2p_process_jpeg_strip(stripbuffer, &striplength, buffer, - t2p->tiff_datasize, &bufferoffset, - i, t2p->tiff_length)) - { - TIFFError(TIFF2PDF_MODULE, - "Can't process JPEG data in input file %s", - TIFFFileName(input)); - _TIFFfree(samplebuffer); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - } - t2pWriteFile(output, (tdata_t)buffer, bufferoffset); - t2pWriteFile(output, (tdata_t)jpeg_eof_marker, - sizeof(jpeg_eof_marker)); - _TIFFfree(stripbuffer); - _TIFFfree(buffer); - return (bufferoffset); - } + if(t2p->tiff_compression == COMPRESSION_JPEG) { + uint32 count = 0; + buffer = (unsigned char*) + _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + if (TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) { + if(count > 4) { + _TIFFmemcpy(buffer, jpt, count); + bufferoffset += count - 2; + } + } + stripcount=TIFFNumberOfStrips(input); + TIFFGetField(input, TIFFTAG_STRIPBYTECOUNTS, &sbc); + for(i=0;imax_striplength) max_striplength=sbc[i]; + } + stripbuffer = (unsigned char*) + _TIFFmalloc(max_striplength); + if(stripbuffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %u bytes of memory for t2p_readwrite_pdf_image, %s", + max_striplength, + TIFFFileName(input)); + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(stripbuffer, 0, max_striplength); + for(i=0;it2p_error = T2P_ERR_ERROR; + return(0); + } + if(!t2p_process_jpeg_strip( + stripbuffer, + &striplength, + buffer, + t2p->tiff_datasize, + &bufferoffset, + i, + t2p->tiff_length)){ + TIFFError(TIFF2PDF_MODULE, + "Can't process JPEG data in input file %s", + TIFFFileName(input)); + _TIFFfree(samplebuffer); + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + } + t2pWriteFile(output, (tdata_t) buffer, bufferoffset); + t2pWriteFile(output, (tdata_t) jpeg_eof_marker, sizeof(jpeg_eof_marker)); + _TIFFfree(stripbuffer); + _TIFFfree(buffer); + return(bufferoffset); + } #endif /* ifdef JPEG_SUPPORT */ - (void)0; - } + (void)0; + } - if (t2p->pdf_sample == T2P_SAMPLE_NOTHING) - { - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - stripsize = TIFFStripSize(input); - stripcount = TIFFNumberOfStrips(input); - for (i = 0; i < stripcount; i++) - { - read = TIFFReadEncodedStrip( - input, i, (tdata_t)&buffer[bufferoffset], - TIFFmin(stripsize, t2p->tiff_datasize - bufferoffset)); - if (read == -1) - { - TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %" PRIu32 " of %s", i, - TIFFFileName(input)); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - bufferoffset += read; - } - } - else - { - if (t2p->pdf_sample & T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG) - { + if(t2p->pdf_sample==T2P_SAMPLE_NOTHING){ + buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + stripsize=TIFFStripSize(input); + stripcount=TIFFNumberOfStrips(input); + for(i=0;itiff_datasize - bufferoffset)); + if(read==-1){ + TIFFError(TIFF2PDF_MODULE, + "Error on decoding strip %u of %s", + i, + TIFFFileName(input)); + _TIFFfree(buffer); + t2p->t2p_error=T2P_ERR_ERROR; + return(0); + } + bufferoffset+=read; + } + } else { + if(t2p->pdf_sample & T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG){ + + sepstripsize=TIFFStripSize(input); + sepstripcount=TIFFNumberOfStrips(input); + + stripsize=sepstripsize*t2p->tiff_samplesperpixel; + stripcount=sepstripcount/t2p->tiff_samplesperpixel; + + buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + samplebuffer = (unsigned char*) _TIFFmalloc(stripsize); + if(samplebuffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + _TIFFfree(buffer); + return(0); + } + for(i=0;itiff_samplesperpixel;j++){ + read = + TIFFReadEncodedStrip(input, + i + j*stripcount, + (tdata_t) &(samplebuffer[samplebufferoffset]), + TIFFmin(sepstripsize, stripsize - samplebufferoffset)); + if(read==-1){ + TIFFError(TIFF2PDF_MODULE, + "Error on decoding strip %u of %s", + i + j*stripcount, + TIFFFileName(input)); + _TIFFfree(buffer); + t2p->t2p_error=T2P_ERR_ERROR; + return(0); + } + samplebufferoffset+=read; + } + t2p_sample_planar_separate_to_contig( + t2p, + &(buffer[bufferoffset]), + samplebuffer, + samplebufferoffset); + bufferoffset+=samplebufferoffset; + } + _TIFFfree(samplebuffer); + goto dataready; + } - sepstripsize = TIFFStripSize(input); - sepstripcount = TIFFNumberOfStrips(input); + buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + stripsize=TIFFStripSize(input); + stripcount=TIFFNumberOfStrips(input); + for(i=0;itiff_datasize - bufferoffset)); + if(read==-1){ + TIFFError(TIFF2PDF_MODULE, + "Error on decoding strip %u of %s", + i, + TIFFFileName(input)); + _TIFFfree(samplebuffer); + _TIFFfree(buffer); + t2p->t2p_error=T2P_ERR_ERROR; + return(0); + } + bufferoffset+=read; + } - stripsize = sepstripsize * t2p->tiff_samplesperpixel; - stripcount = sepstripcount / t2p->tiff_samplesperpixel; + if(t2p->pdf_sample & T2P_SAMPLE_REALIZE_PALETTE){ + // FIXME: overflow? + samplebuffer=(unsigned char*)_TIFFrealloc( + (tdata_t) buffer, + t2p->tiff_datasize * t2p->tiff_samplesperpixel); + if(samplebuffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + _TIFFfree(buffer); + return(0); + } else { + buffer=samplebuffer; + t2p->tiff_datasize *= t2p->tiff_samplesperpixel; + } + t2p_sample_realize_palette(t2p, buffer); + } - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - samplebuffer = (unsigned char *)_TIFFmalloc(stripsize); - if (samplebuffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - _TIFFfree(buffer); - return (0); - } - for (i = 0; i < stripcount; i++) - { - samplebufferoffset = 0; - for (j = 0; j < t2p->tiff_samplesperpixel; j++) - { - read = TIFFReadEncodedStrip( - input, i + j * stripcount, - (tdata_t) & (samplebuffer[samplebufferoffset]), - TIFFmin(sepstripsize, stripsize - samplebufferoffset)); - if (read == -1) - { - TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %" PRIu32 " of %s", - i + j * stripcount, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - _TIFFfree(samplebuffer); - _TIFFfree(buffer); - return (0); - } - samplebufferoffset += read; - } - t2p_sample_planar_separate_to_contig( - t2p, &(buffer[bufferoffset]), samplebuffer, - samplebufferoffset); - bufferoffset += samplebufferoffset; - } - _TIFFfree(samplebuffer); - goto dataready; - } + if(t2p->pdf_sample & T2P_SAMPLE_RGBA_TO_RGB){ + t2p->tiff_datasize=t2p_sample_rgba_to_rgb( + (tdata_t)buffer, + t2p->tiff_width*t2p->tiff_length); + } - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - stripsize = TIFFStripSize(input); - stripcount = TIFFNumberOfStrips(input); - for (i = 0; i < stripcount; i++) - { - read = TIFFReadEncodedStrip( - input, i, (tdata_t)&buffer[bufferoffset], - TIFFmin(stripsize, t2p->tiff_datasize - bufferoffset)); - if (read == -1) - { - TIFFError(TIFF2PDF_MODULE, - "Error on decoding strip %" PRIu32 " of %s", i, - TIFFFileName(input)); - _TIFFfree(samplebuffer); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - bufferoffset += read; - } + if(t2p->pdf_sample & T2P_SAMPLE_RGBAA_TO_RGB){ + t2p->tiff_datasize=t2p_sample_rgbaa_to_rgb( + (tdata_t)buffer, + t2p->tiff_width*t2p->tiff_length); + } - if (t2p->pdf_sample & T2P_SAMPLE_REALIZE_PALETTE) - { - // FIXME: overflow? - samplebuffer = (unsigned char *)_TIFFrealloc( - (tdata_t)buffer, - t2p->tiff_datasize * t2p->tiff_samplesperpixel); - if (samplebuffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - _TIFFfree(buffer); - return (0); - } - else - { - buffer = samplebuffer; - t2p->tiff_datasize *= t2p->tiff_samplesperpixel; - } - t2p_sample_realize_palette(t2p, buffer); - } + if(t2p->pdf_sample & T2P_SAMPLE_YCBCR_TO_RGB){ + samplebuffer=(unsigned char*)_TIFFrealloc( + (tdata_t)buffer, + t2p->tiff_width*t2p->tiff_length*4); + if(samplebuffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + _TIFFfree(buffer); + return(0); + } else { + buffer=samplebuffer; + } + if(!TIFFReadRGBAImageOriented( + input, + t2p->tiff_width, + t2p->tiff_length, + (uint32*)buffer, + ORIENTATION_TOPLEFT, + 0)){ + TIFFError(TIFF2PDF_MODULE, + "Can't use TIFFReadRGBAImageOriented to extract RGB image from %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + t2p->tiff_datasize=t2p_sample_abgr_to_rgb( + (tdata_t) buffer, + t2p->tiff_width*t2p->tiff_length); - if (t2p->pdf_sample & T2P_SAMPLE_RGBA_TO_RGB) - { - t2p->tiff_datasize = t2p_sample_rgba_to_rgb( - (tdata_t)buffer, t2p->tiff_width * t2p->tiff_length); - } + } - if (t2p->pdf_sample & T2P_SAMPLE_RGBAA_TO_RGB) - { - t2p->tiff_datasize = t2p_sample_rgbaa_to_rgb( - (tdata_t)buffer, t2p->tiff_width * t2p->tiff_length); - } - - if (t2p->pdf_sample & T2P_SAMPLE_YCBCR_TO_RGB) - { - samplebuffer = (unsigned char *)_TIFFrealloc( - (tdata_t)buffer, t2p->tiff_width * t2p->tiff_length * 4); - if (samplebuffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - _TIFFfree(buffer); - return (0); - } - else - { - buffer = samplebuffer; - } - if (!TIFFReadRGBAImageOriented(input, t2p->tiff_width, - t2p->tiff_length, (uint32_t *)buffer, - ORIENTATION_TOPLEFT, 0)) - { - TIFFError(TIFF2PDF_MODULE, - "Can't use TIFFReadRGBAImageOriented to extract RGB " - "image from %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - t2p->tiff_datasize = t2p_sample_abgr_to_rgb( - (tdata_t)buffer, t2p->tiff_width * t2p->tiff_length); - } - - if (t2p->pdf_sample & T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED) - { - t2p->tiff_datasize = t2p_sample_lab_signed_to_unsigned( - (tdata_t)buffer, t2p->tiff_width * t2p->tiff_length); - } - } + if(t2p->pdf_sample & T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED){ + t2p->tiff_datasize=t2p_sample_lab_signed_to_unsigned( + (tdata_t)buffer, + t2p->tiff_width*t2p->tiff_length); + } + } dataready: - t2p_disable(output); - TIFFSetField(output, TIFFTAG_PHOTOMETRIC, t2p->tiff_photometric); - TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, t2p->tiff_bitspersample); - TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, t2p->tiff_samplesperpixel); - TIFFSetField(output, TIFFTAG_IMAGEWIDTH, t2p->tiff_width); - TIFFSetField(output, TIFFTAG_IMAGELENGTH, t2p->tiff_length); - TIFFSetField(output, TIFFTAG_ROWSPERSTRIP, t2p->tiff_length); - TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(output, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); + t2p_disable(output); + TIFFSetField(output, TIFFTAG_PHOTOMETRIC, t2p->tiff_photometric); + TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, t2p->tiff_bitspersample); + TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, t2p->tiff_samplesperpixel); + TIFFSetField(output, TIFFTAG_IMAGEWIDTH, t2p->tiff_width); + TIFFSetField(output, TIFFTAG_IMAGELENGTH, t2p->tiff_length); + TIFFSetField(output, TIFFTAG_ROWSPERSTRIP, t2p->tiff_length); + TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(output, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); - switch (t2p->pdf_compression) - { - case T2P_COMPRESS_NONE: - TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - break; + switch(t2p->pdf_compression){ + case T2P_COMPRESS_NONE: + TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + break; #ifdef CCITT_SUPPORT - case T2P_COMPRESS_G4: - TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); - break; + case T2P_COMPRESS_G4: + TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); + break; #endif /* ifdef CCITT_SUPPORT */ #ifdef JPEG_SUPPORT - case T2P_COMPRESS_JPEG: - if (t2p->tiff_photometric == PHOTOMETRIC_YCBCR) - { - uint16_t hor = 0, ver = 0; - if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver) != - 0) - { - if (hor != 0 && ver != 0) - { - TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, - ver); - } - } - if (TIFFGetField(input, TIFFTAG_REFERENCEBLACKWHITE, - &xfloatp) != 0) - { - TIFFSetField(output, TIFFTAG_REFERENCEBLACKWHITE, xfloatp); - } - } - if (TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_JPEG) == - 0) - { - TIFFError( - TIFF2PDF_MODULE, - "Unable to use JPEG compression for input %s and output %s", - TIFFFileName(input), TIFFFileName(output)); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - TIFFSetField(output, TIFFTAG_JPEGTABLESMODE, 0); + case T2P_COMPRESS_JPEG: + if(t2p->tiff_photometric==PHOTOMETRIC_YCBCR) { + uint16 hor = 0, ver = 0; + if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver) !=0 ) { + if(hor != 0 && ver != 0){ + TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, ver); + } + } + if(TIFFGetField(input, TIFFTAG_REFERENCEBLACKWHITE, &xfloatp)!=0){ + TIFFSetField(output, TIFFTAG_REFERENCEBLACKWHITE, xfloatp); + } + } + if(TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_JPEG)==0){ + TIFFError(TIFF2PDF_MODULE, + "Unable to use JPEG compression for input %s and output %s", + TIFFFileName(input), + TIFFFileName(output)); + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + TIFFSetField(output, TIFFTAG_JPEGTABLESMODE, 0); - if (t2p->pdf_colorspace & (T2P_CS_RGB | T2P_CS_LAB)) - { - TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); - if (t2p->tiff_photometric != PHOTOMETRIC_YCBCR) - { - TIFFSetField(output, TIFFTAG_JPEGCOLORMODE, - JPEGCOLORMODE_RGB); - } - else - { - TIFFSetField(output, TIFFTAG_JPEGCOLORMODE, - JPEGCOLORMODE_RAW); - } - } - if (t2p->pdf_colorspace & T2P_CS_GRAY) - { - (void)0; - } - if (t2p->pdf_colorspace & T2P_CS_CMYK) - { - (void)0; - } - if (t2p->pdf_defaultcompressionquality != 0) - { - TIFFSetField(output, TIFFTAG_JPEGQUALITY, - t2p->pdf_defaultcompressionquality); - } - - break; + if(t2p->pdf_colorspace & (T2P_CS_RGB | T2P_CS_LAB)){ + TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); + if(t2p->tiff_photometric != PHOTOMETRIC_YCBCR){ + TIFFSetField(output, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } else { + TIFFSetField(output, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RAW); + } + } + if(t2p->pdf_colorspace & T2P_CS_GRAY){ + (void)0; + } + if(t2p->pdf_colorspace & T2P_CS_CMYK){ + (void)0; + } + if(t2p->pdf_defaultcompressionquality != 0){ + TIFFSetField(output, + TIFFTAG_JPEGQUALITY, + t2p->pdf_defaultcompressionquality); + } + + break; #endif /* ifdef JPEG_SUPPORT */ #ifdef ZIP_SUPPORT - case T2P_COMPRESS_ZIP: - TIFFSetField(output, TIFFTAG_COMPRESSION, - COMPRESSION_ADOBE_DEFLATE); - if (t2p->pdf_defaultcompressionquality % 100 != 0) - { - TIFFSetField(output, TIFFTAG_PREDICTOR, - t2p->pdf_defaultcompressionquality % 100); - } - if (t2p->pdf_defaultcompressionquality / 100 != 0) - { - TIFFSetField(output, TIFFTAG_ZIPQUALITY, - (t2p->pdf_defaultcompressionquality / 100)); - } - break; + case T2P_COMPRESS_ZIP: + TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); + if(t2p->pdf_defaultcompressionquality%100 != 0){ + TIFFSetField(output, + TIFFTAG_PREDICTOR, + t2p->pdf_defaultcompressionquality % 100); + } + if(t2p->pdf_defaultcompressionquality/100 != 0){ + TIFFSetField(output, + TIFFTAG_ZIPQUALITY, + (t2p->pdf_defaultcompressionquality / 100)); + } + break; #endif /* ifdef ZIP_SUPPORT */ - default: - break; - } + default: + break; + } - t2p_enable(output); - t2p->outputwritten = 0; + t2p_enable(output); + t2p->outputwritten = 0; #ifdef JPEG_SUPPORT - if (t2p->pdf_compression == T2P_COMPRESS_JPEG && - t2p->tiff_photometric == PHOTOMETRIC_YCBCR) - { - bufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t)0, buffer, - stripsize * stripcount); - } - else + if(t2p->pdf_compression == T2P_COMPRESS_JPEG + && t2p->tiff_photometric == PHOTOMETRIC_YCBCR){ + bufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t)0, + buffer, + stripsize * stripcount); + } else #endif /* ifdef JPEG_SUPPORT */ - { - bufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t)0, buffer, - t2p->tiff_datasize); - } - if (buffer != NULL) - { - _TIFFfree(buffer); - buffer = NULL; - } + { + bufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t)0, + buffer, + t2p->tiff_datasize); + } + if (buffer != NULL) { + _TIFFfree(buffer); + buffer=NULL; + } - if (bufferoffset == (tsize_t)-1) - { - TIFFError(TIFF2PDF_MODULE, - "Error writing encoded strip to output PDF %s", - TIFFFileName(output)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - - written = t2p->outputwritten; - return (written); + if (bufferoffset == (tsize_t)-1) { + TIFFError(TIFF2PDF_MODULE, + "Error writing encoded strip to output PDF %s", + TIFFFileName(output)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + + written = t2p->outputwritten; + return(written); } /* @@ -3121,1095 +2870,993 @@ dataready: * for the tile. It returns the amount written or zero on error. */ -tsize_t t2p_readwrite_pdf_image_tile(T2P *t2p, TIFF *input, TIFF *output, - ttile_t tile) -{ +tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_t tile){ - uint16_t edge = 0; - tsize_t written = 0; - unsigned char *buffer = NULL; - tsize_t bufferoffset = 0; - unsigned char *samplebuffer = NULL; - tsize_t samplebufferoffset = 0; - tsize_t read = 0; - uint16_t i = 0; - ttile_t tilecount = 0; - /* tsize_t tilesize=0; */ - ttile_t septilecount = 0; - tsize_t septilesize = 0; + uint16 edge=0; + tsize_t written=0; + unsigned char* buffer=NULL; + tsize_t bufferoffset=0; + unsigned char* samplebuffer=NULL; + tsize_t samplebufferoffset=0; + tsize_t read=0; + uint16 i=0; + ttile_t tilecount=0; + /* tsize_t tilesize=0; */ + ttile_t septilecount=0; + tsize_t septilesize=0; #ifdef JPEG_SUPPORT - unsigned char *jpt; - float *xfloatp; - uint32_t xuint32 = 0; + unsigned char* jpt; + float* xfloatp; + uint32 xuint32=0; #endif - /* Fail if prior error (in particular, can't trust tiff_datasize) */ - if (t2p->t2p_error != T2P_ERR_OK) - return (0); + /* Fail if prior error (in particular, can't trust tiff_datasize) */ + if (t2p->t2p_error != T2P_ERR_OK) + return(0); - edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile); - edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile); + edge |= t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile); + edge |= t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile); - if ((t2p->pdf_transcode == T2P_TRANSCODE_RAW) && - ((edge == 0) + if( (t2p->pdf_transcode == T2P_TRANSCODE_RAW) && ((edge == 0) #if defined(JPEG_SUPPORT) || defined(OJPEG_SUPPORT) - || (t2p->pdf_compression == T2P_COMPRESS_JPEG) + || (t2p->pdf_compression == T2P_COMPRESS_JPEG) #endif - )) - { + ) + ){ #ifdef CCITT_SUPPORT - if (t2p->pdf_compression == T2P_COMPRESS_G4) - { - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory " - "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - if (TIFFReadRawTile(input, tile, (tdata_t)buffer, - t2p->tiff_datasize) < 0) - { - TIFFError(TIFF2PDF_MODULE, "TIFFReadRawTile() failed"); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - if (t2p->tiff_fillorder == FILLORDER_LSB2MSB) - { - TIFFReverseBits(buffer, t2p->tiff_datasize); - } - t2pWriteFile(output, (tdata_t)buffer, t2p->tiff_datasize); - _TIFFfree(buffer); - return (t2p->tiff_datasize); - } + if(t2p->pdf_compression == T2P_COMPRESS_G4){ + buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory " + "for t2p_readwrite_pdf_image_tile, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + if (TIFFReadRawTile(input, tile, (tdata_t) buffer, t2p->tiff_datasize) < 0) { + TIFFError(TIFF2PDF_MODULE, + "TIFFReadRawTile() failed"); + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + if (t2p->tiff_fillorder==FILLORDER_LSB2MSB){ + TIFFReverseBits(buffer, t2p->tiff_datasize); + } + t2pWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize); + _TIFFfree(buffer); + return(t2p->tiff_datasize); + } #endif #ifdef ZIP_SUPPORT - if (t2p->pdf_compression == T2P_COMPRESS_ZIP) - { - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory " - "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - if (TIFFReadRawTile(input, tile, (tdata_t)buffer, - t2p->tiff_datasize) < 0) - { - TIFFError(TIFF2PDF_MODULE, "TIFFReadRawTile() failed"); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - if (t2p->tiff_fillorder == FILLORDER_LSB2MSB) - { - TIFFReverseBits(buffer, t2p->tiff_datasize); - } - t2pWriteFile(output, (tdata_t)buffer, t2p->tiff_datasize); - _TIFFfree(buffer); - return (t2p->tiff_datasize); - } + if(t2p->pdf_compression == T2P_COMPRESS_ZIP){ + buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory " + "for t2p_readwrite_pdf_image_tile, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + if (TIFFReadRawTile(input, tile, (tdata_t) buffer, t2p->tiff_datasize) < 0) { + TIFFError(TIFF2PDF_MODULE, + "TIFFReadRawTile() failed"); + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + if (t2p->tiff_fillorder==FILLORDER_LSB2MSB){ + TIFFReverseBits(buffer, t2p->tiff_datasize); + } + t2pWriteFile(output, (tdata_t) buffer, t2p->tiff_datasize); + _TIFFfree(buffer); + return(t2p->tiff_datasize); + } #endif #ifdef OJPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_OJPEG) - { - tsize_t retTIFFReadRawTile; - if (!t2p->pdf_ojpegdata) - { - TIFFError(TIFF2PDF_MODULE, - "No support for OJPEG image %s with " - "bad tables", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory " - "for t2p_readwrite_pdf_image, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - _TIFFmemcpy(buffer, t2p->pdf_ojpegdata, t2p->pdf_ojpegdatalength); - if (edge != 0) - { - if (t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], - tile)) - { - buffer[7] = - (t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength >> - 8) & - 0xff; - buffer[8] = - (t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength) & - 0xff; - } - if (t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], - tile)) - { - buffer[9] = - (t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth >> - 8) & - 0xff; - buffer[10] = - (t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth) & - 0xff; - } - } - bufferoffset = t2p->pdf_ojpegdatalength; - retTIFFReadRawTile = TIFFReadRawTile( - input, tile, - (tdata_t) & (((unsigned char *)buffer)[bufferoffset]), -1); - if (retTIFFReadRawTile < 0) - { - TIFFError(TIFF2PDF_MODULE, "TIFFReadRawTile() failed"); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - bufferoffset += retTIFFReadRawTile; - t2pWriteFile(output, (tdata_t)buffer, bufferoffset); - t2pWriteFile(output, (tdata_t)jpeg_eof_marker, - sizeof(jpeg_eof_marker)); - _TIFFfree(buffer); - return (bufferoffset); - } + if(t2p->tiff_compression == COMPRESSION_OJPEG){ + tsize_t retTIFFReadRawTile; + if(! t2p->pdf_ojpegdata){ + TIFFError(TIFF2PDF_MODULE, + "No support for OJPEG image %s with " + "bad tables", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + buffer=(unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory " + "for t2p_readwrite_pdf_image, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + _TIFFmemcpy(buffer, t2p->pdf_ojpegdata, t2p->pdf_ojpegdatalength); + if(edge!=0){ + if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile)){ + buffer[7]= + (t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength >> 8) & 0xff; + buffer[8]= + (t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength ) & 0xff; + } + if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile)){ + buffer[9]= + (t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth >> 8) & 0xff; + buffer[10]= + (t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth ) & 0xff; + } + } + bufferoffset = t2p->pdf_ojpegdatalength; + retTIFFReadRawTile = TIFFReadRawTile(input, + tile, + (tdata_t) &(((unsigned char*)buffer)[bufferoffset]), + -1); + if (retTIFFReadRawTile < 0) { + TIFFError(TIFF2PDF_MODULE, "TIFFReadRawTile() failed"); + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + bufferoffset += retTIFFReadRawTile; + t2pWriteFile(output, (tdata_t) buffer, bufferoffset); + t2pWriteFile(output, (tdata_t) jpeg_eof_marker, sizeof(jpeg_eof_marker)); + _TIFFfree(buffer); + return(bufferoffset); + } #endif #ifdef JPEG_SUPPORT - if (t2p->tiff_compression == COMPRESSION_JPEG) - { - unsigned char table_end[2]; - uint32_t count = 0; - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory " - "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - if (TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) - { - if (count > 4) - { - tsize_t retTIFFReadRawTile; + if(t2p->tiff_compression == COMPRESSION_JPEG){ + unsigned char table_end[2]; + uint32 count = 0; + buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate " TIFF_SIZE_FORMAT " bytes of memory " + "for t2p_readwrite_pdf_image_tile, %s", + (TIFF_SIZE_T) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + if(TIFFGetField(input, TIFFTAG_JPEGTABLES, &count, &jpt) != 0) { + if (count > 4) { + tsize_t retTIFFReadRawTile; /* Ignore EOI marker of JpegTables */ - _TIFFmemcpy(buffer, jpt, count - 2); - bufferoffset += count - 2; + _TIFFmemcpy(buffer, jpt, count - 2); + bufferoffset += count - 2; /* Store last 2 bytes of the JpegTables */ - table_end[0] = buffer[bufferoffset - 2]; - table_end[1] = buffer[bufferoffset - 1]; - xuint32 = bufferoffset; - bufferoffset -= 2; - retTIFFReadRawTile = TIFFReadRawTile( - input, tile, - (tdata_t) & (((unsigned char *)buffer)[bufferoffset]), - -1); - if (retTIFFReadRawTile < 0) - { - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - bufferoffset += retTIFFReadRawTile; + table_end[0] = buffer[bufferoffset-2]; + table_end[1] = buffer[bufferoffset-1]; + xuint32 = bufferoffset; + bufferoffset -= 2; + retTIFFReadRawTile = TIFFReadRawTile( + input, + tile, + (tdata_t) &(((unsigned char*)buffer)[bufferoffset]), + -1); + if( retTIFFReadRawTile < 0 ) + { + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + bufferoffset += retTIFFReadRawTile; /* Overwrite SOI marker of image scan with previously */ /* saved end of JpegTables */ - buffer[xuint32 - 2] = table_end[0]; - buffer[xuint32 - 1] = table_end[1]; - } - } - t2pWriteFile(output, (tdata_t)buffer, bufferoffset); - _TIFFfree(buffer); - return (bufferoffset); - } + buffer[xuint32-2]=table_end[0]; + buffer[xuint32-1]=table_end[1]; + } + } + t2pWriteFile(output, (tdata_t) buffer, bufferoffset); + _TIFFfree(buffer); + return(bufferoffset); + } #endif - (void)0; - } + (void)0; + } - if (t2p->pdf_sample == T2P_SAMPLE_NOTHING) - { - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory for " - "t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); + if(t2p->pdf_sample==T2P_SAMPLE_NOTHING){ + buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory for " + "t2p_readwrite_pdf_image_tile, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); - read = TIFFReadEncodedTile(input, tile, (tdata_t)&buffer[bufferoffset], - t2p->tiff_datasize); - if (read == -1) - { - TIFFError(TIFF2PDF_MODULE, - "Error on decoding tile %" PRIu32 " of %s", tile, - TIFFFileName(input)); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - } - else - { + read = TIFFReadEncodedTile( + input, + tile, + (tdata_t) &buffer[bufferoffset], + t2p->tiff_datasize); + if(read==-1){ + TIFFError(TIFF2PDF_MODULE, + "Error on decoding tile %u of %s", + tile, + TIFFFileName(input)); + _TIFFfree(buffer); + t2p->t2p_error=T2P_ERR_ERROR; + return(0); + } - if (t2p->pdf_sample == T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG) - { - septilesize = TIFFTileSize(input); - septilecount = TIFFNumberOfTiles(input); - /* tilesize=septilesize*t2p->tiff_samplesperpixel; */ - tilecount = septilecount / t2p->tiff_samplesperpixel; - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory " - "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - samplebuffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (samplebuffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory " - "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, TIFFFileName(input)); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(samplebuffer, 0, t2p->tiff_datasize); - samplebufferoffset = 0; - for (i = 0; i < t2p->tiff_samplesperpixel; i++) - { - read = TIFFReadEncodedTile( - input, tile + i * tilecount, - (tdata_t) & (samplebuffer[samplebufferoffset]), - septilesize); - if (read == -1) - { - TIFFError(TIFF2PDF_MODULE, - "Error on decoding tile %" PRIu32 " of %s", - tile + i * tilecount, TIFFFileName(input)); - _TIFFfree(samplebuffer); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - samplebufferoffset += read; - } - t2p_sample_planar_separate_to_contig( - t2p, &(buffer[bufferoffset]), samplebuffer, samplebufferoffset); - bufferoffset += samplebufferoffset; - _TIFFfree(samplebuffer); - } + } else { - if (buffer == NULL) - { - buffer = (unsigned char *)_TIFFmalloc(t2p->tiff_datasize); - if (buffer == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SSIZE_FORMAT - " bytes of memory " - "for t2p_readwrite_pdf_image_tile, %s", - t2p->tiff_datasize, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - memset(buffer, 0, t2p->tiff_datasize); - read = - TIFFReadEncodedTile(input, tile, (tdata_t)&buffer[bufferoffset], - t2p->tiff_datasize); - if (read == -1) - { - TIFFError(TIFF2PDF_MODULE, - "Error on decoding tile %" PRIu32 " of %s", tile, - TIFFFileName(input)); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - } + if(t2p->pdf_sample == T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG){ + septilesize=TIFFTileSize(input); + septilecount=TIFFNumberOfTiles(input); + /* tilesize=septilesize*t2p->tiff_samplesperpixel; */ + tilecount=septilecount/t2p->tiff_samplesperpixel; + buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory " + "for t2p_readwrite_pdf_image_tile, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + samplebuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(samplebuffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory " + "for t2p_readwrite_pdf_image_tile, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(samplebuffer, 0, t2p->tiff_datasize); + samplebufferoffset=0; + for(i=0;itiff_samplesperpixel;i++){ + read = + TIFFReadEncodedTile(input, + tile + i*tilecount, + (tdata_t) &(samplebuffer[samplebufferoffset]), + septilesize); + if(read==-1){ + TIFFError(TIFF2PDF_MODULE, + "Error on decoding tile %u of %s", + tile + i*tilecount, + TIFFFileName(input)); + _TIFFfree(samplebuffer); + _TIFFfree(buffer); + t2p->t2p_error=T2P_ERR_ERROR; + return(0); + } + samplebufferoffset+=read; + } + t2p_sample_planar_separate_to_contig( + t2p, + &(buffer[bufferoffset]), + samplebuffer, + samplebufferoffset); + bufferoffset+=samplebufferoffset; + _TIFFfree(samplebuffer); + } - if (t2p->pdf_sample & T2P_SAMPLE_RGBA_TO_RGB) - { - t2p->tiff_datasize = t2p_sample_rgba_to_rgb( - (tdata_t)buffer, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth * - t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); - } + if(buffer==NULL){ + buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); + if(buffer==NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %lu bytes of memory " + "for t2p_readwrite_pdf_image_tile, %s", + (unsigned long) t2p->tiff_datasize, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + memset(buffer, 0, t2p->tiff_datasize); + read = TIFFReadEncodedTile( + input, + tile, + (tdata_t) &buffer[bufferoffset], + t2p->tiff_datasize); + if(read==-1){ + TIFFError(TIFF2PDF_MODULE, + "Error on decoding tile %u of %s", + tile, + TIFFFileName(input)); + _TIFFfree(buffer); + t2p->t2p_error=T2P_ERR_ERROR; + return(0); + } + } - if (t2p->pdf_sample & T2P_SAMPLE_RGBAA_TO_RGB) - { - t2p->tiff_datasize = t2p_sample_rgbaa_to_rgb( - (tdata_t)buffer, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth * - t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); - } + if(t2p->pdf_sample & T2P_SAMPLE_RGBA_TO_RGB){ + t2p->tiff_datasize=t2p_sample_rgba_to_rgb( + (tdata_t)buffer, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth + *t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + } - if (t2p->pdf_sample & T2P_SAMPLE_YCBCR_TO_RGB) - { - TIFFError(TIFF2PDF_MODULE, - "No support for YCbCr to RGB in tile for %s", - TIFFFileName(input)); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } + if(t2p->pdf_sample & T2P_SAMPLE_RGBAA_TO_RGB){ + t2p->tiff_datasize=t2p_sample_rgbaa_to_rgb( + (tdata_t)buffer, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth + *t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + } - if (t2p->pdf_sample & T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED) - { - t2p->tiff_datasize = t2p_sample_lab_signed_to_unsigned( - (tdata_t)buffer, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth * - t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); - } - } + if(t2p->pdf_sample & T2P_SAMPLE_YCBCR_TO_RGB){ + TIFFError(TIFF2PDF_MODULE, + "No support for YCbCr to RGB in tile for %s", + TIFFFileName(input)); + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } - if (t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile) != 0) - { - if ((uint64_t)t2p->tiff_datasize < - (uint64_t)TIFFTileRowSize(input) * - (uint64_t)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength) - { - /* we don't know how to handle PLANARCONFIG_CONTIG, - * PHOTOMETRIC_YCBCR with 3 samples per pixel */ - TIFFWarning(TIFF2PDF_MODULE, - "Don't know how to collapse tile to the left"); - } - else - { - t2p_tile_collapse_left( - buffer, TIFFTileRowSize(input), - t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth, - t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); - } - } + if(t2p->pdf_sample & T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED){ + t2p->tiff_datasize=t2p_sample_lab_signed_to_unsigned( + (tdata_t)buffer, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth + *t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + } + } - t2p_disable(output); - TIFFSetField(output, TIFFTAG_PHOTOMETRIC, t2p->tiff_photometric); - TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, t2p->tiff_bitspersample); - TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, t2p->tiff_samplesperpixel); - if (t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile) == 0) - { - TIFFSetField(output, TIFFTAG_IMAGEWIDTH, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); - } - else - { - TIFFSetField(output, TIFFTAG_IMAGEWIDTH, - t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); - } - if (t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile) == 0) - { - TIFFSetField(output, TIFFTAG_IMAGELENGTH, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); - TIFFSetField(output, TIFFTAG_ROWSPERSTRIP, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); - } - else - { - TIFFSetField(output, TIFFTAG_IMAGELENGTH, - t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); - TIFFSetField(output, TIFFTAG_ROWSPERSTRIP, - t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); - } - TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(output, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); + if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile) != 0){ + if ((uint64)t2p->tiff_datasize < (uint64)TIFFTileRowSize(input) * (uint64)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength) { + /* we don't know how to handle PLANARCONFIG_CONTIG, PHOTOMETRIC_YCBCR with 3 samples per pixel */ + TIFFWarning( + TIFF2PDF_MODULE, + "Don't know how to collapse tile to the left"); + } else { + t2p_tile_collapse_left( + buffer, + TIFFTileRowSize(input), + t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + } + } - switch (t2p->pdf_compression) - { - case T2P_COMPRESS_NONE: - TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_NONE); - break; + + t2p_disable(output); + TIFFSetField(output, TIFFTAG_PHOTOMETRIC, t2p->tiff_photometric); + TIFFSetField(output, TIFFTAG_BITSPERSAMPLE, t2p->tiff_bitspersample); + TIFFSetField(output, TIFFTAG_SAMPLESPERPIXEL, t2p->tiff_samplesperpixel); + if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile) == 0){ + TIFFSetField( + output, + TIFFTAG_IMAGEWIDTH, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); + } else { + TIFFSetField( + output, + TIFFTAG_IMAGEWIDTH, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); + } + if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile) == 0){ + TIFFSetField( + output, + TIFFTAG_IMAGELENGTH, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + TIFFSetField( + output, + TIFFTAG_ROWSPERSTRIP, + t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + } else { + TIFFSetField( + output, + TIFFTAG_IMAGELENGTH, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + TIFFSetField( + output, + TIFFTAG_ROWSPERSTRIP, + t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + } + TIFFSetField(output, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(output, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB); + + switch(t2p->pdf_compression){ + case T2P_COMPRESS_NONE: + TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_NONE); + break; #ifdef CCITT_SUPPORT - case T2P_COMPRESS_G4: - TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); - break; + case T2P_COMPRESS_G4: + TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); + break; #endif #ifdef JPEG_SUPPORT - case T2P_COMPRESS_JPEG: - if (t2p->tiff_photometric == PHOTOMETRIC_YCBCR) - { - uint16_t hor = 0, ver = 0; - if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver) != - 0) - { - if (hor != 0 && ver != 0) - { - TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, - ver); - } - } - if (TIFFGetField(input, TIFFTAG_REFERENCEBLACKWHITE, - &xfloatp) != 0) - { - TIFFSetField(output, TIFFTAG_REFERENCEBLACKWHITE, xfloatp); - } - } - TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); - TIFFSetField(output, TIFFTAG_JPEGTABLESMODE, - 0); /* JPEGTABLESMODE_NONE */ - if (t2p->pdf_colorspace & (T2P_CS_RGB | T2P_CS_LAB)) - { - TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); - if (t2p->tiff_photometric != PHOTOMETRIC_YCBCR) - { - TIFFSetField(output, TIFFTAG_JPEGCOLORMODE, - JPEGCOLORMODE_RGB); - } - else - { - TIFFSetField(output, TIFFTAG_JPEGCOLORMODE, - JPEGCOLORMODE_RAW); - } - } - if (t2p->pdf_colorspace & T2P_CS_GRAY) - { - (void)0; - } - if (t2p->pdf_colorspace & T2P_CS_CMYK) - { - (void)0; - } - if (t2p->pdf_defaultcompressionquality != 0) - { - TIFFSetField(output, TIFFTAG_JPEGQUALITY, - t2p->pdf_defaultcompressionquality); - } - break; + case T2P_COMPRESS_JPEG: + if (t2p->tiff_photometric==PHOTOMETRIC_YCBCR) { + uint16 hor = 0, ver = 0; + if (TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &hor, &ver)!=0) { + if (hor != 0 && ver != 0) { + TIFFSetField(output, TIFFTAG_YCBCRSUBSAMPLING, hor, ver); + } + } + if(TIFFGetField(input, TIFFTAG_REFERENCEBLACKWHITE, &xfloatp)!=0){ + TIFFSetField(output, TIFFTAG_REFERENCEBLACKWHITE, xfloatp); + } + } + TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); + TIFFSetField(output, TIFFTAG_JPEGTABLESMODE, 0); /* JPEGTABLESMODE_NONE */ + if(t2p->pdf_colorspace & (T2P_CS_RGB | T2P_CS_LAB)){ + TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); + if(t2p->tiff_photometric != PHOTOMETRIC_YCBCR){ + TIFFSetField(output, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } else { + TIFFSetField(output, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RAW); + } + } + if(t2p->pdf_colorspace & T2P_CS_GRAY){ + (void)0; + } + if(t2p->pdf_colorspace & T2P_CS_CMYK){ + (void)0; + } + if(t2p->pdf_defaultcompressionquality != 0){ + TIFFSetField(output, + TIFFTAG_JPEGQUALITY, + t2p->pdf_defaultcompressionquality); + } + break; #endif #ifdef ZIP_SUPPORT - case T2P_COMPRESS_ZIP: - TIFFSetField(output, TIFFTAG_COMPRESSION, - COMPRESSION_ADOBE_DEFLATE); - if (t2p->pdf_defaultcompressionquality % 100 != 0) - { - TIFFSetField(output, TIFFTAG_PREDICTOR, - t2p->pdf_defaultcompressionquality % 100); - } - if (t2p->pdf_defaultcompressionquality / 100 != 0) - { - TIFFSetField(output, TIFFTAG_ZIPQUALITY, - (t2p->pdf_defaultcompressionquality / 100)); - } - break; + case T2P_COMPRESS_ZIP: + TIFFSetField(output, TIFFTAG_COMPRESSION, COMPRESSION_DEFLATE); + if(t2p->pdf_defaultcompressionquality%100 != 0){ + TIFFSetField(output, + TIFFTAG_PREDICTOR, + t2p->pdf_defaultcompressionquality % 100); + } + if(t2p->pdf_defaultcompressionquality/100 != 0){ + TIFFSetField(output, + TIFFTAG_ZIPQUALITY, + (t2p->pdf_defaultcompressionquality / 100)); + } + break; #endif - default: - break; - } + default: + break; + } - if (TIFFStripSize(output) > t2p->tiff_datasize) - { - TIFFError(TIFF2PDF_MODULE, - "Size mismatch input %" PRId64 ", output %" PRId64, - (int64_t)t2p->tiff_datasize, (int64_t)TIFFStripSize(output)); - _TIFFfree(buffer); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - t2p_enable(output); - t2p->outputwritten = 0; - bufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t)0, buffer, - TIFFStripSize(output)); - if (buffer != NULL) - { - _TIFFfree(buffer); - buffer = NULL; - } - if (bufferoffset == -1) - { - TIFFError(TIFF2PDF_MODULE, - "Error writing encoded tile to output PDF %s", - TIFFFileName(output)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - - written = t2p->outputwritten; - - return (written); + if (TIFFStripSize(output) > t2p->tiff_datasize) { + TIFFError(TIFF2PDF_MODULE, + "Size mismatch input " TIFF_SSIZE_FORMAT ", output " TIFF_SSIZE_FORMAT, + t2p->tiff_datasize, TIFFStripSize(output)); + _TIFFfree(buffer); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + t2p_enable(output); + t2p->outputwritten = 0; + bufferoffset = TIFFWriteEncodedStrip(output, (tstrip_t) 0, buffer, + TIFFStripSize(output)); + if (buffer != NULL) { + _TIFFfree(buffer); + buffer = NULL; + } + if (bufferoffset == -1) { + TIFFError(TIFF2PDF_MODULE, + "Error writing encoded tile to output PDF %s", + TIFFFileName(output)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + + written = t2p->outputwritten; + + return(written); } #ifdef OJPEG_SUPPORT -int t2p_process_ojpeg_tables(T2P *t2p, TIFF *input) -{ - uint16_t proc = 0; - void *q; - uint32_t q_length = 0; - void *dc; - uint32_t dc_length = 0; - void *ac; - uint32_t ac_length = 0; - uint16_t *lp; - uint16_t *pt; - uint16_t h_samp = 1; - uint16_t v_samp = 1; - unsigned char *ojpegdata; - uint16_t table_count; - uint32_t offset_table; - uint32_t offset_ms_l; - uint32_t code_count; - uint32_t i = 0; - uint32_t dest = 0; - uint16_t ri = 0; - uint32_t rows = 0; +int t2p_process_ojpeg_tables(T2P* t2p, TIFF* input){ + uint16 proc=0; + void* q; + uint32 q_length=0; + void* dc; + uint32 dc_length=0; + void* ac; + uint32 ac_length=0; + uint16* lp; + uint16* pt; + uint16 h_samp=1; + uint16 v_samp=1; + unsigned char* ojpegdata; + uint16 table_count; + uint32 offset_table; + uint32 offset_ms_l; + uint32 code_count; + uint32 i=0; + uint32 dest=0; + uint16 ri=0; + uint32 rows=0; + + if(!TIFFGetField(input, TIFFTAG_JPEGPROC, &proc)){ + TIFFError(TIFF2PDF_MODULE, + "Missing JPEGProc field in OJPEG image %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + if(proc!=JPEGPROC_BASELINE && proc!=JPEGPROC_LOSSLESS){ + TIFFError(TIFF2PDF_MODULE, + "Bad JPEGProc field in OJPEG image %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + if(!TIFFGetField(input, TIFFTAG_JPEGQTABLES, &q_length, &q)){ + TIFFError(TIFF2PDF_MODULE, + "Missing JPEGQTables field in OJPEG image %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + if(q_length < (64U * t2p->tiff_samplesperpixel)){ + TIFFError(TIFF2PDF_MODULE, + "Bad JPEGQTables field in OJPEG image %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + if(!TIFFGetField(input, TIFFTAG_JPEGDCTABLES, &dc_length, &dc)){ + TIFFError(TIFF2PDF_MODULE, + "Missing JPEGDCTables field in OJPEG image %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + if(proc==JPEGPROC_BASELINE){ + if(!TIFFGetField(input, TIFFTAG_JPEGACTABLES, &ac_length, &ac)){ + TIFFError(TIFF2PDF_MODULE, + "Missing JPEGACTables field in OJPEG image %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + } else { + if(!TIFFGetField(input, TIFFTAG_JPEGLOSSLESSPREDICTORS, &lp)){ + TIFFError(TIFF2PDF_MODULE, + "Missing JPEGLosslessPredictors field in OJPEG image %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + if(!TIFFGetField(input, TIFFTAG_JPEGPOINTTRANSFORM, &pt)){ + TIFFError(TIFF2PDF_MODULE, + "Missing JPEGPointTransform field in OJPEG image %s", + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + } + if(!TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &h_samp, &v_samp)){ + h_samp=1; + v_samp=1; + } + if(t2p->pdf_ojpegdata != NULL){ + _TIFFfree(t2p->pdf_ojpegdata); + t2p->pdf_ojpegdata=NULL; + } + t2p->pdf_ojpegdata = _TIFFmalloc(2048); + if(t2p->pdf_ojpegdata == NULL){ + TIFFError(TIFF2PDF_MODULE, + "Can't allocate %u bytes of memory for t2p_process_ojpeg_tables, %s", + 2048, + TIFFFileName(input)); + t2p->t2p_error = T2P_ERR_ERROR; + return(0); + } + _TIFFmemset(t2p->pdf_ojpegdata, 0x00, 2048); + t2p->pdf_ojpegdatalength = 0; + table_count=t2p->tiff_samplesperpixel; + if(proc==JPEGPROC_BASELINE){ + if(table_count>2) table_count=2; + } + ojpegdata=(unsigned char*)t2p->pdf_ojpegdata; + ojpegdata[t2p->pdf_ojpegdatalength++]=0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]=0xd8; + ojpegdata[t2p->pdf_ojpegdatalength++]=0xff; + if(proc==JPEGPROC_BASELINE){ + ojpegdata[t2p->pdf_ojpegdatalength++]=0xc0; + } else { + ojpegdata[t2p->pdf_ojpegdatalength++]=0xc3; + } + ojpegdata[t2p->pdf_ojpegdatalength++]=0x00; + ojpegdata[t2p->pdf_ojpegdatalength++]=(8 + 3*t2p->tiff_samplesperpixel); + ojpegdata[t2p->pdf_ojpegdatalength++]=(t2p->tiff_bitspersample & 0xff); + if(TIFFIsTiled(input)){ + ojpegdata[t2p->pdf_ojpegdatalength++]= + (t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength >> 8) & 0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]= + (t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength ) & 0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]= + (t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth >> 8) & 0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]= + (t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth ) & 0xff; + } else { + ojpegdata[t2p->pdf_ojpegdatalength++]= + (t2p->tiff_length >> 8) & 0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]= + (t2p->tiff_length ) & 0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]= + (t2p->tiff_width >> 8) & 0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]= + (t2p->tiff_width ) & 0xff; + } + ojpegdata[t2p->pdf_ojpegdatalength++]=(t2p->tiff_samplesperpixel & 0xff); + for(i=0;itiff_samplesperpixel;i++){ + ojpegdata[t2p->pdf_ojpegdatalength++]=i; + if(i==0){ + ojpegdata[t2p->pdf_ojpegdatalength] |= h_samp<<4 & 0xf0;; + ojpegdata[t2p->pdf_ojpegdatalength++] |= v_samp & 0x0f; + } else { + ojpegdata[t2p->pdf_ojpegdatalength++]= 0x11; + } + ojpegdata[t2p->pdf_ojpegdatalength++]=i; + } + for(dest=0;desttiff_samplesperpixel;dest++){ + ojpegdata[t2p->pdf_ojpegdatalength++]=0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]=0xdb; + ojpegdata[t2p->pdf_ojpegdatalength++]=0x00; + ojpegdata[t2p->pdf_ojpegdatalength++]=0x43; + ojpegdata[t2p->pdf_ojpegdatalength++]=dest; + _TIFFmemcpy( &(ojpegdata[t2p->pdf_ojpegdatalength++]), + &(((unsigned char*)q)[64*dest]), 64); + t2p->pdf_ojpegdatalength+=64; + } + offset_table=0; + for(dest=0;destpdf_ojpegdatalength++]=0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]=0xc4; + offset_ms_l=t2p->pdf_ojpegdatalength; + t2p->pdf_ojpegdatalength+=2; + ojpegdata[t2p->pdf_ojpegdatalength++]=dest & 0x0f; + _TIFFmemcpy( &(ojpegdata[t2p->pdf_ojpegdatalength]), + &(((unsigned char*)dc)[offset_table]), 16); + code_count=0; + offset_table+=16; + for(i=0;i<16;i++){ + code_count+=ojpegdata[t2p->pdf_ojpegdatalength++]; + } + ojpegdata[offset_ms_l]=((19+code_count)>>8) & 0xff; + ojpegdata[offset_ms_l+1]=(19+code_count) & 0xff; + _TIFFmemcpy( &(ojpegdata[t2p->pdf_ojpegdatalength]), + &(((unsigned char*)dc)[offset_table]), code_count); + offset_table+=code_count; + t2p->pdf_ojpegdatalength+=code_count; + } + if(proc==JPEGPROC_BASELINE){ + offset_table=0; + for(dest=0;destpdf_ojpegdatalength++]=0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]=0xc4; + offset_ms_l=t2p->pdf_ojpegdatalength; + t2p->pdf_ojpegdatalength+=2; + ojpegdata[t2p->pdf_ojpegdatalength] |= 0x10; + ojpegdata[t2p->pdf_ojpegdatalength++] |=dest & 0x0f; + _TIFFmemcpy( &(ojpegdata[t2p->pdf_ojpegdatalength]), + &(((unsigned char*)ac)[offset_table]), 16); + code_count=0; + offset_table+=16; + for(i=0;i<16;i++){ + code_count+=ojpegdata[t2p->pdf_ojpegdatalength++]; + } + ojpegdata[offset_ms_l]=((19+code_count)>>8) & 0xff; + ojpegdata[offset_ms_l+1]=(19+code_count) & 0xff; + _TIFFmemcpy( &(ojpegdata[t2p->pdf_ojpegdatalength]), + &(((unsigned char*)ac)[offset_table]), code_count); + offset_table+=code_count; + t2p->pdf_ojpegdatalength+=code_count; + } + } + if(TIFFNumberOfStrips(input)>1){ + ojpegdata[t2p->pdf_ojpegdatalength++]=0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]=0xdd; + ojpegdata[t2p->pdf_ojpegdatalength++]=0x00; + ojpegdata[t2p->pdf_ojpegdatalength++]=0x04; + h_samp*=8; + v_samp*=8; + ri=(t2p->tiff_width+h_samp-1) / h_samp; + TIFFGetField(input, TIFFTAG_ROWSPERSTRIP, &rows); + ri*=(rows+v_samp-1)/v_samp; + ojpegdata[t2p->pdf_ojpegdatalength++]= (ri>>8) & 0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]= ri & 0xff; + } + ojpegdata[t2p->pdf_ojpegdatalength++]=0xff; + ojpegdata[t2p->pdf_ojpegdatalength++]=0xda; + ojpegdata[t2p->pdf_ojpegdatalength++]=0x00; + ojpegdata[t2p->pdf_ojpegdatalength++]=(6 + 2*t2p->tiff_samplesperpixel); + ojpegdata[t2p->pdf_ojpegdatalength++]=t2p->tiff_samplesperpixel & 0xff; + for(i=0;itiff_samplesperpixel;i++){ + ojpegdata[t2p->pdf_ojpegdatalength++]= i & 0xff; + if(proc==JPEGPROC_BASELINE){ + ojpegdata[t2p->pdf_ojpegdatalength] |= + ( ( (i>(table_count-1U)) ? (table_count-1U) : i) << 4U) & 0xf0; + ojpegdata[t2p->pdf_ojpegdatalength++] |= + ( (i>(table_count-1U)) ? (table_count-1U) : i) & 0x0f; + } else { + ojpegdata[t2p->pdf_ojpegdatalength++] = (i << 4) & 0xf0; + } + } + if(proc==JPEGPROC_BASELINE){ + t2p->pdf_ojpegdatalength++; + ojpegdata[t2p->pdf_ojpegdatalength++]=0x3f; + t2p->pdf_ojpegdatalength++; + } else { + ojpegdata[t2p->pdf_ojpegdatalength++]= (lp[0] & 0xff); + t2p->pdf_ojpegdatalength++; + ojpegdata[t2p->pdf_ojpegdatalength++]= (pt[0] & 0x0f); + } - if (!TIFFGetField(input, TIFFTAG_JPEGPROC, &proc)) - { - TIFFError(TIFF2PDF_MODULE, "Missing JPEGProc field in OJPEG image %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - if (proc != JPEGPROC_BASELINE && proc != JPEGPROC_LOSSLESS) - { - TIFFError(TIFF2PDF_MODULE, "Bad JPEGProc field in OJPEG image %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - if (!TIFFGetField(input, TIFFTAG_JPEGQTABLES, &q_length, &q)) - { - TIFFError(TIFF2PDF_MODULE, - "Missing JPEGQTables field in OJPEG image %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - if (q_length < (64U * t2p->tiff_samplesperpixel)) - { - TIFFError(TIFF2PDF_MODULE, "Bad JPEGQTables field in OJPEG image %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - if (!TIFFGetField(input, TIFFTAG_JPEGDCTABLES, &dc_length, &dc)) - { - TIFFError(TIFF2PDF_MODULE, - "Missing JPEGDCTables field in OJPEG image %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - if (proc == JPEGPROC_BASELINE) - { - if (!TIFFGetField(input, TIFFTAG_JPEGACTABLES, &ac_length, &ac)) - { - TIFFError(TIFF2PDF_MODULE, - "Missing JPEGACTables field in OJPEG image %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - } - else - { - if (!TIFFGetField(input, TIFFTAG_JPEGLOSSLESSPREDICTORS, &lp)) - { - TIFFError(TIFF2PDF_MODULE, - "Missing JPEGLosslessPredictors field in OJPEG image %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - if (!TIFFGetField(input, TIFFTAG_JPEGPOINTTRANSFORM, &pt)) - { - TIFFError(TIFF2PDF_MODULE, - "Missing JPEGPointTransform field in OJPEG image %s", - TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - } - if (!TIFFGetField(input, TIFFTAG_YCBCRSUBSAMPLING, &h_samp, &v_samp)) - { - h_samp = 1; - v_samp = 1; - } - if (t2p->pdf_ojpegdata != NULL) - { - _TIFFfree(t2p->pdf_ojpegdata); - t2p->pdf_ojpegdata = NULL; - } - t2p->pdf_ojpegdata = _TIFFmalloc(2048); - if (t2p->pdf_ojpegdata == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %u bytes of memory for " - "t2p_process_ojpeg_tables, %s", - 2048u, TIFFFileName(input)); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - _TIFFmemset(t2p->pdf_ojpegdata, 0x00, 2048); - t2p->pdf_ojpegdatalength = 0; - table_count = t2p->tiff_samplesperpixel; - if (proc == JPEGPROC_BASELINE) - { - if (table_count > 2) - table_count = 2; - } - ojpegdata = (unsigned char *)t2p->pdf_ojpegdata; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xd8; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xff; - if (proc == JPEGPROC_BASELINE) - { - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xc0; - } - else - { - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xc3; - } - ojpegdata[t2p->pdf_ojpegdatalength++] = 0x00; - ojpegdata[t2p->pdf_ojpegdatalength++] = (8 + 3 * t2p->tiff_samplesperpixel); - ojpegdata[t2p->pdf_ojpegdatalength++] = (t2p->tiff_bitspersample & 0xff); - if (TIFFIsTiled(input)) - { - ojpegdata[t2p->pdf_ojpegdatalength++] = - (t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength >> 8) & 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = - (t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength) & 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = - (t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth >> 8) & 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = - (t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth) & 0xff; - } - else - { - ojpegdata[t2p->pdf_ojpegdatalength++] = (t2p->tiff_length >> 8) & 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = (t2p->tiff_length) & 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = (t2p->tiff_width >> 8) & 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = (t2p->tiff_width) & 0xff; - } - ojpegdata[t2p->pdf_ojpegdatalength++] = (t2p->tiff_samplesperpixel & 0xff); - for (i = 0; i < t2p->tiff_samplesperpixel; i++) - { - ojpegdata[t2p->pdf_ojpegdatalength++] = i; - if (i == 0) - { - ojpegdata[t2p->pdf_ojpegdatalength] |= h_samp << 4 & 0xf0; - ; - ojpegdata[t2p->pdf_ojpegdatalength++] |= v_samp & 0x0f; - } - else - { - ojpegdata[t2p->pdf_ojpegdatalength++] = 0x11; - } - ojpegdata[t2p->pdf_ojpegdatalength++] = i; - } - for (dest = 0; dest < t2p->tiff_samplesperpixel; dest++) - { - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xdb; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0x00; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0x43; - ojpegdata[t2p->pdf_ojpegdatalength++] = dest; - _TIFFmemcpy(&(ojpegdata[t2p->pdf_ojpegdatalength++]), - &(((unsigned char *)q)[64 * dest]), 64); - t2p->pdf_ojpegdatalength += 64; - } - offset_table = 0; - for (dest = 0; dest < table_count; dest++) - { - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xc4; - offset_ms_l = t2p->pdf_ojpegdatalength; - t2p->pdf_ojpegdatalength += 2; - ojpegdata[t2p->pdf_ojpegdatalength++] = dest & 0x0f; - _TIFFmemcpy(&(ojpegdata[t2p->pdf_ojpegdatalength]), - &(((unsigned char *)dc)[offset_table]), 16); - code_count = 0; - offset_table += 16; - for (i = 0; i < 16; i++) - { - code_count += ojpegdata[t2p->pdf_ojpegdatalength++]; - } - ojpegdata[offset_ms_l] = ((19 + code_count) >> 8) & 0xff; - ojpegdata[offset_ms_l + 1] = (19 + code_count) & 0xff; - _TIFFmemcpy(&(ojpegdata[t2p->pdf_ojpegdatalength]), - &(((unsigned char *)dc)[offset_table]), code_count); - offset_table += code_count; - t2p->pdf_ojpegdatalength += code_count; - } - if (proc == JPEGPROC_BASELINE) - { - offset_table = 0; - for (dest = 0; dest < table_count; dest++) - { - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xc4; - offset_ms_l = t2p->pdf_ojpegdatalength; - t2p->pdf_ojpegdatalength += 2; - ojpegdata[t2p->pdf_ojpegdatalength] |= 0x10; - ojpegdata[t2p->pdf_ojpegdatalength++] |= dest & 0x0f; - _TIFFmemcpy(&(ojpegdata[t2p->pdf_ojpegdatalength]), - &(((unsigned char *)ac)[offset_table]), 16); - code_count = 0; - offset_table += 16; - for (i = 0; i < 16; i++) - { - code_count += ojpegdata[t2p->pdf_ojpegdatalength++]; - } - ojpegdata[offset_ms_l] = ((19 + code_count) >> 8) & 0xff; - ojpegdata[offset_ms_l + 1] = (19 + code_count) & 0xff; - _TIFFmemcpy(&(ojpegdata[t2p->pdf_ojpegdatalength]), - &(((unsigned char *)ac)[offset_table]), code_count); - offset_table += code_count; - t2p->pdf_ojpegdatalength += code_count; - } - } - if (TIFFNumberOfStrips(input) > 1) - { - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xdd; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0x00; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0x04; - h_samp *= 8; - v_samp *= 8; - ri = (t2p->tiff_width + h_samp - 1) / h_samp; - TIFFGetField(input, TIFFTAG_ROWSPERSTRIP, &rows); - ri *= (rows + v_samp - 1) / v_samp; - ojpegdata[t2p->pdf_ojpegdatalength++] = (ri >> 8) & 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = ri & 0xff; - } - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xff; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0xda; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0x00; - ojpegdata[t2p->pdf_ojpegdatalength++] = (6 + 2 * t2p->tiff_samplesperpixel); - ojpegdata[t2p->pdf_ojpegdatalength++] = t2p->tiff_samplesperpixel & 0xff; - for (i = 0; i < t2p->tiff_samplesperpixel; i++) - { - ojpegdata[t2p->pdf_ojpegdatalength++] = i & 0xff; - if (proc == JPEGPROC_BASELINE) - { - ojpegdata[t2p->pdf_ojpegdatalength] |= - (((i > (table_count - 1U)) ? (table_count - 1U) : i) << 4U) & - 0xf0; - ojpegdata[t2p->pdf_ojpegdatalength++] |= - ((i > (table_count - 1U)) ? (table_count - 1U) : i) & 0x0f; - } - else - { - ojpegdata[t2p->pdf_ojpegdatalength++] = (i << 4) & 0xf0; - } - } - if (proc == JPEGPROC_BASELINE) - { - t2p->pdf_ojpegdatalength++; - ojpegdata[t2p->pdf_ojpegdatalength++] = 0x3f; - t2p->pdf_ojpegdatalength++; - } - else - { - ojpegdata[t2p->pdf_ojpegdatalength++] = (lp[0] & 0xff); - t2p->pdf_ojpegdatalength++; - ojpegdata[t2p->pdf_ojpegdatalength++] = (pt[0] & 0x0f); - } - - return (1); + return(1); } #endif #ifdef JPEG_SUPPORT -int t2p_process_jpeg_strip(unsigned char *strip, tsize_t *striplength, - unsigned char *buffer, tsize_t buffersize, - tsize_t *bufferoffset, tstrip_t no, uint32_t height) -{ +int t2p_process_jpeg_strip( + unsigned char* strip, + tsize_t* striplength, + unsigned char* buffer, + tsize_t buffersize, + tsize_t* bufferoffset, + tstrip_t no, + uint32 height){ - tsize_t i = 0; + tsize_t i=0; - while (i < *striplength) - { - tsize_t datalen; - uint16_t ri; - uint16_t v_samp; - uint16_t h_samp; - int j; - int ncomp; + while (i < *striplength) { + tsize_t datalen; + uint16 ri; + uint16 v_samp; + uint16 h_samp; + int j; + int ncomp; - /* marker header: one or more FFs */ - if (strip[i] != 0xff) - return (0); - i++; - while (i < *striplength && strip[i] == 0xff) - i++; - if (i >= *striplength) - return (0); - /* SOI is the only pre-SOS marker without a length word */ - if (strip[i] == 0xd8) - datalen = 0; - else - { - if ((*striplength - i) <= 2) - return (0); - datalen = (strip[i + 1] << 8) | strip[i + 2]; - if (datalen < 2 || datalen >= (*striplength - i)) - return (0); - } - switch (strip[i]) - { - case 0xd8: /* SOI - start of image */ - if (*bufferoffset + 2 > buffersize) - return (0); - _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i - 1]), 2); - *bufferoffset += 2; - break; - case 0xc0: /* SOF0 */ - case 0xc1: /* SOF1 */ - case 0xc3: /* SOF3 */ - case 0xc9: /* SOF9 */ - case 0xca: /* SOF10 */ - if (no == 0) - { - if (*bufferoffset + datalen + 2 + 6 > buffersize) - return (0); - _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i - 1]), - datalen + 2); - if (*bufferoffset + 9 >= buffersize) - return (0); - ncomp = buffer[*bufferoffset + 9]; - if (ncomp < 1 || ncomp > 4) - return (0); - v_samp = 1; - h_samp = 1; - if (*bufferoffset + 11 + 3 * (ncomp - 1) >= buffersize) - return (0); - for (j = 0; j < ncomp; j++) - { - uint16_t samp = buffer[*bufferoffset + 11 + (3 * j)]; - if ((samp >> 4) > h_samp) - h_samp = (samp >> 4); - if ((samp & 0x0f) > v_samp) - v_samp = (samp & 0x0f); - } - v_samp *= 8; - h_samp *= 8; - ri = (((((uint16_t)(buffer[*bufferoffset + 5]) << 8) | - (uint16_t)(buffer[*bufferoffset + 6])) + - v_samp - 1) / - v_samp); - ri *= (((((uint16_t)(buffer[*bufferoffset + 7]) << 8) | - (uint16_t)(buffer[*bufferoffset + 8])) + - h_samp - 1) / - h_samp); - buffer[*bufferoffset + 5] = - (unsigned char)((height >> 8) & 0xff); - buffer[*bufferoffset + 6] = (unsigned char)(height & 0xff); - *bufferoffset += datalen + 2; - /* insert a DRI marker */ - buffer[(*bufferoffset)++] = 0xff; - buffer[(*bufferoffset)++] = 0xdd; - buffer[(*bufferoffset)++] = 0x00; - buffer[(*bufferoffset)++] = 0x04; - buffer[(*bufferoffset)++] = (ri >> 8) & 0xff; - buffer[(*bufferoffset)++] = ri & 0xff; - } - break; - case 0xc4: /* DHT */ - case 0xdb: /* DQT */ - if (*bufferoffset + datalen + 2 > buffersize) - return (0); - _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i - 1]), - datalen + 2); - *bufferoffset += datalen + 2; - break; - case 0xda: /* SOS */ - if (no == 0) - { - if (*bufferoffset + datalen + 2 > buffersize) - return (0); - _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i - 1]), - datalen + 2); - *bufferoffset += datalen + 2; - } - else - { - if (*bufferoffset + 2 > buffersize) - return (0); - buffer[(*bufferoffset)++] = 0xff; - buffer[(*bufferoffset)++] = - (unsigned char)(0xd0 | ((no - 1) % 8)); - } - i += datalen + 1; - /* copy remainder of strip */ - if (*bufferoffset + *striplength - i > buffersize) - return (0); - _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i]), - *striplength - i); - *bufferoffset += *striplength - i; - return (1); - default: - /* ignore any other marker */ - break; - } - i += datalen + 1; - } + /* marker header: one or more FFs */ + if (strip[i] != 0xff) + return(0); + i++; + while (i < *striplength && strip[i] == 0xff) + i++; + if (i >= *striplength) + return(0); + /* SOI is the only pre-SOS marker without a length word */ + if (strip[i] == 0xd8) + datalen = 0; + else { + if ((*striplength - i) <= 2) + return(0); + datalen = (strip[i+1] << 8) | strip[i+2]; + if (datalen < 2 || datalen >= (*striplength - i)) + return(0); + } + switch( strip[i] ){ + case 0xd8: /* SOI - start of image */ + if( *bufferoffset + 2 > buffersize ) + return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), 2); + *bufferoffset+=2; + break; + case 0xc0: /* SOF0 */ + case 0xc1: /* SOF1 */ + case 0xc3: /* SOF3 */ + case 0xc9: /* SOF9 */ + case 0xca: /* SOF10 */ + if(no==0){ + if( *bufferoffset + datalen + 2 + 6 > buffersize ) + return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2); + if( *bufferoffset + 9 >= buffersize ) + return(0); + ncomp = buffer[*bufferoffset+9]; + if (ncomp < 1 || ncomp > 4) + return(0); + v_samp=1; + h_samp=1; + if( *bufferoffset + 11 + 3*(ncomp-1) >= buffersize ) + return(0); + for(j=0;j>4) > h_samp) + h_samp = (samp>>4); + if( (samp & 0x0f) > v_samp) + v_samp = (samp & 0x0f); + } + v_samp*=8; + h_samp*=8; + ri=((( ((uint16)(buffer[*bufferoffset+5])<<8) | + (uint16)(buffer[*bufferoffset+6]) )+v_samp-1)/ + v_samp); + ri*=((( ((uint16)(buffer[*bufferoffset+7])<<8) | + (uint16)(buffer[*bufferoffset+8]) )+h_samp-1)/ + h_samp); + buffer[*bufferoffset+5]= + (unsigned char) ((height>>8) & 0xff); + buffer[*bufferoffset+6]= + (unsigned char) (height & 0xff); + *bufferoffset+=datalen+2; + /* insert a DRI marker */ + buffer[(*bufferoffset)++]=0xff; + buffer[(*bufferoffset)++]=0xdd; + buffer[(*bufferoffset)++]=0x00; + buffer[(*bufferoffset)++]=0x04; + buffer[(*bufferoffset)++]=(ri >> 8) & 0xff; + buffer[(*bufferoffset)++]= ri & 0xff; + } + break; + case 0xc4: /* DHT */ + case 0xdb: /* DQT */ + if( *bufferoffset + datalen + 2 > buffersize ) + return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2); + *bufferoffset+=datalen+2; + break; + case 0xda: /* SOS */ + if(no==0){ + if( *bufferoffset + datalen + 2 > buffersize ) + return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i-1]), datalen+2); + *bufferoffset+=datalen+2; + } else { + if( *bufferoffset + 2 > buffersize ) + return(0); + buffer[(*bufferoffset)++]=0xff; + buffer[(*bufferoffset)++]= + (unsigned char)(0xd0 | ((no-1)%8)); + } + i += datalen + 1; + /* copy remainder of strip */ + if( *bufferoffset + *striplength - i > buffersize ) + return(0); + _TIFFmemcpy(&(buffer[*bufferoffset]), &(strip[i]), *striplength - i); + *bufferoffset+= *striplength - i; + return(1); + default: + /* ignore any other marker */ + break; + } + i += datalen + 1; + } - /* failed to find SOS marker */ - return (0); + /* failed to find SOS marker */ + return(0); } #endif /* - This functions converts a tilewidth x tilelength buffer of samples into - an edgetilewidth x tilelength buffer of samples. + This functions converts a tilewidth x tilelength buffer of samples into an edgetilewidth x + tilelength buffer of samples. */ -void t2p_tile_collapse_left(tdata_t buffer, tsize_t scanwidth, - uint32_t tilewidth, uint32_t edgetilewidth, - uint32_t tilelength) -{ - - uint32_t i; - tsize_t edgescanwidth = 0; - - edgescanwidth = (scanwidth * edgetilewidth + (tilewidth - 1)) / tilewidth; - for (i = 0; i < tilelength; i++) - { - /* We use memmove() since there can be overlaps in src and dst buffers - * for the first items */ - memmove(&(((char *)buffer)[edgescanwidth * i]), - &(((char *)buffer)[scanwidth * i]), edgescanwidth); - } - - return; +void t2p_tile_collapse_left( + tdata_t buffer, + tsize_t scanwidth, + uint32 tilewidth, + uint32 edgetilewidth, + uint32 tilelength){ + + uint32 i; + tsize_t edgescanwidth=0; + + edgescanwidth = (scanwidth * edgetilewidth + (tilewidth - 1))/ tilewidth; + for(i=0;it2p_error = T2P_ERR_ERROR; - return; - } - t2p_enable(output); - return; + t2p_disable(output); + if(!TIFFWriteDirectory(output)){ + TIFFError(TIFF2PDF_MODULE, + "Error writing virtual directory to output PDF %s", + TIFFFileName(output)); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + t2p_enable(output); + return; } -tsize_t t2p_sample_planar_separate_to_contig(T2P *t2p, unsigned char *buffer, - unsigned char *samplebuffer, - tsize_t samplebuffersize) -{ +tsize_t t2p_sample_planar_separate_to_contig( + T2P* t2p, + unsigned char* buffer, + unsigned char* samplebuffer, + tsize_t samplebuffersize){ - tsize_t stride = 0; - tsize_t i = 0; - tsize_t j = 0; + tsize_t stride=0; + tsize_t i=0; + tsize_t j=0; + + stride=samplebuffersize/t2p->tiff_samplesperpixel; + for(i=0;itiff_samplesperpixel;j++){ + buffer[i*t2p->tiff_samplesperpixel + j] = samplebuffer[i + j*stride]; + } + } - stride = samplebuffersize / t2p->tiff_samplesperpixel; - for (i = 0; i < stride; i++) - { - for (j = 0; j < t2p->tiff_samplesperpixel; j++) - { - buffer[i * t2p->tiff_samplesperpixel + j] = - samplebuffer[i + j * stride]; - } - } - - return (samplebuffersize); + return(samplebuffersize); } -tsize_t t2p_sample_realize_palette(T2P *t2p, unsigned char *buffer) -{ +tsize_t t2p_sample_realize_palette(T2P* t2p, unsigned char* buffer){ - uint32_t sample_count = 0; - uint16_t component_count = 0; - uint32_t palette_offset = 0; - uint32_t sample_offset = 0; - uint32_t i = 0; - uint32_t j = 0; - size_t data_size; - sample_count = t2p->tiff_width * t2p->tiff_length; - component_count = t2p->tiff_samplesperpixel; - data_size = TIFFSafeMultiply(size_t, sample_count, component_count); - if ((data_size == 0U) || (t2p->tiff_datasize < 0) || - (data_size > (size_t)t2p->tiff_datasize)) - { - TIFFError(TIFF2PDF_MODULE, - "Error: sample_count * component_count > t2p->tiff_datasize"); - t2p->t2p_error = T2P_ERR_ERROR; - return 1; - } - - for (i = sample_count; i > 0; i--) - { - palette_offset = buffer[i - 1] * component_count; - sample_offset = (i - 1) * component_count; - if (palette_offset + component_count > t2p->pdf_palettesize) + uint32 sample_count=0; + uint16 component_count=0; + uint32 palette_offset=0; + uint32 sample_offset=0; + uint32 i=0; + uint32 j=0; + size_t data_size; + sample_count=t2p->tiff_width*t2p->tiff_length; + component_count=t2p->tiff_samplesperpixel; + data_size=TIFFSafeMultiply(size_t,sample_count,component_count); + if( (data_size == 0U) || (t2p->tiff_datasize < 0) || + (data_size > (size_t) t2p->tiff_datasize) ) { TIFFError(TIFF2PDF_MODULE, - "Error: palette_offset + component_count > " - "t2p->pdf_palettesize"); + "Error: sample_count * component_count > t2p->tiff_datasize"); + t2p->t2p_error = T2P_ERR_ERROR; return 1; } - for (j = 0; j < component_count; j++) - { - buffer[sample_offset + j] = t2p->pdf_palette[palette_offset + j]; - } - } + + for(i=sample_count;i>0;i--){ + palette_offset=buffer[i-1] * component_count; + sample_offset= (i-1) * component_count; + if(palette_offset + component_count > t2p->pdf_palettesize){ + TIFFError(TIFF2PDF_MODULE, + "Error: palette_offset + component_count > t2p->pdf_palettesize"); + return 1; + } + for(j=0;jpdf_palette[palette_offset+j]; + } + } - return (0); + return(0); } /* - This functions converts in place a buffer of ABGR interleaved data - into RGB interleaved data, discarding A. + This functions converts in place a buffer of ABGR interleaved data + into RGB interleaved data, discarding A. */ -tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32_t samplecount) +tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32 samplecount) { - uint32_t i = 0; - uint32_t sample = 0; + uint32 i=0; + uint32 sample=0; + + for(i=0;i>8) & 0xff); + ((char*)data)[i*3+2]= (char) ((sample>>16) & 0xff); + } - for (i = 0; i < samplecount; i++) - { - sample = ((uint32_t *)data)[i]; - ((char *)data)[i * 3] = (char)(sample & 0xff); - ((char *)data)[i * 3 + 1] = (char)((sample >> 8) & 0xff); - ((char *)data)[i * 3 + 2] = (char)((sample >> 16) & 0xff); - } - - return (i * 3); + return(i*3); } /* @@ -4217,20 +3864,21 @@ tsize_t t2p_sample_abgr_to_rgb(tdata_t data, uint32_t samplecount) * into RGB interleaved data, discarding A. */ -tsize_t t2p_sample_rgbaa_to_rgb(tdata_t data, uint32_t samplecount) +tsize_t +t2p_sample_rgbaa_to_rgb(tdata_t data, uint32 samplecount) { - uint32_t i; + uint32 i; - /* For the 3 first samples, there is overlap between source and - * destination, so use memmove(). - * See http://bugzilla.maptools.org/show_bug.cgi?id=2577 - */ - for (i = 0; i < 3 && i < samplecount; i++) - memmove((uint8_t *)data + i * 3, (uint8_t *)data + i * 4, 3); - for (; i < samplecount; i++) - memcpy((uint8_t *)data + i * 3, (uint8_t *)data + i * 4, 3); + /* For the 3 first samples, there is overlap between source and + * destination, so use memmove(). + * See http://bugzilla.maptools.org/show_bug.cgi?id=2577 + */ + for(i = 0; i < 3 && i < samplecount; i++) + memmove((uint8*)data + i * 3, (uint8*)data + i * 4, 3); + for(; i < samplecount; i++) + memcpy((uint8*)data + i * 3, (uint8*)data + i * 4, 3); - return (i * 3); + return(i * 3); } /* @@ -4238,512 +3886,464 @@ tsize_t t2p_sample_rgbaa_to_rgb(tdata_t data, uint32_t samplecount) * into RGB interleaved data, adding 255-A to each component sample. */ -tsize_t t2p_sample_rgba_to_rgb(tdata_t data, uint32_t samplecount) +tsize_t +t2p_sample_rgba_to_rgb(tdata_t data, uint32 samplecount) { - uint32_t i = 0; - uint32_t sample = 0; - uint8_t alpha = 0; + uint32 i = 0; + uint32 sample = 0; + uint8 alpha = 0; - for (i = 0; i < samplecount; i++) - { - sample = ((uint32_t *)data)[i]; - alpha = (uint8_t)((255 - ((sample >> 24) & 0xff))); - ((uint8_t *)data)[i * 3] = (uint8_t)((sample >> 16) & 0xff) + alpha; - ((uint8_t *)data)[i * 3 + 1] = (uint8_t)((sample >> 8) & 0xff) + alpha; - ((uint8_t *)data)[i * 3 + 2] = (uint8_t)(sample & 0xff) + alpha; - } + for (i = 0; i < samplecount; i++) { + sample=((uint32*)data)[i]; + alpha=(uint8)((255 - ((sample >> 24) & 0xff))); + ((uint8 *)data)[i * 3] = (uint8) ((sample >> 16) & 0xff) + alpha; + ((uint8 *)data)[i * 3 + 1] = (uint8) ((sample >> 8) & 0xff) + alpha; + ((uint8 *)data)[i * 3 + 2] = (uint8) (sample & 0xff) + alpha; + } - return (i * 3); + return (i * 3); } /* - This function converts the a and b samples of Lab data from signed - to unsigned. + This function converts the a and b samples of Lab data from signed + to unsigned. */ -tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t buffer, uint32_t samplecount) -{ +tsize_t t2p_sample_lab_signed_to_unsigned(tdata_t buffer, uint32 samplecount){ - uint32_t i = 0; + uint32 i=0; - for (i = 0; i < samplecount; i++) - { - if ((((unsigned char *)buffer)[(i * 3) + 1] & 0x80) != 0) - { - ((unsigned char *)buffer)[(i * 3) + 1] = - (unsigned char)(0x80 + ((char *)buffer)[(i * 3) + 1]); - } - else - { - ((unsigned char *)buffer)[(i * 3) + 1] |= 0x80; - } - if ((((unsigned char *)buffer)[(i * 3) + 2] & 0x80) != 0) - { - ((unsigned char *)buffer)[(i * 3) + 2] = - (unsigned char)(0x80 + ((char *)buffer)[(i * 3) + 2]); - } - else - { - ((unsigned char *)buffer)[(i * 3) + 2] |= 0x80; - } - } + for(i=0;ipdf_majorversion&0xff, + t2p->pdf_minorversion&0xff); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t)"\n%\342\343\317\323\n", 7); + + return(written); } /* - This function writes the PDF header to output. + This function writes the beginning of a PDF object to output. */ -tsize_t t2p_write_pdf_header(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_obj_start(uint32 number, TIFF* output){ - tsize_t written = 0; - char buffer[16]; - int buflen = 0; + tsize_t written=0; + char buffer[32]; + int buflen=0; - buflen = snprintf(buffer, sizeof(buffer), "%%PDF-%" PRIu16 ".%" PRIu16 " ", - (uint16_t)(t2p->pdf_majorversion & 0xff), - (uint16_t)(t2p->pdf_minorversion & 0xff)); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "\n%\342\343\317\323\n", 7); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)number); + check_snprintf_ret((T2P*)NULL, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen ); + written += t2pWriteFile(output, (tdata_t) " 0 obj\n", 7); - return (written); + return(written); } /* - This function writes the beginning of a PDF object to output. + This function writes the end of a PDF object to output. */ -tsize_t t2p_write_pdf_obj_start(uint32_t number, TIFF *output) -{ +tsize_t t2p_write_pdf_obj_end(TIFF* output){ - tsize_t written = 0; - char buffer[32]; - int buflen = 0; + tsize_t written=0; - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, number); - check_snprintf_ret((T2P *)NULL, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 obj\n", 7); + written += t2pWriteFile(output, (tdata_t) "endobj\n", 7); - return (written); + return(written); } /* - This function writes the end of a PDF object to output. + This function writes a PDF name object to output. */ -tsize_t t2p_write_pdf_obj_end(TIFF *output) -{ +tsize_t t2p_write_pdf_name(const unsigned char* name, TIFF* output){ - tsize_t written = 0; + tsize_t written=0; + uint32 i=0; + char buffer[64]; + uint16 nextchar=0; + size_t namelen=0; + + namelen = strlen((char *)name); + if (namelen>126) { + namelen=126; + } + written += t2pWriteFile(output, (tdata_t) "/", 1); + for (i=0;i 0x7E){ + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + nextchar=1; + } + if (nextchar==0){ + switch (name[i]){ + case 0x23: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x25: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x28: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x29: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x2F: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x3C: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x3E: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x5B: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x5D: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x7B: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + case 0x7D: + snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); + buffer[sizeof(buffer) - 1] = '\0'; + written += t2pWriteFile(output, (tdata_t) buffer, 3); + break; + default: + written += t2pWriteFile(output, (tdata_t) &name[i], 1); + } + } + nextchar=0; + } + written += t2pWriteFile(output, (tdata_t) " ", 1); - written += t2pWriteFile(output, (tdata_t) "endobj\n", 7); - - return (written); -} - -/* - This function writes a PDF name object to output. -*/ - -tsize_t t2p_write_pdf_name(const unsigned char *name, TIFF *output) -{ - - tsize_t written = 0; - uint32_t i = 0; - char buffer[64]; - uint16_t nextchar = 0; - size_t namelen = 0; - - namelen = strlen((char *)name); - if (namelen > 126) - { - namelen = 126; - } - written += t2pWriteFile(output, (tdata_t) "/", 1); - for (i = 0; i < namelen; i++) - { - if (((unsigned char)name[i]) < 0x21) - { - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - nextchar = 1; - } - if (((unsigned char)name[i]) > 0x7E) - { - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - nextchar = 1; - } - if (nextchar == 0) - { - switch (name[i]) - { - case 0x23: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x25: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x28: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x29: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x2F: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x3C: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x3E: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x5B: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x5D: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x7B: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - case 0x7D: - snprintf(buffer, sizeof(buffer), "#%.2X", name[i]); - buffer[sizeof(buffer) - 1] = '\0'; - written += t2pWriteFile(output, (tdata_t)buffer, 3); - break; - default: - written += t2pWriteFile(output, (tdata_t)&name[i], 1); - } - } - nextchar = 0; - } - written += t2pWriteFile(output, (tdata_t) " ", 1); - - return (written); + return(written); } /* * This function writes a PDF string object to output. */ - -tsize_t t2p_write_pdf_string(const char *pdfstr, TIFF *output) + +tsize_t t2p_write_pdf_string(const char* pdfstr, TIFF* output) { - tsize_t written = 0; - uint32_t i = 0; - char buffer[64]; - size_t len = 0; + tsize_t written = 0; + uint32 i = 0; + char buffer[64]; + size_t len = 0; + + len = strlen(pdfstr); + written += t2pWriteFile(output, (tdata_t) "(", 1); + for (i=0; i>\n", 4); - return (written); + return(written); } /* - This function writes the end of a PDF stream dictionary to output. + This function writes a number to output. */ -tsize_t t2p_write_pdf_stream_dict_end(TIFF *output) -{ +tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF* output){ - tsize_t written = 0; + tsize_t written=0; + char buffer[32]; + int buflen=0; - written += t2pWriteFile(output, (tdata_t) " >>\n", 4); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)len); + check_snprintf_ret((T2P*)NULL, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n", 1); - return (written); -} - -/* - This function writes a number to output. -*/ - -tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF *output) -{ - - tsize_t written = 0; - char buffer[32]; - int buflen = 0; - - buflen = snprintf(buffer, sizeof(buffer), "%" TIFF_SSIZE_FORMAT, len); - check_snprintf_ret((T2P *)NULL, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "\n", 1); - - return (written); + return(written); } /* * This function writes the PDF Catalog structure to output. */ -tsize_t t2p_write_pdf_catalog(T2P *t2p, TIFF *output) +tsize_t t2p_write_pdf_catalog(T2P* t2p, TIFF* output) { - tsize_t written = 0; - char buffer[32]; - int buflen = 0; + tsize_t written = 0; + char buffer[32]; + int buflen = 0; - written += - t2pWriteFile(output, (tdata_t) "<< \n/Type /Catalog \n/Pages ", 27); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->pdf_pages); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, - TIFFmin((size_t)buflen, sizeof(buffer) - 1)); - written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); - if (t2p->pdf_fitwindow) - { - written += t2pWriteFile( - output, (tdata_t) "/ViewerPreferences <>\n", 39); - } - written += t2pWriteFile(output, (tdata_t) ">>\n", 3); + written += t2pWriteFile(output, + (tdata_t)"<< \n/Type /Catalog \n/Pages ", + 27); + buflen = snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_pages); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, + TIFFmin((size_t)buflen, sizeof(buffer) - 1)); + written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); + if(t2p->pdf_fitwindow){ + written += t2pWriteFile(output, + (tdata_t) "/ViewerPreferences <>\n", + 39); + } + written += t2pWriteFile(output, (tdata_t)">>\n", 3); - return (written); + return(written); } /* - This function writes the PDF Info structure to output. + This function writes the PDF Info structure to output. */ -tsize_t t2p_write_pdf_info(T2P *t2p, TIFF *input, TIFF *output) +tsize_t t2p_write_pdf_info(T2P* t2p, TIFF* input, TIFF* output) { - tsize_t written = 0; - const char *info; - char buffer[512]; + tsize_t written = 0; + const char* info; + char buffer[512]; - if (t2p->pdf_datetime[0] == '\0') - t2p_pdf_tifftime(t2p, input); - if (strlen(t2p->pdf_datetime) > 0) - { - written += t2pWriteFile(output, (tdata_t) "<< \n/CreationDate ", 18); - written += t2p_write_pdf_string(t2p->pdf_datetime, output); - written += t2pWriteFile(output, (tdata_t) "\n/ModDate ", 10); - written += t2p_write_pdf_string(t2p->pdf_datetime, output); - } - written += t2pWriteFile(output, (tdata_t) "\n/Producer ", 11); - snprintf(buffer, sizeof(buffer), "libtiff / tiff2pdf - %d", - TIFFLIB_VERSION); - written += t2p_write_pdf_string(buffer, output); - written += t2pWriteFile(output, (tdata_t) "\n", 1); - if (!t2p->pdf_creator_set) - { - if (TIFFGetField(input, TIFFTAG_SOFTWARE, &info) != 0 && info) - { - strncpy(t2p->pdf_creator, info, sizeof(t2p->pdf_creator) - 1); - t2p->pdf_creator[sizeof(t2p->pdf_creator) - 1] = '\0'; - } - } - if (t2p->pdf_creator[0] != '\0') - { - written += t2pWriteFile(output, (tdata_t) "/Creator ", 9); - written += t2p_write_pdf_string(t2p->pdf_creator, output); - written += t2pWriteFile(output, (tdata_t) "\n", 1); - } - if (!t2p->pdf_author_set) - { - if ((TIFFGetField(input, TIFFTAG_ARTIST, &info) != 0 || - TIFFGetField(input, TIFFTAG_COPYRIGHT, &info) != 0) && - info) - { - strncpy(t2p->pdf_author, info, sizeof(t2p->pdf_author) - 1); - t2p->pdf_author[sizeof(t2p->pdf_author) - 1] = '\0'; - } - } - if (t2p->pdf_author[0] != '\0') - { - written += t2pWriteFile(output, (tdata_t) "/Author ", 8); - written += t2p_write_pdf_string(t2p->pdf_author, output); - written += t2pWriteFile(output, (tdata_t) "\n", 1); - } - if (!t2p->pdf_title_set) - { - if (TIFFGetField(input, TIFFTAG_DOCUMENTNAME, &info) != 0 && info) - { - strncpy(t2p->pdf_title, info, sizeof(t2p->pdf_title) - 1); - t2p->pdf_title[sizeof(t2p->pdf_title) - 1] = '\0'; - } - } - if (t2p->pdf_title[0] != '\0') - { - written += t2pWriteFile(output, (tdata_t) "/Title ", 7); - written += t2p_write_pdf_string(t2p->pdf_title, output); - written += t2pWriteFile(output, (tdata_t) "\n", 1); - } - if (!t2p->pdf_subject_set) - { - if (TIFFGetField(input, TIFFTAG_IMAGEDESCRIPTION, &info) != 0 && info) - { - strncpy(t2p->pdf_subject, info, sizeof(t2p->pdf_subject) - 1); - t2p->pdf_subject[sizeof(t2p->pdf_subject) - 1] = '\0'; - } - } - if (t2p->pdf_subject[0] != '\0') - { - written += t2pWriteFile(output, (tdata_t) "/Subject ", 9); - written += t2p_write_pdf_string(t2p->pdf_subject, output); - written += t2pWriteFile(output, (tdata_t) "\n", 1); - } - if (t2p->pdf_keywords[0] != '\0') - { - written += t2pWriteFile(output, (tdata_t) "/Keywords ", 10); - written += t2p_write_pdf_string(t2p->pdf_keywords, output); - written += t2pWriteFile(output, (tdata_t) "\n", 1); - } - written += t2pWriteFile(output, (tdata_t) ">> \n", 4); + if(t2p->pdf_datetime[0] == '\0') + t2p_pdf_tifftime(t2p, input); + if (strlen(t2p->pdf_datetime) > 0) { + written += t2pWriteFile(output, (tdata_t) "<< \n/CreationDate ", 18); + written += t2p_write_pdf_string(t2p->pdf_datetime, output); + written += t2pWriteFile(output, (tdata_t) "\n/ModDate ", 10); + written += t2p_write_pdf_string(t2p->pdf_datetime, output); + } + written += t2pWriteFile(output, (tdata_t) "\n/Producer ", 11); + snprintf(buffer, sizeof(buffer), "libtiff / tiff2pdf - %d", TIFFLIB_VERSION); + written += t2p_write_pdf_string(buffer, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + if (!t2p->pdf_creator_set) { + if (TIFFGetField(input, TIFFTAG_SOFTWARE, &info) != 0 && info) { + strncpy(t2p->pdf_creator, info, sizeof(t2p->pdf_creator) - 1); + t2p->pdf_creator[sizeof(t2p->pdf_creator) - 1] = '\0'; + } + } + if (t2p->pdf_creator[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Creator ", 9); + written += t2p_write_pdf_string(t2p->pdf_creator, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } + if (!t2p->pdf_author_set) { + if ((TIFFGetField(input, TIFFTAG_ARTIST, &info) != 0 + || TIFFGetField(input, TIFFTAG_COPYRIGHT, &info) != 0) + && info) { + strncpy(t2p->pdf_author, info, sizeof(t2p->pdf_author) - 1); + t2p->pdf_author[sizeof(t2p->pdf_author) - 1] = '\0'; + } + } + if (t2p->pdf_author[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Author ", 8); + written += t2p_write_pdf_string(t2p->pdf_author, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } + if (!t2p->pdf_title_set) { + if (TIFFGetField(input, TIFFTAG_DOCUMENTNAME, &info) != 0 && info) { + strncpy(t2p->pdf_title, info, sizeof(t2p->pdf_title) - 1); + t2p->pdf_title[sizeof(t2p->pdf_title) - 1] = '\0'; + } + } + if (t2p->pdf_title[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Title ", 7); + written += t2p_write_pdf_string(t2p->pdf_title, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } + if (!t2p->pdf_subject_set) { + if (TIFFGetField(input, TIFFTAG_IMAGEDESCRIPTION, &info) != 0 && info) { + strncpy(t2p->pdf_subject, info, sizeof(t2p->pdf_subject) - 1); + t2p->pdf_subject[sizeof(t2p->pdf_subject) - 1] = '\0'; + } + } + if (t2p->pdf_subject[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Subject ", 9); + written += t2p_write_pdf_string(t2p->pdf_subject, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } + if (t2p->pdf_keywords[0] != '\0') { + written += t2pWriteFile(output, (tdata_t) "/Keywords ", 10); + written += t2p_write_pdf_string(t2p->pdf_keywords, output); + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } + written += t2pWriteFile(output, (tdata_t) ">> \n", 4); - return (written); + return(written); } /* @@ -4751,29 +4351,28 @@ tsize_t t2p_write_pdf_info(T2P *t2p, TIFF *input, TIFF *output) * date string, it is called by t2p_pdf_tifftime. */ -void t2p_pdf_currenttime(T2P *t2p) +void t2p_pdf_currenttime(T2P* t2p) { - struct tm *currenttime; - time_t timenow; + struct tm* currenttime; + time_t timenow; - if (time(&timenow) == (time_t)-1) - { - TIFFError(TIFF2PDF_MODULE, "Can't get the current time: %s", - strerror(errno)); - timenow = (time_t)0; - } + if (time(&timenow) == (time_t) -1) { + TIFFError(TIFF2PDF_MODULE, + "Can't get the current time: %s", strerror(errno)); + timenow = (time_t) 0; + } - currenttime = localtime(&timenow); - snprintf(t2p->pdf_datetime, sizeof(t2p->pdf_datetime), - "D:%.4u%.2u%.2u%.2u%.2u%.2u", - TIFFmin((unsigned)currenttime->tm_year + 1900U, 9999U), - TIFFmin((unsigned)currenttime->tm_mon + 1U, 12U), /* 0-11 + 1 */ - TIFFmin((unsigned)currenttime->tm_mday, 31U), /* 1-31 */ - TIFFmin((unsigned)currenttime->tm_hour, 23U), /* 0-23 */ - TIFFmin((unsigned)currenttime->tm_min, 59U), /* 0-59 */ - TIFFmin((unsigned)(currenttime->tm_sec), 60U)); /* 0-60 */ + currenttime = localtime(&timenow); + snprintf(t2p->pdf_datetime, sizeof(t2p->pdf_datetime), + "D:%.4u%.2u%.2u%.2u%.2u%.2u", + TIFFmin((unsigned) currenttime->tm_year + 1900U,9999U), + TIFFmin((unsigned) currenttime->tm_mon + 1U,12U), /* 0-11 + 1 */ + TIFFmin((unsigned) currenttime->tm_mday,31U), /* 1-31 */ + TIFFmin((unsigned) currenttime->tm_hour,23U), /* 0-23 */ + TIFFmin((unsigned) currenttime->tm_min,59U), /* 0-59 */ + TIFFmin((unsigned) (currenttime->tm_sec),60U)); /* 0-60 */ - return; + return; } /* @@ -4781,1536 +4380,1380 @@ void t2p_pdf_currenttime(T2P *t2p) * TIFF file if it exists or the current time as a PDF date string. */ -void t2p_pdf_tifftime(T2P *t2p, TIFF *input) +void t2p_pdf_tifftime(T2P* t2p, TIFF* input) { - char *datetime; + char* datetime; - if (TIFFGetField(input, TIFFTAG_DATETIME, &datetime) != 0 && - (strlen(datetime) >= 19)) - { - t2p->pdf_datetime[0] = 'D'; - t2p->pdf_datetime[1] = ':'; - t2p->pdf_datetime[2] = datetime[0]; - t2p->pdf_datetime[3] = datetime[1]; - t2p->pdf_datetime[4] = datetime[2]; - t2p->pdf_datetime[5] = datetime[3]; - t2p->pdf_datetime[6] = datetime[5]; - t2p->pdf_datetime[7] = datetime[6]; - t2p->pdf_datetime[8] = datetime[8]; - t2p->pdf_datetime[9] = datetime[9]; - t2p->pdf_datetime[10] = datetime[11]; - t2p->pdf_datetime[11] = datetime[12]; - t2p->pdf_datetime[12] = datetime[14]; - t2p->pdf_datetime[13] = datetime[15]; - t2p->pdf_datetime[14] = datetime[17]; - t2p->pdf_datetime[15] = datetime[18]; - t2p->pdf_datetime[16] = '\0'; - } - else - { - t2p_pdf_currenttime(t2p); - } + if (TIFFGetField(input, TIFFTAG_DATETIME, &datetime) != 0 + && (strlen(datetime) >= 19) ){ + t2p->pdf_datetime[0]='D'; + t2p->pdf_datetime[1]=':'; + t2p->pdf_datetime[2]=datetime[0]; + t2p->pdf_datetime[3]=datetime[1]; + t2p->pdf_datetime[4]=datetime[2]; + t2p->pdf_datetime[5]=datetime[3]; + t2p->pdf_datetime[6]=datetime[5]; + t2p->pdf_datetime[7]=datetime[6]; + t2p->pdf_datetime[8]=datetime[8]; + t2p->pdf_datetime[9]=datetime[9]; + t2p->pdf_datetime[10]=datetime[11]; + t2p->pdf_datetime[11]=datetime[12]; + t2p->pdf_datetime[12]=datetime[14]; + t2p->pdf_datetime[13]=datetime[15]; + t2p->pdf_datetime[14]=datetime[17]; + t2p->pdf_datetime[15]=datetime[18]; + t2p->pdf_datetime[16] = '\0'; + } else { + t2p_pdf_currenttime(t2p); + } - return; + return; } /* * This function writes a PDF Pages Tree structure to output. */ -tsize_t t2p_write_pdf_pages(T2P *t2p, TIFF *output) +tsize_t t2p_write_pdf_pages(T2P* t2p, TIFF* output) { - tsize_t written = 0; - tdir_t i = 0; - char buffer[32]; - int buflen = 0; + tsize_t written=0; + tdir_t i=0; + char buffer[32]; + int buflen=0; - int page = 0; - written += - t2pWriteFile(output, (tdata_t) "<< \n/Type /Pages \n/Kids [ ", 26); - page = t2p->pdf_pages + 1; - for (i = 0; i < t2p->tiff_pagecount; i++) - { - buflen = snprintf(buffer, sizeof(buffer), "%d", page); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - if (((i + 1) % 8) == 0) - { - written += t2pWriteFile(output, (tdata_t) "\n", 1); - } - page += 3; - page += t2p->tiff_pages[i].page_extra; - if (t2p->tiff_pages[i].page_tilecount > 0) - { - page += (2 * t2p->tiff_pages[i].page_tilecount); - } - else - { - page += 2; - } - } - written += t2pWriteFile(output, (tdata_t) "] \n/Count ", 10); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu16, t2p->tiff_pagecount); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " \n>> \n", 6); + int page=0; + written += t2pWriteFile(output, + (tdata_t) "<< \n/Type /Pages \n/Kids [ ", 26); + page = t2p->pdf_pages+1; + for (i=0;itiff_pagecount;i++){ + buflen=snprintf(buffer, sizeof(buffer), "%d", page); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + if ( ((i+1)%8)==0 ) { + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } + page +=3; + page += t2p->tiff_pages[i].page_extra; + if(t2p->tiff_pages[i].page_tilecount>0){ + page += (2 * t2p->tiff_pages[i].page_tilecount); + } else { + page +=2; + } + } + written += t2pWriteFile(output, (tdata_t) "] \n/Count ", 10); + buflen=snprintf(buffer, sizeof(buffer), "%d", t2p->tiff_pagecount); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " \n>> \n", 6); - return (written); + return(written); } /* - This function writes a PDF Page structure to output. + This function writes a PDF Page structure to output. */ -tsize_t t2p_write_pdf_page(uint32_t object, T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_page(uint32 object, T2P* t2p, TIFF* output){ - unsigned int i = 0; - tsize_t written = 0; - char buffer[256]; - int buflen = 0; + unsigned int i=0; + tsize_t written=0; + char buffer[256]; + int buflen=0; - written += t2pWriteFile(output, (tdata_t) "<<\n/Type /Page \n/Parent ", 24); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->pdf_pages); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); - written += t2pWriteFile(output, (tdata_t) "/MediaBox [", 11); - buflen = snprintf(buffer, sizeof(buffer), "%.4f", t2p->pdf_mediabox.x1); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = snprintf(buffer, sizeof(buffer), "%.4f", t2p->pdf_mediabox.y1); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = snprintf(buffer, sizeof(buffer), "%.4f", t2p->pdf_mediabox.x2); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = snprintf(buffer, sizeof(buffer), "%.4f", t2p->pdf_mediabox.y2); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "] \n", 3); - written += t2pWriteFile(output, (tdata_t) "/Contents ", 10); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, object + 1u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); - written += t2pWriteFile(output, (tdata_t) "/Resources << \n", 15); - if (t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount != 0) - { - written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); - for (i = 0; i < t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount; i++) - { - written += t2pWriteFile(output, (tdata_t) "/Im", 3); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu16, - (uint16_t)(t2p->pdf_page + 1u)); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "_", 1); - buflen = snprintf(buffer, sizeof(buffer), "%u", i + 1u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - object + 3u + (2u * i) + - t2p->tiff_pages[t2p->pdf_page].page_extra); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - if (i % 4 == 3) - { - written += t2pWriteFile(output, (tdata_t) "\n", 1); - } - } - written += t2pWriteFile(output, (tdata_t) ">>\n", 3); - } - else - { - written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); - written += t2pWriteFile(output, (tdata_t) "/Im", 3); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu16, - (uint16_t)(t2p->pdf_page + 1u)); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - object + 3u + (2u * i) + - t2p->tiff_pages[t2p->pdf_page].page_extra); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - written += t2pWriteFile(output, (tdata_t) ">>\n", 3); - } - if (t2p->tiff_transferfunctioncount != 0) - { - written += t2pWriteFile(output, (tdata_t) "/ExtGState <<", 13); - t2pWriteFile(output, (tdata_t) "/GS1 ", 5); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, object + 3u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - written += t2pWriteFile(output, (tdata_t) ">> \n", 4); - } - written += t2pWriteFile(output, (tdata_t) "/ProcSet [ ", 11); - if (t2p->pdf_colorspace & T2P_CS_BILEVEL || - t2p->pdf_colorspace & T2P_CS_GRAY) - { - written += t2pWriteFile(output, (tdata_t) "/ImageB ", 8); - } - else - { - written += t2pWriteFile(output, (tdata_t) "/ImageC ", 8); - if (t2p->pdf_colorspace & T2P_CS_PALETTE) - { - written += t2pWriteFile(output, (tdata_t) "/ImageI ", 8); - } - } - written += t2pWriteFile(output, (tdata_t) "]\n>>\n>>\n", 8); + written += t2pWriteFile(output, (tdata_t) "<<\n/Type /Page \n/Parent ", 24); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_pages); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); + written += t2pWriteFile(output, (tdata_t) "/MediaBox [", 11); + buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.x1); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); + buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.y1); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); + buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.x2); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); + buflen=snprintf(buffer, sizeof(buffer), "%.4f",t2p->pdf_mediabox.y2); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "] \n", 3); + written += t2pWriteFile(output, (tdata_t) "/Contents ", 10); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(object + 1)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R \n", 6); + written += t2pWriteFile(output, (tdata_t) "/Resources << \n", 15); + if( t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount != 0 ){ + written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); + for(i=0;itiff_tiles[t2p->pdf_page].tiles_tilecount;i++){ + written += t2pWriteFile(output, (tdata_t) "/Im", 3); + buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "_", 1); + buflen = snprintf(buffer, sizeof(buffer), "%u", i+1); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); + buflen = snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + if(i%4==3){ + written += t2pWriteFile(output, (tdata_t) "\n", 1); + } + } + written += t2pWriteFile(output, (tdata_t) ">>\n", 3); + } else { + written += t2pWriteFile(output, (tdata_t) "/XObject <<\n", 12); + written += t2pWriteFile(output, (tdata_t) "/Im", 3); + buflen = snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); + buflen = snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)(object+3+(2*i)+t2p->tiff_pages[t2p->pdf_page].page_extra)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) ">>\n", 3); + } + if(t2p->tiff_transferfunctioncount != 0) { + written += t2pWriteFile(output, (tdata_t) "/ExtGState <<", 13); + t2pWriteFile(output, (tdata_t) "/GS1 ", 5); + buflen = snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)(object + 3)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) ">> \n", 4); + } + written += t2pWriteFile(output, (tdata_t) "/ProcSet [ ", 11); + if(t2p->pdf_colorspace & T2P_CS_BILEVEL + || t2p->pdf_colorspace & T2P_CS_GRAY + ){ + written += t2pWriteFile(output, (tdata_t) "/ImageB ", 8); + } else { + written += t2pWriteFile(output, (tdata_t) "/ImageC ", 8); + if(t2p->pdf_colorspace & T2P_CS_PALETTE){ + written += t2pWriteFile(output, (tdata_t) "/ImageI ", 8); + } + } + written += t2pWriteFile(output, (tdata_t) "]\n>>\n>>\n", 8); - return (written); + return(written); } /* - This function composes the page size and image and tile locations on a - page. + This function composes the page size and image and tile locations on a page. */ -void t2p_compose_pdf_page(T2P *t2p) -{ +void t2p_compose_pdf_page(T2P* t2p){ - uint32_t i = 0; - uint32_t i2 = 0; - T2P_TILE *tiles = NULL; - T2P_BOX *boxp = NULL; - uint32_t tilecountx = 0; - uint32_t tilecounty = 0; - uint32_t tilewidth = 0; - uint32_t tilelength = 0; - int istiled = 0; - float f = 0; - float width_ratio = 0; - float length_ratio = 0; + uint32 i=0; + uint32 i2=0; + T2P_TILE* tiles=NULL; + T2P_BOX* boxp=NULL; + uint32 tilecountx=0; + uint32 tilecounty=0; + uint32 tilewidth=0; + uint32 tilelength=0; + int istiled=0; + float f=0; + float width_ratio=0; + float length_ratio=0; + + t2p->pdf_xres = t2p->tiff_xres; + t2p->pdf_yres = t2p->tiff_yres; + if(t2p->pdf_overrideres) { + t2p->pdf_xres = t2p->pdf_defaultxres; + t2p->pdf_yres = t2p->pdf_defaultyres; + } + if(t2p->pdf_xres == 0.0) + t2p->pdf_xres = t2p->pdf_defaultxres; + if(t2p->pdf_yres == 0.0) + t2p->pdf_yres = t2p->pdf_defaultyres; + if (t2p->pdf_image_fillpage) { + width_ratio = t2p->pdf_defaultpagewidth/t2p->tiff_width; + length_ratio = t2p->pdf_defaultpagelength/t2p->tiff_length; + if (width_ratio < length_ratio ) { + t2p->pdf_imagewidth = t2p->pdf_defaultpagewidth; + t2p->pdf_imagelength = t2p->tiff_length * width_ratio; + } else { + t2p->pdf_imagewidth = t2p->tiff_width * length_ratio; + t2p->pdf_imagelength = t2p->pdf_defaultpagelength; + } + } else if (t2p->tiff_resunit != RESUNIT_CENTIMETER /* RESUNIT_NONE and */ + && t2p->tiff_resunit != RESUNIT_INCH) { /* other cases */ + t2p->pdf_imagewidth = ((float)(t2p->tiff_width))/t2p->pdf_xres; + t2p->pdf_imagelength = ((float)(t2p->tiff_length))/t2p->pdf_yres; + } else { + t2p->pdf_imagewidth = + ((float)(t2p->tiff_width))*PS_UNIT_SIZE/t2p->pdf_xres; + t2p->pdf_imagelength = + ((float)(t2p->tiff_length))*PS_UNIT_SIZE/t2p->pdf_yres; + } + if(t2p->pdf_overridepagesize != 0) { + t2p->pdf_pagewidth = t2p->pdf_defaultpagewidth; + t2p->pdf_pagelength = t2p->pdf_defaultpagelength; + } else { + t2p->pdf_pagewidth = t2p->pdf_imagewidth; + t2p->pdf_pagelength = t2p->pdf_imagelength; + } + t2p->pdf_mediabox.x1=0.0; + t2p->pdf_mediabox.y1=0.0; + t2p->pdf_mediabox.x2=t2p->pdf_pagewidth; + t2p->pdf_mediabox.y2=t2p->pdf_pagelength; + t2p->pdf_imagebox.x1=0.0; + t2p->pdf_imagebox.y1=0.0; + t2p->pdf_imagebox.x2=t2p->pdf_imagewidth; + t2p->pdf_imagebox.y2=t2p->pdf_imagelength; + if(t2p->pdf_overridepagesize!=0){ + t2p->pdf_imagebox.x1+=((t2p->pdf_pagewidth-t2p->pdf_imagewidth)/2.0F); + t2p->pdf_imagebox.y1+=((t2p->pdf_pagelength-t2p->pdf_imagelength)/2.0F); + t2p->pdf_imagebox.x2+=((t2p->pdf_pagewidth-t2p->pdf_imagewidth)/2.0F); + t2p->pdf_imagebox.y2+=((t2p->pdf_pagelength-t2p->pdf_imagelength)/2.0F); + } + if(t2p->tiff_orientation > 4){ + f=t2p->pdf_mediabox.x2; + t2p->pdf_mediabox.x2=t2p->pdf_mediabox.y2; + t2p->pdf_mediabox.y2=f; + } + istiled=((t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecount==0) ? 0 : 1; + if(istiled==0){ + t2p_compose_pdf_page_orient(&(t2p->pdf_imagebox), t2p->tiff_orientation); + return; + } else { + tilewidth=(t2p->tiff_tiles[t2p->pdf_page]).tiles_tilewidth; + tilelength=(t2p->tiff_tiles[t2p->pdf_page]).tiles_tilelength; + if( tilewidth > INT_MAX || + tilelength > INT_MAX || + t2p->tiff_width > INT_MAX - tilewidth || + t2p->tiff_length > INT_MAX - tilelength ) + { + TIFFError(TIFF2PDF_MODULE, "Integer overflow"); + t2p->t2p_error = T2P_ERR_ERROR; + return; + } + tilecountx=(t2p->tiff_width + + tilewidth -1)/ + tilewidth; + (t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecountx=tilecountx; + tilecounty=(t2p->tiff_length + + tilelength -1)/ + tilelength; + (t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecounty=tilecounty; + (t2p->tiff_tiles[t2p->pdf_page]).tiles_edgetilewidth= + t2p->tiff_width % tilewidth; + (t2p->tiff_tiles[t2p->pdf_page]).tiles_edgetilelength= + t2p->tiff_length % tilelength; + tiles=(t2p->tiff_tiles[t2p->pdf_page]).tiles_tiles; + for(i2=0;i2x1 = + t2p->pdf_imagebox.x1 + + ((float)(t2p->pdf_imagewidth * i * tilewidth) + / (float)t2p->tiff_width); + boxp->x2 = + t2p->pdf_imagebox.x1 + + ((float)(t2p->pdf_imagewidth * (i+1) * tilewidth) + / (float)t2p->tiff_width); + boxp->y1 = + t2p->pdf_imagebox.y2 + - ((float)(t2p->pdf_imagelength * (i2+1) * tilelength) + / (float)t2p->tiff_length); + boxp->y2 = + t2p->pdf_imagebox.y2 + - ((float)(t2p->pdf_imagelength * i2 * tilelength) + / (float)t2p->tiff_length); + } + boxp=&(tiles[i2*tilecountx+i].tile_box); + boxp->x1 = + t2p->pdf_imagebox.x1 + + ((float)(t2p->pdf_imagewidth * i * tilewidth) + / (float)t2p->tiff_width); + boxp->x2 = t2p->pdf_imagebox.x2; + boxp->y1 = + t2p->pdf_imagebox.y2 + - ((float)(t2p->pdf_imagelength * (i2+1) * tilelength) + / (float)t2p->tiff_length); + boxp->y2 = + t2p->pdf_imagebox.y2 + - ((float)(t2p->pdf_imagelength * i2 * tilelength) + / (float)t2p->tiff_length); + } + for(i=0;ix1 = + t2p->pdf_imagebox.x1 + + ((float)(t2p->pdf_imagewidth * i * tilewidth) + / (float)t2p->tiff_width); + boxp->x2 = + t2p->pdf_imagebox.x1 + + ((float)(t2p->pdf_imagewidth * (i+1) * tilewidth) + / (float)t2p->tiff_width); + boxp->y1 = t2p->pdf_imagebox.y1; + boxp->y2 = + t2p->pdf_imagebox.y2 + - ((float)(t2p->pdf_imagelength * i2 * tilelength) + / (float)t2p->tiff_length); + } + boxp=&(tiles[i2*tilecountx+i].tile_box); + boxp->x1 = + t2p->pdf_imagebox.x1 + + ((float)(t2p->pdf_imagewidth * i * tilewidth) + / (float)t2p->tiff_width); + boxp->x2 = t2p->pdf_imagebox.x2; + boxp->y1 = t2p->pdf_imagebox.y1; + boxp->y2 = + t2p->pdf_imagebox.y2 + - ((float)(t2p->pdf_imagelength * i2 * tilelength) + / (float)t2p->tiff_length); + } + if(t2p->tiff_orientation==0 || t2p->tiff_orientation==1){ + for(i=0;i<(t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecount;i++){ + t2p_compose_pdf_page_orient( &(tiles[i].tile_box) , 0); + } + return; + } + for(i=0;i<(t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecount;i++){ + boxp=&(tiles[i].tile_box); + boxp->x1 -= t2p->pdf_imagebox.x1; + boxp->x2 -= t2p->pdf_imagebox.x1; + boxp->y1 -= t2p->pdf_imagebox.y1; + boxp->y2 -= t2p->pdf_imagebox.y1; + if(t2p->tiff_orientation==2 || t2p->tiff_orientation==3){ + boxp->x1 = t2p->pdf_imagebox.x2 - t2p->pdf_imagebox.x1 - boxp->x1; + boxp->x2 = t2p->pdf_imagebox.x2 - t2p->pdf_imagebox.x1 - boxp->x2; + } + if(t2p->tiff_orientation==3 || t2p->tiff_orientation==4){ + boxp->y1 = t2p->pdf_imagebox.y2 - t2p->pdf_imagebox.y1 - boxp->y1; + boxp->y2 = t2p->pdf_imagebox.y2 - t2p->pdf_imagebox.y1 - boxp->y2; + } + if(t2p->tiff_orientation==8 || t2p->tiff_orientation==5){ + boxp->y1 = t2p->pdf_imagebox.y2 - t2p->pdf_imagebox.y1 - boxp->y1; + boxp->y2 = t2p->pdf_imagebox.y2 - t2p->pdf_imagebox.y1 - boxp->y2; + } + if(t2p->tiff_orientation==5 || t2p->tiff_orientation==6){ + boxp->x1 = t2p->pdf_imagebox.x2 - t2p->pdf_imagebox.x1 - boxp->x1; + boxp->x2 = t2p->pdf_imagebox.x2 - t2p->pdf_imagebox.x1 - boxp->x2; + } + if(t2p->tiff_orientation > 4){ + f=boxp->x1; + boxp->x1 = boxp->y1; + boxp->y1 = f; + f=boxp->x2; + boxp->x2 = boxp->y2; + boxp->y2 = f; + t2p_compose_pdf_page_orient_flip(boxp, t2p->tiff_orientation); + } else { + t2p_compose_pdf_page_orient(boxp, t2p->tiff_orientation); + } + + } - t2p->pdf_xres = t2p->tiff_xres; - t2p->pdf_yres = t2p->tiff_yres; - if (t2p->pdf_overrideres) - { - t2p->pdf_xres = t2p->pdf_defaultxres; - t2p->pdf_yres = t2p->pdf_defaultyres; - } - if (t2p->pdf_xres == 0.0) - t2p->pdf_xres = t2p->pdf_defaultxres; - if (t2p->pdf_yres == 0.0) - t2p->pdf_yres = t2p->pdf_defaultyres; - if (t2p->pdf_image_fillpage) - { - width_ratio = t2p->pdf_defaultpagewidth / t2p->tiff_width; - length_ratio = t2p->pdf_defaultpagelength / t2p->tiff_length; - if (width_ratio < length_ratio) - { - t2p->pdf_imagewidth = t2p->pdf_defaultpagewidth; - t2p->pdf_imagelength = t2p->tiff_length * width_ratio; - } - else - { - t2p->pdf_imagewidth = t2p->tiff_width * length_ratio; - t2p->pdf_imagelength = t2p->pdf_defaultpagelength; - } - } - else if (t2p->tiff_resunit != RESUNIT_CENTIMETER /* RESUNIT_NONE and */ - && t2p->tiff_resunit != RESUNIT_INCH) - { /* other cases */ - t2p->pdf_imagewidth = ((float)(t2p->tiff_width)) / t2p->pdf_xres; - t2p->pdf_imagelength = ((float)(t2p->tiff_length)) / t2p->pdf_yres; - } - else - { - t2p->pdf_imagewidth = - ((float)(t2p->tiff_width)) * PS_UNIT_SIZE / t2p->pdf_xres; - t2p->pdf_imagelength = - ((float)(t2p->tiff_length)) * PS_UNIT_SIZE / t2p->pdf_yres; - } - if (t2p->pdf_overridepagesize != 0) - { - t2p->pdf_pagewidth = t2p->pdf_defaultpagewidth; - t2p->pdf_pagelength = t2p->pdf_defaultpagelength; - } - else - { - t2p->pdf_pagewidth = t2p->pdf_imagewidth; - t2p->pdf_pagelength = t2p->pdf_imagelength; - } - t2p->pdf_mediabox.x1 = 0.0; - t2p->pdf_mediabox.y1 = 0.0; - t2p->pdf_mediabox.x2 = t2p->pdf_pagewidth; - t2p->pdf_mediabox.y2 = t2p->pdf_pagelength; - t2p->pdf_imagebox.x1 = 0.0; - t2p->pdf_imagebox.y1 = 0.0; - t2p->pdf_imagebox.x2 = t2p->pdf_imagewidth; - t2p->pdf_imagebox.y2 = t2p->pdf_imagelength; - if (t2p->pdf_overridepagesize != 0) - { - t2p->pdf_imagebox.x1 += - ((t2p->pdf_pagewidth - t2p->pdf_imagewidth) / 2.0F); - t2p->pdf_imagebox.y1 += - ((t2p->pdf_pagelength - t2p->pdf_imagelength) / 2.0F); - t2p->pdf_imagebox.x2 += - ((t2p->pdf_pagewidth - t2p->pdf_imagewidth) / 2.0F); - t2p->pdf_imagebox.y2 += - ((t2p->pdf_pagelength - t2p->pdf_imagelength) / 2.0F); - } - if (t2p->tiff_orientation > 4) - { - f = t2p->pdf_mediabox.x2; - t2p->pdf_mediabox.x2 = t2p->pdf_mediabox.y2; - t2p->pdf_mediabox.y2 = f; - } - istiled = ((t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecount == 0) ? 0 : 1; - if (istiled == 0) - { - t2p_compose_pdf_page_orient(&(t2p->pdf_imagebox), - t2p->tiff_orientation); - return; - } - else - { - tilewidth = (t2p->tiff_tiles[t2p->pdf_page]).tiles_tilewidth; - tilelength = (t2p->tiff_tiles[t2p->pdf_page]).tiles_tilelength; - if (tilewidth > INT_MAX || tilelength > INT_MAX || - t2p->tiff_width > INT_MAX - tilewidth || - t2p->tiff_length > INT_MAX - tilelength) - { - TIFFError(TIFF2PDF_MODULE, "Integer overflow"); - t2p->t2p_error = T2P_ERR_ERROR; - return; - } - tilecountx = (t2p->tiff_width + tilewidth - 1) / tilewidth; - (t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecountx = tilecountx; - tilecounty = (t2p->tiff_length + tilelength - 1) / tilelength; - (t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecounty = tilecounty; - (t2p->tiff_tiles[t2p->pdf_page]).tiles_edgetilewidth = - t2p->tiff_width % tilewidth; - (t2p->tiff_tiles[t2p->pdf_page]).tiles_edgetilelength = - t2p->tiff_length % tilelength; - tiles = (t2p->tiff_tiles[t2p->pdf_page]).tiles_tiles; - for (i2 = 0; i2 < tilecounty - 1; i2++) - { - for (i = 0; i < tilecountx - 1; i++) - { - boxp = &(tiles[i2 * tilecountx + i].tile_box); - boxp->x1 = t2p->pdf_imagebox.x1 + - ((float)(t2p->pdf_imagewidth * i * tilewidth) / - (float)t2p->tiff_width); - boxp->x2 = t2p->pdf_imagebox.x1 + - ((float)(t2p->pdf_imagewidth * (i + 1) * tilewidth) / - (float)t2p->tiff_width); - boxp->y1 = - t2p->pdf_imagebox.y2 - - ((float)(t2p->pdf_imagelength * (i2 + 1) * tilelength) / - (float)t2p->tiff_length); - boxp->y2 = t2p->pdf_imagebox.y2 - - ((float)(t2p->pdf_imagelength * i2 * tilelength) / - (float)t2p->tiff_length); - } - boxp = &(tiles[i2 * tilecountx + i].tile_box); - boxp->x1 = t2p->pdf_imagebox.x1 + - ((float)(t2p->pdf_imagewidth * i * tilewidth) / - (float)t2p->tiff_width); - boxp->x2 = t2p->pdf_imagebox.x2; - boxp->y1 = t2p->pdf_imagebox.y2 - - ((float)(t2p->pdf_imagelength * (i2 + 1) * tilelength) / - (float)t2p->tiff_length); - boxp->y2 = t2p->pdf_imagebox.y2 - - ((float)(t2p->pdf_imagelength * i2 * tilelength) / - (float)t2p->tiff_length); - } - for (i = 0; i < tilecountx - 1; i++) - { - boxp = &(tiles[i2 * tilecountx + i].tile_box); - boxp->x1 = t2p->pdf_imagebox.x1 + - ((float)(t2p->pdf_imagewidth * i * tilewidth) / - (float)t2p->tiff_width); - boxp->x2 = t2p->pdf_imagebox.x1 + - ((float)(t2p->pdf_imagewidth * (i + 1) * tilewidth) / - (float)t2p->tiff_width); - boxp->y1 = t2p->pdf_imagebox.y1; - boxp->y2 = t2p->pdf_imagebox.y2 - - ((float)(t2p->pdf_imagelength * i2 * tilelength) / - (float)t2p->tiff_length); - } - boxp = &(tiles[i2 * tilecountx + i].tile_box); - boxp->x1 = t2p->pdf_imagebox.x1 + - ((float)(t2p->pdf_imagewidth * i * tilewidth) / - (float)t2p->tiff_width); - boxp->x2 = t2p->pdf_imagebox.x2; - boxp->y1 = t2p->pdf_imagebox.y1; - boxp->y2 = t2p->pdf_imagebox.y2 - - ((float)(t2p->pdf_imagelength * i2 * tilelength) / - (float)t2p->tiff_length); - } - if (t2p->tiff_orientation == 0 || t2p->tiff_orientation == 1) - { - for (i = 0; i < (t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecount; i++) - { - t2p_compose_pdf_page_orient(&(tiles[i].tile_box), 0); - } - return; - } - for (i = 0; i < (t2p->tiff_tiles[t2p->pdf_page]).tiles_tilecount; i++) - { - boxp = &(tiles[i].tile_box); - boxp->x1 -= t2p->pdf_imagebox.x1; - boxp->x2 -= t2p->pdf_imagebox.x1; - boxp->y1 -= t2p->pdf_imagebox.y1; - boxp->y2 -= t2p->pdf_imagebox.y1; - if (t2p->tiff_orientation == 2 || t2p->tiff_orientation == 3) - { - boxp->x1 = t2p->pdf_imagebox.x2 - t2p->pdf_imagebox.x1 - boxp->x1; - boxp->x2 = t2p->pdf_imagebox.x2 - t2p->pdf_imagebox.x1 - boxp->x2; - } - if (t2p->tiff_orientation == 3 || t2p->tiff_orientation == 4) - { - boxp->y1 = t2p->pdf_imagebox.y2 - t2p->pdf_imagebox.y1 - boxp->y1; - boxp->y2 = t2p->pdf_imagebox.y2 - t2p->pdf_imagebox.y1 - boxp->y2; - } - if (t2p->tiff_orientation == 8 || t2p->tiff_orientation == 5) - { - boxp->y1 = t2p->pdf_imagebox.y2 - t2p->pdf_imagebox.y1 - boxp->y1; - boxp->y2 = t2p->pdf_imagebox.y2 - t2p->pdf_imagebox.y1 - boxp->y2; - } - if (t2p->tiff_orientation == 5 || t2p->tiff_orientation == 6) - { - boxp->x1 = t2p->pdf_imagebox.x2 - t2p->pdf_imagebox.x1 - boxp->x1; - boxp->x2 = t2p->pdf_imagebox.x2 - t2p->pdf_imagebox.x1 - boxp->x2; - } - if (t2p->tiff_orientation > 4) - { - f = boxp->x1; - boxp->x1 = boxp->y1; - boxp->y1 = f; - f = boxp->x2; - boxp->x2 = boxp->y2; - boxp->y2 = f; - t2p_compose_pdf_page_orient_flip(boxp, t2p->tiff_orientation); - } - else - { - t2p_compose_pdf_page_orient(boxp, t2p->tiff_orientation); - } - } - - return; + return; } -void t2p_compose_pdf_page_orient(T2P_BOX *boxp, uint16_t orientation) -{ +void t2p_compose_pdf_page_orient(T2P_BOX* boxp, uint16 orientation){ - float m1[9]; - float f = 0.0; + float m1[9]; + float f=0.0; + + if( boxp->x1 > boxp->x2){ + f=boxp->x1; + boxp->x1=boxp->x2; + boxp->x2 = f; + } + if( boxp->y1 > boxp->y2){ + f=boxp->y1; + boxp->y1=boxp->y2; + boxp->y2 = f; + } + boxp->mat[0]=m1[0]=boxp->x2-boxp->x1; + boxp->mat[1]=m1[1]=0.0; + boxp->mat[2]=m1[2]=0.0; + boxp->mat[3]=m1[3]=0.0; + boxp->mat[4]=m1[4]=boxp->y2-boxp->y1; + boxp->mat[5]=m1[5]=0.0; + boxp->mat[6]=m1[6]=boxp->x1; + boxp->mat[7]=m1[7]=boxp->y1; + boxp->mat[8]=m1[8]=1.0; + switch(orientation){ + case 0: + case 1: + break; + case 2: + boxp->mat[0]=0.0F-m1[0]; + boxp->mat[6]+=m1[0]; + break; + case 3: + boxp->mat[0]=0.0F-m1[0]; + boxp->mat[4]=0.0F-m1[4]; + boxp->mat[6]+=m1[0]; + boxp->mat[7]+=m1[4]; + break; + case 4: + boxp->mat[4]=0.0F-m1[4]; + boxp->mat[7]+=m1[4]; + break; + case 5: + boxp->mat[0]=0.0F; + boxp->mat[1]=0.0F-m1[0]; + boxp->mat[3]=0.0F-m1[4]; + boxp->mat[4]=0.0F; + boxp->mat[6]+=m1[4]; + boxp->mat[7]+=m1[0]; + break; + case 6: + boxp->mat[0]=0.0F; + boxp->mat[1]=0.0F-m1[0]; + boxp->mat[3]=m1[4]; + boxp->mat[4]=0.0F; + boxp->mat[7]+=m1[0]; + break; + case 7: + boxp->mat[0]=0.0F; + boxp->mat[1]=m1[0]; + boxp->mat[3]=m1[4]; + boxp->mat[4]=0.0F; + break; + case 8: + boxp->mat[0]=0.0F; + boxp->mat[1]=m1[0]; + boxp->mat[3]=0.0F-m1[4]; + boxp->mat[4]=0.0F; + boxp->mat[6]+=m1[4]; + break; + } - if (boxp->x1 > boxp->x2) - { - f = boxp->x1; - boxp->x1 = boxp->x2; - boxp->x2 = f; - } - if (boxp->y1 > boxp->y2) - { - f = boxp->y1; - boxp->y1 = boxp->y2; - boxp->y2 = f; - } - boxp->mat[0] = m1[0] = boxp->x2 - boxp->x1; - boxp->mat[1] = m1[1] = 0.0; - boxp->mat[2] = m1[2] = 0.0; - boxp->mat[3] = m1[3] = 0.0; - boxp->mat[4] = m1[4] = boxp->y2 - boxp->y1; - boxp->mat[5] = m1[5] = 0.0; - boxp->mat[6] = m1[6] = boxp->x1; - boxp->mat[7] = m1[7] = boxp->y1; - boxp->mat[8] = m1[8] = 1.0; - switch (orientation) - { - case 0: - case 1: - break; - case 2: - boxp->mat[0] = 0.0F - m1[0]; - boxp->mat[6] += m1[0]; - break; - case 3: - boxp->mat[0] = 0.0F - m1[0]; - boxp->mat[4] = 0.0F - m1[4]; - boxp->mat[6] += m1[0]; - boxp->mat[7] += m1[4]; - break; - case 4: - boxp->mat[4] = 0.0F - m1[4]; - boxp->mat[7] += m1[4]; - break; - case 5: - boxp->mat[0] = 0.0F; - boxp->mat[1] = 0.0F - m1[0]; - boxp->mat[3] = 0.0F - m1[4]; - boxp->mat[4] = 0.0F; - boxp->mat[6] += m1[4]; - boxp->mat[7] += m1[0]; - break; - case 6: - boxp->mat[0] = 0.0F; - boxp->mat[1] = 0.0F - m1[0]; - boxp->mat[3] = m1[4]; - boxp->mat[4] = 0.0F; - boxp->mat[7] += m1[0]; - break; - case 7: - boxp->mat[0] = 0.0F; - boxp->mat[1] = m1[0]; - boxp->mat[3] = m1[4]; - boxp->mat[4] = 0.0F; - break; - case 8: - boxp->mat[0] = 0.0F; - boxp->mat[1] = m1[0]; - boxp->mat[3] = 0.0F - m1[4]; - boxp->mat[4] = 0.0F; - boxp->mat[6] += m1[4]; - break; - } - - return; + return; } -void t2p_compose_pdf_page_orient_flip(T2P_BOX *boxp, uint16_t orientation) -{ +void t2p_compose_pdf_page_orient_flip(T2P_BOX* boxp, uint16 orientation){ - float m1[9]; - float f = 0.0; + float m1[9]; + float f=0.0; + + if( boxp->x1 > boxp->x2){ + f=boxp->x1; + boxp->x1=boxp->x2; + boxp->x2 = f; + } + if( boxp->y1 > boxp->y2){ + f=boxp->y1; + boxp->y1=boxp->y2; + boxp->y2 = f; + } + boxp->mat[0]=m1[0]=boxp->x2-boxp->x1; + boxp->mat[1]=m1[1]=0.0F; + boxp->mat[2]=m1[2]=0.0F; + boxp->mat[3]=m1[3]=0.0F; + boxp->mat[4]=m1[4]=boxp->y2-boxp->y1; + boxp->mat[5]=m1[5]=0.0F; + boxp->mat[6]=m1[6]=boxp->x1; + boxp->mat[7]=m1[7]=boxp->y1; + boxp->mat[8]=m1[8]=1.0F; + switch(orientation){ + case 5: + boxp->mat[0]=0.0F; + boxp->mat[1]=0.0F-m1[4]; + boxp->mat[3]=0.0F-m1[0]; + boxp->mat[4]=0.0F; + boxp->mat[6]+=m1[0]; + boxp->mat[7]+=m1[4]; + break; + case 6: + boxp->mat[0]=0.0F; + boxp->mat[1]=0.0F-m1[4]; + boxp->mat[3]=m1[0]; + boxp->mat[4]=0.0F; + boxp->mat[7]+=m1[4]; + break; + case 7: + boxp->mat[0]=0.0F; + boxp->mat[1]=m1[4]; + boxp->mat[3]=m1[0]; + boxp->mat[4]=0.0F; + break; + case 8: + boxp->mat[0]=0.0F; + boxp->mat[1]=m1[4]; + boxp->mat[3]=0.0F-m1[0]; + boxp->mat[4]=0.0F; + boxp->mat[6]+=m1[0]; + break; + } - if (boxp->x1 > boxp->x2) - { - f = boxp->x1; - boxp->x1 = boxp->x2; - boxp->x2 = f; - } - if (boxp->y1 > boxp->y2) - { - f = boxp->y1; - boxp->y1 = boxp->y2; - boxp->y2 = f; - } - boxp->mat[0] = m1[0] = boxp->x2 - boxp->x1; - boxp->mat[1] = m1[1] = 0.0F; - boxp->mat[2] = m1[2] = 0.0F; - boxp->mat[3] = m1[3] = 0.0F; - boxp->mat[4] = m1[4] = boxp->y2 - boxp->y1; - boxp->mat[5] = m1[5] = 0.0F; - boxp->mat[6] = m1[6] = boxp->x1; - boxp->mat[7] = m1[7] = boxp->y1; - boxp->mat[8] = m1[8] = 1.0F; - switch (orientation) - { - case 5: - boxp->mat[0] = 0.0F; - boxp->mat[1] = 0.0F - m1[4]; - boxp->mat[3] = 0.0F - m1[0]; - boxp->mat[4] = 0.0F; - boxp->mat[6] += m1[0]; - boxp->mat[7] += m1[4]; - break; - case 6: - boxp->mat[0] = 0.0F; - boxp->mat[1] = 0.0F - m1[4]; - boxp->mat[3] = m1[0]; - boxp->mat[4] = 0.0F; - boxp->mat[7] += m1[4]; - break; - case 7: - boxp->mat[0] = 0.0F; - boxp->mat[1] = m1[4]; - boxp->mat[3] = m1[0]; - boxp->mat[4] = 0.0F; - break; - case 8: - boxp->mat[0] = 0.0F; - boxp->mat[1] = m1[4]; - boxp->mat[3] = 0.0F - m1[0]; - boxp->mat[4] = 0.0F; - boxp->mat[6] += m1[0]; - break; - } - - return; + return; } /* - This function writes a PDF Contents stream to output. + This function writes a PDF Contents stream to output. */ -tsize_t t2p_write_pdf_page_content_stream(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_page_content_stream(T2P* t2p, TIFF* output){ - tsize_t written = 0; - ttile_t i = 0; - char buffer[512]; - int buflen = 0; - T2P_BOX box; + tsize_t written=0; + ttile_t i=0; + char buffer[512]; + int buflen=0; + T2P_BOX box; + + if(t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount>0){ + for(i=0;itiff_tiles[t2p->pdf_page].tiles_tilecount; i++){ + box=t2p->tiff_tiles[t2p->pdf_page].tiles_tiles[i].tile_box; + buflen=snprintf(buffer, sizeof(buffer), + "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d_%ld Do Q\n", + t2p->tiff_transferfunctioncount?"/GS1 gs ":"", + box.mat[0], + box.mat[1], + box.mat[3], + box.mat[4], + box.mat[6], + box.mat[7], + t2p->pdf_page + 1, + (long)(i + 1)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2p_write_pdf_stream(buffer, buflen, output); + } + } else { + box=t2p->pdf_imagebox; + buflen=snprintf(buffer, sizeof(buffer), + "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%d Do Q\n", + t2p->tiff_transferfunctioncount?"/GS1 gs ":"", + box.mat[0], + box.mat[1], + box.mat[3], + box.mat[4], + box.mat[6], + box.mat[7], + t2p->pdf_page+1); + check_snprintf_ret(t2p, buflen, buffer); + written += t2p_write_pdf_stream(buffer, buflen, output); + } - if (t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount > 0) - { - for (i = 0; i < t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount; i++) - { - box = t2p->tiff_tiles[t2p->pdf_page].tiles_tiles[i].tile_box; - buflen = snprintf( - buffer, sizeof(buffer), - "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%" PRIu16 "_%" PRIu32 - " Do Q\n", - t2p->tiff_transferfunctioncount ? "/GS1 gs " : "", box.mat[0], - box.mat[1], box.mat[3], box.mat[4], box.mat[6], box.mat[7], - (uint16_t)(t2p->pdf_page + 1u), i + 1u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2p_write_pdf_stream(buffer, buflen, output); - } - } - else - { - box = t2p->pdf_imagebox; - buflen = snprintf( - buffer, sizeof(buffer), - "q %s %.4f %.4f %.4f %.4f %.4f %.4f cm /Im%" PRIu16 " Do Q\n", - t2p->tiff_transferfunctioncount ? "/GS1 gs " : "", box.mat[0], - box.mat[1], box.mat[3], box.mat[4], box.mat[6], box.mat[7], - (uint16_t)(t2p->pdf_page + 1u)); - check_snprintf_ret(t2p, buflen, buffer); - written += t2p_write_pdf_stream(buffer, buflen, output); - } - - return (written); + return(written); } /* - This function writes a PDF Image XObject stream dictionary to output. + This function writes a PDF Image XObject stream dictionary to output. */ -tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t tile, T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_xobject_stream_dict(ttile_t tile, + T2P* t2p, + TIFF* output){ - tsize_t written = 0; - char buffer[32]; - int buflen = 0; + tsize_t written=0; + char buffer[32]; + int buflen=0; - written += t2p_write_pdf_stream_dict(0, t2p->pdf_xrefcount + 1, output); - written += t2pWriteFile( - output, (tdata_t) "/Type /XObject \n/Subtype /Image \n/Name /Im", 42); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu16, - (uint16_t)(t2p->pdf_page + 1u)); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - if (tile != 0) - { - written += t2pWriteFile(output, (tdata_t) "_", 1); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, tile); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - } - written += t2pWriteFile(output, (tdata_t) "\n/Width ", 8); - if (tile == 0) - { - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->tiff_width); - } - else - { - if (t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile - 1) != - 0) - { - buflen = - snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); - } - else - { - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); - } - } - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "\n/Height ", 9); - if (tile == 0) - { - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->tiff_length); - } - else - { - if (t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile - 1) != - 0) - { - buflen = - snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); - } - else - { - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); - } - } - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "\n/BitsPerComponent ", 19); - buflen = - snprintf(buffer, sizeof(buffer), "%" PRIu16, t2p->tiff_bitspersample); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "\n/ColorSpace ", 13); - written += t2p_write_pdf_xobject_cs(t2p, output); - if (t2p->pdf_image_interpolate) - written += t2pWriteFile(output, (tdata_t) "\n/Interpolate true", 18); - if ((t2p->pdf_switchdecode != 0) + written += t2p_write_pdf_stream_dict(0, t2p->pdf_xrefcount+1, output); + written += t2pWriteFile(output, + (tdata_t) "/Type /XObject \n/Subtype /Image \n/Name /Im", + 42); + buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_page+1); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + if(tile != 0){ + written += t2pWriteFile(output, (tdata_t) "_", 1); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)tile); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } + written += t2pWriteFile(output, (tdata_t) "\n/Width ", 8); + if(tile==0){ + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_width); + } else { + if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){ + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); + } else { + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); + } + } + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n/Height ", 9); + if(tile==0){ + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->tiff_length); + } else { + if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)!=0){ + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + } else { + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + } + } + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n/BitsPerComponent ", 19); + buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n/ColorSpace ", 13); + written += t2p_write_pdf_xobject_cs(t2p, output); + if (t2p->pdf_image_interpolate) + written += t2pWriteFile(output, + (tdata_t) "\n/Interpolate true", 18); + if( (t2p->pdf_switchdecode != 0) #ifdef CCITT_SUPPORT - && !(t2p->pdf_colorspace & T2P_CS_BILEVEL && - t2p->pdf_compression == T2P_COMPRESS_G4) + && ! (t2p->pdf_colorspace & T2P_CS_BILEVEL + && t2p->pdf_compression == T2P_COMPRESS_G4) #endif - ) - { - written += t2p_write_pdf_xobject_decode(t2p, output); - } - written += t2p_write_pdf_xobject_stream_filter(tile, t2p, output); - - return (written); + ){ + written += t2p_write_pdf_xobject_decode(t2p, output); + } + written += t2p_write_pdf_xobject_stream_filter(tile, t2p, output); + + return(written); } + /* used to normalize the White Point */ -#define normalizePoint(x, y, z) \ - do \ - { \ - if (y != 0.0F) \ - { \ - x /= y; \ - z /= y; \ - y = 1.0F; \ - } \ - } while (0) +#define normalizePoint(x,y,z) do { \ + if (y != 0.0F) { \ + x /= y; \ + z /= y; \ + y = 1.0F; \ + } \ +} while(0) /* * This function writes a PDF Image XObject Colorspace name to output. */ -tsize_t t2p_write_pdf_xobject_cs(T2P *t2p, TIFF *output) -{ - tsize_t written = 0; - char buffer[128]; - int buflen = 0; +tsize_t t2p_write_pdf_xobject_cs(T2P* t2p, TIFF* output){ - float X_W = 1.0; - float Y_W = 1.0; - float Z_W = 1.0; + tsize_t written=0; + char buffer[128]; + int buflen=0; - if ((t2p->pdf_colorspace & T2P_CS_ICCBASED) != 0) - { - written += t2p_write_pdf_xobject_icccs(t2p, output); - return (written); - } - if ((t2p->pdf_colorspace & T2P_CS_PALETTE) != 0) - { - written += t2pWriteFile(output, (tdata_t) "[ /Indexed ", 11); - t2p->pdf_colorspace ^= T2P_CS_PALETTE; - written += t2p_write_pdf_xobject_cs(t2p, output); - t2p->pdf_colorspace |= T2P_CS_PALETTE; - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - (uint32_t)(0x1u << t2p->tiff_bitspersample) - 1u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " ", 1); - buflen = - snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->pdf_palettecs); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R ]\n", 7); - return (written); - } - if (t2p->pdf_colorspace & T2P_CS_BILEVEL) - { - written += t2pWriteFile(output, (tdata_t) "/DeviceGray \n", 13); - } - if (t2p->pdf_colorspace & T2P_CS_GRAY) - { - if (t2p->pdf_colorspace & T2P_CS_CALGRAY) - { - written += t2p_write_pdf_xobject_calcs(t2p, output); - } - else - { - written += t2pWriteFile(output, (tdata_t) "/DeviceGray \n", 13); - } - } - if (t2p->pdf_colorspace & T2P_CS_RGB) - { - if (t2p->pdf_colorspace & T2P_CS_CALRGB) - { - written += t2p_write_pdf_xobject_calcs(t2p, output); - } - else - { - written += t2pWriteFile(output, (tdata_t) "/DeviceRGB \n", 12); - } - } - if (t2p->pdf_colorspace & T2P_CS_CMYK) - { - written += t2pWriteFile(output, (tdata_t) "/DeviceCMYK \n", 13); - } - if (t2p->pdf_colorspace & T2P_CS_LAB) - { - written += t2pWriteFile(output, (tdata_t) "[/Lab << \n", 10); - written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12); - X_W = t2p->tiff_whitechromaticities[0]; - Y_W = t2p->tiff_whitechromaticities[1]; - Z_W = 1.0F - (X_W + Y_W); - normalizePoint(X_W, Y_W, Z_W); - buflen = snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, - Y_W, Z_W); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "/Range ", 7); - buflen = snprintf(buffer, sizeof(buffer), "[%d %d %d %d] \n", - t2p->pdf_labrange[0], t2p->pdf_labrange[1], - t2p->pdf_labrange[2], t2p->pdf_labrange[3]); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) ">>] \n", 5); - } - - return (written); + float X_W=1.0; + float Y_W=1.0; + float Z_W=1.0; + + if( (t2p->pdf_colorspace & T2P_CS_ICCBASED) != 0){ + written += t2p_write_pdf_xobject_icccs(t2p, output); + return(written); + } + if( (t2p->pdf_colorspace & T2P_CS_PALETTE) != 0){ + written += t2pWriteFile(output, (tdata_t) "[ /Indexed ", 11); + t2p->pdf_colorspace ^= T2P_CS_PALETTE; + written += t2p_write_pdf_xobject_cs(t2p, output); + t2p->pdf_colorspace |= T2P_CS_PALETTE; + buflen=snprintf(buffer, sizeof(buffer), "%u", (0x0001 << t2p->tiff_bitspersample)-1 ); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " ", 1); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_palettecs ); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ]\n", 7); + return(written); + } + if(t2p->pdf_colorspace & T2P_CS_BILEVEL){ + written += t2pWriteFile(output, (tdata_t) "/DeviceGray \n", 13); + } + if(t2p->pdf_colorspace & T2P_CS_GRAY){ + if(t2p->pdf_colorspace & T2P_CS_CALGRAY){ + written += t2p_write_pdf_xobject_calcs(t2p, output); + } else { + written += t2pWriteFile(output, (tdata_t) "/DeviceGray \n", 13); + } + } + if(t2p->pdf_colorspace & T2P_CS_RGB){ + if(t2p->pdf_colorspace & T2P_CS_CALRGB){ + written += t2p_write_pdf_xobject_calcs(t2p, output); + } else { + written += t2pWriteFile(output, (tdata_t) "/DeviceRGB \n", 12); + } + } + if(t2p->pdf_colorspace & T2P_CS_CMYK){ + written += t2pWriteFile(output, (tdata_t) "/DeviceCMYK \n", 13); + } + if(t2p->pdf_colorspace & T2P_CS_LAB){ + written += t2pWriteFile(output, (tdata_t) "[/Lab << \n", 10); + written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12); + X_W = t2p->tiff_whitechromaticities[0]; + Y_W = t2p->tiff_whitechromaticities[1]; + Z_W = 1.0F - (X_W + Y_W); + normalizePoint(X_W, Y_W, Z_W); + buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Range ", 7); + buflen=snprintf(buffer, sizeof(buffer), "[%d %d %d %d] \n", + t2p->pdf_labrange[0], + t2p->pdf_labrange[1], + t2p->pdf_labrange[2], + t2p->pdf_labrange[3]); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) ">>] \n", 5); + + } + + return(written); } -tsize_t t2p_write_pdf_transfer(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_transfer(T2P* t2p, TIFF* output){ - tsize_t written = 0; - char buffer[32]; - int buflen = 0; + tsize_t written=0; + char buffer[32]; + int buflen=0; - written += t2pWriteFile(output, (tdata_t) "<< /Type /ExtGState \n/TR ", 25); - if (t2p->tiff_transferfunctioncount == 1) - { - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->pdf_xrefcount + 1u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - } - else - { - written += t2pWriteFile(output, (tdata_t) "[ ", 2); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->pdf_xrefcount + 1u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->pdf_xrefcount + 2u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->pdf_xrefcount + 3u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); - written += t2pWriteFile(output, (tdata_t) "/Identity ] ", 12); - } + written += t2pWriteFile(output, (tdata_t) "<< /Type /ExtGState \n/TR ", 25); + if(t2p->tiff_transferfunctioncount == 1){ + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)(t2p->pdf_xrefcount + 1)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + } else { + written += t2pWriteFile(output, (tdata_t) "[ ", 2); + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)(t2p->pdf_xrefcount + 1)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)(t2p->pdf_xrefcount + 2)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)(t2p->pdf_xrefcount + 3)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R ", 5); + written += t2pWriteFile(output, (tdata_t) "/Identity ] ", 12); + } - written += t2pWriteFile(output, (tdata_t) " >> \n", 5); + written += t2pWriteFile(output, (tdata_t) " >> \n", 5); - return (written); + return(written); } -tsize_t t2p_write_pdf_transfer_dict(T2P *t2p, TIFF *output, uint16_t i) -{ +tsize_t t2p_write_pdf_transfer_dict(T2P* t2p, TIFF* output, uint16 i){ - tsize_t written = 0; - char buffer[32]; - int buflen = 0; - (void)i; /* XXX */ + tsize_t written=0; + char buffer[32]; + int buflen=0; + (void)i; /* XXX */ - written += t2pWriteFile(output, (tdata_t) "/FunctionType 0 \n", 17); - written += t2pWriteFile(output, (tdata_t) "/Domain [0.0 1.0] \n", 19); - written += t2pWriteFile(output, (tdata_t) "/Range [0.0 1.0] \n", 18); - buflen = snprintf(buffer, sizeof(buffer), "/Size [%" PRIu16 "] \n", - (uint16_t)(1u << t2p->tiff_bitspersample)); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "/BitsPerSample 16 \n", 19); - written += t2p_write_pdf_stream_dict( - ((tsize_t)1) << (t2p->tiff_bitspersample + 1), 0, output); + written += t2pWriteFile(output, (tdata_t) "/FunctionType 0 \n", 17); + written += t2pWriteFile(output, (tdata_t) "/Domain [0.0 1.0] \n", 19); + written += t2pWriteFile(output, (tdata_t) "/Range [0.0 1.0] \n", 18); + buflen=snprintf(buffer, sizeof(buffer), "/Size [%u] \n", (1<tiff_bitspersample)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/BitsPerSample 16 \n", 19); + written += t2p_write_pdf_stream_dict(((tsize_t)1)<<(t2p->tiff_bitspersample+1), 0, output); - return (written); + return(written); } -tsize_t t2p_write_pdf_transfer_stream(T2P *t2p, TIFF *output, uint16_t i) -{ +tsize_t t2p_write_pdf_transfer_stream(T2P* t2p, TIFF* output, uint16 i){ - tsize_t written = 0; + tsize_t written=0; - written += t2p_write_pdf_stream( - t2p->tiff_transferfunction[i], - (((tsize_t)1) << (t2p->tiff_bitspersample + 1)), output); + written += t2p_write_pdf_stream( + t2p->tiff_transferfunction[i], + (((tsize_t)1)<<(t2p->tiff_bitspersample+1)), + output); - return (written); + return(written); } /* - This function writes a PDF Image XObject Colorspace array to output. + This function writes a PDF Image XObject Colorspace array to output. */ -tsize_t t2p_write_pdf_xobject_calcs(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_xobject_calcs(T2P* t2p, TIFF* output){ - tsize_t written = 0; - char buffer[256]; - int buflen = 0; + tsize_t written=0; + char buffer[256]; + int buflen=0; + + float X_W=0.0; + float Y_W=0.0; + float Z_W=0.0; + float X_R=0.0; + float Y_R=0.0; + float Z_R=0.0; + float X_G=0.0; + float Y_G=0.0; + float Z_G=0.0; + float X_B=0.0; + float Y_B=0.0; + float Z_B=0.0; + float x_w=0.0; + float y_w=0.0; + float z_w=0.0; + float x_r=0.0; + float y_r=0.0; + float x_g=0.0; + float y_g=0.0; + float x_b=0.0; + float y_b=0.0; + float R=1.0; + float G=1.0; + float B=1.0; + + written += t2pWriteFile(output, (tdata_t) "[", 1); + if(t2p->pdf_colorspace & T2P_CS_CALGRAY){ + written += t2pWriteFile(output, (tdata_t) "/CalGray ", 9); + X_W = t2p->tiff_whitechromaticities[0]; + Y_W = t2p->tiff_whitechromaticities[1]; + Z_W = 1.0F - (X_W + Y_W); + normalizePoint(X_W, Y_W, Z_W); + } + if(t2p->pdf_colorspace & T2P_CS_CALRGB){ + written += t2pWriteFile(output, (tdata_t) "/CalRGB ", 8); + x_w = t2p->tiff_whitechromaticities[0]; + y_w = t2p->tiff_whitechromaticities[1]; + x_r = t2p->tiff_primarychromaticities[0]; + y_r = t2p->tiff_primarychromaticities[1]; + x_g = t2p->tiff_primarychromaticities[2]; + y_g = t2p->tiff_primarychromaticities[3]; + x_b = t2p->tiff_primarychromaticities[4]; + y_b = t2p->tiff_primarychromaticities[5]; + z_w = y_w * ((x_g - x_b)*y_r - (x_r-x_b)*y_g + (x_r-x_g)*y_b); + Y_R = (y_r/R) * ((x_g-x_b)*y_w - (x_w-x_b)*y_g + (x_w-x_g)*y_b) / z_w; + X_R = Y_R * x_r / y_r; + Z_R = Y_R * (((1-x_r)/y_r)-1); + Y_G = ((0.0F-(y_g))/G) * ((x_r-x_b)*y_w - (x_w-x_b)*y_r + (x_w-x_r)*y_b) / z_w; + X_G = Y_G * x_g / y_g; + Z_G = Y_G * (((1-x_g)/y_g)-1); + Y_B = (y_b/B) * ((x_r-x_g)*y_w - (x_w-x_g)*y_r + (x_w-x_r)*y_g) / z_w; + X_B = Y_B * x_b / y_b; + Z_B = Y_B * (((1-x_b)/y_b)-1); + X_W = (X_R * R) + (X_G * G) + (X_B * B); + Y_W = (Y_R * R) + (Y_G * G) + (Y_B * B); + Z_W = (Z_R * R) + (Z_G * G) + (Z_B * B); + normalizePoint(X_W, Y_W, Z_W); + } + written += t2pWriteFile(output, (tdata_t) "<< \n", 4); + if(t2p->pdf_colorspace & T2P_CS_CALGRAY){ + written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12); + buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Gamma 2.2 \n", 12); + } + if(t2p->pdf_colorspace & T2P_CS_CALRGB){ + written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12); + buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, Y_W, Z_W); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Matrix ", 8); + buflen=snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f] \n", + X_R, Y_R, Z_R, + X_G, Y_G, Z_G, + X_B, Y_B, Z_B); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Gamma [2.2 2.2 2.2] \n", 22); + } + written += t2pWriteFile(output, (tdata_t) ">>] \n", 5); - float X_W = 0.0; - float Y_W = 0.0; - float Z_W = 0.0; - float X_R = 0.0; - float Y_R = 0.0; - float Z_R = 0.0; - float X_G = 0.0; - float Y_G = 0.0; - float Z_G = 0.0; - float X_B = 0.0; - float Y_B = 0.0; - float Z_B = 0.0; - float x_w = 0.0; - float y_w = 0.0; - float z_w = 0.0; - float x_r = 0.0; - float y_r = 0.0; - float x_g = 0.0; - float y_g = 0.0; - float x_b = 0.0; - float y_b = 0.0; - float R = 1.0; - float G = 1.0; - float B = 1.0; - - written += t2pWriteFile(output, (tdata_t) "[", 1); - if (t2p->pdf_colorspace & T2P_CS_CALGRAY) - { - written += t2pWriteFile(output, (tdata_t) "/CalGray ", 9); - X_W = t2p->tiff_whitechromaticities[0]; - Y_W = t2p->tiff_whitechromaticities[1]; - Z_W = 1.0F - (X_W + Y_W); - normalizePoint(X_W, Y_W, Z_W); - } - if (t2p->pdf_colorspace & T2P_CS_CALRGB) - { - written += t2pWriteFile(output, (tdata_t) "/CalRGB ", 8); - x_w = t2p->tiff_whitechromaticities[0]; - y_w = t2p->tiff_whitechromaticities[1]; - x_r = t2p->tiff_primarychromaticities[0]; - y_r = t2p->tiff_primarychromaticities[1]; - x_g = t2p->tiff_primarychromaticities[2]; - y_g = t2p->tiff_primarychromaticities[3]; - x_b = t2p->tiff_primarychromaticities[4]; - y_b = t2p->tiff_primarychromaticities[5]; - z_w = y_w * ((x_g - x_b) * y_r - (x_r - x_b) * y_g + (x_r - x_g) * y_b); - Y_R = (y_r / R) * - ((x_g - x_b) * y_w - (x_w - x_b) * y_g + (x_w - x_g) * y_b) / z_w; - X_R = Y_R * x_r / y_r; - Z_R = Y_R * (((1 - x_r) / y_r) - 1); - Y_G = ((0.0F - (y_g)) / G) * - ((x_r - x_b) * y_w - (x_w - x_b) * y_r + (x_w - x_r) * y_b) / z_w; - X_G = Y_G * x_g / y_g; - Z_G = Y_G * (((1 - x_g) / y_g) - 1); - Y_B = (y_b / B) * - ((x_r - x_g) * y_w - (x_w - x_g) * y_r + (x_w - x_r) * y_g) / z_w; - X_B = Y_B * x_b / y_b; - Z_B = Y_B * (((1 - x_b) / y_b) - 1); - X_W = (X_R * R) + (X_G * G) + (X_B * B); - Y_W = (Y_R * R) + (Y_G * G) + (Y_B * B); - Z_W = (Z_R * R) + (Z_G * G) + (Z_B * B); - normalizePoint(X_W, Y_W, Z_W); - } - written += t2pWriteFile(output, (tdata_t) "<< \n", 4); - if (t2p->pdf_colorspace & T2P_CS_CALGRAY) - { - written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12); - buflen = snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, - Y_W, Z_W); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "/Gamma 2.2 \n", 12); - } - if (t2p->pdf_colorspace & T2P_CS_CALRGB) - { - written += t2pWriteFile(output, (tdata_t) "/WhitePoint ", 12); - buflen = snprintf(buffer, sizeof(buffer), "[%.4f %.4f %.4f] \n", X_W, - Y_W, Z_W); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "/Matrix ", 8); - buflen = snprintf(buffer, sizeof(buffer), - "[%.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f] \n", - X_R, Y_R, Z_R, X_G, Y_G, Z_G, X_B, Y_B, Z_B); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += - t2pWriteFile(output, (tdata_t) "/Gamma [2.2 2.2 2.2] \n", 22); - } - written += t2pWriteFile(output, (tdata_t) ">>] \n", 5); - - return (written); + return(written); } /* - This function writes a PDF Image XObject Colorspace array to output. + This function writes a PDF Image XObject Colorspace array to output. */ -tsize_t t2p_write_pdf_xobject_icccs(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_xobject_icccs(T2P* t2p, TIFF* output){ - tsize_t written = 0; - char buffer[32]; - int buflen = 0; + tsize_t written=0; + char buffer[32]; + int buflen=0; + + written += t2pWriteFile(output, (tdata_t) "[/ICCBased ", 11); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_icccs); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R] \n", 7); - written += t2pWriteFile(output, (tdata_t) "[/ICCBased ", 11); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->pdf_icccs); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R] \n", 7); - - return (written); + return(written); } -tsize_t t2p_write_pdf_xobject_icccs_dict(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_xobject_icccs_dict(T2P* t2p, TIFF* output){ - tsize_t written = 0; - char buffer[32]; - int buflen = 0; - - written += t2pWriteFile(output, (tdata_t) "/N ", 3); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu16 " \n", - t2p->tiff_samplesperpixel); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "/Alternate ", 11); - t2p->pdf_colorspace ^= T2P_CS_ICCBASED; - written += t2p_write_pdf_xobject_cs(t2p, output); - t2p->pdf_colorspace |= T2P_CS_ICCBASED; - written += t2p_write_pdf_stream_dict(t2p->tiff_iccprofilelength, 0, output); - - return (written); + tsize_t written=0; + char buffer[32]; + int buflen=0; + + written += t2pWriteFile(output, (tdata_t) "/N ", 3); + buflen=snprintf(buffer, sizeof(buffer), "%u \n", t2p->tiff_samplesperpixel); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "/Alternate ", 11); + t2p->pdf_colorspace ^= T2P_CS_ICCBASED; + written += t2p_write_pdf_xobject_cs(t2p, output); + t2p->pdf_colorspace |= T2P_CS_ICCBASED; + written += t2p_write_pdf_stream_dict(t2p->tiff_iccprofilelength, 0, output); + + return(written); } -tsize_t t2p_write_pdf_xobject_icccs_stream(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_xobject_icccs_stream(T2P* t2p, TIFF* output){ - tsize_t written = 0; + tsize_t written=0; - written += - t2p_write_pdf_stream((tdata_t)t2p->tiff_iccprofile, - (tsize_t)t2p->tiff_iccprofilelength, output); - - return (written); + written += t2p_write_pdf_stream( + (tdata_t) t2p->tiff_iccprofile, + (tsize_t) t2p->tiff_iccprofilelength, + output); + + return(written); } /* - This function writes a palette stream for an indexed color space to - output. + This function writes a palette stream for an indexed color space to output. */ -tsize_t t2p_write_pdf_xobject_palettecs_stream(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_xobject_palettecs_stream(T2P* t2p, TIFF* output){ - tsize_t written = 0; + tsize_t written=0; - written += t2p_write_pdf_stream((tdata_t)t2p->pdf_palette, - (tsize_t)t2p->pdf_palettesize, output); - - return (written); + written += t2p_write_pdf_stream( + (tdata_t) t2p->pdf_palette, + (tsize_t) t2p->pdf_palettesize, + output); + + return(written); } /* - This function writes a PDF Image XObject Decode array to output. + This function writes a PDF Image XObject Decode array to output. */ -tsize_t t2p_write_pdf_xobject_decode(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_xobject_decode(T2P* t2p, TIFF* output){ - tsize_t written = 0; - int i = 0; + tsize_t written=0; + int i=0; - written += t2pWriteFile(output, (tdata_t) "/Decode [ ", 10); - for (i = 0; i < t2p->tiff_samplesperpixel; i++) - { - written += t2pWriteFile(output, (tdata_t) "1 0 ", 4); - } - written += t2pWriteFile(output, (tdata_t) "]\n", 2); + written += t2pWriteFile(output, (tdata_t) "/Decode [ ", 10); + for (i=0;itiff_samplesperpixel;i++){ + written += t2pWriteFile(output, (tdata_t) "1 0 ", 4); + } + written += t2pWriteFile(output, (tdata_t) "]\n", 2); - return (written); + return(written); } /* - This function writes a PDF Image XObject stream filter name and - parameters to output. + This function writes a PDF Image XObject stream filter name and parameters to + output. */ -tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P *t2p, - TIFF *output) -{ +tsize_t t2p_write_pdf_xobject_stream_filter(ttile_t tile, T2P* t2p, TIFF* output){ - tsize_t written = 0; - char buffer[32]; - int buflen = 0; + tsize_t written=0; + char buffer[32]; + int buflen=0; - if (t2p->pdf_compression == T2P_COMPRESS_NONE) - { - return (written); - } - written += t2pWriteFile(output, (tdata_t) "/Filter ", 8); - switch (t2p->pdf_compression) - { + if(t2p->pdf_compression==T2P_COMPRESS_NONE){ + return(written); + } + written += t2pWriteFile(output, (tdata_t) "/Filter ", 8); + switch(t2p->pdf_compression){ #ifdef CCITT_SUPPORT - case T2P_COMPRESS_G4: - written += t2pWriteFile(output, (tdata_t) "/CCITTFaxDecode ", 16); - written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); - written += t2pWriteFile(output, (tdata_t) "<< /K -1 ", 9); - if (tile == 0) - { - written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_width); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_length); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - } - else - { - if (t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], - tile - 1) == 0) - { - written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); - buflen = snprintf( - buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - } - else - { - written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); - buflen = snprintf( - buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - } - if (t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], - tile - 1) == 0) - { - written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); - buflen = snprintf( - buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - } - else - { - written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); - buflen = snprintf( - buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - } - } - if (t2p->pdf_switchdecode == 0) - { - written += - t2pWriteFile(output, (tdata_t) " /BlackIs1 true ", 16); - } - written += t2pWriteFile(output, (tdata_t) ">>\n", 3); - break; + case T2P_COMPRESS_G4: + written += t2pWriteFile(output, (tdata_t) "/CCITTFaxDecode ", 16); + written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); + written += t2pWriteFile(output, (tdata_t) "<< /K -1 ", 9); + if(tile==0){ + written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_width); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_length); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } else { + if(t2p_tile_is_right_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ + written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilewidth); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } else { + written += t2pWriteFile(output, (tdata_t) "/Columns ", 9); + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilewidth); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } + if(t2p_tile_is_bottom_edge(t2p->tiff_tiles[t2p->pdf_page], tile-1)==0){ + written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_tilelength); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } else { + written += t2pWriteFile(output, (tdata_t) " /Rows ", 7); + buflen=snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_tiles[t2p->pdf_page].tiles_edgetilelength); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + } + } + if(t2p->pdf_switchdecode == 0){ + written += t2pWriteFile(output, (tdata_t) " /BlackIs1 true ", 16); + } + written += t2pWriteFile(output, (tdata_t) ">>\n", 3); + break; #endif #ifdef JPEG_SUPPORT - case T2P_COMPRESS_JPEG: - written += t2pWriteFile(output, (tdata_t) "/DCTDecode ", 11); + case T2P_COMPRESS_JPEG: + written += t2pWriteFile(output, (tdata_t) "/DCTDecode ", 11); - if (t2p->tiff_photometric != PHOTOMETRIC_YCBCR) - { - written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); - written += t2pWriteFile( - output, (tdata_t) "<< /ColorTransform 1 >>\n", 24); - } - break; + if(t2p->tiff_photometric != PHOTOMETRIC_YCBCR) { + written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); + written += t2pWriteFile(output, (tdata_t) "<< /ColorTransform 1 >>\n", 24); + } + break; #endif #ifdef ZIP_SUPPORT - case T2P_COMPRESS_ZIP: - written += t2pWriteFile(output, (tdata_t) "/FlateDecode ", 13); - if (t2p->pdf_compressionquality % 100) - { - written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); - written += t2pWriteFile(output, (tdata_t) "<< /Predictor ", 14); - buflen = - snprintf(buffer, sizeof(buffer), "%" PRIu16, - (uint16_t)(t2p->pdf_compressionquality % 100u)); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " /Columns ", 10); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, - t2p->tiff_width); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " /Colors ", 9); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu16, - t2p->tiff_samplesperpixel); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += - t2pWriteFile(output, (tdata_t) " /BitsPerComponent ", 19); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu16, - t2p->tiff_bitspersample); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) ">>\n", 3); - } - break; + case T2P_COMPRESS_ZIP: + written += t2pWriteFile(output, (tdata_t) "/FlateDecode ", 13); + if(t2p->pdf_compressionquality%100){ + written += t2pWriteFile(output, (tdata_t) "/DecodeParms ", 13); + written += t2pWriteFile(output, (tdata_t) "<< /Predictor ", 14); + buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->pdf_compressionquality%100); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " /Columns ", 10); + buflen = snprintf(buffer, sizeof(buffer), "%lu", + (unsigned long)t2p->tiff_width); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " /Colors ", 9); + buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_samplesperpixel); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " /BitsPerComponent ", 19); + buflen=snprintf(buffer, sizeof(buffer), "%u", t2p->tiff_bitspersample); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) ">>\n", 3); + } + break; #endif - default: - break; - } + default: + break; + } - return (written); + return(written); } /* - This function writes a PDF xref table to output. + This function writes a PDF xref table to output. */ -tsize_t t2p_write_pdf_xreftable(T2P *t2p, TIFF *output) -{ +tsize_t t2p_write_pdf_xreftable(T2P* t2p, TIFF* output){ - tsize_t written = 0; - char buffer[64]; - int buflen = 0; - uint32_t i = 0; + tsize_t written=0; + char buffer[64]; + int buflen=0; + uint32 i=0; - written += t2pWriteFile(output, (tdata_t) "xref\n0 ", 7); - buflen = - snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->pdf_xrefcount + 1u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " \n0000000000 65535 f \n", 22); - for (i = 0; i < t2p->pdf_xrefcount; i++) - { - snprintf(buffer, sizeof(buffer), "%.10lu 00000 n \n", - (unsigned long)t2p->pdf_xrefoffsets[i]); - written += t2pWriteFile(output, (tdata_t)buffer, 20); - } + written += t2pWriteFile(output, (tdata_t) "xref\n0 ", 7); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount + 1)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " \n0000000000 65535 f \n", 22); + for (i=0;ipdf_xrefcount;i++){ + snprintf(buffer, sizeof(buffer), "%.10lu 00000 n \n", + (unsigned long)t2p->pdf_xrefoffsets[i]); + written += t2pWriteFile(output, (tdata_t) buffer, 20); + } - return (written); + return(written); } /* * This function writes a PDF trailer to output. */ -tsize_t t2p_write_pdf_trailer(T2P *t2p, TIFF *output) +tsize_t t2p_write_pdf_trailer(T2P* t2p, TIFF* output) { - tsize_t written = 0; - char buffer[32]; - int buflen = 0; - size_t i = 0; + tsize_t written = 0; + char buffer[32]; + int buflen = 0; + size_t i = 0; - for (i = 0; i < sizeof(t2p->pdf_fileid) - 8; i += 8) - snprintf(t2p->pdf_fileid + i, 9, "%.8X", rand()); + for (i = 0; i < sizeof(t2p->pdf_fileid) - 8; i += 8) + snprintf(t2p->pdf_fileid + i, 9, "%.8X", rand()); - written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17); - buflen = - snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->pdf_xrefcount + 1u); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "\n/Root ", 7); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->pdf_catalog); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R \n/Info ", 12); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->pdf_info); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11); - written += t2pWriteFile(output, (tdata_t)t2p->pdf_fileid, - sizeof(t2p->pdf_fileid) - 1); - written += t2pWriteFile(output, (tdata_t) "><", 2); - written += t2pWriteFile(output, (tdata_t)t2p->pdf_fileid, - sizeof(t2p->pdf_fileid) - 1); - written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16); - buflen = snprintf(buffer, sizeof(buffer), "%" PRIu32, t2p->pdf_startxref); - check_snprintf_ret(t2p, buflen, buffer); - written += t2pWriteFile(output, (tdata_t)buffer, buflen); - written += t2pWriteFile(output, (tdata_t) "\n%%EOF\n", 7); + written += t2pWriteFile(output, (tdata_t) "trailer\n<<\n/Size ", 17); + buflen = snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)(t2p->pdf_xrefcount+1)); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n/Root ", 7); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_catalog); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R \n/Info ", 12); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_info); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) " 0 R \n/ID[<", 11); + written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, + sizeof(t2p->pdf_fileid) - 1); + written += t2pWriteFile(output, (tdata_t) "><", 2); + written += t2pWriteFile(output, (tdata_t) t2p->pdf_fileid, + sizeof(t2p->pdf_fileid) - 1); + written += t2pWriteFile(output, (tdata_t) ">]\n>>\nstartxref\n", 16); + buflen=snprintf(buffer, sizeof(buffer), "%lu", (unsigned long)t2p->pdf_startxref); + check_snprintf_ret(t2p, buflen, buffer); + written += t2pWriteFile(output, (tdata_t) buffer, buflen); + written += t2pWriteFile(output, (tdata_t) "\n%%EOF\n", 7); - return (written); + return(written); } - + /* This function writes a PDF to a file given a pointer to a TIFF. - The idea with using a TIFF* as output for a PDF file is that the file - can be created with TIFFClientOpen for memory-mapped use within the TIFF - library, and TIFFWriteEncodedStrip can be used to write compressed data to - the output. The output is not actually a TIFF file, it is a PDF file. + The idea with using a TIFF* as output for a PDF file is that the file + can be created with TIFFClientOpen for memory-mapped use within the TIFF + library, and TIFFWriteEncodedStrip can be used to write compressed data to + the output. The output is not actually a TIFF file, it is a PDF file. - This function uses only t2pWriteFile and TIFFWriteEncodedStrip to write to - the output TIFF file. When libtiff would otherwise be writing data to the - output file, the write procedure of the TIFF structure is replaced with an + This function uses only t2pWriteFile and TIFFWriteEncodedStrip to write to + the output TIFF file. When libtiff would otherwise be writing data to the + output file, the write procedure of the TIFF structure is replaced with an empty implementation. - The first argument to the function is an initialized and validated T2P + The first argument to the function is an initialized and validated T2P context struct pointer. - The second argument to the function is the TIFF* that is the input that has + The second argument to the function is the TIFF* that is the input that has been opened for reading and no other functions have been called upon it. - The third argument to the function is the TIFF* that is the output that has - been opened for writing. It has to be opened so that it hasn't written any - data to the output. If the output is seekable then it's OK to seek to the - beginning of the file. The function only writes to the output PDF and does + The third argument to the function is the TIFF* that is the output that has + been opened for writing. It has to be opened so that it hasn't written any + data to the output. If the output is seekable then it's OK to seek to the + beginning of the file. The function only writes to the output PDF and does not seek. See the example usage in the main() function. - TIFF* output = TIFFOpen("output.pdf", "w"); - assert(output != NULL); + TIFF* output = TIFFOpen("output.pdf", "w"); + assert(output != NULL); - if(output->tif_seekproc != NULL){ - t2pSeekFile(output, (toff_t) 0, SEEK_SET); - } + if(output->tif_seekproc != NULL){ + t2pSeekFile(output, (toff_t) 0, SEEK_SET); + } - This function returns the file size of the output PDF file. On error it + This function returns the file size of the output PDF file. On error it returns zero and the t2p->t2p_error variable is set to T2P_ERR_ERROR. - After this function completes, call t2p_free on t2p, TIFFClose on input, + After this function completes, call t2p_free on t2p, TIFFClose on input, and TIFFClose on output. */ -tsize_t t2p_write_pdf(T2P *t2p, TIFF *input, TIFF *output) -{ +tsize_t t2p_write_pdf(T2P* t2p, TIFF* input, TIFF* output){ - tsize_t written = 0; - ttile_t i2 = 0; - tsize_t streamlen = 0; - uint16_t i = 0; + tsize_t written=0; + ttile_t i2=0; + tsize_t streamlen=0; + uint16 i=0; - t2p_read_tiff_init(t2p, input); - if (t2p->t2p_error != T2P_ERR_OK) - { - return (0); - } - t2p->pdf_xrefoffsets = (uint32_t *)_TIFFmalloc( - TIFFSafeMultiply(tmsize_t, t2p->pdf_xrefcount, sizeof(uint32_t))); - if (t2p->pdf_xrefoffsets == NULL) - { - TIFFError(TIFF2PDF_MODULE, - "Can't allocate %" TIFF_SIZE_FORMAT - " bytes of memory for t2p_write_pdf", - sizeof(uint32_t) * t2p->pdf_xrefcount); - t2p->t2p_error = T2P_ERR_ERROR; - return (written); - } - t2p->pdf_xrefcount = 0; - t2p->pdf_catalog = 1; - t2p->pdf_info = 2; - t2p->pdf_pages = 3; - written += t2p_write_pdf_header(t2p, output); - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - t2p->pdf_catalog = t2p->pdf_xrefcount; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_catalog(t2p, output); - written += t2p_write_pdf_obj_end(output); - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - t2p->pdf_info = t2p->pdf_xrefcount; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_info(t2p, input, output); - written += t2p_write_pdf_obj_end(output); - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - t2p->pdf_pages = t2p->pdf_xrefcount; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_pages(t2p, output); - written += t2p_write_pdf_obj_end(output); - for (t2p->pdf_page = 0; t2p->pdf_page < t2p->tiff_pagecount; - t2p->pdf_page++) - { - t2p_read_tiff_data(t2p, input); - if (t2p->t2p_error != T2P_ERR_OK) - { - return (0); - } - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_page(t2p->pdf_xrefcount, t2p, output); - written += t2p_write_pdf_obj_end(output); - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_stream_dict_start(output); - written += t2p_write_pdf_stream_dict(0, t2p->pdf_xrefcount + 1, output); - written += t2p_write_pdf_stream_dict_end(output); - written += t2p_write_pdf_stream_start(output); - streamlen = written; - written += t2p_write_pdf_page_content_stream(t2p, output); - streamlen = written - streamlen; - written += t2p_write_pdf_stream_end(output); - written += t2p_write_pdf_obj_end(output); - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_stream_length(streamlen, output); - written += t2p_write_pdf_obj_end(output); - if (t2p->tiff_transferfunctioncount != 0) - { - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_transfer(t2p, output); - written += t2p_write_pdf_obj_end(output); - for (i = 0; i < t2p->tiff_transferfunctioncount; i++) - { - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_stream_dict_start(output); - written += t2p_write_pdf_transfer_dict(t2p, output, i); - written += t2p_write_pdf_stream_dict_end(output); - written += t2p_write_pdf_stream_start(output); - /* streamlen=written; */ /* value not used */ - written += t2p_write_pdf_transfer_stream(t2p, output, i); - /* streamlen=written-streamlen; */ /* value not used */ - written += t2p_write_pdf_stream_end(output); - written += t2p_write_pdf_obj_end(output); - } - } - if ((t2p->pdf_colorspace & T2P_CS_PALETTE) != 0) - { - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - t2p->pdf_palettecs = t2p->pdf_xrefcount; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_stream_dict_start(output); - written += - t2p_write_pdf_stream_dict(t2p->pdf_palettesize, 0, output); - written += t2p_write_pdf_stream_dict_end(output); - written += t2p_write_pdf_stream_start(output); - /* streamlen=written; */ /* value not used */ - written += t2p_write_pdf_xobject_palettecs_stream(t2p, output); - /* streamlen=written-streamlen; */ /* value not used */ - written += t2p_write_pdf_stream_end(output); - written += t2p_write_pdf_obj_end(output); - } - if ((t2p->pdf_colorspace & T2P_CS_ICCBASED) != 0) - { - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - t2p->pdf_icccs = t2p->pdf_xrefcount; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_stream_dict_start(output); - written += t2p_write_pdf_xobject_icccs_dict(t2p, output); - written += t2p_write_pdf_stream_dict_end(output); - written += t2p_write_pdf_stream_start(output); - /* streamlen=written; */ /* value not used */ - written += t2p_write_pdf_xobject_icccs_stream(t2p, output); - /* streamlen=written-streamlen; */ /* value not used */ - written += t2p_write_pdf_stream_end(output); - written += t2p_write_pdf_obj_end(output); - } - if (t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount != 0) - { - for (i2 = 0; i2 < t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount; - i2++) - { - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_stream_dict_start(output); - written += - t2p_write_pdf_xobject_stream_dict(i2 + 1, t2p, output); - written += t2p_write_pdf_stream_dict_end(output); - written += t2p_write_pdf_stream_start(output); - streamlen = written; - t2p_read_tiff_size_tile(t2p, input, i2); - if (t2p->tiff_maxdatasize && - (t2p->tiff_datasize > t2p->tiff_maxdatasize)) - { - TIFFError(TIFF2PDF_MODULE, - "Allocation of %" PRIu64 - " bytes is forbidden. Limit is %" PRIu64 - ". Use -m option to change limit", - (uint64_t)t2p->tiff_datasize, - (uint64_t)t2p->tiff_maxdatasize); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - written += t2p_readwrite_pdf_image_tile(t2p, input, output, i2); - t2p_write_advance_directory(t2p, output); - if (t2p->t2p_error != T2P_ERR_OK) - { - return (0); - } - streamlen = written - streamlen; - written += t2p_write_pdf_stream_end(output); - written += t2p_write_pdf_obj_end(output); - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_stream_length(streamlen, output); - written += t2p_write_pdf_obj_end(output); - } - } - else - { - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_stream_dict_start(output); - written += t2p_write_pdf_xobject_stream_dict(0, t2p, output); - written += t2p_write_pdf_stream_dict_end(output); - written += t2p_write_pdf_stream_start(output); - streamlen = written; - t2p_read_tiff_size(t2p, input); - if (t2p->tiff_maxdatasize && - (t2p->tiff_datasize > t2p->tiff_maxdatasize)) - { - TIFFError(TIFF2PDF_MODULE, - "Allocation of %" PRIu64 - " bytes is forbidden. Limit is %" PRIu64 - ". Use -m option to change limit", - (uint64_t)t2p->tiff_datasize, - (uint64_t)t2p->tiff_maxdatasize); - t2p->t2p_error = T2P_ERR_ERROR; - return (0); - } - written += t2p_readwrite_pdf_image(t2p, input, output); - t2p_write_advance_directory(t2p, output); - if (t2p->t2p_error != T2P_ERR_OK) - { - return (0); - } - streamlen = written - streamlen; - written += t2p_write_pdf_stream_end(output); - written += t2p_write_pdf_obj_end(output); - t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++] = written; - written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); - written += t2p_write_pdf_stream_length(streamlen, output); - written += t2p_write_pdf_obj_end(output); - } - } - t2p->pdf_startxref = written; - written += t2p_write_pdf_xreftable(t2p, output); - written += t2p_write_pdf_trailer(t2p, output); - t2p_disable(output); + t2p_read_tiff_init(t2p, input); + if(t2p->t2p_error!=T2P_ERR_OK){return(0);} + t2p->pdf_xrefoffsets= (uint32*) _TIFFmalloc(TIFFSafeMultiply(tmsize_t,t2p->pdf_xrefcount,sizeof(uint32)) ); + if(t2p->pdf_xrefoffsets==NULL){ + TIFFError( + TIFF2PDF_MODULE, + "Can't allocate %u bytes of memory for t2p_write_pdf", + (unsigned int) (t2p->pdf_xrefcount * sizeof(uint32)) ); + t2p->t2p_error = T2P_ERR_ERROR; + return(written); + } + t2p->pdf_xrefcount=0; + t2p->pdf_catalog=1; + t2p->pdf_info=2; + t2p->pdf_pages=3; + written += t2p_write_pdf_header(t2p, output); + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + t2p->pdf_catalog=t2p->pdf_xrefcount; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_catalog(t2p, output); + written += t2p_write_pdf_obj_end(output); + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + t2p->pdf_info=t2p->pdf_xrefcount; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_info(t2p, input, output); + written += t2p_write_pdf_obj_end(output); + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + t2p->pdf_pages=t2p->pdf_xrefcount; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_pages(t2p, output); + written += t2p_write_pdf_obj_end(output); + for(t2p->pdf_page=0;t2p->pdf_pagetiff_pagecount;t2p->pdf_page++){ + t2p_read_tiff_data(t2p, input); + if(t2p->t2p_error!=T2P_ERR_OK){return(0);} + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_page(t2p->pdf_xrefcount, t2p, output); + written += t2p_write_pdf_obj_end(output); + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_stream_dict_start(output); + written += t2p_write_pdf_stream_dict(0, t2p->pdf_xrefcount+1, output); + written += t2p_write_pdf_stream_dict_end(output); + written += t2p_write_pdf_stream_start(output); + streamlen=written; + written += t2p_write_pdf_page_content_stream(t2p, output); + streamlen=written-streamlen; + written += t2p_write_pdf_stream_end(output); + written += t2p_write_pdf_obj_end(output); + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_stream_length(streamlen, output); + written += t2p_write_pdf_obj_end(output); + if(t2p->tiff_transferfunctioncount != 0){ + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_transfer(t2p, output); + written += t2p_write_pdf_obj_end(output); + for(i=0; i < t2p->tiff_transferfunctioncount; i++){ + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_stream_dict_start(output); + written += t2p_write_pdf_transfer_dict(t2p, output, i); + written += t2p_write_pdf_stream_dict_end(output); + written += t2p_write_pdf_stream_start(output); + /* streamlen=written; */ /* value not used */ + written += t2p_write_pdf_transfer_stream(t2p, output, i); + /* streamlen=written-streamlen; */ /* value not used */ + written += t2p_write_pdf_stream_end(output); + written += t2p_write_pdf_obj_end(output); + } + } + if( (t2p->pdf_colorspace & T2P_CS_PALETTE) != 0){ + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + t2p->pdf_palettecs=t2p->pdf_xrefcount; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_stream_dict_start(output); + written += t2p_write_pdf_stream_dict(t2p->pdf_palettesize, 0, output); + written += t2p_write_pdf_stream_dict_end(output); + written += t2p_write_pdf_stream_start(output); + /* streamlen=written; */ /* value not used */ + written += t2p_write_pdf_xobject_palettecs_stream(t2p, output); + /* streamlen=written-streamlen; */ /* value not used */ + written += t2p_write_pdf_stream_end(output); + written += t2p_write_pdf_obj_end(output); + } + if( (t2p->pdf_colorspace & T2P_CS_ICCBASED) != 0){ + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + t2p->pdf_icccs=t2p->pdf_xrefcount; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_stream_dict_start(output); + written += t2p_write_pdf_xobject_icccs_dict(t2p, output); + written += t2p_write_pdf_stream_dict_end(output); + written += t2p_write_pdf_stream_start(output); + /* streamlen=written; */ /* value not used */ + written += t2p_write_pdf_xobject_icccs_stream(t2p, output); + /* streamlen=written-streamlen; */ /* value not used */ + written += t2p_write_pdf_stream_end(output); + written += t2p_write_pdf_obj_end(output); + } + if(t2p->tiff_tiles[t2p->pdf_page].tiles_tilecount !=0){ + for(i2=0;i2tiff_tiles[t2p->pdf_page].tiles_tilecount;i2++){ + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_stream_dict_start(output); + written += t2p_write_pdf_xobject_stream_dict( + i2+1, + t2p, + output); + written += t2p_write_pdf_stream_dict_end(output); + written += t2p_write_pdf_stream_start(output); + streamlen=written; + t2p_read_tiff_size_tile(t2p, input, i2); + if (t2p->tiff_maxdatasize && (t2p->tiff_datasize > t2p->tiff_maxdatasize)) { + TIFFError(TIFF2PDF_MODULE, + "Allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ". Use -m option to change limit", + (uint64)t2p->tiff_datasize, (uint64)t2p->tiff_maxdatasize); + t2p->t2p_error = T2P_ERR_ERROR; + return (0); + } + written += t2p_readwrite_pdf_image_tile(t2p, input, output, i2); + t2p_write_advance_directory(t2p, output); + if(t2p->t2p_error!=T2P_ERR_OK){return(0);} + streamlen=written-streamlen; + written += t2p_write_pdf_stream_end(output); + written += t2p_write_pdf_obj_end(output); + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_stream_length(streamlen, output); + written += t2p_write_pdf_obj_end(output); + } + } else { + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_stream_dict_start(output); + written += t2p_write_pdf_xobject_stream_dict( + 0, + t2p, + output); + written += t2p_write_pdf_stream_dict_end(output); + written += t2p_write_pdf_stream_start(output); + streamlen=written; + t2p_read_tiff_size(t2p, input); + if (t2p->tiff_maxdatasize && (t2p->tiff_datasize > t2p->tiff_maxdatasize)) { + TIFFError(TIFF2PDF_MODULE, + "Allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ". Use -m option to change limit", + (uint64)t2p->tiff_datasize, (uint64)t2p->tiff_maxdatasize); + t2p->t2p_error = T2P_ERR_ERROR; + return (0); + } + written += t2p_readwrite_pdf_image(t2p, input, output); + t2p_write_advance_directory(t2p, output); + if(t2p->t2p_error!=T2P_ERR_OK){return(0);} + streamlen=written-streamlen; + written += t2p_write_pdf_stream_end(output); + written += t2p_write_pdf_obj_end(output); + t2p->pdf_xrefoffsets[t2p->pdf_xrefcount++]=written; + written += t2p_write_pdf_obj_start(t2p->pdf_xrefcount, output); + written += t2p_write_pdf_stream_length(streamlen, output); + written += t2p_write_pdf_obj_end(output); + } + } + t2p->pdf_startxref = written; + written += t2p_write_pdf_xreftable(t2p, output); + written += t2p_write_pdf_trailer(t2p, output); + t2p_disable(output); - return (written); + return(written); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiff2ps.c b/thirdparty/SDL2_image/external/libtiff/tools/tiff2ps.c index 541495d23..4ed5eba27 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiff2ps.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiff2ps.c @@ -2,37 +2,40 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" -#include #include -#include /* for atof */ -#include +#include /* for atof */ +#include #include +#include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffio.h" @@ -61,7 +64,7 @@ * warning messages for incompatible command line options. * Add new command line options to specify PageOrientation * Document Structuring Comment for landscape or portrait - * and code to determine the values from output width and height + * and code to determine the values from ouput width and height * if not specified on the command line. * Add new command line option to specify document creator * as an alterntive to the string "tiff2ps" following model @@ -82,24 +85,24 @@ * * Identified incompatible options and returned errors, eg * -i for imagemask operator is only available for Level2 or - * Level3 Postscript in the current implementation since there + * Level3 Postscript in the current implmentation since there * is a difference in the way the operands are called for Level1 * and there is no function to provide the Level1 version. * -H was not handled properly if -h and/or -w were specified. * It should only clip the masked images if the scaled image * exceeds the maxPageHeight specified with -H. - * + * * New design allows for all of the following combinations: * Conversion of TIFF to Postscript with optional rotations * of 90, 180, 270, or auto degrees counterclockwise * Conversion of TIFF to Postscript with entire image scaled - * to maximum of values specified with -h or -w while + * to maximum of values spedified with -h or -w while * maintaining aspect ratio. Same rotations apply. * Conversion of TIFF to Postscript with clipping of output * viewport to height specified with -H, producing multiple * pages at this height and original width as needed. * Same rotations apply. - * Conversion of TIFF to Postscript with image scaled to + * Conversion of TIFF to Postscript with image scaled to * maximum specified by -h and -w and the resulting scaled * image is presented in an output viewport clipped by -H height. * The same rotations apply. @@ -168,11 +171,14 @@ * routine. So user beware, you have been warned! */ -#define EXP_ASCII85ENCODER +#define EXP_ASCII85ENCODER +/* + * NB: this code assumes uint32 works with printf's %l[ud]. + */ #ifndef TRUE -#define TRUE 1 -#define FALSE 0 +#define TRUE 1 +#define FALSE 0 #endif #define DEFAULT_MAX_MALLOC (256 * 1024 * 1024) @@ -181,472 +187,425 @@ * disabled when set to 0 */ static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC; -int ascii85 = FALSE; /* use ASCII85 encoding */ -int interpolate = TRUE; /* interpolate level2 image */ -int level2 = FALSE; /* generate PostScript level 2 */ -int level3 = FALSE; /* generate PostScript level 3 */ -int printAll = FALSE; /* print all images in file */ -int generateEPSF = TRUE; /* generate Encapsulated PostScript */ -int PSduplex = FALSE; /* enable duplex printing */ -int PStumble = FALSE; /* enable top edge binding */ -int PSavoiddeadzone = TRUE; /* enable avoiding printer deadzone */ -double maxPageHeight = - 0; /* maximum height to select from image and print per page */ -double maxPageWidth = - 0; /* maximum width to select from image and print per page */ -double splitOverlap = 0; /* amount for split pages to overlag */ -int rotation = 0; /* optional value for rotation angle */ -int auto_rotate = 0; /* rotate image for best fit on the page */ -char *filename = NULL; /* input filename */ -char *title = NULL; /* optional document title string */ -char *creator = NULL; /* optional document creator string */ -char pageOrientation[12]; /* set optional PageOrientation DSC to Landscape or - Portrait */ -int useImagemask = FALSE; /* Use imagemask instead of image operator */ -uint16_t res_unit = 0; /* Resolution units: 2 - inches, 3 - cm */ +int ascii85 = FALSE; /* use ASCII85 encoding */ +int interpolate = TRUE; /* interpolate level2 image */ +int level2 = FALSE; /* generate PostScript level 2 */ +int level3 = FALSE; /* generate PostScript level 3 */ +int printAll = FALSE; /* print all images in file */ +int generateEPSF = TRUE; /* generate Encapsulated PostScript */ +int PSduplex = FALSE; /* enable duplex printing */ +int PStumble = FALSE; /* enable top edge binding */ +int PSavoiddeadzone = TRUE; /* enable avoiding printer deadzone */ +double maxPageHeight = 0; /* maximum height to select from image and print per page */ +double maxPageWidth = 0; /* maximum width to select from image and print per page */ +double splitOverlap = 0; /* amount for split pages to overlag */ +int rotation = 0; /* optional value for rotation angle */ +int auto_rotate = 0; /* rotate image for best fit on the page */ +char *filename = NULL; /* input filename */ +char *title = NULL; /* optional document title string */ +char *creator = NULL; /* optional document creator string */ +char pageOrientation[12]; /* set optional PageOrientation DSC to Landscape or Portrait */ +int useImagemask = FALSE; /* Use imagemask instead of image operator */ +uint16 res_unit = 0; /* Resolution units: 2 - inches, 3 - cm */ /* * ASCII85 Encoding Support. */ unsigned char ascii85buf[10]; -int ascii85count; -int ascii85breaklen; +int ascii85count; +int ascii85breaklen; -int TIFF2PS(FILE *, TIFF *, double, double, double, double, int); -void PSpage(FILE *, TIFF *, uint32_t, uint32_t); -void PSColorContigPreamble(FILE *, uint32_t, uint32_t, int); -void PSColorSeparatePreamble(FILE *, uint32_t, uint32_t, int); -void PSDataColorContig(FILE *, TIFF *, uint32_t, uint32_t, int); -void PSDataColorSeparate(FILE *, TIFF *, uint32_t, uint32_t, int); -void PSDataPalette(FILE *, TIFF *, uint32_t, uint32_t); -void PSDataBW(FILE *, TIFF *, uint32_t, uint32_t); -void PSRawDataBW(FILE *, TIFF *, uint32_t, uint32_t); -void Ascii85Init(void); -void Ascii85Put(unsigned char code, FILE *fd); -void Ascii85Flush(FILE *fd); -void PSHead(FILE *, double, double, double, double); -void PSTail(FILE *, int); -int psStart(FILE *, int, int, int *, double *, double, double, double, double, - double, double, double, double, double, double); -int psPageSize(FILE *, int, double, double, double, double, double, double); -int psRotateImage(FILE *, int, double, double, double, double); -int psMaskImage(FILE *, TIFF *, int, int, int *, double, double, double, double, - double, double, double, double, double); -int psScaleImage(FILE *, double, int, int, double, double, double, double, - double, double); -int get_viewport(double, double, double, double, double *, double *, int); -int exportMaskedImage(FILE *, double, double, double, double, int, int, double, - double, double, int, int); +int TIFF2PS(FILE*, TIFF*, double, double, double, double, int); +void PSpage(FILE*, TIFF*, uint32, uint32); +void PSColorContigPreamble(FILE*, uint32, uint32, int); +void PSColorSeparatePreamble(FILE*, uint32, uint32, int); +void PSDataColorContig(FILE*, TIFF*, uint32, uint32, int); +void PSDataColorSeparate(FILE*, TIFF*, uint32, uint32, int); +void PSDataPalette(FILE*, TIFF*, uint32, uint32); +void PSDataBW(FILE*, TIFF*, uint32, uint32); +void PSRawDataBW(FILE*, TIFF*, uint32, uint32); +void Ascii85Init(void); +void Ascii85Put(unsigned char code, FILE* fd); +void Ascii85Flush(FILE* fd); +void PSHead(FILE*, double, double, double, double); +void PSTail(FILE*, int); +int psStart(FILE *, int, int, int *, double *, double, double, double, + double, double, double, double, double, double, double); +int psPageSize(FILE *, int, double, double, double, double, double, double); +int psRotateImage(FILE *, int, double, double, double, double); +int psMaskImage(FILE *, TIFF *, int, int, int *, double, double, + double, double, double, double, double, double, double); +int psScaleImage(FILE *, double, int, int, double, double, double, double, + double, double); +int get_viewport (double, double, double, double, double *, double *, int); +int exportMaskedImage(FILE *, double, double, double, double, int, int, + double, double, double, int, int); -#if defined(EXP_ASCII85ENCODER) -tsize_t Ascii85EncodeBlock(uint8_t *ascii85_p, unsigned f_eod, - const uint8_t *raw_p, tsize_t raw_l); +#if defined( EXP_ASCII85ENCODER) +tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, tsize_t raw_l ); #endif -static void usage(int); +static void usage(int); /** * This custom malloc function enforce a maximum allocation size */ -static void *limitMalloc(tmsize_t s) +static void* limitMalloc(tmsize_t s) { - /* tmsize_t is signed and _TIFFmalloc() converts s to size_t. Therefore - * check for negative s. */ - if (maxMalloc && ((s > maxMalloc) || (s < 0))) - { - fprintf(stderr, - "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT - " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", - s, maxMalloc); - fprintf(stderr, " use -M option to change limit.\n"); - return NULL; - } - return _TIFFmalloc(s); + if (maxMalloc && (s > maxMalloc)) { + fprintf(stderr, "MemoryLimitError: allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ".\n", + (uint64)s, (uint64)maxMalloc); + fprintf(stderr, " use -M option to change limit.\n"); + return NULL; + } + return _TIFFmalloc(s); } -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - int dirnum = -1, c, np = 0; - int centered = 0; - double bottommargin = 0; - double leftmargin = 0; - double pageWidth = 0; - double pageHeight = 0; - uint32_t diroff = 0; + int dirnum = -1, c, np = 0; + int centered = 0; + double bottommargin = 0; + double leftmargin = 0; + double pageWidth = 0; + double pageHeight = 0; + uint32 diroff = 0; #if !HAVE_DECL_OPTARG - extern char *optarg; - extern int optind; + extern char *optarg; + extern int optind; #endif - FILE *output = stdout; + FILE* output = stdout; - pageOrientation[0] = '\0'; + pageOrientation[0] = '\0'; - while ((c = getopt(argc, argv, - "b:d:h:H:W:L:M:i:w:l:o:O:P:C:r:t:acemxyzps1238DT")) != - -1) - switch (c) - { - case 'M': - maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; - break; - case 'b': - bottommargin = atof(optarg); - break; - case 'c': - centered = 1; - break; - case 'C': - creator = optarg; - break; - case 'd': /* without -a, this only processes one image at this IFD - */ - dirnum = atoi(optarg); - break; - case 'D': - PSduplex = TRUE; - break; - case 'i': - interpolate = atoi(optarg) ? TRUE : FALSE; - break; - case 'T': - PStumble = TRUE; - break; - case 'e': - PSavoiddeadzone = FALSE; - generateEPSF = TRUE; - break; - case 'h': - pageHeight = atof(optarg); - break; - case 'H': - maxPageHeight = atof(optarg); - break; - case 'W': - maxPageWidth = atof(optarg); - break; - case 'L': - splitOverlap = atof(optarg); - break; - case 'm': - useImagemask = TRUE; - break; - case 'o': - switch (optarg[0]) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - diroff = (uint32_t)strtoul(optarg, NULL, 0); + while ((c = getopt(argc, argv, "b:d:h:H:W:L:M:i:w:l:o:O:P:C:r:t:acemxyzps1238DT")) != -1) + switch (c) { + case 'M': + maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; + break; + case 'b': + bottommargin = atof(optarg); + break; + case 'c': + centered = 1; + break; + case 'C': + creator = optarg; + break; + case 'd': /* without -a, this only processes one image at this IFD */ + dirnum = atoi(optarg); + break; + case 'D': + PSduplex = TRUE; + break; + case 'i': + interpolate = atoi(optarg) ? TRUE:FALSE; + break; + case 'T': + PStumble = TRUE; + break; + case 'e': + PSavoiddeadzone = FALSE; + generateEPSF = TRUE; + break; + case 'h': + pageHeight = atof(optarg); + break; + case 'H': + maxPageHeight = atof(optarg); + break; + case 'W': + maxPageWidth = atof(optarg); + break; + case 'L': + splitOverlap = atof(optarg); + break; + case 'm': + useImagemask = TRUE; + break; + case 'o': + switch (optarg[0]) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': diroff = (uint32) strtoul(optarg, NULL, 0); + break; + default: TIFFError ("-o", "Offset must be a numeric value."); + exit (EXIT_FAILURE); + } + break; + case 'O': /* XXX too bad -o is already taken */ + output = fopen(optarg, "w"); + if (output == NULL) { + fprintf(stderr, + "%s: %s: Cannot open output file.\n", + argv[0], optarg); + exit (EXIT_FAILURE); + } + break; + case 'P': + switch (optarg[0]) + { + case 'l': + case 'L': strcpy (pageOrientation, "Landscape"); + break; + case 'p': + case 'P': strcpy (pageOrientation, "Portrait"); + break; + default: TIFFError ("-P", "Page orientation must be Landscape or Portrait"); + exit (EXIT_FAILURE); + } + break; + case 'l': + leftmargin = atof(optarg); + break; + case 'a': /* removed fall through to generate warning below, R Nolde 09-01-2010 */ + printAll = TRUE; + break; + case 'p': + generateEPSF = FALSE; + break; + case 'r': + if (strcmp (optarg, "auto") == 0) + { + rotation = 0; + auto_rotate = TRUE; + } + else + { + rotation = atoi(optarg); + auto_rotate = FALSE; + } + switch (rotation) + { + case 0: + case 90: + case 180: + case 270: + break; + default: + fprintf (stderr, "Rotation angle must be 90, 180, 270 (degrees ccw) or auto\n"); + exit (EXIT_FAILURE); + } + break; + case 's': + printAll = FALSE; + break; + case 't': + title = optarg; break; - default: - TIFFError("-o", "Offset must be a numeric value."); - exit(EXIT_FAILURE); - } - break; - case 'O': /* XXX too bad -o is already taken */ - output = fopen(optarg, "w"); - if (output == NULL) - { - fprintf(stderr, "%s: %s: Cannot open output file.\n", - argv[0], optarg); - exit(EXIT_FAILURE); - } - break; - case 'P': - switch (optarg[0]) - { - case 'l': - case 'L': - strcpy(pageOrientation, "Landscape"); - break; - case 'p': - case 'P': - strcpy(pageOrientation, "Portrait"); - break; - default: - TIFFError( - "-P", - "Page orientation must be Landscape or Portrait"); - exit(EXIT_FAILURE); - } - break; - case 'l': - leftmargin = atof(optarg); - break; - case 'a': /* removed fall through to generate warning below, R Nolde - 09-01-2010 */ - printAll = TRUE; - break; - case 'p': - generateEPSF = FALSE; - break; - case 'r': - if (strcmp(optarg, "auto") == 0) - { - rotation = 0; - auto_rotate = TRUE; - } - else - { - rotation = atoi(optarg); - auto_rotate = FALSE; - } - switch (rotation) - { - case 0: - case 90: - case 180: - case 270: - break; - default: - fprintf(stderr, "Rotation angle must be 90, 180, 270 " - "(degrees ccw) or auto\n"); - exit(EXIT_FAILURE); - } - break; - case 's': - printAll = FALSE; - break; - case 't': - title = optarg; - break; - case 'w': - pageWidth = atof(optarg); - break; - case 'z': - PSavoiddeadzone = FALSE; - break; - case '1': - level2 = FALSE; - level3 = FALSE; - ascii85 = FALSE; - break; - case '2': - level2 = TRUE; - ascii85 = TRUE; /* default to yes */ - break; - case '3': - level3 = TRUE; - ascii85 = TRUE; /* default to yes */ - break; - case '8': - ascii85 = FALSE; - break; - case 'x': - res_unit = RESUNIT_CENTIMETER; - break; - case 'y': - res_unit = RESUNIT_INCH; - break; - case '?': - usage(EXIT_FAILURE); - } + case 'w': + pageWidth = atof(optarg); + break; + case 'z': + PSavoiddeadzone = FALSE; + break; + case '1': + level2 = FALSE; + level3 = FALSE; + ascii85 = FALSE; + break; + case '2': + level2 = TRUE; + ascii85 = TRUE; /* default to yes */ + break; + case '3': + level3 = TRUE; + ascii85 = TRUE; /* default to yes */ + break; + case '8': + ascii85 = FALSE; + break; + case 'x': + res_unit = RESUNIT_CENTIMETER; + break; + case 'y': + res_unit = RESUNIT_INCH; + break; + case '?': + usage(EXIT_FAILURE); + } - if (useImagemask == TRUE) - { - if ((level2 == FALSE) && (level3 == FALSE)) - { - TIFFError( - "-m ", - " imagemask operator requires Postscript Level2 or Level3"); - exit(EXIT_FAILURE); - } - } - - if (pageWidth && (maxPageWidth > pageWidth)) - { - TIFFError("-W", "Max viewport width cannot exceed page width"); - exit(EXIT_FAILURE); - } - - /* auto rotate requires a specified page width and height */ - if (auto_rotate == TRUE) - { - /* - if ((pageWidth == 0) || (pageHeight == 0)) - TIFFWarning ("-r auto", " requires page height and width specified with - -h and -w"); - */ - if ((maxPageWidth > 0) || (maxPageHeight > 0)) - { - TIFFError("-r auto", " is incompatible with maximum page " - "width/height specified by -H or -W"); - exit(EXIT_FAILURE); - } - } - if ((maxPageWidth > 0) && (maxPageHeight > 0)) - { - TIFFError("-H and -W", - " Use only one of -H or -W to define a viewport"); - exit(EXIT_FAILURE); - } - - if ((generateEPSF == TRUE) && (printAll == TRUE)) - { - TIFFError(" -e and -a", "Warning: Cannot generate Encapsulated " - "Postscript for multiple images"); - generateEPSF = FALSE; - } - - if ((generateEPSF == TRUE) && (PSduplex == TRUE)) - { - TIFFError( - " -e and -D", - "Warning: Encapsulated Postscript does not support Duplex option"); - PSduplex = FALSE; - } - - if ((generateEPSF == TRUE) && (PStumble == TRUE)) - { - TIFFError(" -e and -T", "Warning: Encapsulated Postscript does not " - "support Top Edge Binding option"); - PStumble = FALSE; - } - - if ((generateEPSF == TRUE) && (PSavoiddeadzone == TRUE)) - PSavoiddeadzone = FALSE; - - for (; argc - optind > 0; optind++) - { - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - if (opts == NULL) - { - return EXIT_FAILURE; - } - TIFFOpenOptionsSetMaxSingleMemAlloc(opts, maxMalloc); - TIFF *tif = TIFFOpenExt(filename = argv[optind], "r", opts); - TIFFOpenOptionsFree(opts); - if (tif != NULL) - { - if (dirnum != -1 && !TIFFSetDirectory(tif, (tdir_t)dirnum)) + if (useImagemask == TRUE) + { + if ((level2 == FALSE) && (level3 == FALSE)) { - TIFFClose(tif); - return (EXIT_FAILURE); + TIFFError ("-m "," imagemask operator requres Postscript Level2 or Level3"); + exit (EXIT_FAILURE); } - else if (diroff != 0 && !TIFFSetSubDirectory(tif, diroff)) + } + + if (pageWidth && (maxPageWidth > pageWidth)) + { + TIFFError ("-W", "Max viewport width cannot exceed page width"); + exit (EXIT_FAILURE); + } + + /* auto rotate requires a specified page width and height */ + if (auto_rotate == TRUE) + { + /* + if ((pageWidth == 0) || (pageHeight == 0)) + TIFFWarning ("-r auto", " requires page height and width specified with -h and -w"); + */ + if ((maxPageWidth > 0) || (maxPageHeight > 0)) { - TIFFClose(tif); - return (EXIT_FAILURE); + TIFFError ("-r auto", " is incompatible with maximum page width/height specified by -H or -W"); + exit (EXIT_FAILURE); } - np = TIFF2PS(output, tif, pageWidth, pageHeight, leftmargin, - bottommargin, centered); - if (np < 0) + } + if ((maxPageWidth > 0) && (maxPageHeight > 0)) { - TIFFError("Error", "Unable to process %s", filename); + TIFFError ("-H and -W", " Use only one of -H or -W to define a viewport"); + exit (EXIT_FAILURE); } - TIFFClose(tif); - } - } - if (np) - PSTail(output, np); - else - usage(EXIT_FAILURE); - if (output != stdout) - fclose(output); - return (EXIT_SUCCESS); + + if ((generateEPSF == TRUE) && (printAll == TRUE)) + { + TIFFError(" -e and -a", "Warning: Cannot generate Encapsulated Postscript for multiple images"); + generateEPSF = FALSE; + } + + if ((generateEPSF == TRUE) && (PSduplex == TRUE)) + { + TIFFError(" -e and -D", "Warning: Encapsulated Postscript does not support Duplex option"); + PSduplex = FALSE; + } + + if ((generateEPSF == TRUE) && (PStumble == TRUE)) + { + TIFFError(" -e and -T", "Warning: Encapsulated Postscript does not support Top Edge Binding option"); + PStumble = FALSE; + } + + if ((generateEPSF == TRUE) && (PSavoiddeadzone == TRUE)) + PSavoiddeadzone = FALSE; + + for (; argc - optind > 0; optind++) { + TIFF* tif = TIFFOpen(filename = argv[optind], "r"); + if (tif != NULL) { + if (dirnum != -1 + && !TIFFSetDirectory(tif, (tdir_t)dirnum)) + { + TIFFClose(tif); + return (EXIT_FAILURE); + } + else if (diroff != 0 && + !TIFFSetSubDirectory(tif, diroff)) + { + TIFFClose(tif); + return (EXIT_FAILURE); + } + np = TIFF2PS(output, tif, pageWidth, pageHeight, + leftmargin, bottommargin, centered); + if (np < 0) + { + TIFFError("Error", "Unable to process %s", filename); + } + TIFFClose(tif); + } + } + if (np) + PSTail(output, np); + else + usage(EXIT_FAILURE); + if (output != stdout) + fclose(output); + return (EXIT_SUCCESS); } -static uint16_t samplesperpixel; -static uint16_t bitspersample; -static uint16_t planarconfiguration; -static uint16_t photometric; -static uint16_t compression; -static uint16_t extrasamples; -static int alpha; +static uint16 samplesperpixel; +static uint16 bitspersample; +static uint16 planarconfiguration; +static uint16 photometric; +static uint16 compression; +static uint16 extrasamples; +static int alpha; -static int checkImage(TIFF *tif) +static int +checkImage(TIFF* tif) { - switch (photometric) - { - case PHOTOMETRIC_YCBCR: - if ((compression == COMPRESSION_JPEG || - compression == COMPRESSION_OJPEG) && - planarconfiguration == PLANARCONFIG_CONTIG) - { - /* can rely on libjpeg to convert to RGB */ - TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - photometric = PHOTOMETRIC_RGB; - } - else - { - if (level2 || level3) - break; - TIFFError(filename, "Can not handle image with %s", - "PhotometricInterpretation=YCbCr"); - return (0); - } - /* fall through... */ - case PHOTOMETRIC_RGB: - if (alpha && bitspersample != 8) - { - TIFFError(filename, - "Can not handle %" PRIu16 - "-bit/sample RGB image with alpha", - bitspersample); - return (0); - } - /* fall through... */ - case PHOTOMETRIC_SEPARATED: - case PHOTOMETRIC_PALETTE: - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_MINISWHITE: - break; - case PHOTOMETRIC_LOGL: - case PHOTOMETRIC_LOGLUV: - if (compression != COMPRESSION_SGILOG && - compression != COMPRESSION_SGILOG24) - { - TIFFError( - filename, - "Can not handle %s data with compression other than SGILog", - (photometric == PHOTOMETRIC_LOGL) ? "LogL" : "LogLuv"); - return (0); - } - /* rely on library to convert to RGB/greyscale */ - TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); - photometric = (photometric == PHOTOMETRIC_LOGL) - ? PHOTOMETRIC_MINISBLACK - : PHOTOMETRIC_RGB; - bitspersample = 8; - break; - case PHOTOMETRIC_CIELAB: - /* fall through... */ - default: - TIFFError( - filename, - "Can not handle image with PhotometricInterpretation=%" PRIu16, - photometric); - return (0); - } - switch (bitspersample) - { - case 1: - case 2: - case 4: - case 8: - case 16: - break; - default: - TIFFError(filename, "Can not handle %" PRIu16 "-bit/sample image", - bitspersample); - return (0); - } - if (planarconfiguration == PLANARCONFIG_SEPARATE && extrasamples > 0) - TIFFWarning(filename, "Ignoring extra samples"); - return (1); + switch (photometric) { + case PHOTOMETRIC_YCBCR: + if ((compression == COMPRESSION_JPEG || compression == COMPRESSION_OJPEG) + && planarconfiguration == PLANARCONFIG_CONTIG) { + /* can rely on libjpeg to convert to RGB */ + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, + JPEGCOLORMODE_RGB); + photometric = PHOTOMETRIC_RGB; + } else { + if (level2 || level3) + break; + TIFFError(filename, "Can not handle image with %s", + "PhotometricInterpretation=YCbCr"); + return (0); + } + /* fall through... */ + case PHOTOMETRIC_RGB: + if (alpha && bitspersample != 8) { + TIFFError(filename, + "Can not handle %d-bit/sample RGB image with alpha", + bitspersample); + return (0); + } + /* fall through... */ + case PHOTOMETRIC_SEPARATED: + case PHOTOMETRIC_PALETTE: + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_MINISWHITE: + break; + case PHOTOMETRIC_LOGL: + case PHOTOMETRIC_LOGLUV: + if (compression != COMPRESSION_SGILOG && + compression != COMPRESSION_SGILOG24) { + TIFFError(filename, + "Can not handle %s data with compression other than SGILog", + (photometric == PHOTOMETRIC_LOGL) ? + "LogL" : "LogLuv" + ); + return (0); + } + /* rely on library to convert to RGB/greyscale */ + TIFFSetField(tif, TIFFTAG_SGILOGDATAFMT, SGILOGDATAFMT_8BIT); + photometric = (photometric == PHOTOMETRIC_LOGL) ? + PHOTOMETRIC_MINISBLACK : PHOTOMETRIC_RGB; + bitspersample = 8; + break; + case PHOTOMETRIC_CIELAB: + /* fall through... */ + default: + TIFFError(filename, + "Can not handle image with PhotometricInterpretation=%d", + photometric); + return (0); + } + switch (bitspersample) { + case 1: case 2: + case 4: case 8: + case 16: + break; + default: + TIFFError(filename, "Can not handle %d-bit/sample image", + bitspersample); + return (0); + } + if (planarconfiguration == PLANARCONFIG_SEPARATE && extrasamples > 0) + TIFFWarning(filename, "Ignoring extra samples"); + return (1); } -#define PS_UNIT_SIZE 72.0F -#define PSUNITS(npix, res) ((npix) * (PS_UNIT_SIZE / (res))) +#define PS_UNIT_SIZE 72.0F +#define PSUNITS(npix,res) ((npix) * (PS_UNIT_SIZE / (res))) -static const char RGBcolorimage[] = "\ +static char RGBcolorimage[] = "\ /bwproc {\n\ rgbproc\n\ dup length 3 idiv string 0 3 0\n\ @@ -675,88 +634,87 @@ static const char RGBcolorimage[] = "\ * * It is claimed to be part of some future revision of the EPS spec. */ -static void PhotoshopBanner(FILE *fd, uint32_t w, uint32_t h, int bs, int nc, - const char *startline) +static void +PhotoshopBanner(FILE* fd, uint32 w, uint32 h, int bs, int nc, char* startline) { - fprintf(fd, "%%ImageData: %" PRIu32 " %" PRIu32 " %" PRIu16 " %d 0 %d 2 \"", - w, h, bitspersample, nc, bs); - fprintf(fd, startline, nc); - fprintf(fd, "\"\n"); + fprintf(fd, "%%ImageData: %ld %ld %d %d 0 %d 2 \"", + (long) w, (long) h, bitspersample, nc, bs); + fprintf(fd, startline, nc); + fprintf(fd, "\"\n"); } -/* Convert pixel width and height pw, ph, to points pprw, pprh +/* Convert pixel width and height pw, ph, to points pprw, pprh * using image resolution and resolution units from TIFF tags. * pw : image width in pixels * ph : image height in pixels * pprw : image width in PS units (72 dpi) * pprh : image height in PS units (72 dpi) */ -static void setupPageState(TIFF *tif, uint32_t *pw, uint32_t *ph, double *pprw, - double *pprh) +static void +setupPageState(TIFF* tif, uint32* pw, uint32* ph, double* pprw, double* pprh) { - float xres = 0.0F, yres = 0.0F; + float xres = 0.0F, yres = 0.0F; - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, pw); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, ph); - if (res_unit == 0) /* Not specified as command line option */ - if (!TIFFGetFieldDefaulted(tif, TIFFTAG_RESOLUTIONUNIT, &res_unit)) - res_unit = RESUNIT_INCH; - /* - * Calculate printable area. - */ - if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) || - fabs(xres) < 0.0000001) - xres = PS_UNIT_SIZE; - if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) || - fabs(yres) < 0.0000001) - yres = PS_UNIT_SIZE; - switch (res_unit) - { - case RESUNIT_CENTIMETER: - xres *= 2.54F, yres *= 2.54F; - break; - case RESUNIT_INCH: - break; - case RESUNIT_NONE: /* Subsequent code assumes we have converted to - inches! */ - res_unit = RESUNIT_INCH; - break; - default: /* Last ditch guess for unspecified RESUNIT case - * check that the resolution is not inches before scaling it. - * Moved to end of function with additional check, RJN, - * 08-31-2010 if (xres != PS_UNIT_SIZE || yres != PS_UNIT_SIZE) - * xres *= PS_UNIT_SIZE, yres *= PS_UNIT_SIZE; - */ - break; - } - /* This is a hack to deal with images that have no meaningful Resolution - * Size but may have x and/or y resolutions of 1 pixel per undefined unit. - */ - if ((xres > 1.0) && (xres != PS_UNIT_SIZE)) - *pprw = PSUNITS(*pw, xres); - else - *pprw = PSUNITS(*pw, PS_UNIT_SIZE); - if ((yres > 1.0) && (yres != PS_UNIT_SIZE)) - *pprh = PSUNITS(*ph, yres); - else - *pprh = PSUNITS(*ph, PS_UNIT_SIZE); + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, pw); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, ph); + if (res_unit == 0) /* Not specified as command line option */ + if (!TIFFGetFieldDefaulted(tif, TIFFTAG_RESOLUTIONUNIT, &res_unit)) + res_unit = RESUNIT_INCH; + /* + * Calculate printable area. + */ + if (!TIFFGetField(tif, TIFFTAG_XRESOLUTION, &xres) + || fabs(xres) < 0.0000001) + xres = PS_UNIT_SIZE; + if (!TIFFGetField(tif, TIFFTAG_YRESOLUTION, &yres) + || fabs(yres) < 0.0000001) + yres = PS_UNIT_SIZE; + switch (res_unit) { + case RESUNIT_CENTIMETER: + xres *= 2.54F, yres *= 2.54F; + break; + case RESUNIT_INCH: + break; + case RESUNIT_NONE: /* Subsequent code assumes we have converted to inches! */ + res_unit = RESUNIT_INCH; + break; + default: /* Last ditch guess for unspecified RESUNIT case + * check that the resolution is not inches before scaling it. + * Moved to end of function with additional check, RJN, 08-31-2010 + * if (xres != PS_UNIT_SIZE || yres != PS_UNIT_SIZE) + * xres *= PS_UNIT_SIZE, yres *= PS_UNIT_SIZE; + */ + break; + } + /* This is a hack to deal with images that have no meaningful Resolution Size + * but may have x and/or y resolutions of 1 pixel per undefined unit. + */ + if ((xres > 1.0) && (xres != PS_UNIT_SIZE)) + *pprw = PSUNITS(*pw, xres); + else + *pprw = PSUNITS(*pw, PS_UNIT_SIZE); + if ((yres > 1.0) && (yres != PS_UNIT_SIZE)) + *pprh = PSUNITS(*ph, yres); + else + *pprh = PSUNITS(*ph, PS_UNIT_SIZE); } -static int isCCITTCompression(TIFF *tif) +static int +isCCITTCompression(TIFF* tif) { - uint16_t compress; + uint16 compress; TIFFGetField(tif, TIFFTAG_COMPRESSION, &compress); return (compress == COMPRESSION_CCITTFAX3 || - compress == COMPRESSION_CCITTFAX4 || - compress == COMPRESSION_CCITTRLE || - compress == COMPRESSION_CCITTRLEW); + compress == COMPRESSION_CCITTFAX4 || + compress == COMPRESSION_CCITTRLE || + compress == COMPRESSION_CCITTRLEW); } -static tsize_t tf_bytesperrow; -static tsize_t ps_bytesperrow; -static uint32_t tf_rowsperstrip; -static uint32_t tf_numberstrips; -static char *hex = "0123456789abcdef"; +static tsize_t tf_bytesperrow; +static tsize_t ps_bytesperrow; +static uint32 tf_rowsperstrip; +static uint32 tf_numberstrips; +static char *hex = "0123456789abcdef"; /* * Pagewidth and pageheight are the output size in points, @@ -767,1106 +725,935 @@ static char *hex = "0123456789abcdef"; * Only one of maxPageHeight or maxPageWidth can be used. * These are global variables unfortunately. */ -int get_subimage_count(double pagewidth, double pageheight, double imagewidth, - double imageheight, int *ximages, int *yimages, - int rotation, double scale) +int get_subimage_count(double pagewidth, double pageheight, + double imagewidth, double imageheight, + int *ximages, int *yimages, + int rotation, double scale) { - int pages = 1; - double splitheight = 0; /* Requested Max Height in points */ - double splitwidth = 0; /* Requested Max Width in points */ - double overlap = 0; /* Repeated edge width in points */ + int pages = 1; + double splitheight = 0; /* Requested Max Height in points */ + double splitwidth = 0; /* Requested Max Width in points */ + double overlap = 0; /* Repeated edge width in points */ - splitheight = maxPageHeight * PS_UNIT_SIZE; - splitwidth = maxPageWidth * PS_UNIT_SIZE; - overlap = splitOverlap * PS_UNIT_SIZE; - pagewidth *= PS_UNIT_SIZE; - pageheight *= PS_UNIT_SIZE; + splitheight = maxPageHeight * PS_UNIT_SIZE; + splitwidth = maxPageWidth * PS_UNIT_SIZE; + overlap = splitOverlap * PS_UNIT_SIZE; + pagewidth *= PS_UNIT_SIZE; + pageheight *= PS_UNIT_SIZE; - if ((imagewidth < 1.0) || (imageheight < 1.0)) + if ((imagewidth < 1.0) || (imageheight < 1.0)) + { + TIFFError("get_subimage_count", "Invalid image width or height"); + return (0); + } + + switch (rotation) { - TIFFError("get_subimage_count", "Invalid image width or height"); - return (0); - } - - switch (rotation) - { - case 0: - case 180: - if (splitheight > 0) /* -H maxPageHeight */ - { - if (imageheight > - splitheight) /* More than one vertical image segment */ + case 0: + case 180: if (splitheight > 0) /* -H maxPageHeight */ { - if (pagewidth) - *ximages = (int)ceil((scale * imagewidth) / - (pagewidth - overlap)); - else - *ximages = 1; - *yimages = (int)ceil( - (scale * imageheight) / - (splitheight - overlap)); /* Max vert pages needed */ - } + if (imageheight > splitheight) /* More than one vertical image segment */ + { + if (pagewidth) + *ximages = (int)ceil((scale * imagewidth) / (pagewidth - overlap)); + else + *ximages = 1; + *yimages = (int)ceil((scale * imageheight) / (splitheight - overlap)); /* Max vert pages needed */ + } else - { - if (pagewidth) - *ximages = (int)ceil( - (scale * imagewidth) / - (pagewidth - overlap)); /* Max horz pages needed */ - else - *ximages = 1; - *yimages = 1; /* Max vert pages needed */ - } - } - else - { + { + if (pagewidth) + *ximages = (int)ceil((scale * imagewidth) / (pagewidth - overlap)); /* Max horz pages needed */ + else + *ximages = 1; + *yimages = 1; /* Max vert pages needed */ + } + } + else + { if (splitwidth > 0) /* -W maxPageWidth */ - { - if (imagewidth > splitwidth) - { - *ximages = (int)ceil( - (scale * imagewidth) / - (splitwidth - overlap)); /* Max horz pages needed */ - if (pageheight) - *yimages = (int)ceil( - (scale * imageheight) / - (pageheight - - overlap)); /* Max vert pages needed */ - else - *yimages = 1; - } + { + if (imagewidth >splitwidth) + { + *ximages = (int)ceil((scale * imagewidth) / (splitwidth - overlap)); /* Max horz pages needed */ + if (pageheight) + *yimages = (int)ceil((scale * imageheight) / (pageheight - overlap)); /* Max vert pages needed */ else - { - *ximages = 1; /* Max vert pages needed */ - if (pageheight) - *yimages = (int)ceil( - (scale * imageheight) / - (pageheight - - overlap)); /* Max vert pages needed */ - else - *yimages = 1; - } - } + *yimages = 1; + } + else + { + *ximages = 1; /* Max vert pages needed */ + if (pageheight) + *yimages = (int)ceil((scale * imageheight) / (pageheight - overlap)); /* Max vert pages needed */ + else + *yimages = 1; + } + } else + { + *ximages = 1; + *yimages = 1; + } + } + break; + case 90: + case 270: if (splitheight > 0) /* -H maxPageHeight */ { - *ximages = 1; - *yimages = 1; - } - } - break; - case 90: - case 270: - if (splitheight > 0) /* -H maxPageHeight */ - { - if (imagewidth > - splitheight) /* More than one vertical image segment */ - { - *yimages = (int)ceil( - (scale * imagewidth) / - (splitheight - overlap)); /* Max vert pages needed */ - if (pagewidth) - *ximages = (int)ceil( - (scale * imageheight) / - (pagewidth - overlap)); /* Max horz pages needed */ - else - *ximages = 1; - } + if (imagewidth > splitheight) /* More than one vertical image segment */ + { + *yimages = (int)ceil((scale * imagewidth) / (splitheight - overlap)); /* Max vert pages needed */ + if (pagewidth) + *ximages = (int)ceil((scale * imageheight) / (pagewidth - overlap)); /* Max horz pages needed */ + else + *ximages = 1; + } else - { - *yimages = 1; /* Max vert pages needed */ - if (pagewidth) - *ximages = (int)ceil( - (scale * imageheight) / - (pagewidth - overlap)); /* Max horz pages needed */ - else - *ximages = 1; - } - } - else - { + { + *yimages = 1; /* Max vert pages needed */ + if (pagewidth) + *ximages = (int)ceil((scale * imageheight) / (pagewidth - overlap)); /* Max horz pages needed */ + else + *ximages = 1; + } + } + else + { if (splitwidth > 0) /* -W maxPageWidth */ - { - if (imageheight > splitwidth) - { - if (pageheight) - *yimages = (int)ceil( - (scale * imagewidth) / - (pageheight - - overlap)); /* Max vert pages needed */ - else - *yimages = 1; - *ximages = (int)ceil( - (scale * imageheight) / - (splitwidth - overlap)); /* Max horz pages needed */ - } + { + if (imageheight > splitwidth) + { + if (pageheight) + *yimages = (int)ceil((scale * imagewidth) / (pageheight - overlap)); /* Max vert pages needed */ else - { - if (pageheight) - *yimages = (int)ceil( - (scale * imagewidth) / - (pageheight - - overlap)); /* Max horz pages needed */ - else - *yimages = 1; - *ximages = 1; /* Max vert pages needed */ - } - } + *yimages = 1; + *ximages = (int)ceil((scale * imageheight) / (splitwidth - overlap)); /* Max horz pages needed */ + } + else + { + if (pageheight) + *yimages = (int)ceil((scale * imagewidth) / (pageheight - overlap)); /* Max horz pages needed */ + else + *yimages = 1; + *ximages = 1; /* Max vert pages needed */ + } + } else - { - *ximages = 1; - *yimages = 1; - } - } - break; - default: - *ximages = 1; - *yimages = 1; - } - pages = (*ximages) * (*yimages); - return (pages); -} + { + *ximages = 1; + *yimages = 1; + } + } + break; + default: *ximages = 1; + *yimages = 1; + } + pages = (*ximages) * (*yimages); + return (pages); + } /* New version of PlaceImage that handles only the translation and rotation * for a single output page. */ int exportMaskedImage(FILE *fp, double pagewidth, double pageheight, - double imagewidth, double imageheight, int row, - int column, double left_offset, double bott_offset, - double scale, int center, int rotation) -{ - double xtran = 0.0; - double ytran = 0.0; + double imagewidth, double imageheight, + int row, int column, + double left_offset, double bott_offset, + double scale, int center, int rotation) + { + double xtran = 0.0; + double ytran = 0.0; - double xscale = 1.0; - double yscale = 1.0; + double xscale = 1.0; + double yscale = 1.0; - double splitheight = 0; /* Requested Max Height in points */ - double splitwidth = 0; /* Requested Max Width in points */ - double overlap = 0; /* Repeated edge width in points */ - double subimage_height = 0.0; + double splitheight = 0; /* Requested Max Height in points */ + double splitwidth = 0; /* Requested Max Width in points */ + double overlap = 0; /* Repeated edge width in points */ + double subimage_height = 0.0; - splitheight = maxPageHeight * PS_UNIT_SIZE; - splitwidth = maxPageWidth * PS_UNIT_SIZE; - overlap = splitOverlap * PS_UNIT_SIZE; - xscale = scale * imagewidth; - yscale = scale * imageheight; + splitheight = maxPageHeight * PS_UNIT_SIZE; + splitwidth = maxPageWidth * PS_UNIT_SIZE; + overlap = splitOverlap * PS_UNIT_SIZE; + xscale = scale * imagewidth; + yscale = scale * imageheight; - if ((xscale < 0.0) || (yscale < 0.0)) + if ((xscale < 0.0) || (yscale < 0.0)) { - TIFFError("exportMaskedImage", "Invalid parameters."); - return (-1); + TIFFError("exportMaskedImage", "Invalid parameters."); + return (-1); } - /* If images are cropped to a vewport with -H or -W, the output pages are - * shifted to the top of each output page rather than the Postscript default - * lower edge. - */ - switch (rotation) + /* If images are cropped to a vewport with -H or -W, the output pages are shifted to + * the top of each output page rather than the Postscript default lower edge. + */ + switch (rotation) { - case 0: - case 180: - if (splitheight > 0) /* -H maxPageHeight */ - { - if (splitheight < - imageheight) /* More than one vertical image segments */ + case 0: + case 180: if (splitheight > 0) /* -H maxPageHeight */ { - /* Intra2net: Keep correct apspect ratio */ - xscale = (imagewidth + overlap) * - (pageheight / splitheight) * scale; + if (splitheight < imageheight) /* More than one vertical image segments */ + { + /* Intra2net: Keep correct apspect ratio */ + xscale = (imagewidth + overlap) * (pageheight / splitheight) * scale; - xtran = -1.0 * column * (pagewidth - overlap); - subimage_height = - imageheight - ((splitheight - overlap) * row); - ytran = pageheight - - subimage_height * (pageheight / splitheight); - } - else /* Only one page in vertical direction */ - { - xtran = -1.0 * column * (pagewidth - overlap); - ytran = splitheight - imageheight; - } - } - else - { + xtran = -1.0 * column * (pagewidth - overlap); + subimage_height = imageheight - ((splitheight - overlap) * row); + ytran = pageheight - subimage_height * (pageheight / splitheight); + } + else /* Only one page in vertical direction */ + { + xtran = -1.0 * column * (pagewidth - overlap); + ytran = splitheight - imageheight; + } + } + else + { if (splitwidth > 0) /* maxPageWidth */ - { - if (splitwidth < imagewidth) - { - xtran = -1.0 * column * splitwidth; - ytran = -1.0 * row * (pageheight - overlap); + { + if (splitwidth < imagewidth) + { + xtran = -1.0 * column * splitwidth; + ytran = -1.0 * row * (pageheight - overlap); } - else /* Only one page in horizontal direction */ - { - ytran = -1.0 * row * (pageheight - overlap); - xtran = 0; - } - } - else /* Simple case, no splitting */ - { - ytran = pageheight - imageheight; + else /* Only one page in horizontal direction */ + { + ytran = -1.0 * row * (pageheight - overlap); xtran = 0; + } + } + else /* Simple case, no splitting */ + { + ytran = pageheight - imageheight; + xtran = 0; + } } - } - if (imagewidth <= pagewidth) - { - /* Intra2net: Crop page at the bottom instead of the top (-> - output starts at the top). Only do this in non-page-split - mode */ - if (imageheight <= splitheight) - { - ytran = pageheight - - imageheight; /* Note: Will be negative for images - longer than page size */ + if (imagewidth <= pagewidth) { + /* Intra2net: Crop page at the bottom instead of the top (-> output starts at the top). + Only do this in non-page-split mode */ + if (imageheight <= splitheight) { + ytran = pageheight - imageheight; /* Note: Will be negative for images longer than page size */ } } - bott_offset += ytran / (center ? 2 : 1); - left_offset += xtran / (center ? 2 : 1); - break; - case 90: - case 270: - if (splitheight > 0) /* -H maxPageHeight */ - { - if (splitheight < - imagewidth) /* More than one vertical image segments */ + bott_offset += ytran / (center ? 2 : 1); + left_offset += xtran / (center ? 2 : 1); + break; + case 90: + case 270: if (splitheight > 0) /* -H maxPageHeight */ { - xtran = -1.0 * column * (pageheight - overlap); - /* Commented code places image at bottom of page instead of - top. ytran = -1.0 * row * splitheight; - */ - if (row == 0) - ytran = -1.0 * (imagewidth - splitheight); - else - ytran = -1.0 * (imagewidth - - (splitheight - overlap) * (row + 1)); - } - else /* Only one page in vertical direction */ - { - xtran = -1.0 * column * (pageheight - overlap); - ytran = splitheight - imagewidth; - } - } - else - { + if (splitheight < imagewidth) /* More than one vertical image segments */ + { + xtran = -1.0 * column * (pageheight - overlap); + /* Commented code places image at bottom of page instead of top. + ytran = -1.0 * row * splitheight; + */ + if (row == 0) + ytran = -1.0 * (imagewidth - splitheight); + else + ytran = -1.0 * (imagewidth - (splitheight - overlap) * (row + 1)); + } + else /* Only one page in vertical direction */ + { + xtran = -1.0 * column * (pageheight - overlap); + ytran = splitheight - imagewidth; + } + } + else + { if (splitwidth > 0) /* maxPageWidth */ - { - if (splitwidth < imageheight) - { - xtran = -1.0 * column * splitwidth; - ytran = -1.0 * row * (pagewidth - overlap); - } - else /* Only one page in horizontal direction */ - { - ytran = -1.0 * row * (pagewidth - overlap); - xtran = 0; + { + if (splitwidth < imageheight) + { + xtran = -1.0 * column * splitwidth; + ytran = -1.0 * row * (pagewidth - overlap); } + else /* Only one page in horizontal direction */ + { + ytran = -1.0 * row * (pagewidth - overlap); + xtran = 0; + } + } + else /* Simple case, no splitting */ + { + ytran = pageheight - imageheight; + xtran = 0; /* pagewidth - imagewidth; */ + } } - else /* Simple case, no splitting */ - { - ytran = pageheight - imageheight; - xtran = 0; /* pagewidth - imagewidth; */ - } - } - bott_offset += ytran / (center ? 2 : 1); - left_offset += xtran / (center ? 2 : 1); - break; - default: - xtran = 0; - ytran = 0; + bott_offset += ytran / (center ? 2 : 1); + left_offset += xtran / (center ? 2 : 1); + break; + default: xtran = 0; + ytran = 0; } - switch (rotation) + switch (rotation) { - case 0: - fprintf(fp, "%f %f translate\n", left_offset, bott_offset); - fprintf(fp, "%f %f scale\n", xscale, yscale); - break; - case 180: - fprintf(fp, "%f %f translate\n", left_offset, bott_offset); - fprintf(fp, "%f %f scale\n1 1 translate 180 rotate\n", xscale, - yscale); - break; - case 90: - fprintf(fp, "%f %f translate\n", left_offset, bott_offset); - fprintf(fp, "%f %f scale\n1 0 translate 90 rotate\n", yscale, - xscale); - break; - case 270: - fprintf(fp, "%f %f translate\n", left_offset, bott_offset); - fprintf(fp, "%f %f scale\n0 1 translate 270 rotate\n", yscale, - xscale); - break; - default: - TIFFError("exportMaskedImage", - "Unsupported rotation angle %d. No rotation", rotation); - fprintf(fp, "%f %f scale\n", xscale, yscale); - break; + case 0: fprintf(fp, "%f %f translate\n", left_offset, bott_offset); + fprintf(fp, "%f %f scale\n", xscale, yscale); + break; + case 180: fprintf(fp, "%f %f translate\n", left_offset, bott_offset); + fprintf(fp, "%f %f scale\n1 1 translate 180 rotate\n", xscale, yscale); + break; + case 90: fprintf(fp, "%f %f translate\n", left_offset, bott_offset); + fprintf(fp, "%f %f scale\n1 0 translate 90 rotate\n", yscale, xscale); + break; + case 270: fprintf(fp, "%f %f translate\n", left_offset, bott_offset); + fprintf(fp, "%f %f scale\n0 1 translate 270 rotate\n", yscale, xscale); + break; + default: TIFFError ("exportMaskedImage", "Unsupported rotation angle %d. No rotation", rotation); + fprintf( fp, "%f %f scale\n", xscale, yscale); + break; } - return (0); -} + return (0); + } /* Rotate an image without scaling or clipping */ -int psRotateImage(FILE *fd, int rotation, double pswidth, double psheight, - double left_offset, double bottom_offset) -{ - if ((left_offset != 0.0) || (bottom_offset != 0)) - fprintf(fd, "%f %f translate\n", left_offset, bottom_offset); +int psRotateImage (FILE * fd, int rotation, double pswidth, double psheight, + double left_offset, double bottom_offset) + { + if ((left_offset != 0.0) || (bottom_offset != 0)) + fprintf (fd, "%f %f translate\n", left_offset, bottom_offset); - /* Exchange width and height for 90/270 rotations */ - switch (rotation) + /* Exchange width and height for 90/270 rotations */ + switch (rotation) { - case 0: - fprintf(fd, "%f %f scale\n", pswidth, psheight); - break; - case 90: - fprintf(fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight, - pswidth); - break; - case 180: - fprintf(fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth, - psheight); - break; - case 270: - fprintf(fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight, - pswidth); - break; - default: - TIFFError("psRotateImage", "Unsupported rotation %d.", rotation); - fprintf(fd, "%f %f scale\n", pswidth, psheight); - return (1); + case 0: fprintf (fd, "%f %f scale\n", pswidth, psheight); + break; + case 90: fprintf (fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight, pswidth); + break; + case 180: fprintf (fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth, psheight); + break; + case 270: fprintf (fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight, pswidth); + break; + default: TIFFError ("psRotateImage", "Unsupported rotation %d.", rotation); + fprintf( fd, "%f %f scale\n", pswidth, psheight); + return (1); } - return (0); -} + return (0); + } /* Scale and rotate an image to a single output page. */ -int psScaleImage(FILE *fd, double scale, int rotation, int center, - double reqwidth, double reqheight, double pswidth, - double psheight, double left_offset, double bottom_offset) -{ - double hcenter = 0.0, vcenter = 0.0; +int psScaleImage(FILE * fd, double scale, int rotation, int center, + double reqwidth, double reqheight, double pswidth, double psheight, + double left_offset, double bottom_offset) + { + double hcenter = 0.0, vcenter = 0.0; - /* Adjust offsets for centering */ - if (center) + /* Adjust offsets for centering */ + if (center) { - switch (rotation) - { - case 90: - vcenter = (reqheight - pswidth * scale) / 2; + switch (rotation) + { + case 90: vcenter = (reqheight - pswidth * scale) / 2; hcenter = (reqwidth - psheight * scale) / 2; - fprintf(fd, "%f %f translate\n", hcenter, vcenter); - fprintf(fd, "%f %f scale\n1 0 translate 90 rotate\n", - psheight * scale, pswidth * scale); - break; - case 180: - hcenter = (reqwidth - pswidth * scale) / 2; + fprintf (fd, "%f %f translate\n", hcenter, vcenter); + fprintf (fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight * scale, pswidth * scale); + break; + case 180: hcenter = (reqwidth - pswidth * scale) / 2; vcenter = (reqheight - psheight * scale) / 2; - fprintf(fd, "%f %f translate\n", hcenter, vcenter); - fprintf(fd, "%f %f scale\n1 1 translate 180 rotate\n", - pswidth * scale, psheight * scale); - break; - case 270: - vcenter = (reqheight - pswidth * scale) / 2; + fprintf (fd, "%f %f translate\n", hcenter, vcenter); + fprintf (fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth * scale, psheight * scale); + break; + case 270: vcenter = (reqheight - pswidth * scale) / 2; hcenter = (reqwidth - psheight * scale) / 2; - fprintf(fd, "%f %f translate\n", hcenter, vcenter); - fprintf(fd, "%f %f scale\n0 1 translate 270 rotate\n", - psheight * scale, pswidth * scale); - break; - case 0: - default: - hcenter = (reqwidth - pswidth * scale) / 2; + fprintf (fd, "%f %f translate\n", hcenter, vcenter); + fprintf (fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight * scale, pswidth * scale); + break; + case 0: + default: hcenter = (reqwidth - pswidth * scale) / 2; vcenter = (reqheight - psheight * scale) / 2; - fprintf(fd, "%f %f translate\n", hcenter, vcenter); - fprintf(fd, "%f %f scale\n", pswidth * scale, psheight * scale); - break; - } + fprintf (fd, "%f %f translate\n", hcenter, vcenter); + fprintf (fd, "%f %f scale\n", pswidth * scale, psheight * scale); + break; + } } - else /* Not centered */ + else /* Not centered */ { - switch (rotation) - { - case 0: - fprintf(fd, "%f %f translate\n", - left_offset ? left_offset : 0.0, - bottom_offset ? bottom_offset - : reqheight - (psheight * scale)); - fprintf(fd, "%f %f scale\n", pswidth * scale, psheight * scale); + switch (rotation) + { + case 0: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0, + bottom_offset ? bottom_offset : reqheight - (psheight * scale)); + fprintf (fd, "%f %f scale\n", pswidth * scale, psheight * scale); break; - case 90: - fprintf(fd, "%f %f translate\n", - left_offset ? left_offset : 0.0, - bottom_offset ? bottom_offset - : reqheight - (pswidth * scale)); - fprintf(fd, "%f %f scale\n1 0 translate 90 rotate\n", - psheight * scale, pswidth * scale); + case 90: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0, + bottom_offset ? bottom_offset : reqheight - (pswidth * scale)); + fprintf (fd, "%f %f scale\n1 0 translate 90 rotate\n", psheight * scale, pswidth * scale); break; - case 180: - fprintf(fd, "%f %f translate\n", - left_offset ? left_offset : 0.0, - bottom_offset ? bottom_offset - : reqheight - (psheight * scale)); - fprintf(fd, "%f %f scale\n1 1 translate 180 rotate\n", - pswidth * scale, psheight * scale); + case 180: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0, + bottom_offset ? bottom_offset : reqheight - (psheight * scale)); + fprintf (fd, "%f %f scale\n1 1 translate 180 rotate\n", pswidth * scale, psheight * scale); break; - case 270: - fprintf(fd, "%f %f translate\n", - left_offset ? left_offset : 0.0, - bottom_offset ? bottom_offset - : reqheight - (pswidth * scale)); - fprintf(fd, "%f %f scale\n0 1 translate 270 rotate\n", - psheight * scale, pswidth * scale); + case 270: fprintf (fd, "%f %f translate\n", left_offset ? left_offset : 0.0, + bottom_offset ? bottom_offset : reqheight - (pswidth * scale)); + fprintf (fd, "%f %f scale\n0 1 translate 270 rotate\n", psheight * scale, pswidth * scale); break; - default: - TIFFError("psScaleImage", "Unsupported rotation %d", rotation); - fprintf(fd, "%f %f scale\n", pswidth * scale, psheight * scale); + default: TIFFError ("psScaleImage", "Unsupported rotation %d", rotation); + fprintf (fd, "%f %f scale\n", pswidth * scale, psheight * scale); return (1); - } + } } - return (0); -} + return (0); + } /* This controls the visible portion of the page which is displayed. * N.B. Setting maxPageHeight no longer sets pageheight if not set explicitly */ -int psPageSize(FILE *fd, int rotation, double pgwidth, double pgheight, - double reqwidth, double reqheight, double pswidth, - double psheight) -{ - double xscale = 1.0, yscale = 1.0, scale = 1.0; - double splitheight; - double splitwidth; - double new_width; - double new_height; +int psPageSize (FILE * fd, int rotation, double pgwidth, double pgheight, + double reqwidth, double reqheight, double pswidth, double psheight) + { + double xscale = 1.0, yscale = 1.0, scale = 1.0; + double splitheight; + double splitwidth; + double new_width; + double new_height; - splitheight = maxPageHeight * PS_UNIT_SIZE; - splitwidth = maxPageWidth * PS_UNIT_SIZE; + splitheight = maxPageHeight * PS_UNIT_SIZE; + splitwidth = maxPageWidth * PS_UNIT_SIZE; - switch (rotation) + switch (rotation) { - case 0: - case 180: - if ((splitheight > 0) || (splitwidth > 0)) - { - if (pgwidth != 0 || pgheight != 0) + case 0: + case 180: if ((splitheight > 0) || (splitwidth > 0)) { - xscale = reqwidth / (splitwidth ? splitwidth : pswidth); - yscale = reqheight / (splitheight ? splitheight : psheight); - scale = (xscale < yscale) ? xscale : yscale; - } + if (pgwidth != 0 || pgheight != 0) + { + xscale = reqwidth / (splitwidth ? splitwidth : pswidth); + yscale = reqheight / (splitheight ? splitheight : psheight); + scale = (xscale < yscale) ? xscale : yscale; + } new_width = splitwidth ? splitwidth : scale * pswidth; new_height = splitheight ? splitheight : scale * psheight; if (strlen(pageOrientation)) - fprintf(fd, "%%%%PageOrientation: %s\n", pageOrientation); + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else - fprintf(fd, "%%%%PageOrientation: %s\n", - (new_width > new_height) ? "Landscape" - : "Portrait"); - fprintf(fd, - "%%%%PageBoundingBox: 0 0 %" PRId32 " %" PRId32 "\n", - (int32_t)new_width, (int32_t)new_height); - fprintf(fd, - "1 dict begin /PageSize [ %f %f ] def currentdict end " - "setpagedevice\n", - new_width, new_height); - } - else /* No viewport defined with -H or -W */ - { + fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height); + fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + new_width, new_height); + } + else /* No viewport defined with -H or -W */ + { if ((pgwidth == 0) && (pgheight == 0)) /* Image not scaled */ - { - if (strlen(pageOrientation)) - fprintf(fd, "%%%%PageOrientation: %s\n", - pageOrientation); - else - fprintf(fd, "%%%%PageOrientation: %s\n", - (pswidth > psheight) ? "Landscape" - : "Portrait"); - fprintf(fd, - "%%%%PageBoundingBox: 0 0 %" PRId32 " %" PRId32 - "\n", - (int32_t)pswidth, (int32_t)psheight); - fprintf(fd, - "1 dict begin /PageSize [ %f %f ] def currentdict " - "end setpagedevice\n", - pswidth, psheight); - } - else /* Image scaled */ - { - if (strlen(pageOrientation)) - fprintf(fd, "%%%%PageOrientation: %s\n", - pageOrientation); - else - fprintf(fd, "%%%%PageOrientation: %s\n", - (reqwidth > reqheight) ? "Landscape" - : "Portrait"); - fprintf(fd, - "%%%%PageBoundingBox: 0 0 %" PRId32 " %" PRId32 - "\n", - (int32_t)reqwidth, (int32_t)reqheight); - fprintf(fd, - "1 dict begin /PageSize [ %f %f ] def currentdict " - "end setpagedevice\n", - reqwidth, reqheight); - } - } - break; - case 90: - case 270: - if ((splitheight > 0) || (splitwidth > 0)) - { - if (pgwidth != 0 || pgheight != 0) - { - xscale = reqwidth / (splitwidth ? splitwidth : pswidth); - yscale = reqheight / (splitheight ? splitheight : psheight); - scale = (xscale < yscale) ? xscale : yscale; + { + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (pswidth > psheight) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)pswidth, (long)psheight); + fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + pswidth, psheight); + } + else /* Image scaled */ + { + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight); + fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + reqwidth, reqheight); + } } + break; + case 90: + case 270: if ((splitheight > 0) || (splitwidth > 0)) + { + if (pgwidth != 0 || pgheight != 0) + { + xscale = reqwidth / (splitwidth ? splitwidth : pswidth); + yscale = reqheight / (splitheight ? splitheight : psheight); + scale = (xscale < yscale) ? xscale : yscale; + } new_width = splitwidth ? splitwidth : scale * psheight; new_height = splitheight ? splitheight : scale * pswidth; if (strlen(pageOrientation)) - fprintf(fd, "%%%%PageOrientation: %s\n", pageOrientation); + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); else - fprintf(fd, "%%%%PageOrientation: %s\n", - (new_width > new_height) ? "Landscape" - : "Portrait"); - fprintf(fd, - "%%%%PageBoundingBox: 0 0 %" PRId32 " %" PRId32 "\n", - (int32_t)new_width, (int32_t)new_height); - fprintf(fd, - "1 dict begin /PageSize [ %f %f ] def currentdict end " - "setpagedevice\n", - new_width, new_height); - } - else - { + fprintf (fd, "%%%%PageOrientation: %s\n", (new_width > new_height) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)new_width, (long)new_height); + fprintf (fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + new_width, new_height); + } + else + { if ((pgwidth == 0) && (pgheight == 0)) /* Image not scaled */ - { - if (strlen(pageOrientation)) - fprintf(fd, "%%%%PageOrientation: %s\n", - pageOrientation); - else - fprintf(fd, "%%%%PageOrientation: %s\n", - (psheight > pswidth) ? "Landscape" - : "Portrait"); - fprintf(fd, - "%%%%PageBoundingBox: 0 0 %" PRId32 " %" PRId32 - "\n", - (int32_t)psheight, (int32_t)pswidth); - fprintf(fd, - "1 dict begin /PageSize [ %f %f ] def currentdict " - "end setpagedevice\n", - psheight, pswidth); - } - else /* Image scaled */ - { - if (strlen(pageOrientation)) - fprintf(fd, "%%%%PageOrientation: %s\n", - pageOrientation); - else - fprintf(fd, "%%%%PageOrientation: %s\n", - (reqwidth > reqheight) ? "Landscape" - : "Portrait"); - fprintf(fd, - "%%%%PageBoundingBox: 0 0 %" PRId32 " %" PRId32 - "\n", - (int32_t)reqwidth, (int32_t)reqheight); - fprintf(fd, - "1 dict begin /PageSize [ %f %f ] def currentdict " - "end setpagedevice\n", - reqwidth, reqheight); - } - } - break; - default: - TIFFError("psPageSize", "Invalid rotation %d", rotation); - return (1); + { + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (psheight > pswidth) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)psheight, (long)pswidth); + fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + psheight, pswidth); + } + else /* Image scaled */ + { + if (strlen(pageOrientation)) + fprintf (fd, "%%%%PageOrientation: %s\n", pageOrientation); + else + fprintf (fd, "%%%%PageOrientation: %s\n", (reqwidth > reqheight) ? "Landscape" : "Portrait"); + fprintf (fd, "%%%%PageBoundingBox: 0 0 %ld %ld\n", (long)reqwidth, (long)reqheight); + fprintf(fd, "1 dict begin /PageSize [ %f %f ] def currentdict end setpagedevice\n", + reqwidth, reqheight); + } + } + break; + default: TIFFError ("psPageSize", "Invalid rotation %d", rotation); + return (1); } - fputs("<<\n /Policies <<\n /PageSize 3\n >>\n>> setpagedevice\n", fd); + fputs("<<\n /Policies <<\n /PageSize 3\n >>\n>> setpagedevice\n", fd); - return (0); -} /* end psPageSize */ + return (0); + } /* end psPageSize */ /* Mask an image as a series of pages, each only showing a section defined * by the maxPageHeight or maxPageWidth options. */ -int psMaskImage(FILE *fd, TIFF *tif, int rotation, int center, int *npages, - double pixwidth, double pixheight, double left_margin, - double bottom_margin, double pgwidth, double pgheight, - double pswidth, double psheight, double scale) -{ - int i, j; - int ximages = 1, yimages = 1; - int pages = *npages; - double view_width = 0; - double view_height = 0; +int psMaskImage(FILE *fd, TIFF *tif, int rotation, int center, + int *npages, double pixwidth, double pixheight, + double left_margin, double bottom_margin, + double pgwidth, double pgheight, + double pswidth, double psheight, double scale) + { + int i, j; + int ximages = 1, yimages = 1; + int pages = *npages; + double view_width = 0; + double view_height = 0; - if (get_viewport(pgwidth, pgheight, pswidth, psheight, &view_width, - &view_height, rotation)) + if (get_viewport (pgwidth, pgheight, pswidth, psheight, &view_width, &view_height, rotation)) { - TIFFError("get_viewport", "Unable to set image viewport"); - return (-1); + TIFFError ("get_viewport", "Unable to set image viewport"); + return (-1); } - if (get_subimage_count(pgwidth, pgheight, pswidth, psheight, &ximages, - &yimages, rotation, scale) < 1) + if (get_subimage_count(pgwidth, pgheight, pswidth, psheight, + &ximages, &yimages, rotation, scale) < 1) { - TIFFError("get_subimage_count", - "Invalid image count: %d columns, %d rows", ximages, yimages); - return (-1); + TIFFError("get_subimage_count", "Invalid image count: %d columns, %d rows", ximages, yimages); + return (-1); } - for (i = 0; i < yimages; i++) + for (i = 0; i < yimages; i++) { - for (j = 0; j < ximages; j++) - { - pages++; - *npages = pages; - fprintf(fd, "%%%%Page: %d %d\n", pages, pages); + for (j = 0; j < ximages; j++) + { + pages++; + *npages = pages; + fprintf(fd, "%%%%Page: %d %d\n", pages, pages); - /* Write out the PageSize info for non EPS files */ - if (!generateEPSF && (level2 || level3)) - { - if (psPageSize(fd, rotation, pgwidth, pgheight, view_width, - view_height, pswidth, psheight)) - return (-1); - } - fprintf(fd, "gsave\n"); - fprintf(fd, "100 dict begin\n"); - if (exportMaskedImage(fd, view_width, view_height, pswidth, - psheight, i, j, left_margin, bottom_margin, - scale, center, rotation)) - { - TIFFError("exportMaskedImage", "Invalid image parameters."); - return (-1); - } - PSpage(fd, tif, pixwidth, pixheight); - fprintf(fd, "end\n"); - fprintf(fd, "grestore\n"); - fprintf(fd, "showpage\n"); + /* Write out the PageSize info for non EPS files */ + if (!generateEPSF && ( level2 || level3 )) + { + if (psPageSize(fd, rotation, pgwidth, pgheight, + view_width, view_height, pswidth, psheight)) + return (-1); } + fprintf(fd, "gsave\n"); + fprintf(fd, "100 dict begin\n"); + if (exportMaskedImage(fd, view_width, view_height, pswidth, psheight, + i, j, left_margin, bottom_margin, + scale, center, rotation)) + { + TIFFError("exportMaskedImage", "Invalid image parameters."); + return (-1); + } + PSpage(fd, tif, pixwidth, pixheight); + fprintf(fd, "end\n"); + fprintf(fd, "grestore\n"); + fprintf(fd, "showpage\n"); + } } - return (pages); -} + return (pages); + } /* Compute scale factor and write out file header */ int psStart(FILE *fd, int npages, int auto_rotate, int *rotation, double *scale, double ox, double oy, double pgwidth, double pgheight, - double reqwidth, double reqheight, double pswidth, double psheight, - double left_offset, double bottom_offset) -{ - double maxsource = 0.0; /* Used for auto rotations */ - double maxtarget = 0.0; - double xscale = 1.0, yscale = 1.0; - double splitheight; - double splitwidth; - double view_width = 0.0, view_height = 0.0; - double page_width = 0.0, page_height = 0.0; + double reqwidth, double reqheight, double pswidth, double psheight, + double left_offset, double bottom_offset) + { + double maxsource = 0.0; /* Used for auto rotations */ + double maxtarget = 0.0; + double xscale = 1.0, yscale = 1.0; + double splitheight; + double splitwidth; + double view_width = 0.0, view_height = 0.0; + double page_width = 0.0, page_height = 0.0; - /* Splitheight and splitwidth are in inches */ - splitheight = maxPageHeight * PS_UNIT_SIZE; - splitwidth = maxPageWidth * PS_UNIT_SIZE; + /* Splitheight and splitwidth are in inches */ + splitheight = maxPageHeight * PS_UNIT_SIZE; + splitwidth = maxPageWidth * PS_UNIT_SIZE; - page_width = pgwidth * PS_UNIT_SIZE; - page_height = pgheight * PS_UNIT_SIZE; + page_width = pgwidth * PS_UNIT_SIZE; + page_height = pgheight * PS_UNIT_SIZE; - /* If user has specified a page width and height and requested the - * image to be auto-rotated to fit on that media, we match the - * longest dimension of the image to the longest dimension of the - * target media but we have to ignore auto rotate if user specified - * maxPageHeight since this makes life way too complicated. */ - if (auto_rotate) + /* If user has specified a page width and height and requested the + * image to be auto-rotated to fit on that media, we match the + * longest dimension of the image to the longest dimension of the + * target media but we have to ignore auto rotate if user specified + * maxPageHeight since this makes life way too complicated. */ + if (auto_rotate) { - if ((splitheight != 0) || (splitwidth != 0)) - { - TIFFError("psStart", - "Auto-rotate is incompatible with page splitting "); - return (1); - } + if ((splitheight != 0) || (splitwidth != 0)) + { + TIFFError ("psStart", "Auto-rotate is incompatible with page splitting "); + return (1); + } - /* Find longest edges in image and output media */ - maxsource = (pswidth >= psheight) ? pswidth : psheight; - maxtarget = (reqwidth >= reqheight) ? reqwidth : reqheight; + /* Find longest edges in image and output media */ + maxsource = (pswidth >= psheight) ? pswidth : psheight; + maxtarget = (reqwidth >= reqheight) ? reqwidth : reqheight; - if (((maxsource == pswidth) && (maxtarget != reqwidth)) || - ((maxsource == psheight) && (maxtarget != reqheight))) - { /* optimal orientation does not match input orientation */ - *rotation = 90; - xscale = (reqwidth - left_offset) / psheight; - yscale = (reqheight - bottom_offset) / pswidth; - } - else /* optimal orientation matches input orientation */ - { - xscale = (reqwidth - left_offset) / pswidth; - yscale = (reqheight - bottom_offset) / psheight; - } - *scale = (xscale < yscale) ? xscale : yscale; + if (((maxsource == pswidth) && (maxtarget != reqwidth)) || + ((maxsource == psheight) && (maxtarget != reqheight))) + { /* optimal orientaion does not match input orientation */ + *rotation = 90; + xscale = (reqwidth - left_offset)/psheight; + yscale = (reqheight - bottom_offset)/pswidth; + } + else /* optimal orientaion matches input orientation */ + { + xscale = (reqwidth - left_offset)/pswidth; + yscale = (reqheight - bottom_offset)/psheight; + } + *scale = (xscale < yscale) ? xscale : yscale; - /* Do not scale image beyond original size */ - if (*scale > 1.0) - *scale = 1.0; + /* Do not scale image beyound original size */ + if (*scale > 1.0) + *scale = 1.0; - /* Set the size of the displayed image to requested page size - * and optimal orientation. - */ - if (!npages) - PSHead(fd, reqwidth, reqheight, ox, oy); + /* Set the size of the displayed image to requested page size + * and optimal orientation. + */ + if (!npages) + PSHead(fd, reqwidth, reqheight, ox, oy); - return (0); + return (0); } - /* N.B. If pgwidth or pgheight are set from maxPageHeight/Width, - * we have a problem with the tests below under splitheight. - */ + /* N.B. If pgwidth or pgheight are set from maxPageHeight/Width, + * we have a problem with the tests below under splitheight. + */ - switch (*rotation) /* Auto rotate has NOT been specified */ + switch (*rotation) /* Auto rotate has NOT been specified */ { - case 0: - case 180: - if ((splitheight != 0) || (splitwidth != 0)) - { /* Viewport clipped to maxPageHeight or maxPageWidth */ + case 0: + case 180: if ((splitheight != 0) || (splitwidth != 0)) + { /* Viewport clipped to maxPageHeight or maxPageWidth */ if ((page_width != 0) || (page_height != 0)) /* Image scaled */ - { - xscale = (reqwidth - left_offset) / - (page_width ? page_width : pswidth); - yscale = (reqheight - bottom_offset) / - (page_height ? page_height : psheight); - *scale = (xscale < yscale) ? xscale : yscale; - /* - if (*scale > 1.0) - *scale = 1.0; - */ - } - else /* Image clipped but not scaled */ + { + xscale = (reqwidth - left_offset) / (page_width ? page_width : pswidth); + yscale = (reqheight - bottom_offset) / (page_height ? page_height : psheight); + *scale = (xscale < yscale) ? xscale : yscale; + /* + if (*scale > 1.0) *scale = 1.0; + */ + } + else /* Image clipped but not scaled */ + *scale = 1.0; view_width = splitwidth ? splitwidth : *scale * pswidth; - view_height = splitheight ? splitheight : *scale * psheight; - } - else /* Viewport not clipped to maxPageHeight or maxPageWidth */ - { - if ((page_width != 0) || (page_height != 0)) - { /* Image scaled */ - xscale = (reqwidth - left_offset) / pswidth; - yscale = (reqheight - bottom_offset) / psheight; - - view_width = reqwidth; - view_height = reqheight; - } - else - { /* Image not scaled */ - xscale = (pswidth - left_offset) / pswidth; - yscale = (psheight - bottom_offset) / psheight; - - view_width = pswidth; - view_height = psheight; - } - } - break; - case 90: - case 270: - if ((splitheight != 0) || (splitwidth != 0)) - { /* Viewport clipped to maxPageHeight or maxPageWidth */ - if ((page_width != 0) || (page_height != 0)) /* Image scaled */ + view_height = splitheight ? splitheight: *scale * psheight; + } + else /* Viewport not clipped to maxPageHeight or maxPageWidth */ { - xscale = (reqwidth - left_offset) / psheight; - yscale = (reqheight - bottom_offset) / pswidth; - *scale = (xscale < yscale) ? xscale : yscale; - /* - if (*scale > 1.0) - *scale = 1.0; - */ - } - else /* Image clipped but not scaled */ + if ((page_width != 0) || (page_height != 0)) + { /* Image scaled */ + xscale = (reqwidth - left_offset) / pswidth; + yscale = (reqheight - bottom_offset) / psheight; + + view_width = reqwidth; + view_height = reqheight; + } + else + { /* Image not scaled */ + xscale = (pswidth - left_offset)/pswidth; + yscale = (psheight - bottom_offset)/psheight; + + view_width = pswidth; + view_height = psheight; + } + } + break; + case 90: + case 270: if ((splitheight != 0) || (splitwidth != 0)) + { /* Viewport clipped to maxPageHeight or maxPageWidth */ + if ((page_width != 0) || (page_height != 0)) /* Image scaled */ + { + xscale = (reqwidth - left_offset)/ psheight; + yscale = (reqheight - bottom_offset)/ pswidth; + *scale = (xscale < yscale) ? xscale : yscale; + /* + if (*scale > 1.0) *scale = 1.0; + */ + } + else /* Image clipped but not scaled */ + *scale = 1.0; view_width = splitwidth ? splitwidth : *scale * psheight; view_height = splitheight ? splitheight : *scale * pswidth; - } - else /* Viewport not clipped to maxPageHeight or maxPageWidth */ - { + } + else /* Viewport not clipped to maxPageHeight or maxPageWidth */ + { if ((page_width != 0) || (page_height != 0)) /* Image scaled */ - { - xscale = (reqwidth - left_offset) / psheight; - yscale = (reqheight - bottom_offset) / pswidth; + { + xscale = (reqwidth - left_offset) / psheight; + yscale = (reqheight - bottom_offset) / pswidth; - view_width = reqwidth; - view_height = reqheight; - } + view_width = reqwidth; + view_height = reqheight; + } else - { - xscale = (pswidth - left_offset) / psheight; - yscale = (psheight - bottom_offset) / pswidth; + { + xscale = (pswidth - left_offset)/ psheight; + yscale = (psheight - bottom_offset)/ pswidth; - view_width = psheight; - view_height = pswidth; + view_width = psheight; + view_height = pswidth; + } } - } - break; + break; + default: TIFFError ("psPageSize", "Invalid rotation %d", *rotation); + return (1); + } + + if (!npages) + PSHead(fd, (page_width ? page_width : view_width), (page_height ? page_height : view_height), ox, oy); + + *scale = (xscale < yscale) ? xscale : yscale; + if (*scale > 1.0) + *scale = 1.0; + + return (0); + } + +int get_viewport (double pgwidth, double pgheight, double pswidth, double psheight, + double *view_width, double *view_height, int rotation) + { + /* Only one of maxPageHeight or maxPageWidth can be specified */ + if (maxPageHeight != 0) /* Clip the viewport to maxPageHeight on each page */ + { + if (pgheight != 0 && pgheight < maxPageHeight) + *view_height = pgheight * PS_UNIT_SIZE; + else + *view_height = maxPageHeight * PS_UNIT_SIZE; + /* + * if (res_unit == RESUNIT_CENTIMETER) + * *view_height /= 2.54F; + */ + } + else + { + if (pgheight != 0) /* User has set PageHeight with -h flag */ + { + *view_height = pgheight * PS_UNIT_SIZE; /* Postscript size for Page Height in inches */ + /* if (res_unit == RESUNIT_CENTIMETER) + * *view_height /= 2.54F; + */ + } + else /* If no width or height are specified, use the original size from image */ + switch (rotation) + { default: - TIFFError("psPageSize", "Invalid rotation %d", *rotation); - return (1); + case 0: + case 180: *view_height = psheight; + break; + case 90: + case 270: *view_height = pswidth; + break; + } } - if (!npages) - PSHead(fd, (page_width ? page_width : view_width), - (page_height ? page_height : view_height), ox, oy); - - *scale = (xscale < yscale) ? xscale : yscale; - if (*scale > 1.0) - *scale = 1.0; - - return (0); -} - -int get_viewport(double pgwidth, double pgheight, double pswidth, - double psheight, double *view_width, double *view_height, - int rotation) -{ - /* Only one of maxPageHeight or maxPageWidth can be specified */ - if (maxPageHeight != - 0) /* Clip the viewport to maxPageHeight on each page */ + if (maxPageWidth != 0) /* Clip the viewport to maxPageWidth on each page */ { - if (pgheight != 0 && pgheight < maxPageHeight) - *view_height = pgheight * PS_UNIT_SIZE; - else - *view_height = maxPageHeight * PS_UNIT_SIZE; - /* - * if (res_unit == RESUNIT_CENTIMETER) - * *view_height /= 2.54F; - */ - } + if (pgwidth != 0 && pgwidth < maxPageWidth) + *view_width = pgwidth * PS_UNIT_SIZE; else + *view_width = maxPageWidth * PS_UNIT_SIZE; + /* if (res_unit == RESUNIT_CENTIMETER) + * *view_width /= 2.54F; + */ + } + else { - if (pgheight != 0) /* User has set PageHeight with -h flag */ + if (pgwidth != 0) /* User has set PageWidth with -w flag */ + { + *view_width = pgwidth * PS_UNIT_SIZE; /* Postscript size for Page Width in inches */ + /* if (res_unit == RESUNIT_CENTIMETER) + * *view_width /= 2.54F; + */ + } + else /* If no width or height are specified, use the original size from image */ + switch (rotation) { - *view_height = - pgheight * - PS_UNIT_SIZE; /* Postscript size for Page Height in inches */ - /* if (res_unit == RESUNIT_CENTIMETER) - * *view_height /= 2.54F; - */ - } - else /* If no width or height are specified, use the original size from - image */ - switch (rotation) - { - default: - case 0: - case 180: - *view_height = psheight; - break; - case 90: - case 270: - *view_height = pswidth; - break; - } + default: + case 0: + case 180: *view_width = pswidth; + break; + case 90: + case 270: *view_width = psheight; /* (*view_height / psheight) * psheight; */ + break; + } } - if (maxPageWidth != 0) /* Clip the viewport to maxPageWidth on each page */ - { - if (pgwidth != 0 && pgwidth < maxPageWidth) - *view_width = pgwidth * PS_UNIT_SIZE; - else - *view_width = maxPageWidth * PS_UNIT_SIZE; - /* if (res_unit == RESUNIT_CENTIMETER) - * *view_width /= 2.54F; - */ - } - else - { - if (pgwidth != 0) /* User has set PageWidth with -w flag */ - { - *view_width = - pgwidth * - PS_UNIT_SIZE; /* Postscript size for Page Width in inches */ - /* if (res_unit == RESUNIT_CENTIMETER) - * *view_width /= 2.54F; - */ - } - else /* If no width or height are specified, use the original size from - image */ - switch (rotation) - { - default: - case 0: - case 180: - *view_width = pswidth; - break; - case 90: - case 270: - *view_width = - psheight; /* (*view_height / psheight) * psheight; */ - break; - } - } + return (0); + } - return (0); -} - -/* pgwidth and pgheight specify page width and height in inches from -h and -w - * flags lm and bm are the LeftMargin and BottomMargin in inches center causes - * the image to be centered on the page if the paper size is larger than the - * image size returns the sequence number of the page processed or -1 on error +/* pgwidth and pgheight specify page width and height in inches from -h and -w flags + * lm and bm are the LeftMargin and BottomMargin in inches + * center causes the image to be centered on the page if the paper size is + * larger than the image size + * returns the sequence number of the page processed or -1 on error */ -int TIFF2PS(FILE *fd, TIFF *tif, double pgwidth, double pgheight, double lm, - double bm, int center) -{ - uint32_t pixwidth = 0, pixheight = 0; /* Image width and height in pixels */ - double ox = 0.0, oy = 0.0; /* Offset from current Postscript origin */ - double pswidth, - psheight; /* Original raw image width and height in points */ - double view_width, view_height; /* Viewport width and height in points */ - double scale = 1.0; - double left_offset = lm * PS_UNIT_SIZE; - double bottom_offset = bm * PS_UNIT_SIZE; - uint32_t subfiletype; - uint16_t *sampleinfo; - static int npages = 0; +int TIFF2PS(FILE* fd, TIFF* tif, double pgwidth, double pgheight, double lm, double bm, int center) + { + uint32 pixwidth = 0, pixheight = 0; /* Image width and height in pixels */ + double ox = 0.0, oy = 0.0; /* Offset from current Postscript origin */ + double pswidth, psheight; /* Original raw image width and height in points */ + double view_width, view_height; /* Viewport width and height in points */ + double scale = 1.0; + double left_offset = lm * PS_UNIT_SIZE; + double bottom_offset = bm * PS_UNIT_SIZE; + uint32 subfiletype; + uint16* sampleinfo; + static int npages = 0; - if (!TIFFGetField(tif, TIFFTAG_XPOSITION, &ox)) - ox = 0; - if (!TIFFGetField(tif, TIFFTAG_YPOSITION, &oy)) - oy = 0; + if (!TIFFGetField(tif, TIFFTAG_XPOSITION, &ox)) + ox = 0; + if (!TIFFGetField(tif, TIFFTAG_YPOSITION, &oy)) + oy = 0; - /* Consolidated all the tag information into one code segment, Richard Nolde - */ - do - { - tf_numberstrips = TIFFNumberOfStrips(tif); - TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &tf_rowsperstrip); - TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample); - TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); - TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfiguration); - TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression); - TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples, - &sampleinfo); - alpha = (extrasamples == 1 && sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); - if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) - { - switch (samplesperpixel - extrasamples) - { - case 1: - if (isCCITTCompression(tif)) - photometric = PHOTOMETRIC_MINISWHITE; + /* Consolidated all the tag information into one code segment, Richard Nolde */ + do { + tf_numberstrips = TIFFNumberOfStrips(tif); + TIFFGetFieldDefaulted(tif, TIFFTAG_ROWSPERSTRIP, &tf_rowsperstrip); + TIFFGetFieldDefaulted(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample); + TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + TIFFGetFieldDefaulted(tif, TIFFTAG_PLANARCONFIG, &planarconfiguration); + TIFFGetField(tif, TIFFTAG_COMPRESSION, &compression); + TIFFGetFieldDefaulted(tif, TIFFTAG_EXTRASAMPLES, &extrasamples, &sampleinfo); + alpha = (extrasamples == 1 && sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); + if (!TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &photometric)) + { + switch (samplesperpixel - extrasamples) + { + case 1: if (isCCITTCompression(tif)) + photometric = PHOTOMETRIC_MINISWHITE; else - photometric = PHOTOMETRIC_MINISBLACK; + photometric = PHOTOMETRIC_MINISBLACK; break; - case 3: - photometric = PHOTOMETRIC_RGB; + case 3: photometric = PHOTOMETRIC_RGB; break; - case 4: - photometric = PHOTOMETRIC_SEPARATED; + case 4: photometric = PHOTOMETRIC_SEPARATED; break; } - } + } - /* Read image tags for width and height in pixels pixwidth, pixheight, - * and convert to points pswidth, psheight - */ - setupPageState(tif, &pixwidth, &pixheight, &pswidth, &psheight); - view_width = pswidth; - view_height = psheight; + /* Read image tags for width and height in pixels pixwidth, pixheight, + * and convert to points pswidth, psheight + */ + setupPageState(tif, &pixwidth, &pixheight, &pswidth, &psheight); + view_width = pswidth; + view_height = psheight; - if (get_viewport(pgwidth, pgheight, pswidth, psheight, &view_width, - &view_height, rotation)) - { - TIFFError("get_viewport", "Unable to set image viewport"); - return (1); - } + if (get_viewport (pgwidth, pgheight, pswidth, psheight, &view_width, &view_height, rotation)) + { + TIFFError("get_viewport", "Unable to set image viewport"); + return (1); + } - /* Write the Postscript file header with Bounding Box and Page Size - * definitions */ - if (psStart(fd, npages, auto_rotate, &rotation, &scale, ox, oy, pgwidth, - pgheight, view_width, view_height, pswidth, psheight, - left_offset, bottom_offset)) + /* Write the Postscript file header with Bounding Box and Page Size definitions */ + if (psStart(fd, npages, auto_rotate, &rotation, &scale, ox, oy, + pgwidth, pgheight, view_width, view_height, pswidth, psheight, + left_offset, bottom_offset)) + return (-1); + + if (checkImage(tif)) /* Aborts if unsupported image parameters */ + { + tf_bytesperrow = TIFFScanlineSize(tif); + + /* Set viewport clipping and scaling options */ + if ((maxPageHeight) || (maxPageWidth) || (pgwidth != 0) || (pgheight != 0)) + { + if ((maxPageHeight) || (maxPageWidth)) /* used -H or -W option */ + { + if (psMaskImage(fd, tif, rotation, center, &npages, pixwidth, pixheight, + left_offset, bottom_offset, pgwidth, pgheight, + pswidth, psheight, scale) < 0) return (-1); + } + else /* N.B. Setting maxPageHeight no longer sets pgheight */ + { + if (pgwidth != 0 || pgheight != 0) + { + /* User did not specify a maxium page height or width using -H or -W flag + * but did use -h or -w flag to scale to a specific size page. + */ + npages++; + fprintf(fd, "%%%%Page: %d %d\n", npages, npages); - if (checkImage(tif)) /* Aborts if unsupported image parameters */ - { - tf_bytesperrow = TIFFScanlineSize(tif); + if (!generateEPSF && ( level2 || level3 )) + { + /* Write out the PageSize info for non EPS files */ + if (psPageSize(fd, rotation, pgwidth, pgheight, + view_width, view_height, pswidth, psheight)) + return (-1); + } + fprintf(fd, "gsave\n"); + fprintf(fd, "100 dict begin\n"); + if (psScaleImage(fd, scale, rotation, center, view_width, view_height, + pswidth, psheight, left_offset, bottom_offset)) + return (-1); - /* Set viewport clipping and scaling options */ - if ((maxPageHeight) || (maxPageWidth) || (pgwidth != 0) || - (pgheight != 0)) - { - if ((maxPageHeight) || - (maxPageWidth)) /* used -H or -W option */ - { - if (psMaskImage(fd, tif, rotation, center, &npages, - pixwidth, pixheight, left_offset, - bottom_offset, pgwidth, pgheight, pswidth, - psheight, scale) < 0) - return (-1); - } - else /* N.B. Setting maxPageHeight no longer sets pgheight */ - { - if (pgwidth != 0 || pgheight != 0) - { - /* User did not specify a maximum page height or width - * using -H or -W flag but did use -h or -w flag to - * scale to a specific size page. - */ - npages++; - fprintf(fd, "%%%%Page: %d %d\n", npages, npages); - - if (!generateEPSF && (level2 || level3)) - { - /* Write out the PageSize info for non EPS files */ - if (psPageSize(fd, rotation, pgwidth, pgheight, - view_width, view_height, pswidth, - psheight)) - return (-1); - } - fprintf(fd, "gsave\n"); - fprintf(fd, "100 dict begin\n"); - if (psScaleImage(fd, scale, rotation, center, - view_width, view_height, pswidth, - psheight, left_offset, bottom_offset)) - return (-1); - - PSpage(fd, tif, pixwidth, pixheight); - fprintf(fd, "end\n"); - fprintf(fd, "grestore\n"); - fprintf(fd, "showpage\n"); - } - } - } - else /* Simple rotation: user did not use -H, -W, -h or -w */ - { - npages++; - fprintf(fd, "%%%%Page: %d %d\n", npages, npages); - - if (!generateEPSF && (level2 || level3)) - { - /* Write out the PageSize info for non EPS files */ - if (psPageSize(fd, rotation, pgwidth, pgheight, view_width, - view_height, pswidth, psheight)) - return (-1); - } - fprintf(fd, "gsave\n"); - fprintf(fd, "100 dict begin\n"); - if (psRotateImage(fd, rotation, pswidth, psheight, left_offset, - bottom_offset)) - return (-1); - - PSpage(fd, tif, pixwidth, pixheight); - fprintf(fd, "end\n"); - fprintf(fd, "grestore\n"); - fprintf(fd, "showpage\n"); + PSpage(fd, tif, pixwidth, pixheight); + fprintf(fd, "end\n"); + fprintf(fd, "grestore\n"); + fprintf(fd, "showpage\n"); } + } } - if (generateEPSF) - break; - if (auto_rotate) - rotation = 0.0; - TIFFGetFieldDefaulted(tif, TIFFTAG_SUBFILETYPE, &subfiletype); - } while (((subfiletype & FILETYPE_PAGE) || printAll) && - TIFFReadDirectory(tif)); + else /* Simple rotation: user did not use -H, -W, -h or -w */ + { + npages++; + fprintf(fd, "%%%%Page: %d %d\n", npages, npages); - return (npages); + if (!generateEPSF && ( level2 || level3 )) + { + /* Write out the PageSize info for non EPS files */ + if (psPageSize(fd, rotation, pgwidth, pgheight, + view_width, view_height, pswidth, psheight)) + return (-1); + } + fprintf(fd, "gsave\n"); + fprintf(fd, "100 dict begin\n"); + if (psRotateImage(fd, rotation, pswidth, psheight, left_offset, bottom_offset)) + return (-1); + + PSpage(fd, tif, pixwidth, pixheight); + fprintf(fd, "end\n"); + fprintf(fd, "grestore\n"); + fprintf(fd, "showpage\n"); + } + } + if (generateEPSF) + break; + if (auto_rotate) + rotation = 0.0; + TIFFGetFieldDefaulted(tif, TIFFTAG_SUBFILETYPE, &subfiletype); + } while (((subfiletype & FILETYPE_PAGE) || printAll) && TIFFReadDirectory(tif)); + +return(npages); } -static const char DuplexPreamble[] = "\ +static char DuplexPreamble[] = "\ %%BeginFeature: *Duplex True\n\ systemdict begin\n\ /languagelevel where { pop languagelevel } { 1 } ifelse\n\ @@ -1877,7 +1664,7 @@ end\n\ %%EndFeature\n\ "; -static const char TumblePreamble[] = "\ +static char TumblePreamble[] = "\ %%BeginFeature: *Tumble True\n\ systemdict begin\n\ /languagelevel where { pop languagelevel } { 1 } ifelse\n\ @@ -1888,7 +1675,7 @@ end\n\ %%EndFeature\n\ "; -static const char AvoidDeadZonePreamble[] = "\ +static char AvoidDeadZonePreamble[] = "\ gsave newpath clippath pathbbox grestore\n\ 4 2 roll 2 copy translate\n\ exch 3 1 roll sub 3 1 roll sub exch\n\ @@ -1898,1506 +1685,1386 @@ gsave newpath clippath pathbbox grestore\n\ dup 1 lt { dup scale } { pop } ifelse\n\ "; -void PSHead(FILE *fd, double pagewidth, double pageheight, double xoff, - double yoff) +void +PSHead(FILE *fd, double pagewidth, double pageheight, double xoff, double yoff) { - time_t t; + time_t t; - t = time(0); - fprintf(fd, "%%!PS-Adobe-3.0%s\n", generateEPSF ? " EPSF-3.0" : ""); - fprintf(fd, "%%%%Creator: %s\n", creator ? creator : "tiff2ps"); - fprintf(fd, "%%%%Title: %s\n", title ? title : filename); - fprintf(fd, "%%%%CreationDate: %s", ctime(&t)); - fprintf(fd, "%%%%DocumentData: Clean7Bit\n"); - /* NB: should use PageBoundingBox for each page instead of BoundingBox * - * PageBoundingBox DSC added in PSPageSize function, R Nolde 09-01-2010 - */ - fprintf(fd, "%%%%Origin: %" PRId32 " %" PRId32 "\n", (int32_t)xoff, - (int32_t)yoff); - fprintf(fd, "%%%%BoundingBox: 0 0 %" PRId32 " %" PRId32 "\n", - (int32_t)ceil(pagewidth), (int32_t)ceil(pageheight)); - - fprintf(fd, "%%%%LanguageLevel: %d\n", (level3 ? 3 : (level2 ? 2 : 1))); - if (generateEPSF == TRUE) - fprintf(fd, "%%%%Pages: 1 1\n"); - else - fprintf(fd, "%%%%Pages: (atend)\n"); - fprintf(fd, "%%%%EndComments\n"); - if (generateEPSF == FALSE) - { - fprintf(fd, "%%%%BeginSetup\n"); - if (PSduplex) - fprintf(fd, "%s", DuplexPreamble); - if (PStumble) - fprintf(fd, "%s", TumblePreamble); - if (PSavoiddeadzone && (level2 || level3)) - fprintf(fd, "%s", AvoidDeadZonePreamble); - fprintf(fd, "%%%%EndSetup\n"); - } -} - -void PSTail(FILE *fd, int npages) -{ - fprintf(fd, "%%%%Trailer\n"); - if (generateEPSF == FALSE) - fprintf(fd, "%%%%Pages: %d\n", npages); - fprintf(fd, "%%%%EOF\n"); -} - -static int checkcmap(TIFF *tif, int n, uint16_t *r, uint16_t *g, uint16_t *b) -{ - (void)tif; - while (n-- > 0) - if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) - return (16); - TIFFWarning(filename, "Assuming 8-bit colormap"); - return (8); -} - -static void PS_Lvl2colorspace(FILE *fd, TIFF *tif) -{ - uint16_t *rmap, *gmap, *bmap; - int i, num_colors; - const char *colorspace_p; - - switch (photometric) - { - case PHOTOMETRIC_SEPARATED: - colorspace_p = "CMYK"; - break; - - case PHOTOMETRIC_RGB: - colorspace_p = "RGB"; - break; - - default: - colorspace_p = "Gray"; - } - - /* - * Set up PostScript Level 2 colorspace according to - * section 4.8 in the PostScript reference manual. - */ - fputs("% PostScript Level 2 only.\n", fd); - if (photometric != PHOTOMETRIC_PALETTE) - { - if (photometric == PHOTOMETRIC_YCBCR) - { - /* MORE CODE HERE */ - } - fprintf(fd, "/Device%s setcolorspace\n", colorspace_p); - return; - } - - /* - * Set up an indexed/palette colorspace - */ - num_colors = (1 << bitspersample); - if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) - { - TIFFError(filename, "Palette image w/o \"Colormap\" tag"); - return; - } - if (checkcmap(tif, num_colors, rmap, gmap, bmap) == 16) - { - /* - * Convert colormap to 8-bits values. + t = time(0); + fprintf(fd, "%%!PS-Adobe-3.0%s\n", generateEPSF ? " EPSF-3.0" : ""); + fprintf(fd, "%%%%Creator: %s\n", creator ? creator : "tiff2ps"); + fprintf(fd, "%%%%Title: %s\n", title ? title : filename); + fprintf(fd, "%%%%CreationDate: %s", ctime(&t)); + fprintf(fd, "%%%%DocumentData: Clean7Bit\n"); + /* NB: should use PageBoundingBox for each page instead of BoundingBox * + * PageBoundingBox DSC added in PSPageSize function, R Nolde 09-01-2010 */ -#define CVT(x) (((x)*255) / ((1L << 16) - 1)) - for (i = 0; i < num_colors; i++) - { - rmap[i] = CVT(rmap[i]); - gmap[i] = CVT(gmap[i]); - bmap[i] = CVT(bmap[i]); - } -#undef CVT - } - fprintf(fd, "[ /Indexed /DeviceRGB %d", num_colors - 1); - if (ascii85) - { - Ascii85Init(); - fputs("\n<~", fd); - ascii85breaklen -= 2; - } - else - fputs(" <", fd); - for (i = 0; i < num_colors; i++) - { - if (ascii85) - { - Ascii85Put((unsigned char)rmap[i], fd); - Ascii85Put((unsigned char)gmap[i], fd); - Ascii85Put((unsigned char)bmap[i], fd); - } + fprintf(fd, "%%%%Origin: %ld %ld\n", (long) xoff, (long) yoff); + fprintf(fd, "%%%%BoundingBox: 0 0 %ld %ld\n", + (long) ceil(pagewidth), (long) ceil(pageheight)); + + fprintf(fd, "%%%%LanguageLevel: %d\n", (level3 ? 3 : (level2 ? 2 : 1))); + if (generateEPSF == TRUE) + fprintf(fd, "%%%%Pages: 1 1\n"); else - { - fputs((i % 8) ? " " : "\n ", fd); - fprintf(fd, "%02" PRIx16 "%02" PRIx16 "%02" PRIx16 "", rmap[i], - gmap[i], bmap[i]); - } - } - if (ascii85) - Ascii85Flush(fd); - else - fputs(">\n", fd); - fputs("] setcolorspace\n", fd); + fprintf(fd, "%%%%Pages: (atend)\n"); + fprintf(fd, "%%%%EndComments\n"); + if (generateEPSF == FALSE) + { + fprintf(fd, "%%%%BeginSetup\n"); + if (PSduplex) + fprintf(fd, "%s", DuplexPreamble); + if (PStumble) + fprintf(fd, "%s", TumblePreamble); + if (PSavoiddeadzone && (level2 || level3)) + fprintf(fd, "%s", AvoidDeadZonePreamble); + fprintf(fd, "%%%%EndSetup\n"); + } } -static int PS_Lvl2ImageDict(FILE *fd, TIFF *tif, uint32_t w, uint32_t h) +void +PSTail(FILE *fd, int npages) { - int use_rawdata; - uint32_t tile_width, tile_height; - uint16_t predictor, minsamplevalue, maxsamplevalue; - uint32_t repeat_count; - char im_h[64], im_x[64], im_y[64]; - const char *imageOp = "image"; + fprintf(fd, "%%%%Trailer\n"); + if (generateEPSF == FALSE) + fprintf(fd, "%%%%Pages: %d\n", npages); + fprintf(fd, "%%%%EOF\n"); +} - if (useImagemask && (bitspersample == 1)) - imageOp = "imagemask"; +static int +checkcmap(TIFF* tif, int n, uint16* r, uint16* g, uint16* b) +{ + (void) tif; + while (n-- > 0) + if (*r++ >= 256 || *g++ >= 256 || *b++ >= 256) + return (16); + TIFFWarning(filename, "Assuming 8-bit colormap"); + return (8); +} - (void)strcpy(im_x, "0"); - (void)snprintf(im_y, sizeof(im_y), "%" PRIu32, h); - (void)snprintf(im_h, sizeof(im_h), "%" PRIu32, h); - tile_width = w; - tile_height = h; - if (TIFFIsTiled(tif)) - { - repeat_count = TIFFNumberOfTiles(tif); - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tile_width); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &tile_height); - if (tile_width > w || tile_height > h || (w % tile_width) != 0 || - (h % tile_height != 0)) - { - /* - * The tiles does not fit image width and height. - * Set up a clip rectangle for the image unit square. - */ - fputs("0 0 1 1 rectclip\n", fd); - } - if (tile_width < w) - { - fputs("/im_x 0 def\n", fd); - (void)strcpy(im_x, "im_x neg"); - } - if (tile_height < h) - { - fputs("/im_y 0 def\n", fd); - (void)snprintf(im_y, sizeof(im_y), "%" PRIu32 " im_y sub", h); - } - } - else - { - repeat_count = tf_numberstrips; - tile_height = tf_rowsperstrip; - if (tile_height > h) - tile_height = h; - if (repeat_count > 1) - { - fputs("/im_y 0 def\n", fd); - fprintf(fd, "/im_h %" PRIu32 " def\n", tile_height); - (void)strcpy(im_h, "im_h"); - (void)snprintf(im_y, sizeof(im_y), "%" PRIu32 " im_y sub", h); - } - } +static void +PS_Lvl2colorspace(FILE* fd, TIFF* tif) +{ + uint16 *rmap, *gmap, *bmap; + int i, num_colors; + const char * colorspace_p; - /* - * Output start of exec block - */ - fputs("{ % exec\n", fd); + switch ( photometric ) + { + case PHOTOMETRIC_SEPARATED: + colorspace_p = "CMYK"; + break; - if (repeat_count > 1) - fprintf(fd, "%" PRIu32 " { %% repeat\n", repeat_count); + case PHOTOMETRIC_RGB: + colorspace_p = "RGB"; + break; - /* - * Output filter options and image dictionary. - */ - if (ascii85) - fputs(" /im_stream currentfile /ASCII85Decode filter def\n", fd); - fputs(" <<\n", fd); - fputs(" /ImageType 1\n", fd); - fprintf(fd, " /Width %" PRIu32 "\n", tile_width); - /* - * Workaround for some software that may crash when last strip - * of image contains fewer number of scanlines than specified - * by the `/Height' variable. So for stripped images with multiple - * strips we will set `/Height' as `im_h', because one is - * recalculated for each strip - including the (smaller) final strip. - * For tiled images and images with only one strip `/Height' will - * contain number of scanlines in tile (or image height in case of - * one-stripped image). - */ - if (TIFFIsTiled(tif) || tf_numberstrips == 1) - fprintf(fd, " /Height %" PRIu32 "\n", tile_height); - else - fprintf(fd, " /Height im_h\n"); + default: + colorspace_p = "Gray"; + } - if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) - fputs(" /MultipleDataSources true\n", fd); - fprintf(fd, " /ImageMatrix [ %" PRIu32 " 0 0 %" PRId32 " %s %s ]\n", w, - -(int32_t)h, im_x, im_y); - fprintf(fd, " /BitsPerComponent %" PRIu16 "\n", bitspersample); - fprintf(fd, " /Interpolate %s\n", interpolate ? "true" : "false"); + /* + * Set up PostScript Level 2 colorspace according to + * section 4.8 in the PostScript refenence manual. + */ + fputs("% PostScript Level 2 only.\n", fd); + if (photometric != PHOTOMETRIC_PALETTE) { + if (photometric == PHOTOMETRIC_YCBCR) { + /* MORE CODE HERE */ + } + fprintf(fd, "/Device%s setcolorspace\n", colorspace_p ); + return; + } - switch (samplesperpixel - extrasamples) - { - case 1: - switch (photometric) - { - case PHOTOMETRIC_MINISBLACK: - fputs(" /Decode [0 1]\n", fd); - break; - case PHOTOMETRIC_MINISWHITE: - switch (compression) - { - case COMPRESSION_CCITTRLE: - case COMPRESSION_CCITTRLEW: - case COMPRESSION_CCITTFAX3: - case COMPRESSION_CCITTFAX4: - /* - * Manage inverting with /Blackis1 flag - * since there might be uncompressed parts - */ - fputs(" /Decode [0 1]\n", fd); - break; - default: - /* - * ERROR... - */ - fputs(" /Decode [1 0]\n", fd); - break; - } - break; - case PHOTOMETRIC_PALETTE: - TIFFGetFieldDefaulted(tif, TIFFTAG_MINSAMPLEVALUE, - &minsamplevalue); - TIFFGetFieldDefaulted(tif, TIFFTAG_MAXSAMPLEVALUE, - &maxsamplevalue); - fprintf(fd, " /Decode [%" PRIu16 " %" PRIu16 "]\n", - minsamplevalue, maxsamplevalue); - break; - default: - /* - * ERROR ? - */ - fputs(" /Decode [0 1]\n", fd); - break; - } - break; - case 3: - switch (photometric) - { - case PHOTOMETRIC_RGB: - fputs(" /Decode [0 1 0 1 0 1]\n", fd); - break; - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - default: - /* - * ERROR?? - */ - fputs(" /Decode [0 1 0 1 0 1]\n", fd); - break; - } - break; - case 4: - /* - * ERROR?? - */ - fputs(" /Decode [0 1 0 1 0 1 0 1]\n", fd); - break; - } - fputs(" /DataSource", fd); - if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) - fputs(" [", fd); - if (ascii85) - fputs(" im_stream", fd); - else - fputs(" currentfile /ASCIIHexDecode filter", fd); + /* + * Set up an indexed/palette colorspace + */ + num_colors = (1 << bitspersample); + if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { + TIFFError(filename, + "Palette image w/o \"Colormap\" tag"); + return; + } + if (checkcmap(tif, num_colors, rmap, gmap, bmap) == 16) { + /* + * Convert colormap to 8-bits values. + */ +#define CVT(x) (((x) * 255) / ((1L<<16)-1)) + for (i = 0; i < num_colors; i++) { + rmap[i] = CVT(rmap[i]); + gmap[i] = CVT(gmap[i]); + bmap[i] = CVT(bmap[i]); + } +#undef CVT + } + fprintf(fd, "[ /Indexed /DeviceRGB %d", num_colors - 1); + if (ascii85) { + Ascii85Init(); + fputs("\n<~", fd); + ascii85breaklen -= 2; + } else + fputs(" <", fd); + for (i = 0; i < num_colors; i++) { + if (ascii85) { + Ascii85Put((unsigned char)rmap[i], fd); + Ascii85Put((unsigned char)gmap[i], fd); + Ascii85Put((unsigned char)bmap[i], fd); + } else { + fputs((i % 8) ? " " : "\n ", fd); + fprintf(fd, "%02x%02x%02x", + rmap[i], gmap[i], bmap[i]); + } + } + if (ascii85) + Ascii85Flush(fd); + else + fputs(">\n", fd); + fputs("] setcolorspace\n", fd); +} - use_rawdata = TRUE; - switch (compression) - { - case COMPRESSION_NONE: /* 1: uncompressed */ - break; - case COMPRESSION_CCITTRLE: /* 2: CCITT modified Huffman RLE */ - case COMPRESSION_CCITTRLEW: /* 32771: #1 w/ word alignment */ - case COMPRESSION_CCITTFAX3: /* 3: CCITT Group 3 fax encoding */ - case COMPRESSION_CCITTFAX4: /* 4: CCITT Group 4 fax encoding */ - fputs("\n\t<<\n", fd); - if (compression == COMPRESSION_CCITTFAX3) - { - uint32_t g3_options; +static int +PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h) +{ + int use_rawdata; + uint32 tile_width, tile_height; + uint16 predictor, minsamplevalue, maxsamplevalue; + uint32 repeat_count; + char im_h[64], im_x[64], im_y[64]; + char * imageOp = "image"; - fputs("\t /EndOfLine true\n", fd); - fputs("\t /EndOfBlock false\n", fd); - if (!TIFFGetField(tif, TIFFTAG_GROUP3OPTIONS, &g3_options)) - g3_options = 0; - if (g3_options & GROUP3OPT_2DENCODING) - fprintf(fd, "\t /K %s\n", im_h); - if (g3_options & GROUP3OPT_UNCOMPRESSED) - fputs("\t /Uncompressed true\n", fd); - if (g3_options & GROUP3OPT_FILLBITS) - fputs("\t /EncodedByteAlign true\n", fd); - } - if (compression == COMPRESSION_CCITTFAX4) - { - uint32_t g4_options; + if ( useImagemask && (bitspersample == 1) ) + imageOp = "imagemask"; - fputs("\t /K -1\n", fd); - TIFFGetFieldDefaulted(tif, TIFFTAG_GROUP4OPTIONS, &g4_options); - if (g4_options & GROUP4OPT_UNCOMPRESSED) - fputs("\t /Uncompressed true\n", fd); - } - if (!(tile_width == w && w == 1728U)) - fprintf(fd, "\t /Columns %" PRIu32 "\n", tile_width); - fprintf(fd, "\t /Rows %s\n", im_h); - if (compression == COMPRESSION_CCITTRLE || - compression == COMPRESSION_CCITTRLEW) - { - fputs("\t /EncodedByteAlign true\n", fd); - fputs("\t /EndOfBlock false\n", fd); - } - if (photometric == PHOTOMETRIC_MINISBLACK) - fputs("\t /BlackIs1 true\n", fd); - fprintf(fd, "\t>> /CCITTFaxDecode filter"); - break; - case COMPRESSION_LZW: /* 5: Lempel-Ziv & Welch */ - TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); - if (predictor == 2) - { - fputs("\n\t<<\n", fd); - fprintf(fd, "\t /Predictor %" PRIu16 "\n", predictor); - fprintf(fd, "\t /Columns %" PRIu32 "\n", tile_width); - fprintf(fd, "\t /Colors %" PRIu16 "\n", samplesperpixel); - fprintf(fd, "\t /BitsPerComponent %" PRIu16 "\n", - bitspersample); - fputs("\t>>", fd); - } - fputs(" /LZWDecode filter", fd); - break; - case COMPRESSION_DEFLATE: /* 5: ZIP */ - case COMPRESSION_ADOBE_DEFLATE: - if (level3) - { - TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); - if (predictor > 1) - { - fprintf(fd, "\t %% PostScript Level 3 only."); - fputs("\n\t<<\n", fd); - fprintf(fd, "\t /Predictor %" PRIu16 "\n", predictor); - fprintf(fd, "\t /Columns %" PRIu32 "\n", tile_width); - fprintf(fd, "\t /Colors %" PRIu16 "\n", samplesperpixel); - fprintf(fd, "\t /BitsPerComponent %" PRIu16 "\n", - bitspersample); - fputs("\t>>", fd); - } - fputs(" /FlateDecode filter", fd); - } - else - { - use_rawdata = FALSE; - } - break; - case COMPRESSION_PACKBITS: /* 32773: Macintosh RLE */ - fputs(" /RunLengthDecode filter", fd); - use_rawdata = TRUE; - break; - case COMPRESSION_OJPEG: /* 6: !6.0 JPEG */ - case COMPRESSION_JPEG: /* 7: %JPEG DCT compression */ + (void)strcpy(im_x, "0"); + (void)snprintf(im_y, sizeof(im_y), "%lu", (long) h); + (void)snprintf(im_h, sizeof(im_h), "%lu", (long) h); + tile_width = w; + tile_height = h; + if (TIFFIsTiled(tif)) { + repeat_count = TIFFNumberOfTiles(tif); + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tile_width); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &tile_height); + if (tile_width > w || tile_height > h || + (w % tile_width) != 0 || (h % tile_height != 0)) { + /* + * The tiles does not fit image width and height. + * Set up a clip rectangle for the image unit square. + */ + fputs("0 0 1 1 rectclip\n", fd); + } + if (tile_width < w) { + fputs("/im_x 0 def\n", fd); + (void)strcpy(im_x, "im_x neg"); + } + if (tile_height < h) { + fputs("/im_y 0 def\n", fd); + (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h); + } + } else { + repeat_count = tf_numberstrips; + tile_height = tf_rowsperstrip; + if (tile_height > h) + tile_height = h; + if (repeat_count > 1) { + fputs("/im_y 0 def\n", fd); + fprintf(fd, "/im_h %lu def\n", + (unsigned long) tile_height); + (void)strcpy(im_h, "im_h"); + (void)snprintf(im_y, sizeof(im_y), "%lu im_y sub", (unsigned long) h); + } + } + + /* + * Output start of exec block + */ + fputs("{ % exec\n", fd); + + if (repeat_count > 1) + fprintf(fd, "%u { %% repeat\n", repeat_count); + + /* + * Output filter options and image dictionary. + */ + if (ascii85) + fputs(" /im_stream currentfile /ASCII85Decode filter def\n", + fd); + fputs(" <<\n", fd); + fputs(" /ImageType 1\n", fd); + fprintf(fd, " /Width %lu\n", (unsigned long) tile_width); + /* + * Workaround for some software that may crash when last strip + * of image contains fewer number of scanlines than specified + * by the `/Height' variable. So for stripped images with multiple + * strips we will set `/Height' as `im_h', because one is + * recalculated for each strip - including the (smaller) final strip. + * For tiled images and images with only one strip `/Height' will + * contain number of scanlines in tile (or image height in case of + * one-stripped image). + */ + if (TIFFIsTiled(tif) || tf_numberstrips == 1) + fprintf(fd, " /Height %lu\n", (unsigned long) tile_height); + else + fprintf(fd, " /Height im_h\n"); + + if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) + fputs(" /MultipleDataSources true\n", fd); + fprintf(fd, " /ImageMatrix [ %lu 0 0 %ld %s %s ]\n", + (unsigned long) w, - (long)h, im_x, im_y); + fprintf(fd, " /BitsPerComponent %d\n", bitspersample); + fprintf(fd, " /Interpolate %s\n", interpolate ? "true" : "false"); + + switch (samplesperpixel - extrasamples) { + case 1: + switch (photometric) { + case PHOTOMETRIC_MINISBLACK: + fputs(" /Decode [0 1]\n", fd); + break; + case PHOTOMETRIC_MINISWHITE: + switch (compression) { + case COMPRESSION_CCITTRLE: + case COMPRESSION_CCITTRLEW: + case COMPRESSION_CCITTFAX3: + case COMPRESSION_CCITTFAX4: + /* + * Manage inverting with /Blackis1 flag + * since there migth be uncompressed parts + */ + fputs(" /Decode [0 1]\n", fd); + break; + default: + /* + * ERROR... + */ + fputs(" /Decode [1 0]\n", fd); + break; + } + break; + case PHOTOMETRIC_PALETTE: + TIFFGetFieldDefaulted(tif, TIFFTAG_MINSAMPLEVALUE, + &minsamplevalue); + TIFFGetFieldDefaulted(tif, TIFFTAG_MAXSAMPLEVALUE, + &maxsamplevalue); + fprintf(fd, " /Decode [%u %u]\n", + minsamplevalue, maxsamplevalue); + break; + default: + /* + * ERROR ? + */ + fputs(" /Decode [0 1]\n", fd); + break; + } + break; + case 3: + switch (photometric) { + case PHOTOMETRIC_RGB: + fputs(" /Decode [0 1 0 1 0 1]\n", fd); + break; + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + default: + /* + * ERROR?? + */ + fputs(" /Decode [0 1 0 1 0 1]\n", fd); + break; + } + break; + case 4: + /* + * ERROR?? + */ + fputs(" /Decode [0 1 0 1 0 1 0 1]\n", fd); + break; + } + fputs(" /DataSource", fd); + if (planarconfiguration == PLANARCONFIG_SEPARATE && + samplesperpixel > 1) + fputs(" [", fd); + if (ascii85) + fputs(" im_stream", fd); + else + fputs(" currentfile /ASCIIHexDecode filter", fd); + + use_rawdata = TRUE; + switch (compression) { + case COMPRESSION_NONE: /* 1: uncompressed */ + break; + case COMPRESSION_CCITTRLE: /* 2: CCITT modified Huffman RLE */ + case COMPRESSION_CCITTRLEW: /* 32771: #1 w/ word alignment */ + case COMPRESSION_CCITTFAX3: /* 3: CCITT Group 3 fax encoding */ + case COMPRESSION_CCITTFAX4: /* 4: CCITT Group 4 fax encoding */ + fputs("\n\t<<\n", fd); + if (compression == COMPRESSION_CCITTFAX3) { + uint32 g3_options; + + fputs("\t /EndOfLine true\n", fd); + fputs("\t /EndOfBlock false\n", fd); + if (!TIFFGetField(tif, TIFFTAG_GROUP3OPTIONS, + &g3_options)) + g3_options = 0; + if (g3_options & GROUP3OPT_2DENCODING) + fprintf(fd, "\t /K %s\n", im_h); + if (g3_options & GROUP3OPT_UNCOMPRESSED) + fputs("\t /Uncompressed true\n", fd); + if (g3_options & GROUP3OPT_FILLBITS) + fputs("\t /EncodedByteAlign true\n", fd); + } + if (compression == COMPRESSION_CCITTFAX4) { + uint32 g4_options; + + fputs("\t /K -1\n", fd); + TIFFGetFieldDefaulted(tif, TIFFTAG_GROUP4OPTIONS, + &g4_options); + if (g4_options & GROUP4OPT_UNCOMPRESSED) + fputs("\t /Uncompressed true\n", fd); + } + if (!(tile_width == w && w == 1728U)) + fprintf(fd, "\t /Columns %lu\n", + (unsigned long) tile_width); + fprintf(fd, "\t /Rows %s\n", im_h); + if (compression == COMPRESSION_CCITTRLE || + compression == COMPRESSION_CCITTRLEW) { + fputs("\t /EncodedByteAlign true\n", fd); + fputs("\t /EndOfBlock false\n", fd); + } + if (photometric == PHOTOMETRIC_MINISBLACK) + fputs("\t /BlackIs1 true\n", fd); + fprintf(fd, "\t>> /CCITTFaxDecode filter"); + break; + case COMPRESSION_LZW: /* 5: Lempel-Ziv & Welch */ + TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); + if (predictor == 2) { + fputs("\n\t<<\n", fd); + fprintf(fd, "\t /Predictor %u\n", predictor); + fprintf(fd, "\t /Columns %lu\n", + (unsigned long) tile_width); + fprintf(fd, "\t /Colors %u\n", samplesperpixel); + fprintf(fd, "\t /BitsPerComponent %u\n", + bitspersample); + fputs("\t>>", fd); + } + fputs(" /LZWDecode filter", fd); + break; + case COMPRESSION_DEFLATE: /* 5: ZIP */ + case COMPRESSION_ADOBE_DEFLATE: + if ( level3 ) { + TIFFGetFieldDefaulted(tif, TIFFTAG_PREDICTOR, &predictor); + if (predictor > 1) { + fprintf(fd, "\t %% PostScript Level 3 only."); + fputs("\n\t<<\n", fd); + fprintf(fd, "\t /Predictor %u\n", predictor); + fprintf(fd, "\t /Columns %lu\n", + (unsigned long) tile_width); + fprintf(fd, "\t /Colors %u\n", samplesperpixel); + fprintf(fd, "\t /BitsPerComponent %u\n", + bitspersample); + fputs("\t>>", fd); + } + fputs(" /FlateDecode filter", fd); + } else { + use_rawdata = FALSE ; + } + break; + case COMPRESSION_PACKBITS: /* 32773: Macintosh RLE */ + fputs(" /RunLengthDecode filter", fd); + use_rawdata = TRUE; + break; + case COMPRESSION_OJPEG: /* 6: !6.0 JPEG */ + case COMPRESSION_JPEG: /* 7: %JPEG DCT compression */ #ifdef notdef - /* - * Code not tested yet - */ - fputs(" /DCTDecode filter", fd); - use_rawdata = TRUE; + /* + * Code not tested yet + */ + fputs(" /DCTDecode filter", fd); + use_rawdata = TRUE; #else - use_rawdata = FALSE; + use_rawdata = FALSE; #endif - break; - case COMPRESSION_NEXT: /* 32766: NeXT 2-bit RLE */ - case COMPRESSION_THUNDERSCAN: /* 32809: ThunderScan RLE */ - case COMPRESSION_PIXARFILM: /* 32908: Pixar companded 10bit LZW */ - case COMPRESSION_JBIG: /* 34661: ISO JBIG */ - use_rawdata = FALSE; - break; - case COMPRESSION_SGILOG: /* 34676: SGI LogL or LogLuv */ - case COMPRESSION_SGILOG24: /* 34677: SGI 24-bit LogLuv */ - use_rawdata = FALSE; - break; - default: - /* - * ERROR... - */ - use_rawdata = FALSE; - break; - } - if (planarconfiguration == PLANARCONFIG_SEPARATE && samplesperpixel > 1) - { - uint16_t i; + break; + case COMPRESSION_NEXT: /* 32766: NeXT 2-bit RLE */ + case COMPRESSION_THUNDERSCAN: /* 32809: ThunderScan RLE */ + case COMPRESSION_PIXARFILM: /* 32908: Pixar companded 10bit LZW */ + case COMPRESSION_JBIG: /* 34661: ISO JBIG */ + use_rawdata = FALSE; + break; + case COMPRESSION_SGILOG: /* 34676: SGI LogL or LogLuv */ + case COMPRESSION_SGILOG24: /* 34677: SGI 24-bit LogLuv */ + use_rawdata = FALSE; + break; + default: + /* + * ERROR... + */ + use_rawdata = FALSE; + break; + } + if (planarconfiguration == PLANARCONFIG_SEPARATE && + samplesperpixel > 1) { + uint16 i; - /* - * NOTE: This code does not work yet... - */ - for (i = 1; i < samplesperpixel; i++) - fputs(" dup", fd); - fputs(" ]", fd); - } + /* + * NOTE: This code does not work yet... + */ + for (i = 1; i < samplesperpixel; i++) + fputs(" dup", fd); + fputs(" ]", fd); + } - fprintf(fd, "\n >> %s\n", imageOp); - if (ascii85) - fputs(" im_stream status { im_stream flushfile } if\n", fd); - if (repeat_count > 1) - { - if (tile_width < w) - { - fprintf(fd, " /im_x im_x %" PRIu32 " add def\n", tile_width); - if (tile_height < h) - { - fprintf(fd, " im_x %" PRIu32 " ge {\n", w); - fputs(" /im_x 0 def\n", fd); - fprintf(fd, " /im_y im_y %" PRIu32 " add def\n", tile_height); - fputs(" } if\n", fd); - } - } - if (tile_height < h) - { - if (tile_width >= w) - { - fprintf(fd, " /im_y im_y %" PRIu32 " add def\n", tile_height); - if (!TIFFIsTiled(tif)) - { - fprintf(fd, " /im_h %" PRIu32 " im_y sub", h); - fprintf(fd, " dup %" PRIu32 " gt { pop", tile_height); - fprintf(fd, " %" PRIu32 " } if def\n", tile_height); - } - } - } - fputs("} repeat\n", fd); - } - /* - * End of exec function - */ - fputs("}\n", fd); + fprintf( fd, "\n >> %s\n", imageOp ); + if (ascii85) + fputs(" im_stream status { im_stream flushfile } if\n", fd); + if (repeat_count > 1) { + if (tile_width < w) { + fprintf(fd, " /im_x im_x %lu add def\n", + (unsigned long) tile_width); + if (tile_height < h) { + fprintf(fd, " im_x %lu ge {\n", + (unsigned long) w); + fputs(" /im_x 0 def\n", fd); + fprintf(fd, " /im_y im_y %lu add def\n", + (unsigned long) tile_height); + fputs(" } if\n", fd); + } + } + if (tile_height < h) { + if (tile_width >= w) { + fprintf(fd, " /im_y im_y %lu add def\n", + (unsigned long) tile_height); + if (!TIFFIsTiled(tif)) { + fprintf(fd, " /im_h %lu im_y sub", + (unsigned long) h); + fprintf(fd, " dup %lu gt { pop", + (unsigned long) tile_height); + fprintf(fd, " %lu } if def\n", + (unsigned long) tile_height); + } + } + } + fputs("} repeat\n", fd); + } + /* + * End of exec function + */ + fputs("}\n", fd); - return (use_rawdata); + return(use_rawdata); } /* Flip the byte order of buffers with 16 bit samples */ -static void PS_FlipBytes(unsigned char *buf, tsize_t count) +static void +PS_FlipBytes(unsigned char* buf, tsize_t count) { - int i; - unsigned char temp; + int i; + unsigned char temp; - if (count <= 0 || bitspersample <= 8) - { - return; - } + if (count <= 0 || bitspersample <= 8) { + return; + } - count--; + count--; - for (i = 0; i < count; i += 2) - { - temp = buf[i]; - buf[i] = buf[i + 1]; - buf[i + 1] = temp; - } + for (i = 0; i < count; i += 2) { + temp = buf[i]; + buf[i] = buf[i + 1]; + buf[i + 1] = temp; + } } -#define MAXLINE 36 +#define MAXLINE 36 -int PS_Lvl2page(FILE *fd, TIFF *tif, uint32_t w, uint32_t h) +int +PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h) { - uint16_t fillorder; - int use_rawdata, tiled_image, breaklen = MAXLINE; - uint32_t chunk_no, num_chunks; - uint64_t *bc; - unsigned char *buf_data, *cp; - tsize_t chunk_size, byte_count; + uint16 fillorder; + int use_rawdata, tiled_image, breaklen = MAXLINE; + uint32 chunk_no, num_chunks; + uint64 *bc; + unsigned char *buf_data, *cp; + tsize_t chunk_size, byte_count; -#if defined(EXP_ASCII85ENCODER) - tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ - uint8_t *ascii85_p = 0; /* Holds ASCII85 encoded data */ +#if defined( EXP_ASCII85ENCODER ) + tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ + uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */ #endif - PS_Lvl2colorspace(fd, tif); - use_rawdata = PS_Lvl2ImageDict(fd, tif, w, h); + PS_Lvl2colorspace(fd, tif); + use_rawdata = PS_Lvl2ImageDict(fd, tif, w, h); /* See http://bugzilla.remotesensing.org/show_bug.cgi?id=80 */ #ifdef ENABLE_BROKEN_BEGINENDDATA - fputs("%%BeginData:\n", fd); + fputs("%%BeginData:\n", fd); #endif - fputs("exec\n", fd); + fputs("exec\n", fd); - tiled_image = TIFFIsTiled(tif); - if (tiled_image) - { - num_chunks = TIFFNumberOfTiles(tif); - TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &bc); - } - else - { - num_chunks = TIFFNumberOfStrips(tif); - TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); - } + tiled_image = TIFFIsTiled(tif); + if (tiled_image) { + num_chunks = TIFFNumberOfTiles(tif); + TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &bc); + } else { + num_chunks = TIFFNumberOfStrips(tif); + TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); + } - if (use_rawdata) - { - chunk_size = (tsize_t)bc[0]; - for (chunk_no = 1; chunk_no < num_chunks; chunk_no++) - if ((tsize_t)bc[chunk_no] > chunk_size) - chunk_size = (tsize_t)bc[chunk_no]; - } - else - { - if (tiled_image) - chunk_size = TIFFTileSize(tif); - else - chunk_size = TIFFStripSize(tif); - } - buf_data = (unsigned char *)limitMalloc(chunk_size); - if (!buf_data) - { - TIFFError(filename, "Can't alloc %" TIFF_SSIZE_FORMAT " bytes for %s.", - chunk_size, tiled_image ? "tiles" : "strips"); - return (FALSE); - } + if (use_rawdata) { + chunk_size = (tsize_t) bc[0]; + for (chunk_no = 1; chunk_no < num_chunks; chunk_no++) + if ((tsize_t) bc[chunk_no] > chunk_size) + chunk_size = (tsize_t) bc[chunk_no]; + } else { + if (tiled_image) + chunk_size = TIFFTileSize(tif); + else + chunk_size = TIFFStripSize(tif); + } + buf_data = (unsigned char *)limitMalloc(chunk_size); + if (!buf_data) { + TIFFError(filename, "Can't alloc %lu bytes for %s.", + (unsigned long) chunk_size, tiled_image ? "tiles" : "strips"); + return(FALSE); + } -#if defined(EXP_ASCII85ENCODER) - if (ascii85) - { - /* - * Allocate a buffer to hold the ASCII85 encoded data. Note - * that it is allocated with sufficient room to hold the - * encoded data (5*chunk_size/4) plus the EOD marker (+8) - * and formatting line breaks. The line breaks are more - * than taken care of by using 6*chunk_size/4 rather than - * 5*chunk_size/4. - */ +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85 ) { + /* + * Allocate a buffer to hold the ASCII85 encoded data. Note + * that it is allocated with sufficient room to hold the + * encoded data (5*chunk_size/4) plus the EOD marker (+8) + * and formatting line breaks. The line breaks are more + * than taken care of by using 6*chunk_size/4 rather than + * 5*chunk_size/4. + */ - ascii85_p = limitMalloc((chunk_size + (chunk_size / 2)) + 8); + ascii85_p = limitMalloc( (chunk_size+(chunk_size/2)) + 8 ); - if (!ascii85_p) - { - _TIFFfree(buf_data); + if ( !ascii85_p ) { + _TIFFfree( buf_data ); - TIFFError(filename, "Cannot allocate ASCII85 encoding buffer."); - return (FALSE); - } - } + TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." ); + return ( FALSE ); + } + } #endif - TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder); - for (chunk_no = 0; chunk_no < num_chunks; chunk_no++) - { - if (ascii85) - Ascii85Init(); - else - breaklen = MAXLINE; - if (use_rawdata) - { - if (tiled_image) - byte_count = - TIFFReadRawTile(tif, chunk_no, buf_data, chunk_size); - else - byte_count = - TIFFReadRawStrip(tif, chunk_no, buf_data, chunk_size); - if (fillorder == FILLORDER_LSB2MSB) - TIFFReverseBits(buf_data, byte_count); - } - else - { - if (tiled_image) - byte_count = - TIFFReadEncodedTile(tif, chunk_no, buf_data, chunk_size); - else - byte_count = - TIFFReadEncodedStrip(tif, chunk_no, buf_data, chunk_size); - } - if (byte_count < 0) - { - TIFFError(filename, "Can't read %s %" PRIu32 ".", - tiled_image ? "tile" : "strip", chunk_no); - if (ascii85) - Ascii85Put('\0', fd); - } - /* - * for 16 bits, the two bytes must be most significant - * byte first - */ - if (bitspersample == 16 && !TIFFIsBigEndian(tif)) - { - PS_FlipBytes(buf_data, byte_count); - } - /* - * For images with alpha, matte against a white background; - * i.e. Cback * (1 - Aimage) where Cback = 1. We will fill the - * lower part of the buffer with the modified values. - * - * XXX: needs better solution - */ - if (alpha) - { - int adjust, i, j = 0; - int ncomps = samplesperpixel - extrasamples; - for (i = 0; (i + ncomps) < byte_count; i += samplesperpixel) - { - adjust = 255 - buf_data[i + ncomps]; - switch (ncomps) - { - case 1: - buf_data[j++] = buf_data[i] + adjust; - break; - case 2: - buf_data[j++] = buf_data[i] + adjust; - buf_data[j++] = buf_data[i + 1] + adjust; - break; - case 3: - buf_data[j++] = buf_data[i] + adjust; - buf_data[j++] = buf_data[i + 1] + adjust; - buf_data[j++] = buf_data[i + 2] + adjust; - break; - } - } - byte_count -= j; - } + TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder); + for (chunk_no = 0; chunk_no < num_chunks; chunk_no++) { + if (ascii85) + Ascii85Init(); + else + breaklen = MAXLINE; + if (use_rawdata) { + if (tiled_image) + byte_count = TIFFReadRawTile(tif, chunk_no, + buf_data, chunk_size); + else + byte_count = TIFFReadRawStrip(tif, chunk_no, + buf_data, chunk_size); + if (fillorder == FILLORDER_LSB2MSB) + TIFFReverseBits(buf_data, byte_count); + } else { + if (tiled_image) + byte_count = TIFFReadEncodedTile(tif, + chunk_no, buf_data, + chunk_size); + else + byte_count = TIFFReadEncodedStrip(tif, + chunk_no, buf_data, + chunk_size); + } + if (byte_count < 0) { + TIFFError(filename, "Can't read %s %d.", + tiled_image ? "tile" : "strip", chunk_no); + if (ascii85) + Ascii85Put('\0', fd); + } + /* + * for 16 bits, the two bytes must be most significant + * byte first + */ + if (bitspersample == 16 && !TIFFIsBigEndian(tif)) { + PS_FlipBytes(buf_data, byte_count); + } + /* + * For images with alpha, matte against a white background; + * i.e. Cback * (1 - Aimage) where Cback = 1. We will fill the + * lower part of the buffer with the modified values. + * + * XXX: needs better solution + */ + if (alpha) { + int adjust, i, j = 0; + int ncomps = samplesperpixel - extrasamples; + for (i = 0; (i + ncomps) < byte_count; i+=samplesperpixel) { + adjust = 255 - buf_data[i + ncomps]; + switch (ncomps) { + case 1: + buf_data[j++] = buf_data[i] + adjust; + break; + case 2: + buf_data[j++] = buf_data[i] + adjust; + buf_data[j++] = buf_data[i+1] + adjust; + break; + case 3: + buf_data[j++] = buf_data[i] + adjust; + buf_data[j++] = buf_data[i+1] + adjust; + buf_data[j++] = buf_data[i+2] + adjust; + break; + } + } + byte_count -= j; + } - if (ascii85) - { -#if defined(EXP_ASCII85ENCODER) - ascii85_l = Ascii85EncodeBlock(ascii85_p, 1, buf_data, byte_count); + if (ascii85) { +#if defined( EXP_ASCII85ENCODER ) + ascii85_l = Ascii85EncodeBlock(ascii85_p, 1, buf_data, byte_count ); - if (ascii85_l > 0) - fwrite(ascii85_p, ascii85_l, 1, fd); + if ( ascii85_l > 0 ) + fwrite( ascii85_p, ascii85_l, 1, fd ); #else - for (cp = buf_data; byte_count > 0; byte_count--) - Ascii85Put(*cp++, fd); + for (cp = buf_data; byte_count > 0; byte_count--) + Ascii85Put(*cp++, fd); #endif - } - else - { - for (cp = buf_data; byte_count > 0; byte_count--) - { - putc(hex[((*cp) >> 4) & 0xf], fd); - putc(hex[(*cp) & 0xf], fd); - cp++; + } + else + { + for (cp = buf_data; byte_count > 0; byte_count--) { + putc(hex[((*cp)>>4)&0xf], fd); + putc(hex[(*cp)&0xf], fd); + cp++; - if (--breaklen <= 0) - { - putc('\n', fd); - breaklen = MAXLINE; - } - } - } + if (--breaklen <= 0) { + putc('\n', fd); + breaklen = MAXLINE; + } + } + } - if (!ascii85) - { - if (level2 || level3) - putc('>', fd); - putc('\n', fd); - } -#if !defined(EXP_ASCII85ENCODER) - else - Ascii85Flush(fd); + if ( !ascii85 ) { + if ( level2 || level3 ) + putc( '>', fd ); + putc('\n', fd); + } +#if !defined( EXP_ASCII85ENCODER ) + else + Ascii85Flush(fd); #endif - } + } -#if defined(EXP_ASCII85ENCODER) - if (ascii85_p) - _TIFFfree(ascii85_p); +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85_p ) + _TIFFfree( ascii85_p ); #endif - - _TIFFfree(buf_data); + + _TIFFfree(buf_data); #ifdef ENABLE_BROKEN_BEGINENDDATA - fputs("%%EndData\n", fd); + fputs("%%EndData\n", fd); #endif - return (TRUE); + return(TRUE); } -void PSpage(FILE *fd, TIFF *tif, uint32_t w, uint32_t h) +void +PSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h) { - char *imageOp = "image"; + char * imageOp = "image"; - if (useImagemask && (bitspersample == 1)) - imageOp = "imagemask"; + if ( useImagemask && (bitspersample == 1) ) + imageOp = "imagemask"; - if ((level2 || level3) && PS_Lvl2page(fd, tif, w, h)) - return; - ps_bytesperrow = tf_bytesperrow - (extrasamples * bitspersample / 8) * w; - switch (photometric) - { - case PHOTOMETRIC_RGB: - if (planarconfiguration == PLANARCONFIG_CONTIG) - { - fprintf(fd, "%s", RGBcolorimage); - PSColorContigPreamble(fd, w, h, 3); - PSDataColorContig(fd, tif, w, h, 3); - } - else - { - PSColorSeparatePreamble(fd, w, h, 3); - PSDataColorSeparate(fd, tif, w, h, 3); - } - break; - case PHOTOMETRIC_SEPARATED: - /* XXX should emit CMYKcolorimage */ - if (planarconfiguration == PLANARCONFIG_CONTIG) - { - PSColorContigPreamble(fd, w, h, 4); - PSDataColorContig(fd, tif, w, h, 4); - } - else - { - PSColorSeparatePreamble(fd, w, h, 4); - PSDataColorSeparate(fd, tif, w, h, 4); - } - break; - case PHOTOMETRIC_PALETTE: - fprintf(fd, "%s", RGBcolorimage); - PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage"); - fprintf(fd, "/scanLine %" TIFF_SSIZE_FORMAT " string def\n", - ps_bytesperrow * 3); - fprintf(fd, "%" PRIu32 " %" PRIu32 " 8\n", w, h); - fprintf(fd, "[%" PRIu32 " 0 0 -%" PRIu32 " 0 %" PRIu32 "]\n", w, h, - h); - fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); - fprintf(fd, "false 3 colorimage\n"); - PSDataPalette(fd, tif, w, h); - break; - case PHOTOMETRIC_MINISBLACK: - case PHOTOMETRIC_MINISWHITE: - PhotoshopBanner(fd, w, h, 1, 1, imageOp); - fprintf(fd, "/scanLine %" TIFF_SSIZE_FORMAT " string def\n", - ps_bytesperrow); - fprintf(fd, "%" PRIu32 " %" PRIu32 " %" PRIu16 "\n", w, h, - bitspersample); - fprintf(fd, "[%" PRIu32 " 0 0 -%" PRIu32 " 0 %" PRIu32 "]\n", w, h, - h); - fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); - fprintf(fd, "%s\n", imageOp); - PSDataBW(fd, tif, w, h); - break; - } - putc('\n', fd); + if ((level2 || level3) && PS_Lvl2page(fd, tif, w, h)) + return; + ps_bytesperrow = tf_bytesperrow - (extrasamples * bitspersample / 8)*w; + switch (photometric) { + case PHOTOMETRIC_RGB: + if (planarconfiguration == PLANARCONFIG_CONTIG) { + fprintf(fd, "%s", RGBcolorimage); + PSColorContigPreamble(fd, w, h, 3); + PSDataColorContig(fd, tif, w, h, 3); + } else { + PSColorSeparatePreamble(fd, w, h, 3); + PSDataColorSeparate(fd, tif, w, h, 3); + } + break; + case PHOTOMETRIC_SEPARATED: + /* XXX should emit CMYKcolorimage */ + if (planarconfiguration == PLANARCONFIG_CONTIG) { + PSColorContigPreamble(fd, w, h, 4); + PSDataColorContig(fd, tif, w, h, 4); + } else { + PSColorSeparatePreamble(fd, w, h, 4); + PSDataColorSeparate(fd, tif, w, h, 4); + } + break; + case PHOTOMETRIC_PALETTE: + fprintf(fd, "%s", RGBcolorimage); + PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage"); + fprintf(fd, "/scanLine %ld string def\n", + (long) ps_bytesperrow * 3L); + fprintf(fd, "%lu %lu 8\n", + (unsigned long) w, (unsigned long) h); + fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", + (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "{currentfile scanLine readhexstring pop} bind\n"); + fprintf(fd, "false 3 colorimage\n"); + PSDataPalette(fd, tif, w, h); + break; + case PHOTOMETRIC_MINISBLACK: + case PHOTOMETRIC_MINISWHITE: + PhotoshopBanner(fd, w, h, 1, 1, imageOp); + fprintf(fd, "/scanLine %ld string def\n", + (long) ps_bytesperrow); + fprintf(fd, "%lu %lu %d\n", + (unsigned long) w, (unsigned long) h, bitspersample); + fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", + (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, + "{currentfile scanLine readhexstring pop} bind\n"); + fprintf(fd, "%s\n", imageOp); + PSDataBW(fd, tif, w, h); + break; + } + putc('\n', fd); } -void PSColorContigPreamble(FILE *fd, uint32_t w, uint32_t h, int nc) +void +PSColorContigPreamble(FILE* fd, uint32 w, uint32 h, int nc) { - ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel); - PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage"); - fprintf(fd, "/line %" TIFF_SSIZE_FORMAT " string def\n", ps_bytesperrow); - fprintf(fd, "%" PRIu32 " %" PRIu32 " %" PRIu16 "\n", w, h, bitspersample); - fprintf(fd, "[%" PRIu32 " 0 0 -%" PRIu32 " 0 %" PRIu32 "]\n", w, h, h); - fprintf(fd, "{currentfile line readhexstring pop} bind\n"); - fprintf(fd, "false %d colorimage\n", nc); + ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel); + PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage"); + fprintf(fd, "/line %ld string def\n", (long) ps_bytesperrow); + fprintf(fd, "%lu %lu %d\n", + (unsigned long) w, (unsigned long) h, bitspersample); + fprintf(fd, "[%lu 0 0 -%lu 0 %lu]\n", + (unsigned long) w, (unsigned long) h, (unsigned long) h); + fprintf(fd, "{currentfile line readhexstring pop} bind\n"); + fprintf(fd, "false %d colorimage\n", nc); } -void PSColorSeparatePreamble(FILE *fd, uint32_t w, uint32_t h, int nc) +void +PSColorSeparatePreamble(FILE* fd, uint32 w, uint32 h, int nc) { - int i; + int i; - PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage"); - for (i = 0; i < nc; i++) - fprintf(fd, "/line%d %" TIFF_SSIZE_FORMAT " string def\n", i, - ps_bytesperrow); - fprintf(fd, "%" PRIu32 " %" PRIu32 " %" PRIu16 "\n", w, h, bitspersample); - fprintf(fd, "[%" PRIu32 " 0 0 -%" PRIu32 " 0 %" PRIu32 "] \n", w, h, h); - for (i = 0; i < nc; i++) - fprintf(fd, "{currentfile line%d readhexstring pop}bind\n", i); - fprintf(fd, "true %d colorimage\n", nc); + PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage"); + for (i = 0; i < nc; i++) + fprintf(fd, "/line%d %ld string def\n", + i, (long) ps_bytesperrow); + fprintf(fd, "%lu %lu %d\n", + (unsigned long) w, (unsigned long) h, bitspersample); + fprintf(fd, "[%lu 0 0 -%lu 0 %lu] \n", + (unsigned long) w, (unsigned long) h, (unsigned long) h); + for (i = 0; i < nc; i++) + fprintf(fd, "{currentfile line%d readhexstring pop}bind\n", i); + fprintf(fd, "true %d colorimage\n", nc); } -#define DOBREAK(len, howmany, fd) \ - if (((len) -= (howmany)) <= 0) \ - { \ - putc('\n', fd); \ - (len) = MAXLINE - (howmany); \ - } +#define DOBREAK(len, howmany, fd) \ + if (((len) -= (howmany)) <= 0) { \ + putc('\n', fd); \ + (len) = MAXLINE-(howmany); \ + } +#define PUTHEX(c,fd) putc(hex[((c)>>4)&0xf],fd); putc(hex[(c)&0xf],fd) -static inline void puthex(unsigned int c, FILE *fd) +void +PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) { - putc(hex[((c) >> 4) & 0xf], fd); - putc(hex[(c)&0xf], fd); -} + uint32 row; + int breaklen = MAXLINE, es = samplesperpixel - nc; + tsize_t cc; + unsigned char *tf_buf; + unsigned char *cp, c; -void PSDataColorContig(FILE *fd, TIFF *tif, uint32_t w, uint32_t h, int nc) -{ - uint32_t row; - int breaklen = MAXLINE, es = samplesperpixel - nc; - tsize_t cc; - unsigned char *tf_buf; - unsigned char *cp, c; - - (void)w; - if (es < 0) - { - TIFFError(filename, - "Inconsistent value of es: %d (samplesperpixel=%" PRIu16 - ", nc=%d)", - es, samplesperpixel, nc); - return; - } - tf_buf = (unsigned char *)limitMalloc(tf_bytesperrow); - if (tf_buf == NULL) - { - TIFFError(filename, "No space for scanline buffer"); - return; - } - for (row = 0; row < h; row++) - { - if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) - break; - cp = tf_buf; - /* - * for 16 bits, the two bytes must be most significant - * byte first - */ - if (bitspersample == 16 && !HOST_BIGENDIAN) + (void) w; + if( es < 0 ) { - PS_FlipBytes(cp, tf_bytesperrow); - } - if (alpha) - { - int adjust; - /* - * the code inside this loop reads nc bytes + 1 extra byte (for - * adjust) - */ - for (cc = 0; (cc + nc) < tf_bytesperrow; cc += samplesperpixel) - { - DOBREAK(breaklen, nc, fd); - /* - * For images with alpha, matte against - * a white background; i.e. - * Cback * (1 - Aimage) - * where Cback = 1. - */ - adjust = 255 - cp[nc]; - for (int i = 0; i < nc; ++i) - { - c = *cp++ + adjust; - puthex(c, fd); - } - cp += es; - } - } - else - { - /* - * the code inside this loop reads nc bytes per iteration - */ - for (cc = 0; (cc + nc) <= tf_bytesperrow; cc += samplesperpixel) - { - DOBREAK(breaklen, nc, fd); - for (int i = 0; i < nc; ++i) - { - c = *cp++; - puthex(c, fd); - } - cp += es; - } - } - } - _TIFFfree((char *)tf_buf); -} - -void PSDataColorSeparate(FILE *fd, TIFF *tif, uint32_t w, uint32_t h, int nc) -{ - uint32_t row; - int breaklen = MAXLINE; - tsize_t cc; - tsample_t s, maxs; - unsigned char *tf_buf; - unsigned char *cp, c; - - (void)w; - tf_buf = (unsigned char *)limitMalloc(tf_bytesperrow); - if (tf_buf == NULL) - { - TIFFError(filename, "No space for scanline buffer"); - return; - } - maxs = (samplesperpixel > nc ? nc : samplesperpixel); - for (row = 0; row < h; row++) - { - for (s = 0; s < maxs; s++) - { - if (TIFFReadScanline(tif, tf_buf, row, s) < 0) - goto end_loop; - for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) - { - DOBREAK(breaklen, 1, fd); - c = *cp++; - puthex(c, fd); - } - } - } -end_loop: - _TIFFfree((char *)tf_buf); -} - -#define PUTRGBHEX(c, fd) \ - puthex(rmap[c], fd); \ - puthex(gmap[c], fd); \ - puthex(bmap[c], fd) - -void PSDataPalette(FILE *fd, TIFF *tif, uint32_t w, uint32_t h) -{ - uint16_t *rmap, *gmap, *bmap; - uint32_t row; - int breaklen = MAXLINE, nc; - tsize_t cc; - unsigned char *tf_buf; - unsigned char *cp, c; - - (void)w; - if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) - { - TIFFError(filename, "Palette image w/o \"Colormap\" tag"); - return; - } - switch (bitspersample) - { - case 8: - case 4: - case 2: - case 1: - break; - default: - TIFFError(filename, "Depth %" PRIu16 " not supported", - bitspersample); + TIFFError(filename, "Inconsistent value of es: %d (samplesperpixel=%u, nc=%d)", es, samplesperpixel, nc); return; - } - nc = 3 * (8 / bitspersample); - tf_buf = (unsigned char *)limitMalloc(tf_bytesperrow); - if (tf_buf == NULL) - { - TIFFError(filename, "No space for scanline buffer"); - return; - } - if (checkcmap(tif, 1 << bitspersample, rmap, gmap, bmap) == 16) - { - int i; -#define CVT(x) ((unsigned short)(((x)*255) / ((1U << 16) - 1))) - for (i = (1 << bitspersample) - 1; i >= 0; i--) - { - rmap[i] = CVT(rmap[i]); - gmap[i] = CVT(gmap[i]); - bmap[i] = CVT(bmap[i]); } + tf_buf = (unsigned char *) limitMalloc(tf_bytesperrow); + if (tf_buf == NULL) { + TIFFError(filename, "No space for scanline buffer"); + return; + } + for (row = 0; row < h; row++) { + if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) + break; + cp = tf_buf; + /* + * for 16 bits, the two bytes must be most significant + * byte first + */ + if (bitspersample == 16 && !HOST_BIGENDIAN) { + PS_FlipBytes(cp, tf_bytesperrow); + } + if (alpha) { + int adjust; + /* + * the code inside this loop reads nc bytes + 1 extra byte (for adjust) + */ + for (cc = 0; (cc + nc) < tf_bytesperrow; cc += samplesperpixel) { + DOBREAK(breaklen, nc, fd); + /* + * For images with alpha, matte against + * a white background; i.e. + * Cback * (1 - Aimage) + * where Cback = 1. + */ + adjust = 255 - cp[nc]; + switch (nc) { + case 4: c = *cp++ + adjust; PUTHEX(c,fd); + case 3: c = *cp++ + adjust; PUTHEX(c,fd); + case 2: c = *cp++ + adjust; PUTHEX(c,fd); + case 1: c = *cp++ + adjust; PUTHEX(c,fd); + } + cp += es; + } + } else { + /* + * the code inside this loop reads nc bytes per iteration + */ + for (cc = 0; (cc + nc) <= tf_bytesperrow; cc += samplesperpixel) { + DOBREAK(breaklen, nc, fd); + switch (nc) { + case 4: c = *cp++; PUTHEX(c,fd); + case 3: c = *cp++; PUTHEX(c,fd); + case 2: c = *cp++; PUTHEX(c,fd); + case 1: c = *cp++; PUTHEX(c,fd); + } + cp += es; + } + } + } + _TIFFfree((char *) tf_buf); +} + +void +PSDataColorSeparate(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc) +{ + uint32 row; + int breaklen = MAXLINE; + tsize_t cc; + tsample_t s, maxs; + unsigned char *tf_buf; + unsigned char *cp, c; + + (void) w; + tf_buf = (unsigned char *) limitMalloc(tf_bytesperrow); + if (tf_buf == NULL) { + TIFFError(filename, "No space for scanline buffer"); + return; + } + maxs = (samplesperpixel > nc ? nc : samplesperpixel); + for (row = 0; row < h; row++) { + for (s = 0; s < maxs; s++) { + if (TIFFReadScanline(tif, tf_buf, row, s) < 0) + break; + for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { + DOBREAK(breaklen, 1, fd); + c = *cp++; + PUTHEX(c,fd); + } + } + } + _TIFFfree((char *) tf_buf); +} + +#define PUTRGBHEX(c,fd) \ + PUTHEX(rmap[c],fd); PUTHEX(gmap[c],fd); PUTHEX(bmap[c],fd) + +void +PSDataPalette(FILE* fd, TIFF* tif, uint32 w, uint32 h) +{ + uint16 *rmap, *gmap, *bmap; + uint32 row; + int breaklen = MAXLINE, nc; + tsize_t cc; + unsigned char *tf_buf; + unsigned char *cp, c; + + (void) w; + if (!TIFFGetField(tif, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) { + TIFFError(filename, "Palette image w/o \"Colormap\" tag"); + return; + } + switch (bitspersample) { + case 8: case 4: case 2: case 1: + break; + default: + TIFFError(filename, "Depth %d not supported", bitspersample); + return; + } + nc = 3 * (8 / bitspersample); + tf_buf = (unsigned char *) limitMalloc(tf_bytesperrow); + if (tf_buf == NULL) { + TIFFError(filename, "No space for scanline buffer"); + return; + } + if (checkcmap(tif, 1<= 0; i--) { + rmap[i] = CVT(rmap[i]); + gmap[i] = CVT(gmap[i]); + bmap[i] = CVT(bmap[i]); + } #undef CVT - } - for (row = 0; row < h; row++) - { - if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) - goto end_loop; - for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) - { - DOBREAK(breaklen, nc, fd); - switch (bitspersample) - { - case 8: - c = *cp++; - PUTRGBHEX(c, fd); - break; - case 4: - c = *cp++; - PUTRGBHEX(c & 0xf, fd); - c >>= 4; - PUTRGBHEX(c, fd); - break; - case 2: - c = *cp++; - PUTRGBHEX(c & 0x3, fd); - c >>= 2; - PUTRGBHEX(c & 0x3, fd); - c >>= 2; - PUTRGBHEX(c & 0x3, fd); - c >>= 2; - PUTRGBHEX(c, fd); - break; - case 1: - c = *cp++; - PUTRGBHEX(c & 0x1, fd); - c >>= 1; - PUTRGBHEX(c & 0x1, fd); - c >>= 1; - PUTRGBHEX(c & 0x1, fd); - c >>= 1; - PUTRGBHEX(c & 0x1, fd); - c >>= 1; - PUTRGBHEX(c & 0x1, fd); - c >>= 1; - PUTRGBHEX(c & 0x1, fd); - c >>= 1; - PUTRGBHEX(c & 0x1, fd); - c >>= 1; - PUTRGBHEX(c, fd); - break; - } - } - } -end_loop: - _TIFFfree((char *)tf_buf); + } + for (row = 0; row < h; row++) { + if (TIFFReadScanline(tif, tf_buf, row, 0) < 0) + break; + for (cp = tf_buf, cc = 0; cc < tf_bytesperrow; cc++) { + DOBREAK(breaklen, nc, fd); + switch (bitspersample) { + case 8: + c = *cp++; PUTRGBHEX(c, fd); + break; + case 4: + c = *cp++; PUTRGBHEX(c&0xf, fd); + c >>= 4; PUTRGBHEX(c, fd); + break; + case 2: + c = *cp++; PUTRGBHEX(c&0x3, fd); + c >>= 2; PUTRGBHEX(c&0x3, fd); + c >>= 2; PUTRGBHEX(c&0x3, fd); + c >>= 2; PUTRGBHEX(c, fd); + break; + case 1: + c = *cp++; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c&0x1, fd); + c >>= 1; PUTRGBHEX(c, fd); + break; + } + } + } + _TIFFfree((char *) tf_buf); } -void PSDataBW(FILE *fd, TIFF *tif, uint32_t w, uint32_t h) +void +PSDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) { - int breaklen = MAXLINE; - unsigned char *tf_buf; - unsigned char *cp; - tsize_t stripsize = TIFFStripSize(tif); - tstrip_t s; + int breaklen = MAXLINE; + unsigned char* tf_buf; + unsigned char* cp; + tsize_t stripsize = TIFFStripSize(tif); + tstrip_t s; -#if defined(EXP_ASCII85ENCODER) - tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ - uint8_t *ascii85_p = 0; /* Holds ASCII85 encoded data */ +#if defined( EXP_ASCII85ENCODER ) + tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ + uint8 *ascii85_p = 0; /* Holds ASCII85 encoded data */ #endif - (void)w; - (void)h; - tf_buf = (unsigned char *)limitMalloc(stripsize); - if (tf_buf == NULL) - { - TIFFError(filename, "No space for scanline buffer"); - return; - } + (void) w; (void) h; + tf_buf = (unsigned char *) limitMalloc(stripsize); + if (tf_buf == NULL) { + TIFFError(filename, "No space for scanline buffer"); + return; + } - // FIXME - memset(tf_buf, 0, stripsize); + // FIXME + memset(tf_buf, 0, stripsize); -#if defined(EXP_ASCII85ENCODER) - if (ascii85) - { - /* - * Allocate a buffer to hold the ASCII85 encoded data. Note - * that it is allocated with sufficient room to hold the - * encoded data (5*stripsize/4) plus the EOD marker (+8) - * and formatting line breaks. The line breaks are more - * than taken care of by using 6*stripsize/4 rather than - * 5*stripsize/4. - */ +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85 ) { + /* + * Allocate a buffer to hold the ASCII85 encoded data. Note + * that it is allocated with sufficient room to hold the + * encoded data (5*stripsize/4) plus the EOD marker (+8) + * and formatting line breaks. The line breaks are more + * than taken care of by using 6*stripsize/4 rather than + * 5*stripsize/4. + */ - ascii85_p = limitMalloc((stripsize + (stripsize / 2)) + 8); + ascii85_p = limitMalloc( (stripsize+(stripsize/2)) + 8 ); - if (!ascii85_p) - { - _TIFFfree(tf_buf); + if ( !ascii85_p ) { + _TIFFfree( tf_buf ); - TIFFError(filename, "Cannot allocate ASCII85 encoding buffer."); - return; - } - } + TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." ); + return; + } + } #endif - if (ascii85) - Ascii85Init(); + if (ascii85) + Ascii85Init(); - for (s = 0; s < TIFFNumberOfStrips(tif); s++) - { - tmsize_t cc = TIFFReadEncodedStrip(tif, s, tf_buf, stripsize); - if (cc < 0) - { - TIFFError(filename, "Can't read strip"); - break; - } - cp = tf_buf; - if (photometric == PHOTOMETRIC_MINISWHITE) - { - for (cp += cc; --cp >= tf_buf;) - *cp = ~*cp; - cp++; - } - /* - * for 16 bits, the two bytes must be most significant - * byte first - */ - if (bitspersample == 16 && !HOST_BIGENDIAN) - { - PS_FlipBytes(cp, cc); - } - if (ascii85) - { -#if defined(EXP_ASCII85ENCODER) - if (alpha) - { - int adjust, i; - for (i = 0; i < (cc - 1); i += 2) - { - adjust = 255 - cp[i + 1]; - cp[i / 2] = cp[i] + adjust; - } - cc /= 2; - } + for (s = 0; s < TIFFNumberOfStrips(tif); s++) { + tmsize_t cc = TIFFReadEncodedStrip(tif, s, tf_buf, stripsize); + if (cc < 0) { + TIFFError(filename, "Can't read strip"); + break; + } + cp = tf_buf; + if (photometric == PHOTOMETRIC_MINISWHITE) { + for (cp += cc; --cp >= tf_buf;) + *cp = ~*cp; + cp++; + } + /* + * for 16 bits, the two bytes must be most significant + * byte first + */ + if (bitspersample == 16 && !HOST_BIGENDIAN) { + PS_FlipBytes(cp, cc); + } + if (ascii85) { +#if defined( EXP_ASCII85ENCODER ) + if (alpha) { + int adjust, i; + for (i = 0; i < (cc - 1); i+=2) { + adjust = 255 - cp[i + 1]; + cp[i / 2] = cp[i] + adjust; + } + cc /= 2; + } - ascii85_l = Ascii85EncodeBlock(ascii85_p, 1, cp, cc); + ascii85_l = Ascii85EncodeBlock( ascii85_p, 1, cp, cc ); - if (ascii85_l > 0) - fwrite(ascii85_p, ascii85_l, 1, fd); + if ( ascii85_l > 0 ) + fwrite( ascii85_p, ascii85_l, 1, fd ); #else - while (cc-- > 0) - Ascii85Put(*cp++, fd); + while (cc-- > 0) + Ascii85Put(*cp++, fd); #endif /* EXP_ASCII85_ENCODER */ - } - else - { - unsigned char c; + } else { + unsigned char c; - if (alpha) - { - int adjust; - while (cc-- > 1) - { - DOBREAK(breaklen, 1, fd); - /* - * For images with alpha, matte against - * a white background; i.e. - * Cback * (1 - Aimage) - * where Cback = 1. - */ - adjust = 255 - cp[1]; - c = *cp++ + adjust; - puthex(c, fd); - cp++, cc--; - } - } - else - { - while (cc-- > 0) - { - c = *cp++; - DOBREAK(breaklen, 1, fd); - puthex(c, fd); - } - } - } - } + if (alpha) { + int adjust; + while (cc-- > 1) { + DOBREAK(breaklen, 1, fd); + /* + * For images with alpha, matte against + * a white background; i.e. + * Cback * (1 - Aimage) + * where Cback = 1. + */ + adjust = 255 - cp[1]; + c = *cp++ + adjust; PUTHEX(c,fd); + cp++, cc--; + } + } else { + while (cc-- > 0) { + c = *cp++; + DOBREAK(breaklen, 1, fd); + PUTHEX(c, fd); + } + } + } + } - if (!ascii85) - { - if (level2 || level3) - fputs(">\n", fd); - } -#if !defined(EXP_ASCII85ENCODER) - else - Ascii85Flush(fd); + if ( !ascii85 ) + { + if ( level2 || level3) + fputs(">\n", fd); + } +#if !defined( EXP_ASCII85ENCODER ) + else + Ascii85Flush(fd); #else - if (ascii85_p) - _TIFFfree(ascii85_p); + if ( ascii85_p ) + _TIFFfree( ascii85_p ); #endif - _TIFFfree(tf_buf); + _TIFFfree(tf_buf); } -void PSRawDataBW(FILE *fd, TIFF *tif, uint32_t w, uint32_t h) +void +PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h) { - uint64_t *bc; - uint32_t bufsize; - int breaklen = MAXLINE; - tmsize_t cc; - uint16_t fillorder; - unsigned char *tf_buf; - unsigned char *cp, c; - tstrip_t s; + uint64 *bc; + uint32 bufsize; + int breaklen = MAXLINE; + tmsize_t cc; + uint16 fillorder; + unsigned char *tf_buf; + unsigned char *cp, c; + tstrip_t s; -#if defined(EXP_ASCII85ENCODER) - tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ - uint8_t *ascii85_p = 0; /* Holds ASCII85 encoded data */ +#if defined( EXP_ASCII85ENCODER ) + tsize_t ascii85_l; /* Length, in bytes, of ascii85_p[] data */ + uint8 * ascii85_p = 0; /* Holds ASCII85 encoded data */ #endif - (void)w; - (void)h; - TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder); - TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); + (void) w; (void) h; + TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder); + TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc); - /* - * Find largest strip: - */ + /* + * Find largest strip: + */ - bufsize = (uint32_t)bc[0]; + bufsize = (uint32) bc[0]; - for (s = 0; ++s < tf_numberstrips;) - { - if (bc[s] > bufsize) - bufsize = (uint32_t)bc[s]; - } + for ( s = 0; ++s < tf_numberstrips; ) { + if ( bc[s] > bufsize ) + bufsize = (uint32) bc[s]; + } - tf_buf = (unsigned char *)limitMalloc(bufsize); - if (tf_buf == NULL) - { - TIFFError(filename, "No space for strip buffer"); - return; - } + tf_buf = (unsigned char*) limitMalloc(bufsize); + if (tf_buf == NULL) { + TIFFError(filename, "No space for strip buffer"); + return; + } -#if defined(EXP_ASCII85ENCODER) - if (ascii85) - { - /* - * Allocate a buffer to hold the ASCII85 encoded data. Note - * that it is allocated with sufficient room to hold the - * encoded data (5*bufsize/4) plus the EOD marker (+8) - * and formatting line breaks. The line breaks are more - * than taken care of by using 6*bufsize/4 rather than - * 5*bufsize/4. - */ +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85 ) { + /* + * Allocate a buffer to hold the ASCII85 encoded data. Note + * that it is allocated with sufficient room to hold the + * encoded data (5*bufsize/4) plus the EOD marker (+8) + * and formatting line breaks. The line breaks are more + * than taken care of by using 6*bufsize/4 rather than + * 5*bufsize/4. + */ - ascii85_p = limitMalloc((bufsize + (bufsize / 2)) + 8); + ascii85_p = limitMalloc( (bufsize+(bufsize/2)) + 8 ); - if (!ascii85_p) - { - _TIFFfree(tf_buf); + if ( !ascii85_p ) { + _TIFFfree( tf_buf ); - TIFFError(filename, "Cannot allocate ASCII85 encoding buffer."); - return; - } - } + TIFFError( filename, "Cannot allocate ASCII85 encoding buffer." ); + return; + } + } #endif - for (s = 0; s < tf_numberstrips; s++) - { - cc = TIFFReadRawStrip(tif, s, tf_buf, (tmsize_t)bc[s]); - if (cc < 0) - { - TIFFError(filename, "Can't read strip"); - break; - } - if (fillorder == FILLORDER_LSB2MSB) - TIFFReverseBits(tf_buf, cc); - if (!ascii85) - { - for (cp = tf_buf; cc > 0; cc--) - { - DOBREAK(breaklen, 1, fd); - c = *cp++; - puthex(c, fd); - } - fputs(">\n", fd); - breaklen = MAXLINE; - } - else - { - Ascii85Init(); -#if defined(EXP_ASCII85ENCODER) - ascii85_l = Ascii85EncodeBlock(ascii85_p, 1, tf_buf, cc); + for (s = 0; s < tf_numberstrips; s++) { + cc = TIFFReadRawStrip(tif, s, tf_buf, (tmsize_t) bc[s]); + if (cc < 0) { + TIFFError(filename, "Can't read strip"); + break; + } + if (fillorder == FILLORDER_LSB2MSB) + TIFFReverseBits(tf_buf, cc); + if (!ascii85) { + for (cp = tf_buf; cc > 0; cc--) { + DOBREAK(breaklen, 1, fd); + c = *cp++; + PUTHEX(c, fd); + } + fputs(">\n", fd); + breaklen = MAXLINE; + } else { + Ascii85Init(); +#if defined( EXP_ASCII85ENCODER ) + ascii85_l = Ascii85EncodeBlock( ascii85_p, 1, tf_buf, cc ); - if (ascii85_l > 0) - fwrite(ascii85_p, ascii85_l, 1, fd); + if ( ascii85_l > 0 ) + fwrite( ascii85_p, ascii85_l, 1, fd ); #else - for (cp = tf_buf; cc > 0; cc--) - Ascii85Put(*cp++, fd); - Ascii85Flush(fd); -#endif /* EXP_ASCII85ENCODER */ - } - } - _TIFFfree((char *)tf_buf); + for (cp = tf_buf; cc > 0; cc--) + Ascii85Put(*cp++, fd); + Ascii85Flush(fd); +#endif /* EXP_ASCII85ENCODER */ + } + } + _TIFFfree((char *) tf_buf); -#if defined(EXP_ASCII85ENCODER) - if (ascii85_p) - _TIFFfree(ascii85_p); +#if defined( EXP_ASCII85ENCODER ) + if ( ascii85_p ) + _TIFFfree( ascii85_p ); #endif } -void Ascii85Init(void) +void +Ascii85Init(void) { - ascii85breaklen = 2 * MAXLINE; - ascii85count = 0; + ascii85breaklen = 2*MAXLINE; + ascii85count = 0; } -static char *Ascii85Encode(unsigned char *raw) +static char* +Ascii85Encode(unsigned char* raw) { - static char encoded[6]; - uint32_t word; + static char encoded[6]; + uint32 word; - word = (((raw[0] << 8) + raw[1]) << 16) + (raw[2] << 8) + raw[3]; - if (word != 0L) - { - uint32_t q; - uint16_t w1; + word = (((raw[0]<<8)+raw[1])<<16) + (raw[2]<<8) + raw[3]; + if (word != 0L) { + uint32 q; + uint16 w1; - q = word / (85L * 85 * 85 * 85); /* actually only a byte */ - encoded[0] = (char)(q + '!'); + q = word / (85L*85*85*85); /* actually only a byte */ + encoded[0] = (char) (q + '!'); - word -= q * (85L * 85 * 85 * 85); - q = word / (85L * 85 * 85); - encoded[1] = (char)(q + '!'); + word -= q * (85L*85*85*85); q = word / (85L*85*85); + encoded[1] = (char) (q + '!'); - word -= q * (85L * 85 * 85); - q = word / (85 * 85); - encoded[2] = (char)(q + '!'); + word -= q * (85L*85*85); q = word / (85*85); + encoded[2] = (char) (q + '!'); - w1 = (uint16_t)(word - q * (85L * 85)); - encoded[3] = (char)((w1 / 85) + '!'); - encoded[4] = (char)((w1 % 85) + '!'); - encoded[5] = '\0'; - } - else - encoded[0] = 'z', encoded[1] = '\0'; - return (encoded); + w1 = (uint16) (word - q*(85L*85)); + encoded[3] = (char) ((w1 / 85) + '!'); + encoded[4] = (char) ((w1 % 85) + '!'); + encoded[5] = '\0'; + } else + encoded[0] = 'z', encoded[1] = '\0'; + return (encoded); } -void Ascii85Put(unsigned char code, FILE *fd) +void +Ascii85Put(unsigned char code, FILE* fd) { - ascii85buf[ascii85count++] = code; - if (ascii85count >= 4) - { - unsigned char *p; - int n; + ascii85buf[ascii85count++] = code; + if (ascii85count >= 4) { + unsigned char* p; + int n; - for (n = ascii85count, p = ascii85buf; n >= 4; n -= 4, p += 4) - { - char *cp; - for (cp = Ascii85Encode(p); *cp; cp++) - { - putc(*cp, fd); - if (--ascii85breaklen == 0) - { - putc('\n', fd); - ascii85breaklen = 2 * MAXLINE; - } - } - } - _TIFFmemcpy(ascii85buf, p, n); - ascii85count = n; - } + for (n = ascii85count, p = ascii85buf; n >= 4; n -= 4, p += 4) { + char* cp; + for (cp = Ascii85Encode(p); *cp; cp++) { + putc(*cp, fd); + if (--ascii85breaklen == 0) { + putc('\n', fd); + ascii85breaklen = 2*MAXLINE; + } + } + } + _TIFFmemcpy(ascii85buf, p, n); + ascii85count = n; + } } -void Ascii85Flush(FILE *fd) +void +Ascii85Flush(FILE* fd) { - if (ascii85count > 0) - { - char *res; - _TIFFmemset(&ascii85buf[ascii85count], 0, 3); - res = Ascii85Encode(ascii85buf); - fwrite(res[0] == 'z' ? "!!!!" : res, ascii85count + 1, 1, fd); - } - fputs("~>\n", fd); + if (ascii85count > 0) { + char* res; + _TIFFmemset(&ascii85buf[ascii85count], 0, 3); + res = Ascii85Encode(ascii85buf); + fwrite(res[0] == 'z' ? "!!!!" : res, ascii85count + 1, 1, fd); + } + fputs("~>\n", fd); } -#if defined(EXP_ASCII85ENCODER) - -#define A85BREAKCNTR ascii85breaklen -#define A85BREAKLEN (2 * MAXLINE) +#if defined( EXP_ASCII85ENCODER) + +#define A85BREAKCNTR ascii85breaklen +#define A85BREAKLEN (2*MAXLINE) /***************************************************************************** - * - * Name: Ascii85EncodeBlock( ascii85_p, f_eod, raw_p, raw_l ) - * - * Description: This routine will encode the raw data in the buffer described - * by raw_p and raw_l into ASCII85 format and store the encoding - * in the buffer given by ascii85_p. - * - * Parameters: ascii85_p - A buffer supplied by the caller which will - * contain the encoded ASCII85 data. - * f_eod - Flag: Nz means to end the encoded buffer with - * an End-Of-Data marker. - * raw_p - Pointer to the buffer of data to be encoded - * raw_l - Number of bytes in raw_p[] to be encoded - * - * Returns: (int) < 0 Error, see errno - * >= 0 Number of bytes written to ascii85_p[]. - * - * Notes: An external variable given by A85BREAKCNTR is used to - * determine when to insert newline characters into the - * encoded data. As each byte is placed into ascii85_p this - * external is decremented. If the variable is decrement to - * or past zero then a newline is inserted into ascii85_p - * and the A85BREAKCNTR is then reset to A85BREAKLEN. - * Note: for efficiency reasons the A85BREAKCNTR variable - * is not actually checked on *every* character - * placed into ascii85_p but often only for every - * 5 characters. - * - * THE CALLER IS RESPONSIBLE FOR ENSURING THAT ASCII85_P[] IS - * SUFFICIENTLY LARGE TO THE ENCODED DATA! - * You will need at least 5 * (raw_l/4) bytes plus space for - * newline characters and space for an EOD marker (if - * requested). A safe calculation is to use 6*(raw_l/4) + 8 - * to size ascii85_p. - * - *****************************************************************************/ +* +* Name: Ascii85EncodeBlock( ascii85_p, f_eod, raw_p, raw_l ) +* +* Description: This routine will encode the raw data in the buffer described +* by raw_p and raw_l into ASCII85 format and store the encoding +* in the buffer given by ascii85_p. +* +* Parameters: ascii85_p - A buffer supplied by the caller which will +* contain the encoded ASCII85 data. +* f_eod - Flag: Nz means to end the encoded buffer with +* an End-Of-Data marker. +* raw_p - Pointer to the buffer of data to be encoded +* raw_l - Number of bytes in raw_p[] to be encoded +* +* Returns: (int) < 0 Error, see errno +* >= 0 Number of bytes written to ascii85_p[]. +* +* Notes: An external variable given by A85BREAKCNTR is used to +* determine when to insert newline characters into the +* encoded data. As each byte is placed into ascii85_p this +* external is decremented. If the variable is decrement to +* or past zero then a newline is inserted into ascii85_p +* and the A85BREAKCNTR is then reset to A85BREAKLEN. +* Note: for efficiency reasons the A85BREAKCNTR variable +* is not actually checked on *every* character +* placed into ascii85_p but often only for every +* 5 characters. +* +* THE CALLER IS RESPONSIBLE FOR ENSURING THAT ASCII85_P[] IS +* SUFFICIENTLY LARGE TO THE ENCODED DATA! +* You will need at least 5 * (raw_l/4) bytes plus space for +* newline characters and space for an EOD marker (if +* requested). A safe calculation is to use 6*(raw_l/4) + 8 +* to size ascii85_p. +* +*****************************************************************************/ -tsize_t Ascii85EncodeBlock(uint8_t *ascii85_p, unsigned f_eod, - const uint8_t *raw_p, tsize_t raw_l) +tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw_p, tsize_t raw_l ) { - char ascii85[5]; /* Encoded 5 tuple */ - tsize_t ascii85_l; /* Number of bytes written to ascii85_p[] */ - int rc; /* Return code */ - uint32_t val32; /* Unencoded 4 tuple */ + char ascii85[5]; /* Encoded 5 tuple */ + tsize_t ascii85_l; /* Number of bytes written to ascii85_p[] */ + int rc; /* Return code */ + uint32 val32; /* Unencoded 4 tuple */ - ascii85_l = 0; /* Nothing written yet */ + ascii85_l = 0; /* Nothing written yet */ - if (raw_p) + if ( raw_p ) { - --raw_p; /* Prepare for pre-increment fetches */ + --raw_p; /* Prepare for pre-increment fetches */ - for (; raw_l > 3; raw_l -= 4) + for ( ; raw_l > 3; raw_l -= 4 ) { - val32 = (uint32_t) * (++raw_p) << 24; - val32 += (uint32_t) * (++raw_p) << 16; - val32 += (uint32_t) * (++raw_p) << 8; - val32 += (uint32_t) * (++raw_p); - - if (val32 == 0) /* Special case */ + val32 = (uint32)*(++raw_p) << 24; + val32 += (uint32)*(++raw_p) << 16; + val32 += (uint32)*(++raw_p) << 8; + val32 += (uint32)*(++raw_p); + + if ( val32 == 0 ) /* Special case */ { ascii85_p[ascii85_l] = 'z'; rc = 1; } - + else { - ascii85[4] = (char)((val32 % 85) + 33); + ascii85[4] = (char) ((val32 % 85) + 33); val32 /= 85; - - ascii85[3] = (char)((val32 % 85) + 33); + + ascii85[3] = (char) ((val32 % 85) + 33); val32 /= 85; - - ascii85[2] = (char)((val32 % 85) + 33); + + ascii85[2] = (char) ((val32 % 85) + 33); val32 /= 85; + + ascii85[1] = (char) ((val32 % 85) + 33); + ascii85[0] = (char) ((val32 / 85) + 33); - ascii85[1] = (char)((val32 % 85) + 33); - ascii85[0] = (char)((val32 / 85) + 33); - - _TIFFmemcpy(&ascii85_p[ascii85_l], ascii85, sizeof(ascii85)); + _TIFFmemcpy( &ascii85_p[ascii85_l], ascii85, sizeof(ascii85) ); rc = sizeof(ascii85); } - + ascii85_l += rc; - - if ((A85BREAKCNTR -= rc) <= 0) + + if ( (A85BREAKCNTR -= rc) <= 0 ) { ascii85_p[ascii85_l] = '\n'; ++ascii85_l; A85BREAKCNTR = A85BREAKLEN; } } - + /* * Output any straggler bytes: */ - - if (raw_l > 0) + + if ( raw_l > 0 ) { - tsize_t len; /* Output this many bytes */ - + tsize_t len; /* Output this many bytes */ + len = raw_l + 1; - val32 = (uint32_t) * ++raw_p << 24; /* Prime the pump */ - - if (--raw_l > 0) - val32 += *(++raw_p) << 16; - if (--raw_l > 0) - val32 += *(++raw_p) << 8; - + val32 = (uint32)*++raw_p << 24; /* Prime the pump */ + + if ( --raw_l > 0 ) val32 += *(++raw_p) << 16; + if ( --raw_l > 0 ) val32 += *(++raw_p) << 8; + val32 /= 85; - - ascii85[3] = (char)((val32 % 85) + 33); + + ascii85[3] = (char) ((val32 % 85) + 33); val32 /= 85; - - ascii85[2] = (char)((val32 % 85) + 33); + + ascii85[2] = (char) ((val32 % 85) + 33); val32 /= 85; - - ascii85[1] = (char)((val32 % 85) + 33); - ascii85[0] = (char)((val32 / 85) + 33); - - _TIFFmemcpy(&ascii85_p[ascii85_l], ascii85, len); + + ascii85[1] = (char) ((val32 % 85) + 33); + ascii85[0] = (char) ((val32 / 85) + 33); + + _TIFFmemcpy( &ascii85_p[ascii85_l], ascii85, len ); ascii85_l += len; } } @@ -3406,66 +3073,66 @@ tsize_t Ascii85EncodeBlock(uint8_t *ascii85_p, unsigned f_eod, * If requested add an ASCII85 End Of Data marker: */ - if (f_eod) + if ( f_eod ) { ascii85_p[ascii85_l++] = '~'; ascii85_p[ascii85_l++] = '>'; ascii85_p[ascii85_l++] = '\n'; } - return (ascii85_l); + return ( ascii85_l ); -} /* Ascii85EncodeBlock() */ +} /* Ascii85EncodeBlock() */ -#endif /* EXP_ASCII85ENCODER */ +#endif /* EXP_ASCII85ENCODER */ -static const char usage_info[] = - "Convert a TIFF image to PostScript\n\n" - "usage: tiff2ps [options] input.tif ...\n" - "where options are:\n" - " -1 generate PostScript Level 1 (default)\n" - " -2 generate PostScript Level 2\n" - " -3 generate PostScript Level 3\n" - " -8 disable use of ASCII85 encoding with PostScript Level 2/3\n" - " -a convert all directories in file (default is first), Not " - "EPS\n" - " -b # set the bottom margin to # inches\n" - " -c center image (-b and -l still add to this)\n" - " -C name set postscript document creator name\n" - " -d # set initial directory to # counting from zero\n" - " -D enable duplex printing (two pages per sheet of paper)\n" - " -e generate Encapsulated PostScript (EPS) (implies -z)\n" - " -h # set printed page height to # inches (no default)\n" - " -w # set printed page width to # inches (no default)\n" - " -H # split image if height is more than # inches\n" - " -W # split image if width is more than # inches\n" - " -L # overLap split images by # inches\n" - " -i # enable/disable (Nz/0) pixel interpolation (default: " - "enable)\n" - " -l # set the left margin to # inches\n" - " -m use \"imagemask\" operator instead of \"image\"\n" - " -M size set the memory allocation limit in MiB. 0 to disable " - "limit\n" - " -o # convert directory at file offset # bytes\n" - " -O file write PostScript to file instead of standard output\n" - " -p generate regular (non-encapsulated) PostScript\n" - " -P L or P set optional PageOrientation DSC comment to Landscape or " - "Portrait\n" - " -r # or auto rotate by 90, 180, 270 degrees or auto\n" - " -s generate PostScript for a single image\n" - " -t name set postscript document title. Otherwise the filename is " - "used\n" - " -T print pages for top edge binding\n" - " -x override resolution units as centimeters\n" - " -y override resolution units as inches\n" - " -z enable printing in the deadzone (only for PostScript Level " - "2/3)\n"; -static void usage(int code) +const char* stuff[] = { +"usage: tiff2ps [options] input.tif ...", +"where options are:", +" -1 generate PostScript Level 1 (default)", +" -2 generate PostScript Level 2", +" -3 generate PostScript Level 3", +" -8 disable use of ASCII85 encoding with PostScript Level 2/3", +" -a convert all directories in file (default is first), Not EPS", +" -b # set the bottom margin to # inches", +" -c center image (-b and -l still add to this)", +" -C name set postscript document creator name", +" -d # set initial directory to # counting from zero", +" -D enable duplex printing (two pages per sheet of paper)", +" -e generate Encapsulated PostScript (EPS) (implies -z)", +" -h # set printed page height to # inches (no default)", +" -w # set printed page width to # inches (no default)", +" -H # split image if height is more than # inches", +" -W # split image if width is more than # inches", +" -L # overLap split images by # inches", +" -i # enable/disable (Nz/0) pixel interpolation (default: enable)", +" -l # set the left margin to # inches", +" -m use \"imagemask\" operator instead of \"image\"", +" -M size set the memory allocation limit in MiB. 0 to disable limit", +" -o # convert directory at file offset # bytes", +" -O file write PostScript to file instead of standard output", +" -p generate regular (non-encapsulated) PostScript", +" -P L or P set optional PageOrientation DSC comment to Landscape or Portrait", +" -r # or auto rotate by 90, 180, 270 degrees or auto", +" -s generate PostScript for a single image", +" -t name set postscript document title. Otherwise the filename is used", +" -T print pages for top edge binding", +" -x override resolution units as centimeters", +" -y override resolution units as inches", +" -z enable printing in the deadzone (only for PostScript Level 2/3)", +NULL +}; + +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiff2rgba.c b/thirdparty/SDL2_image/external/libtiff/tools/tiff2rgba.c index 693fc814a..764395f61 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiff2rgba.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiff2rgba.c @@ -2,7 +2,7 @@ * Copyright (c) 1991-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of @@ -22,19 +22,22 @@ * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" #include -#include #include +#include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif -#include "tiffio.h" #include "tiffiop.h" +#include "tiffio.h" #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 @@ -43,165 +46,147 @@ #define EXIT_FAILURE 1 #endif -#define streq(a, b) (strcmp(a, b) == 0) -#define CopyField(tag, v) \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v) +#define streq(a,b) (strcmp(a,b) == 0) +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) #ifndef howmany -#define howmany(x, y) (((x) + ((y)-1)) / (y)) +#define howmany(x, y) (((x)+((y)-1))/(y)) #endif -#define roundup(x, y) (howmany(x, y) * ((uint32_t)(y))) +#define roundup(x, y) (howmany(x,y)*((uint32)(y))) -static uint16_t compression = COMPRESSION_PACKBITS; -static uint32_t rowsperstrip = (uint32_t)-1; -static int process_by_block = 0; /* default is whole image at once */ -static int no_alpha = 0; -static int bigtiff_output = 0; +uint16 compression = COMPRESSION_PACKBITS; +uint32 rowsperstrip = (uint32) -1; +int process_by_block = 0; /* default is whole image at once */ +int no_alpha = 0; +int bigtiff_output = 0; #define DEFAULT_MAX_MALLOC (256 * 1024 * 1024) /* malloc size limit (in bytes) * disabled when set to 0 */ static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC; -static int tiffcvt(TIFF *in, TIFF *out); + +static int tiffcvt(TIFF* in, TIFF* out); static void usage(int code); -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - TIFF *in, *out; - int c; + TIFF *in, *out; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char *optarg; #endif - while ((c = getopt(argc, argv, "c:r:t:bn8hM:")) != -1) - switch (c) - { - case 'M': - maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; - break; - case 'b': - process_by_block = 1; - break; + while ((c = getopt(argc, argv, "c:r:t:bn8hM:")) != -1) + switch (c) { + case 'M': + maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; + break; + case 'b': + process_by_block = 1; + break; - case 'c': - if (streq(optarg, "none")) - compression = COMPRESSION_NONE; - else if (streq(optarg, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (streq(optarg, "lzw")) - compression = COMPRESSION_LZW; - else if (streq(optarg, "jpeg")) - compression = COMPRESSION_JPEG; - else if (streq(optarg, "zip")) - compression = COMPRESSION_ADOBE_DEFLATE; - else - usage(EXIT_FAILURE); - break; + case 'c': + if (streq(optarg, "none")) + compression = COMPRESSION_NONE; + else if (streq(optarg, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (streq(optarg, "lzw")) + compression = COMPRESSION_LZW; + else if (streq(optarg, "jpeg")) + compression = COMPRESSION_JPEG; + else if (streq(optarg, "zip")) + compression = COMPRESSION_DEFLATE; + else + usage(EXIT_FAILURE); + break; - case 'r': - rowsperstrip = atoi(optarg); - break; + case 'r': + rowsperstrip = atoi(optarg); + break; - case 't': - rowsperstrip = atoi(optarg); - break; + case 't': + rowsperstrip = atoi(optarg); + break; - case 'n': - no_alpha = 1; - break; + case 'n': + no_alpha = 1; + break; - case '8': - bigtiff_output = 1; - break; + case '8': + bigtiff_output = 1; + break; - case 'h': - usage(EXIT_SUCCESS); - /*NOTREACHED*/ - break; - case '?': - usage(EXIT_FAILURE); - /*NOTREACHED*/ - break; - } + case 'h': + usage(EXIT_SUCCESS); + /*NOTREACHED*/ + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } - if (argc - optind < 2) - usage(EXIT_FAILURE); + if (argc - optind < 2) + usage(EXIT_FAILURE); - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - if (opts == NULL) - { - return EXIT_FAILURE; - } - TIFFOpenOptionsSetMaxSingleMemAlloc(opts, maxMalloc); - out = TIFFOpenExt(argv[argc - 1], bigtiff_output ? "w8" : "w", opts); - if (out == NULL) - { - TIFFOpenOptionsFree(opts); - return (EXIT_FAILURE); - } + out = TIFFOpen(argv[argc-1], bigtiff_output?"w8":"w"); + if (out == NULL) + return (EXIT_FAILURE); - for (; optind < argc - 1; optind++) - { - in = TIFFOpenExt(argv[optind], "r", opts); - if (in != NULL) - { - do - { - if (!tiffcvt(in, out) || !TIFFWriteDirectory(out)) - { - (void)TIFFClose(out); - (void)TIFFClose(in); - TIFFOpenOptionsFree(opts); - return (1); - } - } while (TIFFReadDirectory(in)); - (void)TIFFClose(in); - } - } - TIFFOpenOptionsFree(opts); - (void)TIFFClose(out); - return (EXIT_SUCCESS); + for (; optind < argc-1; optind++) { + in = TIFFOpen(argv[optind], "r"); + if (in != NULL) { + do { + if (!tiffcvt(in, out) || + !TIFFWriteDirectory(out)) { + (void) TIFFClose(out); + (void) TIFFClose(in); + return (1); + } + } while (TIFFReadDirectory(in)); + (void) TIFFClose(in); + } + } + (void) TIFFClose(out); + return (EXIT_SUCCESS); } -static int cvt_by_tile(TIFF *in, TIFF *out) +static int +cvt_by_tile( TIFF *in, TIFF *out ) { - uint32_t *raster; /* retrieve RGBA image */ - uint32_t width, height; /* image width & height */ - uint32_t tile_width, tile_height; - uint32_t row, col; - uint32_t *wrk_line; - int ok = 1; - uint32_t rastersize, wrk_linesize; + uint32* raster; /* retrieve RGBA image */ + uint32 width, height; /* image width & height */ + uint32 tile_width, tile_height; + uint32 row, col; + uint32 *wrk_line; + int ok = 1; + uint32 rastersize, wrk_linesize; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); - if (!TIFFGetField(in, TIFFTAG_TILEWIDTH, &tile_width) || - !TIFFGetField(in, TIFFTAG_TILELENGTH, &tile_height)) - { + if( !TIFFGetField(in, TIFFTAG_TILEWIDTH, &tile_width) + || !TIFFGetField(in, TIFFTAG_TILELENGTH, &tile_height) ) { TIFFError(TIFFFileName(in), "Source image not tiled"); return (0); } - - TIFFSetField(out, TIFFTAG_TILEWIDTH, tile_width); - TIFFSetField(out, TIFFTAG_TILELENGTH, tile_height); + + TIFFSetField(out, TIFFTAG_TILEWIDTH, tile_width ); + TIFFSetField(out, TIFFTAG_TILELENGTH, tile_height ); /* * Allocate tile buffer */ - rastersize = tile_width * tile_height * sizeof(uint32_t); - if (tile_width != (rastersize / tile_height) / sizeof(uint32_t)) + rastersize = tile_width * tile_height * sizeof (uint32); + if (tile_width != (rastersize / tile_height) / sizeof( uint32)) { - TIFFError(TIFFFileName(in), - "Integer overflow when calculating raster buffer"); - exit(EXIT_FAILURE); + TIFFError(TIFFFileName(in), "Integer overflow when calculating raster buffer"); + exit(EXIT_FAILURE); } - raster = (uint32_t *)_TIFFmalloc(rastersize); - if (raster == 0) - { + raster = (uint32*)_TIFFmalloc(rastersize); + if (raster == 0) { TIFFError(TIFFFileName(in), "No space for raster buffer"); return (0); } @@ -210,67 +195,66 @@ static int cvt_by_tile(TIFF *in, TIFF *out) * Allocate a scanline buffer for swapping during the vertical * mirroring pass. */ - wrk_linesize = tile_width * sizeof(uint32_t); - if (tile_width != wrk_linesize / sizeof(uint32_t)) + wrk_linesize = tile_width * sizeof (uint32); + if (tile_width != wrk_linesize / sizeof (uint32)) { - TIFFError(TIFFFileName(in), - "Integer overflow when calculating wrk_line buffer"); - exit(EXIT_FAILURE); + TIFFError(TIFFFileName(in), "Integer overflow when calculating wrk_line buffer"); + exit(EXIT_FAILURE); } - wrk_line = (uint32_t *)_TIFFmalloc(wrk_linesize); - if (!wrk_line) - { + wrk_line = (uint32*)_TIFFmalloc(wrk_linesize); + if (!wrk_line) { TIFFError(TIFFFileName(in), "No space for raster scanline buffer"); ok = 0; } - + /* * Loop over the tiles. */ - for (row = 0; ok && row < height; row += tile_height) + for( row = 0; ok && row < height; row += tile_height ) { - for (col = 0; ok && col < width; col += tile_width) + for( col = 0; ok && col < width; col += tile_width ) { - uint32_t i_row; + uint32 i_row; /* Read the tile into an RGBA array */ - if (!TIFFReadRGBATile(in, col, row, raster)) - { + if (!TIFFReadRGBATile(in, col, row, raster)) { ok = 0; break; } - /* - * XXX: raster array has 4-byte unsigned integer type, that is why - * we should rearrange it here. - */ + + /* + * XXX: raster array has 4-byte unsigned integer type, that is why + * we should rearrange it here. + */ #if HOST_BIGENDIAN - TIFFSwabArrayOfLong(raster, tile_width * tile_height); + TIFFSwabArrayOfLong(raster, tile_width * tile_height); #endif /* * For some reason the TIFFReadRGBATile() function chooses the * lower left corner as the origin. Vertically mirror scanlines. */ - for (i_row = 0; i_row < tile_height / 2; i_row++) + for( i_row = 0; i_row < tile_height / 2; i_row++ ) { - uint32_t *top_line, *bottom_line; + uint32 *top_line, *bottom_line; top_line = raster + tile_width * i_row; - bottom_line = raster + tile_width * (tile_height - i_row - 1); + bottom_line = raster + tile_width * (tile_height-i_row-1); - _TIFFmemcpy(wrk_line, top_line, 4 * tile_width); - _TIFFmemcpy(top_line, bottom_line, 4 * tile_width); - _TIFFmemcpy(bottom_line, wrk_line, 4 * tile_width); + _TIFFmemcpy(wrk_line, top_line, 4*tile_width); + _TIFFmemcpy(top_line, bottom_line, 4*tile_width); + _TIFFmemcpy(bottom_line, wrk_line, 4*tile_width); } /* * Write out the result in a tile. */ - if (TIFFWriteEncodedTile(out, TIFFComputeTile(out, col, row, 0, 0), - raster, - 4 * tile_width * tile_height) == -1) + if( TIFFWriteEncodedTile( out, + TIFFComputeTile( out, col, row, 0, 0), + raster, + 4 * tile_width * tile_height ) == -1 ) { ok = 0; break; @@ -278,46 +262,44 @@ static int cvt_by_tile(TIFF *in, TIFF *out) } } - _TIFFfree(raster); - _TIFFfree(wrk_line); + _TIFFfree( raster ); + _TIFFfree( wrk_line ); return ok; } -static int cvt_by_strip(TIFF *in, TIFF *out) +static int +cvt_by_strip( TIFF *in, TIFF *out ) { - uint32_t *raster; /* retrieve RGBA image */ - uint32_t width, height; /* image width & height */ - uint32_t row; - uint32_t *wrk_line; - int ok = 1; - uint32_t rastersize, wrk_linesize; + uint32* raster; /* retrieve RGBA image */ + uint32 width, height; /* image width & height */ + uint32 row; + uint32 *wrk_line; + int ok = 1; + uint32 rastersize, wrk_linesize; TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); - if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) - { + if( !TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip) ) { TIFFError(TIFFFileName(in), "Source image not in strips"); return (0); } - + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); /* * Allocate strip buffer */ - rastersize = width * rowsperstrip * sizeof(uint32_t); - if (width != (rastersize / rowsperstrip) / sizeof(uint32_t)) + rastersize = width * rowsperstrip * sizeof (uint32); + if (width != (rastersize / rowsperstrip) / sizeof( uint32)) { - TIFFError(TIFFFileName(in), - "Integer overflow when calculating raster buffer"); - exit(EXIT_FAILURE); + TIFFError(TIFFFileName(in), "Integer overflow when calculating raster buffer"); + exit(EXIT_FAILURE); } - raster = (uint32_t *)_TIFFmalloc(rastersize); - if (raster == 0) - { + raster = (uint32*)_TIFFmalloc(rastersize); + if (raster == 0) { TIFFError(TIFFFileName(in), "No space for raster buffer"); return (0); } @@ -326,46 +308,43 @@ static int cvt_by_strip(TIFF *in, TIFF *out) * Allocate a scanline buffer for swapping during the vertical * mirroring pass. */ - wrk_linesize = width * sizeof(uint32_t); - if (width != wrk_linesize / sizeof(uint32_t)) + wrk_linesize = width * sizeof (uint32); + if (width != wrk_linesize / sizeof (uint32)) { - TIFFError(TIFFFileName(in), - "Integer overflow when calculating wrk_line buffer"); - exit(EXIT_FAILURE); + TIFFError(TIFFFileName(in), "Integer overflow when calculating wrk_line buffer"); + exit(EXIT_FAILURE); } - wrk_line = (uint32_t *)_TIFFmalloc(wrk_linesize); - if (!wrk_line) - { + wrk_line = (uint32*)_TIFFmalloc(wrk_linesize); + if (!wrk_line) { TIFFError(TIFFFileName(in), "No space for raster scanline buffer"); ok = 0; } - + /* * Loop over the strips. */ - for (row = 0; ok && row < height; row += rowsperstrip) + for( row = 0; ok && row < height; row += rowsperstrip ) { - int rows_to_write, i_row; + int rows_to_write, i_row; /* Read the strip into an RGBA array */ - if (!TIFFReadRGBAStrip(in, row, raster)) - { + if (!TIFFReadRGBAStrip(in, row, raster)) { ok = 0; break; } - /* - * XXX: raster array has 4-byte unsigned integer type, that is why - * we should rearrange it here. - */ + /* + * XXX: raster array has 4-byte unsigned integer type, that is why + * we should rearrange it here. + */ #if HOST_BIGENDIAN - TIFFSwabArrayOfLong(raster, width * rowsperstrip); + TIFFSwabArrayOfLong(raster, width * rowsperstrip); #endif /* * Figure out the number of scanlines actually in this strip. */ - if (row + rowsperstrip > height) + if( row + rowsperstrip > height ) rows_to_write = height - row; else rows_to_write = rowsperstrip; @@ -375,32 +354,32 @@ static int cvt_by_strip(TIFF *in, TIFF *out) * lower left corner as the origin. Vertically mirror scanlines. */ - for (i_row = 0; i_row < rows_to_write / 2; i_row++) + for( i_row = 0; i_row < rows_to_write / 2; i_row++ ) { - uint32_t *top_line, *bottom_line; + uint32 *top_line, *bottom_line; top_line = raster + width * i_row; - bottom_line = raster + width * (rows_to_write - i_row - 1); + bottom_line = raster + width * (rows_to_write-i_row-1); - _TIFFmemcpy(wrk_line, top_line, 4 * width); - _TIFFmemcpy(top_line, bottom_line, 4 * width); - _TIFFmemcpy(bottom_line, wrk_line, 4 * width); + _TIFFmemcpy(wrk_line, top_line, 4*width); + _TIFFmemcpy(top_line, bottom_line, 4*width); + _TIFFmemcpy(bottom_line, wrk_line, 4*width); } /* * Write out the result in a strip */ - if (TIFFWriteEncodedStrip(out, row / rowsperstrip, raster, - 4 * rows_to_write * width) == -1) + if( TIFFWriteEncodedStrip( out, row / rowsperstrip, raster, + 4 * rows_to_write * width ) == -1 ) { ok = 0; break; } } - _TIFFfree(raster); - _TIFFfree(wrk_line); + _TIFFfree( raster ); + _TIFFfree( wrk_line ); return ok; } @@ -413,56 +392,46 @@ static int cvt_by_strip(TIFF *in, TIFF *out) * API that we trust. */ -static int cvt_whole_image(TIFF *in, TIFF *out) +static int +cvt_whole_image( TIFF *in, TIFF *out ) { - uint32_t *raster; /* retrieve RGBA image */ - uint32_t width, height; /* image width & height */ - uint32_t row; + uint32* raster; /* retrieve RGBA image */ + uint32 width, height; /* image width & height */ + uint32 row; size_t pixel_count; - + TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); pixel_count = width * height; /* XXX: Check the integer overflow. */ - if (!width || !height || pixel_count / width != height) - { - TIFFError( - TIFFFileName(in), - "Malformed input file; can't allocate buffer for raster of %" PRIu32 - "x%" PRIu32 " size", - width, height); + if (!width || !height || pixel_count / width != height) { + TIFFError(TIFFFileName(in), + "Malformed input file; can't allocate buffer for raster of %lux%lu size", + (unsigned long)width, (unsigned long)height); return 0; } - if (maxMalloc != 0 && - (tmsize_t)pixel_count * (tmsize_t)sizeof(uint32_t) > maxMalloc) - { - TIFFError(TIFFFileName(in), - "Raster size %" TIFF_SIZE_FORMAT - " over memory limit (%" TIFF_SSIZE_FORMAT "), try -b option.", - pixel_count * sizeof(uint32_t), maxMalloc); + if (maxMalloc != 0 && (tmsize_t)pixel_count * (tmsize_t)sizeof(uint32) > maxMalloc) { + TIFFError(TIFFFileName(in), + "Raster size " TIFF_UINT64_FORMAT " over memory limit (" TIFF_UINT64_FORMAT "), try -b option.", + (uint64)pixel_count * sizeof(uint32), (uint64)maxMalloc); return 0; } rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - raster = (uint32_t *)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32_t), - "raster buffer"); - if (raster == 0) - { - TIFFError(TIFFFileName(in), - "Failed to allocate buffer (%" TIFF_SIZE_FORMAT - " elements of %" TIFF_SIZE_FORMAT " each)", - pixel_count, sizeof(uint32_t)); + raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32), "raster buffer"); + if (raster == 0) { + TIFFError(TIFFFileName(in), "Failed to allocate buffer (%lu elements of %lu each)", + (unsigned long)pixel_count, (unsigned long)sizeof(uint32)); return (0); } /* Read the image in one chunk into an RGBA array */ if (!TIFFReadRGBAImageOriented(in, width, height, raster, - ORIENTATION_TOPLEFT, 0)) - { + ORIENTATION_TOPLEFT, 0)) { _TIFFfree(raster); return (0); } @@ -483,14 +452,14 @@ static int cvt_whole_image(TIFF *in, TIFF *out) size_t count = pixel_count; unsigned char *src, *dst; - src = dst = (unsigned char *)raster; + src = dst = (unsigned char *) raster; while (count > 0) { - *(dst++) = *(src++); - *(dst++) = *(src++); - *(dst++) = *(src++); - src++; - count--; + *(dst++) = *(src++); + *(dst++) = *(src++); + *(dst++) = *(src++); + src++; + count--; } } @@ -499,134 +468,130 @@ static int cvt_whole_image(TIFF *in, TIFF *out) */ for (row = 0; row < height; row += rowsperstrip) { - unsigned char *raster_strip; - int rows_to_write; - int bytes_per_pixel; + unsigned char * raster_strip; + int rows_to_write; + int bytes_per_pixel; if (no_alpha) { - raster_strip = ((unsigned char *)raster) + 3 * row * width; + raster_strip = ((unsigned char *) raster) + 3 * row * width; bytes_per_pixel = 3; } else { - raster_strip = (unsigned char *)(raster + row * width); + raster_strip = (unsigned char *) (raster + row * width); bytes_per_pixel = 4; } - if (row + rowsperstrip > height) + if( row + rowsperstrip > height ) rows_to_write = height - row; else rows_to_write = rowsperstrip; - if (TIFFWriteEncodedStrip(out, row / rowsperstrip, raster_strip, - bytes_per_pixel * rows_to_write * width) == - -1) + if( TIFFWriteEncodedStrip( out, row / rowsperstrip, raster_strip, + bytes_per_pixel * rows_to_write * width ) == -1 ) { - _TIFFfree(raster); + _TIFFfree( raster ); return 0; } } - _TIFFfree(raster); + _TIFFfree( raster ); return 1; } -static int tiffcvt(TIFF *in, TIFF *out) + +static int +tiffcvt(TIFF* in, TIFF* out) { - uint32_t width, height; /* image width & height */ - uint16_t shortv; - float floatv; - char *stringv; - uint32_t longv; - uint16_t v[1]; + uint32 width, height; /* image width & height */ + uint16 shortv; + float floatv; + char *stringv; + uint32 longv; + uint16 v[1]; - TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); - TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); + TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); + TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); - CopyField(TIFFTAG_SUBFILETYPE, longv); - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, height); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + CopyField(TIFFTAG_SUBFILETYPE, longv); + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, height); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 8); + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); - CopyField(TIFFTAG_FILLORDER, shortv); - TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); + CopyField(TIFFTAG_FILLORDER, shortv); + TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); - if (no_alpha) - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3); - else - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 4); + if( no_alpha ) + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 3); + else + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 4); - if (!no_alpha) - { - v[0] = EXTRASAMPLE_ASSOCALPHA; - TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, v); - } + if( !no_alpha ) + { + v[0] = EXTRASAMPLE_ASSOCALPHA; + TIFFSetField(out, TIFFTAG_EXTRASAMPLES, 1, v); + } - CopyField(TIFFTAG_XRESOLUTION, floatv); - CopyField(TIFFTAG_YRESOLUTION, floatv); - CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(out, TIFFTAG_SOFTWARE, TIFFGetVersion()); - CopyField(TIFFTAG_DOCUMENTNAME, stringv); + CopyField(TIFFTAG_XRESOLUTION, floatv); + CopyField(TIFFTAG_YRESOLUTION, floatv); + CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(out, TIFFTAG_SOFTWARE, TIFFGetVersion()); + CopyField(TIFFTAG_DOCUMENTNAME, stringv); - if (maxMalloc != 0 && TIFFStripSize(in) > maxMalloc) - { - TIFFError(TIFFFileName(in), - "Strip Size %" TIFF_SSIZE_FORMAT - " over memory limit (%" TIFF_SSIZE_FORMAT ")", - TIFFStripSize(in), maxMalloc); - return 0; - } - if (process_by_block && TIFFIsTiled(in)) - return (cvt_by_tile(in, out)); - else if (process_by_block) - return (cvt_by_strip(in, out)); - else - return (cvt_whole_image(in, out)); + if (maxMalloc != 0 && TIFFStripSize(in) > maxMalloc) + { + TIFFError(TIFFFileName(in), + "Strip Size " TIFF_UINT64_FORMAT " over memory limit (" TIFF_UINT64_FORMAT ")", + (uint64)TIFFStripSize(in), (uint64)maxMalloc); + return 0; + } + if( process_by_block && TIFFIsTiled( in ) ) + return( cvt_by_tile( in, out ) ); + else if( process_by_block ) + return( cvt_by_strip( in, out ) ); + else + return( cvt_whole_image( in, out ) ); } -static const char usage_info[] = - /* Help information format modified for the sake of consistency with the - other tiff tools */ - /* "usage: tiff2rgba [-c comp] [-r rows] [-b] [-n] [-8] [-M size] - input... output" */ - /* "where comp is one of the following compression algorithms:" */ - "Convert a TIFF image to RGBA color space\n\n" - "usage: tiff2rgba [options] input output\n" - "where options are:\n" -#ifdef JPEG_SUPPORT - " -c jpeg JPEG encoding\n" -#endif -#ifdef ZIP_SUPPORT - " -c zip Zip/Deflate encoding\n" -#endif -#ifdef LZW_SUPPORT - " -c lzw Lempel-Ziv & Welch encoding\n" -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits PackBits encoding\n" -#endif -#if defined(JPEG_SUPPORT) || defined(ZIP_SUPPORT) || defined(LZW_SUPPORT) || \ - defined(PACKBITS_SUPPORT) - " -c none no compression\n" -#endif - "\n" - /* "and the other options are:\n" */ - " -r rows/strip\n" - " -b (progress by block rather than as a whole image)\n" - " -n don't emit alpha component.\n" - " -8 write BigTIFF file instead of ClassicTIFF\n" - " -M set the memory allocation limit in MiB. 0 to disable limit\n"; +static const char* stuff[] = { + "usage: tiff2rgba [-c comp] [-r rows] [-b] [-n] [-8] [-M size] input... output", + "where comp is one of the following compression algorithms:", + " jpeg\t\tJPEG encoding", + " zip\t\tZip/Deflate encoding", + " lzw\t\tLempel-Ziv & Welch encoding", + " packbits\tPackBits encoding", + " none\t\tno compression", + "and the other options are:", + " -r\trows/strip", + " -b (progress by block rather than as a whole image)", + " -n don't emit alpha component.", + " -8 write BigTIFF file instead of ClassicTIFF", + " -M set the memory allocation limit in MiB. 0 to disable limit", + NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffcmp.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffcmp.c index 529c1cdc7..041d6a2da 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffcmp.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffcmp.c @@ -2,36 +2,39 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" -#include #include #include #include +#include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffio.h" @@ -43,25 +46,27 @@ #define EXIT_FAILURE 1 #endif -static int stopondiff = 1; -static int stoponfirsttag = 1; -static uint16_t bitspersample = 1; -static uint16_t samplesperpixel = 1; -static uint16_t sampleformat = SAMPLEFORMAT_UINT; -static uint32_t imagewidth; -static uint32_t imagelength; +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); +#endif -static void usage(int code); -static int tiffcmp(TIFF *, TIFF *); -static int cmptags(TIFF *, TIFF *); -static int ContigCompare(int, uint32_t, unsigned char *, unsigned char *, - tsize_t); -static int SeparateCompare(int, int, uint32_t, unsigned char *, - unsigned char *); -static void PrintIntDiff(uint32_t, int, uint32_t, uint32_t, uint32_t); -static void PrintFloatDiff(uint32_t, int, uint32_t, double, double); +static int stopondiff = 1; +static int stoponfirsttag = 1; +static uint16 bitspersample = 1; +static uint16 samplesperpixel = 1; +static uint16 sampleformat = SAMPLEFORMAT_UINT; +static uint32 imagewidth; +static uint32 imagelength; -static void leof(const char *, uint32_t, int); +static void usage(int code); +static int tiffcmp(TIFF*, TIFF*); +static int cmptags(TIFF*, TIFF*); +static int ContigCompare(int, uint32, unsigned char*, unsigned char*, tsize_t); +static int SeparateCompare(int, int, uint32, unsigned char*, unsigned char*); +static void PrintIntDiff(uint32, int, uint32, uint32, uint32); +static void PrintFloatDiff(uint32, int, uint32, double, double); + +static void leof(const char*, uint32, int); /* * exit with status : @@ -69,642 +74,599 @@ static void leof(const char *, uint32_t, int); * 1 Differences were found. * >1 An error occurred. */ -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - TIFF *tif1, *tif2; - int c, dirnum; + TIFF *tif1, *tif2; + int c, dirnum; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - while ((c = getopt(argc, argv, "ltz:h")) != -1) - switch (c) - { - case 'l': - stopondiff = 0; - break; - case 'z': - stopondiff = atoi(optarg); - break; - case 't': - stoponfirsttag = 0; - break; - case 'h': - usage(EXIT_SUCCESS); - break; - case '?': - usage(2); - /*NOTREACHED*/ - break; - } - if (argc - optind < 2) - usage(2); - tif1 = TIFFOpen(argv[optind], "r"); - if (tif1 == NULL) - return (2); - tif2 = TIFFOpen(argv[optind + 1], "r"); - if (tif2 == NULL) - return (2); - dirnum = 0; - while (tiffcmp(tif1, tif2)) - { - if (!TIFFReadDirectory(tif1)) - { - if (!TIFFReadDirectory(tif2)) - break; - printf("No more directories for %s\n", TIFFFileName(tif1)); - return (1); - } - else if (!TIFFReadDirectory(tif2)) - { - printf("No more directories for %s\n", TIFFFileName(tif2)); - return (1); - } - printf("Directory %d:\n", ++dirnum); - } + while ((c = getopt(argc, argv, "ltz:h")) != -1) + switch (c) { + case 'l': + stopondiff = 0; + break; + case 'z': + stopondiff = atoi(optarg); + break; + case 't': + stoponfirsttag = 0; + break; + case 'h': + usage(EXIT_SUCCESS); + case '?': + usage(2); + /*NOTREACHED*/ + } + if (argc - optind < 2) + usage(2); + tif1 = TIFFOpen(argv[optind], "r"); + if (tif1 == NULL) + return (2); + tif2 = TIFFOpen(argv[optind+1], "r"); + if (tif2 == NULL) + return (2); + dirnum = 0; + while (tiffcmp(tif1, tif2)) { + if (!TIFFReadDirectory(tif1)) { + if (!TIFFReadDirectory(tif2)) + break; + printf("No more directories for %s\n", + TIFFFileName(tif1)); + return (1); + } else if (!TIFFReadDirectory(tif2)) { + printf("No more directories for %s\n", + TIFFFileName(tif2)); + return (1); + } + printf("Directory %d:\n", ++dirnum); + } - TIFFClose(tif1); - TIFFClose(tif2); - return (0); + TIFFClose(tif1); + TIFFClose(tif2); + return (0); } -static const char usage_info[] = - "Compare the tags and data in two TIFF files\n\n" - "usage: tiffcmp [options] file1 file2\n" - "where options are:\n" - " -l list each byte of image data that differs between the " - "files\n" - " -z # list specified number of bytes that differs between " - "the files\n" - " -t ignore any differences in directory tags\n"; +static const char* stuff[] = { +"usage: tiffcmp [options] file1 file2", +"where options are:", +" -l list each byte of image data that differs between the files", +" -z # list specified number of bytes that differs between the files", +" -t ignore any differences in directory tags", +NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } -#define checkEOF(tif, row, sample) \ - { \ - leof(TIFFFileName(tif), row, sample); \ - goto bad; \ - } +#define checkEOF(tif, row, sample) { \ + leof(TIFFFileName(tif), row, sample); \ + goto bad; \ +} -static int CheckShortTag(TIFF *, TIFF *, int, char *); -static int CheckShort2Tag(TIFF *, TIFF *, int, char *); -static int CheckShortArrayTag(TIFF *, TIFF *, int, char *); -static int CheckLongTag(TIFF *, TIFF *, int, char *); -static int CheckFloatTag(TIFF *, TIFF *, int, char *); -static int CheckStringTag(TIFF *, TIFF *, int, char *); +static int CheckShortTag(TIFF*, TIFF*, int, char*); +static int CheckShort2Tag(TIFF*, TIFF*, int, char*); +static int CheckShortArrayTag(TIFF*, TIFF*, int, char*); +static int CheckLongTag(TIFF*, TIFF*, int, char*); +static int CheckFloatTag(TIFF*, TIFF*, int, char*); +static int CheckStringTag(TIFF*, TIFF*, int, char*); -static int tiffcmp(TIFF *tif1, TIFF *tif2) +static int +tiffcmp(TIFF* tif1, TIFF* tif2) { - uint16_t config1, config2; - tsize_t size1; - uint32_t row; - tsample_t s; - unsigned char *buf1, *buf2; + uint16 config1, config2; + tsize_t size1; + uint32 row; + tsample_t s; + unsigned char *buf1, *buf2; - if (!CheckShortTag(tif1, tif2, TIFFTAG_BITSPERSAMPLE, "BitsPerSample")) - return (0); - if (!CheckShortTag(tif1, tif2, TIFFTAG_SAMPLESPERPIXEL, "SamplesPerPixel")) - return (0); - if (!CheckLongTag(tif1, tif2, TIFFTAG_IMAGEWIDTH, "ImageWidth")) - return (0); - if (!cmptags(tif1, tif2)) - return (1); - (void)TIFFGetField(tif1, TIFFTAG_BITSPERSAMPLE, &bitspersample); - (void)TIFFGetField(tif1, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); - (void)TIFFGetField(tif1, TIFFTAG_SAMPLEFORMAT, &sampleformat); - (void)TIFFGetField(tif1, TIFFTAG_IMAGEWIDTH, &imagewidth); - (void)TIFFGetField(tif1, TIFFTAG_IMAGELENGTH, &imagelength); - (void)TIFFGetField(tif1, TIFFTAG_PLANARCONFIG, &config1); - (void)TIFFGetField(tif2, TIFFTAG_PLANARCONFIG, &config2); - buf1 = (unsigned char *)_TIFFmalloc(size1 = TIFFScanlineSize(tif1)); - buf2 = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif2)); - if (buf1 == NULL || buf2 == NULL) - { - fprintf(stderr, "No space for scanline buffers\n"); - exit(2); - } - if (config1 != config2 && bitspersample != 8 && samplesperpixel > 1) - { - fprintf(stderr, "Can't handle different planar configuration w/ " - "different bits/sample\n"); - goto bad; - } -#define pack(a, b) ((a) << 8) | (b) - switch (pack(config1, config2)) - { - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG): - for (row = 0; row < imagelength; row++) - { - if (TIFFReadScanline(tif2, buf2, row, 0) < 0) - checkEOF(tif2, row, -1) for (s = 0; s < samplesperpixel; - s++) - { - if (TIFFReadScanline(tif1, buf1, row, s) < 0) - checkEOF(tif1, row, s) if (SeparateCompare( - 1, s, row, buf2, - buf1) < 0) goto bad1; - } - } - break; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE): - for (row = 0; row < imagelength; row++) - { - if (TIFFReadScanline(tif1, buf1, row, 0) < 0) - checkEOF(tif1, row, -1) for (s = 0; s < samplesperpixel; - s++) - { - if (TIFFReadScanline(tif2, buf2, row, s) < 0) - checkEOF(tif2, row, s) if (SeparateCompare( - 0, s, row, buf1, - buf2) < 0) goto bad1; - } - } - break; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE): - for (s = 0; s < samplesperpixel; s++) - for (row = 0; row < imagelength; row++) - { - if (TIFFReadScanline(tif1, buf1, row, s) < 0) - checkEOF(tif1, row, s) if (TIFFReadScanline(tif2, buf2, - row, s) < 0) - checkEOF(tif2, row, - s) if (ContigCompare(s, row, buf1, buf2, - size1) < 0) goto bad1; - } - break; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG): - for (row = 0; row < imagelength; row++) - { - if (TIFFReadScanline(tif1, buf1, row, 0) < 0) - checkEOF(tif1, row, - -1) if (TIFFReadScanline(tif2, buf2, row, 0) < 0) - checkEOF(tif2, row, - -1) if (ContigCompare(-1, row, buf1, buf2, - size1) < 0) goto bad1; - } - break; - } - if (buf1) - _TIFFfree(buf1); - if (buf2) - _TIFFfree(buf2); - return (1); + if (!CheckShortTag(tif1, tif2, TIFFTAG_BITSPERSAMPLE, "BitsPerSample")) + return (0); + if (!CheckShortTag(tif1, tif2, TIFFTAG_SAMPLESPERPIXEL, "SamplesPerPixel")) + return (0); + if (!CheckLongTag(tif1, tif2, TIFFTAG_IMAGEWIDTH, "ImageWidth")) + return (0); + if (!cmptags(tif1, tif2)) + return (1); + (void) TIFFGetField(tif1, TIFFTAG_BITSPERSAMPLE, &bitspersample); + (void) TIFFGetField(tif1, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + (void) TIFFGetField(tif1, TIFFTAG_SAMPLEFORMAT, &sampleformat); + (void) TIFFGetField(tif1, TIFFTAG_IMAGEWIDTH, &imagewidth); + (void) TIFFGetField(tif1, TIFFTAG_IMAGELENGTH, &imagelength); + (void) TIFFGetField(tif1, TIFFTAG_PLANARCONFIG, &config1); + (void) TIFFGetField(tif2, TIFFTAG_PLANARCONFIG, &config2); + buf1 = (unsigned char *)_TIFFmalloc(size1 = TIFFScanlineSize(tif1)); + buf2 = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(tif2)); + if (buf1 == NULL || buf2 == NULL) { + fprintf(stderr, "No space for scanline buffers\n"); + exit(2); + } + if (config1 != config2 && bitspersample != 8 && samplesperpixel > 1) { + fprintf(stderr, +"Can't handle different planar configuration w/ different bits/sample\n"); + goto bad; + } +#define pack(a,b) ((a)<<8)|(b) + switch (pack(config1, config2)) { + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG): + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(tif2, buf2, row, 0) < 0) + checkEOF(tif2, row, -1) + for (s = 0; s < samplesperpixel; s++) { + if (TIFFReadScanline(tif1, buf1, row, s) < 0) + checkEOF(tif1, row, s) + if (SeparateCompare(1, s, row, buf2, buf1) < 0) + goto bad1; + } + } + break; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE): + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(tif1, buf1, row, 0) < 0) + checkEOF(tif1, row, -1) + for (s = 0; s < samplesperpixel; s++) { + if (TIFFReadScanline(tif2, buf2, row, s) < 0) + checkEOF(tif2, row, s) + if (SeparateCompare(0, s, row, buf1, buf2) < 0) + goto bad1; + } + } + break; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE): + for (s = 0; s < samplesperpixel; s++) + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(tif1, buf1, row, s) < 0) + checkEOF(tif1, row, s) + if (TIFFReadScanline(tif2, buf2, row, s) < 0) + checkEOF(tif2, row, s) + if (ContigCompare(s, row, buf1, buf2, size1) < 0) + goto bad1; + } + break; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG): + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(tif1, buf1, row, 0) < 0) + checkEOF(tif1, row, -1) + if (TIFFReadScanline(tif2, buf2, row, 0) < 0) + checkEOF(tif2, row, -1) + if (ContigCompare(-1, row, buf1, buf2, size1) < 0) + goto bad1; + } + break; + } + if (buf1) _TIFFfree(buf1); + if (buf2) _TIFFfree(buf2); + return (1); bad: - if (stopondiff) - exit(1); + if (stopondiff) + exit(1); bad1: - if (buf1) - _TIFFfree(buf1); - if (buf2) - _TIFFfree(buf2); - return (0); + if (buf1) _TIFFfree(buf1); + if (buf2) _TIFFfree(buf2); + return (0); } -#define CmpShortField(tag, name) \ - if (!CheckShortTag(tif1, tif2, tag, name) && stoponfirsttag) \ - return (0) -#define CmpShortField2(tag, name) \ - if (!CheckShort2Tag(tif1, tif2, tag, name) && stoponfirsttag) \ - return (0) -#define CmpLongField(tag, name) \ - if (!CheckLongTag(tif1, tif2, tag, name) && stoponfirsttag) \ - return (0) -#define CmpFloatField(tag, name) \ - if (!CheckFloatTag(tif1, tif2, tag, name) && stoponfirsttag) \ - return (0) -#define CmpStringField(tag, name) \ - if (!CheckStringTag(tif1, tif2, tag, name) && stoponfirsttag) \ - return (0) -#define CmpShortArrayField(tag, name) \ - if (!CheckShortArrayTag(tif1, tif2, tag, name) && stoponfirsttag) \ - return (0) +#define CmpShortField(tag, name) \ + if (!CheckShortTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) +#define CmpShortField2(tag, name) \ + if (!CheckShort2Tag(tif1, tif2, tag, name) && stoponfirsttag) return (0) +#define CmpLongField(tag, name) \ + if (!CheckLongTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) +#define CmpFloatField(tag, name) \ + if (!CheckFloatTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) +#define CmpStringField(tag, name) \ + if (!CheckStringTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) +#define CmpShortArrayField(tag, name) \ + if (!CheckShortArrayTag(tif1, tif2, tag, name) && stoponfirsttag) return (0) -static int cmptags(TIFF *tif1, TIFF *tif2) +static int +cmptags(TIFF* tif1, TIFF* tif2) { - uint16_t compression1, compression2; - CmpLongField(TIFFTAG_SUBFILETYPE, "SubFileType"); - CmpLongField(TIFFTAG_IMAGEWIDTH, "ImageWidth"); - CmpLongField(TIFFTAG_IMAGELENGTH, "ImageLength"); - CmpShortField(TIFFTAG_BITSPERSAMPLE, "BitsPerSample"); - CmpShortField(TIFFTAG_COMPRESSION, "Compression"); - CmpShortField(TIFFTAG_PREDICTOR, "Predictor"); - CmpShortField(TIFFTAG_PHOTOMETRIC, "PhotometricInterpretation"); - CmpShortField(TIFFTAG_THRESHHOLDING, "Thresholding"); - CmpShortField(TIFFTAG_FILLORDER, "FillOrder"); - CmpShortField(TIFFTAG_ORIENTATION, "Orientation"); - CmpShortField(TIFFTAG_SAMPLESPERPIXEL, "SamplesPerPixel"); - CmpShortField(TIFFTAG_MINSAMPLEVALUE, "MinSampleValue"); - CmpShortField(TIFFTAG_MAXSAMPLEVALUE, "MaxSampleValue"); - CmpShortField(TIFFTAG_SAMPLEFORMAT, "SampleFormat"); - CmpFloatField(TIFFTAG_XRESOLUTION, "XResolution"); - CmpFloatField(TIFFTAG_YRESOLUTION, "YResolution"); - if (TIFFGetField(tif1, TIFFTAG_COMPRESSION, &compression1) && - compression1 == COMPRESSION_CCITTFAX3 && - TIFFGetField(tif2, TIFFTAG_COMPRESSION, &compression2) && - compression2 == COMPRESSION_CCITTFAX3) - { - CmpLongField(TIFFTAG_GROUP3OPTIONS, "Group3Options"); - } - if (TIFFGetField(tif1, TIFFTAG_COMPRESSION, &compression1) && - compression1 == COMPRESSION_CCITTFAX4 && - TIFFGetField(tif2, TIFFTAG_COMPRESSION, &compression2) && - compression2 == COMPRESSION_CCITTFAX4) - { - CmpLongField(TIFFTAG_GROUP4OPTIONS, "Group4Options"); - } - CmpShortField(TIFFTAG_RESOLUTIONUNIT, "ResolutionUnit"); - CmpShortField(TIFFTAG_PLANARCONFIG, "PlanarConfiguration"); - CmpLongField(TIFFTAG_ROWSPERSTRIP, "RowsPerStrip"); - CmpFloatField(TIFFTAG_XPOSITION, "XPosition"); - CmpFloatField(TIFFTAG_YPOSITION, "YPosition"); - CmpShortField(TIFFTAG_GRAYRESPONSEUNIT, "GrayResponseUnit"); - CmpShortField(TIFFTAG_COLORRESPONSEUNIT, "ColorResponseUnit"); + uint16 compression1, compression2; + CmpLongField(TIFFTAG_SUBFILETYPE, "SubFileType"); + CmpLongField(TIFFTAG_IMAGEWIDTH, "ImageWidth"); + CmpLongField(TIFFTAG_IMAGELENGTH, "ImageLength"); + CmpShortField(TIFFTAG_BITSPERSAMPLE, "BitsPerSample"); + CmpShortField(TIFFTAG_COMPRESSION, "Compression"); + CmpShortField(TIFFTAG_PREDICTOR, "Predictor"); + CmpShortField(TIFFTAG_PHOTOMETRIC, "PhotometricInterpretation"); + CmpShortField(TIFFTAG_THRESHHOLDING, "Thresholding"); + CmpShortField(TIFFTAG_FILLORDER, "FillOrder"); + CmpShortField(TIFFTAG_ORIENTATION, "Orientation"); + CmpShortField(TIFFTAG_SAMPLESPERPIXEL, "SamplesPerPixel"); + CmpShortField(TIFFTAG_MINSAMPLEVALUE, "MinSampleValue"); + CmpShortField(TIFFTAG_MAXSAMPLEVALUE, "MaxSampleValue"); + CmpShortField(TIFFTAG_SAMPLEFORMAT, "SampleFormat"); + CmpFloatField(TIFFTAG_XRESOLUTION, "XResolution"); + CmpFloatField(TIFFTAG_YRESOLUTION, "YResolution"); + if( TIFFGetField(tif1, TIFFTAG_COMPRESSION, &compression1) && + compression1 == COMPRESSION_CCITTFAX3 && + TIFFGetField(tif2, TIFFTAG_COMPRESSION, &compression2) && + compression2 == COMPRESSION_CCITTFAX3 ) + { + CmpLongField(TIFFTAG_GROUP3OPTIONS, "Group3Options"); + } + if( TIFFGetField(tif1, TIFFTAG_COMPRESSION, &compression1) && + compression1 == COMPRESSION_CCITTFAX4 && + TIFFGetField(tif2, TIFFTAG_COMPRESSION, &compression2) && + compression2 == COMPRESSION_CCITTFAX4 ) + { + CmpLongField(TIFFTAG_GROUP4OPTIONS, "Group4Options"); + } + CmpShortField(TIFFTAG_RESOLUTIONUNIT, "ResolutionUnit"); + CmpShortField(TIFFTAG_PLANARCONFIG, "PlanarConfiguration"); + CmpLongField(TIFFTAG_ROWSPERSTRIP, "RowsPerStrip"); + CmpFloatField(TIFFTAG_XPOSITION, "XPosition"); + CmpFloatField(TIFFTAG_YPOSITION, "YPosition"); + CmpShortField(TIFFTAG_GRAYRESPONSEUNIT, "GrayResponseUnit"); + CmpShortField(TIFFTAG_COLORRESPONSEUNIT, "ColorResponseUnit"); #ifdef notdef - { - uint16_t *graycurve; - CmpField(TIFFTAG_GRAYRESPONSECURVE, graycurve); - } - { - uint16_t *red, *green, *blue; - CmpField3(TIFFTAG_COLORRESPONSECURVE, red, green, blue); - } - { - uint16_t *red, *green, *blue; - CmpField3(TIFFTAG_COLORMAP, red, green, blue); - } + { uint16 *graycurve; + CmpField(TIFFTAG_GRAYRESPONSECURVE, graycurve); + } + { uint16 *red, *green, *blue; + CmpField3(TIFFTAG_COLORRESPONSECURVE, red, green, blue); + } + { uint16 *red, *green, *blue; + CmpField3(TIFFTAG_COLORMAP, red, green, blue); + } #endif - CmpShortField2(TIFFTAG_PAGENUMBER, "PageNumber"); - CmpStringField(TIFFTAG_ARTIST, "Artist"); - CmpStringField(TIFFTAG_IMAGEDESCRIPTION, "ImageDescription"); - CmpStringField(TIFFTAG_MAKE, "Make"); - CmpStringField(TIFFTAG_MODEL, "Model"); - CmpStringField(TIFFTAG_SOFTWARE, "Software"); - CmpStringField(TIFFTAG_DATETIME, "DateTime"); - CmpStringField(TIFFTAG_HOSTCOMPUTER, "HostComputer"); - CmpStringField(TIFFTAG_PAGENAME, "PageName"); - CmpStringField(TIFFTAG_DOCUMENTNAME, "DocumentName"); - CmpShortField(TIFFTAG_MATTEING, "Matteing"); - CmpShortArrayField(TIFFTAG_EXTRASAMPLES, "ExtraSamples"); - return (1); + CmpShortField2(TIFFTAG_PAGENUMBER, "PageNumber"); + CmpStringField(TIFFTAG_ARTIST, "Artist"); + CmpStringField(TIFFTAG_IMAGEDESCRIPTION,"ImageDescription"); + CmpStringField(TIFFTAG_MAKE, "Make"); + CmpStringField(TIFFTAG_MODEL, "Model"); + CmpStringField(TIFFTAG_SOFTWARE, "Software"); + CmpStringField(TIFFTAG_DATETIME, "DateTime"); + CmpStringField(TIFFTAG_HOSTCOMPUTER, "HostComputer"); + CmpStringField(TIFFTAG_PAGENAME, "PageName"); + CmpStringField(TIFFTAG_DOCUMENTNAME, "DocumentName"); + CmpShortField(TIFFTAG_MATTEING, "Matteing"); + CmpShortArrayField(TIFFTAG_EXTRASAMPLES,"ExtraSamples"); + return (1); } -static int ContigCompare(int sample, uint32_t row, unsigned char *p1, - unsigned char *p2, tsize_t size) +static int +ContigCompare(int sample, uint32 row, + unsigned char* p1, unsigned char* p2, tsize_t size) { - uint32_t pix; - int samples_to_test; + uint32 pix; + int ppb = 8 / bitspersample; + int samples_to_test; if (memcmp(p1, p2, size) == 0) return 0; samples_to_test = (sample == -1) ? samplesperpixel : 1; - switch (bitspersample) - { - case 1: - case 2: - case 4: - case 8: - { - unsigned char *pix1 = p1, *pix2 = p2; - unsigned bits = 0; + switch (bitspersample) { + case 1: case 2: case 4: case 8: + { + unsigned char *pix1 = p1, *pix2 = p2; - for (pix = 0; pix < imagewidth; pix++) - { - int s; + for (pix = 0; pix < imagewidth; pix += ppb) { + int s; - for (s = 0; s < samples_to_test; s++) - { - if (*pix1 != *pix2) - { - if (sample == -1) - PrintIntDiff(row, s, pix, *pix1, *pix2); - else - PrintIntDiff(row, sample, pix, *pix1, *pix2); - } + for(s = 0; s < samples_to_test; s++) { + if (*pix1 != *pix2) { + if( sample == -1 ) + PrintIntDiff(row, s, pix, *pix1, *pix2); + else + PrintIntDiff(row, sample, pix, *pix1, *pix2); + } - bits += bitspersample; - pix1 += (bits / 8); - pix2 += (bits / 8); - bits &= 7; - } - } - break; - } - case 16: - { - uint16_t *pix1 = (uint16_t *)p1, *pix2 = (uint16_t *)p2; + pix1++; + pix2++; + } + } + break; + } + case 16: + { + uint16 *pix1 = (uint16 *)p1, *pix2 = (uint16 *)p2; - for (pix = 0; pix < imagewidth; pix++) - { - int s; + for (pix = 0; pix < imagewidth; pix++) { + int s; - for (s = 0; s < samples_to_test; s++) - { - if (*pix1 != *pix2) - PrintIntDiff(row, sample, pix, *pix1, *pix2); + for(s = 0; s < samples_to_test; s++) { + if (*pix1 != *pix2) + PrintIntDiff(row, sample, pix, *pix1, *pix2); + + pix1++; + pix2++; + } + } + break; + } + case 32: + if (sampleformat == SAMPLEFORMAT_UINT + || sampleformat == SAMPLEFORMAT_INT) { + uint32 *pix1 = (uint32 *)p1, *pix2 = (uint32 *)p2; - pix1++; - pix2++; - } - } - break; - } - case 32: - if (sampleformat == SAMPLEFORMAT_UINT || - sampleformat == SAMPLEFORMAT_INT) - { - uint32_t *pix1 = (uint32_t *)p1, *pix2 = (uint32_t *)p2; + for (pix = 0; pix < imagewidth; pix++) { + int s; - for (pix = 0; pix < imagewidth; pix++) - { - int s; + for(s = 0; s < samples_to_test; s++) { + if (*pix1 != *pix2) { + PrintIntDiff(row, sample, pix, + *pix1, *pix2); + } + + pix1++; + pix2++; + } + } + } else if (sampleformat == SAMPLEFORMAT_IEEEFP) { + float *pix1 = (float *)p1, *pix2 = (float *)p2; - for (s = 0; s < samples_to_test; s++) - { - if (*pix1 != *pix2) - { - PrintIntDiff(row, sample, pix, *pix1, *pix2); - } + for (pix = 0; pix < imagewidth; pix++) { + int s; - pix1++; - pix2++; - } - } - } - else if (sampleformat == SAMPLEFORMAT_IEEEFP) - { - float *pix1 = (float *)p1, *pix2 = (float *)p2; - - for (pix = 0; pix < imagewidth; pix++) - { - int s; - - for (s = 0; s < samples_to_test; s++) - { - if (fabs(*pix1 - *pix2) < 0.000000000001) - { - PrintFloatDiff(row, sample, pix, *pix1, *pix2); - } - - pix1++; - pix2++; - } - } - } - else - { - fprintf(stderr, "Sample format %" PRIu16 " is not supported.\n", - sampleformat); - return -1; - } - break; - default: - fprintf(stderr, "Bit depth %" PRIu16 " is not supported.\n", - bitspersample); - return -1; + for(s = 0; s < samples_to_test; s++) { + if (fabs(*pix1 - *pix2) < 0.000000000001) { + PrintFloatDiff(row, sample, pix, + *pix1, *pix2); + } + + pix1++; + pix2++; + } + } + } else { + fprintf(stderr, "Sample format %d is not supported.\n", + sampleformat); + return -1; + } + break; + default: + fprintf(stderr, "Bit depth %d is not supported.\n", bitspersample); + return -1; } return 0; } -static void PrintIntDiff(uint32_t row, int sample, uint32_t pix, uint32_t w1, - uint32_t w2) +static void +PrintIntDiff(uint32 row, int sample, uint32 pix, uint32 w1, uint32 w2) { - if (sample < 0) - sample = 0; - switch (bitspersample) - { - case 1: - case 2: - case 4: - { - int32_t mask1, mask2, s; + if (sample < 0) + sample = 0; + switch (bitspersample) { + case 1: + case 2: + case 4: + { + int32 mask1, mask2, s; - /* mask1 should have the n lowest bits set, where n == bitspersample - */ - mask1 = ((int32_t)1 << bitspersample) - 1; - s = (8 - bitspersample); - mask2 = mask1 << s; - for (; mask2 && pix < imagewidth; - mask2 >>= bitspersample, s -= bitspersample, pix++) - { - if ((w1 & mask2) ^ (w2 & mask2)) - { - printf("Scanline %" PRIu32 ", pixel %" PRIu32 - ", sample %d: %01" PRIx32 " %01" PRIx32 "\n", - row, pix, sample, (w1 >> s) & mask1, - (w2 >> s) & mask1); - if (--stopondiff == 0) - exit(1); - } - } - break; - } - case 8: - printf("Scanline %" PRIu32 ", pixel %" PRIu32 - ", sample %d: %02" PRIx32 " %02" PRIx32 "\n", - row, pix, sample, w1, w2); - if (--stopondiff == 0) - exit(1); - break; - case 16: - printf("Scanline %" PRIu32 ", pixel %" PRIu32 - ", sample %d: %04" PRIx32 " %04" PRIx32 "\n", - row, pix, sample, w1, w2); - if (--stopondiff == 0) - exit(1); - break; - case 32: - printf("Scanline %" PRIu32 ", pixel %" PRIu32 - ", sample %d: %08" PRIx32 " %08" PRIx32 "\n", - row, pix, sample, w1, w2); - if (--stopondiff == 0) - exit(1); - break; - default: - break; - } + /* mask1 should have the n lowest bits set, where n == bitspersample */ + mask1 = ((int32)1 << bitspersample) - 1; + s = (8 - bitspersample); + mask2 = mask1 << s; + for (; mask2 && pix < imagewidth; + mask2 >>= bitspersample, s -= bitspersample, pix++) { + if ((w1 & mask2) ^ (w2 & mask2)) { + printf( + "Scanline %lu, pixel %lu, sample %d: %01x %01x\n", + (unsigned long) row, + (unsigned long) pix, + sample, + (unsigned int)((w1 >> s) & mask1), + (unsigned int)((w2 >> s) & mask1)); + if (--stopondiff == 0) + exit(1); + } + } + break; + } + case 8: + printf("Scanline %lu, pixel %lu, sample %d: %02x %02x\n", + (unsigned long) row, (unsigned long) pix, sample, + (unsigned int) w1, (unsigned int) w2); + if (--stopondiff == 0) + exit(1); + break; + case 16: + printf("Scanline %lu, pixel %lu, sample %d: %04x %04x\n", + (unsigned long) row, (unsigned long) pix, sample, + (unsigned int) w1, (unsigned int) w2); + if (--stopondiff == 0) + exit(1); + break; + case 32: + printf("Scanline %lu, pixel %lu, sample %d: %08x %08x\n", + (unsigned long) row, (unsigned long) pix, sample, + (unsigned int) w1, (unsigned int) w2); + if (--stopondiff == 0) + exit(1); + break; + default: + break; + } } -static void PrintFloatDiff(uint32_t row, int sample, uint32_t pix, double w1, - double w2) +static void +PrintFloatDiff(uint32 row, int sample, uint32 pix, double w1, double w2) { - if (sample < 0) - sample = 0; - switch (bitspersample) - { - case 32: - printf("Scanline %" PRIu32 ", pixel %" PRIu32 - ", sample %d: %g %g\n", - row, pix, sample, w1, w2); - if (--stopondiff == 0) - exit(1); - break; - default: - break; - } + if (sample < 0) + sample = 0; + switch (bitspersample) { + case 32: + printf("Scanline %lu, pixel %lu, sample %d: %g %g\n", + (long) row, (long) pix, sample, w1, w2); + if (--stopondiff == 0) + exit(1); + break; + default: + break; + } } -static int SeparateCompare(int reversed, int sample, uint32_t row, - unsigned char *cp1, unsigned char *p2) +static int +SeparateCompare(int reversed, int sample, uint32 row, + unsigned char* cp1, unsigned char* p2) { - uint32_t npixels = imagewidth; - int pixel; + uint32 npixels = imagewidth; + int pixel; - cp1 += sample; - for (pixel = 0; npixels-- > 0; pixel++, cp1 += samplesperpixel, p2++) - { - if (*cp1 != *p2) - { - printf("Scanline %" PRIu32 ", pixel %" PRIu32 ", sample %d: ", row, - pixel, sample); - if (reversed) - printf("%02x %02x\n", *p2, *cp1); - else - printf("%02x %02x\n", *cp1, *p2); - if (--stopondiff == 0) - exit(1); - } - } + cp1 += sample; + for (pixel = 0; npixels-- > 0; pixel++, cp1 += samplesperpixel, p2++) { + if (*cp1 != *p2) { + printf("Scanline %lu, pixel %lu, sample %ld: ", + (long) row, (long) pixel, (long) sample); + if (reversed) + printf("%02x %02x\n", *p2, *cp1); + else + printf("%02x %02x\n", *cp1, *p2); + if (--stopondiff == 0) + exit(1); + } + } - return 0; + return 0; } -static int checkTag(TIFF *tif1, TIFF *tif2, int tag, char *name, void *p1, - void *p2) +static int +checkTag(TIFF* tif1, TIFF* tif2, int tag, char* name, void* p1, void* p2) { - if (TIFFGetField(tif1, tag, p1)) - { - if (!TIFFGetField(tif2, tag, p2)) - { - printf("%s tag appears only in %s\n", name, TIFFFileName(tif1)); - return (0); - } - return (1); - } - else if (TIFFGetField(tif2, tag, p2)) - { - printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); - return (0); - } - return (-1); + if (TIFFGetField(tif1, tag, p1)) { + if (!TIFFGetField(tif2, tag, p2)) { + printf("%s tag appears only in %s\n", + name, TIFFFileName(tif1)); + return (0); + } + return (1); + } else if (TIFFGetField(tif2, tag, p2)) { + printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); + return (0); + } + return (-1); } -#define CHECK(cmp, fmt) \ - { \ - switch (checkTag(tif1, tif2, tag, name, &v1, &v2)) \ - { \ - case 1: \ - if (cmp) \ - case -1: \ - return (1); \ - printf(fmt, name, v1, v2); \ - } \ - return (0); \ - } +#define CHECK(cmp, fmt) { \ + switch (checkTag(tif1,tif2,tag,name,&v1,&v2)) { \ + case 1: if (cmp) \ + case -1: return (1); \ + printf(fmt, name, v1, v2); \ + } \ + return (0); \ +} -static int CheckShortTag(TIFF *tif1, TIFF *tif2, int tag, char *name) +static int +CheckShortTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - uint16_t v1, v2; - CHECK(v1 == v2, "%s: %" PRIu16 " %" PRIu16 "\n"); + uint16 v1, v2; + CHECK(v1 == v2, "%s: %u %u\n"); } -static int CheckShort2Tag(TIFF *tif1, TIFF *tif2, int tag, char *name) +static int +CheckShort2Tag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - uint16_t v11, v12, v21, v22; + uint16 v11, v12, v21, v22; - if (TIFFGetField(tif1, tag, &v11, &v12)) - { - if (!TIFFGetField(tif2, tag, &v21, &v22)) - { - printf("%s tag appears only in %s\n", name, TIFFFileName(tif1)); - return (0); - } - if (v11 == v21 && v12 == v22) - return (1); - printf("%s: <%" PRIu16 ",%" PRIu16 "> <%" PRIu16 ",%" PRIu16 ">\n", - name, v11, v12, v21, v22); - } - else if (TIFFGetField(tif2, tag, &v21, &v22)) - printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); - else - return (1); - return (0); + if (TIFFGetField(tif1, tag, &v11, &v12)) { + if (!TIFFGetField(tif2, tag, &v21, &v22)) { + printf("%s tag appears only in %s\n", + name, TIFFFileName(tif1)); + return (0); + } + if (v11 == v21 && v12 == v22) + return (1); + printf("%s: <%u,%u> <%u,%u>\n", name, v11, v12, v21, v22); + } else if (TIFFGetField(tif2, tag, &v21, &v22)) + printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); + else + return (1); + return (0); } -static int CheckShortArrayTag(TIFF *tif1, TIFF *tif2, int tag, char *name) +static int +CheckShortArrayTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - uint16_t n1, *a1; - uint16_t n2, *a2; + uint16 n1, *a1; + uint16 n2, *a2; - if (TIFFGetField(tif1, tag, &n1, &a1)) - { - if (!TIFFGetField(tif2, tag, &n2, &a2)) - { - printf("%s tag appears only in %s\n", name, TIFFFileName(tif1)); - return (0); - } - if (n1 == n2) - { - char *sep; - uint16_t i; + if (TIFFGetField(tif1, tag, &n1, &a1)) { + if (!TIFFGetField(tif2, tag, &n2, &a2)) { + printf("%s tag appears only in %s\n", + name, TIFFFileName(tif1)); + return (0); + } + if (n1 == n2) { + char* sep; + uint16 i; - if (memcmp(a1, a2, n1 * sizeof(uint16_t)) == 0) - return (1); - printf("%s: value mismatch, <%" PRIu16 ":", name, n1); - sep = ""; - for (i = 0; i < n1; i++) - printf("%s%" PRIu16, sep, a1[i]), sep = ","; - printf("> and <%" PRIu16 ": ", n2); - sep = ""; - for (i = 0; i < n2; i++) - printf("%s%" PRIu16, sep, a2[i]), sep = ","; - printf(">\n"); - } - else - printf("%s: %" PRIu16 " items in %s, %" PRIu16 " items in %s", name, - n1, TIFFFileName(tif1), n2, TIFFFileName(tif2)); - } - else if (TIFFGetField(tif2, tag, &n2, &a2)) - printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); - else - return (1); - return (0); + if (memcmp(a1, a2, n1 * sizeof(uint16)) == 0) + return (1); + printf("%s: value mismatch, <%u:", name, n1); + sep = ""; + for (i = 0; i < n1; i++) + printf("%s%u", sep, a1[i]), sep = ","; + printf("> and <%u: ", n2); + sep = ""; + for (i = 0; i < n2; i++) + printf("%s%u", sep, a2[i]), sep = ","; + printf(">\n"); + } else + printf("%s: %u items in %s, %u items in %s", name, + n1, TIFFFileName(tif1), + n2, TIFFFileName(tif2) + ); + } else if (TIFFGetField(tif2, tag, &n2, &a2)) + printf("%s tag appears only in %s\n", name, TIFFFileName(tif2)); + else + return (1); + return (0); } -static int CheckLongTag(TIFF *tif1, TIFF *tif2, int tag, char *name) +static int +CheckLongTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - uint32_t v1, v2; - CHECK(v1 == v2, "%s: %" PRIu32 " %" PRIu32 "\n"); + uint32 v1, v2; + CHECK(v1 == v2, "%s: %u %u\n"); } -static int CheckFloatTag(TIFF *tif1, TIFF *tif2, int tag, char *name) +static int +CheckFloatTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - float v1, v2; - CHECK(v1 == v2, "%s: %g %g\n"); + float v1, v2; + CHECK(v1 == v2, "%s: %g %g\n"); } -static int CheckStringTag(TIFF *tif1, TIFF *tif2, int tag, char *name) +static int +CheckStringTag(TIFF* tif1, TIFF* tif2, int tag, char* name) { - char *v1, *v2; - CHECK(strcmp(v1, v2) == 0, "%s: \"%s\" \"%s\"\n"); + char *v1, *v2; + CHECK(strcmp(v1, v2) == 0, "%s: \"%s\" \"%s\"\n"); } -static void leof(const char *name, uint32_t row, int s) +static void +leof(const char* name, uint32 row, int s) { - printf("%s: EOF at scanline %" PRIu32, name, row); - if (s >= 0) - printf(", sample %d", s); - printf("\n"); + printf("%s: EOF at scanline %lu", name, (unsigned long)row); + if (s >= 0) + printf(", sample %d", s); + printf("\n"); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffcp.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffcp.c index 3b2d1ddac..825cfc0cf 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffcp.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffcp.c @@ -16,38 +16,37 @@ * Copies the 2nd image in source.tif to the destination. * ***** - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" -#include #include #include #include +#include #include #ifdef HAVE_UNISTD_H -#include +# include #endif #include "tiffio.h" @@ -59,11 +58,19 @@ #define EXIT_FAILURE 1 #endif -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); +#endif -#define TRUE 1 -#define FALSE 0 +#if defined(VMS) +# define unlink delete +#endif + +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) + +#define TRUE 1 +#define FALSE 0 #define DEFAULT_MAX_MALLOC (256 * 1024 * 1024) @@ -72,1138 +79,905 @@ static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC; static int outtiled = -1; -static uint32_t tilewidth; -static uint32_t tilelength; +static uint32 tilewidth; +static uint32 tilelength; -static uint16_t config; -static uint16_t compression; -static double max_z_error = 0.0; -static uint16_t predictor; +static uint16 config; +static uint16 compression; +static uint16 predictor; static int preset; -static uint16_t fillorder; -static uint16_t orientation; -static uint32_t rowsperstrip; -static uint32_t g3opts; -static int ignore = FALSE; /* if true, ignore read errors */ -static uint32_t defg3opts = (uint32_t)-1; -static int quality = 75; /* JPEG quality */ +static uint16 fillorder; +static uint16 orientation; +static uint32 rowsperstrip; +static uint32 g3opts; +static int ignore = FALSE; /* if true, ignore read errors */ +static uint32 defg3opts = (uint32) -1; +static int quality = 75; /* JPEG quality */ static int jpegcolormode = JPEGCOLORMODE_RGB; -static uint16_t defcompression = (uint16_t)-1; -static uint16_t defpredictor = (uint16_t)-1; -static int defpreset = -1; +static uint16 defcompression = (uint16) -1; +static uint16 defpredictor = (uint16) -1; +static int defpreset = -1; static int subcodec = -1; -static int tiffcp(TIFF *, TIFF *); -static int processCompressOptions(char *); +static int tiffcp(TIFF*, TIFF*); +static int processCompressOptions(char*); static void usage(int code); -static char comma = ','; /* (default) comma separator character */ -static TIFF *bias = NULL; +static char comma = ','; /* (default) comma separator character */ +static TIFF* bias = NULL; static int pageNum = 0; static int pageInSeq = 0; /** * This custom malloc function enforce a maximum allocation size */ -static void *limitMalloc(tmsize_t s) +static void* limitMalloc(tmsize_t s) { - if (maxMalloc && (s > maxMalloc)) - { - fprintf(stderr, - "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT - " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", - s, maxMalloc); - fprintf(stderr, " use -m option to change limit.\n"); - return NULL; - } - return _TIFFmalloc(s); + if (maxMalloc && (s > maxMalloc)) { + fprintf(stderr, "MemoryLimitError: allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ".\n", + (uint64)s, (uint64)maxMalloc); + fprintf(stderr, " use -m option to change limit.\n"); + return NULL; + } + return _TIFFmalloc(s); } -static int nextSrcImage(TIFF *tif, char **imageSpec) +static int nextSrcImage (TIFF *tif, char **imageSpec) /* seek to the next image specified in *imageSpec returns 1 if success, 0 if no more images to process *imageSpec=NULL if subsequent images should be processed in sequence */ { - if (**imageSpec == comma) - { /* if not @comma, we've done all images */ - char *start = *imageSpec + 1; - tdir_t nextImage = (tdir_t)strtol(start, imageSpec, 0); - if (start == *imageSpec) - nextImage = TIFFCurrentDirectory(tif); - if (**imageSpec) - { - if (**imageSpec == comma) - { - /* a trailing comma denotes remaining images in sequence */ - if ((*imageSpec)[1] == '\0') - *imageSpec = NULL; - } - else - { - fprintf(stderr, - "Expected a %c separated image # list after %s\n", - comma, TIFFFileName(tif)); - exit(EXIT_FAILURE); /* syntax error */ - } - } - if (TIFFSetDirectory(tif, nextImage)) - return 1; - fprintf(stderr, "%s%c%" PRIu16 " not found!\n", TIFFFileName(tif), - comma, nextImage); - } - return 0; + if (**imageSpec == comma) { /* if not @comma, we've done all images */ + char *start = *imageSpec + 1; + tdir_t nextImage = (tdir_t)strtol(start, imageSpec, 0); + if (start == *imageSpec) nextImage = TIFFCurrentDirectory (tif); + if (**imageSpec) + { + if (**imageSpec == comma) { + /* a trailing comma denotes remaining images in sequence */ + if ((*imageSpec)[1] == '\0') *imageSpec = NULL; + }else{ + fprintf (stderr, + "Expected a %c separated image # list after %s\n", + comma, TIFFFileName (tif)); + exit (EXIT_FAILURE); /* syntax error */ + } + } + if (TIFFSetDirectory (tif, nextImage)) return 1; + fprintf (stderr, "%s%c%d not found!\n", + TIFFFileName(tif), comma, (int) nextImage); + } + return 0; } -static TIFF *openSrcImage(char **imageSpec) + +static TIFF* openSrcImage (char **imageSpec) /* imageSpec points to a pointer to a filename followed by optional ,image#'s Open the TIFF file and assign *imageSpec to either NULL if there are no images specified, or a pointer to the next image number text */ { - /* disable strip shopping when using jbig compression */ - const char *mode = (defcompression == COMPRESSION_JBIG) ? "rc" : "r"; - TIFF *tif; - char *fn = *imageSpec; - *imageSpec = strchr(fn, comma); - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - if (opts == NULL) - { - return NULL; - } - TIFFOpenOptionsSetMaxSingleMemAlloc(opts, maxMalloc); - if (*imageSpec) - { /* there is at least one image number specifier */ - **imageSpec = '\0'; - tif = TIFFOpenExt(fn, mode, opts); - /* but, ignore any single trailing comma */ - if (!(*imageSpec)[1]) - { - *imageSpec = NULL; - TIFFOpenOptionsFree(opts); - return tif; - } - if (tif) - { - **imageSpec = comma; /* replace the comma */ - if (!nextSrcImage(tif, imageSpec)) - { - TIFFClose(tif); - tif = NULL; - } - } - } - else - tif = TIFFOpenExt(fn, mode, opts); - TIFFOpenOptionsFree(opts); - return tif; + /* disable strip shopping when using jbig compression */ + const char *mode = (defcompression == COMPRESSION_JBIG) ? "rc" : "r"; + TIFF *tif; + char *fn = *imageSpec; + *imageSpec = strchr (fn, comma); + if (*imageSpec) { /* there is at least one image number specifier */ + **imageSpec = '\0'; + tif = TIFFOpen (fn, mode); + /* but, ignore any single trailing comma */ + if (!(*imageSpec)[1]) {*imageSpec = NULL; return tif;} + if (tif) { + **imageSpec = comma; /* replace the comma */ + if (!nextSrcImage(tif, imageSpec)) { + TIFFClose (tif); + tif = NULL; + } + } + }else + tif = TIFFOpen (fn, mode); + return tif; } -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - uint16_t defconfig = (uint16_t)-1; - uint16_t deffillorder = 0; - uint32_t deftilewidth = (uint32_t)-1; - uint32_t deftilelength = (uint32_t)-1; - uint32_t defrowsperstrip = (uint32_t)0; - uint64_t diroff = 0; - TIFF *in; - TIFF *out; - char mode[10]; - char *mp = mode; - int c; + uint16 defconfig = (uint16) -1; + uint16 deffillorder = 0; + uint32 deftilewidth = (uint32) -1; + uint32 deftilelength = (uint32) -1; + uint32 defrowsperstrip = (uint32) 0; + uint64 diroff = 0; + TIFF* in; + TIFF* out; + char mode[10]; + char* mp = mode; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - *mp++ = 'w'; - *mp = '\0'; - while ((c = getopt(argc, argv, "m:,:b:c:f:l:o:p:r:w:aistBLMC8xh")) != -1) - switch (c) - { - case 'm': - maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; - break; - case ',': - if (optarg[0] != '=') - usage(EXIT_FAILURE); - comma = optarg[1]; - break; - case 'b': /* this file is bias image subtracted from others */ - if (bias) - { - fputs("Only 1 bias image may be specified\n", stderr); - exit(EXIT_FAILURE); - } - { - uint16_t samples = (uint16_t)-1; - char **biasFn = &optarg; - bias = openSrcImage(biasFn); - if (!bias) - exit(EXIT_FAILURE); - if (TIFFIsTiled(bias)) - { - fputs("Bias image must be organized in strips\n", - stderr); - exit(EXIT_FAILURE); - } - TIFFGetField(bias, TIFFTAG_SAMPLESPERPIXEL, &samples); - if (samples != 1) - { - fputs("Bias image must be monochrome\n", stderr); - exit(EXIT_FAILURE); - } - } - break; - case 'a': /* append to output */ - mode[0] = 'a'; - break; - case 'c': /* compression scheme */ - if (!processCompressOptions(optarg)) - usage(EXIT_FAILURE); - break; - case 'f': /* fill order */ - if (streq(optarg, "lsb2msb")) - deffillorder = FILLORDER_LSB2MSB; - else if (streq(optarg, "msb2lsb")) - deffillorder = FILLORDER_MSB2LSB; - else - usage(EXIT_FAILURE); - break; - case 'i': /* ignore errors */ - ignore = TRUE; - break; - case 'l': /* tile length */ - outtiled = TRUE; - deftilelength = atoi(optarg); - break; - case 'o': /* initial directory offset */ - diroff = strtoul(optarg, NULL, 0); - break; - case 'p': /* planar configuration */ - if (streq(optarg, "separate")) - defconfig = PLANARCONFIG_SEPARATE; - else if (streq(optarg, "contig")) - defconfig = PLANARCONFIG_CONTIG; - else - usage(EXIT_FAILURE); - break; - case 'r': /* rows/strip */ - defrowsperstrip = atol(optarg); - break; - case 's': /* generate stripped output */ - outtiled = FALSE; - break; - case 't': /* generate tiled output */ - outtiled = TRUE; - break; - case 'w': /* tile width */ - outtiled = TRUE; - deftilewidth = atoi(optarg); - break; - case 'B': - if (strlen(mode) < (sizeof(mode) - 1)) - { - *mp++ = 'b'; - *mp = '\0'; - } - break; - case 'L': - if (strlen(mode) < (sizeof(mode) - 1)) - { - *mp++ = 'l'; - *mp = '\0'; - } - break; - case 'M': - if (strlen(mode) < (sizeof(mode) - 1)) - { - *mp++ = 'm'; - *mp = '\0'; - } - break; - case 'C': - if (strlen(mode) < (sizeof(mode) - 1)) - { - *mp++ = 'c'; - *mp = '\0'; - } - break; - case '8': - if (strlen(mode) < (sizeof(mode) - 1)) - { - *mp++ = '8'; - *mp = '\0'; - } - break; - case 'x': - pageInSeq = 1; - break; - case 'h': - usage(EXIT_SUCCESS); - /*NOTREACHED*/ - break; - case '?': - usage(EXIT_FAILURE); - /*NOTREACHED*/ - break; - } - if (argc - optind < 2) - usage(EXIT_FAILURE); - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - if (opts == NULL) - { - return EXIT_FAILURE; - } - TIFFOpenOptionsSetMaxSingleMemAlloc(opts, maxMalloc); - out = TIFFOpenExt(argv[argc - 1], mode, opts); - TIFFOpenOptionsFree(opts); - if (out == NULL) - return (EXIT_FAILURE); - if ((argc - optind) == 2) - pageNum = -1; - for (; optind < argc - 1; optind++) - { - char *imageCursor = argv[optind]; - in = openSrcImage(&imageCursor); - if (in == NULL) - { - (void)TIFFClose(out); - return (EXIT_FAILURE); - } - if (diroff != 0 && !TIFFSetSubDirectory(in, diroff)) - { - TIFFError(TIFFFileName(in), - "Error, setting subdirectory at %" PRIu64, diroff); - (void)TIFFClose(in); - (void)TIFFClose(out); - return (EXIT_FAILURE); - } - for (;;) - { - config = defconfig; - compression = defcompression; - predictor = defpredictor; - preset = defpreset; - fillorder = deffillorder; - rowsperstrip = defrowsperstrip; - tilewidth = deftilewidth; - tilelength = deftilelength; - g3opts = defg3opts; - if (!tiffcp(in, out) || !TIFFWriteDirectory(out)) - { - (void)TIFFClose(in); - (void)TIFFClose(out); - return (EXIT_FAILURE); - } - if (imageCursor) - { /* seek next image directory */ - if (!nextSrcImage(in, &imageCursor)) - break; - } - else if (!TIFFReadDirectory(in)) - break; - } - (void)TIFFClose(in); - } + *mp++ = 'w'; + *mp = '\0'; + while ((c = getopt(argc, argv, "m:,:b:c:f:l:o:p:r:w:aistBLMC8xh")) != -1) + switch (c) { + case 'm': + maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; + break; + case ',': + if (optarg[0] != '=') usage(EXIT_FAILURE); + comma = optarg[1]; + break; + case 'b': /* this file is bias image subtracted from others */ + if (bias) { + fputs ("Only 1 bias image may be specified\n", stderr); + exit (EXIT_FAILURE); + } + { + uint16 samples = (uint16) -1; + char **biasFn = &optarg; + bias = openSrcImage (biasFn); + if (!bias) exit (EXIT_FAILURE); + if (TIFFIsTiled (bias)) { + fputs ("Bias image must be organized in strips\n", stderr); + exit (EXIT_FAILURE); + } + TIFFGetField(bias, TIFFTAG_SAMPLESPERPIXEL, &samples); + if (samples != 1) { + fputs ("Bias image must be monochrome\n", stderr); + exit (EXIT_FAILURE); + } + } + break; + case 'a': /* append to output */ + mode[0] = 'a'; + break; + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(EXIT_FAILURE); + break; + case 'f': /* fill order */ + if (streq(optarg, "lsb2msb")) + deffillorder = FILLORDER_LSB2MSB; + else if (streq(optarg, "msb2lsb")) + deffillorder = FILLORDER_MSB2LSB; + else + usage(EXIT_FAILURE); + break; + case 'i': /* ignore errors */ + ignore = TRUE; + break; + case 'l': /* tile length */ + outtiled = TRUE; + deftilelength = atoi(optarg); + break; + case 'o': /* initial directory offset */ + diroff = strtoul(optarg, NULL, 0); + break; + case 'p': /* planar configuration */ + if (streq(optarg, "separate")) + defconfig = PLANARCONFIG_SEPARATE; + else if (streq(optarg, "contig")) + defconfig = PLANARCONFIG_CONTIG; + else + usage(EXIT_FAILURE); + break; + case 'r': /* rows/strip */ + defrowsperstrip = atol(optarg); + break; + case 's': /* generate stripped output */ + outtiled = FALSE; + break; + case 't': /* generate tiled output */ + outtiled = TRUE; + break; + case 'w': /* tile width */ + outtiled = TRUE; + deftilewidth = atoi(optarg); + break; + case 'B': + if (strlen(mode) < (sizeof(mode) - 1)) + { + *mp++ = 'b'; *mp = '\0'; + } + break; + case 'L': + if (strlen(mode) < (sizeof(mode) - 1)) + { + *mp++ = 'l'; *mp = '\0'; + } + break; + case 'M': + if (strlen(mode) < (sizeof(mode) - 1)) + { + *mp++ = 'm'; *mp = '\0'; + } + break; + case 'C': + if (strlen(mode) < (sizeof(mode) - 1)) + { + *mp++ = 'c'; *mp = '\0'; + } + break; + case '8': + if (strlen(mode) < (sizeof(mode)-1)) + { + *mp++ = '8'; *mp = '\0'; + } + break; + case 'x': + pageInSeq = 1; + break; + case 'h': + usage(EXIT_SUCCESS); + /*NOTREACHED*/ + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } + if (argc - optind < 2) + usage(EXIT_FAILURE); + out = TIFFOpen(argv[argc-1], mode); + if (out == NULL) + return (EXIT_FAILURE); + if ((argc - optind) == 2) + pageNum = -1; + for (; optind < argc-1 ; optind++) { + char *imageCursor = argv[optind]; + in = openSrcImage (&imageCursor); + if (in == NULL) { + (void) TIFFClose(out); + return (EXIT_FAILURE); + } + if (diroff != 0 && !TIFFSetSubDirectory(in, diroff)) { + TIFFError(TIFFFileName(in), + "Error, setting subdirectory at " TIFF_UINT64_FORMAT, diroff); + (void) TIFFClose(in); + (void) TIFFClose(out); + return (EXIT_FAILURE); + } + for (;;) { + config = defconfig; + compression = defcompression; + predictor = defpredictor; + preset = defpreset; + fillorder = deffillorder; + rowsperstrip = defrowsperstrip; + tilewidth = deftilewidth; + tilelength = deftilelength; + g3opts = defg3opts; + if (!tiffcp(in, out) || !TIFFWriteDirectory(out)) { + (void) TIFFClose(in); + (void) TIFFClose(out); + return (EXIT_FAILURE); + } + if (imageCursor) { /* seek next image directory */ + if (!nextSrcImage(in, &imageCursor)) break; + }else + if (!TIFFReadDirectory(in)) break; + } + (void) TIFFClose(in); + } - (void)TIFFClose(out); - return (EXIT_SUCCESS); + (void) TIFFClose(out); + return (EXIT_SUCCESS); } -static void processZIPOptions(char *cp) +static void +processZIPOptions(char* cp) { - if ((cp = strchr(cp, ':'))) - { - do - { - cp++; - if (isdigit((int)*cp)) - defpredictor = atoi(cp); - else if (*cp == 'p') - defpreset = atoi(++cp); - else if (*cp == 's') - subcodec = atoi(++cp); - else - usage(EXIT_FAILURE); - } while ((cp = strchr(cp, ':'))); - } + if ( (cp = strchr(cp, ':')) ) { + do { + cp++; + if (isdigit((int)*cp)) + defpredictor = atoi(cp); + else if (*cp == 'p') + defpreset = atoi(++cp); + else if (*cp == 's') + subcodec = atoi(++cp); + else + usage(EXIT_FAILURE); + } while( (cp = strchr(cp, ':')) ); + } } -static void processLERCOptions(char *cp) +static void +processG3Options(char* cp) { - if ((cp = strchr(cp, ':'))) - { - do - { - cp++; - if (isdigit((int)*cp)) - max_z_error = atof(cp); - else if (*cp == 's') - subcodec = atoi(++cp); - else if (*cp == 'p') - defpreset = atoi(++cp); - else - usage(EXIT_FAILURE); - } while ((cp = strchr(cp, ':'))); - } + if( (cp = strchr(cp, ':')) ) { + if (defg3opts == (uint32) -1) + defg3opts = 0; + do { + cp++; + if (strneq(cp, "1d", 2)) + defg3opts &= ~GROUP3OPT_2DENCODING; + else if (strneq(cp, "2d", 2)) + defg3opts |= GROUP3OPT_2DENCODING; + else if (strneq(cp, "fill", 4)) + defg3opts |= GROUP3OPT_FILLBITS; + else + usage(EXIT_FAILURE); + } while( (cp = strchr(cp, ':')) ); + } } -static void processG3Options(char *cp) +static int +processCompressOptions(char* opt) { - if ((cp = strchr(cp, ':'))) - { - if (defg3opts == (uint32_t)-1) - defg3opts = 0; - do - { - cp++; - if (strneq(cp, "1d", 2)) - defg3opts &= ~GROUP3OPT_2DENCODING; - else if (strneq(cp, "2d", 2)) - defg3opts |= GROUP3OPT_2DENCODING; - else if (strneq(cp, "fill", 4)) - defg3opts |= GROUP3OPT_FILLBITS; - else - usage(EXIT_FAILURE); - } while ((cp = strchr(cp, ':'))); - } + if (streq(opt, "none")) { + defcompression = COMPRESSION_NONE; + } else if (streq(opt, "packbits")) { + defcompression = COMPRESSION_PACKBITS; + } else if (strneq(opt, "jpeg", 4)) { + char* cp = strchr(opt, ':'); + + defcompression = COMPRESSION_JPEG; + while( cp ) + { + if (isdigit((int)cp[1])) + quality = atoi(cp+1); + else if (cp[1] == 'r' ) + jpegcolormode = JPEGCOLORMODE_RAW; + else + usage(EXIT_FAILURE); + + cp = strchr(cp+1,':'); + } + } else if (strneq(opt, "g3", 2)) { + processG3Options(opt); + defcompression = COMPRESSION_CCITTFAX3; + } else if (streq(opt, "g4")) { + defcompression = COMPRESSION_CCITTFAX4; + } else if (strneq(opt, "lzw", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + defpredictor = atoi(cp+1); + defcompression = COMPRESSION_LZW; + } else if (strneq(opt, "zip", 3)) { + processZIPOptions(opt); + defcompression = COMPRESSION_ADOBE_DEFLATE; + } else if (strneq(opt, "lzma", 4)) { + processZIPOptions(opt); + defcompression = COMPRESSION_LZMA; + } else if (strneq(opt, "zstd", 4)) { + processZIPOptions(opt); + defcompression = COMPRESSION_ZSTD; + } else if (strneq(opt, "webp", 4)) { + processZIPOptions(opt); + defcompression = COMPRESSION_WEBP; + } else if (strneq(opt, "jbig", 4)) { + defcompression = COMPRESSION_JBIG; + } else if (strneq(opt, "sgilog", 6)) { + defcompression = COMPRESSION_SGILOG; + } else + return (0); + return (1); } -static int processCompressOptions(char *opt) -{ - if (streq(opt, "none")) - { - defcompression = COMPRESSION_NONE; - } - else if (streq(opt, "packbits")) - { - defcompression = COMPRESSION_PACKBITS; - } - else if (strneq(opt, "jpeg", 4)) - { - char *cp = strchr(opt, ':'); - - defcompression = COMPRESSION_JPEG; - while (cp) - { - if (isdigit((int)cp[1])) - quality = atoi(cp + 1); - else if (cp[1] == 'r') - jpegcolormode = JPEGCOLORMODE_RAW; - else - usage(EXIT_FAILURE); - - cp = strchr(cp + 1, ':'); - } - } - else if (strneq(opt, "g3", 2)) - { - processG3Options(opt); - defcompression = COMPRESSION_CCITTFAX3; - } - else if (streq(opt, "g4")) - { - defcompression = COMPRESSION_CCITTFAX4; - } - else if (strneq(opt, "lzw", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - defpredictor = atoi(cp + 1); - defcompression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - processZIPOptions(opt); - defcompression = COMPRESSION_ADOBE_DEFLATE; - } - else if (strneq(opt, "lerc", 4)) - { - processLERCOptions(opt); - defcompression = COMPRESSION_LERC; - } - else if (strneq(opt, "lzma", 4)) - { - processZIPOptions(opt); - defcompression = COMPRESSION_LZMA; - } - else if (strneq(opt, "zstd", 4)) - { - processZIPOptions(opt); - defcompression = COMPRESSION_ZSTD; - } - else if (strneq(opt, "webp", 4)) - { - processZIPOptions(opt); - defcompression = COMPRESSION_WEBP; - } - else if (strneq(opt, "jbig", 4)) - { - defcompression = COMPRESSION_JBIG; - } - else if (strneq(opt, "sgilog", 6)) - { - defcompression = COMPRESSION_SGILOG; - } - else - return (0); - return (1); -} - -static const char usage_info[] = - "Copy, convert, or combine TIFF files\n\n" - "usage: tiffcp [options] input... output\n" - "where options are:\n" - " -a append to output instead of overwriting\n" - " -o offset set initial directory offset\n" - " -p contig pack samples contiguously (e.g. RGBRGB...)\n" - " -p separate store samples separately (e.g. RRR...GGG...BBB...)\n" - " -s write output in strips\n" - " -t write output in tiles\n" - " -x force the merged tiff pages in sequence\n" - " -8 write BigTIFF instead of default ClassicTIFF\n" - " -B write big-endian instead of native byte order\n" - " -L write little-endian instead of native byte order\n" - " -M disable use of memory-mapped files\n" - " -C disable strip chopping\n" - " -i ignore read errors\n" - " -b file[,#] bias (dark) monochrome image to be subtracted from all " - "others\n" - " -,=% use % rather than , to separate image #'s (per Note " - "below)\n" - " -m size set maximum memory allocation size (MiB). 0 to disable " - "limit.\n" - "\n" - " -r # make each strip have no more than # rows\n" - " -w # set output tile width (pixels)\n" - " -l # set output tile length (pixels)\n" - "\n" - " -f lsb2msb force lsb-to-msb FillOrder for output\n" - " -f msb2lsb force msb-to-lsb FillOrder for output\n" - "\n" -#ifdef LZW_SUPPORT - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" - /* " LZW options:" */ - " # set predictor value\n" - " For example, -c lzw:2 for LZW-encoded data with horizontal " - "differencing\n" +static const char* stuff[] = { +"usage: tiffcp [options] input... output", +"where options are:", +" -a append to output instead of overwriting", +" -o offset set initial directory offset", +" -p contig pack samples contiguously (e.g. RGBRGB...)", +" -p separate store samples separately (e.g. RRR...GGG...BBB...)", +" -s write output in strips", +" -t write output in tiles", +" -x force the merged tiff pages in sequence", +" -8 write BigTIFF instead of default ClassicTIFF", +" -B write big-endian instead of native byte order", +" -L write little-endian instead of native byte order", +" -M disable use of memory-mapped files", +" -C disable strip chopping", +" -i ignore read errors", +" -b file[,#] bias (dark) monochrome image to be subtracted from all others", +" -,=% use % rather than , to separate image #'s (per Note below)", +" -m size set maximum memory allocation size (MiB). 0 to disable limit.", +"", +" -r # make each strip have no more than # rows", +" -w # set output tile width (pixels)", +" -l # set output tile length (pixels)", +"", +" -f lsb2msb force lsb-to-msb FillOrder for output", +" -f msb2lsb force msb-to-lsb FillOrder for output", +"", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c lzma[:opts] compress output with LZMA2 encoding", +" -c zstd[:opts] compress output with ZSTD encoding", +" -c webp[:opts] compress output with WEBP encoding", +" -c jpeg[:opts] compress output with JPEG encoding", +" -c jbig compress output with ISO JBIG encoding", +" -c packbits compress output with packbits encoding", +" -c g3[:opts] compress output with CCITT Group 3 encoding", +" -c g4 compress output with CCITT Group 4 encoding", +" -c sgilog compress output with SGILOG encoding", +" -c none use no compression algorithm on output", +"", +"Group 3 options:", +" 1d use default CCITT Group 3 1D-encoding", +" 2d use optional CCITT Group 3 2D-encoding", +" fill byte-align EOL codes", +"For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", +"", +"JPEG options:", +" # set compression quality level (0-100, default 75)", +" r output color image as RGB rather than YCbCr", +"For example, -c jpeg:r:50 to get JPEG-encoded RGB data with 50% comp. quality", +"", +"LZW, Deflate (ZIP), LZMA2, ZSTD and WEBP options:", +" # set predictor value", +" p# set compression level (preset)", +#if LIBDEFLATE_SUPPORT +" s# set subcodec (0=zlib, 1=libdeflate) (only for Deflate/ZIP)", #endif -#ifdef ZIP_SUPPORT - " -c zip[:opts] compress output with deflate encoding\n" - /* " Deflate (ZIP) options:", */ - " # set predictor value\n" - " p# set compression level (preset)\n" - " For example, -c zip:3:p9 for maximum compression level and floating\n" - " point predictor.\n" -#endif -#if defined(ZIP_SUPPORT) && defined(LIBDEFLATE_SUPPORT) - " s# set subcodec: 0=zlib, 1=libdeflate (default 1)\n" -/* " (only for Deflate/ZIP)", */ -#endif -#ifdef LERC_SUPPORT - " -c lerc[:opts] compress output with LERC encoding\n" - /* " LERC options:", */ - " # set max_z_error value\n" - " p# set compression level (preset)\n" -#ifdef ZSTD_SUPPORT - " s# set subcodec: 0=none, 1=deflate, 2=zstd (default 0)\n" - " For example, -c lerc:0.5:s2:p22 for max_z_error 0.5,\n" - " zstd additional compression with maximum compression level.\n" -#else - " s# set subcodec: 0=none, 1=deflate (default 0)\n" - " For example, -c lerc:0.5:s1:p12 for max_z_error 0.5,\n" - " deflate additional compression with maximum compression level.\n" -#endif -#endif -#ifdef LZMA_SUPPORT - " -c lzma[:opts] compress output with LZMA2 encoding\n" - /* " LZMA options:", */ - " # set predictor value\n" - " p# set compression level (preset)\n" -#endif -#ifdef ZSTD_SUPPORT - " -c zstd[:opts] compress output with ZSTD encoding\n" - /* " ZSTD options:", */ - " # set predictor value\n" - " p# set compression level (preset)\n" -#endif -#ifdef WEBP_SUPPORT - " -c webp[:opts] compress output with WEBP encoding\n" - /* " WEBP options:", */ - " # set predictor value\n" - " p# set compression level (preset)\n" -#endif -#ifdef JPEG_SUPPORT - " -c jpeg[:opts] compress output with JPEG encoding\n" - /* " JPEG options:", */ - " # set compression quality level (0-100, default 75)\n" - " r output color image as RGB rather than YCbCr\n" - " For example, -c jpeg:r:50 for JPEG-encoded RGB with 50% comp. " - "quality\n" -#endif -#ifdef JBIG_SUPPORT - " -c jbig compress output with ISO JBIG encoding\n" -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits compress output with packbits encoding\n" -#endif -#ifdef CCITT_SUPPORT - " -c g3[:opts] compress output with CCITT Group 3 encoding\n" - /* " CCITT Group 3 options:", */ - " 1d use default CCITT Group 3 1D-encoding\n" - " 2d use optional CCITT Group 3 2D-encoding\n" - " fill byte-align EOL codes\n" - " For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned " - "EOLs\n" - " -c g4 compress output with CCITT Group 4 encoding\n" -#endif -#ifdef LOGLUV_SUPPORT - " -c sgilog compress output with SGILOG encoding\n" -#endif -#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(LZMA_SUPPORT) || \ - defined(ZSTD_SUPPORT) || defined(WEBP_SUPPORT) || defined(JPEG_SUPPORT) || \ - defined(JBIG_SUPPORT) || defined(PACKBITS_SUPPORT) || \ - defined(CCITT_SUPPORT) || defined(LOGLUV_SUPPORT) || defined(LERC_SUPPORT) - " -c none use no compression algorithm on output\n" -#endif - "\n" - "Note that input filenames may be of the form filename,x,y,z\n" - "where x, y, and z specify image numbers in the filename to copy.\n" - "example: tiffcp -b esp.tif,1 esp.tif,0 test.tif\n" - " subtract 2nd image in esp.tif from 1st yielding result test.tif\n"; - -static void usage(int code) -{ - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; - - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); -} - -#define CopyField(tag, v) \ - do \ - { \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v); \ - } while (0) -#define CopyField2(tag, v1, v2) \ - do \ - { \ - if (TIFFGetField(in, tag, &v1, &v2)) \ - TIFFSetField(out, tag, v1, v2); \ - } while (0) -#define CopyField3(tag, v1, v2, v3) \ - do \ - { \ - if (TIFFGetField(in, tag, &v1, &v2, &v3)) \ - TIFFSetField(out, tag, v1, v2, v3); \ - } while (0) -#define CopyField4(tag, v1, v2, v3, v4) \ - do \ - { \ - if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) \ - TIFFSetField(out, tag, v1, v2, v3, v4); \ - } while (0) - -static void cpTag(TIFF *in, TIFF *out, uint16_t tag, uint16_t count, - TIFFDataType type) -{ - switch (type) - { - case TIFF_SHORT: - if (count == 1) - { - uint16_t shortv; - CopyField(tag, shortv); - } - else if (count == 2) - { - uint16_t shortv1, shortv2; - CopyField2(tag, shortv1, shortv2); - } - else if (count == 4) - { - uint16_t *tr, *tg, *tb, *ta; - CopyField4(tag, tr, tg, tb, ta); - } - else if (count == (uint16_t)-1) - { - uint16_t shortv1; - uint16_t *shortav; - CopyField2(tag, shortv1, shortav); - } - break; - case TIFF_LONG: - { - uint32_t longv; - CopyField(tag, longv); - } - break; - case TIFF_RATIONAL: - if (count == 1) - { - float floatv; - CopyField(tag, floatv); - } - else if (count == (uint16_t)-1) - { - float *floatav; - CopyField(tag, floatav); - } - break; - case TIFF_ASCII: - { - char *stringv; - CopyField(tag, stringv); - } - break; - case TIFF_DOUBLE: - if (count == 1) - { - double doublev; - CopyField(tag, doublev); - } - else if (count == (uint16_t)-1) - { - double *doubleav; - CopyField(tag, doubleav); - } - break; - default: - TIFFError(TIFFFileName(in), - "Data type %" PRIu16 " is not supported, tag %d skipped.", - tag, type); - } -} - -static const struct cpTag -{ - uint16_t tag; - uint16_t count; - TIFFDataType type; -} tags[] = { - {TIFFTAG_SUBFILETYPE, 1, TIFF_LONG}, - {TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT}, - {TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII}, - {TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII}, - {TIFFTAG_MAKE, 1, TIFF_ASCII}, - {TIFFTAG_MODEL, 1, TIFF_ASCII}, - {TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_PAGENAME, 1, TIFF_ASCII}, - {TIFFTAG_XPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_YPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT}, - {TIFFTAG_SOFTWARE, 1, TIFF_ASCII}, - {TIFFTAG_DATETIME, 1, TIFF_ASCII}, - {TIFFTAG_ARTIST, 1, TIFF_ASCII}, - {TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII}, - {TIFFTAG_WHITEPOINT, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_PRIMARYCHROMATICITIES, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT}, - {TIFFTAG_INKSET, 1, TIFF_SHORT}, - {TIFFTAG_DOTRANGE, 2, TIFF_SHORT}, - {TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII}, - {TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT}, - {TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT}, - {TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT}, - {TIFFTAG_REFERENCEBLACKWHITE, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_EXTRASAMPLES, (uint16_t)-1, TIFF_SHORT}, - {TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE}, - {TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE}, - {TIFFTAG_STONITS, 1, TIFF_DOUBLE}, +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing,", +"-c zip:3:p9 for Deflate encoding with maximum compression level and floating", +"point predictor.", +"", +"Note that input filenames may be of the form filename,x,y,z", +"where x, y, and z specify image numbers in the filename to copy.", +"example: tiffcp -c none -b esp.tif,1 esp.tif,0 test.tif", +" subtract 2nd image in esp.tif from 1st yielding uncompressed result test.tif", +NULL }; -#define NTAGS (sizeof(tags) / sizeof(tags[0])) -#define CopyTag(tag, count, type) cpTag(in, out, tag, count, type) +static void +usage(int code) +{ + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; -typedef int (*copyFunc)(TIFF *in, TIFF *out, uint32_t l, uint32_t w, - uint16_t samplesperpixel); -static copyFunc pickCopyFunc(TIFF *, TIFF *, uint16_t, uint16_t); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); +} + +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) +#define CopyField2(tag, v1, v2) \ + if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) +#define CopyField3(tag, v1, v2, v3) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) +#define CopyField4(tag, v1, v2, v3, v4) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) + +static void +cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) +{ + switch (type) { + case TIFF_SHORT: + if (count == 1) { + uint16 shortv; + CopyField(tag, shortv); + } else if (count == 2) { + uint16 shortv1, shortv2; + CopyField2(tag, shortv1, shortv2); + } else if (count == 4) { + uint16 *tr, *tg, *tb, *ta; + CopyField4(tag, tr, tg, tb, ta); + } else if (count == (uint16) -1) { + uint16 shortv1; + uint16* shortav; + CopyField2(tag, shortv1, shortav); + } + break; + case TIFF_LONG: + { uint32 longv; + CopyField(tag, longv); + } + break; + case TIFF_RATIONAL: + if (count == 1) { + float floatv; + CopyField(tag, floatv); + } else if (count == (uint16) -1) { + float* floatav; + CopyField(tag, floatav); + } + break; + case TIFF_ASCII: + { char* stringv; + CopyField(tag, stringv); + } + break; + case TIFF_DOUBLE: + if (count == 1) { + double doublev; + CopyField(tag, doublev); + } else if (count == (uint16) -1) { + double* doubleav; + CopyField(tag, doubleav); + } + break; + default: + TIFFError(TIFFFileName(in), + "Data type %d is not supported, tag %d skipped.", + tag, type); + } +} + +static struct cpTag { + uint16 tag; + uint16 count; + TIFFDataType type; +} tags[] = { + { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, + { TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT }, + { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, + { TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII }, + { TIFFTAG_MAKE, 1, TIFF_ASCII }, + { TIFFTAG_MODEL, 1, TIFF_ASCII }, + { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, (uint16) -1, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, + { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, +}; +#define NTAGS (sizeof (tags) / sizeof (tags[0])) + +#define CopyTag(tag, count, type) cpTag(in, out, tag, count, type) + +typedef int (*copyFunc) + (TIFF* in, TIFF* out, uint32 l, uint32 w, uint16 samplesperpixel); +static copyFunc pickCopyFunc(TIFF*, TIFF*, uint16, uint16); /* PODD */ -static int tiffcp(TIFF *in, TIFF *out) +static int +tiffcp(TIFF* in, TIFF* out) { - uint16_t bitspersample = 1, samplesperpixel = 1; - uint16_t input_compression, input_photometric = PHOTOMETRIC_MINISBLACK; - copyFunc cf; - uint32_t width, length; - const struct cpTag *p; + uint16 bitspersample = 1, samplesperpixel = 1; + uint16 input_compression, input_photometric = PHOTOMETRIC_MINISBLACK; + copyFunc cf; + uint32 width, length; + struct cpTag* p; - CopyField(TIFFTAG_IMAGEWIDTH, width); - CopyField(TIFFTAG_IMAGELENGTH, length); - CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample); - CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); - if (compression != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - else - CopyField(TIFFTAG_COMPRESSION, compression); - if (!TIFFIsCODECConfigured(compression)) - return FALSE; - TIFFGetFieldDefaulted(in, TIFFTAG_COMPRESSION, &input_compression); - TIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric); - if (input_compression == COMPRESSION_JPEG) - { - /* Force conversion to RGB */ - TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - } - else if (input_photometric == PHOTOMETRIC_YCBCR) - { - /* Otherwise, can't handle subsampled input */ - uint16_t subsamplinghor, subsamplingver; + CopyField(TIFFTAG_IMAGEWIDTH, width); + CopyField(TIFFTAG_IMAGELENGTH, length); + CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample); + CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); + if (compression != (uint16)-1) + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + else + CopyField(TIFFTAG_COMPRESSION, compression); + TIFFGetFieldDefaulted(in, TIFFTAG_COMPRESSION, &input_compression); + TIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric); + if (input_compression == COMPRESSION_JPEG) { + /* Force conversion to RGB */ + TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } else if (input_photometric == PHOTOMETRIC_YCBCR) { + /* Otherwise, can't handle subsampled input */ + uint16 subsamplinghor,subsamplingver; - TIFFGetFieldDefaulted(in, TIFFTAG_YCBCRSUBSAMPLING, &subsamplinghor, - &subsamplingver); - if (subsamplinghor != 1 || subsamplingver != 1) - { - fprintf(stderr, - "tiffcp: %s: Can't copy/convert subsampled image.\n", - TIFFFileName(in)); - return FALSE; - } - } - if (compression == COMPRESSION_JPEG) - { - if (input_photometric == PHOTOMETRIC_RGB && - jpegcolormode == JPEGCOLORMODE_RGB) - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); - else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); - } - else if (compression == COMPRESSION_SGILOG || - compression == COMPRESSION_SGILOG24) - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - samplesperpixel == 1 ? PHOTOMETRIC_LOGL - : PHOTOMETRIC_LOGLUV); - else if (input_compression == COMPRESSION_JPEG && samplesperpixel == 3) - { - /* RGB conversion was forced above - hence the output will be of the same type */ - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); - } - else - CopyTag(TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT); - if (fillorder != 0) - TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); - else - CopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT); - /* - * Will copy `Orientation' tag from input image - */ - TIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation); - TIFFSetField(out, TIFFTAG_ORIENTATION, orientation); - /* - * Choose tiles/strip for the output image according to - * the command line arguments (-tiles, -strips) and the - * structure of the input image. - */ - if (outtiled == -1) - outtiled = TIFFIsTiled(in); - if (outtiled) - { - /* - * Setup output file's tile width&height. If either - * is not specified, use either the value from the - * input image or, if nothing is defined, use the - * library default. - */ - if (tilewidth == (uint32_t)-1) - TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); - if (tilelength == (uint32_t)-1) - TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); - TIFFDefaultTileSize(out, &tilewidth, &tilelength); - TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); - TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); - } - else - { - /* - * RowsPerStrip is left unspecified: use either the - * value from the input image or, if nothing is defined, - * use the library default. - */ - if (rowsperstrip == (uint32_t)0) - { - if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) - { - rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); - } - if (rowsperstrip > length && rowsperstrip != (uint32_t)-1) - rowsperstrip = length; - } - else if (rowsperstrip == (uint32_t)-1) - rowsperstrip = length; - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - } - if (config != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); - else - CopyField(TIFFTAG_PLANARCONFIG, config); - if (samplesperpixel <= 4) - CopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT); - CopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT); - /* SMinSampleValue & SMaxSampleValue */ - switch (compression) - { - case COMPRESSION_JPEG: - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); - break; - case COMPRESSION_JBIG: - CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); - CopyTag(TIFFTAG_FAXDCS, 1, TIFF_ASCII); - break; - case COMPRESSION_LERC: - if (max_z_error > 0) - { - if (TIFFSetField(out, TIFFTAG_LERC_MAXZERROR, max_z_error) != 1) - { - return FALSE; - } - } - if (subcodec != -1) - { - if (TIFFSetField(out, TIFFTAG_LERC_ADD_COMPRESSION, subcodec) != - 1) - { - return FALSE; - } - } - if (preset != -1) - { - switch (subcodec) - { - case LERC_ADD_COMPRESSION_DEFLATE: - if (TIFFSetField(out, TIFFTAG_ZIPQUALITY, preset) != 1) + TIFFGetFieldDefaulted(in, TIFFTAG_YCBCRSUBSAMPLING, + &subsamplinghor, &subsamplingver); + if (subsamplinghor!=1 || subsamplingver!=1) { + fprintf(stderr, "tiffcp: %s: Can't copy/convert subsampled image.\n", + TIFFFileName(in)); + return FALSE; + } + } + if (compression == COMPRESSION_JPEG) { + if (input_photometric == PHOTOMETRIC_RGB && + jpegcolormode == JPEGCOLORMODE_RGB) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); + } + else if (compression == COMPRESSION_SGILOG + || compression == COMPRESSION_SGILOG24) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, + samplesperpixel == 1 ? + PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); + else if (input_compression == COMPRESSION_JPEG && + samplesperpixel == 3 ) { + /* RGB conversion was forced above + hence the output will be of the same type */ + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); + } + else + CopyTag(TIFFTAG_PHOTOMETRIC, 1, TIFF_SHORT); + if (fillorder != 0) + TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); + else + CopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT); + /* + * Will copy `Orientation' tag from input image + */ + TIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation); + switch (orientation) { + case ORIENTATION_BOTRIGHT: + case ORIENTATION_RIGHTBOT: /* XXX */ + TIFFWarning(TIFFFileName(in), "using bottom-left orientation"); + orientation = ORIENTATION_BOTLEFT; + /* fall through... */ + case ORIENTATION_LEFTBOT: /* XXX */ + case ORIENTATION_BOTLEFT: + break; + case ORIENTATION_TOPRIGHT: + case ORIENTATION_RIGHTTOP: /* XXX */ + default: + TIFFWarning(TIFFFileName(in), "using top-left orientation"); + orientation = ORIENTATION_TOPLEFT; + /* fall through... */ + case ORIENTATION_LEFTTOP: /* XXX */ + case ORIENTATION_TOPLEFT: + break; + } + TIFFSetField(out, TIFFTAG_ORIENTATION, orientation); + /* + * Choose tiles/strip for the output image according to + * the command line arguments (-tiles, -strips) and the + * structure of the input image. + */ + if (outtiled == -1) + outtiled = TIFFIsTiled(in); + if (outtiled) { + /* + * Setup output file's tile width&height. If either + * is not specified, use either the value from the + * input image or, if nothing is defined, use the + * library default. + */ + if (tilewidth == (uint32) -1) + TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); + if (tilelength == (uint32) -1) + TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); + TIFFDefaultTileSize(out, &tilewidth, &tilelength); + TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); + TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); + } else { + /* + * RowsPerStrip is left unspecified: use either the + * value from the input image or, if nothing is defined, + * use the library default. + */ + if (rowsperstrip == (uint32) 0) { + if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, + &rowsperstrip)) { + rowsperstrip = + TIFFDefaultStripSize(out, rowsperstrip); + } + if (rowsperstrip > length && rowsperstrip != (uint32)-1) + rowsperstrip = length; + } + else if (rowsperstrip == (uint32) -1) + rowsperstrip = length; + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + } + if (config != (uint16) -1) + TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + else + CopyField(TIFFTAG_PLANARCONFIG, config); + if (samplesperpixel <= 4) + CopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT); + CopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT); +/* SMinSampleValue & SMaxSampleValue */ + switch (compression) { + case COMPRESSION_JPEG: + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, jpegcolormode); + break; + case COMPRESSION_JBIG: + CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); + CopyTag(TIFFTAG_FAXDCS, 1, TIFF_ASCII); + break; + case COMPRESSION_LZW: + case COMPRESSION_ADOBE_DEFLATE: + case COMPRESSION_DEFLATE: + case COMPRESSION_LZMA: + case COMPRESSION_ZSTD: + if (predictor != (uint16)-1) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + else + CopyField(TIFFTAG_PREDICTOR, predictor); + if( compression == COMPRESSION_ADOBE_DEFLATE || + compression == COMPRESSION_DEFLATE ) { - return FALSE; + if( subcodec != -1 ) + { + if( TIFFSetField(out, TIFFTAG_DEFLATE_SUBCODEC, subcodec) != 1 ) + { + return FALSE; + } + } } - break; - case LERC_ADD_COMPRESSION_ZSTD: - if (TIFFSetField(out, TIFFTAG_ZSTD_LEVEL, preset) != 1) - { - return FALSE; + /*fallthrough*/ + case COMPRESSION_WEBP: + if (preset != -1) { + if (compression == COMPRESSION_ADOBE_DEFLATE + || compression == COMPRESSION_DEFLATE) + TIFFSetField(out, TIFFTAG_ZIPQUALITY, preset); + else if (compression == COMPRESSION_LZMA) + TIFFSetField(out, TIFFTAG_LZMAPRESET, preset); + else if (compression == COMPRESSION_ZSTD) + TIFFSetField(out, TIFFTAG_ZSTD_LEVEL, preset); + else if (compression == COMPRESSION_WEBP) { + if (preset == 100) { + TIFFSetField(out, TIFFTAG_WEBP_LOSSLESS, TRUE); + } else { + TIFFSetField(out, TIFFTAG_WEBP_LEVEL, preset); + } + } } - break; - } - } - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - case COMPRESSION_LZMA: - case COMPRESSION_ZSTD: - if (predictor != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - else if (input_compression == COMPRESSION_LZW || - input_compression == COMPRESSION_ADOBE_DEFLATE || - input_compression == COMPRESSION_DEFLATE || - input_compression == COMPRESSION_LZMA || - input_compression == COMPRESSION_ZSTD) - { - CopyField(TIFFTAG_PREDICTOR, predictor); - } - if (compression == COMPRESSION_ADOBE_DEFLATE || - compression == COMPRESSION_DEFLATE) - { - if (subcodec != -1) - { - if (TIFFSetField(out, TIFFTAG_DEFLATE_SUBCODEC, subcodec) != - 1) - { - return FALSE; - } - } - } - /*fallthrough*/ - case COMPRESSION_WEBP: - if (preset != -1) - { - if (preset == 100) - { - TIFFSetField(out, TIFFTAG_WEBP_LOSSLESS, TRUE); - } - else - { - TIFFSetField(out, TIFFTAG_WEBP_LEVEL, preset); - } - } - break; - case COMPRESSION_CCITTFAX3: - case COMPRESSION_CCITTFAX4: - if (compression == COMPRESSION_CCITTFAX3) - { - if (g3opts != (uint32_t)-1) - TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); - else if (input_compression == COMPRESSION_CCITTFAX3) - CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); - } - else if (input_compression == COMPRESSION_CCITTFAX4) - CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); - if (input_compression == COMPRESSION_CCITTFAX3 || - input_compression == COMPRESSION_CCITTFAX4) - { - CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); - CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); - CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); - } - CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); - break; - } - { - uint32_t len32; - void **data; - if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) - TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); - } - { - uint16_t ninks; - const char *inknames; - if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) - { - TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); - if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) - { - int inknameslen = strlen(inknames) + 1; - const char *cp = inknames; - while (ninks > 1) - { - cp = strchr(cp, '\0'); - cp++; - inknameslen += (strlen(cp) + 1); - ninks--; - } - TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); - } - } - } - { - unsigned short pg0, pg1; + break; + case COMPRESSION_CCITTFAX3: + case COMPRESSION_CCITTFAX4: + if (compression == COMPRESSION_CCITTFAX3) { + if (g3opts != (uint32) -1) + TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, + g3opts); + else + CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); + } else + CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); + CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); + CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); + break; + } + { + uint32 len32; + void** data; + if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) + TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); + } + { + uint16 ninks; + const char* inknames; + if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { + TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); + if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) { + int inknameslen = strlen(inknames) + 1; + const char* cp = inknames; + while (ninks > 1) { + cp = strchr(cp, '\0'); + cp++; + inknameslen += (strlen(cp) + 1); + ninks--; + } + TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); + } + } + } + { + unsigned short pg0, pg1; - if (pageInSeq == 1) - { - if (pageNum < 0) /* only one input file */ - { - if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) - TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); - } - else - TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); - } - else - { - if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) - { - if (pageNum < 0) /* only one input file */ - TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); - else - TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); - } - } - } + if (pageInSeq == 1) { + if (pageNum < 0) /* only one input file */ { + if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) + TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); + } else + TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); - for (p = tags; p < &tags[NTAGS]; p++) - CopyTag(p->tag, p->count, p->type); + } else { + if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) { + if (pageNum < 0) /* only one input file */ + TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); + else + TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); + } + } + } - cf = pickCopyFunc(in, out, bitspersample, samplesperpixel); - return (cf ? (*cf)(in, out, length, width, samplesperpixel) : FALSE); + for (p = tags; p < &tags[NTAGS]; p++) + CopyTag(p->tag, p->count, p->type); + + cf = pickCopyFunc(in, out, bitspersample, samplesperpixel); + return (cf ? (*cf)(in, out, length, width, samplesperpixel) : FALSE); } /* * Copy Functions. */ -#define DECLAREcpFunc(x) \ - static int x(TIFF *in, TIFF *out, uint32_t imagelength, \ - uint32_t imagewidth, tsample_t spp) +#define DECLAREcpFunc(x) \ +static int x(TIFF* in, TIFF* out, \ + uint32 imagelength, uint32 imagewidth, tsample_t spp) -#define DECLAREreadFunc(x) \ - static int x(TIFF *in, uint8_t *buf, uint32_t imagelength, \ - uint32_t imagewidth, tsample_t spp) -typedef int (*readFunc)(TIFF *, uint8_t *, uint32_t, uint32_t, tsample_t); +#define DECLAREreadFunc(x) \ +static int x(TIFF* in, \ + uint8* buf, uint32 imagelength, uint32 imagewidth, tsample_t spp) +typedef int (*readFunc)(TIFF*, uint8*, uint32, uint32, tsample_t); -#define DECLAREwriteFunc(x) \ - static int x(TIFF *out, uint8_t *buf, uint32_t imagelength, \ - uint32_t imagewidth, tsample_t spp) -typedef int (*writeFunc)(TIFF *, uint8_t *, uint32_t, uint32_t, tsample_t); +#define DECLAREwriteFunc(x) \ +static int x(TIFF* out, \ + uint8* buf, uint32 imagelength, uint32 imagewidth, tsample_t spp) +typedef int (*writeFunc)(TIFF*, uint8*, uint32, uint32, tsample_t); /* * Contig -> contig by scanline for rows/strip change. */ DECLAREcpFunc(cpContig2ContigByRow) { - tsize_t scanlinesize = TIFFScanlineSize(in); - tdata_t buf; - uint32_t row; + tsize_t scanlinesize = TIFFScanlineSize(in); + tdata_t buf; + uint32 row; - buf = limitMalloc(scanlinesize); - if (!buf) - return 0; - _TIFFmemset(buf, 0, scanlinesize); - (void)imagewidth; - (void)spp; - for (row = 0; row < imagelength; row++) - { - if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), "Error, can't read scanline %" PRIu32, - row); - goto bad; - } - if (TIFFWriteScanline(out, buf, row, 0) < 0) - { - TIFFError(TIFFFileName(out), "Error, can't write scanline %" PRIu32, - row); - goto bad; - } - } - _TIFFfree(buf); - return 1; + buf = limitMalloc(scanlinesize); + if (!buf) + return 0; + _TIFFmemset(buf, 0, scanlinesize); + (void) imagewidth; (void) spp; + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read scanline %lu", + (unsigned long) row); + goto bad; + } + if (TIFFWriteScanline(out, buf, row, 0) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write scanline %lu", + (unsigned long) row); + goto bad; + } + } + _TIFFfree(buf); + return 1; bad: - _TIFFfree(buf); - return 0; + _TIFFfree(buf); + return 0; } -typedef void biasFn(void *image, void *bias, uint32_t pixels); -#define subtract(bits) \ - static void subtract##bits(void *i, void *b, uint32_t pixels) \ - { \ - uint##bits##_t *image = i; \ - uint##bits##_t *bias = b; \ - while (pixels--) \ - { \ - *image = *image > *bias ? *image - *bias : 0; \ - image++, bias++; \ - } \ - } +typedef void biasFn (void *image, void *bias, uint32 pixels); -subtract(8) subtract(16) subtract(32) +#define subtract(bits) \ +static void subtract##bits (void *i, void *b, uint32 pixels)\ +{\ + uint##bits *image = i;\ + uint##bits *bias = b;\ + while (pixels--) {\ + *image = *image > *bias ? *image-*bias : 0;\ + image++, bias++; \ + } \ +} - static biasFn *lineSubtractFn(unsigned bits) +subtract(8) +subtract(16) +subtract(32) + +static biasFn *lineSubtractFn (unsigned bits) { - switch (bits) - { - case 8: - return subtract8; - case 16: - return subtract16; - case 32: - return subtract32; - } - return NULL; + switch (bits) { + case 8: return subtract8; + case 16: return subtract16; + case 32: return subtract32; + } + return NULL; } /* @@ -1211,133 +985,121 @@ subtract(8) subtract(16) subtract(32) */ DECLAREcpFunc(cpBiasedContig2Contig) { - if (spp == 1) - { - tsize_t biasSize = TIFFScanlineSize(bias); - tsize_t bufSize = TIFFScanlineSize(in); - tdata_t buf, biasBuf; - uint32_t biasWidth = 0, biasLength = 0; - TIFFGetField(bias, TIFFTAG_IMAGEWIDTH, &biasWidth); - TIFFGetField(bias, TIFFTAG_IMAGELENGTH, &biasLength); - if (biasSize == bufSize && imagelength == biasLength && - imagewidth == biasWidth) - { - uint16_t sampleBits = 0; - biasFn *subtractLine; - TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &sampleBits); - subtractLine = lineSubtractFn(sampleBits); - if (subtractLine) - { - uint32_t row; - buf = limitMalloc(bufSize); - biasBuf = limitMalloc(bufSize); - for (row = 0; row < imagelength; row++) - { - if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read scanline %" PRIu32, row); - goto bad; - } - if (TIFFReadScanline(bias, biasBuf, row, 0) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read biased scanline %" PRIu32, - row); - goto bad; - } - subtractLine(buf, biasBuf, imagewidth); - if (TIFFWriteScanline(out, buf, row, 0) < 0) - { - TIFFError(TIFFFileName(out), - "Error, can't write scanline %" PRIu32, row); - goto bad; - } - } + if (spp == 1) { + tsize_t biasSize = TIFFScanlineSize(bias); + tsize_t bufSize = TIFFScanlineSize(in); + tdata_t buf, biasBuf; + uint32 biasWidth = 0, biasLength = 0; + TIFFGetField(bias, TIFFTAG_IMAGEWIDTH, &biasWidth); + TIFFGetField(bias, TIFFTAG_IMAGELENGTH, &biasLength); + if (biasSize == bufSize && + imagelength == biasLength && imagewidth == biasWidth) { + uint16 sampleBits = 0; + biasFn *subtractLine; + TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &sampleBits); + subtractLine = lineSubtractFn (sampleBits); + if (subtractLine) { + uint32 row; + buf = limitMalloc(bufSize); + biasBuf = limitMalloc(bufSize); + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(in, buf, row, 0) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read scanline %lu", + (unsigned long) row); + goto bad; + } + if (TIFFReadScanline(bias, biasBuf, row, 0) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read biased scanline %lu", + (unsigned long) row); + goto bad; + } + subtractLine (buf, biasBuf, imagewidth); + if (TIFFWriteScanline(out, buf, row, 0) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write scanline %lu", + (unsigned long) row); + goto bad; + } + } + + _TIFFfree(buf); + _TIFFfree(biasBuf); + TIFFSetDirectory(bias, + TIFFCurrentDirectory(bias)); /* rewind */ + return 1; +bad: + _TIFFfree(buf); + _TIFFfree(biasBuf); + return 0; + } else { + TIFFError(TIFFFileName(in), + "No support for biasing %d bit pixels\n", + sampleBits); + return 0; + } + } + TIFFError(TIFFFileName(in), + "Bias image %s,%d\nis not the same size as %s,%d\n", + TIFFFileName(bias), TIFFCurrentDirectory(bias), + TIFFFileName(in), TIFFCurrentDirectory(in)); + return 0; + } else { + TIFFError(TIFFFileName(in), + "Can't bias %s,%d as it has >1 Sample/Pixel\n", + TIFFFileName(in), TIFFCurrentDirectory(in)); + return 0; + } - _TIFFfree(buf); - _TIFFfree(biasBuf); - TIFFSetDirectory(bias, TIFFCurrentDirectory(bias)); /* rewind */ - return 1; - bad: - _TIFFfree(buf); - _TIFFfree(biasBuf); - return 0; - } - else - { - TIFFError(TIFFFileName(in), - "No support for biasing %" PRIu16 " bit pixels\n", - sampleBits); - return 0; - } - } - TIFFError(TIFFFileName(in), - "Bias image %s,%" PRIu16 - "\nis not the same size as %s,%" PRIu16 "\n", - TIFFFileName(bias), TIFFCurrentDirectory(bias), - TIFFFileName(in), TIFFCurrentDirectory(in)); - return 0; - } - else - { - TIFFError(TIFFFileName(in), - "Can't bias %s,%" PRIu16 " as it has >1 Sample/Pixel\n", - TIFFFileName(in), TIFFCurrentDirectory(in)); - return 0; - } } + /* * Strip -> strip for change in encoding. */ DECLAREcpFunc(cpDecodedStrips) { - tsize_t stripsize = TIFFStripSize(in); - tdata_t buf = limitMalloc(stripsize); + tsize_t stripsize = TIFFStripSize(in); + tdata_t buf = limitMalloc(stripsize); - (void)imagewidth; - (void)spp; - if (buf) - { - tstrip_t s, ns = TIFFNumberOfStrips(in); - uint32_t row = 0; - _TIFFmemset(buf, 0, stripsize); - for (s = 0; s < ns && row < imagelength; s++) - { - tsize_t cc = (row + rowsperstrip > imagelength) - ? TIFFVStripSize(in, imagelength - row) - : stripsize; - if (TIFFReadEncodedStrip(in, s, buf, cc) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), "Error, can't read strip %" PRIu32, - s); - goto bad; - } - if (TIFFWriteEncodedStrip(out, s, buf, cc) < 0) - { - TIFFError(TIFFFileName(out), - "Error, can't write strip %" PRIu32, s); - goto bad; - } - row += rowsperstrip; - } - _TIFFfree(buf); - return 1; - } - else - { - TIFFError( - TIFFFileName(in), - "Error, can't allocate memory buffer of size %" TIFF_SSIZE_FORMAT - " to read strips", - stripsize); - return 0; - } + (void) imagewidth; (void) spp; + if (buf) { + tstrip_t s, ns = TIFFNumberOfStrips(in); + uint32 row = 0; + _TIFFmemset(buf, 0, stripsize); + for (s = 0; s < ns && row < imagelength; s++) { + tsize_t cc = (row + rowsperstrip > imagelength) ? + TIFFVStripSize(in, imagelength - row) : stripsize; + if (TIFFReadEncodedStrip(in, s, buf, cc) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read strip %lu", + (unsigned long) s); + goto bad; + } + if (TIFFWriteEncodedStrip(out, s, buf, cc) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write strip %lu", + (unsigned long) s); + goto bad; + } + row += rowsperstrip; + } + _TIFFfree(buf); + return 1; + } else { + TIFFError(TIFFFileName(in), + "Error, can't allocate memory buffer of size %lu " + "to read strips", (unsigned long) stripsize); + return 0; + } bad: - _TIFFfree(buf); - return 0; + _TIFFfree(buf); + return 0; } /* @@ -1345,39 +1107,37 @@ bad: */ DECLAREcpFunc(cpSeparate2SeparateByRow) { - tsize_t scanlinesize = TIFFScanlineSize(in); - tdata_t buf; - uint32_t row; - tsample_t s; + tsize_t scanlinesize = TIFFScanlineSize(in); + tdata_t buf; + uint32 row; + tsample_t s; - (void)imagewidth; - buf = limitMalloc(scanlinesize); - if (!buf) - return 0; - _TIFFmemset(buf, 0, scanlinesize); - for (s = 0; s < spp; s++) - { - for (row = 0; row < imagelength; row++) - { - if (TIFFReadScanline(in, buf, row, s) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read scanline %" PRIu32, row); - goto bad; - } - if (TIFFWriteScanline(out, buf, row, s) < 0) - { - TIFFError(TIFFFileName(out), - "Error, can't write scanline %" PRIu32, row); - goto bad; - } - } - } - _TIFFfree(buf); - return 1; + (void) imagewidth; + buf = limitMalloc(scanlinesize); + if (!buf) + return 0; + _TIFFmemset(buf, 0, scanlinesize); + for (s = 0; s < spp; s++) { + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(in, buf, row, s) < 0 && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read scanline %lu", + (unsigned long) row); + goto bad; + } + if (TIFFWriteScanline(out, buf, row, s) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write scanline %lu", + (unsigned long) row); + goto bad; + } + } + } + _TIFFfree(buf); + return 1; bad: - _TIFFfree(buf); - return 0; + _TIFFfree(buf); + return 0; } /* @@ -1385,68 +1145,62 @@ bad: */ DECLAREcpFunc(cpContig2SeparateByRow) { - tsize_t scanlinesizein = TIFFScanlineSize(in); - tsize_t scanlinesizeout = TIFFScanlineSize(out); - tdata_t inbuf; - tdata_t outbuf; - register uint8_t *inp, *outp; - register uint32_t n; - uint32_t row; - tsample_t s; - uint16_t bps = 0; + tsize_t scanlinesizein = TIFFScanlineSize(in); + tsize_t scanlinesizeout = TIFFScanlineSize(out); + tdata_t inbuf; + tdata_t outbuf; + register uint8 *inp, *outp; + register uint32 n; + uint32 row; + tsample_t s; + uint16 bps = 0; - (void)TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); - if (bps != 8) - { - TIFFError(TIFFFileName(in), - "Error, can only handle BitsPerSample=8 in %s", - "cpContig2SeparateByRow"); - return 0; - } - - inbuf = limitMalloc(scanlinesizein); - outbuf = limitMalloc(scanlinesizeout); - if (!inbuf || !outbuf) - goto bad; - _TIFFmemset(inbuf, 0, scanlinesizein); - _TIFFmemset(outbuf, 0, scanlinesizeout); - /* unpack channels */ - for (s = 0; s < spp; s++) - { - for (row = 0; row < imagelength; row++) + (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); + if( bps != 8 ) { - if (TIFFReadScanline(in, inbuf, row, 0) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read scanline %" PRIu32, row); - goto bad; - } - inp = ((uint8_t *)inbuf) + s; - outp = (uint8_t *)outbuf; - for (n = imagewidth; n-- > 0;) - { - *outp++ = *inp; - inp += spp; - } - if (TIFFWriteScanline(out, outbuf, row, s) < 0) - { - TIFFError(TIFFFileName(out), - "Error, can't write scanline %" PRIu32, row); - goto bad; - } + TIFFError(TIFFFileName(in), + "Error, can only handle BitsPerSample=8 in %s", + "cpContig2SeparateByRow"); + return 0; } - } - if (inbuf) - _TIFFfree(inbuf); - if (outbuf) - _TIFFfree(outbuf); - return 1; + + inbuf = limitMalloc(scanlinesizein); + outbuf = limitMalloc(scanlinesizeout); + if (!inbuf || !outbuf) + goto bad; + _TIFFmemset(inbuf, 0, scanlinesizein); + _TIFFmemset(outbuf, 0, scanlinesizeout); + /* unpack channels */ + for (s = 0; s < spp; s++) { + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(in, inbuf, row, 0) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read scanline %lu", + (unsigned long) row); + goto bad; + } + inp = ((uint8*)inbuf) + s; + outp = (uint8*)outbuf; + for (n = imagewidth; n-- > 0;) { + *outp++ = *inp; + inp += spp; + } + if (TIFFWriteScanline(out, outbuf, row, s) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write scanline %lu", + (unsigned long) row); + goto bad; + } + } + } + if (inbuf) _TIFFfree(inbuf); + if (outbuf) _TIFFfree(outbuf); + return 1; bad: - if (inbuf) - _TIFFfree(inbuf); - if (outbuf) - _TIFFfree(outbuf); - return 0; + if (inbuf) _TIFFfree(inbuf); + if (outbuf) _TIFFfree(outbuf); + return 0; } /* @@ -1454,597 +1208,565 @@ bad: */ DECLAREcpFunc(cpSeparate2ContigByRow) { - tsize_t scanlinesizein = TIFFScanlineSize(in); - tsize_t scanlinesizeout = TIFFScanlineSize(out); - tdata_t inbuf; - tdata_t outbuf; - register uint8_t *inp, *outp; - register uint32_t n; - uint32_t row; - tsample_t s; - uint16_t bps = 0; + tsize_t scanlinesizein = TIFFScanlineSize(in); + tsize_t scanlinesizeout = TIFFScanlineSize(out); + tdata_t inbuf; + tdata_t outbuf; + register uint8 *inp, *outp; + register uint32 n; + uint32 row; + tsample_t s; + uint16 bps = 0; - (void)TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); - if (bps != 8) - { - TIFFError(TIFFFileName(in), - "Error, can only handle BitsPerSample=8 in %s", - "cpSeparate2ContigByRow"); - return 0; - } - - inbuf = limitMalloc(scanlinesizein); - outbuf = limitMalloc(scanlinesizeout); - if (!inbuf || !outbuf) - goto bad; - _TIFFmemset(inbuf, 0, scanlinesizein); - _TIFFmemset(outbuf, 0, scanlinesizeout); - for (row = 0; row < imagelength; row++) - { - /* merge channels */ - for (s = 0; s < spp; s++) - { - if (TIFFReadScanline(in, inbuf, row, s) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read scanline %" PRIu32, row); - goto bad; - } - inp = (uint8_t *)inbuf; - outp = ((uint8_t *)outbuf) + s; - for (n = imagewidth; n-- > 0;) - { - *outp = *inp++; - outp += spp; - } - } - if (TIFFWriteScanline(out, outbuf, row, 0) < 0) - { - TIFFError(TIFFFileName(out), "Error, can't write scanline %" PRIu32, - row); - goto bad; - } - } - if (inbuf) - _TIFFfree(inbuf); - if (outbuf) - _TIFFfree(outbuf); - return 1; -bad: - if (inbuf) - _TIFFfree(inbuf); - if (outbuf) - _TIFFfree(outbuf); - return 0; -} - -static void cpStripToTile(uint8_t *out, uint8_t *in, uint32_t rows, - uint32_t cols, int outskew, int64_t inskew) -{ - while (rows-- > 0) - { - uint32_t j = cols; - while (j-- > 0) - *out++ = *in++; - out += outskew; - in += inskew; - } -} - -static void cpContigBufToSeparateBuf(uint8_t *out, uint8_t *in, uint32_t rows, - uint32_t cols, int outskew, int inskew, - tsample_t spp, int bytes_per_sample) -{ - while (rows-- > 0) - { - uint32_t j = cols; - while (j-- > 0) - { - int n = bytes_per_sample; - - while (n--) - { - *out++ = *in++; - } - in += (spp - 1) * bytes_per_sample; - } - out += outskew; - in += inskew; - } -} - -static void cpSeparateBufToContigBuf(uint8_t *out, uint8_t *in, uint32_t rows, - uint32_t cols, int outskew, int inskew, - tsample_t spp, int bytes_per_sample) -{ - while (rows-- > 0) - { - uint32_t j = cols; - while (j-- > 0) - { - int n = bytes_per_sample; - - while (n--) - { - *out++ = *in++; - } - out += (spp - 1) * bytes_per_sample; - } - out += outskew; - in += inskew; - } -} - -static int cpImage(TIFF *in, TIFF *out, readFunc fin, writeFunc fout, - uint32_t imagelength, uint32_t imagewidth, tsample_t spp) -{ - int status = 0; - tdata_t buf = NULL; - tsize_t scanlinesize = TIFFRasterScanlineSize(in); - tsize_t bytes = scanlinesize * (tsize_t)imagelength; - /* - * XXX: Check for integer overflow. - */ - if (scanlinesize && imagelength && - bytes / (tsize_t)imagelength == scanlinesize) - { - buf = limitMalloc(bytes); - if (buf) - { - if ((*fin)(in, (uint8_t *)buf, imagelength, imagewidth, spp)) - { - status = - (*fout)(out, (uint8_t *)buf, imagelength, imagewidth, spp); - } - _TIFFfree(buf); - } - else + (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); + if( bps != 8 ) { TIFFError(TIFFFileName(in), - "Error, can't allocate space for image buffer"); + "Error, can only handle BitsPerSample=8 in %s", + "cpSeparate2ContigByRow"); + return 0; } - } - else - { - TIFFError(TIFFFileName(in), "Error, no space for image buffer"); - } - return status; + inbuf = limitMalloc(scanlinesizein); + outbuf = limitMalloc(scanlinesizeout); + if (!inbuf || !outbuf) + goto bad; + _TIFFmemset(inbuf, 0, scanlinesizein); + _TIFFmemset(outbuf, 0, scanlinesizeout); + for (row = 0; row < imagelength; row++) { + /* merge channels */ + for (s = 0; s < spp; s++) { + if (TIFFReadScanline(in, inbuf, row, s) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read scanline %lu", + (unsigned long) row); + goto bad; + } + inp = (uint8*)inbuf; + outp = ((uint8*)outbuf) + s; + for (n = imagewidth; n-- > 0;) { + *outp = *inp++; + outp += spp; + } + } + if (TIFFWriteScanline(out, outbuf, row, 0) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write scanline %lu", + (unsigned long) row); + goto bad; + } + } + if (inbuf) _TIFFfree(inbuf); + if (outbuf) _TIFFfree(outbuf); + return 1; +bad: + if (inbuf) _TIFFfree(inbuf); + if (outbuf) _TIFFfree(outbuf); + return 0; +} + +static void +cpStripToTile(uint8* out, uint8* in, + uint32 rows, uint32 cols, int outskew, int64 inskew) +{ + while (rows-- > 0) { + uint32 j = cols; + while (j-- > 0) + *out++ = *in++; + out += outskew; + in += inskew; + } +} + +static void +cpContigBufToSeparateBuf(uint8* out, uint8* in, + uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp, + int bytes_per_sample ) +{ + while (rows-- > 0) { + uint32 j = cols; + while (j-- > 0) + { + int n = bytes_per_sample; + + while( n-- ) { + *out++ = *in++; + } + in += (spp-1) * bytes_per_sample; + } + out += outskew; + in += inskew; + } +} + +static void +cpSeparateBufToContigBuf(uint8* out, uint8* in, + uint32 rows, uint32 cols, int outskew, int inskew, tsample_t spp, + int bytes_per_sample) +{ + while (rows-- > 0) { + uint32 j = cols; + while (j-- > 0) { + int n = bytes_per_sample; + + while( n-- ) { + *out++ = *in++; + } + out += (spp-1)*bytes_per_sample; + } + out += outskew; + in += inskew; + } +} + +static int +cpImage(TIFF* in, TIFF* out, readFunc fin, writeFunc fout, + uint32 imagelength, uint32 imagewidth, tsample_t spp) +{ + int status = 0; + tdata_t buf = NULL; + tsize_t scanlinesize = TIFFRasterScanlineSize(in); + tsize_t bytes = scanlinesize * (tsize_t)imagelength; + /* + * XXX: Check for integer overflow. + */ + if (scanlinesize + && imagelength + && bytes / (tsize_t)imagelength == scanlinesize) { + buf = limitMalloc(bytes); + if (buf) { + if ((*fin)(in, (uint8*)buf, imagelength, + imagewidth, spp)) { + status = (*fout)(out, (uint8*)buf, + imagelength, imagewidth, spp); + } + _TIFFfree(buf); + } else { + TIFFError(TIFFFileName(in), + "Error, can't allocate space for image buffer"); + } + } else { + TIFFError(TIFFFileName(in), "Error, no space for image buffer"); + } + + return status; } DECLAREreadFunc(readContigStripsIntoBuffer) { - tsize_t scanlinesize = TIFFScanlineSize(in); - uint8_t *bufp = buf; - uint32_t row; + tsize_t scanlinesize = TIFFScanlineSize(in); + uint8* bufp = buf; + uint32 row; - (void)imagewidth; - (void)spp; - for (row = 0; row < imagelength; row++) - { - if (TIFFReadScanline(in, (tdata_t)bufp, row, 0) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), "Error, can't read scanline %" PRIu32, - row); - return 0; - } - bufp += scanlinesize; - } + (void) imagewidth; (void) spp; + for (row = 0; row < imagelength; row++) { + if (TIFFReadScanline(in, (tdata_t) bufp, row, 0) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read scanline %lu", + (unsigned long) row); + return 0; + } + bufp += scanlinesize; + } - return 1; + return 1; } DECLAREreadFunc(readSeparateStripsIntoBuffer) { - int status = 1; - tsize_t scanlinesize = TIFFScanlineSize(in); - tdata_t scanline; - if (!scanlinesize) - return 0; + int status = 1; + tsize_t scanlinesize = TIFFScanlineSize(in); + tdata_t scanline; + if (!scanlinesize) + return 0; - scanline = limitMalloc(scanlinesize); - if (!scanline) - return 0; - _TIFFmemset(scanline, 0, scanlinesize); - (void)imagewidth; - if (scanline) - { - uint8_t *bufp = (uint8_t *)buf; - uint32_t row; - tsample_t s; - for (row = 0; row < imagelength; row++) - { - /* merge channels */ - for (s = 0; s < spp; s++) - { - uint8_t *bp = bufp + s; - tsize_t n = scanlinesize; - uint8_t *sbuf = scanline; + scanline = limitMalloc(scanlinesize); + if (!scanline) + return 0; + _TIFFmemset(scanline, 0, scanlinesize); + (void) imagewidth; + if (scanline) { + uint8* bufp = (uint8*) buf; + uint32 row; + tsample_t s; + for (row = 0; row < imagelength; row++) { + /* merge channels */ + for (s = 0; s < spp; s++) { + uint8* bp = bufp + s; + tsize_t n = scanlinesize; + uint8* sbuf = scanline; - if (TIFFReadScanline(in, scanline, row, s) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read scanline %" PRIu32, row); - status = 0; - goto done; - } - while (n-- > 0) - *bp = *sbuf++, bp += spp; - } - bufp += scanlinesize * spp; - } - } + if (TIFFReadScanline(in, scanline, row, s) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read scanline %lu", + (unsigned long) row); + status = 0; + goto done; + } + while (n-- > 0) + *bp = *sbuf++, bp += spp; + } + bufp += scanlinesize * spp; + } + } done: - _TIFFfree(scanline); - return status; + _TIFFfree(scanline); + return status; } DECLAREreadFunc(readContigTilesIntoBuffer) { - int status = 1; - tsize_t tilesize = TIFFTileSize(in); - tdata_t tilebuf; - uint32_t imagew = TIFFScanlineSize(in); - uint32_t tilew = TIFFTileRowSize(in); - int64_t iskew = (int64_t)imagew - (int64_t)tilew; - uint8_t *bufp = (uint8_t *)buf; - uint32_t tw, tl; - uint32_t row; + int status = 1; + tsize_t tilesize = TIFFTileSize(in); + tdata_t tilebuf; + uint32 imagew = TIFFScanlineSize(in); + uint32 tilew = TIFFTileRowSize(in); + int64 iskew = (int64)imagew - (int64)tilew; + uint8* bufp = (uint8*) buf; + uint32 tw, tl; + uint32 row; - (void)spp; - tilebuf = limitMalloc(tilesize); - if (tilebuf == 0) - return 0; - _TIFFmemset(tilebuf, 0, tilesize); - (void)TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); - (void)TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); + (void) spp; + tilebuf = limitMalloc(tilesize); + if (tilebuf == 0) + return 0; + _TIFFmemset(tilebuf, 0, tilesize); + (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); + (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); + + for (row = 0; row < imagelength; row += tl) { + uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; + uint32 colb = 0; + uint32 col; - for (row = 0; row < imagelength; row += tl) - { - uint32_t nrow = (row + tl > imagelength) ? imagelength - row : tl; - uint32_t colb = 0; - uint32_t col; - - for (col = 0; col < imagewidth && colb < imagew; col += tw) - { - if (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read tile at %" PRIu32 " %" PRIu32, col, - row); - status = 0; - goto done; - } - if (colb > iskew) - { - uint32_t width = imagew - colb; - uint32_t oskew = tilew - width; - cpStripToTile(bufp + colb, tilebuf, nrow, width, oskew + iskew, - oskew); - } - else - cpStripToTile(bufp + colb, tilebuf, nrow, tilew, iskew, 0); - colb += tilew; - } - bufp += imagew * nrow; - } + for (col = 0; col < imagewidth && colb < imagew; col += tw) { + if (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read tile at %lu %lu", + (unsigned long) col, + (unsigned long) row); + status = 0; + goto done; + } + if (colb > iskew) { + uint32 width = imagew - colb; + uint32 oskew = tilew - width; + cpStripToTile(bufp + colb, + tilebuf, nrow, width, + oskew + iskew, oskew ); + } else + cpStripToTile(bufp + colb, + tilebuf, nrow, tilew, + iskew, 0); + colb += tilew; + } + bufp += imagew * nrow; + } done: - _TIFFfree(tilebuf); - return status; + _TIFFfree(tilebuf); + return status; } DECLAREreadFunc(readSeparateTilesIntoBuffer) { - int status = 1; - uint32_t imagew = TIFFRasterScanlineSize(in); - uint32_t tilew = TIFFTileRowSize(in); - int iskew; - tsize_t tilesize = TIFFTileSize(in); - tdata_t tilebuf; - uint8_t *bufp = (uint8_t *)buf; - uint32_t tw, tl; - uint32_t row; - uint16_t bps = 0, bytes_per_sample; + int status = 1; + uint32 imagew = TIFFRasterScanlineSize(in); + uint32 tilew = TIFFTileRowSize(in); + int iskew; + tsize_t tilesize = TIFFTileSize(in); + tdata_t tilebuf; + uint8* bufp = (uint8*) buf; + uint32 tw, tl; + uint32 row; + uint16 bps = 0, bytes_per_sample; - if (tilew && spp > (INT_MAX / tilew)) - { - TIFFError(TIFFFileName(in), - "Error, cannot handle that much samples per tile row (Tile " - "Width * Samples/Pixel)"); - return 0; - } - iskew = imagew - tilew * spp; - tilebuf = limitMalloc(tilesize); - if (tilebuf == 0) - return 0; - _TIFFmemset(tilebuf, 0, tilesize); - (void)TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); - (void)TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); - (void)TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); - if (bps == 0) - { - TIFFError(TIFFFileName(in), "Error, cannot read BitsPerSample"); - status = 0; - goto done; - } - if ((bps % 8) != 0) - { - TIFFError( - TIFFFileName(in), - "Error, cannot handle BitsPerSample that is not a multiple of 8"); - status = 0; - goto done; - } - bytes_per_sample = bps / 8; - - for (row = 0; row < imagelength; row += tl) - { - uint32_t nrow = (row + tl > imagelength) ? imagelength - row : tl; - uint32_t colb = 0; - uint32_t col; - - for (col = 0; col < imagewidth; col += tw) + if (tilew && spp > (INT_MAX / tilew)) + { + TIFFError(TIFFFileName(in), "Error, cannot handle that much samples per tile row (Tile Width * Samples/Pixel)"); + return 0; + } + iskew = imagew - tilew*spp; + tilebuf = limitMalloc(tilesize); + if (tilebuf == 0) + return 0; + _TIFFmemset(tilebuf, 0, tilesize); + (void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); + (void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); + (void) TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bps); + if( bps == 0 ) { - tsample_t s; - - for (s = 0; s < spp; s++) - { - if (TIFFReadTile(in, tilebuf, col, row, 0, s) < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read tile at %" PRIu32 " %" PRIu32 - ", " - "sample %" PRIu16, - col, row, s); - status = 0; - goto done; - } - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - if (colb + tilew * spp > imagew) - { - uint32_t width = imagew - colb; - int oskew = tilew * spp - width; - cpSeparateBufToContigBuf( - bufp + colb + s * bytes_per_sample, tilebuf, nrow, - width / (spp * bytes_per_sample), oskew + iskew, - oskew / spp, spp, bytes_per_sample); - } - else - cpSeparateBufToContigBuf(bufp + colb + s * bytes_per_sample, - tilebuf, nrow, tw, iskew, 0, spp, - bytes_per_sample); - } - colb += tilew * spp; + TIFFError(TIFFFileName(in), "Error, cannot read BitsPerSample"); + status = 0; + goto done; } - bufp += imagew * nrow; - } + if( (bps % 8) != 0 ) + { + TIFFError(TIFFFileName(in), "Error, cannot handle BitsPerSample that is not a multiple of 8"); + status = 0; + goto done; + } + bytes_per_sample = bps/8; + + for (row = 0; row < imagelength; row += tl) { + uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; + uint32 colb = 0; + uint32 col; + + for (col = 0; col < imagewidth; col += tw) { + tsample_t s; + + for (s = 0; s < spp; s++) { + if (TIFFReadTile(in, tilebuf, col, row, 0, s) < 0 + && !ignore) { + TIFFError(TIFFFileName(in), + "Error, can't read tile at %lu %lu, " + "sample %lu", + (unsigned long) col, + (unsigned long) row, + (unsigned long) s); + status = 0; + goto done; + } + /* + * Tile is clipped horizontally. Calculate + * visible portion and skewing factors. + */ + if (colb + tilew*spp > imagew) { + uint32 width = imagew - colb; + int oskew = tilew*spp - width; + cpSeparateBufToContigBuf( + bufp+colb+s*bytes_per_sample, + tilebuf, nrow, + width/(spp*bytes_per_sample), + oskew + iskew, + oskew/spp, spp, + bytes_per_sample); + } else + cpSeparateBufToContigBuf( + bufp+colb+s*bytes_per_sample, + tilebuf, nrow, tw, + iskew, 0, spp, + bytes_per_sample); + } + colb += tilew*spp; + } + bufp += imagew * nrow; + } done: - _TIFFfree(tilebuf); - return status; + _TIFFfree(tilebuf); + return status; } DECLAREwriteFunc(writeBufferToContigStrips) { - uint32_t row, rowsperstrip; - tstrip_t strip = 0; + uint32 row, rowsperstrip; + tstrip_t strip = 0; - (void)imagewidth; - (void)spp; - (void)TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - for (row = 0; row < imagelength; row += rowsperstrip) - { - uint32_t nrows = (row + rowsperstrip > imagelength) ? imagelength - row - : rowsperstrip; - tsize_t stripsize = TIFFVStripSize(out, nrows); - if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) - { - TIFFError(TIFFFileName(out), "Error, can't write strip %" PRIu32, - strip - 1u); - return 0; - } - buf += stripsize; - } - return 1; + (void) imagewidth; (void) spp; + (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + for (row = 0; row < imagelength; row += rowsperstrip) { + uint32 nrows = (row+rowsperstrip > imagelength) ? + imagelength-row : rowsperstrip; + tsize_t stripsize = TIFFVStripSize(out, nrows); + if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write strip %u", strip - 1); + return 0; + } + buf += stripsize; + } + return 1; } DECLAREwriteFunc(writeBufferToSeparateStrips) { - uint32_t rowsize = imagewidth * spp; - uint32_t rowsperstrip; - tsize_t stripsize = TIFFStripSize(out); - tdata_t obuf; - tstrip_t strip = 0; - tsample_t s; - uint16_t bps = 0, bytes_per_sample; + uint32 rowsize = imagewidth * spp; + uint32 rowsperstrip; + tsize_t stripsize = TIFFStripSize(out); + tdata_t obuf; + tstrip_t strip = 0; + tsample_t s; + uint16 bps = 0, bytes_per_sample; - obuf = limitMalloc(stripsize); - if (obuf == NULL) - return (0); - _TIFFmemset(obuf, 0, stripsize); - (void)TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - (void)TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps); - if (bps == 0) - { - TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample"); - _TIFFfree(obuf); - return 0; - } - if ((bps % 8) != 0) - { - TIFFError( - TIFFFileName(out), - "Error, cannot handle BitsPerSample that is not a multiple of 8"); - _TIFFfree(obuf); - return 0; - } - bytes_per_sample = bps / 8; - for (s = 0; s < spp; s++) - { - uint32_t row; - for (row = 0; row < imagelength; row += rowsperstrip) + obuf = limitMalloc(stripsize); + if (obuf == NULL) + return (0); + _TIFFmemset(obuf, 0, stripsize); + (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + (void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps); + if( bps == 0 ) { - uint32_t nrows = (row + rowsperstrip > imagelength) - ? imagelength - row - : rowsperstrip; - tsize_t stripsize = TIFFVStripSize(out, nrows); - - cpContigBufToSeparateBuf(obuf, (uint8_t *)buf + row * rowsize + s, - nrows, imagewidth, 0, 0, spp, - bytes_per_sample); - if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) - { - TIFFError(TIFFFileName(out), - "Error, can't write strip %" PRIu32, strip - 1u); - _TIFFfree(obuf); - return 0; - } + TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample"); + _TIFFfree(obuf); + return 0; } - } - _TIFFfree(obuf); - return 1; + if( (bps % 8) != 0 ) + { + TIFFError(TIFFFileName(out), "Error, cannot handle BitsPerSample that is not a multiple of 8"); + _TIFFfree(obuf); + return 0; + } + bytes_per_sample = bps/8; + for (s = 0; s < spp; s++) { + uint32 row; + for (row = 0; row < imagelength; row += rowsperstrip) { + uint32 nrows = (row+rowsperstrip > imagelength) ? + imagelength-row : rowsperstrip; + tsize_t stripsize = TIFFVStripSize(out, nrows); + + cpContigBufToSeparateBuf( + obuf, (uint8*) buf + row*rowsize + s, + nrows, imagewidth, 0, 0, spp, bytes_per_sample); + if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write strip %u", + strip - 1); + _TIFFfree(obuf); + return 0; + } + } + } + _TIFFfree(obuf); + return 1; + } DECLAREwriteFunc(writeBufferToContigTiles) { - uint32_t imagew = TIFFScanlineSize(out); - uint32_t tilew = TIFFTileRowSize(out); - int iskew = imagew - tilew; - tsize_t tilesize = TIFFTileSize(out); - tdata_t obuf; - uint8_t *bufp = (uint8_t *)buf; - uint32_t tl, tw; - uint32_t row; + uint32 imagew = TIFFScanlineSize(out); + uint32 tilew = TIFFTileRowSize(out); + int iskew = imagew - tilew; + tsize_t tilesize = TIFFTileSize(out); + tdata_t obuf; + uint8* bufp = (uint8*) buf; + uint32 tl, tw; + uint32 row; - (void)spp; + (void) spp; - obuf = limitMalloc(TIFFTileSize(out)); - if (obuf == NULL) - return 0; - _TIFFmemset(obuf, 0, tilesize); - (void)TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); - (void)TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); - for (row = 0; row < imagelength; row += tilelength) - { - uint32_t nrow = (row + tl > imagelength) ? imagelength - row : tl; - uint32_t colb = 0; - uint32_t col; + obuf = limitMalloc(TIFFTileSize(out)); + if (obuf == NULL) + return 0; + _TIFFmemset(obuf, 0, tilesize); + (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); + (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); + for (row = 0; row < imagelength; row += tilelength) { + uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; + uint32 colb = 0; + uint32 col; - for (col = 0; col < imagewidth && colb < imagew; col += tw) - { - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - if (colb + tilew > imagew) - { - uint32_t width = imagew - colb; - int oskew = tilew - width; - cpStripToTile(obuf, bufp + colb, nrow, width, oskew, - oskew + iskew); - } - else - cpStripToTile(obuf, bufp + colb, nrow, tilew, 0, iskew); - if (TIFFWriteTile(out, obuf, col, row, 0, 0) < 0) - { - TIFFError(TIFFFileName(out), - "Error, can't write tile at %" PRIu32 " %" PRIu32, - col, row); - _TIFFfree(obuf); - return 0; - } - colb += tilew; - } - bufp += nrow * imagew; - } - _TIFFfree(obuf); - return 1; + for (col = 0; col < imagewidth && colb < imagew; col += tw) { + /* + * Tile is clipped horizontally. Calculate + * visible portion and skewing factors. + */ + if (colb + tilew > imagew) { + uint32 width = imagew - colb; + int oskew = tilew - width; + cpStripToTile(obuf, bufp + colb, nrow, width, + oskew, oskew + iskew); + } else + cpStripToTile(obuf, bufp + colb, nrow, tilew, + 0, iskew); + if (TIFFWriteTile(out, obuf, col, row, 0, 0) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write tile at %lu %lu", + (unsigned long) col, + (unsigned long) row); + _TIFFfree(obuf); + return 0; + } + colb += tilew; + } + bufp += nrow * imagew; + } + _TIFFfree(obuf); + return 1; } DECLAREwriteFunc(writeBufferToSeparateTiles) { - uint32_t imagew = TIFFScanlineSize(out); - tsize_t tilew = TIFFTileRowSize(out); - uint32_t iimagew = TIFFRasterScanlineSize(out); - int iskew = iimagew - tilew * spp; - tsize_t tilesize = TIFFTileSize(out); - tdata_t obuf; - uint8_t *bufp = (uint8_t *)buf; - uint32_t tl, tw; - uint32_t row; - uint16_t bps = 0, bytes_per_sample; + uint32 imagew = TIFFScanlineSize(out); + tsize_t tilew = TIFFTileRowSize(out); + uint32 iimagew = TIFFRasterScanlineSize(out); + int iskew = iimagew - tilew*spp; + tsize_t tilesize = TIFFTileSize(out); + tdata_t obuf; + uint8* bufp = (uint8*) buf; + uint32 tl, tw; + uint32 row; + uint16 bps = 0, bytes_per_sample; - obuf = limitMalloc(TIFFTileSize(out)); - if (obuf == NULL) - return 0; - _TIFFmemset(obuf, 0, tilesize); - (void)TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); - (void)TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); - (void)TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps); - if (bps == 0) - { - TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample"); - _TIFFfree(obuf); - return 0; - } - if ((bps % 8) != 0) - { - TIFFError( - TIFFFileName(out), - "Error, cannot handle BitsPerSample that is not a multiple of 8"); - _TIFFfree(obuf); - return 0; - } - bytes_per_sample = bps / 8; - - for (row = 0; row < imagelength; row += tl) - { - uint32_t nrow = (row + tl > imagelength) ? imagelength - row : tl; - uint32_t colb = 0; - uint32_t col; - - for (col = 0; col < imagewidth; col += tw) + obuf = limitMalloc(TIFFTileSize(out)); + if (obuf == NULL) + return 0; + _TIFFmemset(obuf, 0, tilesize); + (void) TIFFGetField(out, TIFFTAG_TILELENGTH, &tl); + (void) TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw); + (void) TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps); + if( bps == 0 ) { - tsample_t s; - for (s = 0; s < spp; s++) - { - /* - * Tile is clipped horizontally. Calculate - * visible portion and skewing factors. - */ - if (colb + tilew > imagew) - { - uint32_t width = (imagew - colb); - int oskew = tilew - width; - - cpContigBufToSeparateBuf(obuf, bufp + (colb * spp) + s, - nrow, width / bytes_per_sample, - oskew, (oskew * spp) + iskew, spp, - bytes_per_sample); - } - else - cpContigBufToSeparateBuf(obuf, bufp + (colb * spp) + s, - nrow, tilewidth, 0, iskew, spp, - bytes_per_sample); - if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) - { - TIFFError(TIFFFileName(out), - "Error, can't write tile at %" PRIu32 " %" PRIu32 - " sample %" PRIu16, - col, row, s); - _TIFFfree(obuf); - return 0; - } - } - colb += tilew; + TIFFError(TIFFFileName(out), "Error, cannot read BitsPerSample"); + _TIFFfree(obuf); + return 0; } - bufp += nrow * iimagew; - } - _TIFFfree(obuf); - return 1; + if( (bps % 8) != 0 ) + { + TIFFError(TIFFFileName(out), "Error, cannot handle BitsPerSample that is not a multiple of 8"); + _TIFFfree(obuf); + return 0; + } + bytes_per_sample = bps/8; + + for (row = 0; row < imagelength; row += tl) { + uint32 nrow = (row+tl > imagelength) ? imagelength-row : tl; + uint32 colb = 0; + uint32 col; + + for (col = 0; col < imagewidth; col += tw) { + tsample_t s; + for (s = 0; s < spp; s++) { + /* + * Tile is clipped horizontally. Calculate + * visible portion and skewing factors. + */ + if (colb + tilew > imagew) { + uint32 width = (imagew - colb); + int oskew = tilew - width; + + cpContigBufToSeparateBuf(obuf, + bufp + (colb*spp) + s, + nrow, width/bytes_per_sample, + oskew, (oskew*spp)+iskew, spp, + bytes_per_sample); + } else + cpContigBufToSeparateBuf(obuf, + bufp + (colb*spp) + s, + nrow, tilewidth, + 0, iskew, spp, + bytes_per_sample); + if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) { + TIFFError(TIFFFileName(out), + "Error, can't write tile at %lu %lu " + "sample %lu", + (unsigned long) col, + (unsigned long) row, + (unsigned long) s); + _TIFFfree(obuf); + return 0; + } + } + colb += tilew; + } + bufp += nrow * iimagew; + } + _TIFFfree(obuf); + return 1; } /* @@ -2052,8 +1774,10 @@ DECLAREwriteFunc(writeBufferToSeparateTiles) */ DECLAREcpFunc(cpContigStrips2ContigTiles) { - return cpImage(in, out, readContigStripsIntoBuffer, - writeBufferToContigTiles, imagelength, imagewidth, spp); + return cpImage(in, out, + readContigStripsIntoBuffer, + writeBufferToContigTiles, + imagelength, imagewidth, spp); } /* @@ -2061,8 +1785,10 @@ DECLAREcpFunc(cpContigStrips2ContigTiles) */ DECLAREcpFunc(cpContigStrips2SeparateTiles) { - return cpImage(in, out, readContigStripsIntoBuffer, - writeBufferToSeparateTiles, imagelength, imagewidth, spp); + return cpImage(in, out, + readContigStripsIntoBuffer, + writeBufferToSeparateTiles, + imagelength, imagewidth, spp); } /* @@ -2070,8 +1796,10 @@ DECLAREcpFunc(cpContigStrips2SeparateTiles) */ DECLAREcpFunc(cpSeparateStrips2ContigTiles) { - return cpImage(in, out, readSeparateStripsIntoBuffer, - writeBufferToContigTiles, imagelength, imagewidth, spp); + return cpImage(in, out, + readSeparateStripsIntoBuffer, + writeBufferToContigTiles, + imagelength, imagewidth, spp); } /* @@ -2079,8 +1807,10 @@ DECLAREcpFunc(cpSeparateStrips2ContigTiles) */ DECLAREcpFunc(cpSeparateStrips2SeparateTiles) { - return cpImage(in, out, readSeparateStripsIntoBuffer, - writeBufferToSeparateTiles, imagelength, imagewidth, spp); + return cpImage(in, out, + readSeparateStripsIntoBuffer, + writeBufferToSeparateTiles, + imagelength, imagewidth, spp); } /* @@ -2088,8 +1818,10 @@ DECLAREcpFunc(cpSeparateStrips2SeparateTiles) */ DECLAREcpFunc(cpContigTiles2ContigTiles) { - return cpImage(in, out, readContigTilesIntoBuffer, writeBufferToContigTiles, - imagelength, imagewidth, spp); + return cpImage(in, out, + readContigTilesIntoBuffer, + writeBufferToContigTiles, + imagelength, imagewidth, spp); } /* @@ -2097,8 +1829,10 @@ DECLAREcpFunc(cpContigTiles2ContigTiles) */ DECLAREcpFunc(cpContigTiles2SeparateTiles) { - return cpImage(in, out, readContigTilesIntoBuffer, - writeBufferToSeparateTiles, imagelength, imagewidth, spp); + return cpImage(in, out, + readContigTilesIntoBuffer, + writeBufferToSeparateTiles, + imagelength, imagewidth, spp); } /* @@ -2106,8 +1840,10 @@ DECLAREcpFunc(cpContigTiles2SeparateTiles) */ DECLAREcpFunc(cpSeparateTiles2ContigTiles) { - return cpImage(in, out, readSeparateTilesIntoBuffer, - writeBufferToContigTiles, imagelength, imagewidth, spp); + return cpImage(in, out, + readSeparateTilesIntoBuffer, + writeBufferToContigTiles, + imagelength, imagewidth, spp); } /* @@ -2115,8 +1851,10 @@ DECLAREcpFunc(cpSeparateTiles2ContigTiles) */ DECLAREcpFunc(cpSeparateTiles2SeparateTiles) { - return cpImage(in, out, readSeparateTilesIntoBuffer, - writeBufferToSeparateTiles, imagelength, imagewidth, spp); + return cpImage(in, out, + readSeparateTilesIntoBuffer, + writeBufferToSeparateTiles, + imagelength, imagewidth, spp); } /* @@ -2124,8 +1862,10 @@ DECLAREcpFunc(cpSeparateTiles2SeparateTiles) */ DECLAREcpFunc(cpContigTiles2ContigStrips) { - return cpImage(in, out, readContigTilesIntoBuffer, - writeBufferToContigStrips, imagelength, imagewidth, spp); + return cpImage(in, out, + readContigTilesIntoBuffer, + writeBufferToContigStrips, + imagelength, imagewidth, spp); } /* @@ -2133,8 +1873,10 @@ DECLAREcpFunc(cpContigTiles2ContigStrips) */ DECLAREcpFunc(cpContigTiles2SeparateStrips) { - return cpImage(in, out, readContigTilesIntoBuffer, - writeBufferToSeparateStrips, imagelength, imagewidth, spp); + return cpImage(in, out, + readContigTilesIntoBuffer, + writeBufferToSeparateStrips, + imagelength, imagewidth, spp); } /* @@ -2142,8 +1884,10 @@ DECLAREcpFunc(cpContigTiles2SeparateStrips) */ DECLAREcpFunc(cpSeparateTiles2ContigStrips) { - return cpImage(in, out, readSeparateTilesIntoBuffer, - writeBufferToContigStrips, imagelength, imagewidth, spp); + return cpImage(in, out, + readSeparateTilesIntoBuffer, + writeBufferToContigStrips, + imagelength, imagewidth, spp); } /* @@ -2151,126 +1895,126 @@ DECLAREcpFunc(cpSeparateTiles2ContigStrips) */ DECLAREcpFunc(cpSeparateTiles2SeparateStrips) { - return cpImage(in, out, readSeparateTilesIntoBuffer, - writeBufferToSeparateStrips, imagelength, imagewidth, spp); + return cpImage(in, out, + readSeparateTilesIntoBuffer, + writeBufferToSeparateStrips, + imagelength, imagewidth, spp); } /* * Select the appropriate copy function to use. */ -static copyFunc pickCopyFunc(TIFF *in, TIFF *out, uint16_t bitspersample, - uint16_t samplesperpixel) +static copyFunc +pickCopyFunc(TIFF* in, TIFF* out, uint16 bitspersample, uint16 samplesperpixel) { - uint16_t shortv; - uint32_t w, l, tw, tl; - int bychunk; + uint16 shortv; + uint32 w, l, tw, tl; + int bychunk; - (void)TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &shortv); - if (shortv != config && bitspersample != 8 && samplesperpixel > 1) - { - fprintf(stderr, - "%s: Cannot handle different planar configuration w/ " - "bits/sample != 8\n", - TIFFFileName(in)); - return (NULL); - } - TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(in, TIFFTAG_IMAGELENGTH, &l); - if (!(TIFFIsTiled(out) || TIFFIsTiled(in))) - { - uint32_t irps = (uint32_t)-1L; - TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &irps); - /* if biased, force decoded copying to allow image subtraction */ - bychunk = !bias && (rowsperstrip == irps); - } - else - { /* either in or out is tiled */ - if (bias) - { - fprintf(stderr, - "%s: Cannot handle tiled configuration w/bias image\n", - TIFFFileName(in)); - return (NULL); - } - if (TIFFIsTiled(out)) - { - if (!TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw)) - tw = w; - if (!TIFFGetField(in, TIFFTAG_TILELENGTH, &tl)) - tl = l; - bychunk = (tw == tilewidth && tl == tilelength); - } - else - { /* out's not, so in must be tiled */ - TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); - bychunk = (tw == w && tl == rowsperstrip); - } - } -#define T 1 -#define F 0 -#define pack(a, b, c, d, e) \ - ((long)(((a) << 11) | ((b) << 3) | ((c) << 2) | ((d) << 1) | (e))) - switch (pack(shortv, config, TIFFIsTiled(in), TIFFIsTiled(out), bychunk)) - { - /* Strips -> Tiles */ - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F, T, F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F, T, T): - return cpContigStrips2ContigTiles; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F, T, F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F, T, T): - return cpContigStrips2SeparateTiles; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F, T, F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F, T, T): - return cpSeparateStrips2ContigTiles; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F, T, F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F, T, T): - return cpSeparateStrips2SeparateTiles; - /* Tiles -> Tiles */ - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T, T, F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T, T, T): - return cpContigTiles2ContigTiles; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T, T, F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T, T, T): - return cpContigTiles2SeparateTiles; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T, T, F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T, T, T): - return cpSeparateTiles2ContigTiles; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T, T, F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T, T, T): - return cpSeparateTiles2SeparateTiles; - /* Tiles -> Strips */ - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T, F, F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T, F, T): - return cpContigTiles2ContigStrips; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T, F, F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T, F, T): - return cpContigTiles2SeparateStrips; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T, F, F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T, F, T): - return cpSeparateTiles2ContigStrips; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T, F, F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T, F, T): - return cpSeparateTiles2SeparateStrips; - /* Strips -> Strips */ - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F, F, F): - return bias ? cpBiasedContig2Contig : cpContig2ContigByRow; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F, F, T): - return cpDecodedStrips; - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F, F, F): - case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F, F, T): - return cpContig2SeparateByRow; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F, F, F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F, F, T): - return cpSeparate2ContigByRow; - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F, F, F): - case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F, F, T): - return cpSeparate2SeparateByRow; - } + (void) TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &shortv); + if (shortv != config && bitspersample != 8 && samplesperpixel > 1) { + fprintf(stderr, + "%s: Cannot handle different planar configuration w/ bits/sample != 8\n", + TIFFFileName(in)); + return (NULL); + } + TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(in, TIFFTAG_IMAGELENGTH, &l); + if (!(TIFFIsTiled(out) || TIFFIsTiled(in))) { + uint32 irps = (uint32) -1L; + TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &irps); + /* if biased, force decoded copying to allow image subtraction */ + bychunk = !bias && (rowsperstrip == irps); + }else{ /* either in or out is tiled */ + if (bias) { + fprintf(stderr, + "%s: Cannot handle tiled configuration w/bias image\n", + TIFFFileName(in)); + return (NULL); + } + if (TIFFIsTiled(out)) { + if (!TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw)) + tw = w; + if (!TIFFGetField(in, TIFFTAG_TILELENGTH, &tl)) + tl = l; + bychunk = (tw == tilewidth && tl == tilelength); + } else { /* out's not, so in must be tiled */ + TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); + bychunk = (tw == w && tl == rowsperstrip); + } + } +#define T 1 +#define F 0 +#define pack(a,b,c,d,e) ((long)(((a)<<11)|((b)<<3)|((c)<<2)|((d)<<1)|(e))) + switch(pack(shortv,config,TIFFIsTiled(in),TIFFIsTiled(out),bychunk)) { + /* Strips -> Tiles */ + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,T,T): + return cpContigStrips2ContigTiles; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,T,T): + return cpContigStrips2SeparateTiles; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,T,T): + return cpSeparateStrips2ContigTiles; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,T,T): + return cpSeparateStrips2SeparateTiles; + /* Tiles -> Tiles */ + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,T,T): + return cpContigTiles2ContigTiles; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,T,T): + return cpContigTiles2SeparateTiles; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,T,T): + return cpSeparateTiles2ContigTiles; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,T,T): + return cpSeparateTiles2SeparateTiles; + /* Tiles -> Strips */ + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, T,F,T): + return cpContigTiles2ContigStrips; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, T,F,T): + return cpContigTiles2SeparateStrips; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, T,F,T): + return cpSeparateTiles2ContigStrips; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, T,F,T): + return cpSeparateTiles2SeparateStrips; + /* Strips -> Strips */ + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,F): + return bias ? cpBiasedContig2Contig : cpContig2ContigByRow; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, F,F,T): + return cpDecodedStrips; + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,F): + case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, F,F,T): + return cpContig2SeparateByRow; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, F,F,T): + return cpSeparate2ContigByRow; + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,F): + case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, F,F,T): + return cpSeparate2SeparateByRow; + } #undef pack #undef F #undef T - fprintf(stderr, "tiffcp: %s: Don't know how to copy/convert image.\n", - TIFFFileName(in)); - return (NULL); + fprintf(stderr, "tiffcp: %s: Don't know how to copy/convert image.\n", + TIFFFileName(in)); + return (NULL); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffcrop.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffcrop.c index 05a7c5f1b..d90de4b93 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffcrop.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffcrop.c @@ -1,148 +1,127 @@ -/* clang-format off */ /* tiffcrop.c -- a port of tiffcp.c extended to include manipulations of * the image data through additional options listed below * * Original code: * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * Additions (c) Richard Nolde 2006-2010 + * Additions (c) Richard Nolde 2006-2010 * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS OR ANY OTHER COPYRIGHT - * HOLDERS 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 + * + * 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 OR ANY OTHER COPYRIGHT + * HOLDERS 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. * - * Some portions of the current code are derived from tiffcp, primarily in + * Some portions of the current code are derived from tiffcp, primarily in * the areas of lowlevel reading and writing of TAGS, scanlines and tiles though * some of the original functions have been extended to support arbitrary bit * depths. These functions are presented at the top of this file. * - * Add support for the options below to extract sections of image(s) + * Add support for the options below to extract sections of image(s) * and to modify the whole image or selected portions of each image by * rotations, mirroring, and colorscale/colormap inversion of selected - * types of TIFF images when appropriate. Some color model dependent + * types of TIFF images when appropriate. Some color model dependent * functions are restricted to bilevel or 8 bit per sample data. * See the man page for the full explanations. * - * New Options: + * New Options: * -h Display the syntax guide. - * -v Report the version and last build date for tiffcrop - * and libtiff. - * -z x1,y1,x2,y2:x3,y3,x4,y4:..xN,yN,xN + 1, yN + 1 + * -v Report the version and last build date for tiffcrop and libtiff. + * -z x1,y1,x2,y2:x3,y3,x4,y4:..xN,yN,xN + 1, yN + 1 * Specify a series of coordinates to define rectangular * regions by the top left and lower right corners. * -e c|d|i|m|s export mode for images and selections from input images - * combined All images and selections are written to a single - * file (default) with multiple selections from one image - * combined into a single image + * combined All images and selections are written to a single file (default) + * with multiple selections from one image combined into a single image * divided All images and selections are written to a single file * with each selection from one image written to a new image - * image Each input image is written to a new file - * (numeric filename sequence) with multiple selections from - * the image combined into one image - * multiple Each input image is written to a new file - * (numeric filename sequence) with each selection from - * the image written to a new image - * separated Individual selections from each image are written - * to separate files + * image Each input image is written to a new file (numeric filename sequence) + * with multiple selections from the image combined into one image + * multiple Each input image is written to a new file (numeric filename sequence) + * with each selection from the image written to a new image + * separated Individual selections from each image are written to separate files * -U units [in, cm, px ] inches, centimeters or pixels * -H # Set horizontal resolution of output images to # * -V # Set vertical resolution of output images to # * -J # Horizontal margin of output page to # expressed in current - * units when sectioning image into columns x rows + * units when sectioning image into columns x rows * using the -S cols:rows option. * -K # Vertical margin of output page to # expressed in current * units when sectioning image into columns x rows * using the -S cols:rows option. * -X # Horizontal dimension of region to extract expressed in current - * units, relative to the specified origin reference 'edge' left - * (default for X) or right. + * units * -Y # Vertical dimension of region to extract expressed in current - * units, relative to the specified origin reference 'edge' top - * (default for Y) or bottom. + * units * -O orient Orientation for output image, portrait, landscape, auto * -P page Page size for output image segments, eg letter, legal, tabloid, * etc. * -S cols:rows Divide the image into equal sized segments using cols across * and rows down - * -E t|l|r|b Edge to use as origin (i.e. 'side' of the image not 'corner') - * top = width from left, zones from top to bottom (default) - * bottom = width from left, zones from bottom to top - * left = zones from left to right, length from top - * right = zones from right to left, length from top + * -E t|l|r|b Edge to use as origin * -m #,#,#,# Margins from edges for selection: top, left, bottom, right * (commas separated) - * -Z #:#,#:# Zones of the image designated as zone X of Y, + * -Z #:#,#:# Zones of the image designated as zone X of Y, * eg 1:3 would be first of three equal portions measured - * from reference edge (i.e. 'side' not corner) - * -N odd|even|#,#-#,#|last + * from reference edge + * -N odd|even|#,#-#,#|last * Select sequences and/or ranges of images within file * to process. The words odd or even may be used to specify * all odd or even numbered images the word last may be used * in place of a number in the sequence to indicate the final * image in the file without knowing how many images there are. * -R # Rotate image or crop selection by 90,180,or 270 degrees - * clockwise + * clockwise * -F h|v Flip (mirror) image or crop selection horizontally - * or vertically + * or vertically * -I [black|white|data|both] - * Invert color space, eg dark to light for bilevel and - * grayscale images If argument is white or black, set the - * PHOTOMETRIC_INTERPRETATION tag to MinIsBlack or MinIsWhite - * without altering the image data. If the argument is data - * or both, the image data are modified: + * Invert color space, eg dark to light for bilevel and grayscale images + * If argument is white or black, set the PHOTOMETRIC_INTERPRETATION + * tag to MinIsBlack or MinIsWhite without altering the image data + * If the argument is data or both, the image data are modified: * both inverts the data and the PHOTOMETRIC_INTERPRETATION tag, * data inverts the data but not the PHOTOMETRIC_INTERPRETATION tag * -D input:,output:,format:,level:N,debug:N - * Dump raw data for input and/or output images to individual - * files in raw (binary) format or text (ASCII) representing - * binary data as strings of 1s and 0s. The filename arguments - * are used as stems from which individual files are created for - * each image. Text format includes annotations for image - * parameters and scanline info. Level selects which functions - * dump data, with higher numbers selecting lower level, - * scanline level routines. Debug reports a limited set - * of messages to monitor progress without enabling dump logs. - * - * Note 1: The (-X|-Y), -Z, -z and -S options are mutually exclusive. - * In no case should the options be applied to a given - * selection successively. - * Note 2: Any of the -X, -Y, -Z and -z options together with other - * PAGE_MODE_x options such as -H, -V, -P, -J or -K are not supported - * and may cause buffer overflows. + * Dump raw data for input and/or output images to individual files + * in raw (binary) format or text (ASCII) representing binary data + * as strings of 1s and 0s. The filename arguments are used as stems + * from which individual files are created for each image. Text format + * includes annotations for image parameters and scanline info. Level + * selects which functions dump data, with higher numbers selecting + * lower level, scanline level routines. Debug reports a limited set + * of messages to monitor progess without enabling dump logs. */ -/* clang-format on */ -#include "libport.h" +static char tiffcrop_version_id[] = "2.4.1"; +static char tiffcrop_rev_date[] = "03-03-2010"; + #include "tif_config.h" #include "tiffiop.h" -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include #include +#include #ifdef HAVE_UNISTD_H -#include +# include #endif #ifndef EXIT_SUCCESS @@ -152,20 +131,32 @@ #define EXIT_FAILURE 1 #endif +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + #include "tiffio.h" +#if defined(VMS) +# define unlink delete +#endif + #ifndef PATH_MAX #define PATH_MAX 1024 #endif -#define TRUE 1 -#define FALSE 0 +#define TIFF_UINT32_MAX 0xFFFFFFFFU + +#define TRUE 1 +#define FALSE 0 #ifndef TIFFhowmany -#define TIFFhowmany(x, y) \ - ((((uint32_t)(x)) + (((uint32_t)(y)) - 1)) / ((uint32_t)(y))) -#define TIFFhowmany8(x) \ - (((x)&0x07) ? ((uint32_t)(x) >> 3) + 1 : (uint32_t)(x) >> 3) +#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y))) +#define TIFFhowmany8(x) (((x)&0x07)?((uint32)(x)>>3)+1:(uint32)(x)>>3) #endif /* @@ -173,514 +164,460 @@ * manipulations. */ -#define EDGE_TOP 1 -#define EDGE_LEFT 2 -#define EDGE_BOTTOM 3 -#define EDGE_RIGHT 4 -#define EDGE_CENTER 5 +#define EDGE_TOP 1 +#define EDGE_LEFT 2 +#define EDGE_BOTTOM 3 +#define EDGE_RIGHT 4 +#define EDGE_CENTER 5 -#define MIRROR_HORIZ 1 -#define MIRROR_VERT 2 -#define MIRROR_BOTH 3 -#define ROTATECW_90 8 +#define MIRROR_HORIZ 1 +#define MIRROR_VERT 2 +#define MIRROR_BOTH 3 +#define ROTATECW_90 8 #define ROTATECW_180 16 #define ROTATECW_270 32 #define ROTATE_ANY (ROTATECW_90 | ROTATECW_180 | ROTATECW_270) -#define CROP_NONE \ - 0 /* "-S" -> Page_MODE_ROWSCOLS and page->rows/->cols != 0 \ - */ -#define CROP_MARGINS 1 /* "-m" */ -#define CROP_WIDTH 2 /* "-X" */ -#define CROP_LENGTH 4 /* "-Y" */ -#define CROP_ZONES 8 /* "-Z" */ -#define CROP_REGIONS 16 /* "-z" */ -#define CROP_ROTATE 32 -#define CROP_MIRROR 64 +#define CROP_NONE 0 +#define CROP_MARGINS 1 +#define CROP_WIDTH 2 +#define CROP_LENGTH 4 +#define CROP_ZONES 8 +#define CROP_REGIONS 16 +#define CROP_ROTATE 32 +#define CROP_MIRROR 64 #define CROP_INVERT 128 /* Modes for writing out images and selections */ -#define ONE_FILE_COMPOSITE 0 /* One file, sections combined sections */ -#define ONE_FILE_SEPARATED 1 /* One file, sections to new IFDs */ +#define ONE_FILE_COMPOSITE 0 /* One file, sections combined sections */ +#define ONE_FILE_SEPARATED 1 /* One file, sections to new IFDs */ #define FILE_PER_IMAGE_COMPOSITE 2 /* One file per image, combined sections */ #define FILE_PER_IMAGE_SEPARATED 3 /* One file per input image */ -#define FILE_PER_SELECTION 4 /* One file per selection */ +#define FILE_PER_SELECTION 4 /* One file per selection */ -#define COMPOSITE_IMAGES 0 /* Selections combined into one image */ -#define SEPARATED_IMAGES 1 /* Selections saved to separate images */ +#define COMPOSITE_IMAGES 0 /* Selections combined into one image */ +#define SEPARATED_IMAGES 1 /* Selections saved to separate images */ -#define STRIP 1 -#define TILE 2 +#define STRIP 1 +#define TILE 2 -#define MAX_REGIONS 8 /* number of regions to extract from a single page */ -#define MAX_OUTBUFFS 8 /* must match larger of zones or regions */ -#define MAX_SECTIONS 32 /* number of sections per page to write to output */ -#define MAX_IMAGES \ - 2048 /* number of images in descrete list, not in the file \ - */ -#define MAX_SAMPLES 8 /* maximum number of samples per pixel supported */ -#define MAX_BITS_PER_SAMPLE 64 /* maximum bit depth supported */ -#define MAX_EXPORT_PAGES 999999 /* maximum number of export pages per file */ +#define MAX_REGIONS 8 /* number of regions to extract from a single page */ +#define MAX_OUTBUFFS 8 /* must match larger of zones or regions */ +#define MAX_SECTIONS 32 /* number of sections per page to write to output */ +#define MAX_IMAGES 2048 /* number of images in descrete list, not in the file */ +#define MAX_SAMPLES 8 /* maximum number of samples per pixel supported */ +#define MAX_BITS_PER_SAMPLE 64 /* maximum bit depth supported */ +#define MAX_EXPORT_PAGES 999999 /* maximum number of export pages per file */ -#define DUMP_NONE 0 -#define DUMP_TEXT 1 -#define DUMP_RAW 2 +#define DUMP_NONE 0 +#define DUMP_TEXT 1 +#define DUMP_RAW 2 -#define TIFF_DIR_MAX 65534 - -/* To avoid mode buffer overflow */ -#define MAX_MODESTRING_LEN 9 +#define TIFF_DIR_MAX 65534 /* Some conversion subroutines require image buffers, which are at least 3 bytes * larger than the necessary size for the image itself. */ -#define NUM_BUFF_OVERSIZE_BYTES 3 +#define NUM_BUFF_OVERSIZE_BYTES 3 /* Offsets into buffer for margins and fixed width and length segments */ -struct offset -{ - uint32_t tmargin; - uint32_t lmargin; - uint32_t bmargin; - uint32_t rmargin; - uint32_t crop_width; - uint32_t crop_length; - uint32_t startx; - uint32_t endx; - uint32_t starty; - uint32_t endy; +struct offset { + uint32 tmargin; + uint32 lmargin; + uint32 bmargin; + uint32 rmargin; + uint32 crop_width; + uint32 crop_length; + uint32 startx; + uint32 endx; + uint32 starty; + uint32 endy; }; -/* Description of a zone within the image. Position 1 of 3 zones would be - * the first third of the image. These are computed after margins and - * width/length requests are applied so that you can extract multiple +/* Description of a zone within the image. Position 1 of 3 zones would be + * the first third of the image. These are computed after margins and + * width/length requests are applied so that you can extract multiple * zones from within a larger region for OCR or barcode recognition. */ -struct buffinfo -{ - size_t size; /* size of this buffer */ - unsigned char *buffer; /* address of the allocated buffer */ +struct buffinfo { + size_t size; /* size of this buffer */ + unsigned char *buffer; /* address of the allocated buffer */ }; -struct zone -{ - int position; /* ordinal of segment to be extracted */ - int total; /* total equal sized divisions of crop area */ +struct zone { + int position; /* ordinal of segment to be extracted */ + int total; /* total equal sized divisions of crop area */ + }; + +struct pageseg { + uint32 x1; /* index of left edge */ + uint32 x2; /* index of right edge */ + uint32 y1; /* index of top edge */ + uint32 y2; /* index of bottom edge */ + int position; /* ordinal of segment to be extracted */ + int total; /* total equal sized divisions of crop area */ + uint32 buffsize; /* size of buffer needed to hold the cropped zone */ }; -struct pageseg -{ - uint32_t x1; /* index of left edge */ - uint32_t x2; /* index of right edge */ - uint32_t y1; /* index of top edge */ - uint32_t y2; /* index of bottom edge */ - int position; /* ordinal of segment to be extracted */ - int total; /* total equal sized divisions of crop area */ - uint32_t buffsize; /* size of buffer needed to hold the cropped zone */ +struct coordpairs { + double X1; /* index of left edge in current units */ + double X2; /* index of right edge in current units */ + double Y1; /* index of top edge in current units */ + double Y2; /* index of bottom edge in current units */ }; -struct coordpairs -{ - double X1; /* index of left edge in current units */ - double X2; /* index of right edge in current units */ - double Y1; /* index of top edge in current units */ - double Y2; /* index of bottom edge in current units */ +struct region { + uint32 x1; /* pixel offset of left edge */ + uint32 x2; /* pixel offset of right edge */ + uint32 y1; /* pixel offset of top edge */ + uint32 y2; /* picel offset of bottom edge */ + uint32 width; /* width in pixels */ + uint32 length; /* length in pixels */ + uint32 buffsize; /* size of buffer needed to hold the cropped region */ }; -struct region -{ - uint32_t x1; /* pixel offset of left edge */ - uint32_t x2; /* pixel offset of right edge */ - uint32_t y1; /* pixel offset of top edge */ - uint32_t y2; /* picel offset of bottom edge */ - uint32_t width; /* width in pixels */ - uint32_t length; /* length in pixels */ - uint32_t buffsize; /* size of buffer needed to hold the cropped region */ -}; - -/* Cropping parameters from command line and image data - * Note: This should be renamed to proc_opts and expanded to include all current - * globals if possible, but each function that accesses global variables will - * have to be redone. +/* Cropping parameters from command line and image data + * Note: This should be renamed to proc_opts and expanded to include all current globals + * if possible, but each function that accesses global variables will have to be redone. */ -struct crop_mask -{ - double - width; /* Selection width for master crop region in requested units */ - double - length; /* Selection length for master crop region in requesed units */ - double margins[4]; /* Top, left, bottom, right margins */ - float xres; /* Horizontal resolution read from image*/ - float yres; /* Vertical resolution read from image */ - uint32_t combined_width; /* Width of combined cropped zones */ - uint32_t combined_length; /* Length of combined cropped zones */ - uint32_t - bufftotal; /* Size of buffer needed to hold all the cropped region */ - uint16_t img_mode; /* Composite or separate images created from zones or - regions */ - uint16_t - exp_mode; /* Export input images or selections to one or more files */ - uint16_t crop_mode; /* Crop options to be applied */ - uint16_t res_unit; /* Resolution unit for margins and selections */ - uint16_t - edge_ref; /* Reference edge for sections extraction and combination */ - uint16_t rotation; /* Clockwise rotation of the extracted region or image */ - uint16_t mirror; /* Mirror extracted region or image horizontally or - vertically */ - uint16_t invert; /* Invert the color map of image or region */ - uint16_t photometric; /* Status of photometric interpretation for inverted - image */ - uint16_t selections; /* Number of regions or zones selected */ - uint16_t regions; /* Number of regions delimited by corner coordinates */ - struct region - regionlist[MAX_REGIONS]; /* Regions within page or master crop region */ - uint16_t zones; /* Number of zones delimited by Ordinal:Total requested */ - struct zone zonelist[MAX_REGIONS]; /* Zones indices to define a region */ - struct coordpairs corners[MAX_REGIONS]; /* Coordinates of upper left and - lower right corner */ +struct crop_mask { + double width; /* Selection width for master crop region in requested units */ + double length; /* Selection length for master crop region in requesed units */ + double margins[4]; /* Top, left, bottom, right margins */ + float xres; /* Horizontal resolution read from image*/ + float yres; /* Vertical resolution read from image */ + uint32 combined_width; /* Width of combined cropped zones */ + uint32 combined_length; /* Length of combined cropped zones */ + uint32 bufftotal; /* Size of buffer needed to hold all the cropped region */ + uint16 img_mode; /* Composite or separate images created from zones or regions */ + uint16 exp_mode; /* Export input images or selections to one or more files */ + uint16 crop_mode; /* Crop options to be applied */ + uint16 res_unit; /* Resolution unit for margins and selections */ + uint16 edge_ref; /* Reference edge for sections extraction and combination */ + uint16 rotation; /* Clockwise rotation of the extracted region or image */ + uint16 mirror; /* Mirror extracted region or image horizontally or vertically */ + uint16 invert; /* Invert the color map of image or region */ + uint16 photometric; /* Status of photometric interpretation for inverted image */ + uint16 selections; /* Number of regions or zones selected */ + uint16 regions; /* Number of regions delimited by corner coordinates */ + struct region regionlist[MAX_REGIONS]; /* Regions within page or master crop region */ + uint16 zones; /* Number of zones delimited by Ordinal:Total requested */ + struct zone zonelist[MAX_REGIONS]; /* Zones indices to define a region */ + struct coordpairs corners[MAX_REGIONS]; /* Coordinates of upper left and lower right corner */ }; -#define MAX_PAPERNAMES \ - (sizeof(PaperTable) / sizeof(PaperTable[0])) /* was 49 \ - */ +#define MAX_PAPERNAMES 49 #define MAX_PAPERNAME_LENGTH 15 -#define DEFAULT_RESUNIT RESUNIT_INCH -#define DEFAULT_PAGE_HEIGHT 14.0 -#define DEFAULT_PAGE_WIDTH 8.5 -#define DEFAULT_RESOLUTION 300 -#define DEFAULT_PAPER_SIZE "legal" +#define DEFAULT_RESUNIT RESUNIT_INCH +#define DEFAULT_PAGE_HEIGHT 14.0 +#define DEFAULT_PAGE_WIDTH 8.5 +#define DEFAULT_RESOLUTION 300 +#define DEFAULT_PAPER_SIZE "legal" -#define ORIENTATION_NONE 0 -#define ORIENTATION_PORTRAIT 1 -#define ORIENTATION_LANDSCAPE 2 -#define ORIENTATION_SEASCAPE 4 -#define ORIENTATION_AUTO 16 +#define ORIENTATION_NONE 0 +#define ORIENTATION_PORTRAIT 1 +#define ORIENTATION_LANDSCAPE 2 +#define ORIENTATION_SEASCAPE 4 +#define ORIENTATION_AUTO 16 -#define PAGE_MODE_NONE 0 -#define PAGE_MODE_RESOLUTION 1 -#define PAGE_MODE_PAPERSIZE 2 -#define PAGE_MODE_MARGINS 4 -#define PAGE_MODE_ROWSCOLS 8 /* for -S option */ +#define PAGE_MODE_NONE 0 +#define PAGE_MODE_RESOLUTION 1 +#define PAGE_MODE_PAPERSIZE 2 +#define PAGE_MODE_MARGINS 4 +#define PAGE_MODE_ROWSCOLS 8 -#define INVERT_DATA_ONLY 10 -#define INVERT_DATA_AND_TAG 11 +#define INVERT_DATA_ONLY 10 +#define INVERT_DATA_AND_TAG 11 -struct paperdef -{ - char name[MAX_PAPERNAME_LENGTH]; - double width; - double length; - double asratio; -}; +struct paperdef { + char name[MAX_PAPERNAME_LENGTH]; + double width; + double length; + double asratio; + }; -/* European page sizes corrected from update sent by +/* European page sizes corrected from update sent by * thomas . jarosch @ intra2net . com on 5/7/2010 * Paper Size Width Length Aspect Ratio */ -static const struct paperdef PaperTable[/*MAX_PAPERNAMES*/] = { - {"default", 8.500, 14.000, 0.607}, - {"pa4", 8.264, 11.000, 0.751}, - {"letter", 8.500, 11.000, 0.773}, - {"legal", 8.500, 14.000, 0.607}, - {"half-letter", 8.500, 5.514, 1.542}, - {"executive", 7.264, 10.528, 0.690}, - {"tabloid", 11.000, 17.000, 0.647}, - {"11x17", 11.000, 17.000, 0.647}, - {"ledger", 17.000, 11.000, 1.545}, - {"archa", 9.000, 12.000, 0.750}, - {"archb", 12.000, 18.000, 0.667}, - {"archc", 18.000, 24.000, 0.750}, - {"archd", 24.000, 36.000, 0.667}, - {"arche", 36.000, 48.000, 0.750}, - {"csheet", 17.000, 22.000, 0.773}, - {"dsheet", 22.000, 34.000, 0.647}, - {"esheet", 34.000, 44.000, 0.773}, - {"superb", 11.708, 17.042, 0.687}, - {"commercial", 4.139, 9.528, 0.434}, - {"monarch", 3.889, 7.528, 0.517}, - {"envelope-dl", 4.333, 8.681, 0.499}, - {"envelope-c5", 6.389, 9.028, 0.708}, - {"europostcard", 4.139, 5.833, 0.710}, - {"a0", 33.110, 46.811, 0.707}, - {"a1", 23.386, 33.110, 0.706}, - {"a2", 16.535, 23.386, 0.707}, - {"a3", 11.693, 16.535, 0.707}, - {"a4", 8.268, 11.693, 0.707}, - {"a5", 5.827, 8.268, 0.705}, - {"a6", 4.134, 5.827, 0.709}, - {"a7", 2.913, 4.134, 0.705}, - {"a8", 2.047, 2.913, 0.703}, - {"a9", 1.457, 2.047, 0.712}, - {"a10", 1.024, 1.457, 0.703}, - {"b0", 39.370, 55.669, 0.707}, - {"b1", 27.835, 39.370, 0.707}, - {"b2", 19.685, 27.835, 0.707}, - {"b3", 13.898, 19.685, 0.706}, - {"b4", 9.843, 13.898, 0.708}, - {"b5", 6.929, 9.843, 0.704}, - {"b6", 4.921, 6.929, 0.710}, - {"c0", 36.102, 51.063, 0.707}, - {"c1", 25.512, 36.102, 0.707}, - {"c2", 18.031, 25.512, 0.707}, - {"c3", 12.756, 18.031, 0.707}, - {"c4", 9.016, 12.756, 0.707}, - {"c5", 6.378, 9.016, 0.707}, - {"c6", 4.488, 6.378, 0.704}, - {"", 0.000, 0.000, 1.000}}; +const struct paperdef PaperTable[MAX_PAPERNAMES] = { + {"default", 8.500, 14.000, 0.607}, + {"pa4", 8.264, 11.000, 0.751}, + {"letter", 8.500, 11.000, 0.773}, + {"legal", 8.500, 14.000, 0.607}, + {"half-letter", 8.500, 5.514, 1.542}, + {"executive", 7.264, 10.528, 0.690}, + {"tabloid", 11.000, 17.000, 0.647}, + {"11x17", 11.000, 17.000, 0.647}, + {"ledger", 17.000, 11.000, 1.545}, + {"archa", 9.000, 12.000, 0.750}, + {"archb", 12.000, 18.000, 0.667}, + {"archc", 18.000, 24.000, 0.750}, + {"archd", 24.000, 36.000, 0.667}, + {"arche", 36.000, 48.000, 0.750}, + {"csheet", 17.000, 22.000, 0.773}, + {"dsheet", 22.000, 34.000, 0.647}, + {"esheet", 34.000, 44.000, 0.773}, + {"superb", 11.708, 17.042, 0.687}, + {"commercial", 4.139, 9.528, 0.434}, + {"monarch", 3.889, 7.528, 0.517}, + {"envelope-dl", 4.333, 8.681, 0.499}, + {"envelope-c5", 6.389, 9.028, 0.708}, + {"europostcard", 4.139, 5.833, 0.710}, + {"a0", 33.110, 46.811, 0.707}, + {"a1", 23.386, 33.110, 0.706}, + {"a2", 16.535, 23.386, 0.707}, + {"a3", 11.693, 16.535, 0.707}, + {"a4", 8.268, 11.693, 0.707}, + {"a5", 5.827, 8.268, 0.705}, + {"a6", 4.134, 5.827, 0.709}, + {"a7", 2.913, 4.134, 0.705}, + {"a8", 2.047, 2.913, 0.703}, + {"a9", 1.457, 2.047, 0.712}, + {"a10", 1.024, 1.457, 0.703}, + {"b0", 39.370, 55.669, 0.707}, + {"b1", 27.835, 39.370, 0.707}, + {"b2", 19.685, 27.835, 0.707}, + {"b3", 13.898, 19.685, 0.706}, + {"b4", 9.843, 13.898, 0.708}, + {"b5", 6.929, 9.843, 0.704}, + {"b6", 4.921, 6.929, 0.710}, + {"c0", 36.102, 51.063, 0.707}, + {"c1", 25.512, 36.102, 0.707}, + {"c2", 18.031, 25.512, 0.707}, + {"c3", 12.756, 18.031, 0.707}, + {"c4", 9.016, 12.756, 0.707}, + {"c5", 6.378, 9.016, 0.707}, + {"c6", 4.488, 6.378, 0.704}, + {"", 0.000, 0.000, 1.000} +}; /* Structure to define input image parameters */ -struct image_data -{ - float xres; - float yres; - uint32_t width; - uint32_t length; - uint16_t res_unit; - uint16_t bps; - uint16_t spp; - uint16_t planar; - uint16_t photometric; - uint16_t orientation; - uint16_t compression; - uint16_t adjustments; +struct image_data { + float xres; + float yres; + uint32 width; + uint32 length; + uint16 res_unit; + uint16 bps; + uint16 spp; + uint16 planar; + uint16 photometric; + uint16 orientation; + uint16 compression; + uint16 adjustments; }; /* Structure to define the output image modifiers */ -struct pagedef -{ - char name[16]; - double width; /* width in pixels */ - double length; /* length in pixels */ - double hmargin; /* margins to subtract from width of sections */ - double vmargin; /* margins to subtract from height of sections */ - double hres; /* horizontal resolution for output */ - double vres; /* vertical resolution for output */ - uint32_t mode; /* bitmask of modifiers to page format */ - uint16_t res_unit; /* resolution unit for output image */ - unsigned int rows; /* number of section rows */ - unsigned int cols; /* number of section cols */ - unsigned int orient; /* portrait, landscape, seascape, auto */ +struct pagedef { + char name[16]; + double width; /* width in pixels */ + double length; /* length in pixels */ + double hmargin; /* margins to subtract from width of sections */ + double vmargin; /* margins to subtract from height of sections */ + double hres; /* horizontal resolution for output */ + double vres; /* vertical resolution for output */ + uint32 mode; /* bitmask of modifiers to page format */ + uint16 res_unit; /* resolution unit for output image */ + unsigned int rows; /* number of section rows */ + unsigned int cols; /* number of section cols */ + unsigned int orient; /* portrait, landscape, seascape, auto */ }; -struct dump_opts -{ - int debug; - int format; - int level; - char mode[4]; - char infilename[PATH_MAX + 1]; - char outfilename[PATH_MAX + 1]; - FILE *infile; - FILE *outfile; -}; +struct dump_opts { + int debug; + int format; + int level; + char mode[4]; + char infilename[PATH_MAX + 1]; + char outfilename[PATH_MAX + 1]; + FILE *infile; + FILE *outfile; + }; /* globals */ -static int outtiled = -1; -static uint32_t tilewidth = 0; -static uint32_t tilelength = 0; +static int outtiled = -1; +static uint32 tilewidth = 0; +static uint32 tilelength = 0; -static uint16_t config = 0; -static uint16_t compression = 0; -static uint16_t predictor = 0; -static uint16_t fillorder = 0; -static uint32_t rowsperstrip = 0; -static uint32_t g3opts = 0; -static int ignore = FALSE; /* if true, ignore read errors */ -static uint32_t defg3opts = (uint32_t)-1; -static int quality = 100; /* JPEG quality */ +static uint16 config = 0; +static uint16 compression = 0; +static uint16 predictor = 0; +static uint16 fillorder = 0; +static uint32 rowsperstrip = 0; +static uint32 g3opts = 0; +static int ignore = FALSE; /* if true, ignore read errors */ +static uint32 defg3opts = (uint32) -1; +static int quality = 100; /* JPEG quality */ /* static int jpegcolormode = -1; was JPEGCOLORMODE_RGB; */ -static int jpegcolormode = JPEGCOLORMODE_RGB; -static uint16_t defcompression = (uint16_t)-1; -static uint16_t defpredictor = (uint16_t)-1; -static int pageNum = 0; -static int little_endian = 1; +static int jpegcolormode = JPEGCOLORMODE_RGB; +static uint16 defcompression = (uint16) -1; +static uint16 defpredictor = (uint16) -1; +static int pageNum = 0; +static int little_endian = 1; /* Functions adapted from tiffcp with additions or significant modifications */ -static int readContigStripsIntoBuffer(TIFF *, uint8_t *); -static int readSeparateStripsIntoBuffer(TIFF *, uint8_t *, uint32_t, uint32_t, - tsample_t, struct dump_opts *); -static int readContigTilesIntoBuffer(TIFF *, uint8_t *, uint32_t, uint32_t, - uint32_t, uint32_t, tsample_t, uint16_t); -static int readSeparateTilesIntoBuffer(TIFF *, uint8_t *, uint32_t, uint32_t, - uint32_t, uint32_t, tsample_t, uint16_t); -static int writeBufferToContigStrips(TIFF *, uint8_t *, uint32_t); -static int writeBufferToContigTiles(TIFF *, uint8_t *, uint32_t, uint32_t, - tsample_t, struct dump_opts *); -static int writeBufferToSeparateStrips(TIFF *, uint8_t *, uint32_t, uint32_t, - tsample_t, struct dump_opts *); -static int writeBufferToSeparateTiles(TIFF *, uint8_t *, uint32_t, uint32_t, - tsample_t, struct dump_opts *); -static int extractContigSamplesToBuffer(uint8_t *, uint8_t *, uint32_t, - uint32_t, tsample_t, uint16_t, uint16_t, - struct dump_opts *); -static int processCompressOptions(char *); +static int readContigStripsIntoBuffer (TIFF*, uint8*); +static int readSeparateStripsIntoBuffer (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); +static int readContigTilesIntoBuffer (TIFF*, uint8*, uint32, uint32, uint32, uint32, tsample_t, uint16); +static int readSeparateTilesIntoBuffer (TIFF*, uint8*, uint32, uint32, uint32, uint32, tsample_t, uint16); +static int writeBufferToContigStrips (TIFF*, uint8*, uint32); +static int writeBufferToContigTiles (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); +static int writeBufferToSeparateStrips (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); +static int writeBufferToSeparateTiles (TIFF*, uint8*, uint32, uint32, tsample_t, struct dump_opts *); +static int extractContigSamplesToBuffer (uint8 *, uint8 *, uint32, uint32, tsample_t, + uint16, uint16, struct dump_opts *); +static int processCompressOptions(char*); static void usage(int code); /* All other functions by Richard Nolde, not found in tiffcp */ -static void initImageData(struct image_data *); -static void initCropMasks(struct crop_mask *); -static void initPageSetup(struct pagedef *, struct pageseg *, - struct buffinfo[]); +static void initImageData (struct image_data *); +static void initCropMasks (struct crop_mask *); +static void initPageSetup (struct pagedef *, struct pageseg *, struct buffinfo []); static void initDumpOptions(struct dump_opts *); /* Command line and file naming functions */ -void process_command_opts(int, char *[], char *, char *, uint32_t *, uint16_t *, - uint16_t *, uint32_t *, uint32_t *, uint32_t *, - struct crop_mask *, struct pagedef *, - struct dump_opts *, unsigned int *, unsigned int *); -static int update_output_file(TIFF **, char *, int, char *, unsigned int *); +void process_command_opts (int, char *[], char *, char *, uint32 *, + uint16 *, uint16 *, uint32 *, uint32 *, uint32 *, + struct crop_mask *, struct pagedef *, + struct dump_opts *, + unsigned int *, unsigned int *); +static int update_output_file (TIFF **, char *, int, char *, unsigned int *); + /* * High level functions for whole image manipulation */ -static int get_page_geometry(char *, struct pagedef *); -static int computeInputPixelOffsets(struct crop_mask *, struct image_data *, - struct offset *); -static int computeOutputPixelOffsets(struct crop_mask *, struct image_data *, - struct pagedef *, struct pageseg *, - struct dump_opts *); -static int loadImage(TIFF *, struct image_data *, struct dump_opts *, - unsigned char **); -static int correct_orientation(struct image_data *, unsigned char **); -static int getCropOffsets(struct image_data *, struct crop_mask *, - struct dump_opts *); -static int processCropSelections(struct image_data *, struct crop_mask *, - unsigned char **, struct buffinfo[]); -static int writeSelections(TIFF *, TIFF **, struct crop_mask *, - struct image_data *, struct dump_opts *, - struct buffinfo[], char *, char *, unsigned int *, - unsigned int); +static int get_page_geometry (char *, struct pagedef*); +static int computeInputPixelOffsets(struct crop_mask *, struct image_data *, + struct offset *); +static int computeOutputPixelOffsets (struct crop_mask *, struct image_data *, + struct pagedef *, struct pageseg *, + struct dump_opts *); +static int loadImage(TIFF *, struct image_data *, struct dump_opts *, unsigned char **); +static int correct_orientation(struct image_data *, unsigned char **); +static int getCropOffsets(struct image_data *, struct crop_mask *, struct dump_opts *); +static int processCropSelections(struct image_data *, struct crop_mask *, + unsigned char **, struct buffinfo []); +static int writeSelections(TIFF *, TIFF **, struct crop_mask *, struct image_data *, + struct dump_opts *, struct buffinfo [], + char *, char *, unsigned int*, unsigned int); /* Section functions */ -static int createImageSection(uint32_t, unsigned char **); -static int extractImageSection(struct image_data *, struct pageseg *, - unsigned char *, unsigned char *); -static int writeSingleSection(TIFF *, TIFF *, struct image_data *, - struct dump_opts *, uint32_t, uint32_t, double, - double, unsigned char *); -static int writeImageSections(TIFF *, TIFF *, struct image_data *, - struct pagedef *, struct pageseg *, - struct dump_opts *, unsigned char *, - unsigned char **); +static int createImageSection(uint32, unsigned char **); +static int extractImageSection(struct image_data *, struct pageseg *, + unsigned char *, unsigned char *); +static int writeSingleSection(TIFF *, TIFF *, struct image_data *, + struct dump_opts *, uint32, uint32, + double, double, unsigned char *); +static int writeImageSections(TIFF *, TIFF *, struct image_data *, + struct pagedef *, struct pageseg *, + struct dump_opts *, unsigned char *, + unsigned char **); /* Whole image functions */ -static int createCroppedImage(struct image_data *, struct crop_mask *, - unsigned char **, unsigned char **); -static int writeCroppedImage(TIFF *, TIFF *, struct image_data *image, - struct dump_opts *dump, uint32_t, uint32_t, - unsigned char *, int, int); +static int createCroppedImage(struct image_data *, struct crop_mask *, + unsigned char **, unsigned char **); +static int writeCroppedImage(TIFF *, TIFF *, struct image_data *image, + struct dump_opts * dump, + uint32, uint32, unsigned char *, int, int); /* Image manipulation functions */ -static int rotateContigSamples8bits(uint16_t, uint16_t, uint16_t, uint32_t, - uint32_t, uint32_t, uint8_t *, uint8_t *); -static int rotateContigSamples16bits(uint16_t, uint16_t, uint16_t, uint32_t, - uint32_t, uint32_t, uint8_t *, uint8_t *); -static int rotateContigSamples24bits(uint16_t, uint16_t, uint16_t, uint32_t, - uint32_t, uint32_t, uint8_t *, uint8_t *); -static int rotateContigSamples32bits(uint16_t, uint16_t, uint16_t, uint32_t, - uint32_t, uint32_t, uint8_t *, uint8_t *); -static int rotateImage(uint16_t, struct image_data *, uint32_t *, uint32_t *, - unsigned char **, size_t *, int); -static int mirrorImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t, - unsigned char *); -static int invertImage(uint16_t, uint16_t, uint16_t, uint32_t, uint32_t, - unsigned char *); +static int rotateContigSamples8bits(uint16, uint16, uint16, uint32, + uint32, uint32, uint8 *, uint8 *); +static int rotateContigSamples16bits(uint16, uint16, uint16, uint32, + uint32, uint32, uint8 *, uint8 *); +static int rotateContigSamples24bits(uint16, uint16, uint16, uint32, + uint32, uint32, uint8 *, uint8 *); +static int rotateContigSamples32bits(uint16, uint16, uint16, uint32, + uint32, uint32, uint8 *, uint8 *); +static int rotateImage(uint16, struct image_data *, uint32 *, uint32 *, + unsigned char **, int); +static int mirrorImage(uint16, uint16, uint16, uint32, uint32, + unsigned char *); +static int invertImage(uint16, uint16, uint16, uint32, uint32, + unsigned char *); /* Functions to reverse the sequence of samples in a scanline */ -static int reverseSamples8bits(uint16_t, uint16_t, uint32_t, uint8_t *, - uint8_t *); -static int reverseSamples16bits(uint16_t, uint16_t, uint32_t, uint8_t *, - uint8_t *); -static int reverseSamples24bits(uint16_t, uint16_t, uint32_t, uint8_t *, - uint8_t *); -static int reverseSamples32bits(uint16_t, uint16_t, uint32_t, uint8_t *, - uint8_t *); -static int reverseSamplesBytes(uint16_t, uint16_t, uint32_t, uint8_t *, - uint8_t *); +static int reverseSamples8bits (uint16, uint16, uint32, uint8 *, uint8 *); +static int reverseSamples16bits (uint16, uint16, uint32, uint8 *, uint8 *); +static int reverseSamples24bits (uint16, uint16, uint32, uint8 *, uint8 *); +static int reverseSamples32bits (uint16, uint16, uint32, uint8 *, uint8 *); +static int reverseSamplesBytes (uint16, uint16, uint32, uint8 *, uint8 *); /* Functions for manipulating individual samples in an image */ static int extractSeparateRegion(struct image_data *, struct crop_mask *, - unsigned char *, unsigned char *, int); -static int extractCompositeRegions(struct image_data *, struct crop_mask *, - unsigned char *, unsigned char *); -static int extractContigSamples8bits(uint8_t *, uint8_t *, uint32_t, tsample_t, - uint16_t, uint16_t, tsample_t, uint32_t, - uint32_t); -static int extractContigSamples16bits(uint8_t *, uint8_t *, uint32_t, tsample_t, - uint16_t, uint16_t, tsample_t, uint32_t, - uint32_t); -static int extractContigSamples24bits(uint8_t *, uint8_t *, uint32_t, tsample_t, - uint16_t, uint16_t, tsample_t, uint32_t, - uint32_t); -static int extractContigSamples32bits(uint8_t *, uint8_t *, uint32_t, tsample_t, - uint16_t, uint16_t, tsample_t, uint32_t, - uint32_t); -static int extractContigSamplesBytes(uint8_t *, uint8_t *, uint32_t, tsample_t, - uint16_t, uint16_t, tsample_t, uint32_t, - uint32_t); -static int extractContigSamplesShifted8bits(uint8_t *, uint8_t *, uint32_t, - tsample_t, uint16_t, uint16_t, - tsample_t, uint32_t, uint32_t, int); -static int extractContigSamplesShifted16bits(uint8_t *, uint8_t *, uint32_t, - tsample_t, uint16_t, uint16_t, - tsample_t, uint32_t, uint32_t, + unsigned char *, unsigned char *, int); +static int extractCompositeRegions(struct image_data *, struct crop_mask *, + unsigned char *, unsigned char *); +static int extractContigSamples8bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamples16bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamples24bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamples32bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamplesBytes (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32); +static int extractContigSamplesShifted8bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32, int); -static int extractContigSamplesShifted24bits(uint8_t *, uint8_t *, uint32_t, - tsample_t, uint16_t, uint16_t, - tsample_t, uint32_t, uint32_t, - int); -static int extractContigSamplesShifted32bits(uint8_t *, uint8_t *, uint32_t, - tsample_t, uint16_t, uint16_t, - tsample_t, uint32_t, uint32_t, - int); -static int extractContigSamplesToTileBuffer(uint8_t *, uint8_t *, uint32_t, - uint32_t, uint32_t, uint32_t, - tsample_t, uint16_t, uint16_t, - uint16_t, struct dump_opts *); +static int extractContigSamplesShifted16bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32, + int); +static int extractContigSamplesShifted24bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32, + int); +static int extractContigSamplesShifted32bits (uint8 *, uint8 *, uint32, + tsample_t, uint16, uint16, + tsample_t, uint32, uint32, + int); +static int extractContigSamplesToTileBuffer(uint8 *, uint8 *, uint32, uint32, + uint32, uint32, tsample_t, uint16, + uint16, uint16, struct dump_opts *); /* Functions to combine separate planes into interleaved planes */ -static int combineSeparateSamples8bits(uint8_t *[], uint8_t *, uint32_t, - uint32_t, uint16_t, uint16_t, FILE *, - int, int); -static int combineSeparateSamples16bits(uint8_t *[], uint8_t *, uint32_t, - uint32_t, uint16_t, uint16_t, FILE *, - int, int); -static int combineSeparateSamples24bits(uint8_t *[], uint8_t *, uint32_t, - uint32_t, uint16_t, uint16_t, FILE *, - int, int); -static int combineSeparateSamples32bits(uint8_t *[], uint8_t *, uint32_t, - uint32_t, uint16_t, uint16_t, FILE *, - int, int); -static int combineSeparateSamplesBytes(unsigned char *[], unsigned char *, - uint32_t, uint32_t, tsample_t, uint16_t, - FILE *, int, int); +static int combineSeparateSamples8bits (uint8 *[], uint8 *, uint32, uint32, + uint16, uint16, FILE *, int, int); +static int combineSeparateSamples16bits (uint8 *[], uint8 *, uint32, uint32, + uint16, uint16, FILE *, int, int); +static int combineSeparateSamples24bits (uint8 *[], uint8 *, uint32, uint32, + uint16, uint16, FILE *, int, int); +static int combineSeparateSamples32bits (uint8 *[], uint8 *, uint32, uint32, + uint16, uint16, FILE *, int, int); +static int combineSeparateSamplesBytes (unsigned char *[], unsigned char *, + uint32, uint32, tsample_t, uint16, + FILE *, int, int); -static int combineSeparateTileSamples8bits(uint8_t *[], uint8_t *, uint32_t, - uint32_t, uint32_t, uint32_t, - uint16_t, uint16_t, FILE *, int, - int); -static int combineSeparateTileSamples16bits(uint8_t *[], uint8_t *, uint32_t, - uint32_t, uint32_t, uint32_t, - uint16_t, uint16_t, FILE *, int, - int); -static int combineSeparateTileSamples24bits(uint8_t *[], uint8_t *, uint32_t, - uint32_t, uint32_t, uint32_t, - uint16_t, uint16_t, FILE *, int, - int); -static int combineSeparateTileSamples32bits(uint8_t *[], uint8_t *, uint32_t, - uint32_t, uint32_t, uint32_t, - uint16_t, uint16_t, FILE *, int, - int); -static int combineSeparateTileSamplesBytes(unsigned char *[], unsigned char *, - uint32_t, uint32_t, uint32_t, - uint32_t, tsample_t, uint16_t, - FILE *, int, int); +static int combineSeparateTileSamples8bits (uint8 *[], uint8 *, uint32, uint32, + uint32, uint32, uint16, uint16, + FILE *, int, int); +static int combineSeparateTileSamples16bits (uint8 *[], uint8 *, uint32, uint32, + uint32, uint32, uint16, uint16, + FILE *, int, int); +static int combineSeparateTileSamples24bits (uint8 *[], uint8 *, uint32, uint32, + uint32, uint32, uint16, uint16, + FILE *, int, int); +static int combineSeparateTileSamples32bits (uint8 *[], uint8 *, uint32, uint32, + uint32, uint32, uint16, uint16, + FILE *, int, int); +static int combineSeparateTileSamplesBytes (unsigned char *[], unsigned char *, + uint32, uint32, uint32, uint32, + tsample_t, uint16, FILE *, int, int); /* Dump functions for debugging */ -static void dump_info(FILE *, int, char *, char *, ...); -static int dump_data(FILE *, int, char *, unsigned char *, uint32_t); -static int dump_byte(FILE *, int, char *, unsigned char); -static int dump_short(FILE *, int, char *, uint16_t); -static int dump_long(FILE *, int, char *, uint32_t); -static int dump_wide(FILE *, int, char *, uint64_t); -static int dump_buffer(FILE *, int, uint32_t, uint32_t, uint32_t, - unsigned char *); +static void dump_info (FILE *, int, char *, char *, ...); +static int dump_data (FILE *, int, char *, unsigned char *, uint32); +static int dump_byte (FILE *, int, char *, unsigned char); +static int dump_short (FILE *, int, char *, uint16); +static int dump_long (FILE *, int, char *, uint32); +static int dump_wide (FILE *, int, char *, uint64); +static int dump_buffer (FILE *, int, uint32, uint32, uint32, unsigned char *); /* End function declarations */ /* Functions derived in whole or in part from tiffcp */ @@ -695,1778 +632,1520 @@ static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC; /** * This custom malloc function enforce a maximum allocation size */ -static void *limitMalloc(tmsize_t s) +static void* limitMalloc(tmsize_t s) { - if (maxMalloc && (s > maxMalloc)) - { - fprintf(stderr, - "MemoryLimitError: allocation of %" PRIu64 - " bytes is forbidden. Limit is %" PRIu64 ".\n", - (uint64_t)s, (uint64_t)maxMalloc); - fprintf(stderr, " use -k option to change limit.\n"); - return NULL; - } - return _TIFFmalloc(s); + if (maxMalloc && (s > maxMalloc)) { + fprintf(stderr, "MemoryLimitError: allocation of " TIFF_UINT64_FORMAT " bytes is forbidden. Limit is " TIFF_UINT64_FORMAT ".\n", + (uint64)s, (uint64)maxMalloc); + fprintf(stderr, " use -k option to change limit.\n"); return NULL; + } + return _TIFFmalloc(s); } -static const char usage_info[] = - "Copy, crop, convert, extract, and/or process TIFF files\n\n" - "usage: tiffcrop [options] source1 ... sourceN destination\n" - "where options are:\n" - " -h Print this syntax listing\n" - " -v Print tiffcrop version identifier and last revision date\n" - " \n" - " -a Append to output instead of overwriting\n" - " -B Force output to be written with Big - Endian byte order.\n" - " -L Force output to be written with Little-Endian byte order.\n" - " -M Suppress the use of memory-mapped files when reading images.\n" - " -C Suppress the use of \"strip chopping\" when reading images that " - "have a single strip/tile of uncompressed data.\n" - " \n" - " -d offset Set initial directory offset, counting first image as one, " - "not zero\n" - " -p contig Pack samples contiguously (e.g. RGBRGB...)\n" - " -p separate Store samples separately (e.g. RRR...GGG...BBB...)\n" - " -s Write output in strips\n" - " -t Write output in tiles\n" - " -i Ignore read errors\n" - " -k size Set the memory allocation limit in MiB. 0 to disable limit\n" - " \n" - " -r # Make each strip have no more than # rows\n" - " -w # Set output tile width (pixels)\n" - " -l # Set output tile length (pixels)\n" - " \n" - " -f lsb2msb Force lsb-to-msb FillOrder for output\n" - " -f msb2lsb Force msb-to-lsb FillOrder for output\n" - "\n" -#ifdef LZW_SUPPORT - " -c lzw[:opts] Compress output with Lempel-Ziv & Welch encoding\n" - /* " LZW options:\n" */ - " # Set predictor value\n" - " For example, -c lzw:2 for LZW-encoded data with horizontal " - "differencing\n" -#endif -#ifdef ZIP_SUPPORT - " -c zip[:opts] Compress output with deflate encoding\n" - /* " Deflate (ZIP) options:\n" */ - " # Set predictor value\n" -#endif -#ifdef JPEG_SUPPORT - " -c jpeg[:opts] Compress output with JPEG encoding\n" - /* " JPEG options:\n" */ - " # Set compression quality level (0-100, default 100)\n" - " raw Output color image as raw YCbCr (default)\n" - " rgb Output color image as RGB\n" - " For example, -c jpeg:rgb:50 for JPEG-encoded RGB with 50% comp. " - "quality\n" -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits Compress output with packbits encoding\n" -#endif -#ifdef CCITT_SUPPORT - " -c g3[:opts] Compress output with CCITT Group 3 encoding\n" - /* " CCITT Group 3 options:\n" */ - " 1d Use default CCITT Group 3 1D-encoding\n" - " 2d Use optional CCITT Group 3 2D-encoding\n" - " fill Byte-align EOL codes\n" - " For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned " - "EOLs\n" - " -c g4 Compress output with CCITT Group 4 encoding\n" -#endif -#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(JPEG_SUPPORT) || \ - defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) - " -c none Use no compression algorithm on output\n" -#endif - "\n" - "Page and selection options:\n" - " -N odd|even|#,#-#,#|last sequences and ranges of images within " - "file to process\n" - " The words odd or even may be used to specify all odd or even " - "numbered images.\n" - " The word last may be used in place of a number in the " - "sequence to indicate.\n" - " The final image in the file without knowing how many images " - "there are.\n" - " Numbers are counted from one even though TIFF IFDs are " - "counted from zero.\n" - "\n" - " -E t|l|r|b edge to use as origin for width and length of crop region\n" - " -U units [in, cm, px ] inches, centimeters or pixels\n" - " \n" - " -m #,#,#,# margins from edges for selection: top, left, bottom, right " - "separated by commas\n" - " -X # horizontal dimension of region to extract expressed in " - "current units\n" - " -Y # vertical dimension of region to extract expressed in current " - "units\n" - " -Z #:#,#:# zones of the image designated as position X of Y,\n" - " eg 1:3 would be first of three equal portions measured from " - "reference edge\n" - " -z x1,y1,x2,y2:...:xN,yN,xN+1,yN+1\n" - " regions of the image designated by upper left and lower " - "right coordinates\n" - "\n" - "Export grouping options:\n" - " -e c|d|i|m|s export mode for images and selections from input " - "images.\n" - " When exporting a composite image from multiple zones or " - "regions\n" - " (combined and image modes), the selections must have " - "equal sizes\n" - " for the axis perpendicular to the edge specified with " - "-E.\n" - " c|combined All images and selections are written to a single file " - "(default).\n" - " with multiple selections from one image combined into a " - "single image.\n" - " d|divided All images and selections are written to a single file\n" - " with each selection from one image written to a new " - "image.\n" - " i|image Each input image is written to a new file (numeric " - "filename sequence)\n" - " with multiple selections from the image combined into " - "one image.\n" - " m|multiple Each input image is written to a new file (numeric " - "filename sequence)\n" - " with each selection from the image written to a new " - "image.\n" - " s|separated Individual selections from each image are written to " - "separate files.\n" - "\n" - "Output options:\n" - " -H # Set horizontal resolution of output images to #\n" - " -V # Set vertical resolution of output images to #\n" - " -J # Set horizontal margin of output page to # expressed in " - "current units\n" - " when sectioning image into columns x rows using the -S " - "cols:rows option\n" - " -K # Set verticalal margin of output page to # expressed in " - "current units\n" - " when sectioning image into columns x rows using the -S " - "cols:rows option\n" - " \n" - " -O orient orientation for output image, portrait, landscape, auto\n" - " -P page page size for output image segments, eg letter, legal, " - "tabloid, etc\n" - " use #.#x#.# to specify a custom page size in the currently " - "defined units\n" - " where #.# represents the width and length\n" - " -S cols:rows Divide the image into equal sized segments using cols " - "across and rows down.\n" - "\n" - " -F hor|vert|both\n" - " flip (mirror) image or region horizontally, vertically, or " - "both\n" - " -R # [90,180,or 270] degrees clockwise rotation of image or " - "extracted region\n" - " -I [black|white|data|both]\n" - " invert color space, eg dark to light for bilevel and " - "grayscale images\n" - " If argument is white or black, set the " - "PHOTOMETRIC_INTERPRETATION \n" - " tag to MinIsBlack or MinIsWhite without altering the image " - "data\n" - " If the argument is data or both, the image data are " - "modified:\n" - " both inverts the data and the PHOTOMETRIC_INTERPRETATION " - "tag,\n" - " data inverts the data but not the PHOTOMETRIC_INTERPRETATION " - "tag\n" - "\n" - "-D opt1:value1,opt2:value2,opt3:value3:opt4:value4\n" - " Debug/dump program progress and/or data to non-TIFF files.\n" - " Options include the following and must be joined as a comma\n" - " separate list. The use of this option is generally limited " - "to\n" - " program debugging and development of future options.\n" - "\n" - " debug:N Display limited program progress indicators where larger N\n" - " increase the level of detail. Note: Tiffcrop may be compiled " - "with\n" - " -DDEVELMODE to enable additional very low level debug " - "reporting.\n" - "\n" - " Format:txt|raw Format any logged data as ASCII text or raw binary \n" - " values. ASCII text dumps include strings of ones and zeroes\n" - " representing the binary values in the image data plus " - "identifying headers.\n" - "\n" - " level:N Specify the level of detail presented in the dump files.\n" - " This can vary from dumps of the entire input or output image " - "data to dumps\n" - " of data processed by specific functions. Current range of " - "levels is 1 to 3.\n" - "\n" - " input:full-path-to-directory/input-dumpname\n" - "\n" - " output:full-path-to-directory/output-dumpnaem\n" - "\n" - " When dump files are being written, each image will be " - "written to a separate\n" - " file with the name built by adding a numeric sequence value " - "to the dumpname\n" - " and an extension of .txt for ASCII dumps or .bin for binary " - "dumps.\n" - "\n" - " The four debug/dump options are independent, though it makes " - "little sense to\n" - " specify a dump file without specifying a detail level.\n" - "\n" - "Note 1: The (-X|-Y), -Z, -z and -S options are mutually exclusive.\n" - " In no case should the options be applied to a given " - "selection successively.\n" - "\n" - "Note 2: Any of the -X, -Y, -Z and -z options together with other " - "PAGE_MODE_x options\n" - " such as - H, -V, -P, -J or -K are not supported and may " - "cause buffer overflows.\n" - "\n"; -/* This function could be modified to pass starting sample offset + +static const char* usage_info[] = { +"usage: tiffcrop [options] source1 ... sourceN destination", +"where options are:", +" -h Print this syntax listing", +" -v Print tiffcrop version identifier and last revision date", +" ", +" -a Append to output instead of overwriting", +" -d offset Set initial directory offset, counting first image as one, not zero", +" -p contig Pack samples contiguously (e.g. RGBRGB...)", +" -p separate Store samples separately (e.g. RRR...GGG...BBB...)", +" -s Write output in strips", +" -t Write output in tiles", +" -i Ignore read errors", +" -k size set the memory allocation limit in MiB. 0 to disable limit", +" ", +" -r # Make each strip have no more than # rows", +" -w # Set output tile width (pixels)", +" -l # Set output tile length (pixels)", +" ", +" -f lsb2msb Force lsb-to-msb FillOrder for output", +" -f msb2lsb Force msb-to-lsb FillOrder for output", +"", +" -c lzw[:opts] Compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] Compress output with deflate encoding", +" -c jpeg[:opts] Compress output with JPEG encoding", +" -c packbits Compress output with packbits encoding", +" -c g3[:opts] Compress output with CCITT Group 3 encoding", +" -c g4 Compress output with CCITT Group 4 encoding", +" -c none Use no compression algorithm on output", +" ", +"Group 3 options:", +" 1d Use default CCITT Group 3 1D-encoding", +" 2d Use optional CCITT Group 3 2D-encoding", +" fill Byte-align EOL codes", +"For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", +" ", +"JPEG options:", +" # Set compression quality level (0-100, default 100)", +" raw Output color image as raw YCbCr", +" rgb Output color image as RGB", +"For example, -c jpeg:rgb:50 to get JPEG-encoded RGB data with 50% comp. quality", +" ", +"LZW and deflate options:", +" # Set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +" ", +"Page and selection options:", +" -N odd|even|#,#-#,#|last sequences and ranges of images within file to process", +" The words odd or even may be used to specify all odd or even numbered images.", +" The word last may be used in place of a number in the sequence to indicate.", +" The final image in the file without knowing how many images there are.", +" Numbers are counted from one even though TIFF IFDs are counted from zero.", +" ", +" -E t|l|r|b edge to use as origin for width and length of crop region", +" -U units [in, cm, px ] inches, centimeters or pixels", +" ", +" -m #,#,#,# margins from edges for selection: top, left, bottom, right separated by commas", +" -X # horizontal dimension of region to extract expressed in current units", +" -Y # vertical dimension of region to extract expressed in current units", +" -Z #:#,#:# zones of the image designated as position X of Y,", +" eg 1:3 would be first of three equal portions measured from reference edge", +" -z x1,y1,x2,y2:...:xN,yN,xN+1,yN+1", +" regions of the image designated by upper left and lower right coordinates", +"", +"Export grouping options:", +" -e c|d|i|m|s export mode for images and selections from input images.", +" When exporting a composite image from multiple zones or regions", +" (combined and image modes), the selections must have equal sizes", +" for the axis perpendicular to the edge specified with -E.", +" c|combined All images and selections are written to a single file (default).", +" with multiple selections from one image combined into a single image.", +" d|divided All images and selections are written to a single file", +" with each selection from one image written to a new image.", +" i|image Each input image is written to a new file (numeric filename sequence)", +" with multiple selections from the image combined into one image.", +" m|multiple Each input image is written to a new file (numeric filename sequence)", +" with each selection from the image written to a new image.", +" s|separated Individual selections from each image are written to separate files.", +"", +"Output options:", +" -H # Set horizontal resolution of output images to #", +" -V # Set vertical resolution of output images to #", +" -J # Set horizontal margin of output page to # expressed in current units", +" when sectioning image into columns x rows using the -S cols:rows option", +" -K # Set verticalal margin of output page to # expressed in current units", +" when sectioning image into columns x rows using the -S cols:rows option", +" ", +" -O orient orientation for output image, portrait, landscape, auto", +" -P page page size for output image segments, eg letter, legal, tabloid, etc", +" use #.#x#.# to specify a custom page size in the currently defined units", +" where #.# represents the width and length", +" -S cols:rows Divide the image into equal sized segments using cols across and rows down.", +" ", +" -F hor|vert|both", +" flip (mirror) image or region horizontally, vertically, or both", +" -R # [90,180,or 270] degrees clockwise rotation of image or extracted region", +" -I [black|white|data|both]", +" invert color space, eg dark to light for bilevel and grayscale images", +" If argument is white or black, set the PHOTOMETRIC_INTERPRETATION ", +" tag to MinIsBlack or MinIsWhite without altering the image data", +" If the argument is data or both, the image data are modified:", +" both inverts the data and the PHOTOMETRIC_INTERPRETATION tag,", +" data inverts the data but not the PHOTOMETRIC_INTERPRETATION tag", +" ", +"-D opt1:value1,opt2:value2,opt3:value3:opt4:value4", +" Debug/dump program progress and/or data to non-TIFF files.", +" Options include the following and must be joined as a comma", +" separate list. The use of this option is generally limited to", +" program debugging and development of future options.", +" ", +" debug:N Display limited program progress indicators where larger N", +" increase the level of detail. Note: Tiffcrop may be compiled with", +" -DDEVELMODE to enable additional very low level debug reporting.", +"", +" Format:txt|raw Format any logged data as ASCII text or raw binary ", +" values. ASCII text dumps include strings of ones and zeroes", +" representing the binary values in the image data plus identifying headers.", +" ", +" level:N Specify the level of detail presented in the dump files.", +" This can vary from dumps of the entire input or output image data to dumps", +" of data processed by specific functions. Current range of levels is 1 to 3.", +" ", +" input:full-path-to-directory/input-dumpname", +" ", +" output:full-path-to-directory/output-dumpnaem", +" ", +" When dump files are being written, each image will be written to a separate", +" file with the name built by adding a numeric sequence value to the dumpname", +" and an extension of .txt for ASCII dumps or .bin for binary dumps.", +" ", +" The four debug/dump options are independent, though it makes little sense to", +" specify a dump file without specifying a detail level.", +"Note 1: The (-X|-Y), -Z, -z and -S options are mutually exclusive.\n" +" In no case should the options be applied to a given selection successively.\n" +"\n" +"Note 2: Any of the -X, -Y, -Z and -z options together with other PAGE_MODE_x options\n" +" such as - H, -V, -P, -J or -K are not supported and may cause buffer overflows.\n" +"\n" +" ", +NULL +}; + +/* This function could be modified to pass starting sample offset * and number of samples as args to select fewer than spp - * from input image. These would then be passed to individual + * from input image. These would then be passed to individual * extractContigSampleXX routines. */ -static int readContigTilesIntoBuffer(TIFF *in, uint8_t *buf, - uint32_t imagelength, uint32_t imagewidth, - uint32_t tw, uint32_t tl, tsample_t spp, - uint16_t bps) -{ - int status = 1; - tsample_t sample = 0; - tsample_t count = spp; - uint32_t row, col, trow; - uint32_t nrow, ncol; - uint32_t dst_rowsize, shift_width; - uint32_t bytes_per_sample, bytes_per_pixel; - uint32_t trailing_bits, prev_trailing_bits; - tmsize_t tile_rowsize = TIFFTileRowSize(in); - tmsize_t src_offset, dst_offset; - uint32_t row_offset, col_offset; - uint8_t *bufp = (uint8_t *)buf; - unsigned char *src = NULL; - unsigned char *dst = NULL; - tsize_t tbytes = 0, tile_buffsize = 0; - tsize_t tilesize = TIFFTileSize(in); - unsigned char *tilebuf = NULL; +static int readContigTilesIntoBuffer (TIFF* in, uint8* buf, + uint32 imagelength, + uint32 imagewidth, + uint32 tw, uint32 tl, + tsample_t spp, uint16 bps) + { + int status = 1; + tsample_t sample = 0; + tsample_t count = spp; + uint32 row, col, trow; + uint32 nrow, ncol; + uint32 dst_rowsize, shift_width; + uint32 bytes_per_sample, bytes_per_pixel; + uint32 trailing_bits, prev_trailing_bits; + tmsize_t tile_rowsize = TIFFTileRowSize(in); + tmsize_t src_offset, dst_offset; + uint32 row_offset, col_offset; + uint8 *bufp = (uint8*) buf; + unsigned char *src = NULL; + unsigned char *dst = NULL; + tsize_t tbytes = 0, tile_buffsize = 0; + tsize_t tilesize = TIFFTileSize(in); + unsigned char *tilebuf = NULL; - bytes_per_sample = (bps + 7) / 8; - bytes_per_pixel = ((bps * spp) + 7) / 8; + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; - if ((bps % 8) == 0) - shift_width = 0; + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; else - { - if (bytes_per_pixel < (bytes_per_sample + 1)) - shift_width = bytes_per_pixel; - else - shift_width = bytes_per_sample + 1; + shift_width = bytes_per_sample + 1; } - tile_buffsize = tilesize; - if (tilesize == 0 || tile_rowsize == 0) - { - TIFFError("readContigTilesIntoBuffer", - "Tile size or tile rowsize is zero"); - exit(EXIT_FAILURE); - } + tile_buffsize = tilesize; + if (tilesize == 0 || tile_rowsize == 0) + { + TIFFError("readContigTilesIntoBuffer", "Tile size or tile rowsize is zero"); + exit(EXIT_FAILURE); + } - if (tilesize < (tsize_t)(tl * tile_rowsize)) + if (tilesize < (tsize_t)(tl * tile_rowsize)) { #ifdef DEBUG2 - TIFFError("readContigTilesIntoBuffer", - "Tilesize %" PRId64 - " is too small, using alternate calculation %" PRIu64, - tilesize, tl * tile_rowsize); + TIFFError("readContigTilesIntoBuffer", + "Tilesize %lu is too small, using alternate calculation %u", + tilesize, tl * tile_rowsize); #endif - if (tile_rowsize != 0 && - (tmsize_t)tl > (TIFF_TMSIZE_T_MAX / tile_rowsize)) - { - TIFFError("readContigTilesIntoBuffer", - "Integer overflow when calculating buffer size."); - exit(EXIT_FAILURE); - } - tile_buffsize = tl * tile_rowsize; - } - - /* Add 3 padding bytes for extractContigSamplesShifted32bits */ - if ((size_t)tile_buffsize > TIFF_TMSIZE_T_MAX - NUM_BUFF_OVERSIZE_BYTES) + tile_buffsize = tl * tile_rowsize; + if (tl != (tile_buffsize / tile_rowsize)) { - TIFFError("readContigTilesIntoBuffer", - "Integer overflow when calculating buffer size."); + TIFFError("readContigTilesIntoBuffer", "Integer overflow when calculating buffer size."); exit(EXIT_FAILURE); } - tilebuf = limitMalloc(tile_buffsize + NUM_BUFF_OVERSIZE_BYTES); - if (tilebuf == 0) - return 0; - tilebuf[tile_buffsize] = 0; - tilebuf[tile_buffsize + 1] = 0; - tilebuf[tile_buffsize + 2] = 0; - - dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; - for (row = 0; row < imagelength; row += tl) - { - nrow = (row + tl > imagelength) ? imagelength - row : tl; - for (col = 0; col < imagewidth; col += tw) - { - tbytes = TIFFReadTile(in, tilebuf, col, row, 0, 0); - if (tbytes < tilesize && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read tile at row %" PRIu32 - " col %" PRIu32 ", Read %" TIFF_SSIZE_FORMAT - " bytes of %" TIFF_SSIZE_FORMAT, - col, row, tbytes, tilesize); - status = 0; - _TIFFfree(tilebuf); - return status; - } - - row_offset = row * dst_rowsize; - col_offset = ((col * bps * spp) + 7) / 8; - bufp = buf + row_offset + col_offset; - - if (col + tw > imagewidth) - ncol = imagewidth - col; - else - ncol = tw; - - /* Each tile scanline will start on a byte boundary but it - * has to be merged into the scanline for the entire - * image buffer and the previous segment may not have - * ended on a byte boundary - */ - /* Optimization for common bit depths, all samples */ - if (((bps % 8) == 0) && (count == spp)) - { - for (trow = 0; trow < nrow; trow++) - { - src_offset = trow * tile_rowsize; - _TIFFmemcpy(bufp, tilebuf + src_offset, - (ncol * spp * bps) / 8); - bufp += (imagewidth * bps * spp) / 8; - } - } - else - { - /* Bit depths not a multiple of 8 and/or extract fewer than spp - * samples */ - prev_trailing_bits = trailing_bits = 0; - trailing_bits = (ncol * bps * spp) % 8; - - /* for (trow = 0; tl < nrow; trow++) */ - for (trow = 0; trow < nrow; trow++) - { - src_offset = trow * tile_rowsize; - src = tilebuf + src_offset; - dst_offset = (row + trow) * (tmsize_t)dst_rowsize; - dst = buf + dst_offset + col_offset; - switch (shift_width) - { - case 0: - if (extractContigSamplesBytes(src, dst, ncol, - sample, spp, bps, - count, 0, ncol)) - { - TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %" PRIu32 - " from tile %" PRIu32, - row, TIFFCurrentTile(in)); - return 1; - } - break; - case 1: - if (bps == 1) - { - if (extractContigSamplesShifted8bits( - src, dst, ncol, sample, spp, bps, count, - 0, ncol, prev_trailing_bits)) - { - TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %" PRIu32 - " from tile %" PRIu32, - row, TIFFCurrentTile(in)); - return 1; - } - break; - } - else if (extractContigSamplesShifted16bits( - src, dst, ncol, sample, spp, bps, - count, 0, ncol, prev_trailing_bits)) - { - TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %" PRIu32 - " from tile %" PRIu32, - row, TIFFCurrentTile(in)); - return 1; - } - break; - case 2: - if (extractContigSamplesShifted24bits( - src, dst, ncol, sample, spp, bps, count, 0, - ncol, prev_trailing_bits)) - { - TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %" PRIu32 - " from tile %" PRIu32, - row, TIFFCurrentTile(in)); - return 1; - } - break; - case 3: - case 4: - case 5: - if (extractContigSamplesShifted32bits( - src, dst, ncol, sample, spp, bps, count, 0, - ncol, prev_trailing_bits)) - { - TIFFError("readContigTilesIntoBuffer", - "Unable to extract row %" PRIu32 - " from tile %" PRIu32, - row, TIFFCurrentTile(in)); - return 1; - } - break; - default: - TIFFError("readContigTilesIntoBuffer", - "Unsupported bit depth %" PRIu16, bps); - return 1; - } - } - prev_trailing_bits += trailing_bits; - /* if (prev_trailing_bits > 7) */ - /* prev_trailing_bits-= 8; */ - } - } } - _TIFFfree(tilebuf); - return status; -} + /* Add 3 padding bytes for extractContigSamplesShifted32bits */ + if( (size_t) tile_buffsize > 0xFFFFFFFFU - 3U ) + { + TIFFError("readContigTilesIntoBuffer", "Integer overflow when calculating buffer size."); + exit(EXIT_FAILURE); + } + tilebuf = limitMalloc(tile_buffsize + NUM_BUFF_OVERSIZE_BYTES); + if (tilebuf == 0) + return 0; + tilebuf[tile_buffsize] = 0; + tilebuf[tile_buffsize+1] = 0; + tilebuf[tile_buffsize+2] = 0; -static int readSeparateTilesIntoBuffer(TIFF *in, uint8_t *obuf, - uint32_t imagelength, - uint32_t imagewidth, uint32_t tw, - uint32_t tl, uint16_t spp, uint16_t bps) -{ - int i, status = 1, sample; - int shift_width, bytes_per_pixel; - uint16_t bytes_per_sample; - uint32_t row, col; /* Current row and col of image */ - uint32_t nrow, ncol; /* Number of rows and cols in current tile */ - uint32_t row_offset, col_offset; /* Output buffer offsets */ - tsize_t tbytes = 0, tilesize = TIFFTileSize(in); - tsample_t s; - uint8_t *bufp = (uint8_t *)obuf; - unsigned char *srcbuffs[MAX_SAMPLES]; - unsigned char *tbuff = NULL; - - bytes_per_sample = (bps + 7) / 8; - - for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + for (row = 0; row < imagelength; row += tl) { - srcbuffs[sample] = NULL; - tbuff = - (unsigned char *)limitMalloc(tilesize + NUM_BUFF_OVERSIZE_BYTES); - if (!tbuff) + nrow = (row + tl > imagelength) ? imagelength - row : tl; + for (col = 0; col < imagewidth; col += tw) + { + tbytes = TIFFReadTile(in, tilebuf, col, row, 0, 0); + if (tbytes < tilesize && !ignore) { - TIFFError("readSeparateTilesIntoBuffer", - "Unable to allocate tile read buffer for sample %d", - sample); - for (i = 0; i < sample; i++) - _TIFFfree(srcbuffs[i]); - return 0; + TIFFError(TIFFFileName(in), + "Error, can't read tile at row %lu col %lu, Read %lu bytes of %lu", + (unsigned long) col, (unsigned long) row, (unsigned long)tbytes, + (unsigned long)tilesize); + status = 0; + _TIFFfree(tilebuf); + return status; + } + + row_offset = row * dst_rowsize; + col_offset = ((col * bps * spp) + 7)/ 8; + bufp = buf + row_offset + col_offset; + + if (col + tw > imagewidth) + ncol = imagewidth - col; + else + ncol = tw; + + /* Each tile scanline will start on a byte boundary but it + * has to be merged into the scanline for the entire + * image buffer and the previous segment may not have + * ended on a byte boundary + */ + /* Optimization for common bit depths, all samples */ + if (((bps % 8) == 0) && (count == spp)) + { + for (trow = 0; trow < nrow; trow++) + { + src_offset = trow * tile_rowsize; + _TIFFmemcpy (bufp, tilebuf + src_offset, (ncol * spp * bps) / 8); + bufp += (imagewidth * bps * spp) / 8; + } } - srcbuffs[sample] = tbuff; - } - /* Each tile contains only the data for a single plane - * arranged in scanlines of tw * bytes_per_sample bytes. - */ - for (row = 0; row < imagelength; row += tl) - { - nrow = (row + tl > imagelength) ? imagelength - row : tl; - for (col = 0; col < imagewidth; col += tw) + else { - for (s = 0; s < spp && s < MAX_SAMPLES; s++) - { /* Read each plane of a tile set into srcbuffs[s] */ - tbytes = TIFFReadTile(in, srcbuffs[s], col, row, 0, s); - if (tbytes < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read tile for row %" PRIu32 - " col %" PRIu32 ", " - "sample %" PRIu16, - col, row, s); - status = 0; - for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); - sample++) - { - tbuff = srcbuffs[sample]; - if (tbuff != NULL) - _TIFFfree(tbuff); - } - return status; - } - } - /* Tiles on the right edge may be padded out to tw - * which must be a multiple of 16. - * Ncol represents the visible (non padding) portion. - */ - if (col + tw > imagewidth) - ncol = imagewidth - col; - else - ncol = tw; + /* Bit depths not a multiple of 8 and/or extract fewer than spp samples */ + prev_trailing_bits = trailing_bits = 0; + trailing_bits = (ncol * bps * spp) % 8; - row_offset = row * (((imagewidth * spp * bps) + 7) / 8); - col_offset = ((col * spp * bps) + 7) / 8; - bufp = obuf + row_offset + col_offset; - - if ((bps % 8) == 0) + /* for (trow = 0; tl < nrow; trow++) */ + for (trow = 0; trow < nrow; trow++) + { + src_offset = trow * tile_rowsize; + src = tilebuf + src_offset; + dst_offset = (row + trow) * dst_rowsize; + dst = buf + dst_offset + col_offset; + switch (shift_width) { - if (combineSeparateTileSamplesBytes(srcbuffs, bufp, ncol, nrow, - imagewidth, tw, spp, bps, - NULL, 0, 0)) - { + case 0: if (extractContigSamplesBytes (src, dst, ncol, sample, + spp, bps, count, 0, ncol)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, ncol, + sample, spp, + bps, count, + 0, ncol, + prev_trailing_bits)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, ncol, + sample, spp, + bps, count, + 0, ncol, + prev_trailing_bits)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, ncol, + sample, spp, + bps, count, + 0, ncol, + prev_trailing_bits)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, ncol, + sample, spp, + bps, count, + 0, ncol, + prev_trailing_bits)) + { + TIFFError("readContigTilesIntoBuffer", + "Unable to extract row %d from tile %lu", + row, (unsigned long)TIFFCurrentTile(in)); + return 1; + } + break; + default: TIFFError("readContigTilesIntoBuffer", "Unsupported bit depth %d", bps); + return 1; + } + } + prev_trailing_bits += trailing_bits; + /* if (prev_trailing_bits > 7) */ + /* prev_trailing_bits-= 8; */ + } + } + } + + _TIFFfree(tilebuf); + return status; + } + +static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf, + uint32 imagelength, uint32 imagewidth, + uint32 tw, uint32 tl, + uint16 spp, uint16 bps) + { + int i, status = 1, sample; + int shift_width, bytes_per_pixel; + uint16 bytes_per_sample; + uint32 row, col; /* Current row and col of image */ + uint32 nrow, ncol; /* Number of rows and cols in current tile */ + uint32 row_offset, col_offset; /* Output buffer offsets */ + tsize_t tbytes = 0, tilesize = TIFFTileSize(in); + tsample_t s; + uint8* bufp = (uint8*)obuf; + unsigned char *srcbuffs[MAX_SAMPLES]; + unsigned char *tbuff = NULL; + + bytes_per_sample = (bps + 7) / 8; + + for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) + { + srcbuffs[sample] = NULL; + tbuff = (unsigned char *)limitMalloc(tilesize + NUM_BUFF_OVERSIZE_BYTES); + if (!tbuff) + { + TIFFError ("readSeparateTilesIntoBuffer", + "Unable to allocate tile read buffer for sample %d", sample); + for (i = 0; i < sample; i++) + _TIFFfree (srcbuffs[i]); + return 0; + } + srcbuffs[sample] = tbuff; + } + /* Each tile contains only the data for a single plane + * arranged in scanlines of tw * bytes_per_sample bytes. + */ + for (row = 0; row < imagelength; row += tl) + { + nrow = (row + tl > imagelength) ? imagelength - row : tl; + for (col = 0; col < imagewidth; col += tw) + { + for (s = 0; s < spp && s < MAX_SAMPLES; s++) + { /* Read each plane of a tile set into srcbuffs[s] */ + tbytes = TIFFReadTile(in, srcbuffs[s], col, row, 0, s); + if (tbytes < 0 && !ignore) + { + TIFFError(TIFFFileName(in), + "Error, can't read tile for row %lu col %lu, " + "sample %lu", + (unsigned long) col, (unsigned long) row, + (unsigned long) s); + status = 0; + for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) + { + tbuff = srcbuffs[sample]; + if (tbuff != NULL) + _TIFFfree(tbuff); + } + return status; + } + } + /* Tiles on the right edge may be padded out to tw + * which must be a multiple of 16. + * Ncol represents the visible (non padding) portion. + */ + if (col + tw > imagewidth) + ncol = imagewidth - col; + else + ncol = tw; + + row_offset = row * (((imagewidth * spp * bps) + 7) / 8); + col_offset = ((col * spp * bps) + 7) / 8; + bufp = obuf + row_offset + col_offset; + + if ((bps % 8) == 0) + { + if (combineSeparateTileSamplesBytes(srcbuffs, bufp, ncol, nrow, imagewidth, + tw, spp, bps, NULL, 0, 0)) + { + status = 0; + break; + } + } + else + { + bytes_per_pixel = ((bps * spp) + 7) / 8; + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + + switch (shift_width) + { + case 1: if (combineSeparateTileSamples8bits (srcbuffs, bufp, ncol, nrow, + imagewidth, tw, spp, bps, + NULL, 0, 0)) + { status = 0; break; - } - } - else - { - bytes_per_pixel = ((bps * spp) + 7) / 8; - if (bytes_per_pixel < (bytes_per_sample + 1)) - shift_width = bytes_per_pixel; - else - shift_width = bytes_per_sample + 1; - - switch (shift_width) - { - case 1: - if (combineSeparateTileSamples8bits( - srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, - bps, NULL, 0, 0)) - { - status = 0; - break; - } - break; - case 2: - if (combineSeparateTileSamples16bits( - srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, - bps, NULL, 0, 0)) - { - status = 0; - break; - } - break; - case 3: - if (combineSeparateTileSamples24bits( - srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, - bps, NULL, 0, 0)) - { - status = 0; - break; - } - break; - case 4: - case 5: - case 6: - case 7: - case 8: - if (combineSeparateTileSamples32bits( - srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, - bps, NULL, 0, 0)) - { - status = 0; - break; - } - break; - default: - TIFFError("readSeparateTilesIntoBuffer", - "Unsupported bit depth: %" PRIu16, bps); - status = 0; - break; - } - } + } + break; + case 2: if (combineSeparateTileSamples16bits (srcbuffs, bufp, ncol, nrow, + imagewidth, tw, spp, bps, + NULL, 0, 0)) + { + status = 0; + break; + } + break; + case 3: if (combineSeparateTileSamples24bits (srcbuffs, bufp, ncol, nrow, + imagewidth, tw, spp, bps, + NULL, 0, 0)) + { + status = 0; + break; + } + break; + case 4: + case 5: + case 6: + case 7: + case 8: if (combineSeparateTileSamples32bits (srcbuffs, bufp, ncol, nrow, + imagewidth, tw, spp, bps, + NULL, 0, 0)) + { + status = 0; + break; + } + break; + default: TIFFError ("readSeparateTilesIntoBuffer", "Unsupported bit depth: %d", bps); + status = 0; + break; + } } + } } - for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) + for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) { - tbuff = srcbuffs[sample]; - if (tbuff != NULL) - _TIFFfree(tbuff); + tbuff = srcbuffs[sample]; + if (tbuff != NULL) + _TIFFfree(tbuff); } + + return status; + } - return status; -} +static int writeBufferToContigStrips(TIFF* out, uint8* buf, uint32 imagelength) + { + uint32 row, nrows, rowsperstrip; + tstrip_t strip = 0; + tsize_t stripsize; -static int writeBufferToContigStrips(TIFF *out, uint8_t *buf, - uint32_t imagelength) -{ - uint32_t row, nrows, rowsperstrip; - tstrip_t strip = 0; - tsize_t stripsize; - - TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - for (row = 0; row < imagelength; row += rowsperstrip) + TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + for (row = 0; row < imagelength; row += rowsperstrip) { - nrows = (row + rowsperstrip > imagelength) ? imagelength - row - : rowsperstrip; - stripsize = TIFFVStripSize(out, nrows); - if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) - { - TIFFError(TIFFFileName(out), "Error, can't write strip %" PRIu32, - strip - 1); - return 1; - } - buf += stripsize; + nrows = (row + rowsperstrip > imagelength) ? + imagelength - row : rowsperstrip; + stripsize = TIFFVStripSize(out, nrows); + if (TIFFWriteEncodedStrip(out, strip++, buf, stripsize) < 0) + { + TIFFError(TIFFFileName(out), "Error, can't write strip %u", strip - 1); + return 1; + } + buf += stripsize; } - return 0; -} + return 0; + } /* Abandon plans to modify code so that plannar orientation separate images * do not have all samples for each channel written before all samples * for the next channel have been abandoned. * Libtiff internals seem to depend on all data for a given sample - * being contiguous within a strip or tile when PLANAR_CONFIG is + * being contiguous within a strip or tile when PLANAR_CONFIG is * separate. All strips or tiles of a given plane are written * before any strips or tiles of a different plane are stored. */ -static int writeBufferToSeparateStrips(TIFF *out, uint8_t *buf, uint32_t length, - uint32_t width, uint16_t spp, - struct dump_opts *dump) -{ - uint8_t *src; - uint16_t bps; - uint32_t row, nrows, rowsize, rowsperstrip; - uint32_t bytes_per_sample; - tsample_t s; - tstrip_t strip = 0; - tsize_t stripsize = TIFFStripSize(out); - tsize_t rowstripsize, scanlinesize = TIFFScanlineSize(out); - tdata_t obuf; +static int +writeBufferToSeparateStrips (TIFF* out, uint8* buf, + uint32 length, uint32 width, uint16 spp, + struct dump_opts *dump) + { + uint8 *src; + uint16 bps; + uint32 row, nrows, rowsize, rowsperstrip; + uint32 bytes_per_sample; + tsample_t s; + tstrip_t strip = 0; + tsize_t stripsize = TIFFStripSize(out); + tsize_t rowstripsize, scanlinesize = TIFFScanlineSize(out); + tsize_t total_bytes = 0; + tdata_t obuf; - (void)TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - (void)TIFFGetFieldDefaulted(out, TIFFTAG_BITSPERSAMPLE, &bps); - bytes_per_sample = (bps + 7) / 8; - if (width == 0 || (uint32_t)bps * (uint32_t)spp > UINT32_MAX / width || - bps * spp * width > UINT32_MAX - 7U) - { - TIFFError( - TIFFFileName(out), - "Error, uint32_t overflow when computing (bps * spp * width) + 7"); - return 1; - } - rowsize = - ((bps * spp * width) + 7U) / 8; /* source has interleaved samples */ - if (bytes_per_sample == 0 || rowsperstrip > UINT32_MAX / bytes_per_sample || - rowsperstrip * bytes_per_sample > UINT32_MAX / (width + 1)) - { - TIFFError(TIFFFileName(out), - "Error, uint32_t overflow when computing rowsperstrip * " - "bytes_per_sample * (width + 1)"); - return 1; - } - rowstripsize = rowsperstrip * bytes_per_sample * (width + 1); + (void) TIFFGetFieldDefaulted(out, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + (void) TIFFGetFieldDefaulted(out, TIFFTAG_BITSPERSAMPLE, &bps); + bytes_per_sample = (bps + 7) / 8; + if( width == 0 || + (uint32)bps * (uint32)spp > TIFF_UINT32_MAX / width || + bps * spp * width > TIFF_UINT32_MAX - 7U ) + { + TIFFError(TIFFFileName(out), + "Error, uint32 overflow when computing (bps * spp * width) + 7"); + return 1; + } + rowsize = ((bps * spp * width) + 7U) / 8; /* source has interleaved samples */ + if( bytes_per_sample == 0 || + rowsperstrip > TIFF_UINT32_MAX / bytes_per_sample || + rowsperstrip * bytes_per_sample > TIFF_UINT32_MAX / (width + 1) ) + { + TIFFError(TIFFFileName(out), + "Error, uint32 overflow when computing rowsperstrip * " + "bytes_per_sample * (width + 1)"); + return 1; + } + rowstripsize = rowsperstrip * bytes_per_sample * (width + 1); - /* Add 3 padding bytes for extractContigSamples32bits */ - obuf = limitMalloc(rowstripsize + NUM_BUFF_OVERSIZE_BYTES); - if (obuf == NULL) - return 1; - - for (s = 0; s < spp; s++) + /* Add 3 padding bytes for extractContigSamples32bits */ + obuf = limitMalloc (rowstripsize + NUM_BUFF_OVERSIZE_BYTES); + if (obuf == NULL) + return 1; + + for (s = 0; s < spp; s++) { - for (row = 0; row < length; row += rowsperstrip) + for (row = 0; row < length; row += rowsperstrip) + { + nrows = (row + rowsperstrip > length) ? length - row : rowsperstrip; + + stripsize = TIFFVStripSize(out, nrows); + src = buf + (row * rowsize); + total_bytes += stripsize; + memset (obuf, '\0',rowstripsize + NUM_BUFF_OVERSIZE_BYTES); + if (extractContigSamplesToBuffer(obuf, src, nrows, width, s, spp, bps, dump)) { - nrows = (row + rowsperstrip > length) ? length - row : rowsperstrip; + _TIFFfree(obuf); + return 1; + } + if ((dump->outfile != NULL) && (dump->level == 1)) + { + if (scanlinesize > 0x0ffffffffULL) { + dump_info(dump->infile, dump->format, "loadImage", + "Attention: scanlinesize " TIFF_SSIZE_FORMAT " is larger than UINT32_MAX.\nFollowing dump might be wrong.", + scanlinesize); + } + dump_info(dump->outfile, dump->format,"", + "Sample %2d, Strip: %2d, bytes: %4d, Row %4d, bytes: %4d, Input offset: %6d", + s + 1, strip + 1, stripsize, row + 1, (uint32)scanlinesize, src - buf); + dump_buffer(dump->outfile, dump->format, nrows, (uint32)scanlinesize, row, obuf); + } - stripsize = TIFFVStripSize(out, nrows); - src = buf + (row * rowsize); - memset(obuf, '\0', rowstripsize + NUM_BUFF_OVERSIZE_BYTES); - if (extractContigSamplesToBuffer(obuf, src, nrows, width, s, spp, - bps, dump)) - { - _TIFFfree(obuf); - return 1; - } - if ((dump->outfile != NULL) && (dump->level == 1)) - { - if ((uint64_t)scanlinesize > 0x0ffffffffULL) - { - dump_info(dump->infile, dump->format, "loadImage", - "Attention: scanlinesize %" PRIu64 - " is larger than UINT32_MAX.\nFollowing dump " - "might be wrong.", - (uint64_t)scanlinesize); - } - dump_info(dump->outfile, dump->format, "", - "Sample %2d, Strip: %2d, bytes: %4d, Row %4d, bytes: " - "%4d, Input offset: %6d", - s + 1, strip + 1, stripsize, row + 1, - (uint32_t)scanlinesize, src - buf); - dump_buffer(dump->outfile, dump->format, nrows, - (uint32_t)scanlinesize, row, obuf); - } + if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) + { + TIFFError(TIFFFileName(out), "Error, can't write strip %u", strip - 1); + _TIFFfree(obuf); + return 1; + } + } + } - if (TIFFWriteEncodedStrip(out, strip++, obuf, stripsize) < 0) - { - TIFFError(TIFFFileName(out), - "Error, can't write strip %" PRIu32, strip - 1); - _TIFFfree(obuf); - return 1; - } - } - } - - _TIFFfree(obuf); - return 0; + _TIFFfree(obuf); + return 0; } -/* Extract all planes from contiguous buffer into a single tile buffer +/* Extract all planes from contiguous buffer into a single tile buffer * to be written out as a tile. */ -static int writeBufferToContigTiles(TIFF *out, uint8_t *buf, - uint32_t imagelength, uint32_t imagewidth, - tsample_t spp, struct dump_opts *dump) -{ - uint16_t bps; - uint32_t tl, tw; - uint32_t row, col, nrow, ncol; - uint32_t src_rowsize, col_offset; - tmsize_t tile_rowsize = TIFFTileRowSize(out); - uint8_t *bufp = (uint8_t *)buf; - tsize_t tile_buffsize = 0; - tsize_t tilesize = TIFFTileSize(out); - unsigned char *tilebuf = NULL; +static int writeBufferToContigTiles (TIFF* out, uint8* buf, uint32 imagelength, + uint32 imagewidth, tsample_t spp, + struct dump_opts* dump) + { + uint16 bps; + uint32 tl, tw; + uint32 row, col, nrow, ncol; + uint32 src_rowsize, col_offset; + tmsize_t tile_rowsize = TIFFTileRowSize(out); + uint8* bufp = (uint8*) buf; + tsize_t tile_buffsize = 0; + tsize_t tilesize = TIFFTileSize(out); + unsigned char *tilebuf = NULL; - if (!TIFFGetField(out, TIFFTAG_TILELENGTH, &tl) || - !TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw) || - !TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps)) - return 1; + if( !TIFFGetField(out, TIFFTAG_TILELENGTH, &tl) || + !TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw) || + !TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps) ) + return 1; - if (tilesize == 0 || tile_rowsize == 0 || tl == 0 || tw == 0) - { - TIFFError( - "writeBufferToContigTiles", - "Tile size, tile row size, tile width, or tile length is zero"); - exit(EXIT_FAILURE); - } - - tile_buffsize = tilesize; - if (tilesize < (tsize_t)(tl * tile_rowsize)) + if (tilesize == 0 || tile_rowsize == 0 || tl == 0 || tw == 0) + { + TIFFError("writeBufferToContigTiles", "Tile size, tile row size, tile width, or tile length is zero"); + exit(EXIT_FAILURE); + } + + tile_buffsize = tilesize; + if (tilesize < (tsize_t)(tl * tile_rowsize)) { #ifdef DEBUG2 - TIFFError("writeBufferToContigTiles", - "Tilesize %" PRId64 - " is too small, using alternate calculation %" PRIu32, - tilesize, tl * tile_rowsize); + TIFFError("writeBufferToContigTiles", + "Tilesize %lu is too small, using alternate calculation %u", + tilesize, tl * tile_rowsize); #endif - if (tile_rowsize != 0 && - (tmsize_t)tl > (TIFF_TMSIZE_T_MAX / tile_rowsize)) - { - TIFFError("writeBufferToContigTiles", - "Integer overflow when calculating buffer size"); - exit(EXIT_FAILURE); - } - tile_buffsize = tl * tile_rowsize; - } - - if (imagewidth == 0 || - (uint32_t)bps * (uint32_t)spp > UINT32_MAX / imagewidth || - bps * spp * imagewidth > UINT32_MAX - 7U) + tile_buffsize = tl * tile_rowsize; + if (tl != tile_buffsize / tile_rowsize) { - TIFFError(TIFFFileName(out), "Error, uint32_t overflow when computing " - "(imagewidth * bps * spp) + 7"); - return 1; + TIFFError("writeBufferToContigTiles", "Integer overflow when calculating buffer size"); + exit(EXIT_FAILURE); + } } - src_rowsize = ((imagewidth * spp * bps) + 7U) / 8; - /* Add 3 padding bytes for extractContigSamples32bits */ - tilebuf = limitMalloc(tile_buffsize + NUM_BUFF_OVERSIZE_BYTES); - if (tilebuf == 0) - return 1; - memset(tilebuf, 0, tile_buffsize + NUM_BUFF_OVERSIZE_BYTES); - for (row = 0; row < imagelength; row += tl) + if( imagewidth == 0 || + (uint32)bps * (uint32)spp > TIFF_UINT32_MAX / imagewidth || + bps * spp * imagewidth > TIFF_UINT32_MAX - 7U ) + { + TIFFError(TIFFFileName(out), + "Error, uint32 overflow when computing (imagewidth * bps * spp) + 7"); + return 1; + } + src_rowsize = ((imagewidth * spp * bps) + 7U) / 8; + + /* Add 3 padding bytes for extractContigSamples32bits */ + tilebuf = limitMalloc(tile_buffsize + NUM_BUFF_OVERSIZE_BYTES); + if (tilebuf == 0) + return 1; + memset(tilebuf, 0, tile_buffsize + NUM_BUFF_OVERSIZE_BYTES); + for (row = 0; row < imagelength; row += tl) { - nrow = (row + tl > imagelength) ? imagelength - row : tl; - for (col = 0; col < imagewidth; col += tw) + nrow = (row + tl > imagelength) ? imagelength - row : tl; + for (col = 0; col < imagewidth; col += tw) + { + /* Calculate visible portion of tile. */ + if (col + tw > imagewidth) + ncol = imagewidth - col; + else + ncol = tw; + + col_offset = (((col * bps * spp) + 7) / 8); + bufp = buf + (row * src_rowsize) + col_offset; + if (extractContigSamplesToTileBuffer(tilebuf, bufp, nrow, ncol, imagewidth, + tw, 0, spp, spp, bps, dump) > 0) { - /* Calculate visible portion of tile. */ - if (col + tw > imagewidth) - ncol = imagewidth - col; - else - ncol = tw; - - col_offset = (((col * bps * spp) + 7) / 8); - bufp = buf + (row * src_rowsize) + col_offset; - if (extractContigSamplesToTileBuffer(tilebuf, bufp, nrow, ncol, - imagewidth, tw, 0, spp, spp, - bps, dump) > 0) - { - TIFFError("writeBufferToContigTiles", - "Unable to extract data to tile for row %" PRIu32 - ", col %" PRIu32, - row, col); - _TIFFfree(tilebuf); - return 1; - } - - if (TIFFWriteTile(out, tilebuf, col, row, 0, 0) < 0) - { - TIFFError("writeBufferToContigTiles", - "Cannot write tile at %" PRIu32 " %" PRIu32, col, - row); - _TIFFfree(tilebuf); - return 1; - } + TIFFError("writeBufferToContigTiles", + "Unable to extract data to tile for row %lu, col %lu", + (unsigned long) row, (unsigned long)col); + _TIFFfree(tilebuf); + return 1; } + + if (TIFFWriteTile(out, tilebuf, col, row, 0, 0) < 0) + { + TIFFError("writeBufferToContigTiles", + "Cannot write tile at %lu %lu", + (unsigned long) col, (unsigned long) row); + _TIFFfree(tilebuf); + return 1; + } + } } - _TIFFfree(tilebuf); + _TIFFfree(tilebuf); - return 0; -} /* end writeBufferToContigTiles */ + return 0; + } /* end writeBufferToContigTiles */ -/* Extract each plane from contiguous buffer into a single tile buffer +/* Extract each plane from contiguous buffer into a single tile buffer * to be written out as a tile. */ -static int writeBufferToSeparateTiles(TIFF *out, uint8_t *buf, - uint32_t imagelength, uint32_t imagewidth, - tsample_t spp, struct dump_opts *dump) -{ - /* Add 3 padding bytes for extractContigSamples32bits */ - tdata_t obuf = limitMalloc(TIFFTileSize(out) + NUM_BUFF_OVERSIZE_BYTES); - uint32_t tl, tw; - uint32_t row, col, nrow, ncol; - uint32_t src_rowsize, col_offset; - uint16_t bps; - tsample_t s; - uint8_t *bufp = (uint8_t *)buf; +static int writeBufferToSeparateTiles (TIFF* out, uint8* buf, uint32 imagelength, + uint32 imagewidth, tsample_t spp, + struct dump_opts * dump) + { + /* Add 3 padding bytes for extractContigSamples32bits */ + tdata_t obuf = limitMalloc(TIFFTileSize(out) + NUM_BUFF_OVERSIZE_BYTES); + uint32 tl, tw; + uint32 row, col, nrow, ncol; + uint32 src_rowsize, col_offset; + uint16 bps; + tsample_t s; + uint8* bufp = (uint8*) buf; - if (obuf == NULL) - return 1; - memset(obuf, 0, TIFFTileSize(out) + NUM_BUFF_OVERSIZE_BYTES); + if (obuf == NULL) + return 1; + memset(obuf, 0, TIFFTileSize(out) + NUM_BUFF_OVERSIZE_BYTES); - if (!TIFFGetField(out, TIFFTAG_TILELENGTH, &tl) || - !TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw) || - !TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps)) + if( !TIFFGetField(out, TIFFTAG_TILELENGTH, &tl) || + !TIFFGetField(out, TIFFTAG_TILEWIDTH, &tw) || + !TIFFGetField(out, TIFFTAG_BITSPERSAMPLE, &bps) ) + return 1; + + if( imagewidth == 0 || + (uint32)bps * (uint32)spp > TIFF_UINT32_MAX / imagewidth || + bps * spp * imagewidth > TIFF_UINT32_MAX - 7 ) + { + TIFFError(TIFFFileName(out), + "Error, uint32 overflow when computing (imagewidth * bps * spp) + 7"); + _TIFFfree(obuf); + return 1; + } + src_rowsize = ((imagewidth * spp * bps) + 7U) / 8; + + for (row = 0; row < imagelength; row += tl) { - _TIFFfree(obuf); - return 1; - } + nrow = (row + tl > imagelength) ? imagelength - row : tl; + for (col = 0; col < imagewidth; col += tw) + { + /* Calculate visible portion of tile. */ + if (col + tw > imagewidth) + ncol = imagewidth - col; + else + ncol = tw; - if (imagewidth == 0 || - (uint32_t)bps * (uint32_t)spp > UINT32_MAX / imagewidth || - bps * spp * imagewidth > UINT32_MAX - 7) - { - TIFFError(TIFFFileName(out), "Error, uint32_t overflow when computing " - "(imagewidth * bps * spp) + 7"); - _TIFFfree(obuf); - return 1; - } - src_rowsize = ((imagewidth * spp * bps) + 7U) / 8; + col_offset = (((col * bps * spp) + 7) / 8); + bufp = buf + (row * src_rowsize) + col_offset; - for (row = 0; row < imagelength; row += tl) - { - nrow = (row + tl > imagelength) ? imagelength - row : tl; - for (col = 0; col < imagewidth; col += tw) + for (s = 0; s < spp; s++) { - /* Calculate visible portion of tile. */ - if (col + tw > imagewidth) - ncol = imagewidth - col; - else - ncol = tw; + if (extractContigSamplesToTileBuffer(obuf, bufp, nrow, ncol, imagewidth, + tw, s, 1, spp, bps, dump) > 0) + { + TIFFError("writeBufferToSeparateTiles", + "Unable to extract data to tile for row %lu, col %lu sample %d", + (unsigned long) row, (unsigned long)col, (int)s); + _TIFFfree(obuf); + return 1; + } - col_offset = (((col * bps * spp) + 7) / 8); - bufp = buf + (row * src_rowsize) + col_offset; - - for (s = 0; s < spp; s++) - { - if (extractContigSamplesToTileBuffer(obuf, bufp, nrow, ncol, - imagewidth, tw, s, 1, spp, - bps, dump) > 0) - { - TIFFError("writeBufferToSeparateTiles", - "Unable to extract data to tile for row %" PRIu32 - ", col %" PRIu32 " sample %" PRIu16, - row, col, s); - _TIFFfree(obuf); - return 1; - } - - if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) - { - TIFFError("writeBufferToseparateTiles", - "Cannot write tile at %" PRIu32 " %" PRIu32 - " sample %" PRIu16, - col, row, s); - _TIFFfree(obuf); - return 1; - } - } - } + if (TIFFWriteTile(out, obuf, col, row, 0, s) < 0) + { + TIFFError("writeBufferToseparateTiles", + "Cannot write tile at %lu %lu sample %lu", + (unsigned long) col, (unsigned long) row, + (unsigned long) s); + _TIFFfree(obuf); + return 1; + } + } + } } - _TIFFfree(obuf); + _TIFFfree(obuf); - return 0; -} /* end writeBufferToSeparateTiles */ + return 0; + } /* end writeBufferToSeparateTiles */ -static void processG3Options(char *cp) +static void +processG3Options(char* cp) { - if ((cp = strchr(cp, ':'))) - { - if (defg3opts == (uint32_t)-1) - defg3opts = 0; - do - { - cp++; - if (strneq(cp, "1d", 2)) - defg3opts &= ~GROUP3OPT_2DENCODING; - else if (strneq(cp, "2d", 2)) - defg3opts |= GROUP3OPT_2DENCODING; - else if (strneq(cp, "fill", 4)) - defg3opts |= GROUP3OPT_FILLBITS; - else - usage(EXIT_FAILURE); - } while ((cp = strchr(cp, ':'))); - } + if( (cp = strchr(cp, ':')) ) { + if (defg3opts == (uint32) -1) + defg3opts = 0; + do { + cp++; + if (strneq(cp, "1d", 2)) + defg3opts &= ~GROUP3OPT_2DENCODING; + else if (strneq(cp, "2d", 2)) + defg3opts |= GROUP3OPT_2DENCODING; + else if (strneq(cp, "fill", 4)) + defg3opts |= GROUP3OPT_FILLBITS; + else + usage(EXIT_FAILURE); + } while( (cp = strchr(cp, ':')) ); + } } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) + { + char* cp = NULL; + + if (strneq(opt, "none",4)) + { + defcompression = COMPRESSION_NONE; + } + else if (streq(opt, "packbits")) + { + defcompression = COMPRESSION_PACKBITS; + } + else if (strneq(opt, "jpeg", 4)) + { + cp = strchr(opt, ':'); + defcompression = COMPRESSION_JPEG; + + while (cp) + { + if (isdigit((int)cp[1])) + quality = atoi(cp + 1); + else if (strneq(cp + 1, "raw", 3 )) + jpegcolormode = JPEGCOLORMODE_RAW; + else if (strneq(cp + 1, "rgb", 3 )) + jpegcolormode = JPEGCOLORMODE_RGB; + else + usage(EXIT_FAILURE); + cp = strchr(cp + 1, ':'); + } + } + else if (strneq(opt, "g3", 2)) + { + processG3Options(opt); + defcompression = COMPRESSION_CCITTFAX3; + } + else if (streq(opt, "g4")) + { + defcompression = COMPRESSION_CCITTFAX4; + } + else if (strneq(opt, "lzw", 3)) + { + cp = strchr(opt, ':'); + if (cp) + defpredictor = atoi(cp+1); + defcompression = COMPRESSION_LZW; + } + else if (strneq(opt, "zip", 3)) + { + cp = strchr(opt, ':'); + if (cp) + defpredictor = atoi(cp+1); + defcompression = COMPRESSION_ADOBE_DEFLATE; + } + else + return (0); + + return (1); + } + +static void +usage(int code) + { + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; + + fprintf(out, "\n%s\n", TIFFGetVersion()); + for (i = 0; usage_info[i] != NULL; i++) + fprintf(out, "%s\n", usage_info[i]); + exit(code); + } + +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) +#define CopyField2(tag, v1, v2) \ + if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) +#define CopyField3(tag, v1, v2, v3) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) +#define CopyField4(tag, v1, v2, v3, v4) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4) + +static void +cpTag(TIFF* in, TIFF* out, uint16 tag, uint16 count, TIFFDataType type) { - char *cp = NULL; - - if (strneq(opt, "none", 4)) - { - defcompression = COMPRESSION_NONE; - } - else if (streq(opt, "packbits")) - { - defcompression = COMPRESSION_PACKBITS; - } - else if (strneq(opt, "jpeg", 4)) - { - cp = strchr(opt, ':'); - defcompression = COMPRESSION_JPEG; - - while (cp) - { - if (isdigit((int)cp[1])) - quality = atoi(cp + 1); - else if (strneq(cp + 1, "raw", 3)) - jpegcolormode = JPEGCOLORMODE_RAW; - else if (strneq(cp + 1, "rgb", 3)) - jpegcolormode = JPEGCOLORMODE_RGB; - else - usage(EXIT_FAILURE); - cp = strchr(cp + 1, ':'); - } - } - else if (strneq(opt, "g3", 2)) - { - processG3Options(opt); - defcompression = COMPRESSION_CCITTFAX3; - } - else if (streq(opt, "g4")) - { - defcompression = COMPRESSION_CCITTFAX4; - } - else if (strneq(opt, "lzw", 3)) - { - cp = strchr(opt, ':'); - if (cp) - defpredictor = atoi(cp + 1); - defcompression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - cp = strchr(opt, ':'); - if (cp) - defpredictor = atoi(cp + 1); - defcompression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - - return (1); + switch (type) { + case TIFF_SHORT: + if (count == 1) { + uint16 shortv; + CopyField(tag, shortv); + } else if (count == 2) { + uint16 shortv1, shortv2; + CopyField2(tag, shortv1, shortv2); + } else if (count == 4) { + uint16 *tr, *tg, *tb, *ta; + CopyField4(tag, tr, tg, tb, ta); + } else if (count == (uint16) -1) { + uint16 shortv1; + uint16* shortav; + CopyField2(tag, shortv1, shortav); + } + break; + case TIFF_LONG: + { uint32 longv; + CopyField(tag, longv); + } + break; + case TIFF_RATIONAL: + if (count == 1) { + float floatv; + CopyField(tag, floatv); + } else if (count == (uint16) -1) { + float* floatav; + CopyField(tag, floatav); + } + break; + case TIFF_ASCII: + { char* stringv; + CopyField(tag, stringv); + } + break; + case TIFF_DOUBLE: + if (count == 1) { + double doublev; + CopyField(tag, doublev); + } else if (count == (uint16) -1) { + double* doubleav; + CopyField(tag, doubleav); + } + break; + default: + TIFFError(TIFFFileName(in), + "Data type %d is not supported, tag %d skipped", + tag, type); + } } -static void usage(int code) -{ - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; - - fprintf(out, "\n%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); -} - -#define CopyField(tag, v) \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v) -#define CopyField2(tag, v1, v2) \ - if (TIFFGetField(in, tag, &v1, &v2)) \ - TIFFSetField(out, tag, v1, v2) -#define CopyField3(tag, v1, v2, v3) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3)) \ - TIFFSetField(out, tag, v1, v2, v3) -#define CopyField4(tag, v1, v2, v3, v4) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) \ - TIFFSetField(out, tag, v1, v2, v3, v4) - -static void cpTag(TIFF *in, TIFF *out, uint16_t tag, uint16_t count, - TIFFDataType type) -{ - switch (type) - { - case TIFF_SHORT: - if (count == 1) - { - uint16_t shortv; - CopyField(tag, shortv); - } - else if (count == 2) - { - uint16_t shortv1, shortv2; - CopyField2(tag, shortv1, shortv2); - } - else if (count == 4) - { - uint16_t *tr, *tg, *tb, *ta; - CopyField4(tag, tr, tg, tb, ta); - } - else if (count == (uint16_t)-1) - { - uint16_t shortv1; - uint16_t *shortav; - CopyField2(tag, shortv1, shortav); - } - break; - case TIFF_LONG: - { - uint32_t longv; - CopyField(tag, longv); - } - break; - case TIFF_RATIONAL: - if (count == 1) - { - float floatv; - CopyField(tag, floatv); - } - else if (count == (uint16_t)-1) - { - float *floatav; - CopyField(tag, floatav); - } - break; - case TIFF_ASCII: - { - char *stringv; - CopyField(tag, stringv); - } - break; - case TIFF_DOUBLE: - if (count == 1) - { - double doublev; - CopyField(tag, doublev); - } - else if (count == (uint16_t)-1) - { - double *doubleav; - CopyField(tag, doubleav); - } - break; - default: - TIFFError(TIFFFileName(in), - "Data type %" PRIu16 " is not supported, tag %d skipped", - tag, type); - } -} - -static const struct cpTag -{ - uint16_t tag; - uint16_t count; - TIFFDataType type; +static struct cpTag { + uint16 tag; + uint16 count; + TIFFDataType type; } tags[] = { - {TIFFTAG_SUBFILETYPE, 1, TIFF_LONG}, - {TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT}, - {TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII}, - {TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII}, - {TIFFTAG_MAKE, 1, TIFF_ASCII}, - {TIFFTAG_MODEL, 1, TIFF_ASCII}, - {TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT}, - {TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL}, - {TIFFTAG_PAGENAME, 1, TIFF_ASCII}, - {TIFFTAG_XPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_YPOSITION, 1, TIFF_RATIONAL}, - {TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT}, - {TIFFTAG_SOFTWARE, 1, TIFF_ASCII}, - {TIFFTAG_DATETIME, 1, TIFF_ASCII}, - {TIFFTAG_ARTIST, 1, TIFF_ASCII}, - {TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII}, - {TIFFTAG_WHITEPOINT, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_PRIMARYCHROMATICITIES, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT}, - {TIFFTAG_INKSET, 1, TIFF_SHORT}, - {TIFFTAG_DOTRANGE, 2, TIFF_SHORT}, - {TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII}, - {TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT}, - {TIFFTAG_YCBCRCOEFFICIENTS, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT}, - {TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT}, - {TIFFTAG_REFERENCEBLACKWHITE, (uint16_t)-1, TIFF_RATIONAL}, - {TIFFTAG_EXTRASAMPLES, (uint16_t)-1, TIFF_SHORT}, - {TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE}, - {TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE}, - {TIFFTAG_STONITS, 1, TIFF_DOUBLE}, + { TIFFTAG_SUBFILETYPE, 1, TIFF_LONG }, + { TIFFTAG_THRESHHOLDING, 1, TIFF_SHORT }, + { TIFFTAG_DOCUMENTNAME, 1, TIFF_ASCII }, + { TIFFTAG_IMAGEDESCRIPTION, 1, TIFF_ASCII }, + { TIFFTAG_MAKE, 1, TIFF_ASCII }, + { TIFFTAG_MODEL, 1, TIFF_ASCII }, + { TIFFTAG_MINSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_MAXSAMPLEVALUE, 1, TIFF_SHORT }, + { TIFFTAG_XRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_YRESOLUTION, 1, TIFF_RATIONAL }, + { TIFFTAG_PAGENAME, 1, TIFF_ASCII }, + { TIFFTAG_XPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_YPOSITION, 1, TIFF_RATIONAL }, + { TIFFTAG_RESOLUTIONUNIT, 1, TIFF_SHORT }, + { TIFFTAG_SOFTWARE, 1, TIFF_ASCII }, + { TIFFTAG_DATETIME, 1, TIFF_ASCII }, + { TIFFTAG_ARTIST, 1, TIFF_ASCII }, + { TIFFTAG_HOSTCOMPUTER, 1, TIFF_ASCII }, + { TIFFTAG_WHITEPOINT, (uint16) -1, TIFF_RATIONAL }, + { TIFFTAG_PRIMARYCHROMATICITIES,(uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_HALFTONEHINTS, 2, TIFF_SHORT }, + { TIFFTAG_INKSET, 1, TIFF_SHORT }, + { TIFFTAG_DOTRANGE, 2, TIFF_SHORT }, + { TIFFTAG_TARGETPRINTER, 1, TIFF_ASCII }, + { TIFFTAG_SAMPLEFORMAT, 1, TIFF_SHORT }, + { TIFFTAG_YCBCRCOEFFICIENTS, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_YCBCRSUBSAMPLING, 2, TIFF_SHORT }, + { TIFFTAG_YCBCRPOSITIONING, 1, TIFF_SHORT }, + { TIFFTAG_REFERENCEBLACKWHITE, (uint16) -1,TIFF_RATIONAL }, + { TIFFTAG_EXTRASAMPLES, (uint16) -1, TIFF_SHORT }, + { TIFFTAG_SMINSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_SMAXSAMPLEVALUE, 1, TIFF_DOUBLE }, + { TIFFTAG_STONITS, 1, TIFF_DOUBLE }, }; -#define NTAGS (sizeof(tags) / sizeof(tags[0])) +#define NTAGS (sizeof (tags) / sizeof (tags[0])) -#define CopyTag(tag, count, type) cpTag(in, out, tag, count, type) +#define CopyTag(tag, count, type) cpTag(in, out, tag, count, type) /* Functions written by Richard Nolde, with exceptions noted. */ -void process_command_opts(int argc, char *argv[], char *mp, char *mode, - uint32_t *dirnum, uint16_t *defconfig, - uint16_t *deffillorder, uint32_t *deftilewidth, - uint32_t *deftilelength, uint32_t *defrowsperstrip, - struct crop_mask *crop_data, struct pagedef *page, - struct dump_opts *dump, unsigned int *imagelist, - unsigned int *image_count) -{ - int c, good_args = 0; - char *opt_offset = NULL; /* Position in string of value sought */ - char *opt_ptr = NULL; /* Pointer to next token in option set */ - char *sep = NULL; /* Pointer to a token separator */ - unsigned int i, j, start, end; +void process_command_opts (int argc, char *argv[], char *mp, char *mode, uint32 *dirnum, + uint16 *defconfig, uint16 *deffillorder, uint32 *deftilewidth, + uint32 *deftilelength, uint32 *defrowsperstrip, + struct crop_mask *crop_data, struct pagedef *page, + struct dump_opts *dump, + unsigned int *imagelist, unsigned int *image_count ) + { + int c, good_args = 0; + char *opt_offset = NULL; /* Position in string of value sought */ + char *opt_ptr = NULL; /* Pointer to next token in option set */ + char *sep = NULL; /* Pointer to a token separator */ + unsigned int i, j, start, end; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif *mp++ = 'w'; *mp = '\0'; while ((c = getopt(argc, argv, - "ac:d:e:f:hik:l:m:p:r:stvw:z:BCD:E:F:H:I:J:K:LMN:O:P:R:" - "S:U:V:X:Y:Z:")) != -1) - { - good_args++; - switch (c) - { - case 'a': - mode[0] = 'a'; /* append to output */ - break; - case 'c': - if (!processCompressOptions(optarg)) /* compression scheme */ - { - TIFFError("Unknown compression option", "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - case 'd': - start = strtoul(optarg, NULL, 0); /* initial IFD offset */ - if (start == 0) - { - TIFFError("", "Directory offset must be greater than zero"); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - *dirnum = start - 1; - break; - case 'e': - switch (tolower((int)optarg[0])) /* image export modes*/ - { - case 'c': - crop_data->exp_mode = ONE_FILE_COMPOSITE; - crop_data->img_mode = COMPOSITE_IMAGES; - break; /* Composite */ - case 'd': - crop_data->exp_mode = ONE_FILE_SEPARATED; - crop_data->img_mode = SEPARATED_IMAGES; - break; /* Divided */ - case 'i': - crop_data->exp_mode = FILE_PER_IMAGE_COMPOSITE; - crop_data->img_mode = COMPOSITE_IMAGES; - break; /* Image */ - case 'm': - crop_data->exp_mode = FILE_PER_IMAGE_SEPARATED; - crop_data->img_mode = SEPARATED_IMAGES; - break; /* Multiple */ - case 's': - crop_data->exp_mode = FILE_PER_SELECTION; - crop_data->img_mode = SEPARATED_IMAGES; - break; /* Sections */ - default: - TIFFError("Unknown export mode", "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - case 'f': - if (streq(optarg, "lsb2msb")) /* fill order */ - *deffillorder = FILLORDER_LSB2MSB; - else if (streq(optarg, "msb2lsb")) - *deffillorder = FILLORDER_MSB2LSB; - else - { - TIFFError("Unknown fill order", "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - case 'h': - usage(EXIT_SUCCESS); - break; - case 'i': - ignore = TRUE; /* ignore errors */ - break; - case 'k': - maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; - break; - case 'l': - outtiled = TRUE; /* tile length */ - *deftilelength = atoi(optarg); - break; - case 'p': /* planar configuration */ - if (streq(optarg, "separate")) - *defconfig = PLANARCONFIG_SEPARATE; - else if (streq(optarg, "contig")) - *defconfig = PLANARCONFIG_CONTIG; - else - { - TIFFError("Unknown planar configuration", "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - case 'r': /* rows/strip */ - *defrowsperstrip = atol(optarg); - break; - case 's': /* generate stripped output */ - outtiled = FALSE; - break; - case 't': /* generate tiled output */ - outtiled = TRUE; - break; - case 'v': - printf("Library Release: %s\n", TIFFGetVersion()); - printf("Tiffcp code: Copyright (c) 1988-1997 Sam Leffler\n"); - printf(" : Copyright (c) 1991-1997 Silicon Graphics, " - "Inc\n"); - printf("Tiffcrop additions: Copyright (c) 2007-2010 Richard " - "Nolde\n"); - exit(EXIT_SUCCESS); - break; - case 'w': /* tile width */ - outtiled = TRUE; - *deftilewidth = atoi(optarg); - break; - case 'z': /* regions of an image specified as - x1,y1,x2,y2:x3,y3,x4,y4 etc */ - crop_data->crop_mode |= CROP_REGIONS; - for (i = 0, opt_ptr = strtok(optarg, ":"); - ((opt_ptr != NULL) && (i < MAX_REGIONS)); - (opt_ptr = strtok(NULL, ":")), i++) - { - crop_data->regions++; - if (sscanf(opt_ptr, "%lf,%lf,%lf,%lf", - &crop_data->corners[i].X1, - &crop_data->corners[i].Y1, - &crop_data->corners[i].X2, - &crop_data->corners[i].Y2) != 4) + "ac:d:e:f:hik:l:m:p:r:stvw:z:BCD:E:F:H:I:J:K:LMN:O:P:R:S:U:V:X:Y:Z:")) != -1) + { + good_args++; + switch (c) { + case 'a': mode[0] = 'a'; /* append to output */ + break; + case 'c': if (!processCompressOptions(optarg)) /* compression scheme */ + { + TIFFError ("Unknown compression option", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + break; + case 'd': start = strtoul(optarg, NULL, 0); /* initial IFD offset */ + if (start == 0) + { + TIFFError ("","Directory offset must be greater than zero"); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + *dirnum = start - 1; + break; + case 'e': switch (tolower((int) optarg[0])) /* image export modes*/ + { + case 'c': crop_data->exp_mode = ONE_FILE_COMPOSITE; + crop_data->img_mode = COMPOSITE_IMAGES; + break; /* Composite */ + case 'd': crop_data->exp_mode = ONE_FILE_SEPARATED; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Divided */ + case 'i': crop_data->exp_mode = FILE_PER_IMAGE_COMPOSITE; + crop_data->img_mode = COMPOSITE_IMAGES; + break; /* Image */ + case 'm': crop_data->exp_mode = FILE_PER_IMAGE_SEPARATED; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Multiple */ + case 's': crop_data->exp_mode = FILE_PER_SELECTION; + crop_data->img_mode = SEPARATED_IMAGES; + break; /* Sections */ + default: TIFFError ("Unknown export mode","%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + break; + case 'f': if (streq(optarg, "lsb2msb")) /* fill order */ + *deffillorder = FILLORDER_LSB2MSB; + else if (streq(optarg, "msb2lsb")) + *deffillorder = FILLORDER_MSB2LSB; + else + { + TIFFError ("Unknown fill order", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + break; + case 'h': usage(EXIT_SUCCESS); + break; + case 'i': ignore = TRUE; /* ignore errors */ + break; + case 'k': maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; + break; + case 'l': outtiled = TRUE; /* tile length */ + *deftilelength = atoi(optarg); + break; + case 'p': /* planar configuration */ + if (streq(optarg, "separate")) + *defconfig = PLANARCONFIG_SEPARATE; + else if (streq(optarg, "contig")) + *defconfig = PLANARCONFIG_CONTIG; + else + { + TIFFError ("Unknown planar configuration", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + break; + case 'r': /* rows/strip */ + *defrowsperstrip = atol(optarg); + break; + case 's': /* generate stripped output */ + outtiled = FALSE; + break; + case 't': /* generate tiled output */ + outtiled = TRUE; + break; + case 'v': printf("Library Release: %s\n", TIFFGetVersion()); + printf("Tiffcrop version: %s, last updated: %s\n", + tiffcrop_version_id, tiffcrop_rev_date); + printf("Tiffcp code: Copyright (c) 1988-1997 Sam Leffler\n"); + printf(" : Copyright (c) 1991-1997 Silicon Graphics, Inc\n"); + printf("Tiffcrop additions: Copyright (c) 2007-2010 Richard Nolde\n"); + exit (EXIT_SUCCESS); + break; + case 'w': /* tile width */ + outtiled = TRUE; + *deftilewidth = atoi(optarg); + break; + case 'z': /* regions of an image specified as x1,y1,x2,y2:x3,y3,x4,y4 etc */ + crop_data->crop_mode |= CROP_REGIONS; + for (i = 0, opt_ptr = strtok (optarg, ":"); + ((opt_ptr != NULL) && (i < MAX_REGIONS)); + (opt_ptr = strtok (NULL, ":")), i++) { - TIFFError("Unable to parse coordinates for region", - "%u %s", i, optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); + crop_data->regions++; + if (sscanf(opt_ptr, "%lf,%lf,%lf,%lf", + &crop_data->corners[i].X1, &crop_data->corners[i].Y1, + &crop_data->corners[i].X2, &crop_data->corners[i].Y2) != 4) + { + TIFFError ("Unable to parse coordinates for region", "%d %s", i, optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } } - } /* check for remaining elements over MAX_REGIONS */ if ((opt_ptr != NULL) && (i >= MAX_REGIONS)) - { - TIFFError("Region list exceeds limit of", "%d regions %s", - MAX_REGIONS, optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - /* options for file open modes */ - case 'B': - { - if (mp < mode + MAX_MODESTRING_LEN) - { - *mp++ = 'b'; - *mp = '\0'; - } - else - { - TIFFError("To many options for output file open modes. " - "Maximum allowed ", - "%d", MAX_MODESTRING_LEN); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - } - break; - case 'L': - { - if (mp < mode + MAX_MODESTRING_LEN) - { - *mp++ = 'l'; - *mp = '\0'; - } - else - { - TIFFError("To many options for output file open modes. " - "Maximum allowed ", - "%d", MAX_MODESTRING_LEN); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - } - break; - case 'M': - { - if (mp < mode + MAX_MODESTRING_LEN) - { - *mp++ = 'm'; - *mp = '\0'; - } - else - { - TIFFError("To many options for output file open modes. " - "Maximum allowed ", - "%d", MAX_MODESTRING_LEN); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - } - break; - case 'C': - { - if (mp < mode + MAX_MODESTRING_LEN) - { - *mp++ = 'c'; - *mp = '\0'; - } - else - { - TIFFError("To many options for output file open modes. " - "Maximum allowed ", - "%d", MAX_MODESTRING_LEN); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - } - break; - /* options for Debugging / data dump */ - case 'D': - for (i = 0, opt_ptr = strtok(optarg, ","); (opt_ptr != NULL); - (opt_ptr = strtok(NULL, ",")), i++) - { - opt_offset = strpbrk(opt_ptr, ":="); - if (opt_offset == NULL) + { + TIFFError ("Region list exceeds limit of", "%d regions %s", MAX_REGIONS, optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE);; + } + break; + /* options for file open modes */ + case 'B': *mp++ = 'b'; *mp = '\0'; + break; + case 'L': *mp++ = 'l'; *mp = '\0'; + break; + case 'M': *mp++ = 'm'; *mp = '\0'; + break; + case 'C': *mp++ = 'c'; *mp = '\0'; + break; + /* options for Debugging / data dump */ + case 'D': for (i = 0, opt_ptr = strtok (optarg, ","); + (opt_ptr != NULL); + (opt_ptr = strtok (NULL, ",")), i++) { - TIFFError("Invalid dump option", "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - + opt_offset = strpbrk(opt_ptr, ":="); + if (opt_offset == NULL) + { + TIFFError("Invalid dump option", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + *opt_offset = '\0'; /* convert option to lowercase */ - end = (unsigned int)strlen(opt_ptr); + end = (unsigned int)strlen (opt_ptr); for (i = 0; i < end; i++) - *(opt_ptr + i) = tolower((int)*(opt_ptr + i)); + *(opt_ptr + i) = tolower((int) *(opt_ptr + i)); /* Look for dump format specification */ if (strncmp(opt_ptr, "for", 3) == 0) - { - /* convert value to lowercase */ - end = (unsigned int)strlen(opt_offset + 1); - for (i = 1; i <= end; i++) - *(opt_offset + i) = tolower((int)*(opt_offset + i)); - /* check dump format value */ - if (strncmp(opt_offset + 1, "txt", 3) == 0) + { + /* convert value to lowercase */ + end = (unsigned int)strlen (opt_offset + 1); + for (i = 1; i <= end; i++) + *(opt_offset + i) = tolower((int) *(opt_offset + i)); + /* check dump format value */ + if (strncmp (opt_offset + 1, "txt", 3) == 0) { - dump->format = DUMP_TEXT; - strcpy(dump->mode, "w"); + dump->format = DUMP_TEXT; + strcpy (dump->mode, "w"); } + else + { + if (strncmp(opt_offset + 1, "raw", 3) == 0) + { + dump->format = DUMP_RAW; + strcpy (dump->mode, "wb"); + } else - { - if (strncmp(opt_offset + 1, "raw", 3) == 0) - { - dump->format = DUMP_RAW; - strcpy(dump->mode, "wb"); - } - else - { - TIFFError("parse_command_opts", - "Unknown dump format %s", - opt_offset + 1); - TIFFError("For valid options type", - "tiffcrop -h"); - exit(EXIT_FAILURE); - } - } - } - else - { /* Look for dump level specification */ - if (strncmp(opt_ptr, "lev", 3) == 0) - dump->level = atoi(opt_offset + 1); + { + TIFFError("parse_command_opts", "Unknown dump format %s", opt_offset + 1); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + } + } + else + { /* Look for dump level specification */ + if (strncmp (opt_ptr, "lev", 3) == 0) + dump->level = atoi(opt_offset + 1); /* Look for input data dump file name */ - if (strncmp(opt_ptr, "in", 2) == 0) - { - strncpy(dump->infilename, opt_offset + 1, - PATH_MAX - 20); - dump->infilename[PATH_MAX - 20] = '\0'; + if (strncmp (opt_ptr, "in", 2) == 0) + { + strncpy (dump->infilename, opt_offset + 1, PATH_MAX - 20); + dump->infilename[PATH_MAX - 20] = '\0'; } /* Look for output data dump file name */ - if (strncmp(opt_ptr, "out", 3) == 0) - { - strncpy(dump->outfilename, opt_offset + 1, - PATH_MAX - 20); - dump->outfilename[PATH_MAX - 20] = '\0'; + if (strncmp (opt_ptr, "out", 3) == 0) + { + strncpy (dump->outfilename, opt_offset + 1, PATH_MAX - 20); + dump->outfilename[PATH_MAX - 20] = '\0'; } - if (strncmp(opt_ptr, "deb", 3) == 0) - dump->debug = atoi(opt_offset + 1); + if (strncmp (opt_ptr, "deb", 3) == 0) + dump->debug = atoi(opt_offset + 1); + } } - } - if ((strlen(dump->infilename)) || (strlen(dump->outfilename))) - { - if (dump->level == 1) - TIFFError("", "Defaulting to dump level 1, no data."); - if (dump->format == DUMP_NONE) + if ((strlen(dump->infilename)) || (strlen(dump->outfilename))) + { + if (dump->level == 1) + TIFFError("","Defaulting to dump level 1, no data."); + if (dump->format == DUMP_NONE) { - TIFFError( - "", - "You must specify a dump format for dump files"); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - } - break; + TIFFError("", "You must specify a dump format for dump files"); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + } + break; - /* image manipulation routine options */ - case 'm': /* margins to exclude from selection, uppercase M was - already used */ - /* order of values must be TOP, LEFT, BOTTOM, RIGHT */ - crop_data->crop_mode |= CROP_MARGINS; - for (i = 0, opt_ptr = strtok(optarg, ",:"); - ((opt_ptr != NULL) && (i < 4)); - (opt_ptr = strtok(NULL, ",:")), i++) - { - crop_data->margins[i] = atof(opt_ptr); - } - break; - case 'E': /* edge reference */ - switch (tolower((int)optarg[0])) - { - case 't': - crop_data->edge_ref = EDGE_TOP; - break; - case 'b': - crop_data->edge_ref = EDGE_BOTTOM; - break; - case 'l': - crop_data->edge_ref = EDGE_LEFT; - break; - case 'r': - crop_data->edge_ref = EDGE_RIGHT; - break; - default: - TIFFError("Edge reference must be top, bottom, left, " - "or right", - "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - case 'F': /* flip eg mirror image or cropped segment, M was already - used */ - crop_data->crop_mode |= CROP_MIRROR; - switch (tolower((int)optarg[0])) - { - case 'h': - crop_data->mirror = MIRROR_HORIZ; - break; - case 'v': - crop_data->mirror = MIRROR_VERT; - break; - case 'b': - crop_data->mirror = MIRROR_BOTH; - break; - default: - TIFFError("Flip mode must be horiz, vert, or both", - "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - case 'H': /* set horizontal resolution to new value */ - page->hres = atof(optarg); + /* image manipulation routine options */ + case 'm': /* margins to exclude from selection, uppercase M was already used */ + /* order of values must be TOP, LEFT, BOTTOM, RIGHT */ + crop_data->crop_mode |= CROP_MARGINS; + for (i = 0, opt_ptr = strtok (optarg, ",:"); + ((opt_ptr != NULL) && (i < 4)); + (opt_ptr = strtok (NULL, ",:")), i++) + { + crop_data->margins[i] = atof(opt_ptr); + } + break; + case 'E': /* edge reference */ + switch (tolower((int) optarg[0])) + { + case 't': crop_data->edge_ref = EDGE_TOP; + break; + case 'b': crop_data->edge_ref = EDGE_BOTTOM; + break; + case 'l': crop_data->edge_ref = EDGE_LEFT; + break; + case 'r': crop_data->edge_ref = EDGE_RIGHT; + break; + default: TIFFError ("Edge reference must be top, bottom, left, or right", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + break; + case 'F': /* flip eg mirror image or cropped segment, M was already used */ + crop_data->crop_mode |= CROP_MIRROR; + switch (tolower((int) optarg[0])) + { + case 'h': crop_data->mirror = MIRROR_HORIZ; + break; + case 'v': crop_data->mirror = MIRROR_VERT; + break; + case 'b': crop_data->mirror = MIRROR_BOTH; + break; + default: TIFFError ("Flip mode must be horiz, vert, or both", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + break; + case 'H': /* set horizontal resolution to new value */ + page->hres = atof (optarg); page->mode |= PAGE_MODE_RESOLUTION; - break; - case 'I': /* invert the color space, eg black to white */ - crop_data->crop_mode |= CROP_INVERT; + break; + case 'I': /* invert the color space, eg black to white */ + crop_data->crop_mode |= CROP_INVERT; /* The PHOTOMETIC_INTERPRETATION tag may be updated */ if (streq(optarg, "black")) - { - crop_data->photometric = PHOTOMETRIC_MINISBLACK; - continue; - } + { + crop_data->photometric = PHOTOMETRIC_MINISBLACK; + continue; + } if (streq(optarg, "white")) - { - crop_data->photometric = PHOTOMETRIC_MINISWHITE; - continue; - } - if (streq(optarg, "data")) - { - crop_data->photometric = INVERT_DATA_ONLY; - continue; - } + { + crop_data->photometric = PHOTOMETRIC_MINISWHITE; + continue; + } + if (streq(optarg, "data")) + { + crop_data->photometric = INVERT_DATA_ONLY; + continue; + } if (streq(optarg, "both")) - { - crop_data->photometric = INVERT_DATA_AND_TAG; - continue; - } + { + crop_data->photometric = INVERT_DATA_AND_TAG; + continue; + } - TIFFError("Missing or unknown option for inverting " - "PHOTOMETRIC_INTERPRETATION", - "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - break; - case 'J': /* horizontal margin for sectioned output pages */ - page->hmargin = atof(optarg); + TIFFError("Missing or unknown option for inverting PHOTOMETRIC_INTERPRETATION", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + break; + case 'J': /* horizontal margin for sectioned ouput pages */ + page->hmargin = atof(optarg); page->mode |= PAGE_MODE_MARGINS; - break; - case 'K': /* vertical margin for sectioned output pages*/ + break; + case 'K': /* vertical margin for sectioned ouput pages*/ page->vmargin = atof(optarg); page->mode |= PAGE_MODE_MARGINS; - break; - case 'N': /* list of images to process */ - for (i = 0, opt_ptr = strtok(optarg, ","); - ((opt_ptr != NULL) && (i < MAX_IMAGES)); - (opt_ptr = strtok(NULL, ","))) - { /* We do not know how many images are in file yet - * so we build a list to include the maximum allowed - * and follow it until we hit the end of the file. - * Image count is not accurate for odd, even, last - * so page numbers won't be valid either. - */ - if (streq(opt_ptr, "odd")) - { - for (j = 1; j <= MAX_IMAGES; j += 2) - imagelist[i++] = j; - *image_count = (MAX_IMAGES - 1) / 2; - break; - } - else - { - if (streq(opt_ptr, "even")) - { - for (j = 2; j <= MAX_IMAGES; j += 2) - imagelist[i++] = j; - *image_count = MAX_IMAGES / 2; - break; - } - else - { - if (streq(opt_ptr, "last")) - imagelist[i++] = MAX_IMAGES; - else /* single value between commas */ - { - sep = strpbrk(opt_ptr, ":-"); - if (!sep) - imagelist[i++] = atoi(opt_ptr); - else - { - *sep = '\0'; - start = atoi(opt_ptr); - if (!strcmp((sep + 1), "last")) - end = MAX_IMAGES; - else - end = atoi(sep + 1); - for (j = start; - j <= end && j - start + i < MAX_IMAGES; - j++) - imagelist[i++] = j; - } - } - } - } - } + break; + case 'N': /* list of images to process */ + for (i = 0, opt_ptr = strtok (optarg, ","); + ((opt_ptr != NULL) && (i < MAX_IMAGES)); + (opt_ptr = strtok (NULL, ","))) + { /* We do not know how many images are in file yet + * so we build a list to include the maximum allowed + * and follow it until we hit the end of the file. + * Image count is not accurate for odd, even, last + * so page numbers won't be valid either. + */ + if (streq(opt_ptr, "odd")) + { + for (j = 1; j <= MAX_IMAGES; j += 2) + imagelist[i++] = j; + *image_count = (MAX_IMAGES - 1) / 2; + break; + } + else + { + if (streq(opt_ptr, "even")) + { + for (j = 2; j <= MAX_IMAGES; j += 2) + imagelist[i++] = j; + *image_count = MAX_IMAGES / 2; + break; + } + else + { + if (streq(opt_ptr, "last")) + imagelist[i++] = MAX_IMAGES; + else /* single value between commas */ + { + sep = strpbrk(opt_ptr, ":-"); + if (!sep) + imagelist[i++] = atoi(opt_ptr); + else + { + *sep = '\0'; + start = atoi (opt_ptr); + if (!strcmp((sep + 1), "last")) + end = MAX_IMAGES; + else + end = atoi (sep + 1); + for (j = start; j <= end && j - start + i < MAX_IMAGES; j++) + imagelist[i++] = j; + } + } + } + } + } *image_count = i; - break; - case 'O': /* page orientation */ - switch (tolower((int)optarg[0])) - { - case 'a': - page->orient = ORIENTATION_AUTO; - break; - case 'p': - page->orient = ORIENTATION_PORTRAIT; - break; - case 'l': - page->orient = ORIENTATION_LANDSCAPE; - break; - default: - TIFFError( - "Orientation must be portrait, landscape, or auto.", - "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - case 'P': /* page size selection */ - if (sscanf(optarg, "%lfx%lf", &page->width, &page->length) == 2) - { - strcpy(page->name, "Custom"); - page->mode |= PAGE_MODE_PAPERSIZE; - break; - } - if (get_page_geometry(optarg, page)) - { - if (!strcmp(optarg, "list")) + break; + case 'O': /* page orientation */ + switch (tolower((int) optarg[0])) + { + case 'a': page->orient = ORIENTATION_AUTO; + break; + case 'p': page->orient = ORIENTATION_PORTRAIT; + break; + case 'l': page->orient = ORIENTATION_LANDSCAPE; + break; + default: TIFFError ("Orientation must be portrait, landscape, or auto.", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + break; + case 'P': /* page size selection */ + if (sscanf(optarg, "%lfx%lf", &page->width, &page->length) == 2) + { + strcpy (page->name, "Custom"); + page->mode |= PAGE_MODE_PAPERSIZE; + break; + } + if (get_page_geometry (optarg, page)) + { + if (!strcmp(optarg, "list")) { - TIFFError("", - "Name Width Length (in inches)"); - for (i = 0; i < MAX_PAPERNAMES - 1; i++) - TIFFError("", "%-15.15s %5.2f %5.2f", - PaperTable[i].name, PaperTable[i].width, - PaperTable[i].length); - exit(EXIT_FAILURE); - } - - TIFFError("Invalid paper size", "%s", optarg); - TIFFError("", "Select one of:"); - TIFFError("", "Name Width Length (in inches)"); + TIFFError("", "Name Width Length (in inches)"); for (i = 0; i < MAX_PAPERNAMES - 1; i++) - TIFFError("", "%-15.15s %5.2f %5.2f", - PaperTable[i].name, PaperTable[i].width, - PaperTable[i].length); - exit(EXIT_FAILURE); - } - else - { - page->mode |= PAGE_MODE_PAPERSIZE; - } - break; - case 'R': /* rotate image or cropped segment */ - crop_data->crop_mode |= CROP_ROTATE; - switch (strtoul(optarg, NULL, 0)) - { - case 90: - crop_data->rotation = (uint16_t)90; - break; - case 180: - crop_data->rotation = (uint16_t)180; - break; - case 270: - crop_data->rotation = (uint16_t)270; - break; - default: - TIFFError("Rotation must be 90, 180, or 270 degrees " - "clockwise", - "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - case 'S': /* subdivide into Cols:Rows sections, eg 3:2 would be 3 - across and 2 down */ - sep = strpbrk(optarg, ",:"); - if (sep) - { - *sep = '\0'; - page->cols = atoi(optarg); - page->rows = atoi(sep + 1); - } - else - { - page->cols = atoi(optarg); - page->rows = atoi(optarg); - } - if ((page->cols * page->rows) > MAX_SECTIONS) - { - TIFFError( - "Limit for subdivisions, ie rows x columns, exceeded", - "%d", MAX_SECTIONS); - exit(EXIT_FAILURE); - } - page->mode |= PAGE_MODE_ROWSCOLS; - break; - case 'U': /* units for measurements and offsets */ - if (streq(optarg, "in")) - { - crop_data->res_unit = RESUNIT_INCH; - page->res_unit = RESUNIT_INCH; - } - else if (streq(optarg, "cm")) - { - crop_data->res_unit = RESUNIT_CENTIMETER; - page->res_unit = RESUNIT_CENTIMETER; - } - else if (streq(optarg, "px")) - { - crop_data->res_unit = RESUNIT_NONE; - page->res_unit = RESUNIT_NONE; - } - else - { - TIFFError("Illegal unit of measure", "%s", optarg); - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - } - break; - case 'V': /* set vertical resolution to new value */ - page->vres = atof(optarg); - page->mode |= PAGE_MODE_RESOLUTION; - break; - case 'X': /* selection width */ - crop_data->crop_mode |= CROP_WIDTH; - crop_data->width = atof(optarg); - break; - case 'Y': /* selection length */ - crop_data->crop_mode |= CROP_LENGTH; - crop_data->length = atof(optarg); - break; - case 'Z': /* zones of an image X:Y read as zone X of Y */ - crop_data->crop_mode |= CROP_ZONES; - for (i = 0, opt_ptr = strtok(optarg, ","); - ((opt_ptr != NULL) && (i < MAX_REGIONS)); - (opt_ptr = strtok(NULL, ",")), i++) - { - crop_data->zones++; - opt_offset = strchr(opt_ptr, ':'); - if (!opt_offset) - { - TIFFError("Wrong parameter syntax for -Z", - "tiffcrop -h"); - exit(EXIT_FAILURE); + TIFFError ("", "%-15.15s %5.2f %5.2f", + PaperTable[i].name, PaperTable[i].width, + PaperTable[i].length); + exit (EXIT_FAILURE); } + + TIFFError ("Invalid paper size", "%s", optarg); + TIFFError ("", "Select one of:"); + TIFFError("", "Name Width Length (in inches)"); + for (i = 0; i < MAX_PAPERNAMES - 1; i++) + TIFFError ("", "%-15.15s %5.2f %5.2f", + PaperTable[i].name, PaperTable[i].width, + PaperTable[i].length); + exit (EXIT_FAILURE); + } + else + { + page->mode |= PAGE_MODE_PAPERSIZE; + } + break; + case 'R': /* rotate image or cropped segment */ + crop_data->crop_mode |= CROP_ROTATE; + switch (strtoul(optarg, NULL, 0)) + { + case 90: crop_data->rotation = (uint16)90; + break; + case 180: crop_data->rotation = (uint16)180; + break; + case 270: crop_data->rotation = (uint16)270; + break; + default: TIFFError ("Rotation must be 90, 180, or 270 degrees clockwise", "%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + break; + case 'S': /* subdivide into Cols:Rows sections, eg 3:2 would be 3 across and 2 down */ + sep = strpbrk(optarg, ",:"); + if (sep) + { + *sep = '\0'; + page->cols = atoi(optarg); + page->rows = atoi(sep +1); + } + else + { + page->cols = atoi(optarg); + page->rows = atoi(optarg); + } + if ((page->cols * page->rows) > MAX_SECTIONS) + { + TIFFError ("Limit for subdivisions, ie rows x columns, exceeded", "%d", MAX_SECTIONS); + exit (EXIT_FAILURE); + } + page->mode |= PAGE_MODE_ROWSCOLS; + break; + case 'U': /* units for measurements and offsets */ + if (streq(optarg, "in")) + { + crop_data->res_unit = RESUNIT_INCH; + page->res_unit = RESUNIT_INCH; + } + else if (streq(optarg, "cm")) + { + crop_data->res_unit = RESUNIT_CENTIMETER; + page->res_unit = RESUNIT_CENTIMETER; + } + else if (streq(optarg, "px")) + { + crop_data->res_unit = RESUNIT_NONE; + page->res_unit = RESUNIT_NONE; + } + else + { + TIFFError ("Illegal unit of measure","%s", optarg); + TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + } + break; + case 'V': /* set vertical resolution to new value */ + page->vres = atof (optarg); + page->mode |= PAGE_MODE_RESOLUTION; + break; + case 'X': /* selection width */ + crop_data->crop_mode |= CROP_WIDTH; + crop_data->width = atof(optarg); + break; + case 'Y': /* selection length */ + crop_data->crop_mode |= CROP_LENGTH; + crop_data->length = atof(optarg); + break; + case 'Z': /* zones of an image X:Y read as zone X of Y */ + crop_data->crop_mode |= CROP_ZONES; + for (i = 0, opt_ptr = strtok (optarg, ","); + ((opt_ptr != NULL) && (i < MAX_REGIONS)); + (opt_ptr = strtok (NULL, ",")), i++) + { + crop_data->zones++; + opt_offset = strchr(opt_ptr, ':'); + if (!opt_offset) { + TIFFError("Wrong parameter syntax for -Z", "tiffcrop -h"); + exit(EXIT_FAILURE); + } *opt_offset = '\0'; crop_data->zonelist[i].position = atoi(opt_ptr); - crop_data->zonelist[i].total = atoi(opt_offset + 1); - } + crop_data->zonelist[i].total = atoi(opt_offset + 1); + } /* check for remaining elements over MAX_REGIONS */ if ((opt_ptr != NULL) && (i >= MAX_REGIONS)) - { - TIFFError("Zone list exceeds region limit", "%d", - MAX_REGIONS); - exit(EXIT_FAILURE); - } - break; - case '?': - TIFFError("For valid options type", "tiffcrop -h"); - exit(EXIT_FAILURE); - /*NOTREACHED*/ - } + { + TIFFError("Zone list exceeds region limit", "%d", MAX_REGIONS); + exit (EXIT_FAILURE); + } + break; + case '?': TIFFError ("For valid options type", "tiffcrop -h"); + exit (EXIT_FAILURE); + /*NOTREACHED*/ + } } + { /*-- Check for not allowed combinations (e.g. -X, -Y and -Z, -z and -S are * mutually exclusive) --*/ char XY, Z, R, S; @@ -2497,4817 +2176,4330 @@ overflows. "other PAGE_MODE_x options such as - H, -V, -P, -J or -K is " "not supported and may cause buffer overflows..->exit"); exit(EXIT_FAILURE); + } } - -} /* end process_command_opts */ + } /* end process_command_opts */ /* Start a new output file if one has not been previously opened or * autoindex is set to non-zero. Update page and file counters * so TIFFTAG PAGENUM will be correct in image. */ -static int update_output_file(TIFF **tiffout, char *mode, int autoindex, - char *outname, unsigned int *page) -{ - static int findex = 0; /* file sequence indicator */ - size_t basename_len; - char *sep; - char export_ext[16]; - char exportname[PATH_MAX]; +static int +update_output_file (TIFF **tiffout, char *mode, int autoindex, + char *outname, unsigned int *page) + { + static int findex = 0; /* file sequence indicator */ + size_t basename_len; + char *sep; + char export_ext[16]; + char exportname[PATH_MAX]; - if (autoindex && (*tiffout != NULL)) + if (autoindex && (*tiffout != NULL)) { - /* Close any export file that was previously opened */ - TIFFClose(*tiffout); - *tiffout = NULL; + /* Close any export file that was previously opened */ + TIFFClose (*tiffout); + *tiffout = NULL; } - memcpy(export_ext, ".tiff", 6); - memset(exportname, '\0', sizeof(exportname)); + memcpy (export_ext, ".tiff", 6); + memset (exportname, '\0', sizeof(exportname)); -/* Leave room for page number portion of the new filename : - * hyphen + 6 digits + dot + 4 extension characters + null terminator */ -#define FILENUM_MAX_LENGTH (1 + 6 + 1 + 4 + 1) - strncpy(exportname, outname, sizeof(exportname) - FILENUM_MAX_LENGTH); - if (*tiffout == NULL) /* This is a new export file */ + /* Leave room for page number portion of the new filename : + * hyphen + 6 digits + dot + 4 extension characters + null terminator */ + #define FILENUM_MAX_LENGTH (1+6+1+4+1) + strncpy (exportname, outname, sizeof(exportname) - FILENUM_MAX_LENGTH); + if (*tiffout == NULL) /* This is a new export file */ { - if (autoindex) - { /* create a new filename for each export */ - findex++; - if ((sep = strstr(exportname, ".tif")) || - (sep = strstr(exportname, ".TIF"))) - { - strncpy(export_ext, sep, 5); - *sep = '\0'; - } - else - memcpy(export_ext, ".tiff", 5); - export_ext[5] = '\0'; - basename_len = strlen(exportname); - - /* MAX_EXPORT_PAGES limited to 6 digits to prevent string overflow - * of pathname */ - if (findex > MAX_EXPORT_PAGES) - { - TIFFError("update_output_file", - "Maximum of %d pages per file exceeded", - MAX_EXPORT_PAGES); - return 1; - } - - /* We previously assured that there will be space left */ - snprintf(exportname + basename_len, - sizeof(exportname) - basename_len, "-%03d%.5s", findex, - export_ext); - } - exportname[sizeof(exportname) - 1] = '\0'; - - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - if (opts == NULL) + if (autoindex) + { /* create a new filename for each export */ + findex++; + if ((sep = strstr(exportname, ".tif")) || (sep = strstr(exportname, ".TIF"))) { - return 1; + strncpy (export_ext, sep, 5); + *sep = '\0'; } - TIFFOpenOptionsSetMaxSingleMemAlloc(opts, maxMalloc); - *tiffout = TIFFOpenExt(exportname, mode, opts); - TIFFOpenOptionsFree(opts); - if (*tiffout == NULL) - { - TIFFError("update_output_file", "Unable to open output file %s", - exportname); - return 1; - } - *page = 0; + else + memcpy (export_ext, ".tiff", 5); + export_ext[5] = '\0'; + basename_len = strlen(exportname); - return 0; - } - else - (*page)++; + /* MAX_EXPORT_PAGES limited to 6 digits to prevent string overflow of pathname */ + if (findex > MAX_EXPORT_PAGES) + { + TIFFError("update_output_file", "Maximum of %d pages per file exceeded", MAX_EXPORT_PAGES); + return 1; + } + + /* We previously assured that there will be space left */ + snprintf(exportname + basename_len, sizeof(exportname) - basename_len, "-%03d%.5s", findex, export_ext); + } + exportname[sizeof(exportname) - 1] = '\0'; + + *tiffout = TIFFOpen(exportname, mode); + if (*tiffout == NULL) + { + TIFFError("update_output_file", "Unable to open output file %s", exportname); + return 1; + } + *page = 0; return 0; -} /* end update_output_file */ + } + else + (*page)++; -int main(int argc, char *argv[]) -{ + return 0; + } /* end update_output_file */ + + +int +main(int argc, char* argv[]) + { #if !HAVE_DECL_OPTARG - extern int optind; + extern int optind; #endif - uint16_t defconfig = (uint16_t)-1; - uint16_t deffillorder = 0; - uint32_t deftilewidth = (uint32_t)0; - uint32_t deftilelength = (uint32_t)0; - uint32_t defrowsperstrip = (uint32_t)0; - uint32_t dirnum = 0; + uint16 defconfig = (uint16) -1; + uint16 deffillorder = 0; + uint32 deftilewidth = (uint32) 0; + uint32 deftilelength = (uint32) 0; + uint32 defrowsperstrip = (uint32) 0; + uint32 dirnum = 0; - TIFF *in = NULL; - TIFF *out = NULL; - char mode[10]; - char *mp = mode; + TIFF *in = NULL; + TIFF *out = NULL; + char mode[10]; + char *mp = mode; - /** RJN additions **/ - struct image_data image; /* Image parameters for one image */ - struct crop_mask crop; /* Cropping parameters for all images */ - struct pagedef page; /* Page definition for output pages */ - struct pageseg sections[MAX_SECTIONS]; /* Sections of one output page */ - struct buffinfo - seg_buffs[MAX_SECTIONS]; /* Segment buffer sizes and pointers */ - struct dump_opts dump; /* Data dump options */ - unsigned char *read_buff = NULL; /* Input image data buffer */ - unsigned char *crop_buff = NULL; /* Crop area buffer */ - unsigned char *sect_buff = NULL; /* Image section buffer */ - unsigned char *sect_src = NULL; /* Image section buffer pointer */ - unsigned int imagelist[MAX_IMAGES + 1]; /* individually specified images */ - unsigned int image_count = 0; - unsigned int dump_images = 0; - unsigned int next_image = 0; - unsigned int next_page = 0; - unsigned int total_pages = 0; - unsigned int total_images = 0; - unsigned int end_of_input = FALSE; - int seg; - size_t length; - char temp_filename[PATH_MAX + 16]; /* Extra space keeps the compiler from - complaining */ + /** RJN additions **/ + struct image_data image; /* Image parameters for one image */ + struct crop_mask crop; /* Cropping parameters for all images */ + struct pagedef page; /* Page definition for output pages */ + struct pageseg sections[MAX_SECTIONS]; /* Sections of one output page */ + struct buffinfo seg_buffs[MAX_SECTIONS]; /* Segment buffer sizes and pointers */ + struct dump_opts dump; /* Data dump options */ + unsigned char *read_buff = NULL; /* Input image data buffer */ + unsigned char *crop_buff = NULL; /* Crop area buffer */ + unsigned char *sect_buff = NULL; /* Image section buffer */ + unsigned char *sect_src = NULL; /* Image section buffer pointer */ + unsigned int imagelist[MAX_IMAGES + 1]; /* individually specified images */ + unsigned int image_count = 0; + unsigned int dump_images = 0; + unsigned int next_image = 0; + unsigned int next_page = 0; + unsigned int total_pages = 0; + unsigned int total_images = 0; + unsigned int end_of_input = FALSE; + int seg; + size_t length; + char temp_filename[PATH_MAX + 16]; /* Extra space keeps the compiler from complaining */ - assert(NUM_BUFF_OVERSIZE_BYTES >= 3); + assert(NUM_BUFF_OVERSIZE_BYTES >= 3); - little_endian = *((unsigned char *)&little_endian) & '1'; + little_endian = *((unsigned char *)&little_endian) & '1'; - initImageData(&image); - initCropMasks(&crop); - initPageSetup(&page, sections, seg_buffs); - initDumpOptions(&dump); + initImageData(&image); + initCropMasks(&crop); + initPageSetup(&page, sections, seg_buffs); + initDumpOptions(&dump); - process_command_opts(argc, argv, mp, mode, &dirnum, &defconfig, - &deffillorder, &deftilewidth, &deftilelength, - &defrowsperstrip, &crop, &page, &dump, imagelist, - &image_count); + process_command_opts (argc, argv, mp, mode, &dirnum, &defconfig, + &deffillorder, &deftilewidth, &deftilelength, &defrowsperstrip, + &crop, &page, &dump, imagelist, &image_count); - if (argc - optind < 2) - usage(EXIT_FAILURE); + if (argc - optind < 2) + usage(EXIT_FAILURE); - if ((argc - optind) == 2) - pageNum = -1; + if ((argc - optind) == 2) + pageNum = -1; + else + total_images = 0; + /* Read multiple input files and write to output file(s) */ + while (optind < argc - 1) + { + in = TIFFOpen (argv[optind], "r"); + if (in == NULL) + return (-3); + + /* If only one input file is specified, we can use directory count */ + total_images = TIFFNumberOfDirectories(in); + if (total_images > TIFF_DIR_MAX) + { + TIFFError (TIFFFileName(in), "File contains too many directories"); + if (out != NULL) + (void) TIFFClose(out); + return (1); + } + if (image_count == 0) + { + dirnum = 0; + total_pages = total_images; /* Only valid with single input file */ + } else - total_images = 0; - /* Read multiple input files and write to output file(s) */ - while (optind < argc - 1) - { + { + dirnum = (tdir_t)(imagelist[next_image] - 1); + next_image++; - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - if (opts == NULL) - { - return -3; - } - TIFFOpenOptionsSetMaxSingleMemAlloc(opts, maxMalloc); - in = TIFFOpenExt(argv[optind], "r", opts); - TIFFOpenOptionsFree(opts); - if (in == NULL) - return (-3); + /* Total pages only valid for enumerated list of pages not derived + * using odd, even, or last keywords. + */ + if (image_count > total_images) + image_count = total_images; + + total_pages = image_count; + } - /* If only one input file is specified, we can use directory count */ - total_images = TIFFNumberOfDirectories(in); - if (total_images > TIFF_DIR_MAX) + /* MAX_IMAGES is used for special case "last" in selection list */ + if (dirnum == (MAX_IMAGES - 1)) + dirnum = total_images - 1; + + if (dirnum > (total_images)) + { + TIFFError (TIFFFileName(in), + "Invalid image number %d, File contains only %d images", + (int)dirnum + 1, total_images); + if (out != NULL) + (void) TIFFClose(out); + return (1); + } + + if (dirnum != 0 && !TIFFSetDirectory(in, (tdir_t)dirnum)) + { + TIFFError(TIFFFileName(in),"Error, setting subdirectory at %d", dirnum); + if (out != NULL) + (void) TIFFClose(out); + return (1); + } + + end_of_input = FALSE; + while (end_of_input == FALSE) + { + config = defconfig; + compression = defcompression; + predictor = defpredictor; + fillorder = deffillorder; + rowsperstrip = defrowsperstrip; + tilewidth = deftilewidth; + tilelength = deftilelength; + g3opts = defg3opts; + + if (dump.format != DUMP_NONE) { - TIFFError(TIFFFileName(in), "File contains too many directories"); - if (out != NULL) - (void)TIFFClose(out); - return (1); + /* manage input and/or output dump files here */ + dump_images++; + length = strlen(dump.infilename); + if (length > 0) + { + if (dump.infile != NULL) + fclose (dump.infile); + + /* dump.infilename is guaranteed to be NUL terminated and have 20 bytes + fewer than PATH_MAX */ + snprintf(temp_filename, sizeof(temp_filename), "%s-read-%03d.%s", + dump.infilename, dump_images, + (dump.format == DUMP_TEXT) ? "txt" : "raw"); + if ((dump.infile = fopen(temp_filename, dump.mode)) == NULL) + { + TIFFError ("Unable to open dump file for writing", "%s", temp_filename); + exit (EXIT_FAILURE); + } + dump_info(dump.infile, dump.format, "Reading image","%d from %s", + dump_images, TIFFFileName(in)); + } + length = strlen(dump.outfilename); + if (length > 0) + { + if (dump.outfile != NULL) + fclose (dump.outfile); + + /* dump.outfilename is guaranteed to be NUL terminated and have 20 bytes + fewer than PATH_MAX */ + snprintf(temp_filename, sizeof(temp_filename), "%s-write-%03d.%s", + dump.outfilename, dump_images, + (dump.format == DUMP_TEXT) ? "txt" : "raw"); + if ((dump.outfile = fopen(temp_filename, dump.mode)) == NULL) + { + TIFFError ("Unable to open dump file for writing", "%s", temp_filename); + exit (EXIT_FAILURE); + } + dump_info(dump.outfile, dump.format, "Writing image","%d from %s", + dump_images, TIFFFileName(in)); + } } - if (image_count == 0) + + if (dump.debug) + TIFFError("main", "Reading image %4d of %4d total pages.", dirnum + 1, total_pages); + + if (loadImage(in, &image, &dump, &read_buff)) { - dirnum = 0; - total_pages = total_images; /* Only valid with single input file */ + TIFFError("main", "Unable to load source image"); + exit (EXIT_FAILURE); } + + /* Correct the image orientation if it was not ORIENTATION_TOPLEFT. + */ + if (image.adjustments != 0) + { + if (correct_orientation(&image, &read_buff)) + TIFFError("main", "Unable to correct image orientation"); + } + + if (getCropOffsets(&image, &crop, &dump)) + { + TIFFError("main", "Unable to define crop regions"); + exit (EXIT_FAILURE); + } + + /* Crop input image and copy zones and regions from input image into seg_buffs or crop_buff. */ + if (crop.selections > 0) + { + if (processCropSelections(&image, &crop, &read_buff, seg_buffs)) + { + TIFFError("main", "Unable to process image selections"); + exit (EXIT_FAILURE); + } + } + else /* Single image segment without zones or regions */ + { + if (createCroppedImage(&image, &crop, &read_buff, &crop_buff)) + { + TIFFError("main", "Unable to create output image"); + exit (EXIT_FAILURE); + } + } + /* Format and write selected image parts to output file(s). */ + if (page.mode == PAGE_MODE_NONE) + { /* Whole image or sections not based on output page size */ + if (crop.selections > 0) + { + writeSelections(in, &out, &crop, &image, &dump, seg_buffs, + mp, argv[argc - 1], &next_page, total_pages); + } + else /* One file all images and sections */ + { + if (update_output_file (&out, mp, crop.exp_mode, argv[argc - 1], + &next_page)) + exit (EXIT_FAILURE); + if (writeCroppedImage(in, out, &image, &dump,crop.combined_width, + crop.combined_length, crop_buff, next_page, total_pages)) + { + TIFFError("main", "Unable to write new image"); + exit (EXIT_FAILURE); + } + } + } + else + { + /* If we used a crop buffer, our data is there, otherwise it is + * in the read_buffer + */ + if (crop_buff != NULL) + sect_src = crop_buff; else - { - dirnum = (tdir_t)(imagelist[next_image] - 1); - next_image++; + sect_src = read_buff; + /* Break input image into pages or rows and columns */ + if (computeOutputPixelOffsets(&crop, &image, &page, sections, &dump)) + { + TIFFError("main", "Unable to compute output section data"); + exit (EXIT_FAILURE); + } + /* If there are multiple files on the command line, the final one is assumed + * to be the output filename into which the images are written. + */ + if (update_output_file (&out, mp, crop.exp_mode, argv[argc - 1], &next_page)) + exit (EXIT_FAILURE); - /* Total pages only valid for enumerated list of pages not derived - * using odd, even, or last keywords. - */ - if (image_count > total_images) - image_count = total_images; - - total_pages = image_count; + if (writeImageSections(in, out, &image, &page, sections, &dump, sect_src, §_buff)) + { + TIFFError("main", "Unable to write image sections"); + exit (EXIT_FAILURE); + } } - /* MAX_IMAGES is used for special case "last" in selection list */ - if (dirnum == (MAX_IMAGES - 1)) - dirnum = total_images - 1; - - if (dirnum > (total_images)) + /* No image list specified, just read the next image */ + if (image_count == 0) + dirnum++; + else { - TIFFError(TIFFFileName(in), - "Invalid image number %" PRIu32 - ", File contains only %" PRIu32 " images", - dirnum + 1u, total_images); - if (out != NULL) - (void)TIFFClose(out); - return (1); + dirnum = (tdir_t)(imagelist[next_image] - 1); + next_image++; } - if (dirnum != 0 && !TIFFSetDirectory(in, (tdir_t)dirnum)) - { - TIFFError(TIFFFileName(in), - "Error, setting subdirectory at %" PRIu32, dirnum); - if (out != NULL) - (void)TIFFClose(out); - return (1); - } + if (dirnum == MAX_IMAGES - 1) + dirnum = TIFFNumberOfDirectories(in) - 1; - end_of_input = FALSE; - while (end_of_input == FALSE) - { - config = defconfig; - compression = defcompression; - predictor = defpredictor; - fillorder = deffillorder; - rowsperstrip = defrowsperstrip; - tilewidth = deftilewidth; - tilelength = deftilelength; - g3opts = defg3opts; - - if (dump.format != DUMP_NONE) - { - /* manage input and/or output dump files here */ - dump_images++; - length = strlen(dump.infilename); - if (length > 0) - { - if (dump.infile != NULL) - fclose(dump.infile); - - /* dump.infilename is guaranteed to be NUL terminated and - have 20 bytes fewer than PATH_MAX */ - snprintf(temp_filename, sizeof(temp_filename), - "%s-read-%03d.%s", dump.infilename, dump_images, - (dump.format == DUMP_TEXT) ? "txt" : "raw"); - if ((dump.infile = fopen(temp_filename, dump.mode)) == NULL) - { - TIFFError("Unable to open dump file for writing", "%s", - temp_filename); - exit(EXIT_FAILURE); - } - dump_info(dump.infile, dump.format, "Reading image", - "%u from %s", dump_images, TIFFFileName(in)); - } - length = strlen(dump.outfilename); - if (length > 0) - { - if (dump.outfile != NULL) - fclose(dump.outfile); - - /* dump.outfilename is guaranteed to be NUL terminated and - have 20 bytes fewer than PATH_MAX */ - snprintf(temp_filename, sizeof(temp_filename), - "%s-write-%03d.%s", dump.outfilename, dump_images, - (dump.format == DUMP_TEXT) ? "txt" : "raw"); - if ((dump.outfile = fopen(temp_filename, dump.mode)) == - NULL) - { - TIFFError("Unable to open dump file for writing", "%s", - temp_filename); - exit(EXIT_FAILURE); - } - dump_info(dump.outfile, dump.format, "Writing image", - "%u from %s", dump_images, TIFFFileName(in)); - } - } - - if (dump.debug) - TIFFError("main", "Reading image %4d of %4d total pages.", - dirnum + 1, total_pages); - - if (loadImage(in, &image, &dump, &read_buff)) - { - TIFFError("main", "Unable to load source image"); - exit(EXIT_FAILURE); - } - - /* Correct the image orientation if it was not ORIENTATION_TOPLEFT. - */ - if (image.adjustments != 0) - { - if (correct_orientation(&image, &read_buff)) - TIFFError("main", "Unable to correct image orientation"); - } - - if (getCropOffsets(&image, &crop, &dump)) - { - TIFFError("main", "Unable to define crop regions"); - exit(EXIT_FAILURE); - } - - /* Crop input image and copy zones and regions from input image into - * seg_buffs or crop_buff. */ - if (crop.selections > 0) - { - if (processCropSelections(&image, &crop, &read_buff, seg_buffs)) - { - TIFFError("main", "Unable to process image selections"); - exit(EXIT_FAILURE); - } - } - else /* Single image segment without zones or regions */ - { - if (createCroppedImage(&image, &crop, &read_buff, &crop_buff)) - { - TIFFError("main", "Unable to create output image"); - exit(EXIT_FAILURE); - } - } - /* Format and write selected image parts to output file(s). */ - if (page.mode == PAGE_MODE_NONE) - { /* Whole image or sections not based on output page size */ - if (crop.selections > 0) - { - if (writeSelections(in, &out, &crop, &image, &dump, - seg_buffs, mp, argv[argc - 1], - &next_page, total_pages)) - { - TIFFError("main", - "Unable to write new image selections"); - exit(EXIT_FAILURE); - } - } - else /* One file all images and sections */ - { - if (update_output_file(&out, mp, crop.exp_mode, - argv[argc - 1], &next_page)) - exit(EXIT_FAILURE); - if (writeCroppedImage(in, out, &image, &dump, - crop.combined_width, - crop.combined_length, crop_buff, - next_page, total_pages)) - { - TIFFError("main", "Unable to write new image"); - exit(EXIT_FAILURE); - } - } - } - else - { - /* If we used a crop buffer, our data is there, otherwise it is - * in the read_buffer - */ - if (crop_buff != NULL) - sect_src = crop_buff; - else - sect_src = read_buff; - /* Break input image into pages or rows and columns */ - if (computeOutputPixelOffsets(&crop, &image, &page, sections, - &dump)) - { - TIFFError("main", "Unable to compute output section data"); - exit(EXIT_FAILURE); - } - /* If there are multiple files on the command line, the final - * one is assumed to be the output filename into which the - * images are written. - */ - if (update_output_file(&out, mp, crop.exp_mode, argv[argc - 1], - &next_page)) - exit(EXIT_FAILURE); - - if (writeImageSections(in, out, &image, &page, sections, &dump, - sect_src, §_buff)) - { - TIFFError("main", "Unable to write image sections"); - exit(EXIT_FAILURE); - } - } - - /* No image list specified, just read the next image */ - if (image_count == 0) - dirnum++; - else - { - dirnum = (tdir_t)(imagelist[next_image] - 1); - next_image++; - } - - if (dirnum == MAX_IMAGES - 1) - dirnum = TIFFNumberOfDirectories(in) - 1; - - if (!TIFFSetDirectory(in, (tdir_t)dirnum)) - end_of_input = TRUE; - } - TIFFClose(in); - optind++; + if (!TIFFSetDirectory(in, (tdir_t)dirnum)) + end_of_input = TRUE; + } + TIFFClose(in); + optind++; } - /* If we did not use the read buffer as the crop buffer */ - if (read_buff) - _TIFFfree(read_buff); + /* If we did not use the read buffer as the crop buffer */ + if (read_buff) + _TIFFfree(read_buff); - if (crop_buff) - _TIFFfree(crop_buff); + if (crop_buff) + _TIFFfree(crop_buff); - if (sect_buff) - _TIFFfree(sect_buff); + if (sect_buff) + _TIFFfree(sect_buff); - /* Clean up any segment buffers used for zones or regions */ - for (seg = 0; seg < crop.selections; seg++) - _TIFFfree(seg_buffs[seg].buffer); + /* Clean up any segment buffers used for zones or regions */ + for (seg = 0; seg < crop.selections; seg++) + _TIFFfree (seg_buffs[seg].buffer); - if (dump.format != DUMP_NONE) + if (dump.format != DUMP_NONE) { - if (dump.infile != NULL) - fclose(dump.infile); + if (dump.infile != NULL) + fclose (dump.infile); - if (dump.outfile != NULL) - { - dump_info(dump.outfile, dump.format, "", "Completed run for %s", - TIFFFileName(out)); - fclose(dump.outfile); - } + if (dump.outfile != NULL) + { + dump_info (dump.outfile, dump.format, "", "Completed run for %s", TIFFFileName(out)); + fclose (dump.outfile); + } } - if (out != NULL) + if (out != NULL) { - TIFFClose(out); + TIFFClose(out); } - return (0); -} /* end main */ + return (0); + } /* end main */ + /* Debugging functions */ -static int dump_data(FILE *dumpfile, int format, char *dump_tag, - unsigned char *data, uint32_t count) -{ - int j, k; - uint32_t i; - char dump_array[10]; - unsigned char bitset; +static int dump_data (FILE *dumpfile, int format, char *dump_tag, unsigned char *data, uint32 count) + { + int j, k; + uint32 i; + char dump_array[10]; + unsigned char bitset; - if (dumpfile == NULL) + if (dumpfile == NULL) { - TIFFError("", "Invalid FILE pointer for dump file"); - return (1); + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); } - if (format == DUMP_TEXT) + if (format == DUMP_TEXT) { - fprintf(dumpfile, " %s ", dump_tag); - for (i = 0; i < count; i++) + fprintf (dumpfile," %s ", dump_tag); + for (i = 0; i < count; i++) + { + for (j = 0, k = 7; j < 8; j++, k--) { - for (j = 0, k = 7; j < 8; j++, k--) - { - bitset = (*(data + i)) & (((unsigned char)1 << k)) ? 1 : 0; - sprintf(&dump_array[j], (bitset) ? "1" : "0"); - } - dump_array[8] = '\0'; - fprintf(dumpfile, " %s", dump_array); + bitset = (*(data + i)) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); } - fprintf(dumpfile, "\n"); + dump_array[8] = '\0'; + fprintf (dumpfile," %s", dump_array); + } + fprintf (dumpfile,"\n"); } - else + else { - if ((fwrite(data, 1, count, dumpfile)) != count) - { - TIFFError("", "Unable to write binary data to dump file"); - return (1); - } + if ((fwrite (data, 1, count, dumpfile)) != count) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } } - return (0); -} + return (0); + } -static int dump_byte(FILE *dumpfile, int format, char *dump_tag, - unsigned char data) -{ - int j, k; - char dump_array[10]; - unsigned char bitset; +static int dump_byte (FILE *dumpfile, int format, char *dump_tag, unsigned char data) + { + int j, k; + char dump_array[10]; + unsigned char bitset; - if (dumpfile == NULL) + if (dumpfile == NULL) { - TIFFError("", "Invalid FILE pointer for dump file"); - return (1); + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); } - if (format == DUMP_TEXT) + if (format == DUMP_TEXT) { - fprintf(dumpfile, " %s ", dump_tag); - for (j = 0, k = 7; j < 8; j++, k--) - { - bitset = data & (((unsigned char)1 << k)) ? 1 : 0; - sprintf(&dump_array[j], (bitset) ? "1" : "0"); - } - dump_array[8] = '\0'; - fprintf(dumpfile, " %s\n", dump_array); + fprintf (dumpfile," %s ", dump_tag); + for (j = 0, k = 7; j < 8; j++, k--) + { + bitset = data & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); + } + dump_array[8] = '\0'; + fprintf (dumpfile," %s\n", dump_array); } - else + else { - if ((fwrite(&data, 1, 1, dumpfile)) != 1) - { - TIFFError("", "Unable to write binary data to dump file"); - return (1); - } + if ((fwrite (&data, 1, 1, dumpfile)) != 1) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } } - return (0); -} + return (0); + } -static int dump_short(FILE *dumpfile, int format, char *dump_tag, uint16_t data) -{ - int j, k; - char dump_array[20]; - unsigned char bitset; +static int dump_short (FILE *dumpfile, int format, char *dump_tag, uint16 data) + { + int j, k; + char dump_array[20]; + unsigned char bitset; - if (dumpfile == NULL) + if (dumpfile == NULL) { - TIFFError("", "Invalid FILE pointer for dump file"); - return (1); + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); } - if (format == DUMP_TEXT) + if (format == DUMP_TEXT) { - fprintf(dumpfile, " %s ", dump_tag); - for (j = 0, k = 15; k >= 0; j++, k--) - { - bitset = data & (((unsigned char)1 << k)) ? 1 : 0; - sprintf(&dump_array[j], (bitset) ? "1" : "0"); - if ((k % 8) == 0) - sprintf(&dump_array[++j], " "); - } - dump_array[17] = '\0'; - fprintf(dumpfile, " %s\n", dump_array); + fprintf (dumpfile," %s ", dump_tag); + for (j = 0, k = 15; k >= 0; j++, k--) + { + bitset = data & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); + if ((k % 8) == 0) + sprintf(&dump_array[++j], " "); + } + dump_array[17] = '\0'; + fprintf (dumpfile," %s\n", dump_array); } - else + else { - if ((fwrite(&data, 2, 1, dumpfile)) != 2) - { - TIFFError("", "Unable to write binary data to dump file"); - return (1); - } + if ((fwrite (&data, 2, 1, dumpfile)) != 2) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } } - return (0); -} + return (0); + } -static int dump_long(FILE *dumpfile, int format, char *dump_tag, uint32_t data) -{ - int j, k; - char dump_array[40]; - unsigned char bitset; +static int dump_long (FILE *dumpfile, int format, char *dump_tag, uint32 data) + { + int j, k; + char dump_array[40]; + unsigned char bitset; - if (dumpfile == NULL) + if (dumpfile == NULL) { - TIFFError("", "Invalid FILE pointer for dump file"); - return (1); + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); } - if (format == DUMP_TEXT) + if (format == DUMP_TEXT) { - fprintf(dumpfile, " %s ", dump_tag); - for (j = 0, k = 31; k >= 0; j++, k--) - { - bitset = data & (((uint32_t)1 << k)) ? 1 : 0; - sprintf(&dump_array[j], (bitset) ? "1" : "0"); - if ((k % 8) == 0) - sprintf(&dump_array[++j], " "); - } - dump_array[35] = '\0'; - fprintf(dumpfile, " %s\n", dump_array); + fprintf (dumpfile," %s ", dump_tag); + for (j = 0, k = 31; k >= 0; j++, k--) + { + bitset = data & (((uint32)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); + if ((k % 8) == 0) + sprintf(&dump_array[++j], " "); + } + dump_array[35] = '\0'; + fprintf (dumpfile," %s\n", dump_array); } - else + else { - if ((fwrite(&data, 4, 1, dumpfile)) != 4) - { - TIFFError("", "Unable to write binary data to dump file"); - return (1); - } + if ((fwrite (&data, 4, 1, dumpfile)) != 4) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } } - return (0); -} + return (0); + } -static int dump_wide(FILE *dumpfile, int format, char *dump_tag, uint64_t data) -{ - int j, k; - char dump_array[80]; - unsigned char bitset; +static int dump_wide (FILE *dumpfile, int format, char *dump_tag, uint64 data) + { + int j, k; + char dump_array[80]; + unsigned char bitset; - if (dumpfile == NULL) + if (dumpfile == NULL) { - TIFFError("", "Invalid FILE pointer for dump file"); - return (1); + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); } - if (format == DUMP_TEXT) + if (format == DUMP_TEXT) { - fprintf(dumpfile, " %s ", dump_tag); - for (j = 0, k = 63; k >= 0; j++, k--) - { - bitset = data & (((uint64_t)1 << k)) ? 1 : 0; - sprintf(&dump_array[j], (bitset) ? "1" : "0"); - if ((k % 8) == 0) - sprintf(&dump_array[++j], " "); - } - dump_array[71] = '\0'; - fprintf(dumpfile, " %s\n", dump_array); + fprintf (dumpfile," %s ", dump_tag); + for (j = 0, k = 63; k >= 0; j++, k--) + { + bitset = data & (((uint64)1 << k)) ? 1 : 0; + sprintf(&dump_array[j], (bitset) ? "1" : "0"); + if ((k % 8) == 0) + sprintf(&dump_array[++j], " "); + } + dump_array[71] = '\0'; + fprintf (dumpfile," %s\n", dump_array); } - else + else { - if ((fwrite(&data, 8, 1, dumpfile)) != 8) - { - TIFFError("", "Unable to write binary data to dump file"); - return (1); - } + if ((fwrite (&data, 8, 1, dumpfile)) != 8) + { + TIFFError ("", "Unable to write binary data to dump file"); + return (1); + } } - return (0); -} + return (0); + } static void dump_info(FILE *dumpfile, int format, char *prefix, char *msg, ...) -{ + { + if (format == DUMP_TEXT) + { + va_list ap; + va_start(ap, msg); + fprintf(dumpfile, "%s ", prefix); + vfprintf(dumpfile, msg, ap); + fprintf(dumpfile, "\n"); + va_end(ap); + } + } + +static int dump_buffer (FILE* dumpfile, int format, uint32 rows, uint32 width, + uint32 row, unsigned char *buff) + { + int j, k; + uint32 i; + unsigned char * dump_ptr; + + if (dumpfile == NULL) + { + TIFFError ("", "Invalid FILE pointer for dump file"); + return (1); + } + + for (i = 0; i < rows; i++) + { + dump_ptr = buff + (i * width); if (format == DUMP_TEXT) - { - va_list ap; - va_start(ap, msg); - fprintf(dumpfile, "%s ", prefix); - vfprintf(dumpfile, msg, ap); - fprintf(dumpfile, "\n"); - va_end(ap); + dump_info (dumpfile, format, "", + "Row %4d, %d bytes at offset %d", + row + i + 1, width, row * width); + + for (j = 0, k = width; k >= 10; j += 10, k -= 10, dump_ptr += 10) + dump_data (dumpfile, format, "", dump_ptr, 10); + if (k > 0) + dump_data (dumpfile, format, "", dump_ptr, k); } -} - -static int dump_buffer(FILE *dumpfile, int format, uint32_t rows, - uint32_t width, uint32_t row, unsigned char *buff) -{ - int k; - uint32_t i; - unsigned char *dump_ptr; - - if (dumpfile == NULL) - { - TIFFError("", "Invalid FILE pointer for dump file"); - return (1); - } - - for (i = 0; i < rows; i++) - { - dump_ptr = buff + (i * width); - if (format == DUMP_TEXT) - dump_info(dumpfile, format, "", - "Row %4" PRIu32 ", %" PRIu32 " bytes at offset %" PRIu32, - row + i + 1u, width, row * width); - - for (k = width; k >= 10; k -= 10, dump_ptr += 10) - dump_data(dumpfile, format, "", dump_ptr, 10); - if (k > 0) - dump_data(dumpfile, format, "", dump_ptr, k); - } - return (0); -} + return (0); + } /* Extract one or more samples from an interleaved buffer. If count == 1, - * only the sample plane indicated by sample will be extracted. If count > 1, - * count samples beginning at sample will be extracted. Portions of a + * only the sample plane indicated by sample will be extracted. If count > 1, + * count samples beginning at sample will be extracted. Portions of a * scanline can be extracted by specifying a start and end value. */ -static int extractContigSamplesBytes(uint8_t *in, uint8_t *out, uint32_t cols, - tsample_t sample, uint16_t spp, - uint16_t bps, tsample_t count, - uint32_t start, uint32_t end) -{ - int i, bytes_per_sample, sindex; - uint32_t col, dst_rowsize, bit_offset, numcols; - uint32_t src_byte /*, src_bit */; - uint8_t *src = in; - uint8_t *dst = out; +static int +extractContigSamplesBytes (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int i, bytes_per_sample, sindex; + uint32 col, dst_rowsize, bit_offset; + uint32 src_byte /*, src_bit */; + uint8 *src = in; + uint8 *dst = out; - if ((src == NULL) || (dst == NULL)) + if ((src == NULL) || (dst == NULL)) { - TIFFError("extractContigSamplesBytes", - "Invalid input or output buffer"); - return (1); + TIFFError("extractContigSamplesBytes","Invalid input or output buffer"); + return (1); } - /* Number of extracted columns shall be kept as (end-start + 1). Otherwise - * buffer-overflow might occur. 'start' and 'col' count from 0 to (cols-1) - * but 'end' is to be set one after the index of the last column to be - * copied! - */ - if (end >= start) - numcols = end - start; - else - numcols = start - end; - if ((start > end) || (start > cols)) + if ((start > end) || (start > cols)) { - TIFFError("extractContigSamplesBytes", - "Invalid start column value %" PRIu32 " ignored", start); - start = 0; + TIFFError ("extractContigSamplesBytes", + "Invalid start column value %d ignored", start); + start = 0; } - if ((end == 0) || (end > cols)) + if ((end == 0) || (end > cols)) { - TIFFError("extractContigSamplesBytes", - "Invalid end column value %" PRIu32 " ignored", end); - end = cols; - } - if ((end - start) > numcols) - { - end = start + numcols; + TIFFError ("extractContigSamplesBytes", + "Invalid end column value %d ignored", end); + end = cols; } - dst_rowsize = (bps * (end - start) * count) / 8; + dst_rowsize = (bps * (end - start) * count) / 8; - bytes_per_sample = (bps + 7) / 8; - /* Optimize case for copying all samples */ - if (count == spp) + bytes_per_sample = (bps + 7) / 8; + /* Optimize case for copying all samples */ + if (count == spp) { - src = in + (start * spp * bytes_per_sample); - _TIFFmemcpy(dst, src, dst_rowsize); + src = in + (start * spp * bytes_per_sample); + _TIFFmemcpy (dst, src, dst_rowsize); } - else + else { - for (col = start; col < end; col++) - { - for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); - sindex++) - { - bit_offset = col * bps * spp; - if (sindex == 0) - { - src_byte = bit_offset / 8; - /* src_bit = bit_offset % 8; */ - } - else - { - src_byte = (bit_offset + (sindex * bps)) / 8; - /* src_bit = (bit_offset + (sindex * bps)) % 8; */ - } - src = in + src_byte; - for (i = 0; i < bytes_per_sample; i++) - *dst++ = *src++; - } - } - } - - return (0); -} /* end extractContigSamplesBytes */ - -static int extractContigSamples8bits(uint8_t *in, uint8_t *out, uint32_t cols, - tsample_t sample, uint16_t spp, - uint16_t bps, tsample_t count, - uint32_t start, uint32_t end) -{ - int ready_bits = 0, sindex = 0; - uint32_t col, src_byte, src_bit, bit_offset, numcols; - uint8_t maskbits = 0, matchbits = 0; - uint8_t buff1 = 0, buff2 = 0; - uint8_t *src = in; - uint8_t *dst = out; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("extractContigSamples8bits", - "Invalid input or output buffer"); - return (1); - } - - /* Number of extracted columns shall be kept as (end-start + 1). Otherwise - * buffer-overflow might occur. 'start' and 'col' count from 0 to (cols-1) - * but 'end' is to be set one after the index of the last column to be - * copied! - */ - if (end >= start) - numcols = end - start; - else - numcols = start - end; - if ((start > end) || (start > cols)) - { - TIFFError("extractContigSamples8bits", - "Invalid start column value %" PRIu32 " ignored", start); - start = 0; - } - if ((end == 0) || (end > cols)) - { - TIFFError("extractContigSamples8bits", - "Invalid end column value %" PRIu32 " ignored", end); - end = cols; - } - if ((end - start) > numcols) - { - end = start + numcols; - } - - ready_bits = 0; - maskbits = (uint8_t)-1 >> (8 - bps); - buff1 = buff2 = 0; for (col = start; col < end; col++) - { /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps * spp; - for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); - sindex++) + { + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) { - if (sindex == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sindex * bps)) / 8; - src_bit = (bit_offset + (sindex * bps)) % 8; - } - - src = in + src_byte; - matchbits = maskbits << (8 - src_bit - bps); - buff1 = ((*src) & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 8) - { - *dst++ = buff2; - buff2 = buff1; - ready_bits -= 8; - } - else - buff2 = (buff2 | (buff1 >> ready_bits)); - ready_bits += bps; + bit_offset = col * bps * spp; + if (sindex == 0) + { + src_byte = bit_offset / 8; + /* src_bit = bit_offset % 8; */ + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + /* src_bit = (bit_offset + (sindex * bps)) % 8; */ + } + src = in + src_byte; + for (i = 0; i < bytes_per_sample; i++) + *dst++ = *src++; } + } } - while (ready_bits > 0) + return (0); + } /* end extractContigSamplesBytes */ + +static int +extractContigSamples8bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint8 maskbits = 0, matchbits = 0; + uint8 buff1 = 0, buff2 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((src == NULL) || (dst == NULL)) { - buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); - *dst++ = buff1; + TIFFError("extractContigSamples8bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamples8bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamples8bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = 0; + maskbits = (uint8)-1 >> ( 8 - bps); + buff1 = buff2 = 0; + for (col = start; col < end; col++) + { /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (8 - src_bit - bps); + buff1 = ((*src) & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + *dst++ = buff2; + buff2 = buff1; ready_bits -= 8; - } - - return (0); -} /* end extractContigSamples8bits */ - -static int extractContigSamples16bits(uint8_t *in, uint8_t *out, uint32_t cols, - tsample_t sample, uint16_t spp, - uint16_t bps, tsample_t count, - uint32_t start, uint32_t end) -{ - int ready_bits = 0, sindex = 0; - uint32_t col, src_byte, src_bit, bit_offset, numcols; - uint16_t maskbits = 0, matchbits = 0; - uint16_t buff1 = 0, buff2 = 0; - uint8_t bytebuff = 0; - uint8_t *src = in; - uint8_t *dst = out; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("extractContigSamples16bits", - "Invalid input or output buffer"); - return (1); - } - - /* Number of extracted columns shall be kept as (end-start + 1). Otherwise - * buffer-overflow might occur. 'start' and 'col' count from 0 to (cols-1) - * but 'end' is to be set one after the index of the last column to be - * copied! - */ - if (end >= start) - numcols = end - start; - else - numcols = start - end; - if ((start > end) || (start > cols)) - { - TIFFError("extractContigSamples16bits", - "Invalid start column value %" PRIu32 " ignored", start); - start = 0; - } - if ((end == 0) || (end > cols)) - { - TIFFError("extractContigSamples16bits", - "Invalid end column value %" PRIu32 " ignored", end); - end = cols; - } - if ((end - start) > numcols) - { - end = start + numcols; - } - - ready_bits = 0; - maskbits = (uint16_t)-1 >> (16 - bps); - - for (col = start; col < end; col++) - { /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps * spp; - for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); - sindex++) - { - if (sindex == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sindex * bps)) / 8; - src_bit = (bit_offset + (sindex * bps)) % 8; - } - - src = in + src_byte; - matchbits = maskbits << (16 - src_bit - bps); - - if (little_endian) - buff1 = (src[0] << 8) | src[1]; - else - buff1 = (src[1] << 8) | src[0]; - - buff1 = (buff1 & matchbits) << (src_bit); - if (ready_bits < 8) /* add another bps bits to the buffer */ - { - bytebuff = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - else /* If we have a full buffer's worth, write it out */ - { - bytebuff = (buff2 >> 8); - *dst++ = bytebuff; - ready_bits -= 8; - /* shift in new bits */ - buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); - } - ready_bits += bps; } + else + buff2 = (buff2 | (buff1 >> ready_bits)); + ready_bits += bps; + } } - /* catch any trailing bits at the end of the line */ - while (ready_bits > 0) + while (ready_bits > 0) { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamples8bits */ + +static int +extractContigSamples16bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint16 maskbits = 0, matchbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("extractContigSamples16bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamples16bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamples16bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = 0; + maskbits = (uint16)-1 >> (16 - bps); + + for (col = start; col < end; col++) + { /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (16 - src_bit - bps); + + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; + + buff1 = (buff1 & matchbits) << (src_bit); + if (ready_bits < 8) /* add another bps bits to the buffer */ + { + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { bytebuff = (buff2 >> 8); *dst++ = bytebuff; ready_bits -= 8; - } - - return (0); -} /* end extractContigSamples16bits */ - -static int extractContigSamples24bits(uint8_t *in, uint8_t *out, uint32_t cols, - tsample_t sample, uint16_t spp, - uint16_t bps, tsample_t count, - uint32_t start, uint32_t end) -{ - int ready_bits = 0, sindex = 0; - uint32_t col, src_byte, src_bit, bit_offset, numcols; - uint32_t maskbits = 0, matchbits = 0; - uint32_t buff1 = 0, buff2 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0; - uint8_t *src = in; - uint8_t *dst = out; - - if ((in == NULL) || (out == NULL)) - { - TIFFError("extractContigSamples24bits", - "Invalid input or output buffer"); - return (1); - } - - /* Number of extracted columns shall be kept as (end-start + 1). Otherwise - * buffer-overflow might occur. 'start' and 'col' count from 0 to (cols-1) - * but 'end' is to be set one after the index of the last column to be - * copied! - */ - if (end >= start) - numcols = end - start; - else - numcols = start - end; - if ((start > end) || (start > cols)) - { - TIFFError("extractContigSamples24bits", - "Invalid start column value %" PRIu32 " ignored", start); - start = 0; - } - if ((end == 0) || (end > cols)) - { - TIFFError("extractContigSamples24bits", - "Invalid end column value %" PRIu32 " ignored", end); - end = cols; - } - if ((end - start) > numcols) - { - end = start + numcols; - } - - ready_bits = 0; - maskbits = (uint32_t)-1 >> (32 - bps); - for (col = start; col < end; col++) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps * spp; - for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); - sindex++) - { - if (sindex == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sindex * bps)) / 8; - src_bit = (bit_offset + (sindex * bps)) % 8; - } - - src = in + src_byte; - matchbits = maskbits << (32 - src_bit - bps); - if (little_endian) - { - buff1 = (src[0] << 24); - if (matchbits & 0x00ff0000) - buff1 |= (src[1] << 16); - if (matchbits & 0x0000ff00) - buff1 |= (src[2] << 8); - if (matchbits & 0x000000ff) - buff1 |= src[3]; - } - else - { - buff1 = src[0]; - if (matchbits & 0x0000ff00) - buff1 |= (src[1] << 8); - if (matchbits & 0x00ff0000) - buff1 |= (src[2] << 16); - if (matchbits & 0xff000000) - buff1 |= (src[3] << 24); - } - buff1 = (buff1 & matchbits) << (src_bit); - - if (ready_bits < 16) /* add another bps bits to the buffer */ - { - bytebuff1 = bytebuff2 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - else /* If we have a full buffer's worth, write it out */ - { - bytebuff1 = (buff2 >> 24); - *dst++ = bytebuff1; - bytebuff2 = (buff2 >> 16); - *dst++ = bytebuff2; - ready_bits -= 16; - - /* shift in new bits */ - buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); - } - ready_bits += bps; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); } + ready_bits += bps; + } } - /* catch any trailing bits at the end of the line */ - while (ready_bits > 0) + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamples16bits */ + + +static int +extractContigSamples24bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint32 maskbits = 0, matchbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((in == NULL) || (out == NULL)) + { + TIFFError("extractContigSamples24bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamples24bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamples24bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = 0; + maskbits = (uint32)-1 >> ( 32 - bps); + for (col = start; col < end; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (32 - src_bit - bps); + if (little_endian) + { + buff1 = (src[0] << 24); + if (matchbits & 0x00ff0000) + buff1 |= (src[1] << 16); + if (matchbits & 0x0000ff00) + buff1 |= (src[2] << 8); + if (matchbits & 0x000000ff) + buff1 |= src[3]; + } + else + { + buff1 = src[0]; + if (matchbits & 0x0000ff00) + buff1 |= (src[1] << 8); + if (matchbits & 0x00ff0000) + buff1 |= (src[2] << 16); + if (matchbits & 0xff000000) + buff1 |= (src[3] << 24); + } + buff1 = (buff1 & matchbits) << (src_bit); + + if (ready_bits < 16) /* add another bps bits to the buffer */ + { + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { bytebuff1 = (buff2 >> 24); *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; - buff2 = (buff2 << 8); - bytebuff2 = bytebuff1; - ready_bits -= 8; - } - - return (0); -} /* end extractContigSamples24bits */ - -static int extractContigSamples32bits(uint8_t *in, uint8_t *out, uint32_t cols, - tsample_t sample, uint16_t spp, - uint16_t bps, tsample_t count, - uint32_t start, uint32_t end) -{ - int ready_bits = 0, sindex = 0 /*, shift_width = 0 */; - uint32_t col, src_byte, src_bit, bit_offset, numcols; - uint32_t longbuff1 = 0, longbuff2 = 0; - uint64_t maskbits = 0, matchbits = 0; - uint64_t buff1 = 0, buff2 = 0, buff3 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; - uint8_t *src = in; - uint8_t *dst = out; - - if ((in == NULL) || (out == NULL)) - { - TIFFError("extractContigSamples32bits", - "Invalid input or output buffer"); - return (1); - } - - /* Number of extracted columns shall be kept as (end-start + 1). Otherwise - * buffer-overflow might occur. 'start' and 'col' count from 0 to (cols-1) - * but 'end' is to be set one after the index of the last column to be - * copied! - */ - if (end >= start) - numcols = end - start; - else - numcols = start - end; - if ((start > end) || (start > cols)) - { - TIFFError("extractContigSamples32bits", - "Invalid start column value %" PRIu32 " ignored", start); - start = 0; - } - if ((end == 0) || (end > cols)) - { - TIFFError("extractContigSamples32bits", - "Invalid end column value %" PRIu32 " ignored", end); - end = cols; - } - if ((end - start) > numcols) - { - end = start + numcols; - } - - /* shift_width = ((bps + 7) / 8) + 1; */ - ready_bits = 0; - maskbits = (uint64_t)-1 >> (64 - bps); - for (col = start; col < end; col++) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps * spp; - for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); - sindex++) - { - if (sindex == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sindex * bps)) / 8; - src_bit = (bit_offset + (sindex * bps)) % 8; - } - - src = in + src_byte; - matchbits = maskbits << (64 - src_bit - bps); - if (little_endian) - { - longbuff1 = - (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; - longbuff2 = longbuff1; - } - else - { - longbuff1 = - (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; - longbuff2 = longbuff1; - } - - buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; - buff1 = (buff3 & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 32) - { - bytebuff1 = (uint8_t)(buff2 >> 56); - *dst++ = bytebuff1; - bytebuff2 = (uint8_t)(buff2 >> 48); - *dst++ = bytebuff2; - bytebuff3 = (uint8_t)(buff2 >> 40); - *dst++ = bytebuff3; - bytebuff4 = (uint8_t)(buff2 >> 32); - *dst++ = bytebuff4; - ready_bits -= 32; - - /* shift in new bits */ - buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); - } - else - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - ready_bits += bps; + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); } + ready_bits += bps; + } } - while (ready_bits > 0) + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) { - bytebuff1 = (buff2 >> 56); + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamples24bits */ + +static int +extractContigSamples32bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end) + { + int ready_bits = 0, sindex = 0 /*, shift_width = 0 */; + uint32 col, src_byte, src_bit, bit_offset; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((in == NULL) || (out == NULL)) + { + TIFFError("extractContigSamples32bits","Invalid input or output buffer"); + return (1); + } + + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamples32bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamples32bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + /* shift_width = ((bps + 7) / 8) + 1; */ + ready_bits = 0; + maskbits = (uint64)-1 >> ( 64 - bps); + for (col = start; col < end; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (64 - src_bit - bps); + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 32) + { + bytebuff1 = (uint8)(buff2 >> 56); *dst++ = bytebuff1; - buff2 = (buff2 << 8); - ready_bits -= 8; - } - - return (0); -} /* end extractContigSamples32bits */ - -static int extractContigSamplesShifted8bits(uint8_t *in, uint8_t *out, - uint32_t cols, tsample_t sample, - uint16_t spp, uint16_t bps, - tsample_t count, uint32_t start, - uint32_t end, int shift) -{ - int ready_bits = 0, sindex = 0; - uint32_t col, src_byte, src_bit, bit_offset, numcols; - uint8_t maskbits = 0, matchbits = 0; - uint8_t buff1 = 0, buff2 = 0; - uint8_t *src = in; - uint8_t *dst = out; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("extractContigSamplesShifted8bits", - "Invalid input or output buffer"); - return (1); - } - - /* Number of extracted columns shall be kept as (end-start + 1). Otherwise - * buffer-overflow might occur. 'start' and 'col' count from 0 to (cols-1) - * but 'end' is to be set one after the index of the last column to be - * copied! - */ - if (end >= start) - numcols = end - start; - else - numcols = start - end; - if ((start > end) || (start > cols)) - { - TIFFError("extractContigSamplesShifted8bits", - "Invalid start column value %" PRIu32 " ignored", start); - start = 0; - } - if ((end == 0) || (end > cols)) - { - TIFFError("extractContigSamplesShifted8bits", - "Invalid end column value %" PRIu32 " ignored", end); - end = cols; - } - if ((end - start) > numcols) - { - end = start + numcols; - } - - ready_bits = shift; - maskbits = (uint8_t)-1 >> (8 - bps); - buff1 = buff2 = 0; - for (col = start; col < end; col++) - { /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps * spp; - for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); - sindex++) - { - if (sindex == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sindex * bps)) / 8; - src_bit = (bit_offset + (sindex * bps)) % 8; - } - - src = in + src_byte; - matchbits = maskbits << (8 - src_bit - bps); - buff1 = ((*src) & matchbits) << (src_bit); - if ((col == start) && (sindex == sample)) - buff2 = *src & ((uint8_t)-1) << (shift); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 8) - { - *dst++ |= buff2; - buff2 = buff1; - ready_bits -= 8; - } - else - buff2 = buff2 | (buff1 >> ready_bits); - ready_bits += bps; + bytebuff2 = (uint8)(buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (uint8)(buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (uint8)(buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); } - } - - while (ready_bits > 0) - { - buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); - *dst++ = buff1; - ready_bits -= 8; - } - - return (0); -} /* end extractContigSamplesShifted8bits */ - -static int extractContigSamplesShifted16bits(uint8_t *in, uint8_t *out, - uint32_t cols, tsample_t sample, - uint16_t spp, uint16_t bps, - tsample_t count, uint32_t start, - uint32_t end, int shift) -{ - int ready_bits = 0, sindex = 0; - uint32_t col, src_byte, src_bit, bit_offset, numcols; - uint16_t maskbits = 0, matchbits = 0; - uint16_t buff1 = 0, buff2 = 0; - uint8_t bytebuff = 0; - uint8_t *src = in; - uint8_t *dst = out; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("extractContigSamplesShifted16bits", - "Invalid input or output buffer"); - return (1); - } - - /* Number of extracted columns shall be kept as (end-start + 1). Otherwise - * buffer-overflow might occur. 'start' and 'col' count from 0 to (cols-1) - * but 'end' is to be set one after the index of the last column to be - * copied! - */ - if (end >= start) - numcols = end - start; - else - numcols = start - end; - if ((start > end) || (start > cols)) - { - TIFFError("extractContigSamplesShifted16bits", - "Invalid start column value %" PRIu32 " ignored", start); - start = 0; - } - if ((end == 0) || (end > cols)) - { - TIFFError("extractContigSamplesShifted16bits", - "Invalid end column value %" PRIu32 " ignored", end); - end = cols; - } - if ((end - start) > numcols) - { - end = start + numcols; - } - - ready_bits = shift; - maskbits = (uint16_t)-1 >> (16 - bps); - for (col = start; col < end; col++) - { /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps * spp; - for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); - sindex++) - { - if (sindex == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sindex * bps)) / 8; - src_bit = (bit_offset + (sindex * bps)) % 8; - } - - src = in + src_byte; - matchbits = maskbits << (16 - src_bit - bps); - if (little_endian) - buff1 = (src[0] << 8) | src[1]; - else - buff1 = (src[1] << 8) | src[0]; - - if ((col == start) && (sindex == sample)) - buff2 = buff1 & ((uint16_t)-1) << (8 - shift); - - buff1 = (buff1 & matchbits) << (src_bit); - - if (ready_bits < 8) /* add another bps bits to the buffer */ - buff2 = buff2 | (buff1 >> ready_bits); - else /* If we have a full buffer's worth, write it out */ - { - bytebuff = (buff2 >> 8); - *dst++ = bytebuff; - ready_bits -= 8; - /* shift in new bits */ - buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); - } - - ready_bits += bps; + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); } + ready_bits += bps; + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamples32bits */ + +static int +extractContigSamplesShifted8bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end, + int shift) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint8 maskbits = 0, matchbits = 0; + uint8 buff1 = 0, buff2 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("extractContigSamplesShifted8bits","Invalid input or output buffer"); + return (1); } - /* catch any trailing bits at the end of the line */ - while (ready_bits > 0) + if ((start > end) || (start > cols)) { + TIFFError ("extractContigSamplesShifted8bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamplesShifted8bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = shift; + maskbits = (uint8)-1 >> ( 8 - bps); + buff1 = buff2 = 0; + for (col = start; col < end; col++) + { /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (8 - src_bit - bps); + buff1 = ((*src) & matchbits) << (src_bit); + if ((col == start) && (sindex == sample)) + buff2 = *src & ((uint8)-1) << (shift); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + *dst++ |= buff2; + buff2 = buff1; + ready_bits -= 8; + } + else + buff2 = buff2 | (buff1 >> ready_bits); + ready_bits += bps; + } + } + + while (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamplesShifted8bits */ + +static int +extractContigSamplesShifted16bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end, + int shift) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint16 maskbits = 0, matchbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("extractContigSamplesShifted16bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamplesShifted16bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamplesShifted16bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = shift; + maskbits = (uint16)-1 >> (16 - bps); + for (col = start; col < end; col++) + { /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (16 - src_bit - bps); + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; + + if ((col == start) && (sindex == sample)) + buff2 = buff1 & ((uint16)-1) << (8 - shift); + + buff1 = (buff1 & matchbits) << (src_bit); + + if (ready_bits < 8) /* add another bps bits to the buffer */ + buff2 = buff2 | (buff1 >> ready_bits); + else /* If we have a full buffer's worth, write it out */ + { bytebuff = (buff2 >> 8); *dst++ = bytebuff; ready_bits -= 8; - } - - return (0); -} /* end extractContigSamplesShifted16bits */ - -static int extractContigSamplesShifted24bits(uint8_t *in, uint8_t *out, - uint32_t cols, tsample_t sample, - uint16_t spp, uint16_t bps, - tsample_t count, uint32_t start, - uint32_t end, int shift) -{ - int ready_bits = 0, sindex = 0; - uint32_t col, src_byte, src_bit, bit_offset, numcols; - uint32_t maskbits = 0, matchbits = 0; - uint32_t buff1 = 0, buff2 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0; - uint8_t *src = in; - uint8_t *dst = out; - - if ((in == NULL) || (out == NULL)) - { - TIFFError("extractContigSamplesShifted24bits", - "Invalid input or output buffer"); - return (1); - } - - /* Number of extracted columns shall be kept as (end-start + 1). Otherwise - * buffer-overflow might occur. 'start' and 'col' count from 0 to (cols-1) - * but 'end' is to be set one after the index of the last column to be - * copied! - */ - /*--- Remark, which is true for all those functions - * extractCongigSamplesXXX() -- The mitigation of the start/end test does - * not allways make sense, because the function is often called with e.g.: - * start = 31; end = 32; cols = 32 to extract the last column in a 32x32 - * sample image. If then, a worng parameter (e.g. cols = 10) is provided, - * the mitigated settings would be start=0; end=1. Therefore, an error - * message and no copy action might be the better reaction to wrong - * parameter configurations. - */ - if (end >= start) - numcols = end - start; - else - numcols = start - end; - if ((start > end) || (start > cols)) - { - TIFFError("extractContigSamplesShifted24bits", - "Invalid start column value %" PRIu32 " ignored", start); - start = 0; - } - if ((end == 0) || (end > cols)) - { - TIFFError("extractContigSamplesShifted24bits", - "Invalid end column value %" PRIu32 " ignored", end); - end = cols; - } - if ((end - start) > numcols) - { - end = start + numcols; - } - - ready_bits = shift; - maskbits = (uint32_t)-1 >> (32 - bps); - for (col = start; col < end; col++) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps * spp; - for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); - sindex++) - { - if (sindex == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sindex * bps)) / 8; - src_bit = (bit_offset + (sindex * bps)) % 8; - } - - src = in + src_byte; - matchbits = maskbits << (32 - src_bit - bps); - if (little_endian) - buff1 = - (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; - else - buff1 = - (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; - - if ((col == start) && (sindex == sample)) - buff2 = buff1 & ((uint32_t)-1) << (16 - shift); - - buff1 = (buff1 & matchbits) << (src_bit); - - if (ready_bits < 16) /* add another bps bits to the buffer */ - { - bytebuff1 = bytebuff2 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - else /* If we have a full buffer's worth, write it out */ - { - bytebuff1 = (buff2 >> 24); - *dst++ = bytebuff1; - bytebuff2 = (buff2 >> 16); - *dst++ = bytebuff2; - ready_bits -= 16; - - /* shift in new bits */ - buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); - } - ready_bits += bps; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); } + + ready_bits += bps; + } } - /* catch any trailing bits at the end of the line */ - while (ready_bits > 0) + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamplesShifted16bits */ + + +static int +extractContigSamplesShifted24bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end, + int shift) + { + int ready_bits = 0, sindex = 0; + uint32 col, src_byte, src_bit, bit_offset; + uint32 maskbits = 0, matchbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((in == NULL) || (out == NULL)) + { + TIFFError("extractContigSamplesShifted24bits","Invalid input or output buffer"); + return (1); + } + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamplesShifted24bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamplesShifted24bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + ready_bits = shift; + maskbits = (uint32)-1 >> ( 32 - bps); + for (col = start; col < end; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (32 - src_bit - bps); + if (little_endian) + buff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + else + buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + + if ((col == start) && (sindex == sample)) + buff2 = buff1 & ((uint32)-1) << (16 - shift); + + buff1 = (buff1 & matchbits) << (src_bit); + + if (ready_bits < 16) /* add another bps bits to the buffer */ + { + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { bytebuff1 = (buff2 >> 24); *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; - buff2 = (buff2 << 8); - bytebuff2 = bytebuff1; - ready_bits -= 8; - } - - return (0); -} /* end extractContigSamplesShifted24bits */ - -static int extractContigSamplesShifted32bits(uint8_t *in, uint8_t *out, - uint32_t cols, tsample_t sample, - uint16_t spp, uint16_t bps, - tsample_t count, uint32_t start, - uint32_t end, int shift) -{ - int ready_bits = 0, sindex = 0 /*, shift_width = 0 */; - uint32_t col, src_byte, src_bit, bit_offset, numcols; - uint32_t longbuff1 = 0, longbuff2 = 0; - uint64_t maskbits = 0, matchbits = 0; - uint64_t buff1 = 0, buff2 = 0, buff3 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; - uint8_t *src = in; - uint8_t *dst = out; - - if ((in == NULL) || (out == NULL)) - { - TIFFError("extractContigSamplesShifted32bits", - "Invalid input or output buffer"); - return (1); - } - - /* Number of extracted columns shall be kept as (end-start + 1). Otherwise - * buffer-overflow might occur. 'start' and 'col' count from 0 to (cols-1) - * but 'end' is to be set one after the index of the last column to be - * copied! - */ - if (end >= start) - numcols = end - start; - else - numcols = start - end; - if ((start > end) || (start > cols)) - { - TIFFError("extractContigSamplesShifted32bits", - "Invalid start column value %" PRIu32 " ignored", start); - start = 0; - } - if ((end == 0) || (end > cols)) - { - TIFFError("extractContigSamplesShifted32bits", - "Invalid end column value %" PRIu32 " ignored", end); - end = cols; - } - if ((end - start) > numcols) - { - end = start + numcols; - } - - /* shift_width = ((bps + 7) / 8) + 1; */ - ready_bits = shift; - maskbits = (uint64_t)-1 >> (64 - bps); - for (col = start; col < end; col++) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps * spp; - for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); - sindex++) - { - if (sindex == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sindex * bps)) / 8; - src_bit = (bit_offset + (sindex * bps)) % 8; - } - - src = in + src_byte; - matchbits = maskbits << (64 - src_bit - bps); - if (little_endian) - { - longbuff1 = - (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; - longbuff2 = longbuff1; - } - else - { - longbuff1 = - (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; - longbuff2 = longbuff1; - } - - buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; - if ((col == start) && (sindex == sample)) - buff2 = buff3 & ((uint64_t)-1) << (32 - shift); - - buff1 = (buff3 & matchbits) << (src_bit); - - if (ready_bits < 32) - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - else /* If we have a full buffer's worth, write it out */ - { - bytebuff1 = (uint8_t)(buff2 >> 56); - *dst++ = bytebuff1; - bytebuff2 = (uint8_t)(buff2 >> 48); - *dst++ = bytebuff2; - bytebuff3 = (uint8_t)(buff2 >> 40); - *dst++ = bytebuff3; - bytebuff4 = (uint8_t)(buff2 >> 32); - *dst++ = bytebuff4; - ready_bits -= 32; - - /* shift in new bits */ - buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); - } - ready_bits += bps; + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); } + ready_bits += bps; + } } - while (ready_bits > 0) + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) { - bytebuff1 = (buff2 >> 56); + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamplesShifted24bits */ + +static int +extractContigSamplesShifted32bits (uint8 *in, uint8 *out, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + tsample_t count, uint32 start, uint32 end, + int shift) + { + int ready_bits = 0, sindex = 0 /*, shift_width = 0 */; + uint32 col, src_byte, src_bit, bit_offset; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8 *src = in; + uint8 *dst = out; + + if ((in == NULL) || (out == NULL)) + { + TIFFError("extractContigSamplesShifted32bits","Invalid input or output buffer"); + return (1); + } + + + if ((start > end) || (start > cols)) + { + TIFFError ("extractContigSamplesShifted32bits", + "Invalid start column value %d ignored", start); + start = 0; + } + if ((end == 0) || (end > cols)) + { + TIFFError ("extractContigSamplesShifted32bits", + "Invalid end column value %d ignored", end); + end = cols; + } + + /* shift_width = ((bps + 7) / 8) + 1; */ + ready_bits = shift; + maskbits = (uint64)-1 >> ( 64 - bps); + for (col = start; col < end; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps * spp; + for (sindex = sample; (sindex < spp) && (sindex < (sample + count)); sindex++) + { + if (sindex == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sindex * bps)) / 8; + src_bit = (bit_offset + (sindex * bps)) % 8; + } + + src = in + src_byte; + matchbits = maskbits << (64 - src_bit - bps); + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + if ((col == start) && (sindex == sample)) + buff2 = buff3 & ((uint64)-1) << (32 - shift); + + buff1 = (buff3 & matchbits) << (src_bit); + + if (ready_bits < 32) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (uint8)(buff2 >> 56); *dst++ = bytebuff1; - buff2 = (buff2 << 8); - ready_bits -= 8; + bytebuff2 = (uint8)(buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (uint8)(buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (uint8)(buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + return (0); + } /* end extractContigSamplesShifted32bits */ - return (0); -} /* end extractContigSamplesShifted32bits */ +static int +extractContigSamplesToBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols, + tsample_t sample, uint16 spp, uint16 bps, + struct dump_opts *dump) + { + int shift_width, bytes_per_sample, bytes_per_pixel; + uint32 src_rowsize, src_offset, row, first_col = 0; + uint32 dst_rowsize, dst_offset; + tsample_t count = 1; + uint8 *src, *dst; -static int extractContigSamplesToBuffer(uint8_t *out, uint8_t *in, - uint32_t rows, uint32_t cols, - tsample_t sample, uint16_t spp, - uint16_t bps, struct dump_opts *dump) -{ - int shift_width, bytes_per_sample, bytes_per_pixel; - uint32_t src_rowsize, src_offset, row, first_col = 0; - uint32_t dst_rowsize, dst_offset; - tsample_t count = 1; - uint8_t *src, *dst; - - bytes_per_sample = (bps + 7) / 8; - bytes_per_pixel = ((bps * spp) + 7) / 8; - if ((bps % 8) == 0) - shift_width = 0; + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; else - { - if (bytes_per_pixel < (bytes_per_sample + 1)) - shift_width = bytes_per_pixel; - else - shift_width = bytes_per_sample + 1; + shift_width = bytes_per_sample + 1; } - src_rowsize = ((bps * spp * cols) + 7) / 8; - dst_rowsize = ((bps * cols) + 7) / 8; + src_rowsize = ((bps * spp * cols) + 7) / 8; + dst_rowsize = ((bps * cols) + 7) / 8; - if ((dump->outfile != NULL) && (dump->level == 4)) + if ((dump->outfile != NULL) && (dump->level == 4)) { - dump_info(dump->outfile, dump->format, "extractContigSamplesToBuffer", - "Sample %" PRIu32 ", %" PRIu32 " rows", sample + 1u, - rows + 1u); + dump_info (dump->outfile, dump->format, "extractContigSamplesToBuffer", + "Sample %d, %d rows", sample + 1, rows + 1); } - for (row = 0; row < rows; row++) + for (row = 0; row < rows; row++) { - src_offset = row * src_rowsize; - dst_offset = row * dst_rowsize; - src = in + src_offset; - dst = out + dst_offset; + src_offset = row * src_rowsize; + dst_offset = row * dst_rowsize; + src = in + src_offset; + dst = out + dst_offset; - /* pack the data into the scanline */ - switch (shift_width) - { - case 0: - if (extractContigSamplesBytes(src, dst, cols, sample, spp, bps, - count, first_col, cols)) - return (1); - break; - case 1: - if (bps == 1) - { - if (extractContigSamples8bits(src, dst, cols, sample, spp, - bps, count, first_col, cols)) - return (1); - break; - } - else if (extractContigSamples16bits(src, dst, cols, sample, spp, - bps, count, first_col, - cols)) - return (1); - break; - case 2: - if (extractContigSamples24bits(src, dst, cols, sample, spp, bps, - count, first_col, cols)) - return (1); - break; - case 3: - case 4: - case 5: - if (extractContigSamples32bits(src, dst, cols, sample, spp, bps, - count, first_col, cols)) - return (1); - break; - default: - TIFFError("extractContigSamplesToBuffer", - "Unsupported bit depth: %" PRIu16, bps); + /* pack the data into the scanline */ + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, cols, sample, + spp, bps, count, first_col, cols)) return (1); - } - if ((dump->outfile != NULL) && (dump->level == 4)) - dump_buffer(dump->outfile, dump->format, 1, dst_rowsize, row, dst); + break; + case 1: if (bps == 1) + { + if (extractContigSamples8bits (src, dst, cols, sample, + spp, bps, count, first_col, cols)) + return (1); + break; + } + else + if (extractContigSamples16bits (src, dst, cols, sample, + spp, bps, count, first_col, cols)) + return (1); + break; + case 2: if (extractContigSamples24bits (src, dst, cols, sample, + spp, bps, count, first_col, cols)) + return (1); + break; + case 3: + case 4: + case 5: if (extractContigSamples32bits (src, dst, cols, sample, + spp, bps, count, first_col, cols)) + return (1); + break; + default: TIFFError ("extractContigSamplesToBuffer", "Unsupported bit depth: %d", bps); + return (1); + } + if ((dump->outfile != NULL) && (dump->level == 4)) + dump_buffer(dump->outfile, dump->format, 1, dst_rowsize, row, dst); } - return (0); -} /* end extractContigSamplesToBuffer */ + return (0); + } /* end extractContigSamplesToBuffer */ -static int extractContigSamplesToTileBuffer( - uint8_t *out, uint8_t *in, uint32_t rows, uint32_t cols, - uint32_t imagewidth, uint32_t tilewidth, tsample_t sample, uint16_t count, - uint16_t spp, uint16_t bps, struct dump_opts *dump) -{ - int shift_width, bytes_per_sample, bytes_per_pixel; - uint32_t src_rowsize, src_offset, row; - uint32_t dst_rowsize, dst_offset; - uint8_t *src, *dst; +static int +extractContigSamplesToTileBuffer(uint8 *out, uint8 *in, uint32 rows, uint32 cols, + uint32 imagewidth, uint32 tilewidth, tsample_t sample, + uint16 count, uint16 spp, uint16 bps, struct dump_opts *dump) + { + int shift_width, bytes_per_sample, bytes_per_pixel; + uint32 src_rowsize, src_offset, row; + uint32 dst_rowsize, dst_offset; + uint8 *src, *dst; - bytes_per_sample = (bps + 7) / 8; - bytes_per_pixel = ((bps * spp) + 7) / 8; - if ((bps % 8) == 0) - shift_width = 0; + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; else - { - if (bytes_per_pixel < (bytes_per_sample + 1)) - shift_width = bytes_per_pixel; - else - shift_width = bytes_per_sample + 1; + shift_width = bytes_per_sample + 1; } - if ((dump->outfile != NULL) && (dump->level == 4)) + if ((dump->outfile != NULL) && (dump->level == 4)) { - dump_info( - dump->outfile, dump->format, "extractContigSamplesToTileBuffer", - "Sample %" PRIu32 ", %" PRIu32 " rows", sample + 1u, rows + 1u); + dump_info (dump->outfile, dump->format, "extractContigSamplesToTileBuffer", + "Sample %d, %d rows", sample + 1, rows + 1); } - src_rowsize = ((bps * spp * imagewidth) + 7) / 8; - dst_rowsize = ((bps * tilewidth * count) + 7) / 8; + src_rowsize = ((bps * spp * imagewidth) + 7) / 8; + dst_rowsize = ((bps * tilewidth * count) + 7) / 8; - for (row = 0; row < rows; row++) + for (row = 0; row < rows; row++) { - src_offset = row * src_rowsize; - dst_offset = row * dst_rowsize; - src = in + src_offset; - dst = out + dst_offset; + src_offset = row * src_rowsize; + dst_offset = row * dst_rowsize; + src = in + src_offset; + dst = out + dst_offset; - /* pack the data into the scanline */ - switch (shift_width) - { - case 0: - if (extractContigSamplesBytes(src, dst, cols, sample, spp, bps, - count, 0, cols)) - return (1); - break; - case 1: - if (bps == 1) - { - if (extractContigSamples8bits(src, dst, cols, sample, spp, - bps, count, 0, cols)) - return (1); - break; - } - else if (extractContigSamples16bits(src, dst, cols, sample, spp, - bps, count, 0, cols)) - return (1); - break; - case 2: - if (extractContigSamples24bits(src, dst, cols, sample, spp, bps, - count, 0, cols)) - return (1); - break; - case 3: - case 4: - case 5: - if (extractContigSamples32bits(src, dst, cols, sample, spp, bps, - count, 0, cols)) - return (1); - break; - default: - TIFFError("extractContigSamplesToTileBuffer", - "Unsupported bit depth: %" PRIu16, bps); + /* pack the data into the scanline */ + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, cols, sample, + spp, bps, count, 0, cols)) return (1); - } - if ((dump->outfile != NULL) && (dump->level == 4)) - dump_buffer(dump->outfile, dump->format, 1, dst_rowsize, row, dst); + break; + case 1: if (bps == 1) + { + if (extractContigSamples8bits (src, dst, cols, sample, + spp, bps, count, 0, cols)) + return (1); + break; + } + else + if (extractContigSamples16bits (src, dst, cols, sample, + spp, bps, count, 0, cols)) + return (1); + break; + case 2: if (extractContigSamples24bits (src, dst, cols, sample, + spp, bps, count, 0, cols)) + return (1); + break; + case 3: + case 4: + case 5: if (extractContigSamples32bits (src, dst, cols, sample, + spp, bps, count, 0, cols)) + return (1); + break; + default: TIFFError ("extractContigSamplesToTileBuffer", "Unsupported bit depth: %d", bps); + return (1); + } + if ((dump->outfile != NULL) && (dump->level == 4)) + dump_buffer(dump->outfile, dump->format, 1, dst_rowsize, row, dst); } - return (0); -} /* end extractContigSamplesToTileBuffer */ + return (0); + } /* end extractContigSamplesToTileBuffer */ -static int readContigStripsIntoBuffer(TIFF *in, uint8_t *buf) +static int readContigStripsIntoBuffer (TIFF* in, uint8* buf) { - uint8_t *bufp = buf; - tmsize_t bytes_read = 0; - uint32_t strip, nstrips = TIFFNumberOfStrips(in); - tmsize_t stripsize = TIFFStripSize(in); - tmsize_t rows = 0; - uint32_t rps = TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); - tsize_t scanline_size = TIFFScanlineSize(in); + uint8* bufp = buf; + tmsize_t bytes_read = 0; + uint32 strip, nstrips = TIFFNumberOfStrips(in); + tmsize_t stripsize = TIFFStripSize(in); + tmsize_t rows = 0; + uint32 rps = TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); + tsize_t scanline_size = TIFFScanlineSize(in); - if (scanline_size == 0) - { - TIFFError("", "TIFF scanline size is zero!"); - return 0; - } - - for (strip = 0; strip < nstrips; strip++) - { - bytes_read = TIFFReadEncodedStrip(in, strip, bufp, -1); - rows = bytes_read / scanline_size; - if ((strip < (nstrips - 1)) && (bytes_read != (int32_t)stripsize)) - TIFFError("", - "Strip %" PRIu32 ": read %" PRId64 - " bytes, strip size %" PRIu64, - strip + 1, (uint64_t)bytes_read, (uint64_t)stripsize); - - if (bytes_read < 0 && !ignore) - { - TIFFError("", - "Error reading strip %" PRIu32 " after %" PRIu64 " rows", - strip, (uint64_t)rows); - return 0; + if (scanline_size == 0) { + TIFFError("", "TIFF scanline size is zero!"); + return 0; } - bufp += stripsize; - } - return 1; + for (strip = 0; strip < nstrips; strip++) { + bytes_read = TIFFReadEncodedStrip (in, strip, bufp, -1); + rows = bytes_read / scanline_size; + if ((strip < (nstrips - 1)) && (bytes_read != (int32)stripsize)) + TIFFError("", "Strip %u: read " TIFF_SSIZE_FORMAT " bytes, strip size " TIFF_SSIZE_FORMAT, + strip + 1, bytes_read, stripsize); + + if (bytes_read < 0 && !ignore) { + TIFFError("", "Error reading strip %u after " TIFF_SSIZE_FORMAT " rows", + strip, rows); + return 0; + } + bufp += stripsize; + } + + return 1; } /* end readContigStripsIntoBuffer */ -static int combineSeparateSamplesBytes(unsigned char *srcbuffs[], - unsigned char *out, uint32_t cols, - uint32_t rows, uint16_t spp, - uint16_t bps, FILE *dumpfile, int format, - int level) -{ - int i, bytes_per_sample; - uint32_t row, col, col_offset, src_rowsize, dst_rowsize, row_offset; - unsigned char *src; - unsigned char *dst; - tsample_t s; +static int +combineSeparateSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, + uint32 cols, uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int i, bytes_per_sample; + uint32 row, col, col_offset, src_rowsize, dst_rowsize, row_offset; + unsigned char *src; + unsigned char *dst; + tsample_t s; - src = srcbuffs[0]; - dst = out; - if ((src == NULL) || (dst == NULL)) + src = srcbuffs[0]; + dst = out; + if ((src == NULL) || (dst == NULL)) { - TIFFError("combineSeparateSamplesBytes", "Invalid buffer address"); - return (1); + TIFFError("combineSeparateSamplesBytes","Invalid buffer address"); + return (1); } - bytes_per_sample = (bps + 7) / 8; + bytes_per_sample = (bps + 7) / 8; - src_rowsize = ((bps * cols) + 7) / 8; - dst_rowsize = ((bps * spp * cols) + 7) / 8; - for (row = 0; row < rows; row++) + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * spp * cols) + 7) / 8; + for (row = 0; row < rows; row++) { - if ((dumpfile != NULL) && (level == 2)) + if ((dumpfile != NULL) && (level == 2)) + { + for (s = 0; s < spp; s++) { - for (s = 0; s < spp; s++) - { - dump_info(dumpfile, format, "combineSeparateSamplesBytes", - "Input data, Sample %" PRIu16, s); - dump_buffer(dumpfile, format, 1, cols, row, - srcbuffs[s] + (row * src_rowsize)); - } + dump_info (dumpfile, format, "combineSeparateSamplesBytes","Input data, Sample %d", s); + dump_buffer(dumpfile, format, 1, cols, row, srcbuffs[s] + (row * src_rowsize)); } - dst = out + (row * dst_rowsize); - row_offset = row * src_rowsize; - for (col = 0; col < cols; col++) + } + dst = out + (row * dst_rowsize); + row_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + col_offset = row_offset + (col * (bps / 8)); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) { - col_offset = row_offset + (col * (bps / 8)); - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = srcbuffs[s] + col_offset; - for (i = 0; i < bytes_per_sample; i++) - *(dst + i) = *(src + i); - src += bytes_per_sample; - dst += bytes_per_sample; - } - } + src = srcbuffs[s] + col_offset; + for (i = 0; i < bytes_per_sample; i++) + *(dst + i) = *(src + i); + src += bytes_per_sample; + dst += bytes_per_sample; + } + } - if ((dumpfile != NULL) && (level == 2)) - { - dump_info(dumpfile, format, "combineSeparateSamplesBytes", - "Output data, combined samples"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, - out + (row * dst_rowsize)); - } + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateSamplesBytes","Output data, combined samples"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } } - return (0); -} /* end combineSeparateSamplesBytes */ + return (0); + } /* end combineSeparateSamplesBytes */ -static int combineSeparateSamples8bits(uint8_t *in[], uint8_t *out, - uint32_t cols, uint32_t rows, - uint16_t spp, uint16_t bps, - FILE *dumpfile, int format, int level) -{ - int ready_bits = 0; - /* int bytes_per_sample = 0; */ - uint32_t src_rowsize, dst_rowsize, src_offset; - uint32_t bit_offset; - uint32_t row, col, src_byte = 0, src_bit = 0; - uint8_t maskbits = 0, matchbits = 0; - uint8_t buff1 = 0, buff2 = 0; - tsample_t s; - unsigned char *src = in[0]; - unsigned char *dst = out; - char action[32]; +static int +combineSeparateSamples8bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0; + /* int bytes_per_sample = 0; */ + uint32 src_rowsize, dst_rowsize, src_offset; + uint32 bit_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint8 maskbits = 0, matchbits = 0; + uint8 buff1 = 0, buff2 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[32]; - if ((src == NULL) || (dst == NULL)) + if ((src == NULL) || (dst == NULL)) { - TIFFError("combineSeparateSamples8bits", - "Invalid input or output buffer"); - return (1); + TIFFError("combineSeparateSamples8bits","Invalid input or output buffer"); + return (1); } - /* bytes_per_sample = (bps + 7) / 8; */ - src_rowsize = ((bps * cols) + 7) / 8; - dst_rowsize = ((bps * cols * spp) + 7) / 8; - maskbits = (uint8_t)-1 >> (8 - bps); + /* bytes_per_sample = (bps + 7) / 8; */ + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * cols * spp) + 7) / 8; + maskbits = (uint8)-1 >> ( 8 - bps); - for (row = 0; row < rows; row++) + for (row = 0; row < rows; row++) { - ready_bits = 0; - buff1 = buff2 = 0; - dst = out + (row * dst_rowsize); - src_offset = row * src_rowsize; - for (col = 0; col < cols; col++) + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (8 - src_bit - bps); + /* load up next sample from each plane */ + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps; - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - - matchbits = maskbits << (8 - src_bit - bps); - /* load up next sample from each plane */ - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = in[s] + src_offset + src_byte; - buff1 = ((*src) & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 8) - { - *dst++ = buff2; - buff2 = buff1; - ready_bits -= 8; - strcpy(action, "Flush"); - } - else - { - buff2 = (buff2 | (buff1 >> ready_bits)); - strcpy(action, "Update"); - } - ready_bits += bps; - - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3" PRIu32 ", Col %3" PRIu32 - ", Samples %" PRIu16 ", Src byte offset %3" PRIu32 - " bit offset %2" PRIu32 " Dst offset %3td", - row + 1u, col + 1u, s, src_byte, src_bit, - dst - out); - dump_byte(dumpfile, format, "Match bits", matchbits); - dump_byte(dumpfile, format, "Src bits", *src); - dump_byte(dumpfile, format, "Buff1 bits", buff1); - dump_byte(dumpfile, format, "Buff2 bits", buff2); - dump_info(dumpfile, format, "", "%s", action); - } - } - } - - if (ready_bits > 0) - { - buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); - *dst++ = buff1; - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3" PRIu32 ", Col %3" PRIu32 - ", Src byte offset %3" PRIu32 " bit offset %2" PRIu32 - " Dst offset %3td", - row + 1u, col + 1u, src_byte, src_bit, dst - out); - dump_byte(dumpfile, format, "Final bits", buff1); - } - } - - if ((dumpfile != NULL) && (level >= 2)) - { - dump_info(dumpfile, format, "combineSeparateSamples8bits", - "Output data"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, - out + (row * dst_rowsize)); - } - } - - return (0); -} /* end combineSeparateSamples8bits */ - -static int combineSeparateSamples16bits(uint8_t *in[], uint8_t *out, - uint32_t cols, uint32_t rows, - uint16_t spp, uint16_t bps, - FILE *dumpfile, int format, int level) -{ - int ready_bits = 0 /*, bytes_per_sample = 0 */; - uint32_t src_rowsize, dst_rowsize; - uint32_t bit_offset, src_offset; - uint32_t row, col, src_byte = 0, src_bit = 0; - uint16_t maskbits = 0, matchbits = 0; - uint16_t buff1 = 0, buff2 = 0; - uint8_t bytebuff = 0; - tsample_t s; - unsigned char *src = in[0]; - unsigned char *dst = out; - char action[8]; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("combineSeparateSamples16bits", - "Invalid input or output buffer"); - return (1); - } - - /* bytes_per_sample = (bps + 7) / 8; */ - src_rowsize = ((bps * cols) + 7) / 8; - dst_rowsize = ((bps * cols * spp) + 7) / 8; - maskbits = (uint16_t)-1 >> (16 - bps); - - for (row = 0; row < rows; row++) - { - ready_bits = 0; - buff1 = buff2 = 0; - dst = out + (row * dst_rowsize); - src_offset = row * src_rowsize; - for (col = 0; col < cols; col++) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps; - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - - matchbits = maskbits << (16 - src_bit - bps); - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = in[s] + src_offset + src_byte; - if (little_endian) - buff1 = (src[0] << 8) | src[1]; - else - buff1 = (src[1] << 8) | src[0]; - - buff1 = (buff1 & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 8) - { - bytebuff = (buff2 >> 8); - *dst++ = bytebuff; - ready_bits -= 8; - /* shift in new bits */ - buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); - strcpy(action, "Flush"); - } - else - { /* add another bps bits to the buffer */ - bytebuff = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - strcpy(action, "Update"); - } - ready_bits += bps; - - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3" PRIu32 ", Col %3" PRIu32 - ", Samples %" PRIu16 ", Src byte offset %3" PRIu32 - " bit offset %2" PRIu32 " Dst offset %3td", - row + 1u, col + 1u, s, src_byte, src_bit, - dst - out); - - dump_short(dumpfile, format, "Match bits", matchbits); - dump_data(dumpfile, format, "Src bits", src, 2); - dump_short(dumpfile, format, "Buff1 bits", buff1); - dump_short(dumpfile, format, "Buff2 bits", buff2); - dump_byte(dumpfile, format, "Write byte", bytebuff); - dump_info(dumpfile, format, "", "Ready bits: %d, %s", - ready_bits, action); - } - } - } - - /* catch any trailing bits at the end of the line */ - if (ready_bits > 0) - { - bytebuff = (buff2 >> 8); - *dst++ = bytebuff; - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3d, Col %3d, Src byte offset %3d bit offset " - "%2d Dst offset %3d", - row + 1, col + 1, src_byte, src_bit, dst - out); - dump_byte(dumpfile, format, "Final bits", bytebuff); - } - } - - if ((dumpfile != NULL) && (level == 2)) - { - dump_info(dumpfile, format, "combineSeparateSamples16bits", - "Output data"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, - out + (row * dst_rowsize)); - } - } - - return (0); -} /* end combineSeparateSamples16bits */ - -static int combineSeparateSamples24bits(uint8_t *in[], uint8_t *out, - uint32_t cols, uint32_t rows, - uint16_t spp, uint16_t bps, - FILE *dumpfile, int format, int level) -{ - int ready_bits = 0 /*, bytes_per_sample = 0 */; - uint32_t src_rowsize, dst_rowsize; - uint32_t bit_offset, src_offset; - uint32_t row, col, src_byte = 0, src_bit = 0; - uint32_t maskbits = 0, matchbits = 0; - uint32_t buff1 = 0, buff2 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0; - tsample_t s; - unsigned char *src = in[0]; - unsigned char *dst = out; - char action[8]; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("combineSeparateSamples24bits", - "Invalid input or output buffer"); - return (1); - } - - /* bytes_per_sample = (bps + 7) / 8; */ - src_rowsize = ((bps * cols) + 7) / 8; - dst_rowsize = ((bps * cols * spp) + 7) / 8; - maskbits = (uint32_t)-1 >> (32 - bps); - - for (row = 0; row < rows; row++) - { - ready_bits = 0; - buff1 = buff2 = 0; - dst = out + (row * dst_rowsize); - src_offset = row * src_rowsize; - for (col = 0; col < cols; col++) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps; - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - - matchbits = maskbits << (32 - src_bit - bps); - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = in[s] + src_offset + src_byte; - if (little_endian) - buff1 = ((uint32_t)src[0] << 24) | - ((uint32_t)src[1] << 16) | ((uint32_t)src[2] << 8) | - (uint32_t)src[3]; - else - buff1 = ((uint32_t)src[3] << 24) | - ((uint32_t)src[2] << 16) | ((uint32_t)src[1] << 8) | - (uint32_t)src[0]; - buff1 = (buff1 & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 16) - { - bytebuff1 = (buff2 >> 24); - *dst++ = bytebuff1; - bytebuff2 = (buff2 >> 16); - *dst++ = bytebuff2; - ready_bits -= 16; - - /* shift in new bits */ - buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); - strcpy(action, "Flush"); - } - else - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - strcpy(action, "Update"); - } - ready_bits += bps; - - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3" PRIu32 ", Col %3" PRIu32 - ", Samples %" PRIu16 ", Src byte offset %3" PRIu32 - " bit offset %2" PRIu32 " Dst offset %3td", - row + 1u, col + 1u, s, src_byte, src_bit, - dst - out); - dump_long(dumpfile, format, "Match bits ", matchbits); - dump_data(dumpfile, format, "Src bits ", src, 4); - dump_long(dumpfile, format, "Buff1 bits ", buff1); - dump_long(dumpfile, format, "Buff2 bits ", buff2); - dump_byte(dumpfile, format, "Write bits1", bytebuff1); - dump_byte(dumpfile, format, "Write bits2", bytebuff2); - dump_info(dumpfile, format, "", "Ready bits: %d, %s", - ready_bits, action); - } - } - } - - /* catch any trailing bits at the end of the line */ - while (ready_bits > 0) - { - bytebuff1 = (buff2 >> 24); - *dst++ = bytebuff1; - - buff2 = (buff2 << 8); - bytebuff2 = bytebuff1; - ready_bits -= 8; - } + src = in[s] + src_offset + src_byte; + buff1 = ((*src) & matchbits) << (src_bit); + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + *dst++ = buff2; + buff2 = buff1; + ready_bits -= 8; + strcpy (action, "Flush"); + } + else + { + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3d, Col %3d, Src byte offset %3d bit offset %2d " - "Dst offset %3d", - row + 1, col + 1, src_byte, src_bit, dst - out); - - dump_long(dumpfile, format, "Match bits ", matchbits); - dump_data(dumpfile, format, "Src bits ", src, 4); - dump_long(dumpfile, format, "Buff1 bits ", buff1); - dump_long(dumpfile, format, "Buff2 bits ", buff2); - dump_byte(dumpfile, format, "Write bits1", bytebuff1); - dump_byte(dumpfile, format, "Write bits2", bytebuff2); - dump_info(dumpfile, format, "", "Ready bits: %2d", ready_bits); + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Match bits", matchbits); + dump_byte (dumpfile, format, "Src bits", *src); + dump_byte (dumpfile, format, "Buff1 bits", buff1); + dump_byte (dumpfile, format, "Buff2 bits", buff2); + dump_info (dumpfile, format, "","%s", action); + } } + } - if ((dumpfile != NULL) && (level == 2)) + if (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + if ((dumpfile != NULL) && (level == 3)) { - dump_info(dumpfile, format, "combineSeparateSamples24bits", - "Output data"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, - out + (row * dst_rowsize)); + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Final bits", buff1); } + } + + if ((dumpfile != NULL) && (level >= 2)) + { + dump_info (dumpfile, format, "combineSeparateSamples8bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } } - return (0); -} /* end combineSeparateSamples24bits */ + return (0); + } /* end combineSeparateSamples8bits */ -static int combineSeparateSamples32bits(uint8_t *in[], uint8_t *out, - uint32_t cols, uint32_t rows, - uint16_t spp, uint16_t bps, - FILE *dumpfile, int format, int level) -{ - int ready_bits = 0 /*, bytes_per_sample = 0, shift_width = 0 */; - uint32_t src_rowsize, dst_rowsize, bit_offset, src_offset; - uint32_t src_byte = 0, src_bit = 0; - uint32_t row, col; - uint32_t longbuff1 = 0, longbuff2 = 0; - uint64_t maskbits = 0, matchbits = 0; - uint64_t buff1 = 0, buff2 = 0, buff3 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; - tsample_t s; - unsigned char *src = in[0]; - unsigned char *dst = out; - char action[8]; +static int +combineSeparateSamples16bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0 /*, bytes_per_sample = 0 */; + uint32 src_rowsize, dst_rowsize; + uint32 bit_offset, src_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint16 maskbits = 0, matchbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; - if ((src == NULL) || (dst == NULL)) + if ((src == NULL) || (dst == NULL)) { - TIFFError("combineSeparateSamples32bits", - "Invalid input or output buffer"); - return (1); + TIFFError("combineSeparateSamples16bits","Invalid input or output buffer"); + return (1); } - /* bytes_per_sample = (bps + 7) / 8; */ - src_rowsize = ((bps * cols) + 7) / 8; - dst_rowsize = ((bps * cols * spp) + 7) / 8; - maskbits = (uint64_t)-1 >> (64 - bps); - /* shift_width = ((bps + 7) / 8) + 1; */ + /* bytes_per_sample = (bps + 7) / 8; */ + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * cols * spp) + 7) / 8; + maskbits = (uint16)-1 >> (16 - bps); - for (row = 0; row < rows; row++) + for (row = 0; row < rows; row++) { - ready_bits = 0; - buff1 = buff2 = 0; - dst = out + (row * dst_rowsize); - src_offset = row * src_rowsize; - for (col = 0; col < cols; col++) + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (16 - src_bit - bps); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps; - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; + src = in[s] + src_offset + src_byte; + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; - matchbits = maskbits << (64 - src_bit - bps); - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = in[s] + src_offset + src_byte; - if (little_endian) - { - longbuff1 = (src[0] << 24) | (src[1] << 16) | - (src[2] << 8) | src[3]; - longbuff2 = longbuff1; - } - else - { - longbuff1 = (src[3] << 24) | (src[2] << 16) | - (src[1] << 8) | src[0]; - longbuff2 = longbuff1; - } - buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; - buff1 = (buff3 & matchbits) << (src_bit); + buff1 = (buff1 & matchbits) << (src_bit); - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 32) - { - bytebuff1 = (uint8_t)(buff2 >> 56); - *dst++ = bytebuff1; - bytebuff2 = (uint8_t)(buff2 >> 48); - *dst++ = bytebuff2; - bytebuff3 = (uint8_t)(buff2 >> 40); - *dst++ = bytebuff3; - bytebuff4 = (uint8_t)(buff2 >> 32); - *dst++ = bytebuff4; - ready_bits -= 32; + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; - /* shift in new bits */ - buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); - strcpy(action, "Flush"); - } - else - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - strcpy(action, "Update"); - } - ready_bits += bps; + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3" PRIu32 ", Col %3" PRIu32 - ", Sample %" PRIu16 ", Src byte offset %3" PRIu32 - " bit offset %2" PRIu32 " Dst offset %3td", - row + 1u, col + 1u, s, src_byte, src_bit, - dst - out); - dump_wide(dumpfile, format, "Match bits ", matchbits); - dump_data(dumpfile, format, "Src bits ", src, 8); - dump_wide(dumpfile, format, "Buff1 bits ", buff1); - dump_wide(dumpfile, format, "Buff2 bits ", buff2); - dump_info(dumpfile, format, "", "Ready bits: %d, %s", - ready_bits, action); - } - } - } - while (ready_bits > 0) - { - bytebuff1 = (buff2 >> 56); - *dst++ = bytebuff1; - buff2 = (buff2 << 8); - ready_bits -= 8; - } + dump_short (dumpfile, format, "Match bits", matchbits); + dump_data (dumpfile, format, "Src bits", src, 2); + dump_short (dumpfile, format, "Buff1 bits", buff1); + dump_short (dumpfile, format, "Buff2 bits", buff2); + dump_byte (dumpfile, format, "Write byte", bytebuff); + dump_info (dumpfile, format, "","Ready bits: %d, %s", ready_bits, action); + } + } + } - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3d, Col %3d, Src byte offset %3d bit offset %2d " - "Dst offset %3d", - row + 1, col + 1, src_byte, src_bit, dst - out); + /* catch any trailing bits at the end of the line */ + if (ready_bits > 0) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Final bits", bytebuff); + } + } - dump_wide(dumpfile, format, "Match bits ", matchbits); - dump_data(dumpfile, format, "Src bits ", src, 4); - dump_wide(dumpfile, format, "Buff1 bits ", buff1); - dump_wide(dumpfile, format, "Buff2 bits ", buff2); - dump_byte(dumpfile, format, "Write bits1", bytebuff1); - dump_byte(dumpfile, format, "Write bits2", bytebuff2); - dump_info(dumpfile, format, "", "Ready bits: %2d", ready_bits); - } - - if ((dumpfile != NULL) && (level == 2)) - { - dump_info(dumpfile, format, "combineSeparateSamples32bits", - "Output data"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, out); - } + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateSamples16bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } } - return (0); -} /* end combineSeparateSamples32bits */ + return (0); + } /* end combineSeparateSamples16bits */ -static int combineSeparateTileSamplesBytes(unsigned char *srcbuffs[], - unsigned char *out, uint32_t cols, - uint32_t rows, uint32_t imagewidth, - uint32_t tw, uint16_t spp, - uint16_t bps, FILE *dumpfile, - int format, int level) -{ - int i, bytes_per_sample; - uint32_t row, col, col_offset, src_rowsize, dst_rowsize, src_offset; - unsigned char *src; - unsigned char *dst; - tsample_t s; +static int +combineSeparateSamples24bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0 /*, bytes_per_sample = 0 */; + uint32 src_rowsize, dst_rowsize; + uint32 bit_offset, src_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint32 maskbits = 0, matchbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; - src = srcbuffs[0]; - dst = out; - if ((src == NULL) || (dst == NULL)) + if ((src == NULL) || (dst == NULL)) { - TIFFError("combineSeparateTileSamplesBytes", "Invalid buffer address"); - return (1); + TIFFError("combineSeparateSamples24bits","Invalid input or output buffer"); + return (1); } - bytes_per_sample = (bps + 7) / 8; - src_rowsize = ((bps * tw) + 7) / 8; - dst_rowsize = imagewidth * bytes_per_sample * spp; - for (row = 0; row < rows; row++) + /* bytes_per_sample = (bps + 7) / 8; */ + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * cols * spp) + 7) / 8; + maskbits = (uint32)-1 >> ( 32 - bps); + + for (row = 0; row < rows; row++) { - if ((dumpfile != NULL) && (level == 2)) + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (32 - src_bit - bps); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) { - for (s = 0; s < spp; s++) - { - dump_info(dumpfile, format, "combineSeparateTileSamplesBytes", - "Input data, Sample %" PRIu16, s); - dump_buffer(dumpfile, format, 1, cols, row, - srcbuffs[s] + (row * src_rowsize)); - } + src = in[s] + src_offset + src_byte; + if (little_endian) + buff1 = ((uint32)src[0] << 24) | ((uint32)src[1] << 16) | ((uint32)src[2] << 8) | (uint32)src[3]; + else + buff1 = ((uint32)src[3] << 24) | ((uint32)src[2] << 16) | ((uint32)src[1] << 8) | (uint32)src[0]; + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 16) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; + + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "","Ready bits: %d, %s", ready_bits, action); + } + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "", "Ready bits: %2d", ready_bits); + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateSamples24bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateSamples24bits */ + +static int +combineSeparateSamples32bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0 /*, bytes_per_sample = 0, shift_width = 0 */; + uint32 src_rowsize, dst_rowsize, bit_offset, src_offset; + uint32 src_byte = 0, src_bit = 0; + uint32 row, col; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateSamples32bits","Invalid input or output buffer"); + return (1); + } + + /* bytes_per_sample = (bps + 7) / 8; */ + src_rowsize = ((bps * cols) + 7) / 8; + dst_rowsize = ((bps * cols * spp) + 7) / 8; + maskbits = (uint64)-1 >> ( 64 - bps); + /* shift_width = ((bps + 7) / 8) + 1; */ + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (64 - src_bit - bps); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 32) + { + bytebuff1 = (uint8)(buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (uint8)(buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (uint8)(buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (uint8)(buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Sample %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_wide (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 8); + dump_wide (dumpfile, format, "Buff1 bits ", buff1); + dump_wide (dumpfile, format, "Buff2 bits ", buff2); + dump_info (dumpfile, format, "", "Ready bits: %d, %s", ready_bits, action); + } + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + + dump_wide (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_wide (dumpfile, format, "Buff1 bits ", buff1); + dump_wide (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "", "Ready bits: %2d", ready_bits); + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateSamples32bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out); + } + } + + return (0); + } /* end combineSeparateSamples32bits */ + +static int +combineSeparateTileSamplesBytes (unsigned char *srcbuffs[], unsigned char *out, + uint32 cols, uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int i, bytes_per_sample; + uint32 row, col, col_offset, src_rowsize, dst_rowsize, src_offset; + unsigned char *src; + unsigned char *dst; + tsample_t s; + + src = srcbuffs[0]; + dst = out; + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateTileSamplesBytes","Invalid buffer address"); + return (1); + } + + bytes_per_sample = (bps + 7) / 8; + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = imagewidth * bytes_per_sample * spp; + for (row = 0; row < rows; row++) + { + if ((dumpfile != NULL) && (level == 2)) + { + for (s = 0; s < spp; s++) + { + dump_info (dumpfile, format, "combineSeparateTileSamplesBytes","Input data, Sample %d", s); + dump_buffer(dumpfile, format, 1, cols, row, srcbuffs[s] + (row * src_rowsize)); } - dst = out + (row * dst_rowsize); - src_offset = row * src_rowsize; + } + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; #ifdef DEVELMODE - TIFFError("", "Tile row %4d, Src offset %6d Dst offset %6d", row, - src_offset, dst - out); + TIFFError("","Tile row %4d, Src offset %6d Dst offset %6d", + row, src_offset, dst - out); #endif - for (col = 0; col < cols; col++) + for (col = 0; col < cols; col++) + { + col_offset = src_offset + (col * (bps / 8)); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) { - col_offset = src_offset + (col * (bps / 8)); - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = srcbuffs[s] + col_offset; - for (i = 0; i < bytes_per_sample; i++) - *(dst + i) = *(src + i); - dst += bytes_per_sample; - } - } + src = srcbuffs[s] + col_offset; + for (i = 0; i < bytes_per_sample; i++) + *(dst + i) = *(src + i); + dst += bytes_per_sample; + } + } - if ((dumpfile != NULL) && (level == 2)) - { - dump_info(dumpfile, format, "combineSeparateTileSamplesBytes", - "Output data, combined samples"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, - out + (row * dst_rowsize)); - } + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamplesBytes","Output data, combined samples"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } } - return (0); -} /* end combineSeparateTileSamplesBytes */ + return (0); + } /* end combineSeparateTileSamplesBytes */ -static int combineSeparateTileSamples8bits(uint8_t *in[], uint8_t *out, - uint32_t cols, uint32_t rows, - uint32_t imagewidth, uint32_t tw, - uint16_t spp, uint16_t bps, - FILE *dumpfile, int format, - int level) -{ - int ready_bits = 0; - uint32_t src_rowsize, dst_rowsize, src_offset; - uint32_t bit_offset; - uint32_t row, col, src_byte = 0, src_bit = 0; - uint8_t maskbits = 0, matchbits = 0; - uint8_t buff1 = 0, buff2 = 0; - tsample_t s; - unsigned char *src = in[0]; - unsigned char *dst = out; - char action[32]; +static int +combineSeparateTileSamples8bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0; + uint32 src_rowsize, dst_rowsize, src_offset; + uint32 bit_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint8 maskbits = 0, matchbits = 0; + uint8 buff1 = 0, buff2 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[32]; - if ((src == NULL) || (dst == NULL)) + if ((src == NULL) || (dst == NULL)) { - TIFFError("combineSeparateTileSamples8bits", - "Invalid input or output buffer"); - return (1); + TIFFError("combineSeparateTileSamples8bits","Invalid input or output buffer"); + return (1); } - src_rowsize = ((bps * tw) + 7) / 8; - dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; - maskbits = (uint8_t)-1 >> (8 - bps); + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + maskbits = (uint8)-1 >> ( 8 - bps); - for (row = 0; row < rows; row++) + for (row = 0; row < rows; row++) { - ready_bits = 0; - buff1 = buff2 = 0; - dst = out + (row * dst_rowsize); - src_offset = row * src_rowsize; - for (col = 0; col < cols; col++) + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (8 - src_bit - bps); + /* load up next sample from each plane */ + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps; - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - - matchbits = maskbits << (8 - src_bit - bps); - /* load up next sample from each plane */ - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = in[s] + src_offset + src_byte; - buff1 = ((*src) & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 8) - { - *dst++ = buff2; - buff2 = buff1; - ready_bits -= 8; - strcpy(action, "Flush"); - } - else - { - buff2 = (buff2 | (buff1 >> ready_bits)); - strcpy(action, "Update"); - } - ready_bits += bps; - - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3" PRIu32 ", Col %3" PRIu32 - ", Samples %" PRIu16 ", Src byte offset %3" PRIu32 - " bit offset %2" PRIu32 " Dst offset %3td", - row + 1u, col + 1u, s, src_byte, src_bit, - dst - out); - dump_byte(dumpfile, format, "Match bits", matchbits); - dump_byte(dumpfile, format, "Src bits", *src); - dump_byte(dumpfile, format, "Buff1 bits", buff1); - dump_byte(dumpfile, format, "Buff2 bits", buff2); - dump_info(dumpfile, format, "", "%s", action); - } - } - } - - if (ready_bits > 0) - { - buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); - *dst++ = buff1; - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3d, Col %3d, Src byte offset %3d bit offset " - "%2d Dst offset %3d", - row + 1, col + 1, src_byte, src_bit, dst - out); - dump_byte(dumpfile, format, "Final bits", buff1); - } - } - - if ((dumpfile != NULL) && (level >= 2)) - { - dump_info(dumpfile, format, "combineSeparateTileSamples8bits", - "Output data"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, - out + (row * dst_rowsize)); - } - } - - return (0); -} /* end combineSeparateTileSamples8bits */ - -static int combineSeparateTileSamples16bits(uint8_t *in[], uint8_t *out, - uint32_t cols, uint32_t rows, - uint32_t imagewidth, uint32_t tw, - uint16_t spp, uint16_t bps, - FILE *dumpfile, int format, - int level) -{ - int ready_bits = 0; - uint32_t src_rowsize, dst_rowsize; - uint32_t bit_offset, src_offset; - uint32_t row, col, src_byte = 0, src_bit = 0; - uint16_t maskbits = 0, matchbits = 0; - uint16_t buff1 = 0, buff2 = 0; - uint8_t bytebuff = 0; - tsample_t s; - unsigned char *src = in[0]; - unsigned char *dst = out; - char action[8]; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("combineSeparateTileSamples16bits", - "Invalid input or output buffer"); - return (1); - } - - src_rowsize = ((bps * tw) + 7) / 8; - dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; - maskbits = (uint16_t)-1 >> (16 - bps); - - for (row = 0; row < rows; row++) - { - ready_bits = 0; - buff1 = buff2 = 0; - dst = out + (row * dst_rowsize); - src_offset = row * src_rowsize; - for (col = 0; col < cols; col++) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps; - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - - matchbits = maskbits << (16 - src_bit - bps); - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = in[s] + src_offset + src_byte; - if (little_endian) - buff1 = (src[0] << 8) | src[1]; - else - buff1 = (src[1] << 8) | src[0]; - buff1 = (buff1 & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 8) - { - bytebuff = (buff2 >> 8); - *dst++ = bytebuff; - ready_bits -= 8; - /* shift in new bits */ - buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); - strcpy(action, "Flush"); - } - else - { /* add another bps bits to the buffer */ - bytebuff = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - strcpy(action, "Update"); - } - ready_bits += bps; - - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3" PRIu32 ", Col %3" PRIu32 - ", Samples %" PRIu16 ", Src byte offset %3" PRIu32 - " bit offset %2" PRIu32 " Dst offset %3td", - row + 1u, col + 1u, s, src_byte, src_bit, - dst - out); - - dump_short(dumpfile, format, "Match bits", matchbits); - dump_data(dumpfile, format, "Src bits", src, 2); - dump_short(dumpfile, format, "Buff1 bits", buff1); - dump_short(dumpfile, format, "Buff2 bits", buff2); - dump_byte(dumpfile, format, "Write byte", bytebuff); - dump_info(dumpfile, format, "", "Ready bits: %d, %s", - ready_bits, action); - } - } - } - - /* catch any trailing bits at the end of the line */ - if (ready_bits > 0) - { - bytebuff = (buff2 >> 8); - *dst++ = bytebuff; - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3d, Col %3d, Src byte offset %3d bit offset " - "%2d Dst offset %3d", - row + 1, col + 1, src_byte, src_bit, dst - out); - dump_byte(dumpfile, format, "Final bits", bytebuff); - } - } - - if ((dumpfile != NULL) && (level == 2)) - { - dump_info(dumpfile, format, "combineSeparateTileSamples16bits", - "Output data"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, - out + (row * dst_rowsize)); - } - } - - return (0); -} /* end combineSeparateTileSamples16bits */ - -static int combineSeparateTileSamples24bits(uint8_t *in[], uint8_t *out, - uint32_t cols, uint32_t rows, - uint32_t imagewidth, uint32_t tw, - uint16_t spp, uint16_t bps, - FILE *dumpfile, int format, - int level) -{ - int ready_bits = 0; - uint32_t src_rowsize, dst_rowsize; - uint32_t bit_offset, src_offset; - uint32_t row, col, src_byte = 0, src_bit = 0; - uint32_t maskbits = 0, matchbits = 0; - uint32_t buff1 = 0, buff2 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0; - tsample_t s; - unsigned char *src = in[0]; - unsigned char *dst = out; - char action[8]; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("combineSeparateTileSamples24bits", - "Invalid input or output buffer"); - return (1); - } - - src_rowsize = ((bps * tw) + 7) / 8; - dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; - maskbits = (uint32_t)-1 >> (32 - bps); - - for (row = 0; row < rows; row++) - { - ready_bits = 0; - buff1 = buff2 = 0; - dst = out + (row * dst_rowsize); - src_offset = row * src_rowsize; - for (col = 0; col < cols; col++) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps; - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - - matchbits = maskbits << (32 - src_bit - bps); - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = in[s] + src_offset + src_byte; - if (little_endian) - buff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | - src[3]; - else - buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | - src[0]; - buff1 = (buff1 & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 16) - { - bytebuff1 = (buff2 >> 24); - *dst++ = bytebuff1; - bytebuff2 = (buff2 >> 16); - *dst++ = bytebuff2; - ready_bits -= 16; - - /* shift in new bits */ - buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); - strcpy(action, "Flush"); - } - else - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - strcpy(action, "Update"); - } - ready_bits += bps; - - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3" PRIu32 ", Col %3" PRIu32 - ", Samples %" PRIu16 ", Src byte offset %3" PRIu32 - " bit offset %2" PRIu32 " Dst offset %3td", - row + 1u, col + 1u, s, src_byte, src_bit, - dst - out); - dump_long(dumpfile, format, "Match bits ", matchbits); - dump_data(dumpfile, format, "Src bits ", src, 4); - dump_long(dumpfile, format, "Buff1 bits ", buff1); - dump_long(dumpfile, format, "Buff2 bits ", buff2); - dump_byte(dumpfile, format, "Write bits1", bytebuff1); - dump_byte(dumpfile, format, "Write bits2", bytebuff2); - dump_info(dumpfile, format, "", "Ready bits: %d, %s", - ready_bits, action); - } - } - } - - /* catch any trailing bits at the end of the line */ - while (ready_bits > 0) - { - bytebuff1 = (buff2 >> 24); - *dst++ = bytebuff1; - - buff2 = (buff2 << 8); - bytebuff2 = bytebuff1; - ready_bits -= 8; - } + src = in[s] + src_offset + src_byte; + buff1 = ((*src) & matchbits) << (src_bit); + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + *dst++ = buff2; + buff2 = buff1; + ready_bits -= 8; + strcpy (action, "Flush"); + } + else + { + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3d, Col %3d, Src byte offset %3d bit offset %2d " - "Dst offset %3d", - row + 1, col + 1, src_byte, src_bit, dst - out); - - dump_long(dumpfile, format, "Match bits ", matchbits); - dump_data(dumpfile, format, "Src bits ", src, 4); - dump_long(dumpfile, format, "Buff1 bits ", buff1); - dump_long(dumpfile, format, "Buff2 bits ", buff2); - dump_byte(dumpfile, format, "Write bits1", bytebuff1); - dump_byte(dumpfile, format, "Write bits2", bytebuff2); - dump_info(dumpfile, format, "", "Ready bits: %2d", ready_bits); + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Match bits", matchbits); + dump_byte (dumpfile, format, "Src bits", *src); + dump_byte (dumpfile, format, "Buff1 bits", buff1); + dump_byte (dumpfile, format, "Buff2 bits", buff2); + dump_info (dumpfile, format, "","%s", action); + } } + } - if ((dumpfile != NULL) && (level == 2)) + if (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + if ((dumpfile != NULL) && (level == 3)) { - dump_info(dumpfile, format, "combineSeparateTileSamples24bits", - "Output data"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, - out + (row * dst_rowsize)); + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Final bits", buff1); } + } + + if ((dumpfile != NULL) && (level >= 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamples8bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } } + return (0); + } /* end combineSeparateTileSamples8bits */ + +static int +combineSeparateTileSamples16bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0; + uint32 src_rowsize, dst_rowsize; + uint32 bit_offset, src_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint16 maskbits = 0, matchbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateTileSamples16bits","Invalid input or output buffer"); + return (1); + } + + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + maskbits = (uint16)-1 >> (16 - bps); + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (16 - src_bit - bps); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + + dump_short (dumpfile, format, "Match bits", matchbits); + dump_data (dumpfile, format, "Src bits", src, 2); + dump_short (dumpfile, format, "Buff1 bits", buff1); + dump_short (dumpfile, format, "Buff2 bits", buff2); + dump_byte (dumpfile, format, "Write byte", bytebuff); + dump_info (dumpfile, format, "","Ready bits: %d, %s", ready_bits, action); + } + } + } + + /* catch any trailing bits at the end of the line */ + if (ready_bits > 0) + { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + dump_byte (dumpfile, format, "Final bits", bytebuff); + } + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamples16bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateTileSamples16bits */ + +static int +combineSeparateTileSamples24bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0; + uint32 src_rowsize, dst_rowsize; + uint32 bit_offset, src_offset; + uint32 row, col, src_byte = 0, src_bit = 0; + uint32 maskbits = 0, matchbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateTileSamples24bits","Invalid input or output buffer"); + return (1); + } + + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + maskbits = (uint32)-1 >> ( 32 - bps); + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (32 - src_bit - bps); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + buff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + else + buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 16) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; + + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Samples %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "","Ready bits: %d, %s", ready_bits, action); + } + } + } + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + + dump_long (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_long (dumpfile, format, "Buff1 bits ", buff1); + dump_long (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "", "Ready bits: %2d", ready_bits); + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamples24bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out + (row * dst_rowsize)); + } + } + + return (0); + } /* end combineSeparateTileSamples24bits */ + +static int +combineSeparateTileSamples32bits (uint8 *in[], uint8 *out, uint32 cols, + uint32 rows, uint32 imagewidth, + uint32 tw, uint16 spp, uint16 bps, + FILE *dumpfile, int format, int level) + { + int ready_bits = 0 /*, shift_width = 0 */; + uint32 src_rowsize, dst_rowsize, bit_offset, src_offset; + uint32 src_byte = 0, src_bit = 0; + uint32 row, col; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + tsample_t s; + unsigned char *src = in[0]; + unsigned char *dst = out; + char action[8]; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("combineSeparateTileSamples32bits","Invalid input or output buffer"); + return (1); + } + + src_rowsize = ((bps * tw) + 7) / 8; + dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; + maskbits = (uint64)-1 >> ( 64 - bps); + /* shift_width = ((bps + 7) / 8) + 1; */ + + for (row = 0; row < rows; row++) + { + ready_bits = 0; + buff1 = buff2 = 0; + dst = out + (row * dst_rowsize); + src_offset = row * src_rowsize; + for (col = 0; col < cols; col++) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = col * bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + + matchbits = maskbits << (64 - src_bit - bps); + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + src = in[s] + src_offset + src_byte; + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 32) + { + bytebuff1 = (uint8)(buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (uint8)(buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (uint8)(buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (uint8)(buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + strcpy (action, "Flush"); + } + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + strcpy (action, "Update"); + } + ready_bits += bps; + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Sample %d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, s, src_byte, src_bit, dst - out); + dump_wide (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 8); + dump_wide (dumpfile, format, "Buff1 bits ", buff1); + dump_wide (dumpfile, format, "Buff2 bits ", buff2); + dump_info (dumpfile, format, "", "Ready bits: %d, %s", ready_bits, action); + } + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + if ((dumpfile != NULL) && (level == 3)) + { + dump_info (dumpfile, format, "", + "Row %3d, Col %3d, Src byte offset %3d bit offset %2d Dst offset %3d", + row + 1, col + 1, src_byte, src_bit, dst - out); + + dump_wide (dumpfile, format, "Match bits ", matchbits); + dump_data (dumpfile, format, "Src bits ", src, 4); + dump_wide (dumpfile, format, "Buff1 bits ", buff1); + dump_wide (dumpfile, format, "Buff2 bits ", buff2); + dump_byte (dumpfile, format, "Write bits1", bytebuff1); + dump_byte (dumpfile, format, "Write bits2", bytebuff2); + dump_info (dumpfile, format, "", "Ready bits: %2d", ready_bits); + } + + if ((dumpfile != NULL) && (level == 2)) + { + dump_info (dumpfile, format, "combineSeparateTileSamples32bits","Output data"); + dump_buffer(dumpfile, format, 1, dst_rowsize, row, out); + } + } + + return (0); + } /* end combineSeparateTileSamples32bits */ + + +static int readSeparateStripsIntoBuffer (TIFF *in, uint8 *obuf, uint32 length, + uint32 width, uint16 spp, + struct dump_opts *dump) + { + int i, bytes_per_sample, bytes_per_pixel, shift_width, result = 1; + uint32 j; + tmsize_t bytes_read = 0; + uint16 bps = 0, planar; + uint32 nstrips; + uint32 strips_per_sample; + uint32 src_rowsize, dst_rowsize, rows_processed, rps; + uint32 rows_this_strip = 0; + tsample_t s; + tstrip_t strip; + tsize_t scanlinesize = TIFFScanlineSize(in); + tsize_t stripsize = TIFFStripSize(in); + unsigned char *srcbuffs[MAX_SAMPLES]; + unsigned char *buff = NULL; + unsigned char *dst = NULL; + + if (obuf == NULL) + { + TIFFError("readSeparateStripsIntoBuffer","Invalid buffer argument"); return (0); -} /* end combineSeparateTileSamples24bits */ - -static int combineSeparateTileSamples32bits(uint8_t *in[], uint8_t *out, - uint32_t cols, uint32_t rows, - uint32_t imagewidth, uint32_t tw, - uint16_t spp, uint16_t bps, - FILE *dumpfile, int format, - int level) -{ - int ready_bits = 0 /*, shift_width = 0 */; - uint32_t src_rowsize, dst_rowsize, bit_offset, src_offset; - uint32_t src_byte = 0, src_bit = 0; - uint32_t row, col; - uint32_t longbuff1 = 0, longbuff2 = 0; - uint64_t maskbits = 0, matchbits = 0; - uint64_t buff1 = 0, buff2 = 0, buff3 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; - tsample_t s; - unsigned char *src = in[0]; - unsigned char *dst = out; - char action[8]; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("combineSeparateTileSamples32bits", - "Invalid input or output buffer"); - return (1); } - src_rowsize = ((bps * tw) + 7) / 8; - dst_rowsize = ((imagewidth * bps * spp) + 7) / 8; - maskbits = (uint64_t)-1 >> (64 - bps); - /* shift_width = ((bps + 7) / 8) + 1; */ + memset (srcbuffs, '\0', sizeof(srcbuffs)); + TIFFGetFieldDefaulted(in, TIFFTAG_BITSPERSAMPLE, &bps); + TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &planar); + TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); + if (rps > length) + rps = length; - for (row = 0; row < rows; row++) + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + + src_rowsize = ((bps * width) + 7) / 8; + dst_rowsize = ((bps * width * spp) + 7) / 8; + dst = obuf; + + if ((dump->infile != NULL) && (dump->level == 3)) { - ready_bits = 0; - buff1 = buff2 = 0; - dst = out + (row * dst_rowsize); - src_offset = row * src_rowsize; - for (col = 0; col < cols; col++) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = col * bps; - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - - matchbits = maskbits << (64 - src_bit - bps); - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - src = in[s] + src_offset + src_byte; - if (little_endian) - { - longbuff1 = (src[0] << 24) | (src[1] << 16) | - (src[2] << 8) | src[3]; - longbuff2 = longbuff1; - } - else - { - longbuff1 = (src[3] << 24) | (src[2] << 16) | - (src[1] << 8) | src[0]; - longbuff2 = longbuff1; - } - - buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; - buff1 = (buff3 & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 32) - { - bytebuff1 = (uint8_t)(buff2 >> 56); - *dst++ = bytebuff1; - bytebuff2 = (uint8_t)(buff2 >> 48); - *dst++ = bytebuff2; - bytebuff3 = (uint8_t)(buff2 >> 40); - *dst++ = bytebuff3; - bytebuff4 = (uint8_t)(buff2 >> 32); - *dst++ = bytebuff4; - ready_bits -= 32; - - /* shift in new bits */ - buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); - strcpy(action, "Flush"); - } - else - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - strcpy(action, "Update"); - } - ready_bits += bps; - - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3" PRIu32 ", Col %3" PRIu32 - ", Sample %" PRIu16 ", Src byte offset %3" PRIu32 - " bit offset %2" PRIu32 " Dst offset %3td", - row + 1u, col + 1u, s, src_byte, src_bit, - dst - out); - dump_wide(dumpfile, format, "Match bits ", matchbits); - dump_data(dumpfile, format, "Src bits ", src, 8); - dump_wide(dumpfile, format, "Buff1 bits ", buff1); - dump_wide(dumpfile, format, "Buff2 bits ", buff2); - dump_info(dumpfile, format, "", "Ready bits: %d, %s", - ready_bits, action); - } - } - } - while (ready_bits > 0) - { - bytebuff1 = (buff2 >> 56); - *dst++ = bytebuff1; - buff2 = (buff2 << 8); - ready_bits -= 8; - } - - if ((dumpfile != NULL) && (level == 3)) - { - dump_info(dumpfile, format, "", - "Row %3d, Col %3d, Src byte offset %3d bit offset %2d " - "Dst offset %3d", - row + 1, col + 1, src_byte, src_bit, dst - out); - - dump_wide(dumpfile, format, "Match bits ", matchbits); - dump_data(dumpfile, format, "Src bits ", src, 4); - dump_wide(dumpfile, format, "Buff1 bits ", buff1); - dump_wide(dumpfile, format, "Buff2 bits ", buff2); - dump_byte(dumpfile, format, "Write bits1", bytebuff1); - dump_byte(dumpfile, format, "Write bits2", bytebuff2); - dump_info(dumpfile, format, "", "Ready bits: %2d", ready_bits); - } - - if ((dumpfile != NULL) && (level == 2)) - { - dump_info(dumpfile, format, "combineSeparateTileSamples32bits", - "Output data"); - dump_buffer(dumpfile, format, 1, dst_rowsize, row, out); - } + dump_info (dump->infile, dump->format, "", + "Image width %d, length %d, Scanline size, %4d bytes", + width, length, scanlinesize); + dump_info (dump->infile, dump->format, "", + "Bits per sample %d, Samples per pixel %d, Shift width %d", + bps, spp, shift_width); } - return (0); -} /* end combineSeparateTileSamples32bits */ + /* Libtiff seems to assume/require that data for separate planes are + * written one complete plane after another and not interleaved in any way. + * Multiple scanlines and possibly strips of the same plane must be + * written before data for any other plane. + */ + nstrips = TIFFNumberOfStrips(in); + strips_per_sample = nstrips /spp; -static int readSeparateStripsIntoBuffer(TIFF *in, uint8_t *obuf, - uint32_t length, uint32_t width, - uint16_t spp, struct dump_opts *dump) -{ - int i, bytes_per_sample, bytes_per_pixel, shift_width, result = 1; - uint32_t j; - tmsize_t bytes_read = 0; - uint16_t bps = 0, planar; - uint32_t nstrips; - uint32_t strips_per_sample; - uint32_t src_rowsize, dst_rowsize, rows_processed, rps; - uint32_t rows_this_strip = 0; - tsample_t s; - tstrip_t strip; - tsize_t scanlinesize = TIFFScanlineSize(in); - tsize_t stripsize = TIFFStripSize(in); - unsigned char *srcbuffs[MAX_SAMPLES]; - unsigned char *buff = NULL; - unsigned char *dst = NULL; + /* Add 3 padding bytes for combineSeparateSamples32bits */ + if( (size_t) stripsize > 0xFFFFFFFFU - 3U ) + { + TIFFError("readSeparateStripsIntoBuffer", "Integer overflow when calculating buffer size."); + exit(EXIT_FAILURE); + } - if (obuf == NULL) + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) { - TIFFError("readSeparateStripsIntoBuffer", "Invalid buffer argument"); - return (0); + srcbuffs[s] = NULL; + buff = limitMalloc(stripsize + NUM_BUFF_OVERSIZE_BYTES); + if (!buff) + { + TIFFError ("readSeparateStripsIntoBuffer", + "Unable to allocate strip read buffer for sample %d", s); + for (i = 0; i < s; i++) + _TIFFfree (srcbuffs[i]); + return 0; + } + buff[stripsize] = 0; + buff[stripsize+1] = 0; + buff[stripsize+2] = 0; + srcbuffs[s] = buff; } - memset(srcbuffs, '\0', sizeof(srcbuffs)); - TIFFGetFieldDefaulted(in, TIFFTAG_BITSPERSAMPLE, &bps); - TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &planar); - TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rps); - if (rps > length) - rps = length; + rows_processed = 0; + for (j = 0; (j < strips_per_sample) && (result == 1); j++) + { + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + { + buff = srcbuffs[s]; + strip = (s * strips_per_sample) + j; + bytes_read = TIFFReadEncodedStrip (in, strip, buff, stripsize); + rows_this_strip = (uint32)(bytes_read / src_rowsize); + if (bytes_read < 0 && !ignore) + { + TIFFError(TIFFFileName(in), + "Error, can't read strip %lu for sample %d", + (unsigned long) strip, s + 1); + result = 0; + break; + } +#ifdef DEVELMODE + TIFFError("", "Strip %2d, read %5d bytes for %4d scanlines, shift width %d", + strip, bytes_read, rows_this_strip, shift_width); +#endif + } - bytes_per_sample = (bps + 7) / 8; - bytes_per_pixel = ((bps * spp) + 7) / 8; - if (bytes_per_pixel < (bytes_per_sample + 1)) - shift_width = bytes_per_pixel; + if (rps > rows_this_strip) + rps = rows_this_strip; + dst = obuf + (dst_rowsize * rows_processed); + if ((bps % 8) == 0) + { + if (combineSeparateSamplesBytes (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } + } else - shift_width = bytes_per_sample + 1; - - src_rowsize = ((bps * width) + 7) / 8; - dst_rowsize = ((bps * width * spp) + 7) / 8; - dst = obuf; - - if ((dump->infile != NULL) && (dump->level == 3)) - { - dump_info(dump->infile, dump->format, "", - "Image width %" PRIu32 ", length %" PRIu32 - ", Scanline size, %4" PRId64 " bytes", - width, length, scanlinesize); - dump_info(dump->infile, dump->format, "", - "Bits per sample %" PRIu16 ", Samples per pixel %" PRIu16 - ", Shift width %d", - bps, spp, shift_width); - } - - /* Libtiff seems to assume/require that data for separate planes are - * written one complete plane after another and not interleaved in any way. - * Multiple scanlines and possibly strips of the same plane must be - * written before data for any other plane. - */ - nstrips = TIFFNumberOfStrips(in); - strips_per_sample = nstrips / spp; - - /* Add 3 padding bytes for combineSeparateSamples32bits */ - if ((size_t)stripsize > TIFF_TMSIZE_T_MAX - NUM_BUFF_OVERSIZE_BYTES) - { - TIFFError("readSeparateStripsIntoBuffer", - "Integer overflow when calculating buffer size."); - exit(EXIT_FAILURE); - } - - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - srcbuffs[s] = NULL; - buff = limitMalloc(stripsize + NUM_BUFF_OVERSIZE_BYTES); - if (!buff) + { + switch (shift_width) { - TIFFError( - "readSeparateStripsIntoBuffer", - "Unable to allocate strip read buffer for sample %" PRIu16, s); - for (i = 0; i < s; i++) - _TIFFfree(srcbuffs[i]); - return 0; - } - buff[stripsize] = 0; - buff[stripsize + 1] = 0; - buff[stripsize + 2] = 0; - srcbuffs[s] = buff; - } - - rows_processed = 0; - for (j = 0; (j < strips_per_sample) && (result == 1); j++) - { - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) - { - buff = srcbuffs[s]; - strip = (s * strips_per_sample) + j; - bytes_read = TIFFReadEncodedStrip(in, strip, buff, stripsize); - rows_this_strip = (uint32_t)(bytes_read / src_rowsize); - if (bytes_read < 0 && !ignore) - { - TIFFError(TIFFFileName(in), - "Error, can't read strip %" PRIu32 - " for sample %" PRIu32, - strip, s + 1u); - result = 0; + case 1: if (combineSeparateSamples8bits (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } + break; + case 2: if (combineSeparateSamples16bits (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } + break; + case 3: if (combineSeparateSamples24bits (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } break; - } -#ifdef DEVELMODE - TIFFError("", - "Strip %2" PRIu32 ", read %5" PRId32 - " bytes for %4" PRIu32 " scanlines, shift width %d", - strip, bytes_read, rows_this_strip, shift_width); -#endif + case 4: + case 5: + case 6: + case 7: + case 8: if (combineSeparateSamples32bits (srcbuffs, dst, width, rps, + spp, bps, dump->infile, + dump->format, dump->level)) + { + result = 0; + break; + } + break; + default: TIFFError ("readSeparateStripsIntoBuffer", "Unsupported bit depth: %d", bps); + result = 0; + break; } - - if (rps > rows_this_strip) - rps = rows_this_strip; - dst = obuf + (dst_rowsize * rows_processed); - if ((bps % 8) == 0) - { - if (combineSeparateSamplesBytes(srcbuffs, dst, width, rps, spp, bps, - dump->infile, dump->format, - dump->level)) - { - result = 0; - break; - } - } - else - { - switch (shift_width) - { - case 1: - if (combineSeparateSamples8bits(srcbuffs, dst, width, rps, - spp, bps, dump->infile, - dump->format, dump->level)) - { - result = 0; - break; - } - break; - case 2: - if (combineSeparateSamples16bits(srcbuffs, dst, width, rps, - spp, bps, dump->infile, - dump->format, dump->level)) - { - result = 0; - break; - } - break; - case 3: - if (combineSeparateSamples24bits(srcbuffs, dst, width, rps, - spp, bps, dump->infile, - dump->format, dump->level)) - { - result = 0; - break; - } - break; - case 4: - case 5: - case 6: - case 7: - case 8: - if (combineSeparateSamples32bits(srcbuffs, dst, width, rps, - spp, bps, dump->infile, - dump->format, dump->level)) - { - result = 0; - break; - } - break; - default: - TIFFError("readSeparateStripsIntoBuffer", - "Unsupported bit depth: %" PRIu16, bps); - result = 0; - break; - } - } - - if ((rows_processed + rps) > length) - { - rows_processed = length; - rps = length - rows_processed; - } - else - rows_processed += rps; + } + + if ((rows_processed + rps) > length) + { + rows_processed = length; + rps = length - rows_processed; + } + else + rows_processed += rps; } - /* free any buffers allocated for each plane or scanline and - * any temporary buffers - */ - for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) + /* free any buffers allocated for each plane or scanline and + * any temporary buffers + */ + for (s = 0; (s < spp) && (s < MAX_SAMPLES); s++) { - buff = srcbuffs[s]; - if (buff != NULL) - _TIFFfree(buff); + buff = srcbuffs[s]; + if (buff != NULL) + _TIFFfree(buff); } - return (result); -} /* end readSeparateStripsIntoBuffer */ + return (result); + } /* end readSeparateStripsIntoBuffer */ -static int get_page_geometry(char *name, struct pagedef *page) -{ +static int +get_page_geometry (char *name, struct pagedef *page) + { char *ptr; - unsigned int n; + int n; for (ptr = name; *ptr; ptr++) - *ptr = (char)tolower((int)*ptr); + *ptr = (char)tolower((int)*ptr); for (n = 0; n < MAX_PAPERNAMES; n++) - { - if (strcmp(name, PaperTable[n].name) == 0) + { + if (strcmp(name, PaperTable[n].name) == 0) { - page->width = PaperTable[n].width; - page->length = PaperTable[n].length; - strncpy(page->name, PaperTable[n].name, 15); - page->name[15] = '\0'; - return (0); + page->width = PaperTable[n].width; + page->length = PaperTable[n].length; + strncpy (page->name, PaperTable[n].name, 15); + page->name[15] = '\0'; + return (0); } - } + } - return (1); -} + return (1); + } -static void initPageSetup(struct pagedef *page, struct pageseg *pagelist, - struct buffinfo seg_buffs[]) -{ - int i; - strcpy(page->name, ""); - page->mode = PAGE_MODE_NONE; - page->res_unit = RESUNIT_NONE; - page->hres = 0.0; - page->vres = 0.0; - page->width = 0.0; - page->length = 0.0; - page->hmargin = 0.0; - page->vmargin = 0.0; - page->rows = 0; - page->cols = 0; - page->orient = ORIENTATION_NONE; +static void +initPageSetup (struct pagedef *page, struct pageseg *pagelist, + struct buffinfo seg_buffs[]) + { + int i; - for (i = 0; i < MAX_SECTIONS; i++) - { - pagelist[i].x1 = (uint32_t)0; - pagelist[i].x2 = (uint32_t)0; - pagelist[i].y1 = (uint32_t)0; - pagelist[i].y2 = (uint32_t)0; - pagelist[i].buffsize = (uint32_t)0; - pagelist[i].position = 0; - pagelist[i].total = 0; - } + strcpy (page->name, ""); + page->mode = PAGE_MODE_NONE; + page->res_unit = RESUNIT_NONE; + page->hres = 0.0; + page->vres = 0.0; + page->width = 0.0; + page->length = 0.0; + page->hmargin = 0.0; + page->vmargin = 0.0; + page->rows = 0; + page->cols = 0; + page->orient = ORIENTATION_NONE; - for (i = 0; i < MAX_OUTBUFFS; i++) - { - seg_buffs[i].size = 0; - seg_buffs[i].buffer = NULL; - } -} + for (i = 0; i < MAX_SECTIONS; i++) + { + pagelist[i].x1 = (uint32)0; + pagelist[i].x2 = (uint32)0; + pagelist[i].y1 = (uint32)0; + pagelist[i].y2 = (uint32)0; + pagelist[i].buffsize = (uint32)0; + pagelist[i].position = 0; + pagelist[i].total = 0; + } -static void initImageData(struct image_data *image) -{ - image->xres = 0.0; - image->yres = 0.0; - image->width = 0; - image->length = 0; - image->res_unit = RESUNIT_NONE; - image->bps = 0; - image->spp = 0; - image->planar = 0; - image->photometric = 0; - image->orientation = 0; - image->compression = COMPRESSION_NONE; - image->adjustments = 0; -} + for (i = 0; i < MAX_OUTBUFFS; i++) + { + seg_buffs[i].size = 0; + seg_buffs[i].buffer = NULL; + } + } -static void initCropMasks(struct crop_mask *cps) -{ - int i; +static void +initImageData (struct image_data *image) + { + image->xres = 0.0; + image->yres = 0.0; + image->width = 0; + image->length = 0; + image->res_unit = RESUNIT_NONE; + image->bps = 0; + image->spp = 0; + image->planar = 0; + image->photometric = 0; + image->orientation = 0; + image->compression = COMPRESSION_NONE; + image->adjustments = 0; + } - cps->crop_mode = CROP_NONE; - cps->res_unit = RESUNIT_NONE; - cps->edge_ref = EDGE_TOP; - cps->width = 0; - cps->length = 0; - for (i = 0; i < 4; i++) - cps->margins[i] = 0.0; - cps->bufftotal = (uint32_t)0; - cps->combined_width = (uint32_t)0; - cps->combined_length = (uint32_t)0; - cps->rotation = (uint16_t)0; - cps->photometric = INVERT_DATA_AND_TAG; - cps->mirror = (uint16_t)0; - cps->invert = (uint16_t)0; - cps->zones = (uint32_t)0; - cps->regions = (uint32_t)0; - for (i = 0; i < MAX_REGIONS; i++) - { - cps->corners[i].X1 = 0.0; - cps->corners[i].X2 = 0.0; - cps->corners[i].Y1 = 0.0; - cps->corners[i].Y2 = 0.0; - cps->regionlist[i].x1 = 0; - cps->regionlist[i].x2 = 0; - cps->regionlist[i].y1 = 0; - cps->regionlist[i].y2 = 0; - cps->regionlist[i].width = 0; - cps->regionlist[i].length = 0; - cps->regionlist[i].buffsize = 0; - cps->zonelist[i].position = 0; - cps->zonelist[i].total = 0; - } - cps->exp_mode = ONE_FILE_COMPOSITE; - cps->img_mode = COMPOSITE_IMAGES; -} +static void +initCropMasks (struct crop_mask *cps) + { + int i; + + cps->crop_mode = CROP_NONE; + cps->res_unit = RESUNIT_NONE; + cps->edge_ref = EDGE_TOP; + cps->width = 0; + cps->length = 0; + for (i = 0; i < 4; i++) + cps->margins[i] = 0.0; + cps->bufftotal = (uint32)0; + cps->combined_width = (uint32)0; + cps->combined_length = (uint32)0; + cps->rotation = (uint16)0; + cps->photometric = INVERT_DATA_AND_TAG; + cps->mirror = (uint16)0; + cps->invert = (uint16)0; + cps->zones = (uint32)0; + cps->regions = (uint32)0; + for (i = 0; i < MAX_REGIONS; i++) + { + cps->corners[i].X1 = 0.0; + cps->corners[i].X2 = 0.0; + cps->corners[i].Y1 = 0.0; + cps->corners[i].Y2 = 0.0; + cps->regionlist[i].x1 = 0; + cps->regionlist[i].x2 = 0; + cps->regionlist[i].y1 = 0; + cps->regionlist[i].y2 = 0; + cps->regionlist[i].width = 0; + cps->regionlist[i].length = 0; + cps->regionlist[i].buffsize = 0; + cps->zonelist[i].position = 0; + cps->zonelist[i].total = 0; + } + cps->exp_mode = ONE_FILE_COMPOSITE; + cps->img_mode = COMPOSITE_IMAGES; + } static void initDumpOptions(struct dump_opts *dump) + { + dump->debug = 0; + dump->format = DUMP_NONE; + dump->level = 1; + sprintf (dump->mode, "w"); + memset (dump->infilename, '\0', PATH_MAX + 1); + memset (dump->outfilename, '\0',PATH_MAX + 1); + dump->infile = NULL; + dump->outfile = NULL; + } + +static uint32 _TIFFClampDoubleToUInt32(double val) { - dump->debug = 0; - dump->format = DUMP_NONE; - dump->level = 1; - sprintf(dump->mode, "w"); - memset(dump->infilename, '\0', PATH_MAX + 1); - memset(dump->outfilename, '\0', PATH_MAX + 1); - dump->infile = NULL; - dump->outfile = NULL; + if (val < 0) + return 0; + if (val > 0xFFFFFFFFU || val != val) + return 0xFFFFFFFFU; + return (uint32)val; } - /* Compute pixel offsets into the image for margins and fixed regions */ -static int computeInputPixelOffsets(struct crop_mask *crop, - struct image_data *image, - struct offset *off) -{ - double scale; - float xres, yres; - /* Values for these offsets are in pixels from start of image, not bytes, - * and are indexed from zero to width - 1 or length - 1 */ - uint32_t tmargin, bmargin, lmargin, rmargin; - uint32_t startx, endx; /* offsets of first and last columns to extract */ - uint32_t starty, endy; /* offsets of first and last row to extract */ - uint32_t width, length, crop_width, crop_length; - uint32_t i, max_width, max_length, zwidth, zlength, buffsize; - uint32_t x1, x2, y1, y2; +static int +computeInputPixelOffsets(struct crop_mask *crop, struct image_data *image, + struct offset *off) + { + double scale; + float xres, yres; + /* Values for these offsets are in pixels from start of image, not bytes, + * and are indexed from zero to width - 1 or length - 1 */ + uint32 tmargin, bmargin, lmargin, rmargin; + uint32 startx, endx; /* offsets of first and last columns to extract */ + uint32 starty, endy; /* offsets of first and last row to extract */ + uint32 width, length, crop_width, crop_length; + uint32 i, max_width, max_length, zwidth, zlength, buffsize; + uint32 x1, x2, y1, y2; - if (image->res_unit != RESUNIT_INCH && - image->res_unit != RESUNIT_CENTIMETER) + if (image->res_unit != RESUNIT_INCH && image->res_unit != RESUNIT_CENTIMETER) { - xres = 1.0; - yres = 1.0; + xres = 1.0; + yres = 1.0; } - else + else { - if (((image->xres == 0) || (image->yres == 0)) && - (crop->res_unit != RESUNIT_NONE) && - ((crop->crop_mode & CROP_REGIONS) || - (crop->crop_mode & CROP_MARGINS) || - (crop->crop_mode & CROP_LENGTH) || (crop->crop_mode & CROP_WIDTH))) + if (((image->xres == 0) || (image->yres == 0)) && + (crop->res_unit != RESUNIT_NONE) && + ((crop->crop_mode & CROP_REGIONS) || (crop->crop_mode & CROP_MARGINS) || + (crop->crop_mode & CROP_LENGTH) || (crop->crop_mode & CROP_WIDTH))) + { + TIFFError("computeInputPixelOffsets", "Cannot compute margins or fixed size sections without image resolution"); + TIFFError("computeInputPixelOffsets", "Specify units in pixels and try again"); + return (-1); + } + xres = image->xres; + yres = image->yres; + } + + /* Translate user units to image units */ + scale = 1.0; + switch (crop->res_unit) { + case RESUNIT_CENTIMETER: + if (image->res_unit == RESUNIT_INCH) + scale = 1.0/2.54; + break; + case RESUNIT_INCH: + if (image->res_unit == RESUNIT_CENTIMETER) + scale = 2.54; + break; + case RESUNIT_NONE: /* Dimensions in pixels */ + default: + break; + } + + if (crop->crop_mode & CROP_REGIONS) + { + max_width = max_length = 0; + for (i = 0; i < crop->regions; i++) + { + uint32 aux; + if ((crop->res_unit == RESUNIT_INCH) || (crop->res_unit == RESUNIT_CENTIMETER)) { - TIFFError("computeInputPixelOffsets", - "Cannot compute margins or fixed size sections without " - "image resolution"); - TIFFError("computeInputPixelOffsets", - "Specify units in pixels and try again"); - return (-1); + x1 = _TIFFClampDoubleToUInt32(crop->corners[i].X1 * scale * xres); + x2 = _TIFFClampDoubleToUInt32(crop->corners[i].X2 * scale * xres); + y1 = _TIFFClampDoubleToUInt32(crop->corners[i].Y1 * scale * yres); + y2 = _TIFFClampDoubleToUInt32(crop->corners[i].Y2 * scale * yres); } - xres = image->xres; - yres = image->yres; - } - - /* Translate user units to image units */ - scale = 1.0; - switch (crop->res_unit) - { - case RESUNIT_CENTIMETER: - if (image->res_unit == RESUNIT_INCH) - scale = 1.0 / 2.54; - break; - case RESUNIT_INCH: - if (image->res_unit == RESUNIT_CENTIMETER) - scale = 2.54; - break; - case RESUNIT_NONE: /* Dimensions in pixels */ - default: - break; - } - - if (crop->crop_mode & CROP_REGIONS) - { - max_width = max_length = 0; - for (i = 0; i < crop->regions; i++) + else { - if ((crop->res_unit == RESUNIT_INCH) || - (crop->res_unit == RESUNIT_CENTIMETER)) - { - x1 = _TIFFClampDoubleToUInt32(crop->corners[i].X1 * scale * - xres); - x2 = _TIFFClampDoubleToUInt32(crop->corners[i].X2 * scale * - xres); - y1 = _TIFFClampDoubleToUInt32(crop->corners[i].Y1 * scale * - yres); - y2 = _TIFFClampDoubleToUInt32(crop->corners[i].Y2 * scale * - yres); - } - else - { - x1 = _TIFFClampDoubleToUInt32(crop->corners[i].X1); - x2 = _TIFFClampDoubleToUInt32(crop->corners[i].X2); - y1 = _TIFFClampDoubleToUInt32(crop->corners[i].Y1); - y2 = _TIFFClampDoubleToUInt32(crop->corners[i].Y2); - } - /* a) Region needs to be within image sizes 0.. width-1; 0..length-1 - * b) Corners are expected to be submitted as top-left to - * bottom-right. Therefore, check that and reorder input. (be aware - * x,y are already casted to (uint32_t) and avoid (0 - 1) ) - */ - uint32_t aux; - if (x1 > x2) - { - aux = x1; - x1 = x2; - x2 = aux; - } - if (y1 > y2) - { - aux = y1; - y1 = y2; - y2 = aux; - } - if (x1 > image->width - 1) - crop->regionlist[i].x1 = image->width - 1; - else if (x1 > 0) - crop->regionlist[i].x1 = (uint32_t)(x1 - 1); + x1 = _TIFFClampDoubleToUInt32(crop->corners[i].X1); + x2 = _TIFFClampDoubleToUInt32(crop->corners[i].X2); + y1 = _TIFFClampDoubleToUInt32(crop->corners[i].Y1); + y2 = _TIFFClampDoubleToUInt32(crop->corners[i].Y2); + } + /* a) Region needs to be within image sizes 0.. width-1; 0..length-1 + * b) Corners are expected to be submitted as top-left to bottom-right. + * Therefore, check that and reorder input. + * (be aware x,y are already casted to (uint32) and avoid (0 - 1) ) + */ + if (x1 > x2) { + aux = x1; + x1 = x2; + x2 = aux; + } + if (y1 > y2) { + aux = y1; + y1 = y2; + y2 = aux; + } + if (x1 > image->width - 1) + crop->regionlist[i].x1 = image->width - 1; + else if (x1 > 0) + crop->regionlist[i].x1 = (uint32)(x1 - 1); - if (x2 > image->width - 1) - crop->regionlist[i].x2 = image->width - 1; - else if (x2 > 0) - crop->regionlist[i].x2 = (uint32_t)(x2 - 1); + if (x2 > image->width - 1) + crop->regionlist[i].x2 = image->width - 1; + else if (x2 > 0) + crop->regionlist[i].x2 = (uint32)(x2 - 1); - zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; + zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; - if (y1 > image->length - 1) - crop->regionlist[i].y1 = image->length - 1; - else if (y1 > 0) - crop->regionlist[i].y1 = (uint32_t)(y1 - 1); + if (y1 > image->length - 1) + crop->regionlist[i].y1 = image->length - 1; + else if (y1 > 0) + crop->regionlist[i].y1 = (uint32)(y1 - 1); - if (y2 > image->length - 1) - crop->regionlist[i].y2 = image->length - 1; - else if (y2 > 0) - crop->regionlist[i].y2 = (uint32_t)(y2 - 1); + if (y2 > image->length - 1) + crop->regionlist[i].y2 = image->length - 1; + else if (y2 > 0) + crop->regionlist[i].y2 = (uint32)(y2 - 1); - zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; - if (zwidth > max_width) - max_width = zwidth; - if (zlength > max_length) - max_length = zlength; + zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; + if (zwidth > max_width) + max_width = zwidth; + if (zlength > max_length) + max_length = zlength; - buffsize = (uint32_t)(((zwidth * image->bps * image->spp + 7) / 8) * - (zlength + 1)); + buffsize = (uint32) + (((zwidth * image->bps * image->spp + 7 ) / 8) * (zlength + 1)); - crop->regionlist[i].buffsize = buffsize; - crop->bufftotal += buffsize; + crop->regionlist[i].buffsize = buffsize; + crop->bufftotal += buffsize; - /* For composite images with more than one region, the - * combined_length or combined_width always needs to be equal, - * respectively. - * Otherwise, even the first section/region copy - * action might cause buffer overrun. */ - if (crop->img_mode == COMPOSITE_IMAGES) - { - switch (crop->edge_ref) + /* For composite images with more than one region, the + * combined_length or combined_width always needs to be equal, + * respectively. + * Otherwise, even the first section/region copy + * action might cause buffer overrun. */ + if (crop->img_mode == COMPOSITE_IMAGES) + { + switch (crop->edge_ref) + { + case EDGE_LEFT: + case EDGE_RIGHT: + if (i > 0 && zlength != crop->combined_length) + { + TIFFError( + "computeInputPixelOffsets", + "Only equal length regions can be combined for " + "-E left or right"); + return (-1); + } + crop->combined_length = zlength; + crop->combined_width += zwidth; + break; + case EDGE_BOTTOM: + case EDGE_TOP: /* width from left, length from top */ + default: + if (i > 0 && zwidth != crop->combined_width) { - case EDGE_LEFT: - case EDGE_RIGHT: - if (i > 0 && zlength != crop->combined_length) - { - TIFFError( - "computeInputPixelOffsets", - "Only equal length regions can be combined for " - "-E left or right"); - return (-1); - } - crop->combined_length = zlength; - crop->combined_width += zwidth; - break; - case EDGE_BOTTOM: - case EDGE_TOP: /* width from left, length from top */ - default: - if (i > 0 && zwidth != crop->combined_width) - { - TIFFError("computeInputPixelOffsets", - "Only equal width regions can be " - "combined for -E " - "top or bottom"); - return (-1); - } - crop->combined_width = zwidth; - crop->combined_length += zlength; - break; + TIFFError("computeInputPixelOffsets", + "Only equal width regions can be " + "combined for -E " + "top or bottom"); + return (-1); } - } - } - return (0); - } /* crop_mode == CROP_REGIONS */ - - /* Convert crop margins into offsets into image - * Margins are expressed as pixel rows and columns, not bytes - */ - if (crop->crop_mode & CROP_MARGINS) - { - if (crop->res_unit != RESUNIT_INCH && - crop->res_unit != RESUNIT_CENTIMETER) - { /* User has specified pixels as reference unit */ - tmargin = _TIFFClampDoubleToUInt32(crop->margins[0]); - lmargin = _TIFFClampDoubleToUInt32(crop->margins[1]); - bmargin = _TIFFClampDoubleToUInt32(crop->margins[2]); - rmargin = _TIFFClampDoubleToUInt32(crop->margins[3]); - } - else - { /* inches or centimeters specified */ - tmargin = _TIFFClampDoubleToUInt32(crop->margins[0] * scale * yres); - lmargin = _TIFFClampDoubleToUInt32(crop->margins[1] * scale * xres); - bmargin = _TIFFClampDoubleToUInt32(crop->margins[2] * scale * yres); - rmargin = _TIFFClampDoubleToUInt32(crop->margins[3] * scale * xres); - } - - if ((lmargin + rmargin) > image->width) - { - TIFFError("computeInputPixelOffsets", - "Combined left and right margins exceed image width"); - lmargin = (uint32_t)0; - rmargin = (uint32_t)0; - return (-1); - } - if ((tmargin + bmargin) > image->length) - { - TIFFError("computeInputPixelOffsets", - "Combined top and bottom margins exceed image length"); - tmargin = (uint32_t)0; - bmargin = (uint32_t)0; - return (-1); - } - } /* crop_mode == CROP_MARGINS */ - else - { /* no margins requested */ - tmargin = (uint32_t)0; - lmargin = (uint32_t)0; - bmargin = (uint32_t)0; - rmargin = (uint32_t)0; - } - - /* Width, height, and margins are expressed as pixel offsets into image */ - if (crop->res_unit != RESUNIT_INCH && crop->res_unit != RESUNIT_CENTIMETER) - { - if (crop->crop_mode & CROP_WIDTH) - width = _TIFFClampDoubleToUInt32(crop->width); - else - width = image->width - lmargin - rmargin; - - if (crop->crop_mode & CROP_LENGTH) - length = _TIFFClampDoubleToUInt32(crop->length); - else - length = image->length - tmargin - bmargin; - } - else - { - if (crop->crop_mode & CROP_WIDTH) - width = _TIFFClampDoubleToUInt32(crop->width * scale * image->xres); - else - width = image->width - lmargin - rmargin; - - if (crop->crop_mode & CROP_LENGTH) - length = - _TIFFClampDoubleToUInt32(crop->length * scale * image->yres); - else - length = image->length - tmargin - bmargin; - } - - off->tmargin = tmargin; - off->bmargin = bmargin; - off->lmargin = lmargin; - off->rmargin = rmargin; - - /* Calculate regions defined by margins, width, and length. - * Coordinates expressed as 0 to imagewidth - 1, imagelength - 1, - * since they are used to compute offsets into buffers */ - switch (crop->edge_ref) - { - case EDGE_BOTTOM: - startx = lmargin; - if ((startx + width) >= (image->width - rmargin)) - endx = image->width - rmargin - 1; - else - endx = startx + width - 1; - - endy = image->length - bmargin - 1; - if ((endy - length) <= tmargin) - starty = tmargin; - else - starty = endy - length + 1; - break; - case EDGE_RIGHT: - endx = image->width - rmargin - 1; - if ((endx - width) <= lmargin) - startx = lmargin; - else - startx = endx - width + 1; - - starty = tmargin; - if ((starty + length) >= (image->length - bmargin)) - endy = image->length - bmargin - 1; - else - endy = starty + length - 1; - break; - case EDGE_TOP: /* width from left, length from top */ - case EDGE_LEFT: - default: - startx = lmargin; - if ((startx + width) >= (image->width - rmargin)) - endx = image->width - rmargin - 1; - else - endx = startx + width - 1; - - starty = tmargin; - if ((starty + length) >= (image->length - bmargin)) - endy = image->length - bmargin - 1; - else - endy = starty + length - 1; - break; - } - off->startx = startx; - off->starty = starty; - off->endx = endx; - off->endy = endy; - - if (endx + 1 <= startx) - { - TIFFError( - "computeInputPixelOffsets", - "Invalid left/right margins and /or image crop width requested"); - return (-1); - } - crop_width = endx - startx + 1; - if (crop_width > image->width) - crop_width = image->width; - - if (endy + 1 <= starty) - { - TIFFError( - "computeInputPixelOffsets", - "Invalid top/bottom margins and /or image crop length requested"); - return (-1); - } - crop_length = endy - starty + 1; - if (crop_length > image->length) - crop_length = image->length; - - off->crop_width = crop_width; - off->crop_length = crop_length; - + crop->combined_width = zwidth; + crop->combined_length += zlength; + break; + } + } + } return (0); -} /* end computeInputPixelOffsets */ + } /* crop_mode == CROP_REGIONS */ + + /* Convert crop margins into offsets into image + * Margins are expressed as pixel rows and columns, not bytes + */ + if (crop->crop_mode & CROP_MARGINS) + { + if (crop->res_unit != RESUNIT_INCH && crop->res_unit != RESUNIT_CENTIMETER) + { /* User has specified pixels as reference unit */ + tmargin = _TIFFClampDoubleToUInt32(crop->margins[0]); + lmargin = _TIFFClampDoubleToUInt32(crop->margins[1]); + bmargin = _TIFFClampDoubleToUInt32(crop->margins[2]); + rmargin = _TIFFClampDoubleToUInt32(crop->margins[3]); + } + else + { /* inches or centimeters specified */ + tmargin = _TIFFClampDoubleToUInt32(crop->margins[0] * scale * yres); + lmargin = _TIFFClampDoubleToUInt32(crop->margins[1] * scale * xres); + bmargin = _TIFFClampDoubleToUInt32(crop->margins[2] * scale * yres); + rmargin = _TIFFClampDoubleToUInt32(crop->margins[3] * scale * xres); + } -/* - * Translate crop options into pixel offsets for one or more regions of the - * image. Options are applied in this order: margins, specific width and length, - * zones, but all are optional. Margins are relative to each edge. Width, length - * and zones are relative to the specified reference edge. Zones are expressed - * as X:Y where X is the ordinal value in a set of Y equal sized portions. eg. + if ((lmargin + rmargin) > image->width) + { + TIFFError("computeInputPixelOffsets", "Combined left and right margins exceed image width"); + lmargin = (uint32) 0; + rmargin = (uint32) 0; + return (-1); + } + if ((tmargin + bmargin) > image->length) + { + TIFFError("computeInputPixelOffsets", "Combined top and bottom margins exceed image length"); + tmargin = (uint32) 0; + bmargin = (uint32) 0; + return (-1); + } + } /* crop_mode == CROP_MARGINS */ + else + { /* no margins requested */ + tmargin = (uint32) 0; + lmargin = (uint32) 0; + bmargin = (uint32) 0; + rmargin = (uint32) 0; + } + + /* Width, height, and margins are expressed as pixel offsets into image */ + if (crop->res_unit != RESUNIT_INCH && crop->res_unit != RESUNIT_CENTIMETER) + { + if (crop->crop_mode & CROP_WIDTH) + width = _TIFFClampDoubleToUInt32(crop->width); + else + width = image->width - lmargin - rmargin; + + if (crop->crop_mode & CROP_LENGTH) + length = _TIFFClampDoubleToUInt32(crop->length); + else + length = image->length - tmargin - bmargin; + } + else + { + if (crop->crop_mode & CROP_WIDTH) + width = _TIFFClampDoubleToUInt32(crop->width * scale * image->xres); + else + width = image->width - lmargin - rmargin; + + if (crop->crop_mode & CROP_LENGTH) + length = _TIFFClampDoubleToUInt32(crop->length * scale * image->yres); + else + length = image->length - tmargin - bmargin; + } + + off->tmargin = tmargin; + off->bmargin = bmargin; + off->lmargin = lmargin; + off->rmargin = rmargin; + + /* Calculate regions defined by margins, width, and length. + * Coordinates expressed as 0 to imagewidth - 1, imagelength - 1, + * since they are used to compute offsets into buffers */ + switch (crop->edge_ref) { + case EDGE_BOTTOM: + startx = lmargin; + if ((startx + width) >= (image->width - rmargin)) + endx = image->width - rmargin - 1; + else + endx = startx + width - 1; + + endy = image->length - bmargin - 1; + if ((endy - length) <= tmargin) + starty = tmargin; + else + starty = endy - length + 1; + break; + case EDGE_RIGHT: + endx = image->width - rmargin - 1; + if ((endx - width) <= lmargin) + startx = lmargin; + else + startx = endx - width + 1; + + starty = tmargin; + if ((starty + length) >= (image->length - bmargin)) + endy = image->length - bmargin - 1; + else + endy = starty + length - 1; + break; + case EDGE_TOP: /* width from left, length from top */ + case EDGE_LEFT: + default: + startx = lmargin; + if ((startx + width) >= (image->width - rmargin)) + endx = image->width - rmargin - 1; + else + endx = startx + width - 1; + + starty = tmargin; + if ((starty + length) >= (image->length - bmargin)) + endy = image->length - bmargin - 1; + else + endy = starty + length - 1; + break; + } + off->startx = startx; + off->starty = starty; + off->endx = endx; + off->endy = endy; + + if (endx + 1 <= startx) + { + TIFFError("computeInputPixelOffsets", + "Invalid left/right margins and /or image crop width requested"); + return (-1); + } + crop_width = endx - startx + 1; + if (crop_width > image->width) + crop_width = image->width; + + if (endy + 1 <= starty) + { + TIFFError("computeInputPixelOffsets", + "Invalid top/bottom margins and /or image crop length requested"); + return (-1); + } + crop_length = endy - starty + 1; + if (crop_length > image->length) + crop_length = image->length; + + off->crop_width = crop_width; + off->crop_length = crop_length; + + return (0); + } /* end computeInputPixelOffsets */ + +/* + * Translate crop options into pixel offsets for one or more regions of the image. + * Options are applied in this order: margins, specific width and length, zones, + * but all are optional. Margins are relative to each edge. Width, length and + * zones are relative to the specified reference edge. Zones are expressed as + * X:Y where X is the ordinal value in a set of Y equal sized portions. eg. * 2:3 would indicate the middle third of the region qualified by margins and * any explicit width and length specified. Regions are specified by coordinates * of the top left and lower right corners with range 1 to width or height. */ -static int getCropOffsets(struct image_data *image, struct crop_mask *crop, - struct dump_opts *dump) -{ - struct offset offsets; - int i; - uint32_t uaux; - uint32_t seg, total, need_buff = 0; - uint32_t buffsize; - uint32_t zwidth, zlength; +static int +getCropOffsets(struct image_data *image, struct crop_mask *crop, struct dump_opts *dump) + { + struct offset offsets; + int i,j; + int32 test; + uint32 seg, total, need_buff = 0; + uint32 buffsize; + uint32 zwidth, zlength; - memset(&offsets, '\0', sizeof(struct offset)); - crop->bufftotal = 0; - crop->combined_width = (uint32_t)0; - crop->combined_length = (uint32_t)0; - crop->selections = 0; + memset(&offsets, '\0', sizeof(struct offset)); + crop->bufftotal = 0; + crop->combined_width = (uint32)0; + crop->combined_length = (uint32)0; + crop->selections = 0; - /* Compute pixel offsets if margins or fixed width or length specified */ - if ((crop->crop_mode & CROP_MARGINS) || (crop->crop_mode & CROP_REGIONS) || - (crop->crop_mode & CROP_LENGTH) || (crop->crop_mode & CROP_WIDTH)) + /* Compute pixel offsets if margins or fixed width or length specified */ + if ((crop->crop_mode & CROP_MARGINS) || + (crop->crop_mode & CROP_REGIONS) || + (crop->crop_mode & CROP_LENGTH) || + (crop->crop_mode & CROP_WIDTH)) { - if (computeInputPixelOffsets(crop, image, &offsets)) - { - TIFFError("getCropOffsets", "Unable to compute crop margins"); - return (-1); - } - need_buff = TRUE; - crop->selections = crop->regions; - /* Regions are only calculated from top and left edges with no margins - */ - if (crop->crop_mode & CROP_REGIONS) - return (0); + if (computeInputPixelOffsets(crop, image, &offsets)) + { + TIFFError ("getCropOffsets", "Unable to compute crop margins"); + return (-1); + } + need_buff = TRUE; + crop->selections = crop->regions; + /* Regions are only calculated from top and left edges with no margins */ + if (crop->crop_mode & CROP_REGIONS) + return (0); } - else + else { /* cropped area is the full image */ - offsets.tmargin = 0; - offsets.lmargin = 0; - offsets.bmargin = 0; - offsets.rmargin = 0; - offsets.crop_width = image->width; - offsets.crop_length = image->length; - offsets.startx = 0; - offsets.endx = image->width - 1; - offsets.starty = 0; - offsets.endy = image->length - 1; - need_buff = FALSE; + offsets.tmargin = 0; + offsets.lmargin = 0; + offsets.bmargin = 0; + offsets.rmargin = 0; + offsets.crop_width = image->width; + offsets.crop_length = image->length; + offsets.startx = 0; + offsets.endx = image->width - 1; + offsets.starty = 0; + offsets.endy = image->length - 1; + need_buff = FALSE; } - if (dump->outfile != NULL) + if (dump->outfile != NULL) { - dump_info(dump->outfile, dump->format, "", - "Margins: Top: %" PRIu32 " Left: %" PRIu32 - " Bottom: %" PRIu32 " Right: %" PRIu32, - offsets.tmargin, offsets.lmargin, offsets.bmargin, - offsets.rmargin); - dump_info(dump->outfile, dump->format, "", - "Crop region within margins: Adjusted Width: %6" PRIu32 - " Length: %6" PRIu32, - offsets.crop_width, offsets.crop_length); + dump_info (dump->outfile, dump->format, "", "Margins: Top: %d Left: %d Bottom: %d Right: %d", + offsets.tmargin, offsets.lmargin, offsets.bmargin, offsets.rmargin); + dump_info (dump->outfile, dump->format, "", "Crop region within margins: Adjusted Width: %6d Length: %6d", + offsets.crop_width, offsets.crop_length); } - if (!(crop->crop_mode & CROP_ZONES)) /* no crop zones requested */ + if (!(crop->crop_mode & CROP_ZONES)) /* no crop zones requested */ { - if (need_buff == FALSE) /* No margins or fixed width or length areas */ - { - crop->selections = 0; - crop->combined_width = image->width; - crop->combined_length = image->length; - return (0); - } - else - { - /* Use one region for margins and fixed width or length areas - * even though it was not formally declared as a region. - */ - crop->selections = 1; - crop->zones = 1; - crop->zonelist[0].total = 1; - crop->zonelist[0].position = 1; - } + if (need_buff == FALSE) /* No margins or fixed width or length areas */ + { + crop->selections = 0; + crop->combined_width = image->width; + crop->combined_length = image->length; + return (0); + } + else + { + /* Use one region for margins and fixed width or length areas + * even though it was not formally declared as a region. + */ + crop->selections = 1; + crop->zones = 1; + crop->zonelist[0].total = 1; + crop->zonelist[0].position = 1; + } + } + else + crop->selections = crop->zones; + + /* Initialize regions iterator i */ + i = 0; + for (j = 0; j < crop->zones; j++) + { + seg = crop->zonelist[j].position; + total = crop->zonelist[j].total; + + /* check for not allowed zone cases like 0:0; 4:3; etc. and skip that input */ + if (seg == 0 || total == 0 || seg > total) { + continue; } - else - crop->selections = crop->zones; - /* Initialize regions iterator i */ - i = 0; - for (int j = 0; j < crop->zones; j++) - { - seg = crop->zonelist[j].position; - total = crop->zonelist[j].total; + switch (crop->edge_ref) + { + case EDGE_LEFT: /* zones from left to right, length from top */ + zlength = offsets.crop_length; + crop->regionlist[i].y1 = offsets.starty; + crop->regionlist[i].y2 = offsets.endy; - /* check for not allowed zone cases like 0:0; 4:3; or negative ones etc. - * and skip that input */ - if (crop->zonelist[j].position < 0 || crop->zonelist[j].total < 0) - { - TIFFError("getCropOffsets", - "Negative crop zone values %d:%d are not allowed, thus " - "skipped.", - crop->zonelist[j].position, crop->zonelist[j].total); - continue; - } - if (seg == 0 || total == 0 || seg > total) - { - TIFFError("getCropOffsets", - "Crop zone %d:%d is out of specification, thus skipped.", - seg, total); - continue; - } + crop->regionlist[i].x1 = offsets.startx + + (uint32)(offsets.crop_width * 1.0 * (seg - 1) / total); + test = (int32)offsets.startx + + (int32)(offsets.crop_width * 1.0 * seg / total); + if (test < 1 ) + crop->regionlist[i].x2 = 0; + else + { + if (test > (int32)(image->width - 1)) + crop->regionlist[i].x2 = image->width - 1; + else + crop->regionlist[i].x2 = test - 1; + } + zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; - switch (crop->edge_ref) - { - case EDGE_LEFT: /* zones from left to right, length from top */ - zlength = offsets.crop_length; - crop->regionlist[i].y1 = offsets.starty; - crop->regionlist[i].y2 = offsets.endy; + /* This is passed to extractCropZone or extractCompositeZones */ + crop->combined_length = (uint32)zlength; + if (crop->exp_mode == COMPOSITE_IMAGES) + crop->combined_width += (uint32)zwidth; + else + crop->combined_width = (uint32)zwidth; + break; + case EDGE_BOTTOM: /* width from left, zones from bottom to top */ + zwidth = offsets.crop_width; + crop->regionlist[i].x1 = offsets.startx; + crop->regionlist[i].x2 = offsets.endx; - crop->regionlist[i].x1 = - offsets.startx + - (uint32_t)(offsets.crop_width * 1.0 * (seg - 1) / total); - /* FAULT: IMHO in the old code here, the calculation of x2 was - * based on wrong assumtions. The whole image was assumed and - * 'endy' and 'starty' are not respected anymore!*/ - /* NEW PROPOSED Code: Assumption: offsets are within image with - * top left corner as origin (0,0) and 'start' <= 'end'. */ - if (crop->regionlist[i].x1 > offsets.endx) - { - crop->regionlist[i].x1 = offsets.endx; - } - else if (crop->regionlist[i].x1 >= image->width) - { - crop->regionlist[i].x1 = image->width - 1; - } + test = offsets.endy - (uint32)(offsets.crop_length * 1.0 * seg / total); + if (test < 1 ) + crop->regionlist[i].y1 = 0; + else + crop->regionlist[i].y1 = test + 1; - crop->regionlist[i].x2 = - offsets.startx + - (uint32_t)(offsets.crop_width * 1.0 * seg / total); - if (crop->regionlist[i].x2 > 0) - crop->regionlist[i].x2 = crop->regionlist[i].x2 - 1; - if (crop->regionlist[i].x2 < crop->regionlist[i].x1) - { - crop->regionlist[i].x2 = crop->regionlist[i].x1; - } - else if (crop->regionlist[i].x2 > offsets.endx) - { - crop->regionlist[i].x2 = offsets.endx; - } - else if (crop->regionlist[i].x2 >= image->width) - { - crop->regionlist[i].x2 = image->width - 1; - } - zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; + test = offsets.endy - (offsets.crop_length * 1.0 * (seg - 1) / total); + if (test < 1 ) + crop->regionlist[i].y2 = 0; + else + { + if (test > (int32)(image->length - 1)) + crop->regionlist[i].y2 = image->length - 1; + else + crop->regionlist[i].y2 = test; + } + zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; - /* This is passed to extractCropZone or extractCompositeZones */ - crop->combined_length = (uint32_t)zlength; - if (crop->exp_mode == COMPOSITE_IMAGES) - crop->combined_width += (uint32_t)zwidth; - else - crop->combined_width = (uint32_t)zwidth; - break; - case EDGE_BOTTOM: /* width from left, zones from bottom to top */ - zwidth = offsets.crop_width; - crop->regionlist[i].x1 = offsets.startx; - crop->regionlist[i].x2 = offsets.endx; + /* This is passed to extractCropZone or extractCompositeZones */ + if (crop->exp_mode == COMPOSITE_IMAGES) + crop->combined_length += (uint32)zlength; + else + crop->combined_length = (uint32)zlength; + crop->combined_width = (uint32)zwidth; + break; + case EDGE_RIGHT: /* zones from right to left, length from top */ + zlength = offsets.crop_length; + crop->regionlist[i].y1 = offsets.starty; + crop->regionlist[i].y2 = offsets.endy; - /* FAULT: IMHO in the old code here, the calculation of y1/y2 - * was based on wrong assumtions. The whole image was assumed - * and 'endy' and 'starty' are not respected anymore!*/ - /* NEW PROPOSED Code: Assumption: offsets are within image with - * top left corner as origin (0,0) and 'start' <= 'end'. */ - uaux = (uint32_t)(offsets.crop_length * 1.0 * seg / total); - if (uaux <= offsets.endy + 1) - { - crop->regionlist[i].y1 = offsets.endy - uaux + 1; - } - else - { - crop->regionlist[i].y1 = 0; - } - if (crop->regionlist[i].y1 < offsets.starty) - { - crop->regionlist[i].y1 = offsets.starty; - } + crop->regionlist[i].x1 = offsets.startx + + (uint32)(offsets.crop_width * (total - seg) * 1.0 / total); + test = offsets.startx + + (offsets.crop_width * (total - seg + 1) * 1.0 / total); + if (test < 1 ) + crop->regionlist[i].x2 = 0; + else + { + if (test > (int32)(image->width - 1)) + crop->regionlist[i].x2 = image->width - 1; + else + crop->regionlist[i].x2 = test - 1; + } + zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; - uaux = - (uint32_t)(offsets.crop_length * 1.0 * (seg - 1) / total); - if (uaux <= offsets.endy) - { - crop->regionlist[i].y2 = offsets.endy - uaux; - } - else - { - crop->regionlist[i].y2 = 0; - } - if (crop->regionlist[i].y2 < offsets.starty) - { - crop->regionlist[i].y2 = offsets.starty; - } - zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; + /* This is passed to extractCropZone or extractCompositeZones */ + crop->combined_length = (uint32)zlength; + if (crop->exp_mode == COMPOSITE_IMAGES) + crop->combined_width += (uint32)zwidth; + else + crop->combined_width = (uint32)zwidth; + break; + case EDGE_TOP: /* width from left, zones from top to bottom */ + default: + zwidth = offsets.crop_width; + crop->regionlist[i].x1 = offsets.startx; + crop->regionlist[i].x2 = offsets.endx; - /* This is passed to extractCropZone or extractCompositeZones */ - if (crop->exp_mode == COMPOSITE_IMAGES) - crop->combined_length += (uint32_t)zlength; - else - crop->combined_length = (uint32_t)zlength; - crop->combined_width = (uint32_t)zwidth; - break; - case EDGE_RIGHT: /* zones from right to left, length from top */ - zlength = offsets.crop_length; - crop->regionlist[i].y1 = offsets.starty; - crop->regionlist[i].y2 = offsets.endy; + crop->regionlist[i].y1 = offsets.starty + (uint32)(offsets.crop_length * 1.0 * (seg - 1) / total); + test = offsets.starty + (uint32)(offsets.crop_length * 1.0 * seg / total); + if (test < 1 ) + crop->regionlist[i].y2 = 0; + else + { + if (test > (int32)(image->length - 1)) + crop->regionlist[i].y2 = image->length - 1; + else + crop->regionlist[i].y2 = test - 1; + } + zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; - crop->regionlist[i].x1 = - offsets.startx + (uint32_t)(offsets.crop_width * - (total - seg) * 1.0 / total); - /* FAULT: IMHO from here on, the calculation of y2 are based on - * wrong assumtions. The whole image is assumed and 'endy' and - * 'starty' are not respected anymore!*/ - /* NEW PROPOSED Code: Assumption: offsets are within image with - * top left corner as origin (0,0) and 'start' <= 'end'. */ - uaux = (uint32_t)(offsets.crop_width * 1.0 * seg / total); - if (uaux <= offsets.endx + 1) - { - crop->regionlist[i].x1 = offsets.endx - uaux + 1; - } - else - { - crop->regionlist[i].x1 = 0; - } - if (crop->regionlist[i].x1 < offsets.startx) - { - crop->regionlist[i].x1 = offsets.startx; - } + /* This is passed to extractCropZone or extractCompositeZones */ + if (crop->exp_mode == COMPOSITE_IMAGES) + crop->combined_length += (uint32)zlength; + else + crop->combined_length = (uint32)zlength; + crop->combined_width = (uint32)zwidth; + break; + } /* end switch statement */ - uaux = (uint32_t)(offsets.crop_width * 1.0 * (seg - 1) / total); - if (uaux <= offsets.endx) - { - crop->regionlist[i].x2 = offsets.endx - uaux; - } - else - { - crop->regionlist[i].x2 = 0; - } - if (crop->regionlist[i].x2 < offsets.startx) - { - crop->regionlist[i].x2 = offsets.startx; - } - zwidth = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; + buffsize = (uint32) + ((((zwidth * image->bps * image->spp) + 7 ) / 8) * (zlength + 1)); + crop->regionlist[i].width = (uint32) zwidth; + crop->regionlist[i].length = (uint32) zlength; + crop->regionlist[i].buffsize = buffsize; + crop->bufftotal += buffsize; - /* This is passed to extractCropZone or extractCompositeZones */ - crop->combined_length = (uint32_t)zlength; - if (crop->exp_mode == COMPOSITE_IMAGES) - crop->combined_width += (uint32_t)zwidth; - else - crop->combined_width = (uint32_t)zwidth; - break; - case EDGE_TOP: /* width from left, zones from top to bottom */ - default: - zwidth = offsets.crop_width; - crop->regionlist[i].x1 = offsets.startx; - crop->regionlist[i].x2 = offsets.endx; - crop->regionlist[i].y1 = - offsets.starty + - (uint32_t)(offsets.crop_length * 1.0 * (seg - 1) / total); - if (crop->regionlist[i].y1 > offsets.endy) - { - crop->regionlist[i].y1 = offsets.endy; - } - else if (crop->regionlist[i].y1 >= image->length) - { - crop->regionlist[i].y1 = image->length - 1; - } - - /* FAULT: IMHO from here on, the calculation of y2 are based on - * wrong assumtions. The whole image is assumed and 'endy' and - * 'starty' are not respected anymore!*/ - /* OLD Code: - test = offsets.starty + (uint32_t)(offsets.crop_length * 1.0 * - seg / total); if (test < 1 ) crop->regionlist[i].y2 = 0; else - { - if (test > (int32_t)(image->length - 1)) - crop->regionlist[i].y2 = image->length - 1; - else - crop->regionlist[i].y2 = test - 1; - } - */ - /* NEW PROPOSED Code: Assumption: offsets are within image with - * top left corner as origin (0,0) and 'start' <= 'end'. */ - crop->regionlist[i].y2 = - offsets.starty + - (uint32_t)(offsets.crop_length * 1.0 * seg / total); - if (crop->regionlist[i].y2 > 0) - crop->regionlist[i].y2 = crop->regionlist[i].y2 - 1; - if (crop->regionlist[i].y2 < crop->regionlist[i].y1) - { - crop->regionlist[i].y2 = crop->regionlist[i].y1; - } - else if (crop->regionlist[i].y2 > offsets.endy) - { - crop->regionlist[i].y2 = offsets.endy; - } - else if (crop->regionlist[i].y2 >= image->length) - { - crop->regionlist[i].y2 = image->length - 1; - } - - zlength = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; - - /* This is passed to extractCropZone or extractCompositeZones */ - if (crop->exp_mode == COMPOSITE_IMAGES) - crop->combined_length += (uint32_t)zlength; - else - crop->combined_length = (uint32_t)zlength; - crop->combined_width = (uint32_t)zwidth; - break; - } /* end switch statement */ - - buffsize = (uint32_t)((((zwidth * image->bps * image->spp) + 7) / 8) * - (zlength + 1)); - crop->regionlist[i].width = (uint32_t)zwidth; - crop->regionlist[i].length = (uint32_t)zlength; - crop->regionlist[i].buffsize = buffsize; - crop->bufftotal += buffsize; - - if (dump->outfile != NULL) - dump_info(dump->outfile, dump->format, "", - "Zone %d, width: %4" PRIu32 ", length: %4" PRIu32 - ", x1: %4" PRIu32 " x2: %4" PRIu32 " y1: %4" PRIu32 - " y2: %4" PRIu32, - i + 1, zwidth, zlength, crop->regionlist[i].x1, - crop->regionlist[i].x2, crop->regionlist[i].y1, - crop->regionlist[i].y2); - /* increment regions iterator */ - i++; + if (dump->outfile != NULL) + dump_info (dump->outfile, dump->format, "", "Zone %d, width: %4d, length: %4d, x1: %4d x2: %4d y1: %4d y2: %4d", + i + 1, (uint32)zwidth, (uint32)zlength, + crop->regionlist[i].x1, crop->regionlist[i].x2, + crop->regionlist[i].y1, crop->regionlist[i].y2); + /* increment regions iterator */ + i++; } /* set number of generated regions out of given zones */ crop->selections = i; - return (0); -} /* end getCropOffsets */ + return (0); + } /* end getCropOffsets */ -static int computeOutputPixelOffsets(struct crop_mask *crop, - struct image_data *image, - struct pagedef *page, - struct pageseg *sections, - struct dump_opts *dump) -{ - double scale; - double pwidth, plength; /* Output page width and length in user units*/ - uint32_t iwidth, ilength; /* Input image width and length in pixels*/ - uint32_t owidth, olength; /* Output image width and length in pixels*/ - uint32_t orows, ocols; /* rows and cols for output */ - uint32_t hmargin, vmargin; /* Horizontal and vertical margins */ - uint32_t x1, x2, y1, y2, line_bytes; - /* unsigned int orientation; */ - uint32_t i, j, k; - scale = 1.0; - if (page->res_unit == RESUNIT_NONE) - page->res_unit = image->res_unit; +static int +computeOutputPixelOffsets (struct crop_mask *crop, struct image_data *image, + struct pagedef *page, struct pageseg *sections, + struct dump_opts* dump) + { + double scale; + double pwidth, plength; /* Output page width and length in user units*/ + uint32 iwidth, ilength; /* Input image width and length in pixels*/ + uint32 owidth, olength; /* Output image width and length in pixels*/ + uint32 orows, ocols; /* rows and cols for output */ + uint32 hmargin, vmargin; /* Horizontal and vertical margins */ + uint32 x1, x2, y1, y2, line_bytes; + /* unsigned int orientation; */ + uint32 i, j, k; + + scale = 1.0; + if (page->res_unit == RESUNIT_NONE) + page->res_unit = image->res_unit; - switch (image->res_unit) - { - case RESUNIT_CENTIMETER: - if (page->res_unit == RESUNIT_INCH) - scale = 1.0 / 2.54; - break; - case RESUNIT_INCH: - if (page->res_unit == RESUNIT_CENTIMETER) - scale = 2.54; - break; - case RESUNIT_NONE: /* Dimensions in pixels */ - default: - break; + switch (image->res_unit) { + case RESUNIT_CENTIMETER: + if (page->res_unit == RESUNIT_INCH) + scale = 1.0/2.54; + break; + case RESUNIT_INCH: + if (page->res_unit == RESUNIT_CENTIMETER) + scale = 2.54; + break; + case RESUNIT_NONE: /* Dimensions in pixels */ + default: + break; } - /* get width, height, resolutions of input image selection */ - if (crop->combined_width > 0) - iwidth = crop->combined_width; - else - iwidth = image->width; - if (crop->combined_length > 0) - ilength = crop->combined_length; - else - ilength = image->length; + /* get width, height, resolutions of input image selection */ + if (crop->combined_width > 0) + iwidth = crop->combined_width; + else + iwidth = image->width; + if (crop->combined_length > 0) + ilength = crop->combined_length; + else + ilength = image->length; - if (page->hres <= 1.0) - page->hres = image->xres; - if (page->vres <= 1.0) - page->vres = image->yres; + if (page->hres <= 1.0) + page->hres = image->xres; + if (page->vres <= 1.0) + page->vres = image->yres; - if ((page->hres < 1.0) || (page->vres < 1.0)) + if ((page->hres < 1.0) || (page->vres < 1.0)) { - TIFFError("computeOutputPixelOffsets", - "Invalid horizontal or vertical resolution specified or read " - "from input image"); - return (1); + TIFFError("computeOutputPixelOffsets", + "Invalid horizontal or vertical resolution specified or read from input image"); + return (1); } - /* If no page sizes are being specified, we just use the input image size to - * calculate maximum margins that can be taken from image. - */ - if (page->width <= 0) - pwidth = iwidth; - else - pwidth = page->width; + /* If no page sizes are being specified, we just use the input image size to + * calculate maximum margins that can be taken from image. + */ + if (page->width <= 0) + pwidth = iwidth; + else + pwidth = page->width; - if (page->length <= 0) - plength = ilength; - else - plength = page->length; + if (page->length <= 0) + plength = ilength; + else + plength = page->length; - if (dump->debug) + if (dump->debug) { - TIFFError("", - "Page size: %s, Vres: %3.2f, Hres: %3.2f, " - "Hmargin: %3.2f, Vmargin: %3.2f", - page->name, page->vres, page->hres, page->hmargin, - page->vmargin); - TIFFError("", - "Res_unit: %" PRIu16 - ", Scale: %3.2f, Page width: %3.2f, length: %3.2f", - page->res_unit, scale, pwidth, plength); + TIFFError("", "Page size: %s, Vres: %3.2f, Hres: %3.2f, " + "Hmargin: %3.2f, Vmargin: %3.2f", + page->name, page->vres, page->hres, + page->hmargin, page->vmargin); + TIFFError("", "Res_unit: %d, Scale: %3.2f, Page width: %3.2f, length: %3.2f", + page->res_unit, scale, pwidth, plength); } - /* compute margins at specified unit and resolution */ + /* compute margins at specified unit and resolution */ + if (page->mode & PAGE_MODE_MARGINS) + { + if (page->res_unit == RESUNIT_INCH || page->res_unit == RESUNIT_CENTIMETER) + { /* inches or centimeters specified */ + hmargin = _TIFFClampDoubleToUInt32(page->hmargin * scale * page->hres * ((image->bps + 7) / 8)); + vmargin = _TIFFClampDoubleToUInt32(page->vmargin * scale * page->vres * ((image->bps + 7) / 8)); + } + else + { /* Otherwise user has specified pixels as reference unit */ + hmargin = _TIFFClampDoubleToUInt32(page->hmargin * scale * ((image->bps + 7) / 8)); + vmargin = _TIFFClampDoubleToUInt32(page->vmargin * scale * ((image->bps + 7) / 8)); + } + + if ((hmargin * 2.0) > (pwidth * page->hres)) + { + TIFFError("computeOutputPixelOffsets", + "Combined left and right margins exceed page width"); + hmargin = (uint32) 0; + return (-1); + } + if ((vmargin * 2.0) > (plength * page->vres)) + { + TIFFError("computeOutputPixelOffsets", + "Combined top and bottom margins exceed page length"); + vmargin = (uint32) 0; + return (-1); + } + } + else + { + hmargin = 0; + vmargin = 0; + } + + if (page->mode & PAGE_MODE_ROWSCOLS ) + { + /* Maybe someday but not for now */ if (page->mode & PAGE_MODE_MARGINS) - { - if (page->res_unit == RESUNIT_INCH || - page->res_unit == RESUNIT_CENTIMETER) - { /* inches or centimeters specified */ - hmargin = _TIFFClampDoubleToUInt32( - page->hmargin * scale * page->hres * ((image->bps + 7) / 8)); - vmargin = _TIFFClampDoubleToUInt32( - page->vmargin * scale * page->vres * ((image->bps + 7) / 8)); - } - else - { /* Otherwise user has specified pixels as reference unit */ - hmargin = _TIFFClampDoubleToUInt32(page->hmargin * scale * - ((image->bps + 7) / 8)); - vmargin = _TIFFClampDoubleToUInt32(page->vmargin * scale * - ((image->bps + 7) / 8)); - } + TIFFError("computeOutputPixelOffsets", + "Output margins cannot be specified with rows and columns"); - if ((hmargin * 2.0) > (pwidth * page->hres)) - { - TIFFError("computeOutputPixelOffsets", - "Combined left and right margins exceed page width"); - hmargin = (uint32_t)0; - return (-1); - } - if ((vmargin * 2.0) > (plength * page->vres)) - { - TIFFError("computeOutputPixelOffsets", - "Combined top and bottom margins exceed page length"); - vmargin = (uint32_t)0; - return (-1); - } + owidth = TIFFhowmany(iwidth, page->cols); + olength = TIFFhowmany(ilength, page->rows); } + else + { + if (page->mode & PAGE_MODE_PAPERSIZE ) + { + owidth = _TIFFClampDoubleToUInt32((pwidth * page->hres) - (hmargin * 2)); + olength = _TIFFClampDoubleToUInt32((plength * page->vres) - (vmargin * 2)); + } else - { - hmargin = 0; - vmargin = 0; + { + owidth = _TIFFClampDoubleToUInt32(iwidth - (hmargin * 2 * page->hres)); + olength = _TIFFClampDoubleToUInt32(ilength - (vmargin * 2 * page->vres)); + } } - if (page->mode & PAGE_MODE_ROWSCOLS) - { - /* Maybe someday but not for now */ - if (page->mode & PAGE_MODE_MARGINS) - TIFFError( - "computeOutputPixelOffsets", - "Output margins cannot be specified with rows and columns"); + if (owidth > iwidth) + owidth = iwidth; + if (olength > ilength) + olength = ilength; - owidth = TIFFhowmany(iwidth, page->cols); - olength = TIFFhowmany(ilength, page->rows); - } - else + if (owidth == 0 || olength == 0) + { + TIFFError("computeOutputPixelOffsets", "Integer overflow when calculating the number of pages"); + exit(EXIT_FAILURE); + } + + /* Compute the number of pages required for Portrait or Landscape */ + switch (page->orient) { - if (page->mode & PAGE_MODE_PAPERSIZE) - { - owidth = - _TIFFClampDoubleToUInt32((pwidth * page->hres) - (hmargin * 2)); - olength = _TIFFClampDoubleToUInt32((plength * page->vres) - - (vmargin * 2)); - } - else - { - owidth = - _TIFFClampDoubleToUInt32(iwidth - (hmargin * 2 * page->hres)); - olength = - _TIFFClampDoubleToUInt32(ilength - (vmargin * 2 * page->vres)); - } + case ORIENTATION_NONE: + case ORIENTATION_PORTRAIT: + ocols = TIFFhowmany(iwidth, owidth); + orows = TIFFhowmany(ilength, olength); + /* orientation = ORIENTATION_PORTRAIT; */ + break; + + case ORIENTATION_LANDSCAPE: + ocols = TIFFhowmany(iwidth, olength); + orows = TIFFhowmany(ilength, owidth); + x1 = olength; + olength = owidth; + owidth = x1; + /* orientation = ORIENTATION_LANDSCAPE; */ + break; + + case ORIENTATION_AUTO: + default: + x1 = TIFFhowmany(iwidth, owidth); + x2 = TIFFhowmany(ilength, olength); + y1 = TIFFhowmany(iwidth, olength); + y2 = TIFFhowmany(ilength, owidth); + + if ( (x1 * x2) < (y1 * y2)) + { /* Portrait */ + ocols = x1; + orows = x2; + /* orientation = ORIENTATION_PORTRAIT; */ + } + else + { /* Landscape */ + ocols = y1; + orows = y2; + x1 = olength; + olength = owidth; + owidth = x1; + /* orientation = ORIENTATION_LANDSCAPE; */ + } } - if (owidth > iwidth) - owidth = iwidth; - if (olength > ilength) - olength = ilength; + if (ocols < 1) + ocols = 1; + if (orows < 1) + orows = 1; - if (owidth == 0 || olength == 0) - { - TIFFError("computeOutputPixelOffsets", - "Integer overflow when calculating the number of pages"); - exit(EXIT_FAILURE); - } - - /* Compute the number of pages required for Portrait or Landscape */ - switch (page->orient) - { - case ORIENTATION_NONE: - case ORIENTATION_PORTRAIT: - ocols = TIFFhowmany(iwidth, owidth); - orows = TIFFhowmany(ilength, olength); - /* orientation = ORIENTATION_PORTRAIT; */ - break; - - case ORIENTATION_LANDSCAPE: - ocols = TIFFhowmany(iwidth, olength); - orows = TIFFhowmany(ilength, owidth); - x1 = olength; - olength = owidth; - owidth = x1; - /* orientation = ORIENTATION_LANDSCAPE; */ - break; - - case ORIENTATION_AUTO: - default: - x1 = TIFFhowmany(iwidth, owidth); - x2 = TIFFhowmany(ilength, olength); - y1 = TIFFhowmany(iwidth, olength); - y2 = TIFFhowmany(ilength, owidth); - - if ((x1 * x2) < (y1 * y2)) - { /* Portrait */ - ocols = x1; - orows = x2; - /* orientation = ORIENTATION_PORTRAIT; */ - } - else - { /* Landscape */ - ocols = y1; - orows = y2; - x1 = olength; - olength = owidth; - owidth = x1; - /* orientation = ORIENTATION_LANDSCAPE; */ - } - } - - if (ocols < 1) - ocols = 1; - if (orows < 1) - orows = 1; - - /* Always return rows and cols from calcuation above. - * (correct values needed external to this function) - * Warn, if user input settings has been changed. - */ - - if ((page->rows > 0) && (page->rows != orows)) - { - TIFFError("computeOutputPixelOffsets", - "Number of user input section rows down (%" PRIu32 - ") was changed to (%" PRIu32 ")", - page->rows, orows); - } + /* If user did not specify rows and cols, set them from calcuation */ + if (page->rows < 1) page->rows = orows; - if ((page->cols > 0) && (page->cols != ocols)) - { - TIFFError("computeOutputPixelOffsets", - "Number of user input section cols across (%" PRIu32 - ") was changed to (%" PRIu32 ")", - page->cols, ocols); - } + if (page->cols < 1) page->cols = ocols; - line_bytes = TIFFhowmany8(owidth * image->spp * image->bps); + line_bytes = TIFFhowmany8(owidth * image->bps) * image->spp; - if ((orows * ocols) > MAX_SECTIONS) + if ((page->rows * page->cols) > MAX_SECTIONS) + { + TIFFError("computeOutputPixelOffsets", + "Rows and Columns exceed maximum sections\nIncrease resolution or reduce sections"); + return (-1); + } + + /* build the list of offsets for each output section */ + for (k = 0, i = 0 && k <= MAX_SECTIONS; i < orows; i++) { - TIFFError("computeOutputPixelOffsets", - "Rows and Columns exceed maximum sections\nIncrease " - "resolution or reduce sections"); - return (-1); - } + y1 = (uint32)(olength * i); + y2 = (uint32)(olength * (i + 1) - 1); + if (y2 >= ilength) + y2 = ilength - 1; + for (j = 0; j < ocols; j++, k++) + { + x1 = (uint32)(owidth * j); + x2 = (uint32)(owidth * (j + 1) - 1); + if (x2 >= iwidth) + x2 = iwidth - 1; + sections[k].x1 = x1; + sections[k].x2 = x2; + sections[k].y1 = y1; + sections[k].y2 = y2; + sections[k].buffsize = line_bytes * olength; + sections[k].position = k + 1; + sections[k].total = orows * ocols; + } + } + return (0); + } /* end computeOutputPixelOffsets */ - /* build the list of offsets for each output section */ - for (k = 0, i = 0; i < orows; i++) - { - y1 = (uint32_t)(olength * i); - y2 = (uint32_t)(olength * (i + 1) - 1); - if (y2 >= ilength) - y2 = ilength - 1; - for (j = 0; (j < ocols) && (k < MAX_SECTIONS); j++, k++) - { - x1 = (uint32_t)(owidth * j); - x2 = (uint32_t)(owidth * (j + 1) - 1); - if (x2 >= iwidth) - x2 = iwidth - 1; - sections[k].x1 = x1; - sections[k].x2 = x2; - sections[k].y1 = y1; - sections[k].y2 = y2; - sections[k].buffsize = line_bytes * olength; - sections[k].position = k + 1; - sections[k].total = orows * ocols; - } - } - return (0); -} /* end computeOutputPixelOffsets */ +static int +loadImage(TIFF* in, struct image_data *image, struct dump_opts *dump, unsigned char **read_ptr) + { + uint32 i; + float xres = 0.0, yres = 0.0; + uint32 nstrips = 0, ntiles = 0; + uint16 planar = 0; + uint16 bps = 0, spp = 0, res_unit = 0; + uint16 orientation = 0; + uint16 input_compression = 0, input_photometric = 0; + uint16 subsampling_horiz, subsampling_vert; + uint32 width = 0, length = 0; + tmsize_t stsize = 0, tlsize = 0, buffsize = 0; + tmsize_t scanlinesize = 0; + uint32 tw = 0, tl = 0; /* Tile width and length */ + tmsize_t tile_rowsize = 0; + unsigned char *read_buff = NULL; + unsigned char *new_buff = NULL; + int readunit = 0; + static tmsize_t prev_readsize = 0; -static int loadImage(TIFF *in, struct image_data *image, struct dump_opts *dump, - unsigned char **read_ptr) -{ - uint32_t i; - float xres = 0.0, yres = 0.0; - uint32_t nstrips = 0, ntiles = 0; - uint16_t planar = 0; - uint16_t bps = 0, spp = 0, res_unit = 0; - uint16_t orientation = 0; - uint16_t input_compression = 0, input_photometric = 0; - uint16_t subsampling_horiz, subsampling_vert; - uint32_t width = 0, length = 0; - tmsize_t stsize = 0, tlsize = 0, buffsize = 0; - tmsize_t scanlinesize = 0; - uint32_t tw = 0, tl = 0; /* Tile width and length */ - tmsize_t tile_rowsize = 0; - unsigned char *read_buff = NULL; - int readunit = 0; - - TIFFGetFieldDefaulted(in, TIFFTAG_BITSPERSAMPLE, &bps); - TIFFGetFieldDefaulted(in, TIFFTAG_SAMPLESPERPIXEL, &spp); - TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &planar); - TIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation); - if (!TIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric)) - TIFFError("loadImage", "Image lacks Photometric interpretation tag"); - if (!TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width)) - TIFFError("loadimage", "Image lacks image width tag"); - if (!TIFFGetField(in, TIFFTAG_IMAGELENGTH, &length)) - TIFFError("loadimage", "Image lacks image length tag"); - TIFFGetFieldDefaulted(in, TIFFTAG_XRESOLUTION, &xres); - TIFFGetFieldDefaulted(in, TIFFTAG_YRESOLUTION, &yres); - if (!TIFFGetFieldDefaulted(in, TIFFTAG_RESOLUTIONUNIT, &res_unit)) - res_unit = RESUNIT_INCH; - if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &input_compression)) - input_compression = COMPRESSION_NONE; + TIFFGetFieldDefaulted(in, TIFFTAG_BITSPERSAMPLE, &bps); + TIFFGetFieldDefaulted(in, TIFFTAG_SAMPLESPERPIXEL, &spp); + TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &planar); + TIFFGetFieldDefaulted(in, TIFFTAG_ORIENTATION, &orientation); + if (! TIFFGetFieldDefaulted(in, TIFFTAG_PHOTOMETRIC, &input_photometric)) + TIFFError("loadImage","Image lacks Photometric interpreation tag"); + if (! TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width)) + TIFFError("loadimage","Image lacks image width tag"); + if(! TIFFGetField(in, TIFFTAG_IMAGELENGTH, &length)) + TIFFError("loadimage","Image lacks image length tag"); + TIFFGetFieldDefaulted(in, TIFFTAG_XRESOLUTION, &xres); + TIFFGetFieldDefaulted(in, TIFFTAG_YRESOLUTION, &yres); + if (!TIFFGetFieldDefaulted(in, TIFFTAG_RESOLUTIONUNIT, &res_unit)) + res_unit = RESUNIT_INCH; + if (!TIFFGetField(in, TIFFTAG_COMPRESSION, &input_compression)) + input_compression = COMPRESSION_NONE; #ifdef DEBUG2 - char compressionid[16]; + char compressionid[16]; - switch (input_compression) + switch (input_compression) { - case COMPRESSION_NONE: /* 1 dump mode */ - strcpy(compressionid, "None/dump"); - break; - case COMPRESSION_CCITTRLE: /* 2 CCITT modified Huffman RLE */ - strcpy(compressionid, "Huffman RLE"); - break; - case COMPRESSION_CCITTFAX3: /* 3 CCITT Group 3 fax encoding */ - strcpy(compressionid, "Group3 Fax"); - break; - case COMPRESSION_CCITTFAX4: /* 4 CCITT Group 4 fax encoding */ - strcpy(compressionid, "Group4 Fax"); - break; - case COMPRESSION_LZW: /* 5 Lempel-Ziv & Welch */ - strcpy(compressionid, "LZW"); - break; - case COMPRESSION_OJPEG: /* 6 !6.0 JPEG */ - strcpy(compressionid, "Old Jpeg"); - break; - case COMPRESSION_JPEG: /* 7 %JPEG DCT compression */ - strcpy(compressionid, "New Jpeg"); - break; - case COMPRESSION_NEXT: /* 32766 NeXT 2-bit RLE */ - strcpy(compressionid, "Next RLE"); - break; - case COMPRESSION_CCITTRLEW: /* 32771 #1 w/ word alignment */ - strcpy(compressionid, "CITTRLEW"); - break; - case COMPRESSION_PACKBITS: /* 32773 Macintosh RLE */ - strcpy(compressionid, "Mac Packbits"); - break; - case COMPRESSION_THUNDERSCAN: /* 32809 ThunderScan RLE */ - strcpy(compressionid, "Thunderscan"); - break; - case COMPRESSION_IT8CTPAD: /* 32895 IT8 CT w/padding */ - strcpy(compressionid, "IT8 padded"); - break; - case COMPRESSION_IT8LW: /* 32896 IT8 Linework RLE */ - strcpy(compressionid, "IT8 RLE"); - break; - case COMPRESSION_IT8MP: /* 32897 IT8 Monochrome picture */ - strcpy(compressionid, "IT8 mono"); - break; - case COMPRESSION_IT8BL: /* 32898 IT8 Binary line art */ - strcpy(compressionid, "IT8 lineart"); - break; - case COMPRESSION_PIXARFILM: /* 32908 Pixar companded 10bit LZW */ - strcpy(compressionid, "Pixar 10 bit"); - break; - case COMPRESSION_PIXARLOG: /* 32909 Pixar companded 11bit ZIP */ - strcpy(compressionid, "Pixar 11bit"); - break; - case COMPRESSION_DEFLATE: /* 32946 Deflate compression */ - strcpy(compressionid, "Deflate"); - break; - case COMPRESSION_ADOBE_DEFLATE: /* 8 Deflate compression */ - strcpy(compressionid, "Adobe deflate"); - break; - default: - strcpy(compressionid, "None/unknown"); - break; + case COMPRESSION_NONE: /* 1 dump mode */ + strcpy (compressionid, "None/dump"); + break; + case COMPRESSION_CCITTRLE: /* 2 CCITT modified Huffman RLE */ + strcpy (compressionid, "Huffman RLE"); + break; + case COMPRESSION_CCITTFAX3: /* 3 CCITT Group 3 fax encoding */ + strcpy (compressionid, "Group3 Fax"); + break; + case COMPRESSION_CCITTFAX4: /* 4 CCITT Group 4 fax encoding */ + strcpy (compressionid, "Group4 Fax"); + break; + case COMPRESSION_LZW: /* 5 Lempel-Ziv & Welch */ + strcpy (compressionid, "LZW"); + break; + case COMPRESSION_OJPEG: /* 6 !6.0 JPEG */ + strcpy (compressionid, "Old Jpeg"); + break; + case COMPRESSION_JPEG: /* 7 %JPEG DCT compression */ + strcpy (compressionid, "New Jpeg"); + break; + case COMPRESSION_NEXT: /* 32766 NeXT 2-bit RLE */ + strcpy (compressionid, "Next RLE"); + break; + case COMPRESSION_CCITTRLEW: /* 32771 #1 w/ word alignment */ + strcpy (compressionid, "CITTRLEW"); + break; + case COMPRESSION_PACKBITS: /* 32773 Macintosh RLE */ + strcpy (compressionid, "Mac Packbits"); + break; + case COMPRESSION_THUNDERSCAN: /* 32809 ThunderScan RLE */ + strcpy (compressionid, "Thunderscan"); + break; + case COMPRESSION_IT8CTPAD: /* 32895 IT8 CT w/padding */ + strcpy (compressionid, "IT8 padded"); + break; + case COMPRESSION_IT8LW: /* 32896 IT8 Linework RLE */ + strcpy (compressionid, "IT8 RLE"); + break; + case COMPRESSION_IT8MP: /* 32897 IT8 Monochrome picture */ + strcpy (compressionid, "IT8 mono"); + break; + case COMPRESSION_IT8BL: /* 32898 IT8 Binary line art */ + strcpy (compressionid, "IT8 lineart"); + break; + case COMPRESSION_PIXARFILM: /* 32908 Pixar companded 10bit LZW */ + strcpy (compressionid, "Pixar 10 bit"); + break; + case COMPRESSION_PIXARLOG: /* 32909 Pixar companded 11bit ZIP */ + strcpy (compressionid, "Pixar 11bit"); + break; + case COMPRESSION_DEFLATE: /* 32946 Deflate compression */ + strcpy (compressionid, "Deflate"); + break; + case COMPRESSION_ADOBE_DEFLATE: /* 8 Deflate compression */ + strcpy (compressionid, "Adobe deflate"); + break; + default: + strcpy (compressionid, "None/unknown"); + break; } - TIFFError("loadImage", "Input compression %s", compressionid); + TIFFError("loadImage", "Input compression %s", compressionid); #endif - scanlinesize = TIFFScanlineSize(in); - image->bps = bps; - image->spp = spp; - image->planar = planar; - image->width = width; - image->length = length; - image->xres = xres; - image->yres = yres; - image->res_unit = res_unit; - image->compression = input_compression; - image->photometric = input_photometric; + scanlinesize = TIFFScanlineSize(in); + image->bps = bps; + image->spp = spp; + image->planar = planar; + image->width = width; + image->length = length; + image->xres = xres; + image->yres = yres; + image->res_unit = res_unit; + image->compression = input_compression; + image->photometric = input_photometric; #ifdef DEBUG2 - char photometricid[12]; + char photometricid[12]; - switch (input_photometric) + switch (input_photometric) { - case PHOTOMETRIC_MINISWHITE: - strcpy(photometricid, "MinIsWhite"); - break; - case PHOTOMETRIC_MINISBLACK: - strcpy(photometricid, "MinIsBlack"); - break; - case PHOTOMETRIC_RGB: - strcpy(photometricid, "RGB"); - break; - case PHOTOMETRIC_PALETTE: - strcpy(photometricid, "Palette"); - break; - case PHOTOMETRIC_MASK: - strcpy(photometricid, "Mask"); - break; - case PHOTOMETRIC_SEPARATED: - strcpy(photometricid, "Separated"); - break; - case PHOTOMETRIC_YCBCR: - strcpy(photometricid, "YCBCR"); - break; - case PHOTOMETRIC_CIELAB: - strcpy(photometricid, "CIELab"); - break; - case PHOTOMETRIC_ICCLAB: - strcpy(photometricid, "ICCLab"); - break; - case PHOTOMETRIC_ITULAB: - strcpy(photometricid, "ITULab"); - break; - case PHOTOMETRIC_LOGL: - strcpy(photometricid, "LogL"); - break; - case PHOTOMETRIC_LOGLUV: - strcpy(photometricid, "LOGLuv"); - break; - default: - strcpy(photometricid, "Unknown"); - break; + case PHOTOMETRIC_MINISWHITE: + strcpy (photometricid, "MinIsWhite"); + break; + case PHOTOMETRIC_MINISBLACK: + strcpy (photometricid, "MinIsBlack"); + break; + case PHOTOMETRIC_RGB: + strcpy (photometricid, "RGB"); + break; + case PHOTOMETRIC_PALETTE: + strcpy (photometricid, "Palette"); + break; + case PHOTOMETRIC_MASK: + strcpy (photometricid, "Mask"); + break; + case PHOTOMETRIC_SEPARATED: + strcpy (photometricid, "Separated"); + break; + case PHOTOMETRIC_YCBCR: + strcpy (photometricid, "YCBCR"); + break; + case PHOTOMETRIC_CIELAB: + strcpy (photometricid, "CIELab"); + break; + case PHOTOMETRIC_ICCLAB: + strcpy (photometricid, "ICCLab"); + break; + case PHOTOMETRIC_ITULAB: + strcpy (photometricid, "ITULab"); + break; + case PHOTOMETRIC_LOGL: + strcpy (photometricid, "LogL"); + break; + case PHOTOMETRIC_LOGLUV: + strcpy (photometricid, "LOGLuv"); + break; + default: + strcpy (photometricid, "Unknown"); + break; } - TIFFError("loadImage", "Input photometric interpretation %s", - photometricid); + TIFFError("loadImage", "Input photometric interpretation %s", photometricid); #endif - image->orientation = orientation; - switch (orientation) + image->orientation = orientation; + switch (orientation) { - case 0: - case ORIENTATION_TOPLEFT: - image->adjustments = 0; - break; - case ORIENTATION_TOPRIGHT: - image->adjustments = MIRROR_HORIZ; - break; - case ORIENTATION_BOTRIGHT: - image->adjustments = ROTATECW_180; - break; - case ORIENTATION_BOTLEFT: - image->adjustments = MIRROR_VERT; - break; - case ORIENTATION_LEFTTOP: - image->adjustments = MIRROR_VERT | ROTATECW_90; - break; - case ORIENTATION_RIGHTTOP: - image->adjustments = ROTATECW_90; - break; - case ORIENTATION_RIGHTBOT: - image->adjustments = MIRROR_VERT | ROTATECW_270; - break; - case ORIENTATION_LEFTBOT: - image->adjustments = ROTATECW_270; - break; - default: - image->adjustments = 0; - image->orientation = ORIENTATION_TOPLEFT; + case 0: + case ORIENTATION_TOPLEFT: + image->adjustments = 0; + break; + case ORIENTATION_TOPRIGHT: + image->adjustments = MIRROR_HORIZ; + break; + case ORIENTATION_BOTRIGHT: + image->adjustments = ROTATECW_180; + break; + case ORIENTATION_BOTLEFT: + image->adjustments = MIRROR_VERT; + break; + case ORIENTATION_LEFTTOP: + image->adjustments = MIRROR_VERT | ROTATECW_90; + break; + case ORIENTATION_RIGHTTOP: + image->adjustments = ROTATECW_90; + break; + case ORIENTATION_RIGHTBOT: + image->adjustments = MIRROR_VERT | ROTATECW_270; + break; + case ORIENTATION_LEFTBOT: + image->adjustments = ROTATECW_270; + break; + default: + image->adjustments = 0; + image->orientation = ORIENTATION_TOPLEFT; + } + + if ((bps == 0) || (spp == 0)) + { + TIFFError("loadImage", "Invalid samples per pixel (%d) or bits per sample (%d)", + spp, bps); + return (-1); } - if ((bps == 0) || (spp == 0)) + if (TIFFIsTiled(in)) { - TIFFError("loadImage", - "Invalid samples per pixel (%" PRIu16 - ") or bits per sample (%" PRIu16 ")", - spp, bps); + readunit = TILE; + tlsize = TIFFTileSize(in); + ntiles = TIFFNumberOfTiles(in); + TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); + + tile_rowsize = TIFFTileRowSize(in); + if (ntiles == 0 || tlsize == 0 || tile_rowsize == 0) + { + TIFFError("loadImage", "File appears to be tiled, but the number of tiles, tile size, or tile rowsize is zero."); + exit(EXIT_FAILURE); + } + buffsize = tlsize * ntiles; + if (tlsize != (buffsize / ntiles)) + { + TIFFError("loadImage", "Integer overflow when calculating buffer size"); + exit(EXIT_FAILURE); + } + + if (buffsize < (uint32)(ntiles * tl * tile_rowsize)) + { + buffsize = ntiles * tl * tile_rowsize; + if (ntiles != (buffsize / tl / tile_rowsize)) + { + TIFFError("loadImage", "Integer overflow when calculating buffer size"); + exit(EXIT_FAILURE); + } + +#ifdef DEBUG2 + TIFFError("loadImage", + "Tilesize %u is too small, using ntiles * tilelength * tilerowsize %lu", + tlsize, (unsigned long)buffsize); +#endif + } + + if (dump->infile != NULL) + dump_info (dump->infile, dump->format, "", + "Tilesize: %u, Number of Tiles: %u, Tile row size: %u", + tlsize, ntiles, tile_rowsize); + } + else + { + uint32 buffsize_check; + readunit = STRIP; + TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + stsize = TIFFStripSize(in); + nstrips = TIFFNumberOfStrips(in); + if (nstrips == 0 || stsize == 0) + { + TIFFError("loadImage", "File appears to be striped, but the number of stipes or stripe size is zero."); + exit(EXIT_FAILURE); + } + + buffsize = stsize * nstrips; + if (stsize != (buffsize / nstrips)) + { + TIFFError("loadImage", "Integer overflow when calculating buffer size"); + exit(EXIT_FAILURE); + } + buffsize_check = ((length * width * spp * bps) + 7); + if (length != ((buffsize_check - 7) / width / spp / bps)) + { + TIFFError("loadImage", "Integer overflow detected."); + exit(EXIT_FAILURE); + } + if (buffsize < (uint32) (((length * width * spp * bps) + 7) / 8)) + { + buffsize = ((length * width * spp * bps) + 7) / 8; +#ifdef DEBUG2 + TIFFError("loadImage", + "Stripsize %u is too small, using imagelength * width * spp * bps / 8 = %lu", + stsize, (unsigned long)buffsize); +#endif + } + + if (dump->infile != NULL) + dump_info (dump->infile, dump->format, "", + "Stripsize: %u, Number of Strips: %u, Rows per Strip: %u, Scanline size: %u", + stsize, nstrips, rowsperstrip, scanlinesize); + } + + if (input_compression == COMPRESSION_JPEG) + { /* Force conversion to RGB */ + jpegcolormode = JPEGCOLORMODE_RGB; + TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } + /* The clause up to the read statement is taken from Tom Lane's tiffcp patch */ + else + { /* Otherwise, can't handle subsampled input */ + if (input_photometric == PHOTOMETRIC_YCBCR) + { + TIFFGetFieldDefaulted(in, TIFFTAG_YCBCRSUBSAMPLING, + &subsampling_horiz, &subsampling_vert); + if (subsampling_horiz != 1 || subsampling_vert != 1) + { + TIFFError("loadImage", + "Can't copy/convert subsampled image with subsampling %d horiz %d vert", + subsampling_horiz, subsampling_vert); + return (-1); + } + } + } + + read_buff = *read_ptr; + /* +3 : add a few guard bytes since reverseSamples16bits() can read a bit */ + /* outside buffer */ + if (!read_buff) + { + if( buffsize > 0xFFFFFFFFU - 3 ) + { + TIFFError("loadImage", "Unable to allocate/reallocate read buffer"); return (-1); } - - if (TIFFIsTiled(in)) + read_buff = (unsigned char *)limitMalloc(buffsize + NUM_BUFF_OVERSIZE_BYTES); + } + else { - readunit = TILE; - tlsize = TIFFTileSize(in); - ntiles = TIFFNumberOfTiles(in); - TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(in, TIFFTAG_TILELENGTH, &tl); - - tile_rowsize = TIFFTileRowSize(in); - if (ntiles == 0 || tlsize == 0 || tile_rowsize == 0) - { - TIFFError("loadImage", - "File appears to be tiled, but the number of tiles, tile " - "size, or tile rowsize is zero."); - exit(EXIT_FAILURE); - } - if (ntiles != 0 && tlsize > (tmsize_t)(TIFF_TMSIZE_T_MAX / ntiles)) - { - TIFFError("loadImage", - "Integer overflow when calculating buffer size"); - exit(EXIT_FAILURE); - } - buffsize = tlsize * ntiles; - - if (tl != 0 && ntiles != 0 && - tile_rowsize > (tmsize_t)(TIFF_TMSIZE_T_MAX / tl / ntiles)) - { - TIFFError("loadImage", - "Integer overflow when calculating buffer size"); - exit(EXIT_FAILURE); - } - if (buffsize < (tmsize_t)(ntiles * tl * tile_rowsize)) - { - buffsize = ntiles * tl * tile_rowsize; - -#ifdef DEBUG2 - TIFFError("loadImage", - "Tilesize %" PRIu32 " is too small, using ntiles * " - "tilelength * tilerowsize %" PRIu32, - tlsize, buffsize); -#endif - } - - if (dump->infile != NULL) - dump_info(dump->infile, dump->format, "", - "Tilesize: %" TIFF_SSIZE_FORMAT - ", Number of Tiles: %" PRIu32 - ", Tile row size: %" TIFF_SSIZE_FORMAT, - tlsize, ntiles, tile_rowsize); - } - else + if (prev_readsize < buffsize) { - tmsize_t buffsize_check; - readunit = STRIP; - TIFFGetFieldDefaulted(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - stsize = TIFFStripSize(in); - nstrips = TIFFNumberOfStrips(in); - if (nstrips == 0 || stsize == 0) + if( buffsize > 0xFFFFFFFFU - 3 ) + { + TIFFError("loadImage", "Unable to allocate/reallocate read buffer"); + return (-1); + } + new_buff = _TIFFrealloc(read_buff, buffsize + NUM_BUFF_OVERSIZE_BYTES); + if (!new_buff) { - TIFFError("loadImage", "File appears to be striped, but the number " - "of stipes or stripe size is zero."); - exit(EXIT_FAILURE); + free (read_buff); + read_buff = (unsigned char *)limitMalloc(buffsize + NUM_BUFF_OVERSIZE_BYTES); } - - if (nstrips != 0 && stsize > (tmsize_t)(TIFF_TMSIZE_T_MAX / nstrips)) - { - TIFFError("loadImage", - "Integer overflow when calculating buffer size"); - exit(EXIT_FAILURE); - } - buffsize = stsize * nstrips; - /* The buffsize_check and the possible adaptation of buffsize - * has to account also for padding of each line to a byte boundary. - * This is assumed by mirrorImage() and rotateImage(). - * Furthermore, functions like extractContigSamplesShifted32bits() - * need a buffer, which is at least 3 bytes larger than the actual - * image. Otherwise buffer-overflow might occur there. - */ - if ((spp != 0 && bps != 0 && - width > (uint32_t)((UINT32_MAX - 7) / spp / bps)) || - (width != 0 && spp != 0 && bps != 0 && - length > (tmsize_t)(TIFF_TMSIZE_T_MAX / - (uint32_t)(((width * spp * bps) + 7) / 8)))) - { - TIFFError("loadImage", "Integer overflow detected."); - exit(EXIT_FAILURE); - } - buffsize_check = - (tmsize_t)length * (uint32_t)(((width * spp * bps) + 7) / 8); - if (buffsize < buffsize_check) - { - buffsize = buffsize_check; -#ifdef DEBUG2 - TIFFError("loadImage", - "Stripsize %" PRIu32 " is too small, using imagelength * " - "width * spp * bps / 8 = %" PRIu32, - stsize, (unsigned long)buffsize); -#endif - } - - if (dump->infile != NULL) - dump_info(dump->infile, dump->format, "", - "Stripsize: %" TIFF_SSIZE_FORMAT - ", Number of Strips: %" PRIu32 - ", Rows per Strip: %" PRIu32 - ", Scanline size: %" TIFF_SSIZE_FORMAT, - stsize, nstrips, rowsperstrip, scanlinesize); + else + read_buff = new_buff; + } } - - if (input_compression == COMPRESSION_JPEG) - { /* Force conversion to RGB */ - jpegcolormode = JPEGCOLORMODE_RGB; - TIFFSetField(in, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - } - /* The clause up to the read statement is taken from Tom Lane's tiffcp patch - */ - else - { /* Otherwise, can't handle subsampled input */ - if (input_photometric == PHOTOMETRIC_YCBCR) - { - TIFFGetFieldDefaulted(in, TIFFTAG_YCBCRSUBSAMPLING, - &subsampling_horiz, &subsampling_vert); - if (subsampling_horiz != 1 || subsampling_vert != 1) - { - TIFFError("loadImage", - "Can't copy/convert subsampled image with " - "subsampling %" PRIu16 " horiz %" PRIu16 " vert", - subsampling_horiz, subsampling_vert); - return (-1); - } - } - } - - read_buff = *read_ptr; - /* +3 : add a few guard bytes since reverseSamples16bits() can read a bit - * outside buffer */ - /* Reuse of read_buff from previous image is quite unsafe, because other - * functions (like rotateImage() etc.) reallocate that buffer with different - * size without updating the local prev_readsize value. */ - if (read_buff) + if (!read_buff) { - _TIFFfree(read_buff); - } - if (buffsize > 0xFFFFFFFFU - 3) - { - TIFFError("loadImage", "Required read buffer size too large"); - return (-1); - } - read_buff = - (unsigned char *)limitMalloc(buffsize + NUM_BUFF_OVERSIZE_BYTES); - if (!read_buff) - { - TIFFError("loadImage", "Unable to allocate read buffer"); - return (-1); + TIFFError("loadImage", "Unable to allocate/reallocate read buffer"); + return (-1); } - read_buff[buffsize] = 0; - read_buff[buffsize + 1] = 0; - read_buff[buffsize + 2] = 0; + read_buff[buffsize] = 0; + read_buff[buffsize+1] = 0; + read_buff[buffsize+2] = 0; - *read_ptr = read_buff; + prev_readsize = buffsize; + *read_ptr = read_buff; - /* N.B. The read functions used copy separate plane data into a buffer as - * interleaved samples rather than separate planes so the same logic works - * to extract regions regardless of the way the data are organized in the - * input file. - */ - switch (readunit) - { - case STRIP: - if (planar == PLANARCONFIG_CONTIG) - { - if (!(readContigStripsIntoBuffer(in, read_buff))) - { - TIFFError("loadImage", - "Unable to read contiguous strips into buffer"); - return (-1); - } - } - else - { - if (!(readSeparateStripsIntoBuffer(in, read_buff, length, width, - spp, dump))) - { - TIFFError("loadImage", - "Unable to read separate strips into buffer"); - return (-1); - } - } - break; + /* N.B. The read functions used copy separate plane data into a buffer as interleaved + * samples rather than separate planes so the same logic works to extract regions + * regardless of the way the data are organized in the input file. + */ + switch (readunit) { + case STRIP: + if (planar == PLANARCONFIG_CONTIG) + { + if (!(readContigStripsIntoBuffer(in, read_buff))) + { + TIFFError("loadImage", "Unable to read contiguous strips into buffer"); + return (-1); + } + } + else + { + if (!(readSeparateStripsIntoBuffer(in, read_buff, length, width, spp, dump))) + { + TIFFError("loadImage", "Unable to read separate strips into buffer"); + return (-1); + } + } + break; - case TILE: - if (planar == PLANARCONFIG_CONTIG) - { - if (!(readContigTilesIntoBuffer(in, read_buff, length, width, - tw, tl, spp, bps))) - { - TIFFError("loadImage", - "Unable to read contiguous tiles into buffer"); - return (-1); - } - } - else - { - if (!(readSeparateTilesIntoBuffer(in, read_buff, length, width, - tw, tl, spp, bps))) - { - TIFFError("loadImage", - "Unable to read separate tiles into buffer"); - return (-1); - } - } - break; - default: - TIFFError("loadImage", "Unsupported image file format"); - return (-1); - break; + case TILE: + if (planar == PLANARCONFIG_CONTIG) + { + if (!(readContigTilesIntoBuffer(in, read_buff, length, width, tw, tl, spp, bps))) + { + TIFFError("loadImage", "Unable to read contiguous tiles into buffer"); + return (-1); + } + } + else + { + if (!(readSeparateTilesIntoBuffer(in, read_buff, length, width, tw, tl, spp, bps))) + { + TIFFError("loadImage", "Unable to read separate tiles into buffer"); + return (-1); + } + } + break; + default: TIFFError("loadImage", "Unsupported image file format"); + return (-1); + break; } - if ((dump->infile != NULL) && (dump->level == 2)) + if ((dump->infile != NULL) && (dump->level == 2)) { + dump_info (dump->infile, dump->format, "loadImage", + "Image width %d, length %d, Raw image data, %4d bytes", + width, length, buffsize); + dump_info (dump->infile, dump->format, "", + "Bits per sample %d, Samples per pixel %d", bps, spp); + + if (scanlinesize > 0x0ffffffffULL) { dump_info(dump->infile, dump->format, "loadImage", - "Image width %" PRIu32 ", length %" PRIu32 - ", Raw image data, %4" TIFF_SSIZE_FORMAT " bytes", - width, length, buffsize); - dump_info(dump->infile, dump->format, "", - "Bits per sample %" PRIu16 ", Samples per pixel %" PRIu16, - bps, spp); - - if ((uint64_t)scanlinesize > 0x0ffffffffULL) - { - dump_info( - dump->infile, dump->format, "loadImage", - "Attention: scanlinesize %" PRIu64 - " is larger than UINT32_MAX.\nFollowing dump might be wrong.", - (uint64_t)scanlinesize); - } - for (i = 0; i < length; i++) - dump_buffer(dump->infile, dump->format, 1, (uint32_t)scanlinesize, - i, read_buff + (i * scanlinesize)); + "Attention: scanlinesize " TIFF_SSIZE_FORMAT " is larger than UINT32_MAX.\nFollowing dump might be wrong.", + scanlinesize); } - return (0); -} /* end loadImage */ + for (i = 0; i < length; i++) + dump_buffer(dump->infile, dump->format, 1, (uint32)scanlinesize, + i, read_buff + (i * scanlinesize)); + } + return (0); + } /* end loadImage */ -static int correct_orientation(struct image_data *image, - unsigned char **work_buff_ptr) -{ - uint16_t mirror, rotation; - unsigned char *work_buff; +static int correct_orientation(struct image_data *image, unsigned char **work_buff_ptr) + { + uint16 mirror, rotation; + unsigned char *work_buff; - work_buff = *work_buff_ptr; - if ((image == NULL) || (work_buff == NULL)) + work_buff = *work_buff_ptr; + if ((image == NULL) || (work_buff == NULL)) { - TIFFError("correct_orientatin", "Invalid image or buffer pointer"); - return (-1); + TIFFError ("correct_orientatin", "Invalid image or buffer pointer"); + return (-1); } - if ((image->adjustments & MIRROR_HORIZ) || - (image->adjustments & MIRROR_VERT)) + if ((image->adjustments & MIRROR_HORIZ) || (image->adjustments & MIRROR_VERT)) { - mirror = (uint16_t)(image->adjustments & MIRROR_BOTH); - if (mirrorImage(image->spp, image->bps, mirror, image->width, - image->length, work_buff)) - { - TIFFError("correct_orientation", "Unable to mirror image"); - return (-1); - } + mirror = (uint16)(image->adjustments & MIRROR_BOTH); + if (mirrorImage(image->spp, image->bps, mirror, + image->width, image->length, work_buff)) + { + TIFFError ("correct_orientation", "Unable to mirror image"); + return (-1); + } } - if (image->adjustments & ROTATE_ANY) + if (image->adjustments & ROTATE_ANY) { - if (image->adjustments & ROTATECW_90) - rotation = (uint16_t)90; - else if (image->adjustments & ROTATECW_180) - rotation = (uint16_t)180; - else if (image->adjustments & ROTATECW_270) - rotation = (uint16_t)270; - else - { - TIFFError("correct_orientation", "Invalid rotation value: %" PRIu16, - (uint16_t)(image->adjustments & ROTATE_ANY)); - return (-1); - } - /* Dummy variable in order not to switch two times the - * image->width,->length within rotateImage(), - * but switch xres, yres there. */ - uint32_t width = image->width; - uint32_t length = image->length; - if (rotateImage(rotation, image, &width, &length, work_buff_ptr, NULL, - TRUE)) - { - TIFFError("correct_orientation", "Unable to rotate image"); - return (-1); - } - image->orientation = ORIENTATION_TOPLEFT; - } - - return (0); -} /* end correct_orientation */ - -/* Extract multiple zones from an image and combine into a single composite - * image */ -static int extractCompositeRegions(struct image_data *image, - struct crop_mask *crop, - unsigned char *read_buff, - unsigned char *crop_buff) -{ - int shift_width, bytes_per_sample, bytes_per_pixel; - uint32_t i, trailing_bits, prev_trailing_bits; - uint32_t row, first_row, last_row, first_col, last_col; - uint32_t src_rowsize, dst_rowsize, src_offset, dst_offset; - uint32_t crop_width, crop_length, img_width /*, img_length */; - uint32_t prev_length, prev_width, composite_width; - uint16_t bps, spp; - uint8_t *src, *dst; - tsample_t count, sample = 0; /* Update to extract one or more samples */ - - img_width = image->width; - /* img_length = image->length; */ - bps = image->bps; - spp = image->spp; - count = spp; - - bytes_per_sample = (bps + 7) / 8; - bytes_per_pixel = ((bps * spp) + 7) / 8; - if ((bps % 8) == 0) - shift_width = 0; + uint32 width, length; + if (image->adjustments & ROTATECW_90) + rotation = (uint16) 90; else - { - if (bytes_per_pixel < (bytes_per_sample + 1)) - shift_width = bytes_per_pixel; - else - shift_width = bytes_per_sample + 1; - } - src = read_buff; - dst = crop_buff; + if (image->adjustments & ROTATECW_180) + rotation = (uint16) 180; + else + if (image->adjustments & ROTATECW_270) + rotation = (uint16) 270; + else + { + TIFFError ("correct_orientation", "Invalid rotation value: %d", + image->adjustments & ROTATE_ANY); + return (-1); + } - /* These are setup for adding additional sections */ - prev_width = prev_length = 0; - prev_trailing_bits = trailing_bits = 0; - composite_width = crop->combined_width; - crop->combined_width = 0; - crop->combined_length = 0; + /* Dummy variable in order not to switch two times the + * image->width,->length within rotateImage(), + * but switch xres, yres there. */ + width = image->width; + length = image->length; + if (rotateImage(rotation, image, &width, &length, work_buff_ptr, TRUE)) + { + TIFFError ("correct_orientation", "Unable to rotate image"); + return (-1); + } + image->orientation = ORIENTATION_TOPLEFT; + } + + return (0); + } /* end correct_orientation */ + + +/* Extract multiple zones from an image and combine into a single composite image */ +static int +extractCompositeRegions(struct image_data *image, struct crop_mask *crop, + unsigned char *read_buff, unsigned char *crop_buff) + { + int shift_width, bytes_per_sample, bytes_per_pixel; + uint32 i, trailing_bits, prev_trailing_bits; + uint32 row, first_row, last_row, first_col, last_col; + uint32 src_rowsize, dst_rowsize, src_offset, dst_offset; + uint32 crop_width, crop_length, img_width /*, img_length */; + uint32 prev_length, prev_width, composite_width; + uint16 bps, spp; + uint8 *src, *dst; + tsample_t count, sample = 0; /* Update to extract one or more samples */ + + img_width = image->width; + /* img_length = image->length; */ + bps = image->bps; + spp = image->spp; + count = spp; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + } + src = read_buff; + dst = crop_buff; + + /* These are setup for adding additional sections */ + prev_width = prev_length = 0; + prev_trailing_bits = trailing_bits = 0; + composite_width = crop->combined_width; + crop->combined_width = 0; + crop->combined_length = 0; /* If there is more than one region, check beforehand whether all the width * and length values of the regions are the same, respectively. */ @@ -7318,9 +6510,9 @@ static int extractCompositeRegions(struct image_data *image, case EDGE_BOTTOM: for (i = 1; i < crop->selections; i++) { - uint32_t crop_width0 = + uint32 crop_width0 = crop->regionlist[i - 1].x2 - crop->regionlist[i - 1].x1 + 1; - uint32_t crop_width1 = + uint32 crop_width1 = crop->regionlist[i].x2 - crop->regionlist[i].x1 + 1; if (crop_width0 != crop_width1) { @@ -7335,9 +6527,9 @@ static int extractCompositeRegions(struct image_data *image, case EDGE_RIGHT: for (i = 1; i < crop->selections; i++) { - uint32_t crop_length0 = + uint32 crop_length0 = crop->regionlist[i - 1].y2 - crop->regionlist[i - 1].y1 + 1; - uint32_t crop_length1 = + uint32 crop_length1 = crop->regionlist[i].y2 - crop->regionlist[i].y1 + 1; if (crop_length0 != crop_length1) { @@ -7347,2520 +6539,2230 @@ static int extractCompositeRegions(struct image_data *image, return (1); } } - } + } - for (i = 0; i < crop->selections; i++) + + for (i = 0; i < crop->selections; i++) { - /* rows, columns, width, length are expressed in pixels */ - first_row = crop->regionlist[i].y1; - last_row = crop->regionlist[i].y2; - first_col = crop->regionlist[i].x1; - last_col = crop->regionlist[i].x2; + /* rows, columns, width, length are expressed in pixels */ + first_row = crop->regionlist[i].y1; + last_row = crop->regionlist[i].y2; + first_col = crop->regionlist[i].x1; + last_col = crop->regionlist[i].x2; - crop_width = last_col - first_col + 1; - crop_length = last_row - first_row + 1; + crop_width = last_col - first_col + 1; + crop_length = last_row - first_row + 1; - /* These should not be needed for composite images */ - crop->regionlist[i].width = crop_width; - crop->regionlist[i].length = crop_length; + /* These should not be needed for composite images */ + crop->regionlist[i].width = crop_width; + crop->regionlist[i].length = crop_length; - src_rowsize = ((img_width * bps * spp) + 7) / 8; - dst_rowsize = (((crop_width * bps * count) + 7) / 8); + src_rowsize = ((img_width * bps * spp) + 7) / 8; + dst_rowsize = (((crop_width * bps * count) + 7) / 8); - switch (crop->edge_ref) - { - default: - case EDGE_TOP: - case EDGE_BOTTOM: - if ((crop->selections > i + 1) && + switch (crop->edge_ref) + { + default: + case EDGE_TOP: + case EDGE_BOTTOM: + if ((crop->selections > i + 1) && (crop_width != crop->regionlist[i + 1].width)) - { - TIFFError("extractCompositeRegions", - "Only equal width regions can be combined for -E " - "top or bottom"); - return (1); - } + { + TIFFError ("extractCompositeRegions", + "Only equal width regions can be combined for -E top or bottom"); + return (1); + } - crop->combined_width = crop_width; - crop->combined_length += crop_length; + crop->combined_width = crop_width; + crop->combined_length += crop_length; - for (row = first_row; row <= last_row; row++) - { - src_offset = row * src_rowsize; - dst_offset = (row - first_row) * dst_rowsize; - src = read_buff + src_offset; - dst = crop_buff + dst_offset + (prev_length * dst_rowsize); - switch (shift_width) - { - case 0: - if (extractContigSamplesBytes( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - case 1: - if (bps == 1) - { - if (extractContigSamplesShifted8bits( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1, - prev_trailing_bits)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - } - else if (extractContigSamplesShifted16bits( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1, - prev_trailing_bits)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - case 2: - if (extractContigSamplesShifted24bits( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1, - prev_trailing_bits)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - case 3: - case 4: - case 5: - if (extractContigSamplesShifted32bits( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1, - prev_trailing_bits)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - default: - TIFFError("extractCompositeRegions", - "Unsupported bit depth %" PRIu16, bps); - return (1); - } - } - prev_length += crop_length; - break; - case EDGE_LEFT: /* splice the pieces of each row together, side by - side */ - case EDGE_RIGHT: - if ((crop->selections > i + 1) && + for (row = first_row; row <= last_row; row++) + { + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset + (prev_length * dst_rowsize); + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, sample, + spp, bps, count, first_col, + last_col + 1)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + default: TIFFError("extractCompositeRegions", "Unsupported bit depth %d", bps); + return (1); + } + } + prev_length += crop_length; + break; + case EDGE_LEFT: /* splice the pieces of each row together, side by side */ + case EDGE_RIGHT: + if ((crop->selections > i + 1) && (crop_length != crop->regionlist[i + 1].length)) - { - TIFFError("extractCompositeRegions", - "Only equal length regions can be combined for " - "-E left or right"); - return (1); - } - crop->combined_width += crop_width; - crop->combined_length = crop_length; - dst_rowsize = (((composite_width * bps * count) + 7) / 8); - trailing_bits = (crop_width * bps * count) % 8; - for (row = first_row; row <= last_row; row++) - { - src_offset = row * src_rowsize; - dst_offset = (row - first_row) * dst_rowsize; - src = read_buff + src_offset; - dst = crop_buff + dst_offset + prev_width; + { + TIFFError ("extractCompositeRegions", + "Only equal length regions can be combined for -E left or right"); + return (1); + } + crop->combined_width += crop_width; + crop->combined_length = crop_length; + dst_rowsize = (((composite_width * bps * count) + 7) / 8); + trailing_bits = (crop_width * bps * count) % 8; + for (row = first_row; row <= last_row; row++) + { + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset + prev_width; - switch (shift_width) - { - case 0: - if (extractContigSamplesBytes( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - case 1: - if (bps == 1) - { - if (extractContigSamplesShifted8bits( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1, - prev_trailing_bits)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - } - else if (extractContigSamplesShifted16bits( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1, - prev_trailing_bits)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - case 2: - if (extractContigSamplesShifted24bits( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1, - prev_trailing_bits)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - case 3: - case 4: - case 5: - if (extractContigSamplesShifted32bits( - src, dst, img_width, sample, spp, bps, - count, first_col, last_col + 1, - prev_trailing_bits)) - { - TIFFError("extractCompositeRegions", - "Unable to extract row %" PRIu32, - row); - return (1); - } - break; - default: - TIFFError("extractCompositeRegions", - "Unsupported bit depth %" PRIu16, bps); - return (1); - } - } - prev_width += (crop_width * bps * count) / 8; - prev_trailing_bits += trailing_bits; - if (prev_trailing_bits > 7) - prev_trailing_bits -= 8; - break; - } + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractCompositeRegions", + "Unable to extract row %d", row); + return (1); + } + break; + default: TIFFError("extractCompositeRegions", "Unsupported bit depth %d", bps); + return (1); + } + } + prev_width += (crop_width * bps * count) / 8; + prev_trailing_bits += trailing_bits; + if (prev_trailing_bits > 7) + prev_trailing_bits-= 8; + break; + } } - if (crop->combined_width != composite_width) - TIFFError("combineSeparateRegions", - "Combined width does not match composite width"); + if (crop->combined_width != composite_width) + TIFFError("combineSeparateRegions","Combined width does not match composite width"); + + return (0); + } /* end extractCompositeRegions */ - return (0); -} /* end extractCompositeRegions */ - -/* Copy a single region of input buffer to an output buffer. - * The read functions used copy separate plane data into a buffer +/* Copy a single region of input buffer to an output buffer. + * The read functions used copy separate plane data into a buffer * as interleaved samples rather than separate planes so the same - * logic works to extract regions regardless of the way the data + * logic works to extract regions regardless of the way the data * are organized in the input file. This function can be used to - * extract one or more samples from the input image by updating the + * extract one or more samples from the input image by updating the * parameters for starting sample and number of samples to copy in the * fifth and eighth arguments of the call to extractContigSamples. * They would be passed as new elements of the crop_mask struct. */ -static int extractSeparateRegion(struct image_data *image, - struct crop_mask *crop, - unsigned char *read_buff, - unsigned char *crop_buff, int region) -{ - int shift_width, prev_trailing_bits = 0; - uint32_t bytes_per_sample, bytes_per_pixel; - uint32_t src_rowsize, dst_rowsize; - uint32_t row, first_row, last_row, first_col, last_col; - uint32_t src_offset, dst_offset; - uint32_t crop_width, crop_length, img_width /*, img_length */; - uint16_t bps, spp; - uint8_t *src, *dst; - tsample_t count, sample = 0; /* Update to extract more or more samples */ +static int +extractSeparateRegion(struct image_data *image, struct crop_mask *crop, + unsigned char *read_buff, unsigned char *crop_buff, + int region) + { + int shift_width, prev_trailing_bits = 0; + uint32 bytes_per_sample, bytes_per_pixel; + uint32 src_rowsize, dst_rowsize; + uint32 row, first_row, last_row, first_col, last_col; + uint32 src_offset, dst_offset; + uint32 crop_width, crop_length, img_width /*, img_length */; + uint16 bps, spp; + uint8 *src, *dst; + tsample_t count, sample = 0; /* Update to extract more or more samples */ - img_width = image->width; - /* img_length = image->length; */ - bps = image->bps; - spp = image->spp; - count = spp; + img_width = image->width; + /* img_length = image->length; */ + bps = image->bps; + spp = image->spp; + count = spp; - bytes_per_sample = (bps + 7) / 8; - bytes_per_pixel = ((bps * spp) + 7) / 8; - if ((bps % 8) == 0) - shift_width = 0; /* Byte aligned data only */ + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if ((bps % 8) == 0) + shift_width = 0; /* Byte aligned data only */ + else + { + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; else - { - if (bytes_per_pixel < (bytes_per_sample + 1)) - shift_width = bytes_per_pixel; - else - shift_width = bytes_per_sample + 1; + shift_width = bytes_per_sample + 1; } - /* rows, columns, width, length are expressed in pixels */ - first_row = crop->regionlist[region].y1; - last_row = crop->regionlist[region].y2; - first_col = crop->regionlist[region].x1; - last_col = crop->regionlist[region].x2; + /* rows, columns, width, length are expressed in pixels */ + first_row = crop->regionlist[region].y1; + last_row = crop->regionlist[region].y2; + first_col = crop->regionlist[region].x1; + last_col = crop->regionlist[region].x2; - crop_width = last_col - first_col + 1; - crop_length = last_row - first_row + 1; + crop_width = last_col - first_col + 1; + crop_length = last_row - first_row + 1; - crop->regionlist[region].width = crop_width; - crop->regionlist[region].length = crop_length; + crop->regionlist[region].width = crop_width; + crop->regionlist[region].length = crop_length; - src = read_buff; - dst = crop_buff; - src_rowsize = ((img_width * bps * spp) + 7) / 8; - dst_rowsize = (((crop_width * bps * spp) + 7) / 8); + src = read_buff; + dst = crop_buff; + src_rowsize = ((img_width * bps * spp) + 7) / 8; + dst_rowsize = (((crop_width * bps * spp) + 7) / 8); - for (row = first_row; row <= last_row; row++) + for (row = first_row; row <= last_row; row++) { - src_offset = row * src_rowsize; - dst_offset = (row - first_row) * dst_rowsize; - src = read_buff + src_offset; - dst = crop_buff + dst_offset; + src_offset = row * src_rowsize; + dst_offset = (row - first_row) * dst_rowsize; + src = read_buff + src_offset; + dst = crop_buff + dst_offset; - switch (shift_width) - { - case 0: - if (extractContigSamplesBytes(src, dst, img_width, sample, spp, - bps, count, first_col, - last_col + 1)) + switch (shift_width) + { + case 0: if (extractContigSamplesBytes (src, dst, img_width, sample, + spp, bps, count, first_col, + last_col + 1)) { - TIFFError("extractSeparateRegion", - "Unable to extract row %" PRIu32, row); - return (1); - } - break; - case 1: - if (bps == 1) + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + case 1: if (bps == 1) + { + if (extractContigSamplesShifted8bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + } + else + if (extractContigSamplesShifted16bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) + { + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + case 2: if (extractContigSamplesShifted24bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) { - if (extractContigSamplesShifted8bits( - src, dst, img_width, sample, spp, bps, count, - first_col, last_col + 1, prev_trailing_bits)) - { - TIFFError("extractSeparateRegion", - "Unable to extract row %" PRIu32, row); - return (1); - } - break; - } - else if (extractContigSamplesShifted16bits( - src, dst, img_width, sample, spp, bps, count, - first_col, last_col + 1, prev_trailing_bits)) + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + case 3: + case 4: + case 5: if (extractContigSamplesShifted32bits (src, dst, img_width, + sample, spp, bps, count, + first_col, last_col + 1, + prev_trailing_bits)) { - TIFFError("extractSeparateRegion", - "Unable to extract row %" PRIu32, row); - return (1); - } - break; - case 2: - if (extractContigSamplesShifted24bits( - src, dst, img_width, sample, spp, bps, count, first_col, - last_col + 1, prev_trailing_bits)) - { - TIFFError("extractSeparateRegion", - "Unable to extract row %" PRIu32, row); - return (1); - } - break; - case 3: - case 4: - case 5: - if (extractContigSamplesShifted32bits( - src, dst, img_width, sample, spp, bps, count, first_col, - last_col + 1, prev_trailing_bits)) - { - TIFFError("extractSeparateRegion", - "Unable to extract row %" PRIu32, row); - return (1); - } - break; - default: - TIFFError("extractSeparateRegion", - "Unsupported bit depth %" PRIu16, bps); - return (1); - } + TIFFError("extractSeparateRegion", + "Unable to extract row %d", row); + return (1); + } + break; + default: TIFFError("extractSeparateRegion", "Unsupported bit depth %d", bps); + return (1); + } } + + return (0); + } /* end extractSeparateRegion */ - return (0); -} /* end extractSeparateRegion */ - -static int extractImageSection(struct image_data *image, - struct pageseg *section, unsigned char *src_buff, - unsigned char *sect_buff) -{ - unsigned char bytebuff1, bytebuff2; +static int +extractImageSection(struct image_data *image, struct pageseg *section, + unsigned char *src_buff, unsigned char *sect_buff) + { + unsigned char bytebuff1, bytebuff2; #ifdef DEVELMODE - /* unsigned char *src, *dst; */ + /* unsigned char *src, *dst; */ #endif - uint32_t img_width, img_rowsize; + uint32 img_width, img_rowsize; #ifdef DEVELMODE - uint32_t img_length; + uint32 img_length; #endif - uint32_t j, shift1, trailing_bits; - uint32_t row, first_row, last_row, first_col, last_col; - uint32_t src_offset, dst_offset, row_offset, col_offset; - uint32_t offset1, full_bytes; - uint32_t sect_width; + uint32 j, shift1, trailing_bits; + uint32 row, first_row, last_row, first_col, last_col; + uint32 src_offset, dst_offset, row_offset, col_offset; + uint32 offset1, full_bytes; + uint32 sect_width; #ifdef DEVELMODE - uint32_t sect_length; + uint32 sect_length; #endif - uint16_t bps, spp; + uint16 bps, spp; #ifdef DEVELMODE - int k; - unsigned char bitset; + int k; + unsigned char bitset; #endif - img_width = image->width; + img_width = image->width; #ifdef DEVELMODE - img_length = image->length; + img_length = image->length; #endif - bps = image->bps; - spp = image->spp; + bps = image->bps; + spp = image->spp; #ifdef DEVELMODE - /* src = src_buff; */ - /* dst = sect_buff; */ + /* src = src_buff; */ + /* dst = sect_buff; */ #endif - src_offset = 0; - dst_offset = 0; + src_offset = 0; + dst_offset = 0; #ifdef DEVELMODE - char bitarray[39]; + char bitarray[39]; #endif - /* rows, columns, width, length are expressed in pixels - * first_row, last_row, .. are index into image array starting at 0 to - * width-1, last_col shall be also extracted. */ - first_row = section->y1; - last_row = section->y2; - first_col = section->x1; - last_col = section->x2; + /* rows, columns, width, length are expressed in pixels + * first_row, last_row, .. are index into image array starting at 0 to width-1, + * last_col shall be also extracted. */ + first_row = section->y1; + last_row = section->y2; + first_col = section->x1; + last_col = section->x2; - sect_width = last_col - first_col + 1; + sect_width = last_col - first_col + 1; #ifdef DEVELMODE - sect_length = last_row - first_row + 1; + sect_length = last_row - first_row + 1; #endif - /* The read function loadImage() used copy separate plane data into a buffer - * as interleaved samples rather than separate planes so the same logic - * works to extract regions regardless of the way the data are organized in - * the input file. Furthermore, bytes and bits are arranged in buffer - * according to COMPRESSION=1 and FILLORDER=1 + /* The read function loadImage() used copy separate plane data into a buffer as interleaved + * samples rather than separate planes so the same logic works to extract regions + * regardless of the way the data are organized in the input file. + * Furthermore, bytes and bits are arranged in buffer according to COMPRESSION=1 and FILLORDER=1 */ - img_rowsize = (((img_width * spp * bps) + 7) / - 8); /* row size in full bytes of source image */ - full_bytes = (sect_width * spp * bps) / - 8; /* number of COMPLETE bytes per row in section */ - trailing_bits = - (sect_width * spp * bps) % - 8; /* trailing bits within the last byte of destination buffer */ + img_rowsize = (((img_width * spp * bps) + 7) / 8); /* row size in full bytes of source image */ + full_bytes = (sect_width * spp * bps) / 8; /* number of COMPLETE bytes per row in section */ + trailing_bits = (sect_width * spp * bps) % 8; /* trailing bits within the last byte of destination buffer */ #ifdef DEVELMODE - TIFFError("", - "First row: %" PRIu32 ", last row: %" PRIu32 - ", First col: %" PRIu32 ", last col: %" PRIu32 "\n", - first_row, last_row, first_col, last_col); - TIFFError("", - "Image width: %" PRIu32 ", Image length: %" PRIu32 - ", bps: %" PRIu16 ", spp: %" PRIu16 "\n", - img_width, img_length, bps, spp); - TIFFError("", - "Sect width: %" PRIu32 ", Sect length: %" PRIu32 - ", full bytes: %" PRIu32 " trailing bits %" PRIu32 "\n", - sect_width, sect_length, full_bytes, trailing_bits); + TIFFError ("", "First row: %d, last row: %d, First col: %d, last col: %d\n", + first_row, last_row, first_col, last_col); + TIFFError ("", "Image width: %d, Image length: %d, bps: %d, spp: %d\n", + img_width, img_length, bps, spp); + TIFFError ("", "Sect width: %d, Sect length: %d, full bytes: %d trailing bits %d\n", + sect_width, sect_length, full_bytes, trailing_bits); #endif - if ((bps % 8) == 0) + if ((bps % 8) == 0) { - col_offset = (first_col * spp * bps) / 8; - for (row = first_row; row <= last_row; row++) - { - row_offset = row * img_rowsize; - src_offset = row_offset + col_offset; + col_offset = (first_col * spp * bps) / 8; + for (row = first_row; row <= last_row; row++) + { + row_offset = row * img_rowsize; + src_offset = row_offset + col_offset; #ifdef DEVELMODE - TIFFError("", "Src offset: %8" PRIu32 ", Dst offset: %8" PRIu32, - src_offset, dst_offset); + TIFFError ("", "Src offset: %8d, Dst offset: %8d", src_offset, dst_offset); #endif - _TIFFmemcpy(sect_buff + dst_offset, src_buff + src_offset, - full_bytes); - dst_offset += full_bytes; - } + _TIFFmemcpy (sect_buff + dst_offset, src_buff + src_offset, full_bytes); + dst_offset += full_bytes; + } } - else + else { /* bps != 8 */ - shift1 = - ((first_col * spp * bps) % - 8); /* shift1 = bits to skip in the first byte of source buffer*/ - for (row = first_row; row <= last_row; row++) + shift1 = ((first_col * spp * bps) % 8); /* shift1 = bits to skip in the first byte of source buffer*/ + for (row = first_row; row <= last_row; row++) + { + /* pull out the first byte */ + row_offset = row * img_rowsize; + offset1 = row_offset + ((first_col * spp * bps) / 8); /* offset1 = offset into source of byte with first bits to be extracted */ + +#ifdef DEVELMODE + for (j = 0, k = 7; j < 8; j++, k--) { - /* pull out the first byte */ - row_offset = row * img_rowsize; - offset1 = row_offset + ((first_col * spp * bps) / - 8); /* offset1 = offset into source of byte - with first bits to be extracted */ - -#ifdef DEVELMODE - for (j = 0, k = 7; j < 8; j++, k--) - { - bitset = - *(src_buff + offset1) & (((unsigned char)1 << k)) ? 1 : 0; - sprintf(&bitarray[j], (bitset) ? "1" : "0"); - } - sprintf(&bitarray[8], " "); - sprintf(&bitarray[9], " "); - for (j = 10, k = 7; j < 18; j++, k--) - { - bitset = *(src_buff + offset1 + full_bytes) & - (((unsigned char)1 << k)) - ? 1 - : 0; - sprintf(&bitarray[j], (bitset) ? "1" : "0"); - } - bitarray[18] = '\0'; - TIFFError( - "", - "Row: %3d Offset1: %" PRIu32 ", Shift1: %" PRIu32 - ", Offset2: %" PRIu32 ", Trailing_bits: %" PRIu32 "\n", - row, offset1, shift1, offset1 + full_bytes, trailing_bits); -#endif - - bytebuff1 = bytebuff2 = 0; - if (shift1 == 0) /* the region is byte and sample aligned */ - { - _TIFFmemcpy(sect_buff + dst_offset, src_buff + offset1, - full_bytes); - -#ifdef DEVELMODE - TIFFError("", - " Aligned data src offset1: %8" PRIu32 - ", Dst offset: %8" PRIu32 "\n", - offset1, dst_offset); - sprintf(&bitarray[18], "\n"); - sprintf(&bitarray[19], "\t"); - for (j = 20, k = 7; j < 28; j++, k--) - { - bitset = - *(sect_buff + dst_offset) & (((unsigned char)1 << k)) - ? 1 - : 0; - sprintf(&bitarray[j], (bitset) ? "1" : "0"); - } - bitarray[28] = ' '; - bitarray[29] = ' '; -#endif - dst_offset += full_bytes; - - if (trailing_bits != 0) - { - /* Only copy higher bits of samples and mask lower bits of - * not wanted column samples to zero */ - bytebuff2 = src_buff[offset1 + full_bytes] & - ((unsigned char)255 << (8 - trailing_bits)); - sect_buff[dst_offset] = bytebuff2; -#ifdef DEVELMODE - TIFFError("", - " Trailing bits src offset: %8" PRIu32 - ", Dst offset: %8" PRIu32 "\n", - offset1 + full_bytes, dst_offset); - for (j = 30, k = 7; j < 38; j++, k--) - { - bitset = *(sect_buff + dst_offset) & - (((unsigned char)1 << k)) - ? 1 - : 0; - sprintf(&bitarray[j], (bitset) ? "1" : "0"); - } - bitarray[38] = '\0'; - TIFFError("", - "\tFirst and last bytes before and after " - "masking:\n\t%s\n\n", - bitarray); -#endif - dst_offset++; - } - } - else /* each destination byte will have to be built from two source - bytes*/ - { -#ifdef DEVELMODE - TIFFError("", - " Unalligned data src offset: %8" PRIu32 - ", Dst offset: %8" PRIu32 "\n", - offset1, dst_offset); -#endif - for (j = 0; j <= full_bytes; j++) - { - /* Skip the first shift1 bits and shift the source up by - * shift1 bits before save to destination.*/ - /* Attention: src_buff size needs to be some bytes larger - * than image size, because could read behind image here. */ - bytebuff1 = - src_buff[offset1 + j] & ((unsigned char)255 >> shift1); - bytebuff2 = src_buff[offset1 + j + 1] & - ((unsigned char)255 << (8 - shift1)); - sect_buff[dst_offset + j] = - (bytebuff1 << shift1) | (bytebuff2 >> (8 - shift1)); - } -#ifdef DEVELMODE - sprintf(&bitarray[18], "\n"); - sprintf(&bitarray[19], "\t"); - for (j = 20, k = 7; j < 28; j++, k--) - { - bitset = - *(sect_buff + dst_offset) & (((unsigned char)1 << k)) - ? 1 - : 0; - sprintf(&bitarray[j], (bitset) ? "1" : "0"); - } - bitarray[28] = ' '; - bitarray[29] = ' '; -#endif - dst_offset += full_bytes; - - /* Copy the trailing_bits for the last byte in the destination - buffer. Could come from one ore two bytes of the source - buffer. */ - if (trailing_bits != 0) - { -#ifdef DEVELMODE - TIFFError("", - " Trailing bits %4" PRIu32 - " src offset: %8" PRIu32 - ", Dst offset: %8" PRIu32 "\n", - trailing_bits, offset1 + full_bytes, dst_offset); -#endif - /* More than necessary bits are already copied into last - * destination buffer, only masking of last byte in - * destination buffer is necessary.*/ - sect_buff[dst_offset] &= - ((uint8_t)0xFF << (8 - trailing_bits)); - } -#ifdef DEVELMODE - sprintf(&bitarray[28], " "); - sprintf(&bitarray[29], " "); - for (j = 30, k = 7; j < 38; j++, k--) - { - bitset = - *(sect_buff + dst_offset) & (((unsigned char)1 << k)) - ? 1 - : 0; - sprintf(&bitarray[j], (bitset) ? "1" : "0"); - } - bitarray[38] = '\0'; - TIFFError("", - "\tFirst and last bytes before and after " - "masking:\n\t%s\n\n", - bitarray); -#endif - dst_offset++; - } + bitset = *(src_buff + offset1) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); } + sprintf(&bitarray[8], " "); + sprintf(&bitarray[9], " "); + for (j = 10, k = 7; j < 18; j++, k--) + { + bitset = *(src_buff + offset1 + full_bytes) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[18] = '\0'; + TIFFError ("", "Row: %3d Offset1: %u, Shift1: %u, Offset2: %u, Trailing_bits: %u\n", + row, offset1, shift1, offset1+full_bytes, trailing_bits); +#endif + + bytebuff1 = bytebuff2 = 0; + if (shift1 == 0) /* the region is byte and sample aligned */ + { + _TIFFmemcpy (sect_buff + dst_offset, src_buff + offset1, full_bytes); + +#ifdef DEVELMODE + TIFFError ("", " Aligned data src offset1: %8d, Dst offset: %8d\n", offset1, dst_offset); + sprintf(&bitarray[18], "\n"); + sprintf(&bitarray[19], "\t"); + for (j = 20, k = 7; j < 28; j++, k--) + { + bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[28] = ' '; + bitarray[29] = ' '; +#endif + dst_offset += full_bytes; + + if (trailing_bits != 0) + { + /* Only copy higher bits of samples and mask lower bits of not wanted column samples to zero */ + bytebuff2 = src_buff[offset1 + full_bytes] & ((unsigned char)255 << (8 - trailing_bits)); + sect_buff[dst_offset] = bytebuff2; +#ifdef DEVELMODE + TIFFError ("", " Trailing bits src offset: %8d, Dst offset: %8d\n", + offset1 + full_bytes, dst_offset); + for (j = 30, k = 7; j < 38; j++, k--) + { + bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[38] = '\0'; + TIFFError ("", "\tFirst and last bytes before and after masking:\n\t%s\n\n", bitarray); +#endif + dst_offset++; + } + } + else /* each destination byte will have to be built from two source bytes*/ + { +#ifdef DEVELMODE + TIFFError ("", " Unalligned data src offset: %8d, Dst offset: %8d\n", offset1 , dst_offset); +#endif + for (j = 0; j <= full_bytes; j++) + { + /* Skip the first shift1 bits and shift the source up by shift1 bits before save to destination.*/ + /* Attention: src_buff size needs to be some bytes larger than image size, because could read behind image here. */ + bytebuff1 = src_buff[offset1 + j] & ((unsigned char)255 >> shift1); + bytebuff2 = src_buff[offset1 + j + 1] & ((unsigned char)255 << (8 - shift1)); + sect_buff[dst_offset + j] = (bytebuff1 << shift1) | (bytebuff2 >> (8 - shift1)); + } +#ifdef DEVELMODE + sprintf(&bitarray[18], "\n"); + sprintf(&bitarray[19], "\t"); + for (j = 20, k = 7; j < 28; j++, k--) + { + bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[28] = ' '; + bitarray[29] = ' '; +#endif + dst_offset += full_bytes; + + /* Copy the trailing_bits for the last byte in the destination buffer. + Could come from one ore two bytes of the source buffer. */ + if (trailing_bits != 0) + { +#ifdef DEVELMODE + TIFFError("", " Trailing bits %4u src offset: %8u, Dst offset: %8u\n", trailing_bits, offset1 + full_bytes, dst_offset); +#endif + /* More than necessary bits are already copied into last destination buffer, + * only masking of last byte in destination buffer is necessary.*/ + sect_buff[dst_offset] &= ((uint8)0xFF << (8 - trailing_bits)); + } +#ifdef DEVELMODE + sprintf(&bitarray[28], " "); + sprintf(&bitarray[29], " "); + for (j = 30, k = 7; j < 38; j++, k--) + { + bitset = *(sect_buff + dst_offset) & (((unsigned char)1 << k)) ? 1 : 0; + sprintf(&bitarray[j], (bitset) ? "1" : "0"); + } + bitarray[38] = '\0'; + TIFFError ("", "\tFirst and last bytes before and after masking:\n\t%s\n\n", bitarray); +#endif + dst_offset++; + } + } } - return (0); -} /* end extractImageSection */ + return (0); + } /* end extractImageSection */ -static int writeSelections(TIFF *in, TIFF **out, struct crop_mask *crop, - struct image_data *image, struct dump_opts *dump, - struct buffinfo seg_buffs[], char *mp, - char *filename, unsigned int *page, - unsigned int total_pages) -{ - int i, page_count; - int autoindex = 0; - unsigned char *crop_buff = NULL; +static int +writeSelections(TIFF *in, TIFF **out, struct crop_mask *crop, + struct image_data *image, struct dump_opts *dump, + struct buffinfo seg_buffs[], char *mp, char *filename, + unsigned int *page, unsigned int total_pages) + { + int i, page_count; + int autoindex = 0; + unsigned char *crop_buff = NULL; - /* Where we open a new file depends on the export mode */ - switch (crop->exp_mode) + /* Where we open a new file depends on the export mode */ + switch (crop->exp_mode) { - case ONE_FILE_COMPOSITE: /* Regions combined into single image */ - autoindex = 0; - crop_buff = seg_buffs[0].buffer; - if (update_output_file(out, mp, autoindex, filename, page)) - return (1); - page_count = total_pages; - if (writeCroppedImage(in, *out, image, dump, crop->combined_width, - crop->combined_length, crop_buff, *page, - total_pages)) + case ONE_FILE_COMPOSITE: /* Regions combined into single image */ + autoindex = 0; + crop_buff = seg_buffs[0].buffer; + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); + page_count = total_pages; + if (writeCroppedImage(in, *out, image, dump, + crop->combined_width, + crop->combined_length, + crop_buff, *page, total_pages)) { - TIFFError("writeRegions", "Unable to write new image"); - return (-1); - } - break; - case ONE_FILE_SEPARATED: /* Regions as separated images */ - autoindex = 0; - if (update_output_file(out, mp, autoindex, filename, page)) - return (1); - page_count = crop->selections * total_pages; - for (i = 0; i < crop->selections; i++) - { - crop_buff = seg_buffs[i].buffer; - if (writeCroppedImage(in, *out, image, dump, - crop->regionlist[i].width, - crop->regionlist[i].length, crop_buff, - *page, page_count)) - { - TIFFError("writeRegions", "Unable to write new image"); - return (-1); - } - } - break; - case FILE_PER_IMAGE_COMPOSITE: /* Regions as composite image */ - autoindex = 1; - if (update_output_file(out, mp, autoindex, filename, page)) - return (1); + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + break; + case ONE_FILE_SEPARATED: /* Regions as separated images */ + autoindex = 0; + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); + page_count = crop->selections * total_pages; + for (i = 0; i < crop->selections; i++) + { + crop_buff = seg_buffs[i].buffer; + if (writeCroppedImage(in, *out, image, dump, + crop->regionlist[i].width, + crop->regionlist[i].length, + crop_buff, *page, page_count)) + { + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + } + break; + case FILE_PER_IMAGE_COMPOSITE: /* Regions as composite image */ + autoindex = 1; + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); - crop_buff = seg_buffs[0].buffer; - if (writeCroppedImage(in, *out, image, dump, crop->combined_width, - crop->combined_length, crop_buff, *page, - total_pages)) - { - TIFFError("writeRegions", "Unable to write new image"); - return (-1); - } - break; - case FILE_PER_IMAGE_SEPARATED: /* Regions as separated images */ - autoindex = 1; - page_count = crop->selections; - if (update_output_file(out, mp, autoindex, filename, page)) - return (1); + crop_buff = seg_buffs[0].buffer; + if (writeCroppedImage(in, *out, image, dump, + crop->combined_width, + crop->combined_length, + crop_buff, *page, total_pages)) + { + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + break; + case FILE_PER_IMAGE_SEPARATED: /* Regions as separated images */ + autoindex = 1; + page_count = crop->selections; + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); + + for (i = 0; i < crop->selections; i++) + { + crop_buff = seg_buffs[i].buffer; + /* Write the current region to the current file */ + if (writeCroppedImage(in, *out, image, dump, + crop->regionlist[i].width, + crop->regionlist[i].length, + crop_buff, *page, page_count)) + { + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + } + break; + case FILE_PER_SELECTION: + autoindex = 1; + page_count = 1; + for (i = 0; i < crop->selections; i++) + { + if (update_output_file (out, mp, autoindex, filename, page)) + return (1); - for (i = 0; i < crop->selections; i++) - { - crop_buff = seg_buffs[i].buffer; - /* Write the current region to the current file */ - if (writeCroppedImage(in, *out, image, dump, - crop->regionlist[i].width, - crop->regionlist[i].length, crop_buff, - *page, page_count)) - { - TIFFError("writeRegions", "Unable to write new image"); - return (-1); - } - } - break; - case FILE_PER_SELECTION: - autoindex = 1; - page_count = 1; - for (i = 0; i < crop->selections; i++) - { - if (update_output_file(out, mp, autoindex, filename, page)) - return (1); - - crop_buff = seg_buffs[i].buffer; - /* Write the current region to the current file */ - if (writeCroppedImage(in, *out, image, dump, - crop->regionlist[i].width, - crop->regionlist[i].length, crop_buff, - *page, page_count)) - { - TIFFError("writeRegions", "Unable to write new image"); - return (-1); - } - } - break; - default: - return (1); + crop_buff = seg_buffs[i].buffer; + /* Write the current region to the current file */ + if (writeCroppedImage(in, *out, image, dump, + crop->regionlist[i].width, + crop->regionlist[i].length, + crop_buff, *page, page_count)) + { + TIFFError("writeRegions", "Unable to write new image"); + return (-1); + } + } + break; + default: return (1); } - return (0); -} /* end writeRegions */ + return (0); + } /* end writeRegions */ -static int writeImageSections(TIFF *in, TIFF *out, struct image_data *image, - struct pagedef *page, struct pageseg *sections, - struct dump_opts *dump, unsigned char *src_buff, - unsigned char **sect_buff_ptr) -{ - double hres, vres; - uint32_t i, k, width, length, sectsize; - unsigned char *sect_buff = *sect_buff_ptr; +static int +writeImageSections(TIFF *in, TIFF *out, struct image_data *image, + struct pagedef *page, struct pageseg *sections, + struct dump_opts * dump, unsigned char *src_buff, + unsigned char **sect_buff_ptr) + { + double hres, vres; + uint32 i, k, width, length, sectsize; + unsigned char *sect_buff = *sect_buff_ptr; - hres = page->hres; - vres = page->vres; + hres = page->hres; + vres = page->vres; - k = page->cols * page->rows; - if ((k < 1) || (k > MAX_SECTIONS)) + k = page->cols * page->rows; + if ((k < 1) || (k > MAX_SECTIONS)) + { + TIFFError("writeImageSections", + "%d Rows and Columns exceed maximum sections\nIncrease resolution or reduce sections", k); + return (-1); + } + + for (i = 0; i < k; i++) { - TIFFError("writeImageSections", - "%" PRIu32 " Rows and Columns exceed maximum " - "sections\nIncrease resolution or reduce sections", - k); - return (-1); + width = sections[i].x2 - sections[i].x1 + 1; + length = sections[i].y2 - sections[i].y1 + 1; + sectsize = (uint32) + ceil((width * image->bps * image->spp + 7) / (double)8) * length; + /* allocate a buffer if we don't have one already */ + if (createImageSection(sectsize, sect_buff_ptr)) + { + TIFFError("writeImageSections", "Unable to allocate section buffer"); + exit(EXIT_FAILURE); + } + sect_buff = *sect_buff_ptr; + + if (extractImageSection (image, §ions[i], src_buff, sect_buff)) + { + TIFFError("writeImageSections", "Unable to extract image sections"); + exit(EXIT_FAILURE); + } + + /* call the write routine here instead of outside the loop */ + if (writeSingleSection(in, out, image, dump, width, length, hres, vres, sect_buff)) + { + TIFFError("writeImageSections", "Unable to write image section"); + exit(EXIT_FAILURE); + } } - for (i = 0; i < k; i++) - { - width = sections[i].x2 - sections[i].x1 + 1; - length = sections[i].y2 - sections[i].y1 + 1; - sectsize = - (uint32_t)ceil((width * image->bps * image->spp + 7) / (double)8) * - length; - /* allocate a buffer if we don't have one already */ - if (createImageSection(sectsize, sect_buff_ptr)) - { - TIFFError("writeImageSections", - "Unable to allocate section buffer"); - exit(EXIT_FAILURE); - } - sect_buff = *sect_buff_ptr; - - if (extractImageSection(image, §ions[i], src_buff, sect_buff)) - { - TIFFError("writeImageSections", "Unable to extract image sections"); - exit(EXIT_FAILURE); - } - - /* call the write routine here instead of outside the loop */ - if (writeSingleSection(in, out, image, dump, width, length, hres, vres, - sect_buff)) - { - TIFFError("writeImageSections", "Unable to write image section"); - exit(EXIT_FAILURE); - } - } - - return (0); -} /* end writeImageSections */ + return (0); + } /* end writeImageSections */ /* Code in this function is heavily indebted to code in tiffcp * with modifications by Richard Nolde to handle orientation correctly. * It will have to be updated significantly if support is added to - * extract one or more samples from original image since the + * extract one or more samples from original image since the * original code assumes we are always copying all samples. */ -static int writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, - struct dump_opts *dump, uint32_t width, - uint32_t length, double hres, double vres, - unsigned char *sect_buff) -{ - uint16_t bps, spp; - uint16_t input_compression, input_photometric; - uint16_t input_planar; - const struct cpTag *p; +static int +writeSingleSection(TIFF *in, TIFF *out, struct image_data *image, + struct dump_opts *dump, uint32 width, uint32 length, + double hres, double vres, + unsigned char *sect_buff) + { + uint16 bps, spp; + uint16 input_compression, input_photometric; + uint16 input_planar; + struct cpTag* p; - /* Calling this seems to reset the compression mode on the TIFF *in file. - TIFFGetField(in, TIFFTAG_JPEGCOLORMODE, &input_jpeg_colormode); - */ - input_compression = image->compression; - input_photometric = image->photometric; + /* Calling this seems to reset the compression mode on the TIFF *in file. + TIFFGetField(in, TIFFTAG_JPEGCOLORMODE, &input_jpeg_colormode); + */ + input_compression = image->compression; + input_photometric = image->photometric; - spp = image->spp; - bps = image->bps; - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, length); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bps); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); + spp = image->spp; + bps = image->bps; + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, length); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bps); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); #ifdef DEBUG2 - TIFFError("writeSingleSection", "Input compression: %s", - (input_compression == COMPRESSION_OJPEG) - ? "Old Jpeg" - : ((input_compression == COMPRESSION_JPEG) ? "New Jpeg" - : "Non Jpeg")); + TIFFError("writeSingleSection", "Input compression: %s", + (input_compression == COMPRESSION_OJPEG) ? "Old Jpeg" : + ((input_compression == COMPRESSION_JPEG) ? "New Jpeg" : "Non Jpeg")); #endif - /* This is the global variable compression which is set - * if the user has specified a command line option for - * a compression option. Should be passed around in one - * of the parameters instead of as a global. If no user - * option specified it will still be (uint16_t) -1. */ - if (compression != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - else + /* This is the global variable compression which is set + * if the user has specified a command line option for + * a compression option. Should be passed around in one + * of the parameters instead of as a global. If no user + * option specified it will still be (uint16) -1. */ + if (compression != (uint16)-1) + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + else { /* OJPEG is no longer supported for writing so upgrade to JPEG */ - if (input_compression == COMPRESSION_OJPEG) - { - compression = COMPRESSION_JPEG; - jpegcolormode = JPEGCOLORMODE_RAW; - TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); - } - else /* Use the compression from the input file */ - CopyField(TIFFTAG_COMPRESSION, compression); + if (input_compression == COMPRESSION_OJPEG) + { + compression = COMPRESSION_JPEG; + jpegcolormode = JPEGCOLORMODE_RAW; + TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); + } + else /* Use the compression from the input file */ + CopyField(TIFFTAG_COMPRESSION, compression); } - if (compression == COMPRESSION_JPEG) + if (compression == COMPRESSION_JPEG) { - if ((input_photometric == - PHOTOMETRIC_PALETTE) || /* color map indexed */ - (input_photometric == PHOTOMETRIC_MASK)) /* holdout mask */ - { - TIFFError("writeSingleSection", - "JPEG compression cannot be used with %s image data", - (input_photometric == PHOTOMETRIC_PALETTE) ? "palette" - : "mask"); - return (-1); - } - if ((input_photometric == PHOTOMETRIC_RGB) && - (jpegcolormode == JPEGCOLORMODE_RGB)) - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); - else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); - } + if ((input_photometric == PHOTOMETRIC_PALETTE) || /* color map indexed */ + (input_photometric == PHOTOMETRIC_MASK)) /* holdout mask */ + { + TIFFError ("writeSingleSection", + "JPEG compression cannot be used with %s image data", + (input_photometric == PHOTOMETRIC_PALETTE) ? + "palette" : "mask"); + return (-1); + } + if ((input_photometric == PHOTOMETRIC_RGB) && + (jpegcolormode == JPEGCOLORMODE_RGB)) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); + } + else { - if (compression == COMPRESSION_SGILOG || - compression == COMPRESSION_SGILOG24) - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - spp == 1 ? PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); - else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, image->photometric); + if (compression == COMPRESSION_SGILOG || compression == COMPRESSION_SGILOG24) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, spp == 1 ? + PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, image->photometric); } #ifdef DEBUG2 - TIFFError("writeSingleSection", "Input photometric: %s", - (input_photometric == PHOTOMETRIC_RGB) - ? "RGB" - : ((input_photometric == PHOTOMETRIC_YCBCR) - ? "YCbCr" - : "Not RGB or YCbCr")); + TIFFError("writeSingleSection", "Input photometric: %s", + (input_photometric == PHOTOMETRIC_RGB) ? "RGB" : + ((input_photometric == PHOTOMETRIC_YCBCR) ? "YCbCr" : "Not RGB or YCbCr")); #endif - if (((input_photometric == PHOTOMETRIC_LOGL) || - (input_photometric == PHOTOMETRIC_LOGLUV)) && - ((compression != COMPRESSION_SGILOG) && - (compression != COMPRESSION_SGILOG24))) + if (((input_photometric == PHOTOMETRIC_LOGL) || + (input_photometric == PHOTOMETRIC_LOGLUV)) && + ((compression != COMPRESSION_SGILOG) && + (compression != COMPRESSION_SGILOG24))) { - TIFFError("writeSingleSection", "LogL and LogLuv source data require " - "SGI_LOG or SGI_LOG24 compression"); - return (-1); + TIFFError("writeSingleSection", + "LogL and LogLuv source data require SGI_LOG or SGI_LOG24 compression"); + return (-1); } - if (fillorder != 0) - TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); - else - CopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT); + if (fillorder != 0) + TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); + else + CopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT); - /* The loadimage function reads input orientation and sets - * image->orientation. The correct_image_orientation function - * applies the required rotation and mirror operations to - * present the data in TOPLEFT orientation and updates - * image->orientation if any transforms are performed, - * as per EXIF standard. - */ - TIFFSetField(out, TIFFTAG_ORIENTATION, image->orientation); + /* The loadimage function reads input orientation and sets + * image->orientation. The correct_image_orientation function + * applies the required rotation and mirror operations to + * present the data in TOPLEFT orientation and updates + * image->orientation if any transforms are performed, + * as per EXIF standard. + */ + TIFFSetField(out, TIFFTAG_ORIENTATION, image->orientation); + /* + * Choose tiles/strip for the output image according to + * the command line arguments (-tiles, -strips) and the + * structure of the input image. + */ + if (outtiled == -1) + outtiled = TIFFIsTiled(in); + if (outtiled) { /* - * Choose tiles/strip for the output image according to - * the command line arguments (-tiles, -strips) and the - * structure of the input image. + * Setup output file's tile width&height. If either + * is not specified, use either the value from the + * input image or, if nothing is defined, use the + * library default. */ - if (outtiled == -1) - outtiled = TIFFIsTiled(in); - if (outtiled) - { - /* - * Setup output file's tile width&height. If either - * is not specified, use either the value from the - * input image or, if nothing is defined, use the - * library default. - */ - if (tilewidth == (uint32_t)0) - TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); - if (tilelength == (uint32_t)0) - TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); + if (tilewidth == (uint32) 0) + TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); + if (tilelength == (uint32) 0) + TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); - if (tilewidth == 0 || tilelength == 0) - TIFFDefaultTileSize(out, &tilewidth, &tilelength); - TIFFDefaultTileSize(out, &tilewidth, &tilelength); - TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); - TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); - } - else - { - /* - * RowsPerStrip is left unspecified: use either the - * value from the input image or, if nothing is defined, - * use the library default. - */ - if (rowsperstrip == (uint32_t)0) - { - if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) - rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); - if (compression != COMPRESSION_JPEG) + if (tilewidth == 0 || tilelength == 0) + TIFFDefaultTileSize(out, &tilewidth, &tilelength); + TIFFDefaultTileSize(out, &tilewidth, &tilelength); + TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); + TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); + } else { + /* + * RowsPerStrip is left unspecified: use either the + * value from the input image or, if nothing is defined, + * use the library default. + */ + if (rowsperstrip == (uint32) 0) + { + if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) + rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); + if (compression != COMPRESSION_JPEG) { - if (rowsperstrip > length) - rowsperstrip = length; - } + if (rowsperstrip > length) + rowsperstrip = length; + } + } + else + if (rowsperstrip == (uint32) -1) + rowsperstrip = length; + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + } + + TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &input_planar); + if (config != (uint16) -1) + TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + else + CopyField(TIFFTAG_PLANARCONFIG, config); + if (spp <= 4) + CopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT); + CopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT); + +/* SMinSampleValue & SMaxSampleValue */ + switch (compression) { + /* These are references to GLOBAL variables set by defaults + * and /or the compression flag + */ + case COMPRESSION_JPEG: + if (((bps % 8) == 0) || ((bps % 12) == 0)) + { + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } + else + { + TIFFError("writeSingleSection", + "JPEG compression requires 8 or 12 bits per sample"); + return (-1); + } + break; + case COMPRESSION_LZW: + case COMPRESSION_ADOBE_DEFLATE: + case COMPRESSION_DEFLATE: + if (predictor != (uint16)-1) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + else + CopyField(TIFFTAG_PREDICTOR, predictor); + break; + case COMPRESSION_CCITTFAX3: + case COMPRESSION_CCITTFAX4: + if (compression == COMPRESSION_CCITTFAX3) { + if (g3opts != (uint32) -1) + TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); + else + CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); + } else { + CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); } - else if (rowsperstrip == (uint32_t)-1) - rowsperstrip = length; - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - } + CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); + CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); + break; + } + { uint32 len32; + void** data; + if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) + TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); + } + { uint16 ninks; + const char* inknames; + if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { + TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); + if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) { + int inknameslen = (int)strlen(inknames) + 1; + const char* cp = inknames; + while (ninks > 1) { + cp = strchr(cp, '\0'); + if (cp) { + cp++; + inknameslen += ((int)strlen(cp) + 1); + } + ninks--; + } + TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); + } + } + } + { + unsigned short pg0, pg1; + if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) { + if (pageNum < 0) /* only one input file */ + TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); + else + TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); + } + } - TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &input_planar); - if (config != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + for (p = tags; p < &tags[NTAGS]; p++) + CopyTag(p->tag, p->count, p->type); + + /* Update these since they are overwritten from input res by loop above */ + TIFFSetField(out, TIFFTAG_XRESOLUTION, (float)hres); + TIFFSetField(out, TIFFTAG_YRESOLUTION, (float)vres); + + /* Compute the tile or strip dimensions and write to disk */ + if (outtiled) + { + if (config == PLANARCONFIG_CONTIG) + writeBufferToContigTiles (out, sect_buff, length, width, spp, dump); else - CopyField(TIFFTAG_PLANARCONFIG, config); - if (spp <= 4) - CopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT); - CopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT); - - /* SMinSampleValue & SMaxSampleValue */ - switch (compression) - { - /* These are references to GLOBAL variables set by defaults - * and /or the compression flag - */ - case COMPRESSION_JPEG: - if (((bps % 8) == 0) || ((bps % 12) == 0)) - { - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - } - else - { - TIFFError("writeSingleSection", - "JPEG compression requires 8 or 12 bits per sample"); - return (-1); - } - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - else - CopyField(TIFFTAG_PREDICTOR, predictor); - break; - case COMPRESSION_CCITTFAX3: - case COMPRESSION_CCITTFAX4: - if (bps != 1) - { - TIFFError("writeCroppedImage", - "Group 3/4 compression is not usable with bps > 1"); - return (-1); - } - if (compression == COMPRESSION_CCITTFAX3) - { - if (g3opts != (uint32_t)-1) - TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); - else - CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); - } - else - { - CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); - } - CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); - CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); - CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); - break; + writeBufferToSeparateTiles (out, sect_buff, length, width, spp, dump); } + else { - uint32_t len32; - void **data; - if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) - TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); - } - { - uint16_t ninks; - const char *inknames; - if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) - { - TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); - if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) - { - int inknameslen = (int)strlen(inknames) + 1; - const char *cp = inknames; - while (ninks > 1) - { - cp = strchr(cp, '\0'); - if (cp) - { - cp++; - inknameslen += ((int)strlen(cp) + 1); - } - ninks--; - } - TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); - } - } - } - { - unsigned short pg0, pg1; - if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) - { - if (pageNum < 0) /* only one input file */ - TIFFSetField(out, TIFFTAG_PAGENUMBER, pg0, pg1); - else - TIFFSetField(out, TIFFTAG_PAGENUMBER, pageNum++, 0); - } - } - - for (p = tags; p < &tags[NTAGS]; p++) - CopyTag(p->tag, p->count, p->type); - - /* Update these since they are overwritten from input res by loop above */ - TIFFSetField(out, TIFFTAG_XRESOLUTION, (float)hres); - TIFFSetField(out, TIFFTAG_YRESOLUTION, (float)vres); - - /* Compute the tile or strip dimensions and write to disk */ - if (outtiled) - { - if (config == PLANARCONFIG_CONTIG) - writeBufferToContigTiles(out, sect_buff, length, width, spp, dump); - else - writeBufferToSeparateTiles(out, sect_buff, length, width, spp, - dump); - } + if (config == PLANARCONFIG_CONTIG) + writeBufferToContigStrips (out, sect_buff, length); else - { - if (config == PLANARCONFIG_CONTIG) - writeBufferToContigStrips(out, sect_buff, length); - else - writeBufferToSeparateStrips(out, sect_buff, length, width, spp, - dump); + writeBufferToSeparateStrips(out, sect_buff, length, width, spp, dump); } - if (!TIFFWriteDirectory(out)) + if (!TIFFWriteDirectory(out)) { - TIFFClose(out); - return (-1); + TIFFClose(out); + return (-1); } - return (0); -} /* end writeSingleSection */ + return (0); + } /* end writeSingleSection */ + /* Create a buffer to write one section at a time */ -static int createImageSection(uint32_t sectsize, unsigned char **sect_buff_ptr) -{ - unsigned char *sect_buff = NULL; - unsigned char *new_buff = NULL; - static uint32_t prev_sectsize = 0; - - sect_buff = *sect_buff_ptr; +static int +createImageSection(uint32 sectsize, unsigned char **sect_buff_ptr) + { + unsigned char *sect_buff = NULL; + unsigned char *new_buff = NULL; + static uint32 prev_sectsize = 0; + + sect_buff = *sect_buff_ptr; + if (!sect_buff) + { + sect_buff = (unsigned char *)limitMalloc(sectsize + NUM_BUFF_OVERSIZE_BYTES); if (!sect_buff) { - sect_buff = - (unsigned char *)limitMalloc(sectsize + NUM_BUFF_OVERSIZE_BYTES); - if (!sect_buff) - { - TIFFError("createImageSection", - "Unable to allocate/reallocate section buffer"); - return (-1); - } - _TIFFmemset(sect_buff, 0, sectsize + NUM_BUFF_OVERSIZE_BYTES); + TIFFError("createImageSection", "Unable to allocate/reallocate section buffer"); + return (-1); } + _TIFFmemset(sect_buff, 0, sectsize + NUM_BUFF_OVERSIZE_BYTES); + } + else + { + if (prev_sectsize < sectsize) + { + new_buff = _TIFFrealloc(sect_buff, sectsize + NUM_BUFF_OVERSIZE_BYTES); + if (!new_buff) + { + _TIFFfree (sect_buff); + sect_buff = (unsigned char *)limitMalloc(sectsize + NUM_BUFF_OVERSIZE_BYTES); + } + else + sect_buff = new_buff; + + if (!sect_buff) + { + TIFFError("createImageSection", "Unable to allocate/reallocate section buffer"); + return (-1); + } + _TIFFmemset(sect_buff, 0, sectsize + NUM_BUFF_OVERSIZE_BYTES); + } + } + + prev_sectsize = sectsize; + *sect_buff_ptr = sect_buff; + + return (0); + } /* end createImageSection */ + + +/* Process selections defined by regions, zones, margins, or fixed sized areas */ +static int +processCropSelections(struct image_data *image, struct crop_mask *crop, + unsigned char **read_buff_ptr, struct buffinfo seg_buffs[]) + { + int i; + uint32 width, length, total_width, total_length; + tsize_t cropsize; + unsigned char *crop_buff = NULL; + unsigned char *read_buff = NULL; + unsigned char *next_buff = NULL; + tsize_t prev_cropsize = 0; + + read_buff = *read_buff_ptr; + + if (crop->img_mode == COMPOSITE_IMAGES) + { + cropsize = crop->bufftotal; + crop_buff = seg_buffs[0].buffer; + if (!crop_buff) + crop_buff = (unsigned char *)limitMalloc(cropsize + NUM_BUFF_OVERSIZE_BYTES); else - { - if (prev_sectsize < sectsize) + { + prev_cropsize = seg_buffs[1].size; + if (prev_cropsize < cropsize) { - new_buff = - _TIFFrealloc(sect_buff, sectsize + NUM_BUFF_OVERSIZE_BYTES); - if (!new_buff) - { - _TIFFfree(sect_buff); - sect_buff = (unsigned char *)limitMalloc( - sectsize + NUM_BUFF_OVERSIZE_BYTES); - } - else - sect_buff = new_buff; - - if (!sect_buff) - { - TIFFError("createImageSection", - "Unable to allocate/reallocate section buffer"); - return (-1); - } - _TIFFmemset(sect_buff, 0, sectsize + NUM_BUFF_OVERSIZE_BYTES); - } - } - - prev_sectsize = sectsize; - *sect_buff_ptr = sect_buff; - - return (0); -} /* end createImageSection */ - -/* Process selections defined by regions, zones, margins, or fixed sized areas - */ -static int processCropSelections(struct image_data *image, - struct crop_mask *crop, - unsigned char **read_buff_ptr, - struct buffinfo seg_buffs[]) -{ - int i; - uint32_t width, length, total_width, total_length; - tsize_t cropsize; - unsigned char *crop_buff = NULL; - unsigned char *read_buff = NULL; - unsigned char *next_buff = NULL; - tsize_t prev_cropsize = 0; - - read_buff = *read_buff_ptr; - - if (crop->img_mode == COMPOSITE_IMAGES) - { - cropsize = crop->bufftotal; - crop_buff = seg_buffs[0].buffer; - if (!crop_buff) - crop_buff = (unsigned char *)limitMalloc(cropsize + - NUM_BUFF_OVERSIZE_BYTES); + next_buff = _TIFFrealloc(crop_buff, cropsize + NUM_BUFF_OVERSIZE_BYTES); + if (! next_buff) + { + _TIFFfree (crop_buff); + crop_buff = (unsigned char *)limitMalloc(cropsize + NUM_BUFF_OVERSIZE_BYTES); + } else - { - prev_cropsize = seg_buffs[0].size; - if (prev_cropsize < cropsize) - { - next_buff = - _TIFFrealloc(crop_buff, cropsize + NUM_BUFF_OVERSIZE_BYTES); - if (!next_buff) - { - _TIFFfree(crop_buff); - crop_buff = (unsigned char *)limitMalloc( - cropsize + NUM_BUFF_OVERSIZE_BYTES); - } - else - crop_buff = next_buff; - } + crop_buff = next_buff; } + } - if (!crop_buff) + if (!crop_buff) + { + TIFFError("processCropSelections", "Unable to allocate/reallocate crop buffer"); + return (-1); + } + + _TIFFmemset(crop_buff, 0, cropsize + NUM_BUFF_OVERSIZE_BYTES); + seg_buffs[0].buffer = crop_buff; + seg_buffs[0].size = cropsize; + + /* Checks for matching width or length as required */ + if (extractCompositeRegions(image, crop, read_buff, crop_buff) != 0) + return (1); + + if (crop->crop_mode & CROP_INVERT) + { + switch (crop->photometric) { - TIFFError("processCropSelections", - "Unable to allocate/reallocate crop buffer"); - return (-1); + /* Just change the interpretation */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + image->photometric = crop->photometric; + break; + case INVERT_DATA_ONLY: + case INVERT_DATA_AND_TAG: + if (invertImage(image->photometric, image->spp, image->bps, + crop->combined_width, crop->combined_length, crop_buff)) + { + TIFFError("processCropSelections", + "Failed to invert colorspace for composite regions"); + return (-1); + } + if (crop->photometric == INVERT_DATA_AND_TAG) + { + switch (image->photometric) + { + case PHOTOMETRIC_MINISWHITE: + image->photometric = PHOTOMETRIC_MINISBLACK; + break; + case PHOTOMETRIC_MINISBLACK: + image->photometric = PHOTOMETRIC_MINISWHITE; + break; + default: + break; + } + } + break; + default: break; } + } - _TIFFmemset(crop_buff, 0, cropsize + NUM_BUFF_OVERSIZE_BYTES); - seg_buffs[0].buffer = crop_buff; - seg_buffs[0].size = cropsize; - - /* Checks for matching width or length as required */ - if (extractCompositeRegions(image, crop, read_buff, crop_buff) != 0) - return (1); - - if (crop->crop_mode & CROP_INVERT) + /* Mirror and Rotate will not work with multiple regions unless they are the same width */ + if (crop->crop_mode & CROP_MIRROR) + { + if (mirrorImage(image->spp, image->bps, crop->mirror, + crop->combined_width, crop->combined_length, crop_buff)) { - switch (crop->photometric) - { - /* Just change the interpretation */ - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - image->photometric = crop->photometric; - break; - case INVERT_DATA_ONLY: - case INVERT_DATA_AND_TAG: - if (invertImage(image->photometric, image->spp, image->bps, - crop->combined_width, crop->combined_length, - crop_buff)) - { - TIFFError("processCropSelections", - "Failed to invert colorspace for composite " - "regions"); - return (-1); - } - if (crop->photometric == INVERT_DATA_AND_TAG) - { - switch (image->photometric) - { - case PHOTOMETRIC_MINISWHITE: - image->photometric = PHOTOMETRIC_MINISBLACK; - break; - case PHOTOMETRIC_MINISBLACK: - image->photometric = PHOTOMETRIC_MINISWHITE; - break; - default: - break; - } - } - break; - default: - break; - } + TIFFError("processCropSelections", "Failed to mirror composite regions %s", + (crop->rotation == MIRROR_HORIZ) ? "horizontally" : "vertically"); + return (-1); } + } - /* Mirror and Rotate will not work with multiple regions unless they are - * the same width */ - if (crop->crop_mode & CROP_MIRROR) + if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */ + { + if (rotateImage(crop->rotation, image, &crop->combined_width, + &crop->combined_length, &crop_buff, FALSE)) { - if (mirrorImage(image->spp, image->bps, crop->mirror, - crop->combined_width, crop->combined_length, - crop_buff)) - { - TIFFError("processCropSelections", - "Failed to mirror composite regions %s", - (crop->rotation == MIRROR_HORIZ) ? "horizontally" - : "vertically"); - return (-1); - } - } - - if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can - reallocate the buffer */ - { - /* rotateImage() set up a new buffer and calculates its size - * individually. Therefore, seg_buffs size needs to be updated - * accordingly. */ - size_t rot_buf_size = 0; - if (rotateImage(crop->rotation, image, &crop->combined_width, - &crop->combined_length, &crop_buff, &rot_buf_size, - FALSE)) - { - TIFFError("processCropSelections", - "Failed to rotate composite regions by %" PRIu32 - " degrees", - crop->rotation); - return (-1); - } - seg_buffs[0].buffer = crop_buff; - seg_buffs[0].size = rot_buf_size; + TIFFError("processCropSelections", + "Failed to rotate composite regions by %d degrees", crop->rotation); + return (-1); } + seg_buffs[0].buffer = crop_buff; + seg_buffs[0].size = (((crop->combined_width * image->bps + 7 ) / 8) + * image->spp) * crop->combined_length; + } } - else /* Separated Images */ + else /* Separated Images */ { - total_width = total_length = 0; - for (i = 0; i < crop->selections; i++) + total_width = total_length = 0; + for (i = 0; i < crop->selections; i++) + { + cropsize = crop->bufftotal; + crop_buff = seg_buffs[i].buffer; + if (!crop_buff) + crop_buff = (unsigned char *)limitMalloc(cropsize + NUM_BUFF_OVERSIZE_BYTES); + else { - - cropsize = crop->bufftotal; - crop_buff = seg_buffs[i].buffer; - if (!crop_buff) - crop_buff = (unsigned char *)limitMalloc( - cropsize + NUM_BUFF_OVERSIZE_BYTES); - else + prev_cropsize = seg_buffs[0].size; + if (prev_cropsize < cropsize) + { + next_buff = _TIFFrealloc(crop_buff, cropsize + NUM_BUFF_OVERSIZE_BYTES); + if (! next_buff) { - prev_cropsize = seg_buffs[i].size; - if (prev_cropsize < cropsize) - { - next_buff = _TIFFrealloc( - crop_buff, cropsize + NUM_BUFF_OVERSIZE_BYTES); - if (!next_buff) - { - _TIFFfree(crop_buff); - crop_buff = (unsigned char *)limitMalloc( - cropsize + NUM_BUFF_OVERSIZE_BYTES); - } - else - crop_buff = next_buff; - } + _TIFFfree (crop_buff); + crop_buff = (unsigned char *)limitMalloc(cropsize + NUM_BUFF_OVERSIZE_BYTES); } + else + crop_buff = next_buff; + } + } - if (!crop_buff) - { - TIFFError("processCropSelections", - "Unable to allocate/reallocate crop buffer"); - return (-1); - } + if (!crop_buff) + { + TIFFError("processCropSelections", "Unable to allocate/reallocate crop buffer"); + return (-1); + } + + _TIFFmemset(crop_buff, 0, cropsize + NUM_BUFF_OVERSIZE_BYTES); + seg_buffs[i].buffer = crop_buff; + seg_buffs[i].size = cropsize; - _TIFFmemset(crop_buff, 0, cropsize + NUM_BUFF_OVERSIZE_BYTES); - seg_buffs[i].buffer = crop_buff; - seg_buffs[i].size = cropsize; + if (extractSeparateRegion(image, crop, read_buff, crop_buff, i)) + { + TIFFError("processCropSelections", "Unable to extract cropped region %d from image", i); + return (-1); + } + + width = crop->regionlist[i].width; + length = crop->regionlist[i].length; - if (extractSeparateRegion(image, crop, read_buff, crop_buff, i)) - { - TIFFError("processCropSelections", - "Unable to extract cropped region %d from image", i); - return (-1); - } + if (crop->crop_mode & CROP_INVERT) + { + switch (crop->photometric) + { + /* Just change the interpretation */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + image->photometric = crop->photometric; + break; + case INVERT_DATA_ONLY: + case INVERT_DATA_AND_TAG: + if (invertImage(image->photometric, image->spp, image->bps, + width, length, crop_buff)) + { + TIFFError("processCropSelections", + "Failed to invert colorspace for region"); + return (-1); + } + if (crop->photometric == INVERT_DATA_AND_TAG) + { + switch (image->photometric) + { + case PHOTOMETRIC_MINISWHITE: + image->photometric = PHOTOMETRIC_MINISBLACK; + break; + case PHOTOMETRIC_MINISBLACK: + image->photometric = PHOTOMETRIC_MINISWHITE; + break; + default: + break; + } + } + break; + default: break; + } + } - width = crop->regionlist[i].width; - length = crop->regionlist[i].length; + if (crop->crop_mode & CROP_MIRROR) + { + if (mirrorImage(image->spp, image->bps, crop->mirror, + width, length, crop_buff)) + { + TIFFError("processCropSelections", "Failed to mirror crop region %s", + (crop->rotation == MIRROR_HORIZ) ? "horizontally" : "vertically"); + return (-1); + } + } - if (crop->crop_mode & CROP_INVERT) - { - switch (crop->photometric) - { - /* Just change the interpretation */ - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - image->photometric = crop->photometric; - break; - case INVERT_DATA_ONLY: - case INVERT_DATA_AND_TAG: - if (invertImage(image->photometric, image->spp, - image->bps, width, length, crop_buff)) - { - TIFFError("processCropSelections", - "Failed to invert colorspace for region"); - return (-1); - } - if (crop->photometric == INVERT_DATA_AND_TAG) - { - switch (image->photometric) - { - case PHOTOMETRIC_MINISWHITE: - image->photometric = PHOTOMETRIC_MINISBLACK; - break; - case PHOTOMETRIC_MINISBLACK: - image->photometric = PHOTOMETRIC_MINISWHITE; - break; - default: - break; - } - } - break; - default: - break; - } - } - - if (crop->crop_mode & CROP_MIRROR) - { - if (mirrorImage(image->spp, image->bps, crop->mirror, width, - length, crop_buff)) - { - TIFFError("processCropSelections", - "Failed to mirror crop region %s", - (crop->rotation == MIRROR_HORIZ) ? "horizontally" - : "vertically"); - return (-1); - } - } - - if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it - can reallocate the buffer */ - { - /* rotateImage() changes image->width, ->length, ->xres and - * ->yres, what it schouldn't do here, when more than one - * section is processed. ToDo: Therefore rotateImage() and its - * usage has to be reworked (e.g. like mirrorImage()) !! - * Furthermore, rotateImage() set up a new buffer and calculates - * its size individually. Therefore, seg_buffs size needs to be - * updated accordingly. */ - size_t rot_buf_size = 0; - if (rotateImage(crop->rotation, image, - &crop->regionlist[i].width, - &crop->regionlist[i].length, &crop_buff, - &rot_buf_size, FALSE)) - { - TIFFError("processCropSelections", - "Failed to rotate crop region by %" PRIu16 - " degrees", - crop->rotation); - return (-1); - } - total_width += crop->regionlist[i].width; - total_length += crop->regionlist[i].length; - crop->combined_width = total_width; - crop->combined_length = total_length; - seg_buffs[i].buffer = crop_buff; - seg_buffs[i].size = rot_buf_size; - } - } /* for crop->selections loop */ - } /* Separated Images (else case) */ - return (0); -} /* end processCropSelections */ + if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */ + { + if (rotateImage(crop->rotation, image, &crop->regionlist[i].width, + &crop->regionlist[i].length, &crop_buff, FALSE)) + { + TIFFError("processCropSelections", + "Failed to rotate crop region by %d degrees", crop->rotation); + return (-1); + } + total_width += crop->regionlist[i].width; + total_length += crop->regionlist[i].length; + crop->combined_width = total_width; + crop->combined_length = total_length; + seg_buffs[i].buffer = crop_buff; + seg_buffs[i].size = (((crop->regionlist[i].width * image->bps + 7 ) / 8) + * image->spp) * crop->regionlist[i].length; + } + } + } + return (0); + } /* end processCropSelections */ /* Copy the crop section of the data from the current image into a buffer * and adjust the IFD values to reflect the new size. If no cropping is - * required, use the original read buffer as the crop buffer. + * required, use the origial read buffer as the crop buffer. * * There is quite a bit of redundancy between this routine and the more * specialized processCropSelections, but this provides * the most optimized path when no Zones or Regions are required. */ -static int createCroppedImage(struct image_data *image, struct crop_mask *crop, - unsigned char **read_buff_ptr, - unsigned char **crop_buff_ptr) -{ - tsize_t cropsize; - unsigned char *read_buff = NULL; - unsigned char *crop_buff = NULL; - unsigned char *new_buff = NULL; - static tsize_t prev_cropsize = 0; +static int +createCroppedImage(struct image_data *image, struct crop_mask *crop, + unsigned char **read_buff_ptr, unsigned char **crop_buff_ptr) + { + tsize_t cropsize; + unsigned char *read_buff = NULL; + unsigned char *crop_buff = NULL; + unsigned char *new_buff = NULL; + static tsize_t prev_cropsize = 0; - read_buff = *read_buff_ptr; + read_buff = *read_buff_ptr; - /* Memory is freed before crop_buff_ptr is overwritten */ - if (*crop_buff_ptr != NULL) + /* process full image, no crop buffer needed */ + crop_buff = read_buff; + *crop_buff_ptr = read_buff; + crop->combined_width = image->width; + crop->combined_length = image->length; + + cropsize = crop->bufftotal; + crop_buff = *crop_buff_ptr; + if (!crop_buff) { - _TIFFfree(*crop_buff_ptr); - } - - /* process full image, no crop buffer needed */ - *crop_buff_ptr = read_buff; - crop->combined_width = image->width; - crop->combined_length = image->length; - - cropsize = crop->bufftotal; - crop_buff = *crop_buff_ptr; + crop_buff = (unsigned char *)limitMalloc(cropsize + NUM_BUFF_OVERSIZE_BYTES); if (!crop_buff) { - crop_buff = - (unsigned char *)limitMalloc(cropsize + NUM_BUFF_OVERSIZE_BYTES); - if (!crop_buff) - { - TIFFError("createCroppedImage", - "Unable to allocate/reallocate crop buffer"); - return (-1); - } - _TIFFmemset(crop_buff, 0, cropsize + NUM_BUFF_OVERSIZE_BYTES); - prev_cropsize = cropsize; + TIFFError("createCroppedImage", "Unable to allocate/reallocate crop buffer"); + return (-1); } - else + _TIFFmemset(crop_buff, 0, cropsize + NUM_BUFF_OVERSIZE_BYTES); + prev_cropsize = cropsize; + } + else { - if (prev_cropsize < cropsize) + if (prev_cropsize < cropsize) + { + new_buff = _TIFFrealloc(crop_buff, cropsize + NUM_BUFF_OVERSIZE_BYTES); + if (!new_buff) { - new_buff = - _TIFFrealloc(crop_buff, cropsize + NUM_BUFF_OVERSIZE_BYTES); - if (!new_buff) - { - free(crop_buff); - crop_buff = (unsigned char *)limitMalloc( - cropsize + NUM_BUFF_OVERSIZE_BYTES); - } - else - crop_buff = new_buff; - if (!crop_buff) - { - TIFFError("createCroppedImage", - "Unable to allocate/reallocate crop buffer"); - return (-1); - } - _TIFFmemset(crop_buff, 0, cropsize + NUM_BUFF_OVERSIZE_BYTES); + free (crop_buff); + crop_buff = (unsigned char *)limitMalloc(cropsize + NUM_BUFF_OVERSIZE_BYTES); } + else + crop_buff = new_buff; + if (!crop_buff) + { + TIFFError("createCroppedImage", "Unable to allocate/reallocate crop buffer"); + return (-1); + } + _TIFFmemset(crop_buff, 0, cropsize + NUM_BUFF_OVERSIZE_BYTES); + } } - *crop_buff_ptr = crop_buff; + *crop_buff_ptr = crop_buff; - if (crop->crop_mode & CROP_INVERT) + if (crop->crop_mode & CROP_INVERT) { - switch (crop->photometric) - { - /* Just change the interpretation */ - case PHOTOMETRIC_MINISWHITE: - case PHOTOMETRIC_MINISBLACK: - image->photometric = crop->photometric; - break; - case INVERT_DATA_ONLY: - case INVERT_DATA_AND_TAG: - if (invertImage(image->photometric, image->spp, image->bps, - crop->combined_width, crop->combined_length, - crop_buff)) - { - TIFFError("createCroppedImage", - "Failed to invert colorspace for image or " - "cropped selection"); - return (-1); - } - if (crop->photometric == INVERT_DATA_AND_TAG) - { - switch (image->photometric) - { - case PHOTOMETRIC_MINISWHITE: - image->photometric = PHOTOMETRIC_MINISBLACK; - break; - case PHOTOMETRIC_MINISBLACK: - image->photometric = PHOTOMETRIC_MINISWHITE; - break; - default: - break; - } - } - break; - default: - break; - } + switch (crop->photometric) + { + /* Just change the interpretation */ + case PHOTOMETRIC_MINISWHITE: + case PHOTOMETRIC_MINISBLACK: + image->photometric = crop->photometric; + break; + case INVERT_DATA_ONLY: + case INVERT_DATA_AND_TAG: + if (invertImage(image->photometric, image->spp, image->bps, + crop->combined_width, crop->combined_length, crop_buff)) + { + TIFFError("createCroppedImage", + "Failed to invert colorspace for image or cropped selection"); + return (-1); + } + if (crop->photometric == INVERT_DATA_AND_TAG) + { + switch (image->photometric) + { + case PHOTOMETRIC_MINISWHITE: + image->photometric = PHOTOMETRIC_MINISBLACK; + break; + case PHOTOMETRIC_MINISBLACK: + image->photometric = PHOTOMETRIC_MINISWHITE; + break; + default: + break; + } + } + break; + default: break; + } } - if (crop->crop_mode & CROP_MIRROR) + if (crop->crop_mode & CROP_MIRROR) { - if (mirrorImage(image->spp, image->bps, crop->mirror, - crop->combined_width, crop->combined_length, crop_buff)) - { - TIFFError("createCroppedImage", - "Failed to mirror image or cropped selection %s", - (crop->rotation == MIRROR_HORIZ) ? "horizontally" - : "vertically"); - return (-1); - } + if (mirrorImage(image->spp, image->bps, crop->mirror, + crop->combined_width, crop->combined_length, crop_buff)) + { + TIFFError("createCroppedImage", "Failed to mirror image or cropped selection %s", + (crop->rotation == MIRROR_HORIZ) ? "horizontally" : "vertically"); + return (-1); + } } - if (crop->crop_mode & - CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */ + if (crop->crop_mode & CROP_ROTATE) /* rotate should be last as it can reallocate the buffer */ { - if (rotateImage(crop->rotation, image, &crop->combined_width, - &crop->combined_length, crop_buff_ptr, NULL, TRUE)) - { - TIFFError("createCroppedImage", - "Failed to rotate image or cropped selection by %" PRIu16 - " degrees", - crop->rotation); - return (-1); - } + if (rotateImage(crop->rotation, image, &crop->combined_width, + &crop->combined_length, crop_buff_ptr, TRUE)) + { + TIFFError("createCroppedImage", + "Failed to rotate image or cropped selection by %d degrees", crop->rotation); + return (-1); + } } - if (crop_buff == - read_buff) /* we used the read buffer for the crop buffer */ - *read_buff_ptr = NULL; /* so we don't try to free it later */ + if (crop_buff == read_buff) /* we used the read buffer for the crop buffer */ + *read_buff_ptr = NULL; /* so we don't try to free it later */ + + return (0); + } /* end createCroppedImage */ - return (0); -} /* end createCroppedImage */ /* Code in this function is heavily indebted to code in tiffcp * with modifications by Richard Nolde to handle orientation correctly. * It will have to be updated significantly if support is added to - * extract one or more samples from original image since the + * extract one or more samples from original image since the * original code assumes we are always copying all samples. * Use of global variables for config, compression and others * should be replaced by addition to the crop_mask struct (which * will be renamed to proc_opts indicating that is controls - * user supplied processing options, not just cropping) and + * user supplied processing options, not just cropping) and * then passed in as an argument. */ -static int writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, - struct dump_opts *dump, uint32_t width, - uint32_t length, unsigned char *crop_buff, - int pagenum, int total_pages) -{ - uint16_t bps, spp; - uint16_t input_compression, input_photometric; - uint16_t input_planar; - const struct cpTag *p; +static int +writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image, + struct dump_opts *dump, uint32 width, uint32 length, + unsigned char *crop_buff, int pagenum, int total_pages) + { + uint16 bps, spp; + uint16 input_compression, input_photometric; + uint16 input_planar; + struct cpTag* p; - input_compression = image->compression; - input_photometric = image->photometric; - spp = image->spp; - bps = image->bps; + input_compression = image->compression; + input_photometric = image->photometric; + spp = image->spp; + bps = image->bps; - TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, length); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bps); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); + TIFFSetField(out, TIFFTAG_IMAGEWIDTH, width); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, length); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, bps); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, spp); #ifdef DEBUG2 - TIFFError("writeCroppedImage", "Input compression: %s", - (input_compression == COMPRESSION_OJPEG) - ? "Old Jpeg" - : ((input_compression == COMPRESSION_JPEG) ? "New Jpeg" - : "Non Jpeg")); + TIFFError("writeCroppedImage", "Input compression: %s", + (input_compression == COMPRESSION_OJPEG) ? "Old Jpeg" : + ((input_compression == COMPRESSION_JPEG) ? "New Jpeg" : "Non Jpeg")); #endif - if (compression != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + if (compression != (uint16)-1) + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + else + { + if (input_compression == COMPRESSION_OJPEG) + { + compression = COMPRESSION_JPEG; + jpegcolormode = JPEGCOLORMODE_RAW; + TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); + } else - { - if (input_compression == COMPRESSION_OJPEG) - { - compression = COMPRESSION_JPEG; - jpegcolormode = JPEGCOLORMODE_RAW; - TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_JPEG); - } - else - CopyField(TIFFTAG_COMPRESSION, compression); + CopyField(TIFFTAG_COMPRESSION, compression); } - if (compression == COMPRESSION_JPEG) + if (compression == COMPRESSION_JPEG) { - if ((input_photometric == - PHOTOMETRIC_PALETTE) || /* color map indexed */ - (input_photometric == PHOTOMETRIC_MASK)) /* $holdout mask */ - { - TIFFError("writeCroppedImage", - "JPEG compression cannot be used with %s image data", - (input_photometric == PHOTOMETRIC_PALETTE) ? "palette" - : "mask"); - return (-1); - } - if ((input_photometric == PHOTOMETRIC_RGB) && - (jpegcolormode == JPEGCOLORMODE_RGB)) - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); - else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); - } + if ((input_photometric == PHOTOMETRIC_PALETTE) || /* color map indexed */ + (input_photometric == PHOTOMETRIC_MASK)) /* $holdout mask */ + { + TIFFError ("writeCroppedImage", + "JPEG compression cannot be used with %s image data", + (input_photometric == PHOTOMETRIC_PALETTE) ? + "palette" : "mask"); + return (-1); + } + if ((input_photometric == PHOTOMETRIC_RGB) && + (jpegcolormode == JPEGCOLORMODE_RGB)) + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_YCBCR); else - { - if (compression == COMPRESSION_SGILOG || - compression == COMPRESSION_SGILOG24) - { - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - spp == 1 ? PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); - } - else - { - if (input_compression == COMPRESSION_SGILOG || - input_compression == COMPRESSION_SGILOG24) - { - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, - spp == 1 ? PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); - } - else - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, image->photometric); - } + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, input_photometric); } - - if (((input_photometric == PHOTOMETRIC_LOGL) || - (input_photometric == PHOTOMETRIC_LOGLUV)) && - ((compression != COMPRESSION_SGILOG) && - (compression != COMPRESSION_SGILOG24))) + else { - TIFFError("writeCroppedImage", "LogL and LogLuv source data require " - "SGI_LOG or SGI_LOG24 compression"); - return (-1); - } - - if (fillorder != 0) - TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); + if (compression == COMPRESSION_SGILOG || compression == COMPRESSION_SGILOG24) + { + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, spp == 1 ? + PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); + } else - CopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT); + { + if (input_compression == COMPRESSION_SGILOG || + input_compression == COMPRESSION_SGILOG24) + { + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, spp == 1 ? + PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV); + } + else + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, image->photometric); + } + } - /* The loadimage function reads input orientation and sets - * image->orientation. The correct_image_orientation function - * applies the required rotation and mirror operations to - * present the data in TOPLEFT orientation and updates - * image->orientation if any transforms are performed, - * as per EXIF standard. - */ - TIFFSetField(out, TIFFTAG_ORIENTATION, image->orientation); + if (((input_photometric == PHOTOMETRIC_LOGL) || + (input_photometric == PHOTOMETRIC_LOGLUV)) && + ((compression != COMPRESSION_SGILOG) && + (compression != COMPRESSION_SGILOG24))) + { + TIFFError("writeCroppedImage", + "LogL and LogLuv source data require SGI_LOG or SGI_LOG24 compression"); + return (-1); + } + if (fillorder != 0) + TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); + else + CopyTag(TIFFTAG_FILLORDER, 1, TIFF_SHORT); + + /* The loadimage function reads input orientation and sets + * image->orientation. The correct_image_orientation function + * applies the required rotation and mirror operations to + * present the data in TOPLEFT orientation and updates + * image->orientation if any transforms are performed, + * as per EXIF standard. + */ + TIFFSetField(out, TIFFTAG_ORIENTATION, image->orientation); + + /* + * Choose tiles/strip for the output image according to + * the command line arguments (-tiles, -strips) and the + * structure of the input image. + */ + if (outtiled == -1) + outtiled = TIFFIsTiled(in); + if (outtiled) { /* - * Choose tiles/strip for the output image according to - * the command line arguments (-tiles, -strips) and the - * structure of the input image. + * Setup output file's tile width&height. If either + * is not specified, use either the value from the + * input image or, if nothing is defined, use the + * library default. */ - if (outtiled == -1) - outtiled = TIFFIsTiled(in); - if (outtiled) - { - /* - * Setup output file's tile width&height. If either - * is not specified, use either the value from the - * input image or, if nothing is defined, use the - * library default. - */ - if (tilewidth == (uint32_t)0) - TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); - if (tilelength == (uint32_t)0) - TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); + if (tilewidth == (uint32) 0) + TIFFGetField(in, TIFFTAG_TILEWIDTH, &tilewidth); + if (tilelength == (uint32) 0) + TIFFGetField(in, TIFFTAG_TILELENGTH, &tilelength); - if (tilewidth == 0 || tilelength == 0) - TIFFDefaultTileSize(out, &tilewidth, &tilelength); - TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); - TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); - } + if (tilewidth == 0 || tilelength == 0) + TIFFDefaultTileSize(out, &tilewidth, &tilelength); + TIFFSetField(out, TIFFTAG_TILEWIDTH, tilewidth); + TIFFSetField(out, TIFFTAG_TILELENGTH, tilelength); + } else { + /* + * RowsPerStrip is left unspecified: use either the + * value from the input image or, if nothing is defined, + * use the library default. + */ + if (rowsperstrip == (uint32) 0) + { + if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) + rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); + if (compression != COMPRESSION_JPEG) + { + if (rowsperstrip > length) + rowsperstrip = length; + } + } + else + if (rowsperstrip == (uint32) -1) + rowsperstrip = length; + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + } + + TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &input_planar); + if (config != (uint16) -1) + TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + else + CopyField(TIFFTAG_PLANARCONFIG, config); + if (spp <= 4) + CopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT); + CopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT); + +/* SMinSampleValue & SMaxSampleValue */ + switch (compression) { + case COMPRESSION_JPEG: + if (((bps % 8) == 0) || ((bps % 12) == 0)) + { + TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); + TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + } + else + { + TIFFError("writeCroppedImage", + "JPEG compression requires 8 or 12 bits per sample"); + return (-1); + } + break; + case COMPRESSION_LZW: + case COMPRESSION_ADOBE_DEFLATE: + case COMPRESSION_DEFLATE: + if (predictor != (uint16)-1) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + else + CopyField(TIFFTAG_PREDICTOR, predictor); + break; + case COMPRESSION_CCITTFAX3: + case COMPRESSION_CCITTFAX4: + if (bps != 1) + { + TIFFError("writeCroppedImage", + "Group 3/4 compression is not usable with bps > 1"); + return (-1); + } + if (compression == COMPRESSION_CCITTFAX3) { + if (g3opts != (uint32) -1) + TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); + else + CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); + } else { + CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); + } + CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); + CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); + CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); + break; + case COMPRESSION_NONE: + break; + default: break; + } + { uint32 len32; + void** data; + if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) + TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); + } + { uint16 ninks; + const char* inknames; + if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) { + TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); + if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) { + int inknameslen = (int)strlen(inknames) + 1; + const char* cp = inknames; + while (ninks > 1) { + cp = strchr(cp, '\0'); + if (cp) { + cp++; + inknameslen += ((int)strlen(cp) + 1); + } + ninks--; + } + TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); + } + } + } + { + unsigned short pg0, pg1; + if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) { + TIFFSetField(out, TIFFTAG_PAGENUMBER, pagenum, total_pages); + } + } + + for (p = tags; p < &tags[NTAGS]; p++) + CopyTag(p->tag, p->count, p->type); + + /* Compute the tile or strip dimensions and write to disk */ + if (outtiled) + { + if (config == PLANARCONFIG_CONTIG) + { + if (writeBufferToContigTiles (out, crop_buff, length, width, spp, dump)) + TIFFError("","Unable to write contiguous tile data for page %d", pagenum); + } else - { - /* - * RowsPerStrip is left unspecified: use either the - * value from the input image or, if nothing is defined, - * use the library default. - */ - if (rowsperstrip == (uint32_t)0) - { - if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip)) - rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); - if (compression != COMPRESSION_JPEG) - { - if (rowsperstrip > length) - rowsperstrip = length; - } - } - else if (rowsperstrip == (uint32_t)-1) - rowsperstrip = length; - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + { + if (writeBufferToSeparateTiles (out, crop_buff, length, width, spp, dump)) + TIFFError("","Unable to write separate tile data for page %d", pagenum); + } } - - TIFFGetFieldDefaulted(in, TIFFTAG_PLANARCONFIG, &input_planar); - if (config != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_PLANARCONFIG, config); + else + { + if (config == PLANARCONFIG_CONTIG) + { + if (writeBufferToContigStrips (out, crop_buff, length)) + TIFFError("","Unable to write contiguous strip data for page %d", pagenum); + } else - CopyField(TIFFTAG_PLANARCONFIG, config); - if (spp <= 4) - CopyTag(TIFFTAG_TRANSFERFUNCTION, 4, TIFF_SHORT); - CopyTag(TIFFTAG_COLORMAP, 4, TIFF_SHORT); + { + if (writeBufferToSeparateStrips(out, crop_buff, length, width, spp, dump)) + TIFFError("","Unable to write separate strip data for page %d", pagenum); + } + } - /* SMinSampleValue & SMaxSampleValue */ - switch (compression) + if (!TIFFWriteDirectory(out)) { - case COMPRESSION_JPEG: - if (((bps % 8) == 0) || ((bps % 12) == 0)) - { - TIFFSetField(out, TIFFTAG_JPEGQUALITY, quality); - TIFFSetField(out, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); - } - else - { - TIFFError("writeCroppedImage", - "JPEG compression requires 8 or 12 bits per sample"); - return (-1); - } - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != (uint16_t)-1) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - else - CopyField(TIFFTAG_PREDICTOR, predictor); - break; - case COMPRESSION_CCITTFAX3: - case COMPRESSION_CCITTFAX4: - if (bps != 1) - { - TIFFError("writeCroppedImage", - "Group 3/4 compression is not usable with bps > 1"); - return (-1); - } - if (compression == COMPRESSION_CCITTFAX3) - { - if (g3opts != (uint32_t)-1) - TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts); - else - CopyField(TIFFTAG_GROUP3OPTIONS, g3opts); - } - else - { - CopyTag(TIFFTAG_GROUP4OPTIONS, 1, TIFF_LONG); - } - CopyTag(TIFFTAG_BADFAXLINES, 1, TIFF_LONG); - CopyTag(TIFFTAG_CLEANFAXDATA, 1, TIFF_LONG); - CopyTag(TIFFTAG_CONSECUTIVEBADFAXLINES, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXRECVPARAMS, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXRECVTIME, 1, TIFF_LONG); - CopyTag(TIFFTAG_FAXSUBADDRESS, 1, TIFF_ASCII); - break; - case COMPRESSION_NONE: - break; - default: - break; + TIFFError("","Failed to write IFD for page number %d", pagenum); + return (-1); } + + return (0); + } /* end writeCroppedImage */ + +static int +rotateContigSamples8bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0; + uint32 src_byte = 0, src_bit = 0; + uint32 row, rowsize = 0, bit_offset = 0; + uint8 matchbits = 0, maskbits = 0; + uint8 buff1 = 0, buff2 = 0; + uint8 *next; + tsample_t sample; + + if ((src == NULL) || (dst == NULL)) { - uint32_t len32; - void **data; - if (TIFFGetField(in, TIFFTAG_ICCPROFILE, &len32, &data)) - TIFFSetField(out, TIFFTAG_ICCPROFILE, len32, data); + TIFFError("rotateContigSamples8bits","Invalid src or destination buffer"); + return (1); } + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint8)-1 >> ( 8 - bps); + buff1 = buff2 = 0; + + for (row = 0; row < length ; row++) { - uint16_t ninks; - const char *inknames; - if (TIFFGetField(in, TIFFTAG_NUMBEROFINKS, &ninks)) + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) { - TIFFSetField(out, TIFFTAG_NUMBEROFINKS, ninks); - if (TIFFGetField(in, TIFFTAG_INKNAMES, &inknames)) - { - int inknameslen = (int)strlen(inknames) + 1; - const char *cp = inknames; - while (ninks > 1) - { - cp = strchr(cp, '\0'); - if (cp) - { - cp++; - inknameslen += ((int)strlen(cp) + 1); - } - ninks--; - } - TIFFSetField(out, TIFFTAG_INKNAMES, inknameslen, inknames); - } + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; } - } - { - unsigned short pg0, pg1; - if (TIFFGetField(in, TIFFTAG_PAGENUMBER, &pg0, &pg1)) + else { - TIFFSetField(out, TIFFTAG_PAGENUMBER, pagenum, total_pages); + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; } - } - for (p = tags; p < &tags[NTAGS]; p++) - CopyTag(p->tag, p->count, p->type); + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + return (1); + } + matchbits = maskbits << (8 - src_bit - bps); + buff1 = ((*next) & matchbits) << (src_bit); - /* Compute the tile or strip dimensions and write to disk */ - if (outtiled) - { - if (config == PLANARCONFIG_CONTIG) + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) { - if (writeBufferToContigTiles(out, crop_buff, length, width, spp, - dump)) - TIFFError("", - "Unable to write contiguous tile data for page %d", - pagenum); + *dst++ = buff2; + buff2 = buff1; + ready_bits -= 8; } - else + else { - if (writeBufferToSeparateTiles(out, crop_buff, length, width, spp, - dump)) - TIFFError("", "Unable to write separate tile data for page %d", - pagenum); + buff2 = (buff2 | (buff1 >> ready_bits)); } + ready_bits += bps; + } } - else + + if (ready_bits > 0) { - if (config == PLANARCONFIG_CONTIG) + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; + } + + return (0); + } /* end rotateContigSamples8bits */ + + +static int +rotateContigSamples16bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0; + uint32 row, rowsize, bit_offset; + uint32 src_byte = 0, src_bit = 0; + uint16 matchbits = 0, maskbits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + uint8 *next; + tsample_t sample; + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("rotateContigSamples16bits","Invalid src or destination buffer"); + return (1); + } + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint16)-1 >> (16 - bps); + buff1 = buff2 = 0; + for (row = 0; row < length; row++) + { + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) { - if (writeBufferToContigStrips(out, crop_buff, length)) - TIFFError("", - "Unable to write contiguous strip data for page %d", - pagenum); + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; } - else + else { - if (writeBufferToSeparateStrips(out, crop_buff, length, width, spp, - dump)) - TIFFError("", "Unable to write separate strip data for page %d", - pagenum); + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; } - } - if (!TIFFWriteDirectory(out)) - { - TIFFError("", "Failed to write IFD for page number %d", pagenum); - return (-1); - } + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + return (1); + } + matchbits = maskbits << (16 - src_bit - bps); + if (little_endian) + buff1 = (next[0] << 8) | next[1]; + else + buff1 = (next[1] << 8) | next[0]; - return (0); -} /* end writeCroppedImage */ + buff1 = (buff1 & matchbits) << (src_bit); -static int rotateContigSamples8bits(uint16_t rotation, uint16_t spp, - uint16_t bps, uint32_t width, - uint32_t length, uint32_t col, uint8_t *src, - uint8_t *dst) -{ - int ready_bits = 0; - uint32_t src_byte = 0, src_bit = 0; - uint32_t row, rowsize = 0, bit_offset = 0; - uint8_t matchbits = 0, maskbits = 0; - uint8_t buff1 = 0, buff2 = 0; - uint8_t *next; - tsample_t sample; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("rotateContigSamples8bits", - "Invalid src or destination buffer"); - return (1); - } - - rowsize = ((bps * spp * width) + 7) / 8; - ready_bits = 0; - maskbits = (uint8_t)-1 >> (8 - bps); - buff1 = buff2 = 0; - - for (row = 0; row < length; row++) - { - bit_offset = col * bps * spp; - for (sample = 0; sample < spp; sample++) + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 8) { - if (sample == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sample * bps)) / 8; - src_bit = (bit_offset + (sample * bps)) % 8; - } - - switch (rotation) - { - case 90: - next = src + src_byte - (row * rowsize); - break; - case 270: - next = src + src_byte + (row * rowsize); - break; - default: - TIFFError("rotateContigSamples8bits", - "Invalid rotation %" PRIu16, rotation); - return (1); - } - matchbits = maskbits << (8 - src_bit - bps); - buff1 = ((*next) & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 8) - { - *dst++ = buff2; - buff2 = buff1; - ready_bits -= 8; - } - else - { - buff2 = (buff2 | (buff1 >> ready_bits)); - } - ready_bits += bps; - } - } - - if (ready_bits > 0) - { - buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); - *dst++ = buff1; - } - - return (0); -} /* end rotateContigSamples8bits */ - -static int rotateContigSamples16bits(uint16_t rotation, uint16_t spp, - uint16_t bps, uint32_t width, - uint32_t length, uint32_t col, - uint8_t *src, uint8_t *dst) -{ - int ready_bits = 0; - uint32_t row, rowsize, bit_offset; - uint32_t src_byte = 0, src_bit = 0; - uint16_t matchbits = 0, maskbits = 0; - uint16_t buff1 = 0, buff2 = 0; - uint8_t bytebuff = 0; - uint8_t *next; - tsample_t sample; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("rotateContigSamples16bits", - "Invalid src or destination buffer"); - return (1); - } - - rowsize = ((bps * spp * width) + 7) / 8; - ready_bits = 0; - maskbits = (uint16_t)-1 >> (16 - bps); - buff1 = buff2 = 0; - for (row = 0; row < length; row++) - { - bit_offset = col * bps * spp; - for (sample = 0; sample < spp; sample++) - { - if (sample == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sample * bps)) / 8; - src_bit = (bit_offset + (sample * bps)) % 8; - } - - switch (rotation) - { - case 90: - next = src + src_byte - (row * rowsize); - break; - case 270: - next = src + src_byte + (row * rowsize); - break; - default: - TIFFError("rotateContigSamples8bits", - "Invalid rotation %" PRIu16, rotation); - return (1); - } - matchbits = maskbits << (16 - src_bit - bps); - if (little_endian) - buff1 = (next[0] << 8) | next[1]; - else - buff1 = (next[1] << 8) | next[0]; - - buff1 = (buff1 & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 8) - { - bytebuff = (buff2 >> 8); - *dst++ = bytebuff; - ready_bits -= 8; - /* shift in new bits */ - buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); - } - else - { /* add another bps bits to the buffer */ - bytebuff = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - ready_bits += bps; - } - } - - if (ready_bits > 0) - { bytebuff = (buff2 >> 8); *dst++ = bytebuff; - } - - return (0); -} /* end rotateContigSamples16bits */ - -static int rotateContigSamples24bits(uint16_t rotation, uint16_t spp, - uint16_t bps, uint32_t width, - uint32_t length, uint32_t col, - uint8_t *src, uint8_t *dst) -{ - int ready_bits = 0; - uint32_t row, rowsize, bit_offset; - uint32_t src_byte = 0, src_bit = 0; - uint32_t matchbits = 0, maskbits = 0; - uint32_t buff1 = 0, buff2 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0; - uint8_t *next; - tsample_t sample; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("rotateContigSamples24bits", - "Invalid src or destination buffer"); - return (1); - } - - rowsize = ((bps * spp * width) + 7) / 8; - ready_bits = 0; - maskbits = (uint32_t)-1 >> (32 - bps); - buff1 = buff2 = 0; - for (row = 0; row < length; row++) - { - bit_offset = col * bps * spp; - for (sample = 0; sample < spp; sample++) - { - if (sample == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sample * bps)) / 8; - src_bit = (bit_offset + (sample * bps)) % 8; - } - - switch (rotation) - { - case 90: - next = src + src_byte - (row * rowsize); - break; - case 270: - next = src + src_byte + (row * rowsize); - break; - default: - TIFFError("rotateContigSamples8bits", - "Invalid rotation %" PRIu16, rotation); - return (1); - } - matchbits = maskbits << (32 - src_bit - bps); - if (little_endian) - buff1 = (next[0] << 24) | (next[1] << 16) | (next[2] << 8) | - next[3]; - else - buff1 = (next[3] << 24) | (next[2] << 16) | (next[1] << 8) | - next[0]; - buff1 = (buff1 & matchbits) << (src_bit); - - /* If we have a full buffer's worth, write it out */ - if (ready_bits >= 16) - { - bytebuff1 = (buff2 >> 24); - *dst++ = bytebuff1; - bytebuff2 = (buff2 >> 16); - *dst++ = bytebuff2; - ready_bits -= 16; - - /* shift in new bits */ - buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); - } - else - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - ready_bits += bps; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); } + else + { /* add another bps bits to the buffer */ + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + ready_bits += bps; + } } - /* catch any trailing bits at the end of the line */ - while (ready_bits > 0) + if (ready_bits > 0) { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + } + + return (0); + } /* end rotateContigSamples16bits */ + +static int +rotateContigSamples24bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0; + uint32 row, rowsize, bit_offset; + uint32 src_byte = 0, src_bit = 0; + uint32 matchbits = 0, maskbits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + uint8 *next; + tsample_t sample; + + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("rotateContigSamples24bits","Invalid src or destination buffer"); + return (1); + } + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint32)-1 >> (32 - bps); + buff1 = buff2 = 0; + for (row = 0; row < length; row++) + { + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; + } + + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + return (1); + } + matchbits = maskbits << (32 - src_bit - bps); + if (little_endian) + buff1 = (next[0] << 24) | (next[1] << 16) | (next[2] << 8) | next[3]; + else + buff1 = (next[3] << 24) | (next[2] << 16) | (next[1] << 8) | next[0]; + buff1 = (buff1 & matchbits) << (src_bit); + + /* If we have a full buffer's worth, write it out */ + if (ready_bits >= 16) + { bytebuff1 = (buff2 >> 24); *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; - buff2 = (buff2 << 8); - bytebuff2 = bytebuff1; - ready_bits -= 8; - } - - return (0); -} /* end rotateContigSamples24bits */ - -static int rotateContigSamples32bits(uint16_t rotation, uint16_t spp, - uint16_t bps, uint32_t width, - uint32_t length, uint32_t col, - uint8_t *src, uint8_t *dst) -{ - int ready_bits = 0 /*, shift_width = 0 */; - /* int bytes_per_sample, bytes_per_pixel; */ - uint32_t row, rowsize, bit_offset; - uint32_t src_byte, src_bit; - uint32_t longbuff1 = 0, longbuff2 = 0; - uint64_t maskbits = 0, matchbits = 0; - uint64_t buff1 = 0, buff2 = 0, buff3 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; - uint8_t *next; - tsample_t sample; - - if ((src == NULL) || (dst == NULL)) - { - TIFFError("rotateContigSamples24bits", - "Invalid src or destination buffer"); - return (1); - } - - /* bytes_per_sample = (bps + 7) / 8; */ - /* bytes_per_pixel = ((bps * spp) + 7) / 8; */ - /* if (bytes_per_pixel < (bytes_per_sample + 1)) */ - /* shift_width = bytes_per_pixel; */ - /* else */ - /* shift_width = bytes_per_sample + 1; */ - - rowsize = ((bps * spp * width) + 7) / 8; - ready_bits = 0; - maskbits = (uint64_t)-1 >> (64 - bps); - buff1 = buff2 = 0; - for (row = 0; row < length; row++) - { - bit_offset = col * bps * spp; - for (sample = 0; sample < spp; sample++) - { - if (sample == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sample * bps)) / 8; - src_bit = (bit_offset + (sample * bps)) % 8; - } - - switch (rotation) - { - case 90: - next = src + src_byte - (row * rowsize); - break; - case 270: - next = src + src_byte + (row * rowsize); - break; - default: - TIFFError("rotateContigSamples8bits", - "Invalid rotation %" PRIu16, rotation); - return (1); - } - matchbits = maskbits << (64 - src_bit - bps); - if (little_endian) - { - longbuff1 = (next[0] << 24) | (next[1] << 16) | (next[2] << 8) | - next[3]; - longbuff2 = longbuff1; - } - else - { - longbuff1 = (next[3] << 24) | (next[2] << 16) | (next[1] << 8) | - next[0]; - longbuff2 = longbuff1; - } - - buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; - buff1 = (buff3 & matchbits) << (src_bit); - - if (ready_bits < 32) - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - else /* If we have a full buffer's worth, write it out */ - { - bytebuff1 = (uint8_t)(buff2 >> 56); - *dst++ = bytebuff1; - bytebuff2 = (uint8_t)(buff2 >> 48); - *dst++ = bytebuff2; - bytebuff3 = (uint8_t)(buff2 >> 40); - *dst++ = bytebuff3; - bytebuff4 = (uint8_t)(buff2 >> 32); - *dst++ = bytebuff4; - ready_bits -= 32; - - /* shift in new bits */ - buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); - } - ready_bits += bps; + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); } - } - while (ready_bits > 0) - { - bytebuff1 = (buff2 >> 56); - *dst++ = bytebuff1; - buff2 = (buff2 << 8); - ready_bits -= 8; + else + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + ready_bits += bps; + } } - return (0); -} /* end rotateContigSamples32bits */ + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + return (0); + } /* end rotateContigSamples24bits */ + +static int +rotateContigSamples32bits(uint16 rotation, uint16 spp, uint16 bps, uint32 width, + uint32 length, uint32 col, uint8 *src, uint8 *dst) + { + int ready_bits = 0 /*, shift_width = 0 */; + /* int bytes_per_sample, bytes_per_pixel; */ + uint32 row, rowsize, bit_offset; + uint32 src_byte, src_bit; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 maskbits = 0, matchbits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + uint8 *next; + tsample_t sample; + + + if ((src == NULL) || (dst == NULL)) + { + TIFFError("rotateContigSamples24bits","Invalid src or destination buffer"); + return (1); + } + + /* bytes_per_sample = (bps + 7) / 8; */ + /* bytes_per_pixel = ((bps * spp) + 7) / 8; */ + /* if (bytes_per_pixel < (bytes_per_sample + 1)) */ + /* shift_width = bytes_per_pixel; */ + /* else */ + /* shift_width = bytes_per_sample + 1; */ + + rowsize = ((bps * spp * width) + 7) / 8; + ready_bits = 0; + maskbits = (uint64)-1 >> (64 - bps); + buff1 = buff2 = 0; + for (row = 0; row < length; row++) + { + bit_offset = col * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; + } + + switch (rotation) + { + case 90: next = src + src_byte - (row * rowsize); + break; + case 270: next = src + src_byte + (row * rowsize); + break; + default: TIFFError("rotateContigSamples8bits", "Invalid rotation %d", rotation); + return (1); + } + matchbits = maskbits << (64 - src_bit - bps); + if (little_endian) + { + longbuff1 = (next[0] << 24) | (next[1] << 16) | (next[2] << 8) | next[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (next[3] << 24) | (next[2] << 16) | (next[1] << 8) | next[0]; + longbuff2 = longbuff1; + } + + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & matchbits) << (src_bit); + + if (ready_bits < 32) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (uint8)(buff2 >> 56); + *dst++ = bytebuff1; + bytebuff2 = (uint8)(buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (uint8)(buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (uint8)(buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; + } + + return (0); + } /* end rotateContigSamples32bits */ + /* Rotate an image by a multiple of 90 degrees clockwise */ -static int rotateImage(uint16_t rotation, struct image_data *image, - uint32_t *img_width, uint32_t *img_length, - unsigned char **ibuff_ptr, size_t *rot_buf_size, - int rot_image_params) -{ - int shift_width; - uint32_t bytes_per_pixel, bytes_per_sample; - uint32_t row, rowsize, src_offset, dst_offset; - uint32_t i, col, width, length; - uint32_t colsize, col_offset, pix_offset; - tmsize_t buffsize; - unsigned char *ibuff; - unsigned char *src; - unsigned char *dst; - uint16_t spp, bps; - float res_temp; - unsigned char *rbuff = NULL; +static int +rotateImage(uint16 rotation, struct image_data *image, uint32 *img_width, + uint32 *img_length, unsigned char **ibuff_ptr, int rot_image_params) + { + int shift_width; + uint32 bytes_per_pixel, bytes_per_sample; + uint32 row, rowsize, src_offset, dst_offset; + uint32 i, col, width, length; + uint32 colsize, buffsize, col_offset, pix_offset; + unsigned char *ibuff; + unsigned char *src; + unsigned char *dst; + uint16 spp, bps; + float res_temp; + unsigned char *rbuff = NULL; - width = *img_width; - length = *img_length; - spp = image->spp; - bps = image->bps; + width = *img_width; + length = *img_length; + spp = image->spp; + bps = image->bps; - if ((spp != 0 && bps != 0 && - width > (uint32_t)((UINT32_MAX - 7) / spp / bps)) || - (spp != 0 && bps != 0 && - length > (uint32_t)((UINT32_MAX - 7) / spp / bps))) + rowsize = ((bps * spp * width) + 7) / 8; + colsize = ((bps * spp * length) + 7) / 8; + if ((colsize * width) > (rowsize * length)) + buffsize = (colsize + 1) * width; + else + buffsize = (rowsize + 1) * length; + + bytes_per_sample = (bps + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if (bytes_per_pixel < (bytes_per_sample + 1)) + shift_width = bytes_per_pixel; + else + shift_width = bytes_per_sample + 1; + + switch (rotation) { - TIFFError("rotateImage", "Integer overflow detected."); - return (-1); - } - rowsize = ((bps * spp * width) + 7) / 8; - colsize = ((bps * spp * length) + 7) / 8; - if ((colsize * width) > (rowsize * length)) - { - if (((tmsize_t)colsize + 1) != 0 && - (tmsize_t)width > ((TIFF_TMSIZE_T_MAX - NUM_BUFF_OVERSIZE_BYTES) / - ((tmsize_t)colsize + 1))) - { - TIFFError("rotateImage", - "Integer overflow when calculating buffer size."); - return (-1); - } - buffsize = ((tmsize_t)colsize + 1) * width; - } - else - { - if (((tmsize_t)rowsize + 1) != 0 && - (tmsize_t)length > ((TIFF_TMSIZE_T_MAX - NUM_BUFF_OVERSIZE_BYTES) / - ((tmsize_t)rowsize + 1))) - { - TIFFError("rotateImage", - "Integer overflow when calculating buffer size."); - return (-1); - } - buffsize = ((tmsize_t)rowsize + 1) * length; + case 0: + case 360: return (0); + case 90: + case 180: + case 270: break; + default: TIFFError("rotateImage", "Invalid rotation angle %d", rotation); + return (-1); } - bytes_per_sample = (bps + 7) / 8; - bytes_per_pixel = ((bps * spp) + 7) / 8; - if (bytes_per_pixel < (bytes_per_sample + 1)) - shift_width = bytes_per_pixel; - else - shift_width = bytes_per_sample + 1; - - switch (rotation) + /* Add 3 padding bytes for extractContigSamplesShifted32bits */ + if (!(rbuff = (unsigned char *)limitMalloc(buffsize + NUM_BUFF_OVERSIZE_BYTES))) { - case 0: - case 360: - return (0); - case 90: - case 180: - case 270: - break; - default: - TIFFError("rotateImage", "Invalid rotation angle %" PRIu16, - rotation); - return (-1); + TIFFError("rotateImage", "Unable to allocate rotation buffer of %1u bytes", buffsize + NUM_BUFF_OVERSIZE_BYTES); + return (-1); } + _TIFFmemset(rbuff, '\0', buffsize + NUM_BUFF_OVERSIZE_BYTES); - /* Add 3 padding bytes for extractContigSamplesShifted32bits */ - if (!(rbuff = - (unsigned char *)limitMalloc(buffsize + NUM_BUFF_OVERSIZE_BYTES))) + ibuff = *ibuff_ptr; + switch (rotation) { - TIFFError("rotateImage", - "Unable to allocate rotation buffer of %" TIFF_SSIZE_FORMAT - " bytes ", - buffsize + NUM_BUFF_OVERSIZE_BYTES); - return (-1); - } - _TIFFmemset(rbuff, '\0', buffsize + NUM_BUFF_OVERSIZE_BYTES); - if (rot_buf_size != NULL) - *rot_buf_size = buffsize; - - ibuff = *ibuff_ptr; - switch (rotation) - { - case 180: - if ((bps % 8) == 0) /* byte aligned data */ - { + case 180: if ((bps % 8) == 0) /* byte aligned data */ + { src = ibuff; pix_offset = (spp * bps) / 8; for (row = 0; row < length; row++) - { - dst_offset = (length - row - 1) * rowsize; - for (col = 0; col < width; col++) - { - col_offset = (width - col - 1) * pix_offset; - dst = rbuff + dst_offset + col_offset; + { + dst_offset = (length - row - 1) * rowsize; + for (col = 0; col < width; col++) + { + col_offset = (width - col - 1) * pix_offset; + dst = rbuff + dst_offset + col_offset; - for (i = 0; i < bytes_per_pixel; i++) - *dst++ = *src++; - } + for (i = 0; i < bytes_per_pixel; i++) + *dst++ = *src++; + } + } } - } - else - { /* non 8 bit per sample data */ + else + { /* non 8 bit per sample data */ for (row = 0; row < length; row++) - { - src_offset = row * rowsize; - dst_offset = (length - row - 1) * rowsize; - src = ibuff + src_offset; - dst = rbuff + dst_offset; - switch (shift_width) + { + src_offset = row * rowsize; + dst_offset = (length - row - 1) * rowsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + switch (shift_width) { - case 1: - if (bps == 1) - { - if (reverseSamples8bits(spp, bps, width, src, - dst)) + case 1: if (bps == 1) + { + if (reverseSamples8bits(spp, bps, width, src, dst)) { - _TIFFfree(rbuff); - return (-1); + _TIFFfree(rbuff); + return (-1); } - break; - } + break; + } if (reverseSamples16bits(spp, bps, width, src, dst)) - { - _TIFFfree(rbuff); - return (-1); - } - break; - case 2: - if (reverseSamples24bits(spp, bps, width, src, dst)) - { - _TIFFfree(rbuff); - return (-1); - } - break; - case 3: - case 4: - case 5: - if (reverseSamples32bits(spp, bps, width, src, dst)) - { - _TIFFfree(rbuff); - return (-1); - } - break; - default: - TIFFError("rotateImage", - "Unsupported bit depth %" PRIu16, bps); - _TIFFfree(rbuff); - return (-1); + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 2: if (reverseSamples24bits(spp, bps, width, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 3: + case 4: + case 5: if (reverseSamples32bits(spp, bps, width, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + _TIFFfree(rbuff); + return (-1); } - } - } - _TIFFfree(ibuff); - *(ibuff_ptr) = rbuff; - break; + } + } + _TIFFfree(ibuff); + *(ibuff_ptr) = rbuff; + break; - case 90: - if ((bps % 8) == 0) /* byte aligned data */ - { - for (col = 0; col < width; col++) + case 90: if ((bps % 8) == 0) /* byte aligned data */ { - src_offset = - ((length - 1) * rowsize) + (col * bytes_per_pixel); - dst_offset = col * colsize; - src = ibuff + src_offset; - dst = rbuff + dst_offset; - for (row = length; row > 0; row--) + for (col = 0; col < width; col++) + { + src_offset = ((length - 1) * rowsize) + (col * bytes_per_pixel); + dst_offset = col * colsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + for (row = length; row > 0; row--) { - for (i = 0; i < bytes_per_pixel; i++) - *dst++ = *(src + i); - src -= rowsize; + for (i = 0; i < bytes_per_pixel; i++) + *dst++ = *(src + i); + src -= rowsize; } - } - } - else - { /* non 8 bit per sample data */ + } + } + else + { /* non 8 bit per sample data */ for (col = 0; col < width; col++) - { - src_offset = (length - 1) * rowsize; - dst_offset = col * colsize; - src = ibuff + src_offset; - dst = rbuff + dst_offset; - switch (shift_width) + { + src_offset = (length - 1) * rowsize; + dst_offset = col * colsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + switch (shift_width) { - case 1: - if (bps == 1) - { - if (rotateContigSamples8bits(rotation, spp, bps, - width, length, col, - src, dst)) + case 1: if (bps == 1) + { + if (rotateContigSamples8bits(rotation, spp, bps, width, + length, col, src, dst)) { - _TIFFfree(rbuff); - return (-1); + _TIFFfree(rbuff); + return (-1); } - break; - } - if (rotateContigSamples16bits(rotation, spp, bps, - width, length, col, - src, dst)) - { - _TIFFfree(rbuff); - return (-1); - } - break; - case 2: - if (rotateContigSamples24bits(rotation, spp, bps, - width, length, col, - src, dst)) - { - _TIFFfree(rbuff); - return (-1); - } - break; - case 3: - case 4: - case 5: - if (rotateContigSamples32bits(rotation, spp, bps, - width, length, col, - src, dst)) - { - _TIFFfree(rbuff); - return (-1); - } - break; - default: - TIFFError("rotateImage", - "Unsupported bit depth %" PRIu16, bps); - _TIFFfree(rbuff); - return (-1); - } - } - } - _TIFFfree(ibuff); - *(ibuff_ptr) = rbuff; + break; + } + if (rotateContigSamples16bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 2: if (rotateContigSamples24bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 3: + case 4: + case 5: if (rotateContigSamples32bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + _TIFFfree(rbuff); + return (-1); + } + } + } + _TIFFfree(ibuff); + *(ibuff_ptr) = rbuff; - *img_width = length; - *img_length = width; + *img_width = length; + *img_length = width; /* Only toggle image parameters if whole input image is rotated. */ if (rot_image_params) { @@ -9870,88 +8772,78 @@ static int rotateImage(uint16_t rotation, struct image_data *image, image->xres = image->yres; image->yres = res_temp; } - break; + break; - case 270: - if ((bps % 8) == 0) /* byte aligned data */ - { - for (col = 0; col < width; col++) + case 270: if ((bps % 8) == 0) /* byte aligned data */ { - src_offset = col * bytes_per_pixel; - dst_offset = (width - col - 1) * colsize; - src = ibuff + src_offset; - dst = rbuff + dst_offset; - for (row = length; row > 0; row--) + for (col = 0; col < width; col++) + { + src_offset = col * bytes_per_pixel; + dst_offset = (width - col - 1) * colsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + for (row = length; row > 0; row--) { - for (i = 0; i < bytes_per_pixel; i++) - *dst++ = *(src + i); - src += rowsize; + for (i = 0; i < bytes_per_pixel; i++) + *dst++ = *(src + i); + src += rowsize; } - } - } - else - { /* non 8 bit per sample data */ + } + } + else + { /* non 8 bit per sample data */ for (col = 0; col < width; col++) - { - src_offset = 0; - dst_offset = (width - col - 1) * colsize; - src = ibuff + src_offset; - dst = rbuff + dst_offset; - switch (shift_width) + { + src_offset = 0; + dst_offset = (width - col - 1) * colsize; + src = ibuff + src_offset; + dst = rbuff + dst_offset; + switch (shift_width) { - case 1: - if (bps == 1) - { - if (rotateContigSamples8bits(rotation, spp, bps, - width, length, col, - src, dst)) + case 1: if (bps == 1) + { + if (rotateContigSamples8bits(rotation, spp, bps, width, + length, col, src, dst)) { - _TIFFfree(rbuff); - return (-1); + _TIFFfree(rbuff); + return (-1); } - break; - } - if (rotateContigSamples16bits(rotation, spp, bps, - width, length, col, - src, dst)) - { - _TIFFfree(rbuff); - return (-1); - } - break; - case 2: - if (rotateContigSamples24bits(rotation, spp, bps, - width, length, col, - src, dst)) - { - _TIFFfree(rbuff); - return (-1); - } - break; - case 3: - case 4: - case 5: - if (rotateContigSamples32bits(rotation, spp, bps, - width, length, col, - src, dst)) - { - _TIFFfree(rbuff); - return (-1); - } - break; - default: - TIFFError("rotateImage", - "Unsupported bit depth %" PRIu16, bps); - _TIFFfree(rbuff); - return (-1); - } - } - } - _TIFFfree(ibuff); - *(ibuff_ptr) = rbuff; + break; + } + if (rotateContigSamples16bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 2: if (rotateContigSamples24bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + case 3: + case 4: + case 5: if (rotateContigSamples32bits(rotation, spp, bps, width, + length, col, src, dst)) + { + _TIFFfree(rbuff); + return (-1); + } + break; + default: TIFFError("rotateImage","Unsupported bit depth %d", bps); + _TIFFfree(rbuff); + return (-1); + } + } + } + _TIFFfree(ibuff); + *(ibuff_ptr) = rbuff; - *img_width = length; - *img_length = width; + *img_width = length; + *img_length = width; /* Only toggle image parameters if whole input image is rotated. */ if (rot_image_params) { @@ -9961,592 +8853,576 @@ static int rotateImage(uint16_t rotation, struct image_data *image, image->xres = image->yres; image->yres = res_temp; } - break; - default: - break; + break; + default: + break; } - return (0); -} /* end rotateImage */ + return (0); + } /* end rotateImage */ -static int reverseSamples8bits(uint16_t spp, uint16_t bps, uint32_t width, - uint8_t *ibuff, uint8_t *obuff) -{ - int ready_bits = 0; - uint32_t col; - uint32_t src_byte, src_bit; - uint32_t bit_offset = 0; - uint8_t match_bits = 0, mask_bits = 0; - uint8_t buff1 = 0, buff2 = 0; - unsigned char *src; - unsigned char *dst; - tsample_t sample; +static int +reverseSamples8bits (uint16 spp, uint16 bps, uint32 width, + uint8 *ibuff, uint8 *obuff) + { + int ready_bits = 0; + uint32 col; + uint32 src_byte, src_bit; + uint32 bit_offset = 0; + uint8 match_bits = 0, mask_bits = 0; + uint8 buff1 = 0, buff2 = 0; + unsigned char *src; + unsigned char *dst; + tsample_t sample; - if ((ibuff == NULL) || (obuff == NULL)) + if ((ibuff == NULL) || (obuff == NULL)) { - TIFFError("reverseSamples8bits", "Invalid image or work buffer"); - return (1); + TIFFError("reverseSamples8bits","Invalid image or work buffer"); + return (1); } - ready_bits = 0; - mask_bits = (uint8_t)-1 >> (8 - bps); - dst = obuff; - for (col = width; col > 0; col--) + ready_bits = 0; + mask_bits = (uint8)-1 >> ( 8 - bps); + dst = obuff; + for (col = width; col > 0; col--) { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = (col - 1) * bps * spp; - for (sample = 0; sample < spp; sample++) + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = (col - 1) * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) { - if (sample == 0) - { - src_byte = bit_offset / 8; - src_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sample * bps)) / 8; - src_bit = (bit_offset + (sample * bps)) % 8; - } - - src = ibuff + src_byte; - match_bits = mask_bits << (8 - src_bit - bps); - buff1 = ((*src) & match_bits) << (src_bit); - - if (ready_bits < 8) - buff2 = (buff2 | (buff1 >> ready_bits)); - else /* If we have a full buffer's worth, write it out */ - { - *dst++ = buff2; - buff2 = buff1; - ready_bits -= 8; - } - ready_bits += bps; + src_byte = bit_offset / 8; + src_bit = bit_offset % 8; } - } - if (ready_bits > 0) - { - buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); - *dst++ = buff1; - } - - return (0); -} /* end reverseSamples8bits */ - -static int reverseSamples16bits(uint16_t spp, uint16_t bps, uint32_t width, - uint8_t *ibuff, uint8_t *obuff) -{ - int ready_bits = 0; - uint32_t col; - uint32_t src_byte = 0, high_bit = 0; - uint32_t bit_offset = 0; - uint16_t match_bits = 0, mask_bits = 0; - uint16_t buff1 = 0, buff2 = 0; - uint8_t bytebuff = 0; - unsigned char *src; - unsigned char *dst; - tsample_t sample; - - if ((ibuff == NULL) || (obuff == NULL)) - { - TIFFError("reverseSample16bits", "Invalid image or work buffer"); - return (1); - } - - ready_bits = 0; - mask_bits = (uint16_t)-1 >> (16 - bps); - dst = obuff; - for (col = width; col > 0; col--) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = (col - 1) * bps * spp; - for (sample = 0; sample < spp; sample++) + else { - if (sample == 0) - { - src_byte = bit_offset / 8; - high_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sample * bps)) / 8; - high_bit = (bit_offset + (sample * bps)) % 8; - } - - src = ibuff + src_byte; - match_bits = mask_bits << (16 - high_bit - bps); - if (little_endian) - buff1 = (src[0] << 8) | src[1]; - else - buff1 = (src[1] << 8) | src[0]; - buff1 = (buff1 & match_bits) << (high_bit); - - if (ready_bits < 8) - { /* add another bps bits to the buffer */ - bytebuff = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - else /* If we have a full buffer's worth, write it out */ - { - bytebuff = (buff2 >> 8); - *dst++ = bytebuff; - ready_bits -= 8; - /* shift in new bits */ - buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); - } - ready_bits += bps; + src_byte = (bit_offset + (sample * bps)) / 8; + src_bit = (bit_offset + (sample * bps)) % 8; } + + src = ibuff + src_byte; + match_bits = mask_bits << (8 - src_bit - bps); + buff1 = ((*src) & match_bits) << (src_bit); + + if (ready_bits < 8) + buff2 = (buff2 | (buff1 >> ready_bits)); + else /* If we have a full buffer's worth, write it out */ + { + *dst++ = buff2; + buff2 = buff1; + ready_bits -= 8; + } + ready_bits += bps; + } + } + if (ready_bits > 0) + { + buff1 = (buff2 & ((unsigned int)255 << (8 - ready_bits))); + *dst++ = buff1; } - if (ready_bits > 0) + return (0); + } /* end reverseSamples8bits */ + + +static int +reverseSamples16bits (uint16 spp, uint16 bps, uint32 width, + uint8 *ibuff, uint8 *obuff) + { + int ready_bits = 0; + uint32 col; + uint32 src_byte = 0, high_bit = 0; + uint32 bit_offset = 0; + uint16 match_bits = 0, mask_bits = 0; + uint16 buff1 = 0, buff2 = 0; + uint8 bytebuff = 0; + unsigned char *src; + unsigned char *dst; + tsample_t sample; + + if ((ibuff == NULL) || (obuff == NULL)) { + TIFFError("reverseSample16bits","Invalid image or work buffer"); + return (1); + } + + ready_bits = 0; + mask_bits = (uint16)-1 >> (16 - bps); + dst = obuff; + for (col = width; col > 0; col--) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = (col - 1) * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + high_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + high_bit = (bit_offset + (sample * bps)) % 8; + } + + src = ibuff + src_byte; + match_bits = mask_bits << (16 - high_bit - bps); + if (little_endian) + buff1 = (src[0] << 8) | src[1]; + else + buff1 = (src[1] << 8) | src[0]; + buff1 = (buff1 & match_bits) << (high_bit); + + if (ready_bits < 8) + { /* add another bps bits to the buffer */ + bytebuff = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { bytebuff = (buff2 >> 8); *dst++ = bytebuff; - } - - return (0); -} /* end reverseSamples16bits */ - -static int reverseSamples24bits(uint16_t spp, uint16_t bps, uint32_t width, - uint8_t *ibuff, uint8_t *obuff) -{ - int ready_bits = 0; - uint32_t col; - uint32_t src_byte = 0, high_bit = 0; - uint32_t bit_offset = 0; - uint32_t match_bits = 0, mask_bits = 0; - uint32_t buff1 = 0, buff2 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0; - unsigned char *src; - unsigned char *dst; - tsample_t sample; - - if ((ibuff == NULL) || (obuff == NULL)) - { - TIFFError("reverseSamples24bits", "Invalid image or work buffer"); - return (1); - } - - ready_bits = 0; - mask_bits = (uint32_t)-1 >> (32 - bps); - dst = obuff; - for (col = width; col > 0; col--) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = (col - 1) * bps * spp; - for (sample = 0; sample < spp; sample++) - { - if (sample == 0) - { - src_byte = bit_offset / 8; - high_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sample * bps)) / 8; - high_bit = (bit_offset + (sample * bps)) % 8; - } - - src = ibuff + src_byte; - match_bits = mask_bits << (32 - high_bit - bps); - if (little_endian) - buff1 = - (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; - else - buff1 = - (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; - buff1 = (buff1 & match_bits) << (high_bit); - - if (ready_bits < 16) - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - else /* If we have a full buffer's worth, write it out */ - { - bytebuff1 = (buff2 >> 24); - *dst++ = bytebuff1; - bytebuff2 = (buff2 >> 16); - *dst++ = bytebuff2; - ready_bits -= 16; - - /* shift in new bits */ - buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); - } - ready_bits += bps; + ready_bits -= 8; + /* shift in new bits */ + buff2 = ((buff2 << 8) | (buff1 >> ready_bits)); } + ready_bits += bps; + } } - /* catch any trailing bits at the end of the line */ - while (ready_bits > 0) + if (ready_bits > 0) { + bytebuff = (buff2 >> 8); + *dst++ = bytebuff; + } + + return (0); + } /* end reverseSamples16bits */ + +static int +reverseSamples24bits (uint16 spp, uint16 bps, uint32 width, + uint8 *ibuff, uint8 *obuff) + { + int ready_bits = 0; + uint32 col; + uint32 src_byte = 0, high_bit = 0; + uint32 bit_offset = 0; + uint32 match_bits = 0, mask_bits = 0; + uint32 buff1 = 0, buff2 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0; + unsigned char *src; + unsigned char *dst; + tsample_t sample; + + if ((ibuff == NULL) || (obuff == NULL)) + { + TIFFError("reverseSamples24bits","Invalid image or work buffer"); + return (1); + } + + ready_bits = 0; + mask_bits = (uint32)-1 >> (32 - bps); + dst = obuff; + for (col = width; col > 0; col--) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = (col - 1) * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + high_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + high_bit = (bit_offset + (sample * bps)) % 8; + } + + src = ibuff + src_byte; + match_bits = mask_bits << (32 - high_bit - bps); + if (little_endian) + buff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + else + buff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + buff1 = (buff1 & match_bits) << (high_bit); + + if (ready_bits < 16) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { bytebuff1 = (buff2 >> 24); *dst++ = bytebuff1; + bytebuff2 = (buff2 >> 16); + *dst++ = bytebuff2; + ready_bits -= 16; - buff2 = (buff2 << 8); - bytebuff2 = bytebuff1; - ready_bits -= 8; - } - - return (0); -} /* end reverseSamples24bits */ - -static int reverseSamples32bits(uint16_t spp, uint16_t bps, uint32_t width, - uint8_t *ibuff, uint8_t *obuff) -{ - int ready_bits = 0 /*, shift_width = 0 */; - /* int bytes_per_sample, bytes_per_pixel; */ - uint32_t bit_offset; - uint32_t src_byte = 0, high_bit = 0; - uint32_t col; - uint32_t longbuff1 = 0, longbuff2 = 0; - uint64_t mask_bits = 0, match_bits = 0; - uint64_t buff1 = 0, buff2 = 0, buff3 = 0; - uint8_t bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; - unsigned char *src; - unsigned char *dst; - tsample_t sample; - - if ((ibuff == NULL) || (obuff == NULL)) - { - TIFFError("reverseSamples32bits", "Invalid image or work buffer"); - return (1); - } - - ready_bits = 0; - mask_bits = (uint64_t)-1 >> (64 - bps); - dst = obuff; - - /* bytes_per_sample = (bps + 7) / 8; */ - /* bytes_per_pixel = ((bps * spp) + 7) / 8; */ - /* if (bytes_per_pixel < (bytes_per_sample + 1)) */ - /* shift_width = bytes_per_pixel; */ - /* else */ - /* shift_width = bytes_per_sample + 1; */ - - for (col = width; col > 0; col--) - { - /* Compute src byte(s) and bits within byte(s) */ - bit_offset = (col - 1) * bps * spp; - for (sample = 0; sample < spp; sample++) - { - if (sample == 0) - { - src_byte = bit_offset / 8; - high_bit = bit_offset % 8; - } - else - { - src_byte = (bit_offset + (sample * bps)) / 8; - high_bit = (bit_offset + (sample * bps)) % 8; - } - - src = ibuff + src_byte; - match_bits = mask_bits << (64 - high_bit - bps); - if (little_endian) - { - longbuff1 = - (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; - longbuff2 = longbuff1; - } - else - { - longbuff1 = - (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; - longbuff2 = longbuff1; - } - buff3 = ((uint64_t)longbuff1 << 32) | longbuff2; - buff1 = (buff3 & match_bits) << (high_bit); - - if (ready_bits < 32) - { /* add another bps bits to the buffer */ - bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; - buff2 = (buff2 | (buff1 >> ready_bits)); - } - else /* If we have a full buffer's worth, write it out */ - { - bytebuff1 = (uint8_t)(buff2 >> 56); - *dst++ = bytebuff1; - bytebuff2 = (uint8_t)(buff2 >> 48); - *dst++ = bytebuff2; - bytebuff3 = (uint8_t)(buff2 >> 40); - *dst++ = bytebuff3; - bytebuff4 = (uint8_t)(buff2 >> 32); - *dst++ = bytebuff4; - ready_bits -= 32; - - /* shift in new bits */ - buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); - } - ready_bits += bps; + /* shift in new bits */ + buff2 = ((buff2 << 16) | (buff1 >> ready_bits)); } + ready_bits += bps; + } } - while (ready_bits > 0) + + /* catch any trailing bits at the end of the line */ + while (ready_bits > 0) { - bytebuff1 = (buff2 >> 56); + bytebuff1 = (buff2 >> 24); + *dst++ = bytebuff1; + + buff2 = (buff2 << 8); + bytebuff2 = bytebuff1; + ready_bits -= 8; + } + + return (0); + } /* end reverseSamples24bits */ + + +static int +reverseSamples32bits (uint16 spp, uint16 bps, uint32 width, + uint8 *ibuff, uint8 *obuff) + { + int ready_bits = 0 /*, shift_width = 0 */; + /* int bytes_per_sample, bytes_per_pixel; */ + uint32 bit_offset; + uint32 src_byte = 0, high_bit = 0; + uint32 col; + uint32 longbuff1 = 0, longbuff2 = 0; + uint64 mask_bits = 0, match_bits = 0; + uint64 buff1 = 0, buff2 = 0, buff3 = 0; + uint8 bytebuff1 = 0, bytebuff2 = 0, bytebuff3 = 0, bytebuff4 = 0; + unsigned char *src; + unsigned char *dst; + tsample_t sample; + + if ((ibuff == NULL) || (obuff == NULL)) + { + TIFFError("reverseSamples32bits","Invalid image or work buffer"); + return (1); + } + + ready_bits = 0; + mask_bits = (uint64)-1 >> (64 - bps); + dst = obuff; + + /* bytes_per_sample = (bps + 7) / 8; */ + /* bytes_per_pixel = ((bps * spp) + 7) / 8; */ + /* if (bytes_per_pixel < (bytes_per_sample + 1)) */ + /* shift_width = bytes_per_pixel; */ + /* else */ + /* shift_width = bytes_per_sample + 1; */ + + for (col = width; col > 0; col--) + { + /* Compute src byte(s) and bits within byte(s) */ + bit_offset = (col - 1) * bps * spp; + for (sample = 0; sample < spp; sample++) + { + if (sample == 0) + { + src_byte = bit_offset / 8; + high_bit = bit_offset % 8; + } + else + { + src_byte = (bit_offset + (sample * bps)) / 8; + high_bit = (bit_offset + (sample * bps)) % 8; + } + + src = ibuff + src_byte; + match_bits = mask_bits << (64 - high_bit - bps); + if (little_endian) + { + longbuff1 = (src[0] << 24) | (src[1] << 16) | (src[2] << 8) | src[3]; + longbuff2 = longbuff1; + } + else + { + longbuff1 = (src[3] << 24) | (src[2] << 16) | (src[1] << 8) | src[0]; + longbuff2 = longbuff1; + } + buff3 = ((uint64)longbuff1 << 32) | longbuff2; + buff1 = (buff3 & match_bits) << (high_bit); + + if (ready_bits < 32) + { /* add another bps bits to the buffer */ + bytebuff1 = bytebuff2 = bytebuff3 = bytebuff4 = 0; + buff2 = (buff2 | (buff1 >> ready_bits)); + } + else /* If we have a full buffer's worth, write it out */ + { + bytebuff1 = (uint8)(buff2 >> 56); *dst++ = bytebuff1; - buff2 = (buff2 << 8); - ready_bits -= 8; + bytebuff2 = (uint8)(buff2 >> 48); + *dst++ = bytebuff2; + bytebuff3 = (uint8)(buff2 >> 40); + *dst++ = bytebuff3; + bytebuff4 = (uint8)(buff2 >> 32); + *dst++ = bytebuff4; + ready_bits -= 32; + + /* shift in new bits */ + buff2 = ((buff2 << 32) | (buff1 >> ready_bits)); + } + ready_bits += bps; + } + } + while (ready_bits > 0) + { + bytebuff1 = (buff2 >> 56); + *dst++ = bytebuff1; + buff2 = (buff2 << 8); + ready_bits -= 8; } - return (0); -} /* end reverseSamples32bits */ + return (0); + } /* end reverseSamples32bits */ -static int reverseSamplesBytes(uint16_t spp, uint16_t bps, uint32_t width, - uint8_t *src, uint8_t *dst) -{ - int i; - uint32_t col, bytes_per_pixel, col_offset; - uint8_t bytebuff1; - unsigned char swapbuff[32]; - - if ((src == NULL) || (dst == NULL)) +static int +reverseSamplesBytes (uint16 spp, uint16 bps, uint32 width, + uint8 *src, uint8 *dst) + { + int i; + uint32 col, bytes_per_pixel, col_offset; + uint8 bytebuff1; + unsigned char swapbuff[32]; + + if ((src == NULL) || (dst == NULL)) { - TIFFError("reverseSamplesBytes", "Invalid input or output buffer"); - return (1); + TIFFError("reverseSamplesBytes","Invalid input or output buffer"); + return (1); } - bytes_per_pixel = ((bps * spp) + 7) / 8; - if (bytes_per_pixel > sizeof(swapbuff)) - { - TIFFError("reverseSamplesBytes", "bytes_per_pixel too large"); - return (1); - } - switch (bps / 8) - { - case 8: /* Use memcpy for multiple bytes per sample data */ - case 4: - case 3: - case 2: - for (col = 0; col < (width / 2); col++) - { - col_offset = col * bytes_per_pixel; - _TIFFmemcpy(swapbuff, src + col_offset, bytes_per_pixel); - _TIFFmemcpy(src + col_offset, - dst - col_offset - bytes_per_pixel, - bytes_per_pixel); - _TIFFmemcpy(dst - col_offset - bytes_per_pixel, swapbuff, - bytes_per_pixel); - } - break; - case 1: /* Use byte copy only for single byte per sample data */ - for (col = 0; col < (width / 2); col++) - { - for (i = 0; i < spp; i++) - { - bytebuff1 = *src; - *src++ = *(dst - spp + i); - *(dst - spp + i) = bytebuff1; + bytes_per_pixel = ((bps * spp) + 7) / 8; + if( bytes_per_pixel > sizeof(swapbuff) ) + { + TIFFError("reverseSamplesBytes","bytes_per_pixel too large"); + return (1); + } + switch (bps / 8) + { + case 8: /* Use memcpy for multiple bytes per sample data */ + case 4: + case 3: + case 2: for (col = 0; col < (width / 2); col++) + { + col_offset = col * bytes_per_pixel; + _TIFFmemcpy (swapbuff, src + col_offset, bytes_per_pixel); + _TIFFmemcpy (src + col_offset, dst - col_offset - bytes_per_pixel, bytes_per_pixel); + _TIFFmemcpy (dst - col_offset - bytes_per_pixel, swapbuff, bytes_per_pixel); + } + break; + case 1: /* Use byte copy only for single byte per sample data */ + for (col = 0; col < (width / 2); col++) + { + for (i = 0; i < spp; i++) + { + bytebuff1 = *src; + *src++ = *(dst - spp + i); + *(dst - spp + i) = bytebuff1; + } + dst -= spp; } - dst -= spp; - } - break; - default: - TIFFError("reverseSamplesBytes", "Unsupported bit depth %" PRIu16, - bps); - return (1); - } - return (0); -} /* end reverseSamplesBytes */ + break; + default: TIFFError("reverseSamplesBytes","Unsupported bit depth %d", bps); + return (1); + } + return (0); + } /* end reverseSamplesBytes */ + /* Mirror an image horizontally or vertically */ -static int mirrorImage(uint16_t spp, uint16_t bps, uint16_t mirror, - uint32_t width, uint32_t length, unsigned char *ibuff) -{ - int shift_width; - uint32_t bytes_per_pixel, bytes_per_sample; - uint32_t row, rowsize, row_offset; - unsigned char *line_buff = NULL; - unsigned char *src; - unsigned char *dst; +static int +mirrorImage(uint16 spp, uint16 bps, uint16 mirror, uint32 width, uint32 length, unsigned char *ibuff) + { + int shift_width; + uint32 bytes_per_pixel, bytes_per_sample; + uint32 row, rowsize, row_offset; + unsigned char *line_buff = NULL; + unsigned char *src; + unsigned char *dst; - src = ibuff; - rowsize = ((width * bps * spp) + 7) / 8; - switch (mirror) + src = ibuff; + rowsize = ((width * bps * spp) + 7) / 8; + switch (mirror) { - case MIRROR_BOTH: - case MIRROR_VERT: - line_buff = - (unsigned char *)limitMalloc(rowsize + NUM_BUFF_OVERSIZE_BYTES); - if (line_buff == NULL) - { - TIFFError("mirrorImage", - "Unable to allocate mirror line buffer of %1u bytes", - rowsize + NUM_BUFF_OVERSIZE_BYTES); - return (-1); - } - _TIFFmemset(line_buff, '\0', rowsize + NUM_BUFF_OVERSIZE_BYTES); + case MIRROR_BOTH: + case MIRROR_VERT: + line_buff = (unsigned char *)limitMalloc(rowsize + NUM_BUFF_OVERSIZE_BYTES); + if (line_buff == NULL) + { + TIFFError ("mirrorImage", "Unable to allocate mirror line buffer of %1u bytes", rowsize + NUM_BUFF_OVERSIZE_BYTES); + return (-1); + } + _TIFFmemset(line_buff, '\0', rowsize + NUM_BUFF_OVERSIZE_BYTES); - dst = ibuff + (rowsize * (length - 1)); - for (row = 0; row < length / 2; row++) - { - _TIFFmemcpy(line_buff, src, rowsize); - _TIFFmemcpy(src, dst, rowsize); - _TIFFmemcpy(dst, line_buff, rowsize); - src += (rowsize); - dst -= (rowsize); - } - if (line_buff) - _TIFFfree(line_buff); - if (mirror == MIRROR_VERT) - break; - /* Fall through */ - case MIRROR_HORIZ: - if ((bps % 8) == 0) /* byte aligned data */ - { + dst = ibuff + (rowsize * (length - 1)); + for (row = 0; row < length / 2; row++) + { + _TIFFmemcpy(line_buff, src, rowsize); + _TIFFmemcpy(src, dst, rowsize); + _TIFFmemcpy(dst, line_buff, rowsize); + src += (rowsize); + dst -= (rowsize); + } + if (line_buff) + _TIFFfree(line_buff); + if (mirror == MIRROR_VERT) + break; + /* Fall through */ + case MIRROR_HORIZ : + if ((bps % 8) == 0) /* byte aligned data */ + { for (row = 0; row < length; row++) - { - row_offset = row * rowsize; - src = ibuff + row_offset; - dst = ibuff + row_offset + rowsize; - if (reverseSamplesBytes(spp, bps, width, src, dst)) + { + row_offset = row * rowsize; + src = ibuff + row_offset; + dst = ibuff + row_offset + rowsize; + if (reverseSamplesBytes(spp, bps, width, src, dst)) { - return (-1); + return (-1); } - } - } - else - { /* non 8 bit per sample data */ - if (!(line_buff = (unsigned char *)limitMalloc( - rowsize + NUM_BUFF_OVERSIZE_BYTES))) - { - TIFFError("mirrorImage", - "Unable to allocate mirror line buffer"); - return (-1); - } + } + } + else + { /* non 8 bit per sample data */ + if (!(line_buff = (unsigned char *)limitMalloc(rowsize + NUM_BUFF_OVERSIZE_BYTES))) + { + TIFFError("mirrorImage", "Unable to allocate mirror line buffer"); + return (-1); + } _TIFFmemset(line_buff, '\0', rowsize + NUM_BUFF_OVERSIZE_BYTES); bytes_per_sample = (bps + 7) / 8; - bytes_per_pixel = ((bps * spp) + 7) / 8; + bytes_per_pixel = ((bps * spp) + 7) / 8; if (bytes_per_pixel < (bytes_per_sample + 1)) - shift_width = bytes_per_pixel; + shift_width = bytes_per_pixel; else - shift_width = bytes_per_sample + 1; + shift_width = bytes_per_sample + 1; for (row = 0; row < length; row++) - { - row_offset = row * rowsize; - src = ibuff + row_offset; - _TIFFmemset(line_buff, '\0', - rowsize + NUM_BUFF_OVERSIZE_BYTES); - switch (shift_width) + { + row_offset = row * rowsize; + src = ibuff + row_offset; + _TIFFmemset (line_buff, '\0', rowsize + NUM_BUFF_OVERSIZE_BYTES); + switch (shift_width) { - case 1: - if (reverseSamples16bits(spp, bps, width, src, - line_buff)) - { - _TIFFfree(line_buff); - return (-1); - } - _TIFFmemcpy(src, line_buff, rowsize); - break; - case 2: - if (reverseSamples24bits(spp, bps, width, src, - line_buff)) - { - _TIFFfree(line_buff); - return (-1); - } - _TIFFmemcpy(src, line_buff, rowsize); - break; - case 3: - case 4: - case 5: - if (reverseSamples32bits(spp, bps, width, src, - line_buff)) - { - _TIFFfree(line_buff); - return (-1); - } - _TIFFmemcpy(src, line_buff, rowsize); - break; - default: - TIFFError("mirrorImage", - "Unsupported bit depth %" PRIu16, bps); - _TIFFfree(line_buff); - return (-1); + case 1: if (reverseSamples16bits(spp, bps, width, src, line_buff)) + { + _TIFFfree(line_buff); + return (-1); + } + _TIFFmemcpy (src, line_buff, rowsize); + break; + case 2: if (reverseSamples24bits(spp, bps, width, src, line_buff)) + { + _TIFFfree(line_buff); + return (-1); + } + _TIFFmemcpy (src, line_buff, rowsize); + break; + case 3: + case 4: + case 5: if (reverseSamples32bits(spp, bps, width, src, line_buff)) + { + _TIFFfree(line_buff); + return (-1); + } + _TIFFmemcpy (src, line_buff, rowsize); + break; + default: TIFFError("mirrorImage","Unsupported bit depth %d", bps); + _TIFFfree(line_buff); + return (-1); } - } + } if (line_buff) - _TIFFfree(line_buff); - } - break; + _TIFFfree(line_buff); + } + break; - default: - TIFFError("mirrorImage", "Invalid mirror axis %" PRIu16, mirror); - return (-1); - break; + default: TIFFError ("mirrorImage", "Invalid mirror axis %d", mirror); + return (-1); + break; } - return (0); -} + return (0); + } /* Invert the light and dark values for a bilevel or grayscale image */ -static int invertImage(uint16_t photometric, uint16_t spp, uint16_t bps, - uint32_t width, uint32_t length, - unsigned char *work_buff) -{ - uint32_t row, col; - unsigned char *src; - uint16_t *src_uint16; - uint32_t *src_uint32; +static int +invertImage(uint16 photometric, uint16 spp, uint16 bps, uint32 width, uint32 length, unsigned char *work_buff) + { + uint32 row, col; + unsigned char *src; + uint16 *src_uint16; + uint32 *src_uint32; - if (spp != 1) + if (spp != 1) { - TIFFError( - "invertImage", - "Image inversion not supported for more than one sample per pixel"); - return (-1); + TIFFError("invertImage", "Image inversion not supported for more than one sample per pixel"); + return (-1); } - if (photometric != PHOTOMETRIC_MINISWHITE && - photometric != PHOTOMETRIC_MINISBLACK) + if (photometric != PHOTOMETRIC_MINISWHITE && photometric != PHOTOMETRIC_MINISBLACK) { - TIFFError("invertImage", - "Only black and white and grayscale images can be inverted"); - return (-1); + TIFFError("invertImage", "Only black and white and grayscale images can be inverted"); + return (-1); } - src = work_buff; - if (src == NULL) + src = work_buff; + if (src == NULL) { - TIFFError("invertImage", "Invalid crop buffer passed to invertImage"); - return (-1); + TIFFError ("invertImage", "Invalid crop buffer passed to invertImage"); + return (-1); } - switch (bps) + switch (bps) { - case 32: - src_uint32 = (uint32_t *)src; - for (row = 0; row < length; row++) - for (col = 0; col < width; col++) + case 32: src_uint32 = (uint32 *)src; + for (row = 0; row < length; row++) + for (col = 0; col < width; col++) + { + *src_uint32 = ~(*src_uint32); + src_uint32++; + } + break; + case 16: src_uint16 = (uint16 *)src; + for (row = 0; row < length; row++) + for (col = 0; col < width; col++) + { + *src_uint16 = ~(*src_uint16); + src_uint16++; + } + break; + case 8: + case 4: + case 2: + case 1: for (row = 0; row < length; row++) + for (col = 0; col < width; col += 8 / bps) { - *src_uint32 = ~(*src_uint32); - src_uint32++; + *src = ~(*src); + src++; } break; - case 16: - src_uint16 = (uint16_t *)src; - for (row = 0; row < length; row++) - for (col = 0; col < width; col++) - { - *src_uint16 = ~(*src_uint16); - src_uint16++; - } - break; - case 8: - case 4: - case 2: - case 1: - for (row = 0; row < length; row++) - for (col = 0; col < width; col += 8 / bps) - { - *src = ~(*src); - src++; - } - break; - default: - TIFFError("invertImage", "Unsupported bit depth %" PRIu16, bps); - return (-1); + default: TIFFError("invertImage", "Unsupported bit depth %d", bps); + return (-1); } - return (0); -} + return (0); + } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ + diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffdither.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffdither.c index 187a61a24..a9d1b7c58 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffdither.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffdither.c @@ -2,27 +2,26 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" #include @@ -30,7 +29,11 @@ #include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffio.h" @@ -43,328 +46,308 @@ #define EXIT_FAILURE 1 #endif -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) -#define CopyField(tag, v) \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v) +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) -uint32_t imagewidth; -uint32_t imagelength; -int threshold = 128; +uint32 imagewidth; +uint32 imagelength; +int threshold = 128; -static void usage(int code); +static void usage(int code); -/* +/* * Floyd-Steinberg error propragation with threshold. * This code is stolen from tiffmedian. */ -static int fsdither(TIFF *in, TIFF *out) +static int +fsdither(TIFF* in, TIFF* out) { - unsigned char *outline, *inputline, *inptr; - short *thisline, *nextline, *tmpptr; - register unsigned char *outptr; - register short *thisptr, *nextptr; - register uint32_t i, j; - uint32_t imax, jmax; - int lastline, lastpixel; - int bit; - tsize_t outlinesize; - int errcode = 0; + unsigned char *outline, *inputline, *inptr; + short *thisline, *nextline, *tmpptr; + register unsigned char *outptr; + register short *thisptr, *nextptr; + register uint32 i, j; + uint32 imax, jmax; + int lastline, lastpixel; + int bit; + tsize_t outlinesize; + int errcode = 0; - imax = imagelength - 1; - jmax = imagewidth - 1; - inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); - thisline = (short *)_TIFFmalloc( - TIFFSafeMultiply(tmsize_t, imagewidth, sizeof(short))); - nextline = (short *)_TIFFmalloc( - TIFFSafeMultiply(tmsize_t, imagewidth, sizeof(short))); - outlinesize = TIFFScanlineSize(out); - outline = (unsigned char *)_TIFFmalloc(outlinesize); - if (!(inputline && thisline && nextline && outline)) - { - fprintf(stderr, "Out of memory.\n"); - goto skip_on_error; - } + imax = imagelength - 1; + jmax = imagewidth - 1; + inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); + thisline = (short *)_TIFFmalloc(TIFFSafeMultiply(tmsize_t, imagewidth, sizeof (short))); + nextline = (short *)_TIFFmalloc(TIFFSafeMultiply(tmsize_t, imagewidth, sizeof (short))); + outlinesize = TIFFScanlineSize(out); + outline = (unsigned char *) _TIFFmalloc(outlinesize); + if (! (inputline && thisline && nextline && outline)) { + fprintf(stderr, "Out of memory.\n"); + goto skip_on_error; + } - /* - * Get first line - */ - if (TIFFReadScanline(in, inputline, 0, 0) <= 0) - goto skip_on_error; - - inptr = inputline; - nextptr = nextline; - for (j = 0; j < imagewidth; ++j) - *nextptr++ = *inptr++; - for (i = 1; i < imagelength; ++i) - { - tmpptr = thisline; - thisline = nextline; - nextline = tmpptr; - lastline = (i == imax); - if (TIFFReadScanline(in, inputline, i, 0) <= 0) + /* + * Get first line + */ + if (TIFFReadScanline(in, inputline, 0, 0) <= 0) goto skip_on_error; - inptr = inputline; - nextptr = nextline; - for (j = 0; j < imagewidth; ++j) - *nextptr++ = *inptr++; - thisptr = thisline; - nextptr = nextline; - _TIFFmemset(outptr = outline, 0, outlinesize); - bit = 0x80; - for (j = 0; j < imagewidth; ++j) - { - register int v; - lastpixel = (j == jmax); - v = *thisptr++; - if (v < 0) - v = 0; - else if (v > 255) - v = 255; - if (v > threshold) - { - *outptr |= bit; - v -= 255; - } - bit >>= 1; - if (bit == 0) - { - outptr++; - bit = 0x80; - } - if (!lastpixel) - thisptr[0] += v * 7 / 16; - if (!lastline) - { - if (j != 0) - nextptr[-1] += v * 3 / 16; - *nextptr++ += v * 5 / 16; - if (!lastpixel) - nextptr[0] += v / 16; - } - } - if (TIFFWriteScanline(out, outline, i - 1, 0) < 0) - goto skip_on_error; - } - goto exit_label; + inptr = inputline; + nextptr = nextline; + for (j = 0; j < imagewidth; ++j) + *nextptr++ = *inptr++; + for (i = 1; i < imagelength; ++i) { + tmpptr = thisline; + thisline = nextline; + nextline = tmpptr; + lastline = (i == imax); + if (TIFFReadScanline(in, inputline, i, 0) <= 0) + goto skip_on_error; + inptr = inputline; + nextptr = nextline; + for (j = 0; j < imagewidth; ++j) + *nextptr++ = *inptr++; + thisptr = thisline; + nextptr = nextline; + _TIFFmemset(outptr = outline, 0, outlinesize); + bit = 0x80; + for (j = 0; j < imagewidth; ++j) { + register int v; -skip_on_error: - errcode = 1; -exit_label: - _TIFFfree(inputline); - _TIFFfree(thisline); - _TIFFfree(nextline); - _TIFFfree(outline); - return errcode; + lastpixel = (j == jmax); + v = *thisptr++; + if (v < 0) + v = 0; + else if (v > 255) + v = 255; + if (v > threshold) { + *outptr |= bit; + v -= 255; + } + bit >>= 1; + if (bit == 0) { + outptr++; + bit = 0x80; + } + if (!lastpixel) + thisptr[0] += v * 7 / 16; + if (!lastline) { + if (j != 0) + nextptr[-1] += v * 3 / 16; + *nextptr++ += v * 5 / 16; + if (!lastpixel) + nextptr[0] += v / 16; + } + } + if (TIFFWriteScanline(out, outline, i-1, 0) < 0) + goto skip_on_error; + } + goto exit_label; + + skip_on_error: + errcode = 1; + exit_label: + _TIFFfree(inputline); + _TIFFfree(thisline); + _TIFFfree(nextline); + _TIFFfree(outline); + return errcode; } -static uint16_t compression = COMPRESSION_PACKBITS; -static uint16_t predictor = 0; -static uint32_t group3options = 0; +static uint16 compression = COMPRESSION_PACKBITS; +static uint16 predictor = 0; +static uint32 group3options = 0; -static void processG3Options(char *cp) +static void +processG3Options(char* cp) { - if ((cp = strchr(cp, ':'))) - { - do - { - cp++; - if (strneq(cp, "1d", 2)) - group3options &= ~GROUP3OPT_2DENCODING; - else if (strneq(cp, "2d", 2)) - group3options |= GROUP3OPT_2DENCODING; - else if (strneq(cp, "fill", 4)) - group3options |= GROUP3OPT_FILLBITS; - else - usage(EXIT_FAILURE); - } while ((cp = strchr(cp, ':'))); - } + if ((cp = strchr(cp, ':'))) { + do { + cp++; + if (strneq(cp, "1d", 2)) + group3options &= ~GROUP3OPT_2DENCODING; + else if (strneq(cp, "2d", 2)) + group3options |= GROUP3OPT_2DENCODING; + else if (strneq(cp, "fill", 4)) + group3options |= GROUP3OPT_FILLBITS; + else + usage(EXIT_FAILURE); + } while ((cp = strchr(cp, ':'))); + } } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) { - if (streq(opt, "none")) - compression = COMPRESSION_NONE; - else if (streq(opt, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (strneq(opt, "g3", 2)) - { - processG3Options(opt); - compression = COMPRESSION_CCITTFAX3; - } - else if (streq(opt, "g4")) - compression = COMPRESSION_CCITTFAX4; - else if (strneq(opt, "lzw", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + if (streq(opt, "none")) + compression = COMPRESSION_NONE; + else if (streq(opt, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (strneq(opt, "g3", 2)) { + processG3Options(opt); + compression = COMPRESSION_CCITTFAX3; + } else if (streq(opt, "g4")) + compression = COMPRESSION_CCITTFAX4; + else if (strneq(opt, "lzw", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strneq(opt, "zip", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - TIFF *in, *out; - uint16_t samplesperpixel, bitspersample = 1, shortv; - float floatv; - char thing[1024]; - uint32_t rowsperstrip = (uint32_t)-1; - uint16_t fillorder = 0; - int c; + TIFF *in, *out; + uint16 samplesperpixel, bitspersample = 1, shortv; + float floatv; + char thing[1024]; + uint32 rowsperstrip = (uint32) -1; + uint16 fillorder = 0; + int c; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char *optarg; #endif - while ((c = getopt(argc, argv, "c:f:r:t:h")) != -1) - switch (c) - { - case 'c': /* compression scheme */ - if (!processCompressOptions(optarg)) - usage(EXIT_FAILURE); - break; - case 'f': /* fill order */ - if (streq(optarg, "lsb2msb")) - fillorder = FILLORDER_LSB2MSB; - else if (streq(optarg, "msb2lsb")) - fillorder = FILLORDER_MSB2LSB; - else - usage(EXIT_FAILURE); - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case 't': - threshold = atoi(optarg); - if (threshold < 0) - threshold = 0; - else if (threshold > 255) - threshold = 255; - break; - case 'h': - usage(EXIT_SUCCESS); - /*NOTREACHED*/ - break; - case '?': - usage(EXIT_FAILURE); - /*NOTREACHED*/ - break; - } - if (argc - optind < 2) - usage(EXIT_FAILURE); - in = TIFFOpen(argv[optind], "r"); - if (in == NULL) - return (EXIT_FAILURE); - TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); - if (samplesperpixel != 1) - { - fprintf(stderr, "%s: Not a b&w image.\n", argv[0]); - return (EXIT_FAILURE); - } - TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); - if (bitspersample != 8) - { - fprintf(stderr, " %s: Sorry, only handle 8-bit samples.\n", argv[0]); - return (EXIT_FAILURE); - } - out = TIFFOpen(argv[optind + 1], "w"); - if (out == NULL) - return (EXIT_FAILURE); - CopyField(TIFFTAG_IMAGEWIDTH, imagewidth); - TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); - TIFFSetField(out, TIFFTAG_IMAGELENGTH, imagelength - 1); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); - TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - if (fillorder) - TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); - else - CopyField(TIFFTAG_FILLORDER, shortv); - snprintf(thing, sizeof(thing), "Dithered B&W version of %s", argv[optind]); - TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing); - CopyField(TIFFTAG_PHOTOMETRIC, shortv); - CopyField(TIFFTAG_ORIENTATION, shortv); - CopyField(TIFFTAG_XRESOLUTION, floatv); - CopyField(TIFFTAG_YRESOLUTION, floatv); - CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); - rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); - switch (compression) - { - case COMPRESSION_CCITTFAX3: - TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, group3options); - break; - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - break; - } - fsdither(in, out); - TIFFClose(in); - TIFFClose(out); - return (EXIT_SUCCESS); + while ((c = getopt(argc, argv, "c:f:r:t:h")) != -1) + switch (c) { + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(EXIT_FAILURE); + break; + case 'f': /* fill order */ + if (streq(optarg, "lsb2msb")) + fillorder = FILLORDER_LSB2MSB; + else if (streq(optarg, "msb2lsb")) + fillorder = FILLORDER_MSB2LSB; + else + usage(EXIT_FAILURE); + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case 't': + threshold = atoi(optarg); + if (threshold < 0) + threshold = 0; + else if (threshold > 255) + threshold = 255; + break; + case 'h': + usage(EXIT_SUCCESS); + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } + if (argc - optind < 2) + usage(EXIT_FAILURE); + in = TIFFOpen(argv[optind], "r"); + if (in == NULL) + return (EXIT_FAILURE); + TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + if (samplesperpixel != 1) { + fprintf(stderr, "%s: Not a b&w image.\n", argv[0]); + return (EXIT_FAILURE); + } + TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); + if (bitspersample != 8) { + fprintf(stderr, + " %s: Sorry, only handle 8-bit samples.\n", argv[0]); + return (EXIT_FAILURE); + } + out = TIFFOpen(argv[optind+1], "w"); + if (out == NULL) + return (EXIT_FAILURE); + CopyField(TIFFTAG_IMAGEWIDTH, imagewidth); + TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); + TIFFSetField(out, TIFFTAG_IMAGELENGTH, imagelength-1); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, 1); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, 1); + TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + if (fillorder) + TIFFSetField(out, TIFFTAG_FILLORDER, fillorder); + else + CopyField(TIFFTAG_FILLORDER, shortv); + snprintf(thing, sizeof(thing), "Dithered B&W version of %s", argv[optind]); + TIFFSetField(out, TIFFTAG_IMAGEDESCRIPTION, thing); + CopyField(TIFFTAG_PHOTOMETRIC, shortv); + CopyField(TIFFTAG_ORIENTATION, shortv); + CopyField(TIFFTAG_XRESOLUTION, floatv); + CopyField(TIFFTAG_YRESOLUTION, floatv); + CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); + rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); + switch (compression) { + case COMPRESSION_CCITTFAX3: + TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, group3options); + break; + case COMPRESSION_LZW: + case COMPRESSION_DEFLATE: + if (predictor) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + break; + } + fsdither(in, out); + TIFFClose(in); + TIFFClose(out); + return (EXIT_SUCCESS); } -static const char usage_info[] = - "Convert a greyscale image to bilevel using dithering\n\n" - "usage: tiffdither [options] input.tif output.tif\n" - "where options are:\n" - " -r # make each strip have no more than # rows\n" - " -t # set the threshold value for dithering (default 128)\n" - " -f lsb2msb force lsb-to-msb FillOrder for output\n" - " -f msb2lsb force msb-to-lsb FillOrder for output\n" - "\n" -#ifdef LZW_SUPPORT - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" - " # set predictor value\n" - " For example, -c lzw:2 for LZW-encoded data with horizontal " - "differencing\n" -#endif -#ifdef ZIP_SUPPORT - " -c zip[:opts] compress output with deflate encoding\n" - " # set predictor value\n" -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits compress output with packbits encoding\n" -#endif -#ifdef CCITT_SUPPORT - " -c g3[:opts] compress output with CCITT Group 3 encoding\n" - " Group 3 options:\n" - " 1d use default CCITT Group 3 1D-encoding\n" - " 2d use optional CCITT Group 3 2D-encoding\n" - " fill byte-align EOL codes\n" - " For example, -c g3:2d:fill for G3-2D-encoded data with byte-aligned " - "EOLs\n" - " -c g4 compress output with CCITT Group 4 encoding\n" -#endif -#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || \ - defined(PACKBITS_SUPPORT) || defined(CCITT_SUPPORT) - " -c none use no compression algorithm on output\n" -#endif - "\n"; +static const char* stuff[] = { +"usage: tiffdither [options] input.tif output.tif", +"where options are:", +" -r # make each strip have no more than # rows", +" -t # set the threshold value for dithering (default 128)", +" -f lsb2msb force lsb-to-msb FillOrder for output", +" -f msb2lsb force msb-to-lsb FillOrder for output", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c packbits compress output with packbits encoding", +" -c g3[:opts] compress output with CCITT Group 3 encoding", +" -c g4 compress output with CCITT Group 4 encoding", +" -c none use no compression algorithm on output", +"", +"Group 3 options:", +" 1d use default CCITT Group 3 1D-encoding", +" 2d use optional CCITT Group 3 2D-encoding", +" fill byte-align EOL codes", +"For example, -c g3:2d:fill to get G3-2D-encoded data with byte-aligned EOLs", +"", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffdump.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffdump.c index df1f9358b..00be9dd4e 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffdump.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffdump.c @@ -2,27 +2,26 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" #include @@ -30,21 +29,29 @@ #include #ifdef HAVE_UNISTD_H -#include +# include #endif #include "tiffiop.h" #ifdef HAVE_FCNTL_H -#include +# include #endif #ifdef HAVE_SYS_TYPES_H -#include +# include #endif #ifdef HAVE_IO_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" +#endif + +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); #endif #include "tiffio.h" @@ -57,836 +64,831 @@ #endif #ifndef O_BINARY -#define O_BINARY 0 +# define O_BINARY 0 #endif static union { - TIFFHeaderClassic classic; - TIFFHeaderBig big; - TIFFHeaderCommon common; + TIFFHeaderClassic classic; + TIFFHeaderBig big; + TIFFHeaderCommon common; } hdr; -static char *appname; -static char *curfile; -static int swabflag; -static int bigendian; -static int bigtiff; -static uint32_t maxitems = 24; /* maximum indirect data items to print */ +char* appname; +char* curfile; +int swabflag; +int bigendian; +int bigtiff; +uint32 maxitems = 24; /* maximum indirect data items to print */ -static const char bytefmt[] = "%s%#02" PRIx8; /* BYTE */ -static const char sbytefmt[] = "%s%" PRId8; /* SBYTE */ -static const char shortfmtd[] = "%s%" PRIu16; /* SHORT */ -static const char shortfmth[] = "%s%#" PRIx16; -static const char sshortfmtd[] = "%s%" PRId16; /* SSHORT */ -static const char sshortfmth[] = "%s%#" PRIx16; -static const char longfmtd[] = "%s%" PRIu32; /* LONG */ -static const char longfmth[] = "%s%#" PRIx32; -static const char slongfmtd[] = "%s%" PRId32; /* SLONG */ -static const char slongfmth[] = "%s%#" PRIx32; -static const char ifdfmt[] = "%s%#04" PRIx32; /* IFD offset */ -static const char long8fmt[] = "%s%" PRIu64; /* LONG8 */ -static const char slong8fmt[] = "%s%" PRId64; /* SLONG8 */ -static const char ifd8fmt[] = "%s%#08" PRIx64; /* IFD offset8 */ -static const char rationalfmt[] = "%s%g"; /* RATIONAL */ -static const char srationalfmt[] = "%s%g"; /* SRATIONAL */ -static const char floatfmt[] = "%s%g"; /* FLOAT */ -static const char doublefmt[] = "%s%g"; /* DOUBLE */ +const char* bytefmt = "%s%#02x"; /* BYTE */ +const char* sbytefmt = "%s%d"; /* SBYTE */ +const char* shortfmt = "%s%u"; /* SHORT */ +const char* sshortfmt = "%s%d"; /* SSHORT */ +const char* longfmt = "%s%lu"; /* LONG */ +const char* slongfmt = "%s%ld"; /* SLONG */ +const char* ifdfmt = "%s%#04lx"; /* IFD offset */ +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) +const char* long8fmt = "%s%I64u"; /* LONG8 */ +const char* slong8fmt = "%s%I64d"; /* SLONG8 */ +const char* ifd8fmt = "%s%#08I64x"; /* IFD offset8*/ +#else +const char* long8fmt = "%s%llu"; /* LONG8 */ +const char* slong8fmt = "%s%lld"; /* SLONG8 */ +const char* ifd8fmt = "%s%#08llx"; /* IFD offset8*/ +#endif +const char* rationalfmt = "%s%g"; /* RATIONAL */ +const char* srationalfmt = "%s%g"; /* SRATIONAL */ +const char* floatfmt = "%s%g"; /* FLOAT */ +const char* doublefmt = "%s%g"; /* DOUBLE */ -unsigned int hex_mode; - -static void dump(int, uint64_t); +static void dump(int, uint64); #if !HAVE_DECL_OPTARG extern int optind; -extern char *optarg; +extern char* optarg; #endif -void usage() +void +usage() { - fprintf(stderr, "\nDisplay directory information from TIFF files\n\n"); - fprintf(stderr, "usage: %s [-h] [-o offset] [-m maxitems] file.tif ...\n", - appname); - exit(EXIT_FAILURE); + fprintf(stderr, "usage: %s [-h] [-o offset] [-m maxitems] file.tif ...\n", appname); + exit(EXIT_FAILURE); } -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - int one = 1, fd; - int multiplefiles = (argc > 1); - int c; - uint64_t diroff = 0; - hex_mode = 0; - bigendian = (*(char *)&one == 0); + int one = 1, fd; + int multiplefiles = (argc > 1); + int c; + uint64 diroff = 0; + bigendian = (*(char *)&one == 0); - appname = argv[0]; - while ((c = getopt(argc, argv, "m:o:h")) != -1) - { - switch (c) - { - case 'h': /* print values in hex */ - hex_mode = 1; - break; - case 'o': - diroff = (uint64_t)strtoul(optarg, NULL, 0); - break; - case 'm': - maxitems = strtoul(optarg, NULL, 0); - break; - default: - usage(); - } - } - if (optind >= argc) - usage(); - for (; optind < argc; optind++) - { - fd = open(argv[optind], O_RDONLY | O_BINARY, 0); - if (fd < 0) - { - perror(argv[0]); - return (EXIT_FAILURE); - } - if (multiplefiles) - printf("%s:\n", argv[optind]); - curfile = argv[optind]; - swabflag = 0; - bigtiff = 0; - dump(fd, diroff); - close(fd); - } - return (EXIT_SUCCESS); + appname = argv[0]; + while ((c = getopt(argc, argv, "m:o:h")) != -1) { + switch (c) { + case 'h': /* print values in hex */ + shortfmt = "%s%#x"; + sshortfmt = "%s%#x"; + longfmt = "%s%#lx"; + slongfmt = "%s%#lx"; + break; + case 'o': + diroff = (uint64) strtoul(optarg, NULL, 0); + break; + case 'm': + maxitems = strtoul(optarg, NULL, 0); + break; + default: + usage(); + } + } + if (optind >= argc) + usage(); + for (; optind < argc; optind++) { + fd = open(argv[optind], O_RDONLY|O_BINARY, 0); + if (fd < 0) { + perror(argv[0]); + return (EXIT_FAILURE); + } + if (multiplefiles) + printf("%s:\n", argv[optind]); + curfile = argv[optind]; + swabflag = 0; + bigtiff = 0; + dump(fd, diroff); + close(fd); + } + return (EXIT_SUCCESS); } #define ord(e) ((int)e) -static uint64_t ReadDirectory(int, unsigned, uint64_t); -static void ReadError(char *); -static void Error(const char *, ...); -static void Fatal(const char *, ...); +static uint64 ReadDirectory(int, unsigned, uint64); +static void ReadError(char*); +static void Error(const char*, ...); +static void Fatal(const char*, ...); -static void dump(int fd, uint64_t diroff) +static void +dump(int fd, uint64 diroff) { - unsigned i, j; - uint64_t *visited_diroff = NULL; - unsigned int count_visited_dir = 0; + unsigned i, j; + uint64* visited_diroff = NULL; + unsigned int count_visited_dir = 0; - _TIFF_lseek_f(fd, (_TIFF_off_t)0, 0); - if (read(fd, (char *)&hdr, sizeof(TIFFHeaderCommon)) != - sizeof(TIFFHeaderCommon)) - ReadError("TIFF header"); - if (hdr.common.tiff_magic != TIFF_BIGENDIAN && - hdr.common.tiff_magic != TIFF_LITTLEENDIAN && + _TIFF_lseek_f(fd, (_TIFF_off_t) 0, 0); + if (read(fd, (char*) &hdr, sizeof (TIFFHeaderCommon)) != sizeof (TIFFHeaderCommon)) + ReadError("TIFF header"); + if (hdr.common.tiff_magic != TIFF_BIGENDIAN + && hdr.common.tiff_magic != TIFF_LITTLEENDIAN && #if HOST_BIGENDIAN - /* MDI is sensitive to the host byte order, unlike TIFF */ - MDI_BIGENDIAN != hdr.common.tiff_magic + /* MDI is sensitive to the host byte order, unlike TIFF */ + MDI_BIGENDIAN != hdr.common.tiff_magic #else - MDI_LITTLEENDIAN != hdr.common.tiff_magic + MDI_LITTLEENDIAN != hdr.common.tiff_magic #endif - ) - { - Fatal("Not a TIFF or MDI file, bad magic number %u (%#x)", - hdr.common.tiff_magic, hdr.common.tiff_magic); - } - if (hdr.common.tiff_magic == TIFF_BIGENDIAN || - hdr.common.tiff_magic == MDI_BIGENDIAN) - swabflag = !bigendian; - else - swabflag = bigendian; - if (swabflag) - TIFFSwabShort(&hdr.common.tiff_version); - if (hdr.common.tiff_version == 42) - { - if (read(fd, - ((char *)&hdr.classic) + - offsetof(TIFFHeaderClassic, tiff_diroff), - 4) != 4) - ReadError("TIFF header"); - if (swabflag) - TIFFSwabLong(&hdr.classic.tiff_diroff); - printf("Magic: %#x <%s-endian> Version: %#x <%s>\n", - hdr.classic.tiff_magic, - hdr.classic.tiff_magic == TIFF_BIGENDIAN ? "big" : "little", 42, - "ClassicTIFF"); - if (diroff == 0) - diroff = hdr.classic.tiff_diroff; - } - else if (hdr.common.tiff_version == 43) - { - if (read(fd, - ((char *)&hdr.big) + offsetof(TIFFHeaderBig, tiff_offsetsize), - 12) != 12) - ReadError("TIFF header"); - if (swabflag) - { - TIFFSwabShort(&hdr.big.tiff_offsetsize); - TIFFSwabShort(&hdr.big.tiff_unused); - TIFFSwabLong8(&hdr.big.tiff_diroff); - } - printf("Magic: %#x <%s-endian> Version: %#x <%s>\n", hdr.big.tiff_magic, - hdr.big.tiff_magic == TIFF_BIGENDIAN ? "big" : "little", 43, - "BigTIFF"); - printf("OffsetSize: %#x Unused: %#x\n", hdr.big.tiff_offsetsize, - hdr.big.tiff_unused); - if (diroff == 0) - diroff = hdr.big.tiff_diroff; - bigtiff = 1; - } - else - Fatal("Not a TIFF file, bad version number %u (%#x)", - hdr.common.tiff_version, hdr.common.tiff_version); - for (i = 0; diroff != 0; i++) - { - for (j = 0; j < count_visited_dir; j++) - { - if (visited_diroff[j] == diroff) - { - free(visited_diroff); - Fatal("Cycle detected in chaining of TIFF directories!"); - } - } - { - size_t alloc_size; - alloc_size = TIFFSafeMultiply(tmsize_t, (count_visited_dir + 1), - sizeof(uint64_t)); - if (alloc_size == 0) - { - if (visited_diroff) - free(visited_diroff); - visited_diroff = 0; - } - else - { - visited_diroff = - (uint64_t *)realloc(visited_diroff, alloc_size); - } - } - if (!visited_diroff) - Fatal("Out of memory"); - visited_diroff[count_visited_dir] = diroff; - count_visited_dir++; + ) { + Fatal("Not a TIFF or MDI file, bad magic number %u (%#x)", + hdr.common.tiff_magic, hdr.common.tiff_magic); + } + if (hdr.common.tiff_magic == TIFF_BIGENDIAN + || hdr.common.tiff_magic == MDI_BIGENDIAN) + swabflag = !bigendian; + else + swabflag = bigendian; + if (swabflag) + TIFFSwabShort(&hdr.common.tiff_version); + if (hdr.common.tiff_version==42) + { + if (read(fd, (char*) &hdr.classic.tiff_diroff, 4) != 4) + ReadError("TIFF header"); + if (swabflag) + TIFFSwabLong(&hdr.classic.tiff_diroff); + printf("Magic: %#x <%s-endian> Version: %#x <%s>\n", + hdr.classic.tiff_magic, + hdr.classic.tiff_magic == TIFF_BIGENDIAN ? "big" : "little", + 42,"ClassicTIFF"); + if (diroff == 0) + diroff = hdr.classic.tiff_diroff; + } + else if (hdr.common.tiff_version==43) + { + if (read(fd, (char*) &hdr.big.tiff_offsetsize, 12) != 12) + ReadError("TIFF header"); + if (swabflag) + { + TIFFSwabShort(&hdr.big.tiff_offsetsize); + TIFFSwabShort(&hdr.big.tiff_unused); + TIFFSwabLong8(&hdr.big.tiff_diroff); + } + printf("Magic: %#x <%s-endian> Version: %#x <%s>\n", + hdr.big.tiff_magic, + hdr.big.tiff_magic == TIFF_BIGENDIAN ? "big" : "little", + 43,"BigTIFF"); + printf("OffsetSize: %#x Unused: %#x\n", + hdr.big.tiff_offsetsize,hdr.big.tiff_unused); + if (diroff == 0) + diroff = hdr.big.tiff_diroff; + bigtiff = 1; + } + else + Fatal("Not a TIFF file, bad version number %u (%#x)", + hdr.common.tiff_version, hdr.common.tiff_version); + for (i = 0; diroff != 0; i++) { + for(j=0; j 0) - putchar('\n'); - diroff = ReadDirectory(fd, i, diroff); - } - if (visited_diroff) - free(visited_diroff); + if (i > 0) + putchar('\n'); + diroff = ReadDirectory(fd, i, diroff); + } + if( visited_diroff ) + free(visited_diroff); } static const int datawidth[] = { - 0, /* 00 = undefined */ - 1, /* 01 = TIFF_BYTE */ - 1, /* 02 = TIFF_ASCII */ - 2, /* 03 = TIFF_SHORT */ - 4, /* 04 = TIFF_LONG */ - 8, /* 05 = TIFF_RATIONAL */ - 1, /* 06 = TIFF_SBYTE */ - 1, /* 07 = TIFF_UNDEFINED */ - 2, /* 08 = TIFF_SSHORT */ - 4, /* 09 = TIFF_SLONG */ - 8, /* 10 = TIFF_SRATIONAL */ - 4, /* 11 = TIFF_FLOAT */ - 8, /* 12 = TIFF_DOUBLE */ - 4, /* 13 = TIFF_IFD */ - 0, /* 14 = undefined */ - 0, /* 15 = undefined */ - 8, /* 16 = TIFF_LONG8 */ - 8, /* 17 = TIFF_SLONG8 */ - 8, /* 18 = TIFF_IFD8 */ + 0, /* 00 = undefined */ + 1, /* 01 = TIFF_BYTE */ + 1, /* 02 = TIFF_ASCII */ + 2, /* 03 = TIFF_SHORT */ + 4, /* 04 = TIFF_LONG */ + 8, /* 05 = TIFF_RATIONAL */ + 1, /* 06 = TIFF_SBYTE */ + 1, /* 07 = TIFF_UNDEFINED */ + 2, /* 08 = TIFF_SSHORT */ + 4, /* 09 = TIFF_SLONG */ + 8, /* 10 = TIFF_SRATIONAL */ + 4, /* 11 = TIFF_FLOAT */ + 8, /* 12 = TIFF_DOUBLE */ + 4, /* 13 = TIFF_IFD */ + 0, /* 14 = undefined */ + 0, /* 15 = undefined */ + 8, /* 16 = TIFF_LONG8 */ + 8, /* 17 = TIFF_SLONG8 */ + 8, /* 18 = TIFF_IFD8 */ }; -#define NWIDTHS (sizeof(datawidth) / sizeof(datawidth[0])) -static void PrintTag(FILE *, uint16_t); -static void PrintType(FILE *, uint16_t); -static void PrintData(FILE *, uint16_t, uint32_t, unsigned char *); +#define NWIDTHS (sizeof (datawidth) / sizeof (datawidth[0])) +static void PrintTag(FILE*, uint16); +static void PrintType(FILE*, uint16); +static void PrintData(FILE*, uint16, uint32, unsigned char*); /* * Read the next TIFF directory from a file * and convert it to the internal format. * We read directories sequentially. */ -static uint64_t ReadDirectory(int fd, unsigned int ix, uint64_t off) +static uint64 +ReadDirectory(int fd, unsigned int ix, uint64 off) { - uint16_t dircount; - uint32_t direntrysize; - void *dirmem = NULL; - uint64_t nextdiroff = 0; - uint32_t n; - uint8_t *dp; + uint16 dircount; + uint32 direntrysize; + void* dirmem = NULL; + uint64 nextdiroff = 0; + uint32 n; + uint8* dp; - if (off == 0) /* no more directories */ - goto done; - if (_TIFF_lseek_f(fd, (_TIFF_off_t)off, SEEK_SET) != (_TIFF_off_t)off) - { - Fatal("Seek error accessing TIFF directory"); - goto done; - } - if (!bigtiff) - { - if (read(fd, (char *)&dircount, sizeof(uint16_t)) != sizeof(uint16_t)) - { - ReadError("directory count"); - goto done; - } - if (swabflag) - TIFFSwabShort(&dircount); - direntrysize = 12; - } - else - { - uint64_t dircount64 = 0; - if (read(fd, (char *)&dircount64, sizeof(uint64_t)) != sizeof(uint64_t)) - { - ReadError("directory count"); - goto done; - } - if (swabflag) - TIFFSwabLong8(&dircount64); - if (dircount64 > 0xFFFF) - { - Error("Sanity check on directory count failed"); - goto done; - } - dircount = (uint16_t)dircount64; - direntrysize = 20; - } - dirmem = _TIFFmalloc(TIFFSafeMultiply(tmsize_t, dircount, direntrysize)); - if (dirmem == NULL) - { - Fatal("No space for TIFF directory"); - goto done; - } - n = read(fd, (char *)dirmem, dircount * direntrysize); - if (n != dircount * direntrysize) - { - n /= direntrysize; - Error("Could only read %" PRIu32 " of %" PRIu16 - " entries in directory at offset %#" PRIu64, - n, dircount, off); - dircount = n; - nextdiroff = 0; - } - else - { - if (!bigtiff) - { - uint32_t nextdiroff32; - if (read(fd, (char *)&nextdiroff32, sizeof(uint32_t)) != - sizeof(uint32_t)) - nextdiroff32 = 0; - if (swabflag) - TIFFSwabLong(&nextdiroff32); - nextdiroff = nextdiroff32; - } - else - { - if (read(fd, (char *)&nextdiroff, sizeof(uint64_t)) != - sizeof(uint64_t)) - nextdiroff = 0; - if (swabflag) - TIFFSwabLong8(&nextdiroff); - } - } - printf("Directory %u: offset %" PRIu64 " (%#" PRIx64 ") next %" PRIu64 - " (%#" PRIx64 ")\n", - ix, off, off, nextdiroff, nextdiroff); - for (dp = (uint8_t *)dirmem, n = dircount; n > 0; n--) - { - uint16_t tag; - uint16_t type; - uint16_t typewidth; - uint64_t count; - uint64_t datasize; - int datafits; - void *datamem; - uint64_t dataoffset; - int datatruncated; - int datasizeoverflow; + if (off == 0) /* no more directories */ + goto done; + if (_TIFF_lseek_f(fd, (_TIFF_off_t)off, SEEK_SET) != (_TIFF_off_t)off) { + Fatal("Seek error accessing TIFF directory"); + goto done; + } + if (!bigtiff) { + if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) { + ReadError("directory count"); + goto done; + } + if (swabflag) + TIFFSwabShort(&dircount); + direntrysize = 12; + } else { + uint64 dircount64 = 0; + if (read(fd, (char*) &dircount64, sizeof (uint64)) != sizeof (uint64)) { + ReadError("directory count"); + goto done; + } + if (swabflag) + TIFFSwabLong8(&dircount64); + if (dircount64>0xFFFF) { + Error("Sanity check on directory count failed"); + goto done; + } + dircount = (uint16)dircount64; + direntrysize = 20; + } + dirmem = _TIFFmalloc(TIFFSafeMultiply(tmsize_t,dircount,direntrysize)); + if (dirmem == NULL) { + Fatal("No space for TIFF directory"); + goto done; + } + n = read(fd, (char*) dirmem, dircount*direntrysize); + if (n != dircount*direntrysize) { + n /= direntrysize; + Error( +#if defined(__WIN32__) && defined(_MSC_VER) + "Could only read %lu of %u entries in directory at offset %#I64x", + (unsigned long)n, dircount, (unsigned __int64) off); +#else + "Could only read %lu of %u entries in directory at offset %#llx", + (unsigned long)n, dircount, (unsigned long long) off); +#endif + dircount = n; + nextdiroff = 0; + } else { + if (!bigtiff) { + uint32 nextdiroff32; + if (read(fd, (char*) &nextdiroff32, sizeof (uint32)) != sizeof (uint32)) + nextdiroff32 = 0; + if (swabflag) + TIFFSwabLong(&nextdiroff32); + nextdiroff = nextdiroff32; + } else { + if (read(fd, (char*) &nextdiroff, sizeof (uint64)) != sizeof (uint64)) + nextdiroff = 0; + if (swabflag) + TIFFSwabLong8(&nextdiroff); + } + } +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + printf("Directory %u: offset %I64u (%#I64x) next %I64u (%#I64x)\n", ix, + (unsigned __int64)off, (unsigned __int64)off, + (unsigned __int64)nextdiroff, (unsigned __int64)nextdiroff); +#else + printf("Directory %u: offset %llu (%#llx) next %llu (%#llx)\n", ix, + (unsigned long long)off, (unsigned long long)off, + (unsigned long long)nextdiroff, (unsigned long long)nextdiroff); +#endif + for (dp = (uint8*)dirmem, n = dircount; n > 0; n--) { + uint16 tag; + uint16 type; + uint16 typewidth; + uint64 count; + uint64 datasize; + int datafits; + void* datamem; + uint64 dataoffset; + int datatruncated; + int datasizeoverflow; - tag = *(uint16_t *)dp; - if (swabflag) - TIFFSwabShort(&tag); - dp += sizeof(uint16_t); - type = *(uint16_t *)dp; - dp += sizeof(uint16_t); - if (swabflag) - TIFFSwabShort(&type); - PrintTag(stdout, tag); - putchar(' '); - PrintType(stdout, type); - putchar(' '); - if (!bigtiff) - { - uint32_t count32; - count32 = *(uint32_t *)dp; - if (swabflag) - TIFFSwabLong(&count32); - dp += sizeof(uint32_t); - count = count32; - } - else - { - memcpy(&count, dp, sizeof(uint64_t)); - if (swabflag) - TIFFSwabLong8(&count); - dp += sizeof(uint64_t); - } - printf("%" PRIu64 "<", count); - if (type >= NWIDTHS) - typewidth = 0; - else - typewidth = datawidth[type]; - datasize = TIFFSafeMultiply(tmsize_t, count, typewidth); - datasizeoverflow = (typewidth > 0 && datasize / typewidth != count); - datafits = 1; - datamem = dp; - dataoffset = 0; - datatruncated = 0; - if (!bigtiff) - { - if (datasizeoverflow || datasize > 4) - { - uint32_t dataoffset32; - datafits = 0; - datamem = NULL; - dataoffset32 = *(uint32_t *)dp; - if (swabflag) - TIFFSwabLong(&dataoffset32); - dataoffset = dataoffset32; - } - dp += sizeof(uint32_t); - } - else - { - if (datasizeoverflow || datasize > 8) - { - datafits = 0; - datamem = NULL; - memcpy(&dataoffset, dp, sizeof(uint64_t)); - if (swabflag) - TIFFSwabLong8(&dataoffset); - } - dp += sizeof(uint64_t); - } - if (datasizeoverflow || datasize > 0x10000) - { - datatruncated = 1; - count = 0x10000 / typewidth; - datasize = TIFFSafeMultiply(tmsize_t, count, typewidth); - } - if (count > maxitems) - { - datatruncated = 1; - count = maxitems; - datasize = TIFFSafeMultiply(tmsize_t, count, typewidth); - } - if (!datafits) - { - datamem = _TIFFmalloc(datasize); - if (datamem) - { - if (_TIFF_lseek_f(fd, (_TIFF_off_t)dataoffset, 0) != - (_TIFF_off_t)dataoffset) - { - Error("Seek error accessing tag %u value", tag); - _TIFFfree(datamem); - datamem = NULL; - } - else if (read(fd, datamem, (size_t)datasize) != - (tmsize_t)datasize) - { - Error("Read error accessing tag %u value", tag); - _TIFFfree(datamem); - datamem = NULL; - } - } - else - Error("No space for data for tag %u", tag); - } - if (datamem) - { - if (swabflag) - { - switch (type) - { - case TIFF_BYTE: - case TIFF_ASCII: - case TIFF_SBYTE: - case TIFF_UNDEFINED: - break; - case TIFF_SHORT: - case TIFF_SSHORT: - TIFFSwabArrayOfShort((uint16_t *)datamem, - (tmsize_t)count); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - case TIFF_IFD: - TIFFSwabArrayOfLong((uint32_t *)datamem, - (tmsize_t)count); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - TIFFSwabArrayOfLong((uint32_t *)datamem, - (tmsize_t)count * 2); - break; - case TIFF_DOUBLE: - case TIFF_LONG8: - case TIFF_SLONG8: - case TIFF_IFD8: - TIFFSwabArrayOfLong8((uint64_t *)datamem, - (tmsize_t)count); - break; - } - } - PrintData(stdout, type, (uint32_t)count, datamem); - if (datatruncated) - printf(" ..."); - if (!datafits) - { - _TIFFfree(datamem); - datamem = NULL; - } - } - printf(">\n"); - } + tag = *(uint16*)dp; + if (swabflag) + TIFFSwabShort(&tag); + dp += sizeof(uint16); + type = *(uint16*)dp; + dp += sizeof(uint16); + if (swabflag) + TIFFSwabShort(&type); + PrintTag(stdout, tag); + putchar(' '); + PrintType(stdout, type); + putchar(' '); + if (!bigtiff) + { + uint32 count32; + count32 = *(uint32*)dp; + if (swabflag) + TIFFSwabLong(&count32); + dp += sizeof(uint32); + count = count32; + } + else + { + memcpy(&count, dp, sizeof(uint64)); + if (swabflag) + TIFFSwabLong8(&count); + dp += sizeof(uint64); + } +#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__)) + printf("%I64u<", (unsigned __int64)count); +#else + printf("%llu<", (unsigned long long)count); +#endif + if (type >= NWIDTHS) + typewidth = 0; + else + typewidth = datawidth[type]; + datasize = TIFFSafeMultiply(tmsize_t,count,typewidth); + datasizeoverflow = (typewidth > 0 && datasize / typewidth != count); + datafits = 1; + datamem = dp; + dataoffset = 0; + datatruncated = 0; + if (!bigtiff) + { + if (datasizeoverflow || datasize>4) + { + uint32 dataoffset32; + datafits = 0; + datamem = NULL; + dataoffset32 = *(uint32*)dp; + if (swabflag) + TIFFSwabLong(&dataoffset32); + dataoffset = dataoffset32; + } + dp += sizeof(uint32); + } + else + { + if (datasizeoverflow || datasize>8) + { + datafits = 0; + datamem = NULL; + memcpy(&dataoffset, dp, sizeof(uint64)); + if (swabflag) + TIFFSwabLong8(&dataoffset); + } + dp += sizeof(uint64); + } + if (datasizeoverflow || datasize>0x10000) + { + datatruncated = 1; + count = 0x10000/typewidth; + datasize = TIFFSafeMultiply(tmsize_t,count,typewidth); + } + if (count>maxitems) + { + datatruncated = 1; + count = maxitems; + datasize = TIFFSafeMultiply(tmsize_t,count,typewidth); + } + if (!datafits) + { + datamem = _TIFFmalloc(datasize); + if (datamem) { + if (_TIFF_lseek_f(fd, (_TIFF_off_t)dataoffset, 0) != + (_TIFF_off_t)dataoffset) + { + Error( + "Seek error accessing tag %u value", tag); + _TIFFfree(datamem); + datamem = NULL; + } + else if (read(fd, datamem, (size_t)datasize) != (TIFF_SSIZE_T)datasize) + { + Error( + "Read error accessing tag %u value", tag); + _TIFFfree(datamem); + datamem = NULL; + } + } else + Error("No space for data for tag %u",tag); + } + if (datamem) + { + if (swabflag) + { + switch (type) + { + case TIFF_BYTE: + case TIFF_ASCII: + case TIFF_SBYTE: + case TIFF_UNDEFINED: + break; + case TIFF_SHORT: + case TIFF_SSHORT: + TIFFSwabArrayOfShort((uint16*)datamem,(tmsize_t)count); + break; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + case TIFF_IFD: + TIFFSwabArrayOfLong((uint32*)datamem,(tmsize_t)count); + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + TIFFSwabArrayOfLong((uint32*)datamem,(tmsize_t)count*2); + break; + case TIFF_DOUBLE: + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_IFD8: + TIFFSwabArrayOfLong8((uint64*)datamem,(tmsize_t)count); + break; + } + } + PrintData(stdout,type,(uint32)count,datamem); + if (datatruncated) + printf(" ..."); + if (!datafits) + { + _TIFFfree(datamem); + datamem = NULL; + } + } + printf(">\n"); + } done: - if (dirmem) - _TIFFfree((char *)dirmem); - return (nextdiroff); + if (dirmem) + _TIFFfree((char *)dirmem); + return (nextdiroff); } -static const struct tagname -{ - uint16_t tag; - const char *name; +static const struct tagname { + uint16 tag; + const char* name; } tagnames[] = { - {TIFFTAG_SUBFILETYPE, "SubFileType"}, - {TIFFTAG_OSUBFILETYPE, "OldSubFileType"}, - {TIFFTAG_IMAGEWIDTH, "ImageWidth"}, - {TIFFTAG_IMAGELENGTH, "ImageLength"}, - {TIFFTAG_BITSPERSAMPLE, "BitsPerSample"}, - {TIFFTAG_COMPRESSION, "Compression"}, - {TIFFTAG_PHOTOMETRIC, "Photometric"}, - {TIFFTAG_THRESHHOLDING, "Threshholding"}, - {TIFFTAG_CELLWIDTH, "CellWidth"}, - {TIFFTAG_CELLLENGTH, "CellLength"}, - {TIFFTAG_FILLORDER, "FillOrder"}, - {TIFFTAG_DOCUMENTNAME, "DocumentName"}, - {TIFFTAG_IMAGEDESCRIPTION, "ImageDescription"}, - {TIFFTAG_MAKE, "Make"}, - {TIFFTAG_MODEL, "Model"}, - {TIFFTAG_STRIPOFFSETS, "StripOffsets"}, - {TIFFTAG_ORIENTATION, "Orientation"}, - {TIFFTAG_SAMPLESPERPIXEL, "SamplesPerPixel"}, - {TIFFTAG_ROWSPERSTRIP, "RowsPerStrip"}, - {TIFFTAG_STRIPBYTECOUNTS, "StripByteCounts"}, - {TIFFTAG_MINSAMPLEVALUE, "MinSampleValue"}, - {TIFFTAG_MAXSAMPLEVALUE, "MaxSampleValue"}, - {TIFFTAG_XRESOLUTION, "XResolution"}, - {TIFFTAG_YRESOLUTION, "YResolution"}, - {TIFFTAG_PLANARCONFIG, "PlanarConfig"}, - {TIFFTAG_PAGENAME, "PageName"}, - {TIFFTAG_XPOSITION, "XPosition"}, - {TIFFTAG_YPOSITION, "YPosition"}, - {TIFFTAG_FREEOFFSETS, "FreeOffsets"}, - {TIFFTAG_FREEBYTECOUNTS, "FreeByteCounts"}, - {TIFFTAG_GRAYRESPONSEUNIT, "GrayResponseUnit"}, - {TIFFTAG_GRAYRESPONSECURVE, "GrayResponseCurve"}, - {TIFFTAG_GROUP3OPTIONS, "Group3Options"}, - {TIFFTAG_GROUP4OPTIONS, "Group4Options"}, - {TIFFTAG_RESOLUTIONUNIT, "ResolutionUnit"}, - {TIFFTAG_PAGENUMBER, "PageNumber"}, - {TIFFTAG_COLORRESPONSEUNIT, "ColorResponseUnit"}, - {TIFFTAG_TRANSFERFUNCTION, "TransferFunction"}, - {TIFFTAG_SOFTWARE, "Software"}, - {TIFFTAG_DATETIME, "DateTime"}, - {TIFFTAG_ARTIST, "Artist"}, - {TIFFTAG_HOSTCOMPUTER, "HostComputer"}, - {TIFFTAG_PREDICTOR, "Predictor"}, - {TIFFTAG_WHITEPOINT, "Whitepoint"}, - {TIFFTAG_PRIMARYCHROMATICITIES, "PrimaryChromaticities"}, - {TIFFTAG_COLORMAP, "Colormap"}, - {TIFFTAG_HALFTONEHINTS, "HalftoneHints"}, - {TIFFTAG_TILEWIDTH, "TileWidth"}, - {TIFFTAG_TILELENGTH, "TileLength"}, - {TIFFTAG_TILEOFFSETS, "TileOffsets"}, - {TIFFTAG_TILEBYTECOUNTS, "TileByteCounts"}, - {TIFFTAG_BADFAXLINES, "BadFaxLines"}, - {TIFFTAG_CLEANFAXDATA, "CleanFaxData"}, - {TIFFTAG_CONSECUTIVEBADFAXLINES, "ConsecutiveBadFaxLines"}, - {TIFFTAG_SUBIFD, "SubIFD"}, - {TIFFTAG_INKSET, "InkSet"}, - {TIFFTAG_INKNAMES, "InkNames"}, - {TIFFTAG_NUMBEROFINKS, "NumberOfInks"}, - {TIFFTAG_DOTRANGE, "DotRange"}, - {TIFFTAG_TARGETPRINTER, "TargetPrinter"}, - {TIFFTAG_EXTRASAMPLES, "ExtraSamples"}, - {TIFFTAG_SAMPLEFORMAT, "SampleFormat"}, - {TIFFTAG_SMINSAMPLEVALUE, "SMinSampleValue"}, - {TIFFTAG_SMAXSAMPLEVALUE, "SMaxSampleValue"}, - {TIFFTAG_JPEGPROC, "JPEGProcessingMode"}, - {TIFFTAG_JPEGIFOFFSET, "JPEGInterchangeFormat"}, - {TIFFTAG_JPEGIFBYTECOUNT, "JPEGInterchangeFormatLength"}, - {TIFFTAG_JPEGRESTARTINTERVAL, "JPEGRestartInterval"}, - {TIFFTAG_JPEGLOSSLESSPREDICTORS, "JPEGLosslessPredictors"}, - {TIFFTAG_JPEGPOINTTRANSFORM, "JPEGPointTransform"}, - {TIFFTAG_JPEGTABLES, "JPEGTables"}, - {TIFFTAG_JPEGQTABLES, "JPEGQTables"}, - {TIFFTAG_JPEGDCTABLES, "JPEGDCTables"}, - {TIFFTAG_JPEGACTABLES, "JPEGACTables"}, - {TIFFTAG_YCBCRCOEFFICIENTS, "YCbCrCoefficients"}, - {TIFFTAG_YCBCRSUBSAMPLING, "YCbCrSubsampling"}, - {TIFFTAG_YCBCRPOSITIONING, "YCbCrPositioning"}, - {TIFFTAG_REFERENCEBLACKWHITE, "ReferenceBlackWhite"}, - {TIFFTAG_REFPTS, "IgReferencePoints (Island Graphics)"}, - {TIFFTAG_REGIONTACKPOINT, "IgRegionTackPoint (Island Graphics)"}, - {TIFFTAG_REGIONWARPCORNERS, "IgRegionWarpCorners (Island Graphics)"}, - {TIFFTAG_REGIONAFFINE, "IgRegionAffine (Island Graphics)"}, - {TIFFTAG_MATTEING, "OBSOLETE Matteing (Silicon Graphics)"}, - {TIFFTAG_DATATYPE, "OBSOLETE DataType (Silicon Graphics)"}, - {TIFFTAG_IMAGEDEPTH, "ImageDepth (Silicon Graphics)"}, - {TIFFTAG_TILEDEPTH, "TileDepth (Silicon Graphics)"}, - {32768, "OLD BOGUS Matteing tag"}, - {TIFFTAG_COPYRIGHT, "Copyright"}, - {TIFFTAG_ICCPROFILE, "ICC Profile"}, - {TIFFTAG_JBIGOPTIONS, "JBIG Options"}, - {TIFFTAG_STONITS, "StoNits"}, - {TIFFTAG_GDAL_METADATA, "GDALMetadata"}, - {TIFFTAG_GDAL_NODATA, "GDALNoDataValue"}, + { TIFFTAG_SUBFILETYPE, "SubFileType" }, + { TIFFTAG_OSUBFILETYPE, "OldSubFileType" }, + { TIFFTAG_IMAGEWIDTH, "ImageWidth" }, + { TIFFTAG_IMAGELENGTH, "ImageLength" }, + { TIFFTAG_BITSPERSAMPLE, "BitsPerSample" }, + { TIFFTAG_COMPRESSION, "Compression" }, + { TIFFTAG_PHOTOMETRIC, "Photometric" }, + { TIFFTAG_THRESHHOLDING, "Threshholding" }, + { TIFFTAG_CELLWIDTH, "CellWidth" }, + { TIFFTAG_CELLLENGTH, "CellLength" }, + { TIFFTAG_FILLORDER, "FillOrder" }, + { TIFFTAG_DOCUMENTNAME, "DocumentName" }, + { TIFFTAG_IMAGEDESCRIPTION, "ImageDescription" }, + { TIFFTAG_MAKE, "Make" }, + { TIFFTAG_MODEL, "Model" }, + { TIFFTAG_STRIPOFFSETS, "StripOffsets" }, + { TIFFTAG_ORIENTATION, "Orientation" }, + { TIFFTAG_SAMPLESPERPIXEL, "SamplesPerPixel" }, + { TIFFTAG_ROWSPERSTRIP, "RowsPerStrip" }, + { TIFFTAG_STRIPBYTECOUNTS, "StripByteCounts" }, + { TIFFTAG_MINSAMPLEVALUE, "MinSampleValue" }, + { TIFFTAG_MAXSAMPLEVALUE, "MaxSampleValue" }, + { TIFFTAG_XRESOLUTION, "XResolution" }, + { TIFFTAG_YRESOLUTION, "YResolution" }, + { TIFFTAG_PLANARCONFIG, "PlanarConfig" }, + { TIFFTAG_PAGENAME, "PageName" }, + { TIFFTAG_XPOSITION, "XPosition" }, + { TIFFTAG_YPOSITION, "YPosition" }, + { TIFFTAG_FREEOFFSETS, "FreeOffsets" }, + { TIFFTAG_FREEBYTECOUNTS, "FreeByteCounts" }, + { TIFFTAG_GRAYRESPONSEUNIT, "GrayResponseUnit" }, + { TIFFTAG_GRAYRESPONSECURVE,"GrayResponseCurve" }, + { TIFFTAG_GROUP3OPTIONS, "Group3Options" }, + { TIFFTAG_GROUP4OPTIONS, "Group4Options" }, + { TIFFTAG_RESOLUTIONUNIT, "ResolutionUnit" }, + { TIFFTAG_PAGENUMBER, "PageNumber" }, + { TIFFTAG_COLORRESPONSEUNIT,"ColorResponseUnit" }, + { TIFFTAG_TRANSFERFUNCTION, "TransferFunction" }, + { TIFFTAG_SOFTWARE, "Software" }, + { TIFFTAG_DATETIME, "DateTime" }, + { TIFFTAG_ARTIST, "Artist" }, + { TIFFTAG_HOSTCOMPUTER, "HostComputer" }, + { TIFFTAG_PREDICTOR, "Predictor" }, + { TIFFTAG_WHITEPOINT, "Whitepoint" }, + { TIFFTAG_PRIMARYCHROMATICITIES,"PrimaryChromaticities" }, + { TIFFTAG_COLORMAP, "Colormap" }, + { TIFFTAG_HALFTONEHINTS, "HalftoneHints" }, + { TIFFTAG_TILEWIDTH, "TileWidth" }, + { TIFFTAG_TILELENGTH, "TileLength" }, + { TIFFTAG_TILEOFFSETS, "TileOffsets" }, + { TIFFTAG_TILEBYTECOUNTS, "TileByteCounts" }, + { TIFFTAG_BADFAXLINES, "BadFaxLines" }, + { TIFFTAG_CLEANFAXDATA, "CleanFaxData" }, + { TIFFTAG_CONSECUTIVEBADFAXLINES, "ConsecutiveBadFaxLines" }, + { TIFFTAG_SUBIFD, "SubIFD" }, + { TIFFTAG_INKSET, "InkSet" }, + { TIFFTAG_INKNAMES, "InkNames" }, + { TIFFTAG_NUMBEROFINKS, "NumberOfInks" }, + { TIFFTAG_DOTRANGE, "DotRange" }, + { TIFFTAG_TARGETPRINTER, "TargetPrinter" }, + { TIFFTAG_EXTRASAMPLES, "ExtraSamples" }, + { TIFFTAG_SAMPLEFORMAT, "SampleFormat" }, + { TIFFTAG_SMINSAMPLEVALUE, "SMinSampleValue" }, + { TIFFTAG_SMAXSAMPLEVALUE, "SMaxSampleValue" }, + { TIFFTAG_JPEGPROC, "JPEGProcessingMode" }, + { TIFFTAG_JPEGIFOFFSET, "JPEGInterchangeFormat" }, + { TIFFTAG_JPEGIFBYTECOUNT, "JPEGInterchangeFormatLength" }, + { TIFFTAG_JPEGRESTARTINTERVAL,"JPEGRestartInterval" }, + { TIFFTAG_JPEGLOSSLESSPREDICTORS,"JPEGLosslessPredictors" }, + { TIFFTAG_JPEGPOINTTRANSFORM,"JPEGPointTransform" }, + { TIFFTAG_JPEGTABLES, "JPEGTables" }, + { TIFFTAG_JPEGQTABLES, "JPEGQTables" }, + { TIFFTAG_JPEGDCTABLES, "JPEGDCTables" }, + { TIFFTAG_JPEGACTABLES, "JPEGACTables" }, + { TIFFTAG_YCBCRCOEFFICIENTS,"YCbCrCoefficients" }, + { TIFFTAG_YCBCRSUBSAMPLING, "YCbCrSubsampling" }, + { TIFFTAG_YCBCRPOSITIONING, "YCbCrPositioning" }, + { TIFFTAG_REFERENCEBLACKWHITE, "ReferenceBlackWhite" }, + { TIFFTAG_REFPTS, "IgReferencePoints (Island Graphics)" }, + { TIFFTAG_REGIONTACKPOINT, "IgRegionTackPoint (Island Graphics)" }, + { TIFFTAG_REGIONWARPCORNERS,"IgRegionWarpCorners (Island Graphics)" }, + { TIFFTAG_REGIONAFFINE, "IgRegionAffine (Island Graphics)" }, + { TIFFTAG_MATTEING, "OBSOLETE Matteing (Silicon Graphics)" }, + { TIFFTAG_DATATYPE, "OBSOLETE DataType (Silicon Graphics)" }, + { TIFFTAG_IMAGEDEPTH, "ImageDepth (Silicon Graphics)" }, + { TIFFTAG_TILEDEPTH, "TileDepth (Silicon Graphics)" }, + { 32768, "OLD BOGUS Matteing tag" }, + { TIFFTAG_COPYRIGHT, "Copyright" }, + { TIFFTAG_ICCPROFILE, "ICC Profile" }, + { TIFFTAG_JBIGOPTIONS, "JBIG Options" }, + { TIFFTAG_STONITS, "StoNits" }, }; -#define NTAGS (sizeof(tagnames) / sizeof(tagnames[0])) +#define NTAGS (sizeof (tagnames) / sizeof (tagnames[0])) -static void PrintTag(FILE *fd, uint16_t tag) +static void +PrintTag(FILE* fd, uint16 tag) { - const struct tagname *tp; + const struct tagname *tp; - for (tp = tagnames; tp < &tagnames[NTAGS]; tp++) - if (tp->tag == tag) - { - fprintf(fd, "%s (%u)", tp->name, tag); - return; - } - fprintf(fd, "%u (%#x)", tag, tag); + for (tp = tagnames; tp < &tagnames[NTAGS]; tp++) + if (tp->tag == tag) { + fprintf(fd, "%s (%u)", tp->name, tag); + return; + } + fprintf(fd, "%u (%#x)", tag, tag); } -static void PrintType(FILE *fd, uint16_t type) +static void +PrintType(FILE* fd, uint16 type) { - static const char *typenames[] = { - "0", "BYTE", "ASCII", "SHORT", "LONG", - "RATIONAL", "SBYTE", "UNDEFINED", "SSHORT", "SLONG", - "SRATIONAL", "FLOAT", "DOUBLE", "IFD", "14", - "15", "LONG8", "SLONG8", "IFD8"}; -#define NTYPES (sizeof(typenames) / sizeof(typenames[0])) + static const char *typenames[] = { + "0", + "BYTE", + "ASCII", + "SHORT", + "LONG", + "RATIONAL", + "SBYTE", + "UNDEFINED", + "SSHORT", + "SLONG", + "SRATIONAL", + "FLOAT", + "DOUBLE", + "IFD", + "14", + "15", + "LONG8", + "SLONG8", + "IFD8" + }; +#define NTYPES (sizeof (typenames) / sizeof (typenames[0])) - if (type < NTYPES) - fprintf(fd, "%s (%u)", typenames[type], type); - else - fprintf(fd, "%u (%#x)", type, type); + if (type < NTYPES) + fprintf(fd, "%s (%u)", typenames[type], type); + else + fprintf(fd, "%u (%#x)", type, type); } -#undef NTYPES +#undef NTYPES #include -static void PrintASCII(FILE *fd, uint32_t cc, const unsigned char *cp) +static void +PrintASCII(FILE* fd, uint32 cc, const unsigned char* cp) { - for (; cc > 0; cc--, cp++) - { - const char *tp; + for (; cc > 0; cc--, cp++) { + const char* tp; - if (isprint(*cp)) - { - fputc(*cp, fd); - continue; - } - for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) - if (*tp++ == *cp) - break; - if (*tp) - fprintf(fd, "\\%c", *tp); - else if (*cp) - fprintf(fd, "\\%03o", *cp); - else - fprintf(fd, "\\0"); - } + if (isprint(*cp)) { + fputc(*cp, fd); + continue; + } + for (tp = "\tt\bb\rr\nn\vv"; *tp; tp++) + if (*tp++ == *cp) + break; + if (*tp) + fprintf(fd, "\\%c", *tp); + else if (*cp) + fprintf(fd, "\\%03o", *cp); + else + fprintf(fd, "\\0"); + } } -static void PrintData(FILE *fd, uint16_t type, uint32_t count, - unsigned char *data) +static void +PrintData(FILE* fd, uint16 type, uint32 count, unsigned char* data) { - char *sep = ""; + char* sep = ""; - switch (type) - { - case TIFF_BYTE: - while (count-- > 0) - fprintf(fd, bytefmt, sep, *data++), sep = " "; - break; - case TIFF_SBYTE: - while (count-- > 0) - fprintf(fd, sbytefmt, sep, *(char *)data++), sep = " "; - break; - case TIFF_UNDEFINED: - while (count-- > 0) - fprintf(fd, bytefmt, sep, *data++), sep = " "; - break; - case TIFF_ASCII: - PrintASCII(fd, count, data); - break; - case TIFF_SHORT: - { - uint16_t *wp = (uint16_t *)data; - while (count-- > 0) - fprintf(fd, hex_mode ? shortfmth : shortfmtd, sep, *wp++), - sep = " "; - break; - } - case TIFF_SSHORT: - { - int16_t *wp = (int16_t *)data; - while (count-- > 0) - fprintf(fd, hex_mode ? sshortfmth : sshortfmtd, sep, *wp++), - sep = " "; - break; - } - case TIFF_LONG: - { - uint32_t *lp = (uint32_t *)data; - while (count-- > 0) - { - fprintf(fd, hex_mode ? longfmth : longfmtd, sep, *lp++); - sep = " "; - } - break; - } - case TIFF_SLONG: - { - int32_t *lp = (int32_t *)data; - while (count-- > 0) - fprintf(fd, hex_mode ? slongfmth : slongfmtd, sep, *lp++), - sep = " "; - break; - } - case TIFF_LONG8: - { - uint64_t *llp = (uint64_t *)data; - while (count-- > 0) - { - uint64_t val; - memcpy(&val, llp, sizeof(uint64_t)); - llp++; - fprintf(fd, long8fmt, sep, val); - sep = " "; - } - break; - } - case TIFF_SLONG8: - { - int64_t *llp = (int64_t *)data; - while (count-- > 0) - { - int64_t val; - memcpy(&val, llp, sizeof(int64_t)); - llp++; - fprintf(fd, slong8fmt, sep, val); - sep = " "; - } - break; - } - case TIFF_RATIONAL: - { - uint32_t *lp = (uint32_t *)data; - while (count-- > 0) - { - if (lp[1] == 0) - fprintf(fd, "%sNan (%" PRIu32 "/%" PRIu32 ")", sep, lp[0], - lp[1]); - else - fprintf(fd, rationalfmt, sep, - (double)lp[0] / (double)lp[1]); - sep = " "; - lp += 2; - } - break; - } - case TIFF_SRATIONAL: - { - int32_t *lp = (int32_t *)data; - while (count-- > 0) - { - if (lp[1] == 0) - fprintf(fd, "%sNan (%" PRId32 "/%" PRId32 ")", sep, lp[0], - lp[1]); - else - fprintf(fd, srationalfmt, sep, - (double)lp[0] / (double)lp[1]); - sep = " "; - lp += 2; - } - break; - } - case TIFF_FLOAT: - { - float *fp = (float *)data; - while (count-- > 0) - fprintf(fd, floatfmt, sep, *fp++), sep = " "; - break; - } - case TIFF_DOUBLE: - { - double *dp = (double *)data; - while (count-- > 0) - fprintf(fd, doublefmt, sep, *dp++), sep = " "; - break; - } - case TIFF_IFD: - { - uint32_t *lp = (uint32_t *)data; - while (count-- > 0) - { - fprintf(fd, ifdfmt, sep, *lp++); - sep = " "; - } - break; - } - case TIFF_IFD8: - { - uint64_t *llp = (uint64_t *)data; - while (count-- > 0) - { - fprintf(fd, ifd8fmt, sep, *llp++); - sep = " "; - sep = " "; - } - break; - } - } + switch (type) { + case TIFF_BYTE: + while (count-- > 0) + fprintf(fd, bytefmt, sep, *data++), sep = " "; + break; + case TIFF_SBYTE: + while (count-- > 0) + fprintf(fd, sbytefmt, sep, *(char *)data++), sep = " "; + break; + case TIFF_UNDEFINED: + while (count-- > 0) + fprintf(fd, bytefmt, sep, *data++), sep = " "; + break; + case TIFF_ASCII: + PrintASCII(fd, count, data); + break; + case TIFF_SHORT: { + uint16 *wp = (uint16*)data; + while (count-- > 0) + fprintf(fd, shortfmt, sep, *wp++), sep = " "; + break; + } + case TIFF_SSHORT: { + int16 *wp = (int16*)data; + while (count-- > 0) + fprintf(fd, sshortfmt, sep, *wp++), sep = " "; + break; + } + case TIFF_LONG: { + uint32 *lp = (uint32*)data; + while (count-- > 0) { + fprintf(fd, longfmt, sep, (unsigned long) *lp++); + sep = " "; + } + break; + } + case TIFF_SLONG: { + int32 *lp = (int32*)data; + while (count-- > 0) + fprintf(fd, slongfmt, sep, (long) *lp++), sep = " "; + break; + } + case TIFF_LONG8: { + uint64 *llp = (uint64*)data; + while (count-- > 0) { + uint64 val; + memcpy(&val, llp, sizeof(uint64)); + llp ++; + fprintf(fd, long8fmt, sep, val); + sep = " "; + } + break; + } + case TIFF_SLONG8: { + int64 *llp = (int64*)data; + while (count-- > 0) { + int64 val; + memcpy(&val, llp, sizeof(int64)); + llp ++; + fprintf(fd, slong8fmt, sep, val); + sep = " "; + } + break; + } + case TIFF_RATIONAL: { + uint32 *lp = (uint32*)data; + while (count-- > 0) { + if (lp[1] == 0) + fprintf(fd, "%sNan (%lu/%lu)", sep, + (unsigned long) lp[0], + (unsigned long) lp[1]); + else + fprintf(fd, rationalfmt, sep, + (double)lp[0] / (double)lp[1]); + sep = " "; + lp += 2; + } + break; + } + case TIFF_SRATIONAL: { + int32 *lp = (int32*)data; + while (count-- > 0) { + if (lp[1] == 0) + fprintf(fd, "%sNan (%ld/%ld)", sep, + (long) lp[0], (long) lp[1]); + else + fprintf(fd, srationalfmt, sep, + (double)lp[0] / (double)lp[1]); + sep = " "; + lp += 2; + } + break; + } + case TIFF_FLOAT: { + float *fp = (float *)data; + while (count-- > 0) + fprintf(fd, floatfmt, sep, *fp++), sep = " "; + break; + } + case TIFF_DOUBLE: { + double *dp = (double *)data; + while (count-- > 0) + fprintf(fd, doublefmt, sep, *dp++), sep = " "; + break; + } + case TIFF_IFD: { + uint32 *lp = (uint32*)data; + while (count-- > 0) { + fprintf(fd, ifdfmt, sep, (unsigned long) *lp++); + sep = " "; + } + break; + } + case TIFF_IFD8: { + uint64 *llp = (uint64*)data; + while (count-- > 0) { +#if defined(__WIN32__) && defined(_MSC_VER) + fprintf(fd, ifd8fmt, sep, (unsigned __int64) *llp++); +#else + fprintf(fd, ifd8fmt, sep, (unsigned long long) *llp++); +#endif + sep = " "; + } + break; + } + } } -static void ReadError(char *what) { Fatal("Error while reading %s", what); } +static void +ReadError(char* what) +{ + Fatal("Error while reading %s", what); +} #include -static void vError(FILE *fd, const char *fmt, va_list ap) +static void +vError(FILE* fd, const char* fmt, va_list ap) { - fprintf(fd, "%s: ", curfile); - vfprintf(fd, fmt, ap); - fprintf(fd, ".\n"); + fprintf(fd, "%s: ", curfile); + vfprintf(fd, fmt, ap); + fprintf(fd, ".\n"); } -static void Error(const char *fmt, ...) +static void +Error(const char* fmt, ...) { - va_list ap; - va_start(ap, fmt); - vError(stderr, fmt, ap); - va_end(ap); + va_list ap; + va_start(ap, fmt); + vError(stderr, fmt, ap); + va_end(ap); } -static void Fatal(const char *fmt, ...) +static void +Fatal(const char* fmt, ...) { - va_list ap; - va_start(ap, fmt); - vError(stderr, fmt, ap); - va_end(ap); - exit(EXIT_FAILURE); + va_list ap; + va_start(ap, fmt); + vError(stderr, fmt, ap); + va_end(ap); + exit(EXIT_FAILURE); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffgt.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffgt.c index bd7f45af2..f3cca8c97 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffgt.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffgt.c @@ -3,29 +3,27 @@ * Copyright (c) 1991-1997 Silicon Graphics, Inc. * Copyright (c) 2003, Andrey Kiselev * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" - #include #include #include @@ -34,17 +32,17 @@ #endif #ifdef HAVE_OPENGL_GL_H -#include +# include #else -#ifdef _WIN32 -#include -#endif -#include +# ifdef _WIN32 +# include +# endif +# include #endif #ifdef HAVE_GLUT_GLUT_H -#include +# include #else -#include +# include #endif #include "tiffio.h" @@ -57,58 +55,62 @@ #define EXIT_FAILURE 1 #endif -static uint32_t width = 0, height = 0; /* window width & height */ -static uint32_t *raster = NULL; /* displayable image */ +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); +#endif + +static uint32 width = 0, height = 0; /* window width & height */ +static uint32* raster = NULL; /* displayable image */ static TIFFRGBAImage img; -static int order0 = 0, order; -static uint16_t photo0 = (uint16_t)-1, photo; -static int stoponerr = 0; /* stop on read error */ -static int verbose = 0; -#define TITLE_LENGTH 1024 -static char title[TITLE_LENGTH]; /* window title line */ -static uint32_t xmax, ymax; -static char **filelist = NULL; -static int fileindex; -static int filenum; +static int order0 = 0, order; +static uint16 photo0 = (uint16) -1, photo; +static int stoponerr = 0; /* stop on read error */ +static int verbose = 0; +#define TITLE_LENGTH 1024 +static char title[TITLE_LENGTH]; /* window title line */ +static uint32 xmax, ymax; +static char** filelist = NULL; +static int fileindex; +static int filenum; static TIFFErrorHandler oerror; static TIFFErrorHandler owarning; -static void cleanup_and_exit(int); -static int initImage(void); -static int prevImage(void); -static int nextImage(void); -static void setWindowSize(void); -static void usage(int); -static uint16_t photoArg(const char *); -static void raster_draw(void); -static void raster_reshape(int, int); -static void raster_keys(unsigned char, int, int); -static void raster_special(int, int, int); +static void cleanup_and_exit(int); +static int initImage(void); +static int prevImage(void); +static int nextImage(void); +static void setWindowSize(void); +static void usage(int); +static uint16 photoArg(const char*); +static void raster_draw(void); +static void raster_reshape(int, int); +static void raster_keys(unsigned char, int, int); +static void raster_special(int, int, int); #if !HAVE_DECL_OPTARG -extern char *optarg; -extern int optind; +extern char* optarg; +extern int optind; #endif /* GLUT framework on MacOS X produces deprecation warnings */ -#if defined(__GNUC__) && defined(__APPLE__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#endif +# if defined(__GNUC__) && defined(__APPLE__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +# endif -static TIFF *tif = NULL; +static TIFF* tif = NULL; -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - int c; - int dirnum = -1; - uint32_t diroff = 0; + int c; + int dirnum = -1; + uint32 diroff = 0; - oerror = TIFFSetErrorHandler(NULL); - owarning = TIFFSetWarningHandler(NULL); - while ((c = getopt(argc, argv, "d:o:p:eflmsvwh")) != -1) - switch (c) - { + oerror = TIFFSetErrorHandler(NULL); + owarning = TIFFSetWarningHandler(NULL); + while ((c = getopt(argc, argv, "d:o:p:eflmsvwh")) != -1) + switch (c) { case 'd': dirnum = atoi(optarg); break; @@ -142,350 +144,355 @@ int main(int argc, char *argv[]) case '?': usage(EXIT_FAILURE); /*NOTREACHED*/ + } + filenum = argc - optind; + if ( filenum < 1) + usage(EXIT_FAILURE); + + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + + /* + * Get the screen size + */ + xmax = glutGet(GLUT_SCREEN_WIDTH); + ymax = glutGet(GLUT_SCREEN_HEIGHT); + + /* + * Use 90% of the screen size + */ + xmax = xmax - xmax / 10.0; + ymax = ymax - ymax / 10.0; + + filelist = (char **) _TIFFmalloc(filenum * sizeof(char*)); + if (!filelist) { + TIFFError(argv[0], "Can not allocate space for the file list."); + return EXIT_FAILURE; } - filenum = argc - optind; - if (filenum < 1) - usage(EXIT_FAILURE); + _TIFFmemcpy(filelist, argv + optind, filenum * sizeof(char*)); + fileindex = -1; + if (nextImage() < 0) { + _TIFFfree(filelist); + return EXIT_FAILURE; + } + /* + * Set initial directory if user-specified + * file was opened successfully. + */ + if (dirnum != -1 && !TIFFSetDirectory(tif, dirnum)) + TIFFError(argv[0], "Error, seeking to directory %d", dirnum); + if (diroff != 0 && !TIFFSetSubDirectory(tif, diroff)) + TIFFError(argv[0], "Error, setting subdirectory at %#x", diroff); + order = order0; + photo = photo0; + if (initImage() < 0){ + _TIFFfree(filelist); + return EXIT_FAILURE; + } + /* + * Create a new window or reconfigure an existing + * one to suit the image to be displayed. + */ + glutInitWindowSize(width, height); + snprintf(title, TITLE_LENGTH - 1, "%s [%u]", filelist[fileindex], + (unsigned int) TIFFCurrentDirectory(tif)); + glutCreateWindow(title); + glutDisplayFunc(raster_draw); + glutReshapeFunc(raster_reshape); + glutKeyboardFunc(raster_keys); + glutSpecialFunc(raster_special); + glutMainLoop(); - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - - /* - * Get the screen size - */ - xmax = glutGet(GLUT_SCREEN_WIDTH); - ymax = glutGet(GLUT_SCREEN_HEIGHT); - - /* - * Use 90% of the screen size - */ - xmax = xmax - xmax / 10.0; - ymax = ymax - ymax / 10.0; - - filelist = (char **)_TIFFmalloc(filenum * sizeof(char *)); - if (!filelist) - { - TIFFError(argv[0], "Can not allocate space for the file list."); - return EXIT_FAILURE; - } - _TIFFmemcpy(filelist, argv + optind, filenum * sizeof(char *)); - fileindex = -1; - if (nextImage() < 0) - { - _TIFFfree(filelist); - return EXIT_FAILURE; - } - /* - * Set initial directory if user-specified - * file was opened successfully. - */ - if (dirnum != -1 && !TIFFSetDirectory(tif, dirnum)) - TIFFError(argv[0], "Error, seeking to directory %d", dirnum); - if (diroff != 0 && !TIFFSetSubDirectory(tif, diroff)) - TIFFError(argv[0], "Error, setting subdirectory at %#x", diroff); - order = order0; - photo = photo0; - if (initImage() < 0) - { - _TIFFfree(filelist); - return EXIT_FAILURE; - } - /* - * Create a new window or reconfigure an existing - * one to suit the image to be displayed. - */ - glutInitWindowSize(width, height); - snprintf(title, TITLE_LENGTH - 1, "%s [%u]", filelist[fileindex], - TIFFCurrentDirectory(tif)); - glutCreateWindow(title); - glutDisplayFunc(raster_draw); - glutReshapeFunc(raster_reshape); - glutKeyboardFunc(raster_keys); - glutSpecialFunc(raster_special); - glutMainLoop(); - - cleanup_and_exit(EXIT_SUCCESS); - return EXIT_SUCCESS; + cleanup_and_exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } -static void cleanup_and_exit(int code) +static void +cleanup_and_exit(int code) { - TIFFRGBAImageEnd(&img); - if (filelist != NULL) - _TIFFfree(filelist); - if (raster != NULL) - _TIFFfree(raster); - if (tif != NULL) - TIFFClose(tif); - exit(code); -} - -static int initImage(void) -{ - uint32_t w, h; - - if (order) - TIFFSetField(tif, TIFFTAG_FILLORDER, order); - if (photo != (uint16_t)-1) - TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photo); - if (!TIFFRGBAImageBegin(&img, tif, stoponerr, title)) - { - TIFFError(filelist[fileindex], "%s", title); - TIFFClose(tif); - tif = NULL; - return -1; - } - - /* - * Setup the image raster as required. - */ - h = img.height; - w = img.width; - if (h > ymax) - { - w = (int)(w * ((float)ymax / h)); - h = ymax; - } - if (w > xmax) - { - h = (int)(h * ((float)xmax / w)); - w = xmax; - } - - if (w != width || h != height) - { - uint32_t rastersize = _TIFFMultiply32(tif, img.width, img.height, - "allocating raster buffer"); + TIFFRGBAImageEnd(&img); + if (filelist != NULL) + _TIFFfree(filelist); if (raster != NULL) - _TIFFfree(raster), raster = NULL; - raster = (uint32_t *)_TIFFCheckMalloc(tif, rastersize, sizeof(uint32_t), - "allocating raster buffer"); - if (raster == NULL) - { - width = height = 0; - TIFFError(filelist[fileindex], "No space for raster buffer"); - cleanup_and_exit(EXIT_FAILURE); + _TIFFfree(raster); + if (tif != NULL) + TIFFClose(tif); + exit(code); +} + +static int +initImage(void) +{ + uint32 w, h; + + if (order) + TIFFSetField(tif, TIFFTAG_FILLORDER, order); + if (photo != (uint16) -1) + TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, photo); + if (!TIFFRGBAImageBegin(&img, tif, stoponerr, title)) { + TIFFError(filelist[fileindex], "%s", title); + TIFFClose(tif); + tif = NULL; + return -1; } - width = w; - height = h; - } - TIFFRGBAImageGet(&img, raster, img.width, img.height); + + /* + * Setup the image raster as required. + */ + h = img.height; + w = img.width; + if (h > ymax) { + w = (int)(w * ((float)ymax / h)); + h = ymax; + } + if (w > xmax) { + h = (int)(h * ((float)xmax / w)); + w = xmax; + } + + if (w != width || h != height) { + uint32 rastersize = + _TIFFMultiply32(tif, img.width, img.height, "allocating raster buffer"); + if (raster != NULL) + _TIFFfree(raster), raster = NULL; + raster = (uint32*) _TIFFCheckMalloc(tif, rastersize, sizeof (uint32), + "allocating raster buffer"); + if (raster == NULL) { + width = height = 0; + TIFFError(filelist[fileindex], "No space for raster buffer"); + cleanup_and_exit(EXIT_FAILURE); + } + width = w; + height = h; + } + TIFFRGBAImageGet(&img, raster, img.width, img.height); #if HOST_BIGENDIAN - TIFFSwabArrayOfLong(raster, img.width * img.height); + TIFFSwabArrayOfLong(raster,img.width*img.height); #endif - return 0; + return 0; } -static int prevImage(void) +static int +prevImage(void) { - if (fileindex > 0) - fileindex--; - else if (tif) + if (fileindex > 0) + fileindex--; + else if (tif) + return fileindex; + if (tif) + TIFFClose(tif); + tif = TIFFOpen(filelist[fileindex], "r"); + if (tif == NULL) + return -1; return fileindex; - if (tif) - TIFFClose(tif); - tif = TIFFOpen(filelist[fileindex], "r"); - if (tif == NULL) - return -1; - return fileindex; } -static int nextImage(void) +static int +nextImage(void) { - if (fileindex < filenum - 1) - fileindex++; - else if (tif) + if (fileindex < filenum - 1) + fileindex++; + else if (tif) + return fileindex; + if (tif) + TIFFClose(tif); + tif = TIFFOpen(filelist[fileindex], "r"); + if (tif == NULL) + return -1; return fileindex; - if (tif) - TIFFClose(tif); - tif = TIFFOpen(filelist[fileindex], "r"); - if (tif == NULL) - return -1; - return fileindex; } -static void setWindowSize(void) { glutReshapeWindow(width, height); } - -static void raster_draw(void) +static void +setWindowSize(void) { - glDrawPixels(img.width, img.height, GL_RGBA, GL_UNSIGNED_BYTE, - (const GLvoid *)raster); - glFlush(); + glutReshapeWindow(width, height); } -static void raster_reshape(int win_w, int win_h) +static void +raster_draw(void) { - GLfloat xratio = (GLfloat)win_w / img.width; - GLfloat yratio = (GLfloat)win_h / img.height; - int ratio = (int)(((xratio > yratio) ? xratio : yratio) * 100); - - glPixelZoom(xratio, yratio); - glViewport(0, 0, win_w, win_h); - snprintf(title, 1024, "%s [%u] %d%%", filelist[fileindex], - TIFFCurrentDirectory(tif), ratio); - glutSetWindowTitle(title); + glDrawPixels(img.width, img.height, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid *) raster); + glFlush(); } -static void raster_keys(unsigned char key, int x, int y) +static void +raster_reshape(int win_w, int win_h) { - (void)x; - (void)y; - switch (key) - { - case 'b': /* photometric MinIsBlack */ - photo = PHOTOMETRIC_MINISBLACK; - initImage(); - break; - case 'l': /* lsb-to-msb FillOrder */ - order = FILLORDER_LSB2MSB; - initImage(); - break; - case 'm': /* msb-to-lsb FillOrder */ - order = FILLORDER_MSB2LSB; - initImage(); - break; - case 'w': /* photometric MinIsWhite */ - photo = PHOTOMETRIC_MINISWHITE; - initImage(); - break; - case 'W': /* toggle warnings */ - owarning = TIFFSetWarningHandler(owarning); - initImage(); - break; - case 'E': /* toggle errors */ - oerror = TIFFSetErrorHandler(oerror); - initImage(); - break; - case 'z': /* reset to defaults */ - case 'Z': - order = order0; - photo = photo0; - if (owarning == NULL) - owarning = TIFFSetWarningHandler(NULL); - if (oerror == NULL) - oerror = TIFFSetErrorHandler(NULL); - initImage(); - break; - case 'q': /* exit */ - case '\033': - cleanup_and_exit(EXIT_SUCCESS); - } - glutPostRedisplay(); + GLfloat xratio = (GLfloat)win_w/img.width; + GLfloat yratio = (GLfloat)win_h/img.height; + int ratio = (int)(((xratio > yratio)?xratio:yratio) * 100); + + glPixelZoom(xratio, yratio); + glViewport(0, 0, win_w, win_h); + snprintf(title, 1024, "%s [%u] %d%%", filelist[fileindex], + (unsigned int) TIFFCurrentDirectory(tif), ratio); + glutSetWindowTitle(title); } -static void raster_special(int key, int x, int y) +static void +raster_keys(unsigned char key, int x, int y) { - (void)x; - (void)y; - switch (key) - { - case GLUT_KEY_PAGE_UP: /* previous logical image */ - if (TIFFCurrentDirectory(tif) > 0) - { - if (TIFFSetDirectory(tif, TIFFCurrentDirectory(tif) - 1)) - { + (void) x; + (void) y; + switch (key) { + case 'b': /* photometric MinIsBlack */ + photo = PHOTOMETRIC_MINISBLACK; initImage(); - setWindowSize(); - } - } - else - { - TIFFRGBAImageEnd(&img); - prevImage(); - initImage(); - setWindowSize(); - } - break; - case GLUT_KEY_PAGE_DOWN: /* next logical image */ - if (!TIFFLastDirectory(tif)) - { - if (TIFFReadDirectory(tif)) - { + break; + case 'l': /* lsb-to-msb FillOrder */ + order = FILLORDER_LSB2MSB; initImage(); - setWindowSize(); - } - } - else - { - TIFFRGBAImageEnd(&img); - nextImage(); - initImage(); - setWindowSize(); - } - break; - case GLUT_KEY_HOME: /* 1st image in current file */ - if (TIFFSetDirectory(tif, 0)) - { - TIFFRGBAImageEnd(&img); - initImage(); - setWindowSize(); - } - break; - case GLUT_KEY_END: /* last image in current file */ - TIFFRGBAImageEnd(&img); - while (!TIFFLastDirectory(tif)) - TIFFReadDirectory(tif); - initImage(); - setWindowSize(); - break; - } - glutPostRedisplay(); + break; + case 'm': /* msb-to-lsb FillOrder */ + order = FILLORDER_MSB2LSB; + initImage(); + break; + case 'w': /* photometric MinIsWhite */ + photo = PHOTOMETRIC_MINISWHITE; + initImage(); + break; + case 'W': /* toggle warnings */ + owarning = TIFFSetWarningHandler(owarning); + initImage(); + break; + case 'E': /* toggle errors */ + oerror = TIFFSetErrorHandler(oerror); + initImage(); + break; + case 'z': /* reset to defaults */ + case 'Z': + order = order0; + photo = photo0; + if (owarning == NULL) + owarning = TIFFSetWarningHandler(NULL); + if (oerror == NULL) + oerror = TIFFSetErrorHandler(NULL); + initImage(); + break; + case 'q': /* exit */ + case '\033': + cleanup_and_exit(EXIT_SUCCESS); + } + glutPostRedisplay(); +} + +static void +raster_special(int key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_PAGE_UP: /* previous logical image */ + if (TIFFCurrentDirectory(tif) > 0) { + if (TIFFSetDirectory(tif, + TIFFCurrentDirectory(tif)-1)) { + initImage(); + setWindowSize(); + } + } else { + TIFFRGBAImageEnd(&img); + prevImage(); + initImage(); + setWindowSize(); + } + break; + case GLUT_KEY_PAGE_DOWN: /* next logical image */ + if (!TIFFLastDirectory(tif)) { + if (TIFFReadDirectory(tif)) { + initImage(); + setWindowSize(); + } + } else { + TIFFRGBAImageEnd(&img); + nextImage(); + initImage(); + setWindowSize(); + } + break; + case GLUT_KEY_HOME: /* 1st image in current file */ + if (TIFFSetDirectory(tif, 0)) { + TIFFRGBAImageEnd(&img); + initImage(); + setWindowSize(); + } + break; + case GLUT_KEY_END: /* last image in current file */ + TIFFRGBAImageEnd(&img); + while (!TIFFLastDirectory(tif)) + TIFFReadDirectory(tif); + initImage(); + setWindowSize(); + break; + } + glutPostRedisplay(); } /* GLUT framework on MacOS X produces deprecation warnings */ -#if defined(__GNUC__) && defined(__APPLE__) -#pragma GCC diagnostic pop -#endif +# if defined(__GNUC__) && defined(__APPLE__) +# pragma GCC diagnostic pop +# endif -static const char *stuff[] = { - "usage: tiffgt [options] file.tif", - "where options are:", - " -c use colormap visual", - " -d dirnum set initial directory (default is 0)", - " -e enable display of TIFF error messages", - " -l force lsb-to-msb FillOrder", - " -m force msb-to-lsb FillOrder", - " -o offset set initial directory offset", - " -p photo override photometric interpretation", - " -r use fullcolor visual", - " -s stop decoding on first error (default is ignore errors)", - " -v enable verbose mode", - " -w enable display of TIFF warning messages", - NULL}; +static const char* stuff[] = { +"usage: tiffgt [options] file.tif", +"where options are:", +" -c use colormap visual", +" -d dirnum set initial directory (default is 0)", +" -e enable display of TIFF error messages", +" -l force lsb-to-msb FillOrder", +" -m force msb-to-lsb FillOrder", +" -o offset set initial directory offset", +" -p photo override photometric interpretation", +" -r use fullcolor visual", +" -s stop decoding on first error (default is ignore errors)", +" -v enable verbose mode", +" -w enable display of TIFF warning messages", +NULL +}; -static void usage(int code) +static void +usage(int code) { - int i; - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - for (i = 0; stuff[i] != NULL; i++) - fprintf(out, "%s\n", stuff[i]); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } -static uint16_t photoArg(const char *arg) +static uint16 +photoArg(const char* arg) { - if (strcmp(arg, "miniswhite") == 0) - return (PHOTOMETRIC_MINISWHITE); - else if (strcmp(arg, "minisblack") == 0) - return (PHOTOMETRIC_MINISBLACK); - else if (strcmp(arg, "rgb") == 0) - return (PHOTOMETRIC_RGB); - else if (strcmp(arg, "palette") == 0) - return (PHOTOMETRIC_PALETTE); - else if (strcmp(arg, "mask") == 0) - return (PHOTOMETRIC_MASK); - else if (strcmp(arg, "separated") == 0) - return (PHOTOMETRIC_SEPARATED); - else if (strcmp(arg, "ycbcr") == 0) - return (PHOTOMETRIC_YCBCR); - else if (strcmp(arg, "cielab") == 0) - return (PHOTOMETRIC_CIELAB); - else if (strcmp(arg, "logl") == 0) - return (PHOTOMETRIC_LOGL); - else if (strcmp(arg, "logluv") == 0) - return (PHOTOMETRIC_LOGLUV); - else - return ((uint16_t)-1); + if (strcmp(arg, "miniswhite") == 0) + return (PHOTOMETRIC_MINISWHITE); + else if (strcmp(arg, "minisblack") == 0) + return (PHOTOMETRIC_MINISBLACK); + else if (strcmp(arg, "rgb") == 0) + return (PHOTOMETRIC_RGB); + else if (strcmp(arg, "palette") == 0) + return (PHOTOMETRIC_PALETTE); + else if (strcmp(arg, "mask") == 0) + return (PHOTOMETRIC_MASK); + else if (strcmp(arg, "separated") == 0) + return (PHOTOMETRIC_SEPARATED); + else if (strcmp(arg, "ycbcr") == 0) + return (PHOTOMETRIC_YCBCR); + else if (strcmp(arg, "cielab") == 0) + return (PHOTOMETRIC_CIELAB); + else if (strcmp(arg, "logl") == 0) + return (PHOTOMETRIC_LOGL); + else if (strcmp(arg, "logluv") == 0) + return (PHOTOMETRIC_LOGLUV); + else + return ((uint16) -1); } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffinfo.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffinfo.c index 6e24d0f0b..64a4bd12f 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffinfo.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffinfo.c @@ -2,27 +2,26 @@ * Copyright (c) 1988-1997 Sam Leffler * Copyright (c) 1991-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" #include @@ -30,11 +29,15 @@ #include #ifdef HAVE_STRINGS_H -#include +# include #endif #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffiop.h" @@ -47,706 +50,516 @@ #endif static TIFFErrorHandler old_error_handler = 0; -static int status = EXIT_SUCCESS; /* exit status */ -static int showdata = 0; /* show data */ -static int rawdata = 0; /* show raw/decoded data */ -static int showwords = 0; /* show data as bytes/words */ -static int readdata = 0; /* read data in file */ -static int stoponerr = 1; /* stop on first read error */ +static int status = EXIT_SUCCESS; /* exit status */ +static int showdata = 0; /* show data */ +static int rawdata = 0; /* show raw/decoded data */ +static int showwords = 0; /* show data as bytes/words */ +static int readdata = 0; /* read data in file */ +static int stoponerr = 1; /* stop on first read error */ -static void usage(int); -static void tiffinfo(TIFF *, uint16_t, long, int); +static void usage(int); +static void tiffinfo(TIFF*, uint16, long, int); -#define DEFAULT_MAX_MALLOC (256 * 1024 * 1024) -/* malloc size limit (in bytes) - * disabled when set to 0 */ -static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC; - -static void PrivateErrorHandler(const char *module, const char *fmt, va_list ap) +static void +PrivateErrorHandler(const char* module, const char* fmt, va_list ap) { - if (old_error_handler) - (*old_error_handler)(module, fmt, ap); - status = EXIT_FAILURE; + if (old_error_handler) + (*old_error_handler)(module,fmt,ap); + status = EXIT_FAILURE; } -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - int dirnum = -1, multiplefiles, c; - uint16_t order = 0; - TIFF *tif; + int dirnum = -1, multiplefiles, c; + uint16 order = 0; + TIFF* tif; #if !HAVE_DECL_OPTARG - extern int optind; - extern char *optarg; + extern int optind; + extern char* optarg; #endif - long flags = 0; - uint64_t diroff = 0; - int chopstrips = 0; /* disable strip chopping */ + long flags = 0; + uint64 diroff = 0; + int chopstrips = 0; /* disable strip chopping */ - while ((c = getopt(argc, argv, "f:o:M:cdDSjilmrsvwz0123456789h")) != -1) - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - dirnum = atoi(&argv[optind - 1][1]); - break; - case 'd': - showdata++; - /* fall through... */ - case 'D': - readdata++; - break; - case 'c': - flags |= TIFFPRINT_COLORMAP | TIFFPRINT_CURVES; - break; - case 'f': /* fill order */ - if (streq(optarg, "lsb2msb")) - order = FILLORDER_LSB2MSB; - else if (streq(optarg, "msb2lsb")) - order = FILLORDER_MSB2LSB; - else - usage(EXIT_FAILURE); - break; - case 'i': - stoponerr = 0; - break; - case 'M': - maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; - break; - case 'o': - diroff = strtoul(optarg, NULL, 0); - break; - case 'j': - flags |= TIFFPRINT_JPEGQTABLES | TIFFPRINT_JPEGACTABLES | - TIFFPRINT_JPEGDCTABLES; - break; - case 'r': - rawdata = 1; - break; - case 's': - flags |= TIFFPRINT_STRIPS; - break; - case 'w': - showwords = 1; - break; - case 'z': - chopstrips = 1; - break; - case 'h': - usage(EXIT_SUCCESS); - /*NOTREACHED*/ - break; - case '?': - usage(EXIT_FAILURE); - /*NOTREACHED*/ - break; - } - if (optind >= argc) - usage(EXIT_FAILURE); + while ((c = getopt(argc, argv, "f:o:cdDSjilmrsvwz0123456789h")) != -1) + switch (c) { + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + case '8': case '9': + dirnum = atoi(&argv[optind-1][1]); + break; + case 'd': + showdata++; + /* fall through... */ + case 'D': + readdata++; + break; + case 'c': + flags |= TIFFPRINT_COLORMAP | TIFFPRINT_CURVES; + break; + case 'f': /* fill order */ + if (streq(optarg, "lsb2msb")) + order = FILLORDER_LSB2MSB; + else if (streq(optarg, "msb2lsb")) + order = FILLORDER_MSB2LSB; + else + usage(EXIT_FAILURE); + break; + case 'i': + stoponerr = 0; + break; + case 'o': + diroff = strtoul(optarg, NULL, 0); + break; + case 'j': + flags |= TIFFPRINT_JPEGQTABLES | + TIFFPRINT_JPEGACTABLES | + TIFFPRINT_JPEGDCTABLES; + break; + case 'r': + rawdata = 1; + break; + case 's': + flags |= TIFFPRINT_STRIPS; + break; + case 'w': + showwords = 1; + break; + case 'z': + chopstrips = 1; + break; + case 'h': + usage(EXIT_SUCCESS); + /*NOTREACHED*/ + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } + if (optind >= argc) + usage(EXIT_FAILURE); - old_error_handler = TIFFSetErrorHandler(PrivateErrorHandler); + old_error_handler = TIFFSetErrorHandler(PrivateErrorHandler); - multiplefiles = (argc - optind > 1); - for (; optind < argc; optind++) - { - if (multiplefiles) - printf("File %s:\n", argv[optind]); - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - if (opts == NULL) - { - status = EXIT_FAILURE; - break; - } - TIFFOpenOptionsSetMaxSingleMemAlloc(opts, maxMalloc); - tif = TIFFOpenExt(argv[optind], chopstrips ? "rC" : "rc", opts); - TIFFOpenOptionsFree(opts); - if (tif != NULL) - { - if (dirnum != -1) - { - if (TIFFSetDirectory(tif, (tdir_t)dirnum)) - tiffinfo(tif, order, flags, 1); - } - else if (diroff != 0) - { - if (TIFFSetSubDirectory(tif, diroff)) - tiffinfo(tif, order, flags, 1); - } - else - { - do - { - toff_t offset = 0; - tdir_t curdir = TIFFCurrentDirectory(tif); - printf("=== TIFF directory %u ===\n", curdir); - tiffinfo(tif, order, flags, 1); - if (TIFFGetField(tif, TIFFTAG_EXIFIFD, &offset)) - { - printf("--- EXIF directory within directory %u \n", - curdir); - if (TIFFReadEXIFDirectory(tif, offset)) - { - tiffinfo(tif, order, flags, 0); - /*-- Go back to previous directory, (directory is - * reloaded from file!) */ - TIFFSetDirectory(tif, curdir); - } - } - if (TIFFGetField(tif, TIFFTAG_GPSIFD, &offset)) - { - printf("--- GPS directory within directory %u \n", - curdir); - if (TIFFReadGPSDirectory(tif, offset)) - { - tiffinfo(tif, order, flags, 0); - TIFFSetDirectory(tif, curdir); - } - } - /*-- Check for SubIFDs --*/ - uint16_t nCount; - void *vPtr; - uint64_t *subIFDoffsets = NULL; - if (TIFFGetField(tif, TIFFTAG_SUBIFD, &nCount, &vPtr)) - { - if (nCount > 0) - { - subIFDoffsets = malloc(nCount * sizeof(uint64_t)); - if (subIFDoffsets != NULL) - { - memcpy(subIFDoffsets, vPtr, - nCount * sizeof(subIFDoffsets[0])); - printf("--- SubIFD image descriptor tag within " - "TIFF directory %u with array of %d " - "SubIFD chains ---\n", - curdir, nCount); - for (int i = 0; i < nCount; i++) - { - offset = subIFDoffsets[i]; - int s = 0; - if (TIFFSetSubDirectory(tif, offset)) - { - /* print info and check for SubIFD chain - */ - do - { - printf("--- SubIFD %d of chain %d " - "at offset 0x%" PRIx64 - " (%" PRIu64 "):\n", - s, i, offset, offset); - tiffinfo(tif, order, flags, 0); - s++; - } while (TIFFReadDirectory(tif)); - } - } - TIFFSetDirectory(tif, curdir); - free(subIFDoffsets); - subIFDoffsets = NULL; - } - else - { - fprintf(stderr, - "Error: Could not allocate memory for " - "SubIFDs list. SubIFDs not parsed.\n"); - } - } - } - printf("\n"); - } while (TIFFReadDirectory(tif)); - } - TIFFClose(tif); - } - } - return (status); + multiplefiles = (argc - optind > 1); + for (; optind < argc; optind++) { + if (multiplefiles) + printf("%s:\n", argv[optind]); + tif = TIFFOpen(argv[optind], chopstrips ? "rC" : "rc"); + if (tif != NULL) { + if (dirnum != -1) { + if (TIFFSetDirectory(tif, (tdir_t) dirnum)) + tiffinfo(tif, order, flags, 1); + } else if (diroff != 0) { + if (TIFFSetSubDirectory(tif, diroff)) + tiffinfo(tif, order, flags, 1); + } else { + do { + toff_t offset=0; + uint16 curdir = TIFFCurrentDirectory(tif); + printf("=== TIFF directory %d ===\n", curdir); + tiffinfo(tif, order, flags, 1); + if (TIFFGetField(tif, TIFFTAG_EXIFIFD, + &offset)) { + if (TIFFReadEXIFDirectory(tif, offset)) { + tiffinfo(tif, order, flags, 0); + /*-- Go back to previous directory, (directory is reloaded from file!) */ + TIFFSetDirectory(tif, curdir); + } + } + if (TIFFGetField(tif, TIFFTAG_GPSIFD, + &offset)) { + if (TIFFReadGPSDirectory(tif, offset)) { + tiffinfo(tif, order, flags, 0); + TIFFSetDirectory(tif, curdir); + } + } + } while (TIFFReadDirectory(tif)); + } + TIFFClose(tif); + } + } + return (status); } -static const char usage_info[] = - "Display information about TIFF files\n\n" - "usage: tiffinfo [options] input...\n" - "where options are:\n" - " -D read data\n" - " -i ignore read errors\n" - " -c display data for grey/color response curve or " - "colormap\n" - " -d display raw/decoded image data\n" - " -f lsb2msb force lsb-to-msb FillOrder for input\n" - " -f msb2lsb force msb-to-lsb FillOrder for input\n" - " -j show JPEG tables\n" - " -o offset set initial directory offset\n" - " -r read/display raw image data instead of decoded data\n" - " -s display strip offsets and byte counts\n" - " -w display raw data in words rather than bytes\n" - " -z enable strip chopping\n" - " -M size set the memory allocation limit in MiB. 0 to disable limit\n" - " -# set initial directory (first directory is # 0)\n"; +static const char* stuff[] = { +"usage: tiffinfo [options] input...", +"where options are:", +" -D read data", +" -i ignore read errors", +" -c display data for grey/color response curve or colormap", +" -d display raw/decoded image data", +" -f lsb2msb force lsb-to-msb FillOrder for input", +" -f msb2lsb force msb-to-lsb FillOrder for input", +" -j show JPEG tables", +" -o offset set initial directory offset", +" -r read/display raw image data instead of decoded data", +" -s display strip offsets and byte counts", +" -w display raw data in words rather than bytes", +" -z enable strip chopping", +" -# set initial directory (first directory is # 0)", +NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } -static void ShowStrip(tstrip_t strip, unsigned char *pp, uint32_t nrow, - tsize_t scanline) +static void +ShowStrip(tstrip_t strip, unsigned char* pp, uint32 nrow, tsize_t scanline) { - register tsize_t cc; + register tsize_t cc; - printf("Strip %" PRIu32 ":\n", strip); - while (nrow-- > 0) - { - for (cc = 0; cc < scanline; cc++) - { - printf(" %02x", *pp++); - if (((cc + 1) % 24) == 0) - putchar('\n'); - } - putchar('\n'); - } + printf("Strip %lu:\n", (unsigned long) strip); + while (nrow-- > 0) { + for (cc = 0; cc < scanline; cc++) { + printf(" %02x", *pp++); + if (((cc+1) % 24) == 0) + putchar('\n'); + } + putchar('\n'); + } } -void TIFFReadContigStripData(TIFF *tif) +void +TIFFReadContigStripData(TIFF* tif) { - unsigned char *buf; - tsize_t scanline = TIFFScanlineSize(tif); - tmsize_t stripsize = TIFFStripSize(tif); + unsigned char *buf; + tsize_t scanline = TIFFScanlineSize(tif); - if (maxMalloc != 0 && stripsize > maxMalloc) - { - fprintf(stderr, - "Memory allocation attempt %" TIFF_SSIZE_FORMAT - " over memory limit (%" TIFF_SSIZE_FORMAT ")\n", - stripsize, maxMalloc); - return; - } - buf = (unsigned char *)_TIFFmalloc(stripsize); - if (buf) - { - uint32_t row, h = 0; - uint32_t rowsperstrip = (uint32_t)-1; + buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif)); + if (buf) { + uint32 row, h=0; + uint32 rowsperstrip = (uint32)-1; - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - for (row = 0; row < h; row += rowsperstrip) - { - uint32_t nrow = (row + rowsperstrip > h ? h - row : rowsperstrip); - tstrip_t strip = TIFFComputeStrip(tif, row, 0); - if (TIFFReadEncodedStrip(tif, strip, buf, nrow * scanline) < 0) - { - if (stoponerr) - break; - } - else if (showdata) - ShowStrip(strip, buf, nrow, scanline); - } - _TIFFfree(buf); - } - else - { - fprintf(stderr, "Cannot allocate %" TIFF_SSIZE_FORMAT " bytes.\n", - stripsize); - } + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + for (row = 0; row < h; row += rowsperstrip) { + uint32 nrow = (row+rowsperstrip > h ? + h-row : rowsperstrip); + tstrip_t strip = TIFFComputeStrip(tif, row, 0); + if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) { + if (stoponerr) + break; + } else if (showdata) + ShowStrip(strip, buf, nrow, scanline); + } + _TIFFfree(buf); + } } -void TIFFReadSeparateStripData(TIFF *tif) +void +TIFFReadSeparateStripData(TIFF* tif) { - unsigned char *buf; - tsize_t scanline = TIFFScanlineSize(tif); - tmsize_t stripsize = TIFFStripSize(tif); + unsigned char *buf; + tsize_t scanline = TIFFScanlineSize(tif); - if (maxMalloc != 0 && stripsize > maxMalloc) - { - fprintf(stderr, - "Memory allocation attempt %" TIFF_SSIZE_FORMAT - " over memory limit (%" TIFF_SSIZE_FORMAT ")\n", - stripsize, maxMalloc); - return; - } - buf = (unsigned char *)_TIFFmalloc(stripsize); - if (buf) - { - uint32_t row, h = 0; - uint32_t rowsperstrip = (uint32_t)-1; - tsample_t s, samplesperpixel = 0; + buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif)); + if (buf) { + uint32 row, h=0; + uint32 rowsperstrip = (uint32)-1; + tsample_t s, samplesperpixel=0; - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); - TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); - for (row = 0; row < h; row += rowsperstrip) - { - for (s = 0; s < samplesperpixel; s++) - { - uint32_t nrow = - (row + rowsperstrip > h ? h - row : rowsperstrip); - tstrip_t strip = TIFFComputeStrip(tif, row, s); - if (TIFFReadEncodedStrip(tif, strip, buf, nrow * scanline) < 0) - { - if (stoponerr) - break; - } - else if (showdata) - ShowStrip(strip, buf, nrow, scanline); - } - } - _TIFFfree(buf); - } - else - { - fprintf(stderr, "Cannot allocate %" TIFF_SSIZE_FORMAT " bytes.\n", - stripsize); - } + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + for (row = 0; row < h; row += rowsperstrip) { + for (s = 0; s < samplesperpixel; s++) { + uint32 nrow = (row+rowsperstrip > h ? + h-row : rowsperstrip); + tstrip_t strip = TIFFComputeStrip(tif, row, s); + if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) { + if (stoponerr) + break; + } else if (showdata) + ShowStrip(strip, buf, nrow, scanline); + } + } + _TIFFfree(buf); + } } -static void ShowTile(uint32_t row, uint32_t col, tsample_t sample, - unsigned char *pp, uint32_t nrow, tsize_t rowsize) +static void +ShowTile(uint32 row, uint32 col, tsample_t sample, + unsigned char* pp, uint32 nrow, tsize_t rowsize) { - uint32_t cc; + uint32 cc; - printf("Tile (%" PRIu32 ",%" PRIu32 "", row, col); - if (sample != (tsample_t)-1) - printf(",%" PRIu16, sample); - printf("):\n"); - while (nrow-- > 0) - { - for (cc = 0; cc < (uint32_t)rowsize; cc++) - { - printf(" %02x", *pp++); - if (((cc + 1) % 24) == 0) - putchar('\n'); - } - putchar('\n'); - } + printf("Tile (%lu,%lu", (unsigned long) row, (unsigned long) col); + if (sample != (tsample_t) -1) + printf(",%u", sample); + printf("):\n"); + while (nrow-- > 0) { + for (cc = 0; cc < (uint32) rowsize; cc++) { + printf(" %02x", *pp++); + if (((cc+1) % 24) == 0) + putchar('\n'); + } + putchar('\n'); + } } -void TIFFReadContigTileData(TIFF *tif) +void +TIFFReadContigTileData(TIFF* tif) { - unsigned char *buf; - tmsize_t rowsize = TIFFTileRowSize(tif); - tmsize_t tilesize = TIFFTileSize(tif); + unsigned char *buf; + tmsize_t rowsize = TIFFTileRowSize(tif); + tmsize_t tilesize = TIFFTileSize(tif); - if (maxMalloc != 0 && tilesize > maxMalloc) - { - fprintf(stderr, - "Memory allocation attempt %" TIFF_SSIZE_FORMAT - " over memory limit (%" TIFF_SSIZE_FORMAT ")\n", - tilesize, maxMalloc); - return; - } - buf = (unsigned char *)_TIFFmalloc(tilesize); - if (buf) - { - uint32_t tw = 0, th = 0, w = 0, h = 0; - uint32_t row, col; + buf = (unsigned char *)_TIFFmalloc(tilesize); + if (buf) { + uint32 tw=0, th=0, w=0, h=0; + uint32 row, col; - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); - if (rowsize == 0 || th > (size_t)(tilesize / rowsize)) + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); + if ( rowsize == 0 || th > (size_t) (tilesize / rowsize) ) { fprintf(stderr, "Cannot display data: th * rowsize > tilesize\n"); _TIFFfree(buf); return; } - for (row = 0; row < h; row += th) - { - for (col = 0; col < w; col += tw) - { - if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0) - { - if (stoponerr) - break; - } - else if (showdata) - ShowTile(row, col, (tsample_t)-1, buf, th, rowsize); - } - } - _TIFFfree(buf); - } - else - { - fprintf(stderr, "Cannot allocate %" TIFF_SSIZE_FORMAT " bytes.\n", - tilesize); - } + for (row = 0; row < h; row += th) { + for (col = 0; col < w; col += tw) { + if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0) { + if (stoponerr) + break; + } else if (showdata) + ShowTile(row, col, (tsample_t) -1, buf, th, rowsize); + } + } + _TIFFfree(buf); + } } -void TIFFReadSeparateTileData(TIFF *tif) +void +TIFFReadSeparateTileData(TIFF* tif) { - unsigned char *buf; - tmsize_t rowsize = TIFFTileRowSize(tif); - tmsize_t tilesize = TIFFTileSize(tif); + unsigned char *buf; + tmsize_t rowsize = TIFFTileRowSize(tif); + tmsize_t tilesize = TIFFTileSize(tif); - if (maxMalloc != 0 && tilesize > maxMalloc) - { - fprintf(stderr, - "Memory allocation attempt %" TIFF_SSIZE_FORMAT - " over memory limit (%" TIFF_SSIZE_FORMAT ")\n", - tilesize, maxMalloc); - return; - } - buf = (unsigned char *)_TIFFmalloc(tilesize); - if (buf) - { - uint32_t tw = 0, th = 0, w = 0, h = 0; - uint32_t row, col; - tsample_t s, samplesperpixel = 0; + buf = (unsigned char *)_TIFFmalloc(tilesize); + if (buf) { + uint32 tw=0, th=0, w=0, h=0; + uint32 row, col; + tsample_t s, samplesperpixel=0; - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); - TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); - TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); - if (rowsize == 0 || th > (size_t)(tilesize / rowsize)) + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); + TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + if ( rowsize == 0 || th > (size_t) (tilesize / rowsize) ) { fprintf(stderr, "Cannot display data: th * rowsize > tilesize\n"); _TIFFfree(buf); return; } - for (row = 0; row < h; row += th) - { - for (col = 0; col < w; col += tw) - { - for (s = 0; s < samplesperpixel; s++) - { - if (TIFFReadTile(tif, buf, col, row, 0, s) < 0) - { - if (stoponerr) - break; - } - else if (showdata) - ShowTile(row, col, s, buf, th, rowsize); - } - } - } - _TIFFfree(buf); - } - else - { - fprintf(stderr, "Cannot allocate %" TIFF_SSIZE_FORMAT " bytes.\n", - tilesize); - } + for (row = 0; row < h; row += th) { + for (col = 0; col < w; col += tw) { + for (s = 0; s < samplesperpixel; s++) { + if (TIFFReadTile(tif, buf, col, row, 0, s) < 0) { + if (stoponerr) + break; + } else if (showdata) + ShowTile(row, col, s, buf, th, rowsize); + } + } + } + _TIFFfree(buf); + } } -void TIFFReadData(TIFF *tif) +void +TIFFReadData(TIFF* tif) { - uint16_t config = PLANARCONFIG_CONTIG; + uint16 config = PLANARCONFIG_CONTIG; - TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); - if (TIFFIsTiled(tif)) - { - if (config == PLANARCONFIG_CONTIG) - TIFFReadContigTileData(tif); - else - TIFFReadSeparateTileData(tif); - } - else - { - if (config == PLANARCONFIG_CONTIG) - TIFFReadContigStripData(tif); - else - TIFFReadSeparateStripData(tif); - } + TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); + if (TIFFIsTiled(tif)) { + if (config == PLANARCONFIG_CONTIG) + TIFFReadContigTileData(tif); + else + TIFFReadSeparateTileData(tif); + } else { + if (config == PLANARCONFIG_CONTIG) + TIFFReadContigStripData(tif); + else + TIFFReadSeparateStripData(tif); + } } -static void ShowRawBytes(unsigned char *pp, uint32_t n) +static void +ShowRawBytes(unsigned char* pp, uint32 n) { - uint32_t i; + uint32 i; - for (i = 0; i < n; i++) - { - printf(" %02x", *pp++); - if (((i + 1) % 24) == 0) - printf("\n "); - } - putchar('\n'); + for (i = 0; i < n; i++) { + printf(" %02x", *pp++); + if (((i+1) % 24) == 0) + printf("\n "); + } + putchar('\n'); } -static void ShowRawWords(uint16_t *pp, uint32_t n) +static void +ShowRawWords(uint16* pp, uint32 n) { - uint32_t i; + uint32 i; - for (i = 0; i < n; i++) - { - printf(" %04" PRIx16, *pp++); - if (((i + 1) % 15) == 0) - printf("\n "); - } - putchar('\n'); + for (i = 0; i < n; i++) { + printf(" %04x", *pp++); + if (((i+1) % 15) == 0) + printf("\n "); + } + putchar('\n'); } -static void TIFFReadRawDataStriped(TIFF *tif, int bitrev) +static void +TIFFReadRawDataStriped(TIFF* tif, int bitrev) { - tstrip_t nstrips = TIFFNumberOfStrips(tif); - const char *what = "Strip"; - uint64_t *stripbc = NULL; + tstrip_t nstrips = TIFFNumberOfStrips(tif); + const char* what = "Strip"; + uint64* stripbc=NULL; - TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbc); - if (stripbc != NULL && nstrips > 0) - { - uint32_t bufsize = 0; - tdata_t buf = NULL; - tstrip_t s; + TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbc); + if (stripbc != NULL && nstrips > 0) { + uint32 bufsize = (uint32) stripbc[0]; + tdata_t buf = _TIFFmalloc(bufsize); + tstrip_t s; - for (s = 0; s < nstrips; s++) - { - if (stripbc[s] > bufsize || buf == NULL) - { - tdata_t newbuf; - if (maxMalloc != 0 && stripbc[s] > (uint64_t)maxMalloc) - { - fprintf(stderr, - "Memory allocation attempt %" TIFF_SSIZE_FORMAT - " over memory limit (%" TIFF_SSIZE_FORMAT ")\n", - (tmsize_t)stripbc[s], maxMalloc); - break; - } - newbuf = _TIFFrealloc(buf, (tmsize_t)stripbc[s]); - if (newbuf == NULL) - { - fprintf(stderr, - "Cannot allocate buffer to read strip %" PRIu32 - "\n", - s); - break; - } - bufsize = (uint32_t)stripbc[s]; - buf = newbuf; - } - if (TIFFReadRawStrip(tif, s, buf, (tmsize_t)stripbc[s]) < 0) - { - fprintf(stderr, "Error reading strip %" PRIu32 "\n", s); - if (stoponerr) - break; - } - else if (showdata) - { - if (bitrev) - { - TIFFReverseBits(buf, (tmsize_t)stripbc[s]); - printf("%s %" PRIu32 ": (bit reversed)\n ", what, s); - } - else - printf("%s %" PRIu32 ":\n ", what, s); - if (showwords) - ShowRawWords((uint16_t *)buf, (uint32_t)stripbc[s] >> 1); - else - ShowRawBytes((unsigned char *)buf, (uint32_t)stripbc[s]); - } - } - if (buf != NULL) - _TIFFfree(buf); - } + for (s = 0; s < nstrips; s++) { + if (stripbc[s] > bufsize) { + buf = _TIFFrealloc(buf, (tmsize_t)stripbc[s]); + bufsize = (uint32) stripbc[s]; + } + if (buf == NULL) { + fprintf(stderr, + "Cannot allocate buffer to read strip %lu\n", + (unsigned long) s); + break; + } + if (TIFFReadRawStrip(tif, s, buf, (tmsize_t) stripbc[s]) < 0) { + fprintf(stderr, "Error reading strip %lu\n", + (unsigned long) s); + if (stoponerr) + break; + } else if (showdata) { + if (bitrev) { + TIFFReverseBits(buf, (tmsize_t)stripbc[s]); + printf("%s %lu: (bit reversed)\n ", + what, (unsigned long) s); + } else + printf("%s %lu:\n ", what, + (unsigned long) s); + if (showwords) + ShowRawWords((uint16*) buf, (uint32) stripbc[s]>>1); + else + ShowRawBytes((unsigned char*) buf, (uint32) stripbc[s]); + } + } + if (buf != NULL) + _TIFFfree(buf); + } } -static void TIFFReadRawDataTiled(TIFF *tif, int bitrev) +static void +TIFFReadRawDataTiled(TIFF* tif, int bitrev) { - const char *what = "Tile"; - uint32_t ntiles = TIFFNumberOfTiles(tif); - uint64_t *tilebc = NULL; + const char* what = "Tile"; + uint32 ntiles = TIFFNumberOfTiles(tif); + uint64 *tilebc; - TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &tilebc); - if (tilebc != NULL && ntiles > 0) - { - uint64_t bufsize = 0; - tdata_t buf = NULL; - uint32_t t; + TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &tilebc); + if (tilebc != NULL && ntiles > 0) { + uint64 bufsize = 0; + tdata_t buf = NULL; + uint32 t; - for (t = 0; t < ntiles; t++) - { - if (tilebc[t] > bufsize || buf == NULL) - { - tdata_t newbuf; - if (maxMalloc != 0 && tilebc[t] > (uint64_t)maxMalloc) - { - fprintf(stderr, - "Memory allocation attempt %" TIFF_SSIZE_FORMAT - " over memory limit (%" TIFF_SSIZE_FORMAT ")\n", - (tmsize_t)tilebc[t], maxMalloc); - break; - } - newbuf = _TIFFrealloc(buf, (tmsize_t)tilebc[t]); - if (newbuf == NULL) - { - fprintf(stderr, - "Cannot allocate buffer to read tile %" PRIu32 "\n", - t); - break; - } - bufsize = (uint32_t)tilebc[t]; - buf = newbuf; - } - if (TIFFReadRawTile(tif, t, buf, (tmsize_t)tilebc[t]) < 0) - { - fprintf(stderr, "Error reading tile %" PRIu32 "\n", t); - if (stoponerr) - break; - } - else if (showdata) - { - if (bitrev) - { - TIFFReverseBits(buf, (tmsize_t)tilebc[t]); - printf("%s %" PRIu32 ": (bit reversed)\n ", what, t); - } - else - { - printf("%s %" PRIu32 ":\n ", what, t); - } - if (showwords) - { - ShowRawWords((uint16_t *)buf, (uint32_t)(tilebc[t] >> 1)); - } - else - { - ShowRawBytes((unsigned char *)buf, (uint32_t)tilebc[t]); - } - } - } - if (buf != NULL) - _TIFFfree(buf); - } + for (t = 0; t < ntiles; t++) { + if (buf == NULL || tilebc[t] > bufsize) { + buf = _TIFFrealloc(buf, (tmsize_t)tilebc[t]); + bufsize = tilebc[t]; + } + if (buf == NULL) { + fprintf(stderr, + "Cannot allocate buffer to read tile %lu\n", + (unsigned long) t); + break; + } + if (TIFFReadRawTile(tif, t, buf, (tmsize_t)tilebc[t]) < 0) { + fprintf(stderr, "Error reading tile %lu\n", + (unsigned long) t); + if (stoponerr) + break; + } else if (showdata) { + if (bitrev) { + TIFFReverseBits(buf, (tmsize_t)tilebc[t]); + printf("%s %lu: (bit reversed)\n ", + what, (unsigned long) t); + } else { + printf("%s %lu:\n ", what, + (unsigned long) t); + } + if (showwords) { + ShowRawWords((uint16*) buf, (uint32)(tilebc[t]>>1)); + } else { + ShowRawBytes((unsigned char*) buf, (uint32) tilebc[t]); + } + } + } + if (buf != NULL) + _TIFFfree(buf); + } } -void TIFFReadRawData(TIFF *tif, int bitrev) +void +TIFFReadRawData(TIFF* tif, int bitrev) { - if (TIFFIsTiled(tif)) - { - TIFFReadRawDataTiled(tif, bitrev); - } - else - { - TIFFReadRawDataStriped(tif, bitrev); - } + if (TIFFIsTiled(tif)) { + TIFFReadRawDataTiled(tif, bitrev); + } else { + TIFFReadRawDataStriped(tif, bitrev); + } } -static void tiffinfo(TIFF *tif, uint16_t order, long flags, int is_image) +static void +tiffinfo(TIFF* tif, uint16 order, long flags, int is_image) { - TIFFPrintDirectory(tif, stdout, flags); - if (!readdata || !is_image) - return; - if (rawdata) - { - if (order) - { - uint16_t o; - TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &o); - TIFFReadRawData(tif, o != order); - } - else - TIFFReadRawData(tif, 0); - } - else - { - if (order) - TIFFSetField(tif, TIFFTAG_FILLORDER, order); - TIFFReadData(tif); - } + TIFFPrintDirectory(tif, stdout, flags); + if (!readdata || !is_image) + return; + if (rawdata) { + if (order) { + uint16 o; + TIFFGetFieldDefaulted(tif, + TIFFTAG_FILLORDER, &o); + TIFFReadRawData(tif, o != order); + } else + TIFFReadRawData(tif, 0); + } else { + if (order) + TIFFSetField(tif, TIFFTAG_FILLORDER, order); + TIFFReadData(tif); + } } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffinfoce.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffinfoce.c new file mode 100644 index 000000000..b90f0382d --- /dev/null +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffinfoce.c @@ -0,0 +1,484 @@ +/* + * Copyright (c) 1988-1997 Sam Leffler + * Copyright (c) 1991-1997 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + * + * Adapted from tifinfo.c by Mateusz Loskot (mateusz@loskot.net) + */ + +#if !defined(_WIN32_WCE) +# error "Only Windows CE target is supported!" +#endif + +#include "tif_config.h" + +#include +#include +#include +#include +#include + +#include "tiffio.h" + +#define streq(a,b) (_stricmp(a,b) == 0) + +/* defined in port/getopt.c */ +int getopt(int argc, char * const argv[], const char *optstring); + +int showdata = 0; /* show data */ +int rawdata = 0; /* show raw/decoded data */ +int showwords = 0; /* show data as bytes/words */ +int readdata = 0; /* read data in file */ +int stoponerr = 1; /* stop on first read error */ + +static void usage(void); +static void tiffinfo(TIFF*, uint16, long); + +int +main(int argc, char* argv[]) +{ + int dirnum = -1, multiplefiles, c; + uint16 order = 0; + TIFF* tif; + extern int optind; + extern char* optarg; + long flags = 0; + uint32 diroff = 0; + int chopstrips = 0; /* disable strip chopping */ + + while ((c = getopt(argc, argv, "f:o:cdDSjilmrsvwz0123456789")) != -1) + switch (c) { + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + case '8': case '9': + dirnum = atoi(&argv[optind-1][1]); + break; + case 'd': + showdata++; + /* fall through... */ + case 'D': + readdata++; + break; + case 'c': + flags |= TIFFPRINT_COLORMAP | TIFFPRINT_CURVES; + break; + case 'f': /* fill order */ + if (streq(optarg, "lsb2msb")) + order = FILLORDER_LSB2MSB; + else if (streq(optarg, "msb2lsb")) + order = FILLORDER_MSB2LSB; + else + usage(); + break; + case 'i': + stoponerr = 0; + break; + case 'o': + diroff = strtoul(optarg, NULL, 0); + break; + case 'j': + flags |= TIFFPRINT_JPEGQTABLES | + TIFFPRINT_JPEGACTABLES | + TIFFPRINT_JPEGDCTABLES; + break; + case 'r': + rawdata = 1; + break; + case 's': + flags |= TIFFPRINT_STRIPS; + break; + case 'w': + showwords = 1; + break; + case 'z': + chopstrips = 1; + break; + case '?': + usage(); + /*NOTREACHED*/ + } + if (optind >= argc) + { + usage(); + } + + multiplefiles = (argc - optind > 1); + for (; optind < argc; optind++) + { + if (multiplefiles) + { + printf("%s:\n", argv[optind]); + } + + tif = TIFFOpen(argv[optind], chopstrips ? "rC" : "rc"); + if (tif != NULL) + { + if (dirnum != -1) + { + if (TIFFSetDirectory(tif, (tdir_t) dirnum)) + tiffinfo(tif, order, flags); + } else if (diroff != 0) { + if (TIFFSetSubDirectory(tif, diroff)) + tiffinfo(tif, order, flags); + } else { + do { + toff_t offset; + + tiffinfo(tif, order, flags); + if (TIFFGetField(tif, TIFFTAG_EXIFIFD, + &offset)) { + if (TIFFReadEXIFDirectory(tif, offset)) + tiffinfo(tif, order, flags); + } + } while (TIFFReadDirectory(tif)); + } + TIFFClose(tif); + } + } + + printf("\n\n"); + getc(stdin); + + return (0); +} + +char* stuff[] = { +"usage: tiffinfo [options] input...", +"where options are:", +" -D read data", +" -i ignore read errors", +" -c display data for grey/color response curve or colormap", +" -d display raw/decoded image data", +" -f lsb2msb force lsb-to-msb FillOrder for input", +" -f msb2lsb force msb-to-lsb FillOrder for input", +" -j show JPEG tables", +" -o offset set initial directory offset", +" -r read/display raw image data instead of decoded data", +" -s display strip offsets and byte counts", +" -w display raw data in words rather than bytes", +" -z enable strip chopping", +" -# set initial directory (first directory is # 0)", +NULL +}; + +static void +usage(void) +{ + /* char buf[BUFSIZ];*/ + int i; + + /* setbuf(stderr, buf); */ + fprintf(stderr, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(stderr, "%s\n", stuff[i]); + exit(-1); +} + +static void +ShowStrip(tstrip_t strip, unsigned char* pp, uint32 nrow, tsize_t scanline) +{ + register tsize_t cc; + + printf("Strip %lu:\n", (unsigned long) strip); + while (nrow-- > 0) { + for (cc = 0; cc < scanline; cc++) { + printf(" %02x", *pp++); + if (((cc+1) % 24) == 0) + putchar('\n'); + } + putchar('\n'); + } +} + +void +TIFFReadContigStripData(TIFF* tif) +{ + unsigned char *buf; + tsize_t scanline = TIFFScanlineSize(tif); + + buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif)); + if (buf) { + uint32 row, h; + uint32 rowsperstrip = (uint32)-1; + + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + for (row = 0; row < h; row += rowsperstrip) { + uint32 nrow = (row+rowsperstrip > h ? + h-row : rowsperstrip); + tstrip_t strip = TIFFComputeStrip(tif, row, 0); + if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) { + if (stoponerr) + break; + } else if (showdata) + ShowStrip(strip, buf, nrow, scanline); + } + _TIFFfree(buf); + } +} + +void +TIFFReadSeparateStripData(TIFF* tif) +{ + unsigned char *buf; + tsize_t scanline = TIFFScanlineSize(tif); + + buf = (unsigned char *)_TIFFmalloc(TIFFStripSize(tif)); + if (buf) { + uint32 row, h; + uint32 rowsperstrip = (uint32)-1; + tsample_t s, samplesperpixel; + + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_ROWSPERSTRIP, &rowsperstrip); + TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + for (row = 0; row < h; row += rowsperstrip) { + for (s = 0; s < samplesperpixel; s++) { + uint32 nrow = (row+rowsperstrip > h ? + h-row : rowsperstrip); + tstrip_t strip = TIFFComputeStrip(tif, row, s); + if (TIFFReadEncodedStrip(tif, strip, buf, nrow*scanline) < 0) { + if (stoponerr) + break; + } else if (showdata) + ShowStrip(strip, buf, nrow, scanline); + } + } + _TIFFfree(buf); + } +} + +static void +ShowTile(uint32 row, uint32 col, tsample_t sample, + unsigned char* pp, uint32 nrow, uint32 rowsize) +{ + uint32 cc; + + printf("Tile (%lu,%lu", (unsigned long) row, (unsigned long) col); + if (sample != (tsample_t) -1) + printf(",%u", sample); + printf("):\n"); + while (nrow-- > 0) { + for (cc = 0; cc < rowsize; cc++) { + printf(" %02x", *pp++); + if (((cc+1) % 24) == 0) + putchar('\n'); + } + putchar('\n'); + } +} + +void +TIFFReadContigTileData(TIFF* tif) +{ + unsigned char *buf; + tmsize_t rowsize = TIFFTileRowSize(tif); + tmsize_t tilesize = TIFFTileSize(tif); + + buf = (unsigned char *)_TIFFmalloc(tilesize); + if (buf) { + uint32 tw=0, th=0, w=0, h=0; + uint32 row, col; + + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); + if( rowsize == 0 || th > tilesize / rowsize ) + { + fprintf(stderr, "Cannot display data: th * rowsize > tilesize\n"); + _TIFFfree(buf); + return; + } + for (row = 0; row < h; row += th) { + for (col = 0; col < w; col += tw) { + if (TIFFReadTile(tif, buf, col, row, 0, 0) < 0) { + if (stoponerr) + break; + } else if (showdata) + ShowTile(row, col, (tsample_t) -1, buf, th, rowsize); + } + } + _TIFFfree(buf); + } +} + +void +TIFFReadSeparateTileData(TIFF* tif) +{ + unsigned char *buf; + tmsize_t rowsize = TIFFTileRowSize(tif); + tmsize_t tilesize = TIFFTileSize(tif); + + buf = (unsigned char *)_TIFFmalloc(tilesize); + if (buf) { + uint32 tw=0, th=0, w=0, h=0; + uint32 row, col; + tsample_t s, samplesperpixel; + + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_TILEWIDTH, &tw); + TIFFGetField(tif, TIFFTAG_TILELENGTH, &th); + TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + if( rowsize == 0 || th > tilesize / rowsize ) + { + fprintf(stderr, "Cannot display data: th * rowsize > tilesize\n"); + _TIFFfree(buf); + return; + } + for (row = 0; row < h; row += th) { + for (col = 0; col < w; col += tw) { + for (s = 0; s < samplesperpixel; s++) { + if (TIFFReadTile(tif, buf, col, row, 0, s) < 0) { + if (stoponerr) + break; + } else if (showdata) + ShowTile(row, col, s, buf, th, rowsize); + } + } + } + _TIFFfree(buf); + } +} + +void +TIFFReadData(TIFF* tif) +{ + uint16 config; + + TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); + if (TIFFIsTiled(tif)) { + if (config == PLANARCONFIG_CONTIG) + TIFFReadContigTileData(tif); + else + TIFFReadSeparateTileData(tif); + } else { + if (config == PLANARCONFIG_CONTIG) + TIFFReadContigStripData(tif); + else + TIFFReadSeparateStripData(tif); + } +} + +static void +ShowRawBytes(unsigned char* pp, uint32 n) +{ + uint32 i; + + for (i = 0; i < n; i++) { + printf(" %02x", *pp++); + if (((i+1) % 24) == 0) + printf("\n "); + } + putchar('\n'); +} + +static void +ShowRawWords(uint16* pp, uint32 n) +{ + uint32 i; + + for (i = 0; i < n; i++) { + printf(" %04x", *pp++); + if (((i+1) % 15) == 0) + printf("\n "); + } + putchar('\n'); +} + +void +TIFFReadRawData(TIFF* tif, int bitrev) +{ + tstrip_t nstrips = TIFFNumberOfStrips(tif); + const char* what = TIFFIsTiled(tif) ? "Tile" : "Strip"; + uint64* stripbc; + + TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &stripbc); + if (nstrips > 0) { + uint32 bufsize = stripbc[0]; + tdata_t buf = _TIFFmalloc(bufsize); + tstrip_t s; + + for (s = 0; s < nstrips; s++) { + if (stripbc[s] > bufsize) { + buf = _TIFFrealloc(buf, stripbc[s]); + bufsize = stripbc[s]; + } + if (buf == NULL) { + fprintf(stderr, + "Cannot allocate buffer to read strip %lu\n", + (unsigned long) s); + break; + } + if (TIFFReadRawStrip(tif, s, buf, stripbc[s]) < 0) { + fprintf(stderr, "Error reading strip %lu\n", + (unsigned long) s); + if (stoponerr) + break; + } else if (showdata) { + if (bitrev) { + TIFFReverseBits(buf, stripbc[s]); + printf("%s %lu: (bit reversed)\n ", + what, (unsigned long) s); + } else + printf("%s %lu:\n ", what, + (unsigned long) s); + if (showwords) + ShowRawWords((uint16*) buf, stripbc[s]>>1); + else + ShowRawBytes((unsigned char*) buf, stripbc[s]); + } + } + if (buf != NULL) + _TIFFfree(buf); + } +} + +static void +tiffinfo(TIFF* tif, uint16 order, long flags) +{ + TIFFPrintDirectory(tif, stdout, flags); + if (!readdata) + return; + if (rawdata) { + if (order) { + uint16 o; + TIFFGetFieldDefaulted(tif, + TIFFTAG_FILLORDER, &o); + TIFFReadRawData(tif, o != order); + } else + TIFFReadRawData(tif, 0); + } else { + if (order) + TIFFSetField(tif, TIFFTAG_FILLORDER, order); + TIFFReadData(tif); + } +} + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffmedian.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffmedian.c index 334566a40..6654cd6fa 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffmedian.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffmedian.c @@ -4,7 +4,7 @@ * tiffmedian [-c n] [-f] input output * -C n - set colortable size. Default is 256. * -f - use Floyd-Steinberg dithering. - * -c lzw - compress output with LZW + * -c lzw - compress output with LZW * -c none - use no compression on output * -c packbits - use packbits compression on output * -r n - create output with n rows/strip of data @@ -18,7 +18,7 @@ * you are at X, moving left to right: * * X 7/16 - * 3/16 5/16 1/16 + * 3/16 5/16 1/16 * * Note that the error goes to four neighbors, not three. I think this * will probably do better (at least for black and white) than the @@ -31,14 +31,13 @@ * half the error one pixel ahead (e.g. to the right on lines you scan * left to right), and half one pixel straight down. Again, this is for * black and white; I've not tried it with color. - * -- + * -- * Lou Steinberg * * [2] Color Image Quantization for Frame Buffer Display, Paul Heckbert, * Siggraph '82 proceedings, pp. 297-307 */ -#include "libport.h" #include "tif_config.h" #include @@ -46,7 +45,11 @@ #include #ifdef HAVE_UNISTD_H -#include +# include +#endif + +#ifdef NEED_LIBPORT +# include "libport.h" #endif #include "tiffio.h" @@ -58,772 +61,702 @@ #define EXIT_FAILURE 1 #endif -#define MAX_CMAP_SIZE 256 +#define MAX_CMAP_SIZE 256 -#define streq(a, b) (strcmp(a, b) == 0) -#define strneq(a, b, n) (strncmp(a, b, n) == 0) +#define streq(a,b) (strcmp(a,b) == 0) +#define strneq(a,b,n) (strncmp(a,b,n) == 0) -#define COLOR_DEPTH 8 -#define MAX_COLOR 256 +#define COLOR_DEPTH 8 +#define MAX_COLOR 256 -#define B_DEPTH 5 /* # bits/pixel to use */ -#define B_LEN (1L << B_DEPTH) +#define B_DEPTH 5 /* # bits/pixel to use */ +#define B_LEN (1L< MAX_CMAP_SIZE) - { - fprintf(stderr, "-C: colormap too big, max %d\n", - MAX_CMAP_SIZE); - usage(EXIT_FAILURE); - } - if (num_colors < 2) - { - fprintf(stderr, "-C: colormap too small, min %d\n", 2); - usage(EXIT_FAILURE); - } - break; - case 'f': /* dither */ - dither = 1; - break; - case 'r': /* rows/strip */ - rowsperstrip = atoi(optarg); - break; - case 'h': - usage(EXIT_SUCCESS); - /*NOTREACHED*/ - break; - case '?': - usage(EXIT_FAILURE); - /*NOTREACHED*/ - break; - } - if (argc - optind != 2) - usage(EXIT_FAILURE); - in = TIFFOpen(argv[optind], "r"); - if (in == NULL) - return (EXIT_FAILURE); - TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &imagewidth); - TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); - TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); - TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); - if (bitspersample != 8 && bitspersample != 16) - { - fprintf(stderr, "%s: Image must have at least 8-bits/sample\n", - argv[optind]); - return (EXIT_FAILURE); - } - if (!TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric) || - photometric != PHOTOMETRIC_RGB || samplesperpixel < 3) - { - fprintf(stderr, "%s: Image must have RGB data\n", argv[optind]); - return (EXIT_FAILURE); - } - TIFFGetField(in, TIFFTAG_PLANARCONFIG, &config); - if (config != PLANARCONFIG_CONTIG) - { - fprintf(stderr, "%s: Can only handle contiguous data packing\n", - argv[optind]); - return (EXIT_FAILURE); - } + num_colors = MAX_CMAP_SIZE; + while ((c = getopt(argc, argv, "c:C:r:fh")) != -1) + switch (c) { + case 'c': /* compression scheme */ + if (!processCompressOptions(optarg)) + usage(EXIT_FAILURE); + break; + case 'C': /* set colormap size */ + num_colors = atoi(optarg); + if (num_colors > MAX_CMAP_SIZE) { + fprintf(stderr, + "-c: colormap too big, max %d\n", + MAX_CMAP_SIZE); + usage(EXIT_FAILURE); + } + break; + case 'f': /* dither */ + dither = 1; + break; + case 'r': /* rows/strip */ + rowsperstrip = atoi(optarg); + break; + case 'h': + usage(EXIT_SUCCESS); + /*NOTREACHED*/ + case '?': + usage(EXIT_FAILURE); + /*NOTREACHED*/ + } + if (argc - optind != 2) + usage(EXIT_FAILURE); + in = TIFFOpen(argv[optind], "r"); + if (in == NULL) + return (EXIT_FAILURE); + TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &imagewidth); + TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength); + TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &bitspersample); + TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); + if (bitspersample != 8 && bitspersample != 16) { + fprintf(stderr, "%s: Image must have at least 8-bits/sample\n", + argv[optind]); + return (EXIT_FAILURE); + } + if (!TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &photometric) || + photometric != PHOTOMETRIC_RGB || samplesperpixel < 3) { + fprintf(stderr, "%s: Image must have RGB data\n", argv[optind]); + return (EXIT_FAILURE); + } + TIFFGetField(in, TIFFTAG_PLANARCONFIG, &config); + if (config != PLANARCONFIG_CONTIG) { + fprintf(stderr, "%s: Can only handle contiguous data packing\n", + argv[optind]); + return (EXIT_FAILURE); + } - /* - * STEP 1: create empty boxes - */ - usedboxes = NULL; - box_list = freeboxes = - (Colorbox *)_TIFFmalloc(num_colors * sizeof(Colorbox)); - freeboxes[0].next = &freeboxes[1]; - freeboxes[0].prev = NULL; - for (i = 1; i < num_colors - 1; ++i) - { - freeboxes[i].next = &freeboxes[i + 1]; - freeboxes[i].prev = &freeboxes[i - 1]; - } - freeboxes[num_colors - 1].next = NULL; - freeboxes[num_colors - 1].prev = &freeboxes[num_colors - 2]; + /* + * STEP 1: create empty boxes + */ + usedboxes = NULL; + box_list = freeboxes = (Colorbox *)_TIFFmalloc(num_colors*sizeof (Colorbox)); + freeboxes[0].next = &freeboxes[1]; + freeboxes[0].prev = NULL; + for (i = 1; i < num_colors-1; ++i) { + freeboxes[i].next = &freeboxes[i+1]; + freeboxes[i].prev = &freeboxes[i-1]; + } + freeboxes[num_colors-1].next = NULL; + freeboxes[num_colors-1].prev = &freeboxes[num_colors-2]; - /* - * STEP 2: get histogram, initialize first box - */ - ptr = freeboxes; - freeboxes = ptr->next; - if (freeboxes) - freeboxes->prev = NULL; - ptr->next = usedboxes; - usedboxes = ptr; - if (ptr->next) - ptr->next->prev = ptr; - get_histogram(in, ptr); + /* + * STEP 2: get histogram, initialize first box + */ + ptr = freeboxes; + freeboxes = ptr->next; + if (freeboxes) + freeboxes->prev = NULL; + ptr->next = usedboxes; + usedboxes = ptr; + if (ptr->next) + ptr->next->prev = ptr; + get_histogram(in, ptr); - /* - * STEP 3: continually subdivide boxes until no more free - * boxes remain or until all colors assigned. - */ - while (freeboxes != NULL) - { - ptr = largest_box(); - if (ptr != NULL) - splitbox(ptr); - else - freeboxes = NULL; - } + /* + * STEP 3: continually subdivide boxes until no more free + * boxes remain or until all colors assigned. + */ + while (freeboxes != NULL) { + ptr = largest_box(); + if (ptr != NULL) + splitbox(ptr); + else + freeboxes = NULL; + } - /* - * STEP 4: assign colors to all boxes - */ - for (i = 0, ptr = usedboxes; ptr != NULL; ++i, ptr = ptr->next) - { - rm[i] = ((ptr->rmin + ptr->rmax) << COLOR_SHIFT) / 2; - gm[i] = ((ptr->gmin + ptr->gmax) << COLOR_SHIFT) / 2; - bm[i] = ((ptr->bmin + ptr->bmax) << COLOR_SHIFT) / 2; - } + /* + * STEP 4: assign colors to all boxes + */ + for (i = 0, ptr = usedboxes; ptr != NULL; ++i, ptr = ptr->next) { + rm[i] = ((ptr->rmin + ptr->rmax) << COLOR_SHIFT) / 2; + gm[i] = ((ptr->gmin + ptr->gmax) << COLOR_SHIFT) / 2; + bm[i] = ((ptr->bmin + ptr->bmax) << COLOR_SHIFT) / 2; + } - /* We're done with the boxes now */ - _TIFFfree(box_list); - freeboxes = usedboxes = NULL; + /* We're done with the boxes now */ + _TIFFfree(box_list); + freeboxes = usedboxes = NULL; - /* - * STEP 5: scan histogram and map all values to closest color - */ - /* 5a: create cell list as described in Heckbert[2] */ - ColorCells = - (C_cell **)_TIFFmalloc(C_LEN * C_LEN * C_LEN * sizeof(C_cell *)); - _TIFFmemset(ColorCells, 0, C_LEN * C_LEN * C_LEN * sizeof(C_cell *)); - /* 5b: create mapping from truncated pixel space to color - table entries */ - map_colortable(); + /* + * STEP 5: scan histogram and map all values to closest color + */ + /* 5a: create cell list as described in Heckbert[2] */ + ColorCells = (C_cell **)_TIFFmalloc(C_LEN*C_LEN*C_LEN*sizeof (C_cell*)); + _TIFFmemset(ColorCells, 0, C_LEN*C_LEN*C_LEN*sizeof (C_cell*)); + /* 5b: create mapping from truncated pixel space to color + table entries */ + map_colortable(); - /* - * STEP 6: scan image, match input values to table entries - */ - out = TIFFOpen(argv[optind + 1], "w"); - if (out == NULL) - return (EXIT_FAILURE); + /* + * STEP 6: scan image, match input values to table entries + */ + out = TIFFOpen(argv[optind+1], "w"); + if (out == NULL) + return (EXIT_FAILURE); - CopyField(TIFFTAG_SUBFILETYPE, longv); - CopyField(TIFFTAG_IMAGEWIDTH, longv); - TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (short)COLOR_DEPTH); - if (compression != (uint16_t)-1) - { - TIFFSetField(out, TIFFTAG_COMPRESSION, compression); - switch (compression) - { - case COMPRESSION_LZW: - case COMPRESSION_ADOBE_DEFLATE: - case COMPRESSION_DEFLATE: - if (predictor != 0) - TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); - break; - } - } - else - CopyField(TIFFTAG_COMPRESSION, compression); - TIFFSetField(out, TIFFTAG_PHOTOMETRIC, (short)PHOTOMETRIC_PALETTE); - CopyField(TIFFTAG_ORIENTATION, shortv); - TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, (short)1); - CopyField(TIFFTAG_PLANARCONFIG, shortv); - TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, - TIFFDefaultStripSize(out, rowsperstrip)); - CopyField(TIFFTAG_MINSAMPLEVALUE, shortv); - CopyField(TIFFTAG_MAXSAMPLEVALUE, shortv); - CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); - CopyField(TIFFTAG_XRESOLUTION, floatv); - CopyField(TIFFTAG_YRESOLUTION, floatv); - CopyField(TIFFTAG_XPOSITION, floatv); - CopyField(TIFFTAG_YPOSITION, floatv); + CopyField(TIFFTAG_SUBFILETYPE, longv); + CopyField(TIFFTAG_IMAGEWIDTH, longv); + TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (short)COLOR_DEPTH); + if (compression != (uint16)-1) { + TIFFSetField(out, TIFFTAG_COMPRESSION, compression); + switch (compression) { + case COMPRESSION_LZW: + case COMPRESSION_DEFLATE: + if (predictor != 0) + TIFFSetField(out, TIFFTAG_PREDICTOR, predictor); + break; + } + } else + CopyField(TIFFTAG_COMPRESSION, compression); + TIFFSetField(out, TIFFTAG_PHOTOMETRIC, (short)PHOTOMETRIC_PALETTE); + CopyField(TIFFTAG_ORIENTATION, shortv); + TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, (short)1); + CopyField(TIFFTAG_PLANARCONFIG, shortv); + TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, + TIFFDefaultStripSize(out, rowsperstrip)); + CopyField(TIFFTAG_MINSAMPLEVALUE, shortv); + CopyField(TIFFTAG_MAXSAMPLEVALUE, shortv); + CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); + CopyField(TIFFTAG_XRESOLUTION, floatv); + CopyField(TIFFTAG_YRESOLUTION, floatv); + CopyField(TIFFTAG_XPOSITION, floatv); + CopyField(TIFFTAG_YPOSITION, floatv); - if (dither) - quant_fsdither(in, out); - else - quant(in, out); - /* - * Scale colormap to TIFF-required 16-bit values. - */ -#define SCALE(x) (((x) * ((1L << 16) - 1)) / 255) - for (i = 0; i < MAX_CMAP_SIZE; ++i) - { - rm[i] = SCALE(rm[i]); - gm[i] = SCALE(gm[i]); - bm[i] = SCALE(bm[i]); - } - TIFFSetField(out, TIFFTAG_COLORMAP, rm, gm, bm); - (void)TIFFClose(out); - return (EXIT_SUCCESS); + if (dither) + quant_fsdither(in, out); + else + quant(in, out); + /* + * Scale colormap to TIFF-required 16-bit values. + */ +#define SCALE(x) (((x)*((1L<<16)-1))/255) + for (i = 0; i < MAX_CMAP_SIZE; ++i) { + rm[i] = SCALE(rm[i]); + gm[i] = SCALE(gm[i]); + bm[i] = SCALE(bm[i]); + } + TIFFSetField(out, TIFFTAG_COLORMAP, rm, gm, bm); + (void) TIFFClose(out); + return (EXIT_SUCCESS); } -static int processCompressOptions(char *opt) +static int +processCompressOptions(char* opt) { - if (streq(opt, "none")) - compression = COMPRESSION_NONE; - else if (streq(opt, "packbits")) - compression = COMPRESSION_PACKBITS; - else if (strneq(opt, "lzw", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_LZW; - } - else if (strneq(opt, "zip", 3)) - { - char *cp = strchr(opt, ':'); - if (cp) - predictor = atoi(cp + 1); - compression = COMPRESSION_ADOBE_DEFLATE; - } - else - return (0); - return (1); + if (streq(opt, "none")) + compression = COMPRESSION_NONE; + else if (streq(opt, "packbits")) + compression = COMPRESSION_PACKBITS; + else if (strneq(opt, "lzw", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_LZW; + } else if (strneq(opt, "zip", 3)) { + char* cp = strchr(opt, ':'); + if (cp) + predictor = atoi(cp+1); + compression = COMPRESSION_DEFLATE; + } else + return (0); + return (1); } -static const char usage_info[] = - "Apply the median cut algorithm to an RGB TIFF file\n\n" - "usage: tiffmedian [options] input.tif output.tif\n" - "where options are:\n" - " -r # make each strip have no more than # rows\n" - " -C # create a colormap with # entries\n" - " -f use Floyd-Steinberg dithering\n" - "\n" -#ifdef LZW_SUPPORT - " -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding\n" - /* " LZW options:" */ - " # set predictor value\n" - " For example, -c lzw:2 to get LZW-encoded data with horizontal " - "differencing\n" -#endif -#ifdef ZIP_SUPPORT - " -c zip[:opts] compress output with deflate encoding\n" - /* " Deflate (ZIP) options:" */ - " # set predictor value\n" -#endif -#ifdef PACKBITS_SUPPORT - " -c packbits compress output with packbits encoding\n" -#endif -#if defined(LZW_SUPPORT) || defined(ZIP_SUPPORT) || defined(PACKBITS_SUPPORT) - " -c none use no compression algorithm on output\n" -#endif - "\n"; +char* stuff[] = { +"usage: tiffmedian [options] input.tif output.tif", +"where options are:", +" -r # make each strip have no more than # rows", +" -C # create a colormap with # entries", +" -f use Floyd-Steinberg dithering", +" -c lzw[:opts] compress output with Lempel-Ziv & Welch encoding", +" -c zip[:opts] compress output with deflate encoding", +" -c packbits compress output with packbits encoding", +" -c none use no compression algorithm on output", +"", +"LZW and deflate options:", +" # set predictor value", +"For example, -c lzw:2 to get LZW-encoded data with horizontal differencing", +NULL +}; -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usage_info); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; stuff[i] != NULL; i++) + fprintf(out, "%s\n", stuff[i]); + exit(code); } -static void get_histogram(TIFF *in, Colorbox *box) +static void +get_histogram(TIFF* in, Colorbox* box) { - register unsigned char *inptr; - register int red, green, blue; - register uint32_t j, i; - unsigned char *inputline; + register unsigned char *inptr; + register int red, green, blue; + register uint32 j, i; + unsigned char *inputline; - inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); - if (inputline == NULL) - { - fprintf(stderr, "No space for scanline buffer\n"); - exit(EXIT_FAILURE); - } - box->rmin = box->gmin = box->bmin = 999; - box->rmax = box->gmax = box->bmax = -1; - box->total = imagewidth * imagelength; + inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); + if (inputline == NULL) { + fprintf(stderr, "No space for scanline buffer\n"); + exit(EXIT_FAILURE); + } + box->rmin = box->gmin = box->bmin = 999; + box->rmax = box->gmax = box->bmax = -1; + box->total = imagewidth * imagelength; - { - register uint32_t *ptr = &histogram[0][0][0]; - for (i = B_LEN * B_LEN * B_LEN; i-- > 0;) - *ptr++ = 0; - } - for (i = 0; i < imagelength; i++) - { - if (TIFFReadScanline(in, inputline, i, 0) <= 0) - break; - inptr = inputline; - for (j = imagewidth; j-- > 0;) - { - red = (*inptr++) & 0xff >> COLOR_SHIFT; - green = (*inptr++) & 0xff >> COLOR_SHIFT; - blue = (*inptr++) & 0xff >> COLOR_SHIFT; - if ((red | green | blue) >= B_LEN) - { - fprintf(stderr, "Logic error. " - "Histogram array overflow!\n"); - exit(EXIT_FAILURE); - } - if (red < box->rmin) - box->rmin = red; - if (red > box->rmax) - box->rmax = red; - if (green < box->gmin) - box->gmin = green; - if (green > box->gmax) - box->gmax = green; - if (blue < box->bmin) - box->bmin = blue; - if (blue > box->bmax) - box->bmax = blue; - histogram[red][green][blue]++; - } - } - _TIFFfree(inputline); -} - -static Colorbox *largest_box(void) -{ - register Colorbox *p, *b; - register uint32_t size; - - b = NULL; - size = 0; - for (p = usedboxes; p != NULL; p = p->next) - if ((p->rmax > p->rmin || p->gmax > p->gmin || p->bmax > p->bmin) && - p->total > size) - size = (b = p)->total; - return (b); -} - -static void splitbox(Colorbox *ptr) -{ - uint32_t hist2[B_LEN]; - int first = 0, last = 0; - register Colorbox *new; - register uint32_t *iptr, *histp; - register int i, j; - register int ir, ig, ib; - register uint32_t sum, sum1, sum2; - enum - { - RED, - GREEN, - BLUE - } axis; - - /* - * See which axis is the largest, do a histogram along that - * axis. Split at median point. Contract both new boxes to - * fit points and return - */ - i = ptr->rmax - ptr->rmin; - if (i >= ptr->gmax - ptr->gmin && i >= ptr->bmax - ptr->bmin) - axis = RED; - else if (ptr->gmax - ptr->gmin >= ptr->bmax - ptr->bmin) - axis = GREEN; - else - axis = BLUE; - /* get histogram along longest axis */ - switch (axis) - { - case RED: - histp = &hist2[ptr->rmin]; - for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) - { - *histp = 0; - for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) - { - iptr = &histogram[ir][ig][ptr->bmin]; - for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) - *histp += *iptr++; - } - histp++; - } - first = ptr->rmin; - last = ptr->rmax; - break; - case GREEN: - histp = &hist2[ptr->gmin]; - for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) - { - *histp = 0; - for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) - { - iptr = &histogram[ir][ig][ptr->bmin]; - for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) - *histp += *iptr++; - } - histp++; - } - first = ptr->gmin; - last = ptr->gmax; - break; - case BLUE: - histp = &hist2[ptr->bmin]; - for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) - { - *histp = 0; - for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) - { - iptr = &histogram[ir][ptr->gmin][ib]; - for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) - { - *histp += *iptr; - iptr += B_LEN; - } - } - histp++; - } - first = ptr->bmin; - last = ptr->bmax; - break; - } - /* find median point */ - sum2 = ptr->total / 2; - histp = &hist2[first]; - sum = 0; - for (i = first; i <= last && (sum += *histp++) < sum2; ++i) - ; - if (i == first) - i++; - - /* Create new box, re-allocate points */ - new = freeboxes; - freeboxes = new->next; - if (freeboxes) - freeboxes->prev = NULL; - if (usedboxes) - usedboxes->prev = new; - new->next = usedboxes; - usedboxes = new; - - histp = &hist2[first]; - for (sum1 = 0, j = first; j < i; j++) - sum1 += *histp++; - for (sum2 = 0, j = i; j <= last; j++) - sum2 += *histp++; - new->total = sum1; - ptr->total = sum2; - - new->rmin = ptr->rmin; - new->rmax = ptr->rmax; - new->gmin = ptr->gmin; - new->gmax = ptr->gmax; - new->bmin = ptr->bmin; - new->bmax = ptr->bmax; - switch (axis) - { - case RED: - new->rmax = i - 1; - ptr->rmin = i; - break; - case GREEN: - new->gmax = i - 1; - ptr->gmin = i; - break; - case BLUE: - new->bmax = i - 1; - ptr->bmin = i; - break; - } - shrinkbox(new); - shrinkbox(ptr); -} - -static void shrinkbox(Colorbox *box) -{ - register uint32_t *histp; - register int ir, ig, ib; - - if (box->rmax > box->rmin) - { - for (ir = box->rmin; ir <= box->rmax; ++ir) - for (ig = box->gmin; ig <= box->gmax; ++ig) - { - histp = &histogram[ir][ig][box->bmin]; - for (ib = box->bmin; ib <= box->bmax; ++ib) - if (*histp++ != 0) - { - box->rmin = ir; - goto have_rmin; - } - } - have_rmin: - if (box->rmax > box->rmin) - for (ir = box->rmax; ir >= box->rmin; --ir) - for (ig = box->gmin; ig <= box->gmax; ++ig) - { - histp = &histogram[ir][ig][box->bmin]; - ib = box->bmin; - for (; ib <= box->bmax; ++ib) - if (*histp++ != 0) - { - box->rmax = ir; - goto have_rmax; + { register uint32 *ptr = &histogram[0][0][0]; + for (i = B_LEN*B_LEN*B_LEN; i-- > 0;) + *ptr++ = 0; + } + for (i = 0; i < imagelength; i++) { + if (TIFFReadScanline(in, inputline, i, 0) <= 0) + break; + inptr = inputline; + for (j = imagewidth; j-- > 0;) { + red = (*inptr++) & 0xff >> COLOR_SHIFT; + green = (*inptr++) & 0xff >> COLOR_SHIFT; + blue = (*inptr++) & 0xff >> COLOR_SHIFT; + if ((red | green | blue) >= B_LEN) { + fprintf(stderr, + "Logic error. " + "Histogram array overflow!\n"); + exit(EXIT_FAILURE); } - } - } + if (red < box->rmin) + box->rmin = red; + if (red > box->rmax) + box->rmax = red; + if (green < box->gmin) + box->gmin = green; + if (green > box->gmax) + box->gmax = green; + if (blue < box->bmin) + box->bmin = blue; + if (blue > box->bmax) + box->bmax = blue; + histogram[red][green][blue]++; + } + } + _TIFFfree(inputline); +} + +static Colorbox * +largest_box(void) +{ + register Colorbox *p, *b; + register uint32 size; + + b = NULL; + size = 0; + for (p = usedboxes; p != NULL; p = p->next) + if ((p->rmax > p->rmin || p->gmax > p->gmin || + p->bmax > p->bmin) && p->total > size) + size = (b = p)->total; + return (b); +} + +static void +splitbox(Colorbox* ptr) +{ + uint32 hist2[B_LEN]; + int first=0, last=0; + register Colorbox *new; + register uint32 *iptr, *histp; + register int i, j; + register int ir,ig,ib; + register uint32 sum, sum1, sum2; + enum { RED, GREEN, BLUE } axis; + + /* + * See which axis is the largest, do a histogram along that + * axis. Split at median point. Contract both new boxes to + * fit points and return + */ + i = ptr->rmax - ptr->rmin; + if (i >= ptr->gmax - ptr->gmin && i >= ptr->bmax - ptr->bmin) + axis = RED; + else if (ptr->gmax - ptr->gmin >= ptr->bmax - ptr->bmin) + axis = GREEN; + else + axis = BLUE; + /* get histogram along longest axis */ + switch (axis) { + case RED: + histp = &hist2[ptr->rmin]; + for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) { + *histp = 0; + for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) { + iptr = &histogram[ir][ig][ptr->bmin]; + for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) + *histp += *iptr++; + } + histp++; + } + first = ptr->rmin; + last = ptr->rmax; + break; + case GREEN: + histp = &hist2[ptr->gmin]; + for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) { + *histp = 0; + for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) { + iptr = &histogram[ir][ig][ptr->bmin]; + for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) + *histp += *iptr++; + } + histp++; + } + first = ptr->gmin; + last = ptr->gmax; + break; + case BLUE: + histp = &hist2[ptr->bmin]; + for (ib = ptr->bmin; ib <= ptr->bmax; ++ib) { + *histp = 0; + for (ir = ptr->rmin; ir <= ptr->rmax; ++ir) { + iptr = &histogram[ir][ptr->gmin][ib]; + for (ig = ptr->gmin; ig <= ptr->gmax; ++ig) { + *histp += *iptr; + iptr += B_LEN; + } + } + histp++; + } + first = ptr->bmin; + last = ptr->bmax; + break; + } + /* find median point */ + sum2 = ptr->total / 2; + histp = &hist2[first]; + sum = 0; + for (i = first; i <= last && (sum += *histp++) < sum2; ++i) + ; + if (i == first) + i++; + + /* Create new box, re-allocate points */ + new = freeboxes; + freeboxes = new->next; + if (freeboxes) + freeboxes->prev = NULL; + if (usedboxes) + usedboxes->prev = new; + new->next = usedboxes; + usedboxes = new; + + histp = &hist2[first]; + for (sum1 = 0, j = first; j < i; j++) + sum1 += *histp++; + for (sum2 = 0, j = i; j <= last; j++) + sum2 += *histp++; + new->total = sum1; + ptr->total = sum2; + + new->rmin = ptr->rmin; + new->rmax = ptr->rmax; + new->gmin = ptr->gmin; + new->gmax = ptr->gmax; + new->bmin = ptr->bmin; + new->bmax = ptr->bmax; + switch (axis) { + case RED: + new->rmax = i-1; + ptr->rmin = i; + break; + case GREEN: + new->gmax = i-1; + ptr->gmin = i; + break; + case BLUE: + new->bmax = i-1; + ptr->bmin = i; + break; + } + shrinkbox(new); + shrinkbox(ptr); +} + +static void +shrinkbox(Colorbox* box) +{ + register uint32 *histp; + register int ir, ig, ib; + + if (box->rmax > box->rmin) { + for (ir = box->rmin; ir <= box->rmax; ++ir) + for (ig = box->gmin; ig <= box->gmax; ++ig) { + histp = &histogram[ir][ig][box->bmin]; + for (ib = box->bmin; ib <= box->bmax; ++ib) + if (*histp++ != 0) { + box->rmin = ir; + goto have_rmin; + } + } + have_rmin: + if (box->rmax > box->rmin) + for (ir = box->rmax; ir >= box->rmin; --ir) + for (ig = box->gmin; ig <= box->gmax; ++ig) { + histp = &histogram[ir][ig][box->bmin]; + ib = box->bmin; + for (; ib <= box->bmax; ++ib) + if (*histp++ != 0) { + box->rmax = ir; + goto have_rmax; + } + } + } have_rmax: - if (box->gmax > box->gmin) - { - for (ig = box->gmin; ig <= box->gmax; ++ig) - for (ir = box->rmin; ir <= box->rmax; ++ir) - { - histp = &histogram[ir][ig][box->bmin]; - for (ib = box->bmin; ib <= box->bmax; ++ib) - if (*histp++ != 0) - { - box->gmin = ig; - goto have_gmin; - } - } - have_gmin: - if (box->gmax > box->gmin) - for (ig = box->gmax; ig >= box->gmin; --ig) - for (ir = box->rmin; ir <= box->rmax; ++ir) - { - histp = &histogram[ir][ig][box->bmin]; - ib = box->bmin; - for (; ib <= box->bmax; ++ib) - if (*histp++ != 0) - { - box->gmax = ig; - goto have_gmax; - } - } - } + if (box->gmax > box->gmin) { + for (ig = box->gmin; ig <= box->gmax; ++ig) + for (ir = box->rmin; ir <= box->rmax; ++ir) { + histp = &histogram[ir][ig][box->bmin]; + for (ib = box->bmin; ib <= box->bmax; ++ib) + if (*histp++ != 0) { + box->gmin = ig; + goto have_gmin; + } + } + have_gmin: + if (box->gmax > box->gmin) + for (ig = box->gmax; ig >= box->gmin; --ig) + for (ir = box->rmin; ir <= box->rmax; ++ir) { + histp = &histogram[ir][ig][box->bmin]; + ib = box->bmin; + for (; ib <= box->bmax; ++ib) + if (*histp++ != 0) { + box->gmax = ig; + goto have_gmax; + } + } + } have_gmax: - if (box->bmax > box->bmin) - { - for (ib = box->bmin; ib <= box->bmax; ++ib) - for (ir = box->rmin; ir <= box->rmax; ++ir) - { - histp = &histogram[ir][box->gmin][ib]; - for (ig = box->gmin; ig <= box->gmax; ++ig) - { - if (*histp != 0) - { - box->bmin = ib; - goto have_bmin; - } - histp += B_LEN; - } - } - have_bmin: - if (box->bmax > box->bmin) - for (ib = box->bmax; ib >= box->bmin; --ib) - for (ir = box->rmin; ir <= box->rmax; ++ir) - { - histp = &histogram[ir][box->gmin][ib]; - ig = box->gmin; - for (; ig <= box->gmax; ++ig) - { - if (*histp != 0) - { - box->bmax = ib; - goto have_bmax; - } - histp += B_LEN; - } - } - } -have_bmax:; + if (box->bmax > box->bmin) { + for (ib = box->bmin; ib <= box->bmax; ++ib) + for (ir = box->rmin; ir <= box->rmax; ++ir) { + histp = &histogram[ir][box->gmin][ib]; + for (ig = box->gmin; ig <= box->gmax; ++ig) { + if (*histp != 0) { + box->bmin = ib; + goto have_bmin; + } + histp += B_LEN; + } + } + have_bmin: + if (box->bmax > box->bmin) + for (ib = box->bmax; ib >= box->bmin; --ib) + for (ir = box->rmin; ir <= box->rmax; ++ir) { + histp = &histogram[ir][box->gmin][ib]; + ig = box->gmin; + for (; ig <= box->gmax; ++ig) { + if (*histp != 0) { + box->bmax = ib; + goto have_bmax; + } + histp += B_LEN; + } + } + } +have_bmax: + ; } -static C_cell *create_colorcell(int red, int green, int blue) +static C_cell * +create_colorcell(int red, int green, int blue) { - register int ir, ig, ib, i; - register C_cell *ptr; - int mindist, next_n; - register int tmp, dist, n; + register int ir, ig, ib, i; + register C_cell *ptr; + int mindist, next_n; + register int tmp, dist, n; - ir = red >> (COLOR_DEPTH - C_DEPTH); - ig = green >> (COLOR_DEPTH - C_DEPTH); - ib = blue >> (COLOR_DEPTH - C_DEPTH); - ptr = (C_cell *)_TIFFmalloc(sizeof(C_cell)); - *(ColorCells + ir * C_LEN * C_LEN + ig * C_LEN + ib) = ptr; - ptr->num_ents = 0; + ir = red >> (COLOR_DEPTH-C_DEPTH); + ig = green >> (COLOR_DEPTH-C_DEPTH); + ib = blue >> (COLOR_DEPTH-C_DEPTH); + ptr = (C_cell *)_TIFFmalloc(sizeof (C_cell)); + *(ColorCells + ir*C_LEN*C_LEN + ig*C_LEN + ib) = ptr; + ptr->num_ents = 0; - /* - * Step 1: find all colors inside this cell, while we're at - * it, find distance of centermost point to furthest corner - */ - mindist = 99999999; - for (i = 0; i < num_colors; ++i) - { - if (rm[i] >> (COLOR_DEPTH - C_DEPTH) != ir || - gm[i] >> (COLOR_DEPTH - C_DEPTH) != ig || - bm[i] >> (COLOR_DEPTH - C_DEPTH) != ib) - continue; - ptr->entries[ptr->num_ents][0] = i; - ptr->entries[ptr->num_ents][1] = 0; - ++ptr->num_ents; - tmp = rm[i] - red; - if (tmp < (MAX_COLOR / C_LEN / 2)) - tmp = MAX_COLOR / C_LEN - 1 - tmp; - dist = tmp * tmp; - tmp = gm[i] - green; - if (tmp < (MAX_COLOR / C_LEN / 2)) - tmp = MAX_COLOR / C_LEN - 1 - tmp; - dist += tmp * tmp; - tmp = bm[i] - blue; - if (tmp < (MAX_COLOR / C_LEN / 2)) - tmp = MAX_COLOR / C_LEN - 1 - tmp; - dist += tmp * tmp; - if (dist < mindist) - mindist = dist; - } + /* + * Step 1: find all colors inside this cell, while we're at + * it, find distance of centermost point to furthest corner + */ + mindist = 99999999; + for (i = 0; i < num_colors; ++i) { + if (rm[i]>>(COLOR_DEPTH-C_DEPTH) != ir || + gm[i]>>(COLOR_DEPTH-C_DEPTH) != ig || + bm[i]>>(COLOR_DEPTH-C_DEPTH) != ib) + continue; + ptr->entries[ptr->num_ents][0] = i; + ptr->entries[ptr->num_ents][1] = 0; + ++ptr->num_ents; + tmp = rm[i] - red; + if (tmp < (MAX_COLOR/C_LEN/2)) + tmp = MAX_COLOR/C_LEN-1 - tmp; + dist = tmp*tmp; + tmp = gm[i] - green; + if (tmp < (MAX_COLOR/C_LEN/2)) + tmp = MAX_COLOR/C_LEN-1 - tmp; + dist += tmp*tmp; + tmp = bm[i] - blue; + if (tmp < (MAX_COLOR/C_LEN/2)) + tmp = MAX_COLOR/C_LEN-1 - tmp; + dist += tmp*tmp; + if (dist < mindist) + mindist = dist; + } - /* - * Step 3: find all points within that distance to cell. - */ - for (i = 0; i < num_colors; ++i) - { - if (rm[i] >> (COLOR_DEPTH - C_DEPTH) == ir && - gm[i] >> (COLOR_DEPTH - C_DEPTH) == ig && - bm[i] >> (COLOR_DEPTH - C_DEPTH) == ib) - continue; - dist = 0; - if ((tmp = red - rm[i]) > 0 || - (tmp = rm[i] - (red + MAX_COLOR / C_LEN - 1)) > 0) - dist += tmp * tmp; - if ((tmp = green - gm[i]) > 0 || - (tmp = gm[i] - (green + MAX_COLOR / C_LEN - 1)) > 0) - dist += tmp * tmp; - if ((tmp = blue - bm[i]) > 0 || - (tmp = bm[i] - (blue + MAX_COLOR / C_LEN - 1)) > 0) - dist += tmp * tmp; - if (dist < mindist) - { - ptr->entries[ptr->num_ents][0] = i; - ptr->entries[ptr->num_ents][1] = dist; - ++ptr->num_ents; - } - } + /* + * Step 3: find all points within that distance to cell. + */ + for (i = 0; i < num_colors; ++i) { + if (rm[i] >> (COLOR_DEPTH-C_DEPTH) == ir && + gm[i] >> (COLOR_DEPTH-C_DEPTH) == ig && + bm[i] >> (COLOR_DEPTH-C_DEPTH) == ib) + continue; + dist = 0; + if ((tmp = red - rm[i]) > 0 || + (tmp = rm[i] - (red + MAX_COLOR/C_LEN-1)) > 0 ) + dist += tmp*tmp; + if ((tmp = green - gm[i]) > 0 || + (tmp = gm[i] - (green + MAX_COLOR/C_LEN-1)) > 0 ) + dist += tmp*tmp; + if ((tmp = blue - bm[i]) > 0 || + (tmp = bm[i] - (blue + MAX_COLOR/C_LEN-1)) > 0 ) + dist += tmp*tmp; + if (dist < mindist) { + ptr->entries[ptr->num_ents][0] = i; + ptr->entries[ptr->num_ents][1] = dist; + ++ptr->num_ents; + } + } - /* - * Sort color cells by distance, use cheap exchange sort - */ - for (n = ptr->num_ents - 1; n > 0; n = next_n) - { - next_n = 0; - for (i = 0; i < n; ++i) - if (ptr->entries[i][1] > ptr->entries[i + 1][1]) - { - tmp = ptr->entries[i][0]; - ptr->entries[i][0] = ptr->entries[i + 1][0]; - ptr->entries[i + 1][0] = tmp; - tmp = ptr->entries[i][1]; - ptr->entries[i][1] = ptr->entries[i + 1][1]; - ptr->entries[i + 1][1] = tmp; - next_n = i; - } - } - return (ptr); + /* + * Sort color cells by distance, use cheap exchange sort + */ + for (n = ptr->num_ents - 1; n > 0; n = next_n) { + next_n = 0; + for (i = 0; i < n; ++i) + if (ptr->entries[i][1] > ptr->entries[i+1][1]) { + tmp = ptr->entries[i][0]; + ptr->entries[i][0] = ptr->entries[i+1][0]; + ptr->entries[i+1][0] = tmp; + tmp = ptr->entries[i][1]; + ptr->entries[i][1] = ptr->entries[i+1][1]; + ptr->entries[i+1][1] = tmp; + next_n = i; + } + } + return (ptr); } -static void map_colortable(void) +static void +map_colortable(void) { - register uint32_t *histp = &histogram[0][0][0]; - register C_cell *cell; - register int j, tmp, d2, dist; - int ir, ig, ib, i; + register uint32 *histp = &histogram[0][0][0]; + register C_cell *cell; + register int j, tmp, d2, dist; + int ir, ig, ib, i; - for (ir = 0; ir < B_LEN; ++ir) - for (ig = 0; ig < B_LEN; ++ig) - for (ib = 0; ib < B_LEN; ++ib, histp++) - { - if (*histp == 0) - { - *histp = -1; - continue; - } - cell = *(ColorCells + - (((ir >> (B_DEPTH - C_DEPTH)) << C_DEPTH * 2) + - ((ig >> (B_DEPTH - C_DEPTH)) << C_DEPTH) + - (ib >> (B_DEPTH - C_DEPTH)))); - if (cell == NULL) - cell = - create_colorcell(ir << COLOR_SHIFT, ig << COLOR_SHIFT, - ib << COLOR_SHIFT); - dist = 9999999; - for (i = 0; i < cell->num_ents && dist > cell->entries[i][1]; - ++i) - { - j = cell->entries[i][0]; - d2 = rm[j] - (ir << COLOR_SHIFT); - d2 *= d2; - tmp = gm[j] - (ig << COLOR_SHIFT); - d2 += tmp * tmp; - tmp = bm[j] - (ib << COLOR_SHIFT); - d2 += tmp * tmp; - if (d2 < dist) - { - dist = d2; - *histp = j; - } - } - } + for (ir = 0; ir < B_LEN; ++ir) + for (ig = 0; ig < B_LEN; ++ig) + for (ib = 0; ib < B_LEN; ++ib, histp++) { + if (*histp == 0) { + *histp = -1; + continue; + } + cell = *(ColorCells + + (((ir>>(B_DEPTH-C_DEPTH)) << C_DEPTH*2) + + ((ig>>(B_DEPTH-C_DEPTH)) << C_DEPTH) + + (ib>>(B_DEPTH-C_DEPTH)))); + if (cell == NULL ) + cell = create_colorcell( + ir << COLOR_SHIFT, + ig << COLOR_SHIFT, + ib << COLOR_SHIFT); + dist = 9999999; + for (i = 0; i < cell->num_ents && + dist > cell->entries[i][1]; ++i) { + j = cell->entries[i][0]; + d2 = rm[j] - (ir << COLOR_SHIFT); + d2 *= d2; + tmp = gm[j] - (ig << COLOR_SHIFT); + d2 += tmp*tmp; + tmp = bm[j] - (ib << COLOR_SHIFT); + d2 += tmp*tmp; + if (d2 < dist) { + dist = d2; + *histp = j; + } + } + } } /* @@ -831,173 +764,162 @@ static void map_colortable(void) * closest to it. Color values are rounded to the nearest color * table entry. */ -static void quant(TIFF *in, TIFF *out) +static void +quant(TIFF* in, TIFF* out) { - unsigned char *outline, *inputline; - register unsigned char *outptr, *inptr; - register uint32_t i, j; - register int red, green, blue; + unsigned char *outline, *inputline; + register unsigned char *outptr, *inptr; + register uint32 i, j; + register int red, green, blue; - inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); - outline = (unsigned char *)_TIFFmalloc(imagewidth); - for (i = 0; i < imagelength; i++) - { - if (TIFFReadScanline(in, inputline, i, 0) <= 0) - break; - inptr = inputline; - outptr = outline; - for (j = 0; j < imagewidth; j++) - { - red = *inptr++ >> COLOR_SHIFT; - green = *inptr++ >> COLOR_SHIFT; - blue = *inptr++ >> COLOR_SHIFT; - *outptr++ = (unsigned char)histogram[red][green][blue]; - } - if (TIFFWriteScanline(out, outline, i, 0) < 0) - break; - } - _TIFFfree(inputline); - _TIFFfree(outline); + inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); + outline = (unsigned char *)_TIFFmalloc(imagewidth); + for (i = 0; i < imagelength; i++) { + if (TIFFReadScanline(in, inputline, i, 0) <= 0) + break; + inptr = inputline; + outptr = outline; + for (j = 0; j < imagewidth; j++) { + red = *inptr++ >> COLOR_SHIFT; + green = *inptr++ >> COLOR_SHIFT; + blue = *inptr++ >> COLOR_SHIFT; + *outptr++ = (unsigned char)histogram[red][green][blue]; + } + if (TIFFWriteScanline(out, outline, i, 0) < 0) + break; + } + _TIFFfree(inputline); + _TIFFfree(outline); } -#define SWAP(type, a, b) \ - { \ - type p; \ - p = a; \ - a = b; \ - b = p; \ - } +#define SWAP(type,a,b) { type p; p = a; a = b; b = p; } -#define GetInputLine(tif, row, bad) \ - do \ - { \ - if (TIFFReadScanline(tif, inputline, row, 0) <= 0) \ - bad; \ - inptr = inputline; \ - nextptr = nextline; \ - for (j = 0; j < imagewidth; ++j) \ - { \ - *nextptr++ = *inptr++; \ - *nextptr++ = *inptr++; \ - *nextptr++ = *inptr++; \ - } \ - } while (0); -#define GetComponent(raw, cshift, c) \ - do \ - { \ - cshift = raw; \ - if (cshift < 0) \ - cshift = 0; \ - else if (cshift >= MAX_COLOR) \ - cshift = MAX_COLOR - 1; \ - c = cshift; \ - cshift >>= COLOR_SHIFT; \ - } while (0); +#define GetInputLine(tif, row, bad) \ + do { \ + if (TIFFReadScanline(tif, inputline, row, 0) <= 0) \ + bad; \ + inptr = inputline; \ + nextptr = nextline; \ + for (j = 0; j < imagewidth; ++j) { \ + *nextptr++ = *inptr++; \ + *nextptr++ = *inptr++; \ + *nextptr++ = *inptr++; \ + } \ + } while (0); +#define GetComponent(raw, cshift, c) \ + do { \ + cshift = raw; \ + if (cshift < 0) \ + cshift = 0; \ + else if (cshift >= MAX_COLOR) \ + cshift = MAX_COLOR-1; \ + c = cshift; \ + cshift >>= COLOR_SHIFT; \ + } while (0); -static void quant_fsdither(TIFF *in, TIFF *out) +static void +quant_fsdither(TIFF* in, TIFF* out) { - unsigned char *outline, *inputline, *inptr; - short *thisline, *nextline; - register unsigned char *outptr; - register short *thisptr, *nextptr; - register uint32_t i, j; - uint32_t imax, jmax; - int lastline, lastpixel; + unsigned char *outline, *inputline, *inptr; + short *thisline, *nextline; + register unsigned char *outptr; + register short *thisptr, *nextptr; + register uint32 i, j; + uint32 imax, jmax; + int lastline, lastpixel; - imax = imagelength - 1; - jmax = imagewidth - 1; - inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); - thisline = (short *)_TIFFmalloc(imagewidth * 3 * sizeof(short)); - nextline = (short *)_TIFFmalloc(imagewidth * 3 * sizeof(short)); - outline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(out)); + imax = imagelength - 1; + jmax = imagewidth - 1; + inputline = (unsigned char *)_TIFFmalloc(TIFFScanlineSize(in)); + thisline = (short *)_TIFFmalloc(imagewidth * 3 * sizeof (short)); + nextline = (short *)_TIFFmalloc(imagewidth * 3 * sizeof (short)); + outline = (unsigned char *) _TIFFmalloc(TIFFScanlineSize(out)); - GetInputLine(in, 0, goto bad); /* get first line */ - for (i = 1; i <= imagelength; ++i) - { - SWAP(short *, thisline, nextline); - lastline = (i >= imax); - if (i <= imax) - GetInputLine(in, i, break); - thisptr = thisline; - nextptr = nextline; - outptr = outline; - for (j = 0; j < imagewidth; ++j) - { - int red, green, blue; - register int oval, r2, g2, b2; + GetInputLine(in, 0, goto bad); /* get first line */ + for (i = 1; i <= imagelength; ++i) { + SWAP(short *, thisline, nextline); + lastline = (i >= imax); + if (i <= imax) + GetInputLine(in, i, break); + thisptr = thisline; + nextptr = nextline; + outptr = outline; + for (j = 0; j < imagewidth; ++j) { + int red, green, blue; + register int oval, r2, g2, b2; - lastpixel = (j == jmax); - GetComponent(*thisptr++, r2, red); - GetComponent(*thisptr++, g2, green); - GetComponent(*thisptr++, b2, blue); - oval = histogram[r2][g2][b2]; - if (oval == -1) - { - int ci; - register int cj, tmp, d2, dist; - register C_cell *cell; + lastpixel = (j == jmax); + GetComponent(*thisptr++, r2, red); + GetComponent(*thisptr++, g2, green); + GetComponent(*thisptr++, b2, blue); + oval = histogram[r2][g2][b2]; + if (oval == -1) { + int ci; + register int cj, tmp, d2, dist; + register C_cell *cell; - cell = *(ColorCells + - (((r2 >> (B_DEPTH - C_DEPTH)) << C_DEPTH * 2) + - ((g2 >> (B_DEPTH - C_DEPTH)) << C_DEPTH) + - (b2 >> (B_DEPTH - C_DEPTH)))); - if (cell == NULL) - cell = create_colorcell(red, green, blue); - dist = 9999999; - for (ci = 0; ci < cell->num_ents && dist > cell->entries[ci][1]; - ++ci) - { - cj = cell->entries[ci][0]; - d2 = (rm[cj] >> COLOR_SHIFT) - r2; - d2 *= d2; - tmp = (gm[cj] >> COLOR_SHIFT) - g2; - d2 += tmp * tmp; - tmp = (bm[cj] >> COLOR_SHIFT) - b2; - d2 += tmp * tmp; - if (d2 < dist) - { - dist = d2; - oval = cj; - } - } - histogram[r2][g2][b2] = oval; - } - *outptr++ = oval; - red -= rm[oval]; - green -= gm[oval]; - blue -= bm[oval]; - if (!lastpixel) - { - thisptr[0] += blue * 7 / 16; - thisptr[1] += green * 7 / 16; - thisptr[2] += red * 7 / 16; - } - if (!lastline) - { - if (j != 0) - { - nextptr[-3] += blue * 3 / 16; - nextptr[-2] += green * 3 / 16; - nextptr[-1] += red * 3 / 16; - } - nextptr[0] += blue * 5 / 16; - nextptr[1] += green * 5 / 16; - nextptr[2] += red * 5 / 16; - if (!lastpixel) - { - nextptr[3] += blue / 16; - nextptr[4] += green / 16; - nextptr[5] += red / 16; - } - nextptr += 3; - } - } - if (TIFFWriteScanline(out, outline, i - 1, 0) < 0) - break; - } + cell = *(ColorCells + + (((r2>>(B_DEPTH-C_DEPTH)) << C_DEPTH*2) + + ((g2>>(B_DEPTH-C_DEPTH)) << C_DEPTH ) + + (b2>>(B_DEPTH-C_DEPTH)))); + if (cell == NULL) + cell = create_colorcell(red, + green, blue); + dist = 9999999; + for (ci = 0; ci < cell->num_ents && dist > cell->entries[ci][1]; ++ci) { + cj = cell->entries[ci][0]; + d2 = (rm[cj] >> COLOR_SHIFT) - r2; + d2 *= d2; + tmp = (gm[cj] >> COLOR_SHIFT) - g2; + d2 += tmp*tmp; + tmp = (bm[cj] >> COLOR_SHIFT) - b2; + d2 += tmp*tmp; + if (d2 < dist) { + dist = d2; + oval = cj; + } + } + histogram[r2][g2][b2] = oval; + } + *outptr++ = oval; + red -= rm[oval]; + green -= gm[oval]; + blue -= bm[oval]; + if (!lastpixel) { + thisptr[0] += blue * 7 / 16; + thisptr[1] += green * 7 / 16; + thisptr[2] += red * 7 / 16; + } + if (!lastline) { + if (j != 0) { + nextptr[-3] += blue * 3 / 16; + nextptr[-2] += green * 3 / 16; + nextptr[-1] += red * 3 / 16; + } + nextptr[0] += blue * 5 / 16; + nextptr[1] += green * 5 / 16; + nextptr[2] += red * 5 / 16; + if (!lastpixel) { + nextptr[3] += blue / 16; + nextptr[4] += green / 16; + nextptr[5] += red / 16; + } + nextptr += 3; + } + } + if (TIFFWriteScanline(out, outline, i-1, 0) < 0) + break; + } bad: - _TIFFfree(inputline); - _TIFFfree(thisline); - _TIFFfree(nextline); - _TIFFfree(outline); + _TIFFfree(inputline); + _TIFFfree(thisline); + _TIFFfree(nextline); + _TIFFfree(outline); } +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffset.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffset.c index 35f188933..e1f10c4f4 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffset.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffset.c @@ -6,23 +6,23 @@ ****************************************************************************** * Copyright (c) 2000, Frank Warmerdam * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. ****************************************************************************** */ @@ -30,13 +30,13 @@ #include "tif_config.h" #include -#include #include +#include #include "tiffio.h" #ifdef NEED_LIBPORT -#include "libport.h" +# include "libport.h" #endif #ifndef EXIT_SUCCESS @@ -46,147 +46,96 @@ #define EXIT_FAILURE 1 #endif -/* - Visual Studio does not support _fseeki64 and _ftelli64 until the 2005 release. - Without these interfaces, files over 2GB in size are not supported for - Windows. - For MinGW, __MSVCRT_VERSION__ must be at least 0x800 to expose these - interfaces. The MinGW compiler must support the requested version. MinGW - does not distribute the CRT (it is supplied by Microsoft) so the correct CRT - must be available on the target computer in order for the program to run. -*/ -#if defined(__WIN32__) && !(defined(_MSC_VER) && _MSC_VER < 1400) && \ - !(defined(__MSVCRT_VERSION__) && __MSVCRT_VERSION__ < 0x800) -#define TIFFfseek(stream, offset, whence) \ - _fseeki64(stream, /* __int64 */ offset, whence) -#define TIFFftell(stream) /* __int64 */ _ftelli64(stream) -#pragma message("...... _fseeki64 defined ....") -#else -#define TIFFfseek(stream, offset, whence) fseek(stream, offset, whence) -#define TIFFftell(stream) ftell(stream) -#endif +static const char* usageMsg[] = { +"usage: tiffset [options] filename", +"where options are:", +" -s [count] ... set the tag value", +" -u to unset the tag", +" -d set the directory", +" -sd set the subdirectory", +" -sf read the tag value from file (for ASCII tags only)", +" -h this help screen", +NULL +}; -#define DEFAULT_MAX_MALLOC (256 * 1024 * 1024) - -/* malloc size limit (in bytes) - * disabled when set to 0 */ -static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC; - -static const char usageMsg[] = - "Set the value of a TIFF header to a specified value\n\n" - "usage: tiffset [options] filename\n" - "where options are:\n" - " -s [count] ... set the tag value\n" - " -u to unset the tag\n" - " -d set the directory\n" - " -sd set the subdirectory\n" - " -sf read the tag value from file (for ASCII tags " - "only)\n" - " -m set maximum memory allocation size (MiB). 0 to disable " - "limit. Must be first parameter.\n" - " -h this help screen\n" - " The options can be repeated and are processed sequentially.\n"; - -static void usage(int code) +static void +usage(int code) { - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; + int i; + FILE * out = (code == EXIT_SUCCESS) ? stdout : stderr; - fprintf(out, "%s\n\n", TIFFGetVersion()); - fprintf(out, "%s", usageMsg); - exit(code); + fprintf(out, "%s\n\n", TIFFGetVersion()); + for (i = 0; usageMsg[i]; i++) + fprintf(out, "%s\n", usageMsg[i]); + exit(code); } -static const TIFFField *GetField(TIFF *tiff, const char *tagname) +static const TIFFField * +GetField(TIFF *tiff, const char *tagname) { const TIFFField *fip; - if (atoi(tagname) > 0) + if( atoi(tagname) > 0 ) fip = TIFFFieldWithTag(tiff, (ttag_t)atoi(tagname)); else fip = TIFFFieldWithName(tiff, tagname); - if (!fip) - { - fprintf(stderr, "Field name \"%s\" is not recognised.\n", tagname); + if (!fip) { + fprintf( stderr, "Field name \"%s\" is not recognised.\n", tagname ); return (TIFFField *)NULL; } return fip; } -/** - * This custom malloc function enforce a maximum allocation size - */ -static void *limitMalloc(tmsize_t s) -{ - if (maxMalloc && (s > maxMalloc)) - { - fprintf(stderr, - "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT - " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", - s, maxMalloc); - fprintf(stderr, " use -m option to change limit.\n"); - return NULL; - } - return _TIFFmalloc(s); -} - -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { TIFF *tiff; - int arg_index; + int arg_index; if (argc < 2) usage(EXIT_FAILURE); - tiff = TIFFOpen(argv[argc - 1], "r+"); + tiff = TIFFOpen(argv[argc-1], "r+"); if (tiff == NULL) return EXIT_FAILURE; - for (arg_index = 1; arg_index < argc - 1; arg_index++) - { - if (strcmp(argv[arg_index], "-d") == 0 && arg_index < argc - 2) - { - arg_index++; - if (TIFFSetDirectory(tiff, atoi(argv[arg_index])) != 1) + for( arg_index = 1; arg_index < argc-1; arg_index++ ) { + if (strcmp(argv[arg_index],"-d") == 0 && arg_index < argc-2) { + arg_index++; + if( TIFFSetDirectory(tiff, atoi(argv[arg_index]) ) != 1 ) { - fprintf(stderr, "Failed to set directory=%s\n", - argv[arg_index]); - return EXIT_FAILURE; + fprintf( stderr, "Failed to set directory=%s\n", argv[arg_index] ); + return EXIT_FAILURE; } - arg_index++; - } - if (strcmp(argv[arg_index], "-sd") == 0 && arg_index < argc - 2) - { - arg_index++; - if (TIFFSetSubDirectory(tiff, atoi(argv[arg_index])) != 1) + arg_index++; + } + if (strcmp(argv[arg_index],"-sd") == 0 && arg_index < argc-2) { + arg_index++; + if( TIFFSetSubDirectory(tiff, atoi(argv[arg_index]) ) != 1 ) { - fprintf(stderr, "Failed to set sub directory=%s\n", - argv[arg_index]); - return EXIT_FAILURE; + fprintf( stderr, "Failed to set sub directory=%s\n", argv[arg_index] ); + return EXIT_FAILURE; } - arg_index++; - } - /* Add unset option to tiffset -- Zach Baker (niquil@niquil.net) - * 11/14/2012 */ - if (strcmp(argv[arg_index], "-u") == 0 && arg_index < argc - 2) - { + arg_index++; + } + /* Add unset option to tiffset -- Zach Baker (niquil@niquil.net) 11/14/2012 */ + if (strcmp(argv[arg_index],"-u") == 0 && arg_index < argc-2) { const TIFFField *fip; const char *tagname; arg_index++; tagname = argv[arg_index]; fip = GetField(tiff, tagname); if (!fip) - return EXIT_FAILURE; + return EXIT_FAILURE; if (TIFFUnsetField(tiff, TIFFFieldTag(fip)) != 1) { - fprintf(stderr, "Failed to unset %s\n", TIFFFieldName(fip)); + fprintf(stderr, "Failed to unset %s\n", TIFFFieldName(fip)); } arg_index++; - } - else if (strcmp(argv[arg_index], "-s") == 0 && arg_index < argc - 3) - { + } else if (strcmp(argv[arg_index],"-s") == 0 && arg_index < argc-3) { const TIFFField *fip; const char *tagname; @@ -198,238 +147,202 @@ int main(int argc, char *argv[]) return 3; arg_index++; - if (TIFFFieldDataType(fip) == TIFF_ASCII) - { - if (TIFFFieldPassCount(fip)) - { + if (TIFFFieldDataType(fip) == TIFF_ASCII) { + if(TIFFFieldPassCount( fip )) { size_t len; len = strlen(argv[arg_index]) + 1; - if (len > UINT16_MAX || - TIFFSetField(tiff, TIFFFieldTag(fip), (uint16_t)len, - argv[arg_index]) != 1) - fprintf(stderr, "Failed to set %s=%s\n", - TIFFFieldName(fip), argv[arg_index]); - } - else - { + if (len > 0xffff || TIFFSetField(tiff, TIFFFieldTag(fip), + (uint16)len, argv[arg_index]) != 1) + fprintf( stderr, "Failed to set %s=%s\n", + TIFFFieldName(fip), argv[arg_index] ); + } else { if (TIFFSetField(tiff, TIFFFieldTag(fip), - argv[arg_index]) != 1) - fprintf(stderr, "Failed to set %s=%s\n", - TIFFFieldName(fip), argv[arg_index]); + argv[arg_index]) != 1) + fprintf( stderr, "Failed to set %s=%s\n", + TIFFFieldName(fip), argv[arg_index] ); } - } - else if (TIFFFieldWriteCount(fip) > 0 || - TIFFFieldWriteCount(fip) == TIFF_VARIABLE) - { - int ret = 1; - short wc; + } else if (TIFFFieldWriteCount(fip) > 0 + || TIFFFieldWriteCount(fip) == TIFF_VARIABLE) { + int ret = 1; + short wc; if (TIFFFieldWriteCount(fip) == TIFF_VARIABLE) - wc = atoi(argv[arg_index++]); + wc = atoi(argv[arg_index++]); else - wc = TIFFFieldWriteCount(fip); + wc = TIFFFieldWriteCount(fip); - if (argc - arg_index < wc) - { - fprintf(stderr, - "Number of tag values is not enough. " - "Expected %d values for %s tag, got %d\n", - wc, TIFFFieldName(fip), argc - arg_index); + if (argc - arg_index < wc) { + fprintf( stderr, + "Number of tag values is not enough. " + "Expected %d values for %s tag, got %d\n", + wc, TIFFFieldName(fip), argc - arg_index); return EXIT_FAILURE; } + + if (wc > 1 || TIFFFieldWriteCount(fip) == TIFF_VARIABLE) { + int i, size; + void *array; - if (wc > 1 || TIFFFieldWriteCount(fip) == TIFF_VARIABLE) - { - int i, size; - void *array; + switch (TIFFFieldDataType(fip)) { + /* + * XXX: We can't use TIFFDataWidth() + * to determine the space needed to store + * the value. For TIFF_RATIONAL values + * TIFFDataWidth() returns 8, but we use 4-byte + * float to represent rationals. + */ + case TIFF_BYTE: + case TIFF_ASCII: + case TIFF_SBYTE: + case TIFF_UNDEFINED: + default: + size = 1; + break; - switch (TIFFFieldDataType(fip)) - { - /* - * XXX: We can't use TIFFDataWidth() - * to determine the space needed to store - * the value. For TIFF_RATIONAL values - * TIFFDataWidth() returns 8, but we use 4-byte - * float to represent rationals. - */ - case TIFF_BYTE: - case TIFF_ASCII: - case TIFF_SBYTE: - case TIFF_UNDEFINED: - default: - size = 1; - break; + case TIFF_SHORT: + case TIFF_SSHORT: + size = 2; + break; - case TIFF_SHORT: - case TIFF_SSHORT: - size = 2; - break; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_FLOAT: + case TIFF_IFD: + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + size = 4; + break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_FLOAT: - case TIFF_IFD: - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - size = 4; - break; - - case TIFF_LONG8: - case TIFF_SLONG8: - case TIFF_IFD8: - case TIFF_DOUBLE: - size = 8; - break; - } - - array = limitMalloc((tmsize_t)wc * size); - if (!array) - { - fprintf(stderr, "No space for %s tag\n", tagname); - return EXIT_FAILURE; - } - - switch (TIFFFieldDataType(fip)) - { - case TIFF_BYTE: - for (i = 0; i < wc; i++) - ((uint8_t *)array)[i] = - atoi(argv[arg_index + i]); - break; - case TIFF_SHORT: - for (i = 0; i < wc; i++) - ((uint16_t *)array)[i] = - atoi(argv[arg_index + i]); - break; - case TIFF_SBYTE: - for (i = 0; i < wc; i++) - ((int8_t *)array)[i] = - atoi(argv[arg_index + i]); - break; - case TIFF_SSHORT: - for (i = 0; i < wc; i++) - ((int16_t *)array)[i] = - atoi(argv[arg_index + i]); - break; - case TIFF_LONG: - for (i = 0; i < wc; i++) - ((uint32_t *)array)[i] = - atol(argv[arg_index + i]); - break; - case TIFF_SLONG: - case TIFF_IFD: - for (i = 0; i < wc; i++) - ((int32_t *)array)[i] = - atol(argv[arg_index + i]); - break; - case TIFF_LONG8: - for (i = 0; i < wc; i++) - ((uint64_t *)array)[i] = strtoll( - argv[arg_index + i], (char **)NULL, 10); - break; - case TIFF_SLONG8: - case TIFF_IFD8: - for (i = 0; i < wc; i++) - ((int64_t *)array)[i] = strtoll( - argv[arg_index + i], (char **)NULL, 10); - break; - case TIFF_DOUBLE: - for (i = 0; i < wc; i++) - ((double *)array)[i] = - atof(argv[arg_index + i]); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - for (i = 0; i < wc; i++) - ((float *)array)[i] = - (float)atof(argv[arg_index + i]); - break; - default: - break; - } - - if (TIFFFieldPassCount(fip)) - { - ret = TIFFSetField(tiff, TIFFFieldTag(fip), wc, array); - } - else if (TIFFFieldTag(fip) == TIFFTAG_PAGENUMBER || - TIFFFieldTag(fip) == TIFFTAG_HALFTONEHINTS || - TIFFFieldTag(fip) == TIFFTAG_YCBCRSUBSAMPLING || - TIFFFieldTag(fip) == TIFFTAG_DOTRANGE) - { - if (TIFFFieldDataType(fip) == TIFF_BYTE) - { - ret = TIFFSetField(tiff, TIFFFieldTag(fip), - ((uint8_t *)array)[0], - ((uint8_t *)array)[1]); + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_IFD8: + case TIFF_DOUBLE: + size = 8; + break; } - else if (TIFFFieldDataType(fip) == TIFF_SHORT) - { - ret = TIFFSetField(tiff, TIFFFieldTag(fip), - ((uint16_t *)array)[0], - ((uint16_t *)array)[1]); - } - } - else - { - ret = TIFFSetField(tiff, TIFFFieldTag(fip), array); - } - _TIFFfree(array); - } - else - { - switch (TIFFFieldDataType(fip)) - { - case TIFF_BYTE: - case TIFF_SHORT: - case TIFF_SBYTE: - case TIFF_SSHORT: - ret = TIFFSetField(tiff, TIFFFieldTag(fip), - atoi(argv[arg_index++])); - break; - case TIFF_LONG: - case TIFF_SLONG: - case TIFF_IFD: - ret = TIFFSetField(tiff, TIFFFieldTag(fip), - atol(argv[arg_index++])); - break; - case TIFF_LONG8: - case TIFF_SLONG8: - case TIFF_IFD8: - ret = TIFFSetField( - tiff, TIFFFieldTag(fip), - strtoll(argv[arg_index++], (char **)NULL, 10)); - break; - case TIFF_DOUBLE: - ret = TIFFSetField(tiff, TIFFFieldTag(fip), - atof(argv[arg_index++])); - break; - case TIFF_RATIONAL: - case TIFF_SRATIONAL: - case TIFF_FLOAT: - ret = TIFFSetField(tiff, TIFFFieldTag(fip), - (float)atof(argv[arg_index++])); - break; - default: - break; - } + array = _TIFFmalloc(wc * size); + if (!array) { + fprintf(stderr, "No space for %s tag\n", + tagname); + return EXIT_FAILURE; + } + + switch (TIFFFieldDataType(fip)) { + case TIFF_BYTE: + for (i = 0; i < wc; i++) + ((uint8 *)array)[i] = atoi(argv[arg_index+i]); + break; + case TIFF_SHORT: + for (i = 0; i < wc; i++) + ((uint16 *)array)[i] = atoi(argv[arg_index+i]); + break; + case TIFF_SBYTE: + for (i = 0; i < wc; i++) + ((int8 *)array)[i] = atoi(argv[arg_index+i]); + break; + case TIFF_SSHORT: + for (i = 0; i < wc; i++) + ((int16 *)array)[i] = atoi(argv[arg_index+i]); + break; + case TIFF_LONG: + for (i = 0; i < wc; i++) + ((uint32 *)array)[i] = atol(argv[arg_index+i]); + break; + case TIFF_SLONG: + case TIFF_IFD: + for (i = 0; i < wc; i++) + ((int32 *)array)[i] = atol(argv[arg_index+i]); + break; + case TIFF_LONG8: + for (i = 0; i < wc; i++) + ((uint64 *)array)[i] = strtoll(argv[arg_index+i], (char **)NULL, 10); + break; + case TIFF_SLONG8: + case TIFF_IFD8: + for (i = 0; i < wc; i++) + ((int64 *)array)[i] = strtoll(argv[arg_index+i], (char **)NULL, 10); + break; + case TIFF_DOUBLE: + for (i = 0; i < wc; i++) + ((double *)array)[i] = atof(argv[arg_index+i]); + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + for (i = 0; i < wc; i++) + ((float *)array)[i] = (float)atof(argv[arg_index+i]); + break; + default: + break; + } + + if (TIFFFieldPassCount(fip)) { + ret = TIFFSetField(tiff, TIFFFieldTag(fip), + wc, array); + } else if (TIFFFieldTag(fip) == TIFFTAG_PAGENUMBER + || TIFFFieldTag(fip) == TIFFTAG_HALFTONEHINTS + || TIFFFieldTag(fip) == TIFFTAG_YCBCRSUBSAMPLING + || TIFFFieldTag(fip) == TIFFTAG_DOTRANGE) { + if (TIFFFieldDataType(fip) == TIFF_BYTE) { + ret = TIFFSetField(tiff, TIFFFieldTag(fip), + ((uint8 *)array)[0], ((uint8 *)array)[1]); + } else if (TIFFFieldDataType(fip) == TIFF_SHORT) { + ret = TIFFSetField(tiff, TIFFFieldTag(fip), + ((uint16 *)array)[0], ((uint16 *)array)[1]); + } + } else { + ret = TIFFSetField(tiff, TIFFFieldTag(fip), + array); + } + + _TIFFfree(array); + } else { + switch (TIFFFieldDataType(fip)) { + case TIFF_BYTE: + case TIFF_SHORT: + case TIFF_SBYTE: + case TIFF_SSHORT: + ret = TIFFSetField(tiff, TIFFFieldTag(fip), + atoi(argv[arg_index++])); + break; + case TIFF_LONG: + case TIFF_SLONG: + case TIFF_IFD: + ret = TIFFSetField(tiff, TIFFFieldTag(fip), + atol(argv[arg_index++])); + break; + case TIFF_LONG8: + case TIFF_SLONG8: + case TIFF_IFD8: + ret = TIFFSetField(tiff, TIFFFieldTag(fip), + strtoll(argv[arg_index++], (char **)NULL, 10)); + break; + case TIFF_DOUBLE: + ret = TIFFSetField(tiff, TIFFFieldTag(fip), + atof(argv[arg_index++])); + break; + case TIFF_RATIONAL: + case TIFF_SRATIONAL: + case TIFF_FLOAT: + ret = TIFFSetField(tiff, TIFFFieldTag(fip), + (float)atof(argv[arg_index++])); + break; + default: + break; + } } if (ret != 1) fprintf(stderr, "Failed to set %s\n", TIFFFieldName(fip)); arg_index += wc; } - } - else if (strcmp(argv[arg_index], "-sf") == 0 && arg_index < argc - 3) - { - FILE *fp; + } else if (strcmp(argv[arg_index],"-sf") == 0 && arg_index < argc-3) { + FILE *fp; const TIFFField *fip; - char *text; - size_t len; + char *text; + size_t len; int ret; - int64_t fsize; arg_index++; fip = GetField(tiff, argv[arg_index]); @@ -437,87 +350,48 @@ int main(int argc, char *argv[]) if (!fip) return EXIT_FAILURE; - if (TIFFFieldDataType(fip) != TIFF_ASCII) - { - fprintf(stderr, - "Only ASCII tags can be set from file. " - "%s is not ASCII tag.\n", - TIFFFieldName(fip)); + if (TIFFFieldDataType(fip) != TIFF_ASCII) { + fprintf( stderr, + "Only ASCII tags can be set from file. " + "%s is not ASCII tag.\n", TIFFFieldName(fip) ); return EXIT_FAILURE; } arg_index++; - fp = fopen(argv[arg_index], "rt"); - if (fp == NULL) - { - perror(argv[arg_index]); + fp = fopen( argv[arg_index], "rt" ); + if(fp == NULL) { + perror( argv[arg_index] ); continue; } - /* Get file size and enlarge it for some space in buffer. - * Maximum ASCII tag size is limited by uint32_t count. - */ - TIFFfseek(fp, 0L, SEEK_END); - fsize = TIFFftell(fp) + 1; - rewind(fp); - - if (fsize > 0xFFFFFFFFUL || /* MAXUINT32 = 0xFFFFFFFFUL */ - fsize > - TIFF_TMSIZE_T_MAX || /* for x32 tmsize_t is only int32_t */ - fsize <= 0) - { - fprintf( - stderr, - "Contents of %s is too large to store in an ASCII tag.\n", - argv[arg_index]); - fclose(fp); + text = (char *) malloc(1000000); + if(text == NULL) { + fprintf( stderr, + "Memory allocation error\n"); + fclose( fp ); continue; } - text = (char *)limitMalloc((tmsize_t)fsize); - if (text == NULL) - { - fprintf(stderr, "Memory allocation error\n"); - fclose(fp); - continue; - } - len = fread(text, 1, (size_t)(fsize - 1), fp); + len = fread( text, 1, 999999, fp ); text[len] = '\0'; - fclose(fp); + fclose( fp ); - if (TIFFFieldPassCount(fip)) - { - ret = - TIFFSetField(tiff, TIFFFieldTag(fip), (uint16_t)len, text); + if(TIFFFieldPassCount( fip )) { + ret = TIFFSetField( tiff, TIFFFieldTag(fip), (uint16)len, text ); + } else { + ret = TIFFSetField( tiff, TIFFFieldTag(fip), text ); } - else - { - ret = TIFFSetField(tiff, TIFFFieldTag(fip), text); - } - if (!ret) - { - fprintf(stderr, "Failed to set %s from file %s\n", + if(!ret) { + fprintf(stderr, "Failed to set %s from file %s\n", TIFFFieldName(fip), argv[arg_index]); } - _TIFFfree(text); + _TIFFfree( text ); arg_index++; - } - else if (strcmp(argv[arg_index], "-m") == 0) - { - arg_index++; - maxMalloc = (tmsize_t)strtoul(argv[arg_index], NULL, 0) << 20; - } - else if (strcmp(argv[arg_index], "-h") == 0 || - strcmp(argv[arg_index], "--help") == 0) - { + } else if (strcmp(argv[arg_index],"-h") == 0 || strcmp(argv[arg_index],"--help") == 0) { usage(EXIT_SUCCESS); - } - else - { - fprintf(stderr, - "Unrecognised option: %s or too few parameters left " - "for this option.\n", + } else { + fprintf(stderr, "Unrecognised option: %s\n", argv[arg_index]); usage(EXIT_FAILURE); } @@ -527,3 +401,12 @@ int main(int argc, char *argv[]) TIFFClose(tiff); return EXIT_SUCCESS; } + +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/external/libtiff/tools/tiffsplit.c b/thirdparty/SDL2_image/external/libtiff/tools/tiffsplit.c index fcbec1d16..43b6fdc11 100644 --- a/thirdparty/SDL2_image/external/libtiff/tools/tiffsplit.c +++ b/thirdparty/SDL2_image/external/libtiff/tools/tiffsplit.c @@ -2,27 +2,26 @@ * Copyright (c) 1992-1997 Sam Leffler * Copyright (c) 1992-1997 Silicon Graphics, Inc. * - * Permission to use, copy, modify, distribute, and sell this software and + * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, provided * that (i) the above copyright notices and this permission notice appear in * all copies of the software and related documentation, and (ii) the names of * Sam Leffler and Silicon Graphics may not be used in any advertising or * publicity relating to the software without the specific, prior written * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ -#include "libport.h" #include "tif_config.h" #include @@ -38,433 +37,274 @@ #define EXIT_FAILURE 1 #endif -#define CopyField(tag, v) \ - if (TIFFGetField(in, tag, &v)) \ - TIFFSetField(out, tag, v) -#define CopyField2(tag, v1, v2) \ - if (TIFFGetField(in, tag, &v1, &v2)) \ - TIFFSetField(out, tag, v1, v2) -#define CopyField3(tag, v1, v2, v3) \ - if (TIFFGetField(in, tag, &v1, &v2, &v3)) \ - TIFFSetField(out, tag, v1, v2, v3) +#ifndef HAVE_GETOPT +extern int getopt(int argc, char * const argv[], const char *optstring); +#endif + +#define CopyField(tag, v) \ + if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v) +#define CopyField2(tag, v1, v2) \ + if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2) +#define CopyField3(tag, v1, v2, v3) \ + if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3) #define PATH_LENGTH 8192 -#define DEFAULT_MAX_MALLOC (256 * 1024 * 1024) - -/* malloc size limit (in bytes) - * disabled when set to 0 */ -static tmsize_t maxMalloc = DEFAULT_MAX_MALLOC; - static const char TIFF_SUFFIX[] = ".tif"; -static char fname[PATH_LENGTH]; +static char fname[PATH_LENGTH]; -static int tiffcp(TIFF *, TIFF *); -static void newfilename(void); -static int cpStrips(TIFF *, TIFF *); -static int cpTiles(TIFF *, TIFF *); +static int tiffcp(TIFF*, TIFF*); +static void newfilename(void); +static int cpStrips(TIFF*, TIFF*); +static int cpTiles(TIFF*, TIFF*); -static void usage(int); - -/** - * This custom malloc function enforce a maximum allocation size - */ -static void *limitMalloc(tmsize_t s) +int +main(int argc, char* argv[]) { - /* tmsize_t is signed and _TIFFmalloc() converts s to size_t. Therefore - * check for negative s. */ - if (maxMalloc && ((s > maxMalloc) || (s < 0))) - { - fprintf(stderr, - "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT - " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", - s, maxMalloc); - fprintf(stderr, " use -M option to change limit.\n"); - return NULL; - } - return _TIFFmalloc(s); + TIFF *in, *out; + + if (argc < 2) { + fprintf(stderr, "%s\n\n", TIFFGetVersion()); + fprintf(stderr, "usage: tiffsplit input.tif [prefix]\n"); + return (EXIT_FAILURE); + } + if (argc > 2) { + strncpy(fname, argv[2], sizeof(fname)); + fname[sizeof(fname) - 1] = '\0'; + } + in = TIFFOpen(argv[1], "r"); + if (in != NULL) { + do { + size_t path_len; + char *path; + + newfilename(); + + path_len = strlen(fname) + sizeof(TIFF_SUFFIX); + path = (char *) _TIFFmalloc(path_len); + strncpy(path, fname, path_len); + path[path_len - 1] = '\0'; + strncat(path, TIFF_SUFFIX, path_len - strlen(path) - 1); + out = TIFFOpen(path, TIFFIsBigEndian(in)?"wb":"wl"); + _TIFFfree(path); + + if (out == NULL) + return (EXIT_FAILURE); + if (!tiffcp(in, out)) + return (EXIT_FAILURE); + TIFFClose(out); + } while (TIFFReadDirectory(in)); + (void) TIFFClose(in); + } + return (EXIT_SUCCESS); } -static void *limitRealloc(void *buf, tmsize_t s) +static void +newfilename(void) { - if (maxMalloc && ((s > maxMalloc) || (s < 0))) - { - fprintf(stderr, - "MemoryLimitError: re-allocation of %" TIFF_SSIZE_FORMAT - " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", - s, maxMalloc); - fprintf(stderr, " use -M option to change limit.\n"); - if (buf != NULL) - _TIFFfree(buf); - return NULL; - } - return _TIFFrealloc(buf, s); -} + static int first = 1; + static long lastTurn; + static long fnum; + static short defname; + static char *fpnt; -int main(int argc, char *argv[]) -{ - TIFF *in, *out; -#if !HAVE_DECL_OPTARG - extern char *optarg; - extern int optind; -#endif - int c; - - while ((c = getopt(argc, argv, "M:")) != -1) - { - switch (c) - { - case 'M': - maxMalloc = (tmsize_t)strtoul(optarg, NULL, 0) << 20; - if ((maxMalloc == 0) && (optarg[0] != '0')) - { - fprintf(stderr, - "tiffsplit: Error: Option -M was not followed by a " - "number but <%s>\n", - optarg); - usage(EXIT_FAILURE); - } - break; - case '?': - usage(EXIT_SUCCESS); - break; - default: - break; - } - } - - c = argc - optind; - if (c < 1 || c > 2) - usage(EXIT_FAILURE); - if (c > 1) - { - strncpy(fname, argv[optind + 1], sizeof(fname)); - fname[sizeof(fname) - 1] = '\0'; - } - - TIFFOpenOptions *opts = TIFFOpenOptionsAlloc(); - if (opts == NULL) - { - return EXIT_FAILURE; - } - TIFFOpenOptionsSetMaxSingleMemAlloc(opts, maxMalloc); - in = TIFFOpenExt(argv[optind], "r", opts); - if (in == NULL) - { - fprintf(stderr, "tiffsplit: Error: Could not open %s \n", argv[optind]); - TIFFOpenOptionsFree(opts); - usage(EXIT_FAILURE); - } - - do - { - size_t path_len; - char *path = NULL; - - newfilename(); - - path_len = strlen(fname) + sizeof(TIFF_SUFFIX); - path = (char *)limitMalloc(path_len); - if (!path) - { - fprintf(stderr, - "tiffsplit: Error: Can't allocate %" TIFF_SSIZE_FORMAT - " bytes for path-variable.\n", - path_len); - TIFFClose(in); - TIFFOpenOptionsFree(opts); - return (EXIT_FAILURE); - } - strncpy(path, fname, path_len); - path[path_len - 1] = '\0'; - strncat(path, TIFF_SUFFIX, path_len - strlen(path) - 1); - out = TIFFOpenExt(path, TIFFIsBigEndian(in) ? "wb" : "wl", opts); - - if (out == NULL) - { - TIFFClose(in); - fprintf(stderr, - "tiffsplit: Error: Could not open output file %s \n", path); - _TIFFfree(path); - TIFFOpenOptionsFree(opts); - return (EXIT_FAILURE); - } - _TIFFfree(path); - if (!tiffcp(in, out)) - { - TIFFClose(in); - TIFFClose(out); - TIFFOpenOptionsFree(opts); - fprintf(stderr, "tiffsplit: Error: Could not copy data from input " - "to output.\n"); - return (EXIT_FAILURE); - } - TIFFClose(out); - } while (TIFFReadDirectory(in)); - - TIFFOpenOptionsFree(opts); - (void)TIFFClose(in); - - return (EXIT_SUCCESS); -} - -static void newfilename(void) -{ - static int first = 1; - static long lastTurn; - static long fnum; - static short defname; - static char *fpnt; - - if (first) - { - if (fname[0]) - { - fpnt = fname + strlen(fname); - defname = 0; - } - else - { - fname[0] = 'x'; - fpnt = fname + 1; - defname = 1; - } - first = 0; - } -#define MAXFILES 17576 - if (fnum == MAXFILES) - { - if (!defname || fname[0] == 'z') - { - fprintf(stderr, "tiffsplit: too many files.\n"); - exit(EXIT_FAILURE); - } - fname[0]++; - fnum = 0; - } - if (fnum % 676 == 0) - { - if (fnum != 0) - { - /* - * advance to next letter every 676 pages - * condition for 'z'++ will be covered above - */ - fpnt[0]++; - } - else - { - /* - * set to 'a' if we are on the very first file - */ - fpnt[0] = 'a'; - } - /* - * set the value of the last turning point + if (first) { + if (fname[0]) { + fpnt = fname + strlen(fname); + defname = 0; + } else { + fname[0] = 'x'; + fpnt = fname + 1; + defname = 1; + } + first = 0; + } +#define MAXFILES 17576 + if (fnum == MAXFILES) { + if (!defname || fname[0] == 'z') { + fprintf(stderr, "tiffsplit: too many files.\n"); + exit(EXIT_FAILURE); + } + fname[0]++; + fnum = 0; + } + if (fnum % 676 == 0) { + if (fnum != 0) { + /* + * advance to next letter every 676 pages + * condition for 'z'++ will be covered above + */ + fpnt[0]++; + } else { + /* + * set to 'a' if we are on the very first file + */ + fpnt[0] = 'a'; + } + /* + * set the value of the last turning point + */ + lastTurn = fnum; + } + /* + * start from 0 every 676 times (provided by lastTurn) + * this keeps us within a-z boundaries */ - lastTurn = fnum; - } - /* - * start from 0 every 676 times (provided by lastTurn) - * this keeps us within a-z boundaries - */ - fpnt[1] = (char)((fnum - lastTurn) / 26) + 'a'; - /* - * cycle last letter every file, from a-z, then repeat - */ - fpnt[2] = (char)(fnum % 26) + 'a'; - fnum++; + fpnt[1] = (char)((fnum - lastTurn) / 26) + 'a'; + /* + * cycle last letter every file, from a-z, then repeat + */ + fpnt[2] = (char)(fnum % 26) + 'a'; + fnum++; } -static int tiffcp(TIFF *in, TIFF *out) +static int +tiffcp(TIFF* in, TIFF* out) { - uint16_t bitspersample, samplesperpixel, compression, shortv, *shortav; - uint32_t w, l; - float floatv; - char *stringv; - uint32_t longv; + uint16 bitspersample, samplesperpixel, compression, shortv, *shortav; + uint32 w, l; + float floatv; + char *stringv; + uint32 longv; - CopyField(TIFFTAG_SUBFILETYPE, longv); - CopyField(TIFFTAG_TILEWIDTH, w); - CopyField(TIFFTAG_TILELENGTH, l); - CopyField(TIFFTAG_IMAGEWIDTH, w); - CopyField(TIFFTAG_IMAGELENGTH, l); - CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample); - CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); - CopyField(TIFFTAG_COMPRESSION, compression); - if (compression == COMPRESSION_JPEG) - { - uint32_t count = 0; - void *table = NULL; - if (TIFFGetField(in, TIFFTAG_JPEGTABLES, &count, &table) && count > 0 && - table) - { - TIFFSetField(out, TIFFTAG_JPEGTABLES, count, table); - } - } - CopyField(TIFFTAG_PHOTOMETRIC, shortv); - CopyField(TIFFTAG_PREDICTOR, shortv); - CopyField(TIFFTAG_THRESHHOLDING, shortv); - CopyField(TIFFTAG_FILLORDER, shortv); - CopyField(TIFFTAG_ORIENTATION, shortv); - CopyField(TIFFTAG_MINSAMPLEVALUE, shortv); - CopyField(TIFFTAG_MAXSAMPLEVALUE, shortv); - CopyField(TIFFTAG_XRESOLUTION, floatv); - CopyField(TIFFTAG_YRESOLUTION, floatv); - CopyField(TIFFTAG_GROUP3OPTIONS, longv); - CopyField(TIFFTAG_GROUP4OPTIONS, longv); - CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); - CopyField(TIFFTAG_PLANARCONFIG, shortv); - CopyField(TIFFTAG_ROWSPERSTRIP, longv); - CopyField(TIFFTAG_XPOSITION, floatv); - CopyField(TIFFTAG_YPOSITION, floatv); - CopyField(TIFFTAG_IMAGEDEPTH, longv); - CopyField(TIFFTAG_TILEDEPTH, longv); - CopyField(TIFFTAG_SAMPLEFORMAT, shortv); - CopyField2(TIFFTAG_EXTRASAMPLES, shortv, shortav); - { - uint16_t *red, *green, *blue; - CopyField3(TIFFTAG_COLORMAP, red, green, blue); - } - { - uint16_t shortv2; - CopyField2(TIFFTAG_PAGENUMBER, shortv, shortv2); - } - CopyField(TIFFTAG_ARTIST, stringv); - CopyField(TIFFTAG_IMAGEDESCRIPTION, stringv); - CopyField(TIFFTAG_MAKE, stringv); - CopyField(TIFFTAG_MODEL, stringv); - CopyField(TIFFTAG_SOFTWARE, stringv); - CopyField(TIFFTAG_DATETIME, stringv); - CopyField(TIFFTAG_HOSTCOMPUTER, stringv); - CopyField(TIFFTAG_PAGENAME, stringv); - CopyField(TIFFTAG_DOCUMENTNAME, stringv); - CopyField(TIFFTAG_BADFAXLINES, longv); - CopyField(TIFFTAG_CLEANFAXDATA, longv); - CopyField(TIFFTAG_CONSECUTIVEBADFAXLINES, longv); - CopyField(TIFFTAG_FAXRECVPARAMS, longv); - CopyField(TIFFTAG_FAXRECVTIME, longv); - CopyField(TIFFTAG_FAXSUBADDRESS, stringv); - CopyField(TIFFTAG_FAXDCS, stringv); - if (TIFFIsTiled(in)) - return (cpTiles(in, out)); - else - return (cpStrips(in, out)); + CopyField(TIFFTAG_SUBFILETYPE, longv); + CopyField(TIFFTAG_TILEWIDTH, w); + CopyField(TIFFTAG_TILELENGTH, l); + CopyField(TIFFTAG_IMAGEWIDTH, w); + CopyField(TIFFTAG_IMAGELENGTH, l); + CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample); + CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel); + CopyField(TIFFTAG_COMPRESSION, compression); + if (compression == COMPRESSION_JPEG) { + uint32 count = 0; + void *table = NULL; + if (TIFFGetField(in, TIFFTAG_JPEGTABLES, &count, &table) + && count > 0 && table) { + TIFFSetField(out, TIFFTAG_JPEGTABLES, count, table); + } + } + CopyField(TIFFTAG_PHOTOMETRIC, shortv); + CopyField(TIFFTAG_PREDICTOR, shortv); + CopyField(TIFFTAG_THRESHHOLDING, shortv); + CopyField(TIFFTAG_FILLORDER, shortv); + CopyField(TIFFTAG_ORIENTATION, shortv); + CopyField(TIFFTAG_MINSAMPLEVALUE, shortv); + CopyField(TIFFTAG_MAXSAMPLEVALUE, shortv); + CopyField(TIFFTAG_XRESOLUTION, floatv); + CopyField(TIFFTAG_YRESOLUTION, floatv); + CopyField(TIFFTAG_GROUP3OPTIONS, longv); + CopyField(TIFFTAG_GROUP4OPTIONS, longv); + CopyField(TIFFTAG_RESOLUTIONUNIT, shortv); + CopyField(TIFFTAG_PLANARCONFIG, shortv); + CopyField(TIFFTAG_ROWSPERSTRIP, longv); + CopyField(TIFFTAG_XPOSITION, floatv); + CopyField(TIFFTAG_YPOSITION, floatv); + CopyField(TIFFTAG_IMAGEDEPTH, longv); + CopyField(TIFFTAG_TILEDEPTH, longv); + CopyField(TIFFTAG_SAMPLEFORMAT, shortv); + CopyField2(TIFFTAG_EXTRASAMPLES, shortv, shortav); + { uint16 *red, *green, *blue; + CopyField3(TIFFTAG_COLORMAP, red, green, blue); + } + { uint16 shortv2; + CopyField2(TIFFTAG_PAGENUMBER, shortv, shortv2); + } + CopyField(TIFFTAG_ARTIST, stringv); + CopyField(TIFFTAG_IMAGEDESCRIPTION, stringv); + CopyField(TIFFTAG_MAKE, stringv); + CopyField(TIFFTAG_MODEL, stringv); + CopyField(TIFFTAG_SOFTWARE, stringv); + CopyField(TIFFTAG_DATETIME, stringv); + CopyField(TIFFTAG_HOSTCOMPUTER, stringv); + CopyField(TIFFTAG_PAGENAME, stringv); + CopyField(TIFFTAG_DOCUMENTNAME, stringv); + CopyField(TIFFTAG_BADFAXLINES, longv); + CopyField(TIFFTAG_CLEANFAXDATA, longv); + CopyField(TIFFTAG_CONSECUTIVEBADFAXLINES, longv); + CopyField(TIFFTAG_FAXRECVPARAMS, longv); + CopyField(TIFFTAG_FAXRECVTIME, longv); + CopyField(TIFFTAG_FAXSUBADDRESS, stringv); + CopyField(TIFFTAG_FAXDCS, stringv); + if (TIFFIsTiled(in)) + return (cpTiles(in, out)); + else + return (cpStrips(in, out)); } -static int cpStrips(TIFF *in, TIFF *out) +static int +cpStrips(TIFF* in, TIFF* out) { - tmsize_t bufsize = TIFFStripSize(in); - unsigned char *buf = (unsigned char *)limitMalloc(bufsize); - if (buf) - { - tstrip_t s, ns = TIFFNumberOfStrips(in); - uint64_t *bytecounts; + tmsize_t bufsize = TIFFStripSize(in); + unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); - if (!TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts)) - { - fprintf(stderr, "tiffsplit: strip byte counts are missing\n"); - _TIFFfree(buf); - return (0); - } - for (s = 0; s < ns; s++) - { - if (bytecounts[s] > (uint64_t)bufsize) - { - buf = - (unsigned char *)limitRealloc(buf, (tmsize_t)bytecounts[s]); - if (!buf) - { - fprintf(stderr, - "tiffsplit: Error: Can't re-allocate " - "%" TIFF_SSIZE_FORMAT " bytes for strip-size.\n", - (tmsize_t)bytecounts[s]); - return (0); - } - bufsize = (tmsize_t)bytecounts[s]; - } - if (TIFFReadRawStrip(in, s, buf, (tmsize_t)bytecounts[s]) < 0 || - TIFFWriteRawStrip(out, s, buf, (tmsize_t)bytecounts[s]) < 0) - { - _TIFFfree(buf); - return (0); - } - } - _TIFFfree(buf); - return (1); - } - else - { - fprintf(stderr, - "tiffsplit: Error: Can't allocate %" TIFF_SSIZE_FORMAT - " bytes for strip-size.\n", - bufsize); - } - return (0); + if (buf) { + tstrip_t s, ns = TIFFNumberOfStrips(in); + uint64 *bytecounts; + + if (!TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts)) { + fprintf(stderr, "tiffsplit: strip byte counts are missing\n"); + _TIFFfree(buf); + return (0); + } + for (s = 0; s < ns; s++) { + if (bytecounts[s] > (uint64)bufsize) { + buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[s]); + if (!buf) + return (0); + bufsize = (tmsize_t)bytecounts[s]; + } + if (TIFFReadRawStrip(in, s, buf, (tmsize_t)bytecounts[s]) < 0 || + TIFFWriteRawStrip(out, s, buf, (tmsize_t)bytecounts[s]) < 0) { + _TIFFfree(buf); + return (0); + } + } + _TIFFfree(buf); + return (1); + } + return (0); } -static int cpTiles(TIFF *in, TIFF *out) +static int +cpTiles(TIFF* in, TIFF* out) { - tmsize_t bufsize = TIFFTileSize(in); - unsigned char *buf = (unsigned char *)limitMalloc(bufsize); + tmsize_t bufsize = TIFFTileSize(in); + unsigned char *buf = (unsigned char *)_TIFFmalloc(bufsize); - if (buf) - { - ttile_t t, nt = TIFFNumberOfTiles(in); - uint64_t *bytecounts; + if (buf) { + ttile_t t, nt = TIFFNumberOfTiles(in); + uint64 *bytecounts; - if (!TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts)) - { - fprintf(stderr, "tiffsplit: tile byte counts are missing\n"); - _TIFFfree(buf); - return (0); - } - for (t = 0; t < nt; t++) - { - if (bytecounts[t] > (uint64_t)bufsize) - { - buf = - (unsigned char *)limitRealloc(buf, (tmsize_t)bytecounts[t]); - if (!buf) - { - fprintf(stderr, - "tiffsplit: Error: Can't re-allocate " - "%" TIFF_SSIZE_FORMAT " bytes for tile-size.\n", - (tmsize_t)bytecounts[t]); - return (0); - } - bufsize = (tmsize_t)bytecounts[t]; - } - if (TIFFReadRawTile(in, t, buf, (tmsize_t)bytecounts[t]) < 0 || - TIFFWriteRawTile(out, t, buf, (tmsize_t)bytecounts[t]) < 0) - { - _TIFFfree(buf); - return (0); - } - } - _TIFFfree(buf); - return (1); - } - else - { - fprintf(stderr, - "tiffsplit: Error: Can't allocate %" TIFF_SSIZE_FORMAT - " bytes for tile-size.\n", - bufsize); - } - return (0); + if (!TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts)) { + fprintf(stderr, "tiffsplit: tile byte counts are missing\n"); + _TIFFfree(buf); + return (0); + } + for (t = 0; t < nt; t++) { + if (bytecounts[t] > (uint64) bufsize) { + buf = (unsigned char *)_TIFFrealloc(buf, (tmsize_t)bytecounts[t]); + if (!buf) + return (0); + bufsize = (tmsize_t)bytecounts[t]; + } + if (TIFFReadRawTile(in, t, buf, (tmsize_t)bytecounts[t]) < 0 || + TIFFWriteRawTile(out, t, buf, (tmsize_t)bytecounts[t]) < 0) { + _TIFFfree(buf); + return (0); + } + } + _TIFFfree(buf); + return (1); + } + return (0); } -static void usage(int code) -{ - FILE *out = (code == EXIT_SUCCESS) ? stdout : stderr; - - fprintf(out, "\n\n%s\n\n", TIFFGetVersion()); - fprintf(out, "Split a multi-image TIFF into single-image TIFF files\n\n"); - fprintf(out, "usage: tiffsplit [option] input.tif [prefix]\n"); - fprintf(out, "where option is:\n"); - fprintf(out, " -M size set the memory allocation limit in MiB. 0 to " - "disable limit.\n"); - exit(code); -} +/* vim: set ts=8 sts=8 sw=8 noet: */ +/* + * Local Variables: + * mode: c + * c-basic-offset: 8 + * fill-column: 78 + * End: + */ diff --git a/thirdparty/SDL2_image/src/IMG_qoi.c b/thirdparty/SDL2_image/src/IMG_qoi.c index f0cda5a98..be54bbacc 100644 --- a/thirdparty/SDL2_image/src/IMG_qoi.c +++ b/thirdparty/SDL2_image/src/IMG_qoi.c @@ -95,7 +95,7 @@ SDL_Surface *IMG_LoadQOI_RW(SDL_RWops *src) (image_info.width * 4), SDL_PIXELFORMAT_RGBA32); if ( !surface ) { - SDL_free(pixel_data); + QOI_FREE(pixel_data); IMG_SetError("Couldn't create SDL_Surface"); return NULL; } diff --git a/thirdparty/SDL2_image/src/nanosvgrast.h b/thirdparty/SDL2_image/src/nanosvgrast.h index 4740a5f3b..2947b1009 100644 --- a/thirdparty/SDL2_image/src/nanosvgrast.h +++ b/thirdparty/SDL2_image/src/nanosvgrast.h @@ -333,6 +333,7 @@ static float nsvg__normalize(float *x, float* y) } static float nsvg__absf(float x) { return x < 0 ? -x : x; } +static float nsvg__roundf(float x) { return (x >= 0) ? floorf(x + 0.5) : ceilf(x - 0.5); } static void nsvg__flattenCubicBez(NSVGrasterizer* r, float x1, float y1, float x2, float y2, @@ -879,10 +880,10 @@ static NSVGactiveEdge* nsvg__addActive(NSVGrasterizer* r, NSVGedge* e, float sta // STBTT_assert(e->y0 <= start_point); // round dx down to avoid going too far if (dxdy < 0) - z->dx = (int)(-floorf(NSVG__FIX * -dxdy)); + z->dx = (int)(-nsvg__roundf(NSVG__FIX * -dxdy)); else - z->dx = (int)floorf(NSVG__FIX * dxdy); - z->x = (int)floorf(NSVG__FIX * (e->x0 + dxdy * (startPoint - e->y0))); + z->dx = (int)nsvg__roundf(NSVG__FIX * dxdy); + z->x = (int)nsvg__roundf(NSVG__FIX * (e->x0 + dxdy * (startPoint - e->y0))); // z->x -= off_x * FIX; z->ey = e->y1; z->next = 0; diff --git a/thirdparty/SDL2_image/test/svg-class.bmp b/thirdparty/SDL2_image/test/svg-class.bmp index d87d36dcc..d99119e0a 100644 --- a/thirdparty/SDL2_image/test/svg-class.bmp +++ b/thirdparty/SDL2_image/test/svg-class.bmp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1f0a98e906da0ce1a5817720b62e5d41c405932e050d1081f375eb291eaddf74 +oid sha256:0b5b0ce39339da7b02e3ee103554e0baa53881ae8398794db23ec42aeb760ce2 size 27018 diff --git a/thirdparty/SDL2_mixer/.gitmodules b/thirdparty/SDL2_mixer/.gitmodules deleted file mode 100644 index c517ffcab..000000000 --- a/thirdparty/SDL2_mixer/.gitmodules +++ /dev/null @@ -1,40 +0,0 @@ -[submodule "external/flac"] - path = external/flac - url = https://github.com/libsdl-org/flac.git - branch = 1.3.4-SDL -[submodule "external/ogg"] - path = external/ogg - url = https://github.com/libsdl-org/ogg.git - branch = v1.3.5-SDL -[submodule "external/vorbis"] - path = external/vorbis - url = https://github.com/libsdl-org/vorbis.git - branch = v1.3.7-SDL -[submodule "external/opus"] - path = external/opus - url = https://github.com/libsdl-org/opus.git - branch = v1.4-SDL -[submodule "external/opusfile"] - path = external/opusfile - url = https://github.com/libsdl-org/opusfile.git - branch = v0.12-SDL -[submodule "external/tremor"] - path = external/tremor - url = https://github.com/libsdl-org/tremor.git - branch = v1.2.1-SDL -[submodule "external/mpg123"] - path = external/mpg123 - url = https://github.com/libsdl-org/mpg123.git - branch = v1.31.3-SDL -[submodule "libxmp"] - path = external/libxmp - url = https://github.com/libsdl-org/libxmp.git - branch = 4.6.x-SDL -[submodule "external/wavpack"] - path = external/wavpack - url = https://github.com/libsdl-org/wavpack.git - branch = 5.6.0-sdl -[submodule "external/libgme"] - path = external/libgme - url = https://github.com/libsdl-org/game-music-emu.git - branch = v0.6.3-SDL diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/HEAD b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/HEAD deleted file mode 100644 index 4ab2fcf86..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/heads/v1.2.1-SDL diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/config b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/config deleted file mode 100644 index d061f961e..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/config +++ /dev/null @@ -1,13 +0,0 @@ -[core] - repositoryformatversion = 0 - filemode = true - bare = false - logallrefupdates = true -[submodule] - active = . -[remote "origin"] - url = https://github.com/libsdl-org/tremor.git - fetch = +refs/heads/*:refs/remotes/origin/* -[branch "v1.2.1-SDL"] - remote = origin - merge = refs/heads/v1.2.1-SDL diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/description b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/description deleted file mode 100644 index 498b267a8..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/description +++ /dev/null @@ -1 +0,0 @@ -Unnamed repository; edit this file 'description' to name the repository. diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/applypatch-msg.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/applypatch-msg.sample deleted file mode 100755 index a5d7b84a6..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/applypatch-msg.sample +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message taken by -# applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. The hook is -# allowed to edit the commit message file. -# -# To enable this hook, rename this file to "applypatch-msg". - -. git-sh-setup -commitmsg="$(git rev-parse --git-path hooks/commit-msg)" -test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} -: diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/commit-msg.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/commit-msg.sample deleted file mode 100755 index b58d1184a..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/commit-msg.sample +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to check the commit log message. -# Called by "git commit" with one argument, the name of the file -# that has the commit message. The hook should exit with non-zero -# status after issuing an appropriate message if it wants to stop the -# commit. The hook is allowed to edit the commit message file. -# -# To enable this hook, rename this file to "commit-msg". - -# Uncomment the below to add a Signed-off-by line to the message. -# Doing this in a hook is a bad idea in general, but the prepare-commit-msg -# hook is more suited to it. -# -# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" - -# This example catches duplicate Signed-off-by lines. - -test "" = "$(grep '^Signed-off-by: ' "$1" | - sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { - echo >&2 Duplicate Signed-off-by lines. - exit 1 -} diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/fsmonitor-watchman.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/fsmonitor-watchman.sample deleted file mode 100755 index 14ed0aa42..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/fsmonitor-watchman.sample +++ /dev/null @@ -1,173 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use IPC::Open2; - -# An example hook script to integrate Watchman -# (https://facebook.github.io/watchman/) with git to speed up detecting -# new and modified files. -# -# The hook is passed a version (currently 2) and last update token -# formatted as a string and outputs to stdout a new update token and -# all files that have been modified since the update token. Paths must -# be relative to the root of the working tree and separated by a single NUL. -# -# To enable this hook, rename this file to "query-watchman" and set -# 'git config core.fsmonitor .git/hooks/query-watchman' -# -my ($version, $last_update_token) = @ARGV; - -# Uncomment for debugging -# print STDERR "$0 $version $last_update_token\n"; - -# Check the hook interface version -if ($version ne 2) { - die "Unsupported query-fsmonitor hook version '$version'.\n" . - "Falling back to scanning...\n"; -} - -my $git_work_tree = get_working_dir(); - -my $retry = 1; - -my $json_pkg; -eval { - require JSON::XS; - $json_pkg = "JSON::XS"; - 1; -} or do { - require JSON::PP; - $json_pkg = "JSON::PP"; -}; - -launch_watchman(); - -sub launch_watchman { - my $o = watchman_query(); - if (is_work_tree_watched($o)) { - output_result($o->{clock}, @{$o->{files}}); - } -} - -sub output_result { - my ($clockid, @files) = @_; - - # Uncomment for debugging watchman output - # open (my $fh, ">", ".git/watchman-output.out"); - # binmode $fh, ":utf8"; - # print $fh "$clockid\n@files\n"; - # close $fh; - - binmode STDOUT, ":utf8"; - print $clockid; - print "\0"; - local $, = "\0"; - print @files; -} - -sub watchman_clock { - my $response = qx/watchman clock "$git_work_tree"/; - die "Failed to get clock id on '$git_work_tree'.\n" . - "Falling back to scanning...\n" if $? != 0; - - return $json_pkg->new->utf8->decode($response); -} - -sub watchman_query { - my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty') - or die "open2() failed: $!\n" . - "Falling back to scanning...\n"; - - # In the query expression below we're asking for names of files that - # changed since $last_update_token but not from the .git folder. - # - # To accomplish this, we're using the "since" generator to use the - # recency index to select candidate nodes and "fields" to limit the - # output to file names only. Then we're using the "expression" term to - # further constrain the results. - if (substr($last_update_token, 0, 1) eq "c") { - $last_update_token = "\"$last_update_token\""; - } - my $query = <<" END"; - ["query", "$git_work_tree", { - "since": $last_update_token, - "fields": ["name"], - "expression": ["not", ["dirname", ".git"]] - }] - END - - # Uncomment for debugging the watchman query - # open (my $fh, ">", ".git/watchman-query.json"); - # print $fh $query; - # close $fh; - - print CHLD_IN $query; - close CHLD_IN; - my $response = do {local $/; }; - - # Uncomment for debugging the watch response - # open ($fh, ">", ".git/watchman-response.json"); - # print $fh $response; - # close $fh; - - die "Watchman: command returned no output.\n" . - "Falling back to scanning...\n" if $response eq ""; - die "Watchman: command returned invalid output: $response\n" . - "Falling back to scanning...\n" unless $response =~ /^\{/; - - return $json_pkg->new->utf8->decode($response); -} - -sub is_work_tree_watched { - my ($output) = @_; - my $error = $output->{error}; - if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) { - $retry--; - my $response = qx/watchman watch "$git_work_tree"/; - die "Failed to make watchman watch '$git_work_tree'.\n" . - "Falling back to scanning...\n" if $? != 0; - $output = $json_pkg->new->utf8->decode($response); - $error = $output->{error}; - die "Watchman: $error.\n" . - "Falling back to scanning...\n" if $error; - - # Uncomment for debugging watchman output - # open (my $fh, ">", ".git/watchman-output.out"); - # close $fh; - - # Watchman will always return all files on the first query so - # return the fast "everything is dirty" flag to git and do the - # Watchman query just to get it over with now so we won't pay - # the cost in git to look up each individual file. - my $o = watchman_clock(); - $error = $output->{error}; - - die "Watchman: $error.\n" . - "Falling back to scanning...\n" if $error; - - output_result($o->{clock}, ("/")); - $last_update_token = $o->{clock}; - - eval { launch_watchman() }; - return 0; - } - - die "Watchman: $error.\n" . - "Falling back to scanning...\n" if $error; - - return 1; -} - -sub get_working_dir { - my $working_dir; - if ($^O =~ 'msys' || $^O =~ 'cygwin') { - $working_dir = Win32::GetCwd(); - $working_dir =~ tr/\\/\//; - } else { - require Cwd; - $working_dir = Cwd::cwd(); - } - - return $working_dir; -} diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/post-update.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/post-update.sample deleted file mode 100755 index ec17ec193..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/post-update.sample +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare a packed repository for use over -# dumb transports. -# -# To enable this hook, rename this file to "post-update". - -exec git update-server-info diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-applypatch.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-applypatch.sample deleted file mode 100755 index 4142082bc..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-applypatch.sample +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed -# by applypatch from an e-mail message. -# -# The hook should exit with non-zero status after issuing an -# appropriate message if it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-applypatch". - -. git-sh-setup -precommit="$(git rev-parse --git-path hooks/pre-commit)" -test -x "$precommit" && exec "$precommit" ${1+"$@"} -: diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-commit.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-commit.sample deleted file mode 100755 index e144712c8..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-commit.sample +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git commit" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message if -# it wants to stop the commit. -# -# To enable this hook, rename this file to "pre-commit". - -if git rev-parse --verify HEAD >/dev/null 2>&1 -then - against=HEAD -else - # Initial commit: diff against an empty tree object - against=$(git hash-object -t tree /dev/null) -fi - -# If you want to allow non-ASCII filenames set this variable to true. -allownonascii=$(git config --type=bool hooks.allownonascii) - -# Redirect output to stderr. -exec 1>&2 - -# Cross platform projects tend to avoid non-ASCII filenames; prevent -# them from being added to the repository. We exploit the fact that the -# printable range starts at the space character and ends with tilde. -if [ "$allownonascii" != "true" ] && - # Note that the use of brackets around a tr range is ok here, (it's - # even required, for portability to Solaris 10's /usr/bin/tr), since - # the square bracket bytes happen to fall in the designated range. - test $(git diff --cached --name-only --diff-filter=A -z $against | - LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 -then - cat <<\EOF -Error: Attempt to add a non-ASCII file name. - -This can cause problems if you want to work with people on other platforms. - -To be portable it is advisable to rename the file. - -If you know what you are doing you can disable this check using: - - git config hooks.allownonascii true -EOF - exit 1 -fi - -# If there are whitespace errors, print the offending file names and fail. -exec git diff-index --check --cached $against -- diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-merge-commit.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-merge-commit.sample deleted file mode 100755 index 399eab192..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-merge-commit.sample +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# An example hook script to verify what is about to be committed. -# Called by "git merge" with no arguments. The hook should -# exit with non-zero status after issuing an appropriate message to -# stderr if it wants to stop the merge commit. -# -# To enable this hook, rename this file to "pre-merge-commit". - -. git-sh-setup -test -x "$GIT_DIR/hooks/pre-commit" && - exec "$GIT_DIR/hooks/pre-commit" -: diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-push.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-push.sample deleted file mode 100755 index 4ce688d32..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-push.sample +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -# An example hook script to verify what is about to be pushed. Called by "git -# push" after it has checked the remote status, but before anything has been -# pushed. If this script exits with a non-zero status nothing will be pushed. -# -# This hook is called with the following parameters: -# -# $1 -- Name of the remote to which the push is being done -# $2 -- URL to which the push is being done -# -# If pushing without using a named remote those arguments will be equal. -# -# Information about the commits which are being pushed is supplied as lines to -# the standard input in the form: -# -# -# -# This sample shows how to prevent push of commits where the log message starts -# with "WIP" (work in progress). - -remote="$1" -url="$2" - -zero=$(git hash-object --stdin &2 "Found WIP commit in $local_ref, not pushing" - exit 1 - fi - fi -done - -exit 0 diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-rebase.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-rebase.sample deleted file mode 100755 index 6cbef5c37..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-rebase.sample +++ /dev/null @@ -1,169 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2006, 2008 Junio C Hamano -# -# The "pre-rebase" hook is run just before "git rebase" starts doing -# its job, and can prevent the command from running by exiting with -# non-zero status. -# -# The hook is called with the following parameters: -# -# $1 -- the upstream the series was forked from. -# $2 -- the branch being rebased (or empty when rebasing the current branch). -# -# This sample shows how to prevent topic branches that are already -# merged to 'next' branch from getting rebased, because allowing it -# would result in rebasing already published history. - -publish=next -basebranch="$1" -if test "$#" = 2 -then - topic="refs/heads/$2" -else - topic=`git symbolic-ref HEAD` || - exit 0 ;# we do not interrupt rebasing detached HEAD -fi - -case "$topic" in -refs/heads/??/*) - ;; -*) - exit 0 ;# we do not interrupt others. - ;; -esac - -# Now we are dealing with a topic branch being rebased -# on top of master. Is it OK to rebase it? - -# Does the topic really exist? -git show-ref -q "$topic" || { - echo >&2 "No such branch $topic" - exit 1 -} - -# Is topic fully merged to master? -not_in_master=`git rev-list --pretty=oneline ^master "$topic"` -if test -z "$not_in_master" -then - echo >&2 "$topic is fully merged to master; better remove it." - exit 1 ;# we could allow it, but there is no point. -fi - -# Is topic ever merged to next? If so you should not be rebasing it. -only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` -only_next_2=`git rev-list ^master ${publish} | sort` -if test "$only_next_1" = "$only_next_2" -then - not_in_topic=`git rev-list "^$topic" master` - if test -z "$not_in_topic" - then - echo >&2 "$topic is already up to date with master" - exit 1 ;# we could allow it, but there is no point. - else - exit 0 - fi -else - not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` - /usr/bin/perl -e ' - my $topic = $ARGV[0]; - my $msg = "* $topic has commits already merged to public branch:\n"; - my (%not_in_next) = map { - /^([0-9a-f]+) /; - ($1 => 1); - } split(/\n/, $ARGV[1]); - for my $elem (map { - /^([0-9a-f]+) (.*)$/; - [$1 => $2]; - } split(/\n/, $ARGV[2])) { - if (!exists $not_in_next{$elem->[0]}) { - if ($msg) { - print STDERR $msg; - undef $msg; - } - print STDERR " $elem->[1]\n"; - } - } - ' "$topic" "$not_in_next" "$not_in_master" - exit 1 -fi - -<<\DOC_END - -This sample hook safeguards topic branches that have been -published from being rewound. - -The workflow assumed here is: - - * Once a topic branch forks from "master", "master" is never - merged into it again (either directly or indirectly). - - * Once a topic branch is fully cooked and merged into "master", - it is deleted. If you need to build on top of it to correct - earlier mistakes, a new topic branch is created by forking at - the tip of the "master". This is not strictly necessary, but - it makes it easier to keep your history simple. - - * Whenever you need to test or publish your changes to topic - branches, merge them into "next" branch. - -The script, being an example, hardcodes the publish branch name -to be "next", but it is trivial to make it configurable via -$GIT_DIR/config mechanism. - -With this workflow, you would want to know: - -(1) ... if a topic branch has ever been merged to "next". Young - topic branches can have stupid mistakes you would rather - clean up before publishing, and things that have not been - merged into other branches can be easily rebased without - affecting other people. But once it is published, you would - not want to rewind it. - -(2) ... if a topic branch has been fully merged to "master". - Then you can delete it. More importantly, you should not - build on top of it -- other people may already want to - change things related to the topic as patches against your - "master", so if you need further changes, it is better to - fork the topic (perhaps with the same name) afresh from the - tip of "master". - -Let's look at this example: - - o---o---o---o---o---o---o---o---o---o "next" - / / / / - / a---a---b A / / - / / / / - / / c---c---c---c B / - / / / \ / - / / / b---b C \ / - / / / / \ / - ---o---o---o---o---o---o---o---o---o---o---o "master" - - -A, B and C are topic branches. - - * A has one fix since it was merged up to "next". - - * B has finished. It has been fully merged up to "master" and "next", - and is ready to be deleted. - - * C has not merged to "next" at all. - -We would want to allow C to be rebased, refuse A, and encourage -B to be deleted. - -To compute (1): - - git rev-list ^master ^topic next - git rev-list ^master next - - if these match, topic has not merged in next at all. - -To compute (2): - - git rev-list master..topic - - if this is empty, it is fully merged to "master". - -DOC_END diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-receive.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-receive.sample deleted file mode 100755 index a1fd29ec1..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/pre-receive.sample +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# -# An example hook script to make use of push options. -# The example simply echoes all push options that start with 'echoback=' -# and rejects all pushes when the "reject" push option is used. -# -# To enable this hook, rename this file to "pre-receive". - -if test -n "$GIT_PUSH_OPTION_COUNT" -then - i=0 - while test "$i" -lt "$GIT_PUSH_OPTION_COUNT" - do - eval "value=\$GIT_PUSH_OPTION_$i" - case "$value" in - echoback=*) - echo "echo from the pre-receive-hook: ${value#*=}" >&2 - ;; - reject) - exit 1 - esac - i=$((i + 1)) - done -fi diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/prepare-commit-msg.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/prepare-commit-msg.sample deleted file mode 100755 index 10fa14c5a..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/prepare-commit-msg.sample +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -# An example hook script to prepare the commit log message. -# Called by "git commit" with the name of the file that has the -# commit message, followed by the description of the commit -# message's source. The hook's purpose is to edit the commit -# message file. If the hook fails with a non-zero status, -# the commit is aborted. -# -# To enable this hook, rename this file to "prepare-commit-msg". - -# This hook includes three examples. The first one removes the -# "# Please enter the commit message..." help message. -# -# The second includes the output of "git diff --name-status -r" -# into the message, just before the "git status" output. It is -# commented because it doesn't cope with --amend or with squashed -# commits. -# -# The third example adds a Signed-off-by line to the message, that can -# still be edited. This is rarely a good idea. - -COMMIT_MSG_FILE=$1 -COMMIT_SOURCE=$2 -SHA1=$3 - -/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" - -# case "$COMMIT_SOURCE,$SHA1" in -# ,|template,) -# /usr/bin/perl -i.bak -pe ' -# print "\n" . `git diff --cached --name-status -r` -# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; -# *) ;; -# esac - -# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') -# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" -# if test -z "$COMMIT_SOURCE" -# then -# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" -# fi diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/push-to-checkout.sample b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/push-to-checkout.sample deleted file mode 100755 index af5a0c001..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/hooks/push-to-checkout.sample +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -# An example hook script to update a checked-out tree on a git push. -# -# This hook is invoked by git-receive-pack(1) when it reacts to git -# push and updates reference(s) in its repository, and when the push -# tries to update the branch that is currently checked out and the -# receive.denyCurrentBranch configuration variable is set to -# updateInstead. -# -# By default, such a push is refused if the working tree and the index -# of the remote repository has any difference from the currently -# checked out commit; when both the working tree and the index match -# the current commit, they are updated to match the newly pushed tip -# of the branch. This hook is to be used to override the default -# behaviour; however the code below reimplements the default behaviour -# as a starting point for convenient modification. -# -# The hook receives the commit with which the tip of the current -# branch is going to be updated: -commit=$1 - -# It can exit with a non-zero status to refuse the push (when it does -# so, it must not modify the index or the working tree). -die () { - echo >&2 "$*" - exit 1 -} - -# Or it can make any necessary changes to the working tree and to the -# index to bring them to the desired state when the tip of the current -# branch is updated to the new commit, and exit with a zero status. -# -# For example, the hook can simply run git read-tree -u -m HEAD "$1" -# in order to emulate git fetch that is run in the reverse direction -# with git push, as the two-tree form of git read-tree -u -m is -# essentially the same as git switch or git checkout that switches -# branches while keeping the local changes in the working tree that do -# not interfere with the difference between the branches. - -# The below is a more-or-less exact translation to shell of the C code -# for the default behaviour for git's push-to-checkout hook defined in -# the push_to_deploy() function in builtin/receive-pack.c. -# -# Note that the hook will be executed from the repository directory, -# not from the working tree, so if you want to perform operations on -# the working tree, you will have to adapt your code accordingly, e.g. -# by adding "cd .." or using relative paths. - -if ! git update-index -q --ignore-submodules --refresh -then - die "Up-to-date check failed" -fi - -if ! git diff-files --quiet --ignore-submodules -- -then - die "Working directory has unstaged changes" -fi - -# This is a rough translation of: -# -# head_has_history() ? "HEAD" : EMPTY_TREE_SHA1_HEX -if git cat-file -e HEAD 2>/dev/null -then - head=HEAD -else - head=$(git hash-object -t tree --stdin &2 - echo " (if you want, you could supply GIT_DIR then run" >&2 - echo " $0 )" >&2 - exit 1 -fi - -if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then - echo "usage: $0 " >&2 - exit 1 -fi - -# --- Config -allowunannotated=$(git config --type=bool hooks.allowunannotated) -allowdeletebranch=$(git config --type=bool hooks.allowdeletebranch) -denycreatebranch=$(git config --type=bool hooks.denycreatebranch) -allowdeletetag=$(git config --type=bool hooks.allowdeletetag) -allowmodifytag=$(git config --type=bool hooks.allowmodifytag) - -# check for no description -projectdesc=$(sed -e '1q' "$GIT_DIR/description") -case "$projectdesc" in -"Unnamed repository"* | "") - echo "*** Project description file hasn't been set" >&2 - exit 1 - ;; -esac - -# --- Check types -# if $newrev is 0000...0000, it's a commit to delete a ref. -zero=$(git hash-object --stdin &2 - echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 - exit 1 - fi - ;; - refs/tags/*,delete) - # delete tag - if [ "$allowdeletetag" != "true" ]; then - echo "*** Deleting a tag is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/tags/*,tag) - # annotated tag - if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 - then - echo "*** Tag '$refname' already exists." >&2 - echo "*** Modifying a tag is not allowed in this repository." >&2 - exit 1 - fi - ;; - refs/heads/*,commit) - # branch - if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then - echo "*** Creating a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/heads/*,delete) - # delete branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - refs/remotes/*,commit) - # tracking branch - ;; - refs/remotes/*,delete) - # delete tracking branch - if [ "$allowdeletebranch" != "true" ]; then - echo "*** Deleting a tracking branch is not allowed in this repository" >&2 - exit 1 - fi - ;; - *) - # Anything else (is there anything else?) - echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 - exit 1 - ;; -esac - -# --- Finished -exit 0 diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/index b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/index deleted file mode 100644 index c317e4826d5c344efb1315b46e759c92eb7b3313..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8802 zcmb8!3pAAJ{{ZmUbzH`{B_TqjQtl}UDWv31n{FE8#mn598MoM_RW7Mjl57`IyS3GJ zPpF?Fmvp1jDkZuhtcW5d{ok2+pULCw`0qN$`F2jn$M^X@-{<>2-f>y(w-iATN≫ zwY-%zbMR6ThzKH&Ao=$15M;}52qN`X_$_ImvSd`X`;Xx_1`E!s_RgaqZJlS*5d~*v zD2IiGnlYkqOYj985D9M(_9Pno`>lOnxsTo-c+$8sXZsUvQ`M!Oi2PD_XRl?hE4`N? z;O9XkoFUkeE37Y*bySjJN-O8zwrXB4{Zw<++(QUusV6lGU5RmdTr*xAkDnNDKqS0R zuqShcs#;Thtkma+Hx9PNH#E<2uLmD6L`X}$eS(&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^{kVLJuY*cAqQF7J@elnt@xq!{on(8CVzV^47mPkN{!L7!GZXG!;MA{>?wN@ zIsC<#g{9R5^U)V}thgU+`zKrZY+LZdZ0pNYR-bmf&8T>ckhu|54jMZ4lLfGUAQJoN z2Ybrr9?mJ5UU4y`DC6&ez(pDB>Gj4*3lT+bJd+oJaxt!`aKHhP@cdzKpr?P*-v6Z~ zy$d(rZ*czMj~zt?LwnvJWZ`%ej5A{50tZCG3xGWd%T=Gz@VuA7x*Muz=w+Zk-G8z3 z8-9Nfdi=M{W^5Y&<1oQ_nq^%U$M^V=@B(2^ij?%?S==A?C6U^F_t&Q_r&RH_>H8x( zu^7|Z%6yf-m4(GTbNnqfe+b2J*&G&Ic$*OGuY!H|&a9oykGJS%JZzTER@obDnERLB z+FOXpcpv|}g~8(Rf0OWEW-&DUmqilu|zxxF5+4+rmw2eOM>!e@!KB;9UGeJ=VaE^iGq|q;|8m#Wjy|sN1?aPc&E-wxx<3 z{Ir6;0FmgAwU8q*U^*h5)1K3Ht*NCY*QD$9-?J|@+ffi@VLoFgWq_Y6{*07RLo6+< z^=%Y3lVa6PXFq>@?!}YI4@cS;8n4K0#-CzV`W6aD=Ct3mPW4WZpP_TwhUbx+?BNlG z-=`598~i_825!YIu~i*0{8H-hKGE{`=#eEi1&|374% Be~ 1697761679 -0500 clone: from https://github.com/libsdl-org/tremor.git diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/logs/refs/heads/v1.2.1-SDL b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/logs/refs/heads/v1.2.1-SDL deleted file mode 100644 index e62132e84..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/logs/refs/heads/v1.2.1-SDL +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 7afc84841ffa2e9610b65950fd233e6c428699c7 Scott Duensing 1697761679 -0500 clone: from https://github.com/libsdl-org/tremor.git diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/logs/refs/remotes/origin/HEAD b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/logs/refs/remotes/origin/HEAD deleted file mode 100644 index 65921a065..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/logs/refs/remotes/origin/HEAD +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 91decb5f1b11a84a2157a6326d9135b22627024b Scott Duensing 1697761679 -0500 clone: from https://github.com/libsdl-org/tremor.git diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/objects/pack/pack-c6357385f1b065747e10299757d477334a8331aa.idx b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/objects/pack/pack-c6357385f1b065747e10299757d477334a8331aa.idx deleted file mode 100644 index 711f901446120e02f12e829da80769fef7c2bced..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 40944 zcmWLBQ*dMp6a~=Ow#|uc+s4GUZ99`mCN?Lw?M!UjcJgAr`>}qz_CDv_uIjG)?WSZ3 z0s;aCfCL}{FaQJqa=;G&1ArO81>gmU0Hgtm09AlCKnGw5umLy&d;kG}a6k;;4dLhSOshXb^wQfQ@}Og5%3210s#R9vVuYb-~p%rOaLwb$PG#X zpaU=hSOJ^>Zh$aA0w51i0;mCi?4U*fYk&*D3*ZL`1w;aX?4U`2Y(PHXFQ6CzbN~f9 zfHnfU0Hc6ez#;(154sOH2mA+&78C#lKmniuZ~#OAQUEOgm@gO;fDOO{5C8x(29p9P z1AYSZ00savfCIn{0L&OH7y!%|EE@0|kOBZ^3Cjc;CFkrsm-~bo^5&*~z4%`GdG2jP)8NdwyvV!vifUMv$07ZZbKnnom1qbE| z4&(*512_R(0UiKPKoB4T5Cup8qyn-41%PS*a2w$5fNnrPU>E?*7#z40@L9kLU<&}u z863zCehatKnI9)Kn?)t08s>}1k?k78-eHq06idp`9n+q zW&n$TRlqLb2yh9w0RT4x0qg(VBmU{nw4Yvt7i^E?74vys)X!}oZfc9&d>=#? z?1;>{nn7=xuaSNrr-WvGv{>=3=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A#|`wM2GHqg-GENaZ>0S|W)-_&3WV%0vBJ?{auS;wronR#phAA zN6e0DMV;XD5;JcIiuVxCQ)a(LFn1n+oHLJD^W^(`L8;@&yv7{WBbVAS4*1M0ay@ z8F+VvcddpJJnL}k!_P6)?x#?>(u3nyv5%#E#_%_!;#+)%V#nu33TmGXxv`nJpuP{~ zoFi5+`|ab`{7l{-;ND-Xxd#LsqSvwxrQN8p)XNF%aV~rO%b9Bs-=BLz%ACnu#W|zY z5E#E1IB}TR*v39Bq!wJDpP%PFsCVDh_-|iwf;wEe2l8-cvm7JHHPoC&`jOsBAgTg# zu{JS%kUeHS>o!2HS`N8l70{2qSdq+qenDJ8O)_H!@S6IIYV;KN6fqdYl$J(YVwR) z+~h!SsG-idu@=LiaNGh7opN9e`|#~KdrEBPgmbML&cltsv;W9R-mS$UW{9bry{{1; zJkw$)YTh`gxo(Bf(g|oHjz7%fvm4HYl|>MKQs0bYxKH zlg|ZX_?(XK8JI)t5-%;i00Uw=_7VF~K+m`U$(dej{D~Z##4K~4++G=>&RkH>gfOZM=zV1-e9HWnMwu|RyY9~Tv_zOaF zKcHtcbzgwA=L6^MI^s`|s(sv)$Xh85q1a%lvy zbb%xbXN?%X9#+WDdGi_IKA@O>5Hgc%Mo|wqQ;w#GrV@t_!l2Q$EB)%s v!$E6ze7@qkZgU%xV-7hUW)pn+N5r&p`!_bU`?jg-`t=LqJfc>eJ#_AWXqe#C diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/objects/pack/pack-c6357385f1b065747e10299757d477334a8331aa.pack b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/objects/pack/pack-c6357385f1b065747e10299757d477334a8331aa.pack deleted file mode 100644 index 73f654e1740ae157ca7c17c151b1afacf7ce618b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 769432 zcmX6^17l##vW#upwr$(CZQHhO+qP|EV{f>z^YY#I56;x|bX9frQ4kcC1^@s60ssI_ z$Vc$V$(@^(0%k-R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_Z5#mwa#vYwp<-+Jv;&yPm!6IF$=arf#bF;1egj?uI&HI{t%9r& z^QwWi556+um4oDC)QqOAeeVlLqAiT+;8#W%{8$-c=~`rfjycSgH4xjs{h=KpQY{4- z(r$Q>;@G^VXVv_E=G-i)e9~hF1I`VO0}+T;lH0dgCPN}NQ^f5^?OY) zP!Z-(n`|34Ulk%w5G&G(JFZB2acR0Y6vJrDImR8umF_T014S_)f&ia*4hY}~=tK1&DU1Nn(K07@>_w8rMWLvIHG2iwZY&t|~JMW|n`XxU}8Nk|+2}fq35SQ+1!K#yX=Sxxe;~Y@foJ=R%D|%7MxWA3Ey|@uI2lRopV)NjZ1dp zTY$8J3@{~Y8f`v<^#Hw{i{mxAB@ee9l4V^3Rs6YULDK;P=q1H3XAXC*E?1tvdyfW=dj~F7ot8kS_j=^GHaUs)c zb$3>S>x?tyo}gcE5FCR>PY!1ZQXbSDb=)fN8jeL7>MRU@!1L)<(Pd_l?(Dhwklx)a zUO(&P6c2nw;`C(?97XuA_y6Q1MF0J@-(WobEJOAE$k%SY=5l8x`t+GkPVYdFm(<>G zer4jHh83$uCCMvB;zf@dcn@F0 z42$37FG>NUE$Q33xT*l=T-qu8|xfx z%aWT13htl~uYrOPn^ONLeWoKpx|JrXg%yH^vAx&8dz; z5G%3}ryfCul9AR?$uz9j03HkE@qOeVcLb0gp!gqQry-^+$wFEm=Xe+ke?JgWsIJ}9 zek@Dam4X1A$aZy8b-gJLcz+F7Oy+tsUNynRfz3dWjU)UTln?x$C5TXGKI!Lo3qP&3 Sa1X#^PSu(A;#CaguJ~Ua&jx@1 diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/packed-refs b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/packed-refs deleted file mode 100644 index 307d73476..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/packed-refs +++ /dev/null @@ -1,9 +0,0 @@ -# pack-refs with: peeled fully-peeled sorted -89a7534bf2e70112e0354452b17a78675ca92dbf refs/remotes/origin/lowmem -7c30a66346199f3f09017a09567c6c8a3a0eedc8 refs/remotes/origin/master -f946f9acbf7aced75d3810a52c878e47680a18f6 refs/remotes/origin/nobyte -91decb5f1b11a84a2157a6326d9135b22627024b refs/remotes/origin/sezero -338f26b8ba2e89a51c72f879b77fa92b413d733e refs/remotes/origin/sezero-lowmem -3175ff964c7d85d070df823189997f6b753cfef7 refs/remotes/origin/tremolo -0bcded806a0327c86d9246703724b45037d1bbaa refs/remotes/origin/tremolo_mips -7afc84841ffa2e9610b65950fd233e6c428699c7 refs/remotes/origin/v1.2.1-SDL diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/refs/heads/v1.2.1-SDL b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/refs/heads/v1.2.1-SDL deleted file mode 100644 index f8f0a6c9f..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/refs/heads/v1.2.1-SDL +++ /dev/null @@ -1 +0,0 @@ -7afc84841ffa2e9610b65950fd233e6c428699c7 diff --git a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/refs/remotes/origin/HEAD b/thirdparty/SDL2_mixer/external/tremor/,git-hidden/refs/remotes/origin/HEAD deleted file mode 100644 index a699016b0..000000000 --- a/thirdparty/SDL2_mixer/external/tremor/,git-hidden/refs/remotes/origin/HEAD +++ /dev/null @@ -1 +0,0 @@ -ref: refs/remotes/origin/sezero diff --git a/thirdparty/SDL2_ttf/.gitmodules b/thirdparty/SDL2_ttf/.gitmodules deleted file mode 100644 index 06e36fd93..000000000 --- a/thirdparty/SDL2_ttf/.gitmodules +++ /dev/null @@ -1,8 +0,0 @@ -[submodule "external/freetype"] - path = external/freetype - url = https://github.com/libsdl-org/freetype.git - branch = VER-2-13-0-SDL -[submodule "external/harfbuzz"] - path = external/harfbuzz - url = https://github.com/libsdl-org/harfbuzz.git - branch = 2.9.1-SDL diff --git a/thirdparty/SDL2_ttf/external/freetype/.gitmodules b/thirdparty/SDL2_ttf/external/freetype/.gitmodules deleted file mode 100644 index b452dffb9..000000000 --- a/thirdparty/SDL2_ttf/external/freetype/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "dlg"] - path = subprojects/dlg - url = https://github.com/nyorain/dlg.git diff --git a/thirdparty/bzip2/.gitmodules b/thirdparty/bzip2/.gitmodules deleted file mode 100644 index 3f497732f..000000000 --- a/thirdparty/bzip2/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "tests/input/bzip2-testfiles"] - path = tests/input/bzip2-testfiles - url = https://gitlab.com/bzip2/bzip2-testfiles.git diff --git a/thirdparty/ffms2/.gitmodules b/thirdparty/ffms2/.gitmodules deleted file mode 100644 index 842def338..000000000 --- a/thirdparty/ffms2/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "test/googletest"] - path = test/googletest - url = https://github.com/google/googletest - branch = master